Last active
May 12, 2017 18:15
-
-
Save cormullion/273c2ed08cf289908f5bcc3340c0c654 to your computer and use it in GitHub Desktop.
array slices
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 Luxor | |
function array2dtogrid(a2d::AbstractArray) | |
g = Tiler(200, 200, size(a2d)[1:2]..., margin=25) | |
for (pos, n) in g | |
setgray(a2d[n]) | |
box(pos, g.tilewidth, g.tileheight, :fill) | |
setgray(1-a2d[n]) | |
text(string(round(a2d[n], 2)), pos, halign=:center) | |
end | |
end | |
function drawslice(scene, framenumber) | |
fontsize(8) | |
[(array2dtogrid(a[:,:,prev]); translate(5, 5)) for prev in 1:framenumber] | |
end | |
a = rand(5, 5, 10) | |
m = Movie(300, 300, "arrayslicer") | |
animate(m, [Scene(m, (s, f) -> background("white"), 1:10), Scene(m, drawslice, 1:10)], framerate=3, | |
creategif=true, pathname="/tmp/arrayslicer.gif") |
Author
cormullion
commented
May 12, 2017
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment