# Python, part 10

More animation.
We'll first create a large circle on the canvas which rapid shrinks in
size.  We'll assume the canvas has fill sky blue, or something other
than orange.

oldx = 0                     coordinates will always be (oldx,oldx) and
oldx2 = 400               (oldx2,oldx2)  so we have a circle.

while oldx <= 190:        continue until we're almost at the center

myCanvas.create_oval(oldx,oldx,oldx2,oldx2,fill="orange",\
outline="orange")
myCanvas.pack()
myCanvas.update()
time.sleep(0.1)           0.3 etc to shrink the circle slower
myCanvas.create_oval(oldx,oldx,oldx2,oldx2,fill="orange",\
outline="orange")
oldx = oldx + 5
oldx2 = oldx2 - 5       the upper left-hand corner of the square
moves in and down, the lower right-hand
corner moves left and up.....you can also have
smaller (or larger) increments here.

pulsar

--------------------------------------
Optional exercise:  have the circle pulse in and out 5 times--i.e. starts
large, shrinks to nothing, swells larger and larger, shrinks, etc.  To do
this--we need an outer for loop that loops 5 times: for i in range(5).
Inside the for loop we have the code above to shrink the circle.  Then
we have a second while loop to expand the circle--
oldx = 190
oldx2 = 210
while oldx >= 0:

then we'll have oldx = oldx -5 and oldx2 = oldx2 + 5

Variation:  at maximum size, perhaps print text that says "BOOM!"
at the center of the circle.
-----------------------------------------------

MEASLES
We'll create different-colored spots at random on a white canvas.
Make Canvas white (or whatever).

for i in range(200):        for 200 spots
xpt = random.randrange(1,390)
ypt = random.randrange(1,390)     random x-y coordinates
randcol = random.randrange(1,7)
if randcol == 1:
mycolor = "red"              as shown in a previous page--
elif randcolor == 2:                   we'll pick a color at random
mycolor = "purple"
elif randcolor == 3:
mycolor = "green"
elif randcolor == 4:
mycolor = "blue"
elif randcolor == 5:
mycolor = "orange"
else:
mycolor = "brown"
myCanvas.create_oval(xpt,ypt,xpt+8,ypt+8,fill=mycolor)
for smaller spots, xpt + 5, etc
myCanvas.pack()
myCanvas.update()
time.sleep(0.1)
measles

------------------------------------------