Skip to content

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

529 B
Raw Blame
import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'

export function firstPageId(graph: SceneGraph): string {
  return graph.getPages()[0].id
}

export function createRect(
  graph: SceneGraph,
  parentId: string,
  props: { name?: string; x?: number; y?: number; width?: number; height?: number } = {}
): SceneNode {
  return graph.createNode('RECTANGLE', parentId, {
    name: props.name ?? 'Rect',
    x: props.x ?? 0,
    y: props.y ?? 0,
    width: props.width ?? 50,
    height: props.height ?? 50
  })
}