@invinite-org/chartlang-adapter-kit 1.3.0 → 1.5.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 +68 -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/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 +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interaction/domWiring.d.ts +90 -0
- package/dist/interaction/domWiring.d.ts.map +1 -0
- package/dist/interaction/domWiring.js +113 -0
- package/dist/interaction/domWiring.js.map +1 -0
- package/dist/interaction/index.d.ts +5 -0
- package/dist/interaction/index.d.ts.map +1 -0
- package/dist/interaction/index.js +5 -0
- package/dist/interaction/index.js.map +1 -0
- package/dist/interaction/viewController.d.ts +120 -0
- package/dist/interaction/viewController.d.ts.map +1 -0
- package/dist/interaction/viewController.js +112 -0
- package/dist/interaction/viewController.js.map +1 -0
- package/package.json +8 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boxes.js","sourceRoot":"","sources":["../../../src/geometry/kinds/boxes.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAC/D,EAAE;AACF,oEAAoE;AACpE,kBAAkB;AAClB,0DAA0D;AAC1D,4DAA4D;AAC5D,qBAAqB;AACrB,qEAAqE;AACrE,8DAA8D;AAC9D,qEAAqE;AACrE,qBAAqB;AAarB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAC9B,KAAqB,EACrB,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,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,IAA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,CAAC;QAAE,OAAO,EAAE,CAAC;IAC7E,MAAM,MAAM,GAAa,CAAC,GAAG,CAAC,CAAC,CAAC;IAChC,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;QAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC;IACpC,OAAO;QACH;YACI,IAAI,EAAE,UAAU;YAChB,MAAM;YACN,MAAM,EAAE,IAAI;YACZ,GAAG,CAAC,KAAK,KAAK,SAAS;gBACnB,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC;oBACI,MAAM,EAAE;wBACJ,KAAK;wBACL,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,IAAI,kBAAkB;wBAClD,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,IAAI,OAAO,CAAC;qBACtD;iBACJ,CAAC;YACR,GAAG,CAAC,IAAI,KAAK,SAAS;gBAClB,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,IAAI,kBAAkB,EAAE,EAAE,CAAC;SACvF;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// Stroke + fill geometry moved from the canvas2d adapter's per-kind\n// shape renderers\n// examples/canvas2d-adapter/src/render/draw/{rectangle,\n// rotatedRectangle,triangle,polyline,circle,ellipse,path,\n// fillBetween}.ts.\n// The originating math is invinite's rectangle / rotated-rectangle /\n// triangle / polyline / circle / ellipse / path tools (commit\n// 078f41fe2569d659d5aba726da8bcb5d3e2ced02, © Invinite); re-licensed\n// MIT for chartlang.\n\nimport type {\n CircleState,\n EllipseState,\n FillBetweenState,\n PathState,\n PolylineState,\n RectangleState,\n RotatedRectangleState,\n TriangleState,\n} from \"@invinite-org/chartlang-core\";\n\nimport { dashPattern } from \"../_lib/dash.js\";\nimport { resolveShapeStyle } from \"../_lib/shapeStyle.js\";\nimport { worldPointToPixel } from \"../project.js\";\nimport type { DrawPrimitive, Point2, Viewport } from \"../types.js\";\n\nconst DEFAULT_LINE_WIDTH = 1;\nconst DEFAULT_FILL_ALPHA = 1;\nconst TWO_PI = Math.PI * 2;\n\n/**\n * Number of polyline segments used to approximate an `ellipse`. 64\n * segments give visually smooth strokes at typical viewport widths\n * (≈800 px) while keeping the primitive list bounded — matching the\n * canvas2d source renderer exactly.\n */\nconst ELLIPSE_SEGMENTS = 64;\n\n/**\n * Decompose a `rectangle` drawing — a closed 4-corner polygon derived\n * from the axis-aligned bounding box of the two projected anchors.\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: RectangleState;\n * declare const v: Viewport;\n * const prims = decomposeRectangle(s, v);\n * // prims[0].kind === \"polyline\"; prims[0].closed === true\n * void prims;\n */\nexport function decomposeRectangle(\n state: RectangleState,\n view: Viewport,\n): 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 { stroke, fill } = resolveShapeStyle(state.style);\n return [\n {\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,\n ...(fill === undefined ? {} : { fill }),\n },\n ];\n}\n\n/**\n * Decompose a `rotated-rectangle` drawing — a closed polygon through\n * the four projected anchors (carried in stroke order, so no matrix\n * math is needed).\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: RotatedRectangleState;\n * declare const v: Viewport;\n * const prims = decomposeRotatedRectangle(s, v);\n * void prims;\n */\nexport function decomposeRotatedRectangle(\n state: RotatedRectangleState,\n view: Viewport,\n): ReadonlyArray<DrawPrimitive> {\n const points = state.anchors.map((p) => worldPointToPixel(p, view));\n const { stroke, fill } = resolveShapeStyle(state.style);\n return [\n {\n kind: \"polyline\",\n points,\n closed: true,\n stroke,\n ...(fill === undefined ? {} : { fill }),\n },\n ];\n}\n\n/**\n * Decompose a `triangle` drawing — a closed 3-vertex polygon.\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: TriangleState;\n * declare const v: Viewport;\n * const prims = decomposeTriangle(s, v);\n * void prims;\n */\nexport function decomposeTriangle(\n state: TriangleState,\n view: Viewport,\n): ReadonlyArray<DrawPrimitive> {\n const points = state.anchors.map((p) => worldPointToPixel(p, view));\n const { stroke, fill } = resolveShapeStyle(state.style);\n return [\n {\n kind: \"polyline\",\n points,\n closed: true,\n stroke,\n ...(fill === undefined ? {} : { fill }),\n },\n ];\n}\n\n/**\n * Decompose a `polyline` drawing — a closed N-vertex polyline carrying\n * a `LineDrawStyle` (no fill).\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: PolylineState;\n * declare const v: Viewport;\n * const prims = decomposePolyline(s, v);\n * // prims[0].closed === true\n * void prims;\n */\nexport function decomposePolyline(\n state: PolylineState,\n view: Viewport,\n): ReadonlyArray<DrawPrimitive> {\n const points = state.anchors.map((p) => worldPointToPixel(p, view));\n return [\n {\n kind: \"polyline\",\n points,\n closed: true,\n stroke: {\n color: state.style.color ?? \"#000000\",\n width: state.style.lineWidth ?? DEFAULT_LINE_WIDTH,\n dash: dashPattern(state.style.lineStyle ?? \"solid\"),\n },\n },\n ];\n}\n\n/**\n * Decompose a `circle` drawing — an arc whose radius is the projected\n * pixel distance between the centre anchor and the radius anchor (so\n * the stroke keeps the same apparent thickness across zoom changes).\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: CircleState;\n * declare const v: Viewport;\n * const prims = decomposeCircle(s, v);\n * // prims[0].kind === \"arc\"\n * void prims;\n */\nexport function decomposeCircle(state: CircleState, view: Viewport): ReadonlyArray<DrawPrimitive> {\n const centre = worldPointToPixel(state.anchors[0], view);\n const edge = worldPointToPixel(state.anchors[1], view);\n const radius = Math.hypot(edge.x - centre.x, edge.y - centre.y);\n const { stroke, fill } = resolveShapeStyle(state.style);\n return [\n {\n kind: \"arc\",\n cx: centre.x,\n cy: centre.y,\n r: radius,\n start: 0,\n end: TWO_PI,\n closed: true,\n stroke,\n ...(fill === undefined ? {} : { fill }),\n },\n ];\n}\n\n/**\n * Decompose an axis-aligned `ellipse` drawing — a closed\n * {@link ELLIPSE_SEGMENTS}-segment polyline inscribed in the bounding\n * box of the two anchors. Rotated ellipses are out of scope.\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: EllipseState;\n * declare const v: Viewport;\n * const prims = decomposeEllipse(s, v);\n * void prims;\n */\nexport function decomposeEllipse(\n state: EllipseState,\n view: Viewport,\n): ReadonlyArray<DrawPrimitive> {\n const a = worldPointToPixel(state.anchors[0], view);\n const b = worldPointToPixel(state.anchors[1], view);\n const cx = (a.x + b.x) / 2;\n const cy = (a.y + b.y) / 2;\n const rx = Math.abs(b.x - a.x) / 2;\n const ry = Math.abs(b.y - a.y) / 2;\n const points: Point2[] = [{ x: cx + rx, y: cy }];\n for (let i = 1; i < ELLIPSE_SEGMENTS; i++) {\n const theta = (i / ELLIPSE_SEGMENTS) * TWO_PI;\n points.push({ x: cx + rx * Math.cos(theta), y: cy + ry * Math.sin(theta) });\n }\n const { stroke, fill } = resolveShapeStyle(state.style);\n return [\n {\n kind: \"polyline\",\n points,\n closed: true,\n stroke,\n ...(fill === undefined ? {} : { fill }),\n },\n ];\n}\n\n/**\n * Decompose a `path` drawing — an OPEN N-vertex polyline (unless\n * `style.closed === true`) carrying a `PathOpts` style (no fill).\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: PathState;\n * declare const v: Viewport;\n * const prims = decomposePath(s, v);\n * void prims;\n */\nexport function decomposePath(state: PathState, view: Viewport): ReadonlyArray<DrawPrimitive> {\n const points = state.anchors.map((p) => worldPointToPixel(p, view));\n return [\n {\n kind: \"polyline\",\n points,\n closed: state.style.closed === true,\n stroke: {\n color: state.style.color ?? \"#000000\",\n width: state.style.lineWidth ?? DEFAULT_LINE_WIDTH,\n dash: dashPattern(state.style.lineStyle ?? \"solid\"),\n },\n },\n ];\n}\n\n/**\n * Decompose a `fill-between` drawing — a closed filled polygon walking\n * `edgeA` forward then `edgeB` in reverse. The optional outline strokes\n * only when `style.color` is set; the band fills only when `style.fill`\n * is set. A degenerate edge (`< 1` point) or a non-finite mapped anchor\n * is a silent no-op (returns `[]`), matching the source renderer's\n * warmup behaviour.\n *\n * @since 1.3\n * @stable\n * @example\n * declare const s: FillBetweenState;\n * declare const v: Viewport;\n * const prims = decomposeFillBetween(s, v);\n * void prims;\n */\nexport function decomposeFillBetween(\n state: FillBetweenState,\n view: Viewport,\n): ReadonlyArray<DrawPrimitive> {\n const a = state.edgeA.map((p) => worldPointToPixel(p, view));\n const b = state.edgeB.map((p) => worldPointToPixel(p, view));\n if (a.length < 1 || b.length < 1) return [];\n if (a.some((p) => !Number.isFinite(p.x) || !Number.isFinite(p.y))) return [];\n if (b.some((p) => !Number.isFinite(p.x) || !Number.isFinite(p.y))) return [];\n const points: Point2[] = [...a];\n for (let i = b.length - 1; i >= 0; i--) points.push(b[i]);\n const { color, fill } = state.style;\n return [\n {\n kind: \"polyline\",\n points,\n closed: true,\n ...(color === undefined\n ? {}\n : {\n stroke: {\n color,\n width: state.style.lineWidth ?? DEFAULT_LINE_WIDTH,\n dash: dashPattern(state.style.lineStyle ?? \"solid\"),\n },\n }),\n ...(fill === undefined\n ? {}\n : { fill: { color: fill, alpha: state.style.fillAlpha ?? DEFAULT_FILL_ALPHA } }),\n },\n ];\n}\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { DisjointChannelState, FlatTopBottomState, RegressionTrendState, TrendChannelState } from "@invinite-org/chartlang-core";
|
|
2
|
+
import type { DrawPrimitive, Viewport } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Decompose a `trend-channel` drawing — two parallel line segments. The
|
|
5
|
+
* primary rail runs `anchors[0]` → `anchors[1]`; the second rail is its
|
|
6
|
+
* translate by the offset vector `anchors[2] − anchors[0]`, keeping the
|
|
7
|
+
* pair strictly parallel. Stroke-only — `LineDrawStyle` carries no fill,
|
|
8
|
+
* so there is no inter-rail band (matching the canvas2d source).
|
|
9
|
+
*
|
|
10
|
+
* @since 1.3
|
|
11
|
+
* @stable
|
|
12
|
+
* @example
|
|
13
|
+
* declare const s: TrendChannelState;
|
|
14
|
+
* declare const v: Viewport;
|
|
15
|
+
* const prims = decomposeTrendChannel(s, v);
|
|
16
|
+
* // prims.length === 2
|
|
17
|
+
* void prims;
|
|
18
|
+
*/
|
|
19
|
+
export declare function decomposeTrendChannel(state: TrendChannelState, view: Viewport): ReadonlyArray<DrawPrimitive>;
|
|
20
|
+
/**
|
|
21
|
+
* Decompose a `flat-top-bottom` drawing — two horizontal rails. The top
|
|
22
|
+
* rail sits at `max(anchors[0].price, anchors[2].price)` and the bottom
|
|
23
|
+
* at `min(...)`; both span the time range `anchors[0].time` →
|
|
24
|
+
* `anchors[1].time`. Stroke-only.
|
|
25
|
+
*
|
|
26
|
+
* @since 1.3
|
|
27
|
+
* @stable
|
|
28
|
+
* @example
|
|
29
|
+
* declare const s: FlatTopBottomState;
|
|
30
|
+
* declare const v: Viewport;
|
|
31
|
+
* const prims = decomposeFlatTopBottom(s, v);
|
|
32
|
+
* // prims.length === 2
|
|
33
|
+
* void prims;
|
|
34
|
+
*/
|
|
35
|
+
export declare function decomposeFlatTopBottom(state: FlatTopBottomState, view: Viewport): ReadonlyArray<DrawPrimitive>;
|
|
36
|
+
/**
|
|
37
|
+
* Decompose a `disjoint-channel` drawing — two independent line segments
|
|
38
|
+
* with no shared geometry constraint: `anchors[0]` → `anchors[1]` and
|
|
39
|
+
* `anchors[2]` → `anchors[3]`. Stroke-only.
|
|
40
|
+
*
|
|
41
|
+
* @since 1.3
|
|
42
|
+
* @stable
|
|
43
|
+
* @example
|
|
44
|
+
* declare const s: DisjointChannelState;
|
|
45
|
+
* declare const v: Viewport;
|
|
46
|
+
* const prims = decomposeDisjointChannel(s, v);
|
|
47
|
+
* // prims.length === 2
|
|
48
|
+
* void prims;
|
|
49
|
+
*/
|
|
50
|
+
export declare function decomposeDisjointChannel(state: DisjointChannelState, view: Viewport): ReadonlyArray<DrawPrimitive>;
|
|
51
|
+
/**
|
|
52
|
+
* Decompose a `regression-trend` drawing — a single placeholder line
|
|
53
|
+
* between the two anchors, colour `style.color ?? "#3b82f6"`, width 1,
|
|
54
|
+
* solid. The OLS fit + ±σ bands the `RegressionTrendOpts` flags
|
|
55
|
+
* (`source` / `stdevMultiplier` / `showUpperBand` / `showLowerBand`)
|
|
56
|
+
* describe require a bar buffer the `Viewport` does not expose and band
|
|
57
|
+
* anchors the 2-point `state.anchors` does not carry; the canvas2d
|
|
58
|
+
* source renders the same placeholder line, so this decomposer preserves
|
|
59
|
+
* that geometry. Those style fields are accepted but unused here —
|
|
60
|
+
* consumer adapters with a bar buffer can compute the fit themselves.
|
|
61
|
+
*
|
|
62
|
+
* @since 1.3
|
|
63
|
+
* @stable
|
|
64
|
+
* @example
|
|
65
|
+
* declare const s: RegressionTrendState;
|
|
66
|
+
* declare const v: Viewport;
|
|
67
|
+
* const prims = decomposeRegressionTrend(s, v);
|
|
68
|
+
* // prims.length === 1; prims[0].kind === "polyline"
|
|
69
|
+
* void prims;
|
|
70
|
+
*/
|
|
71
|
+
export declare function decomposeRegressionTrend(state: RegressionTrendState, view: Viewport): ReadonlyArray<DrawPrimitive>;
|
|
72
|
+
//# sourceMappingURL=channels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channels.d.ts","sourceRoot":"","sources":["../../../src/geometry/kinds/channels.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACR,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACpB,MAAM,8BAA8B,CAAC;AAKtC,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAU3D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,iBAAiB,EACxB,IAAI,EAAE,QAAQ,GACf,aAAa,CAAC,aAAa,CAAC,CAmB9B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAClC,KAAK,EAAE,kBAAkB,EACzB,IAAI,EAAE,QAAQ,GACf,aAAa,CAAC,aAAa,CAAC,CAe9B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CACpC,KAAK,EAAE,oBAAoB,EAC3B,IAAI,EAAE,QAAQ,GACf,aAAa,CAAC,aAAa,CAAC,CAU9B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CACpC,KAAK,EAAE,oBAAoB,EAC3B,IAAI,EAAE,QAAQ,GACf,aAAa,CAAC,aAAa,CAAC,CAe9B"}
|
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
// Channel geometry moved from the canvas2d adapter's per-kind renderers
|
|
5
|
+
// examples/canvas2d-adapter/src/render/draw/{trendChannel,
|
|
6
|
+
// flatTopBottom,disjointChannel,regressionTrend}.ts.
|
|
7
|
+
// The originating math is invinite's trend-channel / flat-top-bottom /
|
|
8
|
+
// disjoint-channel / regression-trend tools (commit
|
|
9
|
+
// 078f41fe2569d659d5aba726da8bcb5d3e2ced02, © Invinite); re-licensed
|
|
10
|
+
// MIT for chartlang.
|
|
11
|
+
import { dashPattern } from "../_lib/dash.js";
|
|
12
|
+
import { strokeOf } from "../_lib/strokeStyle.js";
|
|
13
|
+
import { worldPointToPixel } from "../project.js";
|
|
14
|
+
const DEFAULT_LINE_WIDTH = 1;
|
|
15
|
+
/**
|
|
16
|
+
* Default stroke colour of a `regression-trend` placeholder line —
|
|
17
|
+
* `#3b82f6`, matching the canvas2d source renderer.
|
|
18
|
+
*/
|
|
19
|
+
const REGRESSION_DEFAULT_COLOR = "#3b82f6";
|
|
20
|
+
/**
|
|
21
|
+
* Decompose a `trend-channel` drawing — two parallel line segments. The
|
|
22
|
+
* primary rail runs `anchors[0]` → `anchors[1]`; the second rail is its
|
|
23
|
+
* translate by the offset vector `anchors[2] − anchors[0]`, keeping the
|
|
24
|
+
* pair strictly parallel. Stroke-only — `LineDrawStyle` carries no fill,
|
|
25
|
+
* so there is no inter-rail band (matching the canvas2d source).
|
|
26
|
+
*
|
|
27
|
+
* @since 1.3
|
|
28
|
+
* @stable
|
|
29
|
+
* @example
|
|
30
|
+
* declare const s: TrendChannelState;
|
|
31
|
+
* declare const v: Viewport;
|
|
32
|
+
* const prims = decomposeTrendChannel(s, v);
|
|
33
|
+
* // prims.length === 2
|
|
34
|
+
* void prims;
|
|
35
|
+
*/
|
|
36
|
+
export function decomposeTrendChannel(state, view) {
|
|
37
|
+
const a = worldPointToPixel(state.anchors[0], view);
|
|
38
|
+
const b = worldPointToPixel(state.anchors[1], view);
|
|
39
|
+
const hook = worldPointToPixel(state.anchors[2], view);
|
|
40
|
+
const dx = hook.x - a.x;
|
|
41
|
+
const dy = hook.y - a.y;
|
|
42
|
+
const stroke = strokeOf(state.style);
|
|
43
|
+
return [
|
|
44
|
+
{ kind: "polyline", points: [a, b], closed: false, stroke },
|
|
45
|
+
{
|
|
46
|
+
kind: "polyline",
|
|
47
|
+
points: [
|
|
48
|
+
{ x: a.x + dx, y: a.y + dy },
|
|
49
|
+
{ x: b.x + dx, y: b.y + dy },
|
|
50
|
+
],
|
|
51
|
+
closed: false,
|
|
52
|
+
stroke,
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Decompose a `flat-top-bottom` drawing — two horizontal rails. The top
|
|
58
|
+
* rail sits at `max(anchors[0].price, anchors[2].price)` and the bottom
|
|
59
|
+
* at `min(...)`; both span the time range `anchors[0].time` →
|
|
60
|
+
* `anchors[1].time`. Stroke-only.
|
|
61
|
+
*
|
|
62
|
+
* @since 1.3
|
|
63
|
+
* @stable
|
|
64
|
+
* @example
|
|
65
|
+
* declare const s: FlatTopBottomState;
|
|
66
|
+
* declare const v: Viewport;
|
|
67
|
+
* const prims = decomposeFlatTopBottom(s, v);
|
|
68
|
+
* // prims.length === 2
|
|
69
|
+
* void prims;
|
|
70
|
+
*/
|
|
71
|
+
export function decomposeFlatTopBottom(state, view) {
|
|
72
|
+
const p0 = state.anchors[0];
|
|
73
|
+
const p1 = state.anchors[1];
|
|
74
|
+
const p2 = state.anchors[2];
|
|
75
|
+
const topPrice = Math.max(p0.price, p2.price);
|
|
76
|
+
const bottomPrice = Math.min(p0.price, p2.price);
|
|
77
|
+
const topLeft = worldPointToPixel({ time: p0.time, price: topPrice }, view);
|
|
78
|
+
const topRight = worldPointToPixel({ time: p1.time, price: topPrice }, view);
|
|
79
|
+
const bottomLeft = worldPointToPixel({ time: p0.time, price: bottomPrice }, view);
|
|
80
|
+
const bottomRight = worldPointToPixel({ time: p1.time, price: bottomPrice }, view);
|
|
81
|
+
const stroke = strokeOf(state.style);
|
|
82
|
+
return [
|
|
83
|
+
{ kind: "polyline", points: [topLeft, topRight], closed: false, stroke },
|
|
84
|
+
{ kind: "polyline", points: [bottomLeft, bottomRight], closed: false, stroke },
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Decompose a `disjoint-channel` drawing — two independent line segments
|
|
89
|
+
* with no shared geometry constraint: `anchors[0]` → `anchors[1]` and
|
|
90
|
+
* `anchors[2]` → `anchors[3]`. Stroke-only.
|
|
91
|
+
*
|
|
92
|
+
* @since 1.3
|
|
93
|
+
* @stable
|
|
94
|
+
* @example
|
|
95
|
+
* declare const s: DisjointChannelState;
|
|
96
|
+
* declare const v: Viewport;
|
|
97
|
+
* const prims = decomposeDisjointChannel(s, v);
|
|
98
|
+
* // prims.length === 2
|
|
99
|
+
* void prims;
|
|
100
|
+
*/
|
|
101
|
+
export function decomposeDisjointChannel(state, view) {
|
|
102
|
+
const a = worldPointToPixel(state.anchors[0], view);
|
|
103
|
+
const b = worldPointToPixel(state.anchors[1], view);
|
|
104
|
+
const c = worldPointToPixel(state.anchors[2], view);
|
|
105
|
+
const d = worldPointToPixel(state.anchors[3], view);
|
|
106
|
+
const stroke = strokeOf(state.style);
|
|
107
|
+
return [
|
|
108
|
+
{ kind: "polyline", points: [a, b], closed: false, stroke },
|
|
109
|
+
{ kind: "polyline", points: [c, d], closed: false, stroke },
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Decompose a `regression-trend` drawing — a single placeholder line
|
|
114
|
+
* between the two anchors, colour `style.color ?? "#3b82f6"`, width 1,
|
|
115
|
+
* solid. The OLS fit + ±σ bands the `RegressionTrendOpts` flags
|
|
116
|
+
* (`source` / `stdevMultiplier` / `showUpperBand` / `showLowerBand`)
|
|
117
|
+
* describe require a bar buffer the `Viewport` does not expose and band
|
|
118
|
+
* anchors the 2-point `state.anchors` does not carry; the canvas2d
|
|
119
|
+
* source renders the same placeholder line, so this decomposer preserves
|
|
120
|
+
* that geometry. Those style fields are accepted but unused here —
|
|
121
|
+
* consumer adapters with a bar buffer can compute the fit themselves.
|
|
122
|
+
*
|
|
123
|
+
* @since 1.3
|
|
124
|
+
* @stable
|
|
125
|
+
* @example
|
|
126
|
+
* declare const s: RegressionTrendState;
|
|
127
|
+
* declare const v: Viewport;
|
|
128
|
+
* const prims = decomposeRegressionTrend(s, v);
|
|
129
|
+
* // prims.length === 1; prims[0].kind === "polyline"
|
|
130
|
+
* void prims;
|
|
131
|
+
*/
|
|
132
|
+
export function decomposeRegressionTrend(state, view) {
|
|
133
|
+
const a = worldPointToPixel(state.anchors[0], view);
|
|
134
|
+
const b = worldPointToPixel(state.anchors[1], view);
|
|
135
|
+
return [
|
|
136
|
+
{
|
|
137
|
+
kind: "polyline",
|
|
138
|
+
points: [a, b],
|
|
139
|
+
closed: false,
|
|
140
|
+
stroke: {
|
|
141
|
+
color: state.style.color ?? REGRESSION_DEFAULT_COLOR,
|
|
142
|
+
width: DEFAULT_LINE_WIDTH,
|
|
143
|
+
dash: dashPattern("solid"),
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=channels.js.map
|
|
@@ -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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CAAC;IACpD,MAAM,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACpD,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,EAAE,KAAK,EAAE,MAAM,EAAE;QAC3D,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,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
|