@motionscript/patterns 0.1.0-alpha.4 → 0.1.0-alpha.6
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 +48 -16
- package/README.md +13 -9
- package/dist/browser/chunks/chunk-REWLNFZ2.js +2 -0
- package/dist/browser/chunks/chunk-REWLNFZ2.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/dot-grid-pattern/dot-grid-pattern.d.ts +68 -27
- package/dist/dot-grid-pattern/dot-grid-pattern.d.ts.map +1 -1
- package/dist/dot-grid-pattern/dot-grid-pattern.js +71 -75
- package/dist/dot-grid-pattern/dot-grid-pattern.js.map +1 -1
- package/dist/engine.d.ts +4 -4
- package/dist/engine.js +4 -4
- package/dist/engine.js.map +1 -1
- package/dist/grid-pattern/grid-pattern.d.ts +59 -26
- package/dist/grid-pattern/grid-pattern.d.ts.map +1 -1
- package/dist/grid-pattern/grid-pattern.js +83 -102
- package/dist/grid-pattern/grid-pattern.js.map +1 -1
- package/dist/kit/grid-lines.d.ts +7 -0
- package/dist/kit/grid-lines.d.ts.map +1 -1
- package/dist/kit/grid-lines.js +21 -0
- package/dist/kit/grid-lines.js.map +1 -1
- package/dist/kit/index.d.ts +1 -1
- package/dist/kit/index.d.ts.map +1 -1
- package/dist/kit/index.js +1 -1
- package/dist/kit/index.js.map +1 -1
- package/dist/kit/viewport-pattern.d.ts +75 -30
- package/dist/kit/viewport-pattern.d.ts.map +1 -1
- package/dist/kit/viewport-pattern.js +66 -69
- package/dist/kit/viewport-pattern.js.map +1 -1
- package/dist/line-grid-pattern/line-grid-pattern.d.ts +56 -23
- package/dist/line-grid-pattern/line-grid-pattern.d.ts.map +1 -1
- package/dist/line-grid-pattern/line-grid-pattern.js +63 -88
- package/dist/line-grid-pattern/line-grid-pattern.js.map +1 -1
- package/dist/nodes.d.ts +8 -3
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +5 -10
- package/dist/nodes.js.map +1 -1
- package/package.json +4 -4
- package/src/dot-grid-pattern/dot-grid-pattern.ts +101 -78
- package/src/engine.ts +4 -4
- package/src/grid-pattern/grid-pattern.ts +126 -120
- package/src/kit/grid-lines.ts +25 -1
- package/src/kit/index.ts +1 -1
- package/src/kit/viewport-pattern.ts +89 -78
- package/src/line-grid-pattern/line-grid-pattern.ts +95 -103
- package/src/nodes.ts +16 -3
- package/dist/browser/chunks/chunk-EZEE76AY.js +0 -2
- package/dist/browser/chunks/chunk-EZEE76AY.js.map +0 -7
|
@@ -1,30 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface LineGridPatternProps extends ShapeProps {
|
|
3
|
-
/** Cells along each axis: `divisions` of 4 draws 5 major lines per axis. */
|
|
4
|
-
divisions: number;
|
|
5
|
-
/** Finer cells each division is split into. 1 draws no minor lines; 2 adds one per division. */
|
|
6
|
-
subdivisions: number;
|
|
7
|
-
/** Stroke for the minor lines. Defaults to the major `stroke` at half opacity when `subdivisions > 1`. */
|
|
8
|
-
subStroke?: Stroke;
|
|
9
|
-
/** Pans the grid. Lines wrap and tile, so the rect stays full while `offset` scrolls it. */
|
|
10
|
-
offset: Vector2;
|
|
11
|
-
}
|
|
1
|
+
import { type NodeOf, type Vector2, type Alignment as _Alignment, type Fill as _Fill, type FillResolved as _FillResolved, type FlowMode as _FlowMode, type FlowResolved as _FlowResolved, type GapSize as _GapSize, type Node2D as _Node2D, type Node2DProps as _Node2DProps, type Shadow as _Shadow, type ShadowResolved as _ShadowResolved, type Stroke as _Stroke, type StrokeResolved as _StrokeResolved } from "@motionscript/sdk";
|
|
12
2
|
/**
|
|
13
3
|
* A rectangular grid of lines filling the node's layout rect.
|
|
14
4
|
*
|
|
15
5
|
* `stroke` paints the major lines and `subStroke` the minor ones, each as a
|
|
16
6
|
* single union path. `fill` and `shadow` cover the whole rect, behind the lines.
|
|
17
7
|
*/
|
|
18
|
-
export declare
|
|
19
|
-
|
|
20
|
-
readonly
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
8
|
+
export declare const LineGridPattern: import("@motionscript/sdk").Component<"lineGridPattern", import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
9
|
+
/** Cells along each axis: `divisions` of 4 draws 5 major lines per axis. */
|
|
10
|
+
readonly divisions: 4;
|
|
11
|
+
/** Finer cells each division is split into. 1 draws no minor lines; 2 adds one per division. */
|
|
12
|
+
readonly subdivisions: 1;
|
|
13
|
+
/** Stroke for the minor lines. Unset, the major `stroke` at half opacity when `subdivisions > 1`. */
|
|
14
|
+
readonly subStroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
15
|
+
/** Pans the grid. Lines wrap and tile, so the rect stays full while `offset` scrolls it. */
|
|
16
|
+
readonly offset: import("@motionscript/sdk").Type<Vector2, Vector2, false>;
|
|
17
|
+
readonly flow: import("@motionscript/sdk").Type<_FlowMode, _FlowResolved, false>;
|
|
18
|
+
readonly gap: import("@motionscript/sdk").Type<_GapSize, _GapSize, false>;
|
|
19
|
+
readonly wrap: boolean;
|
|
20
|
+
readonly crossGap: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
21
|
+
readonly columns: import("@motionscript/sdk").Type<number, number, false>;
|
|
22
|
+
readonly align: import("@motionscript/sdk").Attribute<_Alignment, Vector2>;
|
|
23
|
+
readonly fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
|
|
24
|
+
readonly stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
25
|
+
readonly shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
26
|
+
readonly overlay: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
|
|
27
|
+
readonly start: import("@motionscript/sdk").Type<number, number, false>;
|
|
28
|
+
readonly end: import("@motionscript/sdk").Type<number, number, false>;
|
|
29
|
+
}>, {
|
|
30
|
+
readonly fillTo: readonly ["fill"];
|
|
31
|
+
readonly strokeTo: readonly ["stroke"];
|
|
32
|
+
readonly shadowTo: readonly ["shadow"];
|
|
33
|
+
readonly overlayTo: readonly ["overlay"];
|
|
34
|
+
readonly progressTo: readonly ["start", "end"];
|
|
35
|
+
readonly flash: {
|
|
36
|
+
readonly portion: import("@motionscript/sdk").Type<number, number, false>;
|
|
37
|
+
};
|
|
38
|
+
}, null, _Node2D<_Node2DProps>, import("@motionscript/sdk").CallProps<import("@motionscript/sdk").Merge<import("@motionscript/sdk").Box2DState, {
|
|
39
|
+
/** Cells along each axis: `divisions` of 4 draws 5 major lines per axis. */
|
|
40
|
+
readonly divisions: 4;
|
|
41
|
+
/** Finer cells each division is split into. 1 draws no minor lines; 2 adds one per division. */
|
|
42
|
+
readonly subdivisions: 1;
|
|
43
|
+
/** Stroke for the minor lines. Unset, the major `stroke` at half opacity when `subdivisions > 1`. */
|
|
44
|
+
readonly subStroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
45
|
+
/** Pans the grid. Lines wrap and tile, so the rect stays full while `offset` scrolls it. */
|
|
46
|
+
readonly offset: import("@motionscript/sdk").Type<Vector2, Vector2, false>;
|
|
47
|
+
readonly flow: import("@motionscript/sdk").Type<_FlowMode, _FlowResolved, false>;
|
|
48
|
+
readonly gap: import("@motionscript/sdk").Type<_GapSize, _GapSize, false>;
|
|
49
|
+
readonly wrap: boolean;
|
|
50
|
+
readonly crossGap: import("@motionscript/sdk").Type<number | undefined, number | undefined, false>;
|
|
51
|
+
readonly columns: import("@motionscript/sdk").Type<number, number, false>;
|
|
52
|
+
readonly align: import("@motionscript/sdk").Attribute<_Alignment, Vector2>;
|
|
53
|
+
readonly fill: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
|
|
54
|
+
readonly stroke: import("@motionscript/sdk").Attribute<_Stroke, _StrokeResolved[]>;
|
|
55
|
+
readonly shadow: import("@motionscript/sdk").Attribute<_Shadow, _ShadowResolved[]>;
|
|
56
|
+
readonly overlay: import("@motionscript/sdk").Attribute<_Fill, _FillResolved[]>;
|
|
57
|
+
readonly start: import("@motionscript/sdk").Type<number, number, false>;
|
|
58
|
+
readonly end: import("@motionscript/sdk").Type<number, number, false>;
|
|
59
|
+
}>, null>>;
|
|
60
|
+
export type LineGridPattern = NodeOf<typeof LineGridPattern>;
|
|
61
|
+
/** What a call or a document row may set. */
|
|
62
|
+
export type LineGridPatternProps = NonNullable<Parameters<typeof LineGridPattern>[0]>;
|
|
30
63
|
//# sourceMappingURL=line-grid-pattern.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-grid-pattern.d.ts","sourceRoot":"","sources":["../../src/line-grid-pattern/line-grid-pattern.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"line-grid-pattern.d.ts","sourceRoot":"","sources":["../../src/line-grid-pattern/line-grid-pattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAOH,KAAK,MAAM,EAGX,KAAK,OAAO,EAEZ,KAAK,SAAS,IAAI,UAAU,EAC5B,KAAK,IAAI,IAAI,KAAK,EAClB,KAAK,YAAY,IAAI,aAAa,EAClC,KAAK,QAAQ,IAAI,SAAS,EAC1B,KAAK,YAAY,IAAI,aAAa,EAClC,KAAK,OAAO,IAAI,QAAQ,EACxB,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,WAAW,IAAI,YAAY,EAChC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACtC,KAAK,MAAM,IAAI,OAAO,EACtB,KAAK,cAAc,IAAI,eAAe,EACzC,MAAM,mBAAmB,CAAC;AAI3B;;;;;GAKG;AACH,eAAO,MAAM,eAAe;IAKpB,4EAA4E;;IAE5E,gGAAgG;;IAEhG,qGAAqG;;IAErG,4FAA4F;;;;;;;;;;;;;;;;;;;;;;;;IAN5F,4EAA4E;;IAE5E,gGAAgG;;IAEhG,qGAAqG;;IAErG,4FAA4F;;;;;;;;;;;;;;UAwClG,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAC7D,6CAA6C;AAC7C,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,96 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { Clip, Graphics2D, ShapeNode, lerpVector2, node, property, strokeProperty, } from "@motionscript/sdk";
|
|
8
|
-
import { centered, dimStroke, gridLinePaths, maxWeight } from "../kit/index.js";
|
|
1
|
+
import { Flow, Graphics2D, Paint, Types, component2d, lerpVector2, } from "@motionscript/sdk";
|
|
2
|
+
import { centered, defaultSubStroke, gridLinePaths, maxWeight } from "../kit/index.js";
|
|
9
3
|
/**
|
|
10
4
|
* A rectangular grid of lines filling the node's layout rect.
|
|
11
5
|
*
|
|
12
6
|
* `stroke` paints the major lines and `subStroke` the minor ones, each as a
|
|
13
7
|
* single union path. `fill` and `shadow` cover the whole rect, behind the lines.
|
|
14
8
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
clipSelf() {
|
|
61
|
-
return new Clip().rect({
|
|
62
|
-
width: this.layoutBounds.width,
|
|
63
|
-
height: this.layoutBounds.height,
|
|
9
|
+
export const LineGridPattern = component2d({
|
|
10
|
+
key: "lineGridPattern",
|
|
11
|
+
state: {
|
|
12
|
+
...Paint.state,
|
|
13
|
+
...Flow.state,
|
|
14
|
+
/** Cells along each axis: `divisions` of 4 draws 5 major lines per axis. */
|
|
15
|
+
divisions: 4,
|
|
16
|
+
/** Finer cells each division is split into. 1 draws no minor lines; 2 adds one per division. */
|
|
17
|
+
subdivisions: 1,
|
|
18
|
+
/** Stroke for the minor lines. Unset, the major `stroke` at half opacity when `subdivisions > 1`. */
|
|
19
|
+
subStroke: Types.stroke,
|
|
20
|
+
/** Pans the grid. Lines wrap and tile, so the rect stays full while `offset` scrolls it. */
|
|
21
|
+
offset: Types.custom({ x: 0, y: 0 }, { lerp: lerpVector2 }),
|
|
22
|
+
},
|
|
23
|
+
defaults: { subStroke: (_state, given) => defaultSubStroke(given) },
|
|
24
|
+
commands: { ...Paint.commands },
|
|
25
|
+
measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),
|
|
26
|
+
layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),
|
|
27
|
+
render: (ctx, state) => {
|
|
28
|
+
const { width, height } = ctx.size;
|
|
29
|
+
const box = new Graphics2D().rect({ width, height });
|
|
30
|
+
ctx.inFront(() => {
|
|
31
|
+
ctx.draw(new Graphics2D()
|
|
32
|
+
.rect({ width, height, start: state.start, end: state.end })
|
|
33
|
+
.shadow(state.shadow)
|
|
34
|
+
.fill(state.fill));
|
|
35
|
+
const divisions = Math.max(1, Math.floor(state.divisions));
|
|
36
|
+
const subdivisions = Math.max(1, Math.floor(state.subdivisions));
|
|
37
|
+
// Lines overscan the rect by half the thickest stroke and are clipped to it, so a
|
|
38
|
+
// thick line slides out under the clip instead of popping at the boundary.
|
|
39
|
+
const major = centered(state.stroke);
|
|
40
|
+
const minorStroke = centered(state.subStroke);
|
|
41
|
+
const overscan = Math.max(maxWeight(major), maxWeight(minorStroke)) / 2;
|
|
42
|
+
const lines = gridPaths(width, height, divisions, subdivisions, overscan, state.offset);
|
|
43
|
+
const centerBounds = [-width / 2, -height / 2, width / 2, height / 2];
|
|
44
|
+
ctx.clip(box, () => {
|
|
45
|
+
// Minor lines first so the major lines sit on top.
|
|
46
|
+
if (subdivisions > 1 && minorStroke.length > 0 && lines.minor.length > 0) {
|
|
47
|
+
ctx.draw(new Graphics2D().path({ data: lines.minor, centerBounds }).stroke(minorStroke));
|
|
48
|
+
}
|
|
49
|
+
if (lines.major.length > 0) {
|
|
50
|
+
ctx.draw(new Graphics2D().path({ data: lines.major, centerBounds }).stroke(major));
|
|
51
|
+
}
|
|
52
|
+
});
|
|
64
53
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
], LineGridPattern.prototype, "divisions", void 0);
|
|
83
|
-
__decorate([
|
|
84
|
-
property({ default: 1 })
|
|
85
|
-
], LineGridPattern.prototype, "subdivisions", void 0);
|
|
86
|
-
__decorate([
|
|
87
|
-
strokeProperty()
|
|
88
|
-
], LineGridPattern.prototype, "subStroke", null);
|
|
89
|
-
__decorate([
|
|
90
|
-
property({ default: { x: 0, y: 0 }, tween: lerpVector2 })
|
|
91
|
-
], LineGridPattern.prototype, "offset", void 0);
|
|
92
|
-
LineGridPattern = __decorate([
|
|
93
|
-
node({ key: "lineGridPattern", parentKey: "shape", forkable: true })
|
|
94
|
-
], LineGridPattern);
|
|
95
|
-
export { LineGridPattern };
|
|
54
|
+
// The rect is what `clip` confines the children to and what picking tests; it paints nothing more.
|
|
55
|
+
Paint.draw(ctx, state, null, { clipShape: box });
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
// One multi-subpath path per group, so each stroke paints its lines as a union with no
|
|
59
|
+
// destructive boolean op (which would erase open lines).
|
|
60
|
+
function gridPaths(width, height, divisions, subdivisions, overscan, offset) {
|
|
61
|
+
// Inset by `overscan` so the outermost lines sit fully inside the rect and are not
|
|
62
|
+
// trimmed to half weight by the clip.
|
|
63
|
+
const cols = divisions * subdivisions;
|
|
64
|
+
const innerW = Math.max(0, width - 2 * overscan);
|
|
65
|
+
const innerH = Math.max(0, height - 2 * overscan);
|
|
66
|
+
const insetX = width / 2 - overscan;
|
|
67
|
+
const insetY = height / 2 - overscan;
|
|
68
|
+
// Anchored at the near edge, so a line sits on each edge of the box for any count of cells.
|
|
69
|
+
return gridLinePaths({ min: -insetX, max: insetX, step: innerW / cols, offset: offset.x, anchor: -insetX }, { min: -insetY, max: insetY, step: innerH / cols, offset: offset.y, anchor: -insetY }, subdivisions, overscan);
|
|
70
|
+
}
|
|
96
71
|
//# sourceMappingURL=line-grid-pattern.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-grid-pattern.js","sourceRoot":"","sources":["../../src/line-grid-pattern/line-grid-pattern.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"line-grid-pattern.js","sourceRoot":"","sources":["../../src/line-grid-pattern/line-grid-pattern.ts"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AI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,KAAK,GAAG,CAAC,GAAG,QAAQ,CAAC;IACpC,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,GAAG,QAAQ,CAAC;IAErC,4FAA4F;IAC5F,OAAO,aAAa,CAChB,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,EACrF,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,EACrF,YAAY,EACZ,QAAQ,CACX,CAAC;AACN,CAAC","sourcesContent":["import {\r\n Flow,\r\n Graphics2D,\r\n Paint,\r\n Types,\r\n component2d,\r\n lerpVector2,\r\n type NodeOf,\r\n type PathBounds,\r\n type PathCommand,\r\n type Vector2,\r\n // Named so the emitted declaration reaches these through the sdk, not core.\r\n type Alignment as _Alignment,\r\n type Fill as _Fill,\r\n type FillResolved as _FillResolved,\r\n type FlowMode as _FlowMode,\r\n type FlowResolved as _FlowResolved,\r\n type GapSize as _GapSize,\r\n type Node2D as _Node2D,\r\n type Node2DProps as _Node2DProps,\r\n type Shadow as _Shadow,\r\n type ShadowResolved as _ShadowResolved,\r\n type Stroke as _Stroke,\r\n type StrokeResolved as _StrokeResolved,\r\n} from \"@motionscript/sdk\";\r\n\r\nimport { centered, defaultSubStroke, gridLinePaths, maxWeight } from \"../kit\";\r\n\r\n/**\r\n * A rectangular grid of lines filling the node's layout rect.\r\n *\r\n * `stroke` paints the major lines and `subStroke` the minor ones, each as a\r\n * single union path. `fill` and `shadow` cover the whole rect, behind the lines.\r\n */\r\nexport const LineGridPattern = component2d({\r\n key: \"lineGridPattern\",\r\n state: {\r\n ...Paint.state,\r\n ...Flow.state,\r\n /** Cells along each axis: `divisions` of 4 draws 5 major lines per axis. */\r\n divisions: 4,\r\n /** Finer cells each division is split into. 1 draws no minor lines; 2 adds one per division. */\r\n subdivisions: 1,\r\n /** Stroke for the minor lines. Unset, the major `stroke` at half opacity when `subdivisions > 1`. */\r\n subStroke: Types.stroke,\r\n /** Pans the grid. Lines wrap and tile, so the rect stays full while `offset` scrolls it. */\r\n offset: Types.custom<Vector2>({ x: 0, y: 0 }, { lerp: lerpVector2 }),\r\n },\r\n defaults: { subStroke: (_state, given) => defaultSubStroke(given) },\r\n commands: { ...Paint.commands },\r\n measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),\r\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\r\n render: (ctx, state) => {\r\n const { width, height } = ctx.size;\r\n const box = new Graphics2D().rect({ width, height });\r\n ctx.inFront(() => {\r\n ctx.draw(new Graphics2D()\r\n .rect({ width, height, start: state.start, end: state.end })\r\n .shadow(state.shadow)\r\n .fill(state.fill));\r\n\r\n const divisions = Math.max(1, Math.floor(state.divisions));\r\n const subdivisions = Math.max(1, Math.floor(state.subdivisions));\r\n\r\n // Lines overscan the rect by half the thickest stroke and are clipped to it, so a\r\n // thick line slides out under the clip instead of popping at the boundary.\r\n const major = centered(state.stroke);\r\n const minorStroke = centered(state.subStroke);\r\n const overscan = Math.max(maxWeight(major), maxWeight(minorStroke)) / 2;\r\n const lines = gridPaths(width, height, divisions, subdivisions, overscan, state.offset);\r\n const centerBounds: PathBounds = [-width / 2, -height / 2, width / 2, height / 2];\r\n\r\n ctx.clip(box, () => {\r\n // Minor lines first so the major lines sit on top.\r\n if (subdivisions > 1 && minorStroke.length > 0 && lines.minor.length > 0) {\r\n ctx.draw(new Graphics2D().path({ data: lines.minor, centerBounds }).stroke(minorStroke));\r\n }\r\n if (lines.major.length > 0) {\r\n ctx.draw(new Graphics2D().path({ data: lines.major, centerBounds }).stroke(major));\r\n }\r\n });\r\n });\r\n // The rect is what `clip` confines the children to and what picking tests; it paints nothing more.\r\n Paint.draw(ctx, state, null, { clipShape: box });\r\n },\r\n});\r\n\r\nexport type LineGridPattern = NodeOf<typeof LineGridPattern>;\r\n/** What a call or a document row may set. */\r\nexport type LineGridPatternProps = NonNullable<Parameters<typeof LineGridPattern>[0]>;\r\n\r\n// One multi-subpath path per group, so each stroke paints its lines as a union with no\r\n// destructive boolean op (which would erase open lines).\r\nfunction gridPaths(\r\n width: number,\r\n height: number,\r\n divisions: number,\r\n subdivisions: number,\r\n overscan: number,\r\n offset: Vector2,\r\n): { major: PathCommand[]; minor: PathCommand[] } {\r\n // Inset by `overscan` so the outermost lines sit fully inside the rect and are not\r\n // trimmed to half weight by the clip.\r\n const cols = divisions * subdivisions;\r\n const innerW = Math.max(0, width - 2 * overscan);\r\n const innerH = Math.max(0, height - 2 * overscan);\r\n const insetX = width / 2 - overscan;\r\n const insetY = height / 2 - overscan;\r\n\r\n // Anchored at the near edge, so a line sits on each edge of the box for any count of cells.\r\n return gridLinePaths(\r\n { min: -insetX, max: insetX, step: innerW / cols, offset: offset.x, anchor: -insetX },\r\n { min: -insetY, max: insetY, step: innerH / cols, offset: offset.y, anchor: -insetY },\r\n subdivisions,\r\n overscan,\r\n );\r\n}\r\n"]}
|
package/dist/nodes.d.ts
CHANGED
|
@@ -5,10 +5,15 @@ import { LineGridPattern } from "./line-grid-pattern/index.js";
|
|
|
5
5
|
* Every node type this package publishes.
|
|
6
6
|
*
|
|
7
7
|
* A host registers these by handing the array to an engine —
|
|
8
|
-
* `new Engine(platform, { nodes: NODES })` — which reads each
|
|
9
|
-
*
|
|
8
|
+
* `new Engine(platform, { nodes: NODES })` — which reads each component's key.
|
|
9
|
+
* Defining a component only *declares* that key: nothing is registered by
|
|
10
|
+
* importing a module, so a registry holds exactly what its owner asked for.
|
|
11
|
+
*
|
|
12
|
+
* Listing the component **values** is also what survives bundling: this package
|
|
10
13
|
* declares `sideEffects: false`, and a document names a node type by string, so
|
|
11
14
|
* an import kept only for its side effect is exactly what gets shaken out.
|
|
12
15
|
*/
|
|
13
|
-
|
|
16
|
+
type KitNode = typeof LineGridPattern | typeof DotGridPattern | typeof GridPattern;
|
|
17
|
+
export declare const NODES: KitNode[];
|
|
18
|
+
export {};
|
|
14
19
|
//# sourceMappingURL=nodes.d.ts.map
|
package/dist/nodes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD;;;;;;;;;;;GAWG;AAEH,KAAK,OAAO,GACN,OAAO,eAAe,GACtB,OAAO,cAAc,GACrB,OAAO,WAAW,CAAA;AAExB,eAAO,MAAM,KAAK,EAAE,OAAO,EAI1B,CAAA"}
|
package/dist/nodes.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { DotGridPattern } from "./dot-grid-pattern/index.js";
|
|
2
2
|
import { GridPattern } from "./grid-pattern/index.js";
|
|
3
3
|
import { LineGridPattern } from "./line-grid-pattern/index.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* key. Listing class **values** is also what survives bundling: this package
|
|
10
|
-
* declares `sideEffects: false`, and a document names a node type by string, so
|
|
11
|
-
* an import kept only for its side effect is exactly what gets shaken out.
|
|
12
|
-
*/
|
|
13
|
-
export const NODES = [LineGridPattern, DotGridPattern, GridPattern];
|
|
4
|
+
export const NODES = [
|
|
5
|
+
LineGridPattern,
|
|
6
|
+
DotGridPattern,
|
|
7
|
+
GridPattern,
|
|
8
|
+
];
|
|
14
9
|
//# sourceMappingURL=nodes.js.map
|
package/dist/nodes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAoBrD,MAAM,CAAC,MAAM,KAAK,GAAc;IAC5B,eAAe;IACf,cAAc;IACd,WAAW;CACd,CAAA","sourcesContent":["import { DotGridPattern } from \"./dot-grid-pattern\"\r\nimport { GridPattern } from \"./grid-pattern\"\r\nimport { LineGridPattern } from \"./line-grid-pattern\"\r\n\r\n/**\r\n * Every node type this package publishes.\r\n *\r\n * A host registers these by handing the array to an engine —\r\n * `new Engine(platform, { nodes: NODES })` — which reads each component's key.\r\n * Defining a component only *declares* that key: nothing is registered by\r\n * importing a module, so a registry holds exactly what its owner asked for.\r\n *\r\n * Listing the component **values** is also what survives bundling: this package\r\n * declares `sideEffects: false`, and a document names a node type by string, so\r\n * an import kept only for its side effect is exactly what gets shaken out.\r\n */\r\n// Typed by name, so the declaration names each component rather than spelling out its type through core.\r\ntype KitNode =\r\n | typeof LineGridPattern\r\n | typeof DotGridPattern\r\n | typeof GridPattern\r\n\r\nexport const NODES: KitNode[] = [\r\n LineGridPattern,\r\n DotGridPattern,\r\n GridPattern,\r\n]\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motionscript/patterns",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Background patterns for Motion Script: line and dot grids that fill a box, and an infinite grid that fills whatever a camera can see.",
|
|
6
6
|
"repository": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
],
|
|
51
51
|
"license": "Apache-2.0",
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@motionscript/sdk": "^0.1.0-alpha.
|
|
53
|
+
"@motionscript/sdk": "^0.1.0-alpha.6"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "^25.6.2",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"typescript": "^6.0.3",
|
|
62
62
|
"typescript-eslint": "^8.48.0",
|
|
63
63
|
"vitest": "^4.1.5",
|
|
64
|
-
"@motionscript/core": "0.1.0-alpha.
|
|
65
|
-
"@motionscript/sdk": "0.1.0-alpha.
|
|
64
|
+
"@motionscript/core": "0.1.0-alpha.6",
|
|
65
|
+
"@motionscript/sdk": "0.1.0-alpha.6"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json --resolve-full-paths && node ../../../scripts/build-browser.mjs",
|