Learning LibraryDigital Art LibraryKids

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

1Start simple

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:

python
from art import Canvas

screen = Canvas.create()
Canvas.fill(screen, (30, 120, 60))
Run it — a blank green stage, ready for art:
A blank canvas filled solid green, with nothing drawn on it yet.

That green square is your canvas. Right now it's empty. Everything you draw next lands on top of it.

2A step further

Now add something. We fill with the plain dark background, then draw one star. The star lands right on the canvas:

python
from art import Canvas, star

screen = Canvas.create()
Canvas.fill(screen)

star(screen, 250, 250)
Run it — one star on the dark stage:
One small yellow star in the middle of a dark navy canvas.

The star needs the screen to know where to go. Create the canvas first, then draw on it.

3In our world

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:

python
from art import Canvas, star

screen = Canvas.create()
Canvas.fill(screen, (30, 30, 60))

star(screen, 250, 250, size=120)
Run it — a filled stage with a star in the middle:
A single large yellow star centered on a deep purple square canvas.

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.

The same idea, everywhere

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.