Class: RulerTool

OSDPaperjsAnnotation.RulerTool()

Ruler tool: two-point measurement. Extends AnnotationUITool only. Creates segments with exactly two points (click-move-click or click-drag). Line width is in screen pixels (zoom-independent via rescale). Displays P1, P2, and distance in toolbar. Emits on project when a measurement's geometry or display changes (for list/UI sync): - `ruler-measurement-updated` with payload `{ item, label?, distance? }` (item = measurement Group; label = display string; distance = length in project units). Fired after segment commit, after endpoint/line drag edit, and when display settings (units etc.) change.

Constructor

new RulerTool()

Source:

Extends

  • AnnotationUITool

Classes

RulerToolbar

Methods

applyPreviewOrPathStyle(path, isPreviewopt)

Apply zoom-independent stroke and optional preview styling to a path.
Parameters:
Name Type Attributes Default Description
path paper.Path
isPreview boolean <optional>
false
Source:

commitRulerSegment(p1, p2)

Commit a two-point segment to the current item and clear placement state.
Parameters:
Name Type Description
p1 paper.Point
p2 paper.Point
Source:

getZoomFactor() → {number}

Zoom factor for stroke width (matches paper-extensions rescale convention).
Source:
Returns:
Type
number

refreshSegmentLabels()

Refresh on-canvas label content/position for all segments (e.g. when units or unitsPerPixel change).
Source:

setCrosshairPosition(point)

Position crosshair at point (project space). Uses view to keep crosshair at 8 view pixels.
Parameters:
Name Type Description
point paper.Point position in project/view space (e.g. ev.original.point)
Source: