Skip to main content

Import

placeDrawing

Place a viewport’s VectorDrawing (model metres) into its frame (paper mm).

viewportTransform

The model→paper point transform for a viewport: model metres centred in the frame at viewport.scale, then rotated by viewport.rotationDeg.

inverseViewportTransform

Inverse of viewportTransform: map a paper-mm point back to model metres for the same viewport.

fitTransform

Compute the stage transform that fits a page into a viewport, centred.

fitViewportScale

The scale and aim that fit a drawing inside a frame, snapped to a real scale.

viewCenterOf

The model point that lands at the centre of the viewport’s frame.

viewSourceToDrawingRequest

Map a viewport’s ViewSource to a core DrawingRequest.

modelToPaper

Model length (metres) → paper length (millimetres) at a drawing scale.

Types

SheetPolicy

Resolved once per sheet (and again per viewport that names its own style).
PaperStyle
required
The flattened style: no extends left, every layer merged.
string
required
'screen' | 'print' | 'both'
required
number
required
hashString(sheet.id) — the salt every hand stroke on this sheet shares.
string
required
Ink for model-anchored drawing.texts, which never pass through penFor.
string[]
required
Style ids, extends, hatch keys and colours that could not be resolved. Warned once per sheet; the render falls back rather than failing.

PlacedDrawing

A viewport’s drawing mapped into paper space (mm), ready to emit. The package does not export this type by name.
DrawingPrimitive[]
required
Standardized primitives in paper mm, with lineweight resolved.
VectorLine[]
required
VectorText[]
required
{ x: number; y: number; width: number; height: number; }
Clip rectangle (the viewport frame) when viewport.clip is set.
PenContext
The style context the primitives were resolved under.

FitViewport

Viewport dimensions in screen pixels.

FitOptions

number
required
Layer scale — how many screen pixels one paper millimetre occupies at 1×.
number
required
Fraction of the viewport to fill, leaving breathing room.
number
required
number
required

FitTransform type

The stage transform that frames a page: uniform scale plus a top-left offset.
Last modified on October 11, 2026