Your First Sketch
Learn the basics: set up a canvas, draw shapes, and understand how setup() and draw() work.
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!
Try it!Try changing "skyblue" to "hotpink" or "midnightblue" — what happens?
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!
Try it!Try moving the sun by changing its x and y numbers. Can you make it bigger?
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!
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