Samples

Browse examples by topic. Open browser-ready samples in the playground; CLI-only samples need local host access.

Basics

Numbers

Text

Lists

Maps

JSON

Input and output

Diagnostic and exit

Write a diagnostic and exit with a status.

Files and directories

Temporary files

Create, read, and remove a temporary file.

Processes

Exit status

Exit when a required argument is missing.

Programs and algorithms

Games

Breakout board

Starts with Space; arrows or A/D steer; P pauses. Short tones mark wall, brick, paddle, miss, and win events.

Frogger board

Move Frogger through traffic that advances at a configurable 3 steps per second.

Pong

Move the left paddle with W/S and the right paddle with the arrow keys. The ball moves at three steps per second.

Pac-Man

Collect corridor dots with arrows or WASD and avoid the ghost as it patrols at one step per second.

Freeway

Cross the road with arrows or WASD. Three traffic lanes move at two, three, and four steps per second.

Seaquest

Steer the submarine with arrows or WASD, touch all three divers, and avoid the enemy before oxygen runs out.

Asterix runner

Press Space, W, or Up to jump incoming obstacles. Clear them at three steps per second.

Snake

Steer with arrows or WASD, eat the red food, and avoid walls and your tail. Moves at three steps per second.

Space Invaders

Move with arrows or A/D, fire with Space, and clear the formation before it reaches you. Invaders move twice per second; shots move four times per second.

Tetris

Move with arrows or A/D, rotate with Up/W, soft-drop with Down/S, hard-drop with Space, and clear rows. Pieces fall twice per second.

Lunar Lander

Use Up or Space to spend fuel and slow down, steer toward the green pad, and land at two positions per second with speed two or less.

Q*bert

Hop with diagonal arrow moves (Up/Left go up; Right/Down go down) and change every tile's color.

Pixel art

Lines and shapes

Render a horizontal line, outline box, and diagonal once on a ten-by-ten board.

Tiny house and arrow icons

Render a small house and a right arrow once on a ten-by-ten board.

Color gradient

Render a horizontal blue-to-lavender color gradient once on a ten-by-ten board.

Animation

Soft color pulse

Ease a centered pixel between soft blue shades at four color steps per second.

Wrap-around pixel

Move a pixel across the board at three steps per second and wrap at the edge.

Friendly blink

A warm smiling face blinks about once every three seconds on a soft blue background.

Dynamic canvas size

Draw new frames on the same canvas while its square size changes from five to nine pixels, three times per second.

Beating heart

Pulse a pixel heart about once per second between two sizes and shades of red.

Bouncing mini

Bounce a colorful mini wordmark around a large blue screen at 3 steps per second.

Interaction

Draw with the pointer

Move the pointer across the canvas to paint a lasting trail of pixels.

Audio

Tone keys

Play four short tones with the arrow keys or WASD; the canvas stays responsive without an update loop.

Slow arpeggio

Press Space to start or pause a four-note melody paced at two notes per second.