TypologySienna Chen
ToolsLightweight

Canvas 2D

The browser’s plain 2D drawing surface.

The browser’s plain 2D drawing surface: lines, shapes, text and images drawn by code. No lighting, no 3D, and it never fails silently, which makes it the safest choice for generative art, diagrams and simple animation. It slows down past a few thousand moving shapes.

Breaks when
drops frames past a few thousand draw callsblurry on retina without DPR scaling
Also called
ctx, HTML canvas, 2D context

Prompts

Plotter-style generative print
A Canvas 2D sketch at 1200 × 1600 that draws 180 flow lines: seed each on the left edge and step 400 times along a 2D simplex flow field (angle = noise(x × 0.003, y × 0.003) × τ). Stroke width 0.8, round caps, one ink color at 0.8 alpha. Deterministic from a seed in the URL hash. A Save PNG button via toBlob. DPR-aware.
Headline that lags the pointer
Canvas 2D with a 120 px system-ui headline: measure each glyph with measureText and draw them individually, each lagging the pointer’s x by 40 ms per index through a spring (stiffness 120, damping 14). Redraw only on pointer move or while a spring is still settling; otherwise stop the loop.
Soft layered shapes without filter cost
Draw 60 soft circles with radial gradients instead of ctx.filter blur (which is slow). Use globalCompositeOperation "multiply" in light mode and "screen" in dark mode, chosen from prefers-color-scheme. Render the static layer once to an OffscreenCanvas and composite the moving layer over it each frame.

Related

Resources · 4

  • halftone-animationA Canvas 2D halftone dot field: shockwave intro, carrier blobs, SDF shapes in dots, cursor ripples, a dial for every constant. MIT.atom63GitHub · code · demoOct 4, 2026
  • Matter.jsliabrusite · code · demoApr 8, 2026
  • p5.jsp5xjssite · code · demoMar 15, 2026
  • MDN: Canvas tutorialmdnsite · codeMar 12, 2026