def draw(self, screen): # draw roads for i in range(self.n_all): for j in range(i, self.n_all): if not self.nodes_distance[i, j] < float('inf'): continue pos_i = utils.lb2lt(tuple(self.nodes_position[i])) pos_j = utils.lb2lt(tuple(self.nodes_position[j])) color = utils.get_color() size = 2 if self.flags_main_road[i, j]: color = utils.get_color('RED') size = 3 draw.aaline(screen, color, pos_i, pos_j) # draw nodes for i in range(self.n_all): pos = utils.lb2lt(tuple(self.nodes_position[i])) if 'D' in self.i2c[i]: xdraw.filled_circle(screen, pos[0], pos[1], 8, utils.get_color('RED')) elif 'Z' in self.i2c[i]: xdraw.filled_circle(screen, pos[0], pos[1], 6, utils.get_color('BLUE')) elif 'J' in self.i2c[i]: xdraw.filled_circle(screen, pos[0], pos[1], 4, utils.get_color('BLACK')) elif 'F' in self.i2c[i]: xdraw.box(screen, (pos[0] - 4, pos[1] - 4, 8, 8), (139, 19, 69))
def __init__(self, parent): super().__init__(parent) self.image = Surface([3, 19]) self.image.fill(COLOR_BOX) self.rect = self.image.get_rect() self.x, self.y, self.w, self.h = self.rect draw.aaline(self.image, COLOR_TEXT, [1, 0], [1, self.h])
def update(self): self.ticks += 1 self.image.fill(self.color_fondo, (1, 1, self.w - 2, self.h - 2)) if len(self.input): t = ''.join(self.input) color = self.color_texto fuente = self.f else: t = 'Ingrese el nombre de un producto' color = 125, 125, 125 fuente = self.empty_f r = fuente.render(t, 1, color, self.color_fondo) rr = r.get_rect(topleft=(self.rect.x + 1, self.rect.y + 1)) if self.rect.contains(rr): self.image.blit(r, (1, 1)) self.dirty = 1 if 10 < self.ticks < 30 and len(self.input) and self.active: draw.aaline(self.image, self.color_texto, (rr.right - self.rect.x + 2, 3), (rr.right - 80 + 2, self.h - 3)) elif self.ticks > 40: self.ticks = 0
def draw(self): #draw graph backdrop = self.graph.copy() self.graph.blit(backdrop, (-1, 0)) if self.tick % 10 != 0: draw.line(self.graph, self.graph_color, (self.gWIDTH - 1, 0), (self.gWIDTH - 1, self.gHEIGTH - 1)) for i in range(10, self.gHEIGTH, 10): self.graph.set_at((self.gWIDTH - 1, i), self.support_line_color) else: draw.line(self.graph, self.support_line_color, (self.gWIDTH - 1, 0), (self.gWIDTH - 1, self.gHEIGTH - 1)) point = (3 * self.gWIDTH // 4, int((self.content - self.min_value) * self.gHEIGTH / (self.max_value - self.min_value))) if self.previous_point: draw.aaline(self.graph, self.line_color, self.previous_point, point) x, y = point self.previous_point = (x - 1, y) self.tick += 1 #draw canvas self.canvas.blit(self.graph, (3 * self.TAB, self.TAB))
def test_color_validation(self): surf = pygame.Surface((10, 10)) colors = 123456, (1, 10, 100), RED # but not '#ab12df' or 'red' ... points = ((0, 0), (1, 1), (1, 0)) # 1. valid colors for col in colors: draw.line(surf, col, (0, 0), (1, 1)) draw.aaline(surf, col, (0, 0), (1, 1)) draw.aalines(surf, col, True, points) draw.lines(surf, col, True, points) draw.arc(surf, col, pygame.Rect(0, 0, 3, 3), 15, 150) draw.ellipse(surf, col, pygame.Rect(0, 0, 3, 6), 1) draw.circle(surf, col, (7, 3), 2) draw.polygon(surf, col, points, 0) # 2. invalid colors for col in ('invalid', 1.256, object(), None, '#ab12df', 'red'): with self.assertRaises(TypeError): draw.line(surf, col, (0, 0), (1, 1)) with self.assertRaises(TypeError): draw.aaline(surf, col, (0, 0), (1, 1)) with self.assertRaises(TypeError): draw.aalines(surf, col, True, points) with self.assertRaises(TypeError): draw.lines(surf, col, True, points) with self.assertRaises(TypeError): draw.arc(surf, col, pygame.Rect(0, 0, 3, 3), 15, 150) with self.assertRaises(TypeError): draw.ellipse(surf, col, pygame.Rect(0, 0, 3, 6), 1) with self.assertRaises(TypeError): draw.circle(surf, col, (7, 3), 2) with self.assertRaises(TypeError): draw.polygon(surf, col, points, 0)
def draw_parus(parus_x, parus_y, p): """ parus_x - координата x левого верхнего угла стержня паруса parus_y - координата y левого верхнего угла стержня паруса p - коэффициент пропорциональности размеров паруса """ draw.rect(screen, (0, 0, 0), (parus_x, parus_y, p * 2 - 2, 2 * 10 * p)) draw.polygon(screen, (218, 173, 128), [(parus_x + p * 2 - 2, parus_y), (parus_x + p * 6, parus_y + p * 10), (parus_x + p * 14, parus_y + p * 10)]) draw.polygon(screen, (218, 173, 128), [(parus_x + p * 2 - 2, parus_y + p * 10 * 2), (parus_x + p * 6, parus_y + p * 10), (parus_x + p * 14, parus_y + p * 10)]) draw.aaline(screen, (0, 0, 0), (parus_x + p * 6, parus_y + p * 10), (parus_x + p * 14, parus_y + p * 10)) draw.aaline(screen, (0, 0, 0), (parus_x + p * 6, parus_y + p * 10), (parus_x + p * 2 - 2, parus_y)) draw.aaline(screen, (0, 0, 0), (parus_x + p * 14, parus_y + p * 10), (parus_x + p * 2 - 2, parus_y)) draw.aaline(screen, (0, 0, 0), (parus_x + p * 6, parus_y + p * 10), (parus_x + p * 2 - 2, parus_y + 2 * 10 * p)) draw.aaline(screen, (0, 0, 0), (parus_x + p * 14, parus_y + p * 10), (parus_x + p * 2 - 2, parus_y + 2 * 10 * p))
def draw(self, surface): c_inner, c_outer = self.colouring() for arm in self.arms: pdraw.aaline(surface, c_outer, arm.p1, arm.p2, 1) gfx.filled_circle(surface, int(self.position[0]), int(self.position[1]), self.radius, c_inner) gfx.aacircle(surface, int(self.position[0]), int(self.position[1]), self.radius, c_outer)
def draw(self, surface, x, y, w, h): start_pos = self.__get_point(self.__start, x, y, w, h) end_pos = self.__get_point(self.__end, x, y, w, h) if start_pos[0] > end_pos[0]: tmp = start_pos start_pos = end_pos end_pos = tmp aaline(surface, (56, 21, 200), start_pos, end_pos, 1)
def _crear(checked): lado = 12 img = Surface((lado, lado)) img.fill((255, 255, 255), (1, 1, lado - 2, lado - 2)) if checked: draw.aaline(img, (0, 0, 0), [2, 2], [9, 10]) # \ draw.aaline(img, (0, 0, 0), [2, 10], [9, 2]) # / return img
def render(direction: math.Vector2, window_size: tuple, surface: Surface) -> None: start_pos = math.Vector2 (window_size[0]/2, window_size[1]/2) if direction is None or direction.length() < 0.05: draw.circle(surface, (255, 0, 0), start_pos, 5, 1) else: # copy, no reference vector = math.Vector2(direction) length = vector.length() vector.scale_to_length(length * 100) draw.aaline(surface, (0, 255, 0), start_pos, start_pos + vector)
def update_turrets(self, screen): lines = [] for turret_id, turret in self.all_turrets.items(): turret.shoot(self.all_enemies_on_map) line = turret.update(screen, self.all_enemies_on_map) lines.append(line) if line is not None else None for line in lines: draw_better_line(screen, line[0].begin(), line[0].end(), line[1][0], 2) aaline(screen, line[1][1], line[0].begin(), line[0].end())
def draw_link(self, surface, link): from pygame.draw import aaline #TODO stop line at side of hole start = self.apos end = link.apos aaline(surface, (100, 50, 50), start, end) return self
def test_aaline_blend(self): """ blends correctly with the background color. """ surface = pygame.Surface((20, 20)) surface.fill(pygame.Color(0, 255, 0)) draw.aaline(surface, pygame.Color(255, 255, 255), (2, 2), (18, 18), 1) draw.aaline(surface, pygame.Color(255, 255, 255), (2, 18), (18, 2), 1) # white should be blended with the background green. self.assertEqual(surface.get_at((10, 10)), (191, 255, 191, 255)) # should be full green here. self.assertEqual(surface.get_at((9, 7)), (0, 255, 0, 255))
def draw(self, screen): screen.fill(BLACK) first = self.waves[0] amp = mapf(first.amp, b=(0, self.scale)) draw.aalines(screen, DARKER_GREY, True, [(x - amp * cos(first.phase), y - amp * sin(first.phase)) for x, y in self.origin_path]) origin = self.MIDDLE if not self.stop: for wave in self.waves[1:]: radius = mapf(wave.amp, b=(0, self.scale)) gfxdraw.aacircle(screen, int(origin.x), int(origin.y), int(max(2, radius)), GREY) angle = self.t * wave.freq + wave.phase end_point = origin + (radius * cos(angle), radius * sin(angle)) draw.aaline(screen, WHITE, origin.int_tuple, end_point.int_tuple) origin = end_point self.trail.append(origin) length = len(self.trail) if length > 1: if self.teleport: prev = self.trail[0] for i in self.trail[1:]: if prev.dist(i) < 10: draw.aaline(screen, NICE_RED, prev.float_tuple, i.float_tuple) prev = i else: draw.aalines(screen, NICE_RED, False, list(map(lambda x: x.float_tuple, self.trail))) if not self.stop: self.t += self.dt if length > self.trail_length + 15: self.stop = True if self.zoom: scaled = transform.scale2x(screen) screen.fill(BLACK) screen.blit(scaled, (self.size[0] / 2 - origin.x * 2, self.size[1] / 2 - origin.y * 2)) font = pygame.font.Font("NanumSquare.ttf", 17) text = font.render("https://github.com/pl-Steve28-lq", True, WHITE) rect = text.get_rect() rect.x = 10 rect.y = int(self.size[1] - rect.size[1] * 3 / 2) screen.blit(text, rect)
def makeColumns(self): columns = int(self.window.display_width / self.grid_size) + 1 temp = 0 for i in (range(1, columns)): start_point = (temp, 0) end_point = (temp, self.window.display_height - 50) draw.aaline(self.window.gameDisplay, colours['lime'], start_point, end_point) temp = temp + self.grid_size
def draw(self, surface, draw_rays=False): updated_rects = [] updated_rects.extend(super(CarAI, self).draw(surface)) for i in range(self._dists.shape[0]): angle = self._ray_angle[i] start_pos = np.copy(self.pos) start_pos[0] += np.cos(self.angle) * self._ray_origin[ i, 0] - np.sin(self.angle) * self._ray_origin[i, 1] start_pos[1] += np.sin(self.angle) * self._ray_origin[ i, 0] + np.cos(self.angle) * self._ray_origin[i, 1] direction = np.array( [np.cos(self.angle + angle), np.sin(self.angle + angle)]) if draw_rays: updated_rects.append( draw.aaline( surface, (0, 127, 0), start_pos.astype(np.int32), (start_pos + self._ray_length[i] * direction).astype( np.int32))) updated_rects.append( draw_text(surface, (255, ) * 3, f'{i}', (start_pos + self._ray_length[i] * direction).astype( np.int32), 8, 'topleft')) updated_rects.append( draw.circle(surface, (0, 255, 0), self._points[i].astype(np.int32), 2)) return updated_rects
def _draw_shape_draft(surface, shape): """Draw the shape on the given surface. Arguments: surface - drawing surface (an instance of pygame.Surface class); shape - shape to draw (an instance of one of the shape classes defined in shapes module); Result: bounding box, defined during the drawing; """ # Get some of the shape attributes ref_point = shape.get_ref_point() r_inner = shape.get_r_inner() # Draw the shape edges shape_bounds = draw.aalines( surface, SHAPE_COLOR, True, shape.get_vertices() ) # Draw the shape inner circle draw.circle( surface, SHAPE_COLOR, # NB! draw.circle() expects integer arguments map(int, ref_point), int(r_inner), 1 # circle edge width ) # Draw the cross in the inner circle center for (a, b) in ( ((-1, 0), (+1, 0)), ((0, +1), (0, -1)) ): draw.aaline( surface, SHAPE_COLOR, *[ [ ref_point[coord] + r_inner / 3 * p[coord] for coord in (0, 1) ] for p in (a, b) ] ) return shape_bounds
def makeRows(self): rows = int(self.window.display_height / self.grid_size) temp = 0 for i in (range(1, rows)): start_point = (0, temp) end_point = (self.window.display_width, temp) draw.aaline(self.window.gameDisplay, colours['lime'], start_point, end_point) temp = temp + self.grid_size draw.aaline(self.window.gameDisplay, colours['black'], start_point, end_point)
def draw(self, screen): h = screen.get_height() s = self.scale_sim_to_vis center = self.body.position top = self.body.GetWorldPoint((0.0, self.sim_radius)) if center.x < 0 or center.y < 0: print(center) return cx = int(round(s * center.x)) cy = int(round(h - s * center.y)) top_x = int(round(s * top.x)) top_y = int(round(h - s * top.y)) gfxdraw.aacircle(screen, cx, cy, self.pixel_radius, self.circle_color) draw.aaline(screen, self.line_color, (cx, cy), (top_x, top_y))
def make_platform_surface(): surf = pygame.Surface((640, 148), flags=pygame.SRCALPHA | pygame.HWSURFACE) for x in xrange(40, 600, 40): draw.rect(surf, LIGHT_COLOUR, pygame.Rect((x, 122), (40, 23))) draw.rect(surf, DARK_COLOUR, pygame.Rect((x, 130), (40, 4))) draw.aaline(surf, BACKGROUND_COLOUR, (x, 140), (x + 40, 140)) draw.aaline(surf, BACKGROUND_COLOUR, (x + 19, 146), (x + 21, 134)) # tunnels draw.rect(surf, DARK_COLOUR, pygame.Rect((35, 0), (5, 147))) draw.rect(surf, LIGHT_COLOUR, pygame.Rect((20, 0), (15, 147))) draw.rect(surf, DARK_COLOUR, pygame.Rect((600, 0), (5, 147))) draw.rect(surf, LIGHT_COLOUR, pygame.Rect((605, 0), (15, 147))) # roof draw.rect(surf, DARK_COLOUR, pygame.Rect((40, 0), (560, 10))) draw.rect(surf, LIGHT_COLOUR, pygame.Rect((40, 10), (560, 20))) return surf
def lines(self, polys: List[List[Tuple[int, int]]], lines: List[Tuple[Tuple[int, int], Tuple[int, int]]]): # Draw polygons for poly in polys: temp = poly.copy() for i in range(len(temp)): temp[i] = (temp[i][0] / 500 * self.scale + self.offset[0], temp[i][1] / 500 * self.scale + self.offset[1]) pygame.draw.polygon(self.surface, (0, 255, 0), temp) for i in range(-1, len(temp) - 1): aaline(self.surface, (255, 255, 255), temp[i], temp[i + 1]) for line in lines: startx = line[0][0] / 500 * self.scale + self.offset[0] starty = line[0][1] / 500 * self.scale + self.offset[1] endx = line[1][0] / 500 * self.scale + self.offset[0] endy = line[1][1] / 500 * self.scale + self.offset[1] aaline(self.surface, (255, 255, 255), (startx, starty), (endx, endy))
def show(screen): global t screen.fill(BLACK) # Original path draw.aalines(screen, DARKER_GREY, True, original_path) # Epicycles origin = MIDDLE # type: Vec2d for wave in waves: # Circle radius = mapf(wave.amp, b=(0, SCALE)) #draw.circle(screen, DARK_GREY, origin.int_tuple, int(max(2, radius)), 1) gfxdraw.aacircle(screen, int(origin.x), int(origin.y), int(max(2, radius)), DARK_GREY) # Line angle = t * wave.freq + wave.phase end_point = origin + (radius * cos(angle), radius * sin(angle)) draw.aaline(screen, WHITE, origin.int_tuple, end_point.int_tuple) origin = end_point # Trail trail.append(origin.float_tuple) if len(trail) > trail_length: trail.pop(0) if len(trail) > 1: draw.aalines(screen, NICE_RED, False, trail) # Zoom if ZOOM: scaled = transform.scale2x(screen) screen.fill(BLACK) screen.blit(scaled, (WIDTH / 2 - origin.x * 2, HEIGHT / 2 - origin.y * 2)) t += dt
def drawing(pos=[0, 0], angle=0, line_size=0): draw.aaline(screen, (0, 255, 0), pos, (sin(angle+120*(pi/180))*line_size+pos[0], cos(angle+120*(pi/180))*line_size+pos[1]), 1) draw.aaline(screen, (0, 255, 0), pos, (sin(angle+240*(pi/180))*line_size+pos[0], cos(angle+240*(pi/180))*line_size+pos[1]), 1) draw.aaline(screen, (0, 255, 0), pos, (sin(angle+0*(pi/180))*line_size+pos[0], cos(angle+0*(pi/180))*line_size+pos[1]), 1)
def draw(self): #draw graph backdrop= self.graph.copy() self.graph.blit(backdrop, (-1, 0)) if self.tick%10 != 0: draw.line(self.graph, self.graph_color, (self.gWIDTH-1, 0), (self.gWIDTH-1, self.gHEIGTH-1)) for i in range(10, self.gHEIGTH, 10): self.graph.set_at( (self.gWIDTH-1,i), self.support_line_color ) else: draw.line(self.graph, self.support_line_color, (self.gWIDTH-1, 0), (self.gWIDTH-1, self.gHEIGTH-1)) point= (3*self.gWIDTH//4, int( (self.content -self.min_value)*self.gHEIGTH/(self.max_value - self.min_value) ) ) if self.previous_point: draw.aaline(self.graph, self.line_color, self.previous_point, point) x, y= point self.previous_point= (x-1, y) self.tick+=1 #draw canvas self.canvas.blit(self.graph, (3*self.TAB, self.TAB ) )
def _render_segment(self, buffer: Surface, theme: Theme, pos_a: Tuple[int, int], pos_b: Tuple[int, int]) -> None: ''' Render a segment of a wire between two route waypoints. The width of the segment is dependent on the wire's bit-width. Parameters: buffer: the pygame surface to render on to theme: the color and layout scheme to use for rendering pos_a: the start position of the line segment pos_b: the end position of the line segment ''' y_off = self.wire_in.width // 2 a_x = pos_a[0] a_y = pos_a[1] - y_off b_x = pos_b[0] b_y = pos_b[1] - y_off for i in range(self.wire_in.width): draw.aaline(buffer, theme.wire_col, (a_x, a_y), (b_x, b_y)) a_y += 1 b_y += 1
def draw(self, surface): if self.status == 'dead': return c_inner, c_outer = self.colouring() for row in self.branches: for segment in row: sp = segment.p1 ep = segment.p2 d, l = (sp - ep).as_polar() p1 = sp + 1 * np.cos(np.radians(d + 90)) p2 = sp + 1 * np.cos(np.radians(d - 90)) p3 = ep + 1 * np.cos(np.radians(d + 90)) p4 = ep + 1 * np.cos(np.radians(d - 90)) gfx.aapolygon(surface, [p1, p2, p3, p4], c_outer) gfx.filled_polygon(surface, [p1, p2, p3, p4], c_outer) for row in self.branches: for segment in row: sp = segment.p1 ep = segment.p2 pdraw.aaline(surface, c_inner, sp, ep, 1)
def _draw_shape_draft(surface, shape): """Draw the shape on the given surface. Arguments: surface - drawing surface (an instance of pygame.Surface class); shape - shape to draw (an instance of one of the shape classes defined in shapes module); Result: bounding box, defined during the drawing; """ # Get some of the shape attributes ref_point = shape.get_ref_point() r_inner = shape.get_r_inner() # Draw the shape edges shape_bounds = draw.aalines(surface, SHAPE_COLOR, True, shape.get_vertices()) # Draw the shape inner circle draw.circle( surface, SHAPE_COLOR, # NB! draw.circle() expects integer arguments map(int, ref_point), int(r_inner), 1 # circle edge width ) # Draw the cross in the inner circle center for (a, b) in (((-1, 0), (+1, 0)), ((0, +1), (0, -1))): draw.aaline( surface, SHAPE_COLOR, *[[ref_point[coord] + r_inner / 3 * p[coord] for coord in (0, 1)] for p in (a, b)]) return shape_bounds
def drawing(pos=[0, 0], angle=0, line_size=0): draw.aaline(screen, (0, 255, 0), pos, (sin(angle + 120 * (pi / 180)) * line_size + pos[0], cos(angle + 120 * (pi / 180)) * line_size + pos[1]), 1) draw.aaline(screen, (0, 255, 0), pos, (sin(angle + 240 * (pi / 180)) * line_size + pos[0], cos(angle + 240 * (pi / 180)) * line_size + pos[1]), 1) draw.aaline(screen, (0, 255, 0), pos, (sin(angle + 0 * (pi / 180)) * line_size + pos[0], cos(angle + 0 * (pi / 180)) * line_size + pos[1]), 1)
def aaline(self, color, startpos, endpos, blend=1): """アンチエイリアス処理のなされた直線を描画します. Parameters ---------- color : tuple of int 描画に使用される色を指定します. startpos : tuple of float 描画される直線の始点を指定します. endpos : tuple of float 描画される直線の終点を指定します. blend : int or bool Trueに設定された場合、描画位置のピクセルに上書きはされず , 半透明の状態で描画されます. Returns ------- rect : pygame.Rect 描画によって影響を受けた範囲を示すpygame.Rectオブジェクトを返します. """ return pyd.aaline(self.pg.screen, color, startpos, endpos, blend)
def _draw_arrow(self, start, end, colour, width=1, rel_spoke_len=0.2): """ internal function for drawing arrows draws directly to screen coordiantes, so make sure start and end have been converted plot._draw_arrow( start: np.array, end: np.array, colour: rgb or name width=1: int, rel_spoke_len=0.2: float) rel_spoke_len is the length of the spokes relative to the length of the line from start to end """ if str(colour) in clrs.info: colour = clrs[colour] strt, endp = np.array(start), np.array(end) diff = endp - strt norm_diff = tools.norm(diff) perp = tools.perp(tools.normalize(diff)) midpoint = strt + diff * 0.7 pnt2 = midpoint - (perp * norm_diff * rel_spoke_len) pnt1 = midpoint + (perp * norm_diff * rel_spoke_len) #pgdraw.line(self.screen, colour, pnt1, pnt2) # draw the arrow #print(strt, endp, pnt1, pnt2) if width != 1: pgdraw.line(self.screen, colour, strt, endp, width) # main line pgdraw.line(self.screen, colour, pnt1, endp, width) # spoke one pgdraw.line(self.screen, colour, pnt2, endp, width) # spoke two else: pgdraw.aaline(self.screen, colour, strt, endp, width) # main line pgdraw.aaline(self.screen, colour, pnt1, endp, width) # spoke one pgdraw.aaline(self.screen, colour, pnt2, endp, width) # spoke two
def show(self, surface): end = self.pos + 10 * self.dir draw.aaline(surface, self.color, self.pos, end, 1)
def draw_aaline(self, color, from_point, to_point): draw.aaline(self.surface, color, from_point, to_point, 1)
def draw_line(o): aaline(surface, (255 * flash, 255 * flash, 0), tuple(a + o*n + (4-abs(o))*m), tuple(b + o*n + -1.*(4-abs(o))*m) )
def draw_umbrella(left_upper_x, left_upper_y, width_umb, height_umb, umb_radius, umb_length, dist_betw_spokes): """ left_upper_x - координата x левого верхнего угла стержня зонтика left_upper_y - координата y левого верхнего угла стержня зонтика width_umb - ширина стержня зонтика height_umb - высота стержня зонтика umb_radius - радиус "шапочки" зонтика umb_length - длина "шапочки" зонтика dist_betw_spokes - ширина между спицами зонтика """ draw.rect(screen, (210, 110, 34), (left_upper_x, left_upper_y, width_umb, height_umb)) draw.polygon( screen, (249, 96, 75), [(left_upper_x + width_umb, left_upper_y), (left_upper_x + width_umb, left_upper_y + umb_length), (left_upper_x + width_umb + umb_radius, left_upper_y + umb_length)]) draw.polygon(screen, (249, 96, 75), [(left_upper_x, left_upper_y), (left_upper_x, left_upper_y + umb_length), (left_upper_x - umb_radius, left_upper_y + umb_length)]) draw.rect(screen, (249, 96, 75), (left_upper_x, left_upper_y, width_umb, umb_length)) draw.aaline(screen, (0, 0, 0), (left_upper_x, left_upper_y), (left_upper_x - umb_radius + 1 * dist_betw_spokes, left_upper_y + umb_length)) draw.aaline(screen, (0, 0, 0), (left_upper_x, left_upper_y), (left_upper_x - umb_radius + 2 * dist_betw_spokes, left_upper_y + umb_length)) draw.aaline(screen, (0, 0, 0), (left_upper_x, left_upper_y), (left_upper_x - umb_radius + 3 * dist_betw_spokes, left_upper_y + umb_length)) draw.aaline(screen, (0, 0, 0), (left_upper_x + width_umb, left_upper_y), (left_upper_x + width_umb + umb_radius - 3 * dist_betw_spokes, left_upper_y + umb_length)) draw.aaline(screen, (0, 0, 0), (left_upper_x + width_umb, left_upper_y), (left_upper_x + width_umb + umb_radius - 2 * dist_betw_spokes, left_upper_y + umb_length)) draw.aaline(screen, (0, 0, 0), (left_upper_x + width_umb, left_upper_y), (left_upper_x + width_umb + umb_radius - 1 * dist_betw_spokes, left_upper_y + umb_length)) draw.aaline(screen, (0, 0, 0), (left_upper_x + width_umb, left_upper_y), (left_upper_x + width_umb, left_upper_y + umb_length)) draw.aaline(screen, (0, 0, 0), (left_upper_x, left_upper_y), (left_upper_x, left_upper_y + umb_length))
def aaline(self, color, start, end, width=1, screen=False): start = start if screen else self._vec2_to_screen(start) end = end if screen else self._vec2_to_screen(end) return draw.aaline(self.surface, color, start, end, width)
def draw_rays(self, start=0): for angulo in range(start, 181, 10): contra = (angulo - 180) + 360 x1, y1 = self.set_xy(angulo) x2, y2 = self.set_xy(contra) draw.aaline(self.image, self.color, (x1, y1), (x2, y2))