@twick/2d 0.14.21 → 0.15.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/dist/index.cjs +10806 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4657 -0
- package/dist/index.d.ts +4657 -0
- package/dist/index.js +10768 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-runtime.d.mts +1 -0
- package/dist/jsx-runtime.d.ts +1 -0
- package/editor/index.css +24 -22
- package/editor/index.css.map +1 -0
- package/editor/index.d.ts +5 -0
- package/editor/index.js +472 -258
- package/editor/index.js.map +1 -1
- package/package.json +54 -27
- package/tsconfig.project.json +3 -2
- package/lib/code/CodeCursor.d.ts +0 -83
- package/lib/code/CodeCursor.d.ts.map +0 -1
- package/lib/code/CodeCursor.js +0 -306
- package/lib/code/CodeDiffer.d.ts +0 -28
- package/lib/code/CodeDiffer.d.ts.map +0 -1
- package/lib/code/CodeDiffer.js +0 -51
- package/lib/code/CodeFragment.d.ts +0 -42
- package/lib/code/CodeFragment.d.ts.map +0 -1
- package/lib/code/CodeFragment.js +0 -72
- package/lib/code/CodeHighlighter.d.ts +0 -71
- package/lib/code/CodeHighlighter.d.ts.map +0 -1
- package/lib/code/CodeHighlighter.js +0 -2
- package/lib/code/CodeMetrics.d.ts +0 -11
- package/lib/code/CodeMetrics.d.ts.map +0 -1
- package/lib/code/CodeMetrics.js +0 -29
- package/lib/code/CodeRange.d.ts +0 -41
- package/lib/code/CodeRange.d.ts.map +0 -1
- package/lib/code/CodeRange.js +0 -179
- package/lib/code/CodeScope.d.ts +0 -16
- package/lib/code/CodeScope.d.ts.map +0 -1
- package/lib/code/CodeScope.js +0 -72
- package/lib/code/CodeSelection.d.ts +0 -6
- package/lib/code/CodeSelection.d.ts.map +0 -1
- package/lib/code/CodeSelection.js +0 -13
- package/lib/code/CodeSignal.d.ts +0 -60
- package/lib/code/CodeSignal.d.ts.map +0 -1
- package/lib/code/CodeSignal.js +0 -194
- package/lib/code/CodeTokenizer.d.ts +0 -8
- package/lib/code/CodeTokenizer.d.ts.map +0 -1
- package/lib/code/CodeTokenizer.js +0 -50
- package/lib/code/DefaultHighlightStyle.d.ts +0 -3
- package/lib/code/DefaultHighlightStyle.d.ts.map +0 -1
- package/lib/code/DefaultHighlightStyle.js +0 -98
- package/lib/code/LezerHighlighter.d.ts +0 -22
- package/lib/code/LezerHighlighter.d.ts.map +0 -1
- package/lib/code/LezerHighlighter.js +0 -89
- package/lib/code/diff.d.ts +0 -31
- package/lib/code/diff.d.ts.map +0 -1
- package/lib/code/diff.js +0 -236
- package/lib/code/extractRange.d.ts +0 -17
- package/lib/code/extractRange.d.ts.map +0 -1
- package/lib/code/extractRange.js +0 -102
- package/lib/code/index.d.ts +0 -14
- package/lib/code/index.d.ts.map +0 -1
- package/lib/code/index.js +0 -14
- package/lib/components/Audio.d.ts +0 -14
- package/lib/components/Audio.d.ts.map +0 -1
- package/lib/components/Audio.js +0 -148
- package/lib/components/Bezier.d.ts +0 -23
- package/lib/components/Bezier.d.ts.map +0 -1
- package/lib/components/Bezier.js +0 -81
- package/lib/components/Circle.d.ts +0 -193
- package/lib/components/Circle.d.ts.map +0 -1
- package/lib/components/Circle.js +0 -178
- package/lib/components/Code.d.ts +0 -231
- package/lib/components/Code.d.ts.map +0 -1
- package/lib/components/Code.js +0 -325
- package/lib/components/CodeBlock.d.ts +0 -133
- package/lib/components/CodeBlock.d.ts.map +0 -1
- package/lib/components/CodeBlock.js +0 -461
- package/lib/components/CubicBezier.d.ts +0 -70
- package/lib/components/CubicBezier.d.ts.map +0 -1
- package/lib/components/CubicBezier.js +0 -81
- package/lib/components/Curve.d.ts +0 -204
- package/lib/components/Curve.d.ts.map +0 -1
- package/lib/components/Curve.js +0 -284
- package/lib/components/Grid.d.ts +0 -76
- package/lib/components/Grid.d.ts.map +0 -1
- package/lib/components/Grid.js +0 -91
- package/lib/components/Icon.d.ts +0 -59
- package/lib/components/Icon.d.ts.map +0 -1
- package/lib/components/Icon.js +0 -58
- package/lib/components/Img.d.ts +0 -118
- package/lib/components/Img.d.ts.map +0 -1
- package/lib/components/Img.js +0 -245
- package/lib/components/Knot.d.ts +0 -90
- package/lib/components/Knot.d.ts.map +0 -1
- package/lib/components/Knot.js +0 -68
- package/lib/components/Latex.d.ts +0 -39
- package/lib/components/Latex.d.ts.map +0 -1
- package/lib/components/Latex.js +0 -101
- package/lib/components/Layout.d.ts +0 -419
- package/lib/components/Layout.d.ts.map +0 -1
- package/lib/components/Layout.js +0 -706
- package/lib/components/Line.d.ts +0 -160
- package/lib/components/Line.d.ts.map +0 -1
- package/lib/components/Line.js +0 -346
- package/lib/components/Media.d.ts +0 -70
- package/lib/components/Media.d.ts.map +0 -1
- package/lib/components/Media.js +0 -493
- package/lib/components/Node.d.ts +0 -836
- package/lib/components/Node.d.ts.map +0 -1
- package/lib/components/Node.js +0 -1317
- package/lib/components/Path.d.ts +0 -20
- package/lib/components/Path.d.ts.map +0 -1
- package/lib/components/Path.js +0 -97
- package/lib/components/Polygon.d.ts +0 -113
- package/lib/components/Polygon.d.ts.map +0 -1
- package/lib/components/Polygon.js +0 -123
- package/lib/components/QuadBezier.d.ts +0 -62
- package/lib/components/QuadBezier.d.ts.map +0 -1
- package/lib/components/QuadBezier.js +0 -76
- package/lib/components/Ray.d.ts +0 -62
- package/lib/components/Ray.d.ts.map +0 -1
- package/lib/components/Ray.js +0 -96
- package/lib/components/Rect.d.ts +0 -114
- package/lib/components/Rect.d.ts.map +0 -1
- package/lib/components/Rect.js +0 -76
- package/lib/components/Rive.d.ts +0 -22
- package/lib/components/Rive.d.ts.map +0 -1
- package/lib/components/Rive.js +0 -117
- package/lib/components/SVG.d.ts +0 -178
- package/lib/components/SVG.d.ts.map +0 -1
- package/lib/components/SVG.js +0 -577
- package/lib/components/Shape.d.ts +0 -40
- package/lib/components/Shape.d.ts.map +0 -1
- package/lib/components/Shape.js +0 -134
- package/lib/components/Spline.d.ts +0 -89
- package/lib/components/Spline.d.ts.map +0 -1
- package/lib/components/Spline.js +0 -256
- package/lib/components/Txt.d.ts +0 -53
- package/lib/components/Txt.d.ts.map +0 -1
- package/lib/components/Txt.js +0 -173
- package/lib/components/TxtLeaf.d.ts +0 -21
- package/lib/components/TxtLeaf.d.ts.map +0 -1
- package/lib/components/TxtLeaf.js +0 -181
- package/lib/components/Video.d.ts +0 -69
- package/lib/components/Video.d.ts.map +0 -1
- package/lib/components/Video.js +0 -342
- package/lib/components/View2D.d.ts +0 -28
- package/lib/components/View2D.d.ts.map +0 -1
- package/lib/components/View2D.js +0 -93
- package/lib/components/index.d.ts +0 -29
- package/lib/components/index.d.ts.map +0 -1
- package/lib/components/index.js +0 -29
- package/lib/components/types.d.ts +0 -17
- package/lib/components/types.d.ts.map +0 -1
- package/lib/components/types.js +0 -2
- package/lib/curves/ArcSegment.d.ts +0 -26
- package/lib/curves/ArcSegment.d.ts.map +0 -1
- package/lib/curves/ArcSegment.js +0 -97
- package/lib/curves/CircleSegment.d.ts +0 -18
- package/lib/curves/CircleSegment.d.ts.map +0 -1
- package/lib/curves/CircleSegment.js +0 -52
- package/lib/curves/CubicBezierSegment.d.ts +0 -18
- package/lib/curves/CubicBezierSegment.d.ts.map +0 -1
- package/lib/curves/CubicBezierSegment.js +0 -55
- package/lib/curves/CurveDrawingInfo.d.ts +0 -11
- package/lib/curves/CurveDrawingInfo.d.ts.map +0 -1
- package/lib/curves/CurveDrawingInfo.js +0 -2
- package/lib/curves/CurvePoint.d.ts +0 -15
- package/lib/curves/CurvePoint.d.ts.map +0 -1
- package/lib/curves/CurvePoint.js +0 -2
- package/lib/curves/CurveProfile.d.ts +0 -7
- package/lib/curves/CurveProfile.d.ts.map +0 -1
- package/lib/curves/CurveProfile.js +0 -2
- package/lib/curves/KnotInfo.d.ts +0 -12
- package/lib/curves/KnotInfo.d.ts.map +0 -1
- package/lib/curves/KnotInfo.js +0 -2
- package/lib/curves/LineSegment.d.ts +0 -16
- package/lib/curves/LineSegment.d.ts.map +0 -1
- package/lib/curves/LineSegment.js +0 -45
- package/lib/curves/Polynomial.d.ts +0 -118
- package/lib/curves/Polynomial.d.ts.map +0 -1
- package/lib/curves/Polynomial.js +0 -259
- package/lib/curves/Polynomial2D.d.ts +0 -22
- package/lib/curves/Polynomial2D.d.ts.map +0 -1
- package/lib/curves/Polynomial2D.js +0 -45
- package/lib/curves/PolynomialSegment.d.ts +0 -39
- package/lib/curves/PolynomialSegment.d.ts.map +0 -1
- package/lib/curves/PolynomialSegment.js +0 -86
- package/lib/curves/QuadBezierSegment.d.ts +0 -17
- package/lib/curves/QuadBezierSegment.d.ts.map +0 -1
- package/lib/curves/QuadBezierSegment.js +0 -49
- package/lib/curves/Segment.d.ts +0 -9
- package/lib/curves/Segment.d.ts.map +0 -1
- package/lib/curves/Segment.js +0 -3
- package/lib/curves/UniformPolynomialCurveSampler.d.ts +0 -43
- package/lib/curves/UniformPolynomialCurveSampler.d.ts.map +0 -1
- package/lib/curves/UniformPolynomialCurveSampler.js +0 -73
- package/lib/curves/createCurveProfileLerp.d.ts +0 -32
- package/lib/curves/createCurveProfileLerp.d.ts.map +0 -1
- package/lib/curves/createCurveProfileLerp.js +0 -351
- package/lib/curves/getBezierSplineProfile.d.ts +0 -12
- package/lib/curves/getBezierSplineProfile.d.ts.map +0 -1
- package/lib/curves/getBezierSplineProfile.js +0 -137
- package/lib/curves/getCircleProfile.d.ts +0 -4
- package/lib/curves/getCircleProfile.d.ts.map +0 -1
- package/lib/curves/getCircleProfile.js +0 -44
- package/lib/curves/getPathProfile.d.ts +0 -3
- package/lib/curves/getPathProfile.d.ts.map +0 -1
- package/lib/curves/getPathProfile.js +0 -128
- package/lib/curves/getPointAtDistance.d.ts +0 -4
- package/lib/curves/getPointAtDistance.d.ts.map +0 -1
- package/lib/curves/getPointAtDistance.js +0 -15
- package/lib/curves/getPolylineProfile.d.ts +0 -4
- package/lib/curves/getPolylineProfile.d.ts.map +0 -1
- package/lib/curves/getPolylineProfile.js +0 -58
- package/lib/curves/getRectProfile.d.ts +0 -4
- package/lib/curves/getRectProfile.d.ts.map +0 -1
- package/lib/curves/getRectProfile.js +0 -57
- package/lib/curves/index.d.ts +0 -17
- package/lib/curves/index.d.ts.map +0 -1
- package/lib/curves/index.js +0 -17
- package/lib/decorators/canvasStyleSignal.d.ts +0 -5
- package/lib/decorators/canvasStyleSignal.d.ts.map +0 -1
- package/lib/decorators/canvasStyleSignal.js +0 -12
- package/lib/decorators/colorSignal.d.ts +0 -2
- package/lib/decorators/colorSignal.d.ts.map +0 -1
- package/lib/decorators/colorSignal.js +0 -9
- package/lib/decorators/compound.d.ts +0 -26
- package/lib/decorators/compound.d.ts.map +0 -1
- package/lib/decorators/compound.js +0 -49
- package/lib/decorators/computed.d.ts +0 -9
- package/lib/decorators/computed.d.ts.map +0 -1
- package/lib/decorators/computed.js +0 -18
- package/lib/decorators/defaultStyle.d.ts +0 -2
- package/lib/decorators/defaultStyle.d.ts.map +0 -1
- package/lib/decorators/defaultStyle.js +0 -14
- package/lib/decorators/filtersSignal.d.ts +0 -13
- package/lib/decorators/filtersSignal.d.ts.map +0 -1
- package/lib/decorators/filtersSignal.js +0 -73
- package/lib/decorators/index.d.ts +0 -11
- package/lib/decorators/index.d.ts.map +0 -1
- package/lib/decorators/index.js +0 -11
- package/lib/decorators/initializers.d.ts +0 -4
- package/lib/decorators/initializers.d.ts.map +0 -1
- package/lib/decorators/initializers.js +0 -27
- package/lib/decorators/nodeName.d.ts +0 -9
- package/lib/decorators/nodeName.d.ts.map +0 -1
- package/lib/decorators/nodeName.js +0 -13
- package/lib/decorators/signal.d.ts +0 -183
- package/lib/decorators/signal.d.ts.map +0 -1
- package/lib/decorators/signal.js +0 -285
- package/lib/decorators/spacingSignal.d.ts +0 -2
- package/lib/decorators/spacingSignal.d.ts.map +0 -1
- package/lib/decorators/spacingSignal.js +0 -15
- package/lib/decorators/vector2Signal.d.ts +0 -9
- package/lib/decorators/vector2Signal.d.ts.map +0 -1
- package/lib/decorators/vector2Signal.js +0 -15
- package/lib/index.d.ts +0 -9
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -9
- package/lib/jsx-dev-runtime.d.ts +0 -3
- package/lib/jsx-dev-runtime.d.ts.map +0 -1
- package/lib/jsx-dev-runtime.js +0 -3
- package/lib/jsx-runtime.d.ts +0 -12
- package/lib/jsx-runtime.d.ts.map +0 -1
- package/lib/jsx-runtime.js +0 -23
- package/lib/partials/Filter.d.ts +0 -82
- package/lib/partials/Filter.d.ts.map +0 -1
- package/lib/partials/Filter.js +0 -135
- package/lib/partials/Gradient.d.ts +0 -31
- package/lib/partials/Gradient.d.ts.map +0 -1
- package/lib/partials/Gradient.js +0 -63
- package/lib/partials/Pattern.d.ts +0 -13
- package/lib/partials/Pattern.d.ts.map +0 -1
- package/lib/partials/Pattern.js +0 -27
- package/lib/partials/ShaderConfig.d.ts +0 -81
- package/lib/partials/ShaderConfig.d.ts.map +0 -1
- package/lib/partials/ShaderConfig.js +0 -25
- package/lib/partials/index.d.ts +0 -5
- package/lib/partials/index.d.ts.map +0 -1
- package/lib/partials/index.js +0 -5
- package/lib/partials/types.d.ts +0 -35
- package/lib/partials/types.d.ts.map +0 -1
- package/lib/partials/types.js +0 -2
- package/lib/scenes/Scene2D.d.ts +0 -29
- package/lib/scenes/Scene2D.d.ts.map +0 -1
- package/lib/scenes/Scene2D.js +0 -180
- package/lib/scenes/index.d.ts +0 -4
- package/lib/scenes/index.d.ts.map +0 -1
- package/lib/scenes/index.js +0 -4
- package/lib/scenes/makeScene2D.d.ts +0 -5
- package/lib/scenes/makeScene2D.d.ts.map +0 -1
- package/lib/scenes/makeScene2D.js +0 -11
- package/lib/scenes/useScene2D.d.ts +0 -3
- package/lib/scenes/useScene2D.d.ts.map +0 -1
- package/lib/scenes/useScene2D.js +0 -5
- package/lib/tsconfig.build.tsbuildinfo +0 -1
- package/lib/utils/CanvasUtils.d.ts +0 -23
- package/lib/utils/CanvasUtils.d.ts.map +0 -1
- package/lib/utils/CanvasUtils.js +0 -138
- package/lib/utils/diff.d.ts +0 -31
- package/lib/utils/diff.d.ts.map +0 -1
- package/lib/utils/diff.js +0 -97
- package/lib/utils/index.d.ts +0 -3
- package/lib/utils/index.d.ts.map +0 -1
- package/lib/utils/index.js +0 -3
- package/lib/utils/is.d.ts +0 -8
- package/lib/utils/is.d.ts.map +0 -1
- package/lib/utils/is.js +0 -10
- package/lib/utils/makeSignalExtensions.d.ts +0 -4
- package/lib/utils/makeSignalExtensions.d.ts.map +0 -1
- package/lib/utils/makeSignalExtensions.js +0 -20
- package/lib/utils/video/ffmpeg-client.d.ts +0 -5
- package/lib/utils/video/ffmpeg-client.d.ts.map +0 -1
- package/lib/utils/video/ffmpeg-client.js +0 -32
- package/lib/utils/video/mp4-parser-manager.d.ts +0 -3
- package/lib/utils/video/mp4-parser-manager.d.ts.map +0 -1
- package/lib/utils/video/mp4-parser-manager.js +0 -55
- package/lib/utils/video/parser/index.d.ts +0 -2
- package/lib/utils/video/parser/index.d.ts.map +0 -1
- package/lib/utils/video/parser/index.js +0 -2
- package/lib/utils/video/parser/parser.d.ts +0 -21
- package/lib/utils/video/parser/parser.d.ts.map +0 -1
- package/lib/utils/video/parser/parser.js +0 -168
- package/lib/utils/video/parser/sampler.d.ts +0 -16
- package/lib/utils/video/parser/sampler.d.ts.map +0 -1
- package/lib/utils/video/parser/sampler.js +0 -56
- package/lib/utils/video/parser/segment.d.ts +0 -48
- package/lib/utils/video/parser/segment.d.ts.map +0 -1
- package/lib/utils/video/parser/segment.js +0 -239
- package/lib/utils/video/parser/sink.d.ts +0 -9
- package/lib/utils/video/parser/sink.d.ts.map +0 -1
- package/lib/utils/video/parser/sink.js +0 -22
- package/lib/utils/video/parser/utils.d.ts +0 -10
- package/lib/utils/video/parser/utils.d.ts.map +0 -1
- package/lib/utils/video/parser/utils.js +0 -22
- package/src/editor/NodeInspectorConfig.tsx +0 -76
- package/src/editor/PreviewOverlayConfig.tsx +0 -67
- package/src/editor/Provider.tsx +0 -93
- package/src/editor/SceneGraphTabConfig.tsx +0 -81
- package/src/editor/icons/CircleIcon.tsx +0 -7
- package/src/editor/icons/CodeBlockIcon.tsx +0 -8
- package/src/editor/icons/CurveIcon.tsx +0 -7
- package/src/editor/icons/GridIcon.tsx +0 -7
- package/src/editor/icons/IconMap.ts +0 -35
- package/src/editor/icons/ImgIcon.tsx +0 -8
- package/src/editor/icons/LayoutIcon.tsx +0 -9
- package/src/editor/icons/LineIcon.tsx +0 -7
- package/src/editor/icons/NodeIcon.tsx +0 -7
- package/src/editor/icons/RayIcon.tsx +0 -7
- package/src/editor/icons/RectIcon.tsx +0 -7
- package/src/editor/icons/ShapeIcon.tsx +0 -7
- package/src/editor/icons/TxtIcon.tsx +0 -8
- package/src/editor/icons/VideoIcon.tsx +0 -7
- package/src/editor/icons/View2DIcon.tsx +0 -10
- package/src/editor/index.css +0 -0
- package/src/editor/index.ts +0 -17
- package/src/editor/tree/DetachedRoot.tsx +0 -23
- package/src/editor/tree/NodeElement.tsx +0 -74
- package/src/editor/tree/TreeElement.tsx +0 -72
- package/src/editor/tree/TreeRoot.tsx +0 -10
- package/src/editor/tree/ViewRoot.tsx +0 -20
- package/src/editor/tree/index.module.scss +0 -38
- package/src/editor/tree/index.ts +0 -3
- package/src/editor/tsconfig.build.json +0 -5
- package/src/editor/tsconfig.json +0 -12
- package/src/editor/tsdoc.json +0 -4
- package/src/editor/vite-env.d.ts +0 -1
- package/src/lib/code/CodeCursor.ts +0 -445
- package/src/lib/code/CodeDiffer.ts +0 -78
- package/src/lib/code/CodeFragment.ts +0 -97
- package/src/lib/code/CodeHighlighter.ts +0 -75
- package/src/lib/code/CodeMetrics.ts +0 -47
- package/src/lib/code/CodeRange.test.ts +0 -74
- package/src/lib/code/CodeRange.ts +0 -216
- package/src/lib/code/CodeScope.ts +0 -101
- package/src/lib/code/CodeSelection.ts +0 -24
- package/src/lib/code/CodeSignal.ts +0 -327
- package/src/lib/code/CodeTokenizer.ts +0 -54
- package/src/lib/code/DefaultHighlightStyle.ts +0 -98
- package/src/lib/code/LezerHighlighter.ts +0 -113
- package/src/lib/code/diff.test.ts +0 -311
- package/src/lib/code/diff.ts +0 -319
- package/src/lib/code/extractRange.ts +0 -126
- package/src/lib/code/index.ts +0 -13
- package/src/lib/components/Audio.ts +0 -168
- package/src/lib/components/Bezier.ts +0 -105
- package/src/lib/components/Circle.ts +0 -266
- package/src/lib/components/Code.ts +0 -526
- package/src/lib/components/CodeBlock.ts +0 -576
- package/src/lib/components/CubicBezier.ts +0 -112
- package/src/lib/components/Curve.ts +0 -455
- package/src/lib/components/Grid.ts +0 -135
- package/src/lib/components/Icon.ts +0 -96
- package/src/lib/components/Img.ts +0 -319
- package/src/lib/components/Knot.ts +0 -157
- package/src/lib/components/Latex.ts +0 -122
- package/src/lib/components/Layout.ts +0 -1092
- package/src/lib/components/Line.ts +0 -429
- package/src/lib/components/Media.ts +0 -576
- package/src/lib/components/Node.ts +0 -1940
- package/src/lib/components/Path.ts +0 -137
- package/src/lib/components/Polygon.ts +0 -171
- package/src/lib/components/QuadBezier.ts +0 -100
- package/src/lib/components/Ray.ts +0 -125
- package/src/lib/components/Rect.ts +0 -187
- package/src/lib/components/Rive.ts +0 -156
- package/src/lib/components/SVG.ts +0 -797
- package/src/lib/components/Shape.ts +0 -143
- package/src/lib/components/Spline.ts +0 -344
- package/src/lib/components/Txt.test.tsx +0 -81
- package/src/lib/components/Txt.ts +0 -203
- package/src/lib/components/TxtLeaf.ts +0 -205
- package/src/lib/components/Video.ts +0 -461
- package/src/lib/components/View2D.ts +0 -98
- package/src/lib/components/__tests__/children.test.tsx +0 -142
- package/src/lib/components/__tests__/clone.test.tsx +0 -126
- package/src/lib/components/__tests__/generatorTest.ts +0 -28
- package/src/lib/components/__tests__/mockScene2D.ts +0 -45
- package/src/lib/components/__tests__/query.test.tsx +0 -122
- package/src/lib/components/__tests__/state.test.tsx +0 -60
- package/src/lib/components/index.ts +0 -28
- package/src/lib/components/types.ts +0 -35
- package/src/lib/curves/ArcSegment.ts +0 -159
- package/src/lib/curves/CircleSegment.ts +0 -77
- package/src/lib/curves/CubicBezierSegment.ts +0 -78
- package/src/lib/curves/CurveDrawingInfo.ts +0 -11
- package/src/lib/curves/CurvePoint.ts +0 -15
- package/src/lib/curves/CurveProfile.ts +0 -7
- package/src/lib/curves/KnotInfo.ts +0 -10
- package/src/lib/curves/LineSegment.ts +0 -62
- package/src/lib/curves/Polynomial.ts +0 -355
- package/src/lib/curves/Polynomial2D.ts +0 -62
- package/src/lib/curves/PolynomialSegment.ts +0 -124
- package/src/lib/curves/QuadBezierSegment.ts +0 -64
- package/src/lib/curves/Segment.ts +0 -17
- package/src/lib/curves/UniformPolynomialCurveSampler.ts +0 -94
- package/src/lib/curves/createCurveProfileLerp.ts +0 -471
- package/src/lib/curves/getBezierSplineProfile.ts +0 -223
- package/src/lib/curves/getCircleProfile.ts +0 -86
- package/src/lib/curves/getPathProfile.ts +0 -178
- package/src/lib/curves/getPointAtDistance.ts +0 -21
- package/src/lib/curves/getPolylineProfile.test.ts +0 -21
- package/src/lib/curves/getPolylineProfile.ts +0 -89
- package/src/lib/curves/getRectProfile.ts +0 -139
- package/src/lib/curves/index.ts +0 -16
- package/src/lib/decorators/canvasStyleSignal.ts +0 -16
- package/src/lib/decorators/colorSignal.ts +0 -9
- package/src/lib/decorators/compound.ts +0 -72
- package/src/lib/decorators/computed.ts +0 -18
- package/src/lib/decorators/defaultStyle.ts +0 -18
- package/src/lib/decorators/filtersSignal.ts +0 -136
- package/src/lib/decorators/index.ts +0 -10
- package/src/lib/decorators/initializers.ts +0 -32
- package/src/lib/decorators/nodeName.ts +0 -13
- package/src/lib/decorators/signal.test.ts +0 -90
- package/src/lib/decorators/signal.ts +0 -345
- package/src/lib/decorators/spacingSignal.ts +0 -15
- package/src/lib/decorators/vector2Signal.ts +0 -30
- package/src/lib/globals.d.ts +0 -2
- package/src/lib/index.ts +0 -8
- package/src/lib/jsx-dev-runtime.ts +0 -2
- package/src/lib/jsx-runtime.ts +0 -46
- package/src/lib/parse-svg-path.d.ts +0 -14
- package/src/lib/partials/Filter.ts +0 -180
- package/src/lib/partials/Gradient.ts +0 -102
- package/src/lib/partials/Pattern.ts +0 -34
- package/src/lib/partials/ShaderConfig.ts +0 -117
- package/src/lib/partials/index.ts +0 -4
- package/src/lib/partials/types.ts +0 -58
- package/src/lib/scenes/Scene2D.ts +0 -242
- package/src/lib/scenes/index.ts +0 -3
- package/src/lib/scenes/makeScene2D.ts +0 -16
- package/src/lib/scenes/useScene2D.ts +0 -6
- package/src/lib/tsconfig.build.json +0 -5
- package/src/lib/tsconfig.json +0 -10
- package/src/lib/tsdoc.json +0 -4
- package/src/lib/utils/CanvasUtils.ts +0 -306
- package/src/lib/utils/diff.test.ts +0 -453
- package/src/lib/utils/diff.ts +0 -148
- package/src/lib/utils/index.ts +0 -2
- package/src/lib/utils/is.ts +0 -11
- package/src/lib/utils/makeSignalExtensions.ts +0 -30
- package/src/lib/utils/video/declarations.d.ts +0 -1
- package/src/lib/utils/video/ffmpeg-client.ts +0 -50
- package/src/lib/utils/video/mp4-parser-manager.ts +0 -72
- package/src/lib/utils/video/parser/index.ts +0 -1
- package/src/lib/utils/video/parser/parser.ts +0 -257
- package/src/lib/utils/video/parser/sampler.ts +0 -72
- package/src/lib/utils/video/parser/segment.ts +0 -302
- package/src/lib/utils/video/parser/sink.ts +0 -29
- package/src/lib/utils/video/parser/utils.ts +0 -31
- package/src/tsconfig.base.json +0 -19
- package/src/tsconfig.build.json +0 -8
- package/src/tsconfig.json +0 -5
package/lib/components/Bezier.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
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, transformVectorAsPoint } from '@twick/core';
|
|
8
|
-
import { computed } from '../decorators';
|
|
9
|
-
import { arc, drawLine, drawPivot, moveTo } from '../utils';
|
|
10
|
-
import { Curve } from './Curve';
|
|
11
|
-
export class Bezier extends Curve {
|
|
12
|
-
profile() {
|
|
13
|
-
const segment = this.segment();
|
|
14
|
-
return {
|
|
15
|
-
segments: [segment],
|
|
16
|
-
arcLength: segment.arcLength,
|
|
17
|
-
minSin: 0,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
childrenBBox() {
|
|
21
|
-
return BBox.fromPoints(...this.segment().points);
|
|
22
|
-
}
|
|
23
|
-
desiredSize() {
|
|
24
|
-
return this.segment().getBBox().size;
|
|
25
|
-
}
|
|
26
|
-
offsetComputedLayout(box) {
|
|
27
|
-
box.position = box.position.sub(this.segment().getBBox().center);
|
|
28
|
-
return box;
|
|
29
|
-
}
|
|
30
|
-
drawOverlay(context, matrix) {
|
|
31
|
-
const size = this.computedSize();
|
|
32
|
-
const box = this.childrenBBox().transformCorners(matrix);
|
|
33
|
-
const offsetBeforeTransform = size.mul(this.offset()).scale(0.5);
|
|
34
|
-
const offset = transformVectorAsPoint(offsetBeforeTransform, matrix);
|
|
35
|
-
const overlayInfo = this.overlayInfo(matrix);
|
|
36
|
-
context.lineWidth = 1;
|
|
37
|
-
context.strokeStyle = 'white';
|
|
38
|
-
context.fillStyle = 'white';
|
|
39
|
-
// Draw the curve itself first so everything else gets drawn on top of it
|
|
40
|
-
context.stroke(overlayInfo.curve);
|
|
41
|
-
context.fillStyle = 'white';
|
|
42
|
-
context.globalAlpha = 0.5;
|
|
43
|
-
context.beginPath();
|
|
44
|
-
context.stroke(overlayInfo.handleLines);
|
|
45
|
-
context.globalAlpha = 1;
|
|
46
|
-
context.lineWidth = 2;
|
|
47
|
-
// Draw start and end points
|
|
48
|
-
for (const point of [overlayInfo.startPoint, overlayInfo.endPoint]) {
|
|
49
|
-
moveTo(context, point);
|
|
50
|
-
context.beginPath();
|
|
51
|
-
arc(context, point, 4);
|
|
52
|
-
context.closePath();
|
|
53
|
-
context.stroke();
|
|
54
|
-
context.fill();
|
|
55
|
-
}
|
|
56
|
-
// Draw the control points
|
|
57
|
-
context.fillStyle = 'black';
|
|
58
|
-
for (const point of overlayInfo.controlPoints) {
|
|
59
|
-
moveTo(context, point);
|
|
60
|
-
context.beginPath();
|
|
61
|
-
arc(context, point, 4);
|
|
62
|
-
context.closePath();
|
|
63
|
-
context.fill();
|
|
64
|
-
context.stroke();
|
|
65
|
-
}
|
|
66
|
-
// Draw the offset marker
|
|
67
|
-
context.lineWidth = 1;
|
|
68
|
-
context.beginPath();
|
|
69
|
-
drawPivot(context, offset);
|
|
70
|
-
context.stroke();
|
|
71
|
-
// Draw the bounding box
|
|
72
|
-
context.beginPath();
|
|
73
|
-
drawLine(context, box);
|
|
74
|
-
context.closePath();
|
|
75
|
-
context.stroke();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
__decorate([
|
|
79
|
-
computed()
|
|
80
|
-
], Bezier.prototype, "childrenBBox", null);
|
|
81
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQmV6aWVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xpYi9jb21wb25lbnRzL0Jlemllci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFDQSxPQUFPLEVBQUMsSUFBSSxFQUFFLHNCQUFzQixFQUFDLE1BQU0sYUFBYSxDQUFDO0FBR3pELE9BQU8sRUFBQyxRQUFRLEVBQUMsTUFBTSxlQUFlLENBQUM7QUFFdkMsT0FBTyxFQUF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UFDLE1BQU0sRUFBRSxDQUFDO0lBQ25CLENBQUM7Q0FDRjtBQXhFVztJQURULFFBQVEsRUFBRTswQ0FHViJ9
|
|
@@ -1,193 +0,0 @@
|
|
|
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 CircleProps extends CurveProps {
|
|
8
|
-
/**
|
|
9
|
-
* {@inheritDoc Circle.startAngle}
|
|
10
|
-
*/
|
|
11
|
-
startAngle?: SignalValue<number>;
|
|
12
|
-
/**
|
|
13
|
-
* {@inheritDoc Circle.endAngle}
|
|
14
|
-
*/
|
|
15
|
-
endAngle?: SignalValue<number>;
|
|
16
|
-
/**
|
|
17
|
-
* {@inheritDoc Circle.counterclockwise}
|
|
18
|
-
*/
|
|
19
|
-
counterclockwise?: SignalValue<boolean>;
|
|
20
|
-
/**
|
|
21
|
-
* {@inheritDoc Circle.closed}
|
|
22
|
-
*/
|
|
23
|
-
closed?: SignalValue<boolean>;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* A node for drawing circular shapes.
|
|
27
|
-
*
|
|
28
|
-
* @remarks
|
|
29
|
-
* This node can be used to render shapes such as: circle, ellipse, arc, and
|
|
30
|
-
* sector (pie chart).
|
|
31
|
-
*
|
|
32
|
-
* @preview
|
|
33
|
-
* ```tsx editor
|
|
34
|
-
* // snippet Simple circle
|
|
35
|
-
* import {makeScene2D, Circle} from '@twick/2d';
|
|
36
|
-
*
|
|
37
|
-
* export default makeScene2D(function* (view) {
|
|
38
|
-
* view.add(
|
|
39
|
-
* <Circle
|
|
40
|
-
* size={160}
|
|
41
|
-
* fill={'lightseagreen'}
|
|
42
|
-
* />
|
|
43
|
-
* );
|
|
44
|
-
* });
|
|
45
|
-
*
|
|
46
|
-
* // snippet Ellipse
|
|
47
|
-
* import {makeScene2D, Circle} from '@twick/2d';
|
|
48
|
-
*
|
|
49
|
-
* export default makeScene2D(function* (view) {
|
|
50
|
-
* view.add(
|
|
51
|
-
* <Circle
|
|
52
|
-
* width={160}
|
|
53
|
-
* height={80}
|
|
54
|
-
* fill={'lightseagreen'}
|
|
55
|
-
* />
|
|
56
|
-
* );
|
|
57
|
-
* });
|
|
58
|
-
*
|
|
59
|
-
* // snippet Sector (pie chart):
|
|
60
|
-
* import {makeScene2D, Circle} from '@twick/2d';
|
|
61
|
-
* import {createRef} from '@twick/core';
|
|
62
|
-
*
|
|
63
|
-
* export default makeScene2D(function* (view) {
|
|
64
|
-
* const ref = createRef<Circle>();
|
|
65
|
-
* view.add(
|
|
66
|
-
* <Circle
|
|
67
|
-
* ref={ref}
|
|
68
|
-
* size={160}
|
|
69
|
-
* fill={'lightseagreen'}
|
|
70
|
-
* startAngle={30}
|
|
71
|
-
* endAngle={270}
|
|
72
|
-
* closed={true}
|
|
73
|
-
* />
|
|
74
|
-
* );
|
|
75
|
-
*
|
|
76
|
-
* yield* ref().startAngle(270, 2).to(30, 2);
|
|
77
|
-
* });
|
|
78
|
-
*
|
|
79
|
-
* // snippet Arc:
|
|
80
|
-
* import {makeScene2D, Circle} from '@twick/2d';
|
|
81
|
-
* import {createRef} from '@twick/core';
|
|
82
|
-
*
|
|
83
|
-
* export default makeScene2D(function* (view) {
|
|
84
|
-
* const ref = createRef<Circle>();
|
|
85
|
-
* view.add(
|
|
86
|
-
* <Circle
|
|
87
|
-
* ref={ref}
|
|
88
|
-
* size={160}
|
|
89
|
-
* stroke={'lightseagreen'}
|
|
90
|
-
* lineWidth={8}
|
|
91
|
-
* startAngle={-90}
|
|
92
|
-
* endAngle={90}
|
|
93
|
-
* />
|
|
94
|
-
* );
|
|
95
|
-
*
|
|
96
|
-
* yield* ref().startAngle(-270, 2).to(-90, 2);
|
|
97
|
-
* });
|
|
98
|
-
*
|
|
99
|
-
* // snippet Curve properties:
|
|
100
|
-
* import {makeScene2D, Circle} from '@twick/2d';
|
|
101
|
-
* import {all, createRef, easeInCubic, easeOutCubic} from '@twick/core';
|
|
102
|
-
*
|
|
103
|
-
* export default makeScene2D(function* (view) {
|
|
104
|
-
* const ref = createRef<Circle>();
|
|
105
|
-
* view.add(
|
|
106
|
-
* <Circle
|
|
107
|
-
* ref={ref}
|
|
108
|
-
* size={160}
|
|
109
|
-
* stroke={'lightseagreen'}
|
|
110
|
-
* lineWidth={8}
|
|
111
|
-
* endAngle={270}
|
|
112
|
-
* endArrow
|
|
113
|
-
* />,
|
|
114
|
-
* );
|
|
115
|
-
*
|
|
116
|
-
* yield* all(ref().start(1, 1), ref().rotation(180, 1, easeInCubic));
|
|
117
|
-
* ref().start(0).end(0);
|
|
118
|
-
* yield* all(ref().end(1, 1), ref().rotation(360, 1, easeOutCubic));
|
|
119
|
-
* });
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
export declare class Circle extends Curve {
|
|
123
|
-
/**
|
|
124
|
-
* The starting angle in degrees for the circle sector.
|
|
125
|
-
*
|
|
126
|
-
* @remarks
|
|
127
|
-
* This property can be used together with {@link startAngle} to turn this
|
|
128
|
-
* circle into a sector (when using fill) or an arc (when using stroke).
|
|
129
|
-
*
|
|
130
|
-
* @defaultValue 0
|
|
131
|
-
*/
|
|
132
|
-
readonly startAngle: SimpleSignal<number, this>;
|
|
133
|
-
/**
|
|
134
|
-
* The ending angle in degrees for the circle sector.
|
|
135
|
-
*
|
|
136
|
-
* @remarks
|
|
137
|
-
* This property can be used together with {@link endAngle} to turn this
|
|
138
|
-
* circle into a sector (when using fill) or an arc (when using stroke).
|
|
139
|
-
*
|
|
140
|
-
* @defaultValue 360
|
|
141
|
-
*/
|
|
142
|
-
readonly endAngle: SimpleSignal<number, this>;
|
|
143
|
-
/**
|
|
144
|
-
* Whether the circle sector should be drawn counterclockwise.
|
|
145
|
-
*
|
|
146
|
-
* @remarks
|
|
147
|
-
* By default, the circle begins at {@link startAngle} and is drawn clockwise
|
|
148
|
-
* until reaching {@link endAngle}. Setting this property to true will reverse
|
|
149
|
-
* this direction.
|
|
150
|
-
*/
|
|
151
|
-
readonly counterclockwise: SimpleSignal<boolean, this>;
|
|
152
|
-
/**
|
|
153
|
-
* Whether the path of this circle should be closed.
|
|
154
|
-
*
|
|
155
|
-
* @remarks
|
|
156
|
-
* When set to true, the path of this circle will start and end at the center.
|
|
157
|
-
* This can be used to fine-tune how sectors are rendered.
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* A closed circle will look like a pie chart:
|
|
161
|
-
* ```tsx
|
|
162
|
-
* <Circle
|
|
163
|
-
* size={300}
|
|
164
|
-
* fill={'lightseagreen'}
|
|
165
|
-
* endAngle={230}
|
|
166
|
-
* closed={true}
|
|
167
|
-
* />
|
|
168
|
-
* ```
|
|
169
|
-
* An open one will look like an arc:
|
|
170
|
-
* ```tsx
|
|
171
|
-
* <Circle
|
|
172
|
-
* size={300}
|
|
173
|
-
* stroke={'lightseagreen'}
|
|
174
|
-
* lineWidth={8}
|
|
175
|
-
* endAngle={230}
|
|
176
|
-
* closed={false}
|
|
177
|
-
* />
|
|
178
|
-
* ```
|
|
179
|
-
*
|
|
180
|
-
* @defaultValue false
|
|
181
|
-
*/
|
|
182
|
-
readonly closed: SimpleSignal<boolean, this>;
|
|
183
|
-
constructor(props: CircleProps);
|
|
184
|
-
profile(): CurveProfile;
|
|
185
|
-
protected desiredSize(): SerializedVector2<DesiredLength>;
|
|
186
|
-
protected offsetComputedLayout(box: BBox): BBox;
|
|
187
|
-
protected childrenBBox(): BBox;
|
|
188
|
-
protected getPath(): Path2D;
|
|
189
|
-
protected getRipplePath(): Path2D;
|
|
190
|
-
protected getCacheBBox(): BBox;
|
|
191
|
-
protected createPath(expand?: number): Path2D;
|
|
192
|
-
}
|
|
193
|
-
//# sourceMappingURL=Circle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
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AY,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAEzC,KAAK,EAAE,WAAW;IAK9B,OAAO,IAAI,YAAY;cAUX,WAAW,IAAI,iBAAiB,CAAC,aAAa,CAAC;cAO/C,oBAAoB,CAAC,GAAG,EAAE,IAAI,GAAG,IAAI;cAIrC,YAAY,IAAI,IAAI;cAIpB,OAAO,IAAI,MAAM;cAQjB,aAAa,IAAI,MAAM;cAIvB,YAAY,IAAI,IAAI;IAIvC,SAAS,CAAC,UAAU,CAAC,MAAM,SAAI;CAsBhC"}
|
package/lib/components/Circle.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
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, DEG2RAD } from '@twick/core';
|
|
8
|
-
import { getCircleProfile } from '../curves';
|
|
9
|
-
import { computed, initial, nodeName, signal } from '../decorators';
|
|
10
|
-
import { Curve } from './Curve';
|
|
11
|
-
/**
|
|
12
|
-
* A node for drawing circular shapes.
|
|
13
|
-
*
|
|
14
|
-
* @remarks
|
|
15
|
-
* This node can be used to render shapes such as: circle, ellipse, arc, and
|
|
16
|
-
* sector (pie chart).
|
|
17
|
-
*
|
|
18
|
-
* @preview
|
|
19
|
-
* ```tsx editor
|
|
20
|
-
* // snippet Simple circle
|
|
21
|
-
* import {makeScene2D, Circle} from '@twick/2d';
|
|
22
|
-
*
|
|
23
|
-
* export default makeScene2D(function* (view) {
|
|
24
|
-
* view.add(
|
|
25
|
-
* <Circle
|
|
26
|
-
* size={160}
|
|
27
|
-
* fill={'lightseagreen'}
|
|
28
|
-
* />
|
|
29
|
-
* );
|
|
30
|
-
* });
|
|
31
|
-
*
|
|
32
|
-
* // snippet Ellipse
|
|
33
|
-
* import {makeScene2D, Circle} from '@twick/2d';
|
|
34
|
-
*
|
|
35
|
-
* export default makeScene2D(function* (view) {
|
|
36
|
-
* view.add(
|
|
37
|
-
* <Circle
|
|
38
|
-
* width={160}
|
|
39
|
-
* height={80}
|
|
40
|
-
* fill={'lightseagreen'}
|
|
41
|
-
* />
|
|
42
|
-
* );
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* // snippet Sector (pie chart):
|
|
46
|
-
* import {makeScene2D, Circle} from '@twick/2d';
|
|
47
|
-
* import {createRef} from '@twick/core';
|
|
48
|
-
*
|
|
49
|
-
* export default makeScene2D(function* (view) {
|
|
50
|
-
* const ref = createRef<Circle>();
|
|
51
|
-
* view.add(
|
|
52
|
-
* <Circle
|
|
53
|
-
* ref={ref}
|
|
54
|
-
* size={160}
|
|
55
|
-
* fill={'lightseagreen'}
|
|
56
|
-
* startAngle={30}
|
|
57
|
-
* endAngle={270}
|
|
58
|
-
* closed={true}
|
|
59
|
-
* />
|
|
60
|
-
* );
|
|
61
|
-
*
|
|
62
|
-
* yield* ref().startAngle(270, 2).to(30, 2);
|
|
63
|
-
* });
|
|
64
|
-
*
|
|
65
|
-
* // snippet Arc:
|
|
66
|
-
* import {makeScene2D, Circle} from '@twick/2d';
|
|
67
|
-
* import {createRef} from '@twick/core';
|
|
68
|
-
*
|
|
69
|
-
* export default makeScene2D(function* (view) {
|
|
70
|
-
* const ref = createRef<Circle>();
|
|
71
|
-
* view.add(
|
|
72
|
-
* <Circle
|
|
73
|
-
* ref={ref}
|
|
74
|
-
* size={160}
|
|
75
|
-
* stroke={'lightseagreen'}
|
|
76
|
-
* lineWidth={8}
|
|
77
|
-
* startAngle={-90}
|
|
78
|
-
* endAngle={90}
|
|
79
|
-
* />
|
|
80
|
-
* );
|
|
81
|
-
*
|
|
82
|
-
* yield* ref().startAngle(-270, 2).to(-90, 2);
|
|
83
|
-
* });
|
|
84
|
-
*
|
|
85
|
-
* // snippet Curve properties:
|
|
86
|
-
* import {makeScene2D, Circle} from '@twick/2d';
|
|
87
|
-
* import {all, createRef, easeInCubic, easeOutCubic} from '@twick/core';
|
|
88
|
-
*
|
|
89
|
-
* export default makeScene2D(function* (view) {
|
|
90
|
-
* const ref = createRef<Circle>();
|
|
91
|
-
* view.add(
|
|
92
|
-
* <Circle
|
|
93
|
-
* ref={ref}
|
|
94
|
-
* size={160}
|
|
95
|
-
* stroke={'lightseagreen'}
|
|
96
|
-
* lineWidth={8}
|
|
97
|
-
* endAngle={270}
|
|
98
|
-
* endArrow
|
|
99
|
-
* />,
|
|
100
|
-
* );
|
|
101
|
-
*
|
|
102
|
-
* yield* all(ref().start(1, 1), ref().rotation(180, 1, easeInCubic));
|
|
103
|
-
* ref().start(0).end(0);
|
|
104
|
-
* yield* all(ref().end(1, 1), ref().rotation(360, 1, easeOutCubic));
|
|
105
|
-
* });
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
let Circle = class Circle extends Curve {
|
|
109
|
-
constructor(props) {
|
|
110
|
-
super(props);
|
|
111
|
-
}
|
|
112
|
-
profile() {
|
|
113
|
-
return getCircleProfile(this.size().scale(0.5), this.startAngle() * DEG2RAD, this.endAngle() * DEG2RAD, this.closed(), this.counterclockwise());
|
|
114
|
-
}
|
|
115
|
-
desiredSize() {
|
|
116
|
-
return {
|
|
117
|
-
x: this.width.context.getter(),
|
|
118
|
-
y: this.height.context.getter(),
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
offsetComputedLayout(box) {
|
|
122
|
-
return box;
|
|
123
|
-
}
|
|
124
|
-
childrenBBox() {
|
|
125
|
-
return BBox.fromSizeCentered(this.computedSize());
|
|
126
|
-
}
|
|
127
|
-
getPath() {
|
|
128
|
-
if (this.requiresProfile()) {
|
|
129
|
-
return this.curveDrawingInfo().path;
|
|
130
|
-
}
|
|
131
|
-
return this.createPath();
|
|
132
|
-
}
|
|
133
|
-
getRipplePath() {
|
|
134
|
-
return this.createPath(this.rippleSize());
|
|
135
|
-
}
|
|
136
|
-
getCacheBBox() {
|
|
137
|
-
return super.getCacheBBox().expand(this.rippleSize());
|
|
138
|
-
}
|
|
139
|
-
createPath(expand = 0) {
|
|
140
|
-
const path = new Path2D();
|
|
141
|
-
const start = this.startAngle() * DEG2RAD;
|
|
142
|
-
let end = this.endAngle() * DEG2RAD;
|
|
143
|
-
const size = this.size().scale(0.5).add(expand);
|
|
144
|
-
const closed = this.closed();
|
|
145
|
-
if (end > start + Math.PI * 2) {
|
|
146
|
-
const loops = Math.floor((end - start) / (Math.PI * 2));
|
|
147
|
-
end -= Math.PI * 2 * loops;
|
|
148
|
-
}
|
|
149
|
-
if (closed) {
|
|
150
|
-
path.moveTo(0, 0);
|
|
151
|
-
}
|
|
152
|
-
path.ellipse(0, 0, size.x, size.y, 0, start, end, this.counterclockwise());
|
|
153
|
-
if (closed) {
|
|
154
|
-
path.closePath();
|
|
155
|
-
}
|
|
156
|
-
return path;
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
__decorate([
|
|
160
|
-
initial(0),
|
|
161
|
-
signal()
|
|
162
|
-
], Circle.prototype, "startAngle", void 0);
|
|
163
|
-
__decorate([
|
|
164
|
-
initial(360),
|
|
165
|
-
signal()
|
|
166
|
-
], Circle.prototype, "endAngle", void 0);
|
|
167
|
-
__decorate([
|
|
168
|
-
initial(false),
|
|
169
|
-
signal()
|
|
170
|
-
], Circle.prototype, "counterclockwise", void 0);
|
|
171
|
-
__decorate([
|
|
172
|
-
computed()
|
|
173
|
-
], Circle.prototype, "profile", null);
|
|
174
|
-
Circle = __decorate([
|
|
175
|
-
nodeName('Circle')
|
|
176
|
-
], Circle);
|
|
177
|
-
export { Circle };
|
|
178
|
-
//# sourceMappingURL=data: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Z2QixPQUFPLENBQUMsQ0FBQyxDQUFDO0lBQ1YsTUFBTSxFQUFFOzBDQUNzRDtBQWF2QztJQUZ2QixPQUFPLENBQUMsR0FBRyxDQUFDO0lBQ1osTUFBTSxFQUFFO3dDQUNvRDtBQVlyQztJQUZ2QixPQUFPLENBQUMsS0FBSyxDQUFDO0lBQ2QsTUFBTSxFQUFFO2dEQUM2RDtBQXVDL0Q7SUFETixRQUFRLEVBQUU7cUNBU1Y7QUFwRlUsTUFBTTtJQURsQixRQUFRLENBQUMsUUFBUSxDQUFDO0dBQ04sTUFBTSxDQTJJbEIifQ==
|
package/lib/components/Code.d.ts
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import type { SerializedVector2, Signal, SignalValue, SimpleSignal, ThreadGenerator, TimingFunction, Vector2 } from '@twick/core';
|
|
2
|
-
import { BBox } from '@twick/core';
|
|
3
|
-
import type { CodeFragmentDrawingInfo, CodeHighlighter, CodePoint, CodeRange, CodeSelection, CodeSignal, PossibleCodeScope, PossibleCodeSelection } from '../code';
|
|
4
|
-
import type { DesiredLength } from '../partials';
|
|
5
|
-
import type { ShapeProps } from './Shape';
|
|
6
|
-
import { Shape } from './Shape';
|
|
7
|
-
export interface DrawTokenHook {
|
|
8
|
-
(ctx: CanvasRenderingContext2D, text: string, position: Vector2, color: string, selection: number): void;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Describes custom drawing logic used by the Code node.
|
|
12
|
-
*/
|
|
13
|
-
export interface DrawHooks {
|
|
14
|
-
/**
|
|
15
|
-
* Custom drawing logic for individual code tokens.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* token(ctx, text, position, color, selection) {
|
|
20
|
-
* const blur = map(3, 0, selection);
|
|
21
|
-
* const alpha = map(0.5, 1, selection);
|
|
22
|
-
* ctx.globalAlpha *= alpha;
|
|
23
|
-
* ctx.filter = `blur(${blur}px)`;
|
|
24
|
-
* ctx.fillStyle = color;
|
|
25
|
-
* ctx.fillText(text, position.x, position.y);
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
token: DrawTokenHook;
|
|
30
|
-
}
|
|
31
|
-
export interface CodeProps extends ShapeProps {
|
|
32
|
-
/**
|
|
33
|
-
* {@inheritDoc Code.highlighter}
|
|
34
|
-
*/
|
|
35
|
-
highlighter?: SignalValue<CodeHighlighter | null>;
|
|
36
|
-
/**
|
|
37
|
-
* {@inheritDoc Code.code}
|
|
38
|
-
*/
|
|
39
|
-
code?: SignalValue<PossibleCodeScope>;
|
|
40
|
-
/**
|
|
41
|
-
* {@inheritDoc Code.selection}
|
|
42
|
-
*/
|
|
43
|
-
selection?: SignalValue<PossibleCodeSelection>;
|
|
44
|
-
/**
|
|
45
|
-
* {@inheritDoc Code.drawHooks}
|
|
46
|
-
*/
|
|
47
|
-
drawHooks?: SignalValue<DrawHooks>;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* A node for displaying and animating code.
|
|
51
|
-
*
|
|
52
|
-
* @experimental
|
|
53
|
-
*
|
|
54
|
-
* @preview
|
|
55
|
-
* ```tsx editor
|
|
56
|
-
* import {parser} from '@lezer/javascript';
|
|
57
|
-
* import {Code, LezerHighlighter, makeScene2D} from '@twick/2d';
|
|
58
|
-
* import {createRef} from '@twick/core';
|
|
59
|
-
*
|
|
60
|
-
* export default makeScene2D(function* (view) {
|
|
61
|
-
* LezerHighlighter.registerParser(parser);
|
|
62
|
-
* const code = createRef<Code>();
|
|
63
|
-
*
|
|
64
|
-
* view.add(
|
|
65
|
-
* <Code
|
|
66
|
-
* ref={code}
|
|
67
|
-
* offset={-1}
|
|
68
|
-
* position={view.size().scale(-0.5).add(60)}
|
|
69
|
-
* fontFamily={'JetBrains Mono, monospace'}
|
|
70
|
-
* fontSize={36}
|
|
71
|
-
* code={`\
|
|
72
|
-
* function hello() {
|
|
73
|
-
* console.log('Hello');
|
|
74
|
-
* }`}
|
|
75
|
-
* />,
|
|
76
|
-
* );
|
|
77
|
-
*
|
|
78
|
-
* yield* code()
|
|
79
|
-
* .code(
|
|
80
|
-
* `\
|
|
81
|
-
* function hello() {
|
|
82
|
-
* console.warn('Hello World');
|
|
83
|
-
* }`,
|
|
84
|
-
* 1,
|
|
85
|
-
* )
|
|
86
|
-
* .wait(0.5)
|
|
87
|
-
* .back(1)
|
|
88
|
-
* .wait(0.5);
|
|
89
|
-
* });
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
export declare class Code extends Shape {
|
|
93
|
-
/**
|
|
94
|
-
* Create a standalone code signal.
|
|
95
|
-
*
|
|
96
|
-
* @param initial - The initial code.
|
|
97
|
-
* @param highlighter - Custom highlighter to use.
|
|
98
|
-
*/
|
|
99
|
-
static createSignal(initial: PossibleCodeScope, highlighter?: SignalValue<CodeHighlighter>): CodeSignal<void>;
|
|
100
|
-
static defaultHighlighter: CodeHighlighter | null;
|
|
101
|
-
/**
|
|
102
|
-
* The code highlighter to use for this code node.
|
|
103
|
-
*
|
|
104
|
-
* @remarks
|
|
105
|
-
* Defaults to a shared {@link code.LezerHighlighter}.
|
|
106
|
-
*/
|
|
107
|
-
readonly highlighter: SimpleSignal<CodeHighlighter | null, this>;
|
|
108
|
-
/**
|
|
109
|
-
* The code to display.
|
|
110
|
-
*/
|
|
111
|
-
readonly code: CodeSignal<this>;
|
|
112
|
-
/**
|
|
113
|
-
* Custom drawing logic for the code.
|
|
114
|
-
*
|
|
115
|
-
* @remarks
|
|
116
|
-
* Check out {@link DrawHooks} for available render hooks.
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* Make the unselected code blurry and transparent:
|
|
120
|
-
* ```tsx
|
|
121
|
-
* <Code
|
|
122
|
-
* drawHooks={{
|
|
123
|
-
* token(ctx, text, position, color, selection) {
|
|
124
|
-
* const blur = map(3, 0, selection);
|
|
125
|
-
* const alpha = map(0.5, 1, selection);
|
|
126
|
-
* ctx.globalAlpha *= alpha;
|
|
127
|
-
* ctx.filter = `blur(${blur}px)`;
|
|
128
|
-
* ctx.fillStyle = color;
|
|
129
|
-
* ctx.fillText(text, position.x, position.y);
|
|
130
|
-
* },
|
|
131
|
-
* }}
|
|
132
|
-
* // ...
|
|
133
|
-
* />
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
|
-
readonly drawHooks: SimpleSignal<DrawHooks, this>;
|
|
137
|
-
protected setDrawHooks(value: DrawHooks): void;
|
|
138
|
-
/**
|
|
139
|
-
* The currently selected code range.
|
|
140
|
-
*
|
|
141
|
-
* @remarks
|
|
142
|
-
* Either a single {@link code.CodeRange} or an array of them
|
|
143
|
-
* describing which parts of the code should be visually emphasized.
|
|
144
|
-
*
|
|
145
|
-
* You can use {@link code.word} and
|
|
146
|
-
* {@link code.lines} to quickly create ranges.
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* The following will select the word "console" in the code.
|
|
150
|
-
* Both lines and columns are 0-based. So it will select a 7-character-long
|
|
151
|
-
* (`7`) word in the second line (`1`) starting at the third character (`2`).
|
|
152
|
-
* ```tsx
|
|
153
|
-
* <Code
|
|
154
|
-
* selection={word(1, 2, 7)}
|
|
155
|
-
* code={`\
|
|
156
|
-
* function hello() => {
|
|
157
|
-
* console.log('Hello');
|
|
158
|
-
* }`}
|
|
159
|
-
* // ...
|
|
160
|
-
* />
|
|
161
|
-
* ```
|
|
162
|
-
*/
|
|
163
|
-
readonly selection: Signal<PossibleCodeSelection, CodeSelection, this>;
|
|
164
|
-
oldSelection: CodeSelection | null;
|
|
165
|
-
selectionProgress: SimpleSignal<number | null, void>;
|
|
166
|
-
protected tweenSelection(value: CodeRange[], duration: number, timingFunction: TimingFunction): ThreadGenerator;
|
|
167
|
-
/**
|
|
168
|
-
* Get the currently displayed code as a string.
|
|
169
|
-
*/
|
|
170
|
-
parsed(): string;
|
|
171
|
-
highlighterCache(): {
|
|
172
|
-
before: unknown;
|
|
173
|
-
after: unknown;
|
|
174
|
-
} | null;
|
|
175
|
-
private cursorCache;
|
|
176
|
-
private get cursor();
|
|
177
|
-
constructor(props: CodeProps);
|
|
178
|
-
/**
|
|
179
|
-
* Create a child code signal.
|
|
180
|
-
*
|
|
181
|
-
* @param initial - The initial code.
|
|
182
|
-
*/
|
|
183
|
-
createSignal(initial: PossibleCodeScope): CodeSignal<this>;
|
|
184
|
-
/**
|
|
185
|
-
* Find all code ranges that match the given pattern.
|
|
186
|
-
*
|
|
187
|
-
* @param pattern - Either a string or a regular expression to match.
|
|
188
|
-
*/
|
|
189
|
-
findAllRanges(pattern: string | RegExp): CodeRange[];
|
|
190
|
-
/**
|
|
191
|
-
* Find the first code range that matches the given pattern.
|
|
192
|
-
*
|
|
193
|
-
* @param pattern - Either a string or a regular expression to match.
|
|
194
|
-
*/
|
|
195
|
-
findFirstRange(pattern: string | RegExp): CodeRange;
|
|
196
|
-
/**
|
|
197
|
-
* Find the last code range that matches the given pattern.
|
|
198
|
-
*
|
|
199
|
-
* @param pattern - Either a string or a regular expression to match.
|
|
200
|
-
*/
|
|
201
|
-
findLastRange(pattern: string | RegExp): CodeRange;
|
|
202
|
-
/**
|
|
203
|
-
* Return the bounding box of the given point (character) in the code.
|
|
204
|
-
*
|
|
205
|
-
* @remarks
|
|
206
|
-
* The returned bound box is in local space of the `Code` node.
|
|
207
|
-
*
|
|
208
|
-
* @param point - The point to get the bounding box for.
|
|
209
|
-
*/
|
|
210
|
-
getPointBbox(point: CodePoint): BBox;
|
|
211
|
-
/**
|
|
212
|
-
* Return bounding boxes of all characters in the selection.
|
|
213
|
-
*
|
|
214
|
-
* @remarks
|
|
215
|
-
* The returned bound boxes are in local space of the `Code` node.
|
|
216
|
-
* Each line of code has a separate bounding box.
|
|
217
|
-
*
|
|
218
|
-
* @param selection - The selection to get the bounding boxes for.
|
|
219
|
-
*/
|
|
220
|
-
getSelectionBbox(selection: PossibleCodeSelection): BBox[];
|
|
221
|
-
protected drawingInfo(): {
|
|
222
|
-
fragments: CodeFragmentDrawingInfo[];
|
|
223
|
-
verticalOffset: number;
|
|
224
|
-
fontHeight: number;
|
|
225
|
-
};
|
|
226
|
-
protected desiredSize(): SerializedVector2<DesiredLength>;
|
|
227
|
-
protected draw(context: CanvasRenderingContext2D): Promise<void>;
|
|
228
|
-
protected applyText(context: CanvasRenderingContext2D): void;
|
|
229
|
-
protected collectAsyncResources(): void;
|
|
230
|
-
}
|
|
231
|
-
//# sourceMappingURL=Code.d.ts.map
|