Inks and tools
The canvas has one active Tool. Pass it as SketchCanvas's tool prop; change the prop to switch tools.
type Tool =
| { type: 'ink'; ink: InkType; color: number; width: number }
| { type: 'eraser'; mode: EraserMode; width: number }
| { type: 'lasso' }
Widths are content points. Colours are 0xRRGGBBAA. Without a tool prop the canvas draws with { type: 'ink', ink: 'pen', color: 0x000000ff, width: 4 }.
Inks
| Ink | Behaviour |
|---|---|
pen | Opaque; width follows pressure (or speed with a finger). |
monoline | Opaque, constant width; ignores pressure and speed. |
fountainPen | Opaque, with a 45° broad nib: broad across the nib, a hairline along it; pressure adds weight. |
marker | Translucent highlighter of constant width. |
pencil | Grainy; widens with stylus tilt. |
crayon | Waxy with paper-grain gaps; widens with stylus tilt. |
watercolor | Translucent wash with soft edges and pigment blooms; overlapping strokes darken. Width follows pressure. |
<SketchCanvas
tool={{ type: 'ink', ink: 'fountainPen', color: 0x1e3a8aff, width: 6 }}
layout={{ flex: 1 }}
/>
The canvas reads pressure, tilt and nib direction, and uses coalesced and predicted touches for low latency. Each sample is stored as a StrokePoint.
SVG and PDF exports draw pencil, crayon and watercolor strokes flat, without their texture and soft edges. PNG and JPEG keep them.
Erasers
| Mode | Effect |
|---|---|
stroke | Removes every stroke the eraser touches. |
pixel | Cuts away only the touched parts of strokes. |
width is the eraser's diameter in content points.
<SketchCanvas tool={{ type: 'eraser', mode: 'pixel', width: 16 }} layout={{ flex: 1 }} />
Lasso
{ type: 'lasso' } selects strokes by drawing a loop around them. Drag the selection to move it. See Selection for deleting, duplicating and recolouring it from code.
Setting tools imperatively
The tool prop calls these CanvasController methods for you. Use them directly only when you drive the canvas without the prop.
| Method | Equivalent tool |
|---|---|
setInkingTool(ink) | { type: 'ink', ink: ink.type, color, width } |
setEraserTool(mode, width) | { type: 'eraser', mode, width } |
setLassoTool() | { type: 'lasso' } |
setInkingTool throws when the width is not above zero.