# This program draws four objects: a rectangle, a circle, a polygon and text; # and their reference points. # Then it rotates three first objects. 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_ref_point=Circle(1,Point(300,350)) # creating a circle c=Circle(80,Point(130,250)) c.setFillColor('Blue') c.adjustReference(50,10) # moving reference point c_ref_point=Circle(1,Point(130+50,250+10)) c_ref_point.setDepth(10) # 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) p=Polygon(a,b,c_,d,e,f,g,h) p.setFillColor((245,226,245)) p.move(400,450) p_ref_point=Circle(1,Point(20+400,50+450)) p_ref_point.setBorderColor("Blue") # creating a text message and moving it immediately m=Text("Hello! How are you?") m.move(140,50) # adding all objects to the canvas, i.e. drawing them paper.add(r), paper.add(c), paper.add(p), paper.add(m) #adding all objects' reference points paper.add(r_ref_point), paper.add(c_ref_point), paper.add(p_ref_point) # pause time.sleep(1) # loop with 100 iterations, at each iteration each of the # first three objects rotates 10 degrees (clockwise) for i in range(100): r.rotate(15) c.rotate(15) p.rotate(15) #m.rotate(15) time.sleep(0.25) main()