vUX / SketchPad / v4.1.0

A whiteboard in one element.

Shapes, curved connectors, freehand ink and text on a pan-and-zoom canvas, with undo, export and a scene you can save as JSON. Draw on the board below.

select 0 elements nothing selected 100%

01Every config property, live

These act on the board above. Most settings take effect immediately; keyboardScope is read once by initialize(), so changing it here destroys the pad and builds a new one around the same scene.

config.tools
config

Equivalent code

                
config.callbacks0 renders

counterInvertImages is for pages that theme the surface with a CSS invert() filter, as Sketchpad's dark mode does. Ticking it here also inverts the board: shapes flip, while placed images like the sun are drawn pre-inverted and keep their real colours.

02The scene is data

pad.elements is a plain array of JSON objects in scene coordinates. Save it however you like and hand it back to load(). exportCanvas() renders the whole scene, cropped to its content.

pad.elements
follows the board; edit it and press load()
exportCanvas()

Press Export to render the board
at 2× onto a new canvas.

03Constrained: one box on a card

The same component with the whiteboard switched off: tools: ["select", "rect"], a fixed view, bounded so nothing leaves the card, and maxElements: 1. This is the configuration an app uses to let someone mark the area on an uploaded design where a guest's name gets printed.

you are invited An Evening
of Small Things
Saturday · eight o'clock
What the app would send

Try to draw past an edge, or drag the box off the card: bounded clamps it. A second box is refused until this one is deleted.

04Stamps from SVG

createStamp(svgText) turns SVG source into something the stamp tool places with each click. A stamp drawn only in black is mono: once placed, the fill colour re-tints it. A coloured one keeps its own colours.

stamp toolclick the paper to place
pad.stamp
re-tints selected mono stamps

05Bad input fails loudly

Arguments are checked at the call, and every error names the property or method and what it wanted. None of these buttons changes the pads above: each call throws before it touches anything.

No error yet. Press one of the buttons above.