Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Colors & Background

All color values use the 0–255 range, matching Processing.

Background

Clear the canvas each frame:

#![allow(unused)]
fn main() {
background(30, 30, 40);        // opaque RGB
background_a(30, 30, 40, 128); // with alpha
}

Stroke

Set the outline color for shapes and lines:

#![allow(unused)]
fn main() {
stroke(255, 100, 50);          // opaque
stroke_a(255, 100, 50, 128);   // semi-transparent
no_stroke();                   // disable outlines
}

Fill

Set the interior color for shapes:

#![allow(unused)]
fn main() {
fill(60, 200, 120);            // opaque
fill_a(60, 200, 120, 80);     // semi-transparent
no_fill();                     // disable fill (outlines only)
}

Stroke weight

Control line and outline thickness:

#![allow(unused)]
fn main() {
stroke_weight(3.0); // 3 logical pixels wide
}

Anti-aliasing

Configure MSAA sample count before run(). Valid values: 1 (off), 2, 4, 8.

#![allow(unused)]
fn main() {
smooth(4); // 4x MSAA (default)
}