This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using ColorSchemes | |
| using Javis | |
| N = 6 # Number of dots | |
| radius = 20 # Radius of each dot | |
| colors = ColorSchemes.rainbow1 # Color palette | |
| speed = 10 # Degrees per frame | |
| function draw_circle(frame, i, radius, speed) | |
| # Angle of the direction vector for the dot | |
| θ = (π/N)*i | |
| # Parameterize the dot's position in terms | |
| # of the frame index | |
| ρ = (frame % 360)*(speed/360) | |
| r = 230cos(θ + ρ) | |
| v = Point(cos(θ), sin(θ)) | |
| position = r*v | |
| # Set the color of the dot | |
| color_idx = Int(floor(length(colors) / N)) * i | |
| sethue(colors[color_idx]) | |
| # Draw the dot | |
| circle(position, radius, :fill) | |
| end | |
| video = Video(500, 500) | |
| frames = 226 | |
| Background(1:frames, (args...) -> background("black")) | |
| for i in 1:N | |
| Object(1:frames, (_, _, frame) -> draw_circle(frame, i, radius, speed)) | |
| end | |
| render(video, pathname="circles.gif") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment