@twick/2d 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/editor/editor/NodeInspectorConfig.d.ts +3 -0
- package/editor/editor/NodeInspectorConfig.d.ts.map +1 -0
- package/editor/editor/PreviewOverlayConfig.d.ts +3 -0
- package/editor/editor/PreviewOverlayConfig.d.ts.map +1 -0
- package/editor/editor/Provider.d.ts +17 -0
- package/editor/editor/Provider.d.ts.map +1 -0
- package/editor/editor/SceneGraphTabConfig.d.ts +3 -0
- package/editor/editor/SceneGraphTabConfig.d.ts.map +1 -0
- package/editor/editor/icons/CircleIcon.d.ts +2 -0
- package/editor/editor/icons/CircleIcon.d.ts.map +1 -0
- package/editor/editor/icons/CodeBlockIcon.d.ts +2 -0
- package/editor/editor/icons/CodeBlockIcon.d.ts.map +1 -0
- package/editor/editor/icons/CurveIcon.d.ts +2 -0
- package/editor/editor/icons/CurveIcon.d.ts.map +1 -0
- package/editor/editor/icons/GridIcon.d.ts +2 -0
- package/editor/editor/icons/GridIcon.d.ts.map +1 -0
- package/editor/editor/icons/IconMap.d.ts +3 -0
- package/editor/editor/icons/IconMap.d.ts.map +1 -0
- package/editor/editor/icons/ImgIcon.d.ts +2 -0
- package/editor/editor/icons/ImgIcon.d.ts.map +1 -0
- package/editor/editor/icons/LayoutIcon.d.ts +2 -0
- package/editor/editor/icons/LayoutIcon.d.ts.map +1 -0
- package/editor/editor/icons/LineIcon.d.ts +2 -0
- package/editor/editor/icons/LineIcon.d.ts.map +1 -0
- package/editor/editor/icons/NodeIcon.d.ts +2 -0
- package/editor/editor/icons/NodeIcon.d.ts.map +1 -0
- package/editor/editor/icons/RayIcon.d.ts +2 -0
- package/editor/editor/icons/RayIcon.d.ts.map +1 -0
- package/editor/editor/icons/RectIcon.d.ts +2 -0
- package/editor/editor/icons/RectIcon.d.ts.map +1 -0
- package/editor/editor/icons/ShapeIcon.d.ts +2 -0
- package/editor/editor/icons/ShapeIcon.d.ts.map +1 -0
- package/editor/editor/icons/TxtIcon.d.ts +2 -0
- package/editor/editor/icons/TxtIcon.d.ts.map +1 -0
- package/editor/editor/icons/VideoIcon.d.ts +2 -0
- package/editor/editor/icons/VideoIcon.d.ts.map +1 -0
- package/editor/editor/icons/View2DIcon.d.ts +2 -0
- package/editor/editor/icons/View2DIcon.d.ts.map +1 -0
- package/editor/editor/index.d.ts +4 -0
- package/editor/editor/index.d.ts.map +1 -0
- package/editor/editor/tree/DetachedRoot.d.ts +2 -0
- package/editor/editor/tree/DetachedRoot.d.ts.map +1 -0
- package/editor/editor/tree/NodeElement.d.ts +8 -0
- package/editor/editor/tree/NodeElement.d.ts.map +1 -0
- package/editor/editor/tree/TreeElement.d.ts +15 -0
- package/editor/editor/tree/TreeElement.d.ts.map +1 -0
- package/editor/editor/tree/TreeRoot.d.ts +3 -0
- package/editor/editor/tree/TreeRoot.d.ts.map +1 -0
- package/editor/editor/tree/ViewRoot.d.ts +2 -0
- package/editor/editor/tree/ViewRoot.d.ts.map +1 -0
- package/editor/editor/tree/index.d.ts +4 -0
- package/editor/editor/tree/index.d.ts.map +1 -0
- package/editor/editor/tsconfig.build.tsbuildinfo +1 -0
- package/editor/index.css +33 -0
- package/editor/index.js +341 -0
- package/editor/index.js.map +1 -0
- package/lib/code/CodeCursor.d.ts +83 -0
- package/lib/code/CodeCursor.d.ts.map +1 -0
- package/lib/code/CodeCursor.js +306 -0
- package/lib/code/CodeDiffer.d.ts +28 -0
- package/lib/code/CodeDiffer.d.ts.map +1 -0
- package/lib/code/CodeDiffer.js +51 -0
- package/lib/code/CodeFragment.d.ts +42 -0
- package/lib/code/CodeFragment.d.ts.map +1 -0
- package/lib/code/CodeFragment.js +72 -0
- package/lib/code/CodeHighlighter.d.ts +71 -0
- package/lib/code/CodeHighlighter.d.ts.map +1 -0
- package/lib/code/CodeHighlighter.js +2 -0
- package/lib/code/CodeMetrics.d.ts +11 -0
- package/lib/code/CodeMetrics.d.ts.map +1 -0
- package/lib/code/CodeMetrics.js +29 -0
- package/lib/code/CodeRange.d.ts +41 -0
- package/lib/code/CodeRange.d.ts.map +1 -0
- package/lib/code/CodeRange.js +179 -0
- package/lib/code/CodeScope.d.ts +16 -0
- package/lib/code/CodeScope.d.ts.map +1 -0
- package/lib/code/CodeScope.js +72 -0
- package/lib/code/CodeSelection.d.ts +6 -0
- package/lib/code/CodeSelection.d.ts.map +1 -0
- package/lib/code/CodeSelection.js +13 -0
- package/lib/code/CodeSignal.d.ts +60 -0
- package/lib/code/CodeSignal.d.ts.map +1 -0
- package/lib/code/CodeSignal.js +194 -0
- package/lib/code/CodeTokenizer.d.ts +8 -0
- package/lib/code/CodeTokenizer.d.ts.map +1 -0
- package/lib/code/CodeTokenizer.js +50 -0
- package/lib/code/DefaultHighlightStyle.d.ts +3 -0
- package/lib/code/DefaultHighlightStyle.d.ts.map +1 -0
- package/lib/code/DefaultHighlightStyle.js +98 -0
- package/lib/code/LezerHighlighter.d.ts +22 -0
- package/lib/code/LezerHighlighter.d.ts.map +1 -0
- package/lib/code/LezerHighlighter.js +89 -0
- package/lib/code/diff.d.ts +31 -0
- package/lib/code/diff.d.ts.map +1 -0
- package/lib/code/diff.js +236 -0
- package/lib/code/extractRange.d.ts +17 -0
- package/lib/code/extractRange.d.ts.map +1 -0
- package/lib/code/extractRange.js +102 -0
- package/lib/code/index.d.ts +14 -0
- package/lib/code/index.d.ts.map +1 -0
- package/lib/code/index.js +14 -0
- package/lib/components/Audio.d.ts +14 -0
- package/lib/components/Audio.d.ts.map +1 -0
- package/lib/components/Audio.js +118 -0
- package/lib/components/Bezier.d.ts +23 -0
- package/lib/components/Bezier.d.ts.map +1 -0
- package/lib/components/Bezier.js +81 -0
- package/lib/components/Circle.d.ts +193 -0
- package/lib/components/Circle.d.ts.map +1 -0
- package/lib/components/Circle.js +178 -0
- package/lib/components/Code.d.ts +231 -0
- package/lib/components/Code.d.ts.map +1 -0
- package/lib/components/Code.js +325 -0
- package/lib/components/CodeBlock.d.ts +133 -0
- package/lib/components/CodeBlock.d.ts.map +1 -0
- package/lib/components/CodeBlock.js +461 -0
- package/lib/components/CubicBezier.d.ts +70 -0
- package/lib/components/CubicBezier.d.ts.map +1 -0
- package/lib/components/CubicBezier.js +81 -0
- package/lib/components/Curve.d.ts +204 -0
- package/lib/components/Curve.d.ts.map +1 -0
- package/lib/components/Curve.js +284 -0
- package/lib/components/Grid.d.ts +76 -0
- package/lib/components/Grid.d.ts.map +1 -0
- package/lib/components/Grid.js +91 -0
- package/lib/components/Icon.d.ts +59 -0
- package/lib/components/Icon.d.ts.map +1 -0
- package/lib/components/Icon.js +58 -0
- package/lib/components/Img.d.ts +118 -0
- package/lib/components/Img.d.ts.map +1 -0
- package/lib/components/Img.js +245 -0
- package/lib/components/Knot.d.ts +90 -0
- package/lib/components/Knot.d.ts.map +1 -0
- package/lib/components/Knot.js +68 -0
- package/lib/components/Latex.d.ts +39 -0
- package/lib/components/Latex.d.ts.map +1 -0
- package/lib/components/Latex.js +101 -0
- package/lib/components/Layout.d.ts +419 -0
- package/lib/components/Layout.d.ts.map +1 -0
- package/lib/components/Layout.js +706 -0
- package/lib/components/Line.d.ts +160 -0
- package/lib/components/Line.d.ts.map +1 -0
- package/lib/components/Line.js +346 -0
- package/lib/components/Media.d.ts +65 -0
- package/lib/components/Media.d.ts.map +1 -0
- package/lib/components/Media.js +303 -0
- package/lib/components/Node.d.ts +836 -0
- package/lib/components/Node.d.ts.map +1 -0
- package/lib/components/Node.js +1317 -0
- package/lib/components/Path.d.ts +20 -0
- package/lib/components/Path.d.ts.map +1 -0
- package/lib/components/Path.js +97 -0
- package/lib/components/Polygon.d.ts +113 -0
- package/lib/components/Polygon.d.ts.map +1 -0
- package/lib/components/Polygon.js +123 -0
- package/lib/components/QuadBezier.d.ts +62 -0
- package/lib/components/QuadBezier.d.ts.map +1 -0
- package/lib/components/QuadBezier.js +76 -0
- package/lib/components/Ray.d.ts +62 -0
- package/lib/components/Ray.d.ts.map +1 -0
- package/lib/components/Ray.js +96 -0
- package/lib/components/Rect.d.ts +114 -0
- package/lib/components/Rect.d.ts.map +1 -0
- package/lib/components/Rect.js +76 -0
- package/lib/components/Rive.d.ts +22 -0
- package/lib/components/Rive.d.ts.map +1 -0
- package/lib/components/Rive.js +117 -0
- package/lib/components/SVG.d.ts +178 -0
- package/lib/components/SVG.d.ts.map +1 -0
- package/lib/components/SVG.js +577 -0
- package/lib/components/Shape.d.ts +40 -0
- package/lib/components/Shape.d.ts.map +1 -0
- package/lib/components/Shape.js +134 -0
- package/lib/components/Spline.d.ts +89 -0
- package/lib/components/Spline.d.ts.map +1 -0
- package/lib/components/Spline.js +256 -0
- package/lib/components/Txt.d.ts +53 -0
- package/lib/components/Txt.d.ts.map +1 -0
- package/lib/components/Txt.js +173 -0
- package/lib/components/TxtLeaf.d.ts +21 -0
- package/lib/components/TxtLeaf.d.ts.map +1 -0
- package/lib/components/TxtLeaf.js +181 -0
- package/lib/components/Video.d.ts +69 -0
- package/lib/components/Video.d.ts.map +1 -0
- package/lib/components/Video.js +283 -0
- package/lib/components/View2D.d.ts +28 -0
- package/lib/components/View2D.d.ts.map +1 -0
- package/lib/components/View2D.js +93 -0
- package/lib/components/index.d.ts +29 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/index.js +29 -0
- package/lib/components/types.d.ts +17 -0
- package/lib/components/types.d.ts.map +1 -0
- package/lib/components/types.js +2 -0
- package/lib/curves/ArcSegment.d.ts +26 -0
- package/lib/curves/ArcSegment.d.ts.map +1 -0
- package/lib/curves/ArcSegment.js +97 -0
- package/lib/curves/CircleSegment.d.ts +18 -0
- package/lib/curves/CircleSegment.d.ts.map +1 -0
- package/lib/curves/CircleSegment.js +52 -0
- package/lib/curves/CubicBezierSegment.d.ts +18 -0
- package/lib/curves/CubicBezierSegment.d.ts.map +1 -0
- package/lib/curves/CubicBezierSegment.js +55 -0
- package/lib/curves/CurveDrawingInfo.d.ts +11 -0
- package/lib/curves/CurveDrawingInfo.d.ts.map +1 -0
- package/lib/curves/CurveDrawingInfo.js +2 -0
- package/lib/curves/CurvePoint.d.ts +15 -0
- package/lib/curves/CurvePoint.d.ts.map +1 -0
- package/lib/curves/CurvePoint.js +2 -0
- package/lib/curves/CurveProfile.d.ts +7 -0
- package/lib/curves/CurveProfile.d.ts.map +1 -0
- package/lib/curves/CurveProfile.js +2 -0
- package/lib/curves/KnotInfo.d.ts +12 -0
- package/lib/curves/KnotInfo.d.ts.map +1 -0
- package/lib/curves/KnotInfo.js +2 -0
- package/lib/curves/LineSegment.d.ts +16 -0
- package/lib/curves/LineSegment.d.ts.map +1 -0
- package/lib/curves/LineSegment.js +45 -0
- package/lib/curves/Polynomial.d.ts +118 -0
- package/lib/curves/Polynomial.d.ts.map +1 -0
- package/lib/curves/Polynomial.js +259 -0
- package/lib/curves/Polynomial2D.d.ts +22 -0
- package/lib/curves/Polynomial2D.d.ts.map +1 -0
- package/lib/curves/Polynomial2D.js +45 -0
- package/lib/curves/PolynomialSegment.d.ts +39 -0
- package/lib/curves/PolynomialSegment.d.ts.map +1 -0
- package/lib/curves/PolynomialSegment.js +86 -0
- package/lib/curves/QuadBezierSegment.d.ts +17 -0
- package/lib/curves/QuadBezierSegment.d.ts.map +1 -0
- package/lib/curves/QuadBezierSegment.js +49 -0
- package/lib/curves/Segment.d.ts +9 -0
- package/lib/curves/Segment.d.ts.map +1 -0
- package/lib/curves/Segment.js +3 -0
- package/lib/curves/UniformPolynomialCurveSampler.d.ts +43 -0
- package/lib/curves/UniformPolynomialCurveSampler.d.ts.map +1 -0
- package/lib/curves/UniformPolynomialCurveSampler.js +73 -0
- package/lib/curves/createCurveProfileLerp.d.ts +32 -0
- package/lib/curves/createCurveProfileLerp.d.ts.map +1 -0
- package/lib/curves/createCurveProfileLerp.js +351 -0
- package/lib/curves/getBezierSplineProfile.d.ts +12 -0
- package/lib/curves/getBezierSplineProfile.d.ts.map +1 -0
- package/lib/curves/getBezierSplineProfile.js +137 -0
- package/lib/curves/getCircleProfile.d.ts +4 -0
- package/lib/curves/getCircleProfile.d.ts.map +1 -0
- package/lib/curves/getCircleProfile.js +44 -0
- package/lib/curves/getPathProfile.d.ts +3 -0
- package/lib/curves/getPathProfile.d.ts.map +1 -0
- package/lib/curves/getPathProfile.js +128 -0
- package/lib/curves/getPointAtDistance.d.ts +4 -0
- package/lib/curves/getPointAtDistance.d.ts.map +1 -0
- package/lib/curves/getPointAtDistance.js +15 -0
- package/lib/curves/getPolylineProfile.d.ts +4 -0
- package/lib/curves/getPolylineProfile.d.ts.map +1 -0
- package/lib/curves/getPolylineProfile.js +58 -0
- package/lib/curves/getRectProfile.d.ts +4 -0
- package/lib/curves/getRectProfile.d.ts.map +1 -0
- package/lib/curves/getRectProfile.js +57 -0
- package/lib/curves/index.d.ts +17 -0
- package/lib/curves/index.d.ts.map +1 -0
- package/lib/curves/index.js +17 -0
- package/lib/decorators/canvasStyleSignal.d.ts +5 -0
- package/lib/decorators/canvasStyleSignal.d.ts.map +1 -0
- package/lib/decorators/canvasStyleSignal.js +12 -0
- package/lib/decorators/colorSignal.d.ts +2 -0
- package/lib/decorators/colorSignal.d.ts.map +1 -0
- package/lib/decorators/colorSignal.js +9 -0
- package/lib/decorators/compound.d.ts +26 -0
- package/lib/decorators/compound.d.ts.map +1 -0
- package/lib/decorators/compound.js +49 -0
- package/lib/decorators/computed.d.ts +9 -0
- package/lib/decorators/computed.d.ts.map +1 -0
- package/lib/decorators/computed.js +18 -0
- package/lib/decorators/defaultStyle.d.ts +2 -0
- package/lib/decorators/defaultStyle.d.ts.map +1 -0
- package/lib/decorators/defaultStyle.js +14 -0
- package/lib/decorators/filtersSignal.d.ts +13 -0
- package/lib/decorators/filtersSignal.d.ts.map +1 -0
- package/lib/decorators/filtersSignal.js +73 -0
- package/lib/decorators/index.d.ts +11 -0
- package/lib/decorators/index.d.ts.map +1 -0
- package/lib/decorators/index.js +11 -0
- package/lib/decorators/initializers.d.ts +4 -0
- package/lib/decorators/initializers.d.ts.map +1 -0
- package/lib/decorators/initializers.js +27 -0
- package/lib/decorators/nodeName.d.ts +9 -0
- package/lib/decorators/nodeName.d.ts.map +1 -0
- package/lib/decorators/nodeName.js +13 -0
- package/lib/decorators/signal.d.ts +183 -0
- package/lib/decorators/signal.d.ts.map +1 -0
- package/lib/decorators/signal.js +285 -0
- package/lib/decorators/spacingSignal.d.ts +2 -0
- package/lib/decorators/spacingSignal.d.ts.map +1 -0
- package/lib/decorators/spacingSignal.js +15 -0
- package/lib/decorators/vector2Signal.d.ts +9 -0
- package/lib/decorators/vector2Signal.d.ts.map +1 -0
- package/lib/decorators/vector2Signal.js +15 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +9 -0
- package/lib/jsx-dev-runtime.d.ts +3 -0
- package/lib/jsx-dev-runtime.d.ts.map +1 -0
- package/lib/jsx-dev-runtime.js +3 -0
- package/lib/jsx-runtime.d.ts +12 -0
- package/lib/jsx-runtime.d.ts.map +1 -0
- package/lib/jsx-runtime.js +23 -0
- package/lib/partials/Filter.d.ts +82 -0
- package/lib/partials/Filter.d.ts.map +1 -0
- package/lib/partials/Filter.js +135 -0
- package/lib/partials/Gradient.d.ts +31 -0
- package/lib/partials/Gradient.d.ts.map +1 -0
- package/lib/partials/Gradient.js +63 -0
- package/lib/partials/Pattern.d.ts +13 -0
- package/lib/partials/Pattern.d.ts.map +1 -0
- package/lib/partials/Pattern.js +27 -0
- package/lib/partials/ShaderConfig.d.ts +81 -0
- package/lib/partials/ShaderConfig.d.ts.map +1 -0
- package/lib/partials/ShaderConfig.js +25 -0
- package/lib/partials/index.d.ts +5 -0
- package/lib/partials/index.d.ts.map +1 -0
- package/lib/partials/index.js +5 -0
- package/lib/partials/types.d.ts +35 -0
- package/lib/partials/types.d.ts.map +1 -0
- package/lib/partials/types.js +2 -0
- package/lib/scenes/Scene2D.d.ts +29 -0
- package/lib/scenes/Scene2D.d.ts.map +1 -0
- package/lib/scenes/Scene2D.js +180 -0
- package/lib/scenes/index.d.ts +4 -0
- package/lib/scenes/index.d.ts.map +1 -0
- package/lib/scenes/index.js +4 -0
- package/lib/scenes/makeScene2D.d.ts +5 -0
- package/lib/scenes/makeScene2D.d.ts.map +1 -0
- package/lib/scenes/makeScene2D.js +11 -0
- package/lib/scenes/useScene2D.d.ts +3 -0
- package/lib/scenes/useScene2D.d.ts.map +1 -0
- package/lib/scenes/useScene2D.js +5 -0
- package/lib/tsconfig.build.tsbuildinfo +1 -0
- package/lib/utils/CanvasUtils.d.ts +23 -0
- package/lib/utils/CanvasUtils.d.ts.map +1 -0
- package/lib/utils/CanvasUtils.js +138 -0
- package/lib/utils/diff.d.ts +31 -0
- package/lib/utils/diff.d.ts.map +1 -0
- package/lib/utils/diff.js +97 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +3 -0
- package/lib/utils/is.d.ts +8 -0
- package/lib/utils/is.d.ts.map +1 -0
- package/lib/utils/is.js +10 -0
- package/lib/utils/makeSignalExtensions.d.ts +4 -0
- package/lib/utils/makeSignalExtensions.d.ts.map +1 -0
- package/lib/utils/makeSignalExtensions.js +20 -0
- package/lib/utils/video/ffmpeg-client.d.ts +5 -0
- package/lib/utils/video/ffmpeg-client.d.ts.map +1 -0
- package/lib/utils/video/ffmpeg-client.js +32 -0
- package/lib/utils/video/mp4-parser-manager.d.ts +3 -0
- package/lib/utils/video/mp4-parser-manager.d.ts.map +1 -0
- package/lib/utils/video/mp4-parser-manager.js +55 -0
- package/lib/utils/video/parser/index.d.ts +2 -0
- package/lib/utils/video/parser/index.d.ts.map +1 -0
- package/lib/utils/video/parser/index.js +2 -0
- package/lib/utils/video/parser/parser.d.ts +21 -0
- package/lib/utils/video/parser/parser.d.ts.map +1 -0
- package/lib/utils/video/parser/parser.js +168 -0
- package/lib/utils/video/parser/sampler.d.ts +16 -0
- package/lib/utils/video/parser/sampler.d.ts.map +1 -0
- package/lib/utils/video/parser/sampler.js +56 -0
- package/lib/utils/video/parser/segment.d.ts +48 -0
- package/lib/utils/video/parser/segment.d.ts.map +1 -0
- package/lib/utils/video/parser/segment.js +239 -0
- package/lib/utils/video/parser/sink.d.ts +9 -0
- package/lib/utils/video/parser/sink.d.ts.map +1 -0
- package/lib/utils/video/parser/sink.js +22 -0
- package/lib/utils/video/parser/utils.d.ts +10 -0
- package/lib/utils/video/parser/utils.d.ts.map +1 -0
- package/lib/utils/video/parser/utils.js +22 -0
- package/package.json +53 -0
- package/src/editor/NodeInspectorConfig.tsx +76 -0
- package/src/editor/PreviewOverlayConfig.tsx +67 -0
- package/src/editor/Provider.tsx +93 -0
- package/src/editor/SceneGraphTabConfig.tsx +81 -0
- package/src/editor/icons/CircleIcon.tsx +7 -0
- package/src/editor/icons/CodeBlockIcon.tsx +8 -0
- package/src/editor/icons/CurveIcon.tsx +7 -0
- package/src/editor/icons/GridIcon.tsx +7 -0
- package/src/editor/icons/IconMap.ts +35 -0
- package/src/editor/icons/ImgIcon.tsx +8 -0
- package/src/editor/icons/LayoutIcon.tsx +9 -0
- package/src/editor/icons/LineIcon.tsx +7 -0
- package/src/editor/icons/NodeIcon.tsx +7 -0
- package/src/editor/icons/RayIcon.tsx +7 -0
- package/src/editor/icons/RectIcon.tsx +7 -0
- package/src/editor/icons/ShapeIcon.tsx +7 -0
- package/src/editor/icons/TxtIcon.tsx +8 -0
- package/src/editor/icons/VideoIcon.tsx +7 -0
- package/src/editor/icons/View2DIcon.tsx +10 -0
- package/src/editor/index.css +0 -0
- package/src/editor/index.ts +17 -0
- package/src/editor/tree/DetachedRoot.tsx +23 -0
- package/src/editor/tree/NodeElement.tsx +74 -0
- package/src/editor/tree/TreeElement.tsx +72 -0
- package/src/editor/tree/TreeRoot.tsx +10 -0
- package/src/editor/tree/ViewRoot.tsx +20 -0
- package/src/editor/tree/index.module.scss +38 -0
- package/src/editor/tree/index.ts +3 -0
- package/src/editor/tsconfig.build.json +5 -0
- package/src/editor/tsconfig.json +12 -0
- package/src/editor/tsdoc.json +4 -0
- package/src/editor/vite-env.d.ts +1 -0
- package/src/lib/code/CodeCursor.ts +445 -0
- package/src/lib/code/CodeDiffer.ts +78 -0
- package/src/lib/code/CodeFragment.ts +97 -0
- package/src/lib/code/CodeHighlighter.ts +75 -0
- package/src/lib/code/CodeMetrics.ts +47 -0
- package/src/lib/code/CodeRange.test.ts +74 -0
- package/src/lib/code/CodeRange.ts +216 -0
- package/src/lib/code/CodeScope.ts +101 -0
- package/src/lib/code/CodeSelection.ts +24 -0
- package/src/lib/code/CodeSignal.ts +327 -0
- package/src/lib/code/CodeTokenizer.ts +54 -0
- package/src/lib/code/DefaultHighlightStyle.ts +98 -0
- package/src/lib/code/LezerHighlighter.ts +113 -0
- package/src/lib/code/diff.test.ts +311 -0
- package/src/lib/code/diff.ts +319 -0
- package/src/lib/code/extractRange.ts +126 -0
- package/src/lib/code/index.ts +13 -0
- package/src/lib/components/Audio.ts +131 -0
- package/src/lib/components/Bezier.ts +105 -0
- package/src/lib/components/Circle.ts +266 -0
- package/src/lib/components/Code.ts +526 -0
- package/src/lib/components/CodeBlock.ts +576 -0
- package/src/lib/components/CubicBezier.ts +112 -0
- package/src/lib/components/Curve.ts +455 -0
- package/src/lib/components/Grid.ts +135 -0
- package/src/lib/components/Icon.ts +96 -0
- package/src/lib/components/Img.ts +319 -0
- package/src/lib/components/Knot.ts +157 -0
- package/src/lib/components/Latex.ts +122 -0
- package/src/lib/components/Layout.ts +1092 -0
- package/src/lib/components/Line.ts +429 -0
- package/src/lib/components/Media.ts +379 -0
- package/src/lib/components/Node.ts +1940 -0
- package/src/lib/components/Path.ts +137 -0
- package/src/lib/components/Polygon.ts +171 -0
- package/src/lib/components/QuadBezier.ts +100 -0
- package/src/lib/components/Ray.ts +125 -0
- package/src/lib/components/Rect.ts +187 -0
- package/src/lib/components/Rive.ts +156 -0
- package/src/lib/components/SVG.ts +797 -0
- package/src/lib/components/Shape.ts +143 -0
- package/src/lib/components/Spline.ts +344 -0
- package/src/lib/components/Txt.test.tsx +81 -0
- package/src/lib/components/Txt.ts +203 -0
- package/src/lib/components/TxtLeaf.ts +205 -0
- package/src/lib/components/Video.ts +397 -0
- package/src/lib/components/View2D.ts +98 -0
- package/src/lib/components/__tests__/children.test.tsx +142 -0
- package/src/lib/components/__tests__/clone.test.tsx +126 -0
- package/src/lib/components/__tests__/generatorTest.ts +28 -0
- package/src/lib/components/__tests__/mockScene2D.ts +45 -0
- package/src/lib/components/__tests__/query.test.tsx +122 -0
- package/src/lib/components/__tests__/state.test.tsx +60 -0
- package/src/lib/components/index.ts +28 -0
- package/src/lib/components/types.ts +35 -0
- package/src/lib/curves/ArcSegment.ts +159 -0
- package/src/lib/curves/CircleSegment.ts +77 -0
- package/src/lib/curves/CubicBezierSegment.ts +78 -0
- package/src/lib/curves/CurveDrawingInfo.ts +11 -0
- package/src/lib/curves/CurvePoint.ts +15 -0
- package/src/lib/curves/CurveProfile.ts +7 -0
- package/src/lib/curves/KnotInfo.ts +10 -0
- package/src/lib/curves/LineSegment.ts +62 -0
- package/src/lib/curves/Polynomial.ts +355 -0
- package/src/lib/curves/Polynomial2D.ts +62 -0
- package/src/lib/curves/PolynomialSegment.ts +124 -0
- package/src/lib/curves/QuadBezierSegment.ts +64 -0
- package/src/lib/curves/Segment.ts +17 -0
- package/src/lib/curves/UniformPolynomialCurveSampler.ts +94 -0
- package/src/lib/curves/createCurveProfileLerp.ts +471 -0
- package/src/lib/curves/getBezierSplineProfile.ts +223 -0
- package/src/lib/curves/getCircleProfile.ts +86 -0
- package/src/lib/curves/getPathProfile.ts +178 -0
- package/src/lib/curves/getPointAtDistance.ts +21 -0
- package/src/lib/curves/getPolylineProfile.test.ts +21 -0
- package/src/lib/curves/getPolylineProfile.ts +89 -0
- package/src/lib/curves/getRectProfile.ts +139 -0
- package/src/lib/curves/index.ts +16 -0
- package/src/lib/decorators/canvasStyleSignal.ts +16 -0
- package/src/lib/decorators/colorSignal.ts +9 -0
- package/src/lib/decorators/compound.ts +72 -0
- package/src/lib/decorators/computed.ts +18 -0
- package/src/lib/decorators/defaultStyle.ts +18 -0
- package/src/lib/decorators/filtersSignal.ts +136 -0
- package/src/lib/decorators/index.ts +10 -0
- package/src/lib/decorators/initializers.ts +32 -0
- package/src/lib/decorators/nodeName.ts +13 -0
- package/src/lib/decorators/signal.test.ts +90 -0
- package/src/lib/decorators/signal.ts +345 -0
- package/src/lib/decorators/spacingSignal.ts +15 -0
- package/src/lib/decorators/vector2Signal.ts +30 -0
- package/src/lib/globals.d.ts +2 -0
- package/src/lib/index.ts +8 -0
- package/src/lib/jsx-dev-runtime.ts +2 -0
- package/src/lib/jsx-runtime.ts +46 -0
- package/src/lib/parse-svg-path.d.ts +14 -0
- package/src/lib/partials/Filter.ts +180 -0
- package/src/lib/partials/Gradient.ts +102 -0
- package/src/lib/partials/Pattern.ts +34 -0
- package/src/lib/partials/ShaderConfig.ts +117 -0
- package/src/lib/partials/index.ts +4 -0
- package/src/lib/partials/types.ts +58 -0
- package/src/lib/scenes/Scene2D.ts +242 -0
- package/src/lib/scenes/index.ts +3 -0
- package/src/lib/scenes/makeScene2D.ts +16 -0
- package/src/lib/scenes/useScene2D.ts +6 -0
- package/src/lib/tsconfig.build.json +5 -0
- package/src/lib/tsconfig.json +10 -0
- package/src/lib/tsdoc.json +4 -0
- package/src/lib/utils/CanvasUtils.ts +306 -0
- package/src/lib/utils/diff.test.ts +453 -0
- package/src/lib/utils/diff.ts +148 -0
- package/src/lib/utils/index.ts +2 -0
- package/src/lib/utils/is.ts +11 -0
- package/src/lib/utils/makeSignalExtensions.ts +30 -0
- package/src/lib/utils/video/declarations.d.ts +1 -0
- package/src/lib/utils/video/ffmpeg-client.ts +50 -0
- package/src/lib/utils/video/mp4-parser-manager.ts +72 -0
- package/src/lib/utils/video/parser/index.ts +1 -0
- package/src/lib/utils/video/parser/parser.ts +257 -0
- package/src/lib/utils/video/parser/sampler.ts +72 -0
- package/src/lib/utils/video/parser/segment.ts +302 -0
- package/src/lib/utils/video/parser/sink.ts +29 -0
- package/src/lib/utils/video/parser/utils.ts +31 -0
- package/src/tsconfig.base.json +19 -0
- package/src/tsconfig.build.json +8 -0
- package/src/tsconfig.json +5 -0
- package/tsconfig.project.json +7 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SignalValue, SimpleSignal, TimingFunction, Vector2 } from '@twick/core';
|
|
2
|
+
import { BBox } from '@twick/core';
|
|
3
|
+
import type { CurveProfile } from '../curves';
|
|
4
|
+
import type { CurveProps } from './Curve';
|
|
5
|
+
import { Curve } from './Curve';
|
|
6
|
+
export interface PathProps extends CurveProps {
|
|
7
|
+
data: SignalValue<string>;
|
|
8
|
+
}
|
|
9
|
+
export declare class Path extends Curve {
|
|
10
|
+
private currentProfile;
|
|
11
|
+
readonly data: SimpleSignal<string, this>;
|
|
12
|
+
constructor(props: PathProps);
|
|
13
|
+
profile(): CurveProfile;
|
|
14
|
+
protected childrenBBox(): BBox;
|
|
15
|
+
protected lineWidthCoefficient(): number;
|
|
16
|
+
protected processSubpath(path: Path2D, startPoint: Vector2 | null, endPoint: Vector2 | null): void;
|
|
17
|
+
protected tweenData(newPath: SignalValue<string>, time: number, timingFunction: TimingFunction): Generator<void | import("@twick/core").ThreadGenerator | Promise<any> | import("@twick/core").Promisable<any>, void, any>;
|
|
18
|
+
drawOverlay(context: CanvasRenderingContext2D, matrix: DOMMatrix): void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=Path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Path.d.ts","sourceRoot":"","sources":["../../src/lib/components/Path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,cAAc,EACd,OAAO,EACR,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,IAAI,EAML,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAK5C,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AACxC,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAE9B,MAAM,WAAW,SAAU,SAAQ,UAAU;IAC3C,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC3B;AAED,qBAAa,IAAK,SAAQ,KAAK;IAC7B,OAAO,CAAC,cAAc,CAA2C;IACjE,SACwB,IAAI,EAAE,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBAEtC,KAAK,EAAE,SAAS;IAMnB,OAAO,IAAI,YAAY;cAIpB,YAAY;cAKZ,oBAAoB,IAAI,MAAM;cAe9B,cAAc,CAC/B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,OAAO,GAAG,IAAI,EAC1B,QAAQ,EAAE,OAAO,GAAG,IAAI,GACvB,IAAI;IAOP,SAAS,CAAE,SAAS,CAClB,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,EAC5B,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,cAAc;IAqBhB,WAAW,CACzB,OAAO,EAAE,wBAAwB,EACjC,MAAM,EAAE,SAAS,GAChB,IAAI;CAqCR"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { BBox, createSignal, isReactive, threadable, transformVectorAsPoint, tween, } from '@twick/core';
|
|
8
|
+
import { createCurveProfileLerp } from '../curves/createCurveProfileLerp';
|
|
9
|
+
import { getPathProfile } from '../curves/getPathProfile';
|
|
10
|
+
import { computed, signal } from '../decorators';
|
|
11
|
+
import { drawLine, drawPivot } from '../utils';
|
|
12
|
+
import { Curve } from './Curve';
|
|
13
|
+
export class Path extends Curve {
|
|
14
|
+
constructor(props) {
|
|
15
|
+
super(props);
|
|
16
|
+
this.currentProfile = createSignal(null);
|
|
17
|
+
this.canHaveSubpath = true;
|
|
18
|
+
}
|
|
19
|
+
profile() {
|
|
20
|
+
return this.currentProfile() ?? getPathProfile(this.data());
|
|
21
|
+
}
|
|
22
|
+
childrenBBox() {
|
|
23
|
+
const points = this.profile().segments.flatMap(segment => segment.points);
|
|
24
|
+
return BBox.fromPoints(...points);
|
|
25
|
+
}
|
|
26
|
+
lineWidthCoefficient() {
|
|
27
|
+
const join = this.lineJoin();
|
|
28
|
+
let coefficient = super.lineWidthCoefficient();
|
|
29
|
+
if (join === 'miter') {
|
|
30
|
+
const { minSin } = this.profile();
|
|
31
|
+
if (minSin > 0) {
|
|
32
|
+
coefficient = Math.max(coefficient, 0.5 / minSin);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return coefficient;
|
|
36
|
+
}
|
|
37
|
+
processSubpath(path, startPoint, endPoint) {
|
|
38
|
+
if (startPoint && endPoint && startPoint.equals(endPoint)) {
|
|
39
|
+
path.closePath();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
*tweenData(newPath, time, timingFunction) {
|
|
43
|
+
const fromProfile = this.profile();
|
|
44
|
+
const toProfile = getPathProfile(isReactive(newPath) ? newPath() : newPath);
|
|
45
|
+
const interpolator = createCurveProfileLerp(fromProfile, toProfile);
|
|
46
|
+
this.currentProfile(fromProfile);
|
|
47
|
+
yield* tween(time, value => {
|
|
48
|
+
const progress = timingFunction(value);
|
|
49
|
+
this.currentProfile(interpolator(progress));
|
|
50
|
+
}, () => {
|
|
51
|
+
this.currentProfile(null);
|
|
52
|
+
this.data(newPath);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
drawOverlay(context, matrix) {
|
|
56
|
+
const box = this.childrenBBox().transformCorners(matrix);
|
|
57
|
+
const size = this.computedSize();
|
|
58
|
+
const offsetVector = size.mul(this.offset()).scale(0.5);
|
|
59
|
+
const offset = transformVectorAsPoint(offsetVector, matrix);
|
|
60
|
+
const segments = this.profile().segments;
|
|
61
|
+
context.lineWidth = 1;
|
|
62
|
+
context.strokeStyle = 'white';
|
|
63
|
+
context.fillStyle = 'white';
|
|
64
|
+
context.save();
|
|
65
|
+
context.setTransform(matrix);
|
|
66
|
+
let endPoint = null;
|
|
67
|
+
let path = new Path2D();
|
|
68
|
+
for (const segment of segments) {
|
|
69
|
+
if (endPoint && !segment.getPoint(0).position.equals(endPoint)) {
|
|
70
|
+
context.stroke(path);
|
|
71
|
+
path = new Path2D();
|
|
72
|
+
endPoint = null;
|
|
73
|
+
}
|
|
74
|
+
const [, end] = segment.draw(path, 0, 1, endPoint == null);
|
|
75
|
+
endPoint = end.position;
|
|
76
|
+
}
|
|
77
|
+
context.stroke(path);
|
|
78
|
+
context.restore();
|
|
79
|
+
context.beginPath();
|
|
80
|
+
drawPivot(context, offset);
|
|
81
|
+
context.stroke();
|
|
82
|
+
context.beginPath();
|
|
83
|
+
drawLine(context, box);
|
|
84
|
+
context.closePath();
|
|
85
|
+
context.stroke();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
__decorate([
|
|
89
|
+
signal()
|
|
90
|
+
], Path.prototype, "data", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
computed()
|
|
93
|
+
], Path.prototype, "profile", null);
|
|
94
|
+
__decorate([
|
|
95
|
+
threadable()
|
|
96
|
+
], Path.prototype, "tweenData", null);
|
|
97
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUGF0aC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvY29t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QU8sQ0FBQyxNQUFNLEVBQUUsQ0FBQztRQUVqQixPQUFPLENBQUMsU0FBUyxFQUFFLENBQUM7UUFDcEIsUUFBUSxDQUFDLE9BQU8sRUFBRSxHQUFHLENBQUMsQ0FBQztRQUN2QixPQUFPLENBQUMsU0FBUyxFQUFFLENBQUM7UUFDcEIsT0FBTyxDQUFDLE1BQU0sRUFBRSxDQUFDO0lBQ25CLENBQUM7Q0FDRjtBQTNHeUI7SUFEdkIsTUFBTSxFQUFFO2tDQUNnRDtBQVF6QztJQURmLFFBQVEsRUFBRTttQ0FHVjtBQWlDVTtJQURWLFVBQVUsRUFBRTtxQ0F1QloifQ==
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { SerializedVector2, SignalValue, SimpleSignal } from '@twick/core';
|
|
2
|
+
import { BBox } from '@twick/core';
|
|
3
|
+
import type { CurveProfile } from '../curves';
|
|
4
|
+
import type { DesiredLength } from '../partials';
|
|
5
|
+
import type { CurveProps } from './Curve';
|
|
6
|
+
import { Curve } from './Curve';
|
|
7
|
+
export interface PolygonProps extends CurveProps {
|
|
8
|
+
/**
|
|
9
|
+
* {@inheritDoc Polygon.sides}
|
|
10
|
+
*/
|
|
11
|
+
sides?: SignalValue<number>;
|
|
12
|
+
/**
|
|
13
|
+
* {@inheritDoc Polygon.radius}
|
|
14
|
+
*/
|
|
15
|
+
radius?: SignalValue<number>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A node for drawing regular polygons.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* This node can be used to render shapes such as: triangle, pentagon,
|
|
22
|
+
* hexagon and more.
|
|
23
|
+
*
|
|
24
|
+
* Note that the polygon is inscribed in a circle defined by the height
|
|
25
|
+
* and width. If height and width are unequal, the polygon is inscribed
|
|
26
|
+
* in the resulting ellipse.
|
|
27
|
+
*
|
|
28
|
+
* Since the polygon is inscribed in the circle, the actual displayed
|
|
29
|
+
* height and width may differ somewhat from the bounding rectangle. This
|
|
30
|
+
* will be particularly noticeable if the number of sides is low, e.g. for a
|
|
31
|
+
* triangle.
|
|
32
|
+
*
|
|
33
|
+
* @preview
|
|
34
|
+
* ```tsx editor
|
|
35
|
+
* // snippet Polygon
|
|
36
|
+
* import {makeScene2D, Polygon} from '@twick/2d';
|
|
37
|
+
* import {createRef} from '@twick/core';
|
|
38
|
+
*
|
|
39
|
+
* export default makeScene2D(function* (view) {
|
|
40
|
+
* const ref = createRef<Polygon>();
|
|
41
|
+
* view.add(
|
|
42
|
+
* <Polygon
|
|
43
|
+
* ref={ref}
|
|
44
|
+
* sides={6}
|
|
45
|
+
* size={160}
|
|
46
|
+
* fill={'lightseagreen'}
|
|
47
|
+
* />
|
|
48
|
+
* );
|
|
49
|
+
*
|
|
50
|
+
* yield* ref().sides(3, 2).to(6, 2);
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* // snippet Pentagon outline
|
|
54
|
+
* import {makeScene2D, Polygon} from '@twick/2d';
|
|
55
|
+
*
|
|
56
|
+
* export default makeScene2D(function* (view) {
|
|
57
|
+
* view.add(
|
|
58
|
+
* <Polygon
|
|
59
|
+
* sides={5}
|
|
60
|
+
* size={160}
|
|
61
|
+
* radius={30}
|
|
62
|
+
* stroke={'lightblue'}
|
|
63
|
+
* lineWidth={8}
|
|
64
|
+
* />
|
|
65
|
+
* );
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare class Polygon extends Curve {
|
|
70
|
+
/**
|
|
71
|
+
* The number of sides of the polygon.
|
|
72
|
+
*
|
|
73
|
+
* @remarks
|
|
74
|
+
* For example, a value of 6 creates a hexagon.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* <Polygon
|
|
79
|
+
* size={320}
|
|
80
|
+
* sides={7}
|
|
81
|
+
* stroke={'#fff'}
|
|
82
|
+
* lineWidth={8}
|
|
83
|
+
* fill={'lightseagreen'}
|
|
84
|
+
* />
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
readonly sides: SimpleSignal<number, this>;
|
|
88
|
+
/**
|
|
89
|
+
* The radius of the polygon's corners.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```tsx
|
|
93
|
+
* <Polygon
|
|
94
|
+
* radius={30}
|
|
95
|
+
* size={320}
|
|
96
|
+
* sides={3}
|
|
97
|
+
* stroke={'#fff'}
|
|
98
|
+
* lineWidth={8}
|
|
99
|
+
* />
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
readonly radius: SimpleSignal<number, this>;
|
|
103
|
+
constructor(props: PolygonProps);
|
|
104
|
+
profile(): CurveProfile;
|
|
105
|
+
protected desiredSize(): SerializedVector2<DesiredLength>;
|
|
106
|
+
protected offsetComputedLayout(box: BBox): BBox;
|
|
107
|
+
protected childrenBBox(): BBox;
|
|
108
|
+
protected requiresProfile(): boolean;
|
|
109
|
+
protected getPath(): Path2D;
|
|
110
|
+
protected getRipplePath(): Path2D;
|
|
111
|
+
protected createPath(expand?: number): Path2D;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=Polygon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Polygon.d.ts","sourceRoot":"","sources":["../../src/lib/components/Polygon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAC,IAAI,EAAU,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAG5C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AACxC,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAE9B,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C;;OAEG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5B;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,qBAAa,OAAQ,SAAQ,KAAK;IAChC;;;;;;;;;;;;;;;;OAgBG;IACH,SAEwB,KAAK,EAAE,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAE1D;;;;;;;;;;;;;OAaG;IACH,SAEwB,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBAExC,KAAK,EAAE,YAAY;IAKtB,OAAO,IAAI,YAAY;cAepB,WAAW,IAAI,iBAAiB,CAAC,aAAa,CAAC;cAO/C,oBAAoB,CAAC,GAAG,EAAE,IAAI,GAAG,IAAI;cAIrC,YAAY,IAAI,IAAI;cAIpB,eAAe,IAAI,OAAO;cAI1B,OAAO,IAAI,MAAM;cAOjB,aAAa,IAAI,MAAM;IAI1C,SAAS,CAAC,UAAU,CAAC,MAAM,SAAI;CAOhC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { BBox, Vector2 } from '@twick/core';
|
|
8
|
+
import { getPolylineProfile } from '../curves';
|
|
9
|
+
import { computed, initial, signal } from '../decorators';
|
|
10
|
+
import { drawPolygon } from '../utils';
|
|
11
|
+
import { Curve } from './Curve';
|
|
12
|
+
/**
|
|
13
|
+
* A node for drawing regular polygons.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* This node can be used to render shapes such as: triangle, pentagon,
|
|
17
|
+
* hexagon and more.
|
|
18
|
+
*
|
|
19
|
+
* Note that the polygon is inscribed in a circle defined by the height
|
|
20
|
+
* and width. If height and width are unequal, the polygon is inscribed
|
|
21
|
+
* in the resulting ellipse.
|
|
22
|
+
*
|
|
23
|
+
* Since the polygon is inscribed in the circle, the actual displayed
|
|
24
|
+
* height and width may differ somewhat from the bounding rectangle. This
|
|
25
|
+
* will be particularly noticeable if the number of sides is low, e.g. for a
|
|
26
|
+
* triangle.
|
|
27
|
+
*
|
|
28
|
+
* @preview
|
|
29
|
+
* ```tsx editor
|
|
30
|
+
* // snippet Polygon
|
|
31
|
+
* import {makeScene2D, Polygon} from '@twick/2d';
|
|
32
|
+
* import {createRef} from '@twick/core';
|
|
33
|
+
*
|
|
34
|
+
* export default makeScene2D(function* (view) {
|
|
35
|
+
* const ref = createRef<Polygon>();
|
|
36
|
+
* view.add(
|
|
37
|
+
* <Polygon
|
|
38
|
+
* ref={ref}
|
|
39
|
+
* sides={6}
|
|
40
|
+
* size={160}
|
|
41
|
+
* fill={'lightseagreen'}
|
|
42
|
+
* />
|
|
43
|
+
* );
|
|
44
|
+
*
|
|
45
|
+
* yield* ref().sides(3, 2).to(6, 2);
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* // snippet Pentagon outline
|
|
49
|
+
* import {makeScene2D, Polygon} from '@twick/2d';
|
|
50
|
+
*
|
|
51
|
+
* export default makeScene2D(function* (view) {
|
|
52
|
+
* view.add(
|
|
53
|
+
* <Polygon
|
|
54
|
+
* sides={5}
|
|
55
|
+
* size={160}
|
|
56
|
+
* radius={30}
|
|
57
|
+
* stroke={'lightblue'}
|
|
58
|
+
* lineWidth={8}
|
|
59
|
+
* />
|
|
60
|
+
* );
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export class Polygon extends Curve {
|
|
65
|
+
constructor(props) {
|
|
66
|
+
super(props);
|
|
67
|
+
}
|
|
68
|
+
profile() {
|
|
69
|
+
const sides = this.sides();
|
|
70
|
+
const radius = this.radius();
|
|
71
|
+
const points = [];
|
|
72
|
+
const size = this.computedSize().scale(0.5);
|
|
73
|
+
for (let i = 0; i < sides; i++) {
|
|
74
|
+
const theta = (i * 2 * Math.PI) / sides;
|
|
75
|
+
const direction = Vector2.fromRadians(theta).perpendicular;
|
|
76
|
+
points.push(direction.mul(size));
|
|
77
|
+
}
|
|
78
|
+
return getPolylineProfile(points, radius, true);
|
|
79
|
+
}
|
|
80
|
+
desiredSize() {
|
|
81
|
+
return {
|
|
82
|
+
x: this.width.context.getter(),
|
|
83
|
+
y: this.height.context.getter(),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
offsetComputedLayout(box) {
|
|
87
|
+
return box;
|
|
88
|
+
}
|
|
89
|
+
childrenBBox() {
|
|
90
|
+
return BBox.fromSizeCentered(this.computedSize());
|
|
91
|
+
}
|
|
92
|
+
requiresProfile() {
|
|
93
|
+
return super.requiresProfile() || this.radius() > 0;
|
|
94
|
+
}
|
|
95
|
+
getPath() {
|
|
96
|
+
if (this.requiresProfile()) {
|
|
97
|
+
return this.curveDrawingInfo().path;
|
|
98
|
+
}
|
|
99
|
+
return this.createPath();
|
|
100
|
+
}
|
|
101
|
+
getRipplePath() {
|
|
102
|
+
return this.createPath(this.rippleSize());
|
|
103
|
+
}
|
|
104
|
+
createPath(expand = 0) {
|
|
105
|
+
const path = new Path2D();
|
|
106
|
+
const sides = this.sides();
|
|
107
|
+
const box = BBox.fromSizeCentered(this.size()).expand(expand);
|
|
108
|
+
drawPolygon(path, box, sides);
|
|
109
|
+
return path;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
__decorate([
|
|
113
|
+
initial(6),
|
|
114
|
+
signal()
|
|
115
|
+
], Polygon.prototype, "sides", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
initial(0),
|
|
118
|
+
signal()
|
|
119
|
+
], Polygon.prototype, "radius", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
computed()
|
|
122
|
+
], Polygon.prototype, "profile", null);
|
|
123
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUG9seWdvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvY29tcG9uZW50cy9Qb2x5Z29uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUNBLE9BQU8sRUFBQyxJQUFJLEVBQUUsT0FBTyxFQUFDLE1BQU0sYUFBYSxDQUFDO0FBRTFDLE9BQU8sRUFBQyxrQkFBa0IsRUFBQyxNQUFNLFdBQVcsQ0FBQztBQUM3QyxPQUFPLEVBQUMsUUFBUSxFQUFFLE9BQU8sRUFBRSxNQUFNLEVBQUMsTUFBTSxlQUFlLENBQUM7QUFFeEQsT0FBTyxFQUFDLFdBQVcsRUFBQyxNQUFNLFVBQVUsQ0FBQztBQUVyQyxPQUFPLEVBQUMsS0FBSyxFQUFDLE1BQU0sU0FBUyxDQUFDO0FBYTlCOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FtREc7QUFDSCxNQUFNLE9BQU8sT0FBUSxTQUFRLEtBQUs7SUF3Q2hDLFlBQW1CLEtBQW1CO1FBQ3BDLEtBQUssQ0FBQyxLQUFLLENBQUMsQ0FBQztJQUNmLENBQUM7SUFHZSxPQUFPO1FBQ3JCLE1BQU0sS0FBSyxHQUFHLElBQUksQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUMzQixNQUFNLE1BQU0sR0FBRyxJQUFJLENBQU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@@
|
|
|
1
|
+
import type { PossibleVector2, SignalValue, Vector2Signal } from '@twick/core';
|
|
2
|
+
import type { PolynomialSegment } from '../curves/PolynomialSegment';
|
|
3
|
+
import type { BezierOverlayInfo } from './Bezier';
|
|
4
|
+
import { Bezier } from './Bezier';
|
|
5
|
+
import type { CurveProps } from './Curve';
|
|
6
|
+
export interface QuadBezierProps extends CurveProps {
|
|
7
|
+
p0?: SignalValue<PossibleVector2>;
|
|
8
|
+
p0X?: SignalValue<number>;
|
|
9
|
+
p0Y?: SignalValue<number>;
|
|
10
|
+
p1?: SignalValue<PossibleVector2>;
|
|
11
|
+
p1X?: SignalValue<number>;
|
|
12
|
+
p1Y?: SignalValue<number>;
|
|
13
|
+
p2?: SignalValue<PossibleVector2>;
|
|
14
|
+
p2X?: SignalValue<number>;
|
|
15
|
+
p2Y?: SignalValue<number>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A node for drawing a quadratic Bézier curve.
|
|
19
|
+
*
|
|
20
|
+
* @preview
|
|
21
|
+
* ```tsx editor
|
|
22
|
+
* import {makeScene2D, QuadBezier} from '@twick/2d';
|
|
23
|
+
* import {createRef} from '@twick/core';
|
|
24
|
+
*
|
|
25
|
+
* export default makeScene2D(function* (view) {
|
|
26
|
+
* const bezier = createRef<QuadBezier>();
|
|
27
|
+
*
|
|
28
|
+
* view.add(
|
|
29
|
+
* <QuadBezier
|
|
30
|
+
* ref={bezier}
|
|
31
|
+
* lineWidth={4}
|
|
32
|
+
* stroke={'lightseagreen'}
|
|
33
|
+
* p0={[-200, 0]}
|
|
34
|
+
* p1={[0, -200]}
|
|
35
|
+
* p2={[200, 0]}
|
|
36
|
+
* end={0}
|
|
37
|
+
* />
|
|
38
|
+
* );
|
|
39
|
+
*
|
|
40
|
+
* yield* bezier().end(1, 1);
|
|
41
|
+
* yield* bezier().start(1, 1).to(0, 1);
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare class QuadBezier extends Bezier {
|
|
46
|
+
/**
|
|
47
|
+
* The start point of the Bézier curve.
|
|
48
|
+
*/
|
|
49
|
+
readonly p0: Vector2Signal<this>;
|
|
50
|
+
/**
|
|
51
|
+
* The control point of the Bézier curve.
|
|
52
|
+
*/
|
|
53
|
+
readonly p1: Vector2Signal<this>;
|
|
54
|
+
/**
|
|
55
|
+
* The end point of the Bézier curve.
|
|
56
|
+
*/
|
|
57
|
+
readonly p2: Vector2Signal<this>;
|
|
58
|
+
constructor(props: QuadBezierProps);
|
|
59
|
+
protected segment(): PolynomialSegment;
|
|
60
|
+
protected overlayInfo(matrix: DOMMatrix): BezierOverlayInfo;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=QuadBezier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuadBezier.d.ts","sourceRoot":"","sources":["../../src/lib/components/QuadBezier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAE,WAAW,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAE7E,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAGnE,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,UAAU,CAAC;AAChD,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AAExC,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD,EAAE,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IAClC,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAE1B,EAAE,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IAClC,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAE1B,EAAE,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IAClC,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,UAAW,SAAQ,MAAM;IACpC;;OAEG;IACH,SACwB,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAEhD;;OAEG;IACH,SACwB,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAEhD;;OAEG;IACH,SACwB,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;gBAE7B,KAAK,EAAE,eAAe;IAKzC,SAAS,CAAC,OAAO,IAAI,iBAAiB;IAItC,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,iBAAiB;CAoB5D"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { QuadBezierSegment } from '../curves';
|
|
8
|
+
import { computed, vector2Signal } from '../decorators';
|
|
9
|
+
import { lineTo, moveTo, quadraticCurveTo } from '../utils';
|
|
10
|
+
import { Bezier } from './Bezier';
|
|
11
|
+
/**
|
|
12
|
+
* A node for drawing a quadratic Bézier curve.
|
|
13
|
+
*
|
|
14
|
+
* @preview
|
|
15
|
+
* ```tsx editor
|
|
16
|
+
* import {makeScene2D, QuadBezier} from '@twick/2d';
|
|
17
|
+
* import {createRef} from '@twick/core';
|
|
18
|
+
*
|
|
19
|
+
* export default makeScene2D(function* (view) {
|
|
20
|
+
* const bezier = createRef<QuadBezier>();
|
|
21
|
+
*
|
|
22
|
+
* view.add(
|
|
23
|
+
* <QuadBezier
|
|
24
|
+
* ref={bezier}
|
|
25
|
+
* lineWidth={4}
|
|
26
|
+
* stroke={'lightseagreen'}
|
|
27
|
+
* p0={[-200, 0]}
|
|
28
|
+
* p1={[0, -200]}
|
|
29
|
+
* p2={[200, 0]}
|
|
30
|
+
* end={0}
|
|
31
|
+
* />
|
|
32
|
+
* );
|
|
33
|
+
*
|
|
34
|
+
* yield* bezier().end(1, 1);
|
|
35
|
+
* yield* bezier().start(1, 1).to(0, 1);
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export class QuadBezier extends Bezier {
|
|
40
|
+
constructor(props) {
|
|
41
|
+
super(props);
|
|
42
|
+
}
|
|
43
|
+
segment() {
|
|
44
|
+
return new QuadBezierSegment(this.p0(), this.p1(), this.p2());
|
|
45
|
+
}
|
|
46
|
+
overlayInfo(matrix) {
|
|
47
|
+
const [p0, p1, p2] = this.segment().transformPoints(matrix);
|
|
48
|
+
const curvePath = new Path2D();
|
|
49
|
+
moveTo(curvePath, p0);
|
|
50
|
+
quadraticCurveTo(curvePath, p1, p2);
|
|
51
|
+
const handleLinesPath = new Path2D();
|
|
52
|
+
moveTo(handleLinesPath, p0);
|
|
53
|
+
lineTo(handleLinesPath, p1);
|
|
54
|
+
lineTo(handleLinesPath, p2);
|
|
55
|
+
return {
|
|
56
|
+
curve: curvePath,
|
|
57
|
+
startPoint: p0,
|
|
58
|
+
endPoint: p2,
|
|
59
|
+
controlPoints: [p1],
|
|
60
|
+
handleLines: handleLinesPath,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
__decorate([
|
|
65
|
+
vector2Signal('p0')
|
|
66
|
+
], QuadBezier.prototype, "p0", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
vector2Signal('p1')
|
|
69
|
+
], QuadBezier.prototype, "p1", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
vector2Signal('p2')
|
|
72
|
+
], QuadBezier.prototype, "p2", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
computed()
|
|
75
|
+
], QuadBezier.prototype, "segment", null);
|
|
76
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUXVhZEJlemllci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvY29tcG9uZW50cy9RdWFkQmV6aWVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUNBLE9BQU8sRUFBQyxpQkFBaUIsRUFBQyxNQUFNLFdBQVcsQ0FBQztBQUU1QyxPQUFPLEVBQUMsUUFBUSxFQUFFLGFBQWEsRUFBQyxNQUFNLGVBQWUsQ0FBQztBQUN0RCxPQUFPLEVBQUMsTUFBTSxFQUFFLE1BQU0sRUFBRSxnQkFBZ0IsRUFBQyxNQUFNLFVBQVUsQ0FBQztBQUUxRCxPQUFPLEVBQUMsTUFBTSxFQUFDLE1BQU0sVUFBVSxDQUFDO0FBaUJoQzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBMkJHO0FBQ0gsTUFBTSxPQUFPLFVBQVcsU0FBUSxNQUFNO0lBbUJwQyxZQUFtQixLQUFzQjtRQUN2QyxLQUFLLENBQUMsS0FBSyxDQUFDLENBQUM7SUFDZixDQUFDO0lBR1MsT0FBTztRQUNmLE9BQU8sSUFBSSxpQkFBaUIsQ0FBQyxJQUFJLENBQUMsRUFBRSxFQUFFLEVBQUUsSUFBSSxDQUFDLEVBQUUsRUFBRSxFQUFFLElBQUksQ0FBQyxF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type { PossibleVector2, SignalValue, Vector2Signal } from '@twick/core';
|
|
2
|
+
import { BBox } from '@twick/core';
|
|
3
|
+
import type { CurveProfile } from '../curves';
|
|
4
|
+
import type { CurveProps } from './Curve';
|
|
5
|
+
import { Curve } from './Curve';
|
|
6
|
+
export interface RayProps extends CurveProps {
|
|
7
|
+
/**
|
|
8
|
+
* {@inheritDoc Ray.from}
|
|
9
|
+
*/
|
|
10
|
+
from?: SignalValue<PossibleVector2>;
|
|
11
|
+
fromX?: SignalValue<number>;
|
|
12
|
+
fromY?: SignalValue<number>;
|
|
13
|
+
/**
|
|
14
|
+
* {@inheritDoc Ray.to}
|
|
15
|
+
*/
|
|
16
|
+
to?: SignalValue<PossibleVector2>;
|
|
17
|
+
toX?: SignalValue<number>;
|
|
18
|
+
toY?: SignalValue<number>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A node for drawing an individual line segment.
|
|
22
|
+
*
|
|
23
|
+
* @preview
|
|
24
|
+
* ```tsx editor
|
|
25
|
+
* import {makeScene2D} from '@twick/2d';
|
|
26
|
+
* import {Ray} from '@twick/2d';
|
|
27
|
+
* import {createRef} from '@twick/core';
|
|
28
|
+
*
|
|
29
|
+
* export default makeScene2D(function* (view) {
|
|
30
|
+
* const ray = createRef<Ray>();
|
|
31
|
+
*
|
|
32
|
+
* view.add(
|
|
33
|
+
* <Ray
|
|
34
|
+
* ref={ray}
|
|
35
|
+
* lineWidth={8}
|
|
36
|
+
* endArrow
|
|
37
|
+
* stroke={'lightseagreen'}
|
|
38
|
+
* fromX={-200}
|
|
39
|
+
* toX={200}
|
|
40
|
+
* />,
|
|
41
|
+
* );
|
|
42
|
+
*
|
|
43
|
+
* yield* ray().start(1, 1);
|
|
44
|
+
* yield* ray().start(0).end(0).start(1, 1);
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare class Ray extends Curve {
|
|
49
|
+
/**
|
|
50
|
+
* The starting point of the ray.
|
|
51
|
+
*/
|
|
52
|
+
readonly from: Vector2Signal<this>;
|
|
53
|
+
/**
|
|
54
|
+
* The ending point of the ray.
|
|
55
|
+
*/
|
|
56
|
+
readonly to: Vector2Signal<this>;
|
|
57
|
+
constructor(props: RayProps);
|
|
58
|
+
protected childrenBBox(): BBox;
|
|
59
|
+
profile(): CurveProfile;
|
|
60
|
+
drawOverlay(context: CanvasRenderingContext2D, matrix: DOMMatrix): void;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=Ray.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Ray.d.ts","sourceRoot":"","sources":["../../src/lib/components/Ray.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAE,WAAW,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAC,IAAI,EAAyB,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAI5C,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AACxC,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAE9B,MAAM,WAAW,QAAS,SAAQ,UAAU;IAC1C;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IACpC,KAAK,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5B,KAAK,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAE5B;;OAEG;IACH,EAAE,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAC;IAClC,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBACa,GAAI,SAAQ,KAAK;IAC5B;;OAEG;IACH,SACwB,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAElD;;OAEG;IACH,SACwB,EAAE,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;gBAE7B,KAAK,EAAE,QAAQ;cAIf,YAAY;IAIf,OAAO,IAAI,YAAY;IAUvB,WAAW,CACzB,OAAO,EAAE,wBAAwB,EACjC,MAAM,EAAE,SAAS;CAqCpB"}
|