Skip to content

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

feat: draw .pen icons and image fills (#1415)

Danila Poyarkov62768020b382
diff --git a/changes/1415/added.md b/changes/1415/added.md
new file mode 100644
index 000000000..d4e5af7a0
--- /dev/null
+++ b/changes/1415/added.md
@@ -0,0 +1 @@
+- `.pen` icons draw as pen.dev draws them: Lucide, Feather, and Phosphor from their icon sets, Material Symbols from Google's fonts at the icon's weight, and icons whose library or name is a variable in the layer's theme. `.pen` image fills draw from data URLs everywhere, and from files in the document's folder in the CLI and desktop app.
diff --git a/desktop/capabilities/default.json b/desktop/capabilities/default.json
index 600827e2a..5bb102f50 100644
--- a/desktop/capabilities/default.json
+++ b/desktop/capabilities/default.json
@@ -62,6 +62,10 @@
"identifier": "fs:allow-stat",
"allow": [{ "path": "**" }]
},
+ {
+ "identifier": "fs:allow-lstat",
+ "allow": [{ "path": "**" }]
+ },
{
"identifier": "fs:allow-open",
"allow": [{ "path": "**" }],
diff --git a/packages/cli/src/headless.ts b/packages/cli/src/headless.ts
index ef7ba545b..5f32a6ac5 100644
--- a/packages/cli/src/headless.ts
+++ b/packages/cli/src/headless.ts
@@ -1,4 +1,5 @@
-import { readFile, writeFile } from 'node:fs/promises'
+import { readFile, realpath, writeFile } from 'node:fs/promises'
+import { dirname, resolve, sep } from 'node:path'
import { SkiaRenderer } from '@open-pencil/core/canvas'
import { BUILTIN_IO_FORMATS, IORegistry } from '@open-pencil/core/io'
@@ -17,9 +18,26 @@ export const CLI_IO_FORMATS = [...BUILTIN_IO_FORMATS, headlessHTMLReader]
const io = new IORegistry(CLI_IO_FORMATS)
+/**
+ * Reads a file a document names relative to itself, only from the document's folder: a path that
+ * leaves it, through `..` or a link, reads nothing.
+ */
+function documentAssetReader(filePath: string) {
+ return async (path: string): Promise<Uint8Array | null> => {
+ const folder = await realpath(dirname(filePath))
+ const target = await realpath(resolve(folder, path)).catch(() => null)
+ if (!target?.startsWith(folder + sep)) return null
+ return new Uint8Array(await readFile(target))
+ }
+}
+
export async function loadDocument(filePath: string): Promise<SceneGraph> {
const bytes = new Uint8Array(await readFile(filePath))
- const { graph } = await io.readDocument({ name: filePath, data: bytes })
+ const { graph } = await io.readDocument({
+ name: filePath,
+ data: bytes,
+ readAsset: documentAssetReader(filePath)
+ })
graph.applyDerivedLayoutDuring(() => computeAllLayouts(graph))
return graph
}
diff --git a/packages/cli/tests/headless/pen-assets.test.ts b/packages/cli/tests/headless/pen-assets.test.ts
new file mode 100644
index 000000000..03fecd95f
--- /dev/null
+++ b/packages/cli/tests/headless/pen-assets.test.ts
@@ -0,0 +1,50 @@
+import { afterAll, describe, expect, test } from 'bun:test'
+import { mkdtemp, mkdir, rm, symlink, writeFile } from 'node:fs/promises'
+import { tmpdir } from 'node:os'
+import { join } from 'node:path'
+
+import { toUint8Array } from 'js-base64'
+
+import { loadDocument } from '#cli/headless'
+
+// A 2 × 1 PNG.
+const PNG = toUint8Array(
+ 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAABCAIAAAB7QOjdAAAADElEQVR4nGP8zwACAAYIAQFazwZIAAAAAElFTkSuQmCC'
+)
+
+const root = await mkdtemp(join(tmpdir(), 'pen-assets-'))
+afterAll(() => rm(root, { recursive: true, force: true }))
+
+describe('loadDocument — .pen images', () => {
+ test('reads images beside the document, but nothing outside its folder', async () => {
+ const folder = join(root, 'doc')
+ await mkdir(join(folder, 'images'), { recursive: true })
+ await writeFile(join(folder, 'images', 'inside.png'), PNG)
+ await writeFile(join(root, 'outside.png'), PNG)
+ await symlink(join(root, 'outside.png'), join(folder, 'linked.png'))
+ const image = (id: string, url: string) => ({
+ id,
+ type: 'rectangle',
+ width: 20,
+ height: 10,
+ fill: { type: 'image', url }
+ })
+ await writeFile(
+ join(folder, 'doc.pen'),
+ JSON.stringify({
+ version: '2.21',
+ children: [
+ image('inside', './images/inside.png'),
+ image('parent', '../outside.png'),
+ image('linked', 'linked.png')
+ ]
+ })
+ )
+
+ const graph = await loadDocument(join(folder, 'doc.pen'))
+
+ expect(graph.getNode('inside')?.fills[0]?.type).toBe('IMAGE')
+ expect(graph.getNode('parent')?.fills).toEqual([])
+ expect(graph.getNode('linked')?.fills).toEqual([])
+ })
+})
diff --git a/packages/core/AGENTS.md b/packages/core/AGENTS.md
index 9bb8b418e..05153d077 100644
--- a/packages/core/AGENTS.md
+++ b/packages/core/AGENTS.md
@@ -6,6 +6,7 @@ Renderer, layout, editor, Figma API, tools, clipboard, vector conversion, and do
- CanvasKit runtime loading is centralized in `@open-pencil/core/canvaskit`. Headless raster export may dynamically load `canvaskit-wasm/full`; elsewhere `import type` and pass CanvasKit in.
- Drawing and input share preview-aware geometry through `@open-pencil/core/geometry`, built on Scene Graph matrices. Use it for world/screen transforms, inverses, bounds, and handle placement.
- Content an author wrote (design JSX, HTML, `.pen`) gets its sizes and positions from `layoutAuthoredNodes` in `packages/core/src/layout.ts`, which measures text that resizes to its content wherever it sits and then lays out the pages involved; renderers and readers of authored formats call it, while `.fig` keeps the geometry it stores (`packages/core/tests/layout/authored.test.ts`).
+- `.pen` documents draw as pen.dev draws them. `bun tools/generate/visual-oracles/src/cli.ts compare pen` exports every frame of the document open in pen.dev into `tests/fixtures/pen-oracles/` with the icons and fonts it uses; a new reading rule adds a probe frame there and a threshold to its `manifest.json` (`packages/core/tests/io/formats/pen/oracle.test.ts`).
- HTML is styled by whoever has a CSS runtime and built into layers by `sceneGraphFromStyledHTML` (`packages/core/src/io/formats/html/layers.ts`), which browser builds may bundle. `readHTMLDocument` and `headlessHTMLReader` use the headless CSS runtime, which cannot be bundled for browsers, so they stay out of `BUILTIN_IO_FORMATS` and the CLI registers the reader (`packages/core/tests/io/formats/html/import.test.ts`).
- Copies of part of a document, such as previews, history snapshots, and exports, come from `extractPageContext` or `extractExportGraph` in `packages/core/src/io/subgraph.ts`, not another copier. Pass `componentSets` when instances must switch variant and `shareTables` for a read-only view rebuilt often (`packages/core/tests/io/subgraph.test.ts`).
- Undo for structural AI and MCP edits records only what an edit touches with `captureDocumentChange`: the edit's page is copied up front, and another page or the document node the first time `SceneGraph.observeNodeChanges` reports it about to change, so code that writes into a node directly calls `willChangeNode` first. Copies share values rather than deep-copying, so values must be replaced rather than written into, apart from the child lists, source metadata, and override maps it copies; comments on the document node stay out of undo (`packages/core/tests/editor/history/document-change.test.ts`).
diff --git a/packages/core/src/icons/index.ts b/packages/core/src/icons/index.ts
index 8b039460c..f4422ed78 100644
--- a/packages/core/src/icons/index.ts
+++ b/packages/core/src/icons/index.ts
@@ -8,6 +8,7 @@ export {
} from './provider'
export {
detachIcon,
+ drawIcon,
iconColor,
placeIcon,
recolorIcon,
diff --git a/packages/core/src/icons/render.ts b/packages/core/src/icons/render.ts
index 96efa2d59..bfeb96e08 100644
--- a/packages/core/src/icons/render.ts
+++ b/packages/core/src/icons/render.ts
@@ -11,12 +11,14 @@ import {
withIconTint,
type IconPaint
} from '@open-pencil/scene-graph/icons'
+import Matrix from '@open-pencil/scene-graph/matrix'
import type { Color } from '@open-pencil/scene-graph/primitives'
import {
createResizeSnapshot,
scaledChildRect,
scaledGeometryChanges
} from '@open-pencil/scene-graph/resize'
+import { transformVectorNetwork } from '@open-pencil/scene-graph/vector-network'
import { createPathStroke, pathStrokeLineStyle } from '#core/icons/path-style'
@@ -100,6 +102,32 @@ export function placeIcon(
return graph.getNode(frame.id) ?? frame
}
+/** An icon's paths, scaled from the size they were built at to `size`. */
+function scaledPaths(icon: IconData, size: number): IconPath[] {
+ const scale = size / Math.max(icon.width, icon.height)
+ if (scale === 1) return icon.paths
+ return icon.paths.map((path) => ({
+ ...path,
+ vectorNetwork: transformVectorNetwork(Matrix.scaled(scale, scale), path.vectorNetwork),
+ strokeWidth: path.strokeWidth * scale
+ }))
+}
+
+/**
+ * Draws an icon into a frame that already exists, `size` square at its origin, and records the
+ * icon on it, as for one placed with {@link placeIcon}. The icon may have been built at any size.
+ */
+export function drawIcon(
+ graph: SceneGraph,
+ frameId: string,
+ icon: IconData,
+ size: number,
+ color: Color
+): void {
+ for (const path of scaledPaths(icon, size)) addPath(graph, frameId, path, size, color)
+ recordIcon(graph, frameId, `${icon.prefix}:${icon.name}`)
+}
+
/** Writes the icon `name` on its frame with a fingerprint of the paths it draws now. */
function recordIcon(graph: SceneGraph, frameId: string, name: string): void {
const frame = graph.getNode(frameId)
diff --git a/packages/core/src/io/formats.ts b/packages/core/src/io/formats.ts
index 0cdbdda18..6d2f4798d 100644
--- a/packages/core/src/io/formats.ts
+++ b/packages/core/src/io/formats.ts
@@ -1,7 +1,14 @@
import { sceneNodeToJSX, selectionToJSX } from '@open-pencil/design-jsx'
-import { parsePenFile } from '@open-pencil/pen'
+import {
+ buildPenGraph,
+ isDataURL,
+ parsePenDocument,
+ penAssets,
+ type PenIconSource
+} from '@open-pencil/pen'
import type { SceneGraph } from '@open-pencil/scene-graph'
+import { drawIcon, iconify, type IconData, type IconProvider } from '#core/icons'
import { layoutAuthoredNodes } from '#core/layout'
import { exportFigFile, parseFigFile } from './formats/fig'
@@ -19,6 +26,7 @@ import type {
IOFormatExportOptions,
IOFormatSupport,
RasterExportOptions,
+ ReadDocumentInput,
SVGExportOptions
} from './types'
@@ -213,6 +221,56 @@ async function writeFig(
return { format: 'fig', mimeType: 'application/octet-stream', extension: 'fig', data }
}
+/** The size icons are fetched at; each is scaled to the box it is drawn in. */
+const PEN_ICON_SIZE = 24
+
+/**
+ * An image's bytes: a data URL decoded by the platform's own URL handling, a file through the
+ * host; null when either fails.
+ */
+async function loadPenImage(url: string, input: ReadDocumentInput): Promise<Uint8Array | null> {
+ try {
+ if (!isDataURL(url)) return (await input.readAsset?.(url)) ?? null
+ // Through `URL`, which lowercases the scheme for runtimes that only fetch `data:`.
+ return new Uint8Array(await (await fetch(new URL(url))).arrayBuffer())
+ } catch {
+ return null
+ }
+}
+
+async function loadPenImages(
+ urls: readonly string[],
+ input: ReadDocumentInput
+): Promise<Map<string, Uint8Array>> {
+ const images = new Map<string, Uint8Array>()
+ await Promise.all(
+ urls.map(async (url) => {
+ const bytes = await loadPenImage(url, input)
+ if (bytes) images.set(url, bytes)
+ })
+ )
+ return images
+}
+
+/** Icons from `provider`; a document whose icons cannot be fetched opens with empty icons. */
+async function loadPenIcons(
+ names: readonly string[],
+ provider: IconProvider
+): Promise<PenIconSource> {
+ const glyphs: Map<string, IconData> =
+ names.length > 0
+ ? await provider.icons(names, PEN_ICON_SIZE).catch(() => new Map<string, IconData>())
+ : new Map()
+ return {
+ draw(graph, frameId, name, size, color) {
+ const icon = glyphs.get(name)
+ if (!icon) return false
+ drawIcon(graph, frameId, icon, size, color)
+ return true
+ }
+ }
+}
+
export const penFormat: IOFormatAdapter<'pen'> = {
id: 'pen',
label: 'Pencil Document',
@@ -226,10 +284,17 @@ export const penFormat: IOFormatAdapter<'pen'> = {
matchesFile(fileName, mimeType) {
return lowerExt(fileName) === 'pen' || mimeType === 'application/json'
},
- async readDocument(input) {
- const text = new TextDecoder().decode(input.data)
+ async readDocument(input, context) {
+ const doc = parsePenDocument(new TextDecoder().decode(input.data))
+ const assets = penAssets(doc)
+ const [images, icons] = await Promise.all([
+ loadPenImages(assets.images, input),
+ loadPenIcons(assets.icons, context?.icons ?? iconify)
+ ])
// A .pen file stores its layout intent, not the sizes and positions it implies.
- const graph = parsePenFile(text, {
+ const graph = buildPenGraph(doc, {
+ images,
+ icons,
layout: (target) =>
layoutAuthoredNodes(
target,
diff --git a/packages/core/src/io/types.ts b/packages/core/src/io/types.ts
index f4a84fabf..20f95e8c6 100644
--- a/packages/core/src/io/types.ts
+++ b/packages/core/src/io/types.ts
@@ -4,6 +4,7 @@ import type { SceneGraph } from '@open-pencil/scene-graph'
import type { RenderColorSpace } from '@open-pencil/scene-graph/color'
import type { SkiaRenderer } from '#core/canvas'
+import type { IconProvider } from '#core/icons'
import type { RasterExportFormat } from './formats/raster'
@@ -21,6 +22,11 @@ export interface ReadDocumentInput {
name?: string
mimeType?: string
data: Uint8Array
+ /**
+ * Reads a file a document names relative to itself, such as a `.pen` document's images; null
+ * when it cannot. Hosts that know where the document lives pass it.
+ */
+ readAsset?(path: string): Promise<Uint8Array | null>
}
export interface ReadDocumentResult {
@@ -62,6 +68,8 @@ export interface ExportRequest {
export interface IOContext {
canvasKit?: CanvasKit
renderer?: SkiaRenderer
+ /** Where documents' icons come from; Iconify unless a host passes its own. */
+ icons?: IconProvider
}
export interface FigWriteOptions {
diff --git a/packages/core/tests/io/formats/pen/assets.test.ts b/packages/core/tests/io/formats/pen/assets.test.ts
new file mode 100644
index 000000000..5ee500eaf
--- /dev/null
+++ b/packages/core/tests/io/formats/pen/assets.test.ts
@@ -0,0 +1,152 @@
+import { describe, expect, test } from 'bun:test'
+
+import { fromUint8Array, toUint8Array } from 'js-base64'
+
+import type { IconData, IconProvider } from '@open-pencil/core/icons'
+import { IORegistry, penFormat } from '@open-pencil/core/io'
+import { parseSVGPath } from '@open-pencil/scene-graph/parse-path'
+
+// A 2 × 1 PNG.
+const PNG = toUint8Array(
+ 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAABCAIAAAB7QOjdAAAADElEQVR4nGP8zwACAAYIAQFazwZIAAAAAElFTkSuQmCC'
+)
+
+function iconProvider(available: string[], requested: string[][]): IconProvider {
+ const glyph = (name: string, size: number): IconData => {
+ const [prefix = '', iconName = ''] = name.split(':')
+ return {
+ prefix,
+ name: iconName,
+ width: size,
+ height: size,
+ paths: [
+ {
+ vectorNetwork: parseSVGPath(`M0 0H${size}V${size}Z`),
+ fill: 'currentColor',
+ stroke: null,
+ strokeWidth: 0,
+ strokeCap: 'butt',
+ strokeJoin: 'miter'
+ }
+ ]
+ }
+ }
+ return {
+ async icons(names, size) {
+ requested.push([...names])
+ return new Map(
+ names.filter((name) => available.includes(name)).map((name) => [name, glyph(name, size)])
+ )
+ },
+ search: () => Promise.resolve({ icons: [], total: 0, collections: {} }),
+ previews: () => Promise.resolve(new Map()),
+ collections: () => Promise.resolve([]),
+ browse: () => Promise.resolve([])
+ }
+}
+
+const io = new IORegistry([penFormat])
+
+function penBytes(children: unknown[]) {
+ return new TextEncoder().encode(JSON.stringify({ version: '2.21', children }))
+}
+
+describe('penFormat.readDocument — assets', () => {
+ test('draws Iconify icons from the provider', async () => {
+ const requested: string[][] = []
+ const icons = iconProvider(['lucide:house'], requested)
+ const { graph } = await io.readDocument(
+ {
+ name: 'icons.pen',
+ data: penBytes([
+ {
+ id: 'home',
+ type: 'icon',
+ library: 'lucide',
+ icon: 'house',
+ width: 48,
+ height: 48,
+ fill: '#222222'
+ },
+ {
+ id: 'symbol',
+ type: 'icon',
+ library: 'Material Symbols Outlined',
+ icon: 'home',
+ width: 48,
+ height: 48
+ }
+ ])
+ },
+ { icons }
+ )
+ expect(requested).toEqual([['lucide:house']])
+ const glyphs = graph.getChildren('home')
+ expect(glyphs).toHaveLength(1)
+ expect(glyphs[0]?.width).toBe(48)
+ expect(graph.getChildren('symbol').map((glyph) => glyph.type)).toEqual(['TEXT'])
+ })
+
+ test('reads image files through the host and leaves unreadable ones unpainted', async () => {
+ const asked: string[] = []
+ const { graph } = await io.readDocument(
+ {
+ name: 'images.pen',
+ data: penBytes([
+ {
+ id: 'photo',
+ type: 'rectangle',
+ width: 20,
+ height: 10,
+ fill: { type: 'image', url: './photo.png' }
+ },
+ {
+ id: 'gone',
+ type: 'rectangle',
+ width: 20,
+ height: 10,
+ fill: { type: 'image', url: './gone.png' }
+ }
+ ]),
+ readAsset: async (path) => {
+ asked.push(path)
+ return path === './photo.png' ? PNG : null
+ }
+ },
+ { icons: iconProvider([], []) }
+ )
+ expect([...asked].sort()).toEqual(['./gone.png', './photo.png'])
+ expect(graph.getNode('photo')?.fills[0]?.type).toBe('IMAGE')
+ expect(graph.getNode('gone')?.fills).toEqual([])
+ })
+
+ test('decodes data URLs as URLs, without the host', async () => {
+ const encoded = fromUint8Array(PNG)
+ const { graph } = await io.readDocument(
+ {
+ name: 'inline.pen',
+ data: penBytes([
+ {
+ id: 'plain',
+ type: 'rectangle',
+ fill: { type: 'image', url: `data:image/png;base64,${encoded}` }
+ },
+ {
+ id: 'named',
+ type: 'rectangle',
+ fill: { type: 'image', url: `DATA:image/png;name=a.png;base64,${encoded}` }
+ },
+ {
+ id: 'broken',
+ type: 'rectangle',
+ fill: { type: 'image', url: 'data:image/png;base64,!!!' }
+ }
+ ])
+ },
+ { icons: iconProvider([], []) }
+ )
+ expect(graph.getNode('plain')?.fills[0]?.type).toBe('IMAGE')
+ expect(graph.getNode('named')?.fills[0]?.type).toBe('IMAGE')
+ expect(graph.getNode('broken')?.fills).toEqual([])
+ })
+})
diff --git a/packages/core/tests/io/formats/pen/oracle.test.ts b/packages/core/tests/io/formats/pen/oracle.test.ts
new file mode 100644
index 000000000..a27f5a567
--- /dev/null
+++ b/packages/core/tests/io/formats/pen/oracle.test.ts
@@ -0,0 +1,131 @@
+import { afterAll, describe, expect, test } from 'bun:test'
+import { existsSync } from 'node:fs'
+import { join } from 'node:path'
+
+import { FIXTURES } from '#core-tests/helpers/paths'
+import { once, pick } from 'es-toolkit'
+import * as v from 'valibot'
+
+import { createIconifyProvider } from '@open-pencil/core/icons'
+import { IORegistry, penFormat } from '@open-pencil/core/io'
+import {
+ comparePNGs,
+ createCanvasKitRasterCodec,
+ headlessRenderNodes,
+ initCanvasKit
+} from '@open-pencil/core/io/formats/raster'
+import { computeAllLayouts } from '@open-pencil/core/layout'
+import { fontManager, prepareGraphFonts, WEB_FONT_PROVIDER_IDS } from '@open-pencil/core/text'
+import { parsePenDocument } from '@open-pencil/pen'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+
+// pen.dev's own exports of every frame in probes.pen, recorded with the fonts and icons they draw
+// by `bun tools/generate/visual-oracles/src/cli.ts compare pen`.
+const ORACLES = join(FIXTURES, 'pen-oracles')
+
+const manifestSchema = v.pipe(
+ v.string(),
+ v.parseJson(),
+ v.object({
+ document: v.string(),
+ targets: v.array(
+ v.object({
+ node: v.string(),
+ penNodeId: v.string(),
+ maximumDifferentPercent: v.number(),
+ note: v.optional(v.string())
+ })
+ )
+ })
+)
+
+const iconSetSchema = v.pipe(
+ v.string(),
+ v.parseJson(),
+ v.looseObject({
+ prefix: v.string(),
+ width: v.optional(v.number()),
+ height: v.optional(v.number()),
+ icons: v.record(v.string(), v.looseObject({ body: v.string() }))
+ })
+)
+
+const manifest = v.parse(manifestSchema, await Bun.file(join(ORACLES, 'manifest.json')).text())
+const source = await Bun.file(join(ORACLES, manifest.document)).text()
+
+/** Icons from the recorded Iconify sets only. */
+function recordedIcons() {
+ return createIconifyProvider({
+ async fetchCollection(prefix, names) {
+ const file = Bun.file(join(ORACLES, 'iconify', `${prefix}.json`))
+ if (!(await file.exists())) throw new Error(`No "${prefix}" icons were recorded`)
+ const set = v.parse(iconSetSchema, await file.text())
+ return { ...set, icons: pick(set.icons, names) }
+ },
+ search: () => Promise.resolve({ icons: [], total: 0, collections: {} }),
+ collections: () => Promise.resolve([]),
+ collectionIcons: () => Promise.resolve([])
+ })
+}
+
+const enabledProviders = fontManager.enabledOnlineFontProviders()
+
+/** The probe document, read with the recorded faces and the bundled ones, never a download. */
+const readProbes = once(async (): Promise<SceneGraph> => {
+ fontManager.setOnlineFontProviders(
+ Object.fromEntries(WEB_FONT_PROVIDER_IDS.map((id) => [id, false]))
+ )
+ fontManager.setDownloadedFontCache({
+ async read(family, style) {
+ const file = Bun.file(join(ORACLES, 'fonts', `${family}--${style}.font`))
+ return (await file.exists()) ? file.arrayBuffer() : null
+ },
+ write: () => Promise.resolve()
+ })
+ const { graph } = await new IORegistry([penFormat]).readDocument(
+ {
+ name: manifest.document,
+ data: new TextEncoder().encode(source),
+ readAsset: (path) => Bun.file(join(ORACLES, path)).bytes()
+ },
+ { icons: recordedIcons() }
+ )
+ graph.applyDerivedLayoutDuring(() => computeAllLayouts(graph))
+ await prepareGraphFonts(
+ graph,
+ manifest.targets.map((target) => target.penNodeId)
+ )
+ return graph
+})
+
+afterAll(() => {
+ fontManager.setDownloadedFontCache(null)
+ fontManager.setOnlineFontProviders(
+ Object.fromEntries(WEB_FONT_PROVIDER_IDS.map((id) => [id, enabledProviders.includes(id)]))
+ )
+})
+
+describe('.pen frames against pen.dev', () => {
+ test('every target is a frame of the probe document, exported by pen.dev', () => {
+ const frames = new Set(parsePenDocument(source).children.map((node) => node.id))
+ for (const { penNodeId } of manifest.targets) {
+ expect(frames.has(penNodeId)).toBe(true)
+ expect(existsSync(join(ORACLES, `${penNodeId}.png`))).toBe(true)
+ }
+ })
+
+ for (const target of manifest.targets) {
+ test(`${target.node} draws as pen.dev draws it`, async () => {
+ const graph = await readProbes()
+ const codec = createCanvasKitRasterCodec(await initCanvasKit())
+ const pen = await Bun.file(join(ORACLES, `${target.penNodeId}.png`)).bytes()
+ const ours = await headlessRenderNodes(graph, graph.getPages()[0].id, [target.penNodeId])
+ expect(ours).not.toBeNull()
+ const comparison = ours ? comparePNGs(codec, pen, ours) : null
+ expect(comparison).not.toBeNull()
+ if (!comparison) return
+ const differentPercent = (100 * comparison.changedPixels) / comparison.totalPixels
+ expect(differentPercent).toBeLessThanOrEqual(target.maximumDifferentPercent)
+ })
+ }
+})
diff --git a/packages/pen/package.json b/packages/pen/package.json
index 55a00ac4b..5100ca00e 100644
--- a/packages/pen/package.json
+++ b/packages/pen/package.json
@@ -2,7 +2,20 @@
"name": "@open-pencil/pen",
"version": "0.16.0",
"license": "MIT",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/open-pencil/open-pencil.git",
+ "directory": "packages/pen"
+ },
+ "files": [
+ "dist",
+ "src",
+ "README.md"
+ ],
"type": "module",
+ "sideEffects": false,
+ "main": "./dist/index.js",
+ "types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
@@ -11,14 +24,10 @@
"default": "./dist/index.js"
}
},
- "main": "./dist/index.js",
- "types": "./dist/index.d.ts",
- "sideEffects": false,
- "files": [
- "dist",
- "src",
- "README.md"
- ],
+ "publishConfig": {
+ "access": "public",
+ "provenance": true
+ },
"scripts": {
"build": "bunx tsdown --config tsdown.config.ts",
"check": "bun run typecheck && bun run build && bun run smoke:dist",
@@ -26,18 +35,6 @@
"smoke:dist": "bun scripts/smoke-dist.ts",
"typecheck": "bunx tsc --noEmit -p tsconfig.json"
},
- "repository": {
- "type": "git",
- "url": "git+https://github.com/open-pencil/open-pencil.git",
- "directory": "packages/pen"
- },
- "publishConfig": {
- "access": "public",
- "provenance": true
- },
- "peerDependencies": {
- "@open-pencil/scene-graph": "workspace:*"
- },
"dependencies": {
"valibot": "^1.5.0"
},
@@ -45,5 +42,8 @@
"@types/bun": "^1.3.14",
"tsdown": "^0.22.14",
"typescript": "~5.8.3"
+ },
+ "peerDependencies": {
+ "@open-pencil/scene-graph": "workspace:*"
}
}
diff --git a/packages/pen/src/assets.ts b/packages/pen/src/assets.ts
new file mode 100644
index 000000000..51d6097e3
--- /dev/null
+++ b/packages/pen/src/assets.ts
@@ -0,0 +1,117 @@
+import type { PenDocument, PenNode, PenOverride, PenPaint, PenPaints } from './schema'
+import { possibleValues } from './variables'
+
+/**
+ * Where pen.dev's icon libraries come from. Lucide, Feather, and Phosphor are drawn from their
+ * Iconify sets, which pen.dev draws at one weight; Material Symbols are glyphs of Google's variable
+ * fonts, drawn at the icon's weight, as pen.dev draws them.
+ */
+const ICON_LIBRARIES: Partial<Record<string, { iconify: string } | { font: string }>> = {
+ lucide: { iconify: 'lucide' },
+ feather: { iconify: 'feather' },
+ phosphor: { iconify: 'ph' },
+ 'Material Symbols Outlined': { font: 'Material Symbols Outlined' },
+ 'Material Symbols Rounded': { font: 'Material Symbols Rounded' },
+ 'Material Symbols Sharp': { font: 'Material Symbols Sharp' }
+}
+
+/** The Iconify name of an icon from a library drawn from Iconify. */
+export function iconName(library: string, icon: string): string | null {
+ const source = ICON_LIBRARIES[library]
+ return source && 'iconify' in source ? `${source.iconify}:${icon}` : null
+}
+
+/** The font family of a library whose icons are font glyphs. */
+export function iconFontFamily(library: string): string | null {
+ const source = ICON_LIBRARIES[library]
+ return source && 'font' in source ? source.font : null
+}
+
+/**
+ * Whether an image URL names a file in the document's folder: no scheme, no absolute path, and no
+ * `..` step out of it.
+ */
+export function isDocumentAssetPath(url: string): boolean {
+ if (/^[a-z][a-z0-9+.-]*:/i.test(url) || url.startsWith('/') || url.startsWith('\\')) return false
+ return !url.split(/[/\\]/).includes('..')
+}
+
+/** Whether an image URL carries the image itself, for the host to decode as a URL. */
+export function isDataURL(url: string): boolean {
+ return /^data:/i.test(url)
+}
+
+/** What a document draws from outside itself. */
+export interface PenAssets {
+ /** Iconify names of every icon drawn from Iconify. */
+ icons: string[]
+ /** Images to load: files relative to the document, and data URLs. */
+ images: string[]
+}
+
+function paintList(paints: PenPaints | undefined): PenPaint[] {
+ if (paints === undefined) return []
+ return Array.isArray(paints) ? paints : [paints]
+}
+
+function paintImages(paints: PenPaints | undefined, images: Set<string>) {
+ for (const paint of paintList(paints)) {
+ if (typeof paint === 'object' && paint.type === 'image' && typeof paint.url === 'string') {
+ if (isDocumentAssetPath(paint.url) || isDataURL(paint.url)) images.add(paint.url)
+ }
+ }
+}
+
+interface Found {
+ doc: PenDocument
+ icons: Set<string>
+ images: Set<string>
+ libraries: Set<string>
+ /** Icons an override names without its library, which comes from the layer it overrides. */
+ bareIcons: Set<string>
+}
+
+function addIcons(libraries: readonly string[], icons: readonly string[], found: Set<string>) {
+ for (const library of libraries) {
+ for (const icon of icons) {
+ const name = iconName(library, icon)
+ if (name) found.add(name)
+ }
+ }
+}
+
+function collect(node: PenOverride, assets: Found) {
+ if (node.icon && (node.type === 'icon' || node.type === undefined)) {
+ const icons = possibleValues(node.icon, assets.doc)
+ if (node.library) {
+ const libraries = possibleValues(node.library, assets.doc)
+ for (const library of libraries) assets.libraries.add(library)
+ addIcons(libraries, icons, assets.icons)
+ } else {
+ for (const icon of icons) assets.bareIcons.add(icon)
+ }
+ }
+ paintImages(node.fill, assets.images)
+ if (!(typeof node.stroke === 'object' && 'thickness' in node.stroke)) {
+ paintImages(node.stroke, assets.images)
+ }
+ for (const child of node.children ?? []) collect(child, assets)
+ for (const override of Object.values(node.descendants ?? {})) collect(override, assets)
+}
+
+/**
+ * The Iconify icons and the image files a document draws, so a host can load them before reading
+ * it. An icon or library bound to a variable counts every value the variable has.
+ */
+export function penAssets(doc: PenDocument): PenAssets {
+ const assets: Found = {
+ doc,
+ icons: new Set(),
+ images: new Set(),
+ libraries: new Set(),
+ bareIcons: new Set()
+ }
+ for (const node of doc.children) collect(node satisfies PenNode, assets)
+ addIcons([...assets.libraries], [...assets.bareIcons], assets.icons)
+ return { icons: [...assets.icons], images: [...assets.images] }
+}
diff --git a/packages/pen/src/images.ts b/packages/pen/src/images.ts
new file mode 100644
index 000000000..79c3d8295
--- /dev/null
+++ b/packages/pen/src/images.ts
@@ -0,0 +1,109 @@
+import type { Fill, ImageScaleMode, SceneGraph } from '@open-pencil/scene-graph'
+import { BLACK } from '@open-pencil/scene-graph/constants'
+import { coverImageTransform, computeImageHash, imageSize } from '@open-pencil/scene-graph/images'
+import type { Matrix, Size } from '@open-pencil/scene-graph/primitives'
+
+import type { PenImagePaint } from './schema'
+
+/** An image a paint draws: its bytes' name in the graph and its size in pixels. */
+export interface PenImage {
+ hash: string
+ size: Size | null
+}
+
+/** The images a document's paints name, by URL. */
+export interface PenImages {
+ get(url: string): PenImage | undefined
+}
+
+/** Stores the images a host loaded, by the URLs paints name them with; others stay unpainted. */
+export function createImageStore(
+ graph: SceneGraph,
+ files: ReadonlyMap<string, Uint8Array> = new Map()
+): PenImages {
+ const byURL = new Map<string, PenImage | undefined>()
+ const store = (bytes: Uint8Array): PenImage => {
+ const hash = computeImageHash(bytes)
+ graph.images.set(hash, bytes)
+ // A header declaring no pixels gives no size to fit a crop to.
+ const size = imageSize(bytes)
+ return { hash, size: size && size.width > 0 && size.height > 0 ? size : null }
+ }
+ return {
+ get(url) {
+ if (byURL.has(url)) return byURL.get(url)
+ const file = files.get(url)
+ const image = file ? store(file) : undefined
+ byURL.set(url, image)
+ return image
+ }
+ }
+}
+
+/** pen.dev's affine `[a, b, c, d, tx, ty]`, inverted, as the scene graph's matrix. */
+function invertAffine([a, b, c, d, tx, ty]: readonly number[]): Matrix | null {
+ const det = a * d - b * c
+ if (Math.abs(det) < 1e-12) return null
+ return {
+ m00: d / det,
+ m01: -c / det,
+ m02: (c * ty - d * tx) / det,
+ m10: -b / det,
+ m11: a / det,
+ m12: (b * tx - a * ty) / det
+ }
+}
+
+function compose(outer: Matrix, inner: Matrix): Matrix {
+ return {
+ m00: outer.m00 * inner.m00 + outer.m01 * inner.m10,
+ m01: outer.m00 * inner.m01 + outer.m01 * inner.m11,
+ m02: outer.m00 * inner.m02 + outer.m01 * inner.m12 + outer.m02,
+ m10: outer.m10 * inner.m00 + outer.m11 * inner.m10,
+ m11: outer.m10 * inner.m01 + outer.m11 * inner.m11,
+ m12: outer.m10 * inner.m02 + outer.m11 * inner.m12 + outer.m12
+ }
+}
+
+const IDENTITY: Matrix = { m00: 1, m01: 0, m02: 0, m10: 0, m11: 1, m12: 0 }
+
+/**
+ * Where an image paint draws. `cover` and `contain` are Fill and Fit, and `stretch` a crop of the
+ * whole image. pen.dev's `transform` crops the image first and fits the crop as it would a whole
+ * image; the scene graph has that as a crop of the image's window, which needs the image's size
+ * when the crop is covered. A crop fitted with `contain` is drawn covered, since a crop cannot
+ * leave the bars `contain` shows beside it.
+ */
+function placement(
+ paint: PenImagePaint,
+ image: PenImage,
+ box: Size
+): { imageScaleMode: ImageScaleMode; imageTransform?: Matrix } {
+ const mode = paint.mode ?? 'cover'
+ const crop = paint.transform ? invertAffine(paint.transform) : null
+ if (!crop) {
+ if (mode === 'stretch') return { imageScaleMode: 'CROP', imageTransform: IDENTITY }
+ return { imageScaleMode: mode === 'contain' ? 'FIT' : 'FILL' }
+ }
+ if (mode === 'stretch' || !image.size) return { imageScaleMode: 'CROP', imageTransform: crop }
+ const cropWidth = image.size.width * Math.hypot(crop.m00, crop.m10)
+ const cropHeight = image.size.height * Math.hypot(crop.m01, crop.m11)
+ const covered = coverImageTransform(box.width, box.height, cropWidth, cropHeight)
+ return { imageScaleMode: 'CROP', imageTransform: compose(crop, covered) }
+}
+
+export function imagePaint(
+ paint: PenImagePaint,
+ image: PenImage,
+ box: Size,
+ opacity: number
+): Fill {
+ return {
+ type: 'IMAGE',
+ color: { ...BLACK },
+ opacity,
+ visible: true,
+ imageHash: image.hash,
+ ...placement(paint, image, box)
+ }
+}
diff --git a/packages/pen/src/index.ts b/packages/pen/src/index.ts
index d6defc5be..957b651d2 100644
--- a/packages/pen/src/index.ts
+++ b/packages/pen/src/index.ts
@@ -1,2 +1,17 @@
-export { parsePenFile, readPenFile } from './read'
+export {
+ iconFontFamily,
+ iconName,
+ isDataURL,
+ isDocumentAssetPath,
+ penAssets,
+ type PenAssets
+} from './assets'
+export type { PenIconSource } from './nodes'
+export {
+ buildPenGraph,
+ parsePenDocument,
+ parsePenFile,
+ readPenFile,
+ type PenReadOptions
+} from './read'
export type { PenDocument, PenNode, PenOverride } from './schema'
diff --git a/packages/pen/src/nodes.ts b/packages/pen/src/nodes.ts
index 62439a332..bf6333576 100644
--- a/packages/pen/src/nodes.ts
+++ b/packages/pen/src/nodes.ts
@@ -6,10 +6,14 @@ import type {
SceneGraph,
SceneNode
} from '@open-pencil/scene-graph'
+import { BLACK } from '@open-pencil/scene-graph/constants'
import { fillSizingFields } from '@open-pencil/scene-graph/layout'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+import { iconFontFamily, iconName } from './assets'
import { convertEffects } from './effects'
import { ellipseArc, pathNetwork } from './geometry'
+import type { PenImages } from './images'
import {
applyCornerRadius,
applyPadding,
@@ -22,12 +26,29 @@ import { applyStroke, convertPaints, strokeFields } from './paints'
import { isPlain, type PenPlacement } from './placement'
import type { PenNode, PenOverride } from './schema'
import { applyTextProps } from './text'
-import { bindIfVar, resolveBoolean, resolveNumber, type VarContext } from './variables'
+import {
+ bindIfVar,
+ resolveBoolean,
+ resolveNumber,
+ resolveString,
+ type VarContext
+} from './variables'
+
+/** Where icon glyphs come from, as the host loaded them. */
+export interface PenIconSource {
+ /**
+ * Draws the Iconify icon `name` into the frame, `size` square at its origin, painted `color`
+ * where the icon takes its colour. False when the source does not have it.
+ */
+ draw(graph: SceneGraph, frameId: string, name: string, size: number, color: Color): boolean
+}
/** What reading one document builds up. */
export interface Build {
graph: SceneGraph
ctx: VarContext
+ images: PenImages
+ icons: PenIconSource | undefined
/** Reusable nodes by their pen.dev ID. */
components: Map<string, PenNode>
/** The pen.dev fields each layer was built from, its instance's and overrides' merged in. */
@@ -157,8 +178,8 @@ export function applyPenProperties(node: SceneNode, pen: PenNode, build: Build):
if (pen.type === 'group' || !isPlain(placement)) build.placements.set(node.id, placement)
else build.placements.delete(node.id)
- node.fills = convertPaints(pen.fill, 'fills', ctx, node)
- applyStroke(node, strokeFields(pen), ctx)
+ node.fills = convertPaints(pen.fill, 'fills', ctx, node, build.images)
+ applyStroke(node, strokeFields(pen), ctx, build.images)
node.effects = convertEffects(pen.effect, ctx)
applyCornerRadius(node, pen.cornerRadius, ctx)
applyPadding(node, pen.padding, ctx)
@@ -166,6 +187,7 @@ export function applyPenProperties(node: SceneNode, pen: PenNode, build: Build):
// Text without a width resizes to its content, which laying out the document measures.
if (isTextLike) applyTextProps(node, pen, ctx)
+ if (pen.type === 'icon') drawIcon(node, pen, build)
if (pen.type === 'ellipse') node.arcData = ellipseArc(pen, ctx)
if (pen.type === 'polygon') node.pointCount = Math.max(3, resolveNumber(pen.polygonCount, ctx, 3))
if (pen.type === 'path') {
@@ -180,6 +202,60 @@ export function applyPenProperties(node: SceneNode, pen: PenNode, build: Build):
build.effective.set(node.id, pen)
}
+/** The weight pen.dev draws Material Symbols at when an icon sets none. */
+const MATERIAL_SYMBOLS_WEIGHT = 200
+
+/** A font icon's glyph: its name set in the icon font, which turns it into the glyph. */
+function drawFontGlyph(
+ build: Build,
+ frameId: string,
+ family: string,
+ icon: string,
+ weight: number,
+ size: number,
+ color: Color
+): void {
+ build.graph.createNode('TEXT', frameId, {
+ name: icon,
+ text: icon,
+ fontFamily: family,
+ fontWeight: weight,
+ fontVariations: [{ axis: 'wght', value: weight }],
+ fontSize: size,
+ lineHeight: size,
+ width: size,
+ height: size,
+ textAutoResize: 'NONE',
+ fills: [{ type: 'SOLID', color, opacity: 1, visible: true }]
+ })
+}
+
+/**
+ * An icon draws its glyph in its fill colour, scaled to fit its box and centred, as pen.dev does;
+ * an icon the host could not load is an empty frame. Its library and name may be variables.
+ */
+function drawIcon(node: SceneNode, pen: PenNode, build: Build): void {
+ const { graph, ctx } = build
+ const color = node.fills.find((fill) => fill.type === 'SOLID')?.color ?? { ...BLACK }
+ node.fills = []
+ for (const childId of node.childIds) graph.deleteNode(childId)
+ const library = resolveString(pen.library, ctx)
+ const icon = resolveString(pen.icon, ctx)
+ const size = Math.min(node.width, node.height)
+ if (!library || !icon || size <= 0) return
+ const family = iconFontFamily(library)
+ const name = iconName(library, icon)
+ if (family) {
+ const weight = resolveNumber(pen.weight, ctx, MATERIAL_SYMBOLS_WEIGHT)
+ drawFontGlyph(build, node.id, family, icon, weight, size, color)
+ } else if (!name || !build.icons?.draw(graph, node.id, name, size, color)) return
+ const dx = (node.width - size) / 2
+ const dy = (node.height - size) / 2
+ for (const glyph of graph.getChildren(node.id)) {
+ graph.updateNode(glyph.id, { x: glyph.x + dx, y: glyph.y + dy })
+ }
+}
+
/**
* The fields an instance draws with: its component's, with the `ref` node's own replacing them one
* by one, as pen.dev reads them. A theme on both merges axis by axis.
diff --git a/packages/pen/src/paints.ts b/packages/pen/src/paints.ts
index e491d589a..300ce7413 100644
--- a/packages/pen/src/paints.ts
+++ b/packages/pen/src/paints.ts
@@ -15,8 +15,10 @@ import {
} from '@open-pencil/scene-graph/gradient'
import type { Vector } from '@open-pencil/scene-graph/primitives'
+import { imagePaint, type PenImages } from './images'
import type {
PenGradientPaint,
+ PenImagePaint,
PenLegacyStroke,
PenNode,
PenOverride,
@@ -112,7 +114,8 @@ function convertPaint(
index: number,
field: PaintField,
ctx: VarContext,
- node: SceneNode | undefined
+ node: SceneNode | undefined,
+ images: PenImages | undefined
): Fill | null {
if (typeof paint === 'string' || paint.type === 'color') {
const raw = typeof paint === 'string' ? paint : paint.color
@@ -141,6 +144,17 @@ function convertPaint(
gradientTransform: gradientTransform(gradient, type, ctx)
}
}
+ if (paint.type === 'image') {
+ const source = paint as PenImagePaint
+ const image = source.url ? images?.get(source.url) : undefined
+ if (!image) return null
+ const box = { width: node?.width ?? 0, height: node?.height ?? 0 }
+ return {
+ ...imagePaint(source, image, box, resolveNumber(source.opacity, ctx, 1)),
+ visible: resolveBoolean(source.enabled, ctx),
+ blendMode: mapBlendMode(source.blendMode)
+ }
+ }
return null
}
@@ -149,13 +163,14 @@ export function convertPaints(
paints: PenPaints | undefined,
field: PaintField,
ctx: VarContext,
- node?: SceneNode
+ node?: SceneNode,
+ images?: PenImages
): Fill[] {
if (paints === undefined) return []
const list = Array.isArray(paints) ? paints : [paints]
const result: Fill[] = []
for (const paint of list) {
- const converted = convertPaint(paint, result.length, field, ctx, node)
+ const converted = convertPaint(paint, result.length, field, ctx, node, images)
if (converted) result.push(converted)
}
return result
@@ -222,7 +237,12 @@ function sideWeights(sides: PenSides, ctx: VarContext) {
* Sets a node's strokes. pen.dev draws a stroke only with both paints and a width: a missing side
* of a per-side width is zero, and the alignment defaults to centred.
*/
-export function applyStroke(node: SceneNode, fields: PenStrokeFields, ctx: VarContext): void {
+export function applyStroke(
+ node: SceneNode,
+ fields: PenStrokeFields,
+ ctx: VarContext,
+ images?: PenImages
+): void {
node.strokes = []
node.independentStrokeWeights = false
if (fields.paints === undefined || fields.width === undefined) return
@@ -247,7 +267,7 @@ export function applyStroke(node: SceneNode, fields: PenStrokeFields, ctx: VarCo
const join = JOINS[fields.join ?? 'miter'] ?? 'MITER'
node.strokeCap = cap
node.strokeJoin = join
- node.strokes = convertPaints(fields.paints, 'strokes', ctx, node).map((paint) => ({
+ node.strokes = convertPaints(fields.paints, 'strokes', ctx, node, images).map((paint) => ({
...paint,
weight,
align,
diff --git a/packages/pen/src/read.ts b/packages/pen/src/read.ts
index 89f9536f4..45f98edc1 100644
--- a/packages/pen/src/read.ts
+++ b/packages/pen/src/read.ts
@@ -2,11 +2,12 @@ import * as v from 'valibot'
import { SceneGraph } from '@open-pencil/scene-graph'
+import { createImageStore } from './images'
import { populateInstances } from './instances'
import { spreadAround } from './layout'
-import { createSceneNode, type Build } from './nodes'
+import { createSceneNode, type Build, type PenIconSource } from './nodes'
import { placeLayers } from './placement'
-import { penFileSchema, type PenNode } from './schema'
+import { penFileSchema, type PenDocument, type PenNode } from './schema'
import { buildVarContext } from './variables'
/** Options for reading a document. */
@@ -16,6 +17,10 @@ export interface PenReadOptions {
* mirrored layers are placed after it, since where they land depends on their final size.
*/
layout?(graph: SceneGraph): void
+ /** The image files the document's paints name, by their URL in it; see `penAssets`. */
+ images?: ReadonlyMap<string, Uint8Array>
+ /** Where icon glyphs come from; icons are empty frames without it. */
+ icons?: PenIconSource
}
function collectComponents(nodes: PenNode[], components: Map<string, PenNode>): void {
@@ -35,12 +40,17 @@ function groupsInFlow(graph: SceneGraph, groupIds: Iterable<string>): boolean {
return false
}
-export function parsePenFile(json: string, options: PenReadOptions = {}): SceneGraph {
+/** A `.pen` document's JSON, validated; throws for text that is not one. */
+export function parsePenDocument(json: string): PenDocument {
const parsed = v.safeParse(penFileSchema, json)
if (!parsed.success) {
throw new Error(`Not a .pen document: ${v.summarize(parsed.issues)}`)
}
- const doc = parsed.output
+ return parsed.output
+}
+
+/** Builds the scene graph of a document `parsePenDocument` read. */
+export function buildPenGraph(doc: PenDocument, options: PenReadOptions = {}): SceneGraph {
const graph = new SceneGraph()
for (const page of graph.getPages(true)) {
@@ -50,6 +60,8 @@ export function parsePenFile(json: string, options: PenReadOptions = {}): SceneG
const build: Build = {
graph,
ctx: buildVarContext(graph, doc),
+ images: createImageStore(graph, options.images),
+ icons: options.icons,
components: new Map(),
effective: new Map(),
instances: new Map(),
@@ -75,6 +87,10 @@ export function parsePenFile(json: string, options: PenReadOptions = {}): SceneG
return graph
}
+export function parsePenFile(json: string, options: PenReadOptions = {}): SceneGraph {
+ return buildPenGraph(parsePenDocument(json), options)
+}
+
export async function readPenFile(file: File, options?: PenReadOptions): Promise<SceneGraph> {
return parsePenFile(await file.text(), options)
}
diff --git a/packages/pen/src/schema.ts b/packages/pen/src/schema.ts
index 150d7254d..c282d77c7 100644
--- a/packages/pen/src/schema.ts
+++ b/packages/pen/src/schema.ts
@@ -225,6 +225,7 @@ export type PenVariableScalar = v.InferOutput<typeof variableScalarSchema>
export type PenPaint = v.InferOutput<typeof paintSchema>
export type PenPaints = v.InferOutput<typeof paintsSchema>
export type PenGradientPaint = v.InferOutput<typeof gradientPaintSchema>
+export type PenImagePaint = v.InferOutput<typeof imagePaintSchema>
export type PenLegacyStroke = v.InferOutput<typeof legacyStrokeSchema>
export type PenEffect = v.InferOutput<typeof effectSchema>
export type PenSides = v.InferOutput<typeof sidesSchema>
diff --git a/packages/pen/src/text.ts b/packages/pen/src/text.ts
index 1094bc26f..3ce09b930 100644
--- a/packages/pen/src/text.ts
+++ b/packages/pen/src/text.ts
@@ -1,7 +1,7 @@
import type { SceneNode, TextAlignVertical, TextAutoResize } from '@open-pencil/scene-graph'
import type { PenNode } from './schema'
-import { bindIfVar, isVarRef, resolveNumber, type VarContext } from './variables'
+import { bindIfVar, isVarRef, resolveNumber, resolveString, type VarContext } from './variables'
const FONT_WEIGHTS: Partial<Record<string, number>> = {
thin: 100,
@@ -49,10 +49,6 @@ const TEXT_GROWTH: Partial<Record<string, TextAutoResize>> = {
'fixed-width-height': 'NONE'
}
-function resolveString(value: string | undefined, ctx: VarContext): string | undefined {
- return value !== undefined && isVarRef(value) ? ctx.resolveString(value) : value
-}
-
/**
* A text layer's content and style. Content that reads like a variable reference stays as written,
* as pen.dev shows it. pen.dev 2.21 draws no underline, strikethrough, or text stroke, so those
diff --git a/packages/pen/src/variables.ts b/packages/pen/src/variables.ts
index 9a2383a91..5a86b9920 100644
--- a/packages/pen/src/variables.ts
+++ b/packages/pen/src/variables.ts
@@ -67,6 +67,37 @@ export function resolveBoolean(
return isVarRef(value) ? ctx.resolveBoolean(value) : value !== 'false'
}
+/** A string, or the value of the string variable it references. */
+export function resolveString(value: string | undefined, ctx: VarContext): string | undefined {
+ return value !== undefined && isVarRef(value) ? ctx.resolveString(value) : value
+}
+
+/**
+ * Every value a field can take: the value itself, or each value its variable has in any theme,
+ * through aliases. For loading what a document may draw before it is read in a theme.
+ */
+export function possibleValues(value: string | undefined, doc: PenDocument): string[] {
+ const found = new Set<string>()
+ const seen = new Set<string>()
+ const visit = (raw: PenVariableScalar | undefined) => {
+ if (raw === undefined) return
+ if (!isVarRef(raw)) {
+ found.add(String(raw))
+ return
+ }
+ const name = varName(raw)
+ const definition = doc.variables?.[name]
+ if (!definition || seen.has(name)) return
+ seen.add(name)
+ const entries = Array.isArray(definition.value)
+ ? definition.value
+ : [{ value: definition.value }]
+ for (const entry of entries) visit(entry.value)
+ }
+ visit(value)
+ return [...found]
+}
+
/** A colour, or the value of the colour variable it references. */
export function resolveColor(value: string, ctx: VarContext): Color {
return isVarRef(value) ? ctx.resolveColor(value) : parseColor(value)
diff --git a/packages/pen/tests/assets.test.ts b/packages/pen/tests/assets.test.ts
new file mode 100644
index 000000000..65db862d5
--- /dev/null
+++ b/packages/pen/tests/assets.test.ts
@@ -0,0 +1,218 @@
+import { describe, expect, test } from 'bun:test'
+
+import { toUint8Array } from 'js-base64'
+
+import {
+ iconFontFamily,
+ iconName,
+ penAssets,
+ parsePenDocument,
+ type PenDocument,
+ type PenNode
+} from '@open-pencil/pen'
+import type { SceneGraph } from '@open-pencil/scene-graph'
+import type { Color } from '@open-pencil/scene-graph/primitives'
+
+import { expectDefined, getNodeOrThrow } from './helpers/assert'
+import { parseDocument } from './helpers/document'
+
+// A 2 × 1 PNG.
+const PNG =
+ 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAABCAIAAAB7QOjdAAAADElEQVR4nGP8zwACAAYIAQFazwZIAAAAAElFTkSuQmCC'
+
+describe('penAssets', () => {
+ test('lists Iconify icons, images in the document folder, and data URLs', () => {
+ const doc = parsePenDocument(
+ JSON.stringify({
+ version: '2.21',
+ children: [
+ { id: 'a', type: 'icon', library: 'lucide', icon: 'heart' },
+ { id: 'b', type: 'icon', library: 'Material Symbols Rounded', icon: 'settings' },
+ { id: 'c', type: 'rectangle', fill: { type: 'image', url: './photo.png' } },
+ { id: 'd', type: 'rectangle', fill: [{ type: 'image', url: '../secret.png' }] },
+ { id: 'e', type: 'rectangle', fill: { type: 'image', url: 'https://example.com/a.png' } },
+ { id: 'f', type: 'rectangle', fill: { type: 'image', url: '/etc/a.png' } },
+ { id: 'g', type: 'ref', ref: 'x', descendants: { inner: { icon: 'star' } } },
+ { id: 'i', type: 'icon', library: 'phosphor', icon: 'house' },
+ {
+ id: 'h',
+ type: 'rectangle',
+ fill: { type: 'image', url: `data:image/png;base64,${PNG}` }
+ }
+ ]
+ })
+ )
+ expect(penAssets(doc)).toEqual({
+ icons: ['lucide:heart', 'ph:house', 'lucide:star', 'ph:star'],
+ images: ['./photo.png', `data:image/png;base64,${PNG}`]
+ })
+ })
+
+ test('lists every icon a variable names in any theme', () => {
+ const doc = parsePenDocument(
+ JSON.stringify({
+ version: '2.21',
+ themes: { mode: ['light', 'dark'] },
+ variables: {
+ glyph: {
+ type: 'string',
+ value: [{ value: 'sun' }, { value: '$night', theme: { mode: 'dark' } }]
+ },
+ night: { type: 'string', value: 'moon' },
+ set: { type: 'string', value: 'lucide' }
+ },
+ children: [{ id: 'a', type: 'icon', library: '$set', icon: '$glyph' }]
+ })
+ )
+ expect(penAssets(doc).icons).toEqual(['lucide:sun', 'lucide:moon'])
+ })
+
+ test('draws Lucide, Feather, and Phosphor from Iconify, and Material Symbols from their fonts', () => {
+ expect(iconName('feather', 'star')).toBe('feather:star')
+ expect(iconName('phosphor', 'airplane')).toBe('ph:airplane')
+ expect(iconName('Material Symbols Outlined', 'home')).toBeNull()
+ expect(iconFontFamily('Material Symbols Sharp')).toBe('Material Symbols Sharp')
+ expect(iconFontFamily('lucide')).toBeNull()
+ expect(iconName('unknown', 'home')).toBeNull()
+ })
+})
+
+describe('parsePenFile — images', () => {
+ function fillWith(fill: PenNode['fill'], bytes = toUint8Array(PNG)) {
+ const graph = parseDocument(
+ [{ id: 'shape', type: 'rectangle', width: 200, height: 100, fill }],
+ {},
+ { images: new Map([['./image.png', bytes]]) }
+ )
+ return { graph, fill: getNodeOrThrow(graph, 'shape').fills[0] }
+ }
+
+ test.each([
+ [undefined, 'FILL'],
+ ['cover', 'FILL'],
+ ['contain', 'FIT'],
+ ['stretch', 'CROP']
+ ] as const)('draws mode %s as %s', (mode, expected) => {
+ const { graph, fill } = fillWith({ type: 'image', url: './image.png', mode })
+ expect(fill).toMatchObject({ type: 'IMAGE', imageScaleMode: expected })
+ expect(graph.images.has(expectDefined(fill.imageHash))).toBe(true)
+ })
+
+ test('crops, then covers the layer with the crop', () => {
+ // The right half of a 2 × 1 image is square, so on a 200 × 100 layer it is cut to its middle.
+ const { fill } = fillWith({
+ type: 'image',
+ url: './image.png',
+ transform: [2, 0, 0, 1, -1, 0]
+ })
+ const window = expectDefined(fill.imageTransform)
+ expect(window.m00).toBeCloseTo(0.5)
+ expect(window.m02).toBeCloseTo(0.5)
+ expect(window.m11).toBeCloseTo(0.5)
+ expect(window.m12).toBeCloseTo(0.25)
+ })
+
+ test('crops an image whose header declares no pixels without fitting it', () => {
+ const empty = toUint8Array(PNG)
+ // The IHDR width, which follows the signature, the chunk length, and the chunk type.
+ empty.set([0, 0, 0, 0], 16)
+ const { fill } = fillWith(
+ { type: 'image', url: './image.png', transform: [2, 0, 0, 1, -1, 0] },
+ empty
+ )
+ const window = expectDefined(fill.imageTransform)
+ expect(Object.values(window).every(Number.isFinite)).toBe(true)
+ })
+
+ test('reads image files the host loaded, and skips the ones it did not', () => {
+ const graph = parseDocument(
+ [
+ {
+ id: 'loaded',
+ type: 'rectangle',
+ fill: [{ type: 'image', url: './a.png', opacity: 0.5 }]
+ },
+ { id: 'missing', type: 'rectangle', fill: [{ type: 'image', url: './b.png' }, '#FF0000'] }
+ ],
+ {},
+ { images: new Map([['./a.png', toUint8Array(PNG)]]) }
+ )
+ expect(getNodeOrThrow(graph, 'missing').fills.map((fill) => fill.type)).toEqual(['SOLID'])
+ expect(getNodeOrThrow(graph, 'loaded').fills[0]).toMatchObject({ type: 'IMAGE', opacity: 0.5 })
+ })
+})
+
+describe('parsePenFile — icons', () => {
+ function drawn(fields: Partial<PenNode>, doc: Partial<PenDocument> = {}) {
+ const calls: { name: string; size: number; color: Color }[] = []
+ const icons = {
+ draw(graph: SceneGraph, frameId: string, name: string, size: number, color: Color) {
+ calls.push({ name, size, color })
+ graph.createNode('VECTOR', frameId, { width: size, height: size })
+ return true
+ }
+ }
+ const graph = parseDocument(
+ [
+ {
+ id: 'icon',
+ type: 'icon',
+ library: 'lucide',
+ icon: 'heart',
+ width: 96,
+ height: 30,
+ fill: '#CC0000',
+ ...fields
+ }
+ ],
+ doc,
+ { icons }
+ )
+ return { graph, calls, icon: getNodeOrThrow(graph, 'icon') }
+ }
+
+ test('draws the glyph in the fill colour, fitted and centred in the box', () => {
+ const { graph, calls, icon } = drawn({})
+ expect(calls).toEqual([{ name: 'lucide:heart', size: 30, color: { r: 0.8, g: 0, b: 0, a: 1 } }])
+ expect(icon.fills).toEqual([])
+ expect(graph.getChildren('icon').map((glyph) => [glyph.x, glyph.y])).toEqual([[33, 0]])
+ })
+
+ test('sets a Material Symbol in its font at the icon weight, 200 by default', () => {
+ for (const [weight, expected] of [
+ [undefined, 200],
+ [650, 650]
+ ] as const) {
+ const { graph, calls } = drawn({ library: 'Material Symbols Rounded', icon: 'home', weight })
+ expect(calls).toEqual([])
+ expect(graph.getChildren('icon')).toMatchObject([
+ {
+ type: 'TEXT',
+ text: 'home',
+ fontFamily: 'Material Symbols Rounded',
+ fontVariations: [{ axis: 'wght', value: expected }],
+ fontSize: 30,
+ x: 33,
+ y: 0
+ }
+ ])
+ }
+ })
+
+ test('reads the library and icon from variables in the layer theme', () => {
+ const { calls } = drawn(
+ { library: '$set', icon: '$glyph', theme: { mode: 'dark' } },
+ {
+ themes: { mode: ['light', 'dark'] },
+ variables: {
+ set: { type: 'string', value: 'feather' },
+ glyph: {
+ type: 'string',
+ value: [{ value: 'sun' }, { value: 'moon', theme: { mode: 'dark' } }]
+ }
+ }
+ }
+ )
+ expect(calls.map((call) => call.name)).toEqual(['feather:moon'])
+ })
+})
diff --git a/packages/pen/tests/helpers/document.ts b/packages/pen/tests/helpers/document.ts
index fd646fded..1442d08e9 100644
--- a/packages/pen/tests/helpers/document.ts
+++ b/packages/pen/tests/helpers/document.ts
@@ -1,6 +1,10 @@
-import { parsePenFile, type PenDocument, type PenNode } from '@open-pencil/pen'
+import { parsePenFile, type PenDocument, type PenNode, type PenReadOptions } from '@open-pencil/pen'
/** Reads a document holding `children`, as pen.dev 2.21 writes it. */
-export function parseDocument(children: PenNode[], fields: Partial<PenDocument> = {}) {
- return parsePenFile(JSON.stringify({ version: '2.21', ...fields, children }))
+export function parseDocument(
+ children: PenNode[],
+ fields: Partial<PenDocument> = {},
+ options: PenReadOptions = {}
+) {
+ return parsePenFile(JSON.stringify({ version: '2.21', ...fields, children }), options)
}
diff --git a/packages/scene-graph/src/images.ts b/packages/scene-graph/src/images.ts
index e40667891..89d7824be 100644
--- a/packages/scene-graph/src/images.ts
+++ b/packages/scene-graph/src/images.ts
@@ -1,7 +1,7 @@
import { sha1 } from '@noble/hashes/legacy.js'
import { bytesToHex } from '@noble/hashes/utils.js'
-import type { Matrix } from './primitives'
+import type { Matrix, Size } from './primitives'
/**
* The name an image's bytes are stored under: the hex SHA-1 of the bytes, as Figma names images,
@@ -27,6 +27,52 @@ export function imageMimeType(data: Uint8Array): ImageMimeType {
return 'image/png'
}
+function jpegSize(data: Uint8Array, view: DataView): Size | null {
+ for (let offset = 2; offset + 9 < data.length;) {
+ if (data[offset] !== 0xff) return null
+ const marker = data[offset + 1]
+ const length = view.getUint16(offset + 2)
+ // Start-of-frame markers, except the DHT, JPG, and DAC ones that share their range.
+ if (marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc) {
+ return { width: view.getUint16(offset + 7), height: view.getUint16(offset + 5) }
+ }
+ offset += 2 + length
+ }
+ return null
+}
+
+function webpSize(data: Uint8Array, view: DataView): Size | null {
+ const chunk = String.fromCharCode(data[12], data[13], data[14], data[15])
+ if (chunk === 'VP8X' && data.length >= 30) {
+ const width = 1 + (data[24] | (data[25] << 8) | (data[26] << 16))
+ const height = 1 + (data[27] | (data[28] << 8) | (data[29] << 16))
+ return { width, height }
+ }
+ if (chunk === 'VP8L' && data.length >= 25) {
+ const bits = view.getUint32(21, true)
+ return { width: (bits & 0x3fff) + 1, height: ((bits >> 14) & 0x3fff) + 1 }
+ }
+ if (chunk === 'VP8 ' && data.length >= 30) {
+ return { width: view.getUint16(26, true) & 0x3fff, height: view.getUint16(28, true) & 0x3fff }
+ }
+ return null
+}
+
+/** An image's size in pixels, read from its header; null for bytes it cannot read. */
+export function imageSize(data: Uint8Array): Size | null {
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength)
+ const type = imageMimeType(data)
+ if (type === 'image/jpeg') return jpegSize(data, view)
+ if (type === 'image/gif') {
+ return data.length >= 10
+ ? { width: view.getUint16(6, true), height: view.getUint16(8, true) }
+ : null
+ }
+ if (type === 'image/webp') return webpSize(data, view)
+ const png = data.length >= 24 && data[1] === 0x50 && data[2] === 0x4e && data[3] === 0x47
+ return png ? { width: view.getUint32(16), height: view.getUint32(20) } : null
+}
+
/**
* The crop that shows an image as Fill does: scaled to cover a `width` × `height` layer and
* centred. Figma starts a crop from it, as the image-space window a crop's transform holds.
diff --git a/packages/scene-graph/tests/images.test.ts b/packages/scene-graph/tests/images.test.ts
index e4a2c8e6d..499765634 100644
--- a/packages/scene-graph/tests/images.test.ts
+++ b/packages/scene-graph/tests/images.test.ts
@@ -1,6 +1,13 @@
import { describe, expect, test } from 'bun:test'
-import { computeImageHash, imageMimeType, coverImageTransform } from '@open-pencil/scene-graph/images'
+import { toUint8Array } from 'js-base64'
+
+import {
+ computeImageHash,
+ coverImageTransform,
+ imageMimeType,
+ imageSize
+} from '@open-pencil/scene-graph/images'
describe('computeImageHash', () => {
test('names bytes by their SHA-1, as Figma names images', () => {
@@ -41,3 +48,27 @@ describe('coverImageTransform', () => {
])
})
})
+
+describe('imageSize', () => {
+ // 37 × 21 images, encoded by Pillow.
+ test.each([
+ ['PNG', 'iVBORw0KGgoAAAANSUhEUgAAACUAAAAVCAIAAABOhrD5AAAANklEQVR4nO3NMREAAAzCQIp/z60EllwnXkAyq1f+3ak/luFe0h/LcC/pj2W4l/THMtxL+hPqAPB4ASnUWyUUAAAAAElFTkSuQmCC'],
+ ['GIF', 'R0lGODdhJQAVAIEAAP8AAAAAAAAAAAAAACwAAAAAJQAVAEAILwABCBxIsKDBgwgTKlzIsKHDhxAjSpxIsaLFixgzatzIsaPHjyBDihxJsqRJkgEBADs='],
+ ['lossless WebP', 'UklGRhwAAABXRUJQVlA4TA8AAAAvJAAFAAcQ/Y/+ByKi/wEA'],
+ ['lossy WebP', 'UklGRk4AAABXRUJQVlA4IEIAAACQAwCdASolABUAPm02l0ikIyIhJWgAgA2JZwDPkoB+AAAr98NwAP7wm0P/5BcsLrka//yA/5Af8gP/498Ql180AAA=']
+ ])('reads a %s header', (_format, base64) => {
+ expect(imageSize(toUint8Array(base64))).toEqual({ width: 37, height: 21 })
+ })
+
+ test('reads a JPEG frame header past the segments before it', () => {
+ const jpeg = new Uint8Array([
+ 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x04, 0x00, 0x00, 0xff, 0xc4, 0x00, 0x02, 0xff, 0xc0, 0x00,
+ 0x11, 0x08, 0x00, 0x15, 0x00, 0x25, 0x03
+ ])
+ expect(imageSize(jpeg)).toEqual({ width: 37, height: 21 })
+ })
+
+ test('gives null for bytes it cannot read', () => {
+ expect(imageSize(new TextEncoder().encode('not an image'))).toBeNull()
+ })
+})
diff --git a/src/app/document/io/assets.ts b/src/app/document/io/assets.ts
new file mode 100644
index 000000000..07bb06414
--- /dev/null
+++ b/src/app/document/io/assets.ts
@@ -0,0 +1,29 @@
+import { IS_TAURI } from '@open-pencil/core/constants'
+import type { ReadDocumentInput } from '@open-pencil/core/io'
+
+/**
+ * Reads the files a document opened from `path` names relative to itself, such as a `.pen`
+ * document's images, from the document's folder only. A browser has no path to read beside, so
+ * documents opened there get none. A path that leaves the folder, through `..` or a link, reads
+ * nothing.
+ */
+export function documentAssetReader(path: string | undefined): ReadDocumentInput['readAsset'] {
+ if (!IS_TAURI || !path) return undefined
+ return async (relative) => {
+ const [{ dirname, join, resolve, sep }, { lstat, readFile }] = await Promise.all([
+ import('@tauri-apps/api/path'),
+ import('@tauri-apps/plugin-fs')
+ ])
+ const folder = await dirname(path)
+ const target = await resolve(folder, relative)
+ if (!target.startsWith(folder + sep())) return null
+ // A link inside the folder could still lead out of it, so no step of the path may be one.
+ let step = folder
+ for (const part of target.slice(folder.length + 1).split(sep())) {
+ step = await join(step, part)
+ const info = await lstat(step).catch(() => null)
+ if (!info || info.isSymlink) return null
+ }
+ return readFile(target).catch(() => null)
+ }
+}
diff --git a/src/app/tabs/index.ts b/src/app/tabs/index.ts
index ab61d340c..d3803ffd4 100644
--- a/src/app/tabs/index.ts
+++ b/src/app/tabs/index.ts
@@ -12,6 +12,7 @@ import { describeDiagnosticError, recordStorageFailure } from '@/app/diagnostics
import { confirmAllDocuments } from '@/app/document/close/all'
import { confirmDocumentClose } from '@/app/document/close/controller'
import { requestDocumentClose } from '@/app/document/close/prompt'
+import { documentAssetReader } from '@/app/document/io/assets'
import { readFigDocument } from '@/app/document/io/fig'
import { applyImportedDocument } from '@/app/document/io/imported-document'
import type { DocumentSourceIdentity } from '@/app/document/io/types'
@@ -502,7 +503,8 @@ export async function openFileInNewTab(
const result = await io.readDocument({
name: file.name,
mimeType: file.type || undefined,
- data: new Uint8Array(await file.arrayBuffer())
+ data: new Uint8Array(await file.arrayBuffer()),
+ readAsset: documentAssetReader(path)
})
imported = result.graph
sourceFormat = result.sourceFormat
diff --git a/tests/fixtures/pen-oracles/AMkAG.png b/tests/fixtures/pen-oracles/AMkAG.png
new file mode 100644
index 000000000..880f317a5
Binary files /dev/null and b/tests/fixtures/pen-oracles/AMkAG.png differ
diff --git a/tests/fixtures/pen-oracles/G1aH4g.png b/tests/fixtures/pen-oracles/G1aH4g.png
new file mode 100644
index 000000000..d4e773b75
Binary files /dev/null and b/tests/fixtures/pen-oracles/G1aH4g.png differ
diff --git a/tests/fixtures/pen-oracles/HD4Cf.png b/tests/fixtures/pen-oracles/HD4Cf.png
new file mode 100644
index 000000000..2406a742f
Binary files /dev/null and b/tests/fixtures/pen-oracles/HD4Cf.png differ
diff --git a/tests/fixtures/pen-oracles/MBeS5.png b/tests/fixtures/pen-oracles/MBeS5.png
new file mode 100644
index 000000000..38a36f785
Binary files /dev/null and b/tests/fixtures/pen-oracles/MBeS5.png differ
diff --git a/tests/fixtures/pen-oracles/MOmt0.png b/tests/fixtures/pen-oracles/MOmt0.png
new file mode 100644
index 000000000..a45dce059
Binary files /dev/null and b/tests/fixtures/pen-oracles/MOmt0.png differ
diff --git a/tests/fixtures/pen-oracles/VuLq8.png b/tests/fixtures/pen-oracles/VuLq8.png
new file mode 100644
index 000000000..4415d6c78
Binary files /dev/null and b/tests/fixtures/pen-oracles/VuLq8.png differ
diff --git a/tests/fixtures/pen-oracles/XwyoV.png b/tests/fixtures/pen-oracles/XwyoV.png
new file mode 100644
index 000000000..6584a9393
Binary files /dev/null and b/tests/fixtures/pen-oracles/XwyoV.png differ
diff --git a/tests/fixtures/pen-oracles/ZqgQn.png b/tests/fixtures/pen-oracles/ZqgQn.png
new file mode 100644
index 000000000..3f3906bb2
Binary files /dev/null and b/tests/fixtures/pen-oracles/ZqgQn.png differ
diff --git a/tests/fixtures/pen-oracles/alRyT.png b/tests/fixtures/pen-oracles/alRyT.png
new file mode 100644
index 000000000..fcaaa5157
Binary files /dev/null and b/tests/fixtures/pen-oracles/alRyT.png differ
diff --git a/tests/fixtures/pen-oracles/apjeC.png b/tests/fixtures/pen-oracles/apjeC.png
new file mode 100644
index 000000000..280f6d80a
Binary files /dev/null and b/tests/fixtures/pen-oracles/apjeC.png differ
diff --git a/tests/fixtures/pen-oracles/ayqm5.png b/tests/fixtures/pen-oracles/ayqm5.png
new file mode 100644
index 000000000..9fac58e26
Binary files /dev/null and b/tests/fixtures/pen-oracles/ayqm5.png differ
diff --git a/tests/fixtures/pen-oracles/bi8Au.png b/tests/fixtures/pen-oracles/bi8Au.png
new file mode 100644
index 000000000..c4f265fc2
Binary files /dev/null and b/tests/fixtures/pen-oracles/bi8Au.png differ
diff --git a/tests/fixtures/pen-oracles/c6sX3L.png b/tests/fixtures/pen-oracles/c6sX3L.png
new file mode 100644
index 000000000..a1c6c4f59
Binary files /dev/null and b/tests/fixtures/pen-oracles/c6sX3L.png differ
diff --git a/tests/fixtures/pen-oracles/cDh6W.png b/tests/fixtures/pen-oracles/cDh6W.png
new file mode 100644
index 000000000..32cb7ba0d
Binary files /dev/null and b/tests/fixtures/pen-oracles/cDh6W.png differ
diff --git a/tests/fixtures/pen-oracles/fonts/Inter--Light.font b/tests/fixtures/pen-oracles/fonts/Inter--Light.font
new file mode 100644
index 000000000..f6f160841
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Inter--Light.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Inter--Regular Italic.font b/tests/fixtures/pen-oracles/fonts/Inter--Regular Italic.font
new file mode 100644
index 000000000..42757216c
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Inter--Regular Italic.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--Bold.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--Bold.font
new file mode 100644
index 000000000..8e46b3880
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--Bold.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--ExtraLight.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--ExtraLight.font
new file mode 100644
index 000000000..246a92919
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--ExtraLight.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--Light.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--Light.font
new file mode 100644
index 000000000..ba3c5d7d5
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--Light.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--Medium.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--Medium.font
new file mode 100644
index 000000000..083ce6315
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--Medium.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--Regular.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--Regular.font
new file mode 100644
index 000000000..1526512b1
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--Regular.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--SemiBold.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--SemiBold.font
new file mode 100644
index 000000000..ff1b2df12
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--SemiBold.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--Thin.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--Thin.font
new file mode 100644
index 000000000..12b40401e
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Outlined--Thin.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--Bold.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--Bold.font
new file mode 100644
index 000000000..7cc42e8c3
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--Bold.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--ExtraLight.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--ExtraLight.font
new file mode 100644
index 000000000..505efe3d0
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--ExtraLight.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--Light.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--Light.font
new file mode 100644
index 000000000..f7c6326d0
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--Light.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--Medium.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--Medium.font
new file mode 100644
index 000000000..b5c744033
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--Medium.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--Regular.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--Regular.font
new file mode 100644
index 000000000..93eb4208b
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--Regular.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--SemiBold.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--SemiBold.font
new file mode 100644
index 000000000..bf4085a2a
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--SemiBold.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--Thin.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--Thin.font
new file mode 100644
index 000000000..ba264a8da
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Rounded--Thin.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--Bold.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--Bold.font
new file mode 100644
index 000000000..59dbef37d
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--Bold.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--ExtraLight.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--ExtraLight.font
new file mode 100644
index 000000000..6f27d1e8f
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--ExtraLight.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--Light.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--Light.font
new file mode 100644
index 000000000..e9628c88d
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--Light.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--Medium.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--Medium.font
new file mode 100644
index 000000000..9ff3179f0
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--Medium.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--Regular.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--Regular.font
new file mode 100644
index 000000000..bc153b8b4
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--Regular.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--SemiBold.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--SemiBold.font
new file mode 100644
index 000000000..168feae1c
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--SemiBold.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--Thin.font b/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--Thin.font
new file mode 100644
index 000000000..78b5ab813
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Material Symbols Sharp--Thin.font differ
diff --git a/tests/fixtures/pen-oracles/fonts/Roboto--Regular.font b/tests/fixtures/pen-oracles/fonts/Roboto--Regular.font
new file mode 100644
index 000000000..68b54693b
Binary files /dev/null and b/tests/fixtures/pen-oracles/fonts/Roboto--Regular.font differ
diff --git a/tests/fixtures/pen-oracles/iconify/feather.json b/tests/fixtures/pen-oracles/iconify/feather.json
new file mode 100644
index 000000000..c24eb5fef
--- /dev/null
+++ b/tests/fixtures/pen-oracles/iconify/feather.json
@@ -0,0 +1,19 @@
+{
+ "prefix": "feather",
+ "width": 24,
+ "height": 24,
+ "icons": {
+ "star": {
+ "body": "<path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m12 2l3.09 6.26L22 9.27l-5 4.87l1.18 6.88L12 17.77l-6.18 3.25L7 14.14L2 9.27l6.91-1.01z\"/>"
+ },
+ "home": {
+ "body": "<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path d=\"m3 9l9-7l9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z\"/><path d=\"M9 22V12h6v10\"/></g>"
+ },
+ "sun": {
+ "body": "<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><circle cx=\"12\" cy=\"12\" r=\"5\"/><path d=\"M12 1v2m0 18v2M4.22 4.22l1.42 1.42m12.72 12.72l1.42 1.42M1 12h2m18 0h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42\"/></g>"
+ }
+ },
+ "lastModified": 1722793403,
+ "aliases": {},
+ "not_found": ["dark_mode"]
+}
diff --git a/tests/fixtures/pen-oracles/iconify/lucide.json b/tests/fixtures/pen-oracles/iconify/lucide.json
new file mode 100644
index 000000000..15f8f83bc
--- /dev/null
+++ b/tests/fixtures/pen-oracles/iconify/lucide.json
@@ -0,0 +1,19 @@
+{
+ "prefix": "lucide",
+ "width": 24,
+ "height": 24,
+ "icons": {
+ "heart": {
+ "body": "<path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M2 9.5a5.5 5.5 0 0 1 9.591-3.676a.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5\"/>"
+ },
+ "house": {
+ "body": "<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path d=\"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8\"/><path d=\"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z\"/></g>"
+ },
+ "sun": {
+ "body": "<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><circle cx=\"12\" cy=\"12\" r=\"4\"/><path d=\"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41\"/></g>"
+ }
+ },
+ "lastModified": 1792510664,
+ "aliases": {},
+ "not_found": ["dark_mode"]
+}
diff --git a/tests/fixtures/pen-oracles/iconify/ph.json b/tests/fixtures/pen-oracles/iconify/ph.json
new file mode 100644
index 000000000..b704a23ab
--- /dev/null
+++ b/tests/fixtures/pen-oracles/iconify/ph.json
@@ -0,0 +1,15 @@
+{
+ "prefix": "ph",
+ "width": 256,
+ "height": 256,
+ "icons": {
+ "airplane": {
+ "body": "<path fill=\"currentColor\" d=\"M235.58 128.84L160 91.06V48a32 32 0 0 0-64 0v43.06l-75.58 37.78A8 8 0 0 0 16 136v32a8 8 0 0 0 9.57 7.84L96 161.76v18.93l-13.66 13.65A8 8 0 0 0 80 200v32a8 8 0 0 0 11 7.43l37-14.81l37 14.81a8 8 0 0 0 11-7.43v-32a8 8 0 0 0-2.34-5.66L160 180.69v-18.93l70.43 14.08A8 8 0 0 0 240 168v-32a8 8 0 0 0-4.42-7.16M224 158.24l-70.43-14.08A8 8 0 0 0 144 152v32a8 8 0 0 0 2.34 5.66L160 203.31v16.87l-29-11.61a8 8 0 0 0-5.94 0L96 220.18v-16.87l13.66-13.65A8 8 0 0 0 112 184v-32a8 8 0 0 0-9.57-7.84L32 158.24v-17.3l75.58-37.78A8 8 0 0 0 112 96V48a16 16 0 0 1 32 0v48a8 8 0 0 0 4.42 7.16L224 140.94Z\"/>"
+ },
+ "house": {
+ "body": "<path fill=\"currentColor\" d=\"m219.31 108.68l-80-80a16 16 0 0 0-22.62 0l-80 80A15.87 15.87 0 0 0 32 120v96a8 8 0 0 0 8 8h64a8 8 0 0 0 8-8v-56h32v56a8 8 0 0 0 8 8h64a8 8 0 0 0 8-8v-96a15.87 15.87 0 0 0-4.69-11.32M208 208h-48v-56a8 8 0 0 0-8-8h-48a8 8 0 0 0-8 8v56H48v-88l80-80l80 80Z\"/>"
+ }
+ },
+ "lastModified": 1714973607,
+ "aliases": {}
+}
diff --git a/tests/fixtures/pen-oracles/manifest.json b/tests/fixtures/pen-oracles/manifest.json
new file mode 100644
index 000000000..c6cd51ec6
--- /dev/null
+++ b/tests/fixtures/pen-oracles/manifest.json
@@ -0,0 +1,109 @@
+{
+ "document": "probes.pen",
+ "targets": [
+ {
+ "node": "Frame",
+ "penNodeId": "bi8Au",
+ "maximumDifferentPercent": 0.05
+ },
+ {
+ "node": "Stroke Probe",
+ "penNodeId": "XwyoV",
+ "maximumDifferentPercent": 0.05
+ },
+ {
+ "node": "Align Probe",
+ "penNodeId": "ZqgQn",
+ "maximumDifferentPercent": 0.05
+ },
+ {
+ "node": "P Fills",
+ "penNodeId": "VuLq8",
+ "maximumDifferentPercent": 0.05
+ },
+ {
+ "node": "P Effects",
+ "penNodeId": "AMkAG",
+ "maximumDifferentPercent": 0.05
+ },
+ {
+ "node": "P Shapes",
+ "penNodeId": "G1aH4g",
+ "maximumDifferentPercent": 0.05
+ },
+ {
+ "node": "P Transforms",
+ "penNodeId": "ptfGa",
+ "maximumDifferentPercent": 0.05
+ },
+ {
+ "node": "P Text",
+ "penNodeId": "or6x9",
+ "maximumDifferentPercent": 1.02,
+ "note": "pen.dev lets fixed-size text overflow its box; OpenPencil clips it."
+ },
+ {
+ "node": "P Layout",
+ "penNodeId": "MBeS5",
+ "maximumDifferentPercent": 0.05
+ },
+ {
+ "node": "P Vars",
+ "penNodeId": "o2znWP",
+ "maximumDifferentPercent": 0.13
+ },
+ {
+ "node": "P Components",
+ "penNodeId": "w0MCR",
+ "maximumDifferentPercent": 0.25
+ },
+ {
+ "node": "P Images",
+ "penNodeId": "ayqm5",
+ "maximumDifferentPercent": 0.07
+ },
+ {
+ "node": "P Icons",
+ "penNodeId": "rMpIj",
+ "maximumDifferentPercent": 0.05
+ },
+ {
+ "node": "P Strokes",
+ "penNodeId": "sqoEc",
+ "maximumDifferentPercent": 0.05
+ },
+ {
+ "node": "P Other types",
+ "penNodeId": "c6sX3L",
+ "maximumDifferentPercent": 9.45,
+ "note": "Note, context, and prompt layers are pen.dev's own and are not read."
+ },
+ {
+ "node": "M Gradients",
+ "penNodeId": "cDh6W",
+ "maximumDifferentPercent": 0.05
+ },
+ {
+ "node": "M Transforms",
+ "penNodeId": "apjeC",
+ "maximumDifferentPercent": 0.05
+ },
+ {
+ "node": "M Themes",
+ "penNodeId": "HD4Cf",
+ "maximumDifferentPercent": 0.05
+ },
+ {
+ "node": "P Icon weights",
+ "penNodeId": "MOmt0",
+ "maximumDifferentPercent": 0.24,
+ "note": "Google's static Material Symbols faces for weights 100 and 200 both declare weight class 250, and the renderer picks a family's face by it, so with both loaded 200 draws as 100."
+ },
+ {
+ "node": "P Icon variables",
+ "penNodeId": "alRyT",
+ "maximumDifferentPercent": 0.19,
+ "note": "Google's static Material Symbols faces for weights 100 and 200 both declare weight class 250, and the renderer picks a family's face by it, so with both loaded 200 draws as 100."
+ }
+ ]
+}
diff --git a/tests/fixtures/pen-oracles/o2znWP.png b/tests/fixtures/pen-oracles/o2znWP.png
new file mode 100644
index 000000000..b022c6eb2
Binary files /dev/null and b/tests/fixtures/pen-oracles/o2znWP.png differ
diff --git a/tests/fixtures/pen-oracles/or6x9.png b/tests/fixtures/pen-oracles/or6x9.png
new file mode 100644
index 000000000..d8a414d86
Binary files /dev/null and b/tests/fixtures/pen-oracles/or6x9.png differ
diff --git a/tests/fixtures/pen-oracles/probes.pen b/tests/fixtures/pen-oracles/probes.pen
new file mode 100644
index 000000000..a9473922b
--- /dev/null
+++ b/tests/fixtures/pen-oracles/probes.pen
@@ -0,0 +1,3782 @@
+{
+ "children": [
+ {
+ "id": "bi8Au",
+ "type": "frame",
+ "x": 0,
+ "y": 0,
+ "name": "Frame",
+ "clip": true,
+ "width": 800,
+ "height": 600,
+ "fill": "#FFFFFF",
+ "layout": "none"
+ },
+ {
+ "id": "XwyoV",
+ "type": "frame",
+ "x": 840,
+ "y": 0,
+ "name": "Stroke Probe",
+ "width": 520,
+ "height": 140,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "F9iz7g",
+ "x": 20,
+ "y": 30,
+ "name": "color only",
+ "fill": "#EEEEEE",
+ "width": 100,
+ "height": 80,
+ "stroke": "#FF0000"
+ },
+ {
+ "type": "rectangle",
+ "id": "oqvg1",
+ "x": 145,
+ "y": 30,
+ "name": "width only",
+ "fill": "#EEEEEE",
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "rectangle",
+ "id": "zmWkO",
+ "x": 270,
+ "y": 30,
+ "name": "both",
+ "fill": "#EEEEEE",
+ "width": 100,
+ "height": 80,
+ "stroke": "#FF0000",
+ "strokeWidth": 4
+ },
+ {
+ "type": "rectangle",
+ "id": "dzNph",
+ "x": 395,
+ "y": 30,
+ "name": "list",
+ "fill": "#EEEEEE",
+ "width": 100,
+ "height": 80,
+ "stroke": [
+ "#FF0000",
+ "#0000FF80"
+ ],
+ "strokeWidth": 4
+ }
+ ]
+ },
+ {
+ "id": "ZqgQn",
+ "type": "frame",
+ "x": 840,
+ "y": 180,
+ "name": "Align Probe",
+ "width": 520,
+ "height": 140,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "B8CUEc",
+ "x": 20,
+ "y": 30,
+ "name": "default",
+ "fill": "#EEEEEE",
+ "width": 100,
+ "height": 80,
+ "stroke": "#FF0000",
+ "strokeWidth": 10
+ },
+ {
+ "type": "rectangle",
+ "id": "hGBlS",
+ "x": 145,
+ "y": 30,
+ "name": "inner",
+ "fill": "#EEEEEE",
+ "width": 100,
+ "height": 80,
+ "stroke": "#FF0000",
+ "strokeWidth": 10,
+ "strokeAlignment": "inner"
+ },
+ {
+ "type": "rectangle",
+ "id": "D1zQOq",
+ "x": 270,
+ "y": 30,
+ "name": "center",
+ "fill": "#EEEEEE",
+ "width": 100,
+ "height": 80,
+ "stroke": "#FF0000",
+ "strokeWidth": 10
+ },
+ {
+ "type": "rectangle",
+ "id": "S77jN",
+ "x": 395,
+ "y": 30,
+ "name": "outer",
+ "fill": "#EEEEEE",
+ "width": 100,
+ "height": 80,
+ "stroke": "#FF0000",
+ "strokeWidth": 10,
+ "strokeAlignment": "outer"
+ },
+ {
+ "type": "line",
+ "id": "sEJi2",
+ "x": 20,
+ "y": 125,
+ "name": "line width only",
+ "width": 480,
+ "height": 0
+ }
+ ]
+ },
+ {
+ "id": "VuLq8",
+ "type": "frame",
+ "x": 0,
+ "y": 640,
+ "name": "P Fills",
+ "clip": true,
+ "width": 660,
+ "height": 240,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "MwNb7",
+ "x": 20,
+ "y": 20,
+ "name": "hex alpha",
+ "fill": "#FF000080",
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "rectangle",
+ "id": "SNH9N",
+ "x": 140,
+ "y": 20,
+ "name": "color obj",
+ "fill": "#00AA00",
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "rectangle",
+ "id": "UB2rL",
+ "x": 260,
+ "y": 20,
+ "name": "stack",
+ "fill": [
+ "#FF0000",
+ "#0000FF80"
+ ],
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "rectangle",
+ "id": "WF9er",
+ "x": 380,
+ "y": 20,
+ "name": "disabled top",
+ "fill": [
+ "#FF0000",
+ {
+ "type": "color",
+ "color": "#0000FF",
+ "enabled": false
+ }
+ ],
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "rectangle",
+ "id": "NwchB",
+ "x": 500,
+ "y": 20,
+ "name": "blend multiply",
+ "fill": [
+ "#FFFF00",
+ {
+ "type": "color",
+ "color": "#00FFFF",
+ "enabled": true,
+ "blendMode": "multiply"
+ }
+ ],
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "rectangle",
+ "id": "YB07w",
+ "x": 20,
+ "y": 130,
+ "name": "lin default",
+ "fill": {
+ "type": "gradient",
+ "gradientType": "linear",
+ "enabled": true,
+ "rotation": 0,
+ "size": {
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#FF0000",
+ "position": 0
+ },
+ {
+ "color": "#0000FF",
+ "position": 1
+ }
+ ]
+ },
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "rectangle",
+ "id": "eQu2X",
+ "x": 140,
+ "y": 130,
+ "name": "lin rot90",
+ "fill": {
+ "type": "gradient",
+ "gradientType": "linear",
+ "enabled": true,
+ "rotation": 90,
+ "size": {
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#FF0000",
+ "position": 0
+ },
+ {
+ "color": "#0000FF",
+ "position": 1
+ }
+ ]
+ },
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "rectangle",
+ "id": "Bhm15",
+ "x": 260,
+ "y": 130,
+ "name": "lin small",
+ "fill": {
+ "type": "gradient",
+ "gradientType": "linear",
+ "enabled": true,
+ "opacity": 0.7,
+ "rotation": 45,
+ "size": {
+ "height": 0.5
+ },
+ "colors": [
+ {
+ "color": "#FF0000",
+ "position": 0
+ },
+ {
+ "color": "#00FF00",
+ "position": 0.5
+ },
+ {
+ "color": "#0000FF",
+ "position": 1
+ }
+ ],
+ "center": {
+ "x": 0.3,
+ "y": 0.4
+ }
+ },
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "rectangle",
+ "id": "S2saIR",
+ "x": 380,
+ "y": 130,
+ "name": "radial",
+ "fill": {
+ "type": "gradient",
+ "gradientType": "radial",
+ "enabled": true,
+ "rotation": 0,
+ "size": {
+ "width": 0.6,
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#FFFFFF",
+ "position": 0
+ },
+ {
+ "color": "#000000",
+ "position": 1
+ }
+ ],
+ "center": {
+ "x": 0.3
+ }
+ },
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "rectangle",
+ "id": "EhCbd",
+ "x": 500,
+ "y": 130,
+ "name": "angular",
+ "fill": {
+ "type": "gradient",
+ "gradientType": "angular",
+ "enabled": true,
+ "rotation": 30,
+ "size": {
+ "width": 1,
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#FF0000",
+ "position": 0
+ },
+ {
+ "color": "#0000FF",
+ "position": 1
+ }
+ ]
+ },
+ "width": 100,
+ "height": 80
+ }
+ ]
+ },
+ {
+ "id": "AMkAG",
+ "type": "frame",
+ "x": 0,
+ "y": 920,
+ "name": "P Effects",
+ "clip": true,
+ "width": 660,
+ "height": 140,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "rectangle",
+ "cornerRadius": 8,
+ "id": "yz7eP",
+ "x": 20,
+ "y": 30,
+ "name": "shadow default",
+ "fill": "#4488FF",
+ "width": 100,
+ "height": 80,
+ "effect": {
+ "type": "shadow",
+ "shadowType": "outer",
+ "color": "#000000"
+ }
+ },
+ {
+ "type": "rectangle",
+ "cornerRadius": 8,
+ "id": "V8WyF",
+ "x": 140,
+ "y": 30,
+ "name": "shadow outer",
+ "fill": "#4488FF",
+ "width": 100,
+ "height": 80,
+ "effect": {
+ "type": "shadow",
+ "shadowType": "outer",
+ "color": "#00000080",
+ "offset": {
+ "x": 6,
+ "y": 8
+ },
+ "blur": 10
+ }
+ },
+ {
+ "type": "rectangle",
+ "cornerRadius": 8,
+ "id": "Tsy8X",
+ "x": 260,
+ "y": 30,
+ "name": "shadow inner",
+ "fill": "#4488FF",
+ "width": 100,
+ "height": 80,
+ "effect": {
+ "type": "shadow",
+ "shadowType": "inner",
+ "color": "#000000AA",
+ "offset": {
+ "x": 4,
+ "y": 4
+ },
+ "blur": 6
+ }
+ },
+ {
+ "type": "rectangle",
+ "cornerRadius": 8,
+ "id": "BarLD",
+ "x": 380,
+ "y": 30,
+ "name": "blur",
+ "fill": "#4488FF",
+ "width": 100,
+ "height": 80,
+ "effect": {
+ "type": "blur",
+ "radius": 8
+ }
+ },
+ {
+ "type": "rectangle",
+ "cornerRadius": 8,
+ "id": "fpoVI",
+ "x": 500,
+ "y": 30,
+ "name": "two shadows",
+ "fill": "#4488FF",
+ "width": 100,
+ "height": 80,
+ "effect": [
+ {
+ "type": "shadow",
+ "shadowType": "outer",
+ "color": "#FF0000",
+ "offset": {
+ "x": -6,
+ "y": 0
+ }
+ },
+ {
+ "type": "shadow",
+ "shadowType": "outer",
+ "color": "#00AA00",
+ "offset": {
+ "x": 6,
+ "y": 0
+ }
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "id": "G1aH4g",
+ "type": "frame",
+ "x": 0,
+ "y": 1100,
+ "name": "P Shapes",
+ "clip": true,
+ "width": 660,
+ "height": 260,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "ellipse",
+ "id": "mps8g",
+ "x": 20,
+ "y": 20,
+ "name": "ellipse",
+ "fill": "#335599",
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "ellipse",
+ "id": "x61wE",
+ "x": 140,
+ "y": 20,
+ "name": "ring",
+ "innerRadius": 0.5,
+ "fill": "#335599",
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "ellipse",
+ "id": "eJMbM",
+ "x": 260,
+ "y": 20,
+ "name": "arc",
+ "startAngle": 30,
+ "sweepAngle": 200,
+ "fill": "#335599",
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "ellipse",
+ "id": "Sm4fA",
+ "x": 380,
+ "y": 20,
+ "name": "arc cw ring",
+ "innerRadius": 0.4,
+ "sweepAngle": -90,
+ "fill": "#335599",
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "polygon",
+ "polygonCount": 3,
+ "id": "jQMNl",
+ "x": 500,
+ "y": 20,
+ "name": "tri",
+ "fill": "#335599",
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "polygon",
+ "polygonCount": 6,
+ "id": "G1GsqE",
+ "x": 20,
+ "y": 140,
+ "name": "hex",
+ "fill": "#335599",
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "polygon",
+ "polygonCount": 5,
+ "cornerRadius": 10,
+ "id": "o33qNH",
+ "x": 140,
+ "y": 140,
+ "name": "pent round",
+ "fill": "#335599",
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "path",
+ "id": "W1QVLc",
+ "x": 260,
+ "y": 140,
+ "name": "path viewbox",
+ "geometry": "M0 0l50 0 0 50z",
+ "viewBox": [
+ 0,
+ 0,
+ 100,
+ 100
+ ],
+ "fill": "#335599",
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "path",
+ "id": "STs7E",
+ "x": 380,
+ "y": 140,
+ "name": "path evenodd",
+ "geometry": "M0 0h100v80h-100z m25 20h50v40h-50z",
+ "fillRule": "evenodd",
+ "fill": "#335599",
+ "width": 100,
+ "height": 80
+ },
+ {
+ "type": "rectangle",
+ "cornerRadius": [
+ 0,
+ 10,
+ 30,
+ 60
+ ],
+ "id": "m8QEog",
+ "x": 500,
+ "y": 140,
+ "name": "radii",
+ "fill": "#335599",
+ "width": 100,
+ "height": 80
+ }
+ ]
+ },
+ {
+ "id": "ptfGa",
+ "type": "frame",
+ "x": 0,
+ "y": 1400,
+ "name": "P Transforms",
+ "clip": true,
+ "width": 660,
+ "height": 220,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "EEcZU",
+ "x": 40,
+ "y": 40,
+ "name": "rot30",
+ "rotation": 29.999999999999996,
+ "fill": "#335599",
+ "width": 100,
+ "height": 60
+ },
+ {
+ "type": "rectangle",
+ "id": "h2uUy9",
+ "x": 200,
+ "y": 60,
+ "name": "rot-45",
+ "rotation": -45,
+ "fill": "#335599",
+ "width": 100,
+ "height": 60
+ },
+ {
+ "type": "rectangle",
+ "id": "h9RSK4",
+ "x": 340,
+ "y": 40,
+ "name": "flipX grad",
+ "flipX": true,
+ "fill": {
+ "type": "gradient",
+ "gradientType": "linear",
+ "enabled": true,
+ "rotation": 90,
+ "size": {
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#FF0000",
+ "position": 0
+ },
+ {
+ "color": "#0000FF",
+ "position": 1
+ }
+ ]
+ },
+ "width": 100,
+ "height": 60
+ },
+ {
+ "type": "rectangle",
+ "id": "OtQdh",
+ "x": 480,
+ "y": 40,
+ "name": "opacity",
+ "opacity": 0.4,
+ "fill": "#335599",
+ "width": 100,
+ "height": 60
+ },
+ {
+ "type": "group",
+ "id": "RWcnU",
+ "x": 60,
+ "y": 140,
+ "name": "group rot",
+ "rotation": 10,
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "mXgwe",
+ "x": 0,
+ "y": 0,
+ "name": "g a",
+ "fill": "#FF8800",
+ "width": 60,
+ "height": 40
+ },
+ {
+ "type": "ellipse",
+ "id": "xM33c",
+ "x": 70,
+ "y": 10,
+ "name": "g b",
+ "fill": "#00AA88",
+ "width": 40,
+ "height": 40
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "id": "or6x9",
+ "type": "frame",
+ "x": 0,
+ "y": 1660,
+ "name": "P Text",
+ "clip": true,
+ "width": 660,
+ "height": 420,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "text",
+ "id": "Uvujd",
+ "x": 20,
+ "y": 20,
+ "name": "auto default",
+ "fill": "#111111",
+ "content": "auto default",
+ "fontFamily": "Inter",
+ "fontSize": 16,
+ "fontWeight": "normal"
+ },
+ {
+ "type": "text",
+ "id": "OhQ0u",
+ "x": 20,
+ "y": 50,
+ "name": "bold 700",
+ "fill": "#111111",
+ "content": "bold 700",
+ "fontFamily": "Inter",
+ "fontSize": 16,
+ "fontWeight": "700"
+ },
+ {
+ "type": "text",
+ "id": "rUAzJ",
+ "x": 20,
+ "y": 80,
+ "name": "italic",
+ "fill": "#111111",
+ "content": "italic",
+ "fontFamily": "Inter",
+ "fontSize": 16,
+ "fontWeight": "normal",
+ "fontStyle": "italic"
+ },
+ {
+ "type": "text",
+ "id": "v0cpvq",
+ "x": 20,
+ "y": 110,
+ "name": "underline strike",
+ "fill": "#111111",
+ "content": "underline strike",
+ "fontFamily": "Inter",
+ "fontSize": 16,
+ "fontWeight": "normal"
+ },
+ {
+ "type": "text",
+ "id": "zijPf",
+ "x": 20,
+ "y": 140,
+ "name": "letterSpacing 4",
+ "fill": "#111111",
+ "content": "letterSpacing 4",
+ "fontFamily": "Inter",
+ "fontSize": 16,
+ "fontWeight": "normal",
+ "letterSpacing": 4
+ },
+ {
+ "type": "text",
+ "id": "iHu6g",
+ "x": 20,
+ "y": 170,
+ "name": "size 28 lh 2",
+ "fill": "#111111",
+ "content": "size 28 lh 2",
+ "lineHeight": 2,
+ "fontFamily": "Inter",
+ "fontSize": 28,
+ "fontWeight": "normal"
+ },
+ {
+ "type": "text",
+ "id": "k0NT2",
+ "x": 20,
+ "y": 260,
+ "name": "fixed width wraps this sentence into lines",
+ "fill": "#111111",
+ "textGrowth": "fixed-width",
+ "width": 150,
+ "content": "fixed width wraps this sentence into lines",
+ "textAlign": "center",
+ "fontFamily": "Inter",
+ "fontSize": 16,
+ "fontWeight": "normal"
+ },
+ {
+ "type": "text",
+ "id": "kbDwt",
+ "x": 200,
+ "y": 20,
+ "name": "fixed wh middle bottom",
+ "fill": "#111111",
+ "textGrowth": "fixed-width-height",
+ "width": 180,
+ "height": 100,
+ "content": "fixed wh middle bottom",
+ "textAlignVertical": "middle",
+ "fontFamily": "Inter",
+ "fontSize": 16,
+ "fontWeight": "normal"
+ },
+ {
+ "type": "rectangle",
+ "id": "D1DF7A",
+ "x": 200,
+ "y": 20,
+ "name": "box1",
+ "fill": "#00000010",
+ "width": 180,
+ "height": 100
+ },
+ {
+ "type": "text",
+ "id": "GNsom",
+ "x": 200,
+ "y": 140,
+ "name": "justify justify justify justify justify words here",
+ "fill": "#111111",
+ "textGrowth": "fixed-width",
+ "width": 180,
+ "content": "justify justify justify justify justify words here",
+ "textAlign": "justify",
+ "fontFamily": "Inter",
+ "fontSize": 16,
+ "fontWeight": "normal"
+ },
+ {
+ "type": "text",
+ "id": "e9pdBe",
+ "x": 200,
+ "y": 230,
+ "name": "right aligned",
+ "fill": "#111111",
+ "textGrowth": "fixed-width",
+ "width": 180,
+ "content": "right aligned",
+ "textAlign": "right",
+ "fontFamily": "Inter",
+ "fontSize": 16,
+ "fontWeight": "normal"
+ },
+ {
+ "type": "text",
+ "id": "axX5E",
+ "x": 420,
+ "y": 20,
+ "name": "weight light",
+ "fill": "#111111",
+ "content": "weight light",
+ "fontFamily": "Inter",
+ "fontSize": 16,
+ "fontWeight": "300"
+ },
+ {
+ "type": "text",
+ "id": "vtENf",
+ "x": 420,
+ "y": 50,
+ "name": "weight semibold",
+ "fill": "#111111",
+ "content": "weight semibold",
+ "fontFamily": "Inter",
+ "fontSize": 16,
+ "fontWeight": "600"
+ },
+ {
+ "type": "text",
+ "id": "iAO1p",
+ "x": 420,
+ "y": 80,
+ "name": "Roboto",
+ "fill": "#111111",
+ "content": "Roboto",
+ "fontFamily": "Roboto",
+ "fontSize": 16,
+ "fontWeight": "normal"
+ },
+ {
+ "type": "text",
+ "id": "BuHBT",
+ "x": 420,
+ "y": 110,
+ "name": "stroked text",
+ "fill": "#111111",
+ "content": "stroked text",
+ "fontFamily": "Inter",
+ "fontSize": 28,
+ "fontWeight": "normal"
+ },
+ {
+ "type": "text",
+ "id": "RQQuu",
+ "x": 420,
+ "y": 160,
+ "name": "line1\nline2 auto",
+ "fill": "#111111",
+ "content": "line1\nline2 auto",
+ "fontFamily": "Inter",
+ "fontSize": 16,
+ "fontWeight": "normal"
+ },
+ {
+ "type": "text",
+ "id": "V4rsS",
+ "x": 420,
+ "y": 230,
+ "name": "fixed-wh overflow text that is long and keeps going",
+ "fill": "#111111",
+ "textGrowth": "fixed-width-height",
+ "width": 120,
+ "height": 40,
+ "content": "fixed-wh overflow text that is long and keeps going",
+ "fontFamily": "Inter",
+ "fontSize": 16,
+ "fontWeight": "normal"
+ }
+ ]
+ },
+ {
+ "id": "MBeS5",
+ "type": "frame",
+ "x": 0,
+ "y": 2120,
+ "name": "P Layout",
+ "clip": true,
+ "width": 660,
+ "height": 460,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "frame",
+ "id": "A0jM98",
+ "x": 20,
+ "y": 20,
+ "name": "space_around",
+ "width": 300,
+ "height": 50,
+ "fill": "#EEEEEE",
+ "justifyContent": "space_around",
+ "alignItems": "center",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "vgpRT",
+ "name": "a",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ },
+ {
+ "type": "rectangle",
+ "id": "P75Bf",
+ "name": "b",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 20
+ },
+ {
+ "type": "rectangle",
+ "id": "l4IX4l",
+ "name": "c",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "X9e7G",
+ "x": 20,
+ "y": 90,
+ "name": "space_between pad",
+ "width": 300,
+ "height": 50,
+ "fill": "#EEEEEE",
+ "padding": [
+ 5,
+ 10
+ ],
+ "justifyContent": "space_between",
+ "alignItems": "end",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "t6O1NL",
+ "name": "a",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ },
+ {
+ "type": "rectangle",
+ "id": "QqXTD",
+ "name": "b",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 20
+ },
+ {
+ "type": "rectangle",
+ "id": "hMvrm",
+ "name": "c",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "XdUhh",
+ "x": 20,
+ "y": 160,
+ "name": "center gap",
+ "width": 300,
+ "height": 50,
+ "fill": "#EEEEEE",
+ "gap": 12,
+ "justifyContent": "center",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "e42El",
+ "name": "a",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ },
+ {
+ "type": "rectangle",
+ "id": "uZ9sQ",
+ "name": "b",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 20
+ },
+ {
+ "type": "rectangle",
+ "id": "AITY2",
+ "name": "c",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "VCo0m",
+ "x": 20,
+ "y": 230,
+ "name": "absolute+disabled",
+ "width": 300,
+ "height": 50,
+ "fill": "#EEEEEE",
+ "gap": 8,
+ "padding": 6,
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "VG1SZ",
+ "name": "a",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ },
+ {
+ "type": "rectangle",
+ "id": "giFz1",
+ "name": "b",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 20
+ },
+ {
+ "type": "rectangle",
+ "id": "pGOEZ",
+ "name": "c",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ },
+ {
+ "type": "rectangle",
+ "id": "VJ5zc",
+ "layoutPosition": "absolute",
+ "x": 200,
+ "y": 10,
+ "name": "abs",
+ "fill": "#FF5500",
+ "width": 30,
+ "height": 30
+ },
+ {
+ "type": "rectangle",
+ "id": "Z88aL",
+ "x": 0,
+ "y": 0,
+ "name": "off",
+ "enabled": false,
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ },
+ {
+ "type": "rectangle",
+ "id": "k6Iukc",
+ "name": "after",
+ "fill": "#00AA55",
+ "width": 30,
+ "height": 30
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "skscE",
+ "x": 360,
+ "y": 20,
+ "name": "vertical fit",
+ "fill": "#EEEEEE",
+ "layout": "vertical",
+ "gap": 6,
+ "padding": 8,
+ "alignItems": "center",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "nehPD",
+ "name": "v1",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ },
+ {
+ "type": "rectangle",
+ "id": "DDiPN",
+ "name": "v2",
+ "fill": "#3355AA",
+ "width": 60,
+ "height": 30
+ },
+ {
+ "type": "rectangle",
+ "id": "x9xpuV",
+ "name": "v fill",
+ "fill": "#AA3355",
+ "width": "fill_container",
+ "height": 10
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "hiBH6",
+ "x": 360,
+ "y": 200,
+ "name": "fit fallback",
+ "width": "fit_content(90)",
+ "height": "fit_content(40)",
+ "fill": "#CCCCFF"
+ },
+ {
+ "type": "frame",
+ "id": "IV3yr",
+ "x": 480,
+ "y": 20,
+ "name": "includeStroke",
+ "fill": "#EEEEEE",
+ "stroke": "#000000",
+ "strokeWidth": 6,
+ "padding": 4,
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "TXXVj",
+ "name": "s1",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "pJJhV",
+ "x": 560,
+ "y": 20,
+ "name": "noIncludeStroke",
+ "fill": "#EEEEEE",
+ "stroke": "#000000",
+ "strokeWidth": 6,
+ "padding": 4,
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "vL6wn",
+ "name": "s2",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "SUqnZ",
+ "x": 20,
+ "y": 300,
+ "name": "fill grow",
+ "width": 400,
+ "height": 50,
+ "fill": "#EEEEEE",
+ "gap": 10,
+ "padding": 5,
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "FzKku",
+ "name": "f1",
+ "fill": "#3355AA",
+ "width": "fill_container",
+ "height": 30
+ },
+ {
+ "type": "rectangle",
+ "id": "r3dVX3",
+ "name": "f2",
+ "fill": "#3355AA",
+ "width": "fill_container",
+ "height": 30
+ },
+ {
+ "type": "rectangle",
+ "id": "R7S0N",
+ "name": "f3",
+ "fill": "#3355AA",
+ "width": 50,
+ "height": "fill_container"
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "ZVUob",
+ "x": 20,
+ "y": 370,
+ "name": "overflow clip",
+ "clip": true,
+ "width": 120,
+ "height": 50,
+ "fill": "#EEEEEE",
+ "gap": 10,
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "g5MMDo",
+ "name": "o1",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ },
+ {
+ "type": "rectangle",
+ "id": "xLm7i",
+ "name": "o2",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ },
+ {
+ "type": "rectangle",
+ "id": "G8ZYPu",
+ "name": "o3",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ },
+ {
+ "type": "rectangle",
+ "id": "mdBtT",
+ "name": "o4",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ },
+ {
+ "type": "rectangle",
+ "id": "SxeAA",
+ "name": "o5",
+ "fill": "#3355AA",
+ "width": 30,
+ "height": 30
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "id": "o2znWP",
+ "type": "frame",
+ "x": 0,
+ "y": 2620,
+ "name": "P Vars",
+ "clip": true,
+ "width": 660,
+ "height": 300,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "frame",
+ "id": "zkv3W",
+ "x": 20,
+ "y": 20,
+ "name": "no theme",
+ "width": 140,
+ "fill": "$pv-bg",
+ "cornerRadius": "$pv-radius",
+ "stroke": "$pv-accent",
+ "strokeWidth": "$pv-w",
+ "layout": "vertical",
+ "gap": "$pv-gap",
+ "padding": 10,
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "MiAbw",
+ "name": "sw accent",
+ "fill": "$pv-accent",
+ "width": "fill_container",
+ "height": 20
+ },
+ {
+ "type": "rectangle",
+ "id": "gW9GC",
+ "name": "sw alias",
+ "fill": "$pv-alias",
+ "width": "fill_container",
+ "height": 20
+ },
+ {
+ "type": "rectangle",
+ "id": "JOtob",
+ "name": "sw shown",
+ "enabled": "$pv-show",
+ "fill": "#888888",
+ "width": "fill_container",
+ "height": 20
+ },
+ {
+ "type": "text",
+ "id": "Bk4cp",
+ "name": "label",
+ "fill": "$pv-accent",
+ "content": "$pv-label",
+ "fontFamily": "Inter",
+ "fontSize": 14,
+ "fontWeight": "normal"
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "e4Pnfo",
+ "x": 180,
+ "y": 20,
+ "name": "dark",
+ "theme": {
+ "mode": "dark"
+ },
+ "width": 140,
+ "fill": "$pv-bg",
+ "cornerRadius": "$pv-radius",
+ "stroke": "$pv-accent",
+ "strokeWidth": "$pv-w",
+ "layout": "vertical",
+ "gap": "$pv-gap",
+ "padding": 10,
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "MjSig",
+ "name": "sw accent",
+ "fill": "$pv-accent",
+ "width": "fill_container",
+ "height": 20
+ },
+ {
+ "type": "rectangle",
+ "id": "o7dbLC",
+ "name": "sw alias",
+ "fill": "$pv-alias",
+ "width": "fill_container",
+ "height": 20
+ },
+ {
+ "type": "rectangle",
+ "id": "V6ir7",
+ "x": 0,
+ "y": 0,
+ "name": "sw shown",
+ "enabled": "$pv-show",
+ "fill": "#888888",
+ "width": "fill_container(0)",
+ "height": 20
+ },
+ {
+ "type": "text",
+ "id": "IMnPD",
+ "name": "label",
+ "fill": "$pv-accent",
+ "content": "$pv-label",
+ "fontFamily": "Inter",
+ "fontSize": 14,
+ "fontWeight": "normal"
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "kkhqq",
+ "x": 340,
+ "y": 20,
+ "name": "light cozy",
+ "theme": {
+ "mode": "light",
+ "density": "cozy"
+ },
+ "width": 140,
+ "fill": "$pv-bg",
+ "cornerRadius": "$pv-radius",
+ "stroke": "$pv-accent",
+ "strokeWidth": "$pv-w",
+ "layout": "vertical",
+ "gap": "$pv-gap",
+ "padding": 10,
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "wIVuA",
+ "name": "sw accent",
+ "fill": "$pv-accent",
+ "width": "fill_container",
+ "height": 20
+ },
+ {
+ "type": "rectangle",
+ "id": "hJcgQ",
+ "name": "sw alias",
+ "fill": "$pv-alias",
+ "width": "fill_container",
+ "height": 20
+ },
+ {
+ "type": "rectangle",
+ "id": "kidux",
+ "name": "sw shown",
+ "enabled": "$pv-show",
+ "fill": "#888888",
+ "width": "fill_container",
+ "height": 20
+ },
+ {
+ "type": "text",
+ "id": "SLyXg",
+ "name": "label",
+ "fill": "$pv-accent",
+ "content": "$pv-label",
+ "fontFamily": "Inter",
+ "fontSize": 14,
+ "fontWeight": "normal"
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "x1tjh",
+ "x": 500,
+ "y": 20,
+ "name": "nested theme",
+ "theme": {
+ "mode": "dark"
+ },
+ "width": 150,
+ "fill": "#DDDDDD",
+ "layout": "vertical",
+ "padding": 5,
+ "children": [
+ {
+ "type": "frame",
+ "id": "E8Mmzl",
+ "name": "inner cozy",
+ "theme": {
+ "density": "cozy"
+ },
+ "width": "fill_container",
+ "fill": "$pv-bg",
+ "layout": "vertical",
+ "gap": "$pv-gap",
+ "padding": 5,
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "Mq3tn",
+ "name": "i1",
+ "fill": "$pv-accent",
+ "width": "fill_container",
+ "height": 20
+ },
+ {
+ "type": "rectangle",
+ "id": "A5iW7",
+ "name": "i2",
+ "fill": "$pv-accent",
+ "width": "fill_container",
+ "height": 20
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "id": "w0MCR",
+ "type": "frame",
+ "x": 0,
+ "y": 2960,
+ "name": "P Components",
+ "clip": true,
+ "width": 660,
+ "height": 360,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "frame",
+ "id": "tdnZY",
+ "x": 20,
+ "y": 20,
+ "name": "Btn",
+ "reusable": true,
+ "fill": "#2255CC",
+ "cornerRadius": 6,
+ "stroke": "#001155",
+ "strokeWidth": 2,
+ "gap": 6,
+ "padding": [
+ 8,
+ 14
+ ],
+ "alignItems": "center",
+ "children": [
+ {
+ "type": "ellipse",
+ "id": "NrSwD",
+ "name": "Dot",
+ "fill": "#FFFFFF",
+ "width": 10,
+ "height": 10
+ },
+ {
+ "type": "text",
+ "id": "v59FT",
+ "name": "Label",
+ "fill": "#FFFFFF",
+ "content": "Button",
+ "fontFamily": "Inter",
+ "fontSize": 14,
+ "fontWeight": "normal"
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "d0jmwn",
+ "x": 20,
+ "y": 80,
+ "name": "Card",
+ "reusable": true,
+ "width": 180,
+ "fill": "#F0F0F0",
+ "layout": "vertical",
+ "gap": 8,
+ "padding": 10,
+ "children": [
+ {
+ "type": "text",
+ "id": "YrRwJ",
+ "name": "Title",
+ "fill": "#111111",
+ "content": "Card title",
+ "fontFamily": "Inter",
+ "fontSize": 14,
+ "fontWeight": "normal"
+ },
+ {
+ "id": "GjuZS",
+ "type": "ref",
+ "ref": "tdnZY",
+ "name": "Card Btn"
+ }
+ ]
+ },
+ {
+ "id": "ItGuy",
+ "type": "ref",
+ "ref": "tdnZY",
+ "x": 240,
+ "y": 20,
+ "name": "plain"
+ },
+ {
+ "id": "XHB11",
+ "type": "ref",
+ "ref": "tdnZY",
+ "x": 360,
+ "y": 20,
+ "name": "label+fill",
+ "fill": "#CC2255",
+ "descendants": {
+ "v59FT": {
+ "content": "Changed"
+ }
+ }
+ },
+ {
+ "id": "zAje5",
+ "type": "ref",
+ "ref": "tdnZY",
+ "x": 500,
+ "y": 20,
+ "name": "stroke color only",
+ "stroke": "#FFAA00"
+ },
+ {
+ "id": "guaK6",
+ "type": "ref",
+ "ref": "tdnZY",
+ "x": 240,
+ "y": 70,
+ "name": "hide dot, width",
+ "width": 150,
+ "descendants": {
+ "NrSwD": {
+ "enabled": false
+ }
+ }
+ },
+ {
+ "id": "vEs7L",
+ "type": "ref",
+ "ref": "tdnZY",
+ "x": 420,
+ "y": 70,
+ "name": "replace dot",
+ "descendants": {
+ "NrSwD": {
+ "type": "rectangle",
+ "id": "N5P3S",
+ "name": "Sq",
+ "fill": "#FFFF00",
+ "width": 10,
+ "height": 10
+ }
+ }
+ },
+ {
+ "id": "c7LeA",
+ "type": "ref",
+ "ref": "d0jmwn",
+ "name": "card nested override",
+ "x": 240,
+ "y": 130,
+ "descendants": {
+ "YrRwJ": {
+ "content": "Nested"
+ },
+ "GjuZS": {
+ "fill": "#119944"
+ },
+ "GjuZS/v59FT": {
+ "content": "Deep"
+ }
+ }
+ },
+ {
+ "id": "Mo0eZ",
+ "type": "ref",
+ "ref": "d0jmwn",
+ "name": "card plain",
+ "x": 440,
+ "y": 130
+ },
+ {
+ "id": "XUF9P",
+ "type": "ref",
+ "ref": "tdnZY",
+ "name": "radius+layout override",
+ "x": 240,
+ "y": 260,
+ "cornerRadius": 20,
+ "layout": "vertical",
+ "padding": 12
+ }
+ ]
+ },
+ {
+ "id": "ayqm5",
+ "type": "frame",
+ "x": 0,
+ "y": 3360,
+ "name": "P Images",
+ "clip": true,
+ "width": 660,
+ "height": 140,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "UTiAA",
+ "x": 20,
+ "y": 20,
+ "name": "cover",
+ "fill": {
+ "type": "image",
+ "enabled": true,
+ "url": "quad.png",
+ "mode": "cover"
+ },
+ "width": 100,
+ "height": 100
+ },
+ {
+ "type": "rectangle",
+ "id": "rdI4q",
+ "x": 140,
+ "y": 20,
+ "name": "contain",
+ "fill": {
+ "type": "image",
+ "enabled": true,
+ "url": "quad.png",
+ "mode": "contain"
+ },
+ "width": 100,
+ "height": 100
+ },
+ {
+ "type": "rectangle",
+ "id": "tA12Z",
+ "x": 260,
+ "y": 20,
+ "name": "stretch",
+ "fill": {
+ "type": "image",
+ "enabled": true,
+ "url": "quad.png",
+ "mode": "stretch"
+ },
+ "width": 100,
+ "height": 100
+ },
+ {
+ "type": "rectangle",
+ "id": "xs85A",
+ "x": 380,
+ "y": 20,
+ "name": "crop right half",
+ "fill": {
+ "type": "image",
+ "enabled": true,
+ "url": "quad.png",
+ "mode": "cover",
+ "transform": [
+ 2,
+ 0,
+ 0,
+ 1,
+ -1,
+ 0
+ ]
+ },
+ "width": 100,
+ "height": 100
+ },
+ {
+ "type": "rectangle",
+ "id": "YF2On",
+ "x": 500,
+ "y": 20,
+ "name": "opacity",
+ "fill": {
+ "type": "image",
+ "opacity": 0.5,
+ "enabled": true,
+ "url": "quad.png",
+ "mode": "cover"
+ },
+ "width": 100,
+ "height": 100
+ }
+ ]
+ },
+ {
+ "id": "rMpIj",
+ "type": "frame",
+ "x": 0,
+ "y": 3540,
+ "name": "P Icons",
+ "clip": true,
+ "width": 660,
+ "height": 100,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "icon",
+ "id": "DIBUg",
+ "x": 20,
+ "y": 20,
+ "name": "lucide heart",
+ "width": 48,
+ "height": 48,
+ "icon": "heart",
+ "library": "lucide",
+ "fill": "#222222"
+ },
+ {
+ "type": "icon",
+ "id": "PsW0e",
+ "x": 100,
+ "y": 20,
+ "name": "feather star",
+ "width": 48,
+ "height": 48,
+ "icon": "star",
+ "library": "feather",
+ "fill": "#222222"
+ },
+ {
+ "type": "icon",
+ "id": "d5FQX",
+ "x": 180,
+ "y": 20,
+ "name": "mat outlined home",
+ "width": 48,
+ "height": 48,
+ "icon": "home",
+ "library": "Material Symbols Outlined",
+ "fill": "#222222"
+ },
+ {
+ "type": "icon",
+ "id": "UuJwK",
+ "x": 260,
+ "y": 20,
+ "name": "mat rounded w700",
+ "width": 48,
+ "height": 48,
+ "icon": "settings",
+ "library": "Material Symbols Rounded",
+ "weight": 700,
+ "fill": "#222222"
+ },
+ {
+ "type": "icon",
+ "id": "Ka00B",
+ "x": 340,
+ "y": 20,
+ "name": "phosphor",
+ "width": 48,
+ "height": 48,
+ "icon": "airplane",
+ "library": "phosphor",
+ "fill": "#222222"
+ },
+ {
+ "type": "icon",
+ "id": "i90QP",
+ "x": 420,
+ "y": 20,
+ "name": "lucide wide",
+ "width": 96,
+ "height": 30,
+ "icon": "heart",
+ "library": "lucide",
+ "fill": "#CC0000"
+ }
+ ]
+ },
+ {
+ "id": "sqoEc",
+ "type": "frame",
+ "x": 0,
+ "y": 3680,
+ "name": "P Strokes",
+ "clip": true,
+ "width": 660,
+ "height": 160,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "k5PMO",
+ "x": 20,
+ "y": 30,
+ "name": "per side",
+ "fill": "#EEEEEE",
+ "width": 80,
+ "height": 60,
+ "stroke": "#0044CC",
+ "strokeWidth": {
+ "top": 2,
+ "right": 8,
+ "left": 4
+ }
+ },
+ {
+ "type": "rectangle",
+ "id": "T3xsm",
+ "x": 130,
+ "y": 30,
+ "name": "per side outer",
+ "fill": "#EEEEEE",
+ "width": 80,
+ "height": 60,
+ "stroke": "#0044CC",
+ "strokeWidth": {
+ "top": 2,
+ "right": 8,
+ "left": 4
+ },
+ "strokeAlignment": "outer"
+ },
+ {
+ "type": "rectangle",
+ "cornerRadius": 16,
+ "id": "XDM8n",
+ "x": 240,
+ "y": 30,
+ "name": "radius inner",
+ "fill": "#EEEEEE",
+ "width": 80,
+ "height": 60,
+ "stroke": "#0044CC",
+ "strokeWidth": 6,
+ "strokeAlignment": "inner"
+ },
+ {
+ "type": "rectangle",
+ "id": "VHorf",
+ "x": 350,
+ "y": 30,
+ "name": "grad stroke",
+ "fill": "#EEEEEE",
+ "width": 80,
+ "height": 60,
+ "stroke": {
+ "type": "gradient",
+ "gradientType": "linear",
+ "enabled": true,
+ "rotation": 90,
+ "size": {
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#FF0000",
+ "position": 0
+ },
+ {
+ "color": "#0000FF",
+ "position": 1
+ }
+ ]
+ },
+ "strokeWidth": 6
+ },
+ {
+ "type": "path",
+ "id": "rfWhU",
+ "x": 460,
+ "y": 30,
+ "name": "path caps",
+ "geometry": "M0 60l40-60 40 60",
+ "width": 80,
+ "height": 60,
+ "stroke": "#000000",
+ "strokeWidth": 10,
+ "strokeLinejoin": "round",
+ "strokeLinecap": "round"
+ },
+ {
+ "type": "ellipse",
+ "id": "u62iKA",
+ "x": 560,
+ "y": 30,
+ "name": "ellipse stroke",
+ "width": 80,
+ "height": 60,
+ "stroke": "#00AA00",
+ "strokeWidth": 4
+ }
+ ]
+ },
+ {
+ "id": "c6sX3L",
+ "type": "frame",
+ "x": 0,
+ "y": 3880,
+ "name": "P Other types",
+ "clip": true,
+ "width": 660,
+ "height": 180,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "note",
+ "id": "Obb9z",
+ "x": 20,
+ "y": 20,
+ "name": "note",
+ "width": 150,
+ "height": 100,
+ "content": "A note"
+ },
+ {
+ "type": "context",
+ "id": "QqC95",
+ "x": 190,
+ "y": 20,
+ "name": "context",
+ "width": 150,
+ "height": 100,
+ "content": "Context"
+ },
+ {
+ "type": "prompt",
+ "id": "A1A7t",
+ "x": 360,
+ "y": 20,
+ "name": "prompt",
+ "width": 150,
+ "height": 100,
+ "content": "Prompt"
+ },
+ {
+ "type": "rectangle",
+ "id": "yuKpK",
+ "x": 530,
+ "y": 20,
+ "name": "after",
+ "fill": "#AA00AA",
+ "width": 100,
+ "height": 100
+ }
+ ]
+ },
+ {
+ "id": "cDh6W",
+ "type": "frame",
+ "x": 0,
+ "y": 4100,
+ "name": "M Gradients",
+ "width": 880,
+ "height": 260,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "XFPRr",
+ "x": 20,
+ "y": 20,
+ "name": "lin0",
+ "fill": {
+ "type": "gradient",
+ "gradientType": "linear",
+ "enabled": true,
+ "rotation": 0,
+ "size": {
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#000000",
+ "position": 0
+ },
+ {
+ "color": "#FFFFFF",
+ "position": 1
+ }
+ ]
+ },
+ "width": 200,
+ "height": 100
+ },
+ {
+ "type": "rectangle",
+ "id": "OCZM8",
+ "x": 240,
+ "y": 20,
+ "name": "lin45",
+ "fill": {
+ "type": "gradient",
+ "gradientType": "linear",
+ "enabled": true,
+ "rotation": 45,
+ "size": {
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#000000",
+ "position": 0
+ },
+ {
+ "color": "#FFFFFF",
+ "position": 1
+ }
+ ]
+ },
+ "width": 200,
+ "height": 100
+ },
+ {
+ "type": "rectangle",
+ "id": "oWMd6",
+ "x": 460,
+ "y": 20,
+ "name": "lin30 c s",
+ "fill": {
+ "type": "gradient",
+ "gradientType": "linear",
+ "enabled": true,
+ "rotation": 30,
+ "size": {
+ "height": 0.5
+ },
+ "colors": [
+ {
+ "color": "#000000",
+ "position": 0
+ },
+ {
+ "color": "#FFFFFF",
+ "position": 1
+ }
+ ],
+ "center": {
+ "x": 0.3,
+ "y": 0.6
+ }
+ },
+ "width": 200,
+ "height": 100
+ },
+ {
+ "type": "rectangle",
+ "id": "wpstP",
+ "x": 680,
+ "y": 20,
+ "name": "lin90 w",
+ "fill": {
+ "type": "gradient",
+ "gradientType": "linear",
+ "enabled": true,
+ "rotation": 90,
+ "size": {
+ "height": 0.6
+ },
+ "colors": [
+ {
+ "color": "#000000",
+ "position": 0
+ },
+ {
+ "color": "#FFFFFF",
+ "position": 1
+ }
+ ]
+ },
+ "width": 200,
+ "height": 100
+ },
+ {
+ "type": "rectangle",
+ "id": "sGGZS",
+ "x": 20,
+ "y": 140,
+ "name": "rad",
+ "fill": {
+ "type": "gradient",
+ "gradientType": "radial",
+ "enabled": true,
+ "rotation": 0,
+ "size": {
+ "width": 0.6,
+ "height": 0.8
+ },
+ "colors": [
+ {
+ "color": "#000000",
+ "position": 0
+ },
+ {
+ "color": "#FFFFFF",
+ "position": 1
+ }
+ ],
+ "center": {
+ "x": 0.3,
+ "y": 0.6
+ }
+ },
+ "width": 200,
+ "height": 100
+ },
+ {
+ "type": "rectangle",
+ "id": "Z5mhk",
+ "x": 240,
+ "y": 140,
+ "name": "rad rot",
+ "fill": {
+ "type": "gradient",
+ "gradientType": "radial",
+ "enabled": true,
+ "rotation": 30,
+ "size": {
+ "width": 1,
+ "height": 0.5
+ },
+ "colors": [
+ {
+ "color": "#000000",
+ "position": 0
+ },
+ {
+ "color": "#FFFFFF",
+ "position": 1
+ }
+ ]
+ },
+ "width": 200,
+ "height": 100
+ },
+ {
+ "type": "rectangle",
+ "id": "zuIgv",
+ "x": 460,
+ "y": 140,
+ "name": "ang0",
+ "fill": {
+ "type": "gradient",
+ "gradientType": "angular",
+ "enabled": true,
+ "rotation": 0,
+ "size": {
+ "width": 1,
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#000000",
+ "position": 0
+ },
+ {
+ "color": "#FFFFFF",
+ "position": 1
+ }
+ ]
+ },
+ "width": 200,
+ "height": 100
+ },
+ {
+ "type": "rectangle",
+ "id": "jlao5",
+ "x": 680,
+ "y": 140,
+ "name": "ang90 c",
+ "fill": {
+ "type": "gradient",
+ "gradientType": "angular",
+ "enabled": true,
+ "rotation": 90,
+ "size": {
+ "width": 1,
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#000000",
+ "position": 0
+ },
+ {
+ "color": "#FFFFFF",
+ "position": 1
+ }
+ ],
+ "center": {
+ "x": 0.25
+ }
+ },
+ "width": 200,
+ "height": 100
+ }
+ ]
+ },
+ {
+ "id": "apjeC",
+ "type": "frame",
+ "x": 0,
+ "y": 4400,
+ "name": "M Transforms",
+ "clip": true,
+ "width": 660,
+ "height": 300,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "rectangle",
+ "cornerRadius": [
+ 0,
+ 0,
+ 0,
+ 24
+ ],
+ "id": "P5AMwP",
+ "x": 60,
+ "y": 40,
+ "name": "rot30",
+ "rotation": 29.999999999999996,
+ "fill": [
+ {
+ "type": "gradient",
+ "gradientType": "linear",
+ "enabled": true,
+ "rotation": 90,
+ "size": {
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#FF0000",
+ "position": 0
+ },
+ {
+ "color": "#0000FF",
+ "position": 1
+ }
+ ]
+ },
+ "#00000000"
+ ],
+ "width": 100,
+ "height": 60
+ },
+ {
+ "type": "rectangle",
+ "cornerRadius": [
+ 0,
+ 0,
+ 0,
+ 24
+ ],
+ "id": "GO7bN",
+ "x": 220,
+ "y": 40,
+ "name": "rot30 flipX",
+ "rotation": 29.999999999999996,
+ "flipX": true,
+ "fill": [
+ {
+ "type": "gradient",
+ "gradientType": "linear",
+ "enabled": true,
+ "rotation": 90,
+ "size": {
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#FF0000",
+ "position": 0
+ },
+ {
+ "color": "#0000FF",
+ "position": 1
+ }
+ ]
+ },
+ "#00000000"
+ ],
+ "width": 100,
+ "height": 60
+ },
+ {
+ "type": "rectangle",
+ "cornerRadius": [
+ 0,
+ 0,
+ 0,
+ 24
+ ],
+ "id": "NDkya",
+ "x": 380,
+ "y": 40,
+ "name": "rot30 flipY",
+ "rotation": 29.999999999999996,
+ "flipY": true,
+ "fill": [
+ {
+ "type": "gradient",
+ "gradientType": "linear",
+ "enabled": true,
+ "rotation": 90,
+ "size": {
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#FF0000",
+ "position": 0
+ },
+ {
+ "color": "#0000FF",
+ "position": 1
+ }
+ ]
+ },
+ "#00000000"
+ ],
+ "width": 100,
+ "height": 60
+ },
+ {
+ "type": "rectangle",
+ "cornerRadius": [
+ 0,
+ 0,
+ 0,
+ 24
+ ],
+ "id": "lpH4H",
+ "x": 540,
+ "y": 120,
+ "name": "rot-60 flipXY",
+ "rotation": -59.99999999999999,
+ "flipX": true,
+ "flipY": true,
+ "fill": [
+ {
+ "type": "gradient",
+ "gradientType": "linear",
+ "enabled": true,
+ "rotation": 90,
+ "size": {
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#FF0000",
+ "position": 0
+ },
+ {
+ "color": "#0000FF",
+ "position": 1
+ }
+ ]
+ },
+ "#00000000"
+ ],
+ "width": 100,
+ "height": 60
+ },
+ {
+ "type": "group",
+ "id": "K3EF3V",
+ "x": 80,
+ "y": 180,
+ "name": "grp",
+ "rotation": 20,
+ "flipX": true,
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "X52r6A",
+ "x": 0,
+ "y": 0,
+ "name": "ga",
+ "fill": {
+ "type": "gradient",
+ "gradientType": "linear",
+ "enabled": true,
+ "rotation": 90,
+ "size": {
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#FF0000",
+ "position": 0
+ },
+ {
+ "color": "#0000FF",
+ "position": 1
+ }
+ ]
+ },
+ "width": 80,
+ "height": 40
+ },
+ {
+ "type": "ellipse",
+ "id": "JS9Sw",
+ "x": 90,
+ "y": 20,
+ "name": "gb",
+ "fill": "#00AA00",
+ "width": 30,
+ "height": 30
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "f0SEDx",
+ "x": 300,
+ "y": 200,
+ "name": "frm",
+ "rotation": -14.999999999999998,
+ "width": 120,
+ "height": 60,
+ "fill": "#DDDDDD",
+ "layout": "none",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "QuNsj",
+ "x": 10,
+ "y": 10,
+ "name": "fa",
+ "fill": {
+ "type": "gradient",
+ "gradientType": "linear",
+ "enabled": true,
+ "rotation": 90,
+ "size": {
+ "height": 1
+ },
+ "colors": [
+ {
+ "color": "#FF0000",
+ "position": 0
+ },
+ {
+ "color": "#0000FF",
+ "position": 1
+ }
+ ]
+ },
+ "width": 40,
+ "height": 20
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "id": "HD4Cf",
+ "type": "frame",
+ "x": 0,
+ "y": 4740,
+ "name": "M Themes",
+ "width": 700,
+ "height": 200,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "frame",
+ "id": "Dz2b7",
+ "x": 10,
+ "y": 10,
+ "name": "row 0",
+ "width": 680,
+ "height": 40,
+ "gap": "$pq-num",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "j07TIs",
+ "name": "pq-generic-first",
+ "fill": "$pq-generic-first",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "y81lz6",
+ "name": "pq-generic-last",
+ "fill": "$pq-generic-last",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "f9md47",
+ "name": "pq-two-match",
+ "fill": "$pq-two-match",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "y78IL",
+ "name": "pq-no-match",
+ "fill": "$pq-no-match",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "F0Vo8u",
+ "name": "pq-specific",
+ "fill": "$pq-specific",
+ "width": 40,
+ "height": 40
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "gEqGp",
+ "x": 10,
+ "y": 55,
+ "name": "row 1",
+ "theme": {
+ "mode": "light"
+ },
+ "width": 680,
+ "height": 40,
+ "gap": "$pq-num",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "Bik0C",
+ "name": "pq-generic-first",
+ "fill": "$pq-generic-first",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "JBeYs",
+ "name": "pq-generic-last",
+ "fill": "$pq-generic-last",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "gzBzu",
+ "name": "pq-two-match",
+ "fill": "$pq-two-match",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "kI29C",
+ "name": "pq-no-match",
+ "fill": "$pq-no-match",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "oAHhT",
+ "name": "pq-specific",
+ "fill": "$pq-specific",
+ "width": 40,
+ "height": 40
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "L1EgVR",
+ "x": 10,
+ "y": 100,
+ "name": "row 2",
+ "theme": {
+ "mode": "dark"
+ },
+ "width": 680,
+ "height": 40,
+ "gap": "$pq-num",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "d9zmQ",
+ "name": "pq-generic-first",
+ "fill": "$pq-generic-first",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "GI3K4",
+ "name": "pq-generic-last",
+ "fill": "$pq-generic-last",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "D3wmed",
+ "name": "pq-two-match",
+ "fill": "$pq-two-match",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "xVf3D",
+ "name": "pq-no-match",
+ "fill": "$pq-no-match",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "KslcA",
+ "name": "pq-specific",
+ "fill": "$pq-specific",
+ "width": 40,
+ "height": 40
+ }
+ ]
+ },
+ {
+ "type": "frame",
+ "id": "XSJea",
+ "x": 10,
+ "y": 145,
+ "name": "row 3",
+ "theme": {
+ "mode": "dark",
+ "density": "cozy"
+ },
+ "width": 680,
+ "height": 40,
+ "gap": "$pq-num",
+ "children": [
+ {
+ "type": "rectangle",
+ "id": "XbplW",
+ "name": "pq-generic-first",
+ "fill": "$pq-generic-first",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "x2JKg",
+ "name": "pq-generic-last",
+ "fill": "$pq-generic-last",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "Y3Mduw",
+ "name": "pq-two-match",
+ "fill": "$pq-two-match",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "e3sZ2c",
+ "name": "pq-no-match",
+ "fill": "$pq-no-match",
+ "width": 40,
+ "height": 40
+ },
+ {
+ "type": "rectangle",
+ "id": "Lo6ZK",
+ "name": "pq-specific",
+ "fill": "$pq-specific",
+ "width": 40,
+ "height": 40
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "id": "MOmt0",
+ "type": "frame",
+ "x": 0,
+ "y": 4980,
+ "name": "P Icon weights",
+ "width": 420,
+ "height": 320,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "icon",
+ "id": "eLiWC",
+ "x": 10,
+ "y": 10,
+ "name": "Material Symbols Outlined default",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Outlined",
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "i1Wdz",
+ "x": 60,
+ "y": 10,
+ "name": "Material Symbols Outlined 100",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Outlined",
+ "weight": 100,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "o7Gyo",
+ "x": 110,
+ "y": 10,
+ "name": "Material Symbols Outlined 200",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Outlined",
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "n18R5",
+ "x": 160,
+ "y": 10,
+ "name": "Material Symbols Outlined 300",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Outlined",
+ "weight": 300,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "IhlMf",
+ "x": 210,
+ "y": 10,
+ "name": "Material Symbols Outlined 400",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Outlined",
+ "weight": 400,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "M4eq2N",
+ "x": 260,
+ "y": 10,
+ "name": "Material Symbols Outlined 500",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Outlined",
+ "weight": 500,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "s2POCd",
+ "x": 310,
+ "y": 10,
+ "name": "Material Symbols Outlined 600",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Outlined",
+ "weight": 600,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "jjE2B",
+ "x": 360,
+ "y": 10,
+ "name": "Material Symbols Outlined 700",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Outlined",
+ "weight": 700,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "kCEYc",
+ "x": 10,
+ "y": 60,
+ "name": "Material Symbols Rounded default",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Rounded",
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "S3MFim",
+ "x": 60,
+ "y": 60,
+ "name": "Material Symbols Rounded 100",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Rounded",
+ "weight": 100,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "ZH7xq",
+ "x": 110,
+ "y": 60,
+ "name": "Material Symbols Rounded 200",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Rounded",
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "ApuSb",
+ "x": 160,
+ "y": 60,
+ "name": "Material Symbols Rounded 300",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Rounded",
+ "weight": 300,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "y0emRx",
+ "x": 210,
+ "y": 60,
+ "name": "Material Symbols Rounded 400",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Rounded",
+ "weight": 400,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "ke5wF",
+ "x": 260,
+ "y": 60,
+ "name": "Material Symbols Rounded 500",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Rounded",
+ "weight": 500,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "TdbyI",
+ "x": 310,
+ "y": 60,
+ "name": "Material Symbols Rounded 600",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Rounded",
+ "weight": 600,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "wH4Fi",
+ "x": 360,
+ "y": 60,
+ "name": "Material Symbols Rounded 700",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Rounded",
+ "weight": 700,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "yKzJX",
+ "x": 10,
+ "y": 110,
+ "name": "Material Symbols Sharp default",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Sharp",
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "Z5x1be",
+ "x": 60,
+ "y": 110,
+ "name": "Material Symbols Sharp 100",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Sharp",
+ "weight": 100,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "GJOxI",
+ "x": 110,
+ "y": 110,
+ "name": "Material Symbols Sharp 200",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Sharp",
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "uRDvt",
+ "x": 160,
+ "y": 110,
+ "name": "Material Symbols Sharp 300",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Sharp",
+ "weight": 300,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "W5d8qB",
+ "x": 210,
+ "y": 110,
+ "name": "Material Symbols Sharp 400",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Sharp",
+ "weight": 400,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "aGat3",
+ "x": 260,
+ "y": 110,
+ "name": "Material Symbols Sharp 500",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Sharp",
+ "weight": 500,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "KJgnK",
+ "x": 310,
+ "y": 110,
+ "name": "Material Symbols Sharp 600",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Sharp",
+ "weight": 600,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "KsBHG",
+ "x": 360,
+ "y": 110,
+ "name": "Material Symbols Sharp 700",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "Material Symbols Sharp",
+ "weight": 700,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "AP7Ym",
+ "x": 10,
+ "y": 160,
+ "name": "phosphor default",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "phosphor",
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "PHaIm",
+ "x": 60,
+ "y": 160,
+ "name": "phosphor 100",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "phosphor",
+ "weight": 100,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "x6bcVL",
+ "x": 110,
+ "y": 160,
+ "name": "phosphor 200",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "phosphor",
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "Lv91H",
+ "x": 160,
+ "y": 160,
+ "name": "phosphor 300",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "phosphor",
+ "weight": 300,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "Z9xf5s",
+ "x": 210,
+ "y": 160,
+ "name": "phosphor 400",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "phosphor",
+ "weight": 400,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "nacuB",
+ "x": 260,
+ "y": 160,
+ "name": "phosphor 500",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "phosphor",
+ "weight": 500,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "vCv3R",
+ "x": 310,
+ "y": 160,
+ "name": "phosphor 600",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "phosphor",
+ "weight": 600,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "lWzUt",
+ "x": 360,
+ "y": 160,
+ "name": "phosphor 700",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "phosphor",
+ "weight": 700,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "ZcgqG",
+ "x": 10,
+ "y": 210,
+ "name": "lucide default",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "lucide",
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "c7zts",
+ "x": 60,
+ "y": 210,
+ "name": "lucide 100",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "lucide",
+ "weight": 100,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "wUYZ3",
+ "x": 110,
+ "y": 210,
+ "name": "lucide 200",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "lucide",
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "t7Kx5",
+ "x": 160,
+ "y": 210,
+ "name": "lucide 300",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "lucide",
+ "weight": 300,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "H0f60",
+ "x": 210,
+ "y": 210,
+ "name": "lucide 400",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "lucide",
+ "weight": 400,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "I73JQD",
+ "x": 260,
+ "y": 210,
+ "name": "lucide 500",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "lucide",
+ "weight": 500,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "l9cY1h",
+ "x": 310,
+ "y": 210,
+ "name": "lucide 600",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "lucide",
+ "weight": 600,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "wcu9Y",
+ "x": 360,
+ "y": 210,
+ "name": "lucide 700",
+ "width": 40,
+ "height": 40,
+ "icon": "house",
+ "library": "lucide",
+ "weight": 700,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "m98ocB",
+ "x": 10,
+ "y": 260,
+ "name": "feather default",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "feather",
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "xHq5f",
+ "x": 60,
+ "y": 260,
+ "name": "feather 100",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "feather",
+ "weight": 100,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "o87j1",
+ "x": 110,
+ "y": 260,
+ "name": "feather 200",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "feather",
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "gJtYL",
+ "x": 160,
+ "y": 260,
+ "name": "feather 300",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "feather",
+ "weight": 300,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "kuyZK",
+ "x": 210,
+ "y": 260,
+ "name": "feather 400",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "feather",
+ "weight": 400,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "AbECo",
+ "x": 260,
+ "y": 260,
+ "name": "feather 500",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "feather",
+ "weight": 500,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "aaNuR",
+ "x": 310,
+ "y": 260,
+ "name": "feather 600",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "feather",
+ "weight": 600,
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "I0jPTl",
+ "x": 360,
+ "y": 260,
+ "name": "feather 700",
+ "width": 40,
+ "height": 40,
+ "icon": "home",
+ "library": "feather",
+ "weight": 700,
+ "fill": "#111111"
+ }
+ ]
+ },
+ {
+ "id": "alRyT",
+ "type": "frame",
+ "x": 0,
+ "y": 5340,
+ "name": "P Icon variables",
+ "width": 240,
+ "height": 70,
+ "fill": "#FFFFFF",
+ "layout": "none",
+ "children": [
+ {
+ "type": "icon",
+ "id": "X8LilL",
+ "x": 10,
+ "y": 10,
+ "name": "default theme",
+ "width": 48,
+ "height": 48,
+ "icon": "$pq-icon",
+ "library": "$pq-icon-set",
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "LOiwH",
+ "x": 70,
+ "y": 10,
+ "name": "dark theme",
+ "theme": {
+ "mode": "dark"
+ },
+ "width": 48,
+ "height": 48,
+ "icon": "$pq-icon",
+ "library": "$pq-icon-set",
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "rMruQ",
+ "x": 130,
+ "y": 10,
+ "name": "fixed lib var icon",
+ "width": 48,
+ "height": 48,
+ "icon": "$pq-icon",
+ "library": "feather",
+ "fill": "#111111"
+ },
+ {
+ "type": "icon",
+ "id": "R7vj4S",
+ "x": 180,
+ "y": 20,
+ "name": "wide material",
+ "width": 50,
+ "height": 30,
+ "icon": "home",
+ "library": "Material Symbols Outlined",
+ "weight": 450,
+ "fill": "#AA0000"
+ }
+ ]
+ }
+ ],
+ "version": "2.21",
+ "themes": {
+ "mode": [
+ "light",
+ "dark"
+ ],
+ "density": [
+ "compact",
+ "cozy"
+ ]
+ },
+ "variables": {
+ "pv-bg": {
+ "type": "color",
+ "value": [
+ {
+ "value": "#FFE0E0",
+ "theme": {
+ "mode": "light"
+ }
+ },
+ {
+ "value": "#202040",
+ "theme": {
+ "mode": "dark"
+ }
+ }
+ ]
+ },
+ "pv-accent": {
+ "type": "color",
+ "value": [
+ {
+ "value": "#CC0000",
+ "theme": {
+ "mode": "light",
+ "density": "compact"
+ }
+ },
+ {
+ "value": "#00CC00",
+ "theme": {
+ "mode": "dark"
+ }
+ },
+ {
+ "value": "#0000CC",
+ "theme": {
+ "mode": "light",
+ "density": "cozy"
+ }
+ }
+ ]
+ },
+ "pv-alias": {
+ "type": "color",
+ "value": "$pv-accent"
+ },
+ "pv-gap": {
+ "type": "number",
+ "value": [
+ {
+ "value": 4,
+ "theme": {
+ "density": "compact"
+ }
+ },
+ {
+ "value": 16,
+ "theme": {
+ "density": "cozy"
+ }
+ }
+ ]
+ },
+ "pv-radius": {
+ "type": "number",
+ "value": 12
+ },
+ "pv-show": {
+ "type": "boolean",
+ "value": [
+ {
+ "value": true,
+ "theme": {
+ "mode": "light"
+ }
+ },
+ {
+ "value": false,
+ "theme": {
+ "mode": "dark"
+ }
+ }
+ ]
+ },
+ "pv-label": {
+ "type": "string",
+ "value": [
+ {
+ "value": "Light label",
+ "theme": {
+ "mode": "light"
+ }
+ },
+ {
+ "value": "Dark label",
+ "theme": {
+ "mode": "dark"
+ }
+ }
+ ]
+ },
+ "pv-w": {
+ "type": "number",
+ "value": 3
+ },
+ "pq-generic-first": {
+ "type": "color",
+ "value": [
+ {
+ "value": "#00AA00",
+ "theme": {
+ "mode": "dark"
+ }
+ }
+ ]
+ },
+ "pq-generic-last": {
+ "type": "color",
+ "value": "#FF0000"
+ },
+ "pq-two-match": {
+ "type": "color",
+ "value": [
+ {
+ "value": "#FF00FF",
+ "theme": {
+ "density": "cozy"
+ }
+ }
+ ]
+ },
+ "pq-no-match": {
+ "type": "color",
+ "value": [
+ {
+ "value": "#00AAAA",
+ "theme": {
+ "mode": "dark"
+ }
+ }
+ ]
+ },
+ "pq-specific": {
+ "type": "color",
+ "value": [
+ {
+ "value": "#888888",
+ "theme": {
+ "mode": "dark"
+ }
+ }
+ ]
+ },
+ "pq-num": {
+ "type": "number",
+ "value": [
+ {
+ "value": 10,
+ "theme": {
+ "mode": "dark"
+ }
+ }
+ ]
+ },
+ "pq-icon-set": {
+ "type": "string",
+ "value": [
+ {
+ "value": "lucide",
+ "theme": {
+ "mode": "light"
+ }
+ },
+ {
+ "value": "Material Symbols Rounded",
+ "theme": {
+ "mode": "dark"
+ }
+ }
+ ]
+ },
+ "pq-icon": {
+ "type": "string",
+ "value": [
+ {
+ "value": "sun",
+ "theme": {
+ "mode": "light"
+ }
+ },
+ {
+ "value": "$pq-icon-night",
+ "theme": {
+ "mode": "dark"
+ }
+ }
+ ]
+ },
+ "pq-icon-night": {
+ "type": "string",
+ "value": "dark_mode"
+ },
+ "pq-icon-heart": {
+ "type": "string",
+ "value": "heart"
+ }
+ }
+}
diff --git a/tests/fixtures/pen-oracles/ptfGa.png b/tests/fixtures/pen-oracles/ptfGa.png
new file mode 100644
index 000000000..2a36fd19b
Binary files /dev/null and b/tests/fixtures/pen-oracles/ptfGa.png differ
diff --git a/tests/fixtures/pen-oracles/quad.png b/tests/fixtures/pen-oracles/quad.png
new file mode 100644
index 000000000..2699bf474
Binary files /dev/null and b/tests/fixtures/pen-oracles/quad.png differ
diff --git a/tests/fixtures/pen-oracles/rMpIj.png b/tests/fixtures/pen-oracles/rMpIj.png
new file mode 100644
index 000000000..2d2fb3d59
Binary files /dev/null and b/tests/fixtures/pen-oracles/rMpIj.png differ
diff --git a/tests/fixtures/pen-oracles/sqoEc.png b/tests/fixtures/pen-oracles/sqoEc.png
new file mode 100644
index 000000000..a174f6c57
Binary files /dev/null and b/tests/fixtures/pen-oracles/sqoEc.png differ
diff --git a/tests/fixtures/pen-oracles/w0MCR.png b/tests/fixtures/pen-oracles/w0MCR.png
new file mode 100644
index 000000000..8c6ddc9b8
Binary files /dev/null and b/tests/fixtures/pen-oracles/w0MCR.png differ
diff --git a/tools/generate/visual-oracles/src/commands/compare.ts b/tools/generate/visual-oracles/src/commands/compare.ts
index 1a3f2e10c..9b4142882 100644
--- a/tools/generate/visual-oracles/src/commands/compare.ts
+++ b/tools/generate/visual-oracles/src/commands/compare.ts
@@ -20,6 +20,11 @@ export default defineCommand({
'Capture every page a reader produces, and diff it against an earlier capture',
'tools/generate/visual-oracles/src/operations/compare/digest.ts'
),
+ pen: operationCommand(
+ 'pen',
+ 'Export every frame of the document open in pen.dev and record the .pen fixtures',
+ 'tools/generate/visual-oracles/src/operations/compare/pen.ts'
+ ),
'interpreted-document': operationCommand(
'interpreted-document',
'Compare an interpreted archive with the same document opened in Figma',
diff --git a/tools/generate/visual-oracles/src/operations/compare/pen.ts b/tools/generate/visual-oracles/src/operations/compare/pen.ts
new file mode 100644
index 000000000..41462e317
--- /dev/null
+++ b/tools/generate/visual-oracles/src/operations/compare/pen.ts
@@ -0,0 +1,293 @@
+#!/usr/bin/env bun
+/**
+ * pen.dev oracle: exports the frames listed in the fixtures' manifest.json from the document open
+ * in pen.dev, renders the same frames with OpenPencil, and records what the comparison in CI needs
+ * to run offline.
+ *
+ * Open the probe document in pen.dev, then run:
+ * bun tools/generate/visual-oracles/src/cli.ts compare pen ~/.pencil/documents/<id>/untitled.pen
+ *
+ * Replaces the fixture folder (tests/fixtures/pen-oracles by default) with:
+ * probes.pen and its images — the document
+ * <frame id>.png — pen.dev's export of each frame, at scale 1
+ * iconify/<prefix>.json — the icons the document draws, as Iconify sets
+ * fonts/<family>--<style>.font — the font faces its text is drawn with, icon fonts subset to
+ * the icons it draws
+ * keeping manifest.json, and writes pen.png, openpencil.png, diff.png, and metrics.json per frame
+ * to --output.
+ */
+
+import { copyFileSync, mkdirSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
+import { dirname, join, resolve } from 'node:path'
+import { parseArgs } from 'node:util'
+
+import { Client } from '@modelcontextprotocol/client'
+import { StdioClientTransport } from '@modelcontextprotocol/client/stdio'
+import { groupBy, omit, pick, uniq } from 'es-toolkit'
+import * as v from 'valibot'
+
+import { createIconifyProvider, parseIconName } from '@open-pencil/core/icons'
+import { IORegistry, penFormat } from '@open-pencil/core/io'
+import {
+ comparePNGs,
+ createCanvasKitRasterCodec,
+ headlessRenderNodes,
+ initCanvasKit
+} from '@open-pencil/core/io/formats/raster'
+import { computeAllLayouts } from '@open-pencil/core/layout'
+import { fontManager, prepareGraphFonts } from '@open-pencil/core/text'
+import {
+ iconFontFamily,
+ isDocumentAssetPath,
+ parsePenDocument,
+ penAssets,
+ type PenNode,
+ type PenOverride
+} from '@open-pencil/pen'
+import { styleToWeight } from '@open-pencil/scene-graph/font-style'
+
+const PEN_MCP_SERVER =
+ '/Applications/Pen.app/Contents/Resources/app.asar.unpacked/out/mcp-server-darwin-arm64'
+const ICONIFY_API = 'https://api.iconify.design'
+const GOOGLE_FONTS_CSS = 'https://fonts.googleapis.com/css2'
+
+const iconSetSchema = v.pipe(
+ v.string(),
+ v.parseJson(),
+ v.looseObject({
+ prefix: v.string(),
+ width: v.optional(v.number()),
+ height: v.optional(v.number()),
+ icons: v.record(v.string(), v.looseObject({ body: v.string() }))
+ })
+)
+type IconSet = v.InferOutput<typeof iconSetSchema>
+
+const savedDocumentSchema = v.pipe(
+ v.string(),
+ v.parseJson(),
+ v.looseObject({ children: v.array(v.looseObject({ id: v.string() })) })
+)
+const manifestSchema = v.pipe(
+ v.string(),
+ v.parseJson(),
+ v.looseObject({ targets: v.array(v.looseObject({ penNodeId: v.string() })) })
+)
+
+const { values, positionals } = parseArgs({
+ allowPositionals: true,
+ options: {
+ fixtures: { type: 'string', default: 'tests/fixtures/pen-oracles' },
+ output: { type: 'string', short: 'o', default: '/tmp/open-pencil-pen-oracle' },
+ server: { type: 'string', default: PEN_MCP_SERVER }
+ }
+})
+const source = positionals[0]
+if (!source) {
+ console.error(
+ 'Usage: bun tools/generate/visual-oracles/src/cli.ts compare pen <document open in pen.dev> [--fixtures DIR] [--output DIR]'
+ )
+ process.exit(1)
+}
+
+const fixtures = resolve(values.fixtures)
+const output = resolve(values.output)
+const { targets } = v.parse(manifestSchema, await Bun.file(join(fixtures, 'manifest.json')).text())
+const wanted = new Set(targets.map((target) => target.penNodeId))
+// The fixture keeps the manifest's frames and the components they use, and drops the `fileToken`
+// pen.dev stamps each saved file with.
+const saved = v.parse(savedDocumentSchema, await Bun.file(source).text())
+const kept = withComponents(parsePenDocument(JSON.stringify(saved)).children, wanted)
+const text = `${JSON.stringify(
+ { ...omit(saved, ['fileToken']), children: saved.children.filter((node) => kept.has(node.id)) },
+ null,
+ 2
+)}\n`
+const doc = parsePenDocument(text)
+const frames = doc.children.filter((node) => wanted.has(node.id))
+const missing = [...wanted].filter((id) => !frames.some((frame) => frame.id === id))
+if (missing.length > 0) throw new Error(`The document has no top-level ${missing.join(', ')}`)
+const assets = penAssets(doc)
+
+clearFixtures()
+writeFileSync(join(fixtures, 'probes.pen'), text)
+for (const image of assets.images.filter(isDocumentAssetPath)) {
+ mkdirSync(dirname(join(fixtures, image)), { recursive: true })
+ copyFileSync(join(dirname(source), image), join(fixtures, image))
+}
+await exportFromPen(
+ source,
+ frames.map((frame) => frame.id),
+ fixtures
+)
+
+const iconSets = await fetchIconSets(assets.icons)
+for (const set of iconSets.values()) {
+ writeFileSync(
+ join(fixtures, 'iconify', `${set.prefix}.json`),
+ `${JSON.stringify(set, null, 2)}\n`
+ )
+}
+const fonts = new Map<string, { family: string; style: string; data: ArrayBuffer }>()
+fontManager.setDownloadedFontCache({
+ read: () => Promise.resolve(null),
+ write(family, style, data) {
+ fonts.set(`${family}--${style}`, { family, style, data })
+ return Promise.resolve()
+ }
+})
+
+const icons = createIconifyProvider({
+ fetchCollection: (prefix, names) => {
+ const set = iconSets.get(prefix)
+ if (!set) return Promise.reject(new Error(`No "${prefix}" icons were recorded`))
+ return Promise.resolve({ ...set, icons: pick(set.icons, names) })
+ },
+ search: () => Promise.resolve({ icons: [], total: 0, collections: {} }),
+ collections: () => Promise.resolve([]),
+ collectionIcons: () => Promise.resolve([])
+})
+const { graph } = await new IORegistry([penFormat]).readDocument(
+ {
+ name: 'probes.pen',
+ data: new TextEncoder().encode(text),
+ readAsset: (path) => Bun.file(join(fixtures, path)).bytes()
+ },
+ { icons }
+)
+graph.applyDerivedLayoutDuring(() => computeAllLayouts(graph))
+const pageId = graph.getPages()[0].id
+await prepareGraphFonts(
+ graph,
+ frames.map((frame) => frame.id)
+)
+
+const codec = createCanvasKitRasterCodec(await initCanvasKit())
+for (const frame of frames) {
+ const name = frame.name ?? frame.id
+ const dir = join(output, frame.id)
+ mkdirSync(dir, { recursive: true })
+ const pen = await Bun.file(join(fixtures, `${frame.id}.png`)).bytes()
+ writeFileSync(join(dir, 'pen.png'), pen)
+ const ours = await headlessRenderNodes(graph, pageId, [frame.id])
+ if (!ours) {
+ console.log(`${name} (${frame.id}): OpenPencil rendered nothing`)
+ continue
+ }
+ writeFileSync(join(dir, 'openpencil.png'), ours)
+ const comparison = comparePNGs(codec, pen, ours)
+ const differentPercent = comparison
+ ? (100 * comparison.changedPixels) / comparison.totalPixels
+ : 100
+ if (comparison?.mask) writeFileSync(join(dir, 'diff.png'), comparison.mask)
+ writeFileSync(
+ join(dir, 'metrics.json'),
+ `${JSON.stringify({ id: frame.id, name, differentPercent }, null, 2)}\n`
+ )
+ console.log(`${name} (${frame.id}): ${differentPercent.toFixed(2)}% pixels differ`)
+}
+
+// Icon fonts are recorded as just the icons the document draws; whole, each weight is a megabyte.
+const iconsByFamily = groupBy(
+ [...graph.getAllNodes()].filter(
+ (node) => node.type === 'TEXT' && iconFontFamily(node.fontFamily) !== null
+ ),
+ (node) => node.fontFamily
+)
+for (const [face, { family, style, data }] of fonts) {
+ const bytes = Object.hasOwn(iconsByFamily, family)
+ ? await iconFontSubset(
+ family,
+ style,
+ iconsByFamily[family].map((node) => node.text)
+ )
+ : new Uint8Array(data)
+ writeFileSync(join(fixtures, 'fonts', `${face}.font`), bytes)
+}
+console.log(`Recorded ${iconSets.size} icon sets and ${fonts.size} font faces in ${fixtures}`)
+
+/** Empties the fixture folder except its manifest, which holds the comparison's thresholds. */
+function clearFixtures() {
+ mkdirSync(fixtures, { recursive: true })
+ for (const entry of readdirSync(fixtures)) {
+ if (entry !== 'manifest.json') rmSync(join(fixtures, entry), { recursive: true, force: true })
+ }
+ mkdirSync(join(fixtures, 'iconify'))
+ mkdirSync(join(fixtures, 'fonts'))
+ mkdirSync(output, { recursive: true })
+}
+
+/** The IDs of `ids` and of every top-level node holding a component they use, at any depth. */
+function withComponents(nodes: readonly PenNode[], ids: ReadonlySet<string>): Set<string> {
+ const owners = new Map<string, string>()
+ const refs = new Map<string, string[]>()
+ const visit = (node: PenOverride, top: string) => {
+ if (node.id) owners.set(node.id, top)
+ if (node.ref) refs.get(top)?.push(node.ref)
+ for (const child of node.children ?? []) visit(child, top)
+ for (const override of Object.values(node.descendants ?? {})) visit(override, top)
+ }
+ for (const node of nodes) {
+ refs.set(node.id, [])
+ visit(node, node.id)
+ }
+ const kept = new Set(ids)
+ for (const id of kept) {
+ for (const ref of refs.get(id) ?? []) {
+ const owner = owners.get(ref)
+ if (owner) kept.add(owner)
+ }
+ }
+ return kept
+}
+
+/** Exports frames from the document open in pen.dev, through pen.dev's MCP server. */
+async function exportFromPen(document: string, frameIds: string[], directory: string) {
+ const client = new Client({ name: 'open-pencil-pen-oracle', version: '0.0.0' })
+ await client.connect(
+ new StdioClientTransport({ command: values.server, args: ['--app', 'desktop'] })
+ )
+ try {
+ const result = await client.callTool({
+ name: 'execute',
+ arguments: {
+ filePath: document,
+ input: `Export(${JSON.stringify(frameIds)}, "png", ${JSON.stringify(directory)}, { scale: 1 })`
+ }
+ })
+ if (result.isError) throw new Error(`pen.dev export failed: ${JSON.stringify(result.content)}`)
+ } finally {
+ await client.close()
+ }
+}
+
+/**
+ * Google's own subset of an icon font face holding only `names`, in the TrueType it serves to
+ * clients that do not ask for WOFF2.
+ */
+async function iconFontSubset(family: string, style: string, names: string[]): Promise<Uint8Array> {
+ const query = new URLSearchParams({
+ family: `${family}:wght@${styleToWeight(style)}`,
+ icon_names: uniq(names).sort().join(',')
+ })
+ const css = await (await fetch(`${GOOGLE_FONTS_CSS}?${query}`)).text()
+ const url = /src: url\((https:[^)]+)\) format\('truetype'\)/.exec(css)?.[1]
+ if (!url) throw new Error(`Google Fonts has no subset of ${family} ${style}`)
+ return (await fetch(url)).bytes()
+}
+
+/** The Iconify sets holding `names`, each with just the icons named from it. */
+async function fetchIconSets(names: readonly string[]): Promise<Map<string, IconSet>> {
+ const byPrefix = groupBy(
+ names.flatMap((name) => parseIconName(name) ?? []),
+ (icon) => icon.prefix
+ )
+ const sets = new Map<string, IconSet>()
+ for (const [prefix, icons] of Object.entries(byPrefix)) {
+ const query = icons.map((icon) => icon.iconName).join(',')
+ const response = await fetch(`${ICONIFY_API}/${prefix}.json?icons=${query}`)
+ if (!response.ok) throw new Error(`Iconify answered ${response.status} for "${prefix}"`)
+ sets.set(prefix, v.parse(iconSetSchema, await response.text()))
+ }
+ return sets
+}