Open In App

Draw a happy face using Arcade Library in Python

Arcade is a Python module used for developing 2D games. For drawing a happy face, steps are as follows:

import arcade
arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)

The function used with arcade is open_window. This command opens a window with a given size i.e width and height along with screen title.



SCREEN_WIDTH = 600
SCREEN_HEIGHT = 600
SCREEN_TITLE = "Happy Face GfG "
arcade.set_background_color(arcade.color.BLACK)
arcade.start_render()
x = 300
y = 300
radius = 200
arcade.draw_circle_filled(x, y, radius, arcade.color.YELLOW)
# Draw the right eye
x = 370
y = 350
radius = 20
arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)
# Draw the left eye
x = 230
y = 350
radius = 20
arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)
# Draw the smile
x = 300
y = 280
width = 120
height = 100
start_angle = 190
end_angle = 350
arcade.draw_arc_outline(x, y, width, height,
                       arcade.color.BLACK, 
                       start_angle, end_angle, 10)
# Finish drawing
arcade.finish_render()
# Keep the window open until the user
# hits the 'close' button
arcade.run()

Complete Source Code:




import arcade
  
  
# specify the parameters
SCREEN_WIDTH = 600
SCREEN_HEIGHT = 600
SCREEN_TITLE = "Happy Face GfG "
  
# Open the window. Set the window title and dimensions
arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
  
# Set the background color
arcade.set_background_color(arcade.color.BLACK)
  
# start render process
arcade.start_render()
  
# Draw the face
x = 300
y = 300
radius = 200
arcade.draw_circle_filled(x, y, radius, arcade.color.YELLOW)
  
# Draw the right eye
x = 370
y = 350
radius = 20
arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)
  
# Draw the left eye
x = 230
y = 350
radius = 20
arcade.draw_circle_filled(x, y, radius, arcade.color.BLACK)
  
# Draw the smile
x = 300
y = 280
width = 120
height = 100
start_angle = 190
end_angle = 350
arcade.draw_arc_outline(x, y, width, height, arcade.color.BLACK,
                        start_angle, end_angle, 10)
  
# Finish drawing
arcade.finish_render()
  
# Keep the window open until the user hits 
# the 'close' button
arcade.run()

Output:




Article Tags :