Skip to content

Instantly share code, notes, and snippets.

@somacdivad
Last active March 30, 2022 02:06
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somacdivad/b9b2ec686d81d4bddeed74aec485aaf7 to your computer and use it in GitHub Desktop.
Save somacdivad/b9b2ec686d81d4bddeed74aec485aaf7 to your computer and use it in GitHub Desktop.
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