Happy Face

This example shows how to use the Arcade drawing commands. This is one of the simplest things that can be done with Arcade and a great way to get started learning how to do graphics.

For a more detailed step-through on how to draw with Python Arcade see How to Draw with Your Computer.

For ideas on what to do, see:

To look up all the available commands search for the Drawing Primitives in the API Index. To see some of these commands in action see Drawing Primitives.

To keep things simple, this example does not have many of the things commonly shown in the Starting Template Using Window Class.

Screenshot of drawing example program
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()