@kensio/colophon 2.11.1 → 2.13.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 (198) hide show
  1. package/README.md +4 -1
  2. package/dist/astro/index.d.ts.map +1 -1
  3. package/dist/astro/index.js +0 -1
  4. package/dist/astro/index.js.map +1 -1
  5. package/dist/config/defaults.d.ts +24 -0
  6. package/dist/config/defaults.d.ts.map +1 -1
  7. package/dist/config/defaults.js +29 -0
  8. package/dist/config/defaults.js.map +1 -1
  9. package/dist/config/index.d.ts.map +1 -1
  10. package/dist/config/index.js +2 -1
  11. package/dist/config/index.js.map +1 -1
  12. package/dist/config/size.d.ts.map +1 -1
  13. package/dist/config/size.js +3 -0
  14. package/dist/config/size.js.map +1 -1
  15. package/dist/layout/fill.d.ts +32 -0
  16. package/dist/layout/fill.d.ts.map +1 -0
  17. package/dist/layout/fill.js +34 -0
  18. package/dist/layout/fill.js.map +1 -0
  19. package/dist/layout/index.d.ts +4 -2
  20. package/dist/layout/index.d.ts.map +1 -1
  21. package/dist/layout/index.js +2 -1
  22. package/dist/layout/index.js.map +1 -1
  23. package/dist/measure/faces.d.ts.map +1 -1
  24. package/dist/measure/faces.js.map +1 -1
  25. package/dist/render/svg.js +1 -1
  26. package/dist/render/svg.js.map +1 -1
  27. package/dist/templates/banner/index.js +2 -2
  28. package/dist/templates/banner/index.js.map +1 -1
  29. package/dist/templates/card/index.js +2 -2
  30. package/dist/templates/card/index.js.map +1 -1
  31. package/dist/templates/code/bar.d.ts +24 -0
  32. package/dist/templates/code/bar.d.ts.map +1 -0
  33. package/dist/templates/code/bar.js +31 -0
  34. package/dist/templates/code/bar.js.map +1 -0
  35. package/dist/templates/code/gutter.d.ts +30 -0
  36. package/dist/templates/code/gutter.d.ts.map +1 -0
  37. package/dist/templates/code/gutter.js +64 -0
  38. package/dist/templates/code/gutter.js.map +1 -0
  39. package/dist/templates/code/index.d.ts.map +1 -1
  40. package/dist/templates/code/index.js +34 -15
  41. package/dist/templates/code/index.js.map +1 -1
  42. package/dist/templates/code/layout.d.ts +6 -1
  43. package/dist/templates/code/layout.d.ts.map +1 -1
  44. package/dist/templates/code/layout.js +8 -3
  45. package/dist/templates/code/layout.js.map +1 -1
  46. package/dist/templates/code/mark/draw.d.ts +26 -0
  47. package/dist/templates/code/mark/draw.d.ts.map +1 -0
  48. package/dist/templates/code/mark/draw.js +41 -0
  49. package/dist/templates/code/mark/draw.js.map +1 -0
  50. package/dist/templates/code/mark/index.d.ts +16 -0
  51. package/dist/templates/code/mark/index.d.ts.map +1 -0
  52. package/dist/templates/code/mark/index.js +34 -0
  53. package/dist/templates/code/mark/index.js.map +1 -0
  54. package/dist/templates/code/mark/locate.d.ts +20 -0
  55. package/dist/templates/code/mark/locate.d.ts.map +1 -0
  56. package/dist/templates/code/mark/locate.js +56 -0
  57. package/dist/templates/code/mark/locate.js.map +1 -0
  58. package/dist/templates/code/mark/read.d.ts +30 -0
  59. package/dist/templates/code/mark/read.d.ts.map +1 -0
  60. package/dist/templates/code/mark/read.js +61 -0
  61. package/dist/templates/code/mark/read.js.map +1 -0
  62. package/dist/templates/code/plate.d.ts +7 -1
  63. package/dist/templates/code/plate.d.ts.map +1 -1
  64. package/dist/templates/code/plate.js +14 -4
  65. package/dist/templates/code/plate.js.map +1 -1
  66. package/dist/templates/footer.d.ts +9 -1
  67. package/dist/templates/footer.d.ts.map +1 -1
  68. package/dist/templates/footer.js +24 -0
  69. package/dist/templates/footer.js.map +1 -1
  70. package/dist/templates/frame.d.ts.map +1 -1
  71. package/dist/templates/frame.js +5 -7
  72. package/dist/templates/frame.js.map +1 -1
  73. package/dist/templates/index.d.ts +1 -0
  74. package/dist/templates/index.d.ts.map +1 -1
  75. package/dist/templates/index.js +3 -0
  76. package/dist/templates/index.js.map +1 -1
  77. package/dist/templates/terminal/index.js +4 -4
  78. package/dist/templates/terminal/index.js.map +1 -1
  79. package/dist/templates/thumbnail/index.d.ts +21 -0
  80. package/dist/templates/thumbnail/index.d.ts.map +1 -0
  81. package/dist/templates/thumbnail/index.js +68 -0
  82. package/dist/templates/thumbnail/index.js.map +1 -0
  83. package/dist/templates/thumbnail/lines.d.ts +38 -0
  84. package/dist/templates/thumbnail/lines.d.ts.map +1 -0
  85. package/dist/templates/thumbnail/lines.js +76 -0
  86. package/dist/templates/thumbnail/lines.js.map +1 -0
  87. package/dist/templates/window/dots.d.ts +11 -0
  88. package/dist/templates/window/dots.d.ts.map +1 -0
  89. package/dist/templates/window/dots.js +32 -0
  90. package/dist/templates/window/dots.js.map +1 -0
  91. package/dist/templates/{terminal/window.d.ts → window/index.d.ts} +4 -2
  92. package/dist/templates/window/index.d.ts.map +1 -0
  93. package/dist/templates/window/index.js +48 -0
  94. package/dist/templates/window/index.js.map +1 -0
  95. package/dist/templates/window/title.d.ts +9 -0
  96. package/dist/templates/window/title.d.ts.map +1 -0
  97. package/dist/templates/window/title.js +24 -0
  98. package/dist/templates/window/title.js.map +1 -0
  99. package/dist/text/fill.d.ts +34 -0
  100. package/dist/text/fill.d.ts.map +1 -0
  101. package/dist/text/fill.js +57 -0
  102. package/dist/text/fill.js.map +1 -0
  103. package/dist/text/fit.d.ts.map +1 -1
  104. package/dist/text/fit.js +2 -6
  105. package/dist/text/fit.js.map +1 -1
  106. package/dist/text/index.d.ts +2 -0
  107. package/dist/text/index.d.ts.map +1 -1
  108. package/dist/text/index.js +1 -0
  109. package/dist/text/index.js.map +1 -1
  110. package/dist/text/step.d.ts +13 -0
  111. package/dist/text/step.d.ts.map +1 -0
  112. package/dist/text/step.js +17 -0
  113. package/dist/text/step.js.map +1 -0
  114. package/dist/text/unbroken.d.ts +22 -0
  115. package/dist/text/unbroken.d.ts.map +1 -0
  116. package/dist/text/unbroken.js +29 -0
  117. package/dist/text/unbroken.js.map +1 -0
  118. package/dist/texture/chevrons.d.ts +13 -0
  119. package/dist/texture/chevrons.d.ts.map +1 -0
  120. package/dist/texture/chevrons.js +22 -0
  121. package/dist/texture/chevrons.js.map +1 -0
  122. package/dist/texture/grid.d.ts +14 -0
  123. package/dist/texture/grid.d.ts.map +1 -0
  124. package/dist/texture/grid.js +38 -0
  125. package/dist/texture/grid.js.map +1 -0
  126. package/dist/texture/halftone.d.ts +14 -0
  127. package/dist/texture/halftone.d.ts.map +1 -0
  128. package/dist/texture/halftone.js +55 -0
  129. package/dist/texture/halftone.js.map +1 -0
  130. package/dist/texture/honeycomb.d.ts +14 -0
  131. package/dist/texture/honeycomb.d.ts.map +1 -0
  132. package/dist/texture/honeycomb.js +43 -0
  133. package/dist/texture/honeycomb.js.map +1 -0
  134. package/dist/texture/index.d.ts +15 -4
  135. package/dist/texture/index.d.ts.map +1 -1
  136. package/dist/texture/index.js +64 -14
  137. package/dist/texture/index.js.map +1 -1
  138. package/dist/texture/moire.d.ts +18 -0
  139. package/dist/texture/moire.d.ts.map +1 -0
  140. package/dist/texture/moire.js +44 -0
  141. package/dist/texture/moire.js.map +1 -0
  142. package/dist/texture/pattern.d.ts +10 -0
  143. package/dist/texture/pattern.d.ts.map +1 -1
  144. package/dist/texture/pattern.js +36 -13
  145. package/dist/texture/pattern.js.map +1 -1
  146. package/dist/texture/rays.d.ts +13 -0
  147. package/dist/texture/rays.d.ts.map +1 -0
  148. package/dist/texture/rays.js +36 -0
  149. package/dist/texture/rays.js.map +1 -0
  150. package/dist/texture/resolve.d.ts +10 -0
  151. package/dist/texture/resolve.d.ts.map +1 -1
  152. package/dist/texture/resolve.js +15 -0
  153. package/dist/texture/resolve.js.map +1 -1
  154. package/dist/texture/scallops.d.ts +14 -0
  155. package/dist/texture/scallops.d.ts.map +1 -0
  156. package/dist/texture/scallops.js +29 -0
  157. package/dist/texture/scallops.js.map +1 -0
  158. package/dist/texture/tile.d.ts +14 -0
  159. package/dist/texture/tile.d.ts.map +1 -0
  160. package/dist/texture/tile.js +23 -0
  161. package/dist/texture/tile.js.map +1 -0
  162. package/dist/texture/topographic/contours.d.ts +13 -0
  163. package/dist/texture/topographic/contours.d.ts.map +1 -0
  164. package/dist/texture/topographic/contours.js +72 -0
  165. package/dist/texture/topographic/contours.js.map +1 -0
  166. package/dist/texture/topographic/field.d.ts +8 -0
  167. package/dist/texture/topographic/field.d.ts.map +1 -0
  168. package/dist/texture/topographic/field.js +29 -0
  169. package/dist/texture/topographic/field.js.map +1 -0
  170. package/dist/texture/topographic/index.d.ts +17 -0
  171. package/dist/texture/topographic/index.d.ts.map +1 -0
  172. package/dist/texture/topographic/index.js +48 -0
  173. package/dist/texture/topographic/index.js.map +1 -0
  174. package/dist/theme/presets.d.ts +13 -5
  175. package/dist/theme/presets.d.ts.map +1 -1
  176. package/dist/theme/presets.js +16 -5
  177. package/dist/theme/presets.js.map +1 -1
  178. package/dist/types.d.ts +259 -3
  179. package/dist/types.d.ts.map +1 -1
  180. package/dist/validate/collect.d.ts.map +1 -1
  181. package/dist/validate/collect.js +2 -1
  182. package/dist/validate/collect.js.map +1 -1
  183. package/dist/validate/keys.d.ts +37 -0
  184. package/dist/validate/keys.d.ts.map +1 -1
  185. package/dist/validate/keys.js +132 -2
  186. package/dist/validate/keys.js.map +1 -1
  187. package/dist/validate/texture.d.ts +4 -5
  188. package/dist/validate/texture.d.ts.map +1 -1
  189. package/dist/validate/texture.js +11 -20
  190. package/dist/validate/texture.js.map +1 -1
  191. package/dist/validate/values.d.ts +6 -0
  192. package/dist/validate/values.d.ts.map +1 -1
  193. package/dist/validate/values.js +16 -1
  194. package/dist/validate/values.js.map +1 -1
  195. package/package.json +3 -10
  196. package/dist/templates/terminal/window.d.ts.map +0 -1
  197. package/dist/templates/terminal/window.js +0 -84
  198. package/dist/templates/terminal/window.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/texture/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,Q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M,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC;KAC7C,CAAC;IAEF,OAAO,uBAAuB,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC;AACpF,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Dimensions, Texture } from "../types.js";
2
+ /**
3
+ * Two square grids, one turned a few degrees against the other.
4
+ *
5
+ * What is seen is the interference between them rather than either grid: the
6
+ * lines cross at a different offset in every part of the image, which the eye
7
+ * reads as broad bands sweeping across it. It is the same idea as `waves` with
8
+ * straight edges instead of arcs, and that is what makes it much cheaper to
9
+ * store, since a row of the image is closer to repeating.
10
+ *
11
+ * The angle is the whole texture. Below about a degree the bands are wider
12
+ * than the image and it looks like one grid slightly out of true; above about
13
+ * ten they are tight enough to read as a weave.
14
+ */
15
+ export declare function moireSvg(texture: Extract<Texture, {
16
+ readonly type: "moire";
17
+ }>, dimensions: Dimensions, id: string): string;
18
+ //# sourceMappingURL=moire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moire.d.ts","sourceRoot":"","sources":["../../src/texture/moire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA8CvD;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,EACrD,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,MAAM,GACT,MAAM,CAaR"}
@@ -0,0 +1,44 @@
1
+ import { fallbackColor } from "./color.js";
2
+ import { tile } from "./tile.js";
3
+ const moireDefaults = { opacity: 0.1, width: 1, gap: 16, angle: 4 };
4
+ /**
5
+ * How much fainter the turned grid is than the square one.
6
+ *
7
+ * The same reasoning as the second set of rings in `waves`: two grids at one
8
+ * opacity read as two grids, and dropping one of them is what turns the
9
+ * crossings into a surface.
10
+ */
11
+ const secondaryScale = 0.65;
12
+ /** One square grid: a line through the middle of the tile on each axis. */
13
+ function grid(texture, dimensions, id, angle, opacity) {
14
+ const gap = texture.gap ?? moireDefaults.gap;
15
+ const middle = String(gap / 2);
16
+ const size = String(gap);
17
+ // Down the middle of the tile on both axes rather than along its edges, for
18
+ // the reason `rulesSvg` gives: a stroke centred on the edge would have half
19
+ // of itself outside the tile, where the pattern does not repeat it.
20
+ const lines = `<path d="M0 ${middle}H${size}M${middle} 0V${size}"` +
21
+ ` stroke="${texture.color ?? fallbackColor}"` +
22
+ ` stroke-width="${String(texture.width ?? moireDefaults.width)}"` +
23
+ ` fill="none"/>`;
24
+ return tile(id, gap, lines, angle === 0 ? "" : ` patternTransform="rotate(${String(angle)})"`, dimensions, opacity);
25
+ }
26
+ /**
27
+ * Two square grids, one turned a few degrees against the other.
28
+ *
29
+ * What is seen is the interference between them rather than either grid: the
30
+ * lines cross at a different offset in every part of the image, which the eye
31
+ * reads as broad bands sweeping across it. It is the same idea as `waves` with
32
+ * straight edges instead of arcs, and that is what makes it much cheaper to
33
+ * store, since a row of the image is closer to repeating.
34
+ *
35
+ * The angle is the whole texture. Below about a degree the bands are wider
36
+ * than the image and it looks like one grid slightly out of true; above about
37
+ * ten they are tight enough to read as a weave.
38
+ */
39
+ export function moireSvg(texture, dimensions, id) {
40
+ const opacity = texture.opacity ?? moireDefaults.opacity;
41
+ return (grid(texture, dimensions, `${id}a`, 0, opacity) +
42
+ grid(texture, dimensions, `${id}b`, texture.angle ?? moireDefaults.angle, Math.round(opacity * secondaryScale * 1000) / 1000));
43
+ }
44
+ //# sourceMappingURL=moire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moire.js","sourceRoot":"","sources":["../../src/texture/moire.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,IAA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,CAAC;QAC/C,IAAI,CACF,OAAO,EACP,UAAU,EACV,GAAG,EAAE,GAAG,EACR,OAAO,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK,EACpC,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,cAAc,GAAG,IAAI,CAAC,GAAG,IAAI,CACnD,CACF,CAAC;AACJ,CAAC"}
@@ -3,6 +3,16 @@ import type { Dimensions, Texture } from "../types.js";
3
3
  export declare function dotsSvg(texture: Extract<Texture, {
4
4
  readonly type: "dots";
5
5
  }>, dimensions: Dimensions, id: string): string;
6
+ /**
7
+ * A small cross where each line of a grid would meet, one to a tile.
8
+ *
9
+ * It is the dot grid with a little more to look at, and it costs the same: the
10
+ * mark is two strokes rather than a fill, and the tile is square to the image
11
+ * either way.
12
+ */
13
+ export declare function crossesSvg(texture: Extract<Texture, {
14
+ readonly type: "crosses";
15
+ }>, dimensions: Dimensions, id: string): string;
6
16
  /**
7
17
  * Ruled lines, one to a tile, rotated as a set.
8
18
  *
@@ -1 +1 @@
1
- {"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../../src/texture/pattern.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA+BvD,qCAAqC;AACrC,wBAAgB,OAAO,CACrB,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EACpD,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,MAAM,GACT,MAAM,CAgBR;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,EACrD,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,MAAM,GACT,MAAM,CAiBR"}
1
+ {"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../../src/texture/pattern.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAiBvD,qCAAqC;AACrC,wBAAgB,OAAO,CACrB,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EACpD,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,MAAM,GACT,MAAM,CAgBR;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,EACvD,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,MAAM,GACT,MAAM,CAoBR;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,EACrD,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,MAAM,GACT,MAAM,CA8BR"}
@@ -1,20 +1,16 @@
1
1
  import { fallbackColor } from "./color.js";
2
+ import { tile } from "./tile.js";
2
3
  const dotDefaults = { opacity: 0.08, size: 5, gap: 44 };
3
4
  const ruleDefaults = { opacity: 0.06, width: 2, gap: 28, angle: 45 };
5
+ const crossDefaults = { opacity: 0.09, size: 9, width: 1.5, gap: 48 };
4
6
  /**
5
- * A tiled pattern over the whole image: the `<pattern>` under the given `id`,
6
- * and the rect that fills with it.
7
+ * How much fainter the crossing set of rules is than the first.
8
+ *
9
+ * The same figure the two sets of rings in `waves` use, and for the same
10
+ * reason: two sets at one opacity read as two sets, and dropping one of them
11
+ * is what turns the crossings into a surface with a weave to it.
7
12
  */
8
- function tile(id, gap, contents, transform, dimensions, opacity) {
9
- const { width, height } = dimensions;
10
- const size = String(gap);
11
- return (`<defs>` +
12
- `<pattern id="${id}" width="${size}" height="${size}"` +
13
- ` patternUnits="userSpaceOnUse"${transform}>${contents}</pattern>` +
14
- `</defs>` +
15
- `<rect width="${String(width)}" height="${String(height)}"` +
16
- ` fill="url(#${id})" opacity="${String(opacity)}"/>`);
17
- }
13
+ const crossScale = 0.65;
18
14
  /** A grid of dots, one to a tile. */
19
15
  export function dotsSvg(texture, dimensions, id) {
20
16
  const gap = texture.gap ?? dotDefaults.gap;
@@ -24,6 +20,25 @@ export function dotsSvg(texture, dimensions, id) {
24
20
  ` fill="${texture.color ?? fallbackColor}"/>`;
25
21
  return tile(id, gap, dot, "", dimensions, texture.opacity ?? dotDefaults.opacity);
26
22
  }
23
+ /**
24
+ * A small cross where each line of a grid would meet, one to a tile.
25
+ *
26
+ * It is the dot grid with a little more to look at, and it costs the same: the
27
+ * mark is two strokes rather than a fill, and the tile is square to the image
28
+ * either way.
29
+ */
30
+ export function crossesSvg(texture, dimensions, id) {
31
+ const gap = texture.gap ?? crossDefaults.gap;
32
+ const centre = gap / 2;
33
+ const arm = (texture.size ?? crossDefaults.size) / 2;
34
+ const from = String(centre - arm);
35
+ const to = String(centre + arm);
36
+ const cross = `<path d="M${from} ${String(centre)}H${to}M${String(centre)} ${from}V${to}"` +
37
+ ` stroke="${texture.color ?? fallbackColor}"` +
38
+ ` stroke-width="${String(texture.width ?? crossDefaults.width)}"` +
39
+ ` fill="none"/>`;
40
+ return tile(id, gap, cross, "", dimensions, texture.opacity ?? crossDefaults.opacity);
41
+ }
27
42
  /**
28
43
  * Ruled lines, one to a tile, rotated as a set.
29
44
  *
@@ -39,6 +54,14 @@ export function rulesSvg(texture, dimensions, id) {
39
54
  ` stroke="${texture.color ?? fallbackColor}"` +
40
55
  ` stroke-width="${String(texture.width ?? ruleDefaults.width)}"/>`;
41
56
  const angle = texture.angle ?? ruleDefaults.angle;
42
- return tile(id, gap, line, ` patternTransform="rotate(${String(angle)})"`, dimensions, texture.opacity ?? ruleDefaults.opacity);
57
+ const opacity = texture.opacity ?? ruleDefaults.opacity;
58
+ const set = (name, at, alpha) => tile(name, gap, line, ` patternTransform="rotate(${String(at)})"`, dimensions, alpha);
59
+ if (texture.cross !== true) {
60
+ // One set keeps the id it always had, so that the common case draws what
61
+ // it drew before, down to the byte.
62
+ return set(id, angle, opacity);
63
+ }
64
+ return (set(`${id}a`, angle, opacity) +
65
+ set(`${id}b`, -angle, Math.round(opacity * crossScale * 1000) / 1000));
43
66
  }
44
67
  //# sourceMappingURL=pattern.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pattern.js","sourceRoot":"","sources":["../../src/texture/pattern.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,WAAW,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;AACxD,MAAM,YAAY,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AAErE;;;GAGG;AACH,SAAS,IAAI,CACX,EAAU,EACV,GAAW,EACX,QAAgB,EAChB,SAAiB,EACjB,UAAsB,EACtB,OAAe;IAEf,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IACrC,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAEzB,OAAO,CACL,QAAQ;QACR,gBAAgB,EAAE,YAAY,IAAI,aAAa,IAAI,GAAG;QACtD,iCAAiC,SAAS,IAAI,QAAQ,YAAY;QAClE,SAAS;QACT,gBAAgB,MAAM,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,MAAM,CAAC,GAAG;QAC3D,eAAe,EAAE,eAAe,MAAM,CAAC,OAAO,CAAC,KAAK,CACrD,CAAC;AACJ,CAAC;AAED,qCAAqC;AACrC,MAAM,UAAU,OAAO,CACrB,OAAoD,EACpD,UAAsB,EACtB,EAAU;IA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KAAK,IAAI,YAAY,CAAC,KAAK,CAAC;IAClD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC;IAExD,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAU,EAAE,KAAa,EAAU,EAAE,CAC9D,IAAI,CACF,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,6BAA6B,MAAM,CAAC,EAAE,CAAC,IAAI,EAC3C,UAAU,EACV,KAAK,CACN,CAAC;IAEJ,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QAC3B,yEAAyE;QACzE,oCAAoC;QACpC,OAAO,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,CACL,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC;QAC7B,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,UAAU,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CACtE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Dimensions, Texture } from "../types.js";
2
+ /**
3
+ * Straight lines fanning out from one point.
4
+ *
5
+ * The rays are spread around the whole circle rather than over the angle that
6
+ * happens to face the image, so moving the origin changes what is seen without
7
+ * changing how close together the lines are. Nothing clips the ones that point
8
+ * away: they are outside the SVG's viewport and are simply not painted.
9
+ */
10
+ export declare function raysSvg(texture: Extract<Texture, {
11
+ readonly type: "rays";
12
+ }>, dimensions: Dimensions): string;
13
+ //# sourceMappingURL=rays.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rays.d.ts","sourceRoot":"","sources":["../../src/texture/rays.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAkBvD;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACrB,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EACpD,UAAU,EAAE,UAAU,GACrB,MAAM,CA0BR"}
@@ -0,0 +1,36 @@
1
+ import { fallbackColor } from "./color.js";
2
+ const rayDefaults = { opacity: 0.07, width: 2, count: 36, x: 0.5, y: 1.15 };
3
+ /** How far a ray has to run to leave the image from where it starts. */
4
+ function reach(origin, dimensions) {
5
+ return Math.hypot(Math.max(origin.x, dimensions.width - origin.x), Math.max(origin.y, dimensions.height - origin.y));
6
+ }
7
+ /**
8
+ * Straight lines fanning out from one point.
9
+ *
10
+ * The rays are spread around the whole circle rather than over the angle that
11
+ * happens to face the image, so moving the origin changes what is seen without
12
+ * changing how close together the lines are. Nothing clips the ones that point
13
+ * away: they are outside the SVG's viewport and are simply not painted.
14
+ */
15
+ export function raysSvg(texture, dimensions) {
16
+ const count = Math.max(1, Math.round(texture.count ?? rayDefaults.count));
17
+ const origin = {
18
+ x: dimensions.width * (texture.x ?? rayDefaults.x),
19
+ y: dimensions.height * (texture.y ?? rayDefaults.y),
20
+ };
21
+ const length = reach(origin, dimensions);
22
+ let rays = "";
23
+ for (let ray = 0; ray < count; ray += 1) {
24
+ const angle = (ray / count) * Math.PI * 2;
25
+ rays +=
26
+ `<line x1="${String(Math.round(origin.x))}"` +
27
+ ` y1="${String(Math.round(origin.y))}"` +
28
+ ` x2="${String(Math.round(origin.x + Math.cos(angle) * length))}"` +
29
+ ` y2="${String(Math.round(origin.y + Math.sin(angle) * length))}"/>`;
30
+ }
31
+ return (`<g stroke="${texture.color ?? fallbackColor}"` +
32
+ ` stroke-width="${String(texture.width ?? rayDefaults.width)}"` +
33
+ ` opacity="${String(texture.opacity ?? rayDefaults.opacity)}">` +
34
+ `${rays}</g>`);
35
+ }
36
+ //# sourceMappingURL=rays.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rays.js","sourceRoot":"","sources":["../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,KAAK,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QAE1C,IAAI;YACF,aAAa,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG;gBAC5C,QAAQ,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG;gBACvC,QAAQ,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG;gBAClE,QAAQ,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,KAAK,CAAC;IACzE,CAAC;IAED,OAAO,CACL,cAAc,OAAO,CAAC,KAAK,IAAI,aAAa,GAAG;QAC/C,kBAAkB,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,WAAW,CAAC,KAAK,CAAC,GAAG;QAC/D,aAAa,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,IAAI;QAC/D,GAAG,IAAI,MAAM,CACd,CAAC;AACJ,CAAC"}
@@ -14,4 +14,14 @@ import type { BrandColors, Texture } from "../types.js";
14
14
  * palette change then re-renders the texture that follows it.
15
15
  */
16
16
  export declare function resolveTexture(texture: Texture | undefined, colors: Required<BrandColors>): Texture | undefined;
17
+ /**
18
+ * The texture scale a config asked for, or `1`.
19
+ *
20
+ * A scale of nothing, or of something that is not a positive number, is taken
21
+ * as no scaling rather than as an error. Everything it could mean instead is
22
+ * worse: zero would divide the image by nothing, and a negative would draw the
23
+ * treatment backwards through the origin, so both are configs that would fail
24
+ * as a blank image rather than as a message.
25
+ */
26
+ export declare function resolveTextureScale(scale: number | undefined): number;
17
27
  //# sourceMappingURL=resolve.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/texture/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAC5B,OAAO,GAAG,SAAS,CAMrB"}
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/texture/resolve.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAC5B,OAAO,GAAG,SAAS,CAMrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAIrE"}
@@ -1,3 +1,4 @@
1
+ import { DEFAULT_TEXTURE_SCALE } from "../config/defaults.js";
1
2
  /**
2
3
  * Fill in the colour a texture left open, from the palette it will be drawn
3
4
  * over.
@@ -18,4 +19,18 @@ export function resolveTexture(texture, colors) {
18
19
  }
19
20
  return { color: colors.foreground, ...texture };
20
21
  }
22
+ /**
23
+ * The texture scale a config asked for, or `1`.
24
+ *
25
+ * A scale of nothing, or of something that is not a positive number, is taken
26
+ * as no scaling rather than as an error. Everything it could mean instead is
27
+ * worse: zero would divide the image by nothing, and a negative would draw the
28
+ * treatment backwards through the origin, so both are configs that would fail
29
+ * as a blank image rather than as a message.
30
+ */
31
+ export function resolveTextureScale(scale) {
32
+ return scale === undefined || !Number.isFinite(scale) || scale <= 0
33
+ ? DEFAULT_TEXTURE_SCALE
34
+ : scale;
35
+ }
21
36
  //# sourceMappingURL=resolve.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/texture/resolve.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAC5B,OAA4B,EAC5B,MAA6B;IAE7B,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QACtD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,GAAG,OAAO,EAAE,CAAC;AAClD,CAAC"}
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/texture/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAG9D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAC5B,OAA4B,EAC5B,MAA6B;IAE7B,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QACtD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,GAAG,OAAO,EAAE,CAAC;AAClD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAyB;IAC3D,OAAO,KAAK,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;QACjE,CAAC,CAAC,qBAAqB;QACvB,CAAC,CAAC,KAAK,CAAC;AACZ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Dimensions, Texture } from "../types.js";
2
+ /**
3
+ * Fish scales: rows of arcs, each row offset by half a scale from the one
4
+ * above, which is what makes them read as overlapping rather than as stacked
5
+ * semicircles.
6
+ *
7
+ * The tile holds two rows for that reason: one repeat has to contain both the
8
+ * offset row and the row it is offset from, since a `<pattern>` cannot stagger
9
+ * its own rows.
10
+ */
11
+ export declare function scallopsSvg(texture: Extract<Texture, {
12
+ readonly type: "scallops";
13
+ }>, dimensions: Dimensions, id: string): string;
14
+ //# sourceMappingURL=scallops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scallops.d.ts","sourceRoot":"","sources":["../../src/texture/scallops.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAcvD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,EACxD,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,MAAM,GACT,MAAM,CAqBR"}
@@ -0,0 +1,29 @@
1
+ import { fallbackColor } from "./color.js";
2
+ import { tile } from "./tile.js";
3
+ const scallopDefaults = { opacity: 0.07, width: 2, size: 40 };
4
+ /** One arc of a row, bulging downwards from the two points it spans. */
5
+ function scallop(cx, y, radius) {
6
+ return (`M${String(cx - radius)} ${String(y)}` +
7
+ `A${String(radius)} ${String(radius)} 0 0 0 ${String(cx + radius)} ${String(y)}`);
8
+ }
9
+ /**
10
+ * Fish scales: rows of arcs, each row offset by half a scale from the one
11
+ * above, which is what makes them read as overlapping rather than as stacked
12
+ * semicircles.
13
+ *
14
+ * The tile holds two rows for that reason: one repeat has to contain both the
15
+ * offset row and the row it is offset from, since a `<pattern>` cannot stagger
16
+ * its own rows.
17
+ */
18
+ export function scallopsSvg(texture, dimensions, id) {
19
+ const size = texture.size ?? scallopDefaults.size;
20
+ const radius = size / 2;
21
+ const rows = scallop(radius, 0, radius) +
22
+ scallop(0, radius, radius) +
23
+ scallop(size, radius, radius);
24
+ const arcs = `<path d="${rows}" stroke="${texture.color ?? fallbackColor}"` +
25
+ ` stroke-width="${String(texture.width ?? scallopDefaults.width)}"` +
26
+ ` fill="none"/>`;
27
+ return tile(id, size, arcs, "", dimensions, texture.opacity ?? scallopDefaults.opacity);
28
+ }
29
+ //# sourceMappingURL=scallops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scallops.js","sourceRoot":"","sources":["../../src/texture/scallops.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,eAAe,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AAE9D,wEAAwE;AACxE,SAAS,OAAO,CAAC,EAAU,EAAE,CAAS,EAAE,MAAc;IACpD,OAAO,CACL,IAAI,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;QACtC,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CACjF,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CACzB,OAAwD,EACxD,UAAsB,EACtB,EAAU;IAEV,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,eAAe,CAAC,IAAI,CAAC;IAClD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC;IACxB,MAAM,IAAI,GACR,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC;QAC1B,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC;QAC1B,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhC,MAAM,IAAI,GACR,YAAY,IAAI,aAAa,OAAO,CAAC,KAAK,IAAI,aAAa,GAAG;QAC9D,kBAAkB,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG;QACnE,gBAAgB,CAAC;IAEnB,OAAO,IAAI,CACT,EAAE,EACF,IAAI,EACJ,IAAI,EACJ,EAAE,EACF,UAAU,EACV,OAAO,CAAC,OAAO,IAAI,eAAe,CAAC,OAAO,CAC3C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Dimensions } from "../types.js";
2
+ /**
3
+ * A tiled pattern over the whole image: the `<pattern>` under the given `id`,
4
+ * and the rect that fills with it.
5
+ *
6
+ * A tile is what makes a treatment cheap to store as well as to draw. PNG
7
+ * compresses along a row, and a repeating tile means a row that repeats, which
8
+ * is the difference between the dot grid's 20KB and the half a megabyte a
9
+ * pattern that never repeats costs.
10
+ */
11
+ export declare function tile(id: string,
12
+ /** The repeat: one number for a square tile, or both sides where it is not. */
13
+ gap: number | Dimensions, contents: string, transform: string, dimensions: Dimensions, opacity: number): string;
14
+ //# sourceMappingURL=tile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile.d.ts","sourceRoot":"","sources":["../../src/texture/tile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAClB,EAAE,EAAE,MAAM;AACV,+EAA+E;AAC/E,GAAG,EAAE,MAAM,GAAG,UAAU,EACxB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,MAAM,GACd,MAAM,CAcR"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * A tiled pattern over the whole image: the `<pattern>` under the given `id`,
3
+ * and the rect that fills with it.
4
+ *
5
+ * A tile is what makes a treatment cheap to store as well as to draw. PNG
6
+ * compresses along a row, and a repeating tile means a row that repeats, which
7
+ * is the difference between the dot grid's 20KB and the half a megabyte a
8
+ * pattern that never repeats costs.
9
+ */
10
+ export function tile(id,
11
+ /** The repeat: one number for a square tile, or both sides where it is not. */
12
+ gap, contents, transform, dimensions, opacity) {
13
+ const { width, height } = dimensions;
14
+ const repeat = typeof gap === "number" ? { width: gap, height: gap } : { ...gap };
15
+ return (`<defs>` +
16
+ `<pattern id="${id}" width="${String(repeat.width)}"` +
17
+ ` height="${String(repeat.height)}"` +
18
+ ` patternUnits="userSpaceOnUse"${transform}>${contents}</pattern>` +
19
+ `</defs>` +
20
+ `<rect width="${String(width)}" height="${String(height)}"` +
21
+ ` fill="url(#${id})" opacity="${String(opacity)}"/>`);
22
+ }
23
+ //# sourceMappingURL=tile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile.js","sourceRoot":"","sources":["../../src/texture/tile.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,UAAU,IAAI,CAClB,EAAU;AACV,+EAA+E;AAC/E,GAAwB,EACxB,QAAgB,EAChB,SAAiB,EACjB,UAAsB,EACtB,OAAe;IAEf,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IACrC,MAAM,MAAM,GACV,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC;IAErE,OAAO,CACL,QAAQ;QACR,gBAAgB,EAAE,YAAY,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG;QACrD,YAAY,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG;QACpC,iCAAiC,SAAS,IAAI,QAAQ,YAAY;QAClE,SAAS;QACT,gBAAgB,MAAM,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,MAAM,CAAC,GAAG;QAC3D,eAAe,EAAE,eAAe,MAAM,CAAC,OAAO,CAAC,KAAK,CACrD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Dimensions } from "../../types.js";
2
+ /**
3
+ * One contour of the landscape, as the segments where the ground passes
4
+ * through a given height.
5
+ *
6
+ * This is marching squares: the field is sampled on a grid, and each cell
7
+ * contributes the piece of the line that crosses it. Drawing the segments
8
+ * separately rather than joining them into loops costs a little more markup
9
+ * and saves the bookkeeping of walking a contour from cell to cell, which
10
+ * would not change the picture.
11
+ */
12
+ export declare function contourAt(level: number, step: number, dimensions: Dimensions, seed: number, relief: number): string;
13
+ //# sourceMappingURL=contours.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contours.d.ts","sourceRoot":"","sources":["../../../src/texture/topographic/contours.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAyEjD;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,MAAM,CAmBR"}
@@ -0,0 +1,72 @@
1
+ import { height } from "./field.js";
2
+ /**
3
+ * Where between two corners the contour crosses, by how far each of them is
4
+ * above or below the level. Interpolating rather than taking the midpoint is
5
+ * what makes the line smooth instead of stepped.
6
+ */
7
+ function between(a, b, above, below) {
8
+ const along = above / (above - below);
9
+ return { x: a.x + (b.x - a.x) * along, y: a.y + (b.y - a.y) * along };
10
+ }
11
+ /** The corners of one cell, clockwise from the top left. */
12
+ function corners(x, y, step) {
13
+ return [
14
+ { x, y },
15
+ { x: x + step, y },
16
+ { x: x + step, y: y + step },
17
+ { x, y: y + step },
18
+ ];
19
+ }
20
+ /**
21
+ * The segments of one contour crossing one cell.
22
+ *
23
+ * Which edges it crosses is decided by which corners are above the level, read
24
+ * as four bits. The two ambiguous cases, where opposite corners are above and
25
+ * the other two below, are drawn as two separate segments: a saddle can be
26
+ * joined either way and this is the reading that never crosses itself.
27
+ */
28
+ function cell(values, points, level) {
29
+ const above = values.map((value) => value > level);
30
+ const edges = [];
31
+ for (const [index, isAbove] of above.entries()) {
32
+ const next = (index + 1) % 4;
33
+ if (isAbove !== above[next]) {
34
+ edges.push(between(points[index], points[next], values[index] - level, values[next] - level));
35
+ }
36
+ }
37
+ if (edges.length === 2) {
38
+ return [[edges[0], edges[1]]];
39
+ }
40
+ return edges.length === 4
41
+ ? [
42
+ [edges[0], edges[1]],
43
+ [edges[2], edges[3]],
44
+ ]
45
+ : [];
46
+ }
47
+ /**
48
+ * One contour of the landscape, as the segments where the ground passes
49
+ * through a given height.
50
+ *
51
+ * This is marching squares: the field is sampled on a grid, and each cell
52
+ * contributes the piece of the line that crosses it. Drawing the segments
53
+ * separately rather than joining them into loops costs a little more markup
54
+ * and saves the bookkeeping of walking a contour from cell to cell, which
55
+ * would not change the picture.
56
+ */
57
+ export function contourAt(level, step, dimensions, seed, relief) {
58
+ let path = "";
59
+ for (let y = -step; y < dimensions.height + step; y += step) {
60
+ for (let x = -step; x < dimensions.width + step; x += step) {
61
+ const points = corners(x, y, step);
62
+ const values = points.map((point) => height(point.x, point.y, seed) * relief);
63
+ for (const [from, to] of cell(values, points, level)) {
64
+ path +=
65
+ `M${String(Math.round(from.x))} ${String(Math.round(from.y))}` +
66
+ `L${String(Math.round(to.x))} ${String(Math.round(to.y))}`;
67
+ }
68
+ }
69
+ }
70
+ return path;
71
+ }
72
+ //# sourceMappingURL=contours.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contours.js","sourceRoot":"","sources":["../../../src/texture/topographic/contours.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAQpC;;;;GAIG;AACH,SAAS,OAAO,CAAC,CAAQ,EAAE,CAAQ,EAAE,KAAa,EAAE,KAAa;IAC/D,MAAM,KAAK,GAAG,KAAK,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;IAEtC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC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C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;wBAC9D,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/D,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The height of the ground at a point, from -1 to 1.
3
+ *
4
+ * `seed` shifts each wave's phase by a different amount, so one number picks a
5
+ * whole landscape and the same number always picks the same one.
6
+ */
7
+ export declare function height(x: number, y: number, seed: number): number;
8
+ //# sourceMappingURL=field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../src/texture/topographic/field.ts"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CASjE"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The waves the ground is made of: how far one runs before it repeats, which
3
+ * way it runs, and how much of the height it accounts for.
4
+ *
5
+ * Three at unrelated wavelengths and angles is enough to read as terrain
6
+ * rather than as a pattern. Deliberately not random: the rebuild stamp assumes
7
+ * one config draws one picture, so a texture that rolled dice would come out
8
+ * different every time nothing had changed.
9
+ */
10
+ const waves = [
11
+ { length: 260, dx: 1, dy: 0.35, weight: 0.5 },
12
+ { length: 170, dx: -0.4, dy: 1, weight: 0.32 },
13
+ { length: 95, dx: 0.7, dy: -0.8, weight: 0.18 },
14
+ ];
15
+ /**
16
+ * The height of the ground at a point, from -1 to 1.
17
+ *
18
+ * `seed` shifts each wave's phase by a different amount, so one number picks a
19
+ * whole landscape and the same number always picks the same one.
20
+ */
21
+ export function height(x, y, seed) {
22
+ let sum = 0;
23
+ for (const [index, wave] of waves.entries()) {
24
+ const along = (x * wave.dx + y * wave.dy) / wave.length;
25
+ sum += wave.weight * Math.sin(along + seed * (index + 1) * 1.7);
26
+ }
27
+ return sum;
28
+ }
29
+ //# sourceMappingURL=field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.js","sourceRoot":"","sources":["../../../src/texture/topographic/field.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,KAAK,GAAG;IACZ,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE;IAC7C,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE;IAC9C,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;CAChD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,CAAS,EAAE,CAAS,EAAE,IAAY;IACvD,IAAI,GAAG,GAAG,CAAC,CAAC;IAEZ,KAAK,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5C,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QACxD,GAAG,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { Dimensions, Texture } from "../../types.js";
2
+ /**
3
+ * Contour lines, the look of a map: the height of a made-up landscape, drawn
4
+ * every `gap` pixels of it.
5
+ *
6
+ * These are the real thing rather than rings pretending: the field is sampled
7
+ * on a grid and each contour is the line where the ground passes through one
8
+ * height, so the shapes close where the ground has a summit, run off the edge
9
+ * where it keeps rising, and never cross each other. An earlier attempt drew
10
+ * circles pushed in and out by the same field, and no amount of pushing made
11
+ * it read as anything but a wobbly bullseye: what makes a map is that the
12
+ * shapes owe nothing to a centre.
13
+ */
14
+ export declare function topographicSvg(texture: Extract<Texture, {
15
+ readonly type: "topographic";
16
+ }>, dimensions: Dimensions): string;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/texture/topographic/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAqB1D;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC,EAC3D,UAAU,EAAE,UAAU,GACrB,MAAM,CAsBR"}