Exemplo n.º 1
0
 def draw_one_path(self, path, color):
     points = list()
     for p in path:
         n = (p[0] * SPRITE_SIZE + SPRITE_SIZE / 2,
              p[1] * SPRITE_SIZE + SPRITE_SIZE / 2)
         points.append(n)
     ar.draw_line_strip(points, color, 5)
Exemplo n.º 2
0
 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.actor_list[x][y]) == int:
                 arcade.draw_rectangle_filled(x * 10, y * 10, 9, 9,
                                              arcade.color.YELLOW)
             if type(self.item_list[x][y]) == int:
                 arcade.draw_rectangle_filled(x * 10, y * 10, 9, 9,
                                              arcade.color.GREEN)
             # if self.dg_list[x][y] == TILE.STAIRS_DOWN:
             #     arcade.draw_rectangle_filled(x*10, y*10, 9, 9, arcade.color.BALL_BLUE)
             if self.dg_list[x][y] == TILE.DOOR_H:
                 arcade.draw_rectangle_filled(x * 10, y * 10, 9, 9,
                                              arcade.color.HOT_PINK)
             if self.dg_list[x][y] == TILE.DOOR_W:
                 arcade.draw_rectangle_filled(x * 10, y * 10, 9, 9,
                                              arcade.color.HOT_PINK)
             if self.dg_list[x][y] == self.bsp.room_count:
                 arcade.draw_rectangle_filled(x * 10, y * 10, 9, 9,
                                              arcade.color.BALL_BLUE)
             # if (x,y) in self.path:
             #     arcade.draw_point(x*10, y*10, arcade.color.RED, 3)
     arcade.draw_line_strip(self.path, arcade.color.ANDROID_GREEN, 3)
Exemplo n.º 3
0
 def draw_steps_path(self, key):
     points = list()
     for step in self.path[key][:self.path_index_bfs + 1]:
         n = (step[0] * SPRITE_SIZE + SPRITE_SIZE / 2,
              step[1] * SPRITE_SIZE + SPRITE_SIZE / 2)
         points.append(n)
     ar.draw_line_strip(points, ar.color.ORANGE_PEEL, 3)
Exemplo n.º 4
0
 def draw_one_path(self, path, color):
     points = list()
     for p in path:
         n = (p[0] * self.tile_size + self.tile_size / 2,
              p[1] * self.tile_size + self.tile_size / 2)
         points.append(n)
     ar.draw_line_strip(points, color, 5)
Exemplo n.º 5
0
    def on_draw(self):
        arcade.start_render()

        arcade.draw_points(self.cities, arcade.color.WHITE, 10)
        if not self.done:
            arcade.draw_line_strip(self.permutations[self.current_permutation],
                                   arcade.color.WHITE, 2)
        arcade.draw_line_strip(self.cities, arcade.color.GREEN, 3)

        percent_done = self.current_permutation / (len(self.permutations) -
                                                   1) * 100
        arcade.draw_text(f'{percent_done:.3f}%',
                         SCREEN_WIDTH // 2,
                         30,
                         arcade.color.WHITE,
                         24,
                         anchor_x='center')
        arcade.draw_text(f"Shortest Path: {self.shortest:.3f}",
                         SCREEN_WIDTH // 2,
                         SCREEN_HEIGHT - 30,
                         arcade.color.WHITE,
                         anchor_x='center')
        if self.done:
            arcade.draw_text(
                f"Time to Find Shortest Path: {self.total_time:.3f} seconds",
                SCREEN_WIDTH // 2,
                SCREEN_HEIGHT - 60,
                arcade.color.WHITE,
                anchor_x='center')
Exemplo n.º 6
0
 def on_draw(self):
     """ Called whenever we need to draw the window. """
     arcade.start_render()
     # draw pen
     self.small_ball.draw()
     # draw line by points
     for line in self.points:
         arcade.draw_line_strip(line, arcade.color.BLACK, 6)
Exemplo n.º 7
0
 def draw(self) -> None:
     segments = [
         segment for name, segment in self.segments.items() if name != "eye"
     ]
     for segment in segments:
         points = [p.curr_pos for p in segment]
         arcade.draw_line_strip(points, Turkey.color, 2)
     eye_pos = self.segments["eye"][0].curr_pos
     arcade.draw_circle_filled(*eye_pos, self.scale / 2, color=Turkey.color)
Exemplo n.º 8
0
    def on_draw(self):
        arcade.start_render()

        for value in self.layers.values():
            value.draw()
        self.bullet_list.draw()
        self.ai_sprite_list.draw()
        self.tank_list.draw()
        self.draw_health()

        if self.path:
            arcade.draw_line_strip(self.path, arcade.color.BLUE, 2)
Exemplo n.º 9
0
    def on_draw(self):
        self.clear()
        if not self.shown:
            return

        # Camera zoom
        star_zoom = ease_quartout(1, 0.9, self.last_beat, self.last_beat + self.beat_time, self.song.time)
        cam_zoom = ease_quartout(1.05, 1, self.last_beat, self.last_beat + self.beat_time, self.song.time)
        self.star_camera.scale = star_zoom
        self.camera.scale = 1 / cam_zoom
        self.highway.camera.scale = 1 / cam_zoom

        # Gradient
        self.gradient.draw()

        # Scroll star camera and draw stars
        self.star_camera.move_to((0, 0 - (self.song.time * self.scroll_speed)))
        self.star_camera.use()
        self.stars.draw()

        self.camera.use()

        # Note flashes
        if self.chart_available:
            player_note = self.player_chart.lt(self.song.time)
            if player_note:
                player_color = colormap[player_note.lane]
                player_time = player_note.time
                player_opacity = ease_linear(32, 0, player_time, player_time + self.beat_time, self.song.time)
                player_color = player_color + (int(player_opacity),)
                arcade.draw_xywh_rectangle_filled(Settings.width / 2, 0, Settings.width / 2, Settings.height, player_color)
            enemy_note = self.enemy_chart.lt(self.song.time)
            if enemy_note:
                enemy_color = colormap[enemy_note.lane]
                enemy_time = enemy_note.time
                enemy_opacity = ease_linear(32, 0, enemy_time, enemy_time + self.beat_time, self.song.time)
                enemy_color = enemy_color + (int(enemy_opacity),)
                arcade.draw_xywh_rectangle_filled(0, 0, Settings.width / 2, Settings.height, enemy_color)

        # Text
        if self.show_text:
            self.text.draw()

        line_color = (0, 255, 255, 255)
        line_outline_color = (255, 255, 255, 255)
        arcade.draw_line_strip(self.pixels, line_outline_color, self.line_width + 2)
        arcade.draw_line_strip(self.pixels, line_color, self.line_width)

        if self.chart_available:
            self.sprite_list.draw()
            self.highway.draw()

        super().on_draw()
Exemplo n.º 10
0
    def on_draw(self):  #рисуем!))
        arcade.start_render()  # эта команда начинает процесс рисовки

        #отрисовка пути поезда
        arcade.draw_line_strip(self.way_list, (255, 0, 0))

        #отрисовка всего что есть от нижних слоёв к верхним

        arcade.draw_lrwh_rectangle_textured(0, 0,
                                            window.get_size()[0],
                                            window.get_size()[1],
                                            self.background)

        self.bullet_list.draw()
        self.people_list.draw()
        if window.get_size() != self.permission:
            self.permission = window.get_size()
            for i in range(len(self.blocks)):
                self.blocks[i].center_x = self.permission[
                    0] * sp_coordinates_obstacles[i][0]
                self.blocks[i].center_y = self.permission[
                    1] * sp_coordinates_obstacles[i][1]
            self.blocks.draw()
        else:
            self.blocks.draw()

        #for i in range(1, len(self.way_list)):
        #    arcade.draw_line(self.way_list[i-1][0], self.way_list[i-1][1], self.way_list[i][0], self.way_list[i][1], (255, 0, 255), 2)

        #отрисовка времени и кол-ва пуль в обойме. Позже запихну это в отдельный класс Интерфейса
        arcade.draw_text(
            F'{int(self.time-self.start_time)//60}:{int(self.time-self.start_time)%60}',
            SCREEN_WIDTH - 100, 20, arcade.color.WHITE, 16)
        arcade.draw_text(F':{self.player_sprite.bullet_now}', 40, 20,
                         arcade.color.WHITE, 16)

        #отображение жизней
        hero = self.player_sprite
        draw_hp(hero.center_x, hero.center_y, hero._height, hero.max_hp,
                hero.hp)
        for guard in self.people_list:
            draw_hp(guard.center_x, guard.center_y, guard._height,
                    guard.max_hp, guard.hp)
        for thing in self.all_sprites:
            thing.draw_hit_box()
        #отображение пути до гг
        for guard in self.guards_list:
            if guard.path:
                arcade.draw_line_strip(guard.path, arcade.color.BLUE, 2)

        self.train.draw_all()
Exemplo n.º 11
0
    def on_draw(self):
        arcade.start_render()

        # Draw track outer boundary
        arcade.draw_line_strip(
            self.track.track_outer_boundary, arcade.color.BLACK)

        # Draw track inner boundary
        arcade.draw_line_strip(
            self.track.track_inner_boundary, arcade.color.BLACK)

        # Draw car
        arcade.draw_rectangle_filled(
            self.car.x, self.car.y, 30, 14, self.color, self.car.rotation)
Exemplo n.º 12
0
    def on_draw(self):
        #render to the screen

        #clear the screen to the background color
        arcade.start_render()

        #draw our sprites
        self.wall_list.draw()
        self.background_list.draw()
        self.wall_list.draw()
        self.pickup_list.draw()
        self.player_list.draw()
        self.melee_list.draw()
        self.enemy_list.draw()

        for bad_guy in self.enemy_list:
            if bad_guy.path:
                arcade.draw_line_strip(bad_guy.path, arcade.color.BLUE, 2)

        #Draw our score on the screen, scrolling it with the viewport
        score_text = f"Arrows: {self.ammo}"
        if self.ammo == 0:
            color = arcade.csscolor.RED
        else:
            color = arcade.csscolor.WHITE
        arcade.draw_text(score_text, 775, 590, color, 18)

        health_text = f"Health: {self.player_sprite.hp}"
        if self.player_sprite.hp <= 35:
            color = arcade.csscolor.RED
        else:
            color = arcade.csscolor.WHITE
        arcade.draw_text(health_text, 775, 540, color, 18)

        if len(self.charge_list) > 0:
            power = self.charge_list[0].power // 10
        else:
            power = 0
        indicator = '-' * power
        space = ' ' * (10 - power)
        if power == 10:
            charge_color = arcade.csscolor.RED
        else:
            charge_color = arcade.csscolor.WHITE
        charge_text = f"Charging: <{indicator}{space}>"
        arcade.draw_text(charge_text, 775, 490, charge_color, 18)

        self.projectile_list.draw()
    def on_draw(self):
        arcade.start_render()
        arcade.draw_points(self.cities, arcade.color.WHITE, 10)
        if len(self.path) > 1:
            arcade.draw_line_strip(self.path, arcade.color.WHITE, 2)

        if self.done:
            arcade.draw_text(f"Shortest Path: {self.shortest:.3f}",
                             SCREEN_WIDTH // 2,
                             SCREEN_HEIGHT - 30,
                             arcade.color.WHITE,
                             anchor_x='center')
            arcade.draw_text(
                f"Time to Find Shortest Path: {self.total_time:.3f} seconds",
                SCREEN_WIDTH // 2,
                SCREEN_HEIGHT - 60,
                arcade.color.WHITE,
                anchor_x='center')
Exemplo n.º 14
0
def viz_angle():
	# Determine number of samples to graph (min is used for beggining stage really)
	N = min(500, states.shape[0])

	# Generate x axis
	x = np.linspace(SCREEN_WIDTH//2 - N/2, SCREEN_WIDTH//2 + N/2, N).reshape((-1,1))
	
	# Extract last N angles
	angles = 10 * 180 * states[-N:,2].reshape((-1,1)) / np.pi 
	# Keep them between -100 and 100 (i.e. -10 to 10 degrees)
	angles = angles * (np.abs(angles) < 100)
	# Shift up to top of screen
	angles += 4 * SCREEN_HEIGHT // 5

	# Append x and y into 1 tall matrix
	pairs = np.hstack((x, angles))
	# Plot the matrix and the zero line
	arcade.draw_line(SCREEN_WIDTH//2 - N/2 -10, 4 * SCREEN_HEIGHT // 5, SCREEN_WIDTH//2 + N/2 + 10, 4 * SCREEN_HEIGHT // 5, arcade.color.BLACK, 1)
	arcade.draw_line_strip(pairs, arcade.color.BLUE, 2)
def tegn_senmand():
    # Snemand
    arcade.draw_circle_filled(500, 100, 70, arcade.color.WHITE_SMOKE)
    arcade.draw_circle_filled(500, 200, 50, arcade.color.WHITE_SMOKE)
    arcade.draw_circle_filled(500, 280, 40, arcade.color.WHITE_SMOKE)
    # Mund
    point_list_mund = ((485, 258), (488, 256), (510, 255), (515, 260))
    arcade.draw_line_strip(point_list_mund, arcade.color.RED, 3)

    # Øjne
    arcade.draw_circle_filled(513, 283, 9, arcade.color.BLACK)
    arcade.draw_circle_filled(487, 283, 9, arcade.color.BLACK)
    arcade.draw_circle_filled(513, 283, 7, arcade.color.WHITE)
    arcade.draw_circle_filled(487, 283, 7, arcade.color.WHITE)
    arcade.draw_circle_filled(512, 281, 5, arcade.color.TROPICAL_RAIN_FOREST)
    arcade.draw_circle_filled(486, 281, 5, arcade.color.TROPICAL_RAIN_FOREST)

    # Næse
    point_list = (
        (500, 275),
        (504, 273),
        (505, 270),
        (504, 267),
        (500, 265),
        (480, 259),
        (480, 260),
    )
    arcade.draw_polygon_filled(point_list, arcade.color.ORANGE_PEEL)

    # Venstre Arm
    arcade.draw_line(400, 280, 466, 224, arcade.color.BROWN, 3)
    # Fingre
    arcade.draw_line(400, 280, 385, 264, arcade.color.BROWN, 3)
    arcade.draw_line(400, 280, 383, 290, arcade.color.BROWN, 3)
    arcade.draw_line(400, 280, 395, 300, arcade.color.BROWN, 3)

    # Højre Arm
    arcade.draw_line(600, 270, 530, 224, arcade.color.BROWN, 3)
    # Fingre
    arcade.draw_line(600, 270, 615, 264, arcade.color.BROWN, 3)
    arcade.draw_line(600, 270, 613, 290, arcade.color.BROWN, 3)
    arcade.draw_line(600, 270, 620, 280, arcade.color.BROWN, 3)
    def on_draw(self):
        """
        Render the screen.
        """
        try:
            # This command has to happen before we start drawing
            arcade.start_render()

            # Draw all the sprites.
            self.player_list.draw()
            self.wall_list.draw()
            self.enemy_list.draw()

            if self.path:
                arcade.draw_line_strip(self.path, arcade.color.BLUE, 2)

        except Exception:

            import traceback
            traceback.print_exc()
Exemplo n.º 17
0
    def diamond(self, loc_x, loc_y, fill=None):
        height = 125
        width = 60
        border_width = 5
        if self.color == 'red':
            color = arcade.color.RED
        elif self.color == 'green':
            color = arcade.color.GO_GREEN
        elif self.color == 'purple':
            color = arcade.color.PURPLE_HEART
        else:
            color = arcade.color.BLACK

        x_1 = loc_x - width / 2
        y_1 = loc_y
        x_2 = loc_x
        y_2 = loc_y + height / 2
        x_3 = loc_x + width / 2
        y_3 = loc_y
        x_4 = loc_x
        y_4 = loc_y - height / 2
        point_list = (
            (x_1, y_1),
            (x_2, y_2),
            (x_3, y_3),
            (x_4, y_4),
            (x_1, y_1)
        )

        arcade.draw_line_strip(point_list, color, border_width)

        if fill == 'shaded':
            self.shade_diamond(loc_x, loc_y, color)

        if fill == 'solid':
            self.fill_diamond(point_list, color)
Exemplo n.º 18
0
def _render_map(viewport: Viewport, interaction_map: Map) -> None:
    to_draw = {
        WayKind.SolidLine,
        WayKind.ThickLine,
        WayKind.DashedLine,
        WayKind.GuardRail,
    }

    for osm_id, lane in interaction_map.lanes.items():
        triangles = lane.to_triangles()
        for triangle in triangles:
            triangle = viewport.project(triangle)
            arcade.draw_polygon_filled(triangle, (140, 140, 140))

    for osm_id, way in interaction_map.ways.items():
        if way.kind is WayKind.StopLine:
            ps = viewport.project(
                [interaction_map.nodes[n.osm_id].position for n in way.nodes])
            arcade.draw_line_strip(ps, arcade.color.AMBER, 5)

    for osm_id, lane in interaction_map.lanes.items():
        left_ps = [n.position for n in lane.left_way.nodes]
        right_ps = [n.position for n in lane.right_way.nodes]

        left_ps = viewport.project(left_ps)
        right_ps = viewport.project(right_ps)

        if lane.left_way.kind is not WayKind.Virtual:
            thickness = 1.5
            if lane.left_way.kind is WayKind.ThickLine:
                thickness = 2
            arcade.draw_line_strip(left_ps, (240, 240, 240), thickness)

        if lane.right_way.kind is not WayKind.Virtual:
            thickness = 1.5
            if lane.right_way.kind is WayKind.ThickLine:
                thickness = 2
            elif lane.right_way.kind is WayKind.DashedLine:
                thickness = 2
            arcade.draw_line_strip(right_ps, (240, 240, 240), thickness)
Exemplo n.º 19
0
              (450, 480),
              (390, 510),
              (450, 510)
              )
arcade.draw_lines(point_list, arcade.color.BLUE, 3)

# Draw a line strip
arcade.draw_text("draw_line_strip", 483, 405, arcade.color.WHITE, 12)
point_list = ((510, 450),
              (570, 450),
              (510, 480),
              (570, 480),
              (510, 510),
              (570, 510)
              )
arcade.draw_line_strip(point_list, arcade.color.TROPICAL_RAIN_FOREST, 3)

# Draw a polygon
arcade.draw_text("draw_polygon_outline", 3, 207, arcade.color.WHITE, 9)
point_list = ((30, 240),
              (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),
Exemplo n.º 20
0
    def on_draw(self):
        """
        Render the screen.
        """

        # 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.BLACK, 2)

        # Draw horizontal lines every 200 pixels
        for y in range(0, 601, 200):
            arcade.draw_line(0, y, 800, y, arcade.color.BLACK, 2)

        # Draw a point
        arcade.draw_text("draw_point", 3, 405, arcade.color.BLACK, 12)
        arcade.draw_point(60, 495, arcade.color.RED, 10)

        # Draw a set of points
        arcade.draw_text("draw_points", 123, 405, arcade.color.BLACK, 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.BLACK, 12)
        arcade.draw_line(270, 495, 300, 450, arcade.color.WOOD_BROWN, 3)

        # Draw a set of lines
        arcade.draw_text("draw_lines", 363, 405, arcade.color.BLACK, 12)
        point_list = ((390, 450), (450, 450), (390, 480), (450, 480),
                      (390, 510), (450, 510))
        arcade.draw_lines(point_list, arcade.color.BLUE, 3)

        # Draw a line strip
        arcade.draw_text("draw_line_strip", 483, 405, arcade.color.BLACK, 12)
        point_list = ((510, 450), (570, 450), (510, 480), (570, 480),
                      (510, 510), (570, 510))
        arcade.draw_line_strip(point_list, arcade.color.TROPICAL_RAIN_FOREST,
                               3)
        arcade.draw_line_strip(point_list, arcade.color.BEIGE)

        # Draw a polygon
        arcade.draw_text("draw_polygon_outline", 3, 207, arcade.color.BLACK, 9)
        point_list = ((30, 240), (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.BLACK,
                         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.BLACK,
                         10)
        arcade.draw_circle_outline(300, 285, 18, arcade.color.WISTERIA, 3)
        arcade.draw_circle_outline(350, 285, 18, arcade.color.WISTERIA)

        # Draw a filled in circle
        arcade.draw_text("draw_circle_filled", 363, 207, arcade.color.BLACK,
                         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.BLACK,
                         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)

        # Draw a filled ellipse, and another one rotated
        arcade.draw_text("draw_ellipse_filled", 3, 3, arcade.color.BLACK, 10)
        arcade.draw_ellipse_filled(60, 81, 15, 36, arcade.color.AMBER)
        arcade.draw_ellipse_filled(60, 144, 15, 36, arcade.color.BLACK_BEAN,
                                   45)

        # Draw an arc, and another one rotated
        arcade.draw_text("draw_arc/filled_arc", 123, 3, arcade.color.BLACK, 10)
        arcade.draw_arc_outline(150, 81, 15, 36, arcade.color.BRIGHT_MAROON,
                                90, 360)
        arcade.draw_arc_filled(150, 144, 15, 36, arcade.color.BOTTLE_GREEN, 90,
                               360, 45)

        # Draw an rectangle outline
        arcade.draw_text("draw_rect", 243, 3, arcade.color.BLACK, 10)
        arcade.draw_rectangle_outline(295, 100, 45, 65,
                                      arcade.color.BRITISH_RACING_GREEN)
        arcade.draw_rectangle_outline(295, 160, 20, 45,
                                      arcade.color.BRITISH_RACING_GREEN, 3, 45)

        # Draw a filled in rectangle
        arcade.draw_text("draw_filled_rect", 363, 3, arcade.color.BLACK, 10)
        arcade.draw_rectangle_filled(420, 100, 45, 65, arcade.color.BLUSH)
        arcade.draw_rectangle_filled(420, 160, 20, 40, arcade.color.BLUSH, 45)

        # Load and draw an image to the screen
        # Image from kenney.nl asset pack #1
        arcade.draw_text("draw_bitmap", 483, 3, arcade.color.BLACK, 12)
        texture = arcade.load_texture("images/playerShip1_orange.png")
        scale = .6
        arcade.draw_texture_rectangle(540, 120, scale * texture.width,
                                      scale * texture.height, texture, 0)
        arcade.draw_texture_rectangle(540, 60, scale * texture.width,
                                      scale * texture.height, texture, 45)

        color = arcade.get_pixel(100, 100)
        assert color == (255, 255, 255)

        image = arcade.get_image()
Exemplo n.º 21
0
    def on_draw(self):
        self.parent.set_viewport(*self.viewport.as_tuple())

        # update agent sprites
        self.update_agent_sprites()

        # build map VBO if necessary
        if self.tiles_vbo is None or self.fog:
            self.build_grid()

        # render main map tiles
        # fix projection each frame
        with self.tiles_vbo.vao:
            self.tiles_vbo.program['Projection'] = arcade.get_projection(
            ).flatten()
        # and draw
        self.tiles_vbo.draw()

        # render stuff on top of the map
        if self.map_items is None:
            self.build_map_items()
        # fix projection each frame
        with self.map_items.program:
            self.map_items.program['Projection'] = arcade.get_projection(
            ).flatten()
        # and draw
        self.map_items.draw()

        # draw noises
        for noise in self.world.noises + self.world.old_noises:
            radius = max(
                0, noise.radius - (self.world.time_ticks - noise.time) *
                self.world.TIME_PER_TICK * 0.5 * noise.radius)
            if radius > 0:  # and not noise.drawn:
                arcade.draw_ellipse_outline(noise.location.x,
                                            noise.location.y,
                                            radius,
                                            radius,
                                            arcade.color.AIR_FORCE_BLUE,
                                            border_width=0.2)

        # draw agent trails
        for ID, agent in self.world.agents.items():
            arcade.draw_line_strip(self.agent_trails[agent],
                                   color=[int(255 * c) for c in agent.color])

        # draw agents
        self.agent_sprites.draw()

        # change back to pixel viewport for the next WindowComponent
        self.parent.set_viewport(0, self.parent.SCREEN_WIDTH, 0,
                                 self.parent.SCREEN_HEIGHT)

        # print map position of the cursor
        location = self.screen_to_map(self.mouse_x, self.mouse_y, round=False)
        text = f"({location[0]:3.2f}, {location[1]:3.2f})"
        arcade.draw_lrtb_rectangle_filled(self.parent.SCREEN_WIDTH -
                                          12 * len(text) - 6,
                                          self.parent.SCREEN_WIDTH,
                                          self.parent.SCREEN_HEIGHT,
                                          self.parent.SCREEN_HEIGHT - 24 - 6,
                                          color=(0, 0, 0, 192))
        arcade.draw_text(text, self.parent.SCREEN_WIDTH - 12 * len(text),
                         self.parent.SCREEN_HEIGHT - 24, arcade.color.WHITE,
                         16)
Exemplo n.º 22
0
# Sun has to have sunglasses
arcade.draw_ellipse_filled(350, 360, 40, 25, arcade.color.BLACK)
arcade.draw_ellipse_filled(300, 360, 40, 25, arcade.color.BLACK)
arcade.draw_line(300, 360, 370, 360, arcade.color.BLACK)

# Cat Body
arcade.draw_ellipse_filled(240, 155, 150, 40, arcade.color.CADET_GREY)

# Cat Legs
arcade.draw_lrtb_rectangle_filled(200, 210, 155, 60, arcade.color.CADET_GREY)
arcade.draw_lrtb_rectangle_filled(215, 225, 155, 60, arcade.color.CADET_GREY)
arcade.draw_lrtb_rectangle_filled(260, 270, 155, 60, arcade.color.CADET_GREY)
arcade.draw_lrtb_rectangle_filled(280, 290, 155, 60, arcade.color.CADET_GREY)

# Cat Tail
arcade.draw_line_strip([[300, 155], [325, 170], [325, 220], [350, 230]],
                       arcade.color.BLACK, 5)

# Start of Cat head
arcade.draw_polygon_filled([[200, 175], [150, 175], [164, 125], [190, 130]],
                           arcade.color.ASH_GREY)
arcade.draw_circle_filled(175, 135, 7, arcade.color.PINK)
arcade.draw_circle_filled(190, 160, 5, arcade.color.BLACK)
arcade.draw_circle_filled(170, 160, 5, arcade.color.BLACK)

# Ears
arcade.draw_triangle_filled(150, 175, 175, 200, 170, 175, arcade.color.BLACK)
arcade.draw_triangle_filled(180, 175, 190, 200, 200, 175, arcade.color.BLACK)

# Whiskers
arcade.draw_line_strip([[145, 125], [165, 130]], arcade.color.BLACK, 2)
arcade.draw_line_strip([[145, 135], [165, 135]], arcade.color.BLACK, 2)
Exemplo n.º 23
0
    def on_draw(self):
        """
            Tegnefunktionen der bliver kalt flere gange hver sekund.
        """
        arcade.start_render()
        # Sne
        arcade.draw_rectangle_filled(400, 30, 800, 60, arcade.color.WHITE)

        # Snemand
        arcade.draw_circle_filled(500, 100, 70, arcade.color.WHITE_SMOKE)
        arcade.draw_circle_filled(500, 200, 50, arcade.color.WHITE_SMOKE)
        arcade.draw_circle_filled(500, 280, 40, arcade.color.WHITE_SMOKE)

        # Mund
        point_list_mund = ((485, 258), (488, 256), (510, 255), (515, 260))
        arcade.draw_line_strip(point_list_mund, arcade.color.RED, 3)

        # Øjne
        arcade.draw_circle_filled(513, 283, 9, arcade.color.BLACK)
        arcade.draw_circle_filled(487, 283, 9, arcade.color.BLACK)
        arcade.draw_circle_filled(513, 283, 7, arcade.color.WHITE)
        arcade.draw_circle_filled(487, 283, 7, arcade.color.WHITE)
        arcade.draw_circle_filled(512, 281, 5,
                                  arcade.color.TROPICAL_RAIN_FOREST)
        arcade.draw_circle_filled(486, 281, 5,
                                  arcade.color.TROPICAL_RAIN_FOREST)

        # Næse
        point_list = (
            (500, 275),
            (504, 273),
            (505, 270),
            (504, 267),
            (500, 265),
            (480, 259),
            (480, 260),
        )
        arcade.draw_polygon_filled(point_list, arcade.color.ORANGE_PEEL)

        # Venstre Arm
        arcade.draw_line(400, 280, 466, 224, arcade.color.BROWN, 3)
        # Fingre
        arcade.draw_line(400, 280, 385, 264, arcade.color.BROWN, 3)
        arcade.draw_line(400, 280, 383, 290, arcade.color.BROWN, 3)
        arcade.draw_line(400, 280, 395, 300, arcade.color.BROWN, 3)

        # Højre Arm
        arcade.draw_line(600, 270, 530, 224, arcade.color.BROWN, 3)
        # Fingre
        arcade.draw_line(600, 270, 615, 264, arcade.color.BROWN, 3)
        arcade.draw_line(600, 270, 613, 290, arcade.color.BROWN, 3)
        arcade.draw_line(600, 270, 620, 280, arcade.color.BROWN, 3)

        # træstamme
        arcade.draw_rectangle_filled(200, 50, 40, 50, arcade.color.BROWN)

        # Grønt
        point_list = (
            (150, 100),
            (250, 100),
            (300, 50),
            (290, 45),
            (105, 45),
            (100, 50),
        )
        arcade.draw_polygon_filled(point_list, arcade.color.DARK_GREEN)

        point_list = (
            (175, 150),
            (225, 150),
            (275, 100),
            (265, 95),
            (130, 95),
            (125, 100),
        )
        arcade.draw_polygon_filled(point_list, arcade.color.DEEP_MOSS_GREEN)

        point_list = (
            (199, 200),
            (201, 200),
            (250, 150),
            (245, 145),
            (155, 145),
            (145, 150),
        )
        arcade.draw_polygon_filled(point_list, arcade.color.GREEN)

        arcade.draw_circle_filled(400, self.y, 7, arcade.color.WHITE)
        self.y = self.y - 2
Exemplo n.º 24
0
 def draw(self):
     if self.path:
         arcade.draw_line_strip(self.path, arcade.color.BLUE, 2)
Exemplo n.º 25
0
 def draw_original_path(self):
     point_list = tuple(tuple([point[0], point[1]]) for point in self.path)
     arcade.draw_line_strip(point_list, arcade.color.BLACK, 5)
Exemplo n.º 26
0
 def draw_smooth_path(self):
     point_list = tuple(tuple([point[0], point[1]]) for point in self.smooth_path)
     arcade.draw_line_strip(point_list, arcade.color.RED, 5)        
Exemplo n.º 27
0
 def draw_line_strip(self):
     arcade.draw_line_strip(self.line_strip, arcade.color.WHITE, 20.0)
Exemplo n.º 28
0
# 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))

point_list = ((0, 0), (0, 90), (40, 110), (80, 120), (110, 130), (150, 140),
              (180, 130), (230, 140), (300, 130), (380, 125), (430, 80),
              (450, 60), (600, 0))
arcade.draw_polygon_filled(point_list, (107, 151, 115))

# Draw the amazon river and its branches
point_list = ((300, 0), (280, 50), (270, 70), (290, 100), (310, 120), (300,
                                                                       140))
arcade.draw_line_strip(point_list, (126, 207, 205), 5)

point_list = ((280, 50), (270, 70), (260, 90), (255, 100), (240, 120), (210,
                                                                        145))
arcade.draw_line_strip(point_list, (126, 207, 205), 5)

point_list = ((280, 50), (270, 70), (280, 90), (275, 100), (280, 120), (270,
                                                                        145))
arcade.draw_line_strip(point_list, (126, 207, 205), 5)

point_list = ((280, 50), (240, 70), (230, 90), (220, 100), (200, 120), (190,
                                                                        140))
arcade.draw_line_strip(point_list, (126, 207, 205), 5)

# Robotic arm in ISS
arcade.draw_rectangle_filled(550, 570, 20, 150, arcade.color.WHITE, 110)
 def draw(self):
     # drawing the lines is unbuffered because each line segment may change between frames
     # it might make sense to have an option to disable line drawing completely for performance boost
     arcade.draw_line_strip(self.x, self.color, self.width)
              (450, 480),
              (390, 510),
              (450, 510)
              )
arcade.draw_lines(point_list, arcade.color.BLUE, 3)

# Draw a line strip
arcade.draw_text("draw_line_strip", 483, 405, arcade.color.BLACK, 12)
point_list = ((510, 450),
              (570, 450),
              (510, 480),
              (570, 480),
              (510, 510),
              (570, 510)
              )
arcade.draw_line_strip(point_list, arcade.color.TROPICAL_RAIN_FOREST, 3)

# Draw a polygon
arcade.draw_text("draw_polygon_outline", 3, 207, arcade.color.BLACK, 9)
point_list = ((30, 240),
              (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.BLACK, 9)
point_list = ((150, 240),
              (165, 240),
Exemplo n.º 31
0
    def on_draw(self):
        """
        Render the screen.
        """

        # 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.BLACK, 2)

        # Draw horizontal lines every 200 pixels
        for y in range(0, 601, 200):
            arcade.draw_line(0, y, 800, y, arcade.color.BLACK, 2)

        # Draw a point
        arcade.draw_text("draw_point", 3, 405, arcade.color.BLACK, 12)
        arcade.draw_point(60, 495, arcade.color.RED, 10)

        # Draw a set of points
        arcade.draw_text("draw_points", 123, 405, arcade.color.BLACK, 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.BLACK, 12)
        arcade.draw_line(270, 495, 300, 450, arcade.color.WOOD_BROWN, 3)

        # Draw a set of lines
        arcade.draw_text("draw_lines", 363, 405, arcade.color.BLACK, 12)
        point_list = ((390, 450), (450, 450), (390, 480), (450, 480),
                      (390, 510), (450, 510))
        arcade.draw_lines(point_list, arcade.color.BLUE, 3)

        # Draw a line strip
        arcade.draw_text("draw_line_strip", 483, 405, arcade.color.BLACK, 12)
        point_list = ((510, 450), (570, 450), (510, 480), (570, 480),
                      (510, 510), (570, 510))
        arcade.draw_line_strip(point_list, arcade.color.TROPICAL_RAIN_FOREST,
                               3)
        arcade.draw_line_strip(point_list, arcade.color.BEIGE)

        # Draw a polygon
        arcade.draw_text("draw_polygon_outline", 3, 207, arcade.color.BLACK, 9)
        point_list = ((30, 240), (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.BLACK,
                         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.BLACK,
                         10)
        arcade.draw_circle_outline(300, 285, 18, arcade.color.WISTERIA, 3)
        arcade.draw_circle_outline(350, 285, 18, arcade.color.WISTERIA)

        # Draw a filled in circle
        arcade.draw_text("draw_circle_filled", 363, 207, arcade.color.BLACK,
                         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.BLACK,
                         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)

        # Draw a filled ellipse, and another one rotated
        arcade.draw_text("draw_ellipse_filled", 3, 3, arcade.color.BLACK, 10)
        arcade.draw_ellipse_filled(60, 81, 15, 36, arcade.color.AMBER)
        arcade.draw_ellipse_filled(60, 144, 15, 36, arcade.color.BLACK_BEAN,
                                   45)

        # Draw an arc, and another one rotated
        arcade.draw_text("draw_arc/filled_arc", 123, 3, arcade.color.BLACK, 10)
        arcade.draw_arc_outline(150, 81, 15, 36, arcade.color.BRIGHT_MAROON,
                                90, 360)
        arcade.draw_arc_filled(150, 144, 15, 36, arcade.color.BOTTLE_GREEN, 90,
                               360, 45)

        # Draw an rectangle outline
        arcade.draw_text("draw_rect", 243, 3, arcade.color.BLACK, 10)
        arcade.draw_rectangle_outline(295, 100, 45, 65,
                                      arcade.color.BRITISH_RACING_GREEN)
        arcade.draw_rectangle_outline(295, 160, 20, 45,
                                      arcade.color.BRITISH_RACING_GREEN, 3, 45)

        # Draw a filled in rectangle
        arcade.draw_text("draw_filled_rect", 363, 3, arcade.color.BLACK, 10)
        arcade.draw_rectangle_filled(420, 100, 45, 65, arcade.color.BLUSH)
        arcade.draw_rectangle_filled(420, 160, 20, 40, arcade.color.BLUSH, 45)

        # Load and draw an image to the screen
        # Image from kenney.nl asset pack #1
        arcade.draw_text("draw_bitmap", 483, 3, arcade.color.BLACK, 12)
        texture = arcade.load_texture(
            ":resources:images/space_shooter/playerShip1_orange.png")
        scale = .6
        # arcade.draw_texture_rectangle(540, 120, scale * texture.width,
        #                               scale * texture.height, texture, 0)
        # arcade.draw_texture_rectangle(540, 60, scale * texture.width,
        #                               scale * texture.height, texture, 45)
        #
        # Overlapping, with transparency test
        # Draw
        arcade.draw_rectangle_filled(650, 100, 50, 50, (255, 0, 0))
        arcade.draw_rectangle_filled(670, 100, 50, 50, (0, 255, 0, 127))

        import sys
        # TODO: Fix. See https://github.com/pvcraven/arcade/issues/539
        if sys.platform != "darwin":
            # Test colors
            color = arcade.get_pixel(635, 100)
            assert color == (255, 0, 0)
            color = arcade.get_pixel(670, 100)
            assert color == (128, 127, 0)
            color = arcade.get_pixel(690, 100)
            assert color == (128, 255, 128)

            # Test this other thing
            color = arcade.get_pixel(100, 100)
            assert color == (255, 255, 255)

        # Run the get image. Ideally we'd test the output
        arcade.get_image()