The canvas: where your art lives
Before you can draw anything, you need somewhere to draw it. The canvas is your blank stage — a square you create, fill with a color, and cover in art.
The big idea
The canvas is the surface your drawing appears on; you create it, then fill and draw on it.
See it in code
Two lines make a canvas. Canvas.create() builds a 500-by-500 stage. Canvas.fill(screen, ...) paints the whole thing one color. Here it turns solid green:
from art import Canvas
screen = Canvas.create()
Canvas.fill(screen, (30, 120, 60))
That green square is your canvas. Right now it's empty. Everything you draw next lands on top of it.
Now add something. We fill with the plain dark background, then draw one star. The star lands right on the canvas:
from art import Canvas, star
screen = Canvas.create()
Canvas.fill(screen)
star(screen, 250, 250)
The star needs the screen to know where to go. Create the canvas first, then draw on it.
Now pick your own color. We fill a deep purple, then add a big star in the middle. Every shape lands on top of the fill:
from art import Canvas, star
screen = Canvas.create()
Canvas.fill(screen, (30, 30, 60))
star(screen, 250, 250, size=120)
The screen is your canvas. We filled it purple, then drew on top. Everything you make in the art studio starts with these two lines: create the canvas, fill it.
Every drawing program has a canvas — a game screen, a paint app, a phone display. It's the space your pixels live in. Create it first, then everything else goes on top, layer by layer.
Try it yourself
Change the fill color to (10, 40, 10) for a dark green stage. Then leave out the Canvas.fill line — the canvas starts with its own dark background either way.
The common mistake
Drawing before creating the canvas. star(screen, ...) needs a screen to draw on, so Canvas.create() has to come first. No canvas, nowhere for the star to go.
What it unlocks
The canvas is the base for pygame drawing, RGB colors, and every piece you compose with imported art pieces.