6.8 Animations

Recording an animation with CairoMakie (GLMakie).

Test animation:

function first_animation()
    Random.seed!(123)
    npts = 100
    initms = 8*rand(npts) # initial marker size
    msize = Node(initms) # this is the variable that will change
    # first frame, initial plot
    fig, ax = scatter(2*rand(npts), rand(npts); markersize = msize,
        color = initms, colormap = (:viridis, 0.75), strokewidth = 0.5,
        strokecolor = :white, figure = (; resolution=(600,400)),
        axis = (xlabel = "x", ylabel = "y",))
    limits!(ax, 0,2,0,1)
    # the animation is done by updating the node values
    record(fig, "animScatters.mp4") do io
        for i in 1:0.1:8
            msize[] = i*initms
            recordframe!(io)  # record a new frame
        end
    end
end

does it work?



CC BY-NC-SA 4.0 Jose Storopoli, Rik Huijzer and Lazaro Alonso