diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml new file mode 100644 index 0000000..c743950 --- /dev/null +++ b/.JuliaFormatter.toml @@ -0,0 +1 @@ +style = "blue" \ No newline at end of file diff --git a/src/ReCo.jl b/src/ReCo.jl index 3514546..1db082f 100644 --- a/src/ReCo.jl +++ b/src/ReCo.jl @@ -8,7 +8,7 @@ using GLMakie, ColorSchemes, LaTeXStrings using StaticArrays import Dates: now, CompoundPeriod, canonicalize -import Base.push! +import Base: push!, run # Development deps using Revise diff --git a/src/animation.jl b/src/animation.jl index 7a4dbb8..a495c53 100644 --- a/src/animation.jl +++ b/src/animation.jl @@ -3,7 +3,7 @@ function animate(sol::Solution, args, name_part::String; framerate::Int64=10) set_theme!(theme_black()) - fig = Figure(resolution=(1080, 1080)) + fig = Figure(; resolution=(1080, 1080)) ax = Axis( fig[1, 1]; limits=(-args.l, args.l, -args.l, args.l), @@ -12,13 +12,18 @@ function animate(sol::Solution, args, name_part::String; framerate::Int64=10) ylabel=L"y", ) - Colorbar(fig[1, 2]; limits=(0, 2), colormap=ColorSchemes.rainbow, label=L"\frac{\varphi}{\pi}") + Colorbar( + fig[1, 2]; + limits=(0, 2), + colormap=ColorSchemes.rainbow, + label=L"\frac{\varphi}{\pi}", + ) animation_path = "exports/$name_part.mkv" record(fig, animation_path; framerate=framerate) do io - circles = Vector{Circle}(undef, args.N) - colors = Vector{RGBAf}(undef, args.N) + circles = Observable(Vector{Circle}(undef, args.N)) + colors = Observable(Vector{RGBAf}(undef, args.N)) if args.debug segments_x = zeros(2 * args.N) @@ -31,15 +36,21 @@ function animate(sol::Solution, args, name_part::String; framerate::Int64=10) skin_colors = Vector{RGBAf}(undef, args.N) end - @showprogress 0.5 for frame in 1:args.n_frames - @simd for i in 1:args.N - circles[i] = Circle(Point2(sol.center[i, frame]), args.particle_diameter / 2) - - color = get(ColorSchemes.rainbow, rem2pi(sol.φ[i, frame] / (2 * π), RoundDown)) - colors[i] = RGBAf(color) + @showprogress 0.5 for frame in 1:(args.n_frames) + @simd for i in 1:(args.N) + circles[][i] = Circle( + Point2(sol.center[i, frame]), args.particle_diameter / 2 + ) + + color = get( + ColorSchemes.rainbow, rem2pi(sol.φ[i, frame] / (2 * π), RoundDown) + ) + colors[][i] = RGBAf(color) if args.debug - interaction_circles[i] = Circle(Point2(sol.center[i, frame]), args.interaction_r) + interaction_circles[i] = Circle( + Point2(sol.center[i, frame]), args.interaction_r + ) skin_circles[i] = Circle(Point2(sol.center[i, frame]), args.skin_r) interaction_colors[i] = RGBAf(color, 0.12) @@ -48,8 +59,6 @@ function animate(sol::Solution, args, name_part::String; framerate::Int64=10) end if frame > 1 - empty!(ax) - if args.debug @simd for i in 1:(args.N) segments_x[2 * i - 1] = sol.center[i, frame - 1][1] @@ -59,18 +68,23 @@ function animate(sol::Solution, args, name_part::String; framerate::Int64=10) segments_y[2 * i] = sol.center[i, frame][2] end - linesegments!(ax, segments_x, segments_y; color=colors) + if frame == 2 + linesegments!(ax, segments_x, segments_y; color=colors) + end end - else + else # First frame + poly!(ax, circles; color=colors) + + if args.debug + poly!(ax, interaction_circles; color=interaction_colors) + poly!(ax, skin_circles; color=skin_colors) + end + println("Started recording!") end - poly!(ax, circles; color=colors) - - if args.debug - poly!(ax, interaction_circles; color=interaction_colors) - poly!(ax, skin_circles; color=skin_colors) - end + notify(circles) + notify(colors) ax.title = "t = $(round(sol.t[frame], digits=3))"