Skip to content

Instantly share code, notes, and snippets.

@cormullion
Last active May 12, 2017 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cormullion/273c2ed08cf289908f5bcc3340c0c654 to your computer and use it in GitHub Desktop.
Save cormullion/273c2ed08cf289908f5bcc3340c0c654 to your computer and use it in GitHub Desktop.
array slices
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")
@cormullion
Copy link
Author

cormullion commented May 12, 2017

arrayslicer

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