Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Multiple loops in an animation?

I want to use two loops to produce an animation of some gridlines changing gradient.

Essentially making all these lines:

t=var('t')
p1=Graphics()
p2=Graphics()
for i in range(-5,5,1):
    p1 +=parametric_plot((t,i),(t,-5,5),color="red")
    p2 +=parametric_plot((i,t),(t,-5,5),color="blue")
show(p1+p2)

Move like these lines all at once:

t=var('t')
p1=Graphics()
p2=Graphics()
v = []
for a in srange(-5,5,1):
    p1 =parametric_plot((t,t*a),(t,-5,5),color="red")
    p2 =parametric_plot((t*a,t),(t,-5,5),color="blue")
    v.append(p1+p2)
j = animate (v, xmin=-2,ymin=-2,xmax=2,ymax=2,figsize=[2,2])
j.show()

How can I combine these two into one animation?