@mocanvas/mocanvas · interface

GeoTypeDefinition

interface GeoTypeDefinition

One geo silhouette.

The id is what lands in shape.props.geo, so it is part of the file format: choose it once and do not rename it.


Methods · 1

getPath(w: number, h: number, opts?: GeoPathOptions): Geometry2d

The outline in a w × h box, in shape-local coordinates.

Returning a Geometry2d rather than a path string is what makes a custom geo type a first-class shape: the same object drives hit-testing, bounds, snapping and the indicator, so none of them can disagree.


Properties · 5

defaultSize?: {

The size a click (rather than a drag) places this silhouette at. Omitted means "use the geo shape's own default box".

icon: string

Name of the toolbar / style-panel icon for this silhouette.

id: string

The value stored in props.geo.

onDoubleClick?(shape: {

What a double click on the shape does, when it should do something other than start editing the label. Return a props patch, or nothing.

snapType: GeoSnapType

How other shapes snap to it; see GeoSnapType.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.