示例#1
0
def main ():
    arcade.open_window(800, 800, "Hey We Have a Window")
    arcade.set_background_color(arcade.color.ALMOND)
    # now create objects
    main_house = arcade.create_rectangle(400, 200, 400, 400, arcade.color.ANTIQUE_BRASS)
    door = arcade.create_rectangle(400, 75, 100, 150, arcade.color.ARMY_GREEN)
    window1 = arcade.create_ellipse(300, 300, 50, 50, arcade.color.BABY_BLUE)
    window2 = arcade.create_ellipse(500, 300, 50, 50, arcade.color.BABY_BLUE)
    roof_points = [(200, 400), (400, 600), (600, 400)]
    roof = arcade.create_polygon(roof_points, arcade.color.DARK_GRAY)
    line = arcade.create_line(175, 725, 550, 725, arcade.color.FALU_RED)

    # now we will begin to draw
    arcade.start_render()
    # draw everything here
    arcade.draw_text("Boy that was an ugly house", 200, 750, arcade.color.ALABAMA_CRIMSON, 22)
    main_house.draw()
    door.draw()
    window1.draw()
    window2.draw()
    roof.draw()
    line.draw()

    arcade.finish_render()

    arcade.run()
    def draw_planes(self, planes=list):
        self.plane_list = None
        self.plane_list = arcade.ShapeElementList()
        for plane in planes:
            if self._draw_planes:
                for (i, j) in plane.edges:
                    p0 = plane.box_intersections[i]
                    p1 = plane.box_intersections[j]

                    dot = arcade.create_ellipse(*p0[:2], 5, 5,
                                                arcade.color.LIGHT_GRAY)
                    self.plane_list.append(dot)
                    dot = arcade.create_ellipse(*p1[:2], 5, 5,
                                                arcade.color.LIGHT_GRAY)
                    self.plane_list.append(dot)

                    line = arcade.create_line(*p0[:2], *p1[:2],
                                              arcade.color.LIGHT_GRAY, 1)
                    self.plane_list.append(line)

            point = arcade.create_ellipse(*plane.point[:2], 5, 5,
                                          arcade.color.LIGHT_GREEN)
            start = plane.point
            end1 = plane.point + 15 * plane.unitnormal
            end2 = plane.point - 15 * plane.unitnormal
            normal1 = arcade.create_line(*start[:2], *end1[:2],
                                         arcade.color.LIGHT_GREEN, 1)
            normal2 = arcade.create_line(*start[:2], *end2[:2],
                                         arcade.color.LIGHT_RED_OCHRE, 1)
            self.plane_list.append(point)
            self.plane_list.append(normal1)
            self.plane_list.append(normal2)

            self.draw_plane_holes(plane)
示例#3
0
def main():
    arcade.open_window(800, 800, "first window example")
    arcade.set_background_color(arcade.color.ALMOND)

    #now create objects
    main_house = arcade.create_rectangle(400, 200, 400, 400,
                                         arcade.color.ANTIQUE_BRASS)
    door = arcade.create_rectangle(400, 75, 100, 150, arcade.color.ARMY_GREEN)
    window_1 = arcade.create_ellipse(300, 300, 50, 50, arcade.color.AERO_BLUE)
    window_2 = arcade.create_ellipse(500, 300, 50, 50, arcade.color.AERO_BLUE)
    roof_points = [(200, 400), (400, 600), (600, 400)]
    roof = arcade.create_polygon(roof_points, arcade.color.DARK_GRAY)
    line = arcade.create_line(200, 730, 510, 730, arcade.color.ROSE)

    #now we will begin to draw
    arcade.start_render()
    #draw everything here
    arcade.draw_text("boy is that an ugly house", 200, 750,
                     arcade.color.ALABAMA_CRIMSON, 22)

    main_house.draw()
    door.draw()
    window_1.draw()
    window_2.draw()
    roof.draw()
    line.draw()

    arcade.finish_render()

    arcade.run()
    def __init__(self, width, height, title):
        """
        Set up the application.
        """
        super().__init__(width, height, title)

        self.shape_list = arcade.ShapeElementList()
        self.shape_list.center_x = SCREEN_WIDTH // 2
        self.shape_list.center_y = SCREEN_HEIGHT // 2
        self.shape_list.angle = 0
        point_list = ((0, 50), (10, 10), (50, 0), (10, -10), (0, -50),
                      (-10, -10), (-50, 0), (-10, 10), (0, 50))
        colors = [
            getattr(arcade.color, color) for color in dir(arcade.color)
            if not color.startswith("__")
        ]
        for i in range(5):
            x = SCREEN_WIDTH // 2 - random.randrange(SCREEN_WIDTH - 50)
            y = SCREEN_HEIGHT // 2 - random.randrange(SCREEN_HEIGHT - 50)
            color = random.choice(colors)
            points = [(px + x, py + y) for px, py in point_list]

            my_line_strip = arcade.create_line_strip(points, color, 5)
            self.shape_list.append(my_line_strip)

        point_list = ((-50, -50), (0, 40), (50, -50))
        for i in range(5):
            x = SCREEN_WIDTH // 2 - random.randrange(SCREEN_WIDTH - 50)
            y = SCREEN_HEIGHT // 2 - random.randrange(SCREEN_HEIGHT - 50)
            points = [(px + x, py + y) for px, py in point_list]
            triangle_filled = arcade.create_triangles_filled_with_colors(
                points, random.sample(colors, 3))
            self.shape_list.append(triangle_filled)

        point_list = ((-50, -70), (-50, 70), (50, 70), (50, -70))
        for i in range(5):
            x = SCREEN_WIDTH // 2 - random.randrange(SCREEN_WIDTH - 50)
            y = SCREEN_HEIGHT // 2 - random.randrange(SCREEN_HEIGHT - 50)
            points = [(px + x, py + y) for px, py in point_list]
            rect_filled = arcade.create_rectangle_filled_with_colors(
                points, random.sample(colors, 4))
            self.shape_list.append(rect_filled)

        point_list = ((100, 100), (50, 150), (100, 200), (200, 200),
                      (250, 150), (200, 100))
        poly = arcade.create_polygon(point_list, (255, 10, 10))
        self.shape_list.append(poly)

        ellipse = arcade.create_ellipse(20, 30, 50, 20, (230, 230, 0))
        self.shape_list.append(ellipse)

        arcade.set_background_color(arcade.color.BLACK)

        self.offscreen = self.ctx.framebuffer(
            color_attachments=self.ctx.texture((SCREEN_WIDTH, SCREEN_HEIGHT),
                                               wrap_x=gl.GL_CLAMP_TO_EDGE,
                                               wrap_y=gl.GL_CLAMP_TO_EDGE))
        self.glow = postprocessing.BloomEffect((SCREEN_WIDTH, SCREEN_HEIGHT))
示例#5
0
    def __init__(self, width, height):
        """
        Set up the application.
        """
        super().__init__(width, height)

        self.shape_list = arcade.ShapeElementList()
        self.shape_list.center_x = SCREEN_WIDTH // 2
        self.shape_list.center_y = SCREEN_HEIGHT // 2
        self.shape_list.angle = 0
        point_list = ((0, 50), (10, 10), (50, 0), (10, -10), (0, -50),
                      (-10, -10), (-50, 0), (-10, 10), (0, 50))
        colors = [
            getattr(arcade.color, color) for color in dir(arcade.color)
            if not color.startswith("__")
        ]
        for i in range(5):
            x = SCREEN_WIDTH // 2 - random.randrange(SCREEN_WIDTH - 50)
            y = SCREEN_HEIGHT // 2 - random.randrange(SCREEN_HEIGHT - 50)
            color = random.choice(colors)
            points = [(px + x, py + y) for px, py in point_list]

            my_line_strip = arcade.create_line_strip(points, color, 5)
            self.shape_list.append(my_line_strip)

        point_list = ((-50, -50), (0, 40), (50, -50))
        for i in range(5):
            x = SCREEN_WIDTH // 2 - random.randrange(SCREEN_WIDTH - 50)
            y = SCREEN_HEIGHT // 2 - random.randrange(SCREEN_HEIGHT - 50)
            points = [(px + x, py + y) for px, py in point_list]
            triangle_filled = arcade.create_triangles_filled_with_colors(
                points, random.sample(colors, 3))
            self.shape_list.append(triangle_filled)

        point_list = ((-50, -70), (-50, 70), (50, 70), (50, -70))
        for i in range(5):
            x = SCREEN_WIDTH // 2 - random.randrange(SCREEN_WIDTH - 50)
            y = SCREEN_HEIGHT // 2 - random.randrange(SCREEN_HEIGHT - 50)
            points = [(px + x, py + y) for px, py in point_list]
            rect_filled = arcade.create_rectangle_filled_with_colors(
                points, random.sample(colors, 4))
            self.shape_list.append(rect_filled)

        point_list = ((100, 100), (50, 150), (100, 200), (200, 200),
                      (250, 150), (200, 100))
        poly = arcade.create_polygon(point_list, (255, 10, 10), 5)
        self.shape_list.append(poly)

        ellipse = arcade.create_ellipse(20, 30, 50, 20, (230, 230, 0))
        self.shape_list.append(ellipse)

        arcade.set_background_color(arcade.color.BLACK)
示例#6
0
    def recreate_grid(self):
        self.shape_list = arcade.ShapeElementList()
        vertical = [
            k for k in list(
                zip([[i * TILE_SIZE + TILE_SIZE, TILE_SIZE]
                     for i in range(BOARD_SIZE + 1)],
                    [[i * TILE_SIZE + TILE_SIZE, TILE_SIZE * BOARD_SIZE]
                     for i in range(BOARD_SIZE)])) for k in k
        ]
        horizontal = [
            k for k in list(
                zip([[TILE_SIZE, i * TILE_SIZE + TILE_SIZE]
                     for i in range(BOARD_SIZE + 1)],
                    [[TILE_SIZE * BOARD_SIZE, i * TILE_SIZE + TILE_SIZE]
                     for i in range(BOARD_SIZE)])) for k in k
        ]
        arcade.create_ellipse(center_x=3 * TILE_SIZE + TILE_SIZE,
                              center_y=3 * TILE_SIZE + TILE_SIZE,
                              height=4,
                              width=4,
                              color=arcade.color.BLACK)
        for x_point in [3, 9, 15]:
            for y_point in [3, 9, 15]:
                self.shape_list.append(
                    arcade.create_ellipse(
                        center_x=x_point * TILE_SIZE + TILE_SIZE,
                        center_y=y_point * TILE_SIZE + TILE_SIZE,
                        height=4,
                        width=4,
                        color=arcade.color.BLACK))

        self.shape_list.append(
            arcade.create_lines(point_list=vertical,
                                color=(10, 10, 10),
                                line_width=1))
        self.shape_list.append(
            arcade.create_lines(point_list=horizontal,
                                color=(10, 10, 10),
                                line_width=1))
示例#7
0
def create_shapes(win_width, win_height):
    shape_list = []
    win_width = win_width / 4
    rectangle = arcade.create_rectangle_filled(win_width, 350, 100, 200,
                                               arcade.color.BABY_PINK)
    circle = arcade.create_ellipse(win_width * 3, 350, 50, 50,
                                   arcade.color.PUCE_RED)
    line = arcade.create_line(win_width, 650, win_width * 3, 75,
                              arcade.color.CANARY_YELLOW)
    shape_list.append(rectangle)
    shape_list.append(circle)
    shape_list.append(line)
    return shape_list
示例#8
0
def main():
    arcade.open_window(700, 700, "Smile Demo")
    arcade.set_background_color(arcade.color.AFRICAN_VIOLET)
    face = arcade.create_ellipse(350, 350, 300, 300,
                                 arcade.color.ANTIQUE_BRASS)
    points = [(250, 350), (450, 350), (350, 425)]
    nose = arcade.create_polygon(points, arcade.color.GRANNY_SMITH_APPLE)
    eye1 = arcade.create_ellipse(300, 450, 100, 100,
                                 arcade.color.BANANA_YELLOW)
    eye2 = arcade.create_ellipse(500, 450, 100, 100,
                                 arcade.color.BANANA_YELLOW)

    arcade.start_render()
    face.draw()
    nose.draw()
    eye1.draw()
    eye2.draw()
    arcade.draw_arc_outline(350, 200, 200, 200, arcade.color.RED_DEVIL, 180,
                            360, 3)
    arcade.finish_render()

    arcade.run()
示例#9
0
    def __setup_draw(self):
        self.road_back.append(
            arcade.create_line_strip(self.points, arcade.color.DARK_GRAY,
                                     self.thickness))
        self.road_front.append(
            arcade.create_line_strip(self.points, arcade.color.BLACK, 1))

        for e in self.points:
            self.draw_points.append(
                arcade.create_ellipse(e.x, e.y, 1, 1, arcade.color.YELLOW))

        for b in self.turn_boundaries:
            self.draw_boundaries.append(b.draw_line(20))
示例#10
0
def main():
    arcade.open_window(700, 700, "Smile Demo")
    arcade.set_background_color(arcade.color.PIGGY_PINK)
    # create objects here
    face = arcade.create_ellipse_outline(350, 350, 200, 200,
                                         arcade.color.BLACK)
    eye1 = arcade.create_ellipse(270, 400, 30, 30, arcade.color.BLACK)
    eye2 = arcade.create_ellipse(420, 400, 30, 30, arcade.color.BLACK)
    nose_points = [(320, 350), (370, 350), (345, 370)]
    nose = arcade.create_polygon(nose_points, arcade.color.DARK_PINK)

    arcade.start_render()
    # draw stuff here
    face.draw()
    eye1.draw()
    eye2.draw()
    nose.draw()
    arcade.draw_arc_outline(350, 350, 200, 125, arcade.color.RADICAL_RED, 180,
                            360, 3)

    arcade.finish_render()

    arcade.run()
示例#11
0
def create_shapes(win_width, win_height):
    x_scale = win_width / 4
    win_height = win_height / 4
    shape_list = []
    rectangle = arcade.create_rectangle(x_scale, win_height, 100, win_height,
                                        arcade.color.COPPER_PENNY)
    circle = arcade.create_ellipse(x_scale * 3, win_height, 50, 50,
                                   arcade.color.DARK_TANGERINE)
    shape_list.append(rectangle)
    shape_list.append(circle)
    line = arcade.create_line(x_scale, 600, x_scale * 3, win_height,
                              arcade.color.ENGLISH_LAVENDER, 3)
    shape_list.append(line)
    return shape_list
示例#12
0
    def on_draw(self):
        arcade.start_render()
        if self.state == "Idle":
            arcade.draw_text("Tic Tac Toe", 300, 300, arcade.color.WHITE, font_size=50, anchor_x="center")
            arcade.draw_text("Press X or O to choose a sign..", 300, 250, arcade.color.WHITE, font_size=20, anchor_x="center")

        elif self.state == "GameOn":
            self.shape_list = arcade.ShapeElementList()
            arcade.draw_line(0, 400, 600, 400, arcade.color.WHITE, 5)
            arcade.draw_line(0, 200, 600, 200, arcade.color.WHITE, 5)
            arcade.draw_line(400, 0, 400, 600, arcade.color.WHITE, 5)
            arcade.draw_line(200, 0, 200, 600, arcade.color.WHITE, 5)

            for sign in self.board:
                if sign == "o":
                    if self.board[0] == "o":
                        self.shape = arcade.create_ellipse(100,500,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(100,500,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[1] == "o":
                        self.shape = arcade.create_ellipse(300,500,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(300,500,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[2] == "o":
                        self.shape = arcade.create_ellipse(500,500,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(500,500,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[3] == "o":
                        self.shape = arcade.create_ellipse(100,300,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(100,300,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[4] == "o":
                        self.shape = arcade.create_ellipse(300,300,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(300,300,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[5] == "o":
                        self.shape = arcade.create_ellipse(500,300,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(500,300,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[6] == "o":
                        self.shape = arcade.create_ellipse(100,100,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(100,100,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[7] == "o":
                        self.shape = arcade.create_ellipse(300,100,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(300,100,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)
                    if self.board[8] == "o":
                        self.shape = arcade.create_ellipse(500,100,100,100,arcade.color.WHITE)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_ellipse(500,100,95,95,arcade.color.AZURE)
                        self.shape_list.append(self.shape)

                elif sign == "x":
                    if self.board[0] == "x":
                        self.shape = arcade.create_line(0, 600, 200, 400, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(200, 600, 0, 400, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[1] == "x":
                        self.shape = arcade.create_line(200, 600, 400, 400, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(400, 600, 200, 400, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[2] == "x":
                        self.shape = arcade.create_line(400, 600, 600, 400, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(600, 600, 400, 400, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[3] == "x":
                        self.shape = arcade.create_line(0, 400, 200, 200, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(200, 400, 0, 200, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[4] == "x":
                        self.shape = arcade.create_line(200, 400, 400, 200, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(400, 400, 200, 200, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[5] == "x":
                        self.shape = arcade.create_line(400, 400, 600, 200, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(600, 400, 400, 200, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[6] == "x":
                        self.shape = arcade.create_line(0, 200, 200, 0, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(200, 200, 0, 0, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[7] == "x":
                        self.shape = arcade.create_line(200, 200, 400, 0, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(400, 200, 200, 0, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                    if self.board[8] == "x":
                        self.shape = arcade.create_line(400, 200, 600, 0, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                        self.shape = arcade.create_line(600, 200, 400, 0, arcade.color.WHITE, 5)
                        self.shape_list.append(self.shape)
                self.shape_list.draw()

        elif self.state == "GameOver":
            if self.win == "p":
                arcade.draw_text("Congratulations, you won !", 300, 300, arcade.color.WHITE, font_size=40, anchor_x="center")
                arcade.draw_text("Click to continue", 300, 250, arcade.color.WHITE, font_size=20, anchor_x="center")

            elif self.win == "c":
                arcade.draw_text("Computer wins :(", 300, 300, arcade.color.WHITE, font_size=50, anchor_x="center")
                arcade.draw_text("Click to continue", 300, 250, arcade.color.WHITE, font_size=20, anchor_x="center")

            elif self.win == "d":
                arcade.draw_text("It's a draw..", 300, 300, arcade.color.WHITE, font_size=50, anchor_x="center")
                arcade.draw_text("Click to continue", 300, 250, arcade.color.WHITE, font_size=20, anchor_x="center")
示例#13
0
def render(w):
    scaled = w.position * 600
    e = arcade.create_ellipse(10, 10, arcade.color.RED)
    for index, row in scaled.iterrows():
        arcade.render_ellipse_filled(e, row.x, row.y)