def on_draw(self): """ Render the screen. """ # This command has to happen before we start drawing arcade.start_render() # Start timing how long this takes draw_start_time = timeit.default_timer() # Draw all the sprites self.sprite_list.draw() # Draw the lines that aren't sprites for line in self.static_lines: body = line.body pv1 = body.position + line.a.rotated(body.angle) pv2 = body.position + line.b.rotated(body.angle) arcade.draw_line(pv1.x, pv1.y, pv2.x, pv2.y, arcade.color.WHITE, 2) # Display timings draw_time = timeit.default_timer() - draw_start_time arcade.draw_text("Processing time: {:.3f}".format(self.time), 20, SCREEN_HEIGHT - 20, arcade.color.BLACK, 12) arcade.draw_text("Drawing time: {:.3f}".format(draw_time), 20, SCREEN_HEIGHT - 40, arcade.color.BLACK, 12)
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(self): if game.middle_pull: arcade.draw_line(held.wid_th, held.hei_ght, self.x, self.y, (60, 60, 60)) arcade.draw_rectangle_filled(self.x, self.y, 25, 25, self.colour) arcade.draw_text("Points ye boi: {}".format(round(self.wincount)), 50, held.hei_ght - 50 - self.text_mod_y, self.colour) if self.crown: draw_crown(self.x, self.y, self)
def draw(self): x, y = self.output.get_position() x1, y1 = self.input.get_position() #draw_list = imgui.get_overlay_draw_list() #draw_list.add_line(x,y,x1,y1, imgui.get_color_u32_rgba(1,1,1,1), 1) wh = arcade.get_window().height y = wh - y y1 = wh - y1 arcade.draw_line(x, y, x1, y1, (arcade.color.WHITE))
def draw_sunlight(center_x, center_y, inner_radio, outer_radio, n_lines=20): rotation = 0 for i in range(n_lines): inner_x = center_x + inner_radio * cos(rotation) inner_y = center_y + inner_radio * sin(rotation) outer_x = center_x + outer_radio * cos(rotation) outer_y = center_y + outer_radio * sin(rotation) arcade.draw_line(inner_x, inner_y, outer_x, outer_y, arcade.color.ORANGE, 2) rotation += pi * 2 / n_lines
def _drawHelpText(self): draw_line(start_x=10, end_x=SCREEN_WIDTH - (2 * X_MARGIN), start_y=HELP_SEPARATOR_Y, end_y=HELP_SEPARATOR_Y, color=color.YELLOW, line_width=1) draw_text( f'Q: `Quit` 1-9: `Update Time` C: `Kill Commanders` A: `Reset`', 10, HELP_Y, color.YELLOW)
def dibujo_camello(x, y): """ Dibujo camello """ arcade.draw_line(x + 10, 235, x + 30, 215, arcade.color.BLACK, 4) arcade.draw_line(x - 10, 235, x - 30, 215, arcade.color.BLACK, 4) arcade.draw_ellipse_filled(x, 250, 70, 40, arcade.csscolor.SANDY_BROWN) # cuerpo arcade.draw_circle_filled(x + 30, 270, 15, arcade.csscolor.SANDY_BROWN) # cabeza arcade.draw_circle_filled(x + 25, 280, 2, arcade.csscolor.BLACK) arcade.draw_circle_filled(x + 40, 280, 2, arcade.csscolor.BLACK)
def initializeGrid(self): for i in range(SIZE_OF_GRID + 1): #x-axis arcade.draw_line(MARGIN + CELL_SIZE * i, MARGIN, CELL_SIZE * i + MARGIN, SCREEN_HEIGHT - MARGIN, arcade.color.BUBBLES, 3) #y-axis arcade.draw_line(MARGIN, MARGIN + CELL_SIZE * i, SCREEN_WIDTH - MARGIN, CELL_SIZE * i + MARGIN, arcade.color.BUBBLES, 3)
def on_draw(self): arcade.start_render() output = "test" size = 60 arcade.draw_rectangle_filled(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2, 60 * len(output), 60, arcade.color.GREEN) arcade.draw_text(output, SCREEN_WIDTH // 2 - size / 4 * len(output), SCREEN_HEIGHT // 2 - size / 2, arcade.color.BRICK_RED, 60) arcade.draw_line(0, 0, 60, 60, arcade.color.BRICK_RED, 2)
def on_draw(self): """Draw textures.""" if self.position > self.width: self.position = self.width elif self.position < 0: self.position = 0 arcade.draw_line(self.left, self.center_y, self.right, self.center_y, (255, 255, 255), 10) self.textures[self.state].draw_scaled(self.left + self.position, self.center_y)
def draw_tulip(x, y): """Draws a flower that resembles a tulip""" arcade.draw_line(x, y, x, y - 50, arcade.csscolor.LIME_GREEN, 3) arcade.draw_ellipse_filled(x + 10, y - 40, 20, 5, arcade.csscolor.LIME_GREEN, 150) arcade.draw_ellipse_filled(x, y, 40, 20, arcade.csscolor.ORCHID, 90) arcade.draw_ellipse_filled(x - 10, y - 5, 40, 20, arcade.csscolor.ORCHID, 30) arcade.draw_ellipse_filled(x + 10, y - 5, 40, 20, arcade.csscolor.ORCHID, 150)
def on_draw(self): arcade.start_render() for shape in space.shapes: if isinstance(shape, pymunk.Circle): pos = shape.body.position r = shape.radius arcade.draw_circle_outline(pos.x, pos.y, r, arcade.color.WHITE) if isinstance(shape, pymunk.Segment): # pymunk.Segment a, b = shape.a, shape.b arcade.draw_line(a.x, a.y, b.x, b.y, arcade.color.WHITE)
def draw(self): arcade.draw_line(self.x1, self.y1, self.x2, self.y2, color=arcade.color.BLACK, border_width=self.line_width) arcade.draw_text(str(int(self.len)), self.label_x, self.label_y, color=arcade.color.RED)
def prevention_techniques(): # RECTANGLE AND OUTLINE arcade.draw_lrtb_rectangle_filled(425, 700, 375, 275, arcade.color.YELLOW) arcade.draw_line(425, 375, 425, 275, arcade.color.DARK_YELLOW, 4) arcade.draw_line(425, 375, 700, 375, arcade.color.DARK_YELLOW, 4) arcade.draw_line(425, 275, 700, 275, arcade.color.DARK_YELLOW, 4) arcade.draw_line(700, 375, 700, 275, arcade.color.DARK_YELLOW, 4) # TEXT AND UNDERLINE arcade.draw_text("Prevention Techniques", 440, 315, arcade.color.DARK_YELLOW, 20, bold=True) arcade.draw_line(440, 310, 680, 310, arcade.color.DARK_YELLOW, 4) # ARROWS arrow_custom = arcade.load_texture("textures/arrow_custom.png") arcade.draw_texture_rectangle(400, 250, 0.8 * arrow_custom.width, 0.8 * arrow_custom.height, arrow_custom) arcade.draw_texture_rectangle(400, 200, 0.8 * arrow_custom.width, 0.8 * arrow_custom.height, arrow_custom) arcade.draw_texture_rectangle(400, 150, 0.8 * arrow_custom.width, 0.8 * arrow_custom.height, arrow_custom) # BULLET POINT AND TEXT 1 arcade.draw_circle_filled(450, 255, 5, arcade.color.DARK_YELLOW) arcade.draw_text( "Avoid sketchy or unreliable websites, \nlinks, or unauthorized programs.", 460, 235, arcade.color.BLACK, 14) # BULLET POINT AND TEXT 2 arcade.draw_circle_filled(450, 205, 5, arcade.color.DARK_YELLOW) arcade.draw_text("Regularly update device!", 460, 198, arcade.color.BLACK, 14) # BULLET POINT AND TEXT 3 arcade.draw_circle_filled(450, 155, 5, arcade.color.DARK_YELLOW) arcade.draw_text("Invest in or download antiviruses \nfor your computer.", 460, 140, arcade.color.BLACK, 14) # SUMMARY arcade.draw_text( "At the end, it all comes down to \nmaking SMART choices everyday!", 350, 50, arcade.color.BLACK, 24, align="center", bold=True) star_custom = arcade.load_texture("textures/star_custom.png") arcade.draw_texture_rectangle(310, 80, 0.8 * star_custom.width, 0.8 * star_custom.height, star_custom)
def draw_church(x, y): arcade.draw_lrtb_rectangle_filled(x, x + 200, y + 200, y, (171, 105, 53)) arcade.draw_triangle_filled(x + 100, y + 350, x, y + 200, x + 200, y + 200, (255, 0, 0)) arcade.draw_lrtb_rectangle_filled(x + 95, x + 105, y + 400, y + 340, (197, 178, 141)) arcade.draw_lrtb_rectangle_filled(x + 80, x + 120, y + 380, y + 375, (197, 178, 141)) arcade.draw_lrtb_rectangle_filled(x + 50, x + 150, y + 150, y, (38, 254, 34)) arcade.draw_line(x + 100, y, x + 100, y + 150, arcade.color.WOOD_BROWN, 2)
def draw_daisy(x, y): """Draws a flower that looks like a daisy""" arcade.draw_line(x, y, x, y - 40, arcade.csscolor.LIME_GREEN, 4) arcade.draw_ellipse_filled(x + 4, y - 35, 20, 5, arcade.csscolor.LIME_GREEN, 120) arcade.draw_ellipse_filled(x - 4, y - 35, 20, 5, arcade.csscolor.LIME_GREEN, 60) arcade.draw_ellipse_filled(x, y, 50, 20, arcade.csscolor.WHITE, 90) arcade.draw_ellipse_filled(x, y, 50, 20, arcade.csscolor.WHITE, 150) arcade.draw_ellipse_filled(x, y, 50, 20, arcade.csscolor.WHITE, 30) arcade.draw_circle_filled(x, y, 8, arcade.csscolor.YELLOW)
def draw_player(self, name): player = self.players[name] arcade.draw_circle_filled(player.x, player.y, self.radius, player.color) r_rad = math.radians(player.r) arcade.draw_line(player.x, player.y, player.x + self.radius * math.cos(r_rad), player.y + self.radius * math.sin(r_rad), arcade.color.BLACK, 2.0)
def draw_chair(x, y): #chair arcade.draw_line(x - 40, y - 50, x - 40, y, arcade.color.BLACK, 5) arcade.draw_line(x - 60, y - 50, x - 20, y - 50, arcade.color.BLACK, 5) #wheels arcade.draw_circle_filled(x - 40, y - 55, 5, arcade.color.BLACK) arcade.draw_circle_filled(x - 60, y - 55, 5, arcade.color.BLACK) arcade.draw_circle_filled(x - 20, y - 55, 5, arcade.color.BLACK) #chair back and seat arcade.draw_ellipse_filled(x - 40, y + 10, 50, 50, arcade.color.CADET) arcade.draw_ellipse_filled(x - 40, y - 30, 60, 25, arcade.color.CADET)
def laser_animation(self): for i in range(0, 25): arcade.draw_line(400, 240, 400, 220 + ((i / 25) * 400), arcade.color.BLUE, 4) arcade.draw_text(str(10 * self.player.ship["laser"]), 385, 650, colors["white"], font_size=18) arcade.draw_texture_rectangle(400, 600, 40, 40, self.explosion, 0) self.player.laser = False
def _drawHeader(self): # Header draw_text(f'Event Type', EVENT_TYPE_X, EVENT_TYPE_Y, EVENT_HEADER_COLOR, EVENT_HEADER_FONT_SIZE) # Separator line draw_line(start_x=EVENT_TYPE_X, end_x=SCREEN_WIDTH - (2 * X_MARGIN), start_y=EVENT_TYPE_Y, end_y=EVENT_TYPE_Y, color=color.WHITE, line_width=2)
def draw(self): startPos = coordsToPix(self.center) if self.length is None: endPos = coordsToPix(self.end) else: direction = (self.end - self.center).normalize(self.length) endPos = coordsToPix(self.center + direction) pixThick = sizeToPix(self.thickness) if (startPos - endPos).length() < 0.001: startPos.y += 1 arcade.draw_line(startPos.x, startPos.y, endPos.x, endPos.y, self.color, pixThick)
def draw(self): if self.enable: arcade.draw_line(self.start_x, self.start_y - 10, self.start_x + 75, self.start_y - 10, arcade.color.BLACK, 2) arcade.draw_text(self.label + self.text, self.start_x, self.start_y, arcade.color.BLACK, self.font_size, font_name=self.font_name)
def on_draw(self): """ Render the screen. """ # This command has to happen before we start drawing arcade.start_render() self.print_numlist.draw() ## Row/Column/Section Indicators if self.current_selected: x = self.current_selected[1] * (WIDTH + MARGIN) + MARGIN / 2 y = self.current_selected[0] * (HEIGHT + MARGIN) + MARGIN / 2 # Row arcade.draw_lrtb_rectangle_filled( 0, SCREEN_WIDTH, y + HEIGHT + MARGIN, y, (200, 0, 0, 20) ) # Column arcade.draw_lrtb_rectangle_filled( x, x + WIDTH + MARGIN, SCREEN_HEIGHT, 0, (0, 200, 0, 20) ) # Section sec_row = self.current_selected[0] // DIV_ROW sec_col = self.current_selected[1] // DIV_COL start_x = sec_col * (WIDTH + MARGIN) * DIV_COL start_y = sec_row * (HEIGHT + MARGIN) * DIV_ROW end_x = start_x + (WIDTH + MARGIN) * DIV_COL end_y = start_y + (HEIGHT + MARGIN) * DIV_ROW arcade.draw_lrtb_rectangle_filled( start_x, end_x, end_y, start_y, (0, 0, 200, 20) ) ## LINES SEPARATING THE GRID ## # Horizontal for i in range(SIZE // DIV_ROW + 1): yloc = (i / DIV_COL) * SCREEN_HEIGHT arcade.draw_line(0, yloc, SCREEN_WIDTH, yloc, arcade.color.SILVER, 7) # Vertical for i in range(SIZE // DIV_COL + 1): xloc = (i / DIV_ROW) * SCREEN_WIDTH arcade.draw_line(xloc, 0, xloc, SCREEN_HEIGHT, arcade.color.SILVER, 7) # Final screen telling user if they won or lost if self.correct == True: arcade.draw_lrwh_rectangle_textured( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, self.win ) elif self.incorrect == True: arcade.draw_lrwh_rectangle_textured( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, self.lost )
def draw(): for line in output_lines: if self.selected: dline = ((line[0][0],line[0][1]),(line[1][0],line[1][1])) #def draw(): arcade.draw_line(dline[0][0], dline[0][1], dline[1][0], dline[1][1], arcade.color.RED, 3) #print(-dist(line[0][0], line[0][1],const.SCREEN_WIDTH/2,const.SCREEN_HEIGHT/2)-500,flush = True) # else: if self.obj.owner != None: #def draw(): arcade.draw_line(line[0][0], line[0][1], line[1][0], line[1][1], arcade.color.WOOD_BROWN, 3)
def draw_game_elements(self): # draw basic game elements self.draw_instructions() self.floor1.draw() self.floor2.draw() self.floor3.draw() self.frogsprite_list.draw() arcade.draw_line(*self.body.tongue_args) self.popsprite_list.draw() self.draw_rising_levels() self.draw_candy_levels() self.draw_boss_levels()
def draw_game(self): self.player_list.draw() self.arena.draw() output = f"Score: {self.best_score} Generation: {self.gen_number}" arcade.draw_text(output, 10, 80, arcade.color.WHITE, 14) arcade.draw_line(0, 600, 800, 600, arcade.color.WOOD_BROWN, 10) arcade.draw_line(0, 500, 800, 500, arcade.color.WOOD_BROWN, 3) arcade.draw_line(0, 400, 800, 400, arcade.color.WOOD_BROWN, 3) arcade.draw_line(0, 300, 800, 300, arcade.color.WOOD_BROWN, 3) arcade.draw_line(0, 200, 800, 200, arcade.color.WOOD_BROWN, 10)
def draw_score_board(self): # Draw vertical lines every 128 pixels for x in [x * self.screen_width for x in range(1, 4)]: arcade.draw_line(x, self.screen_height, x, self.board_height, arcade.color.BLACK, 2) draw_x = self.screen_width * 1 / 16 draw_y = self.board_height + SCORE_BOARD_HEIGHT * 1 / 2 for dir, presses in self.key_presses.items(): arcade.draw_text("{} pressed\n{} times".format(dir, presses), draw_x, draw_y, arcade.color.BLACK, 12) draw_x += self.screen_width * 1 / 4
def draw_grid(): """ Draws grid lines for reference. """ lines = [] for i, j in zip(range(GRID_ROWS), range(GRID_COLS)): lines.append((i, 0, i, GRID_COLS - 1)) lines.append((0, j, GRID_ROWS - 1, j)) hs = GRID_SIZE // 2 for si, sj, ei, ej in lines: x0, y0 = get_xy(si, sj) x1, y1 = get_xy(ei, ej) arcade.draw_line(x0 - hs, y0 - hs, x1 - hs, y1 - hs, (0, 0, 0, 255))
def draw_grid(bo): for i in range(len(bo)): if i != 0: arcade.draw_line(0, HEIGHT / len(bo) * i, WIDTH, HEIGHT / len(bo) * i, arcade.color.BLACK, 4 if i % 3 == 0 else 1) for j in range(len(bo[0])): if j != 0: arcade.draw_line(WIDTH / len(bo[0]) * j, 0, WIDTH / len(bo[0]) * j, HEIGHT, arcade.color.BLACK, 4 if j % 3 == 0 else 1)
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_field(self): for i in range(self.size + 1): arcade.draw_line(self.left_border + self.cell_size * i, # vertical lines self.bottom_border, self.left_border + self.cell_size * i, self.bottom_border + self.size_in_pixels, color=arcade.color.BLACK_LEATHER_JACKET, line_width=3) arcade.draw_line(self.left_border, # horizontal line self.bottom_border + self.cell_size * i, self.left_border + self.size_in_pixels, self.bottom_border + self.cell_size * i, color=arcade.color.BLACK_LEATHER_JACKET, line_width=3)
def on_draw(self): arcade.start_render() self.all_sprites_list.draw() arcade.draw_text("Score: {}".format(self.score), self.ortho_left + 0.01, 9.75, arcade.color.BLACK, 12) grid_color = (0, 0, 255, 127) for y in range(0, 801, 32): arcade.draw_line(0, y, 800, y, grid_color) for x in range(0, 801, 32): arcade.draw_line(x, 0, x, 800, grid_color)
def on_draw(delta_time): """ Use this function to draw everything to the screen. """ # Move the angle of the sweep. on_draw.angle += RADIANS_PER_FRAME # Calculate the end point of our radar sweep. Using math. x = SWEEP_LENGTH * math.sin(on_draw.angle) + CENTER_X y = SWEEP_LENGTH * math.cos(on_draw.angle) + CENTER_Y # Start the render. This must happen before any drawing # commands. We do NOT need an stop render command. arcade.start_render() # Draw the radar line arcade.draw_line(CENTER_X, CENTER_Y, x, y, arcade.color.OLIVE, 2) # Draw the outline of the radar arcade.draw_circle_outline(CENTER_X, CENTER_Y, SWEEP_LENGTH, arcade.color.DARK_GREEN, 3)
arcade.open_window("Drawing Example", 600, 600) # Set the background color to white # For a list of named colors see # https://pythonhosted.org/arcade/arcade.color.html # Colors can also be specified in (red, green, blue) format and # (red, green, blue, alpha) format. arcade.set_background_color(arcade.color.BLUE_GRAY) # 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),
""" # Library imports import math import arcade import time # Open the window and set the background arcade.open_window("Drawing Example", 600, 600) arcade.set_background_color(arcade.color.WHITE) # Start the render process. This must be done before any drawing commands. arcade.start_render() arcade.draw_line(120, 0, 120, 600, arcade.color.BLACK, 2) # Draw a grid x = 120 while x < 800: arcade.draw_line(x, 0, x, 600, arcade.color.BLACK, 2) x += 120 y = 200 while y < 500: arcade.draw_line(0, y, 800, y, arcade.color.BLACK, 2) y += 200 # Draw a point arcade.draw_text("draw_point", 3, 405, arcade.color.BLACK, 12) arcade.draw_point(60, 495, arcade.color.RED, 10)