def draw(self): if self.forever_function is not None: self.forever_function() if not self.hidden: offsetx = self.canvas.winfo_reqwidth()/2 offsety = self.canvas.winfo_reqheight()/2 cx = self.xcor cy = self.ycor xf = 1 yf = 1 if self.x_flipped: xf = -1 if self.y_flipped: yf = -1 points = [self.xcor-xf*self.x1, self.ycor-yf*self.y1, self.xcor-xf*self.x2, self.ycor-yf*self.y2, self.xcor-xf*self.x3, self.ycor-yf*self.y3, self.xcor-xf*self.x4, self.ycor-yf*self.y4] point_tuple = transformations.poly_poly(cx, cy, points, -self.heading) points[0] = offsetx + self.size*point_tuple[0] points[1] = offsety - self.size*point_tuple[1] points[2] = offsetx + self.size*point_tuple[2] points[3] = offsety - self.size*point_tuple[3] points[4] = offsetx + self.size*point_tuple[4] points[5] = offsety - self.size*point_tuple[5] points[6] = offsetx + self.size*point_tuple[6] points[7] = offsety - self.size*point_tuple[7] self.canvas.create_polygon(tuple(points), fill=self.color, outline=self.outline) for p in self.polygons: self.canvas.create_polygon(tuple(p[0]), fill=p[1]) for l in self.lines: self.canvas.create_line(l[0], fill=l[1], width=l[2]) if self.say_time != 0: self.canvas.create_text(self.xcor + self.canvas.winfo_reqwidth()/2, self.canvas.winfo_reqheight()/2 - self.ycor - 100, text=self.say_text, font=(self.say_font, self.say_size), fill=self.say_color) self.say_time -= 1
def draw(self): if self.forever_function is not None: self.forever_function() if not self.hidden: offsetx = self.canvas.winfo_reqwidth()/2 offsety = self.canvas.winfo_reqheight()/2 cx = offsetx + self.xcor cy = offsety - self.ycor xf = 1 yf = 1 if self.x_flipped: xf = -1 if self.y_flipped: yf = -1 x1 = cx - xf*self.size*self.width/2 y1 = cy + yf*self.size*self.height/2 x2 = cx + xf*self.size*self.width/2 y2 = cy + yf*self.size*self.height/2 x3 = cx - xf*self.size*self.width/2 y3 = cy - yf*self.size*self.height/2 points = [x1, y1, x2, y2, x3, y3] self.canvas.create_polygon(transformations.poly_poly(cx, cy, points, self.heading), fill=self.color, outline=self.outline) for p in self.polygons: self.canvas.create_polygon(tuple(p[0]), fill=p[1]) for l in self.lines: self.canvas.create_line(l[0], fill=l[1], width=l[2]) if self.say_time != 0: self.canvas.create_text(self.xcor + self.canvas.winfo_reqwidth()/2, self.canvas.winfo_reqheight()/2 - self.ycor - 100, text=self.say_text, font=(self.say_font, self.say_size), fill=self.say_color) self.say_time -= 1