@cardanvil/frame-kit 0.6.0 → 0.7.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/README.md +75 -1
- package/dist/authoring/collectorInfo.d.ts +17 -0
- package/dist/authoring/collectorInfo.js +62 -0
- package/dist/authoring/index.d.ts +2 -0
- package/dist/authoring/index.js +2 -0
- package/dist/authoring/layoutDefaults.d.ts +20 -2
- package/dist/authoring/layoutDefaults.js +48 -13
- package/dist/authoring/opacityStops.d.ts +8 -0
- package/dist/authoring/opacityStops.js +17 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/cli/loadFrame.js +1 -1
- package/dist/cli/main.js +72 -0
- package/dist/cli/studio/boxSets.js +11 -8
- package/dist/cli/studio/serve.js +4 -1
- package/dist/cli/trim.d.ts +62 -0
- package/dist/cli/trim.js +251 -0
- package/dist/layout/border.d.ts +27 -0
- package/dist/layout/border.js +31 -0
- package/dist/layout/boxOverrides.d.ts +28 -0
- package/dist/layout/boxOverrides.js +95 -0
- package/dist/layout/color.d.ts +23 -0
- package/dist/layout/color.js +53 -0
- package/dist/layout/cutouts.d.ts +28 -0
- package/dist/layout/cutouts.js +29 -0
- package/dist/layout/decorations.d.ts +1 -6
- package/dist/layout/decorations.js +7 -11
- package/dist/layout/frameLayers.d.ts +29 -2
- package/dist/layout/frameLayers.js +145 -3
- package/dist/layout/index.d.ts +17 -6
- package/dist/layout/index.js +17 -6
- package/dist/layout/paint.d.ts +36 -0
- package/dist/layout/paint.js +148 -0
- package/dist/layout/powerToughnessRow.d.ts +26 -0
- package/dist/layout/powerToughnessRow.js +13 -0
- package/dist/layout/resolveFrameAsset.d.ts +6 -0
- package/dist/layout/resolveFrameAsset.js +8 -0
- package/dist/layout/rulesSlide.d.ts +13 -0
- package/dist/layout/rulesSlide.js +33 -0
- package/dist/layout/settings.d.ts +26 -0
- package/dist/layout/settings.js +62 -0
- package/dist/layout/textStyle.d.ts +29 -0
- package/dist/layout/textStyle.js +28 -0
- package/dist/layout/turn.d.ts +54 -0
- package/dist/layout/turn.js +107 -0
- package/dist/manifest/contract.d.ts +6074 -9392
- package/dist/manifest/contract.js +46 -1
- package/dist/manifest/testFrame.js +9 -0
- package/dist/schema/collectorInfo.d.ts +95 -0
- package/dist/schema/collectorInfo.js +80 -0
- package/dist/schema/condition.d.ts +67 -0
- package/dist/schema/condition.js +47 -0
- package/dist/schema/frame.d.ts +17291 -25435
- package/dist/schema/frame.js +402 -14
- package/dist/schema/frameAssets.d.ts +53 -33
- package/dist/schema/frameAssets.js +77 -5
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/index.js +3 -0
- package/dist/schema/layout.d.ts +29 -4
- package/dist/schema/layout.js +27 -2
- package/dist/schema/paint.d.ts +202 -0
- package/dist/schema/paint.js +109 -0
- package/dist/studio/assets/index-BnhNwm_r.js +74 -0
- package/dist/studio/index.html +1 -1
- package/package.json +5 -3
- package/dist/studio/assets/index-CNzyV22G.js +0 -76
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** The color plain-text drop shadows are drawn in. */
|
|
2
|
+
export const TEXT_SHADOW_COLOR = "#17191b";
|
|
3
|
+
/** A box's outline, when it sets both an `outlineColor` and an `outlineWidth`. */
|
|
4
|
+
export function textOutlineFor(box) {
|
|
5
|
+
return box.outlineColor && box.outlineWidth
|
|
6
|
+
? { color: box.outlineColor, width: box.outlineWidth }
|
|
7
|
+
: undefined;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The drop shadow a plain-text box — title, type, P/T, nickname title,
|
|
11
|
+
* collector info — is drawn with: only when it asks for one with `shadow`,
|
|
12
|
+
* and never alongside an outline, which always wins. The offsets default to
|
|
13
|
+
* fractions of the box's `fontSize`, unless the box sets its own.
|
|
14
|
+
*
|
|
15
|
+
* Symbols read `shadow` differently (on unless turned off), so this is for
|
|
16
|
+
* plain text only.
|
|
17
|
+
*/
|
|
18
|
+
export function textShadowFor(box) {
|
|
19
|
+
if (!box.shadow || textOutlineFor(box)) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
color: TEXT_SHADOW_COLOR,
|
|
24
|
+
offsetX: box.shadowOffsetX ?? -(box.fontSize * 0.029),
|
|
25
|
+
offsetY: box.shadowOffsetY ?? box.fontSize * 0.075,
|
|
26
|
+
blur: box.shadowBlur ?? 0,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Bounds, Rotation } from "../schema/frame.js";
|
|
2
|
+
/**
|
|
3
|
+
* The geometry of a turned box set — one whose `rotation` says the card is
|
|
4
|
+
* turned to read it (see `CardBoxesSchema`).
|
|
5
|
+
*
|
|
6
|
+
* Two spaces are in play. The **sheet** is the canvas as printed, and never
|
|
7
|
+
* turns. A set's **turned space** is that sheet as it lies once the card has
|
|
8
|
+
* been turned `rotation` degrees clockwise, which is where the set's boxes are
|
|
9
|
+
* measured. Everything here maps the second onto the first.
|
|
10
|
+
*/
|
|
11
|
+
export interface Size {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}
|
|
15
|
+
export interface Point {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A 2D affine transform in the order a canvas takes one:
|
|
21
|
+
* `x' = a·x + c·y + e`, `y' = b·x + d·y + f`.
|
|
22
|
+
*/
|
|
23
|
+
export type Matrix = readonly [
|
|
24
|
+
a: number,
|
|
25
|
+
b: number,
|
|
26
|
+
c: number,
|
|
27
|
+
d: number,
|
|
28
|
+
e: number,
|
|
29
|
+
f: number
|
|
30
|
+
];
|
|
31
|
+
/** The sheet as a turned set sees it: a quarter turn swaps its sides. */
|
|
32
|
+
export declare function turnedSheetSize(sheet: Size, rotation: Rotation | undefined): Size;
|
|
33
|
+
/**
|
|
34
|
+
* Where a turned set's origin lands on the sheet and how far it is rotated
|
|
35
|
+
* there, in degrees clockwise — the `x`, `y` and `rotation` of a node that
|
|
36
|
+
* draws the set. Turning the card clockwise to read a set means the set
|
|
37
|
+
* itself sits counter-clockwise on the sheet, hence the opposite sign.
|
|
38
|
+
*/
|
|
39
|
+
export declare function turnPlacement(sheet: Size, rotation: Rotation | undefined): Point & {
|
|
40
|
+
rotation: number;
|
|
41
|
+
};
|
|
42
|
+
/** {@link turnPlacement} as a matrix taking turned space to the sheet. */
|
|
43
|
+
export declare function turnMatrix(sheet: Size, rotation: Rotation | undefined): Matrix;
|
|
44
|
+
/** A point in a matrix's source space, in its target space. */
|
|
45
|
+
export declare function applyMatrix(matrix: Matrix, point: Point): Point;
|
|
46
|
+
/** The rectangle a turned set's box covers on the sheet. */
|
|
47
|
+
export declare function turnedBoundsOnSheet(bounds: Bounds, sheet: Size, rotation: Rotation | undefined): Bounds;
|
|
48
|
+
/**
|
|
49
|
+
* A direction in a turned set's space, as a direction on the sheet. Only the
|
|
50
|
+
* turn applies; a direction has no position to translate.
|
|
51
|
+
*/
|
|
52
|
+
export declare function turnedVectorOnSheet(vector: Point, rotation: Rotation | undefined): Point;
|
|
53
|
+
/** The reverse of {@link turnedVectorOnSheet}. */
|
|
54
|
+
export declare function sheetVectorInTurned(vector: Point, rotation: Rotation | undefined): Point;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/** The sheet as a turned set sees it: a quarter turn swaps its sides. */
|
|
2
|
+
export function turnedSheetSize(sheet, rotation) {
|
|
3
|
+
return rotation === 90 || rotation === 270
|
|
4
|
+
? { width: sheet.height, height: sheet.width }
|
|
5
|
+
: { width: sheet.width, height: sheet.height };
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Where a turned set's origin lands on the sheet and how far it is rotated
|
|
9
|
+
* there, in degrees clockwise — the `x`, `y` and `rotation` of a node that
|
|
10
|
+
* draws the set. Turning the card clockwise to read a set means the set
|
|
11
|
+
* itself sits counter-clockwise on the sheet, hence the opposite sign.
|
|
12
|
+
*/
|
|
13
|
+
export function turnPlacement(sheet, rotation) {
|
|
14
|
+
switch (rotation) {
|
|
15
|
+
case 90:
|
|
16
|
+
return { x: 0, y: sheet.height, rotation: -90 };
|
|
17
|
+
case 180:
|
|
18
|
+
return { x: sheet.width, y: sheet.height, rotation: 180 };
|
|
19
|
+
case 270:
|
|
20
|
+
return { x: sheet.width, y: 0, rotation: 90 };
|
|
21
|
+
default:
|
|
22
|
+
return { x: 0, y: 0, rotation: 0 };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** {@link turnPlacement} as a matrix taking turned space to the sheet. */
|
|
26
|
+
export function turnMatrix(sheet, rotation) {
|
|
27
|
+
switch (rotation) {
|
|
28
|
+
case 90:
|
|
29
|
+
return [0, -1, 1, 0, 0, sheet.height];
|
|
30
|
+
case 180:
|
|
31
|
+
return [-1, 0, 0, -1, sheet.width, sheet.height];
|
|
32
|
+
case 270:
|
|
33
|
+
return [0, 1, -1, 0, sheet.width, 0];
|
|
34
|
+
default:
|
|
35
|
+
return [1, 0, 0, 1, 0, 0];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** A point in a matrix's source space, in its target space. */
|
|
39
|
+
export function applyMatrix(matrix, point) {
|
|
40
|
+
const [a, b, c, d, e, f] = matrix;
|
|
41
|
+
return {
|
|
42
|
+
x: a * point.x + c * point.y + e,
|
|
43
|
+
y: b * point.x + d * point.y + f,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** The rectangle a turned set's box covers on the sheet. */
|
|
47
|
+
export function turnedBoundsOnSheet(bounds, sheet, rotation) {
|
|
48
|
+
switch (rotation) {
|
|
49
|
+
case 90:
|
|
50
|
+
return {
|
|
51
|
+
x: bounds.y,
|
|
52
|
+
y: sheet.height - bounds.x - bounds.width,
|
|
53
|
+
width: bounds.height,
|
|
54
|
+
height: bounds.width,
|
|
55
|
+
};
|
|
56
|
+
case 180:
|
|
57
|
+
return {
|
|
58
|
+
x: sheet.width - bounds.x - bounds.width,
|
|
59
|
+
y: sheet.height - bounds.y - bounds.height,
|
|
60
|
+
width: bounds.width,
|
|
61
|
+
height: bounds.height,
|
|
62
|
+
};
|
|
63
|
+
case 270:
|
|
64
|
+
return {
|
|
65
|
+
x: sheet.width - bounds.y - bounds.height,
|
|
66
|
+
y: bounds.x,
|
|
67
|
+
width: bounds.height,
|
|
68
|
+
height: bounds.width,
|
|
69
|
+
};
|
|
70
|
+
default:
|
|
71
|
+
return {
|
|
72
|
+
x: bounds.x,
|
|
73
|
+
y: bounds.y,
|
|
74
|
+
width: bounds.width,
|
|
75
|
+
height: bounds.height,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A direction in a turned set's space, as a direction on the sheet. Only the
|
|
81
|
+
* turn applies; a direction has no position to translate.
|
|
82
|
+
*/
|
|
83
|
+
export function turnedVectorOnSheet(vector, rotation) {
|
|
84
|
+
switch (rotation) {
|
|
85
|
+
case 90:
|
|
86
|
+
return { x: vector.y, y: -vector.x };
|
|
87
|
+
case 180:
|
|
88
|
+
return { x: -vector.x, y: -vector.y };
|
|
89
|
+
case 270:
|
|
90
|
+
return { x: -vector.y, y: vector.x };
|
|
91
|
+
default:
|
|
92
|
+
return { x: vector.x, y: vector.y };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** The reverse of {@link turnedVectorOnSheet}. */
|
|
96
|
+
export function sheetVectorInTurned(vector, rotation) {
|
|
97
|
+
switch (rotation) {
|
|
98
|
+
case 90:
|
|
99
|
+
return { x: -vector.y, y: vector.x };
|
|
100
|
+
case 180:
|
|
101
|
+
return { x: -vector.x, y: -vector.y };
|
|
102
|
+
case 270:
|
|
103
|
+
return { x: vector.y, y: -vector.x };
|
|
104
|
+
default:
|
|
105
|
+
return { x: vector.x, y: vector.y };
|
|
106
|
+
}
|
|
107
|
+
}
|