Skip to main content

Types

All types are exported from nitro-ui-sketch. Positions and sizes are content points; colours are 0xRRGGBBAA numbers.

Tool​

The active canvas tool. Widths are in content points.

type Tool =
| { type: 'ink'; ink: InkType; color: number; width: number }
| { type: 'eraser'; mode: EraserMode; width: number }
| { type: 'lasso' }
VariantFieldDescription
inkinkInk family.
inkcolorColour as 0xRRGGBBAA.
inkwidthNominal width in content points.
erasermodeWhole strokes or parts of strokes.
eraserwidthEraser diameter in content points.
lassoSelects strokes by drawing a loop around them; drag to move them.

Ink​

The look of a stroke.

FieldTypeDescription
typeInkTypeInk family.
colornumberColour as 0xRRGGBBAA.
widthnumberNominal width in content points; above zero.

InkType​

type InkType = 'pen' | 'marker' | 'pencil' | 'monoline' | 'fountainPen' | 'watercolor' | 'crayon'

See Inks for how each one draws.

EraserMode​

type EraserMode = 'stroke' | 'pixel'

stroke removes every stroke it touches; pixel cuts away only the touched parts.

DrawingPolicy​

type DrawingPolicy = 'anyInput' | 'stylusOnly'

Which touches draw. With stylusOnly, a single finger pans instead. Default anyInput.

StrokePoint​

One sample of a stroke, in content space.

FieldTypeDescription
xnumberHorizontal position in content points.
ynumberVertical position in content points.
timeOffsetnumberSeconds since the stroke began.
sizenumberRendered diameter at this point, in content points.
forcenumberNormalised pressure from 0 to 1; 1 when the device reports none.
azimuthnumberStylus azimuth in radians, 0 along +x, clockwise positive.
altitudenumberStylus altitude in radians; Math.PI / 2 is perpendicular to the screen.

Rect​

An axis-aligned rectangle in content points.

FieldTypeDescription
xnumberLeft edge.
ynumberTop edge.
widthnumberWidth; zero for an empty rect.
heightnumberHeight; zero for an empty rect.

Size​

FieldTypeDescription
widthnumberWidth in points.
heightnumberHeight in points.

Viewport​

The visible part of the content.

FieldTypeDescription
zoomnumberScale factor; 1 shows one content point per view point.
xnumberContent x coordinate shown at the view's left edge.
ynumberContent y coordinate shown at the view's top edge.

ImageExportOptions​

Options for Drawing.toImage.

FieldTypeDescription
formatImageFormatEncoding of the returned bytes.
qualitynumberJPEG quality from 0 to 100; ignored for PNG.
scalenumberPixels per content point; above zero. At most 8192 pixels per side.
rectRect, optionalContent area to export. Defaults to the bounds of all strokes.
backgroundColornumber, optional0xRRGGBBAA. Defaults to transparent for PNG and white for JPEG.

ImageFormat​

type ImageFormat = 'png' | 'jpeg'

VectorExportOptions​

Options for Drawing.toSvg and Drawing.toPdf.

FieldTypeDescription
rectRect, optionalContent area to export. Defaults to the bounds of all strokes.
backgroundColornumber, optional0xRRGGBBAA. Defaults to none.

GlassStyle​

type GlassStyle = 'regular' | 'clear'

regular frosts what is behind it; clear stays see-through and needs a busy backdrop to read well.

ListenerSubscription​

Owns a registered listener.

MemberTypeDescription
remove()() => voidRemoves the listener. Safe to call more than once.