Skip to content

Instantly share code, notes, and snippets.

@cormullion
Created May 11, 2017 09:14
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 cormullion/b85c3f6ddfca5d8650f4f31e805d15ec to your computer and use it in GitHub Desktop.
Save cormullion/b85c3f6ddfca5d8650f4f31e805d15ec to your computer and use it in GitHub Desktop.
Animated hypotrochoids
#!/usr/bin/env julia
using Luxor
function makerandomepitrochoid(n)
hlist = []
plist = []
for i in 1:n
R = 20
r = rand(30:3:91)
d = rand(35:3:49)
push!(hlist, epitrochoid(R, r, d, vertices=true))
push!(plist, (R, r, d))
end
return hlist, plist
end
function plotaframe(p, params, n, pos)
fontsize(9)
gsave()
translate(pos)
# background
gsave()
sethue("grey85")
setline(0.15)
poly(p, :stroke)
grestore()
portion = n
setline(1)
pdists = polydistances(p)
ppp = polyportion(p, portion, pdist=pdists)
poly(ppp, :stroke)
sethue("cyan")
circle(ppp[end], 2, :fill)
grestore()
end
function framef(scene, framenumber)
tiles = Tiler(1200, 900, 2, 3, margin=25)
cols = [rand(3) for i in 1:15]
for (pos, n) in tiles
sethue(cols[n]...)
plotaframe(epitrochoidslist[n], paramlist[n], framenumber/scene.movie.movieframerange.stop, pos)
end
sethue("grey60")
text("$(paramlist)", Point(0, 880/2), halign=:center)
end
srand(42)
epimovie = Movie(1200, 900, "animhypo")
epitrochoidslist, paramlist = makerandomepitrochoid(6)
animate(epimovie, [Scene(epimovie, (s, f) -> background("grey20")), Scene(epimovie, framef)], creategif=true)
@cormullion
Copy link
Author

cormullion commented May 11, 2017

https://youtu.be/Om45f-U9tX4

This isn't quite the same file as I thought: hypotrochoid changed to epitrochoid (and isn't so good)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment