@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.
Files changed (66) hide show
  1. package/README.md +75 -1
  2. package/dist/authoring/collectorInfo.d.ts +17 -0
  3. package/dist/authoring/collectorInfo.js +62 -0
  4. package/dist/authoring/index.d.ts +2 -0
  5. package/dist/authoring/index.js +2 -0
  6. package/dist/authoring/layoutDefaults.d.ts +20 -2
  7. package/dist/authoring/layoutDefaults.js +48 -13
  8. package/dist/authoring/opacityStops.d.ts +8 -0
  9. package/dist/authoring/opacityStops.js +17 -0
  10. package/dist/cli/index.d.ts +1 -0
  11. package/dist/cli/index.js +1 -0
  12. package/dist/cli/loadFrame.js +1 -1
  13. package/dist/cli/main.js +72 -0
  14. package/dist/cli/studio/boxSets.js +11 -8
  15. package/dist/cli/studio/serve.js +4 -1
  16. package/dist/cli/trim.d.ts +62 -0
  17. package/dist/cli/trim.js +251 -0
  18. package/dist/layout/border.d.ts +27 -0
  19. package/dist/layout/border.js +31 -0
  20. package/dist/layout/boxOverrides.d.ts +28 -0
  21. package/dist/layout/boxOverrides.js +95 -0
  22. package/dist/layout/color.d.ts +23 -0
  23. package/dist/layout/color.js +53 -0
  24. package/dist/layout/cutouts.d.ts +28 -0
  25. package/dist/layout/cutouts.js +29 -0
  26. package/dist/layout/decorations.d.ts +1 -6
  27. package/dist/layout/decorations.js +7 -11
  28. package/dist/layout/frameLayers.d.ts +29 -2
  29. package/dist/layout/frameLayers.js +145 -3
  30. package/dist/layout/index.d.ts +17 -6
  31. package/dist/layout/index.js +17 -6
  32. package/dist/layout/paint.d.ts +36 -0
  33. package/dist/layout/paint.js +148 -0
  34. package/dist/layout/powerToughnessRow.d.ts +26 -0
  35. package/dist/layout/powerToughnessRow.js +13 -0
  36. package/dist/layout/resolveFrameAsset.d.ts +6 -0
  37. package/dist/layout/resolveFrameAsset.js +8 -0
  38. package/dist/layout/rulesSlide.d.ts +13 -0
  39. package/dist/layout/rulesSlide.js +33 -0
  40. package/dist/layout/settings.d.ts +26 -0
  41. package/dist/layout/settings.js +62 -0
  42. package/dist/layout/textStyle.d.ts +29 -0
  43. package/dist/layout/textStyle.js +28 -0
  44. package/dist/layout/turn.d.ts +54 -0
  45. package/dist/layout/turn.js +107 -0
  46. package/dist/manifest/contract.d.ts +6074 -9392
  47. package/dist/manifest/contract.js +46 -1
  48. package/dist/manifest/testFrame.js +9 -0
  49. package/dist/schema/collectorInfo.d.ts +95 -0
  50. package/dist/schema/collectorInfo.js +80 -0
  51. package/dist/schema/condition.d.ts +67 -0
  52. package/dist/schema/condition.js +47 -0
  53. package/dist/schema/frame.d.ts +17291 -25435
  54. package/dist/schema/frame.js +402 -14
  55. package/dist/schema/frameAssets.d.ts +53 -33
  56. package/dist/schema/frameAssets.js +77 -5
  57. package/dist/schema/index.d.ts +3 -0
  58. package/dist/schema/index.js +3 -0
  59. package/dist/schema/layout.d.ts +29 -4
  60. package/dist/schema/layout.js +27 -2
  61. package/dist/schema/paint.d.ts +202 -0
  62. package/dist/schema/paint.js +109 -0
  63. package/dist/studio/assets/index-BnhNwm_r.js +74 -0
  64. package/dist/studio/index.html +1 -1
  65. package/package.json +5 -3
  66. 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
+ }