def on_draw(self): arcade.start_render() for x in range(len(self.dg_list[0])): for y in range(len(self.dg_list)): if self.dg_list[x][y] == TILE.STAIRS_UP: arcade.draw_rectangle_filled(x * 10, y * 10, 9, 9, arcade.color.RED) if self.dg_list[x][y] == TILE.EMPTY or type( self.dg_list[x][y]) == int: arcade.draw_rectangle_filled(x * 10, y * 10, 9, 9, arcade.color.BLACK) # if type(self.item_list[x][y]) == int: # arcade.draw_rectangle_filled(x*10, y*10, 9, 9, arcade.color.GREEN) if (x, y) in self.path: arcade.draw_point(x * 10, y * 10, arcade.color.RED, 3) if type(self.actor_list[x][y]) == int: arcade.draw_rectangle_filled(x * 10, y * 10, 9, 9, arcade.color.YELLOW) if self.dg_list[x][y] == TILE.STAIRS_DOWN: arcade.draw_rectangle_filled(x * 10, y * 10, 9, 9, arcade.color.BALL_BLUE) if (x, y) == self.bsp.room_center_list[-1]: arcade.draw_rectangle_filled(x * 10, y * 10, 9, 9, arcade.color.BALL_BLUE) arcade.draw_line_strip(self.path2, arcade.color.ANDROID_GREEN, 3)
def on_draw(self): p1 = self.p1 p2 = self.p2 arcade.start_render() arcade.set_viewport(-300, 300, -300, 300) arcade.draw_text("Press arrow keys to push pendulums", -300, 285, arcade.color.BLACK) G_CONST = 9.8 / 100 denom = 2 * p1.mass + p2.mass - p2.mass * math.cos(2 * p1.angle - 2 * p2.angle) accel_1 = (-G_CONST * (2 * p1.mass + p2.mass) * math.sin(p1.angle) - G_CONST * p2.mass * math.sin(p1.angle - 2 * p2.angle) - 2 * math.sin(p1.angle - p2.angle) * p2.mass * (p2.velocity**2 * p2.length + p1.velocity**2 * p1.length * math.cos(p1.angle - p2.angle))) / (denom * p1.length) accel_2 = (2 * math.sin(p1.angle - p2.angle) * (p1.velocity**2 * p1.length * (p1.mass + p2.mass) + G_CONST * (p1.mass + p2.mass) * math.cos(p1.angle) + p2.velocity**2 * p2.length * p2.mass * math.cos(p1.angle - p2.angle))) / ( denom * p2.length) p1.update(accel_1) p2.update(accel_2) path.append((p2.tail_x, p2.tail_y)) for i, point in enumerate(path): color = 255 - int(255 / len(path) * i) arcade.draw_point(*point, (color, color, color), 1) p1.draw() p2.draw()
def draw(self): """ draw function is placeholder for drawing flying object. Each flying object will override this with their own draw function. For now we will draw a dot representing the center of the flying object. """ #draw a dot at the flying object center point, dot is blue and 5px arcade.draw_point(self.center.x, self.center.y, arcade.color.BLUE_SAPPHIRE, 5)
def draw_dresser(): # ------Dresser # Mirror texture8 = arcade.load_texture("images/glass.png") scale = .3 arcade.draw_texture_rectangle(499, 395, scale * texture8.width, scale * texture8.height, texture8, 0) # Foundation arcade.draw_rectangle_filled(580, 250, 70, 150, arcade.color.VIVID_VIOLET) arcade.draw_rectangle_filled(420, 250, 70, 150, arcade.color.VIVID_VIOLET) arcade.draw_rectangle_filled(500, 290, 150, 70, arcade.color.VIVID_VIOLET) # Counter arcade.draw_rectangle_filled(500, 290, 200, 30, arcade.color.BLACK) arcade.draw_rectangle_outline(500, 290, 200, 30, arcade.color.CYBER_GRAPE, 3) # Drawers arcade.draw_rectangle_outline(580, 200, 45, 30, arcade.color.BLACK, 2) arcade.draw_rectangle_outline(420, 200, 45, 30, arcade.color.BLACK, 2) arcade.draw_rectangle_outline(580, 250, 45, 30, arcade.color.BLACK, 2) arcade.draw_rectangle_outline(420, 250, 45, 30, arcade.color.BLACK, 2) # Knobs arcade.draw_point(580, 250, arcade.color.CYBER_GRAPE, 6) arcade.draw_point(580, 200, arcade.color.CYBER_GRAPE, 6) # Mirror Frame texture7 = arcade.load_texture("images/mirror.png") scale = .3 arcade.draw_texture_rectangle(499, 395, scale * texture7.width, scale * texture7.height, texture7, 0)
def on_draw(self): """ Render the screen. """ arcade.start_render() # Draw the y labels i = 0 for y in range(START, END, STEP): arcade.draw_point(0, y, arcade.color.BLUE, 5) arcade.draw_text(f"{y}", 5, y, arcade.color.BLACK, 12, anchor_x="left", anchor_y="bottom") i += 1 # Draw the x labels. i = 1 for x in range(START + STEP, END, STEP): arcade.draw_point(x, 0, arcade.color.BLUE, 5) arcade.draw_text(f"{x}", x, 5, arcade.color.BLACK, 12, anchor_x="left", anchor_y="bottom") i += 1
def draw_beach(x, y): """ Draw the beach """ # Draw a point at x, y for reference arcade.draw_point(x, y, arcade.color.BLUE, 5) # Beach ball arcade.draw_circle_filled(x - 300, 200 - y, 50, arcade.color.ICTERINE)
def draw_cloud(x, y): """Draw clouds anywhere""" arcade.draw_point(x, y, arcade.color.RED, 5) arcade.draw_ellipse_filled(x, 35 + y, 200, 70, arcade.color.GRAY_BLUE) arcade.draw_circle_filled(35 + x, 60 + y, 35, arcade.color.GRAY_BLUE) arcade.draw_ellipse_filled(-10 + x, 85 + y, 75, 130, arcade.color.GRAY_BLUE) arcade.draw_circle_filled(-40 + x, 60 + y, 35, arcade.color.GRAY_BLUE)
def draw(): arcade.start_render() # Draw stuff arcade.draw_rectangle_filled(25,35, PADDLE_WIDTH, PADDLE_HEIGHT, arcade.color.LIME) arcade.draw_rectangle_filled(250,100, PADDLE_WIDTH, PADDLE_HEIGHT, arcade.color.LIME) arcade.draw_point(50,50,arcade.color.GREEN,15) x=arcade.load_texture('paddle.png') arcade.draw_texture_rectangle, 50,50,100,100,2)
def on_draw(self): """ Render the screen. """ # This command should happen before we start drawing. It will clear # the screen to the background color, and erase what we drew last frame arcade.start_render() self.room.background.draw() arcade.draw_rectangle_filled(SCREEN_WIDTH/2, 150/2, SCREEN_WIDTH, 200, arcade.csscolor.BLACK) # Draw inventory squares for i in range(8): for j in range(2): arcade.draw_rectangle_filled( i*80+50, j*80+50, 64, 64, arcade.csscolor.RED) self.inventory_arrows.draw(filter=gl.GL_NEAREST) if DEBUG: for sprite in self.inventory_arrows: sprite.draw_hit_box(color=arcade.csscolor.RED) for sprite in self.level_sprites: sprite.draw(filter=gl.GL_NEAREST) if DEBUG: arcade.draw_point(self.player_sprite.center_x, self.player_sprite.center_y, arcade.csscolor.RED, 5) arcade.draw_point(self.player_sprite.goto_x, self.player_sprite.goto_y, arcade.csscolor.RED, 5) arcade.draw_line(self.player_sprite.center_x, self.player_sprite.center_y, self.player_sprite.goto_x, self.player_sprite.goto_y, arcade.csscolor.RED, 2) self.text_list.draw() arcade.draw_text(self.text, self.text_x, self.text_y, self.text_color, 18, width=200, align="center", anchor_x="center", anchor_y="center") self.current_cursor.draw() if DEBUG: arcade.draw_circle_outline( self.player_sprite.center_x, self.player_sprite.center_y, 200, arcade.csscolor.RED, 2, 30 )
def draw(self): # draw revealed map areas: for shapes_list in self.shapes_lists.values(): shapes_list.draw() for entity in self.drawn_entities: draw_point(*entity) # draw current viewport position on the game map: draw_rectangle_outline(*self.viewport, color=WHITE) draw_rectangle_outline(*self.position, self.width, self.height, RED, 1)
def snowman(x, y, size=1): arcade.draw_circle_filled(x, y, 90 * size, arcade.color.WHITE) arcade.draw_circle_filled(x, y + (70 * size), 60 * size, arcade.color.WHITE) arcade.draw_circle_filled(x, y + 130 * size, 40 * size, arcade.color.WHITE) arcade.draw_point(x + 20 * size, y + 140 * size, (0, 0, 0), 5 * size) arcade.draw_point(x - 20 * size, y + 140 * size, (0, 0, 0), 5 * size) arcade.draw_line(x - 20 * size, y + 130 * size, x + 20 * size, y + 130 * size, (0, 0, 0), 5 * size)
def on_draw(self): arcade.start_render() arcade.draw_texture_rectangle(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2, SCREEN_WIDTH, SCREEN_HEIGHT, self.background) self.player_list.draw() start_y = SCREEN_HEIGHT*8/9 start_x = SCREEN_WIDTH*4/5 arcade.draw_point(start_x, start_y, arcade.color.AMAZON, 5) arcade.draw_text(str(self.score), start_x, start_y, arcade.color.BLACK, 14)
def draw_background(self): color = arcade.color.ANDROID_GREEN for y in range(int(self.tile_size / 2), int(self.height - self.tile_size / 2) + 1, self.tile_size): for x in range(int(self.tile_size / 2), int(self.width - self.tile_size / 2) + 1, self.tile_size): arcade.draw_point(x, y, color, self.tile_size) color = (arcade.color.ANDROID_GREEN if color != arcade.color.ANDROID_GREEN else arcade.color.APPLE_GREEN) color = (arcade.color.ANDROID_GREEN if color != arcade.color.ANDROID_GREEN else arcade.color.APPLE_GREEN)
def draw_snoman(x: object, y: object, snow_color: object, eyes_color: object) -> object: # Draw a snow person arcade.draw_circle_filled(x, 60 + y, 60, snow_color) arcade.draw_circle_filled(x, 140 + y, 50, snow_color) arcade.draw_circle_filled(x, 200 + y, 40, snow_color) # Eyes arcade.draw_circle_filled(x - 15, 210 + y, 5, eyes_color) arcade.draw_circle_filled(x + 15, 210 + y, 5, eyes_color) # Draw a point at x, y for reference arcade.draw_point(x, y, arcade.color.RED, 5)
def on_render_mainmenu(): """ Главное меню """ # Дальше пишем все что будем рисовать # пример рисования смайлика: http://arcade.academy/examples/happy_face.html#happy-face # функции рисования: http://arcade.academy/quick_index.html#drawing-module # сайт фреймворка arcade: http://arcade.academy # Текст start_x = 50 start_y = 450 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("Главное меню", start_x, start_y, arcade.color.BLACK, 40)
def draw_snow_person(x, y): '''Draw a snow person''' #draw a reference point arcade.draw_point(x, y, arcade.color.RED, 5) #snow body arcade.draw_circle_filled(x, 60 + y, 60, arcade.color.WHITE) arcade.draw_circle_filled(x, 140 + y, 50, arcade.color.WHITE) arcade.draw_circle_filled(x, 200 + y, 40, arcade.color.WHITE) #eyes arcade.draw_circle_filled(x - 15, 210 + y, 5, arcade.color.BLACK) arcade.draw_circle_filled(x + 15, 210 + y, 5, arcade.color.BLACK)
def draw_line(line, tasks): x1 = CORE_WIDTH * line.src_core + CORE_WIDTH / 2 y1 = SCREEN_HEIGHT - (CORE_WIDTH + (line.start - 1) * TICK_HEIGHT) x2 = CORE_WIDTH * line.dst_core + CORE_WIDTH / 2 y2 = SCREEN_HEIGHT - (CORE_WIDTH + (line.start + line.weight - 1) * TICK_HEIGHT) ARC.draw_line(x1, y1, x2, y2, ARC.color.RED, 4) ARC.draw_text( str(line.src_task + 1) + "-" + str(line.dst_task + 1), (x1 + x2) / 2, (y1 + y2) / 2, ARC.color.GREEN, 14) ARC.draw_point(x1, y1, ARC.color.BLUE, 6) ARC.draw_point(x2, y2, ARC.color.BLUE, 6)
def draw_snow_person(x, y): # Draw a point at x, y for reference arcade.draw_point(x, y, arcade.color.RED, 5) # Snow arcade.draw_circle_filled(x, 60 + y, 60, arcade.color.WHITE) arcade.draw_circle_filled(x, 140 + y, 50, arcade.color.WHITE) arcade.draw_circle_filled(x, 200 + y, 40, arcade.color.WHITE) # Eyes arcade.draw_circle_filled(x - 15, 210 + y, 5, arcade.color.BLACK) arcade.draw_circle_filled(x + 15, 210 + y, 5, arcade.color.BLACK)
def draw(self, color: Color = BLACK, size: float = 10): """ Draw the point on the screen Args: color: The color of the point size: The size of the point Return: None """ draw_point(self.x, self.y, color, size)
def on_draw(self): """Called whenever we need to draw our window """ # Clear the screen and start drawing arcade.start_render() # Draw a blue arc arcade.draw_arc_filled(100, 100, 40, 40, arcade.color.BLUE, 0, 125) # Draw a red ellipse arcade.draw_ellipse_outline(300, 100, 60, 30, arcade.color.RED, border_width=2) # Draw some purple lines arcade.draw_line(500, 100, 550, 100, arcade.color.PURPLE) arcade.draw_line(500, 90, 550, 90, arcade.color.PURPLE, line_width=2) arcade.draw_line(500, 80, 550, 80, arcade.color.PURPLE, line_width=3) # Draw an orange parabola arcade.draw_parabola_filled(100, 100, 130, 120, arcade.color.ORANGE) # Draw a black point arcade.draw_point(300, 300, arcade.color.BLACK, 20) # Draw a green polygon points_list = [ [500, 300], [550, 300], [575, 325], [550, 350], [525, 340], ] arcade.draw_polygon_outline(points_list, arcade.color.GREEN, line_width=5) # Draw some rectangles arcade.draw_rectangle_filled(100, 500, 150, 75, arcade.color.AZURE) arcade.draw_lrtb_rectangle_filled(150, 250, 575, 525, arcade.color.AMARANTH_PINK) arcade.draw_xywh_rectangle_filled(200, 550, 150, 75, arcade.color.ASPARAGUS) # Draw some triangles arcade.draw_triangle_filled(400, 500, 500, 500, 450, 575, arcade.color.DEEP_RUBY)
def draw_snow_person(x, y): """ Draw a snow person """ # Draw a point at x, y for reference arcade.draw_point(x, y, arcade.color.RED, 5) # Snow arcade.draw_circle_filled(300 + x, 200 + y, 60, arcade.color.WHITE) arcade.draw_circle_filled(300 + x, 280 + y, 50, arcade.color.WHITE) arcade.draw_circle_filled(300 + x, 340 + y, 40, arcade.color.WHITE) # Eyes arcade.draw_circle_filled(285 + x, 350 + y, 5, arcade.color.BLACK) arcade.draw_circle_filled(315 + x, 350 + y, 5, arcade.color.BLACK)
def draw_snow_person(x, y): """ Draw a snow person """ # Draw a point at x, y for reference arcade.draw_point(snow_person_x, y, arcade.color.RED, 5) # Snow arcade.draw_circle_filled(x, 200 + y, 60, arcade.color.RED_DEVIL) arcade.draw_circle_filled(x, 280 + y, 50, arcade.color.WHITE) arcade.draw_circle_filled(x, 340 + y, 40, arcade.color.ROYAL_BLUE) # Eyes arcade.draw_circle_filled(-15 + x, 350 + y, 5, arcade.color.YELLOW) arcade.draw_circle_filled(15 + x, 350 + y, 5, arcade.color.YELLOW)
def draw_snow_person(x, y): """ Draw a snow person """ # Draw a point at x, y for reference arcade.draw_point(x, y, arcade.color.RED, 5) # Snow # (center_x, center_y, radius, color) arcade.draw_circle_filled(x, 60 + y, 60, arcade.color.WHITE) arcade.draw_circle_filled(x, 140 + y, 50, arcade.color.WHITE) arcade.draw_circle_filled(x, 200 + y, 40, arcade.color.WHITE) # Eyes arcade.draw_circle_filled(x - 15, 210 + y, 5, arcade.color.BLACK) arcade.draw_circle_filled(x + 15, 210 + y, 5, arcade.color.BLACK)
def _draw_eyes(self): # left eye arcade.draw_point( self.left_eye_x, self.left_eye_y, arcade.color.BLACK, self.eye_size, ) # right eye arcade.draw_point( self.right_eye_x, self.right_eye_y, arcade.color.BLACK, self.eye_size, )
def main() -> object: arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, "Drawing Example") arcade.set_background_color(DAY) arcade.start_render() # Drawing code goes here # Draw a point at x, y for reference draw_ground(SAND) draw_pine_tree(50, 50) arcade.draw_point(50, 50, arcade.color.RED, 5) # Finish and run arcade.finish_render() arcade.run()
def draw(self): """Draws the spaceship. """ if self.alive: arcade.draw_point(self.position_x, self.position_y + 20, arcade.color.BLACK, 5) texture = arcade.load_texture("images/spaceShips_008.png") scale = .5 arcade.draw_texture_rectangle(self.position_x, self.position_y + 20, scale * texture.width, scale * texture.height, texture, 0)
def draw(self): for i in range(self.x_size): for j in range(self.y_size): potential = 0 for charge in self.charges: dist = math.sqrt((charge.x - i)**2 + (charge.y - j)**2 + charge.z**2) if dist == 0: potential = 0 break potential += self.pot_factor * charge.charge / (math.sqrt((charge.x - i)**2 + (charge.y - j)**2)) if potential > 0: arcade.draw_point(float(i), float(j), [abs(int(potential) % 256), 0, 0], 1.0) else: arcade.draw_point(float(i), float(j), [0, 0, abs(int(potential) % 256)], 1.0) # arcade.finish_render() self.factor_changed = False
def on_draw(self): arcade.start_render() for ball in self.ball_list: ball.draw() for wall in self.wall_list[4:]: wall.draw() arcade.draw_point(self.source.x, self.source.y, arcade.color.CAROLINA_BLUE, 10) output = "Pulse frequency: {}".format(str(self.freq) + " Hz") arcade.draw_text(output, 10, 20, arcade.color.WHITE, 14)
def on_key_press(self, key, key_modifiers): """ Called whenever a key on the keyboard is pressed. For a full list of keys, see: http://pythonhosted.org/arcade/arcade.key.html """ # See if the user hit Shift-Space # (Key modifiers are in powers of two, so you can detect multiple # modifiers by using a bit-wise 'and'.) if key == arcade.key.SPACE and key_modifiers == arcade.key.MOD_SHIFT: print("You pressed shift-space") # See if the user just hit space. elif key == arcade.key.SPACE: arcade.draw_point(100, 100, arcade.color.RED, 1000) print("You pressed the space bar.")
def on_draw(self): """ Render the screen. """ # This command should happen before we start drawing. It will clear # the screen to the background color, and erase what we drew last frame. arcade.start_render() # start_x and start_y make the start point for the text. # We draw a dot to make it easy too see # the text in relation to its start x and y. start_x = 50 start_y = 450 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text(_("Simple line of text in 12 point"), start_x, start_y, arcade.color.BLACK, 12)
# Start the render process. This must be done before any drawing commands. arcade.start_render() # Draw a grid # Draw vertical lines every 120 pixels for x in range(0, 601, 120): arcade.draw_line(x, 0, x, 600, arcade.color.WHITE, 2) # Draw horizontal lines every 200 pixels for y in range(0, 601, 200): arcade.draw_line(0, y, 800, y, arcade.color.WHITE, 2) # Draw a point arcade.draw_text("draw_point", 7, 405, arcade.color.WHITE, 12) arcade.draw_point(60, 495, arcade.color.RED, 10) # Draw a set of points arcade.draw_text("draw_points", 133, 405, arcade.color.WHITE, 12) point_list = ((165, 495), (165, 480), (165, 465), (195, 495), (195, 480), (195, 465)) arcade.draw_points(point_list, arcade.color.ZAFFRE, 10) # Draw a line arcade.draw_text("draw_line", 243, 405, arcade.color.WHITE, 12) arcade.draw_line(270, 495, 300, 450, arcade.color.BURNT_ORANGE, 3)
def on_draw(self): """ Render the screen. """ # This command should happen before we start drawing. It will clear # the screen to the background color, and erase what we drew last frame. arcade.start_render() # start_x and start_y make the start point for the text. We draw a dot to make it easy too see # the text in relation to its start x and y. start_x = 50 start_y = 450 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("Simple line of text in 12 point", start_x, start_y, arcade.color.BLACK, 12) start_x = 50 start_y = 400 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("Text anchored 'top' and 'left'.", start_x, start_y, arcade.color.BLACK, 12, anchor_x="left", anchor_y="top") start_y = 350 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("14 point multi\nline\ntext", start_x, start_y, arcade.color.BLACK, 14, anchor_y="top") start_y = 450 start_x = 300 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("Set of text\nthat\nis centered.", start_x, start_y, arcade.color.BLACK, 14, width=200, align="center", anchor_y="top") start_y = 250 start_x = 300 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("Text centered on\na point", start_x, start_y, arcade.color.BLACK, 14, width=200, align="center", anchor_x="center", anchor_y="center") start_y = 150 start_x = 300 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("Text rotated on\na point", start_x, start_y, arcade.color.BLACK, 14, width=200, align="center", anchor_x="center", anchor_y="center", rotation=self.text_angle) start_y = 150 start_x = 20 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("Sidewarys text", start_x, start_y, arcade.color.BLACK, 14, width=200, align="center", anchor_x="center", anchor_y="center", rotation=90.0) start_y = 20 start_x = 50 arcade.draw_point(start_x, start_y, arcade.color.BLUE, 5) arcade.draw_text("Time elapsed: {:5.1f}".format(self.time_elapsed), start_x, start_y, arcade.color.BLACK, 14)