Rolling Circle Animation

The code below produces eight pictures each showing a circle of radius 1. In each one the 'variable linewidth' idea is used to rotate the circle. The circle is rolled along as it turns round. TODO: to make a better animation requires more images!


                using Plots
                
                mutable struct Circle end
                
                @recipe function f(::Circle, radius::Float64 = 1.0; cx = 0.0)
                    aspect_ratio := :equal
                    framestyle := :origin
                    legend := false
                    xlims := (0,12)
                    ylims := (-1.5, 1.5)
                    t = range(0, 2 * pi, length=96)
                    xs = @. radius * sin(t) 
                    x = @. cx + xs
                    y = @. radius * cos(t)
                    (x,y)
                end
                
                c = Circle()
                lws = range(0, 8, 96)
                for e in 1:8
                    p = plot(c, 1.0; cx=e, linewidth = circshift(lws, e * 12))
                    png(p, "temp/pr$(string(e, pad=3))" )
                end
                
                # To turn the images into a video:
                # convert -delay 20 pr*.png circle.mp4