@weasel-js/core 0.7.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +541 -0
  2. package/dist/{DrawCommand-CJtqqt8H.d.ts → DrawCommand-DCmiNkBj.d.ts} +38 -170
  3. package/dist/{chunk-CQNKCG34.js → chunk-6SHZHXXR.js} +47 -10
  4. package/dist/chunk-6SHZHXXR.js.map +1 -0
  5. package/dist/{chunk-5F3PIERN.js → chunk-D2C6K6FO.js} +1420 -652
  6. package/dist/chunk-D2C6K6FO.js.map +1 -0
  7. package/dist/chunk-DCIU3SRK.js +505 -0
  8. package/dist/chunk-DCIU3SRK.js.map +1 -0
  9. package/dist/chunk-IO5Z75X4.js +167 -0
  10. package/dist/chunk-IO5Z75X4.js.map +1 -0
  11. package/dist/{chunk-VOVKONXA.js → chunk-UB6A6L77.js} +3 -3
  12. package/dist/{chunk-VOVKONXA.js.map → chunk-UB6A6L77.js.map} +1 -1
  13. package/dist/{chunk-BGGZ4CVF.js → chunk-Z3KNFTTS.js} +6 -6
  14. package/dist/chunk-Z3KNFTTS.js.map +1 -0
  15. package/dist/clipboard.d.ts +2 -2
  16. package/dist/clone.d.ts +1 -1
  17. package/dist/{geometry-D9BDMiQi.d.ts → geometry-DVeZ2i-c.d.ts} +1 -1
  18. package/dist/{grid-CaSK9bHV.d.ts → grid-XcFQVS0f.d.ts} +1 -1
  19. package/dist/{index-DOYRTfP0.d.ts → index-ChM3ZJ2v.d.ts} +278 -93
  20. package/dist/index.d.ts +442 -57
  21. package/dist/index.js +6 -6
  22. package/dist/insert.d.ts +2 -2
  23. package/dist/insert.js +5 -5
  24. package/dist/insert.js.map +1 -1
  25. package/dist/move.d.ts +3 -3
  26. package/dist/move.js +2 -2
  27. package/dist/{options-DMWeTELe.d.ts → options-wAvCnOZd.d.ts} +1 -1
  28. package/dist/paint-types-CnLIzqq1.d.ts +261 -0
  29. package/dist/patterns-builtin.d.ts +57 -2
  30. package/dist/patterns-builtin.js +1 -97
  31. package/dist/patterns-builtin.js.map +1 -1
  32. package/dist/{pointSnapToGrid-C3EruUwt.d.ts → pointSnapToGrid-BuDZWBrL.d.ts} +2 -2
  33. package/dist/renderer.d.ts +25 -8
  34. package/dist/renderer.js +6 -6
  35. package/dist/resize.d.ts +3 -3
  36. package/dist/resize.js +2 -2
  37. package/dist/routing.d.ts +7 -7
  38. package/dist/routing.js +1 -1
  39. package/dist/{types-Dcaa0tPq.d.ts → types-BhJJ2OCM.d.ts} +9 -1
  40. package/dist/{types-Cpb4hii1.d.ts → types-DUpI7Apc.d.ts} +3 -95
  41. package/dist/{viewToMat3-D4lrBigW.d.ts → viewToMat3-BvaWCN99.d.ts} +1 -1
  42. package/package.json +6 -6
  43. package/dist/chunk-5F3PIERN.js.map +0 -1
  44. package/dist/chunk-BGGZ4CVF.js.map +0 -1
  45. package/dist/chunk-CQNKCG34.js.map +0 -1
  46. package/dist/chunk-SYM6RAM4.js +0 -232
  47. package/dist/chunk-SYM6RAM4.js.map +0 -1
  48. package/dist/chunk-Y52N27PF.js +0 -39
  49. package/dist/chunk-Y52N27PF.js.map +0 -1
  50. package/dist/registerTexture-BzHTLhD9.d.ts +0 -25
  51. /package/dist/{types-B6MMiodD.d.ts → path-B6MMiodD.d.ts} +0 -0
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- export { ALWAYS, ActionDisabledReason, ActionsProvider, ActionsProviderIfRoot, ActiveToolContextProvider, ActiveToolContextProviderIfRoot, BUNDLE_TOOLS, CURVE_REPS, ColorOverrideRegistry, CropIcon, CursorCoordsHud, DEFAULT_ALPHA_DECAY, DEFAULT_ALPHA_MIN, DEFAULT_DEBUG_THEME, DEFAULT_FILL_COLOR, DEFAULT_HANDLE_SIZE, DEFAULT_PALETTE, DEFAULT_ROTATION_HANDLE_DISTANCE, DEFAULT_STROKE_COLOR, DEFAULT_TEXT_STYLE, DEFAULT_VELOCITY_DECAY, DepRegistryProvider, DepRegistryProviderIfRoot, DivideIcon, EASINGS, EllipseIcon, ExcludeIcon, EyedropperIcon, FALLBACK_FIT_VIEW, GHOST_STROKE, HandIcon, IDENTITY_POSE_COMPOSITION, IntersectIcon, KIT_SHAPE_KINDS, LassoIcon, LineIcon, MIXED, MOVE_ANCHORS, MinimapCanvas, NEVER, PATH_ANCHOR_CHROME_ID, PenIcon, PencilIcon, PickHud, PointerProviderIfRoot, PolygonIcon, RECT_ALIGN_PROJECTION, RectIcon, SPRING_PRESETS, SceneCanvas, SceneViewCanvas, SelectIcon, SelectionContextProvider, SelectionContextProviderIfRoot, StarIcon, SubtractIcon, TextIcon, UnionIcon, UnknownIcon, VERSION, WeaselProvider, aabbCenter, actionIs, alignDeltaFor, alignInsertBehavior, alignMoveBehavior, alignResizeBehavior, alignedStrokeRect, always, and, animateLifecycle, animateOnSetPose, annulusSemiAxes, applyBooleanOp, applyHitExistingGate, applyStyleToRange, areaSelectAction, arrayAdapter, asNodeId, bezierCubic, bezierQuadratic, buildChromeCtx, buildRuleCtx, buildSceneViewCommands, canBringForward, canQueryLocalFonts2 as canQueryLocalFonts, canSendBackward, capabilityAll, capabilityIn, capabilityIs, capabilityNot, caretIndexAt, cellAt, charOffsetToDomPosition, clampView, clearSelectionAction, clientToCanvas, cloneAction, composeAffordanceLayer, composePath, composeRectPose, composeSelectionPose, composeWorldPose, computeFitView, computeIndicatorCommand, computeWheelAction, cond, constrainTo45, containedThenNearest, countPathAnchors, createCellHighlightLayer, createChildrenLayer, createCornerResizeAffordance, createDebugOverlayLayer, createDebugSink, createDispatcher, createGridLayer, createGuidesLayer, createHistory, createMarkdownRenderer, createMoveToIndexOp, createNodeProperties, createNodeRouting, createParallaxLayer, createPathAnchorAffordances, createPathEditingOverlayLayer, createPathLayer, createPenPreviewLayer, createReorderOp, createRotationAffordance, createScene, createSelectionHandlesLayer, createSelectionOutlineLayer, createSelectionOverlayLayer, createSetDataOp, createSetLayerOp, createSetPathOp, createSetTextOp, createTextLayer, createViewportLayer, cycleVertexColors, decomposePath, decomposeRectPose, defaultCommitAdapter, defaultDrawOne, defaultLabelTextRenderer, defaultNodeProperties, defaultNodeRouting, defaultVisibilityRules, deriveAlignmentGuides, deriveParallaxView, describeRule, domPositionToCharOffset, domToRuns, drawLayers, easeIn, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOut, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOut, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, editAnchorsAction, enableLocalFontOutlines2 as enableLocalFontOutlines, enterTextEditAction, enumerateAnchors, evaluate, evaluateEnabled, findNodeShape, findShapeInk, findShapeSilhouette, fitTextPose, fitToBounds, fitViewToBounds, fitZoom, focused, fontString, forEachCoalesced, freeform, gateLayer, gesturing, getAlpha01, getImageBitmap, getNodeShapes, getStylusData, hasFontOutlines2 as hasFontOutlines, hexToRgba, hitAffordanceRegions, hitAnchor, hitRotationHandle, hovering, hoveringSelected, imageStatus, inferredNodeProperties, inferredNodeRouting, insertAction, isCanvasFont2 as isCanvasFont, isEditableTarget, lassoSelectAction, layoutMarkdown, lerpColorArray, lerpOklab, lerpOklch, linear, listFontOutlines2 as listFontOutlines, makeViewportZoomAction, markdownToRuns, matchAlignment, matchesKeyBinding, measureText, measureTextBounds, measuredWidth, mergeAlphaFromPrev, modeIn, modeIs, modeNot, modifierHeld, momentum, moveAction, multiActive, nearest, nearestWithin, nestedHitTester, never, none, normalizeHex, not, nurbs, oklabToOklch, oklabToSrgbU8, oklchToOklab, openFilePicker, or, outlineStatus2 as outlineStatus, parseColor, parseColorToRgba255, parseDebugFlags, pathContainsPoint, pathContainsPolygon, pathContainsRect, pathDistanceToPoint, pathDivide, pathExclude, pathFromD, pathInPoseFrame, pathInWorld, pathIntersect, pathIntersectsPolygon, pathIntersectsRect, pathOriginProjection, pathSubtract, pathToAnchors, pathUnion, pickTopMostHit, pinchZoomAction, planPixelRender, pointInRotatedRect, pointInTextPose, poseRotationOf, pressureToWidth, rainbowVertexColors, rebaseLocalPose, rectCorners, registerCanvasFont2 as registerCanvasFont, registerContentHandler, registerFont2 as registerFont, registerFontOutlines2 as registerFontOutlines, registerNodeShape, renderLabel, renderSceneToCanvas, renderSceneToPixels, resizeAction, resolveColor, resolveRuns, resolveTextStyle, resolveVisibility, rgbaToHex, rotateAction, rotateAroundAABBCenter, rotatePathAround, rotatePoint, rotatedRectCorners, rotationDegreesUnit, rotationHandle, roundToCell, runsToDom, runsToMarkdown, runsToPlainText, sceneFromJSON, sceneNodeClientRect, sceneToAdapter, screenToWorld, selectFromLasso, selectionAtLeast, selectionEmpty, selectionIs, shapeCoversPoint, sliceAction, snapPoint, solidVertexColors, specificity, spiro, splitPathByLine, splitSubpaths, springPose, springVertexColors, srgbU8ToOklab, staggerVertexColors, startThresholdDrag, styleAtRange, subscribeGlyphReady2 as subscribeGlyphReady, subscribeImageReady, textCommand, textLineBoxes, tileGrid, toHex8, toRuns, translatePoseViaDescriptor, translateRectPose, tweenPose, tweenVertexColors, unionBounds, unionBoundsPath, unregisterCanvasFont2 as unregisterCanvasFont, unregisterFontOutlines2 as unregisterFontOutlines, useAction, useActionsRegistry, useActiveToolContext, useAlign, useAnimator, useArrayAdapter, useAutoCenter, useBooleans, useBooleansAdapter, useCanvasFocus, useCanvasSize, useDecayLoop, useDepRegistry, useDepSource, useDistribute, useDragGesture, useDragHandle, useDragRadial, useDragRect, useDropZone, useEllipseTool, useEyedropperTool, useGestureDispatcher, useGridCellHover, useGuides, useHandTool, useHandleDrag, useHoverTracking, useImageTool, useKeybindings, useLassoTool, useLineTool, useOptionalActiveToolContext, useOptionalDepRegistry, usePenTool, usePencilTool, usePinchGesture, usePinchZoomTool, usePointerStylus, usePolygonTool, usePublishSelection, useRectTool, useResizePolicy, useRotateTool, useScene, useSceneAdapter, useSceneTextEdit, useSelectTool, useSelection, useSelectionContext, useSimulation, useSliceDep, useStandardActions, useStarTool, useTextEdit, useTextTool, useTools, useVelocityTracker, useViewAnimation, useViewTween, useZoom, verticalAlignOffset, viewToMat3, viewToTransform, viewportDragPanAction, viewportZoomAction, when, withAlpha01, withCoord, worldEditToStorage, worldPoseLookup, worldToScreen, zoomAt, zoomAtLeast } from './chunk-5F3PIERN.js';
2
- export { routing_exports as routing } from './chunk-SYM6RAM4.js';
3
- export { createReparentOp, createTransformOp, deleteScratch, getScratch, scratchKey, setScratch, snap } from './chunk-VOVKONXA.js';
4
- export { CORNER_ANCHORS, cornerPoint, cornerResizeHandles, hitCornerHandle, pointSnapToGrid } from './chunk-BGGZ4CVF.js';
5
- export { DEFAULT_FLATTEN_TOLERANCE, DEFAULT_GUIDE_TOLERANCE_PX, IMPERIAL_INCHES, METRIC_MM, PATH_C, PATH_CMD_LENGTHS, PATH_L, PATH_M, PATH_Q, PATH_Z, PIXELS, PathBuilder, RECT_ORIGIN_PROJECTION, RECT_POSE_DESCRIPTOR, ROTATED_POSE_DESCRIPTOR, boundsOfPath, ellipsePath, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, formatUnit, gridSnapStrategy, guideSnapStrategy, linePath, meanScale, pathPoseDescriptor, pointInPath, pointToGridCell, polygonFromPoints, rectPath, regularPolygonPath, resolveUnit, scalePathToBounds, starPath, transformPath, translatePath, translatePolygonInPlace } from './chunk-CQNKCG34.js';
1
+ export { ALWAYS, ANCHOR_HIT_BASE_PX, ActionsProviderIfRoot, ActiveToolContextProvider, ActiveToolContextProviderIfRoot, BUNDLE_TOOLS, COARSE_TARGET_SCALE, CURVE_REPS, ColorOverrideRegistry, CropIcon, CursorCoordsHud, DEFAULT_ALPHA_DECAY, DEFAULT_ALPHA_MIN, DEFAULT_DEBUG_THEME, DEFAULT_DEVICE_PROFILE, DEFAULT_FILL_COLOR, DEFAULT_HANDLE_SIZE, DEFAULT_PALETTE, DEFAULT_ROTATION_HANDLE_DISTANCE, DEFAULT_STROKE_COLOR, DEFAULT_TEXT_STYLE, DEFAULT_VELOCITY_DECAY, DepRegistryProviderIfRoot, DeviceProfileProvider, DivideIcon, EASINGS, EllipseIcon, ExcludeIcon, EyedropperIcon, FALLBACK_FIT_VIEW, GHOST_STROKE, HANDLE_BASE_PX, HandIcon, IDENTITY_POSE_COMPOSITION, IntersectIcon, KIT_SHAPE_KINDS, LassoIcon, LineIcon, MIXED, MOVE_ANCHORS, MinimapCanvas, NEVER, PATH_ANCHOR_CHROME_ID, PenIcon, PencilIcon, PickHud, PointerProviderIfRoot, PolygonIcon, RECT_ALIGN_PROJECTION, ROTATION_HANDLE_BASE_PX, RectIcon, SPRING_PRESETS, SceneCanvas, SceneViewCanvas, SelectIcon, SelectionContextProvider, SelectionContextProviderIfRoot, StarIcon, SubtractIcon, TextIcon, UnionIcon, UnknownIcon, VERSION, WeaselProvider, aabbCenter, actionIs, alignDeltaFor, alignInsertBehavior, alignMoveBehavior, alignResizeBehavior, alignedStrokeRect, always, and, animateLifecycle, animateOnSetPose, annulusSemiAxes, applyBooleanOp, applyHitExistingGate, applyStyleToRange, areaSelectAction, arrayAdapter, asNodeId, bezierCubic, bezierQuadratic, buildChromeCtx, buildRuleCtx, buildSceneViewCommands, canBringForward, canHover, canQueryLocalFonts2 as canQueryLocalFonts, canSendBackward, capabilityAll, capabilityIn, capabilityIs, capabilityNot, caretIndexAt, cellAt, charOffsetToDomPosition, clampView, clearSelectionAction, clientToCanvas, clipboardCopyAction, clipboardCutAction, cloneAction, coarsePointer, composeAffordanceLayer, composePath, composeRectPose, composeSelectionPose, composeWorldPose, computeFitView, computeIndicatorCommand, computeWheelAction, cond, constrainTo45, containedThenNearest, countPathAnchors, createCellHighlightLayer, createChildrenLayer, createCornerResizeAffordance, createDebugOverlayLayer, createDebugSink, createDispatcher, createGridLayer, createGuidesLayer, createHistory, createMarkdownRenderer, createMoveToIndexOp, createNodeProperties, createNodeRouting, createParallaxLayer, createPathAnchorAffordances, createPathEditingOverlayLayer, createPathLayer, createPenPreviewLayer, createReorderOp, createRotationAffordance, createScene, createSelectionHandlesLayer, createSelectionOutlineLayer, createSelectionOverlayLayer, createSetDataOp, createSetLayerOp, createSetPathOp, createSetTextOp, createTextLayer, createViewportLayer, cycleVertexColors, decomposePath, decomposeRectPose, defaultCommitAdapter, defaultDrawOne, defaultLabelTextRenderer, defaultNodeProperties, defaultNodeRouting, defaultVisibilityRules, deriveAlignmentGuides, deriveParallaxView, describeRule, domPositionToCharOffset, domToRuns, drawLayers, easeIn, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOut, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOut, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, editAnchorsAction, enableLocalFontOutlines2 as enableLocalFontOutlines, enterTextEditAction, enumerateAnchors, evaluate, fillInPoseFrame, fillToBoundsFrame, findNodeShape, findShapeInk, findShapeSilhouette, fitTextPose, fitToBounds, fitViewToBounds, fitZoom, focused, fontString, forEachCoalesced, freeform, gateLayer, gesturing, getAlpha01, getImageBitmap, getNodeShapes, getStylusData, gradientForBounds, gradientGeometry, hasFontOutlines2 as hasFontOutlines, hexToRgba, hitAffordanceRegions, hitAnchor, hitRotationHandle, hovering, hoveringSelected, imageStatus, inferredNodeProperties, inferredNodeRouting, insertAction, isCanvasFont2 as isCanvasFont, isEditableTarget, isPatternSpec, lassoSelectAction, layoutMarkdown, lerpColorArray, lerpOklab, lerpOklch, linear, listFontOutlines2 as listFontOutlines, liveScope, makeViewportZoomAction, markdownToRuns, matchAlignment, matchesKeyBinding, meanScale, measureText, measureTextBounds, measuredWidth, mergeAlphaFromPrev, mergeContributions, modeIn, modeIs, modeNot, modifierHeld, momentum, moveAction, multiActive, nearest, nearestWithin, nestedHitTester, never, nodeHasFlag, none, normalizeHex, not, nurbs, oklabToOklch, oklabToSrgbU8, oklchToOklab, openFilePicker, or, outlineStatus2 as outlineStatus, parseColor, parseColorToRgba255, parseDebugFlags, pathContainsPoint, pathContainsPolygon, pathContainsRect, pathDistanceToPoint, pathDivide, pathExclude, pathFromD, pathInPoseFrame, pathInWorld, pathIntersect, pathIntersectsPolygon, pathIntersectsRect, pathOriginProjection, pathSubtract, pathToAnchors, pathUnion, pickTopMostHit, pinchZoomAction, planPixelRender, pointInRotatedRect, pointInTextPose, poseRotationOf, pressureToWidth, rainbowVertexColors, rebaseLocalPose, rectCorners, registerCanvasFont2 as registerCanvasFont, registerContentHandler, registerFont2 as registerFont, registerFontOutlines2 as registerFontOutlines, registerNodeShape, renderLabel, renderSceneToCanvas, renderSceneToPixels, resizeAction, resolveColor, resolveDeviceProfile, resolveFillPattern, resolvePatternSpec, resolveRuns, resolveTextStyle, resolveVisibility, rgbaToHex, rotateAction, rotateAroundAABBCenter, rotatePathAround, rotatePoint, rotatedRectCorners, rotationDegreesUnit, rotationHandle, roundToCell, runsToDom, runsToMarkdown, runsToPlainText, sampleGradientStops, sceneFromJSON, sceneNodeClientRect, sceneToAdapter, scopeBindings, screenToWorld, selectFromLasso, selectionAtLeast, selectionEmpty, selectionIs, setFlagOverRange, shapeCoversPoint, sliceAction, snapPoint, solidVertexColors, specificity, spiro, splitPathByLine, splitSubpaths, springPose, springVertexColors, srgbU8ToOklab, staggerVertexColors, startThresholdDrag, styleAtRange, subscribeGlyphReady2 as subscribeGlyphReady, subscribeImageReady, textCommand, textLineBoxes, tileGrid, toHex8, toRuns, translatePoseViaDescriptor, translateRectPose, tweenPose, tweenVertexColors, unionBounds, unionBoundsPath, unregisterCanvasFont2 as unregisterCanvasFont, unregisterFontOutlines2 as unregisterFontOutlines, useActiveToolContext, useAlign, useAnimator, useArrayAdapter, useAutoCenter, useBooleans, useBooleansAdapter, useCanvasFocus, useCanvasSize, useDecayLoop, useDeviceProfile, useDistribute, useDragGesture, useDragHandle, useDragRadial, useDragRect, useDropZone, useEllipseTool, useEyedropperTool, useGestureDispatcher, useGridCellHover, useGuides, useHandTool, useHandleDrag, useHoverTracking, useImageTool, useKeybindings, useLassoTool, useLineTool, useOptionalActiveToolContext, usePenTool, usePencilTool, usePinchGesture, usePinchZoomTool, usePointerStylus, usePolygonTool, usePublishSelection, useRectTool, useResizePolicy, useRotateTool, useScene, useSceneAdapter, useSceneTextEdit, useSelectTool, useSelection, useSelectionContext, useSimulation, useSliceDep, useStandardActions, useStarTool, useTextEdit, useTextTool, useTools, useVelocityTracker, useViewAnimation, useViewTween, useZoom, verticalAlignOffset, viewToMat3, viewToTransform, viewportDragPanAction, viewportZoomAction, when, withAlpha01, withCoord, withGradientKind, worldEditToStorage, worldPoseLookup, worldToScreen, zoomAt, zoomAtLeast } from './chunk-D2C6K6FO.js';
2
+ export { ActionDisabledReason, ActionsProvider, DepRegistryProvider, evaluateEnabled, routing_exports as routing, useAction, useActionsRegistry, useDepRegistry, useDepSource, useOptionalDepRegistry } from './chunk-DCIU3SRK.js';
3
+ export { createReparentOp, createTransformOp, deleteScratch, getScratch, scratchKey, setScratch, snap } from './chunk-UB6A6L77.js';
4
+ export { CORNER_ANCHORS, cornerPoint, cornerResizeHandles, hitCornerHandle, pointSnapToGrid } from './chunk-Z3KNFTTS.js';
5
+ export { DEFAULT_FLATTEN_TOLERANCE, DEFAULT_GUIDE_TOLERANCE_PX, IMPERIAL_INCHES, METRIC_MM, PATH_C, PATH_CMD_LENGTHS, PATH_L, PATH_M, PATH_Q, PATH_Z, PIXELS, PathBuilder, RECT_ORIGIN_PROJECTION, RECT_POSE_DESCRIPTOR, ROTATED_POSE_DESCRIPTOR, boundsOfPath, ellipsePath, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, formatUnit, gridSnapStrategy, guideSnapStrategy, linePath, pathPoseDescriptor, pointInPath, pointToGridCell, polygonFromPoints, pxExtent, rectPath, regularPolygonPath, resolveUnit, scaleDelta, scalePathToBounds, starPath, transformPath, translatePath, translatePolygonInPlace, withinPxBox, withinPxRadius } from './chunk-6SHZHXXR.js';
6
6
  export { PointerContextProvider, WEASEL_CLIPBOARD_MIME, WEASEL_CLIPBOARD_MIME_WEB, applyOpsTo, buildWeaselClipboardText, dispatchApplyBatch, dlog, dwarn, embedWeaselMetadataInSvg, extractWeaselClipboardFromSvg, isDebugEnabled, parseWeaselClipboardText, sniffWeaselClipboardText, useClipboardOps, usePointerContext } from './chunk-775XXAHR.js';
7
7
  export { cloneByAltDrag } from './chunk-UGFFCMQP.js';
8
8
  export { createSetSelectionOp } from './chunk-BHVYVFGV.js';
9
9
  export { createDeleteOp, createInsertOp, rebuildOp, registerOpFactory } from './chunk-GVCNT7UH.js';
10
- export { createTilePattern } from './chunk-Y52N27PF.js';
10
+ export { createTilePattern } from './chunk-IO5Z75X4.js';
11
11
  import './chunk-PZ5AY32C.js';
12
12
  //# sourceMappingURL=index.js.map
13
13
  //# sourceMappingURL=index.js.map
package/dist/insert.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { U as UseInsertOptions } from './options-DMWeTELe.js';
2
- import { M as ModifierState, I as InsertBehavior } from './types-Dcaa0tPq.js';
1
+ export { U as UseInsertOptions } from './options-wAvCnOZd.js';
2
+ import { M as ModifierState, I as InsertBehavior } from './types-BhJJ2OCM.js';
3
3
  import { G as Guide } from './types-D2tTKEU0.js';
4
4
  import { V as View } from './view-DSQgxBJB.js';
5
5
  import '@weasel-js/history';
package/dist/insert.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DEFAULT_GUIDE_TOLERANCE_PX, meanScale } from './chunk-CQNKCG34.js';
1
+ import { DEFAULT_GUIDE_TOLERANCE_PX, pxExtent } from './chunk-6SHZHXXR.js';
2
2
  import './chunk-PZ5AY32C.js';
3
3
 
4
4
  // src/interactions/actions/insert/behaviors/snapToGrid.ts
@@ -21,7 +21,7 @@ function snapToGrid(args) {
21
21
  }
22
22
 
23
23
  // src/interactions/actions/insert/behaviors/snapToGuides.ts
24
- function snapPoint(p, guides, worldTolerance) {
24
+ function snapPoint(p, guides, tol) {
25
25
  let bestDx = 0;
26
26
  let bestAbsDx = Infinity;
27
27
  let bestDy = 0;
@@ -30,14 +30,14 @@ function snapPoint(p, guides, worldTolerance) {
30
30
  if (g.axis === "x") {
31
31
  const d = g.offset - p.x;
32
32
  const ad = Math.abs(d);
33
- if (ad <= worldTolerance && ad < bestAbsDx) {
33
+ if (ad <= tol.x && ad < bestAbsDx) {
34
34
  bestAbsDx = ad;
35
35
  bestDx = d;
36
36
  }
37
37
  } else {
38
38
  const d = g.offset - p.y;
39
39
  const ad = Math.abs(d);
40
- if (ad <= worldTolerance && ad < bestAbsDy) {
40
+ if (ad <= tol.y && ad < bestAbsDy) {
41
41
  bestAbsDy = ad;
42
42
  bestDy = d;
43
43
  }
@@ -53,7 +53,7 @@ function snapToGuides(args) {
53
53
  const tolerance = args.tolerance ?? DEFAULT_GUIDE_TOLERANCE_PX;
54
54
  const getView = args.getView;
55
55
  const bypassKey = args.bypassKey;
56
- const computeWorldTol = () => getView ? tolerance / Math.max(1e-9, meanScale(getView().scale)) : tolerance;
56
+ const computeWorldTol = () => getView ? pxExtent(tolerance, getView().scale) : { x: tolerance, y: tolerance };
57
57
  return {
58
58
  onStart(ctx) {
59
59
  if (bypassKey && ctx.modifiers[bypassKey]) return;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interactions/actions/insert/behaviors/snapToGrid.ts","../src/interactions/actions/insert/behaviors/snapToGuides.ts"],"names":[],"mappings":";;;;AAQO,SAAS,WAAkB,IAAA,EAGR;AACxB,EAAA,MAAM,EAAE,OAAA,EAAS,SAAA,EAAU,GAAI,IAAA;AAC/B,EAAA,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AAU,OAAA,EAAQ,CAAE,KAAK,CAAC,CAAA,GAAI,SAAA;AAErE,EAAA,OAAO;AAAA,IACL,QAAQ,GAAA,EAAK;AACX,MAAA,IAAI,SAAA,IAAa,GAAA,CAAI,SAAA,CAAU,SAAS,CAAA,EAAG;AAC3C,MAAA,MAAM,MAAA,GAAS,KAAK,SAAA,EAAU;AAC9B,MAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACzB,MAAA,MAAM,EAAA,GAAK,GAAA,CAAI,UAAA,CAAW,CAAC,CAAA;AAC3B,MAAA,MAAM,CAAA,GAAI,GAAA,CAAI,MAAA,CAAO,GAAA,CAAI,EAAE,CAAA;AAC3B,MAAA,IAAI,CAAC,CAAA,EAAG;AACR,MAAA,MAAM,OAAA,GAAU,SAAA,CAAU,CAAA,EAAG,MAAA,EAAQ,iBAAiB,CAAA;AACtD,MAAA,IAAI,OAAA,EAAS,GAAA,CAAI,MAAA,CAAO,GAAA,CAAI,IAAI,OAA2B,CAAA;AAAA,IAC7D,CAAA;AAAA,IACA,MAAA,CAAO,GAAA,EAAK,EAAE,OAAA,EAAQ,EAAG;AACvB,MAAA,IAAI,SAAA,IAAa,GAAA,CAAI,SAAA,CAAU,SAAS,CAAA,EAAG;AAC3C,MAAA,MAAM,MAAA,GAAS,KAAK,SAAA,EAAU;AAC9B,MAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACzB,MAAA,MAAM,OAAA,GAAU,SAAA,CAAU,OAAA,EAAS,MAAA,EAAQ,iBAAiB,CAAA;AAC5D,MAAA,IAAI,CAAC,OAAA,EAAS;AACd,MAAA,OAAO,EAAE,SAAS,OAAA,EAAQ;AAAA,IAC5B;AAAA,GACF;AACF","file":"insert.js","sourcesContent":["import type {\n InsertBehavior,\n InsertPoint,\n ModifierState,\n} from '../../../gestures/types';\n\ntype ModKey = keyof ModifierState;\n\nexport function snapToGrid<TPose>(args: {\n spacing: number;\n bypassKey?: ModKey;\n}): InsertBehavior<TPose> {\n const { spacing, bypassKey } = args;\n const round = (v: number) => Math.round(v / spacing) * spacing;\n return {\n onStart(ctx) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const id = ctx.draggedIds[0];\n const o = ctx.origin.get(id) as unknown as InsertPoint | undefined;\n if (!o) return;\n ctx.origin.set(id, { x: round(o.x), y: round(o.y) } as unknown as TPose);\n },\n onMove(ctx, { current }) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n return { current: { x: round(current.x), y: round(current.y) } };\n },\n };\n}\n","import type {\n InsertBehavior,\n InsertPoint,\n ModifierState,\n} from '../../../gestures/types';\nimport type { Guide } from 'features/guides/types';\nimport type { View } from 'core/viewport/view';\nimport { meanScale } from 'core/viewport/meanScale';\nimport { DEFAULT_GUIDE_TOLERANCE_PX } from '../../../gestures/shared/strategies/guides';\n\ntype ModKey = keyof ModifierState;\n\n/** Options for the insert-flavored `snapToGuides`. */\nexport interface SnapToGuidesInsertArgs {\n /** Stable getter into the live guide list (typically from `useGuides`). */\n getGuides: () => readonly Guide[];\n /** Snap tolerance (screen px when `getView` is set, world units otherwise). */\n tolerance?: number;\n /** Read the active view; required for screen-pixel tolerance. */\n getView?: () => View;\n /** Modifier key that bypasses snapping while held. */\n bypassKey?: ModKey;\n}\n\nfunction snapPoint(\n p: InsertPoint,\n guides: readonly Guide[],\n worldTolerance: number,\n): InsertPoint | null {\n let bestDx = 0;\n let bestAbsDx = Infinity;\n let bestDy = 0;\n let bestAbsDy = Infinity;\n for (const g of guides) {\n if (g.axis === 'x') {\n const d = g.offset - p.x;\n const ad = Math.abs(d);\n if (ad <= worldTolerance && ad < bestAbsDx) {\n bestAbsDx = ad;\n bestDx = d;\n }\n } else {\n const d = g.offset - p.y;\n const ad = Math.abs(d);\n if (ad <= worldTolerance && ad < bestAbsDy) {\n bestAbsDy = ad;\n bestDy = d;\n }\n }\n }\n if (bestAbsDx === Infinity && bestAbsDy === Infinity) return null;\n const dx = bestAbsDx === Infinity ? 0 : bestDx;\n const dy = bestAbsDy === Infinity ? 0 : bestDy;\n if (dx === 0 && dy === 0) return null;\n return { x: p.x + dx, y: p.y + dy };\n}\n\n/**\n * Insert behavior that snaps the start anchor (on gesture start) and the\n * live current point (during drag) to the nearest guide on each axis when\n * within `tolerance`. Pair with `useGuides` and `createGuidesLayer`.\n */\nexport function snapToGuides<TPose>(\n args: SnapToGuidesInsertArgs,\n): InsertBehavior<TPose> {\n const tolerance = args.tolerance ?? DEFAULT_GUIDE_TOLERANCE_PX;\n const getView = args.getView;\n const bypassKey = args.bypassKey;\n\n const computeWorldTol = (): number =>\n getView ? tolerance / Math.max(1e-9, meanScale(getView().scale)) : tolerance;\n\n return {\n onStart(ctx) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const guides = args.getGuides();\n if (guides.length === 0) return;\n const id = ctx.draggedIds[0];\n const o = ctx.origin.get(id) as unknown as InsertPoint | undefined;\n if (!o) return;\n const snapped = snapPoint(o, guides, computeWorldTol());\n if (snapped) ctx.origin.set(id, snapped as unknown as TPose);\n },\n onMove(ctx, { current }) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const guides = args.getGuides();\n if (guides.length === 0) return;\n const snapped = snapPoint(current, guides, computeWorldTol());\n if (!snapped) return;\n return { current: snapped };\n },\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/interactions/actions/insert/behaviors/snapToGrid.ts","../src/interactions/actions/insert/behaviors/snapToGuides.ts"],"names":[],"mappings":";;;;AAQO,SAAS,WAAkB,IAAA,EAGR;AACxB,EAAA,MAAM,EAAE,OAAA,EAAS,SAAA,EAAU,GAAI,IAAA;AAC/B,EAAA,MAAM,QAAQ,CAAC,CAAA,KAAc,KAAK,KAAA,CAAM,CAAA,GAAI,OAAO,CAAA,GAAI,OAAA;AACvD,EAAA,OAAO;AAAA,IACL,QAAQ,GAAA,EAAK;AACX,MAAA,IAAI,SAAA,IAAa,GAAA,CAAI,SAAA,CAAU,SAAS,CAAA,EAAG;AAC3C,MAAA,MAAM,EAAA,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,SAAA,EAAU;AAC9B,MAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACzB,MAAA,MAAM,EAAA,GAAK,GAAA,CAAI,UAAA,CAAW,CAAC,CAAA;AAC3B,MAAA,MAAM,CAAA,GAAI,GAAA,CAAI,MAAA,CAAO,GAAA,CAAI,EAAE,CAAA;AAC3B,MAAA,IAAI,CAAC,CAAA,EAAG;AACR,MAAA,MAAM,OAAA,GAAU,SAAA,CAAU,CAAA,EAAG,MAAA,EAAQ,iBAAiB,CAAA;AACtD,MAAA,IAAI,OAAA,EAAS,GAAA,CAAI,MAAA,CAAO,GAAA,CAAI,IAAI,OAA2B,CAAA;AAAA,IAC7D,CAAA;AAAA,IACA,MAAA,CAAO,GAAA,EAAK,EAAE,OAAA,EAAQ,EAAG;AACvB,MAAA,IAAI,SAAA,IAAa,GAAA,CAAI,SAAA,CAAU,SAAS,CAAA,EAAG;AAC3C,MAAA,MAAM,MAAA,GAAS,KAAK,SAAA,EAAU;AAC9B,MAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACzB,MAAA,MAAM,OAAA,GAAU,SAAA,CAAU,OAAA,EAAS,MAAA,EAAQ,iBAAiB,CAAA;AAC5D,MAAA,IAAI,CAAC,OAAA,EAAS;AACd,MAAA,OAAO,EAAE,SAAS,OAAA,EAAQ;AAAA,IAC5B;AAAA,GACF;AACF","file":"insert.js","sourcesContent":["import type {\n InsertBehavior,\n InsertPoint,\n ModifierState,\n} from '../../../gestures/types';\n\ntype ModKey = keyof ModifierState;\n\nexport function snapToGrid<TPose>(args: {\n spacing: number;\n bypassKey?: ModKey;\n}): InsertBehavior<TPose> {\n const { spacing, bypassKey } = args;\n const round = (v: number) => Math.round(v / spacing) * spacing;\n return {\n onStart(ctx) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const id = ctx.draggedIds[0];\n const o = ctx.origin.get(id) as unknown as InsertPoint | undefined;\n if (!o) return;\n ctx.origin.set(id, { x: round(o.x), y: round(o.y) } as unknown as TPose);\n },\n onMove(ctx, { current }) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n return { current: { x: round(current.x), y: round(current.y) } };\n },\n };\n}\n","import type {\n InsertBehavior,\n InsertPoint,\n ModifierState,\n} from '../../../gestures/types';\nimport type { Guide } from 'features/guides/types';\nimport type { View } from 'core/viewport/view';\nimport { pxExtent } from 'core/viewport/pxExtent';\nimport { DEFAULT_GUIDE_TOLERANCE_PX } from '../../../gestures/shared/strategies/guides';\n\ntype ModKey = keyof ModifierState;\n\n/** Options for the insert-flavored `snapToGuides`. */\nexport interface SnapToGuidesInsertArgs {\n /** Stable getter into the live guide list (typically from `useGuides`). */\n getGuides: () => readonly Guide[];\n /** Snap tolerance (screen px when `getView` is set, world units otherwise). */\n tolerance?: number;\n /** Read the active view; required for screen-pixel tolerance. */\n getView?: () => View;\n /** Modifier key that bypasses snapping while held. */\n bypassKey?: ModKey;\n}\n\nfunction snapPoint(\n p: InsertPoint,\n guides: readonly Guide[],\n tol: { x: number; y: number },\n): InsertPoint | null {\n let bestDx = 0;\n let bestAbsDx = Infinity;\n let bestDy = 0;\n let bestAbsDy = Infinity;\n for (const g of guides) {\n if (g.axis === 'x') {\n const d = g.offset - p.x;\n const ad = Math.abs(d);\n if (ad <= tol.x && ad < bestAbsDx) {\n bestAbsDx = ad;\n bestDx = d;\n }\n } else {\n const d = g.offset - p.y;\n const ad = Math.abs(d);\n if (ad <= tol.y && ad < bestAbsDy) {\n bestAbsDy = ad;\n bestDy = d;\n }\n }\n }\n if (bestAbsDx === Infinity && bestAbsDy === Infinity) return null;\n const dx = bestAbsDx === Infinity ? 0 : bestDx;\n const dy = bestAbsDy === Infinity ? 0 : bestDy;\n if (dx === 0 && dy === 0) return null;\n return { x: p.x + dx, y: p.y + dy };\n}\n\n/**\n * Insert behavior that snaps the start anchor (on gesture start) and the\n * live current point (during drag) to the nearest guide on each axis when\n * within `tolerance`. Pair with `useGuides` and `createGuidesLayer`.\n */\nexport function snapToGuides<TPose>(\n args: SnapToGuidesInsertArgs,\n): InsertBehavior<TPose> {\n const tolerance = args.tolerance ?? DEFAULT_GUIDE_TOLERANCE_PX;\n const getView = args.getView;\n const bypassKey = args.bypassKey;\n\n // Per axis: a vertical guide is matched by a horizontal distance, so it\n // answers to `scale.x` alone.\n const computeWorldTol = (): { x: number; y: number } =>\n getView ? pxExtent(tolerance, getView().scale) : { x: tolerance, y: tolerance };\n\n return {\n onStart(ctx) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const guides = args.getGuides();\n if (guides.length === 0) return;\n const id = ctx.draggedIds[0];\n const o = ctx.origin.get(id) as unknown as InsertPoint | undefined;\n if (!o) return;\n const snapped = snapPoint(o, guides, computeWorldTol());\n if (snapped) ctx.origin.set(id, snapped as unknown as TPose);\n },\n onMove(ctx, { current }) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const guides = args.getGuides();\n if (guides.length === 0) return;\n const snapped = snapPoint(current, guides, computeWorldTol());\n if (!snapped) return;\n return { current: snapped };\n },\n };\n}\n"]}
package/dist/move.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { O as OriginProjection } from './grid-CaSK9bHV.js';
2
- export { U as UseMoveOptions } from './grid-CaSK9bHV.js';
3
- import { M as ModifierState, b as MoveBehavior } from './types-Dcaa0tPq.js';
1
+ import { O as OriginProjection } from './grid-XcFQVS0f.js';
2
+ export { U as UseMoveOptions } from './grid-XcFQVS0f.js';
3
+ import { M as ModifierState, b as MoveBehavior } from './types-BhJJ2OCM.js';
4
4
  import { S as SnapTarget } from './types-B_-khFM0.js';
5
5
  import { G as Guide } from './types-D2tTKEU0.js';
6
6
  import { V as View } from './view-DSQgxBJB.js';
package/dist/move.js CHANGED
@@ -1,5 +1,5 @@
1
- import { scratchKey, snap, createTransformOp, createReparentOp, getScratch, setScratch } from './chunk-VOVKONXA.js';
2
- import { gridSnapStrategy, RECT_ORIGIN_PROJECTION, guideSnapStrategy } from './chunk-CQNKCG34.js';
1
+ import { scratchKey, snap, createTransformOp, createReparentOp, getScratch, setScratch } from './chunk-UB6A6L77.js';
2
+ import { gridSnapStrategy, RECT_ORIGIN_PROJECTION, guideSnapStrategy } from './chunk-6SHZHXXR.js';
3
3
  import { createDeleteOp } from './chunk-GVCNT7UH.js';
4
4
  import './chunk-PZ5AY32C.js';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { Op } from '@weasel-js/history';
2
- import { I as InsertBehavior, R as ResizePose } from './types-Dcaa0tPq.js';
2
+ import { I as InsertBehavior, R as ResizePose } from './types-BhJJ2OCM.js';
3
3
 
4
4
  /** Option surface for the `insert` action.
5
5
  *
@@ -0,0 +1,261 @@
1
+ /**
2
+ * registerTexture — accepts an image source, assigns an opaque id, stores in
3
+ * a module-level registry. Actual GL upload happens lazily at draw time in
4
+ * drawShader() via GLTextureCache.upload (which is idempotent).
5
+ *
6
+ * Lifecycle: textures live for the renderer's lifetime. No unregister in v1.
7
+ *
8
+ * Convention §9: this registry stores image data only — no per-renderer state.
9
+ * Each WeaselRenderer's GLTextureCache does its own dedup via has(id).
10
+ */
11
+ interface TextureHandle {
12
+ readonly id: string;
13
+ }
14
+ /**
15
+ * Register an image for use as a shader texture uniform.
16
+ *
17
+ * Returns a TextureHandle whose `id` can be passed as a ShaderUniform value.
18
+ * The handle is valid for the lifetime of the renderer it will be used with.
19
+ *
20
+ * @param image The image to register. HTMLImageElement must be fully loaded.
21
+ * @returns Opaque TextureHandle.
22
+ */
23
+ declare function registerTexture(image: HTMLImageElement | ImageBitmap): TextureHandle;
24
+
25
+ /**
26
+ * FillStyle and Stroke types — the unified shape for "what color or texture
27
+ * paints these pixels," modeled on SVG's paint-server concept.
28
+ *
29
+ * - `FillStyle` is a tagged union: solid color, pattern, or gradient. Used
30
+ * wherever a kit option previously took `fillStyle: string`.
31
+ * - `Stroke` pairs a `FillStyle` with structural stroke parameters (width, dash,
32
+ * line cap/join, alignment).
33
+ * - These types are consumed by the GL renderer's DrawCommand path fills
34
+ * and strokes.
35
+ *
36
+ * The 2D `applyPaint` / `applyStroke` / `renderFilledRegion` helpers that
37
+ * formerly lived alongside these types were deleted with the 2D backend in
38
+ * Step 10. `alignedStrokeRect` survives as a pure geometry helper used by
39
+ * path tessellation and the selection overlay.
40
+ */
41
+
42
+ /**
43
+ * Color/texture strategy for fills (and, via `Stroke.paint`, strokes).
44
+ *
45
+ * `fill` is optional and defaults to `'solid'` — `{ color: '#abc' }` is
46
+ * equivalent to `{ fill: 'solid', color: '#abc' }`. Pattern paints must set
47
+ * `fill: 'pattern'` explicitly.
48
+ *
49
+ * The `'pattern'` variant's payload is either a `TilePatternSpec` — plain
50
+ * data naming one of the built-in tiles, which survives serialization — or a
51
+ * `TextureHandle` for a tile the consumer built itself via
52
+ * `createTilePattern()`. A handle is a session-scoped registry key, so a
53
+ * paint carrying one cannot be persisted or exported; prefer the spec.
54
+ *
55
+ * `units` on a pattern names the space the tile's origin and scale live in,
56
+ * not the space of any geometry (a pattern has none). Under `'bounds'` the
57
+ * tile anchors to the painted node's box, so the pattern travels with the
58
+ * node and a resize reveals more tiles rather than stretching them;
59
+ * `fillInPoseFrame` resolves that to a `'local'` paint with an explicit
60
+ * `origin` before the renderer sees it.
61
+ */
62
+ type FillStyle = {
63
+ fill?: 'solid';
64
+ color: string;
65
+ opacity?: number;
66
+ } | {
67
+ fill: 'pattern';
68
+ pattern: TextureHandle | TilePatternSpec;
69
+ units?: GradientUnits;
70
+ origin?: {
71
+ x: number;
72
+ y: number;
73
+ };
74
+ opacity?: number;
75
+ } | {
76
+ fill: 'linear-gradient';
77
+ from: {
78
+ x: number;
79
+ y: number;
80
+ };
81
+ to: {
82
+ x: number;
83
+ y: number;
84
+ };
85
+ stops: GradStop[];
86
+ units?: GradientUnits;
87
+ opacity?: number;
88
+ } | {
89
+ fill: 'radial-gradient';
90
+ center: {
91
+ x: number;
92
+ y: number;
93
+ };
94
+ radius: number;
95
+ stops: GradStop[];
96
+ units?: GradientUnits;
97
+ opacity?: number;
98
+ } | {
99
+ fill: 'conic-gradient';
100
+ center: {
101
+ x: number;
102
+ y: number;
103
+ };
104
+ angle: number;
105
+ stops: GradStop[];
106
+ units?: GradientUnits;
107
+ opacity?: number;
108
+ };
109
+ /**
110
+ * Which coordinate space a gradient's geometry (`from`/`to`, `center`,
111
+ * `radius`) is expressed in. SVG's `gradientUnits`, plus an option for
112
+ * paints that are themselves viewport furniture.
113
+ *
114
+ * - `'bounds'`: fractions of the painted node's bounding box, `0..1` on each
115
+ * axis — SVG `objectBoundingBox`. Resolved by the node painter, before the
116
+ * renderer sees it, so the paint follows the node through moves, resizes
117
+ * and rotation. What a gradient on a scene node wants.
118
+ * - `'local'`: the coordinate space the geometry was handed to the renderer
119
+ * in — the enclosing group's frame. For draw commands a consumer builds
120
+ * itself, where "the coordinates I just wrote" is the useful frame.
121
+ * - `'world'`: scene coordinates. The paint stays put under pan and zoom
122
+ * while the geometry moves through it. SVG `userSpaceOnUse`. Requires the
123
+ * renderer to have been handed a view matrix; falls back to `'screen'`
124
+ * when it has not.
125
+ * - `'screen'`: CSS pixels of the drawing surface. For overlays and
126
+ * viewport-fixed washes that should not move with the content at all.
127
+ *
128
+ * Defaults to `'screen'`, which is the behavior every gradient had before
129
+ * this field existed.
130
+ */
131
+ type GradientUnits = 'bounds' | 'local' | 'world' | 'screen';
132
+ /**
133
+ * A built-in tile, described as plain data. The serializable half of the
134
+ * pattern paint: `resolvePatternSpec()` turns one into a `TextureHandle`
135
+ * at paint time, memoized so identical specs share a texture.
136
+ *
137
+ * `size` is the tile's edge length, and doubles as its extent in paint
138
+ * space — a bigger `size` rasterizes a bigger tile rather than magnifying
139
+ * a small one, which is why there is no separate scale field.
140
+ */
141
+ interface TilePatternSpec {
142
+ tile: 'hatch' | 'crosshatch' | 'dots' | 'chunks';
143
+ color: string;
144
+ /** `chunks` only — omit for a transparent tile background. */
145
+ bg?: string;
146
+ size?: number;
147
+ /** `hatch` / `crosshatch`. */
148
+ lineWidth?: number;
149
+ /** `dots`. */
150
+ radius?: number;
151
+ /** `chunks`. */
152
+ density?: number;
153
+ chunkSize?: number;
154
+ seed?: number;
155
+ }
156
+ /** A single color stop within a gradient. `offset` is in 0..1. */
157
+ interface GradStop {
158
+ offset: number;
159
+ color: string;
160
+ }
161
+ /** The gradient members of `FillStyle`, as one type. What a gradient editor
162
+ * edits, and what the gradient-specific helpers accept. */
163
+ type GradientFill = Extract<FillStyle, {
164
+ fill: 'linear-gradient' | 'radial-gradient' | 'conic-gradient';
165
+ }>;
166
+ /** `GradientFill['fill']` — the three gradient discriminants on their own. */
167
+ type GradientKind = GradientFill['fill'];
168
+ /**
169
+ * Where a stroke sits relative to the geometric edge it strokes.
170
+ *
171
+ * - `'center'` (default): canvas-native — half the stroke width sits inside
172
+ * the geometry, half outside.
173
+ * - `'inner'`: the entire stroke lies inside the geometry. The outer edge of
174
+ * the stroke coincides with the geometric edge.
175
+ * - `'outer'`: the entire stroke lies outside the geometry. The inner edge
176
+ * of the stroke coincides with the geometric edge.
177
+ *
178
+ * Mirrors the (proposed) SVG `stroke-alignment` property. Honoring `inner`
179
+ * or `outer` is the renderer's responsibility — for axis-aligned rects, the
180
+ * kit shifts coordinates by `width / 2`. For arbitrary paths, renderers
181
+ * typically use a stencil mask of the stroked path against the geometry.
182
+ */
183
+ type StrokeAlign = 'center' | 'inner' | 'outer';
184
+ /** Stroke style: a FillStyle plus structural line parameters. */
185
+ interface Stroke {
186
+ paint: FillStyle;
187
+ width?: number;
188
+ /** Per `CanvasRenderingContext2D.setLineDash` — empty/omitted = solid. */
189
+ dash?: number[];
190
+ cap?: 'butt' | 'round' | 'square';
191
+ join?: 'miter' | 'round' | 'bevel';
192
+ /**
193
+ * Miter join fallback threshold. When the miter length exceeds
194
+ * `miterLimit * width / 2`, the join falls back to a bevel. Default 10
195
+ * (matching Canvas2D). SVG's default is 4; consumers that want SVG
196
+ * fidelity should set this explicitly when constructing strokes from
197
+ * SVG sources where the attribute was omitted.
198
+ */
199
+ miterLimit?: number;
200
+ /** Where the stroke sits relative to the geometric edge. Default `'center'`. */
201
+ align?: StrokeAlign;
202
+ /**
203
+ * Per-anchor RGBA, flat (length = 4 × countPathAnchors(path)). Each
204
+ * value in 0..1. Arc-length interpolated across the tessellated ribbon
205
+ * between consecutive anchors. When set, `paint` is still required —
206
+ * its `opacity` (and color, as a placeholder) flow through the shader.
207
+ */
208
+ vertexColors?: number[];
209
+ /**
210
+ * Per-anchor stroke width (length = `countPathAnchors(path)`). When set,
211
+ * the tessellator interpolates half-widths along each segment to produce
212
+ * a tapered ribbon. `width` is used as the fallback for any anchor whose
213
+ * entry is missing or non-finite. Pressure-driven pencil strokes use
214
+ * this; pair with `pressureToWidth` to derive widths from stylus input.
215
+ *
216
+ * Joins between adjacent segments whose widths differ by more than
217
+ * `varyingWidthJoinThreshold` (default 1.5×) are forced to bevel
218
+ * regardless of the `join` setting — miter math is unstable when widths
219
+ * vary across the corner; smooth round joins with mismatched widths
220
+ * are a future enhancement.
221
+ */
222
+ vertexWidths?: number[];
223
+ /**
224
+ * Max width ratio (greater / lesser) at which a non-bevel join is
225
+ * preserved when `vertexWidths` causes adjacent segments to differ.
226
+ * Beyond this ratio the join falls back to bevel. Default 1.5. Ignored
227
+ * when `vertexWidths` is absent.
228
+ */
229
+ varyingWidthJoinThreshold?: number;
230
+ }
231
+ /**
232
+ * Inflate (positive) or deflate (negative) a rect to honor `align` when
233
+ * stroking it. Returns the rect to pass to a stroked-rect renderer. `width`
234
+ * is the stroke width (defaults to 1 to match canvas).
235
+ *
236
+ * Pure geometry helper — no rendering side effects. Used by path
237
+ * tessellation and the selection overlay to produce a rect whose
238
+ * center-aligned stroke visually coincides with the requested
239
+ * inner/outer-aligned stroke of the original rect.
240
+ */
241
+ declare function alignedStrokeRect(rect: {
242
+ x: number;
243
+ y: number;
244
+ width: number;
245
+ height: number;
246
+ }, align: StrokeAlign, width?: number): {
247
+ x: number;
248
+ y: number;
249
+ width: number;
250
+ height: number;
251
+ };
252
+ /** Region a fill is clipped to. */
253
+ interface Region {
254
+ x: number;
255
+ y: number;
256
+ w: number;
257
+ h: number;
258
+ shape: 'rectangle' | 'circle';
259
+ }
260
+
261
+ export { type FillStyle as F, type GradStop as G, type Region as R, type Stroke as S, type TilePatternSpec as T, type TextureHandle as a, type GradientKind as b, type GradientFill as c, type GradientUnits as d, type StrokeAlign as e, alignedStrokeRect as f, registerTexture as r };
@@ -1,4 +1,54 @@
1
- import { T as TextureHandle } from './registerTexture-BzHTLhD9.js';
1
+ import { T as TilePatternSpec, a as TextureHandle } from './paint-types-CnLIzqq1.js';
2
+
3
+ /**
4
+ * The shapes a built-in tile is made of, as data.
5
+ *
6
+ * One description, two renderers: `patterns-builtin` strokes/fills these to
7
+ * an `OffscreenCanvas` to build the GL texture, and `@weasel-js/svg` maps
8
+ * them to `<pattern>` children. Duplicating the tile drawing in the
9
+ * serializer would let the raster and vector forms drift apart silently.
10
+ */
11
+
12
+ type TileShape = {
13
+ kind: 'line';
14
+ x1: number;
15
+ y1: number;
16
+ x2: number;
17
+ y2: number;
18
+ width: number;
19
+ color: string;
20
+ } | {
21
+ kind: 'circle';
22
+ cx: number;
23
+ cy: number;
24
+ r: number;
25
+ color: string;
26
+ } | {
27
+ kind: 'ellipse';
28
+ cx: number;
29
+ cy: number;
30
+ rx: number;
31
+ ry: number;
32
+ rotation: number;
33
+ color: string;
34
+ } | {
35
+ kind: 'rect';
36
+ x: number;
37
+ y: number;
38
+ width: number;
39
+ height: number;
40
+ color: string;
41
+ };
42
+ /** A built-in tile's shapes plus the edge length they're drawn within. */
43
+ interface TileGeometry {
44
+ size: number;
45
+ shapes: TileShape[];
46
+ }
47
+ /** Defaults per tile kind, matching each factory's signature. */
48
+ declare function tileSize(spec: TilePatternSpec): number;
49
+ declare function tileGeometry(spec: TilePatternSpec): TileGeometry;
50
+ /** Draw a tile's shapes to a 2D context — the raster half of the pair. */
51
+ declare function drawTileShapes(oc: CanvasRenderingContext2D, geometry: TileGeometry): void;
2
52
 
3
53
  /**
4
54
  * Built-in pattern factories — generic line/dot/scatter textures. Each
@@ -11,6 +61,11 @@ import { T as TextureHandle } from './registerTexture-BzHTLhD9.js';
11
61
  * All factories require an explicit `color` (and `bg` for `chunks`). No
12
62
  * defaults are baked in — the caller's design system is the source of truth
13
63
  * for palette decisions.
64
+ *
65
+ * Each is a thin wrapper over `tileGeometry`, which describes the tile as
66
+ * shapes so `@weasel-js/svg` can emit the same tile as a `<pattern>`.
67
+ * Prefer naming a tile in a `TilePatternSpec` over calling these directly —
68
+ * a spec serializes, a `TextureHandle` does not.
14
69
  */
15
70
 
16
71
  /** Diagonal hatch (forward slash). */
@@ -52,4 +107,4 @@ interface ChunksParams {
52
107
  }
53
108
  declare function chunks(params: ChunksParams): TextureHandle | null;
54
109
 
55
- export { type ChunksParams, type CrosshatchParams, type DotsParams, type HatchParams, chunks, crosshatch, dots, hatch };
110
+ export { type ChunksParams, type CrosshatchParams, type DotsParams, type HatchParams, type TileGeometry, type TileShape, chunks, crosshatch, dots, drawTileShapes, hatch, tileGeometry, tileSize };
@@ -1,100 +1,4 @@
1
- import { createTilePattern } from './chunk-Y52N27PF.js';
1
+ export { chunks, crosshatch, dots, drawTileShapes, hatch, tileGeometry, tileSize } from './chunk-IO5Z75X4.js';
2
2
  import './chunk-PZ5AY32C.js';
3
-
4
- // src/features/patterns/patterns-builtin.ts
5
- function hatch(params) {
6
- const { color, size = 5, lineWidth = 1 } = params;
7
- return createTilePattern({
8
- size,
9
- draw: (oc, s) => {
10
- oc.strokeStyle = color;
11
- oc.lineWidth = lineWidth;
12
- oc.beginPath();
13
- oc.moveTo(-1, s + 1);
14
- oc.lineTo(s + 1, -1);
15
- oc.moveTo(-1, 1);
16
- oc.lineTo(1, -1);
17
- oc.moveTo(s - 1, s + 1);
18
- oc.lineTo(s + 1, s - 1);
19
- oc.stroke();
20
- }
21
- });
22
- }
23
- function crosshatch(params) {
24
- const { color, size = 6, lineWidth = 0.8 } = params;
25
- return createTilePattern({
26
- size,
27
- draw: (oc, s) => {
28
- oc.strokeStyle = color;
29
- oc.lineWidth = lineWidth;
30
- oc.beginPath();
31
- oc.moveTo(-1, s + 1);
32
- oc.lineTo(s + 1, -1);
33
- oc.moveTo(-1, 1);
34
- oc.lineTo(1, -1);
35
- oc.moveTo(s - 1, s + 1);
36
- oc.lineTo(s + 1, s - 1);
37
- oc.moveTo(-1, -1);
38
- oc.lineTo(s + 1, s + 1);
39
- oc.moveTo(s - 1, -1);
40
- oc.lineTo(s + 1, 1);
41
- oc.moveTo(-1, s - 1);
42
- oc.lineTo(1, s + 1);
43
- oc.stroke();
44
- }
45
- });
46
- }
47
- function dots(params) {
48
- const { color, size = 6, radius = 1 } = params;
49
- return createTilePattern({
50
- size,
51
- draw: (oc, s) => {
52
- oc.fillStyle = color;
53
- oc.beginPath();
54
- oc.arc(s / 2, s / 2, radius, 0, Math.PI * 2);
55
- oc.fill();
56
- }
57
- });
58
- }
59
- function mulberry32(seed) {
60
- let s = seed | 0;
61
- return () => {
62
- s = s + 1831565813 | 0;
63
- let t = Math.imul(s ^ s >>> 15, 1 | s);
64
- t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
65
- return ((t ^ t >>> 14) >>> 0) / 4294967296;
66
- };
67
- }
68
- function chunks(params) {
69
- const { color, bg, size = 48, density = 0.35, chunkSize = 3, seed = 42 } = params;
70
- return createTilePattern({
71
- size,
72
- draw: (oc, s) => {
73
- if (bg !== void 0) {
74
- oc.fillStyle = bg;
75
- oc.fillRect(0, 0, s, s);
76
- }
77
- const rand = mulberry32(seed);
78
- const count = Math.round(s * s * density / (chunkSize * chunkSize));
79
- oc.fillStyle = color;
80
- for (let i = 0; i < count; i++) {
81
- const cx = rand() * s;
82
- const cy = rand() * s;
83
- const w = chunkSize * (0.5 + rand());
84
- const h = chunkSize * (0.5 + rand());
85
- const angle = rand() * Math.PI;
86
- oc.save();
87
- oc.translate(cx, cy);
88
- oc.rotate(angle);
89
- oc.beginPath();
90
- oc.ellipse(0, 0, w / 2, h / 2, 0, 0, Math.PI * 2);
91
- oc.fill();
92
- oc.restore();
93
- }
94
- }
95
- });
96
- }
97
-
98
- export { chunks, crosshatch, dots, hatch };
99
3
  //# sourceMappingURL=patterns-builtin.js.map
100
4
  //# sourceMappingURL=patterns-builtin.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/features/patterns/patterns-builtin.ts"],"names":[],"mappings":";;;;AAuBO,SAAS,MAAM,MAAA,EAA2C;AAC/D,EAAA,MAAM,EAAE,KAAA,EAAO,IAAA,GAAO,CAAA,EAAG,SAAA,GAAY,GAAE,GAAI,MAAA;AAC3C,EAAA,OAAO,iBAAA,CAAkB;AAAA,IACvB,IAAA;AAAA,IACA,IAAA,EAAM,CAAC,EAAA,EAAI,CAAA,KAAM;AACf,MAAA,EAAA,CAAG,WAAA,GAAc,KAAA;AACjB,MAAA,EAAA,CAAG,SAAA,GAAY,SAAA;AACf,MAAA,EAAA,CAAG,SAAA,EAAU;AACb,MAAA,EAAA,CAAG,MAAA,CAAO,EAAA,EAAI,CAAA,GAAI,CAAC,CAAA;AACnB,MAAA,EAAA,CAAG,MAAA,CAAO,CAAA,GAAI,CAAA,EAAG,EAAE,CAAA;AACnB,MAAA,EAAA,CAAG,MAAA,CAAO,IAAI,CAAC,CAAA;AACf,MAAA,EAAA,CAAG,MAAA,CAAO,GAAG,EAAE,CAAA;AACf,MAAA,EAAA,CAAG,MAAA,CAAO,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,CAAC,CAAA;AACtB,MAAA,EAAA,CAAG,MAAA,CAAO,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,CAAC,CAAA;AACtB,MAAA,EAAA,CAAG,MAAA,EAAO;AAAA,IACZ;AAAA,GACD,CAAA;AACH;AASO,SAAS,WAAW,MAAA,EAAgD;AACzE,EAAA,MAAM,EAAE,KAAA,EAAO,IAAA,GAAO,CAAA,EAAG,SAAA,GAAY,KAAI,GAAI,MAAA;AAC7C,EAAA,OAAO,iBAAA,CAAkB;AA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AAG,QAAA,CAAS,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA;AAAA,MACxB;AACA,MAAA,MAAM,IAAA,GAAO,WAAW,IAAI,CAAA;AAC5B,MAAA,MAAM,QAAQ,IAAA,CAAK,KAAA,CAAO,IAAI,CAAA,GAAI,OAAA,IAAY,YAAY,SAAA,CAAU,CAAA;AACpE,MAAA,EAAA,CAAG,SAAA,GAAY,KAAA;AACf,MAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,KAAA,EAAO,CAAA,EAAA,EAAK;AAC9B,QAAA,MAAM,EAAA,GAAK,MAAK,GAAI,CAAA;AACpB,QAAA,MAAM,EAAA,GAAK,MAAK,GAAI,CAAA;AACpB,QAAA,MAAM,CAAA,GAAI,SAAA,IAAa,GAAA,GAAM,IAAA,EAAK,CAAA;AAClC,QAAA,MAAM,CAAA,GAAI,SAAA,IAAa,GAAA,GAAM,IAAA,EAAK,CAAA;AAClC,QAAA,MAAM,KAAA,GAAQ,IAAA,EAAK,GAAI,IAAA,CAAK,EAAA;AAC5B,QAAA,EAAA,CAAG,IAAA,EAAK;AACR,QAAA,EAAA,CAAG,SAAA,CAAU,IAAI,EAAE,CAAA;AACnB,QAAA,EAAA,CAAG,OAAO,KAAK,CAAA;AACf,QAAA,EAAA,CAAG,SAAA,EAAU;AACb,QAAA,EAAA,CAAG,OAAA,CAAQ,CAAA,EAAG,CAAA,EAAG,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,IAAA,CAAK,EAAA,GAAK,CAAC,CAAA;AAChD,QAAA,EAAA,CAAG,IAAA,EAAK;AACR,QAAA,EAAA,CAAG,OAAA,EAAQ;AAAA,MACb;AAAA,IACF;AAAA,GACD,CAAA;AACH","file":"patterns-builtin.js","sourcesContent":["/**\n * Built-in pattern factories — generic line/dot/scatter textures. Each\n * returns a `TextureHandle` you can wrap in a `FillStyle` of\n * `{ fill: 'pattern', pattern }` and pass to anything that accepts a `FillStyle`\n * (`FillStyle`-aware layers, path fills, etc.).\n * Imported from a subpath so consumers that ship their own catalog can\n * avoid the bundle cost.\n *\n * All factories require an explicit `color` (and `bg` for `chunks`). No\n * defaults are baked in — the caller's design system is the source of truth\n * for palette decisions.\n */\n\nimport { createTilePattern } from '.';\nimport type { TextureHandle } from '../../renderer/textures/registerTexture';\n\n/** Diagonal hatch (forward slash). */\nexport interface HatchParams {\n color: string;\n size?: number;\n lineWidth?: number;\n}\n\nexport function hatch(params: HatchParams): TextureHandle | null {\n const { color, size = 5, lineWidth = 1 } = params;\n return createTilePattern({\n size,\n draw: (oc, s) => {\n oc.strokeStyle = color;\n oc.lineWidth = lineWidth;\n oc.beginPath();\n oc.moveTo(-1, s + 1);\n oc.lineTo(s + 1, -1);\n oc.moveTo(-1, 1);\n oc.lineTo(1, -1);\n oc.moveTo(s - 1, s + 1);\n oc.lineTo(s + 1, s - 1);\n oc.stroke();\n },\n });\n}\n\n/** Diagonal hatch in both directions. */\nexport interface CrosshatchParams {\n color: string;\n size?: number;\n lineWidth?: number;\n}\n\nexport function crosshatch(params: CrosshatchParams): TextureHandle | null {\n const { color, size = 6, lineWidth = 0.8 } = params;\n return createTilePattern({\n size,\n draw: (oc, s) => {\n oc.strokeStyle = color;\n oc.lineWidth = lineWidth;\n oc.beginPath();\n // Forward diagonal (with seamless tiling).\n oc.moveTo(-1, s + 1);\n oc.lineTo(s + 1, -1);\n oc.moveTo(-1, 1);\n oc.lineTo(1, -1);\n oc.moveTo(s - 1, s + 1);\n oc.lineTo(s + 1, s - 1);\n // Backward diagonal.\n oc.moveTo(-1, -1);\n oc.lineTo(s + 1, s + 1);\n oc.moveTo(s - 1, -1);\n oc.lineTo(s + 1, 1);\n oc.moveTo(-1, s - 1);\n oc.lineTo(1, s + 1);\n oc.stroke();\n },\n });\n}\n\n/** Regular grid of filled dots. */\nexport interface DotsParams {\n color: string;\n size?: number;\n radius?: number;\n}\n\nexport function dots(params: DotsParams): TextureHandle | null {\n const { color, size = 6, radius = 1 } = params;\n return createTilePattern({\n size,\n draw: (oc, s) => {\n oc.fillStyle = color;\n oc.beginPath();\n oc.arc(s / 2, s / 2, radius, 0, Math.PI * 2);\n oc.fill();\n },\n });\n}\n\n/**\n * Random scatter of small ellipses on top of a solid background. Driven by a\n * seeded PRNG so the same `seed` produces a deterministic tile.\n *\n * Note: the `bg` field is optional — omit it for a transparent background\n * (the scatter shapes draw directly onto whatever sits beneath the overlay).\n */\nexport interface ChunksParams {\n color: string;\n bg?: string;\n size?: number;\n /** Coverage: `chunks * chunkSize²` per `size²` tile. Range ~[0, 1]. */\n density?: number;\n chunkSize?: number;\n seed?: number;\n}\n\n/** Simple seeded PRNG (mulberry32) for deterministic chunk placement. */\nfunction mulberry32(seed: number): () => number {\n let s = seed | 0;\n return () => {\n s = (s + 0x6D2B79F5) | 0;\n let t = Math.imul(s ^ (s >>> 15), 1 | s);\n t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\nexport function chunks(params: ChunksParams): TextureHandle | null {\n const { color, bg, size = 48, density = 0.35, chunkSize = 3, seed = 42 } = params;\n return createTilePattern({\n size,\n draw: (oc, s) => {\n if (bg !== undefined) {\n oc.fillStyle = bg;\n oc.fillRect(0, 0, s, s);\n }\n const rand = mulberry32(seed);\n const count = Math.round((s * s * density) / (chunkSize * chunkSize));\n oc.fillStyle = color;\n for (let i = 0; i < count; i++) {\n const cx = rand() * s;\n const cy = rand() * s;\n const w = chunkSize * (0.5 + rand());\n const h = chunkSize * (0.5 + rand());\n const angle = rand() * Math.PI;\n oc.save();\n oc.translate(cx, cy);\n oc.rotate(angle);\n oc.beginPath();\n oc.ellipse(0, 0, w / 2, h / 2, 0, 0, Math.PI * 2);\n oc.fill();\n oc.restore();\n }\n },\n });\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"patterns-builtin.js"}
@@ -1,5 +1,5 @@
1
- import { c as ResizeAnchor, R as ResizePose, B as BoundsConstraint, P as PointSnapBehavior, d as PointSnapFrame, M as ModifierState } from './types-Dcaa0tPq.js';
2
- import { B as Bounds, P as PoseProjection } from './geometry-D9BDMiQi.js';
1
+ import { c as ResizeAnchor, R as ResizePose, B as BoundsConstraint, P as PointSnapBehavior, d as PointSnapFrame, M as ModifierState } from './types-BhJJ2OCM.js';
2
+ import { B as Bounds, P as PoseProjection } from './geometry-DVeZ2i-c.js';
3
3
  import { D as DebugSink } from './types-BJ8_cyT7.js';
4
4
 
5
5
  /** Corner resize-handle: world-space center plus the anchor that pins the opposite corner during resize. */