API Reference

Everything you can do in Glitchlab. Click a category to see all the functions and try live examples.

πŸ”„

Lifecycle

These control the flow of your program. setup() runs once at the start, draw() runs over and over to animate things, and the rest help you set up your canvas.

9 items
πŸ”·

Shapes

Draw rectangles, circles, lines, triangles, and text on your canvas. These are the building blocks of everything you'll make!

7 items
🎨

Colors & Style

Control how shapes look β€” their fill color, outline color, and line thickness. Colors can be names like "tomato", hex codes like "#ff0000", or a number 0–255 for shades of gray.

7 items
πŸ–±οΈ

Input

Read the mouse position, check if keys are pressed, and respond to user input. These let you make interactive programs and games!

6 items
πŸ”’

Math Helpers

Useful math functions for games β€” random numbers, measuring distance, and keeping values in range.

6 items
πŸ‘Ύ

Sprites & Collision

Sprites are movable game objects β€” rectangles with position, size, velocity, and color. Create them, draw them, move them, and check for collisions!

7 items
🎨

Pixel Art

Create tiny pixel art images using text! Each character in a string becomes a colored pixel. Perfect for making game characters, items, and icons without loading any files.

3 items
πŸ”Š

Sound & Music

Add sound effects and music to your games! All sounds are created instantly in the browser β€” no files to load. Play preset effects, musical notes, or drum beats.

3 items
🌈

Color

Create custom colors with exact red, green, blue, and transparency values. Use this when color names aren't enough!

1 item
πŸ”„

Transforms

Move and rotate the canvas to draw things at angles or offset positions. Always use push() and pop() to save and restore your position!

4 items
⏸️

Loop Control

Pause and resume the draw() loop. Useful for turn-based games, menus, or when you only want to redraw on user input.

2 items
πŸ”§

Helpers

Tools to help you build and debug your sketches. These are not part of your game β€” they're overlays that help you understand the coordinate system and position things.

1 item
🎨

Color Names

Every color name you can use β€” see them all with swatches so you know exactly what you'll get.

140+ colors