def loadingAnimation(canvas, width, height, step): cx = 150 # center of the big circle cy = 150 r = 100 #radius of big circle r2 = 17 #radius of small circles move = ((2 * pi) / 2) / 7.0 canvas.create_oval(cx - r, cy - r, cx + r, cy + r, fill=lightgrey, outline=lightgrey) for a in xrange(0, 8): canvas.create_oval(cx - r * sin(a * move - step * move) - r2, cy - r * cos(a * move - step * move) - r2, cx - r * sin(a * move - step * move) + r2, cy - r * cos(a * move - step * move) + r2, fill=rgbString(a * colorstep, a * colorstep, a * colorstep)) canvas.create_text(cx, cy, text="Loading...", fill="black", font="Helvetica 20 bold") stepAnimation.run(loadingAnimation)
canvas.create_text(cx, cy, text="Loading...", font="Helvetica 26 bold") numCircles=8 for position in xrange (numCircles): #creates 8 circles circleColor=position position -= (step%positions) #creates new circles that rotate clockwise circleAngle = math.pi/2 - 2*math.pi*position/14 #chooses place on large circle that small circle will occupy startX = (cx-r * math.cos(circleAngle)) #creates new starting coordinates as the small circles move startY = (cy-r * math.sin(circleAngle)) white=255 RGB=float(white)/(numCircles-1) #makes a couple of shades of gray. oh and white and black changeColor=circleColor*RGB #changes color of the circles so that the leading circle is constantly black while the other have less color fillColor = rgbString(changeColor, changeColor, changeColor) canvas.create_oval(startX-r/(radiusdivisor*2), startY-r/(radiusdivisor*2), startX+r/(radiusdivisor*2), startY+r/(radiusdivisor*2), outline="black", fill=fillColor) stepAnimation.run(loadingAnimation, width = 700, height = 700) def makeBoardH(canvas, width, height, step): xmargin = 10 ymargin = 20 endxpoint = width-xmargin endypoint = height-ymargin x0 = xmargin y0 = ymargin x1 = x0+endxpoint/5 y1 = y0+endypoint/10 for yposition in xrange(0,10): for xposition in xrange(0,5): if (xposition+yposition)%2 == 0: canvas.create_rectangle(x0, y0, x1, y1, fill="lightblue", width=2) else: canvas.create_rectangle(x0, y0, x1, y1, fill="pink", width=2)
return green colorB=0 # the value of B def fancyWheelGridAnimation(canvas,width,height,step): x1=80 y1=60 # first polygon's center point m=(2*pi)*(10.0/360) # rotate of each step r=55 #radius of each polygon for x in xrange(x1,x1+column*xdistance,xdistance) : for y in xrange(y1,y1+row*ydistance,ydistance): h=(x/xdistance)+(y/ydistance)+4 for a in xrange(0,h): for b in xrange(0,h): if h%2==0: canvas.create_line(x+r*cos((a*2*pi/h)-(step*m)), y-r*sin((a*2*pi/h)-(step*m)), x+r*cos((b*2*pi/h)-(step*m)), y-r*sin((b*2*pi/h)-(step*m)), fill=rgbString(colorR(y),colorG(x),colorB)) else: canvas.create_line(x+r*cos((a*2*pi/h)+(step*m)), y-r*sin((a*2*pi/h)+(step*m)), x+r*cos((b*2*pi/h)+(step*m)), y-r*sin((b*2*pi/h)+(step*m)), fill=rgbString(colorR(y),colorG(x),colorB)) stepAnimation.run(fancyWheelGridAnimation,width=800,height=600,timerDelay=128)
def displayKineticText(text, color): stepAnimation.run(kineticTextAnimation, width=500, height=250, timerDelay=25, text=text, color=color)
h1=50 # height of each rectangle of 10 by 5 w2=50 # width of each rectangle of 5 by 10 h2=100 # height of each rectangle of 5 by 10 if step%100<50: # 10 by 5 for Y in xrange(0,10): for X in xrange(0,5): canvas.create_rectangle(x1+w1*X,y1+h1*Y,x1+w1*(X+1), y1+h1*(Y+1), fill= "lightblue" if( X%2==Y%2)else "pink") canvas.create_rectangle(x1+w1*((step%w1)%5),y1+h1*((step%w1)/5), x1+w1*((step%w1)%5+1),y1+h1*((step%w1)/5+1), fill="blue" if step%2==0 else "red") else: # 5 by 10 for Y in xrange(0,5): for X in xrange(0,10): canvas.create_rectangle(x1+w2*X,y1+h2*Y,x1+w2*(X+1), y1+h2*(Y+1), fill= "lightblue" if( X%2==Y%2)else "pink") if (step%50)%20<10: canvas.create_rectangle(x1+w2*(step%10),y1+h2*((step%w2)/10), x1+w2*(step%10+1),y1+h2*((step%w2)/10+1), fill="blue" if step%2==0 else "red") else: canvas.create_rectangle(x1+w2*(step%10),y1+h2*((step%w2)/10), x1+w2*(step%10+1),y1+h2*((step%w2)/10+1), fill="red" if step%2==0 else "blue") canvas.create_text(width/2,height/2, text="10 by 5" if (step%100<50) else "5 by 10", font="Helvetica 85 bold",fill="brown") stepAnimation.run(alternatingGridAnimation,width=600,height=600)
# stepAnimation.run(staticSquareAnimation) # def sweepingSquareAnimation(canvas, width, height, step): # left = step # canvas.create_rectangle(left, 0, left+20, 20, fill="blue") # stepAnimation.run(sweepingSquareAnimation) def bouncingCircleAnimation(canvas, width, height, step): # First do the horizontal direction halfPeriod = 50 # steps until we reach the right side step = step % (2*halfPeriod) if (step < halfPeriod): m = width/halfPeriod left = m*step else: m = -width/halfPeriod left = m*(step-halfPeriod)+width # Now by analogy do the vertical direction halfPeriod = 10 # steps until we reach the bottom side step = step % (2*halfPeriod) if (step < halfPeriod): m = height/halfPeriod top = m*step else: m = -height/halfPeriod top = m*(step-halfPeriod)+height canvas.create_oval(left, top, left+20, top+20, fill="blue") stepAnimation.run(bouncingCircleAnimation, width=400, height=100, timerDelay=8)
def startAnimation(): stepAnimation.run(quizAnimation,width =500,height=500,timerDelay= 100)
import stepAnimation from math import * def rgbString(red, green, blue): return "#%02x%02x%02x" % (red, green, blue) lightgrey=rgbString(224,224, 224) colorstep=255/7.0 def loadingAnimation(canvas,width,height,step): cx=150 # center of the big circle cy=150 r=100 #radius of big circle r2=17 #radius of small circles move=((2*pi)/2)/7.0 canvas.create_oval(cx-r,cy-r,cx+r,cy+r,fill=lightgrey,outline=lightgrey) for a in xrange(0,8): canvas.create_oval(cx-r*sin(a*move-step*move)-r2, cy-r*cos(a*move-step*move)-r2, cx-r*sin(a*move-step*move)+r2, cy-r*cos(a*move-step*move)+r2,fill=rgbString(a*colorstep, a*colorstep,a*colorstep)) canvas.create_text(cx,cy,text="Loading...", fill="black", font="Helvetica 20 bold") stepAnimation.run(loadingAnimation)