# This program draws two objects: a rectangle, and a polygon. # Then it flips them. from math import * from cs1graphics import * import time def main(): paper=Canvas(600,700,(218,240,248),"Rotation different objects") # creating a rectangle r=Rectangle(100,200,Point(300,350)) r.setFillColor('Red') r.adjustReference(-30,-50) r_ref_point=Circle(1,Point(300-30,350-50)) # vertical axis of symmetry lineR=Path(Point(300-30,30),Point(300-30,600)) # creating a polygon and moving it immediately a=Point(20,50) b=Point(40,40) c=Point(50,20) d=Point(60,40) e=Point(80,50) f=Point(60,60) g=Point(50,80) h=Point(40,60) star=Polygon(a,b,c,d,e,f,g,h) star.setFillColor((245,226,245)) star.move(400,450) star.adjustReference(60,0) star_ref_point=Circle(1,Point(20+400+60,50+450)) star_ref_point.setBorderColor("Blue") # vertical axis of symmetry lineS=Path(Point(480,230),Point(480,660)) # adding all objects to the canvas, i.e. drawing them paper.add(r), paper.add(star) #adding all objects' reference points paper.add(r_ref_point), paper.add(star_ref_point) #adding vertical axis of symmetry paper.add(lineR),paper.add(lineS) # pause time.sleep(2) # flipping objects r.flip(), star.flip() #pause time.sleep(2) # flipping back r.flip(), star.flip() #pause time.sleep(3) # tilting the symmetry axis lineR.adjustReference(0,300-30) lineS.adjustReference(0,500-230) lineR.rotate(20), lineS.rotate(20) #pause time.sleep(3) # flipping with the axis of symmetry changed r.flip(20), star.flip(20) #pause time.sleep(3) # flipping back r.flip(380), star.flip(380) #pause time.sleep(3) # flipping again r.flip(20), star.flip(20) main()