Moving Polygon




5C Relate a 10 point polygon to the position of the mouse.

back to movies page


#
def polygon(x, y):
 for i in range (0, 9):
  for j in range (0, 9):
   g.line(x[i], y[i], x[j], y[j])

 
x = [10, 12, 15, 20, 25, 29, 30, 27, 23, 17, 10]
y = [25, 17, 10, 11, 15, 19, 25, 33, 32, 27, 25]
g.norefresh()


while 1:
 mx=g.getMouse(1)
 my=g.getMouse(2)
 g.paper(0)
 xpoint=[]
 ypoint=[]
 for a in x:
  xpoint.append(a*mx/5)
 for a in y: 
  ypoint.append(a*my/5)
 polygon(xpoint, ypoint)
 g.refresh()