@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-lines.js","sourceRoot":"","sources":["../../src/plots/stream-lines.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,KAAK,GAYR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAA6F,MAAM,mBAAmB,CAAC;AAClL,OAAO,EAAE,UAAU,EAAE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C,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACjE,CAAC;AAED,iHAAiH;AACjH,SAAS,OAAO,CAAC,MAAiB,EAAE,KAAa,EAAE,KAAa;IAC5D,MAAM,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,CAAC;IACtC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5B,IAAI,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED,6HAA6H;AAC7H,SAAS,OAAO,CAAC,KAAa;IAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,UAAU,CAAC;IACrD,OAAO,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import {\n component2d,\n Types,\n type NodeOf,\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 type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n} from \"@motionscript/sdk\";\nimport type { CoordinateMap } from \"../kit/coords\";\nimport { drawField, FIELD_COMMANDS, FIELD_STATE, traceField, type FieldDrawing, type FieldProps, type FieldSampler, type FieldStroke, type FieldValues } from \"../kit/field-mark\";\nimport { PLOT_COLOR } from \"../kit/furniture\";\nimport { clamp } from \"../kit/geometry\";\nimport { inkSize, reading, traced, type MarkReading } from \"../kit/mark\";\n\nexport interface StreamLinesProps extends FieldProps {\n spacing?: number;\n length?: number;\n window?: number;\n phase?: number;\n}\n\nconst MAX_LINES = 1600;\n/** Steps a line takes across one spacing: what keeps a tight swirl round. */\nconst STEPS_PER_SPACING = 8;\nconst MAX_STEPS = 600;\n\nconst state = {\n ...FIELD_STATE,\n /** How far apart the lines start, in graph units. */\n spacing: Types.number(1, { min: 0.01, step: 0.1 }),\n /** How far each line runs from where it starts, in graph units along itself. */\n length: Types.number(3, { min: 0, step: 0.1 }),\n /** The share of each line that is shown at once; one shows all of it. */\n window: Types.number(1, { min: 0.01, max: 1, step: 0.01 }),\n /** Where along its line each shown stretch is: one turn of it runs every line from end to end. */\n phase: Types.number(0, { step: 0.01 }),\n};\n\ninterface LinesValues extends FieldValues {\n readonly spacing: number;\n readonly length: number;\n readonly window: number;\n readonly phase: number;\n}\n\nconst LINES: FieldDrawing<LinesValues> = {\n own: (s) => `${s.spacing}|${s.length}|${s.window}|${s.phase}`,\n strokes: (s, map, field) => lines(s, map, field),\n};\n\nconst traceLines = (s: LinesValues, read: MarkReading) => traceField(\"streamLines\", LINES, s, read);\n\n/**\n * The lines a vector field carries a point along, one from each point of a\n * grid: `(-y, x)` draws circles. With a `window` below one, each line shows\n * only a stretch of itself, and `flowTo` sends those stretches along.\n */\nexport const StreamLines = traced(component2d({\n key: \"streamLines\",\n state,\n defaults: { stroke: { weight: 2, fill: PLOT_COLOR, align: \"center\", cap: \"round\", join: \"round\" }, width: \"hug\", height: \"hug\" },\n commands: {\n ...FIELD_COMMANDS,\n /** Send the shown stretches along their lines: a whole number runs each line that many times over. */\n flowTo: { args: [\"phase\"] },\n },\n measure: (_measurer, s) => inkSize(traceLines(s, reading(s)).runs),\n render: (ctx, s) => drawField(ctx, s, traceLines(s, reading(s))),\n}), (s: LinesValues, read: MarkReading) => traceLines(s, read).runs);\n\nexport type StreamLines = NodeOf<typeof StreamLines>;\n\nfunction lines(s: LinesValues, map: CoordinateMap, field: FieldSampler): FieldStroke[] {\n const [x0, x1] = map.xRange;\n const [y0, y1] = map.yRange;\n let spacing = Math.max(s.spacing, 1e-6);\n const count = () => (Math.floor((x1 - x0) / spacing) + 1) * (Math.floor((y1 - y0) / spacing) + 1);\n while (count() > MAX_LINES) spacing *= 2;\n const step = spacing / STEPS_PER_SPACING;\n const steps = Math.min(MAX_STEPS, Math.round(s.length / step));\n if (steps < 1) return [];\n // A line is followed a little past what is shown, so it leaves the box rather than stopping at its edge.\n const inside = (x: number, y: number) => x >= x0 - spacing && x <= x1 + spacing && y >= y0 - spacing && y <= y1 + spacing;\n const window = clamp(s.window, 0, 1);\n\n const drawn: FieldStroke[] = [];\n let index = 0;\n for (let i = Math.ceil(x0 / spacing - 1e-9); i * spacing <= x1 + 1e-9; i++) {\n for (let j = Math.ceil(y0 / spacing - 1e-9); j * spacing <= y1 + 1e-9; j++) {\n const line = follow(field, i * spacing, j * spacing, step, steps, inside);\n index++;\n if (line.points.length < 2) continue;\n const shown = window >= 1 ? line.points : stretch(line.points, window, s.phase + stagger(index));\n if (shown.length < 2) continue;\n drawn.push({ runs: [shown.map((p) => map.toPoint(p.x, p.y))], magnitude: line.magnitude });\n }\n }\n return drawn;\n}\n\n/** The graph points a field carries a point through from `(x, y)`, at an even pace, and how strong it was on the way. */\nfunction follow(\n field: FieldSampler,\n x: number,\n y: number,\n step: number,\n steps: number,\n inside: (x: number, y: number) => boolean,\n): { points: Vector2[]; magnitude: number } {\n const points: Vector2[] = [{ x, y }];\n const v: Vector2 = { x: 0, y: 0 };\n let strength = 0;\n let read = 0;\n // The field's direction at a point, as a unit step; `false` where it has none or is at rest.\n const heading = (px: number, py: number, out: Vector2): boolean => {\n if (!field(px, py, v)) return false;\n const magnitude = Math.hypot(v.x, v.y);\n if (!(magnitude > 1e-9)) return false;\n out.x = v.x / magnitude;\n out.y = v.y / magnitude;\n strength += magnitude;\n read++;\n return true;\n };\n const a: Vector2 = { x: 0, y: 0 };\n const b: Vector2 = { x: 0, y: 0 };\n for (let i = 0; i < steps; i++) {\n // Midpoint rule: the direction half a step on is the one the whole step takes.\n if (!heading(x, y, a) || !heading(x + (a.x * step) / 2, y + (a.y * step) / 2, b)) break;\n x += b.x * step;\n y += b.y * step;\n if (!inside(x, y)) break;\n points.push({ x, y });\n }\n return { points, magnitude: read > 0 ? strength / read : 0 };\n}\n\n/** The part of `points` a window `share` long shows at `phase`: it enters at one end and leaves by the other. */\nfunction stretch(points: Vector2[], share: number, phase: number): Vector2[] {\n const turn = phase - Math.floor(phase);\n const end = turn * (1 + share);\n const from = Math.max(0, end - share);\n const to = Math.min(1, end);\n if (!(to > from)) return [];\n const last = points.length - 1;\n return points.slice(Math.floor(from * last), Math.ceil(to * last) + 1);\n}\n\n/** A share of a turn that differs from line to line and never from frame to frame, so the stretches do not march in step. */\nfunction stagger(index: number): number {\n const mixed = Math.sin(index * 12.9898) * 43758.5453;\n return mixed - Math.floor(mixed);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"stream-lines.js","sourceRoot":"","sources":["../../src/plots/stream-lines.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,KAAK,GAYR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAA4E,MAAM,mBAAmB,CAAC;AACjK,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB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,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACjE,CAAC;AAED,iHAAiH;AACjH,SAAS,OAAO,CAAC,MAAiB,EAAE,KAAa,EAAE,KAAa;IAC5D,MAAM,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,CAAC;IACtC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5B,IAAI,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED,6HAA6H;AAC7H,SAAS,OAAO,CAAC,KAAa;IAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,UAAU,CAAC;IACrD,OAAO,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import {\n component2d,\n Types,\n type NodeOf,\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 type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n} from \"@motionscript/sdk\";\nimport type { CoordinateMap } from \"../kit/coords\";\nimport { drawField, FIELD_COMMANDS, FIELD_STATE, traceField, type FieldDrawing, type FieldSampler, type FieldStroke, type FieldValues } from \"../kit/field-mark\";\nimport { PLOT_COLOR } from \"../kit/furniture\";\nimport { clamp } from \"../kit/geometry\";\nimport { inkSize, reading, traced, type MarkReading } from \"../kit/mark\";\n\nconst MAX_LINES = 1600;\n/** Steps a line takes across one spacing: what keeps a tight swirl round. */\nconst STEPS_PER_SPACING = 8;\nconst MAX_STEPS = 600;\n\nconst state = {\n ...FIELD_STATE,\n /** How far apart the lines start, in graph units. */\n spacing: Types.number(1, { min: 0.01, step: 0.1 }),\n /** How far each line runs from where it starts, in graph units along itself. */\n length: Types.number(3, { min: 0, step: 0.1 }),\n /** The share of each line that is shown at once; one shows all of it. */\n window: Types.number(1, { min: 0.01, max: 1, step: 0.01 }),\n /** Where along its line each shown stretch is: one turn of it runs every line from end to end. */\n phase: Types.number(0, { step: 0.01 }),\n};\n\ninterface LinesValues extends FieldValues {\n readonly spacing: number;\n readonly length: number;\n readonly window: number;\n readonly phase: number;\n}\n\nconst LINES: FieldDrawing<LinesValues> = {\n own: (s) => `${s.spacing}|${s.length}|${s.window}|${s.phase}`,\n strokes: (s, map, field) => lines(s, map, field),\n};\n\nconst traceLines = (s: LinesValues, read: MarkReading) => traceField(\"streamLines\", LINES, s, read);\n\n/**\n * The lines a vector field carries a point along, one from each point of a\n * grid: `(-y, x)` draws circles. With a `window` below one, each line shows\n * only a stretch of itself, and `flowTo` sends those stretches along.\n */\nexport const StreamLines = traced(component2d({\n key: \"streamLines\",\n state,\n defaults: { stroke: { weight: 2, fill: PLOT_COLOR, align: \"center\", cap: \"round\", join: \"round\" }, width: \"hug\", height: \"hug\" },\n commands: {\n ...FIELD_COMMANDS,\n /** Send the shown stretches along their lines: a whole number runs each line that many times over. */\n flowTo: { args: [\"phase\"] },\n },\n measure: (_measurer, s) => inkSize(traceLines(s, reading(s)).runs),\n render: (ctx, s) => drawField(ctx, s, traceLines(s, reading(s))),\n}), (s: LinesValues, read: MarkReading) => traceLines(s, read).runs);\n\nexport type StreamLines = NodeOf<typeof StreamLines>;\n\nfunction lines(s: LinesValues, map: CoordinateMap, field: FieldSampler): FieldStroke[] {\n const [x0, x1] = map.xRange;\n const [y0, y1] = map.yRange;\n let spacing = Math.max(s.spacing, 1e-6);\n const count = () => (Math.floor((x1 - x0) / spacing) + 1) * (Math.floor((y1 - y0) / spacing) + 1);\n while (count() > MAX_LINES) spacing *= 2;\n const step = spacing / STEPS_PER_SPACING;\n const steps = Math.min(MAX_STEPS, Math.round(s.length / step));\n if (steps < 1) return [];\n // A line is followed a little past what is shown, so it leaves the box rather than stopping at its edge.\n const inside = (x: number, y: number) => x >= x0 - spacing && x <= x1 + spacing && y >= y0 - spacing && y <= y1 + spacing;\n const window = clamp(s.window, 0, 1);\n\n const drawn: FieldStroke[] = [];\n let index = 0;\n for (let i = Math.ceil(x0 / spacing - 1e-9); i * spacing <= x1 + 1e-9; i++) {\n for (let j = Math.ceil(y0 / spacing - 1e-9); j * spacing <= y1 + 1e-9; j++) {\n const line = follow(field, i * spacing, j * spacing, step, steps, inside);\n index++;\n if (line.points.length < 2) continue;\n const shown = window >= 1 ? line.points : stretch(line.points, window, s.phase + stagger(index));\n if (shown.length < 2) continue;\n drawn.push({ runs: [shown.map((p) => map.toPoint(p.x, p.y))], magnitude: line.magnitude });\n }\n }\n return drawn;\n}\n\n/** The graph points a field carries a point through from `(x, y)`, at an even pace, and how strong it was on the way. */\nfunction follow(\n field: FieldSampler,\n x: number,\n y: number,\n step: number,\n steps: number,\n inside: (x: number, y: number) => boolean,\n): { points: Vector2[]; magnitude: number } {\n const points: Vector2[] = [{ x, y }];\n const v: Vector2 = { x: 0, y: 0 };\n let strength = 0;\n let read = 0;\n // The field's direction at a point, as a unit step; `false` where it has none or is at rest.\n const heading = (px: number, py: number, out: Vector2): boolean => {\n if (!field(px, py, v)) return false;\n const magnitude = Math.hypot(v.x, v.y);\n if (!(magnitude > 1e-9)) return false;\n out.x = v.x / magnitude;\n out.y = v.y / magnitude;\n strength += magnitude;\n read++;\n return true;\n };\n const a: Vector2 = { x: 0, y: 0 };\n const b: Vector2 = { x: 0, y: 0 };\n for (let i = 0; i < steps; i++) {\n // Midpoint rule: the direction half a step on is the one the whole step takes.\n if (!heading(x, y, a) || !heading(x + (a.x * step) / 2, y + (a.y * step) / 2, b)) break;\n x += b.x * step;\n y += b.y * step;\n if (!inside(x, y)) break;\n points.push({ x, y });\n }\n return { points, magnitude: read > 0 ? strength / read : 0 };\n}\n\n/** The part of `points` a window `share` long shows at `phase`: it enters at one end and leaves by the other. */\nfunction stretch(points: Vector2[], share: number, phase: number): Vector2[] {\n const turn = phase - Math.floor(phase);\n const end = turn * (1 + share);\n const from = Math.max(0, end - share);\n const to = Math.min(1, end);\n if (!(to > from)) return [];\n const last = points.length - 1;\n return points.slice(Math.floor(from * last), Math.ceil(to * last) + 1);\n}\n\n/** A share of a turn that differs from line to line and never from frame to frame, so the stretches do not march in step. */\nfunction stagger(index: number): number {\n const mixed = Math.sin(index * 12.9898) * 43758.5453;\n return mixed - Math.floor(mixed);\n}\n"]}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { type NodeOf, 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
|
-
|
|
4
|
-
export interface TracedPathProps extends FunctionPlotProps {
|
|
5
|
-
from?: number;
|
|
6
|
-
value?: number;
|
|
7
|
-
tail?: number;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* The trail a point leaves as a value changes: the curve of its equation from
|
|
11
|
-
* where the value began to where it is now. Bind `value` to a variable
|
|
12
|
-
* (`"=[t]"`) and the trail grows as the variable is driven, or drive it with
|
|
13
|
-
* `traceTo`; a `tail` keeps only its most recent stretch.
|
|
14
|
-
*/
|
|
3
|
+
/** The trail a point leaves as a value changes: the curve of its equation from where the value began to where it is. */
|
|
15
4
|
export declare const TracedPath: import("@motionscript/sdk").Component<"tracedPath", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
16
5
|
/** The value the trail starts at. */
|
|
17
6
|
from: import("@motionscript/sdk").Type<number, number, false>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traced-path.d.ts","sourceRoot":"","sources":["../../src/plots/traced-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,MAAM,EAEX,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;AAE3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"traced-path.d.ts","sourceRoot":"","sources":["../../src/plots/traced-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,MAAM,EAEX,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;AAE3B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAqB9C,wHAAwH;AACxH,eAAO,MAAM,UAAU;IAfnB,qCAAqC;;IAErC,2DAA2D;;IAE3D,qFAAqF;;;;;;;;;;;;;;;;IAJrF,qCAAqC;;IAErC,2DAA2D;;IAE3D,qFAAqF;;;;;;;;;IAJrF,qCAAqC;;IAErC,2DAA2D;;IAE3D,qFAAqF;;;;;;;;;;;;;;;2BAsB1E,CAAC;AAEhB,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
|
@@ -12,12 +12,7 @@ const state = {
|
|
|
12
12
|
/** How much of the trail is kept, in the value's own units; zero keeps all of it. */
|
|
13
13
|
tail: Types.number(0, { min: 0, step: 0.1 }),
|
|
14
14
|
};
|
|
15
|
-
/**
|
|
16
|
-
* The trail a point leaves as a value changes: the curve of its equation from
|
|
17
|
-
* where the value began to where it is now. Bind `value` to a variable
|
|
18
|
-
* (`"=[t]"`) and the trail grows as the variable is driven, or drive it with
|
|
19
|
-
* `traceTo`; a `tail` keeps only its most recent stretch.
|
|
20
|
-
*/
|
|
15
|
+
/** The trail a point leaves as a value changes: the curve of its equation from where the value began to where it is. */
|
|
21
16
|
export const TracedPath = traced(component2d({
|
|
22
17
|
key: "tracedPath",
|
|
23
18
|
state,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traced-path.js","sourceRoot":"","sources":["../../src/plots/traced-path.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,KAAK,GASR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAa,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"traced-path.js","sourceRoot":"","sources":["../../src/plots/traced-path.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,KAAK,GASR,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE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,GAAG,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;CAClE,CAAC,EAAE,UAAU,CAAC,CAAC;AAIhB,SAAS,UAAU,CAAC,CAAc,EAAE,IAAiB;IACjD,OAAO,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAED,+GAA+G;AAC/G,SAAS,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAe;IAC5C,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IACxF,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC;AACzE,CAAC","sourcesContent":["import {\n component2d,\n Types,\n type NodeOf,\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 { omit } from \"../kit/component\";\nimport type { Interval } from \"../kit/coords\";\nimport { drawMark, inkSize, reading, traced, type MarkReading } from \"../kit/mark\";\nimport { PLOT_COMMANDS, PLOT_STATE, PLOT_STROKE, tracePlot, type PlotValues } from \"./function-plot\";\n\nconst state = {\n // It reveals itself by its value, so it trims no outline of its own.\n ...omit(PLOT_STATE, \"start\", \"end\"),\n /** The value the trail starts at. */\n from: Types.number(0, { step: 0.1 }),\n /** The value the point is at now: where the trail ends. */\n value: Types.number(0, { step: 0.1 }),\n /** How much of the trail is kept, in the value's own units; zero keeps all of it. */\n tail: Types.number(0, { min: 0, step: 0.1 }),\n};\n\ninterface TrailValues extends PlotValues {\n readonly from: number;\n readonly value: number;\n readonly tail: number;\n}\n\n/** The trail a point leaves as a value changes: the curve of its equation from where the value began to where it is. */\nexport const TracedPath = traced(component2d({\n key: \"tracedPath\",\n state,\n defaults: { stroke: PLOT_STROKE, width: \"hug\", height: \"hug\" },\n commands: {\n ...omit(PLOT_COMMANDS, \"progressTo\", \"flash\"),\n /** Carry the point on to another value, the trail following it. */\n traceTo: { args: [\"value\"] },\n },\n measure: (_measurer, s) => inkSize(traceTrail(s, reading(s))),\n render: (ctx, s) => drawMark(ctx, s, traceTrail(s, reading(s))),\n}), traceTrail);\n\nexport type TracedPath = NodeOf<typeof TracedPath>;\n\nfunction traceTrail(s: TrailValues, read: MarkReading) {\n return tracePlot(s, read, span(s));\n}\n\n/** The span of the free variable the trail covers: from where the value began, or its tail, to where it is. */\nfunction span({ from, value, tail }: TrailValues): Interval {\n const kept = tail > 0 ? Math.min(Math.abs(value - from), tail) : Math.abs(value - from);\n return value >= from ? [value - kept, value] : [value, value + kept];\n}\n"]}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { type NodeOf, 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
|
-
|
|
3
|
-
export interface VectorFieldProps extends FieldProps {
|
|
4
|
-
spacing?: number;
|
|
5
|
-
arrowScale?: number;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* A grid of arrows showing a vector field, two parts in x and y: `(-y, x)`.
|
|
9
|
-
* Each arrow is centred on its point and is as long as the field is strong
|
|
10
|
-
* there, up to the spacing.
|
|
11
|
-
*/
|
|
2
|
+
/** A grid of arrows showing a vector field, `(-y, x)`: each is centred on its point and as long as the field is strong there, up to the spacing. */
|
|
12
3
|
export declare const VectorField: import("@motionscript/sdk").Component<"vectorField", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
13
4
|
/** How far apart the arrows stand, in graph units. */
|
|
14
5
|
spacing: import("@motionscript/sdk").Type<number, number, false>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-field.d.ts","sourceRoot":"","sources":["../../src/plots/vector-field.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,MAAM,EAGX,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;
|
|
1
|
+
{"version":3,"file":"vector-field.d.ts","sourceRoot":"","sources":["../../src/plots/vector-field.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,MAAM,EAGX,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;AAkC3B,oJAAoJ;AACpJ,eAAO,MAAM,WAAW;IAnBpB,sDAAsD;;IAEtD,6EAA6E;;;;;;;;;;;;;;;IAF7E,sDAAsD;;IAEtD,6EAA6E;;;;;;;;;;IAF7E,sDAAsD;;IAEtD,6EAA6E;;;;;;;;;;;;;;2BAwBX,CAAC;AAEvE,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { component2d, Types, } from "@motionscript/sdk";
|
|
2
2
|
import { drawField, FIELD_COMMANDS, FIELD_STATE, traceField } from "../kit/field-mark.js";
|
|
3
3
|
import { PLOT_COLOR } from "../kit/furniture.js";
|
|
4
|
+
import { radians } from "../kit/geometry.js";
|
|
4
5
|
import { inkSize, reading, traced } from "../kit/mark.js";
|
|
5
6
|
/** Past this many arrows the spacing is widened, so a field over a huge range is still a field and not a wash. */
|
|
6
7
|
const MAX_ARROWS = 2400;
|
|
7
8
|
/** An arrow's head, as a share of its length and in pixels at most, and the half-angle it opens to. */
|
|
8
9
|
const HEAD_SHARE = 0.38;
|
|
9
10
|
const HEAD_MAX = 11;
|
|
10
|
-
const HEAD_ANGLE = (26
|
|
11
|
+
const HEAD_ANGLE = radians(26);
|
|
11
12
|
const state = {
|
|
12
13
|
...FIELD_STATE,
|
|
13
14
|
/** How far apart the arrows stand, in graph units. */
|
|
@@ -20,11 +21,7 @@ const ARROWS = {
|
|
|
20
21
|
strokes: (s, map, field) => arrows(s, map, field),
|
|
21
22
|
};
|
|
22
23
|
const traceArrows = (s, read) => traceField("vectorField", ARROWS, s, read);
|
|
23
|
-
/**
|
|
24
|
-
* A grid of arrows showing a vector field, two parts in x and y: `(-y, x)`.
|
|
25
|
-
* Each arrow is centred on its point and is as long as the field is strong
|
|
26
|
-
* there, up to the spacing.
|
|
27
|
-
*/
|
|
24
|
+
/** A grid of arrows showing a vector field, `(-y, x)`: each is centred on its point and as long as the field is strong there, up to the spacing. */
|
|
28
25
|
export const VectorField = traced(component2d({
|
|
29
26
|
key: "vectorField",
|
|
30
27
|
state,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-field.js","sourceRoot":"","sources":["../../src/plots/vector-field.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,KAAK,GAY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CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;IACpH,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,GAAG,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import {\n component2d,\n Types,\n type NodeOf,\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 type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n} from \"@motionscript/sdk\";\nimport type { CoordinateMap } from \"../kit/coords\";\nimport { drawField, FIELD_COMMANDS, FIELD_STATE, traceField, type FieldDrawing, type FieldValues, type FieldSampler, type FieldStroke } from \"../kit/field-mark\";\nimport { PLOT_COLOR } from \"../kit/furniture\";\nimport { radians } from \"../kit/geometry\";\nimport { inkSize, reading, traced, type MarkReading } from \"../kit/mark\";\n\n/** Past this many arrows the spacing is widened, so a field over a huge range is still a field and not a wash. */\nconst MAX_ARROWS = 2400;\n/** An arrow's head, as a share of its length and in pixels at most, and the half-angle it opens to. */\nconst HEAD_SHARE = 0.38;\nconst HEAD_MAX = 11;\nconst HEAD_ANGLE = radians(26);\n\nconst state = {\n ...FIELD_STATE,\n /** How far apart the arrows stand, in graph units. */\n spacing: Types.number(1, { min: 0.01, step: 0.1 }),\n /** How long an arrow is drawn for a vector of length one, in graph units. */\n arrowScale: Types.number(0.4, { min: 0, step: 0.05 }),\n};\n\ninterface ArrowsValues extends FieldValues {\n readonly spacing: number;\n readonly arrowScale: number;\n}\n\nconst ARROWS: FieldDrawing<ArrowsValues> = {\n own: (s) => `${s.spacing}|${s.arrowScale}`,\n strokes: (s, map, field) => arrows(s, map, field),\n};\n\nconst traceArrows = (s: ArrowsValues, read: MarkReading) => traceField(\"vectorField\", ARROWS, s, read);\n\n/** A grid of arrows showing a vector field, `(-y, x)`: each is centred on its point and as long as the field is strong there, up to the spacing. */\nexport const VectorField = traced(component2d({\n key: \"vectorField\",\n state,\n defaults: { stroke: { weight: 2.5, fill: PLOT_COLOR, align: \"center\", cap: \"round\", join: \"round\" }, width: \"hug\", height: \"hug\" },\n commands: FIELD_COMMANDS,\n measure: (_measurer, s) => inkSize(traceArrows(s, reading(s)).runs),\n render: (ctx, s) => drawField(ctx, s, traceArrows(s, reading(s))),\n}), (s: ArrowsValues, read: MarkReading) => traceArrows(s, read).runs);\n\nexport type VectorField = NodeOf<typeof VectorField>;\n\nfunction arrows(s: ArrowsValues, map: CoordinateMap, field: FieldSampler): FieldStroke[] {\n const [x0, x1] = map.xRange;\n const [y0, y1] = map.yRange;\n let spacing = Math.max(s.spacing, 1e-6);\n const count = () => (Math.floor((x1 - x0) / spacing) + 1) * (Math.floor((y1 - y0) / spacing) + 1);\n while (count() > MAX_ARROWS) spacing *= 2;\n\n const drawn: FieldStroke[] = [];\n const v: Vector2 = { x: 0, y: 0 };\n const longest = spacing * 0.9;\n for (let i = Math.ceil(x0 / spacing - 1e-9); i * spacing <= x1 + 1e-9; i++) {\n for (let j = Math.ceil(y0 / spacing - 1e-9); j * spacing <= y1 + 1e-9; j++) {\n const gx = i * spacing;\n const gy = j * spacing;\n if (!field(gx, gy, v)) continue;\n const magnitude = Math.hypot(v.x, v.y);\n const length = Math.min(magnitude * s.arrowScale, longest);\n if (!(length > 0)) continue;\n const hx = ((v.x / magnitude) * length) / 2;\n const hy = ((v.y / magnitude) * length) / 2;\n const tail = map.toPoint(gx - hx, gy - hy);\n const head = map.toPoint(gx + hx, gy + hy);\n drawn.push({ runs: arrow(tail, head), magnitude });\n }\n }\n return drawn;\n}\n\n/** A shaft and the two barbs of its head, in pixels. */\nfunction arrow(tail: Vector2, head: Vector2): Vector2[][] {\n const dx = head.x - tail.x;\n const dy = head.y - tail.y;\n const length = Math.hypot(dx, dy);\n if (!(length > 0)) return [];\n const barb = Math.min(length * HEAD_SHARE, HEAD_MAX);\n const back = Math.atan2(dy, dx) + Math.PI;\n const at = (angle: number): Vector2 => ({ x: head.x + Math.cos(angle) * barb, y: head.y + Math.sin(angle) * barb });\n return [[tail, head], [at(back - HEAD_ANGLE), head, at(back + HEAD_ANGLE)]];\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Fill, type FillResolved, type NodeOf, type Color as _Color, type NormalizedColor, type ShadowResolved, type Size2D, type Stroke as _Stroke, type StrokeResolved, type Values, type Vector2, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow } from "@motionscript/sdk";
|
|
2
2
|
import { type PartFill, type PartFillResolved } from "../kit/part-fills.js";
|
|
3
3
|
import { type GraphEdge, type GraphLayout } from "./graph-layout.js";
|
|
4
4
|
/** A vertex placed by hand, in the graph's box from -1 to 1 each way, y up. */
|
|
@@ -7,21 +7,6 @@ export interface GraphPosition {
|
|
|
7
7
|
x: number;
|
|
8
8
|
y: number;
|
|
9
9
|
}
|
|
10
|
-
export interface NetworkGraphProps extends PaintProps {
|
|
11
|
-
vertices?: string[];
|
|
12
|
-
edges?: GraphEdge[];
|
|
13
|
-
directed?: boolean;
|
|
14
|
-
arrangement?: GraphLayout;
|
|
15
|
-
root?: string;
|
|
16
|
-
positions?: GraphPosition[];
|
|
17
|
-
vertexRadius?: number;
|
|
18
|
-
vertexStroke?: Stroke;
|
|
19
|
-
labels?: boolean;
|
|
20
|
-
labelSize?: number;
|
|
21
|
-
labelColor?: Color;
|
|
22
|
-
fontFamily?: string;
|
|
23
|
-
partFills?: PartFill[];
|
|
24
|
-
}
|
|
25
10
|
declare const state: {
|
|
26
11
|
vertices: import("@motionscript/sdk").Type<string[], string[], false>;
|
|
27
12
|
edges: import("@motionscript/sdk").Type<GraphEdge[], GraphEdge[], false>;
|
|
@@ -33,10 +18,10 @@ declare const state: {
|
|
|
33
18
|
/** Vertices placed by hand, whatever the layout says, in the box from -1 to 1 each way. */
|
|
34
19
|
positions: import("@motionscript/sdk").Type<GraphPosition[], GraphPosition[], false>;
|
|
35
20
|
vertexRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
36
|
-
vertexStroke: import("@motionscript/sdk").Type<
|
|
21
|
+
vertexStroke: import("@motionscript/sdk").Type<_Stroke, StrokeResolved[], false>;
|
|
37
22
|
labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
38
23
|
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
39
|
-
labelColor: import("@motionscript/sdk").Type<
|
|
24
|
+
labelColor: import("@motionscript/sdk").Type<_Color, NormalizedColor, false>;
|
|
40
25
|
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
41
26
|
/** Paints for a vertex by its name, or an edge written `a-b`, over the graph's own. */
|
|
42
27
|
partFills: import("@motionscript/sdk").Type<PartFill[], PartFillResolved[], false>;
|
|
@@ -44,19 +29,15 @@ declare const state: {
|
|
|
44
29
|
layoutFrom: import("@motionscript/sdk").Type<string, string, true>;
|
|
45
30
|
layoutMix: import("@motionscript/sdk").Type<number, number, true>;
|
|
46
31
|
fill: import("@motionscript/sdk").Attribute<Fill, FillResolved[]>;
|
|
47
|
-
stroke: import("@motionscript/sdk").Attribute<
|
|
32
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, StrokeResolved[]>;
|
|
48
33
|
shadow: import("@motionscript/sdk").Attribute<_Shadow, ShadowResolved[]>;
|
|
49
34
|
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
50
35
|
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
51
36
|
};
|
|
52
|
-
/** What a graph is drawn from: its own entries, as its fields and its node both read them. */
|
|
53
37
|
export type GraphValues = Values<typeof state>;
|
|
54
38
|
/**
|
|
55
|
-
* Vertices and the edges between them, arranged by a rule
|
|
56
|
-
*
|
|
57
|
-
* its `stroke` the edges, with an arrowhead each when `directed`. `arrangeTo`
|
|
58
|
-
* moves every vertex to where another rule places it; `partFillTo` paints a
|
|
59
|
-
* vertex, or an edge written `a-b`. (`layout` is every node's own box.)
|
|
39
|
+
* Vertices and the edges between them, arranged by a rule (circle, springs, tree,
|
|
40
|
+
* grid). Its `fill` is the vertices and its `stroke` the edges. (`layout` is every node's own box.)
|
|
60
41
|
*/
|
|
61
42
|
export declare const NetworkGraph: import("@motionscript/sdk").Component<"networkGraph", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
62
43
|
vertices: import("@motionscript/sdk").Type<string[], string[], false>;
|
|
@@ -69,10 +50,10 @@ export declare const NetworkGraph: import("@motionscript/sdk").Component<"networ
|
|
|
69
50
|
/** Vertices placed by hand, whatever the layout says, in the box from -1 to 1 each way. */
|
|
70
51
|
positions: import("@motionscript/sdk").Type<GraphPosition[], GraphPosition[], false>;
|
|
71
52
|
vertexRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
72
|
-
vertexStroke: import("@motionscript/sdk").Type<
|
|
53
|
+
vertexStroke: import("@motionscript/sdk").Type<_Stroke, StrokeResolved[], false>;
|
|
73
54
|
labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
74
55
|
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
75
|
-
labelColor: import("@motionscript/sdk").Type<
|
|
56
|
+
labelColor: import("@motionscript/sdk").Type<_Color, NormalizedColor, false>;
|
|
76
57
|
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
77
58
|
/** Paints for a vertex by its name, or an edge written `a-b`, over the graph's own. */
|
|
78
59
|
partFills: import("@motionscript/sdk").Type<PartFill[], PartFillResolved[], false>;
|
|
@@ -80,7 +61,7 @@ export declare const NetworkGraph: import("@motionscript/sdk").Component<"networ
|
|
|
80
61
|
layoutFrom: import("@motionscript/sdk").Type<string, string, true>;
|
|
81
62
|
layoutMix: import("@motionscript/sdk").Type<number, number, true>;
|
|
82
63
|
fill: import("@motionscript/sdk").Attribute<Fill, FillResolved[]>;
|
|
83
|
-
stroke: import("@motionscript/sdk").Attribute<
|
|
64
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, StrokeResolved[]>;
|
|
84
65
|
shadow: import("@motionscript/sdk").Attribute<_Shadow, ShadowResolved[]>;
|
|
85
66
|
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
86
67
|
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
@@ -110,10 +91,10 @@ export declare const NetworkGraph: import("@motionscript/sdk").Component<"networ
|
|
|
110
91
|
/** Vertices placed by hand, whatever the layout says, in the box from -1 to 1 each way. */
|
|
111
92
|
positions: import("@motionscript/sdk").Type<GraphPosition[], GraphPosition[], false>;
|
|
112
93
|
vertexRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
113
|
-
vertexStroke: import("@motionscript/sdk").Type<
|
|
94
|
+
vertexStroke: import("@motionscript/sdk").Type<_Stroke, StrokeResolved[], false>;
|
|
114
95
|
labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
115
96
|
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
116
|
-
labelColor: import("@motionscript/sdk").Type<
|
|
97
|
+
labelColor: import("@motionscript/sdk").Type<_Color, NormalizedColor, false>;
|
|
117
98
|
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
118
99
|
/** Paints for a vertex by its name, or an edge written `a-b`, over the graph's own. */
|
|
119
100
|
partFills: import("@motionscript/sdk").Type<PartFill[], PartFillResolved[], false>;
|
|
@@ -121,7 +102,7 @@ export declare const NetworkGraph: import("@motionscript/sdk").Component<"networ
|
|
|
121
102
|
layoutFrom: import("@motionscript/sdk").Type<string, string, true>;
|
|
122
103
|
layoutMix: import("@motionscript/sdk").Type<number, number, true>;
|
|
123
104
|
fill: import("@motionscript/sdk").Attribute<Fill, FillResolved[]>;
|
|
124
|
-
stroke: import("@motionscript/sdk").Attribute<
|
|
105
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, StrokeResolved[]>;
|
|
125
106
|
shadow: import("@motionscript/sdk").Attribute<_Shadow, ShadowResolved[]>;
|
|
126
107
|
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
127
108
|
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
@@ -136,10 +117,10 @@ export declare const NetworkGraph: import("@motionscript/sdk").Component<"networ
|
|
|
136
117
|
/** Vertices placed by hand, whatever the layout says, in the box from -1 to 1 each way. */
|
|
137
118
|
positions: import("@motionscript/sdk").Type<GraphPosition[], GraphPosition[], false>;
|
|
138
119
|
vertexRadius: import("@motionscript/sdk").Type<number, number, false>;
|
|
139
|
-
vertexStroke: import("@motionscript/sdk").Type<
|
|
120
|
+
vertexStroke: import("@motionscript/sdk").Type<_Stroke, StrokeResolved[], false>;
|
|
140
121
|
labels: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
141
122
|
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
142
|
-
labelColor: import("@motionscript/sdk").Type<
|
|
123
|
+
labelColor: import("@motionscript/sdk").Type<_Color, NormalizedColor, false>;
|
|
143
124
|
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
144
125
|
/** Paints for a vertex by its name, or an edge written `a-b`, over the graph's own. */
|
|
145
126
|
partFills: import("@motionscript/sdk").Type<PartFill[], PartFillResolved[], false>;
|
|
@@ -147,7 +128,7 @@ export declare const NetworkGraph: import("@motionscript/sdk").Component<"networ
|
|
|
147
128
|
layoutFrom: import("@motionscript/sdk").Type<string, string, true>;
|
|
148
129
|
layoutMix: import("@motionscript/sdk").Type<number, number, true>;
|
|
149
130
|
fill: import("@motionscript/sdk").Attribute<Fill, FillResolved[]>;
|
|
150
|
-
stroke: import("@motionscript/sdk").Attribute<
|
|
131
|
+
stroke: import("@motionscript/sdk").Attribute<_Stroke, StrokeResolved[]>;
|
|
151
132
|
shadow: import("@motionscript/sdk").Attribute<_Shadow, ShadowResolved[]>;
|
|
152
133
|
start: import("@motionscript/sdk").Type<number, number, false>;
|
|
153
134
|
end: import("@motionscript/sdk").Type<number, number, false>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-graph.d.ts","sourceRoot":"","sources":["../../src/structures/network-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,
|
|
1
|
+
{"version":3,"file":"network-graph.d.ts","sourceRoot":"","sources":["../../src/structures/network-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,KAAK,KAAK,IAAI,MAAM,EAEpB,KAAK,eAAe,EAEpB,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,MAAM,IAAI,OAAO,EAEtB,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,OAAO,EAEZ,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,MAAM,IAAI,OAAO,EACzB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAyD,KAAK,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAChI,OAAO,EAAyB,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEzF,+EAA+E;AAC/E,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACb;AA4BD,QAAA,MAAM,KAAK;;;IAIP,8DAA8D;;;IAG9D,2DAA2D;;IAE3D,2FAA2F;;;;;;;;IAQ3F,uFAAuF;;IAEvF,wFAAwF;;;;;;;;CAG3F,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,KAAK,CAAC,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,YAAY;;;IA1BrB,8DAA8D;;;IAG9D,2DAA2D;;IAE3D,2FAA2F;;;;;;;;IAQ3F,uFAAuF;;IAEvF,wFAAwF;;;;;;;;;;;;;;;;;;;;;;;;;;IAfxF,8DAA8D;;;IAG9D,2DAA2D;;IAE3D,2FAA2F;;;;;;;;IAQ3F,uFAAuF;;IAEvF,wFAAwF;;;;;;;;;;;IAfxF,8DAA8D;;;IAG9D,2DAA2D;;IAE3D,2FAA2F;;;;;;;;IAQ3F,uFAAuF;;IAEvF,wFAAwF;;;;;;;;;;;;;;;;;;;;;;;2BA6C1F,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AAEvD,wFAAwF;AACxF,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAanF"}
|
|
@@ -48,11 +48,8 @@ const state = {
|
|
|
48
48
|
layoutMix: Types.number(1, { private: true }),
|
|
49
49
|
};
|
|
50
50
|
/**
|
|
51
|
-
* Vertices and the edges between them, arranged by a rule
|
|
52
|
-
*
|
|
53
|
-
* its `stroke` the edges, with an arrowhead each when `directed`. `arrangeTo`
|
|
54
|
-
* moves every vertex to where another rule places it; `partFillTo` paints a
|
|
55
|
-
* vertex, or an edge written `a-b`. (`layout` is every node's own box.)
|
|
51
|
+
* Vertices and the edges between them, arranged by a rule (circle, springs, tree,
|
|
52
|
+
* grid). Its `fill` is the vertices and its `stroke` the edges. (`layout` is every node's own box.)
|
|
56
53
|
*/
|
|
57
54
|
export const NetworkGraph = component2d({
|
|
58
55
|
key: "networkGraph",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-graph.js","sourceRoot":"","sources":["../../src/structures/network-graph.ts"],"names":[],"mappings":"AAAA,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KAAK,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,EAAE,CAAC;QAClF,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import {\n component2d,\n Graphics2D,\n Types,\n type Color,\n type Fill,\n type FillResolved,\n type NodeOf,\n type NormalizedColor,\n type PaintProps,\n type RenderContext,\n type ShadowResolved,\n type Size2D,\n type Stroke,\n type StrokeResolved,\n type Values,\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} from \"@motionscript/sdk\";\nimport { createBoundedCache } from \"../kit/cache\";\nimport { listed, PAINT, PAINT_COMMANDS, painted } from \"../kit/component\";\nimport { drawLabels, loadFormulas, type Label } from \"../kit/furniture\";\nimport { lerpPartFills, partPaint, readPartFills, withPartFill, type PartFill, type PartFillResolved } from \"../kit/part-fills\";\nimport { GRAPH_LAYOUTS, layOut, type GraphEdge, type GraphLayout } from \"./graph-layout\";\n\n/** A vertex placed by hand, in the graph's box from -1 to 1 each way, y up. */\nexport interface GraphPosition {\n vertex: string;\n x: number;\n y: number;\n}\n\nexport interface NetworkGraphProps extends PaintProps {\n vertices?: string[];\n edges?: GraphEdge[];\n directed?: boolean;\n arrangement?: GraphLayout;\n root?: string;\n positions?: GraphPosition[];\n vertexRadius?: number;\n vertexStroke?: Stroke;\n labels?: boolean;\n labelSize?: number;\n labelColor?: Color;\n fontFamily?: string;\n partFills?: PartFill[];\n}\n\n// Every list keeps each entry as it was written, a blank or a repeat included, so\n// an editor showing the list shows the row it just added. What is drawn skips\n// what is not complete yet (`names`, `links`).\n\nfunction readVertices(value: readonly unknown[] | undefined): string[] {\n return (Array.isArray(value) ? value : []).map((name) => String(name ?? \"\"));\n}\n\n// An edge reads from `{ from, to }` or a pair, so a list written by hand is as good as one from a table.\nfunction readEdges(value: readonly unknown[] | undefined): GraphEdge[] {\n return (Array.isArray(value) ? value : []).map((edge) => {\n const [from, to] = Array.isArray(edge) ? edge : [(edge as GraphEdge)?.from, (edge as GraphEdge)?.to];\n return { from: String(from ?? \"\"), to: String(to ?? \"\") };\n });\n}\n\nfunction readPositions(value: readonly GraphPosition[] | undefined): GraphPosition[] {\n const at = (n: unknown) => (typeof n === \"number\" && Number.isFinite(n) ? n : 0);\n return (Array.isArray(value) ? value : []).map((entry) => ({ vertex: String(entry?.vertex ?? \"\"), x: at(entry?.x), y: at(entry?.y) }));\n}\n\n/** How far a directed edge and the one back between the same two vertices bow apart, as a share of their length. */\nconst BOW = 0.12;\n\nconst NUL = String.fromCharCode(0);\n\nconst state = {\n ...PAINT,\n vertices: Types.custom<string[]>([], { resolve: readVertices, animatable: false, kind: \"vector\" }),\n edges: Types.custom<GraphEdge[]>([], { resolve: readEdges, animatable: false, kind: \"vector\" }),\n /** Draw each edge as an arrow from its `from` to its `to`. */\n directed: Types.boolean(false, { animatable: false }),\n arrangement: listed(GRAPH_LAYOUTS, \"circular\", { animatable: false }),\n /** The vertex a tree hangs from; left empty, the first. */\n root: Types.text(\"\", { animatable: false }),\n /** Vertices placed by hand, whatever the layout says, in the box from -1 to 1 each way. */\n positions: Types.custom<GraphPosition[]>([], { resolve: readPositions, animatable: false, kind: \"vector\" }),\n vertexRadius: Types.number(18, { min: 0, unit: \"px\" }),\n vertexStroke: Types.stroke([]),\n labels: Types.boolean(true, { animatable: false }),\n labelSize: Types.number(18, { min: 1, unit: \"px\" }),\n labelColor: Types.color(\"#111827\"),\n fontFamily: Types.text(\"\", { animatable: false }),\n /** Paints for a vertex by its name, or an edge written `a-b`, over the graph's own. */\n partFills: Types.custom<PartFill[], PartFillResolved[]>([], { resolve: readPartFills, lerp: lerpPartFills, kind: \"vector\" }),\n /** The arrangement an `arrangeTo` is leaving, and how far it is towards the new one. */\n layoutFrom: Types.text(\"\", { private: true }),\n layoutMix: Types.number(1, { private: true }),\n};\n\n/** What a graph is drawn from: its own entries, as its fields and its node both read them. */\nexport type GraphValues = Values<typeof state>;\n\n/**\n * Vertices and the edges between them, arranged by a rule: in a circle, by\n * springs, as a tree from `root`, or in a grid. Its `fill` is the vertices and\n * its `stroke` the edges, with an arrowhead each when `directed`. `arrangeTo`\n * moves every vertex to where another rule places it; `partFillTo` paints a\n * vertex, or an edge written `a-b`. (`layout` is every node's own box.)\n */\nexport const NetworkGraph = component2d({\n key: \"networkGraph\",\n state,\n defaults: {\n fill: \"#e5e7eb\",\n stroke: { weight: 3, fill: \"#9ca3af\", align: \"center\", cap: \"round\" },\n },\n load: (loader, s) => {\n if (s.fontFamily !== \"\") loader.font(s.fontFamily);\n if (s.labels) loadFormulas(loader, names(s));\n },\n commands: {\n ...PAINT_COMMANDS,\n /** Move every vertex to where another arrangement places it. */\n arrangeTo: {\n // No default: one left out keeps the arrangement the graph has.\n args: { arrangement: listed(GRAPH_LAYOUTS, undefined) },\n run: (timeline, s) => {\n const from = s.arrangement;\n const to = timeline.args.arrangement ?? from;\n return timeline.animate((t) => ({ arrangement: to, layoutFrom: from, layoutMix: t }));\n },\n },\n /** Paint one part of the graph: a vertex by its name, or an edge written `a-b`. */\n partFillTo: {\n args: { part: Types.text(\"\"), fill: Types.custom<Fill>(\"#facc15\", { kind: \"fills\" }) },\n run: (timeline, s) => {\n const { part, fill } = timeline.args;\n if (!part || fill == null) return timeline.tween({});\n return timeline.tween({ partFills: withPartFill(s.partFills, { part, fill }) });\n },\n },\n },\n render: (ctx, s) => painted(ctx, () => drawGraph(ctx, s)),\n});\n\nexport type NetworkGraph = NodeOf<typeof NetworkGraph>;\n\n/** Where each vertex is drawn in a graph of `size`, in pixels from its centre, y up. */\nexport function vertexPoints(graph: GraphValues, size: Size2D): Map<string, Vector2> {\n const room = graph.vertexRadius + Math.max(2, graph.labelSize * 0.2);\n const halfX = Math.max(0, size.width / 2 - room);\n const halfY = Math.max(0, size.height / 2 - room);\n const to = placed(graph, graph.arrangement);\n const from = graph.layoutMix < 1 && graph.layoutFrom !== \"\" ? placed(graph, graph.layoutFrom as GraphLayout) : null;\n const t = graph.layoutMix;\n const out = new Map<string, Vector2>();\n for (const [name, p] of to) {\n const q = from?.get(name) ?? p;\n out.set(name, { x: (q.x + (p.x - q.x) * t) * halfX, y: (q.y + (p.y - q.y) * t) * halfY });\n }\n return out;\n}\n\nfunction drawGraph(ctx: RenderContext, graph: GraphValues): void {\n const points = vertexPoints(graph, ctx.size);\n if (points.size === 0) return;\n const parts = new Map((graph.partFills as PartFillResolved[]).map((entry) => [entry.part, entry]));\n drawEdges(ctx, graph, points, parts);\n drawVertices(ctx, graph, points, parts);\n}\n\n// Two layouts are held at once while one becomes the other, and a scene may hold several graphs.\nconst layouts = createBoundedCache<Map<string, Vector2>>(32);\n\n/** Each vertex's place under `layout`, from -1 to 1, a hand-placed one where it is. */\nfunction placed(graph: GraphValues, layout: GraphLayout): Map<string, Vector2> {\n const vertices = names(graph);\n const edges = links(graph);\n const key = [layout, graph.root, vertices.join(NUL), JSON.stringify(edges), JSON.stringify(graph.positions)].join(\"|\");\n let at = layouts.get(key);\n if (!at) {\n at = layOut(layout, vertices, edges, graph.root.trim());\n for (const { vertex, x, y } of graph.positions) {\n const name = vertex.trim();\n if (at.has(name)) at.set(name, { x, y });\n }\n layouts.set(key, at);\n }\n return at;\n}\n\nfunction drawEdges(ctx: RenderContext, graph: GraphValues, points: Map<string, Vector2>, parts: Map<string, PartFillResolved>): void {\n const stroke = graph.stroke as StrokeResolved[];\n if (stroke.length === 0) return;\n const r = graph.vertexRadius;\n const all = links(graph);\n const pairs = new Set(all.map(({ from, to }) => `${from}${NUL}${to}`));\n const plain = new Graphics2D();\n let drawnPlain = false;\n for (const { from, to } of all) {\n const a = points.get(from);\n const b = points.get(to);\n if (!a || !b) continue;\n const run = from === to ? loop(a, r) : edge(a, b, r, graph.directed && pairs.has(`${to}${NUL}${from}`) ? BOW : 0);\n if (run.length < 2) continue;\n const paint = parts.get(`${from}-${to}`) ?? (graph.directed ? undefined : parts.get(`${to}-${from}`));\n const own = graph.directed || paint !== undefined;\n const g = own ? new Graphics2D() : plain;\n g.line({ points: run, radius: 0, start: graph.start, end: graph.end });\n if (!own) {\n drawnPlain = true;\n continue;\n }\n let layers = stroke;\n if (paint) layers = layers.map((layer) => ({ ...layer, fill: partPaint(layer.fill, paint) }));\n if (graph.directed && from !== to) layers = layers.map((layer) => ({ ...layer, endCap: layer.endCap ?? \"triangle\" }));\n ctx.draw(g.stroke(layers));\n }\n if (drawnPlain) ctx.draw(plain.stroke(stroke));\n}\n\nfunction drawVertices(ctx: RenderContext, graph: GraphValues, points: Map<string, Vector2>, parts: Map<string, PartFillResolved>): void {\n const r = graph.vertexRadius;\n const fill = graph.fill as FillResolved[];\n const outline = graph.vertexStroke as StrokeResolved[];\n const labels: Label[] = [];\n for (const [name, p] of points) {\n if (r > 0) {\n const paint = partPaint(fill, parts.get(name));\n const disc = new Graphics2D().ellipse({ x: p.x, y: p.y, width: r * 2, height: r * 2 });\n ctx.draw(disc.shadow(graph.shadow as ShadowResolved[]).fill(paint));\n if (outline.length > 0) ctx.draw(new Graphics2D().ellipse({ x: p.x, y: p.y, width: r * 2, height: r * 2 }).stroke(outline));\n }\n if (graph.labels) labels.push({ text: name, at: { x: p.x, y: p.y }, align: \"center\" });\n }\n for (const part of drawLabels(labels, { fontSize: graph.labelSize, fontFamily: graph.fontFamily, color: graph.labelColor as NormalizedColor })) {\n ctx.draw(part);\n }\n}\n\n/** The vertices drawn: each name once, trimmed, the blank ones left out. */\nfunction names(graph: Pick<GraphValues, \"vertices\">): string[] {\n return [...new Set(graph.vertices.map((name) => name.trim()).filter((name) => name !== \"\"))];\n}\n\n/** The edges drawn: both ends named. */\nfunction links(graph: Pick<GraphValues, \"edges\">): GraphEdge[] {\n return graph.edges.flatMap(({ from, to }) => {\n const a = from.trim();\n const b = to.trim();\n return a === \"\" || b === \"\" ? [] : [{ from: a, to: b }];\n });\n}\n\n/** An edge from one vertex's rim to the other's, straight or bowed to its left. */\nfunction edge(a: Vector2, b: Vector2, r: number, bow: number): Vector2[] {\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const length = Math.hypot(dx, dy);\n if (!(length > 2 * r)) return [];\n if (bow === 0) {\n const ux = dx / length;\n const uy = dy / length;\n return [{ x: a.x + ux * r, y: a.y + uy * r }, { x: b.x - ux * r, y: b.y - uy * r }];\n }\n const mid = { x: (a.x + b.x) / 2 - (dy / length) * bow * length, y: (a.y + b.y) / 2 + (dx / length) * bow * length };\n const run: Vector2[] = [];\n for (let i = 0; i <= 16; i++) {\n const t = i / 16;\n const u = 1 - t;\n run.push({ x: u * u * a.x + 2 * u * t * mid.x + t * t * b.x, y: u * u * a.y + 2 * u * t * mid.y + t * t * b.y });\n }\n // Trimmed back to the rims along the curve.\n const outside = (p: Vector2, c: Vector2) => Math.hypot(p.x - c.x, p.y - c.y) >= r;\n return run.filter((p) => outside(p, a) && outside(p, b));\n}\n\n/** An edge from a vertex to itself: a small loop above it. */\nfunction loop(c: Vector2, r: number): Vector2[] {\n const run: Vector2[] = [];\n const radius = Math.max(r * 0.8, 6);\n const cy = c.y + r + radius * 0.6;\n for (let i = 0; i <= 24; i++) {\n const angle = -Math.PI / 2 + (2 * Math.PI * i) / 24;\n const p = { x: c.x + Math.cos(angle) * radius, y: cy + Math.sin(angle) * radius };\n if (Math.hypot(p.x - c.x, p.y - c.y) >= r) run.push(p);\n }\n return run;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"network-graph.js","sourceRoot":"","sources":["../../src/structures/network-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,WAAW,EACX,UAAU,EACV,KAAK,GAmBR,MAAM,m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,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,EAAE,CAAC;QAClF,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import {\n component2d,\n Graphics2D,\n Types,\n type Fill,\n type FillResolved,\n type NodeOf,\n type Color as _Color,\n\n type NormalizedColor,\n type RenderContext,\n type ShadowResolved,\n type Size2D,\n type Stroke as _Stroke,\n\n type StrokeResolved,\n type Values,\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} from \"@motionscript/sdk\";\nimport { createBoundedCache } from \"../kit/cache\";\nimport { listed, PAINT, PAINT_COMMANDS, painted } from \"../kit/component\";\nimport { drawLabels, loadFormulas, type Label } from \"../kit/furniture\";\nimport { lerpPartFills, partPaint, readPartFills, withPartFill, type PartFill, type PartFillResolved } from \"../kit/part-fills\";\nimport { GRAPH_LAYOUTS, layOut, type GraphEdge, type GraphLayout } from \"./graph-layout\";\n\n/** A vertex placed by hand, in the graph's box from -1 to 1 each way, y up. */\nexport interface GraphPosition {\n vertex: string;\n x: number;\n y: number;\n}\n\n// Every list keeps each entry as it was written, a blank or a repeat included, so\n// an editor showing the list shows the row it just added. What is drawn skips\n// what is not complete yet (`names`, `links`).\n\nfunction readVertices(value: readonly unknown[] | undefined): string[] {\n return (Array.isArray(value) ? value : []).map((name) => String(name ?? \"\"));\n}\n\n// An edge reads from `{ from, to }` or a pair, so a list written by hand is as good as one from a table.\nfunction readEdges(value: readonly unknown[] | undefined): GraphEdge[] {\n return (Array.isArray(value) ? value : []).map((edge) => {\n const [from, to] = Array.isArray(edge) ? edge : [(edge as GraphEdge)?.from, (edge as GraphEdge)?.to];\n return { from: String(from ?? \"\"), to: String(to ?? \"\") };\n });\n}\n\nfunction readPositions(value: readonly GraphPosition[] | undefined): GraphPosition[] {\n const at = (n: unknown) => (typeof n === \"number\" && Number.isFinite(n) ? n : 0);\n return (Array.isArray(value) ? value : []).map((entry) => ({ vertex: String(entry?.vertex ?? \"\"), x: at(entry?.x), y: at(entry?.y) }));\n}\n\n/** How far a directed edge and the one back between the same two vertices bow apart, as a share of their length. */\nconst BOW = 0.12;\n\nconst NUL = String.fromCharCode(0);\n\nconst state = {\n ...PAINT,\n vertices: Types.custom<string[]>([], { resolve: readVertices, animatable: false, kind: \"vector\" }),\n edges: Types.custom<GraphEdge[]>([], { resolve: readEdges, animatable: false, kind: \"vector\" }),\n /** Draw each edge as an arrow from its `from` to its `to`. */\n directed: Types.boolean(false, { animatable: false }),\n arrangement: listed(GRAPH_LAYOUTS, \"circular\", { animatable: false }),\n /** The vertex a tree hangs from; left empty, the first. */\n root: Types.text(\"\", { animatable: false }),\n /** Vertices placed by hand, whatever the layout says, in the box from -1 to 1 each way. */\n positions: Types.custom<GraphPosition[]>([], { resolve: readPositions, animatable: false, kind: \"vector\" }),\n vertexRadius: Types.number(18, { min: 0, unit: \"px\" }),\n vertexStroke: Types.stroke([]),\n labels: Types.boolean(true, { animatable: false }),\n labelSize: Types.number(18, { min: 1, unit: \"px\" }),\n labelColor: Types.color(\"#111827\"),\n fontFamily: Types.text(\"\", { animatable: false }),\n /** Paints for a vertex by its name, or an edge written `a-b`, over the graph's own. */\n partFills: Types.custom<PartFill[], PartFillResolved[]>([], { resolve: readPartFills, lerp: lerpPartFills, kind: \"vector\" }),\n /** The arrangement an `arrangeTo` is leaving, and how far it is towards the new one. */\n layoutFrom: Types.text(\"\", { private: true }),\n layoutMix: Types.number(1, { private: true }),\n};\n\nexport type GraphValues = Values<typeof state>;\n\n/**\n * Vertices and the edges between them, arranged by a rule (circle, springs, tree,\n * grid). Its `fill` is the vertices and its `stroke` the edges. (`layout` is every node's own box.)\n */\nexport const NetworkGraph = component2d({\n key: \"networkGraph\",\n state,\n defaults: {\n fill: \"#e5e7eb\",\n stroke: { weight: 3, fill: \"#9ca3af\", align: \"center\", cap: \"round\" },\n },\n load: (loader, s) => {\n if (s.fontFamily !== \"\") loader.font(s.fontFamily);\n if (s.labels) loadFormulas(loader, names(s));\n },\n commands: {\n ...PAINT_COMMANDS,\n /** Move every vertex to where another arrangement places it. */\n arrangeTo: {\n // No default: one left out keeps the arrangement the graph has.\n args: { arrangement: listed(GRAPH_LAYOUTS, undefined) },\n run: (timeline, s) => {\n const from = s.arrangement;\n const to = timeline.args.arrangement ?? from;\n return timeline.animate((t) => ({ arrangement: to, layoutFrom: from, layoutMix: t }));\n },\n },\n /** Paint one part of the graph: a vertex by its name, or an edge written `a-b`. */\n partFillTo: {\n args: { part: Types.text(\"\"), fill: Types.custom<Fill>(\"#facc15\", { kind: \"fills\" }) },\n run: (timeline, s) => {\n const { part, fill } = timeline.args;\n if (!part || fill == null) return timeline.tween({});\n return timeline.tween({ partFills: withPartFill(s.partFills, { part, fill }) });\n },\n },\n },\n render: (ctx, s) => painted(ctx, () => drawGraph(ctx, s)),\n});\n\nexport type NetworkGraph = NodeOf<typeof NetworkGraph>;\n\n/** Where each vertex is drawn in a graph of `size`, in pixels from its centre, y up. */\nexport function vertexPoints(graph: GraphValues, size: Size2D): Map<string, Vector2> {\n const room = graph.vertexRadius + Math.max(2, graph.labelSize * 0.2);\n const halfX = Math.max(0, size.width / 2 - room);\n const halfY = Math.max(0, size.height / 2 - room);\n const to = placed(graph, graph.arrangement);\n const from = graph.layoutMix < 1 && graph.layoutFrom !== \"\" ? placed(graph, graph.layoutFrom as GraphLayout) : null;\n const t = graph.layoutMix;\n const out = new Map<string, Vector2>();\n for (const [name, p] of to) {\n const q = from?.get(name) ?? p;\n out.set(name, { x: (q.x + (p.x - q.x) * t) * halfX, y: (q.y + (p.y - q.y) * t) * halfY });\n }\n return out;\n}\n\nfunction drawGraph(ctx: RenderContext, graph: GraphValues): void {\n const points = vertexPoints(graph, ctx.size);\n if (points.size === 0) return;\n const parts = new Map((graph.partFills as PartFillResolved[]).map((entry) => [entry.part, entry]));\n drawEdges(ctx, graph, points, parts);\n drawVertices(ctx, graph, points, parts);\n}\n\n// Two layouts are held at once while one becomes the other, and a scene may hold several graphs.\nconst layouts = createBoundedCache<Map<string, Vector2>>(32);\n\n/** Each vertex's place under `layout`, from -1 to 1, a hand-placed one where it is. */\nfunction placed(graph: GraphValues, layout: GraphLayout): Map<string, Vector2> {\n const vertices = names(graph);\n const edges = links(graph);\n const key = [layout, graph.root, vertices.join(NUL), JSON.stringify(edges), JSON.stringify(graph.positions)].join(\"|\");\n let at = layouts.get(key);\n if (!at) {\n at = layOut(layout, vertices, edges, graph.root.trim());\n for (const { vertex, x, y } of graph.positions) {\n const name = vertex.trim();\n if (at.has(name)) at.set(name, { x, y });\n }\n layouts.set(key, at);\n }\n return at;\n}\n\nfunction drawEdges(ctx: RenderContext, graph: GraphValues, points: Map<string, Vector2>, parts: Map<string, PartFillResolved>): void {\n const stroke = graph.stroke as StrokeResolved[];\n if (stroke.length === 0) return;\n const r = graph.vertexRadius;\n const all = links(graph);\n const pairs = new Set(all.map(({ from, to }) => `${from}${NUL}${to}`));\n const plain = new Graphics2D();\n let drawnPlain = false;\n for (const { from, to } of all) {\n const a = points.get(from);\n const b = points.get(to);\n if (!a || !b) continue;\n const run = from === to ? loop(a, r) : edge(a, b, r, graph.directed && pairs.has(`${to}${NUL}${from}`) ? BOW : 0);\n if (run.length < 2) continue;\n const paint = parts.get(`${from}-${to}`) ?? (graph.directed ? undefined : parts.get(`${to}-${from}`));\n const own = graph.directed || paint !== undefined;\n const g = own ? new Graphics2D() : plain;\n g.line({ points: run, radius: 0, start: graph.start, end: graph.end });\n if (!own) {\n drawnPlain = true;\n continue;\n }\n let layers = stroke;\n if (paint) layers = layers.map((layer) => ({ ...layer, fill: partPaint(layer.fill, paint) }));\n if (graph.directed && from !== to) layers = layers.map((layer) => ({ ...layer, endCap: layer.endCap ?? \"triangle\" }));\n ctx.draw(g.stroke(layers));\n }\n if (drawnPlain) ctx.draw(plain.stroke(stroke));\n}\n\nfunction drawVertices(ctx: RenderContext, graph: GraphValues, points: Map<string, Vector2>, parts: Map<string, PartFillResolved>): void {\n const r = graph.vertexRadius;\n const fill = graph.fill as FillResolved[];\n const outline = graph.vertexStroke as StrokeResolved[];\n const labels: Label[] = [];\n for (const [name, p] of points) {\n if (r > 0) {\n const paint = partPaint(fill, parts.get(name));\n const disc = new Graphics2D().ellipse({ x: p.x, y: p.y, width: r * 2, height: r * 2 });\n ctx.draw(disc.shadow(graph.shadow as ShadowResolved[]).fill(paint));\n if (outline.length > 0) ctx.draw(new Graphics2D().ellipse({ x: p.x, y: p.y, width: r * 2, height: r * 2 }).stroke(outline));\n }\n if (graph.labels) labels.push({ text: name, at: { x: p.x, y: p.y }, align: \"center\" });\n }\n for (const part of drawLabels(labels, { fontSize: graph.labelSize, fontFamily: graph.fontFamily, color: graph.labelColor as NormalizedColor })) {\n ctx.draw(part);\n }\n}\n\n/** The vertices drawn: each name once, trimmed, the blank ones left out. */\nfunction names(graph: Pick<GraphValues, \"vertices\">): string[] {\n return [...new Set(graph.vertices.map((name) => name.trim()).filter((name) => name !== \"\"))];\n}\n\n/** The edges drawn: both ends named. */\nfunction links(graph: Pick<GraphValues, \"edges\">): GraphEdge[] {\n return graph.edges.flatMap(({ from, to }) => {\n const a = from.trim();\n const b = to.trim();\n return a === \"\" || b === \"\" ? [] : [{ from: a, to: b }];\n });\n}\n\n/** An edge from one vertex's rim to the other's, straight or bowed to its left. */\nfunction edge(a: Vector2, b: Vector2, r: number, bow: number): Vector2[] {\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const length = Math.hypot(dx, dy);\n if (!(length > 2 * r)) return [];\n if (bow === 0) {\n const ux = dx / length;\n const uy = dy / length;\n return [{ x: a.x + ux * r, y: a.y + uy * r }, { x: b.x - ux * r, y: b.y - uy * r }];\n }\n const mid = { x: (a.x + b.x) / 2 - (dy / length) * bow * length, y: (a.y + b.y) / 2 + (dx / length) * bow * length };\n const run: Vector2[] = [];\n for (let i = 0; i <= 16; i++) {\n const t = i / 16;\n const u = 1 - t;\n run.push({ x: u * u * a.x + 2 * u * t * mid.x + t * t * b.x, y: u * u * a.y + 2 * u * t * mid.y + t * t * b.y });\n }\n // Trimmed back to the rims along the curve.\n const outside = (p: Vector2, c: Vector2) => Math.hypot(p.x - c.x, p.y - c.y) >= r;\n return run.filter((p) => outside(p, a) && outside(p, b));\n}\n\n/** An edge from a vertex to itself: a small loop above it. */\nfunction loop(c: Vector2, r: number): Vector2[] {\n const run: Vector2[] = [];\n const radius = Math.max(r * 0.8, 6);\n const cy = c.y + r + radius * 0.6;\n for (let i = 0; i <= 24; i++) {\n const angle = -Math.PI / 2 + (2 * Math.PI * i) / 24;\n const p = { x: c.x + Math.cos(angle) * radius, y: cy + Math.sin(angle) * radius };\n if (Math.hypot(p.x - c.x, p.y - c.y) >= r) run.push(p);\n }\n return run;\n}\n"]}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export interface SampleSpaceProps extends PaintProps {
|
|
3
|
-
columnShares?: number[];
|
|
4
|
-
rowShares?: number[];
|
|
5
|
-
columnFills?: Fill[];
|
|
6
|
-
columnLabels?: string[];
|
|
7
|
-
rowLabels?: string[];
|
|
8
|
-
values?: boolean;
|
|
9
|
-
labelSize?: number;
|
|
10
|
-
labelColor?: Color;
|
|
11
|
-
fontFamily?: string;
|
|
12
|
-
}
|
|
1
|
+
import { type Fill, type FillResolved, type NodeOf, type Color as _Color, type NormalizedColor, type ShadowResolved, type Size2D, type StrokeResolved, type Values, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type Stroke as _Stroke } from "@motionscript/sdk";
|
|
13
2
|
declare const state: {
|
|
14
3
|
/** How the whole is shared across, left to right; any numbers, read as shares of their sum. */
|
|
15
4
|
columnShares: import("@motionscript/sdk").Type<number[], number[], false>;
|
|
@@ -23,12 +12,11 @@ declare const state: {
|
|
|
23
12
|
/** Write each part's probability in it. */
|
|
24
13
|
values: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
25
14
|
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
26
|
-
labelColor: import("@motionscript/sdk").Type<
|
|
15
|
+
labelColor: import("@motionscript/sdk").Type<_Color, NormalizedColor, false>;
|
|
27
16
|
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
28
17
|
stroke: import("@motionscript/sdk").Attribute<_Stroke, StrokeResolved[]>;
|
|
29
18
|
shadow: import("@motionscript/sdk").Attribute<_Shadow, ShadowResolved[]>;
|
|
30
19
|
};
|
|
31
|
-
/** What a sample space is drawn from: its own entries, as its fields and its node both read them. */
|
|
32
20
|
export type SampleSpaceValues = Values<typeof state>;
|
|
33
21
|
/** One part of a sample space: its box in pixels from the node's centre, y up, and its probability. */
|
|
34
22
|
export interface SamplePart {
|
|
@@ -41,11 +29,9 @@ export interface SamplePart {
|
|
|
41
29
|
upper: boolean;
|
|
42
30
|
}
|
|
43
31
|
/**
|
|
44
|
-
* A probability's whole
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* Braces name the columns below and the rows on the left; `divideTo` moves the
|
|
48
|
-
* cuts.
|
|
32
|
+
* A probability's whole as a box cut into columns by `columnShares`, each cut
|
|
33
|
+
* again by its `rowShares` entry (P(B | A) above, the rest below): each part's
|
|
34
|
+
* area is its probability.
|
|
49
35
|
*/
|
|
50
36
|
export declare const SampleSpace: import("@motionscript/sdk").Component<"sampleSpace", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
51
37
|
/** How the whole is shared across, left to right; any numbers, read as shares of their sum. */
|
|
@@ -60,7 +46,7 @@ export declare const SampleSpace: import("@motionscript/sdk").Component<"sampleS
|
|
|
60
46
|
/** Write each part's probability in it. */
|
|
61
47
|
values: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
62
48
|
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
63
|
-
labelColor: import("@motionscript/sdk").Type<
|
|
49
|
+
labelColor: import("@motionscript/sdk").Type<_Color, NormalizedColor, false>;
|
|
64
50
|
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
65
51
|
stroke: import("@motionscript/sdk").Attribute<_Stroke, StrokeResolved[]>;
|
|
66
52
|
shadow: import("@motionscript/sdk").Attribute<_Shadow, ShadowResolved[]>;
|
|
@@ -81,7 +67,7 @@ export declare const SampleSpace: import("@motionscript/sdk").Component<"sampleS
|
|
|
81
67
|
/** Write each part's probability in it. */
|
|
82
68
|
values: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
83
69
|
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
84
|
-
labelColor: import("@motionscript/sdk").Type<
|
|
70
|
+
labelColor: import("@motionscript/sdk").Type<_Color, NormalizedColor, false>;
|
|
85
71
|
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
86
72
|
stroke: import("@motionscript/sdk").Attribute<_Stroke, StrokeResolved[]>;
|
|
87
73
|
shadow: import("@motionscript/sdk").Attribute<_Shadow, ShadowResolved[]>;
|
|
@@ -98,7 +84,7 @@ export declare const SampleSpace: import("@motionscript/sdk").Component<"sampleS
|
|
|
98
84
|
/** Write each part's probability in it. */
|
|
99
85
|
values: import("@motionscript/sdk").Type<boolean, boolean, false>;
|
|
100
86
|
labelSize: import("@motionscript/sdk").Type<number, number, false>;
|
|
101
|
-
labelColor: import("@motionscript/sdk").Type<
|
|
87
|
+
labelColor: import("@motionscript/sdk").Type<_Color, NormalizedColor, false>;
|
|
102
88
|
fontFamily: import("@motionscript/sdk").Type<string, string, false>;
|
|
103
89
|
stroke: import("@motionscript/sdk").Attribute<_Stroke, StrokeResolved[]>;
|
|
104
90
|
shadow: import("@motionscript/sdk").Attribute<_Shadow, ShadowResolved[]>;
|