Example #1
0
    def __create_floor__(self):
        point_list = []
        color_list = []
        for field_x in range(self.engine.field_size[0] + 1):
            x = field_x * FLOOR_TILE_WIDTH
            start = (x, 0)
            end = (x, self.field_height)
            point_list.append(start)
            point_list.append(end)
            for i in range(2):
                color_list.append(arcade.color.BLACK)

        for field_y in range(self.engine.field_size[1] + 1):
            y = field_y * FLOOR_TILE_WIDTH
            start = (0, y)
            end = (self.field_width, y)
            point_list.append(start)
            point_list.append(end)
            for i in range(2):
                color_list.append(arcade.color.BLACK)

        lines = arcade.create_lines_with_colors(point_list, color_list)

        grid = arcade.ShapeElementList()
        grid.append(lines)
        return grid
def create_line_strip():
    shape_list = arcade.ShapeElementList()

    line_strip = arcade.create_lines_with_colors(([10, 10], [500, 10],
                                                  [10, 250], [500, 250],
                                                  [10, 500], [500, 500]),
                                                 (arcade.color.RED, arcade.color.BLACK, arcade.color.GREEN, arcade.color.BLACK, arcade.color.BLUE, arcade.color.BLACK), line_width=4)

    shape_list.append(line_strip)

    return shape_list
Example #3
0
    def __init__(self, width, height, title):
        """
        Set up the application.
        """

        super().__init__(width, height, title)

        arcade.set_background_color(arcade.color.BLACK)

        self.shapes = arcade.ShapeElementList()

        # This is a large rectangle that fills the whole
        # background. The gradient goes between the two colors
        # top to bottom.
        color1 = (215, 214, 165)
        color2 = (219, 166, 123)
        points = (0, 0), (SCREEN_WIDTH, 0), (SCREEN_WIDTH, SCREEN_HEIGHT), (0, SCREEN_HEIGHT)
        colors = (color1, color1, color2, color2)
        rect = arcade.create_rectangle_filled_with_colors(points, colors)
        self.shapes.append(rect)

        # Another rectangle, but in this case the color doesn't change. Just the
        # transparency. This time it goes from left to right.
        color1 = (165, 92, 85, 255)
        color2 = (165, 92, 85, 0)
        points = (100, 100), (SCREEN_WIDTH - 100, 100), (SCREEN_WIDTH - 100, 300), (100, 300)
        colors = (color2, color1, color1, color2)
        rect = arcade.create_rectangle_filled_with_colors(points, colors)
        self.shapes.append(rect)

        # Two lines
        color1 = (7, 67, 88)
        color2 = (69, 137, 133)
        points = (100, 400), (SCREEN_WIDTH - 100, 400), (SCREEN_WIDTH - 100, 500), (100, 500)
        colors = [color2, color1, color2, color1]
        shape = arcade.create_lines_with_colors(points, colors, line_width=5)
        self.shapes.append(shape)

        # Triangle
        color1 = (215, 214, 165)
        color2 = (219, 166, 123)
        color3 = (165, 92, 85)
        points = (SCREEN_WIDTH // 2, 500), (SCREEN_WIDTH // 2 - 100, 400), (SCREEN_WIDTH // 2 + 100, 400)
        colors = (color1, color2, color3)
        shape = arcade.create_triangles_filled_with_colors(points, colors)
        self.shapes.append(shape)

        # Ellipse, gradient between center and outside
        color1 = (69, 137, 133, 127)
        color2 = (7, 67, 88, 127)
        shape = arcade.create_ellipse_filled_with_colors(SCREEN_WIDTH // 2, 350, 50, 50,
                                                         inside_color=color1, outside_color=color2)
        self.shapes.append(shape)
def create_mountain_range(height_min, height_max, color_start, color_end):

    shape_list = arcade.ShapeElementList()

    step_max = 1.5
    step_change = 0.5

    height = random.random() * height_max
    slope = (random.random() * step_max * 2) - step_max

    line_point_list = []
    line_color_list = []

    for x in range(SCREEN_WIDTH):
        height += slope
        slope += (random.random() * step_change * 2) - step_change

        if slope > step_max:
            slope = step_max
        elif slope < -step_max:
            slope = -step_max

        if height > height_max:
            height = height_max
            slope *= -1
        elif height < height_min:
            height = height_min
            slope *= -1

        line_point_list.extend(((x, height), (x, 0)))
        line_color_list.extend((color_start, color_end))

    lines = arcade.create_lines_with_colors(line_point_list, line_color_list)
    shape_list.append(lines)

    return shape_list
Example #5
0
arcade.open_window(800, 600, "Drawing Example")
arcade.set_background_color(arcade.color.WHITE)
my_list = arcade.ShapeElementList()
my_shape = arcade.create_ellipse_outline(50, 50, 20, 20, arcade.color.RED, 45)
my_list.append(my_shape)
my_shape = arcade.create_ellipse_filled(50, 50, 20, 20, arcade.color.RED, 2,
                                        45)
my_list.append(my_shape)
my_shape = arcade.create_rectangle_filled(250, 50, 20, 20, arcade.color.RED,
                                          45)
my_list.append(my_shape)
my_shape = arcade.create_rectangle_outline(450, 50, 20, 20, (127, 0, 27, 127),
                                           2, 45)
my_list.append(my_shape)
my_shape = arcade.create_lines_with_colors(
    ([0, 400], [700, 400]), ((127, 0, 27, 127), arcade.color.GREEN), 2)
my_list.append(my_shape)
my_list.move(5, 5)
arcade.start_render()
my_list.draw()
arcade.finish_render()
arcade.quick_run(3)

import arcade

window = arcade.Window(200, 100, resizable=True)
window.set_update_rate(1 / 20)
window.set_mouse_visible(True)
window.on_mouse_motion(0, 0, 0, 0)
window.on_mouse_press(0, 0, 0, 0)
window.on_mouse_release(0, 0, 0, 0)