Created
May 11, 2017 09:14
-
-
Save cormullion/b85c3f6ddfca5d8650f4f31e805d15ec to your computer and use it in GitHub Desktop.
Animated hypotrochoids
This file contains hidden or 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
#!/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) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://youtu.be/Om45f-U9tX4
This isn't quite the same file as I thought:
hypotrochoid
changed toepitrochoid
(and isn't so good)