喜笑颜开#

此示例显示如何使用Arcade绘图命令。这是使用Arade可以做的最简单的事情之一,也是开始学习如何做图形的一个很好的方法。

有关如何使用Python Arade进行绘制的更详细分步操作,请参阅 How to Draw with Your Computer

有关如何操作的建议,请参阅:

要查找所有可用命令,请在 API指数 。要查看其中一些命令的运行情况,请参见 绘图基本体

为简单起见,此示例没有许多通常在 使用窗口类启动模板

绘图示例程序屏幕截图
happy_face.py#
 1"""
 2Drawing an example happy face
 3
 4If Python and Arcade are installed, this example can be run from the command line with:
 5python -m arcade.examples.happy_face
 6"""
 7
 8import arcade
 9
10# Set constants for the screen size
11SCREEN_WIDTH = 600
12SCREEN_HEIGHT = 600
13SCREEN_TITLE = "Happy Face Example"
14
15# Open the window. Set the window title and dimensions
16arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
17
18# Set the background color
19arcade.set_background_color(arcade.color.WHITE)
20
21# Clear screen and start render process
22arcade.start_render()
23
24# --- Drawing Commands Will Go Here ---
25
26# Draw the face
27x = 300
28y = 300
29radius = 200
30arcade.draw_circle_filled(x, y, radius, arcade.color.YELLOW)
31
32# Draw the right eye
33x = 370
34y = 350
35radius = 20
36arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)
37
38# Draw the left eye
39x = 230
40y = 350
41radius = 20
42arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)
43
44# Draw the smile
45x = 300
46y = 280
47width = 240
48height = 200
49start_angle = 190
50end_angle = 350
51line_width = 20
52arcade.draw_arc_outline(x, y, width, height, arcade.color.BLACK,
53                        start_angle, end_angle, line_width)
54
55# Finish drawing and display the result
56arcade.finish_render()
57
58# Keep the window open until the user hits the 'close' button
59arcade.run()