def rotate(self, x, y, angle): tmp_point_list = [] for i in range(len(self.point_list)): # Two vertex points to local vars x1 = self.point_list[i][0] y1 = self.point_list[i][1] x2 = self.point_list[(i+1)%len(self.point_list)][0] y2 = self.point_list[(i+1)%len(self.point_list)][1] # Preform rotation on temporary line tmp_line = Line(x1, y1, x2, y2) tmp_line.rotate(x, y, angle) # Rotated points back to point list tmp_point_list.append((tmp_line.x1, tmp_line.y1)) self.point_list = tmp_point_list
img.blit( Ellipse(200,50,20,5).fill( Color(0, 255, 0) ) ) # The flag is constructed as such: # The pole is a line with start and end points of (100,125) and (100,50). line1 = Line(100, 125, 100, 50) # The flag is a polygon with vertex points of (100,125), (100,95), and # (60,110) polygon1 = Polygon([(100,125), (100,95), (60,110)]).fill( Color(128, 0, 128) ) # The pole and flag are translated by (0,35), in order to fit in the right # hand of the stick figure. line1.translate(0,35) polygon1.translate(0,35) # The pole and flag are rotated by 45 degrees for a fix point of (100,100), # so the flag and pole are tilted in the right hand of the stick figure. line1.rotate(100,100,45) polygon1.rotate(100,100,45) # The pole and flag are scaled by 1.25 in the x and y values for a fix # point of (100,100), to be larger in the right hand of the stick figure. line1.scale(100,100,1.25,1.25) polygon1.scale(100,100,1.25,1.25) # Blit Rest img.blit( line1 ) img.blit( polygon1 ) # Create/Write Image img.save('test.ppm')