def trees(a, b): # The Bark of the Tree : arcade.draw_rectangle_filled(a, b, 20, 40, arcade.color.BROWN) # Drawing the Top of the Tree : line = b + 20 list = ((a - 40, line), (a, line + 100), (a + 40, line)) arcade.draw_polygon_filled(list, arcade.color.DARK_GREEN)
def fill_oval(self, loc_x, loc_y, color): arc_width = 30 arc_height = 30 line_height = 65 top_arc_y = loc_y + line_height / 2 bottom_arc_y = loc_y - line_height / 2 left_line_x = loc_x - arc_width right_line_x = loc_x + arc_width point_list = ( (left_line_x, top_arc_y), (left_line_x, bottom_arc_y), (right_line_x, bottom_arc_y), (right_line_x, top_arc_y) ) arcade.draw_arc_filled(loc_x, top_arc_y, arc_width, arc_height, color, 0, 180) arcade.draw_arc_filled(loc_x, bottom_arc_y, arc_width, arc_height, color, 180, 360) arcade.draw_polygon_filled(point_list, color)
def draw_fish(x, y): """Function to draw a moderately large white fish with a pink belly at a specific point""" arcade.draw_polygon_filled([[x, y], [x + 55, y + 30], [x + 80, y], [x + 55, y - 30]], arcade.color.WHITE_SMOKE) arcade.draw_ellipse_filled(x + 65, y + 10, 10, 5, arcade.color.BLACK) arcade.draw_triangle_filled(x, y, x + 80, y, x + 55, y - 30, arcade.color.PINK) arcade.draw_triangle_filled(x, y, x - 20, y + 30, x - 20, y - 30, arcade.color.WHITE_SMOKE) arcade.draw_ellipse_filled(x + 40, y, 30, 10, arcade.color.BLUEBERRY)
def hp_bar(self): color = arcade.color.PANSY_PURPLE if self.world.player.element == 0: color = arcade.color.FIRE_ENGINE_RED elif self.world.player.element == 1: color = arcade.color.OCEAN_BOAT_BLUE elif self.world.player.element == 2: color = arcade.color.WINDSOR_TAN elif self.world.player.element == 3: color = arcade.color.SHEEN_GREEN if self.world.player.health >= (1000 / 11): arcade.draw_polygon_filled( [[75, SCREEN_HEIGHT - 25], [75 + (self.world.player.health) * 2.75, SCREEN_HEIGHT - 25], [ 75 + (self.world.player.health) * 2.75, SCREEN_HEIGHT - (25 + (275 - (self.world.player.health) * 2.75)) ], [325, SCREEN_HEIGHT - 50], [75, SCREEN_HEIGHT - 50]], color) self.draw_number(f'{self.world.player.health:.0f}' + '/100', 90, SCREEN_HEIGHT - 45) elif 0 < self.world.player.health < (1000 / 11): arcade.draw_polygon_filled( [[75, SCREEN_HEIGHT - 25], [75 + (self.world.player.health) * 2.75, SCREEN_HEIGHT - 25], [75 + (self.world.player.health) * 2.75, SCREEN_HEIGHT - 50], [75, SCREEN_HEIGHT - 50]], color) self.draw_number(f'{self.world.player.health:.0f}' + '/100', 90, SCREEN_HEIGHT - 45) else: self.draw_number('0/100', 90, SCREEN_HEIGHT - 45)
def Flowerpot(x, y): arcade.draw_lrtb_rectangle_filled(x, x + 400, y + 20, y - 50, arcade.color.BROWN) arcade.draw_polygon_filled([[x + 100, y - 250], [x + 50, y - 50], [x + 350, y - 50], [x + 300, y - 250]], arcade.color.BROWN) arcade.draw_line(x, y - 50, x + 400, y - 50, arcade.color.BLACK, 2)
def on_draw(self): arcade.start_render() for i in range(-self.HALF_RANGE, self.HALF_RANGE + 1): for j in range(-self.HALF_RANGE, self.HALF_RANGE + 1): tile = (i, j) if tile in self.tiles: isWhite = self.tiles[tile][0] else: isWhite = True if isWhite: color = arcade.color.WHITE else: color = arcade.color.BLACK centerY = 3 / 4 * self.h * j if j % 2 == 0: centerX = self.w * i else: centerX = self.w * i + 1 / 2 * self.w point_list = ((centerX, centerY + self.h / 2), (centerX + self.w / 2, centerY + 1 / 4 * self.h), (centerX + self.w / 2, centerY - 1 / 4 * self.h), (centerX, centerY - self.h / 2), (centerX - self.w / 2, centerY - 1 / 4 * self.h), (centerX - self.w / 2, centerY + 1 / 4 * self.h)) arcade.draw_polygon_filled(point_list, color)
def tree(x, y): # draws a lil tree tree = [[x, y], [x + 6, y + 10], [x + 3, y + 10], [x + 10, y + 20], [x + 17, y + 10], [x + 14, y + 10], [x + 20, y]] arcade.draw_polygon_filled(tree, (18, 77, 18))
def on_draw(self): self.clear() self.camera.use() # Charm BG self.small_logos_forward.draw() self.small_logos_backward.draw() arcade.draw_polygon_filled( [(self.welcome_label.x - self.welcome_label._label.content_width // 2, self.welcome_label._label.content_height + 10), (self.welcome_label.x - self.welcome_label._label.content_width // 2 + self.welcome_label._label.content_width, self.welcome_label._label.content_height + 10), (self.welcome_label.x - self.welcome_label._label.content_width // 2 + self.welcome_label._label.content_width + 20, 0), (self.welcome_label.x - self.welcome_label._label.content_width // 2 - 20, 0)], CharmColors.FADED_PURPLE ) self.welcome_label.draw() # Logo and text self.main_sprites.draw() with self.window.ctx.pyglet_rendering(): self.splash_label.draw() self.song_label.draw() if self.hit_start is None: if int(self.local_time) % 2: self.press_label.draw() else: if int(self.local_time * 8) % 2: self.press_label.draw() super().on_draw()
def _draw_background(self): left, right, bottom, top = self.viewport # width, height = self.window_size[0] // 12, self.window_size[1] // 10 width, height = 90, 50 point_list = ( (right, top), (right - width, top), (right - width, top - height), (right, top - height), ) arcade.draw_polygon_filled(point_list, self.colour) # width, height = self.window_size[0] / 7, self.window_size[1] // 8 width, height = 160, 60 point_list = ( (left, top), (left + width, top), (left + width, top - height), (left, top - height), ) arcade.draw_polygon_filled(point_list, self.colour)
def on_draw(self): arcade.start_render() self.player.draw_player() arcade.draw_polygon_filled(point_list, arcade.color.BLACK) arcade.draw_rectangle_filled(430, 250, 20, 300, arcade.color.BLACK) arcade.draw_polygon_filled(point_list2, arcade.color.BLACK) arcade.draw_rectangle_filled(190, 40, 20, 80, arcade.color.BLACK)
def _render_obstacles(viewport: Viewport, frame: Frame) -> None: for agent in frame.agents: # color = AGENT_COLORS[agent.track_id % len(AGENT_COLORS)] color = AGENT_COLORS[hash(agent.track_id) % len(AGENT_COLORS)] position = agent.position if agent.extent is not None and agent.yaw is not None: half_extent = 0.5 * agent.extent sin_theta = math.sin(agent.yaw) cos_theta = math.cos(agent.yaw) rot = np.array([[cos_theta, -sin_theta], [sin_theta, cos_theta]]) offsets = [ half_extent * np.array([1, 1]), half_extent * np.array([1.2, 0]), half_extent * np.array([1, 1]), half_extent * np.array([1, -1]), half_extent * np.array([-1, -1]), half_extent * np.array([-1, 1]), ] ps = [position + rot.dot(o) for o in offsets] ps = viewport.project(ps) arcade.draw_polygon_filled(ps, color) else: position = viewport.project([position])[0] arcade.draw_circle_filled(*position, 5, color=color)
def draw_flammer(): '''tegner flammerne''' global flammer_x global flammer_y flammer_x = random.randint(-30, 30) flammer_y = random.randint(-20, 20) point_list = ((220, 435), (125 + flammer_x, 485), (165 + flammer_x, 440), (50 + flammer_x, 510), (100 + flammer_x, 450), (10 + flammer_x, 435), (100 + flammer_x, 420), (50 + flammer_x, 360), (165 + flammer_x, 430), (125 + flammer_x, 385)) arcade.draw_polygon_filled(point_list, arcade.color.ORANGE) point_list = ((200 + flammer_x, 435), (115 + flammer_x, 475), (155 + flammer_x, 440), (35 + flammer_x, 475), (90 + flammer_x, 435), (35 + flammer_x, 395), (155 + flammer_x, 430), (115 + flammer_x, 395)) arcade.draw_polygon_filled(point_list, arcade.color.RED) point_list = ((180 + flammer_x, 435), (90 + flammer_x, 475), (120 + flammer_x, 435), (90 + flammer_x, 395)) arcade.draw_polygon_filled(point_list, arcade.color.AMBER) point_list = ((160 + flammer_x, 435), (80 + flammer_x, 455), (115 + flammer_x, 435), (80 + flammer_x, 415)) arcade.draw_polygon_filled(point_list, arcade.color.ORANGE) point_list = ((150 + flammer_x, 435), (110 + flammer_x, 445), (130 + flammer_x, 435), (110 + flammer_x, 425)) arcade.draw_polygon_filled(point_list, arcade.color.RED)
def _draw_background(self, top, right): background_width, background_height = 200, 75 point_list = ( (right, top), (right - background_width, top), (right - background_width, top - background_height), (right, top - background_height - (background_height // 3)), ) arcade.draw_polygon_filled(point_list, self.colour)
def on_draw(self): """ Render the screen. """ for i in self.city: arcade.draw_polygon_filled(i, arcade.color.WHITE) minumum = self.DSO.optimaze(1) for i in getCircles(minumum): arcade.draw_polygon_filled(i, (255, 0, 0, 30))
def draw_boat(x, y): arcade.draw_polygon_filled([ [400 + x , 130 + y], [420 + x, 100 + y], [470 + x, 100 + y], [490 + x, 130 + y]], arcade.color.COFFEE ) arcade.draw_line(445 + x, 130 + y, 445 + x, 190 + y, arcade.color.BLACK_OLIVE ) arcade.draw_arc_filled(445 + x, 135 + y, 35, 55, arcade.color.BABY_POWDER, 0, 90, 0, 128)
def draw(self): pospoints = mine.hitbox(self, x=self.xpos, y=self.ypos) if self.dangerous: arcade.draw_polygon_filled(pospoints, arcade.color.ALIZARIN_CRIMSON) else: arcade.draw_polygon_filled(pospoints, arcade.color.BANANA_YELLOW)
def draw_ground(): """Draw the Ground and River""" arcade.draw_lrtb_rectangle_filled(0, 500, 250, 0, arcade.color.AO) arcade.draw_polygon_filled(( (150, 250), (350, 250), (325, 0), (175, 0), ), arcade.color.BLUE_SAPPHIRE)
def house(x, y, color): # draws a lil house house = [[x, y], [x, y + 10], [x + 6, y + 15], [x + 12, y + 10], [x + 12, y]] arcade.draw_polygon_filled(house, color) # and windows arcade.draw_rectangle_filled(x + 3, y + 5, 2, 4, arcade.color.CORNSILK, 0) arcade.draw_rectangle_filled(x + 9, y + 5, 2, 4, arcade.color.CORNSILK, 0)
def draw_earth(): # Draw earth below the spaceship # show diferent layers of colors in the atmosphere arcade.draw_arc_filled(300, 0, 600, 180, (42, 108, 140), 0, 215, -10) arcade.draw_arc_filled(300, 0, 600, 165, (58, 139, 166), 0, 215, -10) # Show body of land on earth point_list = ((0, 0), (0, 100), (40, 120), (80, 130), (110, 140), (150, 150), (180, 140), (230, 150), (300, 140), (380, 135), (430, 90), (450, 70), (600, 0)) arcade.draw_polygon_filled(point_list, (117, 161, 125))
def draw_polygon(poly: Polygon, fill: bool = True, edge_color: tuple = POLYGON_EDGE_COLOR, fill_color: tuple = POLYGON_FILL_COLOR): """ Draws given polygon. """ if fill: arcade.draw_polygon_filled(poly.points, color=fill_color) arcade.draw_polygon_outline(poly.points, color=edge_color) for p in poly.points: draw_point(p, color=edge_color)
def tree_three(): # Draw a tree using a polygon with a list of points arcade.draw_rectangle_filled(500, 320, 20, 60, arcade.csscolor.SIENNA) arcade.draw_polygon_filled(((500, 400), (480, 360), (470, 320), (530, 320), (520, 360) ), arcade.csscolor.DARK_GREEN)
def draw_star(center_x, center_y, inner_radio, outer_radio, color, rotation=0): point_list = [] for i in range(5): point_list.append((center_x + inner_radio * sin(rotation), center_y + inner_radio * cos(rotation))) rotation += pi / 5 point_list.append((center_x + outer_radio * sin(rotation), center_y + outer_radio * cos(rotation))) rotation += pi / 5 arcade.draw_polygon_filled(point_list, color)
def draw_pine_tree(center_x, center_y): arcade.draw_rectangle_filled(center_x, center_y, 20, 40, arcade.color.DARK_BROWN) tree_bottom_y = center_y + 20 point_list = ((center_x - 40, tree_bottom_y), (center_x, tree_bottom_y + 100), (center_x + 40, tree_bottom_y)) arcade.draw_polygon_filled(point_list, arcade.color.DARK_GREEN)
def on_draw(self): arcade.start_render() for rocket in self.rocket_list: tip_list = ((rocket.x - 25, rocket.y + 50), (rocket.x, rocket.y + 75), (rocket.x + 25, rocket.y + 50)) arcade.draw_rectangle_filled(rocket.x, rocket.y, 50, 100, arcade.color.WHITE) arcade.draw_polygon_filled(tip_list, arcade.color.WHITE) for fire in self.fire_list: arcade.draw_circle_filled(rocket.x, fire.y - 50, fire.size, fire.color)
def draw_valley(): point_list = ((0, 400), (0, 0), (150, 0), ( 100, 400, )) arcade.draw_polygon_filled(point_list, arcade.color.GREEN) point_list = ( (800, 400), (800, 0), (650, 0), (700, 400), ) arcade.draw_polygon_filled(point_list, arcade.color.GREEN)
def draw_pine_tree(x, y): """ This function draws a pine tree at the specified location. """ # Draw the trunk arcade.draw_rectangle_filled(x + 30, y - 100, 20, 40, arcade.color.DARK_BROWN) # Draw the triangle on top of the trunk point_list = ((x + 40, y), (x, y - 100), (x + 80, y - 100)) arcade.draw_polygon_filled(point_list, arcade.color.DARK_GREEN)
def draw_house(x, y): arcade.draw_lrtb_rectangle_filled(x + 10, x + 210, y + 100, y, arcade.color.BROWN) #roof arcade.draw_polygon_filled([[x - 40, y + 100], [x + 10, y + 200], [x + 210, y + 200], [x + 260, y + 100]], arcade.color.RED) arcade.draw_arc_outline(x + 20, y + 200, 10, 10, (219, 199, 83), 180, 360) arcade.draw_arc_outline(x + 40, y + 200, 10, 10, (219, 199, 83), 180, 360) arcade.draw_arc_outline(x + 60, y + 200, 10, 10, (219, 199, 83), 180, 360) arcade.draw_arc_outline(x + 80, y + 200, 10, 10, (219, 199, 83), 180, 360) arcade.draw_arc_outline(x + 100, y + 200, 10, 10, (219, 199, 83), 180, 360) arcade.draw_arc_outline(x + 120, y + 200, 10, 10, (219, 199, 83), 180, 360) arcade.draw_arc_outline(x + 140, y + 200, 10, 10, (219, 199, 83), 180, 360) arcade.draw_arc_outline(x + 160, y + 200, 10, 10, (219, 199, 83), 180, 360) arcade.draw_arc_outline(x + 180, y + 200, 10, 10, (219, 199, 83), 180, 360) arcade.draw_arc_outline(x + 200, y + 200, 10, 10, (219, 199, 83), 180, 360) #Chimney arcade.draw_lrtb_rectangle_filled(x + 190, x + 210, y + 250, y + 200, arcade.color.BROWN) arcade.draw_line(x + 10, y, x + 210, y, arcade.color.BISQUE, 5) #left top window arcade.draw_rectangle_filled(x + 50, y + 150, 40, 40, arcade.color.BLACK) arcade.draw_rectangle_filled(x + 50, y + 150, 35, 35, arcade.color.SKY_BLUE) arcade.draw_line(x + 50, y + 132, x + 50, y + 168, arcade.color.BISQUE, 2) arcade.draw_line(x + 30, y + 125, x + 70, y + 125, arcade.color.BISQUE, 10) #right top window arcade.draw_rectangle_filled(x + 170, y + 150, 40, 40, arcade.color.BLACK) arcade.draw_rectangle_filled(x + 170, y + 150, 35, 35, arcade.color.SKY_BLUE) arcade.draw_line(x + 170, y + 132, x + 170, y + 168, arcade.color.BISQUE, 2) arcade.draw_line(x + 150, y + 125, x + 190, y + 125, arcade.color.BISQUE, 10) #right bottom window arcade.draw_rectangle_filled(x + 150, y + 50, 40, 40, arcade.color.BLACK) arcade.draw_rectangle_filled(x + 150, y + 50, 35, 35, arcade.color.SKY_BLUE) arcade.draw_line(x + 150, y + 32, x + 150, y + 68, arcade.color.BISQUE, 2) arcade.draw_line(x + 130, y + 25, x + 170, y + 25, arcade.color.BISQUE, 10) #door arcade.draw_lrtb_rectangle_filled(x + 30, x + 80, y + 70, y + 5, (100, 88, 17)) arcade.draw_rectangle_outline(x + 45, y + 53, 15, 23, arcade.color.BONE, 1) arcade.draw_rectangle_outline(x + 65, y + 53, 15, 23, arcade.color.BONE, 1) arcade.draw_rectangle_outline(x + 45, y + 20, 15, 23, arcade.color.BONE, 1) arcade.draw_rectangle_outline(x + 65, y + 20, 15, 23, arcade.color.BONE, 1) arcade.draw_circle_filled(x + 35, y + 35, 3, arcade.color.BLACK)
def draw(self): self.update() point_list = [] rotation = self.rotation for i in range(5): point_list.append( (self.center_x + self.outer_radio * sin(rotation), self.center_y + self.outer_radio * cos(rotation))) rotation += pi / 5 point_list.append( (self.center_x + self.inner_radio * sin(rotation), self.center_y + self.inner_radio * cos(rotation))) rotation += pi / 5 arcade.draw_polygon_filled(point_list, self.color)
def on_draw(self): """ Render the screen. """ # return arcade.start_render() # Clear screen if not self.draw: return self.car.draw() for o in self._world: arcade.draw_polygon_filled(o, arcade.color.BLUE) arcade.draw_text(str(self._steps), 10, SCREEN_HEIGHT - 20, arcade.color.WHITE) arcade.draw_text(str(self.cum_reward), 10, SCREEN_HEIGHT - 40, arcade.color.WHITE)
def spoceship(): arcade.draw_rectangle_filled(400, 200, 200, 100, arcade.color.RED) arcade.draw_triangle_filled(400, 250, 250, 350, 300, 250, arcade.color.DARK_RED) arcade.draw_triangle_filled(400, 150, 250, 50, 300, 150, arcade.color.DARK_RED) arcade.draw_triangle_filled(500, 250, 600, 200, 500, 150, arcade.color.BLUE_SAPPHIRE) arcade.draw_circle_filled(450, 200, 40, arcade.color.WHITE, 1) arcade.draw_circle_filled(450, 200, 25, arcade.color.AQUA, 1) fire_inside_point_list = ((300, 250), (250, 225), (270, 210), (240, 200), (260, 185), (275, 175), (280, 165), (260, 155), (300, 150)) arcade.draw_polygon_filled(fire_inside_point_list, arcade.color.YELLOW)
def draw_windows(): arcade.draw_polygon_filled(( (280, 360), (355, 360), (345, 380), (280, 380), ), arcade.csscolor.LIGHT_SKY_BLUE) arcade.draw_polygon_filled(( (245, 360), (270, 360), (270, 380), (255, 380), ), arcade.csscolor.LIGHT_SKY_BLUE)
def draw_pine_tree(center_x, center_y): """ This function draws a pine tree at the specified location. Args: :center_x: x position of the tree center. :center_y: y position of the tree trunk center. """ # Draw the trunkcenter_x arcade.draw_rectangle_filled(center_x, center_y, 20, 40, arcade.color.DARK_BROWN) tree_bottom_y = center_y + 20 # Draw the triangle on top of the trunk point_list = ((center_x - 40, tree_bottom_y), (center_x, tree_bottom_y + 100), (center_x + 40, tree_bottom_y)) arcade.draw_polygon_filled(point_list, arcade.color.DARK_GREEN)
(45, 240), (60, 255), (60, 285), (45, 300), (30, 300)) arcade.draw_polygon_outline(point_list, arcade.color.SPANISH_VIOLET, 3) # Draw a filled in polygon arcade.draw_text("draw_polygon_filled", 123, 207, arcade.color.WHITE, 9) point_list = ((150, 240), (165, 240), (180, 255), (180, 285), (165, 300), (150, 300)) arcade.draw_polygon_filled(point_list, arcade.color.SPANISH_VIOLET) # Draw an outline of a circle arcade.draw_text("draw_circle_outline", 243, 207, arcade.color.WHITE, 10) arcade.draw_circle_outline(300, 285, 18, arcade.color.WISTERIA, 3) # Draw a filled in circle arcade.draw_text("draw_circle_filled", 363, 207, arcade.color.WHITE, 10) arcade.draw_circle_filled(420, 285, 18, arcade.color.GREEN) # Draw an ellipse outline, and another one rotated arcade.draw_text("draw_ellipse_outline", 483, 207, arcade.color.WHITE, 10) arcade.draw_ellipse_outline(540, 273, 15, 36, arcade.color.AMBER, 3) arcade.draw_ellipse_outline(540, 336, 15, 36, arcade.color.BLACK_BEAN, 3, 45)