Hello,
animate() functon is not working anymore in sagemath cloud.
Nowadays, to make a "video" you can store a sequence a picture files (.png)
and run ffmpeg, like in the following cell, I made for displaying
Lindgren's Q-swing of a rectangle.
Most important are the last two commented lines : producing a mp4 file
(MPEG 4 movie file) and transform it to a FLV file.
Your car example only displays one picture drawing of the car in one window
of your internet browser...so if you replace your show() with a save()
call (and with name of pgn file as parameter) you will get only one
picture file....so if running ffmpeg on this unique file, you will get one
movie with only one picture...not so nice.
Computing for example a translation of the objects (polygons,circle) in one
loop and saving drawing inside is needed.
Dominique
# Animation computation
myrelpath ='./videos_images'
# Parameters
w1 = 2.0 ; h1 = 3.0 ; w2 = 3.2 ; h2 = w1*h1/w2
dh = (h1-h2)/2.0
# Border
dz = 0.5
pM1 = vector([-dz,-dz])
pM2 = vector([w2+dz,-dz])
pM3 = vector([w2+dz,w2+dz])
pM4 = vector([-dz,w2+dz])
# Not moved part
pA = vector([0.0,0.0])
pB = vector([w1,0.0])
pG = vector([0.0,h2])
pI = vector([w1,dh])
pJ = vector([dh*(w1/h2),h2])
# Compute rotations
alpha = pi.n() - atan(h2/w1)
rJ = dh/sin(alpha) ; [xI,yI] = pI ; [xJ,yJ] = pJ
# Loop for building images files
n = 8
for i in xrange(n+1):
#Initialize graphics
g = Graphics()
# Draw border
g += line([pM1,pM2,pM3,pM4,pM1],color=c1,linestyle=ls)
# Draw not moved part
g += line([pA,pB,pI,pJ,pG,pA],color=c1)
# Draw moved parts
dalpha = (i*pi/n).n()
xH1 = xJ + rJ*cos(alpha - dalpha) ; yH1 = yJ + rJ*sin(alpha - dalpha)
pH1 = vector([xH1,yH1])
xK1 = xI + rJ*cos(alpha - dalpha) ; yK1 = yI + rJ*sin(alpha - dalpha)
pK1 = vector([xK1,yK1])
pD1 = vector([xH1,yH1+dh])
pC1 = vector([xH1+w1,yH1+dh])
pL1 = vector([xH1+w1,yH1+dh-h2])
xG1 = xJ + dh*w1/h2*cos(pi-dalpha) ; yG1 = yJ + dh*w1/h2*sin(pi-dalpha)
pG1 = vector([xG1,yG1])
xL2 = xI + dh*cos(pi/2-dalpha) ; yL2 = yI + dh*sin(pi/2-dalpha)
pL2 = vector([xL2,yL2])
g += line([pK1,pL1,pC1,pD1,pH1,pK1],color=c1)
g += line([pJ,pH1,pG1,pJ],color=c1)
g += line([pI,pL2,pK1,pI],color=c1)
# Save drawing to picture file
imagefilepath = myrelpath+'/'+'image'+str(i+1)+'.png'
save(g,imagefilepath,axes=False,aspect_ratio=True)
print "saved picture file : ",imagefilepath
print "ok..run ffmpeg now"
# BE CAREFUL : mp4 suffix mandatory
# Open terminal and then :
# cd video_images
# ffmpeg -r 1 -i image%d.png -pix_fmt yuv420p -r 10 qswing.mp4
# ffmpeg -i qswing.mp4 -ab 26k -f flv qswing.flv
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.