@invinite-org/chartlang-adapter-kit 1.2.1 → 1.4.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 +157 -0
- package/README.md +7 -0
- package/dist/canvas/index.d.ts +5 -0
- package/dist/canvas/index.d.ts.map +1 -0
- package/dist/canvas/index.js +5 -0
- package/dist/canvas/index.js.map +1 -0
- package/dist/canvas/mockContext.d.ts +168 -0
- package/dist/canvas/mockContext.d.ts.map +1 -0
- package/dist/canvas/mockContext.js +198 -0
- package/dist/canvas/mockContext.js.map +1 -0
- package/dist/canvas/paintPrimitive.d.ts +35 -0
- package/dist/canvas/paintPrimitive.d.ts.map +1 -0
- package/dist/canvas/paintPrimitive.js +171 -0
- package/dist/canvas/paintPrimitive.js.map +1 -0
- package/dist/canvas/renderCtx.d.ts +40 -0
- package/dist/canvas/renderCtx.d.ts.map +1 -0
- package/dist/canvas/renderCtx.js +4 -0
- package/dist/canvas/renderCtx.js.map +1 -0
- package/dist/capabilities/capabilities.d.ts +9 -7
- package/dist/capabilities/capabilities.d.ts.map +1 -1
- package/dist/capabilities/capabilities.js +14 -8
- package/dist/capabilities/capabilities.js.map +1 -1
- package/dist/geometry/_lib/arrowhead.d.ts +18 -0
- package/dist/geometry/_lib/arrowhead.d.ts.map +1 -0
- package/dist/geometry/_lib/arrowhead.js +38 -0
- package/dist/geometry/_lib/arrowhead.js.map +1 -0
- package/dist/geometry/_lib/bezier.d.ts +57 -0
- package/dist/geometry/_lib/bezier.d.ts.map +1 -0
- package/dist/geometry/_lib/bezier.js +84 -0
- package/dist/geometry/_lib/bezier.js.map +1 -0
- package/dist/geometry/_lib/chevron.d.ts +29 -0
- package/dist/geometry/_lib/chevron.d.ts.map +1 -0
- package/dist/geometry/_lib/chevron.js +37 -0
- package/dist/geometry/_lib/chevron.js.map +1 -0
- package/dist/geometry/_lib/dash.d.ts +30 -0
- package/dist/geometry/_lib/dash.d.ts.map +1 -0
- package/dist/geometry/_lib/dash.js +40 -0
- package/dist/geometry/_lib/dash.js.map +1 -0
- package/dist/geometry/_lib/fibLevels.d.ts +36 -0
- package/dist/geometry/_lib/fibLevels.d.ts.map +1 -0
- package/dist/geometry/_lib/fibLevels.js +44 -0
- package/dist/geometry/_lib/fibLevels.js.map +1 -0
- package/dist/geometry/_lib/gannLevels.d.ts +54 -0
- package/dist/geometry/_lib/gannLevels.d.ts.map +1 -0
- package/dist/geometry/_lib/gannLevels.js +88 -0
- package/dist/geometry/_lib/gannLevels.js.map +1 -0
- package/dist/geometry/_lib/lineExtend.d.ts +31 -0
- package/dist/geometry/_lib/lineExtend.d.ts.map +1 -0
- package/dist/geometry/_lib/lineExtend.js +48 -0
- package/dist/geometry/_lib/lineExtend.js.map +1 -0
- package/dist/geometry/_lib/namedPolyline.d.ts +25 -0
- package/dist/geometry/_lib/namedPolyline.d.ts.map +1 -0
- package/dist/geometry/_lib/namedPolyline.js +64 -0
- package/dist/geometry/_lib/namedPolyline.js.map +1 -0
- package/dist/geometry/_lib/pitchforkGeom.d.ts +46 -0
- package/dist/geometry/_lib/pitchforkGeom.d.ts.map +1 -0
- package/dist/geometry/_lib/pitchforkGeom.js +70 -0
- package/dist/geometry/_lib/pitchforkGeom.js.map +1 -0
- package/dist/geometry/_lib/shapeStyle.d.ts +21 -0
- package/dist/geometry/_lib/shapeStyle.d.ts.map +1 -0
- package/dist/geometry/_lib/shapeStyle.js +41 -0
- package/dist/geometry/_lib/shapeStyle.js.map +1 -0
- package/dist/geometry/_lib/strokeStyle.d.ts +34 -0
- package/dist/geometry/_lib/strokeStyle.d.ts.map +1 -0
- package/dist/geometry/_lib/strokeStyle.js +26 -0
- package/dist/geometry/_lib/strokeStyle.js.map +1 -0
- package/dist/geometry/_lib/textStyle.d.ts +70 -0
- package/dist/geometry/_lib/textStyle.d.ts.map +1 -0
- package/dist/geometry/_lib/textStyle.js +78 -0
- package/dist/geometry/_lib/textStyle.js.map +1 -0
- package/dist/geometry/decompose.d.ts +28 -0
- package/dist/geometry/decompose.d.ts.map +1 -0
- package/dist/geometry/decompose.js +176 -0
- package/dist/geometry/decompose.js.map +1 -0
- package/dist/geometry/index.d.ts +4 -0
- package/dist/geometry/index.d.ts.map +1 -0
- package/dist/geometry/index.js +5 -0
- package/dist/geometry/index.js.map +1 -0
- package/dist/geometry/kinds/annotations.d.ts +77 -0
- package/dist/geometry/kinds/annotations.d.ts.map +1 -0
- package/dist/geometry/kinds/annotations.js +219 -0
- package/dist/geometry/kinds/annotations.js.map +1 -0
- package/dist/geometry/kinds/boxes.d.ts +116 -0
- package/dist/geometry/kinds/boxes.d.ts.map +1 -0
- package/dist/geometry/kinds/boxes.js +285 -0
- package/dist/geometry/kinds/boxes.js.map +1 -0
- package/dist/geometry/kinds/channels.d.ts +72 -0
- package/dist/geometry/kinds/channels.d.ts.map +1 -0
- package/dist/geometry/kinds/channels.js +148 -0
- package/dist/geometry/kinds/channels.js.map +1 -0
- package/dist/geometry/kinds/containers.d.ts +54 -0
- package/dist/geometry/kinds/containers.d.ts.map +1 -0
- package/dist/geometry/kinds/containers.js +268 -0
- package/dist/geometry/kinds/containers.js.map +1 -0
- package/dist/geometry/kinds/curves.d.ts +53 -0
- package/dist/geometry/kinds/curves.d.ts.map +1 -0
- package/dist/geometry/kinds/curves.js +110 -0
- package/dist/geometry/kinds/curves.js.map +1 -0
- package/dist/geometry/kinds/cycles.d.ts +52 -0
- package/dist/geometry/kinds/cycles.d.ts.map +1 -0
- package/dist/geometry/kinds/cycles.js +158 -0
- package/dist/geometry/kinds/cycles.js.map +1 -0
- package/dist/geometry/kinds/elliott.d.ts +73 -0
- package/dist/geometry/kinds/elliott.d.ts.map +1 -0
- package/dist/geometry/kinds/elliott.js +116 -0
- package/dist/geometry/kinds/elliott.js.map +1 -0
- package/dist/geometry/kinds/fibonacci.d.ts +166 -0
- package/dist/geometry/kinds/fibonacci.d.ts.map +1 -0
- package/dist/geometry/kinds/fibonacci.js +458 -0
- package/dist/geometry/kinds/fibonacci.js.map +1 -0
- package/dist/geometry/kinds/freehand.d.ts +53 -0
- package/dist/geometry/kinds/freehand.d.ts.map +1 -0
- package/dist/geometry/kinds/freehand.js +115 -0
- package/dist/geometry/kinds/freehand.js.map +1 -0
- package/dist/geometry/kinds/gann.d.ts +63 -0
- package/dist/geometry/kinds/gann.d.ts.map +1 -0
- package/dist/geometry/kinds/gann.js +153 -0
- package/dist/geometry/kinds/gann.js.map +1 -0
- package/dist/geometry/kinds/lines.d.ts +90 -0
- package/dist/geometry/kinds/lines.d.ts.map +1 -0
- package/dist/geometry/kinds/lines.js +201 -0
- package/dist/geometry/kinds/lines.js.map +1 -0
- package/dist/geometry/kinds/marker.d.ts +21 -0
- package/dist/geometry/kinds/marker.d.ts.map +1 -0
- package/dist/geometry/kinds/marker.js +47 -0
- package/dist/geometry/kinds/marker.js.map +1 -0
- package/dist/geometry/kinds/patterns.d.ts +85 -0
- package/dist/geometry/kinds/patterns.d.ts.map +1 -0
- package/dist/geometry/kinds/patterns.js +133 -0
- package/dist/geometry/kinds/patterns.js.map +1 -0
- package/dist/geometry/kinds/pitchforks.d.ts +36 -0
- package/dist/geometry/kinds/pitchforks.d.ts.map +1 -0
- package/dist/geometry/kinds/pitchforks.js +109 -0
- package/dist/geometry/kinds/pitchforks.js.map +1 -0
- package/dist/geometry/project.d.ts +50 -0
- package/dist/geometry/project.d.ts.map +1 -0
- package/dist/geometry/project.js +62 -0
- package/dist/geometry/project.js.map +1 -0
- package/dist/geometry/types.d.ts +146 -0
- package/dist/geometry/types.d.ts.map +1 -0
- package/dist/geometry/types.js +4 -0
- package/dist/geometry/types.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +54 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/validation/validateEmission.d.ts.map +1 -1
- package/dist/validation/validateEmission.js +47 -0
- package/dist/validation/validateEmission.js.map +1 -1
- package/package.json +9 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channels.js","sourceRoot":"","sources":["../../../src/geometry/kinds/channels.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAC/D,EAAE;AACF,wEAAwE;AACxE,6DAA6D;AAC7D,uDAAuD;AACvD,uEAAuE;AACvE,oDAAoD;AACpD,qEAAqE;AACrE,qBAAqB;AASrB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B;;;GAGG;AACH,MAAM,wBAAwB,GAAG,SAAS,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,qBAAqB,CACjC,KAAwB,EACxB,IAAc;IAEd,MAAM,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACpD,MAAM,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACvD,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACxB,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACxB,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrC,OAAO;QACH,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAA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AAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;KAC9D,CAAC;AACN,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,wBAAwB,CACpC,KAA2B,EAC3B,IAAc;IAEd,MAAM,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACpD,MAAM,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACpD,OAAO;QACH;YACI,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YACd,MAAM,EAAE,KAAK;YACb,MAAM,EAAE;gBACJ,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,wBAAwB;gBACpD,KAAK,EAAE,kBAAkB;gBACzB,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC;aAC7B;SACJ;KACJ,CAAC;AACN,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n//\n// Channel geometry moved from the canvas2d adapter's per-kind renderers\n// examples/canvas2d-adapter/src/render/draw/{trendChannel,\n// flatTopBottom,disjointChannel,regressionTrend}.ts.\n// The originating math is invinite's trend-channel / flat-top-bottom /\n// disjoint-channel / regression-trend tools (commit\n// 078f41fe2569d659d5aba726da8bcb5d3e2ced02, © Invinite); re-licensed\n// MIT for chartlang.\n\nimport type {\n DisjointChannelState,\n FlatTopBottomState,\n RegressionTrendState,\n TrendChannelState,\n} from \"@invinite-org/chartlang-core\";\n\nimport { dashPattern } from \"../_lib/dash.js\";\nimport { strokeOf } from \"../_lib/strokeStyle.js\";\nimport { worldPointToPixel } from \"../project.js\";\nimport type { DrawPrimitive, Viewport } from \"../types.js\";\n\nconst DEFAULT_LINE_WIDTH = 1;\n\n/**\n * Default stroke colour of a `regression-trend` placeholder line —\n * `#3b82f6`, matching the canvas2d source renderer.\n */\nconst REGRESSION_DEFAULT_COLOR = \"#3b82f6\";\n\n/**\n * Decompose a `trend-channel` drawing — two parallel line segments. The\n * primary rail runs `anchors[0]` → `anchors[1]`; the second rail is its\n * translate by the offset vector `anchors[2] − anchors[0]`, keeping the\n * pair strictly parallel. Stroke-only — `LineDrawStyle` carries no fill,\n * so there is no inter-rail band (matching the canvas2d source).\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: TrendChannelState;\n * declare const v: Viewport;\n * const prims = decomposeTrendChannel(s, v);\n * // prims.length === 2\n * void prims;\n */\nexport function decomposeTrendChannel(\n state: TrendChannelState,\n view: Viewport,\n): ReadonlyArray<DrawPrimitive> {\n const a = worldPointToPixel(state.anchors[0], view);\n const b = worldPointToPixel(state.anchors[1], view);\n const hook = worldPointToPixel(state.anchors[2], view);\n const dx = hook.x - a.x;\n const dy = hook.y - a.y;\n const stroke = strokeOf(state.style);\n return [\n { kind: \"polyline\", points: [a, b], closed: false, stroke },\n {\n kind: \"polyline\",\n points: [\n { x: a.x + dx, y: a.y + dy },\n { x: b.x + dx, y: b.y + dy },\n ],\n closed: false,\n stroke,\n },\n ];\n}\n\n/**\n * Decompose a `flat-top-bottom` drawing — two horizontal rails. The top\n * rail sits at `max(anchors[0].price, anchors[2].price)` and the bottom\n * at `min(...)`; both span the time range `anchors[0].time` →\n * `anchors[1].time`. Stroke-only.\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: FlatTopBottomState;\n * declare const v: Viewport;\n * const prims = decomposeFlatTopBottom(s, v);\n * // prims.length === 2\n * void prims;\n */\nexport function decomposeFlatTopBottom(\n state: FlatTopBottomState,\n view: Viewport,\n): ReadonlyArray<DrawPrimitive> {\n const p0 = state.anchors[0];\n const p1 = state.anchors[1];\n const p2 = state.anchors[2];\n const topPrice = Math.max(p0.price, p2.price);\n const bottomPrice = Math.min(p0.price, p2.price);\n const topLeft = worldPointToPixel({ time: p0.time, price: topPrice }, view);\n const topRight = worldPointToPixel({ time: p1.time, price: topPrice }, view);\n const bottomLeft = worldPointToPixel({ time: p0.time, price: bottomPrice }, view);\n const bottomRight = worldPointToPixel({ time: p1.time, price: bottomPrice }, view);\n const stroke = strokeOf(state.style);\n return [\n { kind: \"polyline\", points: [topLeft, topRight], closed: false, stroke },\n { kind: \"polyline\", points: [bottomLeft, bottomRight], closed: false, stroke },\n ];\n}\n\n/**\n * Decompose a `disjoint-channel` drawing — two independent line segments\n * with no shared geometry constraint: `anchors[0]` → `anchors[1]` and\n * `anchors[2]` → `anchors[3]`. Stroke-only.\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: DisjointChannelState;\n * declare const v: Viewport;\n * const prims = decomposeDisjointChannel(s, v);\n * // prims.length === 2\n * void prims;\n */\nexport function decomposeDisjointChannel(\n state: DisjointChannelState,\n view: Viewport,\n): ReadonlyArray<DrawPrimitive> {\n const a = worldPointToPixel(state.anchors[0], view);\n const b = worldPointToPixel(state.anchors[1], view);\n const c = worldPointToPixel(state.anchors[2], view);\n const d = worldPointToPixel(state.anchors[3], view);\n const stroke = strokeOf(state.style);\n return [\n { kind: \"polyline\", points: [a, b], closed: false, stroke },\n { kind: \"polyline\", points: [c, d], closed: false, stroke },\n ];\n}\n\n/**\n * Decompose a `regression-trend` drawing — a single placeholder line\n * between the two anchors, colour `style.color ?? \"#3b82f6\"`, width 1,\n * solid. The OLS fit + ±σ bands the `RegressionTrendOpts` flags\n * (`source` / `stdevMultiplier` / `showUpperBand` / `showLowerBand`)\n * describe require a bar buffer the `Viewport` does not expose and band\n * anchors the 2-point `state.anchors` does not carry; the canvas2d\n * source renders the same placeholder line, so this decomposer preserves\n * that geometry. Those style fields are accepted but unused here —\n * consumer adapters with a bar buffer can compute the fit themselves.\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: RegressionTrendState;\n * declare const v: Viewport;\n * const prims = decomposeRegressionTrend(s, v);\n * // prims.length === 1; prims[0].kind === \"polyline\"\n * void prims;\n */\nexport function decomposeRegressionTrend(\n state: RegressionTrendState,\n view: Viewport,\n): ReadonlyArray<DrawPrimitive> {\n const a = worldPointToPixel(state.anchors[0], view);\n const b = worldPointToPixel(state.anchors[1], view);\n return [\n {\n kind: \"polyline\",\n points: [a, b],\n closed: false,\n stroke: {\n color: state.style.color ?? REGRESSION_DEFAULT_COLOR,\n width: DEFAULT_LINE_WIDTH,\n dash: dashPattern(\"solid\"),\n },\n },\n ];\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { FrameState, GroupState, TableState } from "@invinite-org/chartlang-core";
|
|
2
|
+
import type { DrawPrimitive, Viewport } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Decompose a `group` drawing — a no-op container. Groups are
|
|
5
|
+
* metadata-only on the wire: `childHandleIds` reference drawings that
|
|
6
|
+
* decompose through their own arms, and the `Viewport` exposes no
|
|
7
|
+
* child-state side-channel, so a group emits nothing.
|
|
8
|
+
*
|
|
9
|
+
* @since 1.3
|
|
10
|
+
* @stable
|
|
11
|
+
* @example
|
|
12
|
+
* declare const s: GroupState;
|
|
13
|
+
* declare const v: Viewport;
|
|
14
|
+
* const prims = decomposeGroup(s, v);
|
|
15
|
+
* // prims.length === 0
|
|
16
|
+
* void prims;
|
|
17
|
+
*/
|
|
18
|
+
export declare function decomposeGroup(state: GroupState, view: Viewport): ReadonlyArray<DrawPrimitive>;
|
|
19
|
+
/**
|
|
20
|
+
* Decompose a `frame` drawing — a stroked rectangle between the two
|
|
21
|
+
* world anchors `[topLeft, bottomRight]`. An optional `style.bgColor`
|
|
22
|
+
* adds a background `fill` (alpha 1) on the border polyline; an optional
|
|
23
|
+
* `style.label` adds a `text` primitive at the top-left corner.
|
|
24
|
+
* Degenerate anchors (zero width/height, or non-finite) emit `[]`.
|
|
25
|
+
*
|
|
26
|
+
* @since 1.3
|
|
27
|
+
* @stable
|
|
28
|
+
* @example
|
|
29
|
+
* declare const s: FrameState;
|
|
30
|
+
* declare const v: Viewport;
|
|
31
|
+
* const prims = decomposeFrame(s, v);
|
|
32
|
+
* void prims;
|
|
33
|
+
*/
|
|
34
|
+
export declare function decomposeFrame(state: FrameState, view: Viewport): ReadonlyArray<DrawPrimitive>;
|
|
35
|
+
/**
|
|
36
|
+
* Decompose a `draw.table` emission as a CSS-pixel viewport overlay.
|
|
37
|
+
* Unlike every other kind, `table` ignores world-coordinate transforms:
|
|
38
|
+
* `state.position` resolves directly against `Viewport.pxWidth` /
|
|
39
|
+
* `Viewport.pxHeight`. Each cell emits a background-fill polyline + a
|
|
40
|
+
* `text` primitive (+ an optional per-cell border polyline when both
|
|
41
|
+
* `borderColor` and `borderWidth` are set); an optional outer `frame`
|
|
42
|
+
* polyline wraps the whole grid. Zero rows/columns yields a degenerate
|
|
43
|
+
* (possibly empty) grid without throwing.
|
|
44
|
+
*
|
|
45
|
+
* @since 1.3
|
|
46
|
+
* @stable
|
|
47
|
+
* @example
|
|
48
|
+
* declare const s: TableState;
|
|
49
|
+
* declare const v: Viewport;
|
|
50
|
+
* const prims = decomposeTable(s, v);
|
|
51
|
+
* void prims;
|
|
52
|
+
*/
|
|
53
|
+
export declare function decomposeTable(state: TableState, view: Viewport): ReadonlyArray<DrawPrimitive>;
|
|
54
|
+
//# sourceMappingURL=containers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containers.d.ts","sourceRoot":"","sources":["../../../src/geometry/kinds/containers.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACR,UAAU,EACV,UAAU,EAGV,UAAU,EACb,MAAM,8BAA8B,CAAC;AAItC,OAAO,KAAK,EAAE,aAAa,EAA0B,QAAQ,EAAE,MAAM,aAAa,CAAC;AAMnF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC,aAAa,CAAC,CAI9F;AAWD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC,aAAa,CAAC,CAyC9F;AAuID;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC,aAAa,CAAC,CA4D9F"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
|
+
// See the LICENSE file in the repo root for full license text.
|
|
3
|
+
//
|
|
4
|
+
// Container + table geometry moved from the canvas2d adapter's per-kind
|
|
5
|
+
// renderers
|
|
6
|
+
// examples/canvas2d-adapter/src/render/draw/{group,frame,table}.ts.
|
|
7
|
+
// `group` / `frame` state shapes originate from invinite's collab
|
|
8
|
+
// y-doc-bridge (commit 078f41fe2569d659d5aba726da8bcb5d3e2ced02,
|
|
9
|
+
// © Invinite); the frame envelope + table layout are chartlang
|
|
10
|
+
// additions. Re-licensed MIT for chartlang.
|
|
11
|
+
import { SOLID_DASH } from "../_lib/dash.js";
|
|
12
|
+
import { worldPointToPixel } from "../project.js";
|
|
13
|
+
const FILL_OPAQUE = 1;
|
|
14
|
+
// --- group ---------------------------------------------------------------
|
|
15
|
+
/**
|
|
16
|
+
* Decompose a `group` drawing — a no-op container. Groups are
|
|
17
|
+
* metadata-only on the wire: `childHandleIds` reference drawings that
|
|
18
|
+
* decompose through their own arms, and the `Viewport` exposes no
|
|
19
|
+
* child-state side-channel, so a group emits nothing.
|
|
20
|
+
*
|
|
21
|
+
* @since 1.3
|
|
22
|
+
* @stable
|
|
23
|
+
* @example
|
|
24
|
+
* declare const s: GroupState;
|
|
25
|
+
* declare const v: Viewport;
|
|
26
|
+
* const prims = decomposeGroup(s, v);
|
|
27
|
+
* // prims.length === 0
|
|
28
|
+
* void prims;
|
|
29
|
+
*/
|
|
30
|
+
export function decomposeGroup(state, view) {
|
|
31
|
+
void state;
|
|
32
|
+
void view;
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
// --- frame ---------------------------------------------------------------
|
|
36
|
+
const FRAME_STROKE = "#64748b";
|
|
37
|
+
const FRAME_LABEL_COLOR = "#1e293b";
|
|
38
|
+
const FRAME_LINE_WIDTH = 1;
|
|
39
|
+
const FRAME_LABEL_FONT = "12px sans-serif";
|
|
40
|
+
const FRAME_LABEL_INSET_X = 6;
|
|
41
|
+
const FRAME_LABEL_INSET_Y = 14;
|
|
42
|
+
/**
|
|
43
|
+
* Decompose a `frame` drawing — a stroked rectangle between the two
|
|
44
|
+
* world anchors `[topLeft, bottomRight]`. An optional `style.bgColor`
|
|
45
|
+
* adds a background `fill` (alpha 1) on the border polyline; an optional
|
|
46
|
+
* `style.label` adds a `text` primitive at the top-left corner.
|
|
47
|
+
* Degenerate anchors (zero width/height, or non-finite) emit `[]`.
|
|
48
|
+
*
|
|
49
|
+
* @since 1.3
|
|
50
|
+
* @stable
|
|
51
|
+
* @example
|
|
52
|
+
* declare const s: FrameState;
|
|
53
|
+
* declare const v: Viewport;
|
|
54
|
+
* const prims = decomposeFrame(s, v);
|
|
55
|
+
* void prims;
|
|
56
|
+
*/
|
|
57
|
+
export function decomposeFrame(state, view) {
|
|
58
|
+
const a = worldPointToPixel(state.anchors[0], view);
|
|
59
|
+
const b = worldPointToPixel(state.anchors[1], view);
|
|
60
|
+
const xMin = Math.min(a.x, b.x);
|
|
61
|
+
const xMax = Math.max(a.x, b.x);
|
|
62
|
+
const yMin = Math.min(a.y, b.y);
|
|
63
|
+
const yMax = Math.max(a.y, b.y);
|
|
64
|
+
const width = xMax - xMin;
|
|
65
|
+
const height = yMax - yMin;
|
|
66
|
+
if (width === 0 || height === 0)
|
|
67
|
+
return [];
|
|
68
|
+
if (!Number.isFinite(width) || !Number.isFinite(height))
|
|
69
|
+
return [];
|
|
70
|
+
const fill = state.style.bgColor !== undefined
|
|
71
|
+
? { color: state.style.bgColor, alpha: FILL_OPAQUE }
|
|
72
|
+
: undefined;
|
|
73
|
+
const border = {
|
|
74
|
+
kind: "polyline",
|
|
75
|
+
points: [
|
|
76
|
+
{ x: xMin, y: yMin },
|
|
77
|
+
{ x: xMax, y: yMin },
|
|
78
|
+
{ x: xMax, y: yMax },
|
|
79
|
+
{ x: xMin, y: yMax },
|
|
80
|
+
],
|
|
81
|
+
closed: true,
|
|
82
|
+
stroke: { color: FRAME_STROKE, width: FRAME_LINE_WIDTH, dash: SOLID_DASH },
|
|
83
|
+
...(fill !== undefined ? { fill } : {}),
|
|
84
|
+
};
|
|
85
|
+
const out = [border];
|
|
86
|
+
if (state.style.label !== undefined) {
|
|
87
|
+
out.push({
|
|
88
|
+
kind: "text",
|
|
89
|
+
x: xMin + FRAME_LABEL_INSET_X,
|
|
90
|
+
y: yMin + FRAME_LABEL_INSET_Y,
|
|
91
|
+
text: state.style.label,
|
|
92
|
+
color: FRAME_LABEL_COLOR,
|
|
93
|
+
font: FRAME_LABEL_FONT,
|
|
94
|
+
align: "left",
|
|
95
|
+
baseline: "bottom",
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
// --- table ---------------------------------------------------------------
|
|
101
|
+
const TABLE_VIEWPORT_PADDING_PX = 8;
|
|
102
|
+
const TABLE_CELL_PAD_X_PX = 6;
|
|
103
|
+
const TABLE_CELL_PAD_Y_PX = 4;
|
|
104
|
+
const TABLE_DEFAULT_TEXT_COLOR = "#0f172a";
|
|
105
|
+
const TABLE_DEFAULT_BG_COLOR = "#ffffff";
|
|
106
|
+
const TABLE_FONT_FAMILY = "sans-serif";
|
|
107
|
+
const TABLE_TEXT_SIZE_PX = {
|
|
108
|
+
tiny: 8,
|
|
109
|
+
small: 10,
|
|
110
|
+
normal: 12,
|
|
111
|
+
large: 16,
|
|
112
|
+
huge: 24,
|
|
113
|
+
};
|
|
114
|
+
function tableTextSizePx(cell) {
|
|
115
|
+
return TABLE_TEXT_SIZE_PX[cell.textSize ?? "normal"];
|
|
116
|
+
}
|
|
117
|
+
function estimateTextWidth(text, fontPx) {
|
|
118
|
+
return text.length * fontPx * 0.6;
|
|
119
|
+
}
|
|
120
|
+
function columnCount(rows) {
|
|
121
|
+
let count = 0;
|
|
122
|
+
for (const row of rows) {
|
|
123
|
+
if (row.length > count)
|
|
124
|
+
count = row.length;
|
|
125
|
+
}
|
|
126
|
+
return count;
|
|
127
|
+
}
|
|
128
|
+
function resolveTableX(position, tableWidth, view) {
|
|
129
|
+
if (position.endsWith("-center"))
|
|
130
|
+
return view.pxWidth / 2 - tableWidth / 2;
|
|
131
|
+
if (position.endsWith("-right"))
|
|
132
|
+
return view.pxWidth - tableWidth - TABLE_VIEWPORT_PADDING_PX;
|
|
133
|
+
return TABLE_VIEWPORT_PADDING_PX;
|
|
134
|
+
}
|
|
135
|
+
function resolveTableY(position, tableHeight, view) {
|
|
136
|
+
if (position.startsWith("middle-"))
|
|
137
|
+
return view.pxHeight / 2 - tableHeight / 2;
|
|
138
|
+
if (position.startsWith("bottom-"))
|
|
139
|
+
return view.pxHeight - tableHeight - TABLE_VIEWPORT_PADDING_PX;
|
|
140
|
+
return TABLE_VIEWPORT_PADDING_PX;
|
|
141
|
+
}
|
|
142
|
+
function layoutTable(state, view) {
|
|
143
|
+
const columns = columnCount(state.cells);
|
|
144
|
+
const columnWidths = Array.from({ length: columns }, () => 0);
|
|
145
|
+
const rowHeights = state.cells.map((row) => {
|
|
146
|
+
let maxFont = TABLE_TEXT_SIZE_PX.normal;
|
|
147
|
+
for (let column = 0; column < row.length; column++) {
|
|
148
|
+
const cell = row[column];
|
|
149
|
+
const fontPx = tableTextSizePx(cell);
|
|
150
|
+
if (fontPx > maxFont)
|
|
151
|
+
maxFont = fontPx;
|
|
152
|
+
const width = estimateTextWidth(cell.text, fontPx) + TABLE_CELL_PAD_X_PX * 2;
|
|
153
|
+
if (width > columnWidths[column])
|
|
154
|
+
columnWidths[column] = width;
|
|
155
|
+
}
|
|
156
|
+
return maxFont + TABLE_CELL_PAD_Y_PX * 2;
|
|
157
|
+
});
|
|
158
|
+
const width = columnWidths.reduce((sum, widthPx) => sum + widthPx, 0);
|
|
159
|
+
const height = rowHeights.reduce((sum, heightPx) => sum + heightPx, 0);
|
|
160
|
+
return {
|
|
161
|
+
x: resolveTableX(state.position, width, view),
|
|
162
|
+
y: resolveTableY(state.position, height, view),
|
|
163
|
+
width,
|
|
164
|
+
height,
|
|
165
|
+
columnWidths,
|
|
166
|
+
rowHeights,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function rectPolyline(x, y, width, height, stroke, fill) {
|
|
170
|
+
return {
|
|
171
|
+
kind: "polyline",
|
|
172
|
+
points: [
|
|
173
|
+
{ x, y },
|
|
174
|
+
{ x: x + width, y },
|
|
175
|
+
{ x: x + width, y: y + height },
|
|
176
|
+
{ x, y: y + height },
|
|
177
|
+
],
|
|
178
|
+
closed: true,
|
|
179
|
+
...(stroke !== undefined ? { stroke } : {}),
|
|
180
|
+
...(fill !== undefined ? { fill } : {}),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function cellTextX(cell, x, width) {
|
|
184
|
+
switch (cell.textHalign ?? "left") {
|
|
185
|
+
case "center":
|
|
186
|
+
return x + width / 2;
|
|
187
|
+
case "right":
|
|
188
|
+
return x + width - TABLE_CELL_PAD_X_PX;
|
|
189
|
+
case "left":
|
|
190
|
+
return x + TABLE_CELL_PAD_X_PX;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function cellTextY(cell, y, height) {
|
|
194
|
+
switch (cell.textValign ?? "middle") {
|
|
195
|
+
case "top":
|
|
196
|
+
return y + TABLE_CELL_PAD_Y_PX;
|
|
197
|
+
case "bottom":
|
|
198
|
+
return y + height - TABLE_CELL_PAD_Y_PX;
|
|
199
|
+
case "middle":
|
|
200
|
+
return y + height / 2;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function cellAlign(cell) {
|
|
204
|
+
return cell.textHalign ?? "left";
|
|
205
|
+
}
|
|
206
|
+
function cellBaseline(cell) {
|
|
207
|
+
return cell.textValign ?? "middle";
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Decompose a `draw.table` emission as a CSS-pixel viewport overlay.
|
|
211
|
+
* Unlike every other kind, `table` ignores world-coordinate transforms:
|
|
212
|
+
* `state.position` resolves directly against `Viewport.pxWidth` /
|
|
213
|
+
* `Viewport.pxHeight`. Each cell emits a background-fill polyline + a
|
|
214
|
+
* `text` primitive (+ an optional per-cell border polyline when both
|
|
215
|
+
* `borderColor` and `borderWidth` are set); an optional outer `frame`
|
|
216
|
+
* polyline wraps the whole grid. Zero rows/columns yields a degenerate
|
|
217
|
+
* (possibly empty) grid without throwing.
|
|
218
|
+
*
|
|
219
|
+
* @since 1.3
|
|
220
|
+
* @stable
|
|
221
|
+
* @example
|
|
222
|
+
* declare const s: TableState;
|
|
223
|
+
* declare const v: Viewport;
|
|
224
|
+
* const prims = decomposeTable(s, v);
|
|
225
|
+
* void prims;
|
|
226
|
+
*/
|
|
227
|
+
export function decomposeTable(state, view) {
|
|
228
|
+
const layout = layoutTable(state, view);
|
|
229
|
+
const out = [];
|
|
230
|
+
let y = layout.y;
|
|
231
|
+
for (let rowIndex = 0; rowIndex < state.cells.length; rowIndex++) {
|
|
232
|
+
const row = state.cells[rowIndex];
|
|
233
|
+
const height = layout.rowHeights[rowIndex];
|
|
234
|
+
let x = layout.x;
|
|
235
|
+
for (let columnIndex = 0; columnIndex < layout.columnWidths.length; columnIndex++) {
|
|
236
|
+
const width = layout.columnWidths[columnIndex];
|
|
237
|
+
const cell = row[columnIndex] ?? { text: "" };
|
|
238
|
+
out.push(rectPolyline(x, y, width, height, undefined, {
|
|
239
|
+
color: cell.bgColor ?? TABLE_DEFAULT_BG_COLOR,
|
|
240
|
+
alpha: FILL_OPAQUE,
|
|
241
|
+
}));
|
|
242
|
+
out.push({
|
|
243
|
+
kind: "text",
|
|
244
|
+
x: cellTextX(cell, x, width),
|
|
245
|
+
y: cellTextY(cell, y, height),
|
|
246
|
+
text: cell.text,
|
|
247
|
+
color: cell.textColor ?? TABLE_DEFAULT_TEXT_COLOR,
|
|
248
|
+
font: `${tableTextSizePx(cell)}px ${TABLE_FONT_FAMILY}`,
|
|
249
|
+
align: cellAlign(cell),
|
|
250
|
+
baseline: cellBaseline(cell),
|
|
251
|
+
});
|
|
252
|
+
if (state.borderColor !== undefined && state.borderWidth !== undefined) {
|
|
253
|
+
out.push(rectPolyline(x, y, width, height, {
|
|
254
|
+
color: state.borderColor,
|
|
255
|
+
width: state.borderWidth,
|
|
256
|
+
dash: SOLID_DASH,
|
|
257
|
+
}, undefined));
|
|
258
|
+
}
|
|
259
|
+
x += width;
|
|
260
|
+
}
|
|
261
|
+
y += height;
|
|
262
|
+
}
|
|
263
|
+
if (state.frame !== undefined) {
|
|
264
|
+
out.push(rectPolyline(layout.x, layout.y, layout.width, layout.height, { color: state.frame.color, width: state.frame.width, dash: SOLID_DASH }, undefined));
|
|
265
|
+
}
|
|
266
|
+
return out;
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=containers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containers.js","sourceRoot":"","sources":["../../../src/geometry/kinds/containers.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAC/D,EAAE;AACF,wEAAwE;AACxE,YAAY;AACZ,sEAAsE;AACtE,kEAAkE;AAClE,iEAAiE;AACjE,+DAA+D;AAC/D,4CAA4C;AAU5C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,4EAA4E;AAE5E;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,cAAc,CAAC,KAAiB,EAAE,IAAc;IAC5D,KAAK,KAAK,CAAC;IACX,KAAK,IAAI,CAAC;IACV,OAAO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AAC,WAAW;oBACxB,IAAI,EAAE,UAAU;iBACnB,EACD,SAAS,CACZ,CACJ,CAAC;YACN,CAAC;YACD,CAAC,IAAI,KAAK,CAAC;QACf,CAAC;QACD,CAAC,IAAI,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5B,GAAG,CAAC,IAAI,CACJ,YAAY,CACR,MAAM,CAAC,CAAC,EACR,MAAM,CAAC,CAAC,EACR,MAAM,CAAC,KAAK,EACZ,MAAM,CAAC,MAAM,EACb,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,EACxE,SAAS,CACZ,CACJ,CAAC;IACN,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n//\n// Container + table geometry moved from the canvas2d adapter's per-kind\n// renderers\n// examples/canvas2d-adapter/src/render/draw/{group,frame,table}.ts.\n// `group` / `frame` state shapes originate from invinite's collab\n// y-doc-bridge (commit 078f41fe2569d659d5aba726da8bcb5d3e2ced02,\n// © Invinite); the frame envelope + table layout are chartlang\n// additions. Re-licensed MIT for chartlang.\n\nimport type {\n FrameState,\n GroupState,\n TableCell,\n TablePosition,\n TableState,\n} from \"@invinite-org/chartlang-core\";\n\nimport { SOLID_DASH } from \"../_lib/dash.js\";\nimport { worldPointToPixel } from \"../project.js\";\nimport type { DrawPrimitive, FillStyle, StrokeStyle, Viewport } from \"../types.js\";\n\nconst FILL_OPAQUE = 1;\n\n// --- group ---------------------------------------------------------------\n\n/**\n * Decompose a `group` drawing — a no-op container. Groups are\n * metadata-only on the wire: `childHandleIds` reference drawings that\n * decompose through their own arms, and the `Viewport` exposes no\n * child-state side-channel, so a group emits nothing.\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: GroupState;\n * declare const v: Viewport;\n * const prims = decomposeGroup(s, v);\n * // prims.length === 0\n * void prims;\n */\nexport function decomposeGroup(state: GroupState, view: Viewport): ReadonlyArray<DrawPrimitive> {\n void state;\n void view;\n return [];\n}\n\n// --- frame ---------------------------------------------------------------\n\nconst FRAME_STROKE = \"#64748b\";\nconst FRAME_LABEL_COLOR = \"#1e293b\";\nconst FRAME_LINE_WIDTH = 1;\nconst FRAME_LABEL_FONT = \"12px sans-serif\";\nconst FRAME_LABEL_INSET_X = 6;\nconst FRAME_LABEL_INSET_Y = 14;\n\n/**\n * Decompose a `frame` drawing — a stroked rectangle between the two\n * world anchors `[topLeft, bottomRight]`. An optional `style.bgColor`\n * adds a background `fill` (alpha 1) on the border polyline; an optional\n * `style.label` adds a `text` primitive at the top-left corner.\n * Degenerate anchors (zero width/height, or non-finite) emit `[]`.\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: FrameState;\n * declare const v: Viewport;\n * const prims = decomposeFrame(s, v);\n * void prims;\n */\nexport function decomposeFrame(state: FrameState, view: Viewport): ReadonlyArray<DrawPrimitive> {\n const a = worldPointToPixel(state.anchors[0], view);\n const b = worldPointToPixel(state.anchors[1], view);\n const xMin = Math.min(a.x, b.x);\n const xMax = Math.max(a.x, b.x);\n const yMin = Math.min(a.y, b.y);\n const yMax = Math.max(a.y, b.y);\n const width = xMax - xMin;\n const height = yMax - yMin;\n if (width === 0 || height === 0) return [];\n if (!Number.isFinite(width) || !Number.isFinite(height)) return [];\n const fill: FillStyle | undefined =\n state.style.bgColor !== undefined\n ? { color: state.style.bgColor, alpha: FILL_OPAQUE }\n : undefined;\n const border: DrawPrimitive = {\n kind: \"polyline\",\n points: [\n { x: xMin, y: yMin },\n { x: xMax, y: yMin },\n { x: xMax, y: yMax },\n { x: xMin, y: yMax },\n ],\n closed: true,\n stroke: { color: FRAME_STROKE, width: FRAME_LINE_WIDTH, dash: SOLID_DASH },\n ...(fill !== undefined ? { fill } : {}),\n };\n const out: DrawPrimitive[] = [border];\n if (state.style.label !== undefined) {\n out.push({\n kind: \"text\",\n x: xMin + FRAME_LABEL_INSET_X,\n y: yMin + FRAME_LABEL_INSET_Y,\n text: state.style.label,\n color: FRAME_LABEL_COLOR,\n font: FRAME_LABEL_FONT,\n align: \"left\",\n baseline: \"bottom\",\n });\n }\n return out;\n}\n\n// --- table ---------------------------------------------------------------\n\nconst TABLE_VIEWPORT_PADDING_PX = 8;\nconst TABLE_CELL_PAD_X_PX = 6;\nconst TABLE_CELL_PAD_Y_PX = 4;\nconst TABLE_DEFAULT_TEXT_COLOR = \"#0f172a\";\nconst TABLE_DEFAULT_BG_COLOR = \"#ffffff\";\nconst TABLE_FONT_FAMILY = \"sans-serif\";\n\nconst TABLE_TEXT_SIZE_PX: Readonly<Record<NonNullable<TableCell[\"textSize\"]>, number>> = {\n tiny: 8,\n small: 10,\n normal: 12,\n large: 16,\n huge: 24,\n};\n\ntype TableLayout = {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n readonly columnWidths: ReadonlyArray<number>;\n readonly rowHeights: ReadonlyArray<number>;\n};\n\nfunction tableTextSizePx(cell: TableCell): number {\n return TABLE_TEXT_SIZE_PX[cell.textSize ?? \"normal\"];\n}\n\nfunction estimateTextWidth(text: string, fontPx: number): number {\n return text.length * fontPx * 0.6;\n}\n\nfunction columnCount(rows: ReadonlyArray<ReadonlyArray<TableCell>>): number {\n let count = 0;\n for (const row of rows) {\n if (row.length > count) count = row.length;\n }\n return count;\n}\n\nfunction resolveTableX(position: TablePosition, tableWidth: number, view: Viewport): number {\n if (position.endsWith(\"-center\")) return view.pxWidth / 2 - tableWidth / 2;\n if (position.endsWith(\"-right\")) return view.pxWidth - tableWidth - TABLE_VIEWPORT_PADDING_PX;\n return TABLE_VIEWPORT_PADDING_PX;\n}\n\nfunction resolveTableY(position: TablePosition, tableHeight: number, view: Viewport): number {\n if (position.startsWith(\"middle-\")) return view.pxHeight / 2 - tableHeight / 2;\n if (position.startsWith(\"bottom-\"))\n return view.pxHeight - tableHeight - TABLE_VIEWPORT_PADDING_PX;\n return TABLE_VIEWPORT_PADDING_PX;\n}\n\nfunction layoutTable(state: TableState, view: Viewport): TableLayout {\n const columns = columnCount(state.cells);\n const columnWidths = Array.from({ length: columns }, () => 0);\n const rowHeights = state.cells.map((row) => {\n let maxFont = TABLE_TEXT_SIZE_PX.normal;\n for (let column = 0; column < row.length; column++) {\n const cell = row[column];\n const fontPx = tableTextSizePx(cell);\n if (fontPx > maxFont) maxFont = fontPx;\n const width = estimateTextWidth(cell.text, fontPx) + TABLE_CELL_PAD_X_PX * 2;\n if (width > columnWidths[column]) columnWidths[column] = width;\n }\n return maxFont + TABLE_CELL_PAD_Y_PX * 2;\n });\n const width = columnWidths.reduce((sum, widthPx) => sum + widthPx, 0);\n const height = rowHeights.reduce((sum, heightPx) => sum + heightPx, 0);\n return {\n x: resolveTableX(state.position, width, view),\n y: resolveTableY(state.position, height, view),\n width,\n height,\n columnWidths,\n rowHeights,\n };\n}\n\nfunction rectPolyline(\n x: number,\n y: number,\n width: number,\n height: number,\n stroke: StrokeStyle | undefined,\n fill: FillStyle | undefined,\n): DrawPrimitive {\n return {\n kind: \"polyline\",\n points: [\n { x, y },\n { x: x + width, y },\n { x: x + width, y: y + height },\n { x, y: y + height },\n ],\n closed: true,\n ...(stroke !== undefined ? { stroke } : {}),\n ...(fill !== undefined ? { fill } : {}),\n };\n}\n\nfunction cellTextX(cell: TableCell, x: number, width: number): number {\n switch (cell.textHalign ?? \"left\") {\n case \"center\":\n return x + width / 2;\n case \"right\":\n return x + width - TABLE_CELL_PAD_X_PX;\n case \"left\":\n return x + TABLE_CELL_PAD_X_PX;\n }\n}\n\nfunction cellTextY(cell: TableCell, y: number, height: number): number {\n switch (cell.textValign ?? \"middle\") {\n case \"top\":\n return y + TABLE_CELL_PAD_Y_PX;\n case \"bottom\":\n return y + height - TABLE_CELL_PAD_Y_PX;\n case \"middle\":\n return y + height / 2;\n }\n}\n\nfunction cellAlign(cell: TableCell): \"left\" | \"center\" | \"right\" {\n return cell.textHalign ?? \"left\";\n}\n\nfunction cellBaseline(cell: TableCell): \"top\" | \"middle\" | \"bottom\" {\n return cell.textValign ?? \"middle\";\n}\n\n/**\n * Decompose a `draw.table` emission as a CSS-pixel viewport overlay.\n * Unlike every other kind, `table` ignores world-coordinate transforms:\n * `state.position` resolves directly against `Viewport.pxWidth` /\n * `Viewport.pxHeight`. Each cell emits a background-fill polyline + a\n * `text` primitive (+ an optional per-cell border polyline when both\n * `borderColor` and `borderWidth` are set); an optional outer `frame`\n * polyline wraps the whole grid. Zero rows/columns yields a degenerate\n * (possibly empty) grid without throwing.\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: TableState;\n * declare const v: Viewport;\n * const prims = decomposeTable(s, v);\n * void prims;\n */\nexport function decomposeTable(state: TableState, view: Viewport): ReadonlyArray<DrawPrimitive> {\n const layout = layoutTable(state, view);\n const out: DrawPrimitive[] = [];\n let y = layout.y;\n for (let rowIndex = 0; rowIndex < state.cells.length; rowIndex++) {\n const row = state.cells[rowIndex];\n const height = layout.rowHeights[rowIndex];\n let x = layout.x;\n for (let columnIndex = 0; columnIndex < layout.columnWidths.length; columnIndex++) {\n const width = layout.columnWidths[columnIndex];\n const cell = row[columnIndex] ?? { text: \"\" };\n out.push(\n rectPolyline(x, y, width, height, undefined, {\n color: cell.bgColor ?? TABLE_DEFAULT_BG_COLOR,\n alpha: FILL_OPAQUE,\n }),\n );\n out.push({\n kind: \"text\",\n x: cellTextX(cell, x, width),\n y: cellTextY(cell, y, height),\n text: cell.text,\n color: cell.textColor ?? TABLE_DEFAULT_TEXT_COLOR,\n font: `${tableTextSizePx(cell)}px ${TABLE_FONT_FAMILY}`,\n align: cellAlign(cell),\n baseline: cellBaseline(cell),\n });\n if (state.borderColor !== undefined && state.borderWidth !== undefined) {\n out.push(\n rectPolyline(\n x,\n y,\n width,\n height,\n {\n color: state.borderColor,\n width: state.borderWidth,\n dash: SOLID_DASH,\n },\n undefined,\n ),\n );\n }\n x += width;\n }\n y += height;\n }\n if (state.frame !== undefined) {\n out.push(\n rectPolyline(\n layout.x,\n layout.y,\n layout.width,\n layout.height,\n { color: state.frame.color, width: state.frame.width, dash: SOLID_DASH },\n undefined,\n ),\n );\n }\n return out;\n}\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ArcState, CurveState, DoubleCurveState } from "@invinite-org/chartlang-core";
|
|
2
|
+
import type { DrawPrimitive, Viewport } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Decompose an `arc` drawing — a quadratic Bezier whose middle anchor
|
|
5
|
+
* (the apex) lies ON the curve at `t = 0.5`. The off-curve control point
|
|
6
|
+
* is derived by inverse-quadratic interpolation
|
|
7
|
+
* (`2·apex − 0.5·(from + to)`) so the sampled curve passes through the
|
|
8
|
+
* apex, then sampled into one open {@link CURVE_SAMPLES}-segment
|
|
9
|
+
* polyline.
|
|
10
|
+
*
|
|
11
|
+
* @since 1.3
|
|
12
|
+
* @stable
|
|
13
|
+
* @example
|
|
14
|
+
* declare const s: ArcState;
|
|
15
|
+
* declare const v: Viewport;
|
|
16
|
+
* const prims = decomposeArc(s, v);
|
|
17
|
+
* // prims[0].kind === "polyline"; prims[0].closed === false
|
|
18
|
+
* void prims;
|
|
19
|
+
*/
|
|
20
|
+
export declare function decomposeArc(state: ArcState, view: Viewport): ReadonlyArray<DrawPrimitive>;
|
|
21
|
+
/**
|
|
22
|
+
* Decompose a `curve` drawing — a quadratic Bezier whose middle anchor
|
|
23
|
+
* IS the off-curve control point (distinct from `arc`, whose apex lies
|
|
24
|
+
* on the curve). Sampled into one open {@link CURVE_SAMPLES}-segment
|
|
25
|
+
* polyline.
|
|
26
|
+
*
|
|
27
|
+
* @since 1.3
|
|
28
|
+
* @stable
|
|
29
|
+
* @example
|
|
30
|
+
* declare const s: CurveState;
|
|
31
|
+
* declare const v: Viewport;
|
|
32
|
+
* const prims = decomposeCurve(s, v);
|
|
33
|
+
* void prims;
|
|
34
|
+
*/
|
|
35
|
+
export declare function decomposeCurve(state: CurveState, view: Viewport): ReadonlyArray<DrawPrimitive>;
|
|
36
|
+
/**
|
|
37
|
+
* Decompose a `double-curve` drawing — a single cubic Bezier from
|
|
38
|
+
* `anchors[0]` to `anchors[4]` with off-curve controls `anchors[1]` and
|
|
39
|
+
* `anchors[3]`. The middle stitch anchor `anchors[2]` is preserved in
|
|
40
|
+
* state but unused by the current single-cubic render path (matching the
|
|
41
|
+
* canvas2d source). Sampled into one open {@link CURVE_SAMPLES}-segment
|
|
42
|
+
* polyline.
|
|
43
|
+
*
|
|
44
|
+
* @since 1.3
|
|
45
|
+
* @stable
|
|
46
|
+
* @example
|
|
47
|
+
* declare const s: DoubleCurveState;
|
|
48
|
+
* declare const v: Viewport;
|
|
49
|
+
* const prims = decomposeDoubleCurve(s, v);
|
|
50
|
+
* void prims;
|
|
51
|
+
*/
|
|
52
|
+
export declare function decomposeDoubleCurve(state: DoubleCurveState, view: Viewport): ReadonlyArray<DrawPrimitive>;
|
|
53
|
+
//# sourceMappingURL=curves.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"curves.d.ts","sourceRoot":"","sources":["../../../src/geometry/kinds/curves.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAK3F,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAU3D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC,aAAa,CAAC,CAgB1F;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,GAAG,aAAa,CAAC,aAAa,CAAC,CAY9F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAChC,KAAK,EAAE,gBAAgB,EACvB,IAAI,EAAE,QAAQ,GACf,aAAa,CAAC,aAAa,CAAC,CAa9B"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Copyright (c) 2026 Invinite. Licensed under the MIT License.
|
|
2
|
+
// See the LICENSE file in the repo root for full license text.
|
|
3
|
+
//
|
|
4
|
+
// Curve geometry moved from the canvas2d adapter's per-kind renderers
|
|
5
|
+
// examples/canvas2d-adapter/src/render/draw/{arc,curve,doubleCurve}.ts.
|
|
6
|
+
// The originating math is invinite's arc / curve / double-curve tools
|
|
7
|
+
// (commit 078f41fe2569d659d5aba726da8bcb5d3e2ced02, © Invinite);
|
|
8
|
+
// re-licensed MIT for chartlang.
|
|
9
|
+
import { sampleCubic, sampleQuadratic } from "../_lib/bezier.js";
|
|
10
|
+
import { strokeOf } from "../_lib/strokeStyle.js";
|
|
11
|
+
import { worldPointToPixel } from "../project.js";
|
|
12
|
+
/**
|
|
13
|
+
* Number of polyline segments each curve is sampled into — matching the
|
|
14
|
+
* canvas2d source renderers exactly (the structural `RenderCtx` exposes
|
|
15
|
+
* no `quadraticCurveTo` / `bezierCurveTo`, so every curve is stroked as
|
|
16
|
+
* a sampled polyline).
|
|
17
|
+
*/
|
|
18
|
+
const CURVE_SAMPLES = 32;
|
|
19
|
+
/**
|
|
20
|
+
* Decompose an `arc` drawing — a quadratic Bezier whose middle anchor
|
|
21
|
+
* (the apex) lies ON the curve at `t = 0.5`. The off-curve control point
|
|
22
|
+
* is derived by inverse-quadratic interpolation
|
|
23
|
+
* (`2·apex − 0.5·(from + to)`) so the sampled curve passes through the
|
|
24
|
+
* apex, then sampled into one open {@link CURVE_SAMPLES}-segment
|
|
25
|
+
* polyline.
|
|
26
|
+
*
|
|
27
|
+
* @since 1.3
|
|
28
|
+
* @stable
|
|
29
|
+
* @example
|
|
30
|
+
* declare const s: ArcState;
|
|
31
|
+
* declare const v: Viewport;
|
|
32
|
+
* const prims = decomposeArc(s, v);
|
|
33
|
+
* // prims[0].kind === "polyline"; prims[0].closed === false
|
|
34
|
+
* void prims;
|
|
35
|
+
*/
|
|
36
|
+
export function decomposeArc(state, view) {
|
|
37
|
+
const from = worldPointToPixel(state.anchors[0], view);
|
|
38
|
+
const apex = worldPointToPixel(state.anchors[1], view);
|
|
39
|
+
const to = worldPointToPixel(state.anchors[2], view);
|
|
40
|
+
const control = {
|
|
41
|
+
x: 2 * apex.x - 0.5 * (from.x + to.x),
|
|
42
|
+
y: 2 * apex.y - 0.5 * (from.y + to.y),
|
|
43
|
+
};
|
|
44
|
+
return [
|
|
45
|
+
{
|
|
46
|
+
kind: "polyline",
|
|
47
|
+
points: sampleQuadratic(from, control, to, CURVE_SAMPLES),
|
|
48
|
+
closed: false,
|
|
49
|
+
stroke: strokeOf(state.style),
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Decompose a `curve` drawing — a quadratic Bezier whose middle anchor
|
|
55
|
+
* IS the off-curve control point (distinct from `arc`, whose apex lies
|
|
56
|
+
* on the curve). Sampled into one open {@link CURVE_SAMPLES}-segment
|
|
57
|
+
* polyline.
|
|
58
|
+
*
|
|
59
|
+
* @since 1.3
|
|
60
|
+
* @stable
|
|
61
|
+
* @example
|
|
62
|
+
* declare const s: CurveState;
|
|
63
|
+
* declare const v: Viewport;
|
|
64
|
+
* const prims = decomposeCurve(s, v);
|
|
65
|
+
* void prims;
|
|
66
|
+
*/
|
|
67
|
+
export function decomposeCurve(state, view) {
|
|
68
|
+
const from = worldPointToPixel(state.anchors[0], view);
|
|
69
|
+
const control = worldPointToPixel(state.anchors[1], view);
|
|
70
|
+
const to = worldPointToPixel(state.anchors[2], view);
|
|
71
|
+
return [
|
|
72
|
+
{
|
|
73
|
+
kind: "polyline",
|
|
74
|
+
points: sampleQuadratic(from, control, to, CURVE_SAMPLES),
|
|
75
|
+
closed: false,
|
|
76
|
+
stroke: strokeOf(state.style),
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Decompose a `double-curve` drawing — a single cubic Bezier from
|
|
82
|
+
* `anchors[0]` to `anchors[4]` with off-curve controls `anchors[1]` and
|
|
83
|
+
* `anchors[3]`. The middle stitch anchor `anchors[2]` is preserved in
|
|
84
|
+
* state but unused by the current single-cubic render path (matching the
|
|
85
|
+
* canvas2d source). Sampled into one open {@link CURVE_SAMPLES}-segment
|
|
86
|
+
* polyline.
|
|
87
|
+
*
|
|
88
|
+
* @since 1.3
|
|
89
|
+
* @stable
|
|
90
|
+
* @example
|
|
91
|
+
* declare const s: DoubleCurveState;
|
|
92
|
+
* declare const v: Viewport;
|
|
93
|
+
* const prims = decomposeDoubleCurve(s, v);
|
|
94
|
+
* void prims;
|
|
95
|
+
*/
|
|
96
|
+
export function decomposeDoubleCurve(state, view) {
|
|
97
|
+
const p0 = worldPointToPixel(state.anchors[0], view);
|
|
98
|
+
const p1 = worldPointToPixel(state.anchors[1], view);
|
|
99
|
+
const p3 = worldPointToPixel(state.anchors[3], view);
|
|
100
|
+
const p4 = worldPointToPixel(state.anchors[4], view);
|
|
101
|
+
return [
|
|
102
|
+
{
|
|
103
|
+
kind: "polyline",
|
|
104
|
+
points: sampleCubic(p0, p1, p3, p4, CURVE_SAMPLES),
|
|
105
|
+
closed: false,
|
|
106
|
+
stroke: strokeOf(state.style),
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=curves.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"curves.js","sourceRoot":"","sources":["../../../src/geometry/kinds/curves.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAC/D,EAAE;AACF,sEAAsE;AACtE,0EAA0E;AAC1E,sEAAsE;AACtE,iEAAiE;AACjE,iCAAiC;AAIjC,OAAO,EAAE,WAAW,EAAE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CAAC;IACvD,MAAM,OAAO,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC1D,MAAM,EAAE,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACrD,OAAO;QACH;YACI,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,aAAa,CAAC;YACzD,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;SAChC;KACJ,CAAC;AACN,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,oBAAoB,CAChC,KAAuB,EACvB,IAAc;IAEd,MAAM,EAAE,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACrD,MAAM,EAAE,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACrD,MAAM,EAAE,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACrD,MAAM,EAAE,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACrD,OAAO;QACH;YACI,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,WAAW,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,aAAa,CAAC;YAClD,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC;SAChC;KACJ,CAAC;AACN,CAAC","sourcesContent":["// Copyright (c) 2026 Invinite. Licensed under the MIT License.\n// See the LICENSE file in the repo root for full license text.\n//\n// Curve geometry moved from the canvas2d adapter's per-kind renderers\n// examples/canvas2d-adapter/src/render/draw/{arc,curve,doubleCurve}.ts.\n// The originating math is invinite's arc / curve / double-curve tools\n// (commit 078f41fe2569d659d5aba726da8bcb5d3e2ced02, © Invinite);\n// re-licensed MIT for chartlang.\n\nimport type { ArcState, CurveState, DoubleCurveState } from \"@invinite-org/chartlang-core\";\n\nimport { sampleCubic, sampleQuadratic } from \"../_lib/bezier.js\";\nimport { strokeOf } from \"../_lib/strokeStyle.js\";\nimport { worldPointToPixel } from \"../project.js\";\nimport type { DrawPrimitive, Viewport } from \"../types.js\";\n\n/**\n * Number of polyline segments each curve is sampled into — matching the\n * canvas2d source renderers exactly (the structural `RenderCtx` exposes\n * no `quadraticCurveTo` / `bezierCurveTo`, so every curve is stroked as\n * a sampled polyline).\n */\nconst CURVE_SAMPLES = 32;\n\n/**\n * Decompose an `arc` drawing — a quadratic Bezier whose middle anchor\n * (the apex) lies ON the curve at `t = 0.5`. The off-curve control point\n * is derived by inverse-quadratic interpolation\n * (`2·apex − 0.5·(from + to)`) so the sampled curve passes through the\n * apex, then sampled into one open {@link CURVE_SAMPLES}-segment\n * polyline.\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: ArcState;\n * declare const v: Viewport;\n * const prims = decomposeArc(s, v);\n * // prims[0].kind === \"polyline\"; prims[0].closed === false\n * void prims;\n */\nexport function decomposeArc(state: ArcState, view: Viewport): ReadonlyArray<DrawPrimitive> {\n const from = worldPointToPixel(state.anchors[0], view);\n const apex = worldPointToPixel(state.anchors[1], view);\n const to = worldPointToPixel(state.anchors[2], view);\n const control = {\n x: 2 * apex.x - 0.5 * (from.x + to.x),\n y: 2 * apex.y - 0.5 * (from.y + to.y),\n };\n return [\n {\n kind: \"polyline\",\n points: sampleQuadratic(from, control, to, CURVE_SAMPLES),\n closed: false,\n stroke: strokeOf(state.style),\n },\n ];\n}\n\n/**\n * Decompose a `curve` drawing — a quadratic Bezier whose middle anchor\n * IS the off-curve control point (distinct from `arc`, whose apex lies\n * on the curve). Sampled into one open {@link CURVE_SAMPLES}-segment\n * polyline.\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: CurveState;\n * declare const v: Viewport;\n * const prims = decomposeCurve(s, v);\n * void prims;\n */\nexport function decomposeCurve(state: CurveState, view: Viewport): ReadonlyArray<DrawPrimitive> {\n const from = worldPointToPixel(state.anchors[0], view);\n const control = worldPointToPixel(state.anchors[1], view);\n const to = worldPointToPixel(state.anchors[2], view);\n return [\n {\n kind: \"polyline\",\n points: sampleQuadratic(from, control, to, CURVE_SAMPLES),\n closed: false,\n stroke: strokeOf(state.style),\n },\n ];\n}\n\n/**\n * Decompose a `double-curve` drawing — a single cubic Bezier from\n * `anchors[0]` to `anchors[4]` with off-curve controls `anchors[1]` and\n * `anchors[3]`. The middle stitch anchor `anchors[2]` is preserved in\n * state but unused by the current single-cubic render path (matching the\n * canvas2d source). Sampled into one open {@link CURVE_SAMPLES}-segment\n * polyline.\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: DoubleCurveState;\n * declare const v: Viewport;\n * const prims = decomposeDoubleCurve(s, v);\n * void prims;\n */\nexport function decomposeDoubleCurve(\n state: DoubleCurveState,\n view: Viewport,\n): ReadonlyArray<DrawPrimitive> {\n const p0 = worldPointToPixel(state.anchors[0], view);\n const p1 = worldPointToPixel(state.anchors[1], view);\n const p3 = worldPointToPixel(state.anchors[3], view);\n const p4 = worldPointToPixel(state.anchors[4], view);\n return [\n {\n kind: \"polyline\",\n points: sampleCubic(p0, p1, p3, p4, CURVE_SAMPLES),\n closed: false,\n stroke: strokeOf(state.style),\n },\n ];\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { CyclicLinesState, SineLineState, TimeCyclesState } from "@invinite-org/chartlang-core";
|
|
2
|
+
import type { DrawPrimitive, Viewport } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Decompose a `cyclic-lines` drawing — repeated full-height vertical
|
|
5
|
+
* lines spaced at `periodPx = |toX − fromX|` to the right of the `from`
|
|
6
|
+
* anchor. Returns `[]` when the period is non-positive or non-finite;
|
|
7
|
+
* caps at 256 repeats, breaking past the right edge and skipping strokes
|
|
8
|
+
* left of the viewport (matching the source).
|
|
9
|
+
*
|
|
10
|
+
* @since 1.3
|
|
11
|
+
* @stable
|
|
12
|
+
* @example
|
|
13
|
+
* declare const s: CyclicLinesState;
|
|
14
|
+
* declare const v: Viewport;
|
|
15
|
+
* const prims = decomposeCyclicLines(s, v);
|
|
16
|
+
* void prims;
|
|
17
|
+
*/
|
|
18
|
+
export declare function decomposeCyclicLines(state: CyclicLinesState, view: Viewport): ReadonlyArray<DrawPrimitive>;
|
|
19
|
+
/**
|
|
20
|
+
* Decompose a `time-cycles` drawing — concentric upper-half arcs centred
|
|
21
|
+
* at the midpoint of `(from, to)` on the `from.price` baseline, radius
|
|
22
|
+
* `|toX − fromX| / 2`, tiled across the viewport at multiples of the
|
|
23
|
+
* diameter. Returns `[]` when the diameter is non-positive or non-finite.
|
|
24
|
+
* Each arc spans `[π, 2π]` (upper half).
|
|
25
|
+
*
|
|
26
|
+
* @since 1.3
|
|
27
|
+
* @stable
|
|
28
|
+
* @example
|
|
29
|
+
* declare const s: TimeCyclesState;
|
|
30
|
+
* declare const v: Viewport;
|
|
31
|
+
* const prims = decomposeTimeCycles(s, v);
|
|
32
|
+
* void prims;
|
|
33
|
+
*/
|
|
34
|
+
export declare function decomposeTimeCycles(state: TimeCyclesState, view: Viewport): ReadonlyArray<DrawPrimitive>;
|
|
35
|
+
/**
|
|
36
|
+
* Decompose a `sine-line` drawing — one sampled sinusoidal polyline. The
|
|
37
|
+
* half-period is `|toX − fromX|`; baseline is the midpoint of
|
|
38
|
+
* `(fromY, toY)`; amplitude is half the y-distance between anchors. The
|
|
39
|
+
* wave starts at the extreme nearest `from` (sign `peakAtFrom`), sampled
|
|
40
|
+
* 32 points per full period across the padded viewport. Returns `[]`
|
|
41
|
+
* when the half-period is non-positive or non-finite.
|
|
42
|
+
*
|
|
43
|
+
* @since 1.3
|
|
44
|
+
* @stable
|
|
45
|
+
* @example
|
|
46
|
+
* declare const s: SineLineState;
|
|
47
|
+
* declare const v: Viewport;
|
|
48
|
+
* const prims = decomposeSineLine(s, v);
|
|
49
|
+
* void prims;
|
|
50
|
+
*/
|
|
51
|
+
export declare function decomposeSineLine(state: SineLineState, view: Viewport): ReadonlyArray<DrawPrimitive>;
|
|
52
|
+
//# sourceMappingURL=cycles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cycles.d.ts","sourceRoot":"","sources":["../../../src/geometry/kinds/cycles.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACR,gBAAgB,EAChB,aAAa,EACb,eAAe,EAClB,MAAM,8BAA8B,CAAC;AAItC,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQ3D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAChC,KAAK,EAAE,gBAAgB,EACvB,IAAI,EAAE,QAAQ,GACf,aAAa,CAAC,aAAa,CAAC,CAsB9B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAC/B,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,QAAQ,GACf,aAAa,CAAC,aAAa,CAAC,CAwC9B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,QAAQ,GACf,aAAa,CAAC,aAAa,CAAC,CAyB9B"}
|