Color
Fill and stroke are persistent state, set before the shape that uses them. All three-argument color methods are interpreted through the current ColorMode — RGB (0–255) or HSB (hue 0–360, saturation/brightness 0–100).
On this page · 14 entries
ColorMode
ColorMode(ColorSpaceMode mode)ColorMode(mode, max)ColorMode(mode, max1, max2, max3, maxA?)
Chooses how Fill/Stroke/Background/Color interpret arguments. With no range given, both RGB and HSB default to 0–255 on every channel — same as Processing, HSB doesn't silently switch to 360/100/100 until you ask for it explicitly, e.g. ColorMode(HSB, 360, 100, 100). The 3-max overload leaves alpha's range untouched.
Color
Color(a1, a2, a3, alpha = 255)Color(gray, alpha = 255) → Color
Builds a Color value, interpreted through the current ColorMode — the direct equivalent of Processing's color(...) function. Different from new Color(r, g, b), which is always plain 0–255 RGB no matter what ColorMode is set to.
Color the struct can't declare a same-named method on itself (C# error CS0542), so new Color(r, g, b) is the constructor form. GraphicsContext.Color(...) is a different type entirely, so it's free to use the name — and C# never confuses the two: new Color(...) always means the constructor, bare Color(...) always means this method.Fill · FillHSB · NoFill
Fill(a1, a2, a3, alpha = 255)Fill(gray, alpha = 255)Fill(Color c)FillHSB(...)NoFill()
Sets the fill color. FillHSB(h, s, b, alpha = 255) always reads as HSB (hue 0–360 and wrapping around, saturation and brightness 0–100) regardless of ColorMode: a shortcut for the most common case.
Stroke · StrokeHSB · NoStroke
Stroke(a1, a2, a3, alpha = 255)Stroke(gray, alpha = 255)Stroke(Color c)StrokeHSB(...)NoStroke()
Sets the stroke (outline) color.
StrokeWeight · StrokeCap · StrokeJoin
StrokeWeight(float w)StrokeCap(StrokeCapKind)StrokeJoin(StrokeJoinKind)
Line width, end-cap style, and corner style.
StrokeCapKind.Square maps to Skia's Butt (flush), and StrokeCapKind.Project maps to Skia's Square (extends past the endpoint).Background · Clear
Background(a1, a2, a3, alpha = 255)Background(gray, alpha = 255)Background(Color c)Clear()
Background fills the canvas with an opaque color. Clear wipes to transparent — useful on PGraphics.
Tint · NoTint
Tint(a1, a2, a3, alpha = 255)Tint(byte alpha)NoTint()
Sets a color/alpha multiplier applied to images drawn via Image().
Red / Green / Blue / Alpha / Hue / Saturation / Brightness(Color c)
Extracts one channel from a Color.
LerpColor
LerpColor(Color c1, Color c2, float amt) → Color
Interpolates two colors in RGB space.
struct Color
An RGBA value — a real struct built with new Color(r, g, b, a) or Color.FromHsb(h, s, br, a).
PushStyle · PopStyle
PushStyle()PopStyle()
Saves/restores every drawing style this class tracks — fill/stroke colors, ColorMode ranges, RectMode/EllipseMode/ShapeMode/ImageMode, tint, stroke weight/cap/join, text size/align/leading, curve tightness, Smooth, and BlendMode — deliberately everything PushMatrix/PopMatrix doesn't already cover.
LinearGradientFill/RadialGradientFill isn't tracked by PushStyle — call Fill() with a plain color afterward if you need to clear one.Smooth · NoSmooth
Smooth()NoSmooth()
Toggles antialiasing for shapes, lines, and text drawn from here on. On by default; NoSmooth() gives hard, pixelated edges — occasionally wanted for pixel-art-style sketches.
BlendMode
BlendMode(BlendModeKind mode)
Sets the compositing mode for every drawing operation from here on — shapes, images, and text. See BlendModeKind for the full list, and Pixels for Blend(), which takes a mode per call instead of setting it globally.
Runnable example
A complete sketch using this section. Test in Dana opens it in the IDE, or paste it into a new tab and press Run.
// RGB, gray, alpha and HSB side by side. Move the mouse to change the hue. public class Colors : Sketch { public override void Setup() => Size(600, 300); public override void Draw() { Background(240); NoStroke(); Fill(230, 80, 60); Rect(20, 20, 120, 120); // RGB Fill(90); Rect(160, 20, 120, 120); // gray Fill(40, 120, 220, 120); Rect(100, 80, 120, 120); // RGB + alpha, overlapping // FillHSB: hue 0..360, saturation and brightness 0..100. float hue = Map(MouseX, 0, Width, 0, 360); for (int i = 0; i < 10; i++) { FillHSB(hue + i * 12, 70, 95); Rect(320 + i * 26, 20, 24, 180); } // Colors are values: build them once, mix them with LerpColor. Color a = Color(255, 200, 0), b = Color(120, 0, 200); for (int i = 0; i < 20; i++) { Fill(LerpColor(a, b, i / 19f)); Rect(20 + i * 28, 230, 26, 50); } } }