function animate(sol::Solution, args, name_part::String; framerate::Int64=10) println("Generating animation...") fig = Figure() ax = Axis( fig[1, 1]; limits=(-args.l, args.l, -args.l, args.l), aspect=AxisAspect(1), xlabel=L"x", ylabel=L"y", ) animation_path = "exports/$name_part.mkv" record(fig, animation_path; framerate=framerate) do io old_cx = zeros(args.N) old_cy = zeros(args.N) new_cx = zeros(args.N) new_cy = zeros(args.N) segments_x = zeros(2 * args.N) segments_y = zeros(2 * args.N) done_first_iter = false @showprogress 0.5 for frame in 1:args.n_frames new_cx .= get_c_x.(sol.position[frame]) new_cy .= get_c_y.(sol.position[frame]) if done_first_iter empty!(ax) for i in 1:(args.N) segments_x[2 * i - 1] = old_cx[i] segments_x[2 * i] = new_cx[i] segments_y[2 * i - 1] = old_cy[i] segments_y[2 * i] = new_cy[i] end linesegments!(ax, segments_x, segments_y; color=1:(args.N)) else done_first_iter = true println("Started recording!") end old_cx .= new_cx old_cy .= new_cy poly!( ax, [Circle(Point2(x, y), args.particle_diameter / 2) for (x, y) in zip(new_cx, new_cy)]; color=1:(args.N), ) # DEBUG BEGIN for (x, y) in zip(new_cx, new_cy) arc!(ax, Point2(x, y), args.interaction_r, 0.0, 2 * π) end # DEBUG END ax.title = "t = $(round(sol.t[frame], digits=2))" recordframe!(io) end end println("Animation done and saved to $animation_path.") return nothing end