@weasel-js/core 1.7.0 → 1.7.1
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.
- package/CHANGELOG.md +764 -0
- package/README.md +7 -8
- package/dist/WeaselProvider.js +15 -0
- package/dist/WeaselProvider.js.map +1 -0
- package/dist/affordances/composeAffordanceLayer.js +224 -0
- package/dist/affordances/composeAffordanceLayer.js.map +1 -0
- package/dist/affordances/cornerResize.js +69 -0
- package/dist/affordances/cornerResize.js.map +1 -0
- package/dist/affordances/hitAffordanceRegions.js +138 -0
- package/dist/affordances/hitAffordanceRegions.js.map +1 -0
- package/dist/affordances/pathAnchors.js +66 -0
- package/dist/affordances/pathAnchors.js.map +1 -0
- package/dist/affordances/rotationHandle.js +103 -0
- package/dist/affordances/rotationHandle.js.map +1 -0
- package/dist/animation/behaviors/momentum.js +118 -0
- package/dist/animation/behaviors/momentum.js.map +1 -0
- package/dist/animation/colorHelpers.js +135 -0
- package/dist/animation/colorHelpers.js.map +1 -0
- package/dist/animation/colorRegistry.js +37 -0
- package/dist/animation/colorRegistry.js.map +1 -0
- package/dist/animation/index.js +20 -0
- package/dist/animation/loop.js +62 -0
- package/dist/animation/loop.js.map +1 -0
- package/dist/animation/observe.js +23 -0
- package/dist/animation/observe.js.map +1 -0
- package/dist/animation/poseHelpers.js +50 -0
- package/dist/animation/poseHelpers.js.map +1 -0
- package/dist/animation/reflow.js +121 -0
- package/dist/animation/reflow.js.map +1 -0
- package/dist/animation/rig/bindRig.js +74 -0
- package/dist/animation/rig/bindRig.js.map +1 -0
- package/dist/animation/rig/blendPoses.js +43 -0
- package/dist/animation/rig/blendPoses.js.map +1 -0
- package/dist/animation/rig/mirrorPose.js +19 -0
- package/dist/animation/rig/mirrorPose.js.map +1 -0
- package/dist/animation/rig/resolveSkeleton.js +33 -0
- package/dist/animation/rig/resolveSkeleton.js.map +1 -0
- package/dist/animation/rig/solveIk.js +103 -0
- package/dist/animation/rig/solveIk.js.map +1 -0
- package/dist/animation/rig/types.js +12 -0
- package/dist/animation/rig/types.js.map +1 -0
- package/dist/animation/rig/useRig.js +23 -0
- package/dist/animation/rig/useRig.js.map +1 -0
- package/dist/animation/slew.js +27 -0
- package/dist/animation/slew.js.map +1 -0
- package/dist/animation/stagger.js +138 -0
- package/dist/animation/stagger.js.map +1 -0
- package/dist/animation/timeline/booking.js +106 -0
- package/dist/animation/timeline/booking.js.map +1 -0
- package/dist/animation/timeline/createTimeline.js +116 -0
- package/dist/animation/timeline/createTimeline.js.map +1 -0
- package/dist/animation/timeline/sampleTrack.js +29 -0
- package/dist/animation/timeline/sampleTrack.js.map +1 -0
- package/dist/animation/useAnimator.js +329 -0
- package/dist/animation/useAnimator.js.map +1 -0
- package/dist/animation/wrappers/animateLifecycle.js +40 -0
- package/dist/animation/wrappers/animateLifecycle.js.map +1 -0
- package/dist/animation/wrappers/animateOnSetPose.js +44 -0
- package/dist/animation/wrappers/animateOnSetPose.js.map +1 -0
- package/dist/{autoPoseDescriptor-_XOyF7t4.d.ts → autoPoseDescriptor-BT_vp9FO.d.ts} +2 -2
- package/dist/{builtins-DLn2lCr_.d.ts → builtins-BSUfH8nU.d.ts} +738 -513
- package/dist/canvas/Canvas.js +608 -0
- package/dist/canvas/Canvas.js.map +1 -0
- package/dist/canvas/CanvasView.js +255 -0
- package/dist/canvas/CanvasView.js.map +1 -0
- package/dist/canvas/CursorCoordsHud.js +75 -0
- package/dist/canvas/CursorCoordsHud.js.map +1 -0
- package/dist/canvas/DrawCanvas.js +67 -0
- package/dist/canvas/DrawCanvas.js.map +1 -0
- package/dist/canvas/MinimapCanvas.js +139 -0
- package/dist/canvas/MinimapCanvas.js.map +1 -0
- package/dist/canvas/ModalityHud.js +66 -0
- package/dist/canvas/ModalityHud.js.map +1 -0
- package/dist/canvas/NodeShape.js +391 -0
- package/dist/canvas/NodeShape.js.map +1 -0
- package/dist/canvas/PickHud.js +93 -0
- package/dist/canvas/PickHud.js.map +1 -0
- package/dist/canvas/SceneCanvas/ActionsProviderIfRoot.js +10 -0
- package/dist/canvas/SceneCanvas/ActionsProviderIfRoot.js.map +1 -0
- package/dist/canvas/SceneCanvas/DepRegistryProviderIfRoot.js +10 -0
- package/dist/canvas/SceneCanvas/DepRegistryProviderIfRoot.js.map +1 -0
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js +51 -0
- package/dist/canvas/SceneCanvas/PointerProviderIfRoot.js.map +1 -0
- package/dist/canvas/SceneCanvas/contributionFrameHooks.js +42 -0
- package/dist/canvas/SceneCanvas/contributionFrameHooks.js.map +1 -0
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js +549 -0
- package/dist/canvas/SceneCanvas/defaultNodeProperties.js.map +1 -0
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js +26 -0
- package/dist/canvas/SceneCanvas/defaultNodeRouting.js.map +1 -0
- package/dist/canvas/SceneCanvas/dispatcherGestureBounds.js +69 -0
- package/dist/canvas/SceneCanvas/dispatcherGestureBounds.js.map +1 -0
- package/dist/canvas/SceneCanvas/features.js +97 -0
- package/dist/canvas/SceneCanvas/features.js.map +1 -0
- package/dist/canvas/SceneCanvas/poseGeometry.js +46 -0
- package/dist/canvas/SceneCanvas/poseGeometry.js.map +1 -0
- package/dist/canvas/SceneCanvas/useActionsPropResolver.js +48 -0
- package/dist/canvas/SceneCanvas/useActionsPropResolver.js.map +1 -0
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js +70 -0
- package/dist/canvas/SceneCanvas/useBuiltinShapeTools.js.map +1 -0
- package/dist/canvas/SceneCanvas/useContributionRoles.js +75 -0
- package/dist/canvas/SceneCanvas/useContributionRoles.js.map +1 -0
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js +172 -0
- package/dist/canvas/SceneCanvas/useDispatcherOverlayLayer.js.map +1 -0
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js +69 -0
- package/dist/canvas/SceneCanvas/usePreviewGhostLayer.js.map +1 -0
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js +127 -0
- package/dist/canvas/SceneCanvas/useSceneSelectTool.js.map +1 -0
- package/dist/canvas/SceneCanvas/useViewportActions.js +30 -0
- package/dist/canvas/SceneCanvas/useViewportActions.js.map +1 -0
- package/dist/canvas/SceneCanvas.js +992 -0
- package/dist/canvas/SceneCanvas.js.map +1 -0
- package/dist/canvas/SceneViewCanvas.js +54 -0
- package/dist/canvas/SceneViewCanvas.js.map +1 -0
- package/dist/canvas/accentColor.js +9 -0
- package/dist/canvas/accentColor.js.map +1 -0
- package/dist/canvas/affordanceAt.js +63 -0
- package/dist/canvas/affordanceAt.js.map +1 -0
- package/dist/canvas/buildSceneTree.js +65 -0
- package/dist/canvas/buildSceneTree.js.map +1 -0
- package/dist/canvas/canvasRenderer.js +89 -0
- package/dist/canvas/canvasRenderer.js.map +1 -0
- package/dist/canvas/colorOverrides.js +16 -0
- package/dist/canvas/colorOverrides.js.map +1 -0
- package/dist/canvas/defaultDrawOne.js +43 -0
- package/dist/canvas/defaultDrawOne.js.map +1 -0
- package/dist/canvas/deps/areaSelect.js +19 -0
- package/dist/canvas/deps/areaSelect.js.map +1 -0
- package/dist/canvas/deps/debug.js +9 -0
- package/dist/canvas/deps/debug.js.map +1 -0
- package/dist/canvas/deps/dispatcher.js +11 -0
- package/dist/canvas/deps/dispatcher.js.map +1 -0
- package/dist/canvas/deps/editAnchors.js +101 -0
- package/dist/canvas/deps/editAnchors.js.map +1 -0
- package/dist/canvas/deps/geometryProjection.js +11 -0
- package/dist/canvas/deps/geometryProjection.js.map +1 -0
- package/dist/canvas/deps/hitTestArea.js +51 -0
- package/dist/canvas/deps/hitTestArea.js.map +1 -0
- package/dist/canvas/deps/ingestion.js +31 -0
- package/dist/canvas/deps/ingestion.js.map +1 -0
- package/dist/canvas/deps/insert.js +116 -0
- package/dist/canvas/deps/insert.js.map +1 -0
- package/dist/canvas/deps/lassoSelect.js +20 -0
- package/dist/canvas/deps/lassoSelect.js.map +1 -0
- package/dist/canvas/deps/layout.js +34 -0
- package/dist/canvas/deps/layout.js.map +1 -0
- package/dist/canvas/deps/nodeAtPoint.js +19 -0
- package/dist/canvas/deps/nodeAtPoint.js.map +1 -0
- package/dist/canvas/deps/poseComposition.js +11 -0
- package/dist/canvas/deps/poseComposition.js.map +1 -0
- package/dist/canvas/deps/poseDescriptor.js +12 -0
- package/dist/canvas/deps/poseDescriptor.js.map +1 -0
- package/dist/canvas/deps/resizePolicy.js +35 -0
- package/dist/canvas/deps/resizePolicy.js.map +1 -0
- package/dist/canvas/deps/slice.js +99 -0
- package/dist/canvas/deps/slice.js.map +1 -0
- package/dist/canvas/deps/snap.js +11 -0
- package/dist/canvas/deps/snap.js.map +1 -0
- package/dist/canvas/deps/textEdit.js +21 -0
- package/dist/canvas/deps/textEdit.js.map +1 -0
- package/dist/canvas/deps/view.js +43 -0
- package/dist/canvas/deps/view.js.map +1 -0
- package/dist/canvas/derivedPath.js +47 -0
- package/dist/canvas/derivedPath.js.map +1 -0
- package/dist/canvas/drawEnvelope.js +22 -0
- package/dist/canvas/drawEnvelope.js.map +1 -0
- package/dist/canvas/getNodeAtPoint.js +18 -0
- package/dist/canvas/getNodeAtPoint.js.map +1 -0
- package/dist/canvas/hostAnchor.js +29 -0
- package/dist/canvas/hostAnchor.js.map +1 -0
- package/dist/canvas/hud.module.js +18 -0
- package/dist/canvas/hud.module.js.map +1 -0
- package/dist/canvas/insertPreviewExtent.js +103 -0
- package/dist/canvas/insertPreviewExtent.js.map +1 -0
- package/dist/canvas/kitRequirements.js +177 -0
- package/dist/canvas/kitRequirements.js.map +1 -0
- package/dist/canvas/layerOrder.js +66 -0
- package/dist/canvas/layerOrder.js.map +1 -0
- package/dist/canvas/layerSlots.js +14 -0
- package/dist/canvas/layerSlots.js.map +1 -0
- package/dist/canvas/minimapMath.js +80 -0
- package/dist/canvas/minimapMath.js.map +1 -0
- package/dist/canvas/mountedCanvases.js +20 -0
- package/dist/canvas/mountedCanvases.js.map +1 -0
- package/dist/canvas/overlayRoleStrokes.js +17 -0
- package/dist/canvas/overlayRoleStrokes.js.map +1 -0
- package/dist/canvas/paintCull.js +20 -0
- package/dist/canvas/paintCull.js.map +1 -0
- package/dist/canvas/pickWalk.js +158 -0
- package/dist/canvas/pickWalk.js.map +1 -0
- package/dist/canvas/planeClips.js +30 -0
- package/dist/canvas/planeClips.js.map +1 -0
- package/dist/canvas/poseRotation.js +35 -0
- package/dist/canvas/poseRotation.js.map +1 -0
- package/dist/canvas/rasterToPng.js +21 -0
- package/dist/canvas/rasterToPng.js.map +1 -0
- package/dist/canvas/renderDebugSnapshot.js +32 -0
- package/dist/canvas/renderDebugSnapshot.js.map +1 -0
- package/dist/canvas/renderNeeds.js +25 -0
- package/dist/canvas/renderNeeds.js.map +1 -0
- package/dist/canvas/renderSceneToPixels.js +143 -0
- package/dist/canvas/renderSceneToPixels.js.map +1 -0
- package/dist/canvas/sceneAdapter.js +270 -0
- package/dist/canvas/sceneAdapter.js.map +1 -0
- package/dist/canvas/sceneLayerPaint.js +37 -0
- package/dist/canvas/sceneLayerPaint.js.map +1 -0
- package/dist/canvas/sceneSlotWiring.js +20 -0
- package/dist/canvas/sceneSlotWiring.js.map +1 -0
- package/dist/canvas/sceneViewRender.js +72 -0
- package/dist/canvas/sceneViewRender.js.map +1 -0
- package/dist/canvas/slopsDebugLayer.js +61 -0
- package/dist/canvas/slopsDebugLayer.js.map +1 -0
- package/dist/canvas/surfaceContribution.js +15 -0
- package/dist/canvas/surfaceContribution.js.map +1 -0
- package/dist/canvas/toolPreview.js +39 -0
- package/dist/canvas/toolPreview.js.map +1 -0
- package/dist/canvas/useCanvasRenderer.js +11 -0
- package/dist/canvas/useCanvasRenderer.js.map +1 -0
- package/dist/canvas/useFrameLoop.js +60 -0
- package/dist/canvas/useFrameLoop.js.map +1 -0
- package/dist/canvas/useHostAnchor.js +71 -0
- package/dist/canvas/useHostAnchor.js.map +1 -0
- package/dist/canvas/useLateContentRedraw.js +21 -0
- package/dist/canvas/useLateContentRedraw.js.map +1 -0
- package/dist/canvas/useRedrawOn.js +21 -0
- package/dist/canvas/useRedrawOn.js.map +1 -0
- package/dist/canvas/useViewHelpers.js +120 -0
- package/dist/canvas/useViewHelpers.js.map +1 -0
- package/dist/canvas/viewInputs.js +17 -0
- package/dist/canvas/viewInputs.js.map +1 -0
- package/dist/canvas/viewRegistry.js +61 -0
- package/dist/canvas/viewRegistry.js.map +1 -0
- package/dist/canvas/wrapNodeOutput.js +14 -0
- package/dist/canvas/wrapNodeOutput.js.map +1 -0
- package/dist/clipboard.d.ts +10 -5
- package/dist/clipboard.js +3 -5
- package/dist/clone.d.ts +3 -3
- package/dist/clone.js +2 -5
- package/dist/core/adapters/arrayAdapter.js +85 -0
- package/dist/core/adapters/arrayAdapter.js.map +1 -0
- package/dist/core/adapters/useArrayAdapter.js +13 -0
- package/dist/core/adapters/useArrayAdapter.js.map +1 -0
- package/dist/core/applyOps.js +12 -0
- package/dist/core/applyOps.js.map +1 -0
- package/dist/core/device/index.js +4 -0
- package/dist/core/device/targets.js +17 -0
- package/dist/core/device/targets.js.map +1 -0
- package/dist/core/device/useDeviceProfile.js +75 -0
- package/dist/core/device/useDeviceProfile.js.map +1 -0
- package/dist/core/fillInPoseFrame.js +102 -0
- package/dist/core/fillInPoseFrame.js.map +1 -0
- package/dist/core/geometry/poseDescriptor.js +98 -0
- package/dist/core/geometry/poseDescriptor.js.map +1 -0
- package/dist/core/geometry/poseRotation.js +58 -0
- package/dist/core/geometry/poseRotation.js.map +1 -0
- package/dist/core/geometry/regionHit.js +102 -0
- package/dist/core/geometry/regionHit.js.map +1 -0
- package/dist/core/geometry/unionBounds.js +60 -0
- package/dist/core/geometry/unionBounds.js.map +1 -0
- package/dist/core/gradient.js +136 -0
- package/dist/core/gradient.js.map +1 -0
- package/dist/core/isPlainObject.js +11 -0
- package/dist/core/isPlainObject.js.map +1 -0
- package/dist/core/layers/render.js +150 -0
- package/dist/core/layers/render.js.map +1 -0
- package/dist/core/markerInset.js +24 -0
- package/dist/core/markerInset.js.map +1 -0
- package/dist/core/mixed.js +6 -0
- package/dist/core/mixed.js.map +1 -0
- package/dist/core/ops/arrange.js +31 -0
- package/dist/core/ops/arrange.js.map +1 -0
- package/dist/core/ops/create.js +32 -0
- package/dist/core/ops/create.js.map +1 -0
- package/dist/core/ops/createHistory.js +20 -0
- package/dist/core/ops/createHistory.js.map +1 -0
- package/dist/core/ops/delete.js +89 -0
- package/dist/core/ops/delete.js.map +1 -0
- package/dist/core/ops/registry.js +17 -0
- package/dist/core/ops/registry.js.map +1 -0
- package/dist/core/ops/reorder/algorithms.js +55 -0
- package/dist/core/ops/reorder/algorithms.js.map +1 -0
- package/dist/core/ops/reorder/index.js +140 -0
- package/dist/core/ops/reorder/index.js.map +1 -0
- package/dist/core/ops/reparent.js +52 -0
- package/dist/core/ops/reparent.js.map +1 -0
- package/dist/core/ops/select.js +34 -0
- package/dist/core/ops/select.js.map +1 -0
- package/dist/core/ops/setData.js +34 -0
- package/dist/core/ops/setData.js.map +1 -0
- package/dist/core/ops/setLayer.js +34 -0
- package/dist/core/ops/setLayer.js.map +1 -0
- package/dist/core/ops/setLayout.js +31 -0
- package/dist/core/ops/setLayout.js.map +1 -0
- package/dist/core/ops/setPath.js +57 -0
- package/dist/core/ops/setPath.js.map +1 -0
- package/dist/core/ops/setText.js +34 -0
- package/dist/core/ops/setText.js.map +1 -0
- package/dist/core/ops/slot.js +37 -0
- package/dist/core/ops/slot.js.map +1 -0
- package/dist/core/ops/transform.js +42 -0
- package/dist/core/ops/transform.js.map +1 -0
- package/dist/core/paintKinds.js +156 -0
- package/dist/core/paintKinds.js.map +1 -0
- package/dist/core/scene/NodeProperties.js +20 -0
- package/dist/core/scene/NodeProperties.js.map +1 -0
- package/dist/core/scene/NodeRouting.js +24 -0
- package/dist/core/scene/NodeRouting.js.map +1 -0
- package/dist/core/scene/arrivals.js +12 -0
- package/dist/core/scene/arrivals.js.map +1 -0
- package/dist/core/scene/composeFrame.js +29 -0
- package/dist/core/scene/composeFrame.js.map +1 -0
- package/dist/core/scene/depMemo.js +18 -0
- package/dist/core/scene/depMemo.js.map +1 -0
- package/dist/core/scene/dependents.js +66 -0
- package/dist/core/scene/dependents.js.map +1 -0
- package/dist/core/scene/derivedPath.js +31 -0
- package/dist/core/scene/derivedPath.js.map +1 -0
- package/dist/core/scene/effectivePose.js +78 -0
- package/dist/core/scene/effectivePose.js.map +1 -0
- package/dist/core/scene/kitRegistry.js +33 -0
- package/dist/core/scene/kitRegistry.js.map +1 -0
- package/dist/core/scene/layoutPass.js +96 -0
- package/dist/core/scene/layoutPass.js.map +1 -0
- package/dist/core/scene/nodeFnFields.js +83 -0
- package/dist/core/scene/nodeFnFields.js.map +1 -0
- package/dist/core/scene/nodeMemo.js +28 -0
- package/dist/core/scene/nodeMemo.js.map +1 -0
- package/dist/core/scene/poseFeed.js +87 -0
- package/dist/core/scene/poseFeed.js.map +1 -0
- package/dist/core/scene/poseOverrides.js +52 -0
- package/dist/core/scene/poseOverrides.js.map +1 -0
- package/dist/core/scene/poseSnapshot.js +54 -0
- package/dist/core/scene/poseSnapshot.js.map +1 -0
- package/dist/core/scene/scene.js +1271 -0
- package/dist/core/scene/scene.js.map +1 -0
- package/dist/core/scene/types.js +6 -0
- package/dist/core/scene/types.js.map +1 -0
- package/dist/core/scene/useScene.js +32 -0
- package/dist/core/scene/useScene.js.map +1 -0
- package/dist/core/selection/chromeState.js +31 -0
- package/dist/core/selection/chromeState.js.map +1 -0
- package/dist/core/selection/selectionTarget.js +6 -0
- package/dist/core/selection/selectionTarget.js.map +1 -0
- package/dist/core/selection/useSelection.js +71 -0
- package/dist/core/selection/useSelection.js.map +1 -0
- package/dist/core/shapeKinds.js +54 -0
- package/dist/core/shapeKinds.js.map +1 -0
- package/dist/core/strokeMarkerShapes.js +139 -0
- package/dist/core/strokeMarkerShapes.js.map +1 -0
- package/dist/core/strokeMarkers.js +28 -0
- package/dist/core/strokeMarkers.js.map +1 -0
- package/dist/core/stylus/stylus.js +39 -0
- package/dist/core/stylus/stylus.js.map +1 -0
- package/dist/core/stylus/usePointerStylus.js +51 -0
- package/dist/core/stylus/usePointerStylus.js.map +1 -0
- package/dist/core/usePaintKinds.js +17 -0
- package/dist/core/usePaintKinds.js.map +1 -0
- package/dist/core/viewport/clampView.js +24 -0
- package/dist/core/viewport/clampView.js.map +1 -0
- package/dist/core/viewport/clientToWorld.js +8 -0
- package/dist/core/viewport/clientToWorld.js.map +1 -0
- package/dist/core/viewport/createVelocityTracker.js +39 -0
- package/dist/core/viewport/createVelocityTracker.js.map +1 -0
- package/dist/core/viewport/fitToBounds.js +18 -0
- package/dist/core/viewport/fitToBounds.js.map +1 -0
- package/dist/core/viewport/fitViewToBounds.js +36 -0
- package/dist/core/viewport/fitViewToBounds.js.map +1 -0
- package/dist/core/viewport/interpolateView.js +34 -0
- package/dist/core/viewport/interpolateView.js.map +1 -0
- package/dist/core/viewport/meanScale.js +8 -0
- package/dist/core/viewport/meanScale.js.map +1 -0
- package/dist/core/viewport/parallax.js +111 -0
- package/dist/core/viewport/parallax.js.map +1 -0
- package/dist/core/viewport/pxExtent.js +42 -0
- package/dist/core/viewport/pxExtent.js.map +1 -0
- package/dist/core/viewport/sceneNodeClientRect.js +18 -0
- package/dist/core/viewport/sceneNodeClientRect.js.map +1 -0
- package/dist/core/viewport/screenSlop.js +27 -0
- package/dist/core/viewport/screenSlop.js.map +1 -0
- package/dist/core/viewport/useAutoCenter.js +32 -0
- package/dist/core/viewport/useAutoCenter.js.map +1 -0
- package/dist/core/viewport/useCanvasSize.js +29 -0
- package/dist/core/viewport/useCanvasSize.js.map +1 -0
- package/dist/core/viewport/useDecayLoop.js +63 -0
- package/dist/core/viewport/useDecayLoop.js.map +1 -0
- package/dist/core/viewport/useVelocityTracker.js +10 -0
- package/dist/core/viewport/useVelocityTracker.js.map +1 -0
- package/dist/core/viewport/useViewAnimation.js +63 -0
- package/dist/core/viewport/useViewAnimation.js.map +1 -0
- package/dist/core/viewport/view.js +37 -0
- package/dist/core/viewport/view.js.map +1 -0
- package/dist/core/viewport/viewTransform.js +11 -0
- package/dist/core/viewport/viewTransform.js.map +1 -0
- package/dist/core/viewport/viewportWorldRect.js +13 -0
- package/dist/core/viewport/viewportWorldRect.js.map +1 -0
- package/dist/core/viewport/wheelHandler.js +30 -0
- package/dist/core/viewport/wheelHandler.js.map +1 -0
- package/dist/core/viewport/zoomAt.js +22 -0
- package/dist/core/viewport/zoomAt.js.map +1 -0
- package/dist/core/viewport/zoomBounds.js +20 -0
- package/dist/core/viewport/zoomBounds.js.map +1 -0
- package/dist/{pointSnapToGrid-Dp2IxLGb.d.ts → cornerHandles-CDcZOV8h.d.ts} +3 -13
- package/dist/debug/createDebugOverlayLayer.js +358 -0
- package/dist/debug/createDebugOverlayLayer.js.map +1 -0
- package/dist/debug/createDebugSink.js +83 -0
- package/dist/debug/createDebugSink.js.map +1 -0
- package/dist/debug/defaultTheme.js +31 -0
- package/dist/debug/defaultTheme.js.map +1 -0
- package/dist/debug/flag.js +41 -0
- package/dist/debug/flag.js.map +1 -0
- package/dist/debug/frameStats.js +16 -0
- package/dist/debug/frameStats.js.map +1 -0
- package/dist/debug/parseDebugFlags.js +32 -0
- package/dist/debug/parseDebugFlags.js.map +1 -0
- package/dist/features/chrome-caps/buildChromeCtx.js +16 -0
- package/dist/features/chrome-caps/buildChromeCtx.js.map +1 -0
- package/dist/features/chrome-caps/conditions.js +36 -0
- package/dist/features/chrome-caps/conditions.js.map +1 -0
- package/dist/features/chrome-caps/defaults.js +26 -0
- package/dist/features/chrome-caps/defaults.js.map +1 -0
- package/dist/features/chrome-caps/index.js +7 -0
- package/dist/features/chrome-caps/resolve.js +23 -0
- package/dist/features/chrome-caps/resolve.js.map +1 -0
- package/dist/features/chrome-caps/useHoverTracking.js +27 -0
- package/dist/features/chrome-caps/useHoverTracking.js.map +1 -0
- package/dist/features/cursor/paintedCursorLayer.js +60 -0
- package/dist/features/cursor/paintedCursorLayer.js.map +1 -0
- package/dist/features/focus/gateLayer.js +14 -0
- package/dist/features/focus/gateLayer.js.map +1 -0
- package/dist/features/focus/useCanvasFocus.js +29 -0
- package/dist/features/focus/useCanvasFocus.js.map +1 -0
- package/dist/features/groups/children.js +23 -0
- package/dist/features/groups/children.js.map +1 -0
- package/dist/features/groups/composePose.js +67 -0
- package/dist/features/groups/composePose.js.map +1 -0
- package/dist/features/groups/nestedHit.js +40 -0
- package/dist/features/groups/nestedHit.js.map +1 -0
- package/dist/features/groups/unionOfChildren.js +15 -0
- package/dist/features/groups/unionOfChildren.js.map +1 -0
- package/dist/features/images/imageCache.js +94 -0
- package/dist/features/images/imageCache.js.map +1 -0
- package/dist/features/ingestion/contentHandlers.js +37 -0
- package/dist/features/ingestion/contentHandlers.js.map +1 -0
- package/dist/features/ingestion/imageHandler.js +45 -0
- package/dist/features/ingestion/imageHandler.js.map +1 -0
- package/dist/features/ingestion/index.js +8 -0
- package/dist/features/ingestion/openFilePicker.js +15 -0
- package/dist/features/ingestion/openFilePicker.js.map +1 -0
- package/dist/features/ingestion/registerKitHandlers.js +26 -0
- package/dist/features/ingestion/registerKitHandlers.js.map +1 -0
- package/dist/features/ingestion/svgHandler.js +58 -0
- package/dist/features/ingestion/svgHandler.js.map +1 -0
- package/dist/features/ingestion/weaselJsonHandler.js +39 -0
- package/dist/features/ingestion/weaselJsonHandler.js.map +1 -0
- package/dist/features/longPress/longPressFeedback.js +96 -0
- package/dist/features/longPress/longPressFeedback.js.map +1 -0
- package/dist/features/meshPaint/bake.js +79 -0
- package/dist/features/meshPaint/bake.js.map +1 -0
- package/dist/features/meshPaint/bakeCache.js +59 -0
- package/dist/features/meshPaint/bakeCache.js.map +1 -0
- package/dist/features/meshPaint/handles.js +86 -0
- package/dist/features/meshPaint/handles.js.map +1 -0
- package/dist/features/meshPaint/lazyKind.js +1298 -0
- package/dist/features/meshPaint/lazyKind.js.map +1 -0
- package/dist/features/meshPaint/meshPaint.js +236 -0
- package/dist/features/meshPaint/meshPaint.js.map +1 -0
- package/dist/features/meshPaint/meshShader.js +6 -0
- package/dist/features/meshPaint/meshShader.js.map +1 -0
- package/dist/features/meshPaint/register.js +7 -0
- package/dist/features/meshPaint/register.js.map +1 -0
- package/dist/features/meshPaint/surface.js +110 -0
- package/dist/features/meshPaint/surface.js.map +1 -0
- package/dist/features/minimap/actions.js +53 -0
- package/dist/features/minimap/actions.js.map +1 -0
- package/dist/features/minimap/createMinimapContribution.js +96 -0
- package/dist/features/minimap/createMinimapContribution.js.map +1 -0
- package/dist/features/minimap/layers.js +103 -0
- package/dist/features/minimap/layers.js.map +1 -0
- package/dist/features/modes/modeLayers.js +113 -0
- package/dist/features/modes/modeLayers.js.map +1 -0
- package/dist/features/overlays/useNodeOverlayFrame.js +103 -0
- package/dist/features/overlays/useNodeOverlayFrame.js.map +1 -0
- package/dist/features/parallax/createParallaxLayer.js +26 -0
- package/dist/features/parallax/createParallaxLayer.js.map +1 -0
- package/dist/features/parallax/createParallaxPlane.js +26 -0
- package/dist/features/parallax/createParallaxPlane.js.map +1 -0
- package/dist/features/paths/anchorEdits.js +156 -0
- package/dist/features/paths/anchorEdits.js.map +1 -0
- package/dist/features/paths/anchors.js +154 -0
- package/dist/features/paths/anchors.js.map +1 -0
- package/dist/features/paths/booleans.js +2 -0
- package/dist/features/paths/index.js +15 -0
- package/dist/features/paths/markerCommands.js +116 -0
- package/dist/features/paths/markerCommands.js.map +1 -0
- package/dist/features/paths/markerSites.js +59 -0
- package/dist/features/paths/markerSites.js.map +1 -0
- package/dist/features/paths/markers.js +95 -0
- package/dist/features/paths/markers.js.map +1 -0
- package/dist/features/paths/nearestAnchor.js +36 -0
- package/dist/features/paths/nearestAnchor.js.map +1 -0
- package/dist/features/paths/originProjection.js +16 -0
- package/dist/features/paths/originProjection.js.map +1 -0
- package/dist/features/paths/pathEditingOverlayLayer.js +137 -0
- package/dist/features/paths/pathEditingOverlayLayer.js.map +1 -0
- package/dist/features/paths/pathInWorld.js +41 -0
- package/dist/features/paths/pathInWorld.js.map +1 -0
- package/dist/features/paths/pathLayer.js +44 -0
- package/dist/features/paths/pathLayer.js.map +1 -0
- package/dist/features/paths/penPreviewLayer.js +220 -0
- package/dist/features/paths/penPreviewLayer.js.map +1 -0
- package/dist/features/paths/poseDescriptor.js +44 -0
- package/dist/features/paths/poseDescriptor.js.map +1 -0
- package/dist/features/paths/tessellate/stroke.js +230 -0
- package/dist/features/paths/tessellate/stroke.js.map +1 -0
- package/dist/features/patterns/index.js +23 -0
- package/dist/features/patterns/index.js.map +1 -0
- package/dist/features/patterns/patterns-builtin.js +38 -0
- package/dist/features/patterns/patterns-builtin.js.map +1 -0
- package/dist/features/patterns/resolveSpec.js +57 -0
- package/dist/features/patterns/resolveSpec.js.map +1 -0
- package/dist/features/patterns/tileGeometry.js +158 -0
- package/dist/features/patterns/tileGeometry.js.map +1 -0
- package/dist/features/pointer/PointerContext.js +45 -0
- package/dist/features/pointer/PointerContext.js.map +1 -0
- package/dist/features/poseRun/usePoseRun.js +70 -0
- package/dist/features/poseRun/usePoseRun.js.map +1 -0
- package/dist/features/selection/SelectionContext.js +46 -0
- package/dist/features/selection/SelectionContext.js.map +1 -0
- package/dist/features/selection/overlay.js +442 -0
- package/dist/features/selection/overlay.js.map +1 -0
- package/dist/features/simulation/createSimulation.js +61 -0
- package/dist/features/simulation/createSimulation.js.map +1 -0
- package/dist/features/simulation/types.js +6 -0
- package/dist/features/simulation/types.js.map +1 -0
- package/dist/features/simulation/useSimulation.js +74 -0
- package/dist/features/simulation/useSimulation.js.map +1 -0
- package/dist/features/text/domRuns.js +258 -0
- package/dist/features/text/domRuns.js.map +1 -0
- package/dist/features/text/fitTextPose.js +38 -0
- package/dist/features/text/fitTextPose.js.map +1 -0
- package/dist/features/text/hitTest.js +45 -0
- package/dist/features/text/hitTest.js.map +1 -0
- package/dist/features/text/renderLabel.js +14 -0
- package/dist/features/text/renderLabel.js.map +1 -0
- package/dist/features/text/runs/effectiveRangeStyle.js +66 -0
- package/dist/features/text/runs/effectiveRangeStyle.js.map +1 -0
- package/dist/features/text/runs/flagRange.js +53 -0
- package/dist/features/text/runs/flagRange.js.map +1 -0
- package/dist/features/text/runs/rangeStyle.js +135 -0
- package/dist/features/text/runs/rangeStyle.js.map +1 -0
- package/dist/features/text/textCommand.js +59 -0
- package/dist/features/text/textCommand.js.map +1 -0
- package/dist/features/text/textLayer.js +35 -0
- package/dist/features/text/textLayer.js.map +1 -0
- package/dist/features/text/textToPath.js +181 -0
- package/dist/features/text/textToPath.js.map +1 -0
- package/dist/features/text/useSceneTextEdit.js +138 -0
- package/dist/features/text/useSceneTextEdit.js.map +1 -0
- package/dist/features/text/useTextEdit.js +465 -0
- package/dist/features/text/useTextEdit.js.map +1 -0
- package/dist/features/tiling/createTiledLayer.js +63 -0
- package/dist/features/tiling/createTiledLayer.js.map +1 -0
- package/dist/features/tiling/tiledProject.js +14 -0
- package/dist/features/tiling/tiledProject.js.map +1 -0
- package/dist/features/viewports/viewResolver.js +59 -0
- package/dist/features/viewports/viewResolver.js.map +1 -0
- package/dist/features/viewports/viewportLayer.js +58 -0
- package/dist/features/viewports/viewportLayer.js.map +1 -0
- package/dist/icons/ArrowIcon.js +23 -0
- package/dist/icons/ArrowIcon.js.map +1 -0
- package/dist/icons/EllipseIcon.js +21 -0
- package/dist/icons/EllipseIcon.js.map +1 -0
- package/dist/icons/EyedropperIcon.js +49 -0
- package/dist/icons/EyedropperIcon.js.map +1 -0
- package/dist/icons/HandIcon.js +59 -0
- package/dist/icons/HandIcon.js.map +1 -0
- package/dist/icons/ImageIcon.js +34 -0
- package/dist/icons/ImageIcon.js.map +1 -0
- package/dist/icons/LassoIcon.js +22 -0
- package/dist/icons/LassoIcon.js.map +1 -0
- package/dist/icons/LineIcon.js +22 -0
- package/dist/icons/LineIcon.js.map +1 -0
- package/dist/icons/PenIcon.js +36 -0
- package/dist/icons/PenIcon.js.map +1 -0
- package/dist/icons/PencilIcon.js +25 -0
- package/dist/icons/PencilIcon.js.map +1 -0
- package/dist/icons/PolygonIcon.js +19 -0
- package/dist/icons/PolygonIcon.js.map +1 -0
- package/dist/icons/RectIcon.js +37 -0
- package/dist/icons/RectIcon.js.map +1 -0
- package/dist/icons/SelectIcon.js +20 -0
- package/dist/icons/SelectIcon.js.map +1 -0
- package/dist/icons/StarIcon.js +19 -0
- package/dist/icons/StarIcon.js.map +1 -0
- package/dist/icons/TextIcon.js +19 -0
- package/dist/icons/TextIcon.js.map +1 -0
- package/dist/icons/UnknownIcon.js +33 -0
- package/dist/icons/UnknownIcon.js.map +1 -0
- package/dist/icons/_base.js +12 -0
- package/dist/icons/_base.js.map +1 -0
- package/dist/index.css +2 -62
- package/dist/index.d.ts +1955 -1891
- package/dist/index.js +312 -13
- package/dist/input/keyState.js +76 -0
- package/dist/input/keyState.js.map +1 -0
- package/dist/input/useKeyState.js +22 -0
- package/dist/input/useKeyState.js.map +1 -0
- package/dist/interactions/actions/actionShortcuts.js +32 -0
- package/dist/interactions/actions/actionShortcuts.js.map +1 -0
- package/dist/interactions/actions/align/align.js +81 -0
- package/dist/interactions/actions/align/align.js.map +1 -0
- package/dist/interactions/actions/booleans/booleans.js +120 -0
- package/dist/interactions/actions/booleans/booleans.js.map +1 -0
- package/dist/interactions/actions/booleans/useBooleans.js +20 -0
- package/dist/interactions/actions/booleans/useBooleans.js.map +1 -0
- package/dist/interactions/actions/booleans/useBooleansAdapter.js +9 -0
- package/dist/interactions/actions/booleans/useBooleansAdapter.js.map +1 -0
- package/dist/interactions/actions/clipboard/clipboardOps.js +94 -0
- package/dist/interactions/actions/clipboard/clipboardOps.js.map +1 -0
- package/dist/interactions/actions/clipboard/materializePaste.js +25 -0
- package/dist/interactions/actions/clipboard/materializePaste.js.map +1 -0
- package/dist/interactions/actions/clipboard/wireFormat.js +43 -0
- package/dist/interactions/actions/clipboard/wireFormat.js.map +1 -0
- package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js +26 -0
- package/dist/interactions/actions/clone/behaviors/cloneByAltDrag.js.map +1 -0
- package/dist/interactions/actions/defaultCommitAdapter.js +42 -0
- package/dist/interactions/actions/defaultCommitAdapter.js.map +1 -0
- package/dist/interactions/actions/defaults/align.js +71 -0
- package/dist/interactions/actions/defaults/align.js.map +1 -0
- package/dist/interactions/actions/defaults/anchorEditing.js +235 -0
- package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -0
- package/dist/interactions/actions/defaults/areaSelect.js +75 -0
- package/dist/interactions/actions/defaults/areaSelect.js.map +1 -0
- package/dist/interactions/actions/defaults/booleans.js +52 -0
- package/dist/interactions/actions/defaults/booleans.js.map +1 -0
- package/dist/interactions/actions/defaults/cancelGesture.js +24 -0
- package/dist/interactions/actions/defaults/cancelGesture.js.map +1 -0
- package/dist/interactions/actions/defaults/clearSelection.js +19 -0
- package/dist/interactions/actions/defaults/clearSelection.js.map +1 -0
- package/dist/interactions/actions/defaults/clipboard.js +78 -0
- package/dist/interactions/actions/defaults/clipboard.js.map +1 -0
- package/dist/interactions/actions/defaults/clone.js +96 -0
- package/dist/interactions/actions/defaults/clone.js.map +1 -0
- package/dist/interactions/actions/defaults/createOutlines.js +47 -0
- package/dist/interactions/actions/defaults/createOutlines.js.map +1 -0
- package/dist/interactions/actions/defaults/createPaintAction.js +85 -0
- package/dist/interactions/actions/defaults/createPaintAction.js.map +1 -0
- package/dist/interactions/actions/defaults/delete.js +61 -0
- package/dist/interactions/actions/defaults/delete.js.map +1 -0
- package/dist/interactions/actions/defaults/distribute.js +66 -0
- package/dist/interactions/actions/defaults/distribute.js.map +1 -0
- package/dist/interactions/actions/defaults/duplicate.js +83 -0
- package/dist/interactions/actions/defaults/duplicate.js.map +1 -0
- package/dist/interactions/actions/defaults/editAnchors.js +100 -0
- package/dist/interactions/actions/defaults/editAnchors.js.map +1 -0
- package/dist/interactions/actions/defaults/enterPathEdit.js +29 -0
- package/dist/interactions/actions/defaults/enterPathEdit.js.map +1 -0
- package/dist/interactions/actions/defaults/enterTextEdit.js +20 -0
- package/dist/interactions/actions/defaults/enterTextEdit.js.map +1 -0
- package/dist/interactions/actions/defaults/escape.js +26 -0
- package/dist/interactions/actions/defaults/escape.js.map +1 -0
- package/dist/interactions/actions/defaults/exitPathEdit.js +22 -0
- package/dist/interactions/actions/defaults/exitPathEdit.js.map +1 -0
- package/dist/interactions/actions/defaults/flip.js +119 -0
- package/dist/interactions/actions/defaults/flip.js.map +1 -0
- package/dist/interactions/actions/defaults/freshNodeId.js +10 -0
- package/dist/interactions/actions/defaults/freshNodeId.js.map +1 -0
- package/dist/interactions/actions/defaults/group.js +131 -0
- package/dist/interactions/actions/defaults/group.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphIcons.js +40 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphs.js +10 -0
- package/dist/interactions/actions/defaults/icons/actionGlyphs.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/alignIcons.js +173 -0
- package/dist/interactions/actions/defaults/icons/alignIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/booleanIcons.js +171 -0
- package/dist/interactions/actions/defaults/icons/booleanIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/distributeIcons.js +63 -0
- package/dist/interactions/actions/defaults/icons/distributeIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/editIcons.js +280 -0
- package/dist/interactions/actions/defaults/icons/editIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/icons/outlineIcons.js +53 -0
- package/dist/interactions/actions/defaults/icons/outlineIcons.js.map +1 -0
- package/dist/interactions/actions/defaults/ingest.js +58 -0
- package/dist/interactions/actions/defaults/ingest.js.map +1 -0
- package/dist/interactions/actions/defaults/insert.js +288 -0
- package/dist/interactions/actions/defaults/insert.js.map +1 -0
- package/dist/interactions/actions/defaults/insertPathAnchor.js +50 -0
- package/dist/interactions/actions/defaults/insertPathAnchor.js.map +1 -0
- package/dist/interactions/actions/defaults/lassoSelect.js +156 -0
- package/dist/interactions/actions/defaults/lassoSelect.js.map +1 -0
- package/dist/interactions/actions/defaults/move.js +656 -0
- package/dist/interactions/actions/defaults/move.js.map +1 -0
- package/dist/interactions/actions/defaults/nudge.js +110 -0
- package/dist/interactions/actions/defaults/nudge.js.map +1 -0
- package/dist/interactions/actions/defaults/pinchZoom.js +63 -0
- package/dist/interactions/actions/defaults/pinchZoom.js.map +1 -0
- package/dist/interactions/actions/defaults/reorder.js +143 -0
- package/dist/interactions/actions/defaults/reorder.js.map +1 -0
- package/dist/interactions/actions/defaults/requiresSelection.js +10 -0
- package/dist/interactions/actions/defaults/requiresSelection.js.map +1 -0
- package/dist/interactions/actions/defaults/resize.js +332 -0
- package/dist/interactions/actions/defaults/resize.js.map +1 -0
- package/dist/interactions/actions/defaults/rotate.js +181 -0
- package/dist/interactions/actions/defaults/rotate.js.map +1 -0
- package/dist/interactions/actions/defaults/selectAll.js +27 -0
- package/dist/interactions/actions/defaults/selectAll.js.map +1 -0
- package/dist/interactions/actions/defaults/setFill.js +27 -0
- package/dist/interactions/actions/defaults/setFill.js.map +1 -0
- package/dist/interactions/actions/defaults/setFillOpacity.js +15 -0
- package/dist/interactions/actions/defaults/setFillOpacity.js.map +1 -0
- package/dist/interactions/actions/defaults/setStroke.js +36 -0
- package/dist/interactions/actions/defaults/setStroke.js.map +1 -0
- package/dist/interactions/actions/defaults/setStrokeOpacity.js +21 -0
- package/dist/interactions/actions/defaults/setStrokeOpacity.js.map +1 -0
- package/dist/interactions/actions/defaults/slice.js +39 -0
- package/dist/interactions/actions/defaults/slice.js.map +1 -0
- package/dist/interactions/actions/defaults/sliceOps.js +60 -0
- package/dist/interactions/actions/defaults/sliceOps.js.map +1 -0
- package/dist/interactions/actions/defaults/toolActivate.js +35 -0
- package/dist/interactions/actions/defaults/toolActivate.js.map +1 -0
- package/dist/interactions/actions/defaults/toolResetToDefault.js +26 -0
- package/dist/interactions/actions/defaults/toolResetToDefault.js.map +1 -0
- package/dist/interactions/actions/defaults/undoRedo.js +51 -0
- package/dist/interactions/actions/defaults/undoRedo.js.map +1 -0
- package/dist/interactions/actions/defaults/viewportDragPan.js +88 -0
- package/dist/interactions/actions/defaults/viewportDragPan.js.map +1 -0
- package/dist/interactions/actions/defaults/viewportWheelPan.js +57 -0
- package/dist/interactions/actions/defaults/viewportWheelPan.js.map +1 -0
- package/dist/interactions/actions/defaults/viewportZoom.js +143 -0
- package/dist/interactions/actions/defaults/viewportZoom.js.map +1 -0
- package/dist/interactions/actions/distribute/distribute.js +42 -0
- package/dist/interactions/actions/distribute/distribute.js.map +1 -0
- package/dist/interactions/actions/distribute/plan.js +29 -0
- package/dist/interactions/actions/distribute/plan.js.map +1 -0
- package/dist/interactions/actions/edit-anchors/geometry.js +61 -0
- package/dist/interactions/actions/edit-anchors/geometry.js.map +1 -0
- package/dist/interactions/actions/edit-anchors/handles.js +43 -0
- package/dist/interactions/actions/edit-anchors/handles.js.map +1 -0
- package/dist/interactions/actions/flip/helpers.js +35 -0
- package/dist/interactions/actions/flip/helpers.js.map +1 -0
- package/dist/interactions/actions/geometryProjection.js +18 -0
- package/dist/interactions/actions/geometryProjection.js.map +1 -0
- package/dist/interactions/actions/gestureLifecycle.js +44 -0
- package/dist/interactions/actions/gestureLifecycle.js.map +1 -0
- package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js +39 -0
- package/dist/interactions/actions/lasso-select/behaviors/selectFromLasso.js.map +1 -0
- package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js +36 -0
- package/dist/interactions/actions/move/behaviors/snapBackOrDelete.js.map +1 -0
- package/dist/interactions/actions/move/behaviors/snapToContainer.js +67 -0
- package/dist/interactions/actions/move/behaviors/snapToContainer.js.map +1 -0
- package/dist/interactions/actions/move/gestureAdapter.js +37 -0
- package/dist/interactions/actions/move/gestureAdapter.js.map +1 -0
- package/dist/interactions/actions/outlines/createOutlines.js +84 -0
- package/dist/interactions/actions/outlines/createOutlines.js.map +1 -0
- package/dist/interactions/actions/outlines/useCreateOutlinesAdapter.js +9 -0
- package/dist/interactions/actions/outlines/useCreateOutlinesAdapter.js.map +1 -0
- package/dist/interactions/actions/planeInput.js +168 -0
- package/dist/interactions/actions/planeInput.js.map +1 -0
- package/dist/interactions/actions/poseDescriptorDep.js +9 -0
- package/dist/interactions/actions/poseDescriptorDep.js.map +1 -0
- package/dist/interactions/actions/poseFrame.js +38 -0
- package/dist/interactions/actions/poseFrame.js.map +1 -0
- package/dist/interactions/actions/previewOverrides.js +25 -0
- package/dist/interactions/actions/previewOverrides.js.map +1 -0
- package/dist/interactions/actions/resize/autoPoseDescriptor.js +32 -0
- package/dist/interactions/actions/resize/autoPoseDescriptor.js.map +1 -0
- package/dist/interactions/actions/resize/behaviors/clampMinSize.js +18 -0
- package/dist/interactions/actions/resize/behaviors/clampMinSize.js.map +1 -0
- package/dist/interactions/actions/resize/behaviors/index.js +8 -0
- package/dist/interactions/actions/resize/behaviors/index.js.map +1 -0
- package/dist/interactions/actions/resize/behaviors/lockAspect.js +24 -0
- package/dist/interactions/actions/resize/behaviors/lockAspect.js.map +1 -0
- package/dist/interactions/actions/resize/cornerHandles.js +72 -0
- package/dist/interactions/actions/resize/cornerHandles.js.map +1 -0
- package/dist/interactions/actions/resolveOverlays.js +60 -0
- package/dist/interactions/actions/resolveOverlays.js.map +1 -0
- package/dist/interactions/actions/resolvePreviews.js +61 -0
- package/dist/interactions/actions/resolvePreviews.js.map +1 -0
- package/dist/interactions/actions/rotate/geometry.js +46 -0
- package/dist/interactions/actions/rotate/geometry.js.map +1 -0
- package/dist/interactions/actions/rotate/handle.js +27 -0
- package/dist/interactions/actions/rotate/handle.js.map +1 -0
- package/dist/interactions/actions/spatialReference.js +42 -0
- package/dist/interactions/actions/spatialReference.js.map +1 -0
- package/dist/interactions/actions/useStandardActions.js +142 -0
- package/dist/interactions/actions/useStandardActions.js.map +1 -0
- package/dist/interactions/gestures/dragGesture/dragGesture.js +111 -0
- package/dist/interactions/gestures/dragGesture/dragGesture.js.map +1 -0
- package/dist/interactions/gestures/dragRadial/dragRadial.js +117 -0
- package/dist/interactions/gestures/dragRadial/dragRadial.js.map +1 -0
- package/dist/interactions/gestures/dragRect/dragRect.js +164 -0
- package/dist/interactions/gestures/dragRect/dragRect.js.map +1 -0
- package/dist/interactions/gestures/handleDrag/handleDrag.js +46 -0
- package/dist/interactions/gestures/handleDrag/handleDrag.js.map +1 -0
- package/dist/interactions/gestures/pointerDrag/pointerDrag.js +118 -0
- package/dist/interactions/gestures/pointerDrag/pointerDrag.js.map +1 -0
- package/dist/interactions/gestures/shared/originProjection.js +42 -0
- package/dist/interactions/gestures/shared/originProjection.js.map +1 -0
- package/dist/interactions/gestures/shared/screenTolerance.js +21 -0
- package/dist/interactions/gestures/shared/screenTolerance.js.map +1 -0
- package/dist/interactions/gestures/shared/snap.js +24 -0
- package/dist/interactions/gestures/shared/snap.js.map +1 -0
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js +30 -0
- package/dist/interactions/gestures/thresholdDrag/thresholdDrag.js.map +1 -0
- package/dist/layout/arrivals.js +36 -0
- package/dist/layout/arrivals.js.map +1 -0
- package/dist/{math-MCQcf_gc.d.ts → math-CUMxmZzn.d.ts} +8 -116
- package/dist/math.d.ts +4 -5
- package/dist/math.js +6 -4
- package/dist/mesh.d.ts +268 -0
- package/dist/mesh.js +7 -0
- package/dist/move.d.ts +7 -49
- package/dist/move.js +3 -142
- package/dist/originProjection-BSn4xiEy.d.ts +57 -0
- package/dist/patterns-builtin.js +3 -3
- package/dist/{poseDescriptor-rZa9W5hJ.d.ts → poseDescriptor-CjSXMf8X.d.ts} +3 -3
- package/dist/registerProgram-ateHDGjw.d.ts +193 -0
- package/dist/renderer/DrawCommand.js +6 -0
- package/dist/renderer/DrawCommand.js.map +1 -0
- package/dist/renderer/WeaselRenderer.js +328 -0
- package/dist/renderer/WeaselRenderer.js.map +1 -0
- package/dist/renderer/cache/GLImageCache.js +64 -0
- package/dist/renderer/cache/GLImageCache.js.map +1 -0
- package/dist/renderer/cache/GLMeshCache.js +102 -0
- package/dist/renderer/cache/GLMeshCache.js.map +1 -0
- package/dist/renderer/cache/GLTextureCache.js +51 -0
- package/dist/renderer/cache/GLTextureCache.js.map +1 -0
- package/dist/renderer/cache/GradientRampAtlas.js +82 -0
- package/dist/renderer/cache/GradientRampAtlas.js.map +1 -0
- package/dist/renderer/cache/cache.js +13 -0
- package/dist/renderer/cache/cache.js.map +1 -0
- package/dist/renderer/cache/markerCommandCache.js +59 -0
- package/dist/renderer/cache/markerCommandCache.js.map +1 -0
- package/dist/renderer/cache/outlineMeshCache.js +15 -0
- package/dist/renderer/cache/outlineMeshCache.js.map +1 -0
- package/dist/renderer/cache/outlineStrokeMeshCache.js +31 -0
- package/dist/renderer/cache/outlineStrokeMeshCache.js.map +1 -0
- package/dist/renderer/cache/strokeMeshCache.js +44 -0
- package/dist/renderer/cache/strokeMeshCache.js.map +1 -0
- package/dist/renderer/cullDrawCommands.js +89 -0
- package/dist/renderer/cullDrawCommands.js.map +1 -0
- package/dist/renderer/draw.js +1109 -0
- package/dist/renderer/draw.js.map +1 -0
- package/dist/renderer/drawBatch.js +168 -0
- package/dist/renderer/drawBatch.js.map +1 -0
- package/dist/renderer/effects/EffectTargets.js +45 -0
- package/dist/renderer/effects/EffectTargets.js.map +1 -0
- package/dist/renderer/effects/builtins.js +31 -0
- package/dist/renderer/effects/builtins.js.map +1 -0
- package/dist/renderer/effects/composite.js +9 -0
- package/dist/renderer/effects/composite.js.map +1 -0
- package/dist/renderer/effects/effectPrelude.js +10 -0
- package/dist/renderer/effects/effectPrelude.js.map +1 -0
- package/dist/renderer/effects/types.js +10 -0
- package/dist/renderer/effects/types.js.map +1 -0
- package/dist/renderer/index.js +19 -0
- package/dist/renderer/math/color.js +341 -0
- package/dist/renderer/math/color.js.map +1 -0
- package/dist/renderer/math/mat3.js +71 -0
- package/dist/renderer/math/mat3.js.map +1 -0
- package/dist/renderer/math/patternSpace.js +22 -0
- package/dist/renderer/math/patternSpace.js.map +1 -0
- package/dist/renderer/math/viewToMat3.js +19 -0
- package/dist/renderer/math/viewToMat3.js.map +1 -0
- package/dist/renderer/paintResources.js +18 -0
- package/dist/renderer/paintResources.js.map +1 -0
- package/dist/renderer/paintScratch.js +37 -0
- package/dist/renderer/paintScratch.js.map +1 -0
- package/dist/renderer/shaders/ShaderProgram.js +74 -0
- package/dist/renderer/shaders/ShaderProgram.js.map +1 -0
- package/dist/renderer/shaders/batchFill.js +118 -0
- package/dist/renderer/shaders/batchFill.js.map +1 -0
- package/dist/renderer/shaders/customPrelude.js +34 -0
- package/dist/renderer/shaders/customPrelude.js.map +1 -0
- package/dist/renderer/shaders/extractUniformNames.js +184 -0
- package/dist/renderer/shaders/extractUniformNames.js.map +1 -0
- package/dist/renderer/shaders/glyphPaint.js +61 -0
- package/dist/renderer/shaders/glyphPaint.js.map +1 -0
- package/dist/renderer/shaders/gradFill.js +30 -0
- package/dist/renderer/shaders/gradFill.js.map +1 -0
- package/dist/renderer/shaders/imageFill.js +14 -0
- package/dist/renderer/shaders/imageFill.js.map +1 -0
- package/dist/renderer/shaders/pathFill.js +13 -0
- package/dist/renderer/shaders/pathFill.js.map +1 -0
- package/dist/renderer/shaders/patternFill.js +24 -0
- package/dist/renderer/shaders/patternFill.js.map +1 -0
- package/dist/renderer/shaders/registerProgram.js +18 -0
- package/dist/renderer/shaders/registerProgram.js.map +1 -0
- package/dist/renderer/spriteSheet.js +14 -0
- package/dist/renderer/spriteSheet.js.map +1 -0
- package/dist/renderer/state/GroupState.js +77 -0
- package/dist/renderer/state/GroupState.js.map +1 -0
- package/dist/renderer/syntheticItalic.js +6 -0
- package/dist/renderer/syntheticItalic.js.map +1 -0
- package/dist/renderer/textures/registerTexture.js +14 -0
- package/dist/renderer/textures/registerTexture.js.map +1 -0
- package/dist/renderer.d.ts +11 -21
- package/dist/renderer.js +18 -13
- package/dist/resize.d.ts +10 -46
- package/dist/resize.js +7 -5
- package/dist/routing.js +2 -3
- package/dist/scheduling/useVisibleRaf.js +69 -0
- package/dist/scheduling/useVisibleRaf.js.map +1 -0
- package/dist/test-hook/createTestHook.js +39 -0
- package/dist/test-hook/createTestHook.js.map +1 -0
- package/dist/test-hook/install.js +12 -0
- package/dist/test-hook/install.js.map +1 -0
- package/dist/test-seams-fYf6m5pu.d.ts +356 -0
- package/dist/test-seams.d.ts +6 -0
- package/dist/test-seams.js +3 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.js +33 -0
- package/dist/tools/builtin/ellipse/useEllipseTool.js.map +1 -0
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js +55 -0
- package/dist/tools/builtin/eyedropper/useEyedropperTool.js.map +1 -0
- package/dist/tools/builtin/hand/dragPanContribution.js +17 -0
- package/dist/tools/builtin/hand/dragPanContribution.js.map +1 -0
- package/dist/tools/builtin/hand/useHandTool.js +31 -0
- package/dist/tools/builtin/hand/useHandTool.js.map +1 -0
- package/dist/tools/builtin/image/useImageTool.js +41 -0
- package/dist/tools/builtin/image/useImageTool.js.map +1 -0
- package/dist/tools/builtin/lasso/useLassoTool.js +42 -0
- package/dist/tools/builtin/lasso/useLassoTool.js.map +1 -0
- package/dist/tools/builtin/line/useLineTool.js +33 -0
- package/dist/tools/builtin/line/useLineTool.js.map +1 -0
- package/dist/tools/builtin/pen/usePenTool.js +414 -0
- package/dist/tools/builtin/pen/usePenTool.js.map +1 -0
- package/dist/tools/builtin/pencil/usePencilTool.js +36 -0
- package/dist/tools/builtin/pencil/usePencilTool.js.map +1 -0
- package/dist/tools/builtin/pickTopMostHit.js +45 -0
- package/dist/tools/builtin/pickTopMostHit.js.map +1 -0
- package/dist/tools/builtin/polygon/usePolygonTool.js +81 -0
- package/dist/tools/builtin/polygon/usePolygonTool.js.map +1 -0
- package/dist/tools/builtin/rect/useRectTool.js +32 -0
- package/dist/tools/builtin/rect/useRectTool.js.map +1 -0
- package/dist/tools/builtin/select/selectionContributions.js +109 -0
- package/dist/tools/builtin/select/selectionContributions.js.map +1 -0
- package/dist/tools/builtin/select/useSelectTool.js +162 -0
- package/dist/tools/builtin/select/useSelectTool.js.map +1 -0
- package/dist/tools/builtin/shared/insertToolOptions.js +8 -0
- package/dist/tools/builtin/shared/insertToolOptions.js.map +1 -0
- package/dist/tools/builtin/slice/useSliceTool.js +263 -0
- package/dist/tools/builtin/slice/useSliceTool.js.map +1 -0
- package/dist/tools/builtin/star/useStarTool.js +82 -0
- package/dist/tools/builtin/star/useStarTool.js.map +1 -0
- package/dist/tools/builtin/text/useTextTool.js +177 -0
- package/dist/tools/builtin/text/useTextTool.js.map +1 -0
- package/dist/tools/overlayBinding.js +8 -0
- package/dist/tools/overlayBinding.js.map +1 -0
- package/dist/tools/prefs.js +47 -0
- package/dist/tools/prefs.js.map +1 -0
- package/dist/tools/useKeybindings.js +66 -0
- package/dist/tools/useKeybindings.js.map +1 -0
- package/dist/{types-D-9QWBy5.d.ts → types-CA54-mAZ.d.ts} +181 -13
- package/dist/{types-qYpyTAiZ.d.ts → types-DSjd6W3n.d.ts} +32 -6
- package/dist/util/color.js +26 -0
- package/dist/util/color.js.map +1 -0
- package/dist/util/constrainTo45.js +17 -0
- package/dist/util/constrainTo45.js.map +1 -0
- package/dist/util/paint.js +72 -0
- package/dist/util/paint.js.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +29 -19
- package/dist/chunk-3TY6FHAF.js +0 -170
- package/dist/chunk-3TY6FHAF.js.map +0 -1
- package/dist/chunk-DGWNNKGD.js +0 -248
- package/dist/chunk-DGWNNKGD.js.map +0 -1
- package/dist/chunk-G4ZGQMY7.js +0 -33372
- package/dist/chunk-G4ZGQMY7.js.map +0 -1
- package/dist/chunk-L5YNZYEG.js +0 -648
- package/dist/chunk-L5YNZYEG.js.map +0 -1
- package/dist/chunk-LU4IJ52W.js +0 -111
- package/dist/chunk-LU4IJ52W.js.map +0 -1
- package/dist/chunk-M24CLARN.js +0 -28
- package/dist/chunk-M24CLARN.js.map +0 -1
- package/dist/chunk-NE27EOLP.js +0 -146
- package/dist/chunk-NE27EOLP.js.map +0 -1
- package/dist/chunk-PNNZSYRD.js +0 -318
- package/dist/chunk-PNNZSYRD.js.map +0 -1
- package/dist/chunk-UPZY4ART.js +0 -29
- package/dist/chunk-UPZY4ART.js.map +0 -1
- package/dist/chunk-WPNA6L5O.js +0 -250
- package/dist/chunk-WPNA6L5O.js.map +0 -1
- package/dist/chunk-XMAWPGTK.js +0 -128
- package/dist/chunk-XMAWPGTK.js.map +0 -1
- package/dist/clipboard.js.map +0 -1
- package/dist/clone.js.map +0 -1
- package/dist/grid-CY5UKlZh.d.ts +0 -98
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/insert.d.ts +0 -36
- package/dist/insert.js +0 -81
- package/dist/insert.js.map +0 -1
- package/dist/math.js.map +0 -1
- package/dist/move.js.map +0 -1
- package/dist/path-JEV2c5If.d.ts +0 -48
- package/dist/patterns-builtin.js.map +0 -1
- package/dist/renderer.css +0 -62
- package/dist/renderer.css.map +0 -1
- package/dist/renderer.js.map +0 -1
- package/dist/resize.js.map +0 -1
- package/dist/routing.js.map +0 -1
- package/dist/types-D2tTKEU0.d.ts +0 -18
|
@@ -0,0 +1,1298 @@
|
|
|
1
|
+
//#region ../paint/dist/index.js
|
|
2
|
+
var SRGB_TO_LINEAR = (() => {
|
|
3
|
+
const lut = /* @__PURE__ */ new Float64Array(256);
|
|
4
|
+
for (let i = 0; i < 256; i++) {
|
|
5
|
+
const c = i / 255;
|
|
6
|
+
lut[i] = c <= .04045 ? c / 12.92 : Math.pow((c + .055) / 1.055, 2.4);
|
|
7
|
+
}
|
|
8
|
+
return lut;
|
|
9
|
+
})();
|
|
10
|
+
function linearToSrgbByte(c) {
|
|
11
|
+
if (c <= 0) return 0;
|
|
12
|
+
if (c >= 1) return 255;
|
|
13
|
+
const v = c <= .0031308 ? c * 12.92 : 1.055 * Math.pow(c, 1 / 2.4) - .055;
|
|
14
|
+
return Math.round(v * 255);
|
|
15
|
+
}
|
|
16
|
+
var f2u = (v) => Math.max(0, Math.min(255, Math.round(v * 255)));
|
|
17
|
+
function srgbFloatToOklab(r, g, b) {
|
|
18
|
+
return srgbU8ToOklab(f2u(r), f2u(g), f2u(b));
|
|
19
|
+
}
|
|
20
|
+
function srgbU8ToOklab(r, g, b) {
|
|
21
|
+
return linearSrgbToOklab(SRGB_TO_LINEAR[r & 255], SRGB_TO_LINEAR[g & 255], SRGB_TO_LINEAR[b & 255]);
|
|
22
|
+
}
|
|
23
|
+
function linearSrgbToOklab(rl, gl, bl) {
|
|
24
|
+
const l = .4122214708 * rl + .5363325363 * gl + .0514459929 * bl;
|
|
25
|
+
const m = .2119034982 * rl + .6806995451 * gl + .1073969566 * bl;
|
|
26
|
+
const s = .0883024619 * rl + .2817188376 * gl + .6299787005 * bl;
|
|
27
|
+
const lp = Math.cbrt(l);
|
|
28
|
+
const mp = Math.cbrt(m);
|
|
29
|
+
const sp = Math.cbrt(s);
|
|
30
|
+
return [
|
|
31
|
+
.2104542553 * lp + .793617785 * mp - .0040720468 * sp,
|
|
32
|
+
1.9779984951 * lp - 2.428592205 * mp + .4505937099 * sp,
|
|
33
|
+
.0259040371 * lp + .7827717662 * mp - .808675766 * sp
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
function oklabToLinearSrgb(L, A, B) {
|
|
37
|
+
const lp = L + .3963377774 * A + .2158037573 * B;
|
|
38
|
+
const mp = L - .1055613458 * A - .0638541728 * B;
|
|
39
|
+
const sp = L - .0894841775 * A - 1.291485548 * B;
|
|
40
|
+
const l = lp * lp * lp;
|
|
41
|
+
const m = mp * mp * mp;
|
|
42
|
+
const s = sp * sp * sp;
|
|
43
|
+
return [
|
|
44
|
+
4.0767416621 * l - 3.3077115913 * m + .2309699292 * s,
|
|
45
|
+
-1.2684380046 * l + 2.6097574011 * m - .3413193965 * s,
|
|
46
|
+
-.0041960863 * l - .7034186147 * m + 1.707614701 * s
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
function inGamut(rl, gl, bl) {
|
|
50
|
+
return rl >= -1e-6 && rl <= 1.000001 && gl >= -1e-6 && gl <= 1.000001 && bl >= -1e-6 && bl <= 1.000001;
|
|
51
|
+
}
|
|
52
|
+
function clipToGamut(L, A, B) {
|
|
53
|
+
let [rl, gl, bl] = oklabToLinearSrgb(L, A, B);
|
|
54
|
+
if (inGamut(rl, gl, bl)) return [
|
|
55
|
+
rl,
|
|
56
|
+
gl,
|
|
57
|
+
bl
|
|
58
|
+
];
|
|
59
|
+
let lo = 0;
|
|
60
|
+
let hi = 1;
|
|
61
|
+
for (let i = 0; i < 5; i++) {
|
|
62
|
+
const t = (lo + hi) / 2;
|
|
63
|
+
[rl, gl, bl] = oklabToLinearSrgb(L, A * t, B * t);
|
|
64
|
+
if (inGamut(rl, gl, bl)) lo = t;
|
|
65
|
+
else hi = t;
|
|
66
|
+
}
|
|
67
|
+
[rl, gl, bl] = oklabToLinearSrgb(L, A * lo, B * lo);
|
|
68
|
+
return [
|
|
69
|
+
rl,
|
|
70
|
+
gl,
|
|
71
|
+
bl
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
function oklabToSrgbU8(L, A, B) {
|
|
75
|
+
const [rl, gl, bl] = clipToGamut(L, A, B);
|
|
76
|
+
return [
|
|
77
|
+
linearToSrgbByte(rl),
|
|
78
|
+
linearToSrgbByte(gl),
|
|
79
|
+
linearToSrgbByte(bl)
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
function lerpOklab(from, to, t) {
|
|
83
|
+
return [
|
|
84
|
+
from[0] + (to[0] - from[0]) * t,
|
|
85
|
+
from[1] + (to[1] - from[1]) * t,
|
|
86
|
+
from[2] + (to[2] - from[2]) * t
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
function oklabToOklch(L, A, B) {
|
|
90
|
+
return [
|
|
91
|
+
L,
|
|
92
|
+
Math.hypot(A, B),
|
|
93
|
+
Math.atan2(B, A)
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
function oklchToOklab(L, C, h) {
|
|
97
|
+
return [
|
|
98
|
+
L,
|
|
99
|
+
C * Math.cos(h),
|
|
100
|
+
C * Math.sin(h)
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
function lerpOklch(from, to, t) {
|
|
104
|
+
const [L1, C1, h1Raw] = from;
|
|
105
|
+
const [L2, C2, h2Raw] = to;
|
|
106
|
+
const C_EPS = 1e-4;
|
|
107
|
+
const h1 = C1 < C_EPS ? h2Raw : h1Raw;
|
|
108
|
+
const h2 = C2 < C_EPS ? h1Raw : h2Raw;
|
|
109
|
+
const TWO_PI = Math.PI * 2;
|
|
110
|
+
let dh = h2 - h1;
|
|
111
|
+
while (dh > Math.PI) dh -= TWO_PI;
|
|
112
|
+
while (dh < -Math.PI) dh += TWO_PI;
|
|
113
|
+
return [
|
|
114
|
+
L1 + (L2 - L1) * t,
|
|
115
|
+
C1 + (C2 - C1) * t,
|
|
116
|
+
h1 + dh * t
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
var u2f = (v) => v / 255;
|
|
120
|
+
function lerpColorArray(from, to, t, space = "rgb") {
|
|
121
|
+
if (from.length !== to.length) throw new Error(`lerpColorArray: length mismatch (from=${from.length}, to=${to.length})`);
|
|
122
|
+
if (from.length % 4 !== 0) throw new Error(`lerpColorArray: length ${from.length} not divisible by 4`);
|
|
123
|
+
const out = new Array(from.length);
|
|
124
|
+
const n = from.length / 4;
|
|
125
|
+
if (space === "rgb") {
|
|
126
|
+
for (let i = 0; i < from.length; i++) out[i] = from[i] + (to[i] - from[i]) * t;
|
|
127
|
+
return out;
|
|
128
|
+
}
|
|
129
|
+
if (space === "oklch") {
|
|
130
|
+
for (let i = 0; i < n; i++) {
|
|
131
|
+
const k = i * 4;
|
|
132
|
+
const fLab = srgbU8ToOklab(f2u(from[k]), f2u(from[k + 1]), f2u(from[k + 2]));
|
|
133
|
+
const tLab = srgbU8ToOklab(f2u(to[k]), f2u(to[k + 1]), f2u(to[k + 2]));
|
|
134
|
+
const midLch = lerpOklch(oklabToOklch(fLab[0], fLab[1], fLab[2]), oklabToOklch(tLab[0], tLab[1], tLab[2]), t);
|
|
135
|
+
const midLab = oklchToOklab(midLch[0], midLch[1], midLch[2]);
|
|
136
|
+
const [r, g, b] = oklabToSrgbU8(midLab[0], midLab[1], midLab[2]);
|
|
137
|
+
out[k] = u2f(r);
|
|
138
|
+
out[k + 1] = u2f(g);
|
|
139
|
+
out[k + 2] = u2f(b);
|
|
140
|
+
out[k + 3] = from[k + 3] + (to[k + 3] - from[k + 3]) * t;
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
for (let i = 0; i < n; i++) {
|
|
145
|
+
const k = i * 4;
|
|
146
|
+
const mid = lerpOklab(srgbU8ToOklab(f2u(from[k]), f2u(from[k + 1]), f2u(from[k + 2])), srgbU8ToOklab(f2u(to[k]), f2u(to[k + 1]), f2u(to[k + 2])), t);
|
|
147
|
+
const [r, g, b] = oklabToSrgbU8(mid[0], mid[1], mid[2]);
|
|
148
|
+
out[k] = u2f(r);
|
|
149
|
+
out[k + 1] = u2f(g);
|
|
150
|
+
out[k + 2] = u2f(b);
|
|
151
|
+
out[k + 3] = from[k + 3] + (to[k + 3] - from[k + 3]) * t;
|
|
152
|
+
}
|
|
153
|
+
return out;
|
|
154
|
+
}
|
|
155
|
+
function hslToSrgb(h, s, l) {
|
|
156
|
+
if (s === 0) return [
|
|
157
|
+
l,
|
|
158
|
+
l,
|
|
159
|
+
l
|
|
160
|
+
];
|
|
161
|
+
const q = l < .5 ? l * (1 + s) : l + s - l * s;
|
|
162
|
+
const p = 2 * l - q;
|
|
163
|
+
const hk = h / 360;
|
|
164
|
+
return [
|
|
165
|
+
hueToChannel(p, q, hk + 1 / 3),
|
|
166
|
+
hueToChannel(p, q, hk),
|
|
167
|
+
hueToChannel(p, q, hk - 1 / 3)
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
function hueToChannel(p, q, t) {
|
|
171
|
+
if (t < 0) t += 1;
|
|
172
|
+
if (t > 1) t -= 1;
|
|
173
|
+
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
|
174
|
+
if (t < 1 / 2) return q;
|
|
175
|
+
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
|
176
|
+
return p;
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/renderer/math/color.ts
|
|
180
|
+
/**
|
|
181
|
+
* Parse a CSS color string into [r, g, b, a] with 0..1 components.
|
|
182
|
+
*
|
|
183
|
+
* Supported forms:
|
|
184
|
+
* - Hex: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa` (any case)
|
|
185
|
+
* - `rgb()` / `rgba()` with integer, float, or percent R/G/B; number or
|
|
186
|
+
* percent alpha; commas or modern space-separated `R G B / A` syntax
|
|
187
|
+
* - `hsl()` / `hsla()` with hue as a unitless number (deg) or with `deg`,
|
|
188
|
+
* `rad`, `grad`, `turn` units; saturation/lightness as percent (or
|
|
189
|
+
* unitless in the modern syntax); same alpha rules and separator rules
|
|
190
|
+
* as `rgb()`
|
|
191
|
+
* - The 148 CSS named colors plus `transparent`
|
|
192
|
+
*
|
|
193
|
+
* Not supported: `oklch()`, `lab()`, `color()`, `currentColor`, system
|
|
194
|
+
* colors. Throws on anything unrecognized.
|
|
195
|
+
*
|
|
196
|
+
* Results are cached by input-string identity. Callers MUST treat the
|
|
197
|
+
* returned tuple as read-only — mutation would corrupt the cache.
|
|
198
|
+
*/
|
|
199
|
+
function parseColor(input) {
|
|
200
|
+
const cached = CACHE.get(input);
|
|
201
|
+
if (cached !== void 0) return cached;
|
|
202
|
+
const result = parseColorUncached(input);
|
|
203
|
+
if (CACHE.size >= CACHE_MAX) CACHE.clear();
|
|
204
|
+
CACHE.set(input, result);
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
const CACHE = /* @__PURE__ */ new Map();
|
|
208
|
+
const CACHE_MAX = 1024;
|
|
209
|
+
function parseColorUncached(input) {
|
|
210
|
+
const s = input.trim();
|
|
211
|
+
if (s.startsWith("#")) return parseHex(s);
|
|
212
|
+
const lower = s.toLowerCase();
|
|
213
|
+
const named = NAMED_COLORS[lower];
|
|
214
|
+
if (named !== void 0) return named;
|
|
215
|
+
if (lower.startsWith("rgb")) {
|
|
216
|
+
const parsed = parseRgbFunction(lower);
|
|
217
|
+
if (parsed) return parsed;
|
|
218
|
+
}
|
|
219
|
+
if (lower.startsWith("hsl")) {
|
|
220
|
+
const parsed = parseHslFunction(lower);
|
|
221
|
+
if (parsed) return parsed;
|
|
222
|
+
}
|
|
223
|
+
throw new Error(`parseColor: unrecognized color "${input}"`);
|
|
224
|
+
}
|
|
225
|
+
const RESOLVE_COLOR_CACHE_CAP = 1024;
|
|
226
|
+
const resolveColorCache = /* @__PURE__ */ new Map();
|
|
227
|
+
/** Cached `parseColor`. Use this from renderer hot paths (per-frame draw
|
|
228
|
+
* callbacks, gradient ramp builds) so repeated color strings — which are
|
|
229
|
+
* common when many objects share a fill — don't re-tokenize each frame.
|
|
230
|
+
*
|
|
231
|
+
* Cache is keyed by input-string identity, capped at ~1024 entries, and
|
|
232
|
+
* cleared wholesale on overflow (no LRU tracking — simple is fine since
|
|
233
|
+
* the working set in any one app is typically much smaller than the cap). */
|
|
234
|
+
function resolveColor(input) {
|
|
235
|
+
const hit = resolveColorCache.get(input);
|
|
236
|
+
if (hit) return hit;
|
|
237
|
+
if (resolveColorCache.size >= RESOLVE_COLOR_CACHE_CAP) resolveColorCache.clear();
|
|
238
|
+
const frozen = parseColor(input);
|
|
239
|
+
resolveColorCache.set(input, frozen);
|
|
240
|
+
return frozen;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Format [r, g, b, a] (0..1 components) as a hex string. Emits `#rrggbb` when
|
|
244
|
+
* alpha is exactly 1 (or omitted), otherwise `#rrggbbaa`.
|
|
245
|
+
*/
|
|
246
|
+
function rgbaToHex(rgba) {
|
|
247
|
+
const [r, g, b] = rgba;
|
|
248
|
+
const a = rgba.length === 4 ? rgba[3] : 1;
|
|
249
|
+
const f = (n) => Math.max(0, Math.min(255, Math.round(n * 255))).toString(16).padStart(2, "0");
|
|
250
|
+
const base = `#${f(r)}${f(g)}${f(b)}`;
|
|
251
|
+
return a >= 1 ? base : `${base}${f(a)}`;
|
|
252
|
+
}
|
|
253
|
+
function parseHex(s) {
|
|
254
|
+
const hex = s.slice(1);
|
|
255
|
+
if (hex.length === 3) return [
|
|
256
|
+
parseInt(hex[0] + hex[0], 16) / 255,
|
|
257
|
+
parseInt(hex[1] + hex[1], 16) / 255,
|
|
258
|
+
parseInt(hex[2] + hex[2], 16) / 255,
|
|
259
|
+
1
|
|
260
|
+
];
|
|
261
|
+
if (hex.length === 4) return [
|
|
262
|
+
parseInt(hex[0] + hex[0], 16) / 255,
|
|
263
|
+
parseInt(hex[1] + hex[1], 16) / 255,
|
|
264
|
+
parseInt(hex[2] + hex[2], 16) / 255,
|
|
265
|
+
parseInt(hex[3] + hex[3], 16) / 255
|
|
266
|
+
];
|
|
267
|
+
if (hex.length === 6) return [
|
|
268
|
+
parseInt(hex.slice(0, 2), 16) / 255,
|
|
269
|
+
parseInt(hex.slice(2, 4), 16) / 255,
|
|
270
|
+
parseInt(hex.slice(4, 6), 16) / 255,
|
|
271
|
+
1
|
|
272
|
+
];
|
|
273
|
+
if (hex.length === 8) return [
|
|
274
|
+
parseInt(hex.slice(0, 2), 16) / 255,
|
|
275
|
+
parseInt(hex.slice(2, 4), 16) / 255,
|
|
276
|
+
parseInt(hex.slice(4, 6), 16) / 255,
|
|
277
|
+
parseInt(hex.slice(6, 8), 16) / 255
|
|
278
|
+
];
|
|
279
|
+
throw new Error(`parseColor: invalid hex "${s}"`);
|
|
280
|
+
}
|
|
281
|
+
/** Match `name( body )` and return the trimmed body, or null. */
|
|
282
|
+
function unwrapFn(s, name) {
|
|
283
|
+
if (!s.startsWith(name + "(") || !s.endsWith(")")) return null;
|
|
284
|
+
return s.slice(name.length + 1, -1).trim();
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Split a function body into the value tokens (3 channels + optional alpha).
|
|
288
|
+
* Supports both legacy `r, g, b[, a]` and modern `r g b[ / a]` separators.
|
|
289
|
+
* Returns null if the token count is wrong.
|
|
290
|
+
*/
|
|
291
|
+
function splitChannels(body) {
|
|
292
|
+
if (body.includes(",")) {
|
|
293
|
+
const parts = body.split(",").map((p) => p.trim());
|
|
294
|
+
if (parts.length !== 3 && parts.length !== 4) return null;
|
|
295
|
+
return {
|
|
296
|
+
rgb: [
|
|
297
|
+
parts[0],
|
|
298
|
+
parts[1],
|
|
299
|
+
parts[2]
|
|
300
|
+
],
|
|
301
|
+
alpha: parts.length === 4 ? parts[3] : null
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
const slash = body.indexOf("/");
|
|
305
|
+
const head = (slash === -1 ? body : body.slice(0, slash)).trim();
|
|
306
|
+
const alpha = slash === -1 ? null : body.slice(slash + 1).trim();
|
|
307
|
+
const parts = head.split(/\s+/);
|
|
308
|
+
if (parts.length !== 3) return null;
|
|
309
|
+
if (alpha !== null && alpha === "") return null;
|
|
310
|
+
return {
|
|
311
|
+
rgb: [
|
|
312
|
+
parts[0],
|
|
313
|
+
parts[1],
|
|
314
|
+
parts[2]
|
|
315
|
+
],
|
|
316
|
+
alpha
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
/** Parse a channel value: integer, float, or percent. Returns 0..1 (with `max` as the integer scale). */
|
|
320
|
+
function parseChannel(tok, max) {
|
|
321
|
+
if (tok.endsWith("%")) {
|
|
322
|
+
const n = Number(tok.slice(0, -1));
|
|
323
|
+
if (!Number.isFinite(n)) return null;
|
|
324
|
+
return clamp01(n / 100);
|
|
325
|
+
}
|
|
326
|
+
const n = Number(tok);
|
|
327
|
+
if (!Number.isFinite(n)) return null;
|
|
328
|
+
return clamp01(n / max);
|
|
329
|
+
}
|
|
330
|
+
/** Alpha may be a number 0..1 or a percent. */
|
|
331
|
+
function parseAlpha(tok) {
|
|
332
|
+
if (tok === null) return 1;
|
|
333
|
+
if (tok.endsWith("%")) {
|
|
334
|
+
const n = Number(tok.slice(0, -1));
|
|
335
|
+
return Number.isFinite(n) ? clamp01(n / 100) : 1;
|
|
336
|
+
}
|
|
337
|
+
const n = Number(tok);
|
|
338
|
+
return Number.isFinite(n) ? clamp01(n) : 1;
|
|
339
|
+
}
|
|
340
|
+
function parseRgbFunction(s) {
|
|
341
|
+
const body = unwrapFn(s, "rgba") ?? unwrapFn(s, "rgb");
|
|
342
|
+
if (body === null) return null;
|
|
343
|
+
const channels = splitChannels(body);
|
|
344
|
+
if (!channels) return null;
|
|
345
|
+
const r = parseChannel(channels.rgb[0], 255);
|
|
346
|
+
const g = parseChannel(channels.rgb[1], 255);
|
|
347
|
+
const b = parseChannel(channels.rgb[2], 255);
|
|
348
|
+
if (r === null || g === null || b === null) return null;
|
|
349
|
+
return [
|
|
350
|
+
r,
|
|
351
|
+
g,
|
|
352
|
+
b,
|
|
353
|
+
parseAlpha(channels.alpha)
|
|
354
|
+
];
|
|
355
|
+
}
|
|
356
|
+
function parseHslFunction(s) {
|
|
357
|
+
const body = unwrapFn(s, "hsla") ?? unwrapFn(s, "hsl");
|
|
358
|
+
if (body === null) return null;
|
|
359
|
+
const channels = splitChannels(body);
|
|
360
|
+
if (!channels) return null;
|
|
361
|
+
const h = parseHue(channels.rgb[0]);
|
|
362
|
+
const sat = parsePercentOrNumber(channels.rgb[1]);
|
|
363
|
+
const lit = parsePercentOrNumber(channels.rgb[2]);
|
|
364
|
+
if (h === null || sat === null || lit === null) return null;
|
|
365
|
+
const [r, g, b] = hslToRgb(h, sat, lit);
|
|
366
|
+
return [
|
|
367
|
+
r,
|
|
368
|
+
g,
|
|
369
|
+
b,
|
|
370
|
+
parseAlpha(channels.alpha)
|
|
371
|
+
];
|
|
372
|
+
}
|
|
373
|
+
/** Parse a hue token: `<number>`, `<number>deg`, `<number>rad`, `<number>grad`, `<number>turn`. Returns degrees 0..360 (modulo). */
|
|
374
|
+
function parseHue(tok) {
|
|
375
|
+
let n;
|
|
376
|
+
if (tok.endsWith("deg")) n = Number(tok.slice(0, -3));
|
|
377
|
+
else if (tok.endsWith("grad")) n = Number(tok.slice(0, -4)) * .9;
|
|
378
|
+
else if (tok.endsWith("rad")) n = Number(tok.slice(0, -3)) * (180 / Math.PI);
|
|
379
|
+
else if (tok.endsWith("turn")) n = Number(tok.slice(0, -4)) * 360;
|
|
380
|
+
else n = Number(tok);
|
|
381
|
+
if (!Number.isFinite(n)) return null;
|
|
382
|
+
return (n % 360 + 360) % 360;
|
|
383
|
+
}
|
|
384
|
+
/** Saturation/lightness may be percent (CSS Color 3) or unitless number 0..1 (modern). */
|
|
385
|
+
function parsePercentOrNumber(tok) {
|
|
386
|
+
if (tok.endsWith("%")) {
|
|
387
|
+
const n = Number(tok.slice(0, -1));
|
|
388
|
+
return Number.isFinite(n) ? clamp01(n / 100) : null;
|
|
389
|
+
}
|
|
390
|
+
const n = Number(tok);
|
|
391
|
+
return Number.isFinite(n) ? clamp01(n) : null;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* HSL → RGB, all components 0..1 except hue in degrees (0..360). paint's
|
|
395
|
+
* `hslToSrgb` under the name this file's callers use.
|
|
396
|
+
*
|
|
397
|
+
* @internal Not part of the public API; not re-exported from the barrel.
|
|
398
|
+
*/
|
|
399
|
+
const hslToRgb = hslToSrgb;
|
|
400
|
+
function clamp01(n) {
|
|
401
|
+
return n < 0 ? 0 : n > 1 ? 1 : n;
|
|
402
|
+
}
|
|
403
|
+
const NAMED_COLORS = (() => {
|
|
404
|
+
const hex = {
|
|
405
|
+
aliceblue: 15792383,
|
|
406
|
+
antiquewhite: 16444375,
|
|
407
|
+
aqua: 65535,
|
|
408
|
+
aquamarine: 8388564,
|
|
409
|
+
azure: 15794175,
|
|
410
|
+
beige: 16119260,
|
|
411
|
+
bisque: 16770244,
|
|
412
|
+
black: 0,
|
|
413
|
+
blanchedalmond: 16772045,
|
|
414
|
+
blue: 255,
|
|
415
|
+
blueviolet: 9055202,
|
|
416
|
+
brown: 10824234,
|
|
417
|
+
burlywood: 14596231,
|
|
418
|
+
cadetblue: 6266528,
|
|
419
|
+
chartreuse: 8388352,
|
|
420
|
+
chocolate: 13789470,
|
|
421
|
+
coral: 16744272,
|
|
422
|
+
cornflowerblue: 6591981,
|
|
423
|
+
cornsilk: 16775388,
|
|
424
|
+
crimson: 14423100,
|
|
425
|
+
cyan: 65535,
|
|
426
|
+
darkblue: 139,
|
|
427
|
+
darkcyan: 35723,
|
|
428
|
+
darkgoldenrod: 12092939,
|
|
429
|
+
darkgray: 11119017,
|
|
430
|
+
darkgreen: 25600,
|
|
431
|
+
darkgrey: 11119017,
|
|
432
|
+
darkkhaki: 12433259,
|
|
433
|
+
darkmagenta: 9109643,
|
|
434
|
+
darkolivegreen: 5597999,
|
|
435
|
+
darkorange: 16747520,
|
|
436
|
+
darkorchid: 10040012,
|
|
437
|
+
darkred: 9109504,
|
|
438
|
+
darksalmon: 15308410,
|
|
439
|
+
darkseagreen: 9419919,
|
|
440
|
+
darkslateblue: 4734347,
|
|
441
|
+
darkslategray: 3100495,
|
|
442
|
+
darkslategrey: 3100495,
|
|
443
|
+
darkturquoise: 52945,
|
|
444
|
+
darkviolet: 9699539,
|
|
445
|
+
deeppink: 16716947,
|
|
446
|
+
deepskyblue: 49151,
|
|
447
|
+
dimgray: 6908265,
|
|
448
|
+
dimgrey: 6908265,
|
|
449
|
+
dodgerblue: 2003199,
|
|
450
|
+
firebrick: 11674146,
|
|
451
|
+
floralwhite: 16775920,
|
|
452
|
+
forestgreen: 2263842,
|
|
453
|
+
fuchsia: 16711935,
|
|
454
|
+
gainsboro: 14474460,
|
|
455
|
+
ghostwhite: 16316671,
|
|
456
|
+
gold: 16766720,
|
|
457
|
+
goldenrod: 14329120,
|
|
458
|
+
gray: 8421504,
|
|
459
|
+
green: 32768,
|
|
460
|
+
greenyellow: 11403055,
|
|
461
|
+
grey: 8421504,
|
|
462
|
+
honeydew: 15794160,
|
|
463
|
+
hotpink: 16738740,
|
|
464
|
+
indianred: 13458524,
|
|
465
|
+
indigo: 4915330,
|
|
466
|
+
ivory: 16777200,
|
|
467
|
+
khaki: 15787660,
|
|
468
|
+
lavender: 15132410,
|
|
469
|
+
lavenderblush: 16773365,
|
|
470
|
+
lawngreen: 8190976,
|
|
471
|
+
lemonchiffon: 16775885,
|
|
472
|
+
lightblue: 11393254,
|
|
473
|
+
lightcoral: 15761536,
|
|
474
|
+
lightcyan: 14745599,
|
|
475
|
+
lightgoldenrodyellow: 16448210,
|
|
476
|
+
lightgray: 13882323,
|
|
477
|
+
lightgreen: 9498256,
|
|
478
|
+
lightgrey: 13882323,
|
|
479
|
+
lightpink: 16758465,
|
|
480
|
+
lightsalmon: 16752762,
|
|
481
|
+
lightseagreen: 2142890,
|
|
482
|
+
lightskyblue: 8900346,
|
|
483
|
+
lightslategray: 7833753,
|
|
484
|
+
lightslategrey: 7833753,
|
|
485
|
+
lightsteelblue: 11584734,
|
|
486
|
+
lightyellow: 16777184,
|
|
487
|
+
lime: 65280,
|
|
488
|
+
limegreen: 3329330,
|
|
489
|
+
linen: 16445670,
|
|
490
|
+
magenta: 16711935,
|
|
491
|
+
maroon: 8388608,
|
|
492
|
+
mediumaquamarine: 6737322,
|
|
493
|
+
mediumblue: 205,
|
|
494
|
+
mediumorchid: 12211667,
|
|
495
|
+
mediumpurple: 9662683,
|
|
496
|
+
mediumseagreen: 3978097,
|
|
497
|
+
mediumslateblue: 8087790,
|
|
498
|
+
mediumspringgreen: 64154,
|
|
499
|
+
mediumturquoise: 4772300,
|
|
500
|
+
mediumvioletred: 13047173,
|
|
501
|
+
midnightblue: 1644912,
|
|
502
|
+
mintcream: 16121850,
|
|
503
|
+
mistyrose: 16770273,
|
|
504
|
+
moccasin: 16770229,
|
|
505
|
+
navajowhite: 16768685,
|
|
506
|
+
navy: 128,
|
|
507
|
+
oldlace: 16643558,
|
|
508
|
+
olive: 8421376,
|
|
509
|
+
olivedrab: 7048739,
|
|
510
|
+
orange: 16753920,
|
|
511
|
+
orangered: 16729344,
|
|
512
|
+
orchid: 14315734,
|
|
513
|
+
palegoldenrod: 15657130,
|
|
514
|
+
palegreen: 10025880,
|
|
515
|
+
paleturquoise: 11529966,
|
|
516
|
+
palevioletred: 14381203,
|
|
517
|
+
papayawhip: 16773077,
|
|
518
|
+
peachpuff: 16767673,
|
|
519
|
+
peru: 13468991,
|
|
520
|
+
pink: 16761035,
|
|
521
|
+
plum: 14524637,
|
|
522
|
+
powderblue: 11591910,
|
|
523
|
+
purple: 8388736,
|
|
524
|
+
rebeccapurple: 6697881,
|
|
525
|
+
red: 16711680,
|
|
526
|
+
rosybrown: 12357519,
|
|
527
|
+
royalblue: 4286945,
|
|
528
|
+
saddlebrown: 9127187,
|
|
529
|
+
salmon: 16416882,
|
|
530
|
+
sandybrown: 16032864,
|
|
531
|
+
seagreen: 3050327,
|
|
532
|
+
seashell: 16774638,
|
|
533
|
+
sienna: 10506797,
|
|
534
|
+
silver: 12632256,
|
|
535
|
+
skyblue: 8900331,
|
|
536
|
+
slateblue: 6970061,
|
|
537
|
+
slategray: 7372944,
|
|
538
|
+
slategrey: 7372944,
|
|
539
|
+
snow: 16775930,
|
|
540
|
+
springgreen: 65407,
|
|
541
|
+
steelblue: 4620980,
|
|
542
|
+
tan: 13808780,
|
|
543
|
+
teal: 32896,
|
|
544
|
+
thistle: 14204888,
|
|
545
|
+
tomato: 16737095,
|
|
546
|
+
turquoise: 4251856,
|
|
547
|
+
violet: 15631086,
|
|
548
|
+
wheat: 16113331,
|
|
549
|
+
white: 16777215,
|
|
550
|
+
whitesmoke: 16119285,
|
|
551
|
+
yellow: 16776960,
|
|
552
|
+
yellowgreen: 10145074
|
|
553
|
+
};
|
|
554
|
+
const out = { transparent: [
|
|
555
|
+
0,
|
|
556
|
+
0,
|
|
557
|
+
0,
|
|
558
|
+
0
|
|
559
|
+
] };
|
|
560
|
+
for (const name in hex) {
|
|
561
|
+
const n = hex[name];
|
|
562
|
+
out[name] = [
|
|
563
|
+
(n >> 16 & 255) / 255,
|
|
564
|
+
(n >> 8 & 255) / 255,
|
|
565
|
+
(n & 255) / 255,
|
|
566
|
+
1
|
|
567
|
+
];
|
|
568
|
+
}
|
|
569
|
+
return out;
|
|
570
|
+
})();
|
|
571
|
+
//#endregion
|
|
572
|
+
//#region src/features/meshPaint/surface.ts
|
|
573
|
+
/** Corner `i` of the boundary walk. */
|
|
574
|
+
function patchCorner(patch, i) {
|
|
575
|
+
return patch.points[(i & 3) * 3];
|
|
576
|
+
}
|
|
577
|
+
/** `true` when the patch carries the four interior points a tensor patch adds. */
|
|
578
|
+
function isTensorPatch(patch) {
|
|
579
|
+
return patch.points.length >= 16;
|
|
580
|
+
}
|
|
581
|
+
/** A patch is twelve boundary points, or sixteen with the interior. Anything
|
|
582
|
+
* else cannot be evaluated, and saying so here beats painting nonsense. */
|
|
583
|
+
function isValidPatch(patch) {
|
|
584
|
+
return patch.points.length === 12 || patch.points.length === 16;
|
|
585
|
+
}
|
|
586
|
+
function bezier(p0, p1, p2, p3, t) {
|
|
587
|
+
const s = 1 - t;
|
|
588
|
+
const a = s * s * s;
|
|
589
|
+
const b = 3 * s * s * t;
|
|
590
|
+
const c = 3 * s * t * t;
|
|
591
|
+
const d = t * t * t;
|
|
592
|
+
return {
|
|
593
|
+
x: a * p0.x + b * p1.x + c * p2.x + d * p3.x,
|
|
594
|
+
y: a * p0.y + b * p1.y + c * p2.y + d * p3.y
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
/** The edge leaving corner `i`, as its four control points. */
|
|
598
|
+
function edge(patch, i) {
|
|
599
|
+
const p = patch.points;
|
|
600
|
+
const a = (i & 3) * 3;
|
|
601
|
+
return [
|
|
602
|
+
p[a],
|
|
603
|
+
p[a + 1],
|
|
604
|
+
p[a + 2],
|
|
605
|
+
p[(i + 1 & 3) * 3]
|
|
606
|
+
];
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* The patch surface at `(u, v)`, both in `0..1`.
|
|
610
|
+
*
|
|
611
|
+
* `u` runs along the edge leaving corner 0 and `v` along the edge leaving
|
|
612
|
+
* corner 1, so `(0,0)` is corner 0, `(1,0)` corner 1, `(1,1)` corner 2 and
|
|
613
|
+
* `(0,1)` corner 3 — the same walk `colors` is in.
|
|
614
|
+
*/
|
|
615
|
+
function evalPatch(patch, u, v) {
|
|
616
|
+
return isTensorPatch(patch) ? evalTensor(patch, u, v) : evalCoons(patch, u, v);
|
|
617
|
+
}
|
|
618
|
+
function evalCoons(patch, u, v) {
|
|
619
|
+
const [b0, b1, b2, b3] = edge(patch, 0);
|
|
620
|
+
const [r0, r1, r2, r3] = edge(patch, 1);
|
|
621
|
+
const [t0, t1, t2, t3] = edge(patch, 2);
|
|
622
|
+
const [l0, l1, l2, l3] = edge(patch, 3);
|
|
623
|
+
const bottom = bezier(b0, b1, b2, b3, u);
|
|
624
|
+
const top = bezier(t0, t1, t2, t3, 1 - u);
|
|
625
|
+
const right = bezier(r0, r1, r2, r3, v);
|
|
626
|
+
const left = bezier(l0, l1, l2, l3, 1 - v);
|
|
627
|
+
const c0 = patchCorner(patch, 0);
|
|
628
|
+
const c1 = patchCorner(patch, 1);
|
|
629
|
+
const c2 = patchCorner(patch, 2);
|
|
630
|
+
const c3 = patchCorner(patch, 3);
|
|
631
|
+
const ruledU = (a, b) => (1 - v) * a + v * b;
|
|
632
|
+
const ruledV = (a, b) => (1 - u) * a + u * b;
|
|
633
|
+
const corner = (k0, k1, k2, k3) => (1 - u) * (1 - v) * k0 + u * (1 - v) * k1 + u * v * k2 + (1 - u) * v * k3;
|
|
634
|
+
return {
|
|
635
|
+
x: ruledU(bottom.x, top.x) + ruledV(left.x, right.x) - corner(c0.x, c1.x, c2.x, c3.x),
|
|
636
|
+
y: ruledU(bottom.y, top.y) + ruledV(left.y, right.y) - corner(c0.y, c1.y, c2.y, c3.y)
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
/** The bicubic control net a tensor patch's sixteen points make, as
|
|
640
|
+
* `net[i][j]` with `i` along `u` and `j` along `v`. */
|
|
641
|
+
function tensorNet(patch) {
|
|
642
|
+
const p = patch.points;
|
|
643
|
+
return [
|
|
644
|
+
[
|
|
645
|
+
p[0],
|
|
646
|
+
p[11],
|
|
647
|
+
p[10],
|
|
648
|
+
p[9]
|
|
649
|
+
],
|
|
650
|
+
[
|
|
651
|
+
p[1],
|
|
652
|
+
p[12],
|
|
653
|
+
p[13],
|
|
654
|
+
p[8]
|
|
655
|
+
],
|
|
656
|
+
[
|
|
657
|
+
p[2],
|
|
658
|
+
p[15],
|
|
659
|
+
p[14],
|
|
660
|
+
p[7]
|
|
661
|
+
],
|
|
662
|
+
[
|
|
663
|
+
p[3],
|
|
664
|
+
p[4],
|
|
665
|
+
p[5],
|
|
666
|
+
p[6]
|
|
667
|
+
]
|
|
668
|
+
];
|
|
669
|
+
}
|
|
670
|
+
const BERNSTEIN = (t) => {
|
|
671
|
+
const s = 1 - t;
|
|
672
|
+
return [
|
|
673
|
+
s * s * s,
|
|
674
|
+
3 * s * s * t,
|
|
675
|
+
3 * s * t * t,
|
|
676
|
+
t * t * t
|
|
677
|
+
];
|
|
678
|
+
};
|
|
679
|
+
function evalTensor(patch, u, v) {
|
|
680
|
+
const net = tensorNet(patch);
|
|
681
|
+
const bu = BERNSTEIN(u);
|
|
682
|
+
const bv = BERNSTEIN(v);
|
|
683
|
+
let x = 0;
|
|
684
|
+
let y = 0;
|
|
685
|
+
for (let i = 0; i < 4; i++) for (let j = 0; j < 4; j++) {
|
|
686
|
+
const w = bu[i] * bv[j];
|
|
687
|
+
x += w * net[i][j].x;
|
|
688
|
+
y += w * net[i][j].y;
|
|
689
|
+
}
|
|
690
|
+
return {
|
|
691
|
+
x,
|
|
692
|
+
y
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
/** Axis-aligned bounds of a patch, sampled on a grid. Control points alone
|
|
696
|
+
* bound a Bézier but not tightly, and a mesh paint is baked into a texture
|
|
697
|
+
* sized from this — a loose box wastes texels on every side. */
|
|
698
|
+
function patchBounds(patch, steps = 8) {
|
|
699
|
+
let minX = Infinity;
|
|
700
|
+
let minY = Infinity;
|
|
701
|
+
let maxX = -Infinity;
|
|
702
|
+
let maxY = -Infinity;
|
|
703
|
+
for (let i = 0; i <= steps; i++) for (let j = 0; j <= steps; j++) {
|
|
704
|
+
const p = evalPatch(patch, i / steps, j / steps);
|
|
705
|
+
if (p.x < minX) minX = p.x;
|
|
706
|
+
if (p.y < minY) minY = p.y;
|
|
707
|
+
if (p.x > maxX) maxX = p.x;
|
|
708
|
+
if (p.y > maxY) maxY = p.y;
|
|
709
|
+
}
|
|
710
|
+
return {
|
|
711
|
+
x: minX,
|
|
712
|
+
y: minY,
|
|
713
|
+
width: maxX - minX,
|
|
714
|
+
height: maxY - minY
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
/** Texels a rasterized cell spans at most. The rasterizer interpolates color
|
|
718
|
+
* linearly inside a cell and draws a curved edge as its chord, so this is
|
|
719
|
+
* what keeps a perceptual blend perceptual and an edge curved at any size. */
|
|
720
|
+
const TEXELS_PER_CELL = 10;
|
|
721
|
+
/** Quads per patch on a side, never fewer than 24. */
|
|
722
|
+
function gridFor(size) {
|
|
723
|
+
return Math.max(24, Math.ceil(size / TEXELS_PER_CELL));
|
|
724
|
+
}
|
|
725
|
+
/** The union of every patch's bounds, or `null` when nothing is drawable. */
|
|
726
|
+
function meshBounds(patches) {
|
|
727
|
+
let minX = Infinity;
|
|
728
|
+
let minY = Infinity;
|
|
729
|
+
let maxX = -Infinity;
|
|
730
|
+
let maxY = -Infinity;
|
|
731
|
+
for (const patch of patches) {
|
|
732
|
+
if (!isValidPatch(patch)) continue;
|
|
733
|
+
const b = patchBounds(patch);
|
|
734
|
+
minX = Math.min(minX, b.x);
|
|
735
|
+
minY = Math.min(minY, b.y);
|
|
736
|
+
maxX = Math.max(maxX, b.x + b.width);
|
|
737
|
+
maxY = Math.max(maxY, b.y + b.height);
|
|
738
|
+
}
|
|
739
|
+
if (!Number.isFinite(minX) || maxX <= minX || maxY <= minY) return null;
|
|
740
|
+
return {
|
|
741
|
+
x: minX,
|
|
742
|
+
y: minY,
|
|
743
|
+
width: maxX - minX,
|
|
744
|
+
height: maxY - minY
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Corner colors blended at `(u, v)` in `space`.
|
|
749
|
+
*
|
|
750
|
+
* Bilinear as three lerps rather than four weights, because a perceptual space
|
|
751
|
+
* has a midpoint between two colors and no meaningful four-way mix — OKLCh's
|
|
752
|
+
* hue in particular is an arc, which only two endpoints define.
|
|
753
|
+
*/
|
|
754
|
+
function colorAt(corners, u, v, space) {
|
|
755
|
+
return lerpColorArray(lerpColorArray(corners[0], corners[1], u, space), lerpColorArray(corners[3], corners[2], u, space), v, space);
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Rasterize `patches` into a square bitmap covering their union.
|
|
759
|
+
*
|
|
760
|
+
* Returns `null` when no patch is drawable, which is the caller's cue to paint
|
|
761
|
+
* nothing rather than a blank square.
|
|
762
|
+
*/
|
|
763
|
+
function bakeMesh(patches, space = "rgb", size = 256) {
|
|
764
|
+
const box = meshBounds(patches);
|
|
765
|
+
if (!box) return null;
|
|
766
|
+
const pixels = new Uint8ClampedArray(size * size * 4);
|
|
767
|
+
const grid = gridFor(size);
|
|
768
|
+
const toTexel = (p) => ({
|
|
769
|
+
x: (p.x - box.x) / box.width * (size - 1) + .5,
|
|
770
|
+
y: (p.y - box.y) / box.height * (size - 1) + .5
|
|
771
|
+
});
|
|
772
|
+
for (const patch of patches) {
|
|
773
|
+
if (!isValidPatch(patch)) continue;
|
|
774
|
+
const corners = patch.colors.map((c) => resolveColor(c));
|
|
775
|
+
for (let i = 0; i < grid; i++) for (let j = 0; j < grid; j++) {
|
|
776
|
+
const u0 = i / grid;
|
|
777
|
+
const u1 = (i + 1) / grid;
|
|
778
|
+
const v0 = j / grid;
|
|
779
|
+
const v1 = (j + 1) / grid;
|
|
780
|
+
const quad = [
|
|
781
|
+
{
|
|
782
|
+
at: toTexel(evalPatch(patch, u0, v0)),
|
|
783
|
+
color: colorAt(corners, u0, v0, space)
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
at: toTexel(evalPatch(patch, u1, v0)),
|
|
787
|
+
color: colorAt(corners, u1, v0, space)
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
at: toTexel(evalPatch(patch, u1, v1)),
|
|
791
|
+
color: colorAt(corners, u1, v1, space)
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
at: toTexel(evalPatch(patch, u0, v1)),
|
|
795
|
+
color: colorAt(corners, u0, v1, space)
|
|
796
|
+
}
|
|
797
|
+
];
|
|
798
|
+
fillTriangle(pixels, size, quad[0], quad[1], quad[2]);
|
|
799
|
+
fillTriangle(pixels, size, quad[0], quad[2], quad[3]);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
return {
|
|
803
|
+
pixels,
|
|
804
|
+
size,
|
|
805
|
+
box
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* One triangle, barycentric, colors interpolated across it.
|
|
810
|
+
*
|
|
811
|
+
* Neighboring cells share an edge, so a pixel exactly on one is claimed by
|
|
812
|
+
* both — harmless here because both carry the same color there, and cheaper
|
|
813
|
+
* than a fill rule.
|
|
814
|
+
*/
|
|
815
|
+
function fillTriangle(pixels, size, a, b, c) {
|
|
816
|
+
const minX = Math.max(0, Math.floor(Math.min(a.at.x, b.at.x, c.at.x)));
|
|
817
|
+
const maxX = Math.min(size - 1, Math.ceil(Math.max(a.at.x, b.at.x, c.at.x)));
|
|
818
|
+
const minY = Math.max(0, Math.floor(Math.min(a.at.y, b.at.y, c.at.y)));
|
|
819
|
+
const maxY = Math.min(size - 1, Math.ceil(Math.max(a.at.y, b.at.y, c.at.y)));
|
|
820
|
+
if (maxX < minX || maxY < minY) return;
|
|
821
|
+
const area = (b.at.x - a.at.x) * (c.at.y - a.at.y) - (c.at.x - a.at.x) * (b.at.y - a.at.y);
|
|
822
|
+
if (Math.abs(area) < 1e-9) return;
|
|
823
|
+
for (let y = minY; y <= maxY; y++) for (let x = minX; x <= maxX; x++) {
|
|
824
|
+
const px = x + .5;
|
|
825
|
+
const py = y + .5;
|
|
826
|
+
const w0 = ((b.at.x - px) * (c.at.y - py) - (c.at.x - px) * (b.at.y - py)) / area;
|
|
827
|
+
const w1 = ((c.at.x - px) * (a.at.y - py) - (a.at.x - px) * (c.at.y - py)) / area;
|
|
828
|
+
const w2 = 1 - w0 - w1;
|
|
829
|
+
if (w0 < -1e-6 || w1 < -1e-6 || w2 < -1e-6) continue;
|
|
830
|
+
const k = (y * size + x) * 4;
|
|
831
|
+
for (let ch = 0; ch < 4; ch++) pixels[k + ch] = (w0 * a.color[ch] + w1 * b.color[ch] + w2 * c.color[ch]) * 255;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
/** The largest bake, whatever the context allows: 16 MiB of RGBA, and a bake
|
|
835
|
+
* that already takes a noticeable moment on the CPU. */
|
|
836
|
+
const MESH_BAKE_MAX = 2048;
|
|
837
|
+
/** Bytes of baked texture one renderer keeps before evicting the least
|
|
838
|
+
* recently drawn. */
|
|
839
|
+
const MESH_BAKE_CACHE_BYTES = 67108864;
|
|
840
|
+
/**
|
|
841
|
+
* The bake side for a paint drawn `devicePx` device pixels across, on a
|
|
842
|
+
* context accepting `maxTextureSize`: the next power of two at or above it,
|
|
843
|
+
* clamped to `[MESH_BAKE_MIN, MESH_BAKE_MAX]` and to the context. A size that
|
|
844
|
+
* cannot be measured gets `MESH_BAKE_SIZE`.
|
|
845
|
+
*/
|
|
846
|
+
function meshBakeSize(devicePx, maxTextureSize) {
|
|
847
|
+
const ceiling = Math.min(MESH_BAKE_MAX, floorPow2(maxTextureSize));
|
|
848
|
+
if (Number.isNaN(devicePx)) return Math.min(256, ceiling);
|
|
849
|
+
if (devicePx <= 32) return Math.min(32, ceiling);
|
|
850
|
+
if (devicePx >= ceiling) return ceiling;
|
|
851
|
+
return Math.min(ceiling, 2 ** Math.ceil(Math.log2(devicePx)));
|
|
852
|
+
}
|
|
853
|
+
function floorPow2(n) {
|
|
854
|
+
if (!(n >= 1)) return 32;
|
|
855
|
+
if (!Number.isFinite(n)) return MESH_BAKE_MAX;
|
|
856
|
+
return 2 ** Math.floor(Math.log2(n));
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Bakes keyed by paint and bake size, least recently used first out.
|
|
860
|
+
*
|
|
861
|
+
* The paint is held weakly, so a paint nobody draws any more does not pin its
|
|
862
|
+
* key; its texture stays until eviction reaches it, which the bounds keep
|
|
863
|
+
* finite. `free` runs for every value that leaves, by eviction, replacement or
|
|
864
|
+
* `clear`.
|
|
865
|
+
*/
|
|
866
|
+
var MeshBakeCache = class {
|
|
867
|
+
free;
|
|
868
|
+
budgetBytes;
|
|
869
|
+
maxEntries;
|
|
870
|
+
byPaint = /* @__PURE__ */ new WeakMap();
|
|
871
|
+
/** Insertion order is recency: a hit is deleted and re-added. */
|
|
872
|
+
order = /* @__PURE__ */ new Set();
|
|
873
|
+
held = 0;
|
|
874
|
+
constructor(free, budgetBytes = MESH_BAKE_CACHE_BYTES, maxEntries = 256) {
|
|
875
|
+
this.free = free;
|
|
876
|
+
this.budgetBytes = budgetBytes;
|
|
877
|
+
this.maxEntries = maxEntries;
|
|
878
|
+
}
|
|
879
|
+
/** Bytes the held bakes occupy, as RGBA8. */
|
|
880
|
+
get bytes() {
|
|
881
|
+
return this.held;
|
|
882
|
+
}
|
|
883
|
+
/** Bakes held. */
|
|
884
|
+
get size() {
|
|
885
|
+
return this.order.size;
|
|
886
|
+
}
|
|
887
|
+
get(paint, size) {
|
|
888
|
+
const entry = this.byPaint.get(paint)?.get(size);
|
|
889
|
+
if (!entry) return void 0;
|
|
890
|
+
this.order.delete(entry);
|
|
891
|
+
this.order.add(entry);
|
|
892
|
+
return entry.value;
|
|
893
|
+
}
|
|
894
|
+
set(paint, size, value) {
|
|
895
|
+
let bySize = this.byPaint.get(paint);
|
|
896
|
+
if (!bySize) {
|
|
897
|
+
bySize = /* @__PURE__ */ new Map();
|
|
898
|
+
this.byPaint.set(paint, bySize);
|
|
899
|
+
}
|
|
900
|
+
const old = bySize.get(size);
|
|
901
|
+
if (old) this.drop(old);
|
|
902
|
+
const entry = {
|
|
903
|
+
value,
|
|
904
|
+
size,
|
|
905
|
+
bySize
|
|
906
|
+
};
|
|
907
|
+
bySize.set(size, entry);
|
|
908
|
+
this.order.add(entry);
|
|
909
|
+
this.held += size * size * 4;
|
|
910
|
+
this.evict(entry);
|
|
911
|
+
}
|
|
912
|
+
/** Free every bake. The cache stays usable. */
|
|
913
|
+
clear() {
|
|
914
|
+
for (const entry of [...this.order]) this.drop(entry);
|
|
915
|
+
}
|
|
916
|
+
/** Oldest first until both bounds hold, never evicting `keep` — the bake
|
|
917
|
+
* the caller is about to draw. */
|
|
918
|
+
evict(keep) {
|
|
919
|
+
for (const entry of this.order) {
|
|
920
|
+
if (this.held <= this.budgetBytes && this.order.size <= this.maxEntries) return;
|
|
921
|
+
if (entry !== keep) this.drop(entry);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
drop(entry) {
|
|
925
|
+
if (!this.order.delete(entry)) return;
|
|
926
|
+
entry.bySize.delete(entry.size);
|
|
927
|
+
this.held -= entry.size * entry.size * 4;
|
|
928
|
+
this.free(entry.value);
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
//#endregion
|
|
932
|
+
//#region src/features/meshPaint/meshShader.ts
|
|
933
|
+
/**
|
|
934
|
+
* GLSL ES 3.0 sources for the mesh-gradient paint.
|
|
935
|
+
*
|
|
936
|
+
* The vertex stage is the pattern/gradient one: a path fill mesh carries
|
|
937
|
+
* `a_position` only, so paint-space coordinates come back per fragment from
|
|
938
|
+
* the screen position through `u_worldInv`. The fragment stage is a clamped
|
|
939
|
+
* texture read of the baked mesh, with everything outside the bake's box
|
|
940
|
+
* transparent — a mesh covers the area its patches cover, not the whole shape
|
|
941
|
+
* it is filling, and a clamped read would otherwise smear its border colors
|
|
942
|
+
* across the rest.
|
|
943
|
+
*
|
|
944
|
+
* `u_meshOrigin` / `u_meshSize` are the bake's box in paint space, and the
|
|
945
|
+
* bake maps that box onto texel *centers*, which is the half-texel the uv
|
|
946
|
+
* rescale accounts for.
|
|
947
|
+
*
|
|
948
|
+
* Output convention §2: PREMULTIPLIED alpha.
|
|
949
|
+
*/
|
|
950
|
+
/** The id this program is registered under. */
|
|
951
|
+
const MESH_PROGRAM_ID = "kit:mesh-gradient";
|
|
952
|
+
const MESH_VERT_SRC = `#version 300 es
|
|
953
|
+
in vec2 a_position;
|
|
954
|
+
uniform mat3 u_proj;
|
|
955
|
+
uniform mat3 u_model;
|
|
956
|
+
uniform mat3 u_worldInv;
|
|
957
|
+
out vec2 v_world;
|
|
958
|
+
void main() {
|
|
959
|
+
vec3 screen = u_model * vec3(a_position, 1.0);
|
|
960
|
+
vec3 clip = u_proj * vec3(screen.xy, 1.0);
|
|
961
|
+
gl_Position = vec4(clip.xy, 0.0, 1.0);
|
|
962
|
+
vec3 world = u_worldInv * vec3(screen.xy, 1.0);
|
|
963
|
+
v_world = world.xy;
|
|
964
|
+
}
|
|
965
|
+
`;
|
|
966
|
+
const MESH_FRAG_SRC = `#version 300 es
|
|
967
|
+
precision highp float;
|
|
968
|
+
in vec2 v_world;
|
|
969
|
+
uniform sampler2D u_sampler;
|
|
970
|
+
uniform vec2 u_meshOrigin;
|
|
971
|
+
uniform vec2 u_meshSize;
|
|
972
|
+
uniform float u_opacity;
|
|
973
|
+
uniform float u_alpha;
|
|
974
|
+
out vec4 outColor;
|
|
975
|
+
void main() {
|
|
976
|
+
vec2 t =(v_world - u_meshOrigin) / max(u_meshSize, vec2(0.0001));
|
|
977
|
+
if (t.x < 0.0 || t.x > 1.0 || t.y < 0.0 || t.y > 1.0) {
|
|
978
|
+
outColor = vec4(0.0);
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
vec2 texels = vec2(textureSize(u_sampler, 0));
|
|
982
|
+
vec2 uv = (t * (texels - 1.0) + 0.5) / texels;
|
|
983
|
+
vec4 texel = texture(u_sampler, uv);
|
|
984
|
+
float a = texel.a * u_opacity * u_alpha;
|
|
985
|
+
outColor = vec4(texel.rgb * a, a);
|
|
986
|
+
}
|
|
987
|
+
`;
|
|
988
|
+
//#endregion
|
|
989
|
+
//#region src/features/meshPaint/meshPaint.ts
|
|
990
|
+
/** The kind's id, as `FillStyle['fill']` carries it. */
|
|
991
|
+
const MESH_GRADIENT_KIND = "mesh-gradient";
|
|
992
|
+
function asMesh(fill) {
|
|
993
|
+
return fill;
|
|
994
|
+
}
|
|
995
|
+
function asFill(mesh) {
|
|
996
|
+
return mesh;
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* `color` moved in OKLCh — lightness, chroma and hue by the given deltas, with
|
|
1000
|
+
* its alpha kept. The seed's corners come from one color, and they have to
|
|
1001
|
+
* differ enough to read as a mesh rather than as a flat fill.
|
|
1002
|
+
*/
|
|
1003
|
+
function shifted(color, dL, cScale, dHueDeg) {
|
|
1004
|
+
const [r, g, b, a] = resolveColor(color);
|
|
1005
|
+
const [L, A, B] = srgbFloatToOklab(r, g, b);
|
|
1006
|
+
const [, C, h] = oklabToOklch(L, A, B);
|
|
1007
|
+
const [nL, nA, nB] = oklchToOklab(Math.min(1, Math.max(0, L + dL)), Math.max(0, C * cScale), h + dHueDeg * Math.PI / 180);
|
|
1008
|
+
const [nr, ng, nb] = oklabToSrgbU8(nL, nA, nB);
|
|
1009
|
+
return rgbaToHex([
|
|
1010
|
+
nr / 255,
|
|
1011
|
+
ng / 255,
|
|
1012
|
+
nb / 255,
|
|
1013
|
+
a
|
|
1014
|
+
]);
|
|
1015
|
+
}
|
|
1016
|
+
/** A one-patch square covering the unit box, its four corners four readings of
|
|
1017
|
+
* `color` — a mesh seeded from a solid has to show *something* curved, or
|
|
1018
|
+
* switching kind looks like nothing happened. */
|
|
1019
|
+
function seedMeshPatch(color) {
|
|
1020
|
+
const corners = [
|
|
1021
|
+
{
|
|
1022
|
+
x: 0,
|
|
1023
|
+
y: 0
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
x: 1,
|
|
1027
|
+
y: 0
|
|
1028
|
+
},
|
|
1029
|
+
{
|
|
1030
|
+
x: 1,
|
|
1031
|
+
y: 1
|
|
1032
|
+
},
|
|
1033
|
+
{
|
|
1034
|
+
x: 0,
|
|
1035
|
+
y: 1
|
|
1036
|
+
}
|
|
1037
|
+
];
|
|
1038
|
+
const points = [];
|
|
1039
|
+
for (let i = 0; i < 4; i++) {
|
|
1040
|
+
const a = corners[i];
|
|
1041
|
+
const b = corners[(i + 1) % 4];
|
|
1042
|
+
const nx = (b.y - a.y) * .125;
|
|
1043
|
+
const ny = -(b.x - a.x) * .125;
|
|
1044
|
+
points.push(a, {
|
|
1045
|
+
x: a.x + (b.x - a.x) / 3 + nx,
|
|
1046
|
+
y: a.y + (b.y - a.y) / 3 + ny
|
|
1047
|
+
}, {
|
|
1048
|
+
x: a.x + 2 * (b.x - a.x) / 3 + nx,
|
|
1049
|
+
y: a.y + 2 * (b.y - a.y) / 3 + ny
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
return {
|
|
1053
|
+
fill: MESH_GRADIENT_KIND,
|
|
1054
|
+
patches: [{
|
|
1055
|
+
points,
|
|
1056
|
+
colors: [
|
|
1057
|
+
color,
|
|
1058
|
+
shifted(color, .14, .85, 0),
|
|
1059
|
+
shifted(color, -.06, 1.1, 38),
|
|
1060
|
+
shifted(color, -.16, 1, -22)
|
|
1061
|
+
]
|
|
1062
|
+
}],
|
|
1063
|
+
units: "bounds"
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
/** The straight-edged patch covering `[x0, x1] × [0, 1]`, in walk order. */
|
|
1067
|
+
function bandPatch(x0, x1, left, right) {
|
|
1068
|
+
const corners = [
|
|
1069
|
+
{
|
|
1070
|
+
x: x0,
|
|
1071
|
+
y: 0
|
|
1072
|
+
},
|
|
1073
|
+
{
|
|
1074
|
+
x: x1,
|
|
1075
|
+
y: 0
|
|
1076
|
+
},
|
|
1077
|
+
{
|
|
1078
|
+
x: x1,
|
|
1079
|
+
y: 1
|
|
1080
|
+
},
|
|
1081
|
+
{
|
|
1082
|
+
x: x0,
|
|
1083
|
+
y: 1
|
|
1084
|
+
}
|
|
1085
|
+
];
|
|
1086
|
+
const points = [];
|
|
1087
|
+
for (let i = 0; i < 4; i++) {
|
|
1088
|
+
const a = corners[i];
|
|
1089
|
+
const b = corners[(i + 1) % 4];
|
|
1090
|
+
points.push(a, {
|
|
1091
|
+
x: a.x + (b.x - a.x) / 3,
|
|
1092
|
+
y: a.y + (b.y - a.y) / 3
|
|
1093
|
+
}, {
|
|
1094
|
+
x: a.x + 2 * (b.x - a.x) / 3,
|
|
1095
|
+
y: a.y + 2 * (b.y - a.y) / 3
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
return {
|
|
1099
|
+
points,
|
|
1100
|
+
colors: [
|
|
1101
|
+
left,
|
|
1102
|
+
right,
|
|
1103
|
+
right,
|
|
1104
|
+
left
|
|
1105
|
+
]
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
/**
|
|
1109
|
+
* A stop list as a mesh: one full-height band per gap between neighboring
|
|
1110
|
+
* stops, colored left to right. The bands blend exactly the way the ramp
|
|
1111
|
+
* does, so a horizontal gradient survives the switch unchanged. A zero-width
|
|
1112
|
+
* gap is a hard break and gets no band.
|
|
1113
|
+
*/
|
|
1114
|
+
function meshFromStops(stops) {
|
|
1115
|
+
const sorted = [...stops].sort((a, b) => a.offset - b.offset);
|
|
1116
|
+
if (sorted.length === 1) sorted.push({
|
|
1117
|
+
offset: 1,
|
|
1118
|
+
color: sorted[0].color
|
|
1119
|
+
});
|
|
1120
|
+
if (sorted.length === 0) return seedMeshPatch("#000000ff");
|
|
1121
|
+
const patches = [];
|
|
1122
|
+
for (let i = 0; i < sorted.length - 1; i++) {
|
|
1123
|
+
const a = sorted[i];
|
|
1124
|
+
const b = sorted[i + 1];
|
|
1125
|
+
if (b.offset > a.offset) patches.push(bandPatch(a.offset, b.offset, a.color, b.color));
|
|
1126
|
+
}
|
|
1127
|
+
return {
|
|
1128
|
+
fill: MESH_GRADIENT_KIND,
|
|
1129
|
+
patches,
|
|
1130
|
+
units: "bounds"
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* A mesh read as a stop list: every patch's top edge — corner 0 to corner 1 —
|
|
1135
|
+
* placed by its `x` across the mesh's horizontal extent. The inverse of
|
|
1136
|
+
* `meshFromStops`, and for any other mesh the ramp across its top.
|
|
1137
|
+
*/
|
|
1138
|
+
function meshStops(mesh) {
|
|
1139
|
+
const valid = mesh.patches.filter(isValidPatch);
|
|
1140
|
+
if (valid.length === 0) return [];
|
|
1141
|
+
const xs = valid.flatMap((p) => [p.points[0].x, p.points[3].x]);
|
|
1142
|
+
const lo = Math.min(...xs);
|
|
1143
|
+
const span = Math.max(...xs) - lo;
|
|
1144
|
+
const offsetOf = (x) => span > 0 ? (x - lo) / span : 0;
|
|
1145
|
+
const stops = [];
|
|
1146
|
+
for (const patch of valid) for (const [point, color] of [[patch.points[0], patch.colors[0]], [patch.points[3], patch.colors[1]]]) {
|
|
1147
|
+
const offset = offsetOf(point.x);
|
|
1148
|
+
if (!stops.some((s) => s.offset === offset && s.color === color)) stops.push({
|
|
1149
|
+
offset,
|
|
1150
|
+
color
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
return stops.sort((a, b) => a.offset - b.offset);
|
|
1154
|
+
}
|
|
1155
|
+
/** Every patch mapped through `move`. */
|
|
1156
|
+
function mapPatches(mesh, move) {
|
|
1157
|
+
return mesh.patches.map((patch) => ({
|
|
1158
|
+
...patch,
|
|
1159
|
+
points: patch.points.map(move)
|
|
1160
|
+
}));
|
|
1161
|
+
}
|
|
1162
|
+
const CACHES = /* @__PURE__ */ new WeakMap();
|
|
1163
|
+
function cacheFor(ctx) {
|
|
1164
|
+
let cache = CACHES.get(ctx.resources);
|
|
1165
|
+
if (!cache) {
|
|
1166
|
+
const gl = ctx.gl;
|
|
1167
|
+
const made = new MeshBakeCache((entry) => gl.deleteTexture(entry.texture));
|
|
1168
|
+
ctx.resources.onRelease(() => {
|
|
1169
|
+
made.clear();
|
|
1170
|
+
CACHES.delete(ctx.resources);
|
|
1171
|
+
});
|
|
1172
|
+
CACHES.set(ctx.resources, made);
|
|
1173
|
+
cache = made;
|
|
1174
|
+
}
|
|
1175
|
+
return cache;
|
|
1176
|
+
}
|
|
1177
|
+
/** Device pixels the larger side of `box` covers when drawn in `units`. */
|
|
1178
|
+
function devicePixelsOf(ctx, mesh, box) {
|
|
1179
|
+
const m = ctx.spaceToDevice(mesh.units);
|
|
1180
|
+
if (!m) return NaN;
|
|
1181
|
+
return Math.max(box.width * Math.hypot(m[0], m[1]), box.height * Math.hypot(m[3], m[4]));
|
|
1182
|
+
}
|
|
1183
|
+
function bakeFor(ctx, mesh) {
|
|
1184
|
+
const box = meshBounds(mesh.patches);
|
|
1185
|
+
if (!box) return null;
|
|
1186
|
+
const size = meshBakeSize(devicePixelsOf(ctx, mesh, box), ctx.maxTextureSize);
|
|
1187
|
+
const cache = cacheFor(ctx);
|
|
1188
|
+
const hit = cache.get(mesh, size);
|
|
1189
|
+
if (hit) return hit;
|
|
1190
|
+
const baked = bakeMesh(mesh.patches, mesh.interpolate ?? "rgb", size);
|
|
1191
|
+
if (!baked) return null;
|
|
1192
|
+
const gl = ctx.gl;
|
|
1193
|
+
const texture = gl.createTexture();
|
|
1194
|
+
if (!texture) return null;
|
|
1195
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
1196
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
1197
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
1198
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
1199
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
1200
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, baked.size, baked.size, 0, gl.RGBA, gl.UNSIGNED_BYTE, baked.pixels);
|
|
1201
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
1202
|
+
const entry = {
|
|
1203
|
+
texture,
|
|
1204
|
+
baked
|
|
1205
|
+
};
|
|
1206
|
+
cache.set(mesh, size, entry);
|
|
1207
|
+
return entry;
|
|
1208
|
+
}
|
|
1209
|
+
function bindMesh(ctx, fill) {
|
|
1210
|
+
const mesh = asMesh(fill);
|
|
1211
|
+
if (!mesh.patches.some(isValidPatch)) return null;
|
|
1212
|
+
const inverse = ctx.spaceInverse(mesh.units);
|
|
1213
|
+
if (!inverse) return null;
|
|
1214
|
+
const program = ctx.program(MESH_PROGRAM_ID);
|
|
1215
|
+
if (!program) return null;
|
|
1216
|
+
const entry = bakeFor(ctx, mesh);
|
|
1217
|
+
if (!entry) return null;
|
|
1218
|
+
const gl = ctx.gl;
|
|
1219
|
+
gl.useProgram(program.handle);
|
|
1220
|
+
ctx.setProjAndModel(program);
|
|
1221
|
+
gl.uniformMatrix3fv(program.uniform("u_worldInv"), false, inverse);
|
|
1222
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
1223
|
+
gl.bindTexture(gl.TEXTURE_2D, entry.texture);
|
|
1224
|
+
gl.uniform1i(program.uniform("u_sampler"), 0);
|
|
1225
|
+
const { box } = entry.baked;
|
|
1226
|
+
gl.uniform2f(program.uniform("u_meshOrigin"), box.x, box.y);
|
|
1227
|
+
gl.uniform2f(program.uniform("u_meshSize"), box.width, box.height);
|
|
1228
|
+
gl.uniform1f(program.uniform("u_opacity"), mesh.opacity ?? 1);
|
|
1229
|
+
gl.uniform1f(program.uniform("u_alpha"), ctx.alpha);
|
|
1230
|
+
return program;
|
|
1231
|
+
}
|
|
1232
|
+
/** The kind's registry entry, shader program included. `./register` registers
|
|
1233
|
+
* it; core's paint-kind registry loads it on demand otherwise. */
|
|
1234
|
+
const meshGradientKind = {
|
|
1235
|
+
id: MESH_GRADIENT_KIND,
|
|
1236
|
+
programs: { [MESH_PROGRAM_ID]: {
|
|
1237
|
+
vert: MESH_VERT_SRC,
|
|
1238
|
+
frag: MESH_FRAG_SRC
|
|
1239
|
+
} },
|
|
1240
|
+
label: "Mesh",
|
|
1241
|
+
icon: "paintMesh",
|
|
1242
|
+
seed: (color) => asFill(seedMeshPatch(color)),
|
|
1243
|
+
colorOf: (paint) => asMesh(paint).patches?.[0]?.colors?.[0],
|
|
1244
|
+
stopsOf: (paint) => meshStops(asMesh(paint)),
|
|
1245
|
+
fromStops: (stops) => asFill(meshFromStops(stops)),
|
|
1246
|
+
bind: bindMesh,
|
|
1247
|
+
inPoseFrame: (fill, box) => {
|
|
1248
|
+
const mesh = asMesh(fill);
|
|
1249
|
+
if (mesh.units !== "bounds") return fill;
|
|
1250
|
+
return asFill({
|
|
1251
|
+
...mesh,
|
|
1252
|
+
patches: mapPatches(mesh, (p) => ({
|
|
1253
|
+
x: box.x + p.x * box.width,
|
|
1254
|
+
y: box.y + p.y * box.height
|
|
1255
|
+
})),
|
|
1256
|
+
units: "local"
|
|
1257
|
+
});
|
|
1258
|
+
},
|
|
1259
|
+
toBoundsFrame: (fill, box) => {
|
|
1260
|
+
const mesh = asMesh(fill);
|
|
1261
|
+
if (mesh.units === "bounds" || box.width === 0 || box.height === 0) return fill;
|
|
1262
|
+
return asFill({
|
|
1263
|
+
...mesh,
|
|
1264
|
+
patches: mapPatches(mesh, (p) => ({
|
|
1265
|
+
x: (p.x - box.x) / box.width,
|
|
1266
|
+
y: (p.y - box.y) / box.height
|
|
1267
|
+
})),
|
|
1268
|
+
units: "bounds"
|
|
1269
|
+
});
|
|
1270
|
+
},
|
|
1271
|
+
toSvg: (id, fill) => meshGradientXml(id, asMesh(fill))
|
|
1272
|
+
};
|
|
1273
|
+
/**
|
|
1274
|
+
* The `<defs>` entry for a mesh paint, in weasel's own namespace.
|
|
1275
|
+
*
|
|
1276
|
+
* Not SVG's abandoned `<meshgradient>`: that vocabulary only reaches Coons
|
|
1277
|
+
* patches, shares patch edges implicitly — a reader that gets the sharing
|
|
1278
|
+
* wrong tears the surface rather than failing outright — and has exactly one
|
|
1279
|
+
* implementation in the world. Ours writes every patch's points in full.
|
|
1280
|
+
* `@weasel-js/svg` puts the paint fallback color beside the reference, so a
|
|
1281
|
+
* foreign renderer paints flat instead of nothing.
|
|
1282
|
+
*/
|
|
1283
|
+
function meshGradientXml(id, mesh) {
|
|
1284
|
+
const P = "wzl";
|
|
1285
|
+
return `<${P}:meshGradient id="${id}" gradientUnits="${mesh.units === "bounds" ? "objectBoundingBox" : "userSpaceOnUse"}"${mesh.interpolate && mesh.interpolate !== "rgb" ? ` interpolate="${mesh.interpolate}"` : ""}>${mesh.patches.map((patch) => {
|
|
1286
|
+
const points = patch.points.map((p) => `${trim(p.x)},${trim(p.y)}`).join(" ");
|
|
1287
|
+
const colors = patch.colors.join(" ");
|
|
1288
|
+
return `<${P}:patch points="${points}" colors="${colors}"/>`;
|
|
1289
|
+
}).join("")}</${P}:meshGradient>`;
|
|
1290
|
+
}
|
|
1291
|
+
/** Short decimals, matching what `@weasel-js/svg` writes elsewhere. */
|
|
1292
|
+
function trim(n) {
|
|
1293
|
+
return Number.isInteger(n) ? String(n) : String(Number(n.toFixed(4)));
|
|
1294
|
+
}
|
|
1295
|
+
//#endregion
|
|
1296
|
+
export { meshGradientKind };
|
|
1297
|
+
|
|
1298
|
+
//# sourceMappingURL=lazyKind.js.map
|