Skip to content

Instantly share code, notes, and snippets.

@williamstein
Created November 9, 2013 14:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save williamstein/7386062 to your computer and use it in GitHub Desktop.
Save williamstein/7386062 to your computer and use it in GitHub Desktop.
Making a 3d animation in the Sagemath Cloud http://youtu.be/lhirRHCW1q0
%time
filename_pattern = '/tmp/plt-%04d.png'
@parallel
def frame(n, filename):
t = Tachyon(xres=800,yres=800, camera_center=(2,5,2), look_at=(2.5,0,0), antialiasing=True)
t.light((0,0,100), 1, (1,1,1))
t.texture('r', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1,0,0))
for i in range(n):
t.sphere((i/100,sin(i/10),cos(i/10)), 0.05, 'r')
t.texture('white', color=(1,1,1), opacity=1, specular=1, diffuse=1)
t.plane((0,0,-100), (0,0,-100), 'white')
t.save(filename)
print ".",
start = walltime()
len(list(frame([(n, filename_pattern % i) for i, n in enumerate(range(0,500,10))])))
#[frame(n) for n in range(0,500,10)]
print
print walltime() -start
os.system("ffmpeg -f image2 -i %s -b 5M out.ogg" % filename_pattern)
print walltime() -start
os.system("rm *.png")
salvus.file('out.ogg')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment