Skip to main content

Ruler

rulerActive shows a ruler over the canvas, as in PencilKit.

<SketchCanvas tool={tool} rulerActive layout={{ flex: 1 }} />
  • Ink strokes that start on the ruler, or within 24 points of an edge, are drawn straight along that edge.
  • A stylus on the ruler draws along its nearer edge.
  • Drag it with one finger and turn it with two, in either drawing policy.
  • It rests on multiples of 45° and shows its angle while it turns.
  • It stays in place on screen while the canvas scrolls and zooms.
  • It is never exported.

With the tool picker​

ToolPicker shows its 'ruler' item only when you pass onRulerActiveChange. Keep the state in your component and pass it to both:

const [rulerActive, setRulerActive] = useState(false)

<SketchCanvas tool={tool} rulerActive={rulerActive} layout={{ flex: 1 }} />
<ToolPicker
tool={tool}
onToolChange={setTool}
rulerActive={rulerActive}
onRulerActiveChange={setRulerActive}
/>

The picker draws the toggle with RulerButton, which you can also place in your own layout.

From code​

CanvasController.rulerActive is a read-write property, equivalent to the prop.