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
 8from __future__ import annotations
 9
10import arcade
11
12# Set constants for the screen size
13SCREEN_WIDTH = 600
14SCREEN_HEIGHT = 600
15SCREEN_TITLE = "Happy Face Example"
16
17# Open the window. Set the window title and dimensions
18arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
19
20# Set the background color
21arcade.set_background_color(arcade.color.WHITE)
22
23# Clear screen and start render process
24arcade.start_render()
25
26# --- Drawing Commands Will Go Here ---
27
28# Draw the face
29x = 300
30y = 300
31radius = 200
32arcade.draw_circle_filled(x, y, radius, arcade.color.YELLOW)
33
34# Draw the right eye
35x = 370
36y = 350
37radius = 20
38arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)
39
40# Draw the left eye
41x = 230
42y = 350
43radius = 20
44arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)
45
46# Draw the smile
47x = 300
48y = 280
49width = 240
50height = 200
51start_angle = 190
52end_angle = 350
53line_width = 20
54arcade.draw_arc_outline(x, y, width, height, arcade.color.BLACK,
55                        start_angle, end_angle, line_width)
56
57# Finish drawing and display the result
58arcade.finish_render()
59
60# Keep the window open until the user hits the 'close' button
61arcade.run()