SPB Git

Repository Public

web-drawing.ink.generator.ts.txt 1.3 KB 13 lines text

1import { serializeInk, simplifyStroke, emptyInk, type InkPoint, type InkStroke } from "./src/lib/editor/ink";2// Same steps as DrawingView.tsx: points [x,y,pressure] clamped to the canvas, simplifyStroke(points, 0.3), colour = palette + "ff" / "59".3const d = emptyInk(1200, 800);4const pts = (f: (t: number) => [number, number, number], n: number): InkPoint[] => simplifyStroke(Array.from({ length: n }, (_, i) => f(i / (n - 1)) as InkPoint), 0.3);5const strokes: InkStroke[] = [6  { tool: "pen", color: "#111827ff", width: 5, points: pts((t) => [120 + 420 * t, 200 + 90 * Math.sin(t * Math.PI * 2), 0.5], 140) },                       // mouse: pressure 0.57  { tool: "pen", color: "#2563ebff", width: 3, points: pts((t) => [200 + 160 * Math.cos(t * Math.PI * 2), 480 + 110 * Math.sin(t * Math.PI * 2), 0.15 + 0.8 * Math.sin(t * Math.PI)], 160) }, // stylus pressure8  { tool: "marker", color: "#dc2626ff", width: 11, points: pts((t) => [640 + 380 * t, 120 + 240 * t * t, 0.5], 90) },9  { tool: "highlighter", color: "#eab30859", width: 26, points: pts((t) => [600 + 460 * t, 560 + 6 * Math.sin(t * 9), 0.5], 80) },10  { tool: "pen", color: "#16a34aff", width: 9, points: [[900, 700, 0.5]] },                                                                            // a dot11];12process.stdout.write(serializeInk({ ...d, strokes }));13
Files main
Menu

Theme