Tutorials › Your First Sketch Simple Mode

Your First Sketch

Learn the basics: set up a canvas, draw shapes, and understand how setup() and draw() work.

1

Hello, Canvas!

Every Glitchlab program starts with two special blocks: setup: and draw:. The setup block runs once at the very beginning — it's where you set the size of your canvas. The draw block runs over and over, about 60 times per second, which is what makes animation possible. Let's start simple: set up a canvas and paint it sky blue. In Simple Mode, you just write setup: and indent your code underneath — no need for function or curly braces!
0 / 4 lines
Loading editor...
size(400 300) draw: background(skyblue)
Try it!

Try changing "skyblue" to "hotpink" or "midnightblue" — what happens?

2

Drawing Shapes

Now let's add some shapes! Use rect() to draw a rectangle and circle() to draw a circle. Each shape needs a position (x, y) and a size. In Simple Mode, you separate the numbers with spaces instead of commas — so circle(320 60 40) instead of circle(320, 60, 40). Much easier to type!
0 / 12 lines
Loading editor...
size(400 300) draw: background(skyblue) // A green rectangle (ground) fill(mediumseagreen) rect(0 220 400 80) // A yellow circle (sun) fill(gold) circle(320 60 40)
Try it!

Try moving the sun by changing its x and y numbers. Can you make it bigger?

3

Adding More Details

Let's build a little scene! You can draw as many shapes as you want. They stack on top of each other in the order you draw them — shapes drawn later appear on top. Use triangle() for a roof and text() to add words. Notice how you can write color names like tomato and gold without quotes — Simple Mode adds them for you!
0 / 30 lines
Loading editor...
size(400 300) draw: background(skyblue) // Ground fill(mediumseagreen) rect(0 220 400 80) // Sun fill(gold) noStroke() circle(320 60 40) // House body fill(tomato) rect(100 140 120 80) // Roof fill(saddlebrown) triangle(90 140 160 80 230 140) // Door fill(sienna) rect(140 170 40 50) // Title fill(white) textSize(24) text("My First Sketch!" 100 260)

What to try next

  • Add a window to the house (hint: draw a small blue rectangle on the house)
  • Change the colors to make a nighttime scene — try a dark blue background and a white moon
  • Add more houses or trees to build a whole neighborhood
  • Try drawing clouds using a few overlapping white circles