def on_draw():
    arcade.start_render()
    arcade.draw_rectangle_filled(WIDTH * 1 / 5 + 20, HEIGHT / 4 + 30, 640, 480, arcade.color.LIGHT_GREEN)
    for i in range(len(ball_pos)):
        arcade.draw_circle_filled(ball_pos[i][0], ball_pos[i][1], 5, ball_pos[i][2])
    for i in range(len(history)):
        arcade.draw_line(ball_pos[history[i][0]][0], ball_pos[history[i][0]][1], ball_pos[history[i][1]][0],
                         ball_pos[history[i][1]][1], arcade.color.RED)
    arcade.draw_circle_filled(10, 740, 5, arcade.color.BLACK)  # Unaffected
    arcade.draw_circle_filled(10, 720, 5, arcade.color.RED)  # Infected
    arcade.draw_circle_filled(10, 700, 5, arcade.color.GRAY)  # Cured
    arcade.draw_circle_filled(10, 680, 5, arcade.color.YELLOW)  # Dead
    arcade.draw_text(
        f'Number unaffected: {population - len(history) - 1}\nNumber infected: {(len(history) + 1)-CURED-DEAD}\nNumber cured: {CURED}\nNumber deceased: {DEAD}\nTime elapsed: {(time_elapsed):.2f}',
        20, HEIGHT / 2 + 200,
        arcade.color.BLACK, 18)
    if not start:
        draw_button(WIDTH - 100, 50, 100, 30, arcade.color.GREEN, 'Start', arcade.color.LIGHT_GREEN, arcade.color.RED)
    else:
        draw_button(WIDTH - 100, 50, 100, 30, arcade.color.GREEN, 'Pause', arcade.color.LIGHT_GREEN, arcade.color.RED)
    sliders()
    sliders1()
    sliders2()
    draw_reset_button(WIDTH / 2, HEIGHT / 2 - 300, 150, 50, arcade.color.RED, "Reset", arcade.color.SALMON_PINK,
                      arcade.color.PINK)
    graph()
예제 #2
0
    def on_draw(self):
        """
        Render the screen.
        """

        # This command has to happen before we start drawing
        arcadeplus.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)
            arcadeplus.draw_line(pv1.x, pv1.y, pv2.x, pv2.y, arcadeplus.color.WHITE, 2)

        # Display timings
        output = f"Processing time: {self.processing_time:.3f}"
        arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 20, arcadeplus.color.WHITE, 12)

        output = f"Drawing time: {self.draw_time:.3f}"
        arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 40, arcadeplus.color.WHITE, 12)

        self.draw_time = timeit.default_timer() - draw_start_time
def on_draw():
    arcade.start_render()
    # Draw in here...
    # arcade.draw_circle_filled(mouse_x, mouse_y, 25, ball_color)
    arcade.draw_line(0, HEIGHT / 2, WIDTH, HEIGHT / 2, arcade.color.BLACK)
    arcade.draw_line(WIDTH / 2, HEIGHT, WIDTH / 2, 0, arcade.color.BLACK)
    for i in range(WIDTH * 2):
        arcade.draw_point(i, 0.001 * (i - WIDTH / 2)**2, arcade.color.BLUE, 10)
예제 #4
0
def on_draw():
    arcade.start_render()
    # Draw in here...
    # arcade.draw_circle_filled(mouse_x, mouse_y, 25, ball_color)
    for i in range(len(ball_pos)):
        arcade.draw_circle_filled(ball_pos[i][0], ball_pos[i][1], 5, ball_pos[i][2])
    for i in range(len(history)):
        arcade.draw_line(ball_pos[history[i][0]][0], ball_pos[history[i][0]][1], ball_pos[history[i][1]][0],
                         ball_pos[history[i][1]][1], arcade.color.RED)
    arcade.draw_text(f'Number infected: {len(history) + 1}\nTime elapsed: {(time_elapsed):.2f}', 0, 0,
                     arcade.color.BLACK, 18)
def graph():
    middle_x = WIDTH * 3/4 + 70
    middle_y = HEIGHT * 3/4 - 100
    length = 500
    width = 500
    arcade.draw_rectangle_filled(middle_x, middle_y, length, width, arcade.color.WHITE)
    arcade.draw_line(middle_x - width/2, middle_y - length/2 + 20, middle_x + width/2, middle_y - length/2 + 20, arcade.color.BLACK)
    arcade.draw_line(middle_x - width/2 + 20, middle_y - length/2, middle_x - width/2 + 20, middle_y + length/2, arcade.color.BLACK)
    for point in graph_data:
        arcade.draw_point(point[4] * 3 + middle_x - width/2 + 20, point[0] * 3 + middle_y - length/2 + 20, arcade.color.BLACK, 5)
        arcade.draw_point(point[4] * 3 + middle_x - width/2 + 20, point[1] * 3 + middle_y - length/2 + 20, arcade.color.RED, 5)
        arcade.draw_point(point[4] * 3 + middle_x - width/2 + 20, point[2] * 3 + middle_y - length/2 + 20, arcade.color.GRAY, 5)
        arcade.draw_point(point[4] * 3 + middle_x - width/2 + 20, point[3] * 3 + middle_y - length/2 + 20, arcade.color.YELLOW, 5)
예제 #6
0
    def on_draw(self):
        """
        Render the screen.
        """

        # This command has to happen before we start drawing
        arcadeplus.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)
            arcadeplus.draw_line(pv1.x, pv1.y, pv2.x, pv2.y,
                                 arcadeplus.color.WHITE, 2)

        for joint in self.joints:
            color = arcadeplus.color.WHITE
            if isinstance(joint, pymunk.DampedSpring):
                color = arcadeplus.color.DARK_GREEN
            arcadeplus.draw_line(joint.a.position.x, joint.a.position.y,
                                 joint.b.position.x, joint.b.position.y, color,
                                 3)

        # arcadeplus.draw_text(output, 10, 20, arcadeplus.color.WHITE, 14)
        # Display timings
        output = f"Processing time: {self.processing_time:.3f}"
        arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 20,
                             arcadeplus.color.WHITE)

        output = f"Drawing time: {self.draw_time:.3f}"
        arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 40,
                             arcadeplus.color.WHITE)

        self.draw_time = timeit.default_timer() - draw_start_time

        output = f"Mode: {self.mode}"
        arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 60,
                             arcadeplus.color.WHITE)

        output = f"Physics: {self.physics}"
        arcadeplus.draw_text(output, 20, SCREEN_HEIGHT - 80,
                             arcadeplus.color.WHITE)
예제 #7
0
    def draw(self):
        """ Draw the button """
        arcadeplus.draw_rectangle_filled(self.center_x, self.center_y,
                                         self.width, self.height,
                                         self.face_color)

        if not self.pressed:
            color = self.shadow_color
        else:
            color = self.highlight_color

        # Bottom horizontal
        arcadeplus.draw_line(self.center_x - self.width / 2,
                             self.center_y - self.height / 2,
                             self.center_x + self.width / 2,
                             self.center_y - self.height / 2, color,
                             self.button_height)

        # Right vertical
        arcadeplus.draw_line(self.center_x + self.width / 2,
                             self.center_y - self.height / 2,
                             self.center_x + self.width / 2,
                             self.center_y + self.height / 2, color,
                             self.button_height)

        if not self.pressed:
            color = self.highlight_color
        else:
            color = self.shadow_color

        # Top horizontal
        arcadeplus.draw_line(self.center_x - self.width / 2,
                             self.center_y + self.height / 2,
                             self.center_x + self.width / 2,
                             self.center_y + self.height / 2, color,
                             self.button_height)

        # Left vertical
        arcadeplus.draw_line(self.center_x - self.width / 2,
                             self.center_y - self.height / 2,
                             self.center_x - self.width / 2,
                             self.center_y + self.height / 2, color,
                             self.button_height)

        x = self.center_x
        y = self.center_y
        if not self.pressed:
            x -= self.button_height
            y += self.button_height

        arcadeplus.draw_text(self.text,
                             x,
                             y,
                             arcadeplus.color.BLACK,
                             font_size=self.font_size,
                             width=self.width,
                             align="center",
                             anchor_x="center",
                             anchor_y="center")
예제 #8
0
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.
    arcadeplus.start_render()

    # Draw the radar line
    arcadeplus.draw_line(CENTER_X, CENTER_Y, x, y, arcadeplus.color.OLIVE, 4)

    # Draw the outline of the radar
    arcadeplus.draw_circle_outline(CENTER_X, CENTER_Y, SWEEP_LENGTH,
                                   arcadeplus.color.DARK_GREEN, 10)
예제 #9
0
    def draw_color_theme(self):
        arcadeplus.draw_rectangle_filled(self.center_x, self.center_y,
                                         self.width, self.height,
                                         self.face_color)

        if not self.pressed:
            color = self.shadow_color
        else:
            color = self.highlight_color

        # Bottom horizontal
        arcadeplus.draw_line(self.center_x - self.width / 2,
                             self.center_y - self.height / 2,
                             self.center_x + self.width / 2,
                             self.center_y - self.height / 2, color,
                             self.button_height)

        # Right vertical
        arcadeplus.draw_line(self.center_x + self.width / 2,
                             self.center_y - self.height / 2,
                             self.center_x + self.width / 2,
                             self.center_y + self.height / 2, color,
                             self.button_height)

        if not self.pressed:
            color = self.highlight_color
        else:
            color = self.shadow_color

        # Top horizontal
        arcadeplus.draw_line(self.center_x - self.width / 2,
                             self.center_y + self.height / 2,
                             self.center_x + self.width / 2,
                             self.center_y + self.height / 2, color,
                             self.button_height)

        # Left vertical
        arcadeplus.draw_line(self.center_x - self.width / 2,
                             self.center_y - self.height / 2,
                             self.center_x - self.width / 2,
                             self.center_y + self.height / 2, color,
                             self.button_height)

        x = self.center_x
        y = self.center_y
        if not self.pressed:
            x -= self.button_height
            y += self.button_height
예제 #10
0
arcadeplus.open_window(600, 600, "Drawing Primitives Example")

# Set the background color to white
# For a list of named colors see
# http://arcadeplus.academy/arcadeplus.color.html
# Colors can also be specified in (red, green, blue) format and
# (red, green, blue, alpha) format.
arcadeplus.set_background_color(arcadeplus.color.WHITE)

# Start the render process. This must be done before any drawing commands.
arcadeplus.start_render()

# Draw a grid
# Draw vertical lines every 120 pixels
for x in range(0, 601, 120):
    arcadeplus.draw_line(x, 0, x, 600, arcadeplus.color.BLACK, 2)

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

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

# Draw a set of points
arcadeplus.draw_text("draw_points", 123, 405, arcadeplus.color.BLACK, 12)
point_list = ((165, 495), (165, 480), (165, 465), (195, 495), (195, 480),
              (195, 465))
arcadeplus.draw_points(point_list, arcadeplus.color.ZAFFRE, 10)
예제 #11
0
    def on_draw(self):
        """
        Render the screen.
        """

        # Start the render process. This must be done before any drawing commands.
        arcadeplus.start_render()

        # Draw a grid
        # Draw vertical lines every 120 pixels
        for x in range(0, 601, 120):
            arcadeplus.draw_line(x, 0, x, 600, arcadeplus.color.BLACK, 2)

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

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

        # Draw a set of points
        arcadeplus.draw_text("draw_points", 123, 405, arcadeplus.color.BLACK,
                             12)
        point_list = ((165, 495), (165, 480), (165, 465), (195, 495),
                      (195, 480), (195, 465))
        arcadeplus.draw_points(point_list, arcadeplus.color.ZAFFRE, 10)

        # Draw a line
        arcadeplus.draw_text("draw_line", 243, 405, arcadeplus.color.BLACK, 12)
        arcadeplus.draw_line(270, 495, 300, 450, arcadeplus.color.WOOD_BROWN,
                             3)

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

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

        # Draw a polygon
        arcadeplus.draw_text("draw_polygon_outline", 3, 207,
                             arcadeplus.color.BLACK, 9)
        point_list = ((30, 240), (45, 240), (60, 255), (60, 285), (45, 300),
                      (30, 300))
        arcadeplus.draw_polygon_outline(point_list,
                                        arcadeplus.color.SPANISH_VIOLET, 3)

        # Draw a filled in polygon
        arcadeplus.draw_text("draw_polygon_filled", 123, 207,
                             arcadeplus.color.BLACK, 9)
        point_list = ((150, 240), (165, 240), (180, 255), (180, 285),
                      (165, 300), (150, 300))
        arcadeplus.draw_polygon_filled(point_list,
                                       arcadeplus.color.SPANISH_VIOLET)

        # Draw an outline of a circle
        arcadeplus.draw_text("draw_circle_outline", 243, 207,
                             arcadeplus.color.BLACK, 10)
        arcadeplus.draw_circle_outline(300, 285, 18, arcadeplus.color.WISTERIA,
                                       3)
        arcadeplus.draw_circle_outline(350, 285, 18, arcadeplus.color.WISTERIA)

        # Draw a filled in circle
        arcadeplus.draw_text("draw_circle_filled", 363, 207,
                             arcadeplus.color.BLACK, 10)
        arcadeplus.draw_circle_filled(420, 285, 18, arcadeplus.color.GREEN)

        # Draw an ellipse outline, and another one rotated
        arcadeplus.draw_text("draw_ellipse_outline", 483, 207,
                             arcadeplus.color.BLACK, 10)
        arcadeplus.draw_ellipse_outline(540, 273, 15, 36,
                                        arcadeplus.color.AMBER, 3)
        arcadeplus.draw_ellipse_outline(540, 336, 15, 36,
                                        arcadeplus.color.BLACK_BEAN, 3, 45)

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

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

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

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

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

        # Test colors
        color = arcadeplus.get_pixel(635, 100)
        assert color == (255, 0, 0)
        color = arcadeplus.get_pixel(670, 100)
        assert color == (128, 127, 0)
        color = arcadeplus.get_pixel(690, 100)
        assert color == (128, 255, 128)

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

        # Run the get image. Ideally we'd test the output
        arcadeplus.get_image()
예제 #12
0
 def draw(self):
     arcadeplus.draw_line(self.start_x, self.start_y, self.end_x,
                          self.end_y, arcadeplus.color.WOOD_BROWN, 4)
예제 #13
0
    def on_draw(self):
        """
        Render the screen.
        """

        # Start the render process. This must be done before any drawing commands.
        arcadeplus.start_render()

        radius = 50
        width = radius * 2
        x = 200
        y = 100
        arcadeplus.draw_rectangle_outline(x, y, width, width,
                                          arcadeplus.color.BLACK, 2)
        arcadeplus.draw_circle_outline(x, y, radius, arcadeplus.color.BLACK, 2)
        arcadeplus.draw_line(x - radius, y, x + radius, y,
                             arcadeplus.color.BLACK, 2)

        x = 200
        y = 300
        width = 150
        half_width = width / 2
        arcadeplus.draw_rectangle_outline(x, y, width, 50,
                                          arcadeplus.color.BLACK, 2)
        arcadeplus.draw_ellipse_outline(x, y, width, 50,
                                        arcadeplus.color.AFRICAN_VIOLET, 2)
        arcadeplus.draw_line(x - half_width, y, x + half_width, y,
                             arcadeplus.color.RED, 2)

        x = 200
        y = 500
        width = 150
        half_width = width / 2
        arcadeplus.draw_rectangle_outline(x, y, width, 50,
                                          arcadeplus.color.BLACK, 2)
        arcadeplus.draw_arc_outline(x, y, width, 50,
                                    arcadeplus.color.AFRICAN_VIOLET, 0, 180, 5)
        arcadeplus.draw_line(x - half_width, y, x + half_width, y,
                             arcadeplus.color.RED, 2)

        radius = 50
        width = radius * 2
        x = 400
        y = 100
        arcadeplus.draw_rectangle_outline(x, y, width, width,
                                          arcadeplus.color.BLACK, 2)
        arcadeplus.draw_circle_filled(x, y, radius,
                                      arcadeplus.color.AFRICAN_VIOLET)
        arcadeplus.draw_line(x - radius, y, x + radius, y,
                             arcadeplus.color.BLACK, 2)

        x = 400
        y = 300
        width = 150
        half_width = width / 2
        arcadeplus.draw_rectangle_outline(x, y, width, 50,
                                          arcadeplus.color.BLACK, 2)
        arcadeplus.draw_ellipse_filled(x, y, width, 50,
                                       arcadeplus.color.AFRICAN_VIOLET, 2)
        arcadeplus.draw_line(x - half_width, y, x + half_width, y,
                             arcadeplus.color.RED, 2)

        x = 400
        y = 500
        width = 150
        half_width = width / 2
        arcadeplus.draw_rectangle_outline(x, y, width, 50,
                                          arcadeplus.color.BLACK, 2)
        arcadeplus.draw_arc_filled(x, y, width, 50,
                                   arcadeplus.color.AFRICAN_VIOLET, 0, 180)
        arcadeplus.draw_line(x - half_width, y, x + half_width, y,
                             arcadeplus.color.RED, 2)