Skip to content

Commit f9189c7

Browse files
authored
Merge branch 'master' into python-scipy-cluster-optimize
2 parents 0680f9d + de036ef commit f9189c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+4147
-0
lines changed

arcade-a-primer/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Source files supporting the **Arcade - A Modern Python Game Framework** article

arcade-a-primer/arcade_basic.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Basic arcade program
2+
# Displays a white window with a blue circle in the middle
3+
4+
# Imports
5+
import arcade
6+
7+
# Constants
8+
SCREEN_WIDTH = 600
9+
SCREEN_HEIGHT = 800
10+
SCREEN_TITLE = "Welcome to Arcade"
11+
RADIUS = 150
12+
13+
# Open the window
14+
arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
15+
16+
# Set the background color
17+
arcade.set_background_color(arcade.color.WHITE)
18+
19+
# Clear the screen and start drawing
20+
arcade.start_render()
21+
22+
# Draw a blue circle
23+
arcade.draw_circle_filled(
24+
SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, RADIUS, arcade.color.BLUE
25+
)
26+
27+
# Finish drawing
28+
arcade.finish_render()
29+
30+
# Display everything
31+
arcade.run()
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Basic arcade program using objects
2+
# Displays a white window with a blue circle in the middle
3+
4+
# Imports
5+
import arcade
6+
7+
# Constants
8+
SCREEN_WIDTH = 600
9+
SCREEN_HEIGHT = 800
10+
SCREEN_TITLE = "Welcome to Arcade"
11+
RADIUS = 150
12+
13+
# Classes
14+
15+
16+
class Welcome(arcade.Window):
17+
"""Our main welcome window
18+
"""
19+
20+
def __init__(self):
21+
"""Initialize the window
22+
"""
23+
24+
# Call the parent class constructor
25+
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
26+
27+
# Set the background window
28+
arcade.set_background_color(arcade.color.WHITE)
29+
30+
def on_draw(self):
31+
"""Called whenever we need to draw our window
32+
"""
33+
34+
# Clear the screen and start drawing
35+
arcade.start_render()
36+
37+
# Draw a blue circle
38+
arcade.draw_circle_filled(
39+
SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, RADIUS, arcade.color.BLUE
40+
)
41+
42+
43+
# Main code entry point
44+
if __name__ == "__main__":
45+
app = Welcome()
46+
arcade.run()
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Basic arcade program using objects
2+
# Draw shapes on screen
3+
4+
# Imports
5+
import arcade
6+
7+
# Constants
8+
SCREEN_WIDTH = 600
9+
SCREEN_HEIGHT = 650
10+
SCREEN_TITLE = "Draw Shapes"
11+
12+
# Classes
13+
14+
15+
class Welcome(arcade.Window):
16+
"""Our main welcome window
17+
"""
18+
19+
def __init__(self):
20+
"""Initialize the window
21+
"""
22+
23+
# Call the parent class constructor
24+
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
25+
26+
# Set the background window
27+
arcade.set_background_color(arcade.color.WHITE)
28+
29+
def on_draw(self):
30+
"""Called whenever we need to draw our window
31+
"""
32+
33+
# Clear the screen and start drawing
34+
arcade.start_render()
35+
36+
# Draw a blue arc
37+
arcade.draw_arc_filled(100, 100, 40, 40, arcade.color.BLUE, 0, 125)
38+
39+
# Draw a red ellipse
40+
arcade.draw_ellipse_outline(
41+
300, 100, 60, 30, arcade.color.RED, border_width=2
42+
)
43+
44+
# Draw some purple lines
45+
arcade.draw_line(500, 100, 550, 100, arcade.color.PURPLE)
46+
arcade.draw_line(500, 90, 550, 90, arcade.color.PURPLE, line_width=2)
47+
arcade.draw_line(500, 80, 550, 80, arcade.color.PURPLE, line_width=3)
48+
49+
# Draw an orange parabola
50+
arcade.draw_parabola_filled(100, 100, 130, 120, arcade.color.ORANGE)
51+
52+
# Draw a black point
53+
arcade.draw_point(300, 300, arcade.color.BLACK, 20)
54+
55+
# Draw a green polygon
56+
points_list = [
57+
[500, 300],
58+
[550, 300],
59+
[575, 325],
60+
[550, 350],
61+
[525, 340],
62+
]
63+
arcade.draw_polygon_outline(
64+
points_list, arcade.color.GREEN, line_width=5
65+
)
66+
67+
# Draw some rectangles
68+
arcade.draw_rectangle_filled(100, 500, 150, 75, arcade.color.AZURE)
69+
arcade.draw_lrtb_rectangle_filled(
70+
150, 250, 575, 525, arcade.color.AMARANTH_PINK
71+
)
72+
arcade.draw_xywh_rectangle_filled(
73+
200, 550, 150, 75, arcade.color.ASPARAGUS
74+
)
75+
76+
# Draw some triangles
77+
arcade.draw_triangle_filled(
78+
400, 500, 500, 500, 450, 575, arcade.color.DEEP_RUBY
79+
)
80+
81+
82+
# Main code entry point
83+
if __name__ == "__main__":
84+
app = Welcome()
85+
arcade.run()

0 commit comments

Comments
 (0)