Skip to content

Instantly share code, notes, and snippets.

@songkeys
Created October 22, 2025 12:29
Show Gist options
  • Save songkeys/e440ba02b0bb60d210e99be788df5a8e to your computer and use it in GitHub Desktop.
Save songkeys/e440ba02b0bb60d210e99be788df5a8e to your computer and use it in GitHub Desktop.
# Import the "arcade" library
import arcade
# Open up a window.
# From the "arcade" library, use a function called "open_window"
# Set the window title to "Drawing Example"
# Set the dimensions (width and height)
arcade.open_window(600, 600, "Drawing Example")
# Set the background color
arcade.set_background_color(arcade.csscolor.SKY_BLUE)
# Get ready to draw
arcade.start_render()
# Draw a rectangle
# Left of 0, right of 599
# Top of 300, bottom of 0
arcade.draw_lrbt_rectangle_filled(0, 599, 0, 300, arcade.csscolor.GREEN)
# Tree trunk
# Center of 100, 320
# Width of 20
# Height of 60
arcade.draw_rect_filled(arcade.rect.XYWH(100, 320, 20, 60), arcade.csscolor.SIENNA)
# Tree top
arcade.draw_circle_filled(100, 350, 30, arcade.csscolor.DARK_GREEN)
# Another tree, with a trunk and ellipse for top
arcade.draw_rect_filled(arcade.rect.XYWH(200, 320, 20, 60), arcade.csscolor.SIENNA)
arcade.draw_ellipse_filled(200, 370, 60, 80, arcade.csscolor.DARK_GREEN)
# Another tree, with a trunk and arc for top
# Arc is centered at (300, 340) with a width of 60 and height of 100.
# The starting angle is 0, and ending angle is 180.
arcade.draw_rect_filled(arcade.rect.XYWH(300, 320, 20, 60), arcade.csscolor.SIENNA)
arcade.draw_arc_filled(300, 340, 60, 100, arcade.csscolor.DARK_GREEN, 0, 180)
# Another tree, with a trunk and triangle for top
# Triangle is made of these three points:
# (400, 400), (370, 320), (430, 320)
arcade.draw_rect_filled(arcade.rect.XYWH(400, 320, 20, 60), arcade.csscolor.SIENNA)
arcade.draw_triangle_filled(400, 400, 370, 320, 430, 320, arcade.csscolor.DARK_GREEN)
# Draw a tree using a polygon with a list of points
arcade.draw_rect_filled(arcade.rect.XYWH(500, 320, 20, 60), arcade.csscolor.SIENNA)
arcade.draw_polygon_filled(
((500, 400), (480, 360), (470, 320), (530, 320), (520, 360)),
arcade.csscolor.DARK_GREEN,
)
# Draw a sun
arcade.draw_circle_filled(500, 550, 40, arcade.color.YELLOW)
# Rays to the left, right, up, and down
arcade.draw_line(500, 550, 400, 550, arcade.color.YELLOW, 3)
arcade.draw_line(500, 550, 600, 550, arcade.color.YELLOW, 3)
arcade.draw_line(500, 550, 500, 450, arcade.color.YELLOW, 3)
arcade.draw_line(500, 550, 500, 650, arcade.color.YELLOW, 3)
# Diagonal rays
arcade.draw_line(500, 550, 550, 600, arcade.color.YELLOW, 3)
arcade.draw_line(500, 550, 550, 500, arcade.color.YELLOW, 3)
arcade.draw_line(500, 550, 450, 600, arcade.color.YELLOW, 3)
arcade.draw_line(500, 550, 450, 500, arcade.color.YELLOW, 3)
# Draw text at (150, 230) with a font size of 24 pts.
arcade.draw_text("Arbor Day - Plant a Tree!", 150, 230, arcade.color.BLACK, 24)
# Finish drawing
arcade.finish_render()
# Keep the window up until someone closes it.
arcade.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment