@mocanvas/mocanvas · function

shapeToSvg

declare function shapeToSvg(editor: Editor, shape: UnknownShape, ctx: SvgExportContext): string

Render a shape to SVG markup in shape-local space.

Precedence, highest first:

1. ShapeUtil.toSvg — the shape's own opinion about itself. A custom shape is exportable by implementing one method, with nothing to register. 2. shapeSvgRenderers — the registry, which carries the built-in shapes and lets an app override a type whose util it does not own (see registerShapeSvgRenderer). 3. The shape's geometry stroked with its render style — the last resort, so an unknown type still exports as something rather than as nothing.

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.