@motionscript/math 0.1.0 → 0.1.1-alpha.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/CHANGELOG.md +19 -0
- package/dist/annotate/angle-mark.d.ts +4 -14
- package/dist/annotate/angle-mark.d.ts.map +1 -1
- package/dist/annotate/angle-mark.js +2 -1
- package/dist/annotate/angle-mark.js.map +1 -1
- package/dist/annotate/curly-brace.d.ts +4 -16
- package/dist/annotate/curly-brace.d.ts.map +1 -1
- package/dist/annotate/curly-brace.js.map +1 -1
- package/dist/annotate/emphasis-mark.d.ts +0 -5
- package/dist/annotate/emphasis-mark.d.ts.map +1 -1
- package/dist/annotate/emphasis-mark.js.map +1 -1
- package/dist/browser/chunks/chunk-FZ2YBTPL.js +2 -0
- package/dist/browser/chunks/chunk-FZ2YBTPL.js.map +7 -0
- package/dist/browser/chunks/chunk-T42HWKBC.js +2 -0
- package/dist/browser/chunks/chunk-T42HWKBC.js.map +7 -0
- package/dist/browser/chunks/{mathjax-WV55AC2P.js → mathjax-SOM6RSPV.js} +1 -1
- package/dist/browser/chunks/{mathjax-WV55AC2P.js.map → mathjax-SOM6RSPV.js.map} +2 -2
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/browser/tex.js +1 -1
- package/dist/engine.d.ts +3 -4
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +3 -4
- package/dist/engine.js.map +1 -1
- package/dist/kit/cache.d.ts +10 -21
- package/dist/kit/cache.d.ts.map +1 -1
- package/dist/kit/cache.js +33 -24
- package/dist/kit/cache.js.map +1 -1
- package/dist/kit/component.d.ts +5 -14
- package/dist/kit/component.d.ts.map +1 -1
- package/dist/kit/component.js +1 -8
- package/dist/kit/component.js.map +1 -1
- package/dist/kit/coords.d.ts +1 -1
- package/dist/kit/coords.d.ts.map +1 -1
- package/dist/kit/coords.js +2 -1
- package/dist/kit/coords.js.map +1 -1
- package/dist/kit/curve.d.ts +1 -5
- package/dist/kit/curve.d.ts.map +1 -1
- package/dist/kit/curve.js.map +1 -1
- package/dist/kit/equation.d.ts +10 -30
- package/dist/kit/equation.d.ts.map +1 -1
- package/dist/kit/equation.js +9 -44
- package/dist/kit/equation.js.map +1 -1
- package/dist/kit/equation3d.d.ts +3 -3
- package/dist/kit/equation3d.d.ts.map +1 -1
- package/dist/kit/equation3d.js +27 -59
- package/dist/kit/equation3d.js.map +1 -1
- package/dist/kit/expression.d.ts +7 -7
- package/dist/kit/expression.d.ts.map +1 -1
- package/dist/kit/expression.js +18 -17
- package/dist/kit/expression.js.map +1 -1
- package/dist/kit/field-mark.d.ts +0 -7
- package/dist/kit/field-mark.d.ts.map +1 -1
- package/dist/kit/field-mark.js.map +1 -1
- package/dist/kit/field.d.ts +2 -2
- package/dist/kit/field.d.ts.map +1 -1
- package/dist/kit/field.js +11 -31
- package/dist/kit/field.js.map +1 -1
- package/dist/kit/follow.d.ts +3 -10
- package/dist/kit/follow.d.ts.map +1 -1
- package/dist/kit/follow.js +5 -11
- package/dist/kit/follow.js.map +1 -1
- package/dist/kit/furniture.d.ts +2 -1
- package/dist/kit/furniture.d.ts.map +1 -1
- package/dist/kit/furniture.js +6 -3
- package/dist/kit/furniture.js.map +1 -1
- package/dist/kit/geometry.d.ts +1 -0
- package/dist/kit/geometry.d.ts.map +1 -1
- package/dist/kit/geometry.js +3 -0
- package/dist/kit/geometry.js.map +1 -1
- package/dist/kit/mark.d.ts +4 -10
- package/dist/kit/mark.d.ts.map +1 -1
- package/dist/kit/mark.js.map +1 -1
- package/dist/kit/place.d.ts +3 -5
- package/dist/kit/place.d.ts.map +1 -1
- package/dist/kit/place.js +3 -5
- package/dist/kit/place.js.map +1 -1
- package/dist/kit/sampler.d.ts +0 -5
- package/dist/kit/sampler.d.ts.map +1 -1
- package/dist/kit/sampler.js.map +1 -1
- package/dist/kit/system.d.ts +0 -1
- package/dist/kit/system.d.ts.map +1 -1
- package/dist/kit/system.js +3 -10
- package/dist/kit/system.js.map +1 -1
- package/dist/marks/curve-area.d.ts +2 -12
- package/dist/marks/curve-area.d.ts.map +1 -1
- package/dist/marks/curve-area.js +4 -9
- package/dist/marks/curve-area.js.map +1 -1
- package/dist/marks/drop-lines.d.ts +1 -5
- package/dist/marks/drop-lines.d.ts.map +1 -1
- package/dist/marks/drop-lines.js.map +1 -1
- package/dist/marks/plot-point.d.ts +4 -13
- package/dist/marks/plot-point.d.ts.map +1 -1
- package/dist/marks/plot-point.js.map +1 -1
- package/dist/marks/riemann-sum.d.ts +1 -7
- package/dist/marks/riemann-sum.d.ts.map +1 -1
- package/dist/marks/riemann-sum.js +2 -2
- package/dist/marks/riemann-sum.js.map +1 -1
- package/dist/marks/tangent-line.d.ts +2 -12
- package/dist/marks/tangent-line.d.ts.map +1 -1
- package/dist/marks/tangent-line.js +1 -5
- package/dist/marks/tangent-line.js.map +1 -1
- package/dist/marks/vector-arrow.d.ts +2 -11
- package/dist/marks/vector-arrow.d.ts.map +1 -1
- package/dist/marks/vector-arrow.js +3 -6
- package/dist/marks/vector-arrow.js.map +1 -1
- package/dist/nodes.d.ts +1 -12
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js.map +1 -1
- package/dist/plots/function-plot.d.ts +1 -6
- package/dist/plots/function-plot.d.ts.map +1 -1
- package/dist/plots/function-plot.js +1 -5
- package/dist/plots/function-plot.js.map +1 -1
- package/dist/plots/points-plot.d.ts +1 -6
- package/dist/plots/points-plot.d.ts.map +1 -1
- package/dist/plots/points-plot.js.map +1 -1
- package/dist/plots/stream-lines.d.ts +0 -7
- package/dist/plots/stream-lines.d.ts.map +1 -1
- package/dist/plots/stream-lines.js.map +1 -1
- package/dist/plots/traced-path.d.ts +1 -12
- package/dist/plots/traced-path.d.ts.map +1 -1
- package/dist/plots/traced-path.js +1 -6
- package/dist/plots/traced-path.js.map +1 -1
- package/dist/plots/vector-field.d.ts +1 -10
- package/dist/plots/vector-field.d.ts.map +1 -1
- package/dist/plots/vector-field.js +3 -6
- package/dist/plots/vector-field.js.map +1 -1
- package/dist/structures/network-graph.d.ts +15 -34
- package/dist/structures/network-graph.d.ts.map +1 -1
- package/dist/structures/network-graph.js +2 -5
- package/dist/structures/network-graph.js.map +1 -1
- package/dist/structures/sample-space.d.ts +8 -22
- package/dist/structures/sample-space.d.ts.map +1 -1
- package/dist/structures/sample-space.js +3 -5
- package/dist/structures/sample-space.js.map +1 -1
- package/dist/systems/axes2d.d.ts +0 -1
- package/dist/systems/axes2d.d.ts.map +1 -1
- package/dist/systems/axes2d.js +3 -4
- package/dist/systems/axes2d.js.map +1 -1
- package/dist/systems/number-line.d.ts +7 -22
- package/dist/systems/number-line.d.ts.map +1 -1
- package/dist/systems/number-line.js +2 -2
- package/dist/systems/number-line.js.map +1 -1
- package/dist/systems/number-plane.d.ts +12 -27
- package/dist/systems/number-plane.d.ts.map +1 -1
- package/dist/systems/number-plane.js +1 -7
- package/dist/systems/number-plane.js.map +1 -1
- package/dist/systems/polar-plane.d.ts +11 -26
- package/dist/systems/polar-plane.d.ts.map +1 -1
- package/dist/systems/polar-plane.js +7 -10
- package/dist/systems/polar-plane.js.map +1 -1
- package/dist/tex/geometry.d.ts +5 -24
- package/dist/tex/geometry.d.ts.map +1 -1
- package/dist/tex/geometry.js +19 -90
- package/dist/tex/geometry.js.map +1 -1
- package/dist/tex/mathjax.d.ts +0 -13
- package/dist/tex/mathjax.d.ts.map +1 -1
- package/dist/tex/mathjax.js +4 -24
- package/dist/tex/mathjax.js.map +1 -1
- package/dist/tex/matrix.d.ts +1 -10
- package/dist/tex/matrix.d.ts.map +1 -1
- package/dist/tex/matrix.js +1 -5
- package/dist/tex/matrix.js.map +1 -1
- package/dist/tex/tween.d.ts +9 -30
- package/dist/tex/tween.d.ts.map +1 -1
- package/dist/tex/tween.js +19 -67
- package/dist/tex/tween.js.map +1 -1
- package/dist/tex/typeset.d.ts +2 -23
- package/dist/tex/typeset.d.ts.map +1 -1
- package/dist/tex/typeset.js +4 -30
- package/dist/tex/typeset.js.map +1 -1
- package/dist/three/axes3d.d.ts +32 -62
- package/dist/three/axes3d.d.ts.map +1 -1
- package/dist/three/axes3d.js +5 -13
- package/dist/three/axes3d.js.map +1 -1
- package/dist/three/curve-plot3d.d.ts +4 -15
- package/dist/three/curve-plot3d.d.ts.map +1 -1
- package/dist/three/curve-plot3d.js.map +1 -1
- package/dist/three/plot-point3d.d.ts +7 -14
- package/dist/three/plot-point3d.d.ts.map +1 -1
- package/dist/three/plot-point3d.js.map +1 -1
- package/dist/three/space.d.ts +3 -8
- package/dist/three/space.d.ts.map +1 -1
- package/dist/three/space.js +1 -8
- package/dist/three/space.js.map +1 -1
- package/dist/three/surface-plot3d.d.ts +9 -23
- package/dist/three/surface-plot3d.d.ts.map +1 -1
- package/dist/three/surface-plot3d.js.map +1 -1
- package/dist/three/vector-arrow3d.d.ts +1 -7
- package/dist/three/vector-arrow3d.d.ts.map +1 -1
- package/dist/three/vector-arrow3d.js.map +1 -1
- package/package.json +4 -4
- package/src/annotate/angle-mark.ts +4 -14
- package/src/annotate/curly-brace.ts +2 -14
- package/src/annotate/emphasis-mark.ts +1 -6
- package/src/engine.ts +3 -4
- package/src/kit/cache.ts +33 -25
- package/src/kit/component.ts +5 -19
- package/src/kit/coords.ts +2 -2
- package/src/kit/curve.ts +1 -5
- package/src/kit/equation.ts +12 -50
- package/src/kit/equation3d.ts +23 -59
- package/src/kit/expression.ts +18 -23
- package/src/kit/field-mark.ts +1 -7
- package/src/kit/field.ts +10 -26
- package/src/kit/follow.ts +5 -13
- package/src/kit/furniture.ts +7 -4
- package/src/kit/geometry.ts +4 -0
- package/src/kit/mark.ts +4 -11
- package/src/kit/place.ts +3 -5
- package/src/kit/sampler.ts +0 -6
- package/src/kit/system.ts +3 -12
- package/src/marks/curve-area.ts +3 -16
- package/src/marks/drop-lines.ts +0 -6
- package/src/marks/plot-point.ts +2 -12
- package/src/marks/riemann-sum.ts +2 -10
- package/src/marks/tangent-line.ts +1 -13
- package/src/marks/vector-arrow.ts +3 -13
- package/src/nodes.ts +1 -12
- package/src/plots/function-plot.ts +1 -6
- package/src/plots/points-plot.ts +0 -7
- package/src/plots/stream-lines.ts +1 -8
- package/src/plots/traced-path.ts +2 -13
- package/src/plots/vector-field.ts +4 -12
- package/src/structures/network-graph.ts +6 -25
- package/src/structures/sample-space.ts +5 -20
- package/src/systems/axes2d.ts +3 -6
- package/src/systems/number-line.ts +4 -20
- package/src/systems/number-plane.ts +4 -19
- package/src/systems/polar-plane.ts +11 -25
- package/src/tex/geometry.ts +24 -126
- package/src/tex/mathjax.ts +4 -26
- package/src/tex/matrix.ts +1 -11
- package/src/tex/tween.ts +21 -75
- package/src/tex/typeset.ts +4 -37
- package/src/three/axes3d.ts +7 -42
- package/src/three/curve-plot3d.ts +0 -12
- package/src/three/plot-point3d.ts +0 -10
- package/src/three/space.ts +2 -11
- package/src/three/surface-plot3d.ts +0 -15
- package/src/three/vector-arrow3d.ts +0 -8
- package/dist/browser/chunks/chunk-IRZCG6PM.js +0 -2
- package/dist/browser/chunks/chunk-IRZCG6PM.js.map +0 -7
- package/dist/browser/chunks/chunk-WMVW6ZIV.js +0 -2
- package/dist/browser/chunks/chunk-WMVW6ZIV.js.map +0 -7
- package/dist/kit/withdrawn.d.ts +0 -9
- package/dist/kit/withdrawn.d.ts.map +0 -1
- package/dist/kit/withdrawn.js +0 -9
- package/dist/kit/withdrawn.js.map +0 -1
- package/src/kit/withdrawn.ts +0 -8
package/dist/kit/mark.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mark.js","sourceRoot":"","sources":["../../src/kit/mark.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,GAUb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAsB,MAAM,UAAU,CAAC;AACzD,OAAO,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G,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,WAAW,CAAC,CAAY;IACpC,IAAK,CAAC,CAAC,MAAoB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACvD,OAAO,CAAE,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAA4B,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACnG,CAAC","sourcesContent":["import {\n Graphics2D,\n type ChildView,\n type Extents,\n type Fill,\n type RenderContext,\n type Shadow,\n type Size2D,\n type Stroke,\n type StrokeResolved,\n type Vector2,\n} from \"@motionscript/sdk\";\nimport { painted } from \"./component\";\nimport { PIXEL_MAP, type CoordinateMap } from \"./coords\";\nimport { boundsOfRuns, runsToPath } from \"./geometry\";\nimport type { GraphPlane } from \"./graph\";\n\n/**\n * A mark is a node drawn in graph coordinates: a plot, an area, an arrow\n * between two graph points. It answers with runs of pixel points and is\n * otherwise a shape, so its box is the tight box of its ink.\n *\n * Inside a coordinate system (or a plot) the holder lays it out on that ink,\n * calling the mark's own trace with its map, and the mark's `x`/`y` are a shift\n * in graph units. Outside one a graph unit is a pixel and `x`/`y` are the usual\n * offset.\n */\n\n/** What a mark is traced through: the map, its own `x`/`y` as a shift, and the plane it reads curves from. */\nexport interface MarkReading {\n readonly map: CoordinateMap;\n /** Zero outside a system, where `x`/`y` are pixels. */\n readonly shift: Vector2;\n readonly plane: GraphPlane | null;\n}\n\n/** The runs a mark draws, in pixels, y-up from the system's centre. */\nexport type Tracer<V> = (state: V, read: MarkReading) => Vector2[][];\n\n/** What every mark's state reads: its place, and the plane it is laid out on. */\nexport interface MarkState {\n readonly x: number;\n readonly y: number;\n readonly graph: GraphPlane | null;\n}\n\nconst NO_SHIFT: Vector2 = { x: 0, y: 0 };\n\nconst tracers: { readonly is: (child: ChildView) => boolean; readonly trace: Tracer<never> }[] = [];\n\n/** `component`, declared a mark: a holder lays it out on the ink `trace` draws. Hand back the component. */\nexport function traced<C extends { is(child: ChildView): boolean }>(component: C, trace: Tracer<never>): C {\n tracers.push({ is: (child) => component.is(child), trace });\n return component;\n}\n\n/** The runs `child` draws on `plane`, or `undefined` for a child that is no mark. */\nexport function markRuns(child: ChildView, map: CoordinateMap, plane: GraphPlane): Vector2[][] | undefined {\n const mark = tracers.find((entry) => entry.is(child));\n if (!mark) return undefined;\n const state = child.state as unknown as MarkState;\n return (mark.trace as Tracer<MarkState>)(state, { map, shift: { x: state.x, y: state.y }, plane });\n}\n\n/** How a mark's own fields read it: through its plane's map when one lays it out, through pixels when none does. */\nexport function reading(state: MarkState): MarkReading {\n const plane = state.graph;\n return plane ? { map: plane.map, shift: { x: state.x, y: state.y }, plane } : { map: PIXEL_MAP, shift: NO_SHIFT, plane: null };\n}\n\n/** The size of a mark's ink: its box when a node other than a system lays it out. */\nexport function inkSize(runs: readonly (readonly Vector2[])[]): Size2D {\n const ink = boundsOfRuns(runs);\n return ink ? { width: ink.maxX - ink.minX, height: ink.maxY - ink.minY } : { width: 0, height: 0 };\n}\n\n/** The centre of `runs`' ink in the map's pixels: where a mark's children are placed from. */\nexport function inkCentre(runs: readonly (readonly Vector2[])[]): Vector2 {\n const ink = boundsOfRuns(runs);\n return ink ? { x: (ink.minX + ink.maxX) / 2, y: (ink.minY + ink.maxY) / 2 } : NO_SHIFT;\n}\n\n/** A graph point in a mark's own frame, where a handle on it sits. */\nexport function ownPoint(read: MarkReading, runs: readonly (readonly Vector2[])[], point: Vector2): Vector2 {\n const at = read.map.toPoint(point.x + read.shift.x, point.y + read.shift.y);\n const centre = inkCentre(runs);\n return { x: at.x - centre.x, y: at.y - centre.y };\n}\n\n/** The graph point at `at` in a mark's own frame: {@link ownPoint} undone. */\nexport function graphPoint(read: MarkReading, runs: readonly (readonly Vector2[])[], at: Vector2): Vector2 {\n const centre = inkCentre(runs);\n const point = read.map.toCoords(at.x + centre.x, at.y + centre.y);\n return { x: point.x - read.shift.x, y: point.y - read.shift.y };\n}\n\n/** What a mark paints with: a shape's paints, any it withdrew left out. */\nexport interface MarkPaint {\n readonly fill?: Fill;\n readonly stroke?: Stroke;\n readonly shadow: Shadow;\n readonly start?: number;\n readonly end?: number;\n}\n\nexport interface MarkOptions {\n /** Whether each run is closed into an outline. */\n readonly closed?: boolean;\n /** Whether the fill is painted: a mark whose ink has no inside yet (an open line) says no. */\n readonly fills?: boolean;\n /** The stroke along the ink, when it is not the plain one. */\n readonly ink?: (ctx: RenderContext, ink: Extents) => void;\n}\n\nconst NONE: never[] = [];\n\n/** One mark's outline, the same commands for each paint. */\nexport function markShape(runs: readonly (readonly Vector2[])[], s: MarkPaint, closed = false): (() => Graphics2D) | null {\n const ink = boundsOfRuns(runs);\n const data = runsToPath(runs, closed);\n if (!ink || data.length === 0) return null;\n const centerBounds: [number, number, number, number] = [ink.minX, ink.minY, ink.maxX, ink.maxY];\n return () => new Graphics2D().path({ data, centerBounds, start: s.start ?? 0, end: s.end ?? 1 });\n}\n\n/**\n * A mark's paint: the fill under the stroke along its ink, both before its\n * children, so a point or a tangent riding a plot sits on the curve.\n */\nexport function drawMark(ctx: RenderContext, s: MarkPaint, runs: readonly (readonly Vector2[])[], options: MarkOptions = {}): void {\n const shape = markShape(runs, s, options.closed);\n const fill = s.fill ?? NONE;\n painted(ctx, () => {\n if (shape && options.fills !== false) ctx.draw(shape().shadow(s.shadow).fill(fill));\n const ink = options.ink ? boundsOfRuns(runs) : null;\n if (ink && options.ink) options.ink(ctx, ink);\n else if (shape) strokeShape(ctx, shape, s);\n });\n}\n\n/** The stroke along a shape, casting the shadow when nothing fills it. */\nexport function strokeShape(ctx: RenderContext, shape: () => Graphics2D, s: MarkPaint): void {\n const stroke = (s.stroke ?? NONE) as StrokeResolved[];\n if (stroke.length === 0) return;\n ctx.draw(castsShadow(s) ? shape().shadow(s.shadow).stroke(stroke) : shape().stroke(stroke));\n}\n\n/** A shadow is cast by the stroke when nothing visible fills the shape. */\nexport function castsShadow(s: MarkPaint): boolean {\n if ((s.shadow as unknown[]).length === 0) return false;\n return !((s.fill ?? NONE) as { opacity?: number }[]).some((layer) => (layer.opacity ?? 1) > 0);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mark.js","sourceRoot":"","sources":["../../src/kit/mark.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,GAUb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAsB,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAyBtD,MAAM,QAAQ,GAAY,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAEzC,MAAM,OAAO,GAAoF,EAAE,CAAC;AAEpG,4GAA4G;AAC5G,MAAM,UAAU,MAAM,CAA8C,SAAY,EAAE,KAAoB;IAClG,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5D,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,QAAQ,CAAC,KAAgB,EAAE,GAAkB,EAAE,KAAiB;IAC5E,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACtD,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,MAAM,KAAK,GAAG,KAAK,CAAC,KAA6B,CAAC;IAClD,OAAQ,IAAI,CAAC,KAA2B,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,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E,KAAuB,EAAE,CAAY;IACjF,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,CAAqB,CAAC;IACtD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAChC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAChG,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,WAAW,CAAC,CAAY;IACpC,IAAK,CAAC,CAAC,MAAoB,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACvD,OAAO,CAAE,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,CAA4B,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACnG,CAAC","sourcesContent":["import {\n Graphics2D,\n type ChildView,\n type Extents,\n type Fill,\n type RenderContext,\n type Shadow,\n type Size2D,\n type Stroke,\n type StrokeResolved,\n type Vector2,\n} from \"@motionscript/sdk\";\nimport { painted } from \"./component\";\nimport { PIXEL_MAP, type CoordinateMap } from \"./coords\";\nimport { boundsOfRuns, runsToPath } from \"./geometry\";\nimport type { GraphPlane } from \"./graph\";\n\n/**\n * What a mark is traced through: the map, its own `x`/`y` as a shift, and the\n * plane it reads curves from. A mark is a shape whose box is the tight box of its\n * ink; outside a system a graph unit is a pixel and `x`/`y` the usual offset.\n */\nexport interface MarkReading {\n readonly map: CoordinateMap;\n /** Zero outside a system, where `x`/`y` are pixels. */\n readonly shift: Vector2;\n readonly plane: GraphPlane | null;\n}\n\n/** The runs a mark draws, in pixels, y-up from the system's centre. */\nexport type Tracer<V> = (state: V, read: MarkReading) => Vector2[][];\n\n/** What every mark's state reads: its place, and the plane it is laid out on. */\nexport interface MarkState {\n readonly x: number;\n readonly y: number;\n readonly graph: GraphPlane | null;\n}\n\nconst NO_SHIFT: Vector2 = { x: 0, y: 0 };\n\nconst tracers: { readonly is: (child: ChildView) => boolean; readonly trace: Tracer<never> }[] = [];\n\n/** `component`, declared a mark: a holder lays it out on the ink `trace` draws. Hand back the component. */\nexport function traced<C extends { is(child: ChildView): boolean }>(component: C, trace: Tracer<never>): C {\n tracers.push({ is: (child) => component.is(child), trace });\n return component;\n}\n\n/** The runs `child` draws on `plane`, or `undefined` for a child that is no mark. */\nexport function markRuns(child: ChildView, map: CoordinateMap, plane: GraphPlane): Vector2[][] | undefined {\n const mark = tracers.find((entry) => entry.is(child));\n if (!mark) return undefined;\n const state = child.state as unknown as MarkState;\n return (mark.trace as Tracer<MarkState>)(state, { map, shift: { x: state.x, y: state.y }, plane });\n}\n\n/** How a mark's own fields read it: through its plane's map when one lays it out, through pixels when none does. */\nexport function reading(state: MarkState): MarkReading {\n const plane = state.graph;\n return plane ? { map: plane.map, shift: { x: state.x, y: state.y }, plane } : { map: PIXEL_MAP, shift: NO_SHIFT, plane: null };\n}\n\n/** The size of a mark's ink: its box when a node other than a system lays it out. */\nexport function inkSize(runs: readonly (readonly Vector2[])[]): Size2D {\n const ink = boundsOfRuns(runs);\n return ink ? { width: ink.maxX - ink.minX, height: ink.maxY - ink.minY } : { width: 0, height: 0 };\n}\n\n/** The centre of `runs`' ink in the map's pixels: where a mark's children are placed from. */\nexport function inkCentre(runs: readonly (readonly Vector2[])[]): Vector2 {\n const ink = boundsOfRuns(runs);\n return ink ? { x: (ink.minX + ink.maxX) / 2, y: (ink.minY + ink.maxY) / 2 } : NO_SHIFT;\n}\n\n/** A graph point in a mark's own frame, where a handle on it sits. */\nexport function ownPoint(read: MarkReading, runs: readonly (readonly Vector2[])[], point: Vector2): Vector2 {\n const at = read.map.toPoint(point.x + read.shift.x, point.y + read.shift.y);\n const centre = inkCentre(runs);\n return { x: at.x - centre.x, y: at.y - centre.y };\n}\n\n/** The graph point at `at` in a mark's own frame: {@link ownPoint} undone. */\nexport function graphPoint(read: MarkReading, runs: readonly (readonly Vector2[])[], at: Vector2): Vector2 {\n const centre = inkCentre(runs);\n const point = read.map.toCoords(at.x + centre.x, at.y + centre.y);\n return { x: point.x - read.shift.x, y: point.y - read.shift.y };\n}\n\n/** What a mark paints with. */\nexport interface MarkPaint {\n readonly fill?: Fill;\n readonly stroke?: Stroke;\n readonly shadow: Shadow;\n readonly start?: number;\n readonly end?: number;\n}\n\nexport interface MarkOptions {\n /** Whether each run is closed into an outline. */\n readonly closed?: boolean;\n /** Whether the fill is painted: a mark whose ink has no inside yet (an open line) says no. */\n readonly fills?: boolean;\n /** The stroke along the ink, when it is not the plain one. */\n readonly ink?: (ctx: RenderContext, ink: Extents) => void;\n}\n\nconst NONE: never[] = [];\n\n/** One mark's outline, the same commands for each paint. */\nexport function markShape(runs: readonly (readonly Vector2[])[], s: MarkPaint, closed = false): (() => Graphics2D) | null {\n const ink = boundsOfRuns(runs);\n const data = runsToPath(runs, closed);\n if (!ink || data.length === 0) return null;\n const centerBounds: [number, number, number, number] = [ink.minX, ink.minY, ink.maxX, ink.maxY];\n return () => new Graphics2D().path({ data, centerBounds, start: s.start ?? 0, end: s.end ?? 1 });\n}\n\n/**\n * A mark's paint: the fill under the stroke along its ink, both before its\n * children, so a point or a tangent riding a plot sits on the curve.\n */\nexport function drawMark(ctx: RenderContext, s: MarkPaint, runs: readonly (readonly Vector2[])[], options: MarkOptions = {}): void {\n const shape = markShape(runs, s, options.closed);\n const fill = s.fill ?? NONE;\n painted(ctx, () => {\n if (shape && options.fills !== false) ctx.draw(shape().shadow(s.shadow).fill(fill));\n const ink = options.ink ? boundsOfRuns(runs) : null;\n if (ink && options.ink) options.ink(ctx, ink);\n else if (shape) strokeShape(ctx, shape, s);\n });\n}\n\n/** The stroke along a shape, casting the shadow when nothing fills it. */\nexport function strokeShape(ctx: RenderContext, shape: () => Graphics2D, s: MarkPaint): void {\n const stroke = (s.stroke ?? NONE) as StrokeResolved[];\n if (stroke.length === 0) return;\n ctx.draw(castsShadow(s) ? shape().shadow(s.shadow).stroke(stroke) : shape().stroke(stroke));\n}\n\n/** A shadow is cast by the stroke when nothing visible fills the shape. */\nexport function castsShadow(s: MarkPaint): boolean {\n if ((s.shadow as unknown[]).length === 0) return false;\n return !((s.fill ?? NONE) as { opacity?: number }[]).some((layer) => (layer.opacity ?? 1) > 0);\n}\n"]}
|
package/dist/kit/place.d.ts
CHANGED
|
@@ -8,11 +8,9 @@ export declare function anchored<C extends {
|
|
|
8
8
|
is(child: ChildView): boolean;
|
|
9
9
|
}>(component: C, anchor: (state: never, plane: GraphPlane) => Anchor | null): C;
|
|
10
10
|
/**
|
|
11
|
-
* Lay `children` out on `map
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* coordinates. `origin` is the holder's own centre in the map's pixels (y-up),
|
|
15
|
-
* since a child's box is placed from there.
|
|
11
|
+
* Lay `children` out on `map` for a system or a plot: a mark goes on its ink,
|
|
12
|
+
* anything else keeps its size and reads `x`/`y` as graph coordinates.
|
|
13
|
+
* `origin` is the holder's centre in the map's pixels (y-up).
|
|
16
14
|
*/
|
|
17
15
|
export declare function placeOnMap(children: readonly ChildView[], map: CoordinateMap, origin: Vector2, room: Size2D, plane: GraphPlane): Placement2D[];
|
|
18
16
|
/** The plane of a child that is not there yet, under a holder centred on `origin`: where a host would drop one. */
|
package/dist/kit/place.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place.d.ts","sourceRoot":"","sources":["../../src/kit/place.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CA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AK,EAAE,UAAU,GAAG,WAAW,EAAE,CAqB9I;AAED,mHAAmH;AACnH,wBAAgB,SAAS,CAAC,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,GAAG,UAAU,CAQzE"}
|
package/dist/kit/place.js
CHANGED
|
@@ -7,11 +7,9 @@ export function anchored(component, anchor) {
|
|
|
7
7
|
return component;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Lay `children` out on `map
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* coordinates. `origin` is the holder's own centre in the map's pixels (y-up),
|
|
14
|
-
* since a child's box is placed from there.
|
|
10
|
+
* Lay `children` out on `map` for a system or a plot: a mark goes on its ink,
|
|
11
|
+
* anything else keeps its size and reads `x`/`y` as graph coordinates.
|
|
12
|
+
* `origin` is the holder's centre in the map's pixels (y-up).
|
|
15
13
|
*/
|
|
16
14
|
export function placeOnMap(children, map, origin, room, plane) {
|
|
17
15
|
return children.map((child) => {
|
package/dist/kit/place.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place.js","sourceRoot":"","sources":["../../src/kit/place.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAKlC,MAAM,OAAO,GAA0H,EAAE,CAAC;AAE1I,uGAAuG;AACvG,MAAM,UAAU,QAAQ,CAA8C,SAAY,EAAE,MAA0D;IAC1I,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7D,OAAO,SAAS,CAAC;AACrB,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"place.js","sourceRoot":"","sources":["../../src/kit/place.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,YAA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CoordinateMap } from \"./coords\";\nimport { boundsOfRuns } from \"./geometry\";\nimport type { GraphPlane } from \"./graph\";\nimport { markRuns } from \"./mark\";\n\n/** Where a child that sits somewhere other than its own `x`/`y` is (a point riding a curve), given its own `x`/`y`. */\nexport type Anchor = (x: number, y: number) => Vector2;\n\nconst anchors: { readonly is: (child: ChildView) => boolean; readonly anchor: (state: never, plane: GraphPlane) => Anchor | null }[] = [];\n\n/** `component`, declared to sit at `anchor` of its own `x`/`y` on a graph. Hand back the component. */\nexport function anchored<C extends { is(child: ChildView): boolean }>(component: C, anchor: (state: never, plane: GraphPlane) => Anchor | null): C {\n anchors.push({ is: (child) => component.is(child), anchor });\n return component;\n}\n\n/**\n * Lay `children` out on `map` for a system or a plot: a mark goes on its ink,\n * anything else keeps its size and reads `x`/`y` as graph coordinates.\n * `origin` is the holder's centre in the map's pixels (y-up).\n */\nexport function placeOnMap(children: readonly ChildView[], map: CoordinateMap, origin: Vector2, room: Size2D, plane: GraphPlane): Placement2D[] {\n return children.map((child) => {\n const runs = markRuns(child, map, plane);\n if (runs) {\n const ink = boundsOfRuns(runs);\n const cx = ink ? (ink.minX + ink.maxX) / 2 : origin.x;\n const cy = ink ? (ink.minY + ink.maxY) / 2 : origin.y;\n return {\n x: cx - origin.x,\n y: cy - origin.y,\n width: ink ? ink.maxX - ink.minX : 0,\n height: ink ? ink.maxY - ink.minY : 0,\n plane: markPlane(map, cx, cy),\n };\n }\n const size = child.measure({ width: room.width, height: room.height });\n const entry = anchors.find((a) => a.is(child));\n const anchor = entry ? (entry.anchor as (state: unknown, plane: GraphPlane) => Anchor | null)(child.state, plane) : null;\n // Its box is centred on the map's own centre, so its offset from there is its point.\n return { x: -origin.x, y: -origin.y, width: size.width, height: size.height, plane: pointPlane(map, anchor) };\n });\n}\n\n/** The plane of a child that is not there yet, under a holder centred on `origin`: where a host would drop one. */\nexport function openPlane(map: CoordinateMap, origin: Vector2): ChildPlane {\n return {\n toOffset: (x, y) => {\n const at = map.toPoint(x, y);\n return { x: at.x - origin.x, y: at.y - origin.y };\n },\n toCoords: (x, y) => map.toCoords(x + origin.x, y + origin.y),\n };\n}\n\nfunction pointPlane(map: CoordinateMap, anchor: Anchor | null): ChildPlane {\n const point: Vector2 = { x: 0, y: 0 };\n return {\n toOffset: (x, y) => {\n const at = anchor?.(x, y);\n return at ? map.toPoint(at.x, at.y, point) : map.toPoint(x, y, point);\n },\n toCoords: (x, y) => map.toCoords(x, y),\n };\n}\n\n// A mark reads its own `x`/`y` as it draws, so its holder adds nothing; a drag still answers in graph units.\nfunction markPlane(map: CoordinateMap, cx: number, cy: number): ChildPlane {\n const none: Vector2 = { x: 0, y: 0 };\n return {\n toOffset: () => none,\n toCoords: (x, y) => map.toCoords(cx + x, cy + y),\n };\n}\n"]}
|
package/dist/kit/sampler.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import type { Extents, Vector2 } from "@motionscript/sdk";
|
|
2
|
-
/**
|
|
3
|
-
* Turns a curve into the polylines that draw it: adaptively, so a straight
|
|
4
|
-
* stretch costs two points and a tight bend as many as it needs, and broken
|
|
5
|
-
* wherever the curve is, at an asymptote or the edge of its domain.
|
|
6
|
-
*/
|
|
7
2
|
/** A curve's parameter to its pixel, written into `out`. `false` where the curve is undefined. */
|
|
8
3
|
export type CurveProjection = (t: number, out: Vector2) => boolean;
|
|
9
4
|
export interface SampleOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sampler.d.ts","sourceRoot":"","sources":["../../src/kit/sampler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE1D
|
|
1
|
+
{"version":3,"file":"sampler.d.ts","sourceRoot":"","sources":["../../src/kit/sampler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE1D,kGAAkG;AAClG,MAAM,MAAM,eA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YACxB,IAAI,CAAC,GAAG,EAAE;gBAAE,EAAE,GAAG,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,GAAG,EAAE;gBAAE,OAAO,IAAI,CAAC;YACxB,IAAI,CAAC,GAAG,EAAE;gBAAE,EAAE,GAAG,CAAC,CAAC;QACvB,CAAC;IACL,CAAC;IACD,OAAO;QACH,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACpC,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;KACvC,CAAC;AACN,CAAC","sourcesContent":["import type { Extents, Vector2 } from \"@motionscript/sdk\";\n\n/**\n * Turns a curve into the polylines that draw it: adaptively, so a straight\n * stretch costs two points and a tight bend as many as it needs, and broken\n * wherever the curve is, at an asymptote or the edge of its domain.\n */\n\n/** A curve's parameter to its pixel, written into `out`. `false` where the curve is undefined. */\nexport type CurveProjection = (t: number, out: Vector2) => boolean;\n\nexport interface SampleOptions {\n /** The equal steps the parameter range starts as, before any is split. */\n seeds?: number;\n /** A parameter step that is not split again, however bent. */\n minStep?: number;\n}\n\n/** Path coordinates are 32-bit floats in the renderer; past this a clamped point still clips to the same edge. */\nconst COORD_LIMIT = 16_000;\n/** How far, in pixels, the drawn chord may stray from the curve. */\nconst TOLERANCE_PX = 0.25;\n/** A turn, in radians, a chord is allowed to hide: what keeps a symmetric bump from reading as flat. */\nconst ANGLE_TOLERANCE = 0.05;\nconst MAX_DEPTH = 12;\nconst MAX_EVALUATIONS = 40_000;\nconst MAX_POINTS = 24_000;\n/** Bisections spent finding where a domain ends. */\nconst BOUNDARY_STEPS = 60;\nconst DEFAULT_SEEDS = 256;\n\ninterface Sample {\n t: number;\n px: number;\n py: number;\n /** The pixel before clamping: what tells an asymptote from a steep line. */\n rx: number;\n ry: number;\n ok: boolean;\n}\n\n// Midpoints are pooled: a refine is a depth-first walk, so a slot is free again\n// as soon as the seed interval it was taken for is done.\nconst arena: Sample[] = [];\nlet arenaMark = 0;\n\nfunction takeSample(): Sample {\n let slot = arena[arenaMark];\n if (slot === undefined) {\n slot = blank();\n arena.push(slot);\n }\n arenaMark++;\n return slot;\n}\n\nfunction blank(): Sample {\n return { t: 0, px: 0, py: 0, rx: 0, ry: 0, ok: false };\n}\n\nconst scratch: Vector2 = { x: 0, y: 0 };\n\n/** The runs of points that draw `project` over `[t0, t1]`, clipped to `clip`. */\nexport function sampleCurve(\n project: CurveProjection,\n t0: number,\n t1: number,\n clip: Extents,\n { seeds = DEFAULT_SEEDS, minStep = 0 }: SampleOptions = {},\n): Vector2[][] {\n if (!(t1 > t0) || !Number.isFinite(t0) || !Number.isFinite(t1)) return [];\n const pen = new CurvePen(clip);\n let spent = 0;\n\n const write = (slot: Sample, t: number): Sample => {\n const defined = project(t, scratch);\n spent++;\n const ok = defined && Number.isFinite(scratch.x) && Number.isFinite(scratch.y);\n slot.t = t;\n slot.rx = ok ? scratch.x : 0;\n slot.ry = ok ? scratch.y : 0;\n slot.px = clampCoord(slot.rx);\n slot.py = clampCoord(slot.ry);\n slot.ok = ok;\n return slot;\n };\n const at = (t: number): Sample => write(takeSample(), t);\n\n // The last defined point before `to`, which is not: where `sqrt(x)` meets its axis.\n const edgeOf = (from: Sample, to: Sample): Sample => {\n let inside = from;\n let outsideT = to.t;\n for (let i = 0; i < BOUNDARY_STEPS; i++) {\n if (spent >= MAX_EVALUATIONS || offFrame(inside, clip)) break;\n const midT = (inside.t + outsideT) / 2;\n if (midT === inside.t || midT === outsideT) break;\n const mid = at(midT);\n if (!mid.ok) {\n outsideT = midT;\n continue;\n }\n const settled = Math.abs(mid.px - inside.px) < TOLERANCE_PX && Math.abs(mid.py - inside.py) < TOLERANCE_PX;\n inside = mid;\n if (settled) break;\n }\n return inside;\n };\n\n const emit = (a: Sample, m: Sample | null, b: Sample, floored: boolean): void => {\n if (a.ok && b.ok) {\n if (floored && diverges(a, m, b, clip)) pen.break();\n else pen.draw(a, b);\n return;\n }\n if (a.ok) {\n const edge = edgeOf(a, b);\n if (edge.t !== a.t) pen.draw(a, edge);\n pen.break();\n return;\n }\n pen.break();\n if (b.ok) {\n const edge = edgeOf(b, a);\n if (edge.t !== b.t) pen.draw(edge, b);\n else pen.start(b);\n }\n };\n\n const refine = (a: Sample, b: Sample, depth: number): void => {\n if (spent >= MAX_EVALUATIONS || pen.points >= MAX_POINTS) {\n emit(a, null, b, false);\n return;\n }\n const m = at((a.t + b.t) / 2);\n const floored = depth >= MAX_DEPTH || b.t - a.t <= minStep;\n if (floored || flat(a, m, b)) {\n emit(a, m, b, floored);\n return;\n }\n refine(a, m, depth + 1);\n refine(m, b, depth + 1);\n };\n\n const count = Math.max(1, Math.round(seeds));\n const step = (t1 - t0) / count;\n const ends: [Sample, Sample] = [blank(), blank()];\n let previous = write(ends[0], t0);\n for (let i = 1; i <= count; i++) {\n const next = write(ends[i & 1], i === count ? t1 : t0 + i * step);\n arenaMark = 0;\n refine(previous, next, 0);\n previous = next;\n }\n arenaMark = 0;\n return pen.finish();\n}\n\nfunction flat(a: Sample, m: Sample, b: Sample): boolean {\n if (a.ok !== m.ok || m.ok !== b.ok) return false;\n if (!a.ok) return true;\n const dx = b.px - a.px;\n const dy = b.py - a.py;\n const length = Math.hypot(dx, dy) || 1;\n if (Math.abs((m.px - a.px) * dy - (m.py - a.py) * dx) / length > TOLERANCE_PX) return false;\n let turn = Math.abs(Math.atan2(m.py - a.py, m.px - a.px) - Math.atan2(b.py - m.py, b.px - m.px));\n if (turn > Math.PI) turn = 2 * Math.PI - turn;\n return turn < ANGLE_TOLERANCE;\n}\n\n// Two neighbours on opposite sides of the frame, with nothing between them that\n// is between them: an asymptote, not a steep line.\nfunction diverges(a: Sample, m: Sample | null, b: Sample, clip: Extents): boolean {\n const straddles =\n (a.py > clip.maxY && b.py < clip.minY) || (a.py < clip.minY && b.py > clip.maxY) ||\n (a.px > clip.maxX && b.px < clip.minX) || (a.px < clip.minX && b.px > clip.maxX);\n if (!straddles || m === null) return false;\n if (!m.ok) return true;\n return (\n m.ry < Math.min(a.ry, b.ry) || m.ry > Math.max(a.ry, b.ry) ||\n m.rx < Math.min(a.rx, b.rx) || m.rx > Math.max(a.rx, b.rx)\n );\n}\n\nfunction offFrame(sample: Sample, clip: Extents): boolean {\n return sample.py > clip.maxY || sample.py < clip.minY || sample.px > clip.maxX || sample.px < clip.minX;\n}\n\nfunction clampCoord(value: number): number {\n if (value > COORD_LIMIT) return COORD_LIMIT;\n if (value < -COORD_LIMIT) return -COORD_LIMIT;\n return value;\n}\n\nclass CurvePen {\n points = 0;\n private readonly runs: Vector2[][] = [];\n private open: Vector2[] = [];\n private cursor: Vector2 | null = null;\n\n constructor(private readonly clip: Extents) {}\n\n draw(a: Sample, b: Sample): void {\n const segment = clipSegment(a.px, a.py, b.px, b.py, this.clip);\n if (!segment) {\n this.break();\n return;\n }\n const [start, end] = segment;\n if (this.cursor && samePoint(this.cursor, start)) {\n this.push(end);\n } else {\n this.break();\n this.push(start);\n this.push(end);\n }\n this.cursor = end;\n }\n\n start(b: Sample): void {\n this.break();\n if (!inside(b.px, b.py, this.clip)) return;\n this.cursor = { x: b.px, y: b.py };\n this.push(this.cursor);\n }\n\n break(): void {\n if (this.open.length >= 2) this.runs.push(this.open);\n this.open = [];\n this.cursor = null;\n }\n\n finish(): Vector2[][] {\n this.break();\n return this.runs;\n }\n\n private push(point: Vector2): void {\n this.open.push(point);\n this.points++;\n }\n}\n\nfunction samePoint(a: Vector2, b: Vector2): boolean {\n return Math.abs(a.x - b.x) < 0.1 && Math.abs(a.y - b.y) < 0.1;\n}\n\nfunction inside(x: number, y: number, clip: Extents): boolean {\n return x >= clip.minX && x <= clip.maxX && y >= clip.minY && y <= clip.maxY;\n}\n\n// Liang–Barsky: the part of a segment inside the clip, or null when none is.\nfunction clipSegment(ax: number, ay: number, bx: number, by: number, clip: Extents): [Vector2, Vector2] | null {\n const dx = bx - ax;\n const dy = by - ay;\n let t0 = 0;\n let t1 = 1;\n const edges: [number, number][] = [\n [-dx, ax - clip.minX],\n [dx, clip.maxX - ax],\n [-dy, ay - clip.minY],\n [dy, clip.maxY - ay],\n ];\n for (const [p, q] of edges) {\n if (p === 0) {\n if (q < 0) return null;\n continue;\n }\n const r = q / p;\n if (p < 0) {\n if (r > t1) return null;\n if (r > t0) t0 = r;\n } else {\n if (r < t0) return null;\n if (r < t1) t1 = r;\n }\n }\n return [\n { x: ax + t0 * dx, y: ay + t0 * dy },\n { x: ax + t1 * dx, y: ay + t1 * dy },\n ];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sampler.js","sourceRoot":"","sources":["../../src/kit/sampler.ts"],"names":[],"mappings":"AAYA,kHAAkH;AAClH,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,oEAAoE;AACpE,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,wGAAwG;AACxG,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,UAAU,GAAG,MAAM,CAAC;AAC1B,oDAAoD;AACpD,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,aAAa,GAAG,GAAG,CAAC;AAY1B,gFAAgF;AAChF,yDAAyD;AACzD,MAAM,KAAK,GAAa,EAAE,CAAC;AAC3B,IAAI,SAAS,GAAG,CAAC,CAAC;AAElB,SAAS,UAAU;IACf,IAAI,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IAC5B,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACrB,IAAI,GAAG,KAAK,EAAE,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IACD,SAAS,EAAE,CAAC;IACZ,OAAO,IAAI,CAAC;AAChB,CAAC;AAED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CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,GAAG,EAAE;gBAAE,OAAO,IAAI,CAAC;YACxB,IAAI,CAAC,GAAG,EAAE;gBAAE,EAAE,GAAG,CAAC,CAAC;QACvB,CAAC;IACL,CAAC;IACD,OAAO;QACH,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACpC,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;KACvC,CAAC;AACN,CAAC","sourcesContent":["import type { Extents, Vector2 } from \"@motionscript/sdk\";\n\n/** A curve's parameter to its pixel, written into `out`. `false` where the curve is undefined. */\nexport type CurveProjection = (t: number, out: Vector2) => boolean;\n\nexport interface SampleOptions {\n /** The equal steps the parameter range starts as, before any is split. */\n seeds?: number;\n /** A parameter step that is not split again, however bent. */\n minStep?: number;\n}\n\n/** Path coordinates are 32-bit floats in the renderer; past this a clamped point still clips to the same edge. */\nconst COORD_LIMIT = 16_000;\n/** How far, in pixels, the drawn chord may stray from the curve. */\nconst TOLERANCE_PX = 0.25;\n/** A turn, in radians, a chord is allowed to hide: what keeps a symmetric bump from reading as flat. */\nconst ANGLE_TOLERANCE = 0.05;\nconst MAX_DEPTH = 12;\nconst MAX_EVALUATIONS = 40_000;\nconst MAX_POINTS = 24_000;\n/** Bisections spent finding where a domain ends. */\nconst BOUNDARY_STEPS = 60;\nconst DEFAULT_SEEDS = 256;\n\ninterface Sample {\n t: number;\n px: number;\n py: number;\n /** The pixel before clamping: what tells an asymptote from a steep line. */\n rx: number;\n ry: number;\n ok: boolean;\n}\n\n// Midpoints are pooled: a refine is a depth-first walk, so a slot is free again\n// as soon as the seed interval it was taken for is done.\nconst arena: Sample[] = [];\nlet arenaMark = 0;\n\nfunction takeSample(): Sample {\n let slot = arena[arenaMark];\n if (slot === undefined) {\n slot = blank();\n arena.push(slot);\n }\n arenaMark++;\n return slot;\n}\n\nfunction blank(): Sample {\n return { t: 0, px: 0, py: 0, rx: 0, ry: 0, ok: false };\n}\n\nconst scratch: Vector2 = { x: 0, y: 0 };\n\n/** The runs of points that draw `project` over `[t0, t1]`, clipped to `clip`. */\nexport function sampleCurve(\n project: CurveProjection,\n t0: number,\n t1: number,\n clip: Extents,\n { seeds = DEFAULT_SEEDS, minStep = 0 }: SampleOptions = {},\n): Vector2[][] {\n if (!(t1 > t0) || !Number.isFinite(t0) || !Number.isFinite(t1)) return [];\n const pen = new CurvePen(clip);\n let spent = 0;\n\n const write = (slot: Sample, t: number): Sample => {\n const defined = project(t, scratch);\n spent++;\n const ok = defined && Number.isFinite(scratch.x) && Number.isFinite(scratch.y);\n slot.t = t;\n slot.rx = ok ? scratch.x : 0;\n slot.ry = ok ? scratch.y : 0;\n slot.px = clampCoord(slot.rx);\n slot.py = clampCoord(slot.ry);\n slot.ok = ok;\n return slot;\n };\n const at = (t: number): Sample => write(takeSample(), t);\n\n // The last defined point before `to`, which is not: where `sqrt(x)` meets its axis.\n const edgeOf = (from: Sample, to: Sample): Sample => {\n let inside = from;\n let outsideT = to.t;\n for (let i = 0; i < BOUNDARY_STEPS; i++) {\n if (spent >= MAX_EVALUATIONS || offFrame(inside, clip)) break;\n const midT = (inside.t + outsideT) / 2;\n if (midT === inside.t || midT === outsideT) break;\n const mid = at(midT);\n if (!mid.ok) {\n outsideT = midT;\n continue;\n }\n const settled = Math.abs(mid.px - inside.px) < TOLERANCE_PX && Math.abs(mid.py - inside.py) < TOLERANCE_PX;\n inside = mid;\n if (settled) break;\n }\n return inside;\n };\n\n const emit = (a: Sample, m: Sample | null, b: Sample, floored: boolean): void => {\n if (a.ok && b.ok) {\n if (floored && diverges(a, m, b, clip)) pen.break();\n else pen.draw(a, b);\n return;\n }\n if (a.ok) {\n const edge = edgeOf(a, b);\n if (edge.t !== a.t) pen.draw(a, edge);\n pen.break();\n return;\n }\n pen.break();\n if (b.ok) {\n const edge = edgeOf(b, a);\n if (edge.t !== b.t) pen.draw(edge, b);\n else pen.start(b);\n }\n };\n\n const refine = (a: Sample, b: Sample, depth: number): void => {\n if (spent >= MAX_EVALUATIONS || pen.points >= MAX_POINTS) {\n emit(a, null, b, false);\n return;\n }\n const m = at((a.t + b.t) / 2);\n const floored = depth >= MAX_DEPTH || b.t - a.t <= minStep;\n if (floored || flat(a, m, b)) {\n emit(a, m, b, floored);\n return;\n }\n refine(a, m, depth + 1);\n refine(m, b, depth + 1);\n };\n\n const count = Math.max(1, Math.round(seeds));\n const step = (t1 - t0) / count;\n const ends: [Sample, Sample] = [blank(), blank()];\n let previous = write(ends[0], t0);\n for (let i = 1; i <= count; i++) {\n const next = write(ends[i & 1], i === count ? t1 : t0 + i * step);\n arenaMark = 0;\n refine(previous, next, 0);\n previous = next;\n }\n arenaMark = 0;\n return pen.finish();\n}\n\nfunction flat(a: Sample, m: Sample, b: Sample): boolean {\n if (a.ok !== m.ok || m.ok !== b.ok) return false;\n if (!a.ok) return true;\n const dx = b.px - a.px;\n const dy = b.py - a.py;\n const length = Math.hypot(dx, dy) || 1;\n if (Math.abs((m.px - a.px) * dy - (m.py - a.py) * dx) / length > TOLERANCE_PX) return false;\n let turn = Math.abs(Math.atan2(m.py - a.py, m.px - a.px) - Math.atan2(b.py - m.py, b.px - m.px));\n if (turn > Math.PI) turn = 2 * Math.PI - turn;\n return turn < ANGLE_TOLERANCE;\n}\n\n// Two neighbours on opposite sides of the frame, with nothing between them that\n// is between them: an asymptote, not a steep line.\nfunction diverges(a: Sample, m: Sample | null, b: Sample, clip: Extents): boolean {\n const straddles =\n (a.py > clip.maxY && b.py < clip.minY) || (a.py < clip.minY && b.py > clip.maxY) ||\n (a.px > clip.maxX && b.px < clip.minX) || (a.px < clip.minX && b.px > clip.maxX);\n if (!straddles || m === null) return false;\n if (!m.ok) return true;\n return (\n m.ry < Math.min(a.ry, b.ry) || m.ry > Math.max(a.ry, b.ry) ||\n m.rx < Math.min(a.rx, b.rx) || m.rx > Math.max(a.rx, b.rx)\n );\n}\n\nfunction offFrame(sample: Sample, clip: Extents): boolean {\n return sample.py > clip.maxY || sample.py < clip.minY || sample.px > clip.maxX || sample.px < clip.minX;\n}\n\nfunction clampCoord(value: number): number {\n if (value > COORD_LIMIT) return COORD_LIMIT;\n if (value < -COORD_LIMIT) return -COORD_LIMIT;\n return value;\n}\n\nclass CurvePen {\n points = 0;\n private readonly runs: Vector2[][] = [];\n private open: Vector2[] = [];\n private cursor: Vector2 | null = null;\n\n constructor(private readonly clip: Extents) {}\n\n draw(a: Sample, b: Sample): void {\n const segment = clipSegment(a.px, a.py, b.px, b.py, this.clip);\n if (!segment) {\n this.break();\n return;\n }\n const [start, end] = segment;\n if (this.cursor && samePoint(this.cursor, start)) {\n this.push(end);\n } else {\n this.break();\n this.push(start);\n this.push(end);\n }\n this.cursor = end;\n }\n\n start(b: Sample): void {\n this.break();\n if (!inside(b.px, b.py, this.clip)) return;\n this.cursor = { x: b.px, y: b.py };\n this.push(this.cursor);\n }\n\n break(): void {\n if (this.open.length >= 2) this.runs.push(this.open);\n this.open = [];\n this.cursor = null;\n }\n\n finish(): Vector2[][] {\n this.break();\n return this.runs;\n }\n\n private push(point: Vector2): void {\n this.open.push(point);\n this.points++;\n }\n}\n\nfunction samePoint(a: Vector2, b: Vector2): boolean {\n return Math.abs(a.x - b.x) < 0.1 && Math.abs(a.y - b.y) < 0.1;\n}\n\nfunction inside(x: number, y: number, clip: Extents): boolean {\n return x >= clip.minX && x <= clip.maxX && y >= clip.minY && y <= clip.maxY;\n}\n\n// Liang–Barsky: the part of a segment inside the clip, or null when none is.\nfunction clipSegment(ax: number, ay: number, bx: number, by: number, clip: Extents): [Vector2, Vector2] | null {\n const dx = bx - ax;\n const dy = by - ay;\n let t0 = 0;\n let t1 = 1;\n const edges: [number, number][] = [\n [-dx, ax - clip.minX],\n [dx, clip.maxX - ax],\n [-dy, ay - clip.minY],\n [dy, clip.maxY - ay],\n ];\n for (const [p, q] of edges) {\n if (p === 0) {\n if (q < 0) return null;\n continue;\n }\n const r = q / p;\n if (p < 0) {\n if (r > t1) return null;\n if (r > t0) t0 = r;\n } else {\n if (r < t0) return null;\n if (r < t1) t1 = r;\n }\n }\n return [\n { x: ax + t0 * dx, y: ay + t0 * dy },\n { x: ax + t1 * dx, y: ay + t1 * dy },\n ];\n}\n"]}
|
package/dist/kit/system.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Graphics2D, type ChildPlane, type ChildView, type Extents, type InsetsResolved, type Placement2D, type Provided, type RenderContext, type Shadow, type Fill, type Size2D } from "@motionscript/sdk";
|
|
2
2
|
import type { CoordinateMap } from "./coords.js";
|
|
3
|
-
/** What a system's helpers read of its state. */
|
|
4
3
|
export interface SystemState {
|
|
5
4
|
readonly padding: InsetsResolved;
|
|
6
5
|
readonly fill: Fill;
|
package/dist/kit/system.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/kit/system.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EAIV,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,MAAM,EAEd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/kit/system.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EAIV,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,MAAM,E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CAAC,CAAC,GAAG,UAAU,CAE5G;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,UAAU,EAAE,GAAG,IAAI,CAY5I"}
|
package/dist/kit/system.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import { Graphics2D, insetsOps, Paint, provides, } from "@motionscript/sdk";
|
|
2
2
|
import { settle, SYSTEM, systemPlane } from "./graph.js";
|
|
3
3
|
import { openPlane, placeOnMap } from "./place.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* its own size, so anything can be put on a graph: a dot, a label, an image. A
|
|
8
|
-
* mark is drawn through the system's map instead and laid out on its ink.
|
|
9
|
-
*
|
|
10
|
-
* The system's `stroke` is its axis line (so `endCap` is the tip) and its `fill`
|
|
11
|
-
* the backdrop. Ticks, grid and labels are drawing ops, never child nodes: a
|
|
12
|
-
* document's children would otherwise share their indices with them.
|
|
13
|
-
*/
|
|
4
|
+
// A child's `x`/`y` are in the system's units and it keeps its own size; a mark is drawn through the map and laid out on its ink.
|
|
5
|
+
// The `stroke` is the axis line (`endCap` is its tip), the `fill` the backdrop. Ticks, grid and labels are drawing ops, never
|
|
6
|
+
// child nodes: they would share their indices with a document's children.
|
|
14
7
|
const CENTRE = { x: 0, y: 0 };
|
|
15
8
|
/** The plot area: the box less its padding, y-up from the box's centre. */
|
|
16
9
|
export function plotArea(size, padding) {
|
package/dist/kit/system.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/kit/system.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,SAAS,EACT,KAAK,EACL,QAAQ,GAYX,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,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GAAG,GAAG,CAAC,IAAI,CAAC;IACnC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;IAC5C,MAAM,IAAI,GAAG,IAAI,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC;IAC5H,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE;QACb,GAAG,CAAC,IAAI,CAAC,IAAI,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACrG,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,GAAG,CAAC,MAAM;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;;YACjD,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IACH,sGAAsG;IACtG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,KAAoC,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACrF,CAAC","sourcesContent":["import {\n Graphics2D,\n insetsOps,\n Paint,\n provides,\n type ChildPlane,\n type ChildView,\n type Extents,\n type InsetsResolved,\n type Placement2D,\n type Provided,\n type RenderContext,\n type Shadow,\n type Fill,\n type Size2D,\n type Vector2,\n} from \"@motionscript/sdk\";\nimport type { CoordinateMap } from \"./coords\";\nimport { settle, SYSTEM, systemPlane } from \"./graph\";\nimport { openPlane, placeOnMap } from \"./place\";\n\n// A child's `x`/`y` are in the system's units and it keeps its own size; a mark is drawn through the map and laid out on its ink.\n// The `stroke` is the axis line (`endCap` is its tip), the `fill` the backdrop. Ticks, grid and labels are drawing ops, never\n// child nodes: they would share their indices with a document's children.\nconst CENTRE: Vector2 = { x: 0, y: 0 };\n\nexport interface SystemState {\n readonly padding: InsetsResolved;\n readonly fill: Fill;\n readonly shadow: Shadow;\n readonly clip: boolean;\n}\n\n/** How a system's graph values land on its plot area. */\nexport type MapFor<S> = (area: Extents, state: S) => CoordinateMap;\n\n/** The plot area: the box less its padding, y-up from the box's centre. */\nexport function plotArea(size: Size2D, padding: InsetsResolved): Extents {\n const inner = insetsOps.insetBounds(size.width, size.height, padding);\n return {\n minX: inner.x - inner.width / 2,\n maxX: inner.x + inner.width / 2,\n minY: -inner.y - inner.height / 2,\n maxY: -inner.y + inner.height / 2,\n };\n}\n\n/** A system's map at a laid-out `size`. */\nexport function systemMap<S extends SystemState>(size: Size2D, state: S, mapFor: MapFor<S>): CoordinateMap {\n return mapFor(plotArea(size, state.padding), state);\n}\n\n/** A system is the size it is given: its children are placed in it, not measured into it. */\nexport function systemSize(state: SystemState): Size2D {\n const { left, right, top, bottom } = state.padding;\n return { width: left + right, height: top + bottom };\n}\n\n/** What a system hands its subtree: its plane, which its layout keeps current. */\nexport function systemProvides(state: object): readonly Provided[] {\n return [provides(SYSTEM, systemPlane(state))];\n}\n\n/** Lay a system's children out on its map. */\nexport function systemLayout<S extends SystemState>(size: Size2D, state: S, children: readonly ChildView[], mapFor: MapFor<S>): Placement2D[] {\n const map = systemMap(size, state, mapFor);\n const plane = systemPlane(state);\n settle(plane, map, children);\n const inner = insetsOps.insetBounds(size.width, size.height, state.padding);\n return placeOnMap(children, map, CENTRE, inner, plane);\n}\n\n/** Where a child dropped on a system would sit. */\nexport function systemOpenPlane<S extends SystemState>(size: Size2D, state: S, mapFor: MapFor<S>): ChildPlane {\n return openPlane(systemMap(size, state, mapFor), CENTRE);\n}\n\n/**\n * A system's paint: the backdrop, then the furniture under its children, kept\n * in the plot area where the map spills from it, then the children, confined\n * to the plot area when `clip` is set. The stroke is the axis line, drawn with\n * the furniture: painted after the children it would land over them.\n */\nexport function drawSystem(ctx: RenderContext, state: SystemState, map: CoordinateMap, furniture: (map: CoordinateMap) => Graphics2D[]): void {\n const { width, height } = ctx.size;\n const { minX, minY, maxX, maxY } = map.area;\n const area = new Graphics2D().rect({ x: (minX + maxX) / 2, y: (minY + maxY) / 2, width: maxX - minX, height: maxY - minY });\n ctx.inFront(() => {\n ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width, height }).shadow(state.shadow).fill(state.fill));\n const parts = furniture(map);\n if (map.spills) ctx.clip(area, () => ctx.draw(parts));\n else ctx.draw(parts);\n });\n // No shape of its own to paint here; the plot area is what clips the children and what picking tests.\n Paint.draw(ctx, state as unknown as Paint.PaintState, null, { clipShape: area });\n}\n"]}
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import { type NodeOf, type NodeView, type
|
|
1
|
+
import { type NodeOf, type NodeView, type Fill as _Fill, type FillResolved as _FillResolved, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved } from "@motionscript/sdk";
|
|
2
2
|
import type { Interval } from "../kit/coords.js";
|
|
3
|
-
|
|
4
|
-
on?: string;
|
|
5
|
-
under?: string;
|
|
6
|
-
domain?: Interval;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* The region between a plot and the x axis, or between two plots, over a span
|
|
10
|
-
* of x. It sits beside the plots it reads rather than inside one: it may read
|
|
11
|
-
* two, and it has a life of its own on the timeline, swept open or kept while
|
|
12
|
-
* a curve changes.
|
|
13
|
-
*/
|
|
3
|
+
/** The region between a plot and the x axis, or between two plots, over a span of x. It sits beside the plots it reads, since it may read two. */
|
|
14
4
|
export declare const CurveArea: import("@motionscript/sdk").Component<"curveArea", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
15
5
|
/** The plot that bounds the area, by id. */
|
|
16
6
|
on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curve-area.d.ts","sourceRoot":"","sources":["../../src/marks/curve-area.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"curve-area.d.ts","sourceRoot":"","sources":["../../src/marks/curve-area.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,MAAM,EACX,KAAK,QAAQ,EAGb,KAAK,IAAI,IAAI,KAAK,EAClB,KAAK,YAAY,IAAI,aAAa,EAClC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACzC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAwB9C,kJAAkJ;AAClJ,eAAO,MAAM,SAAS;IAflB,4CAA4C;;IAE5C,6DAA6D;;;;;;;;;;;IAF7D,4CAA4C;;IAE5C,6DAA6D;;;;;;;IAF7D,4CAA4C;;IAE5C,6DAA6D;;;;;;;;;;2BAwBnD,CAAC;AAEf,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC"}
|
package/dist/marks/curve-area.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { component2d,
|
|
1
|
+
import { component2d, } from "@motionscript/sdk";
|
|
2
2
|
import { omit, PAINT, PAINT_COMMANDS } from "../kit/component.js";
|
|
3
3
|
import { curveValue } from "../kit/curve.js";
|
|
4
|
-
import {
|
|
4
|
+
import { intervalEntry, PLOT_COLOR } from "../kit/furniture.js";
|
|
5
5
|
import { clamp } from "../kit/geometry.js";
|
|
6
6
|
import { curveFor, PLANE_ENTRY, PLOT_REF } from "../kit/graph.js";
|
|
7
7
|
import { drawMark, inkSize, reading, traced } from "../kit/mark.js";
|
|
@@ -12,15 +12,10 @@ const state = {
|
|
|
12
12
|
on: PLOT_REF,
|
|
13
13
|
/** A second plot to fill down to, in place of the x axis. */
|
|
14
14
|
under: PLOT_REF,
|
|
15
|
-
domain:
|
|
15
|
+
domain: intervalEntry([0, 1]),
|
|
16
16
|
graph: PLANE_ENTRY,
|
|
17
17
|
};
|
|
18
|
-
/**
|
|
19
|
-
* The region between a plot and the x axis, or between two plots, over a span
|
|
20
|
-
* of x. It sits beside the plots it reads rather than inside one: it may read
|
|
21
|
-
* two, and it has a life of its own on the timeline, swept open or kept while
|
|
22
|
-
* a curve changes.
|
|
23
|
-
*/
|
|
18
|
+
/** The region between a plot and the x axis, or between two plots, over a span of x. It sits beside the plots it reads, since it may read two. */
|
|
24
19
|
export const CurveArea = traced(component2d({
|
|
25
20
|
key: "curveArea",
|
|
26
21
|
state,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curve-area.js","sourceRoot":"","sources":["../../src/marks/curve-area.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,
|
|
1
|
+
{"version":3,"file":"curve-area.js","sourceRoot":"","sources":["../../src/marks/curve-area.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,GAWd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,WAAW,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,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAC7G,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import {\n component2d,\n type NodeOf,\n type NodeView,\n type Vector2,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Fill as _Fill,\n type FillResolved as _FillResolved,\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n} from \"@motionscript/sdk\";\nimport { omit, PAINT, PAINT_COMMANDS } from \"../kit/component\";\nimport type { Interval } from \"../kit/coords\";\nimport { curveValue } from \"../kit/curve\";\nimport { intervalEntry, PLOT_COLOR } from \"../kit/furniture\";\nimport { clamp } from \"../kit/geometry\";\nimport { curveFor, PLANE_ENTRY, PLOT_REF } from \"../kit/graph\";\nimport { drawMark, inkSize, reading, traced, type MarkReading } from \"../kit/mark\";\n\nconst state = {\n // An area is only its fill, and has no outline to trim.\n ...omit(PAINT, \"stroke\", \"start\", \"end\"),\n /** The plot that bounds the area, by id. */\n on: PLOT_REF,\n /** A second plot to fill down to, in place of the x axis. */\n under: PLOT_REF,\n domain: intervalEntry([0, 1]),\n graph: PLANE_ENTRY,\n};\n\ninterface AreaValues {\n readonly on: NodeView | null;\n readonly under: NodeView | null;\n readonly domain: Interval;\n}\n\n/** The region between a plot and the x axis, or between two plots, over a span of x. It sits beside the plots it reads, since it may read two. */\nexport const CurveArea = traced(component2d({\n key: \"curveArea\",\n state,\n defaults: { fill: { type: \"solid\", color: PLOT_COLOR, opacity: 0.35 }, width: \"hug\", height: \"hug\" },\n commands: {\n ...omit(PAINT_COMMANDS, \"strokeTo\", \"progressTo\", \"flash\"),\n /** Animate the span of x that is filled: sweep an area open, or slide it along. */\n domainTo: { args: [\"domain\"] },\n },\n measure: (_measurer, s) => inkSize(traceArea(s, reading(s))),\n render: (ctx, s) => drawMark(ctx, s, traceArea(s, reading(s)), { closed: true }),\n}), traceArea);\n\nexport type CurveArea = NodeOf<typeof CurveArea>;\n\nfunction traceArea(s: AreaValues, { map, plane }: MarkReading): Vector2[][] {\n const top = curveFor(plane, s.on);\n if (!top) return [];\n const floor = curveFor(plane, s.under, false);\n const [yMin, yMax] = map.yRange;\n const a = Math.max(s.domain[0], map.xRange[0]);\n const b = Math.min(s.domain[1], map.xRange[1]);\n if (!(b > a)) return [];\n\n const width = Math.abs(map.toPoint(b, 0).x - map.toPoint(a, 0).x);\n const steps = Math.max(8, Math.min(600, Math.round(width / 2)));\n // Held inside the system's range, and at the axis where a curve has no value.\n const height = (value: number) => (Number.isFinite(value) ? clamp(value, yMin, yMax) : clamp(0, yMin, yMax));\n const upper: Vector2[] = [];\n const lower: Vector2[] = [];\n for (let i = 0; i <= steps; i++) {\n const x = a + ((b - a) * i) / steps;\n upper.push(map.toPoint(x, height(curveValue(top, x))));\n lower.push(map.toPoint(x, height(floor ? curveValue(floor, x) : 0)));\n }\n return [[...upper, ...lower.reverse()]];\n}\n"]}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { type NodeOf, type NodeView, type
|
|
1
|
+
import { type NodeOf, type NodeView, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved } from "@motionscript/sdk";
|
|
2
2
|
export type DropAxis = "x" | "y" | "both";
|
|
3
|
-
export interface DropLinesProps extends PaintProps {
|
|
4
|
-
on?: string;
|
|
5
|
-
axis?: DropAxis;
|
|
6
|
-
}
|
|
7
3
|
/**
|
|
8
4
|
* Guide lines from a graph point to the axes, reading its coordinates off them.
|
|
9
5
|
* The point is this node's `x`/`y`, or the point of a plot above its `x`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drop-lines.d.ts","sourceRoot":"","sources":["../../src/marks/drop-lines.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,MAAM,EACX,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"file":"drop-lines.d.ts","sourceRoot":"","sources":["../../src/marks/drop-lines.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,MAAM,EACX,KAAK,QAAQ,EAGb,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACtC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACzC,MAAM,mBAAmB,CAAC;AAQ3B,MAAM,MAAM,QAAQ,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC;AAkB1C;;;GAGG;AACH,eAAO,MAAM,SAAS;IAlBlB,qDAAqD;;IAErD,kFAAkF;;;;;;;;;;;;;;;IAFlF,qDAAqD;;IAErD,kFAAkF;;;;;;;;IAFlF,qDAAqD;;IAErD,kFAAkF;;;;;;;;;;;;;;2BAuBvE,CAAC;AAEhB,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drop-lines.js","sourceRoot":"","sources":["../../src/marks/drop-lines.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,
|
|
1
|
+
{"version":3,"file":"drop-lines.js","sourceRoot":"","sources":["../../src/marks/drop-lines.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,GAWd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAa,CAAC;AAInF,MAAM,KAAK,GAAG;IACV,GAAG,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,EAAE,EAAE,QAAQ;IACZ,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAC/D,KAAK,EAAE,WAAW;CACrB,CAAC;AASF;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC;IACxC,GAAG,EAAE,WAAW;IAChB,KAAK;IACL,QAAQ,EAAE,EAAE,MAAM,EAAE,E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EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC5F,IAAI,CAAC,CAAC,IAAI,KAAK,GAAG;QAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC5F,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import {\n component2d,\n type NodeOf,\n type NodeView,\n type Vector2,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n} from \"@motionscript/sdk\";\nimport { listed, omit, PAINT, PAINT_COMMANDS } from \"../kit/component\";\nimport { curveValue } from \"../kit/curve\";\nimport { AXIS_COLOR } from \"../kit/furniture\";\nimport { clamp } from \"../kit/geometry\";\nimport { curveFor, PLANE_ENTRY, PLOT_REF } from \"../kit/graph\";\nimport { drawMark, inkSize, reading, traced, type MarkReading } from \"../kit/mark\";\n\nexport type DropAxis = \"x\" | \"y\" | \"both\";\n\nconst state = {\n ...omit(PAINT, \"fill\"),\n /** A plot to take the point's height from, by id. */\n on: PLOT_REF,\n /** Which axis to drop to: `x` draws the vertical line, `y` the horizontal one. */\n axis: listed([\"x\", \"y\", \"both\"], \"both\", { animatable: false }),\n graph: PLANE_ENTRY,\n};\n\ninterface DropValues {\n readonly x: number;\n readonly y: number;\n readonly on: NodeView | null;\n readonly axis: DropAxis;\n}\n\n/**\n * Guide lines from a graph point to the axes, reading its coordinates off them.\n * The point is this node's `x`/`y`, or the point of a plot above its `x`.\n */\nexport const DropLines = traced(component2d({\n key: \"dropLines\",\n state,\n defaults: { stroke: { weight: 2, fill: AXIS_COLOR, align: \"center\", dash: [8, 6] }, width: \"hug\", height: \"hug\" },\n commands: omit(PAINT_COMMANDS, \"fillTo\"),\n measure: (_measurer, s) => inkSize(traceDrops(s, reading(s))),\n render: (ctx, s) => drawMark(ctx, s, traceDrops(s, reading(s))),\n}), traceDrops);\n\nexport type DropLines = NodeOf<typeof DropLines>;\n\nfunction traceDrops(s: DropValues, { map, plane }: MarkReading): Vector2[][] {\n const x = s.x;\n const plot = curveFor(plane, s.on);\n const y = plot ? curveValue(plot, x) : s.y;\n if (!Number.isFinite(y)) return [];\n const at = map.toPoint(x, y);\n const runs: Vector2[][] = [];\n // Each line starts on its axis, so drawing it on grows it towards the point.\n if (s.axis !== \"y\") runs.push([map.toPoint(x, clamp(0, map.yRange[0], map.yRange[1])), at]);\n if (s.axis !== \"x\") runs.push([map.toPoint(clamp(0, map.xRange[0], map.xRange[1]), y), at]);\n return runs;\n}\n"]}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type NodeOf, type Color as _Color, type NormalizedColor, type Fill as _Fill, type FillResolved as _FillResolved, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved } from "@motionscript/sdk";
|
|
2
2
|
import { type GraphPlane } from "../kit/graph.js";
|
|
3
|
-
export interface PlotPointProps extends PaintProps {
|
|
4
|
-
on?: string;
|
|
5
|
-
radius?: number;
|
|
6
|
-
label?: string;
|
|
7
|
-
labelSide?: "above" | "below" | "left" | "right";
|
|
8
|
-
labelSize?: number;
|
|
9
|
-
labelColor?: Color;
|
|
10
|
-
fontFamily?: string;
|
|
11
|
-
}
|
|
12
3
|
/**
|
|
13
4
|
* A dot at graph coordinates, with an optional label. Named a plot in `on`, it
|
|
14
5
|
* rides that curve: its `x` is where along it, and its height is the curve's.
|
|
@@ -20,7 +11,7 @@ export declare const PlotPoint: import("@motionscript/sdk").Component<"plotPoint
|
|
|
20
11
|
label: import("@motionscript/sdk").Type<string, string, false>;
|
|
21
12
|
labelSide: import("@motionscript/sdk").Type<"right" | "left" | "below" | "above", "right" | "left" | "below" | "above", false>;
|
|
22
13
|
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
23
|
-
labelColor: import("@motionscript/sdk").Type<
|
|
14
|
+
labelColor: import("@motionscript/sdk").Type<_Color, NormalizedColor, false>;
|
|
24
15
|
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
25
16
|
graph: import("@motionscript/sdk").Type<GraphPlane | null, GraphPlane | null, true>;
|
|
26
17
|
/** The graph height the point is at: the curve's when it rides one. A formula reads it back as `[key.value]`. */
|
|
@@ -39,7 +30,7 @@ export declare const PlotPoint: import("@motionscript/sdk").Component<"plotPoint
|
|
|
39
30
|
label: import("@motionscript/sdk").Type<string, string, false>;
|
|
40
31
|
labelSide: import("@motionscript/sdk").Type<"right" | "left" | "below" | "above", "right" | "left" | "below" | "above", false>;
|
|
41
32
|
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
42
|
-
labelColor: import("@motionscript/sdk").Type<
|
|
33
|
+
labelColor: import("@motionscript/sdk").Type<_Color, NormalizedColor, false>;
|
|
43
34
|
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
44
35
|
graph: import("@motionscript/sdk").Type<GraphPlane | null, GraphPlane | null, true>;
|
|
45
36
|
/** The graph height the point is at: the curve's when it rides one. A formula reads it back as `[key.value]`. */
|
|
@@ -54,7 +45,7 @@ export declare const PlotPoint: import("@motionscript/sdk").Component<"plotPoint
|
|
|
54
45
|
label: import("@motionscript/sdk").Type<string, string, false>;
|
|
55
46
|
labelSide: import("@motionscript/sdk").Type<"right" | "left" | "below" | "above", "right" | "left" | "below" | "above", false>;
|
|
56
47
|
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
57
|
-
labelColor: import("@motionscript/sdk").Type<
|
|
48
|
+
labelColor: import("@motionscript/sdk").Type<_Color, NormalizedColor, false>;
|
|
58
49
|
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
59
50
|
graph: import("@motionscript/sdk").Type<GraphPlane | null, GraphPlane | null, true>;
|
|
60
51
|
/** The graph height the point is at: the curve's when it rides one. A formula reads it back as `[key.value]`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plot-point.d.ts","sourceRoot":"","sources":["../../src/marks/plot-point.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,
|
|
1
|
+
{"version":3,"file":"plot-point.d.ts","sourceRoot":"","sources":["../../src/marks/plot-point.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,MAAM,EACX,KAAK,KAAK,IAAI,MAAM,EAEpB,KAAK,eAAe,EAEpB,KAAK,IAAI,IAAI,KAAK,EAClB,KAAK,YAAY,IAAI,aAAa,EAClC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACtC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACzC,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAmC,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAoBhF;;;GAGG;AACH,eAAO,MAAM,SAAS;IAjBlB,wFAAwF;;;;;;;;;IASxF,iHAAiH;;;;;;;;;;IATjH,wFAAwF;;;;;;;;;IASxF,iHAAiH;;;;;;IATjH,wFAAwF;;;;;;;;;IASxF,iHAAiH;;;;;;;;;2BA4CvB,CAAC;AAE/F,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plot-point.js","sourceRoot":"","sources":["../../src/marks/plot-point.ts"],"names":[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AK,EAAE,EAAE,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAClD,0FAA0F;IAC1F,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import {\n component2d,\n Graphics2D,\n Types,\n type NodeOf,\n type Color as _Color,\n\n type NormalizedColor,\n // Named so the emitted declaration reaches these through the sdk, not core.\n type Fill as _Fill,\n type FillResolved as _FillResolved,\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n} from \"@motionscript/sdk\";\nimport { listed, omit, PAINT, PAINT_COMMANDS, painted } from \"../kit/component\";\nimport { curveValue } from \"../kit/curve\";\nimport { drawLabels, loadFormulas, type Label } from \"../kit/furniture\";\nimport { curveFor, PLANE_ENTRY, PLOT_REF, type GraphPlane } from \"../kit/graph\";\nimport { strokeShape } from \"../kit/mark\";\nimport { anchored } from \"../kit/place\";\n\nconst state = {\n // A dot has no outline worth trimming.\n ...omit(PAINT, \"start\", \"end\"),\n /** The plot this point rides, by id; empty for a point that sits at its own `x`/`y`. */\n on: PLOT_REF,\n radius: Types.number(7, { min: 0, unit: \"px\" }),\n label: Types.text(\"\", { animatable: false }),\n labelSide: listed([\"above\", \"below\", \"left\", \"right\"], \"above\", { animatable: false }),\n labelSize: Types.number(18, { min: 1, unit: \"px\" }),\n labelColor: Types.color(\"#e5e7eb\"),\n fontFamily: Types.text(\"\", { animatable: false }),\n graph: PLANE_ENTRY,\n /** The graph height the point is at: the curve's when it rides one. A formula reads it back as `[key.value]`. */\n value: Types.number(0, { private: true }),\n};\n\n/**\n * A dot at graph coordinates, with an optional label. Named a plot in `on`, it\n * rides that curve: its `x` is where along it, and its height is the curve's.\n */\nexport const PlotPoint = anchored(component2d({\n key: \"plotPoint\",\n state,\n defaults: { fill: \"#e5e7eb\", width: \"hug\", height: \"hug\", value: (s) => heightOf(s.graph, s.on, s.x, s.y) },\n load: (loader, s) => {\n if (s.label !== \"\" && s.fontFamily !== \"\") loader.font(s.fontFamily);\n loadFormulas(loader, [s.label]);\n },\n commands: omit(PAINT_COMMANDS, \"progressTo\", \"flash\"),\n measure: (_measurer, s) => ({ width: s.radius * 2, height: s.radius * 2 }),\n render: (ctx, s) => {\n const size = s.radius * 2;\n const shape = size > 0 ? () => new Graphics2D().ellipse({ x: 0, y: 0, width: size, height: size }) : null;\n painted(\n ctx,\n () => {\n if (shape) ctx.draw(shape().shadow(s.shadow).fill(s.fill));\n if (s.label === \"\") return;\n const gap = s.radius + s.labelSize * 0.45;\n const side = s.labelSide;\n const horizontal = side === \"left\" || side === \"right\";\n const label: Label = {\n text: s.label,\n align: side === \"left\" ? \"right\" : side === \"right\" ? \"left\" : \"center\",\n at: {\n x: horizontal ? (side === \"left\" ? -1 : 1) * gap : 0,\n y: horizontal ? 0 : (side === \"below\" ? -1 : 1) * (gap + s.labelSize / 2),\n },\n };\n ctx.draw(drawLabels([label], { fontSize: s.labelSize, fontFamily: s.fontFamily, color: s.labelColor as NormalizedColor }));\n },\n () => {\n if (shape) strokeShape(ctx, shape, s);\n },\n );\n },\n}), (s: { readonly on: unknown }, plane) => (x, y) => ({ x, y: heightOf(plane, s.on, x, y) }));\n\nexport type PlotPoint = NodeOf<typeof PlotPoint>;\n\n/** The height a point at `x`/`y` sits at: the curve's, when it rides one that has a value there. */\nfunction heightOf(plane: GraphPlane | null, on: unknown, x: number, y: number): number {\n const curve = curveFor(plane, on);\n const height = curve ? curveValue(curve, x) : NaN;\n // Off the end of its curve a point stays where its own `y` puts it rather than vanishing.\n return Number.isFinite(height) ? height : y;\n}\n"]}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import { type NodeOf, type NodeView, type
|
|
1
|
+
import { type NodeOf, type NodeView, type Fill as _Fill, type FillResolved as _FillResolved, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved } from "@motionscript/sdk";
|
|
2
2
|
import type { Interval } from "../kit/coords.js";
|
|
3
3
|
export type RiemannSample = "left" | "right" | "center";
|
|
4
|
-
export interface RiemannSumProps extends PaintProps {
|
|
5
|
-
on?: string;
|
|
6
|
-
domain?: Interval;
|
|
7
|
-
dx?: number;
|
|
8
|
-
sample?: RiemannSample;
|
|
9
|
-
}
|
|
10
4
|
/** Rectangles under a plot, each `dx` wide and as tall as the curve where it is sampled. */
|
|
11
5
|
export declare const RiemannSum: import("@motionscript/sdk").Component<"riemannSum", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
12
6
|
on: import("@motionscript/sdk").Type<string, NodeView<import("@motionscript/sdk").Element<string, unknown, unknown>> | null, false>;
|