Skip to content

AI-native design editor. Open-source Figma alternative.

Pen tool with vector network model

Danila Poyarkovbf054e386b20
diff --git a/src/composables/use-canvas-input.ts b/src/composables/use-canvas-input.ts
index 49971b93b..e765c2c4f 100644
--- a/src/composables/use-canvas-input.ts
+++ b/src/composables/use-canvas-input.ts
@@ -59,7 +59,13 @@ interface DragRotate {
origRotation: number
}
-type DragState = DragDraw | DragMove | DragPan | DragResize | DragMarquee | DragRotate
+interface DragPen {
+ type: 'pen-drag'
+ startX: number
+ startY: number
+}
+
+type DragState = DragDraw | DragMove | DragPan | DragResize | DragMarquee | DragRotate | DragPen
const TOOL_TO_NODE: Partial<Record<Tool, NodeType>> = {
FRAME: 'FRAME',
@@ -371,6 +377,13 @@ export function useCanvasInput(canvasRef: Ref<HTMLCanvasElement | null>, store:
return
}
+ // Pen tool: click to add vertices
+ if (tool === 'PEN') {
+ store.penAddVertex(cx, cy)
+ drag.value = { type: 'pen-drag', startX: cx, startY: cy } as DragState
+ return
+ }
+
// Text tool: click to create text node
if (tool === 'TEXT') {
const nodeId = store.createShape('TEXT', cx, cy, 200, 24)
@@ -392,6 +405,21 @@ export function useCanvasInput(canvasRef: Ref<HTMLCanvasElement | null>, store:
}
function onMouseMove(e: MouseEvent) {
+ // Pen tool: track cursor for preview line
+ if (store.state.activeTool === 'PEN' && store.state.penState && !drag.value) {
+ const { cx, cy } = getCoords(e)
+ store.state.penCursorX = cx
+ store.state.penCursorY = cy
+
+ // Check proximity to first vertex for closing
+ const first = store.state.penState.vertices[0]
+ if (store.state.penState.vertices.length > 2 && first) {
+ const dist = Math.hypot(cx - first.x, cy - first.y)
+ store.penSetClosingToFirst(dist < 8)
+ }
+ store.requestRender()
+ }
+
// Cursor on hover
if (!drag.value && store.state.activeTool === 'SELECT') {
const { sx, sy } = getCoords(e)
@@ -573,6 +601,15 @@ export function useCanvasInput(canvasRef: Ref<HTMLCanvasElement | null>, store:
return
}
+ if (d.type === 'pen-drag') {
+ const tx = cx - d.startX
+ const ty = cy - d.startY
+ if (Math.hypot(tx, ty) > 2) {
+ store.penSetDragTangent(tx, ty)
+ }
+ return
+ }
+
if (d.type === 'draw') {
let w = cx - d.startX
let h = cy - d.startY
@@ -703,6 +740,11 @@ export function useCanvasInput(canvasRef: Ref<HTMLCanvasElement | null>, store:
store.commitResize(d.nodeId, d.origRect)
}
+ if (d.type === 'pen-drag') {
+ drag.value = null
+ return
+ }
+
if (d.type === 'rotate') {
const preview = store.state.rotationPreview
if (preview) {
diff --git a/src/composables/use-canvas.ts b/src/composables/use-canvas.ts
index e2c8d8549..26ce5e2a3 100644
--- a/src/composables/use-canvas.ts
+++ b/src/composables/use-canvas.ts
@@ -57,7 +57,12 @@ export function useCanvas(canvasRef: Ref<HTMLCanvasElement | null>, store: Edito
snapGuides: store.state.snapGuides,
rotationPreview: store.state.rotationPreview,
dropTargetId: store.state.dropTargetId,
- layoutInsertIndicator: store.state.layoutInsertIndicator
+ layoutInsertIndicator: store.state.layoutInsertIndicator,
+ penState: store.state.penState ? {
+ ...store.state.penState,
+ cursorX: store.state.penCursorX,
+ cursorY: store.state.penCursorY
+ } : null
})
}
diff --git a/src/composables/use-keyboard.ts b/src/composables/use-keyboard.ts
index e7a5c9c84..2b2ead204 100644
--- a/src/composables/use-keyboard.ts
+++ b/src/composables/use-keyboard.ts
@@ -86,7 +86,17 @@ export function useKeyboard(store: EditorStore) {
store.deleteSelected()
}
+ if (e.key === 'Enter' && store.state.penState) {
+ e.preventDefault()
+ store.penCommit(false)
+ return
+ }
+
if (e.key === 'Escape') {
+ if (store.state.penState) {
+ store.penCancel()
+ return
+ }
store.clearSelection()
store.setTool('SELECT')
}
diff --git a/src/engine/renderer.ts b/src/engine/renderer.ts
index 944e2eace..c838a2dcf 100644
--- a/src/engine/renderer.ts
+++ b/src/engine/renderer.ts
@@ -1,5 +1,6 @@
import type { SceneNode, SceneGraph, Fill } from './scene-graph'
import type { SnapGuide } from './snap'
+import { vectorNetworkToPath } from './vector'
import type {
CanvasKit,
Surface,
@@ -21,6 +22,14 @@ export interface RenderOverlays {
length: number
direction: 'HORIZONTAL' | 'VERTICAL'
} | null
+ penState?: {
+ vertices: Array<{ x: number; y: number }>
+ segments: Array<{ start: number; end: number; tangentStart: { x: number; y: number }; tangentEnd: { x: number; y: number } }>
+ dragTangent: { x: number; y: number } | null
+ closingToFirst: boolean
+ cursorX?: number
+ cursorY?: number
+ } | null
}
export class SkiaRenderer {
@@ -125,6 +134,7 @@ export class SkiaRenderer {
this.drawSnapGuides(canvas, overlays.snapGuides)
this.drawMarquee(canvas, overlays.marquee)
this.drawLayoutInsertIndicator(canvas, overlays.layoutInsertIndicator)
+ this.drawPenOverlay(canvas, overlays.penState)
canvas.restore()
this.surface.flush()
@@ -598,6 +608,13 @@ export class SkiaRenderer {
this.fillPaint.setAlphaf(fill.opacity)
switch (node.type) {
+ case 'VECTOR':
+ if (node.vectorNetwork) {
+ const vp = vectorNetworkToPath(this.ck, node.vectorNetwork)
+ canvas.drawPath(vp, this.fillPaint)
+ vp.delete()
+ }
+ break
case 'ELLIPSE':
canvas.drawOval(rect, this.fillPaint)
break
@@ -645,6 +662,13 @@ export class SkiaRenderer {
this.strokePaint.setAlphaf(stroke.opacity)
switch (node.type) {
+ case 'VECTOR':
+ if (node.vectorNetwork) {
+ const vp = vectorNetworkToPath(this.ck, node.vectorNetwork)
+ canvas.drawPath(vp, this.strokePaint)
+ vp.delete()
+ }
+ break
case 'ELLIPSE':
canvas.drawOval(rect, this.strokePaint)
break
@@ -714,6 +738,130 @@ export class SkiaRenderer {
}
}
+ private drawPenOverlay(canvas: Canvas, penState: RenderOverlays['penState']): void {
+ if (!penState || penState.vertices.length === 0) return
+
+ const { vertices, segments, dragTangent, cursorX, cursorY } = penState
+ const VERTEX_RADIUS = 4
+
+ const pathPaint = new this.ck.Paint()
+ pathPaint.setStyle(this.ck.PaintStyle.Stroke)
+ pathPaint.setStrokeWidth(2)
+ pathPaint.setColor(this.ck.Color4f(0.23, 0.51, 0.96, 1.0))
+ pathPaint.setAntiAlias(true)
+
+ const handlePaint = new this.ck.Paint()
+ handlePaint.setStyle(this.ck.PaintStyle.Stroke)
+ handlePaint.setStrokeWidth(1)
+ handlePaint.setColor(this.ck.Color4f(0.23, 0.51, 0.96, 0.5))
+ handlePaint.setAntiAlias(true)
+
+ const vertexFill = new this.ck.Paint()
+ vertexFill.setStyle(this.ck.PaintStyle.Fill)
+ vertexFill.setColor(this.ck.WHITE)
+ vertexFill.setAntiAlias(true)
+
+ const vertexStroke = new this.ck.Paint()
+ vertexStroke.setStyle(this.ck.PaintStyle.Stroke)
+ vertexStroke.setStrokeWidth(2)
+ vertexStroke.setColor(this.ck.Color4f(0.23, 0.51, 0.96, 1.0))
+ vertexStroke.setAntiAlias(true)
+
+ const toScreen = (x: number, y: number) => ({
+ x: x * this.zoom + this.panX,
+ y: y * this.zoom + this.panY
+ })
+
+ // Draw existing segments
+ const path = new this.ck.Path()
+ for (const seg of segments) {
+ const s = toScreen(vertices[seg.start].x, vertices[seg.start].y)
+ const e = toScreen(vertices[seg.end].x, vertices[seg.end].y)
+ path.moveTo(s.x, s.y)
+
+ const isLine =
+ seg.tangentStart.x === 0 && seg.tangentStart.y === 0 &&
+ seg.tangentEnd.x === 0 && seg.tangentEnd.y === 0
+ if (isLine) {
+ path.lineTo(e.x, e.y)
+ } else {
+ const cp1 = toScreen(
+ vertices[seg.start].x + seg.tangentStart.x,
+ vertices[seg.start].y + seg.tangentStart.y
+ )
+ const cp2 = toScreen(
+ vertices[seg.end].x + seg.tangentEnd.x,
+ vertices[seg.end].y + seg.tangentEnd.y
+ )
+ path.cubicTo(cp1.x, cp1.y, cp2.x, cp2.y, e.x, e.y)
+ }
+ }
+
+ // Preview line from last vertex to cursor
+ if (vertices.length > 0 && cursorX !== undefined && cursorY !== undefined) {
+ const last = toScreen(vertices[vertices.length - 1].x, vertices[vertices.length - 1].y)
+ const cursor = toScreen(cursorX, cursorY)
+ path.moveTo(last.x, last.y)
+ if (dragTangent) {
+ const cp1 = toScreen(
+ vertices[vertices.length - 1].x + dragTangent.x,
+ vertices[vertices.length - 1].y + dragTangent.y
+ )
+ path.cubicTo(cp1.x, cp1.y, cursor.x, cursor.y, cursor.x, cursor.y)
+ } else {
+ path.lineTo(cursor.x, cursor.y)
+ }
+ }
+
+ canvas.drawPath(path, pathPaint)
+ path.delete()
+
+ // Draw tangent handle lines
+ for (const seg of segments) {
+ const ts = seg.tangentStart
+ const te = seg.tangentEnd
+ if (ts.x !== 0 || ts.y !== 0) {
+ const s = toScreen(vertices[seg.start].x, vertices[seg.start].y)
+ const cp = toScreen(vertices[seg.start].x + ts.x, vertices[seg.start].y + ts.y)
+ canvas.drawLine(s.x, s.y, cp.x, cp.y, handlePaint)
+ canvas.drawCircle(cp.x, cp.y, 3, vertexFill)
+ canvas.drawCircle(cp.x, cp.y, 3, handlePaint)
+ }
+ if (te.x !== 0 || te.y !== 0) {
+ const e = toScreen(vertices[seg.end].x, vertices[seg.end].y)
+ const cp = toScreen(vertices[seg.end].x + te.x, vertices[seg.end].y + te.y)
+ canvas.drawLine(e.x, e.y, cp.x, cp.y, handlePaint)
+ canvas.drawCircle(cp.x, cp.y, 3, vertexFill)
+ canvas.drawCircle(cp.x, cp.y, 3, handlePaint)
+ }
+ }
+
+ // Draw current drag tangent handles
+ if (dragTangent && vertices.length > 0) {
+ const last = vertices[vertices.length - 1]
+ const cp1 = toScreen(last.x + dragTangent.x, last.y + dragTangent.y)
+ const cp2 = toScreen(last.x - dragTangent.x, last.y - dragTangent.y)
+ canvas.drawLine(cp2.x, cp2.y, cp1.x, cp1.y, handlePaint)
+ canvas.drawCircle(cp1.x, cp1.y, 3, vertexFill)
+ canvas.drawCircle(cp1.x, cp1.y, 3, handlePaint)
+ canvas.drawCircle(cp2.x, cp2.y, 3, vertexFill)
+ canvas.drawCircle(cp2.x, cp2.y, 3, handlePaint)
+ }
+
+ // Draw vertices
+ for (let i = 0; i < vertices.length; i++) {
+ const v = toScreen(vertices[i].x, vertices[i].y)
+ const radius = i === 0 && penState.closingToFirst ? VERTEX_RADIUS + 2 : VERTEX_RADIUS
+ canvas.drawCircle(v.x, v.y, radius, vertexFill)
+ canvas.drawCircle(v.x, v.y, radius, vertexStroke)
+ }
+
+ pathPaint.delete()
+ handlePaint.delete()
+ vertexFill.delete()
+ vertexStroke.delete()
+ }
+
destroy(): void {
this.fillPaint.delete()
this.strokePaint.delete()
diff --git a/src/engine/scene-graph.ts b/src/engine/scene-graph.ts
index 3fc361887..ed00f1d1f 100644
--- a/src/engine/scene-graph.ts
+++ b/src/engine/scene-graph.ts
@@ -1,3 +1,33 @@
+export type HandleMirroring = 'NONE' | 'ANGLE' | 'ANGLE_AND_LENGTH'
+export type WindingRule = 'NONZERO' | 'EVENODD'
+
+export interface VectorVertex {
+ x: number
+ y: number
+ strokeCap?: string
+ strokeJoin?: string
+ cornerRadius?: number
+ handleMirroring?: HandleMirroring
+}
+
+export interface VectorSegment {
+ start: number
+ end: number
+ tangentStart: { x: number; y: number }
+ tangentEnd: { x: number; y: number }
+}
+
+export interface VectorRegion {
+ windingRule: WindingRule
+ loops: number[][]
+}
+
+export interface VectorNetwork {
+ vertices: VectorVertex[]
+ segments: VectorSegment[]
+ regions: VectorRegion[]
+}
+
export type NodeType =
| 'FRAME'
| 'RECTANGLE'
@@ -105,6 +135,8 @@ export interface SceneNode {
layoutPositioning: 'AUTO' | 'ABSOLUTE'
layoutGrow: number
layoutAlignSelf: 'AUTO' | 'STRETCH'
+
+ vectorNetwork: VectorNetwork | null
}
let nextLocalID = 1
@@ -160,6 +192,7 @@ function createDefaultNode(type: NodeType, overrides: Partial<SceneNode> = {}):
layoutPositioning: 'AUTO',
layoutGrow: 0,
layoutAlignSelf: 'AUTO',
+ vectorNetwork: null,
...overrides
}
}
diff --git a/src/engine/vector.ts b/src/engine/vector.ts
new file mode 100644
index 000000000..f3ee1d20d
--- /dev/null
+++ b/src/engine/vector.ts
@@ -0,0 +1,173 @@
+import type { CanvasKit, Path } from 'canvaskit-wasm'
+
+import type { VectorNetwork, VectorSegment, VectorVertex } from './scene-graph'
+
+export function vectorNetworkToPath(ck: CanvasKit, network: VectorNetwork): Path {
+ const path = new ck.Path()
+ const { vertices, segments, regions } = network
+
+ if (regions.length > 0) {
+ for (const region of regions) {
+ for (const loop of region.loops) {
+ addLoopToPath(path, loop, segments, vertices)
+ }
+ path.setFillType(
+ region.windingRule === 'EVENODD' ? ck.FillType.EvenOdd : ck.FillType.Winding
+ )
+ }
+ } else {
+ // No regions — draw all segments as open paths
+ const visited = new Set<number>()
+ const chains = buildChains(segments, vertices.length)
+
+ for (const chain of chains) {
+ if (chain.length === 0) continue
+ const firstSeg = segments[chain[0]]
+ path.moveTo(vertices[firstSeg.start].x, vertices[firstSeg.start].y)
+
+ for (const segIdx of chain) {
+ visited.add(segIdx)
+ addSegmentToPath(path, segments[segIdx], vertices)
+ }
+ }
+
+ // Any remaining disconnected segments
+ for (let i = 0; i < segments.length; i++) {
+ if (visited.has(i)) continue
+ const seg = segments[i]
+ path.moveTo(vertices[seg.start].x, vertices[seg.start].y)
+ addSegmentToPath(path, seg, vertices)
+ }
+ }
+
+ return path
+}
+
+function addLoopToPath(
+ path: Path,
+ loop: number[],
+ segments: VectorSegment[],
+ vertices: VectorVertex[]
+): void {
+ if (loop.length === 0) return
+
+ const firstSeg = segments[loop[0]]
+ path.moveTo(vertices[firstSeg.start].x, vertices[firstSeg.start].y)
+
+ for (const segIdx of loop) {
+ addSegmentToPath(path, segments[segIdx], vertices)
+ }
+ path.close()
+}
+
+function addSegmentToPath(
+ path: Path,
+ seg: VectorSegment,
+ vertices: VectorVertex[]
+): void {
+ const start = vertices[seg.start]
+ const end = vertices[seg.end]
+ const ts = seg.tangentStart
+ const te = seg.tangentEnd
+
+ const isLine = ts.x === 0 && ts.y === 0 && te.x === 0 && te.y === 0
+ if (isLine) {
+ path.lineTo(end.x, end.y)
+ } else {
+ // Cubic bezier: control points are tangent offsets from start/end
+ path.cubicTo(
+ start.x + ts.x,
+ start.y + ts.y,
+ end.x + te.x,
+ end.y + te.y,
+ end.x,
+ end.y
+ )
+ }
+}
+
+function buildChains(segments: VectorSegment[], _vertexCount: number): number[][] {
+ if (segments.length === 0) return []
+
+ // Build adjacency: for each vertex, which segments connect to it
+ const adj = new Map<number, number[]>()
+ for (let i = 0; i < segments.length; i++) {
+ const s = segments[i]
+ if (!adj.has(s.start)) adj.set(s.start, [])
+ if (!adj.has(s.end)) adj.set(s.end, [])
+ adj.get(s.start)!.push(i)
+ adj.get(s.end)!.push(i)
+ }
+
+ const visited = new Set<number>()
+ const chains: number[][] = []
+
+ // Start from degree-1 vertices (endpoints) or any unvisited
+ const degree1 = [...adj.entries()]
+ .filter(([, segs]) => segs.length === 1)
+ .map(([v]) => v)
+
+ const startVertices = degree1.length > 0
+ ? degree1
+ : [segments[0].start]
+
+ for (const startVertex of startVertices) {
+ let current = startVertex
+ const chain: number[] = []
+
+ while (true) {
+ const segs = adj.get(current)
+ if (!segs) break
+
+ const nextSeg = segs.find((s) => !visited.has(s))
+ if (nextSeg === undefined) break
+
+ visited.add(nextSeg)
+ chain.push(nextSeg)
+
+ const seg = segments[nextSeg]
+ current = seg.start === current ? seg.end : seg.start
+ }
+
+ if (chain.length > 0) chains.push(chain)
+ }
+
+ return chains
+}
+
+export function computeVectorBounds(
+ network: VectorNetwork
+): { x: number; y: number; width: number; height: number } {
+ if (network.vertices.length === 0) {
+ return { x: 0, y: 0, width: 0, height: 0 }
+ }
+
+ let minX = Infinity
+ let minY = Infinity
+ let maxX = -Infinity
+ let maxY = -Infinity
+
+ for (const v of network.vertices) {
+ minX = Math.min(minX, v.x)
+ minY = Math.min(minY, v.y)
+ maxX = Math.max(maxX, v.x)
+ maxY = Math.max(maxY, v.y)
+ }
+
+ // Also consider bezier control points for tighter bounds
+ for (const seg of network.segments) {
+ const start = network.vertices[seg.start]
+ const end = network.vertices[seg.end]
+ const cp1x = start.x + seg.tangentStart.x
+ const cp1y = start.y + seg.tangentStart.y
+ const cp2x = end.x + seg.tangentEnd.x
+ const cp2y = end.y + seg.tangentEnd.y
+
+ minX = Math.min(minX, cp1x, cp2x)
+ minY = Math.min(minY, cp1y, cp2y)
+ maxX = Math.max(maxX, cp1x, cp2x)
+ maxY = Math.max(maxY, cp1y, cp2y)
+ }
+
+ return { x: minX, y: minY, width: maxX - minX, height: maxY - minY }
+}
diff --git a/src/stores/editor.ts b/src/stores/editor.ts
index f40a1342b..c44fe5cf3 100644
--- a/src/stores/editor.ts
+++ b/src/stores/editor.ts
@@ -12,8 +12,9 @@ import { readFigFile } from '../engine/fig-file'
import { computeLayout, computeAllLayouts } from '../engine/layout'
import { SceneGraph } from '../engine/scene-graph'
import { UndoManager } from '../engine/undo'
+import { computeVectorBounds } from '../engine/vector'
-import type { SceneNode, NodeType, Fill, LayoutMode } from '../engine/scene-graph'
+import type { SceneNode, NodeType, Fill, LayoutMode, VectorVertex, VectorSegment, VectorRegion, VectorNetwork } from '../engine/scene-graph'
import type { SnapGuide } from '../engine/snap'
export type Tool = 'SELECT' | 'FRAME' | 'RECTANGLE' | 'ELLIPSE' | 'LINE' | 'TEXT' | 'PEN' | 'HAND'
@@ -92,6 +93,14 @@ export function createEditorStore() {
direction: 'HORIZONTAL' | 'VERTICAL'
} | null,
editingTextId: null as string | null,
+ penState: null as {
+ vertices: VectorVertex[]
+ segments: VectorSegment[]
+ dragTangent: { x: number; y: number } | null
+ closingToFirst: boolean
+ } | null,
+ penCursorX: 0,
+ penCursorY: 0,
panX: 0,
panY: 0,
zoom: 1,
@@ -196,6 +205,122 @@ export function createEditorStore() {
requestRender()
}
+ function penAddVertex(x: number, y: number) {
+ if (!state.penState) {
+ state.penState = {
+ vertices: [{ x, y }],
+ segments: [],
+ dragTangent: null,
+ closingToFirst: false
+ }
+ requestRender()
+ return
+ }
+
+ const ps = state.penState
+ const prevIdx = ps.vertices.length - 1
+
+ // Check if clicking near first vertex to close
+ const first = ps.vertices[0]
+ const dist = Math.hypot(x - first.x, y - first.y)
+ if (ps.vertices.length > 2 && dist < 8) {
+ // Close the path
+ ps.segments.push({
+ start: prevIdx,
+ end: 0,
+ tangentStart: ps.dragTangent ?? { x: 0, y: 0 },
+ tangentEnd: { x: 0, y: 0 }
+ })
+ penCommit(true)
+ return
+ }
+
+ // Add new vertex and segment from previous
+ ps.vertices.push({ x, y })
+ const newIdx = ps.vertices.length - 1
+ ps.segments.push({
+ start: prevIdx,
+ end: newIdx,
+ tangentStart: ps.dragTangent ?? { x: 0, y: 0 },
+ tangentEnd: { x: 0, y: 0 }
+ })
+ ps.dragTangent = null
+ requestRender()
+ }
+
+ function penSetDragTangent(tx: number, ty: number) {
+ if (!state.penState) return
+ state.penState.dragTangent = { x: tx, y: ty }
+
+ // Also set the tangentStart on the last segment (the one being dragged)
+ const ps = state.penState
+ if (ps.segments.length > 0) {
+ const lastSeg = ps.segments[ps.segments.length - 1]
+ lastSeg.tangentEnd = { x: -tx, y: -ty }
+ }
+ requestRender()
+ }
+
+ function penSetClosingToFirst(closing: boolean) {
+ if (!state.penState) return
+ state.penState.closingToFirst = closing
+ requestRender()
+ }
+
+ function penCommit(closed: boolean) {
+ const ps = state.penState
+ if (!ps || ps.vertices.length < 2) {
+ state.penState = null
+ return
+ }
+
+ const regions: VectorRegion[] = closed
+ ? [{ windingRule: 'NONZERO', loops: [ps.segments.map((_, i) => i)] }]
+ : []
+
+ const network: VectorNetwork = {
+ vertices: ps.vertices,
+ segments: ps.segments,
+ regions
+ }
+
+ const bounds = computeVectorBounds(network)
+
+ // Normalize vertices relative to bounds origin
+ const normalizedVertices = network.vertices.map((v) => ({
+ ...v,
+ x: v.x - bounds.x,
+ y: v.y - bounds.y
+ }))
+
+ const normalizedNetwork: VectorNetwork = {
+ vertices: normalizedVertices,
+ segments: network.segments,
+ regions: network.regions
+ }
+
+ const nodeId = createShape('VECTOR', bounds.x, bounds.y, bounds.width, bounds.height)
+ updateNode(nodeId, {
+ vectorNetwork: normalizedNetwork,
+ name: 'Vector',
+ fills: closed ? undefined : [],
+ strokes: closed
+ ? []
+ : [{ color: { r: 0, g: 0, b: 0, a: 1 }, weight: 2, opacity: 1, visible: true, align: 'CENTER' as const }]
+ })
+ select([nodeId])
+
+ state.penState = null
+ state.activeTool = 'SELECT'
+ requestRender()
+ }
+
+ function penCancel() {
+ state.penState = null
+ state.activeTool = 'SELECT'
+ requestRender()
+ }
+
function startTextEditing(nodeId: string) {
state.editingTextId = nodeId
}
@@ -781,6 +906,11 @@ export function createEditorStore() {
setLayoutInsertIndicator,
reorderInAutoLayout,
reparentNodes,
+ penAddVertex,
+ penSetDragTangent,
+ penSetClosingToFirst,
+ penCommit,
+ penCancel,
startTextEditing,
commitTextEdit,
openFigFile,