@kensio/colophon 2.11.1 → 2.12.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/dist/astro/index.d.ts.map +1 -1
- package/dist/astro/index.js +0 -1
- package/dist/astro/index.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +5 -0
- package/dist/config/defaults.js.map +1 -1
- package/dist/measure/faces.d.ts.map +1 -1
- package/dist/measure/faces.js.map +1 -1
- package/dist/templates/banner/index.js +2 -2
- package/dist/templates/banner/index.js.map +1 -1
- package/dist/templates/card/index.js +2 -2
- package/dist/templates/card/index.js.map +1 -1
- package/dist/templates/code/bar.d.ts +24 -0
- package/dist/templates/code/bar.d.ts.map +1 -0
- package/dist/templates/code/bar.js +31 -0
- package/dist/templates/code/bar.js.map +1 -0
- package/dist/templates/code/gutter.d.ts +30 -0
- package/dist/templates/code/gutter.d.ts.map +1 -0
- package/dist/templates/code/gutter.js +64 -0
- package/dist/templates/code/gutter.js.map +1 -0
- package/dist/templates/code/index.d.ts.map +1 -1
- package/dist/templates/code/index.js +34 -15
- package/dist/templates/code/index.js.map +1 -1
- package/dist/templates/code/layout.d.ts +6 -1
- package/dist/templates/code/layout.d.ts.map +1 -1
- package/dist/templates/code/layout.js +8 -3
- package/dist/templates/code/layout.js.map +1 -1
- package/dist/templates/code/mark/draw.d.ts +26 -0
- package/dist/templates/code/mark/draw.d.ts.map +1 -0
- package/dist/templates/code/mark/draw.js +41 -0
- package/dist/templates/code/mark/draw.js.map +1 -0
- package/dist/templates/code/mark/index.d.ts +16 -0
- package/dist/templates/code/mark/index.d.ts.map +1 -0
- package/dist/templates/code/mark/index.js +34 -0
- package/dist/templates/code/mark/index.js.map +1 -0
- package/dist/templates/code/mark/locate.d.ts +20 -0
- package/dist/templates/code/mark/locate.d.ts.map +1 -0
- package/dist/templates/code/mark/locate.js +56 -0
- package/dist/templates/code/mark/locate.js.map +1 -0
- package/dist/templates/code/mark/read.d.ts +30 -0
- package/dist/templates/code/mark/read.d.ts.map +1 -0
- package/dist/templates/code/mark/read.js +61 -0
- package/dist/templates/code/mark/read.js.map +1 -0
- package/dist/templates/code/plate.d.ts +7 -1
- package/dist/templates/code/plate.d.ts.map +1 -1
- package/dist/templates/code/plate.js +14 -4
- package/dist/templates/code/plate.js.map +1 -1
- package/dist/templates/footer.d.ts +9 -1
- package/dist/templates/footer.d.ts.map +1 -1
- package/dist/templates/footer.js +24 -0
- package/dist/templates/footer.js.map +1 -1
- package/dist/templates/frame.d.ts.map +1 -1
- package/dist/templates/frame.js +5 -7
- package/dist/templates/frame.js.map +1 -1
- package/dist/templates/terminal/index.js +4 -4
- package/dist/templates/terminal/index.js.map +1 -1
- package/dist/templates/window/dots.d.ts +11 -0
- package/dist/templates/window/dots.d.ts.map +1 -0
- package/dist/templates/window/dots.js +32 -0
- package/dist/templates/window/dots.js.map +1 -0
- package/dist/templates/{terminal/window.d.ts → window/index.d.ts} +4 -2
- package/dist/templates/window/index.d.ts.map +1 -0
- package/dist/templates/window/index.js +48 -0
- package/dist/templates/window/index.js.map +1 -0
- package/dist/templates/window/title.d.ts +9 -0
- package/dist/templates/window/title.d.ts.map +1 -0
- package/dist/templates/window/title.js +24 -0
- package/dist/templates/window/title.js.map +1 -0
- package/dist/texture/chevrons.d.ts +13 -0
- package/dist/texture/chevrons.d.ts.map +1 -0
- package/dist/texture/chevrons.js +22 -0
- package/dist/texture/chevrons.js.map +1 -0
- package/dist/texture/grid.d.ts +14 -0
- package/dist/texture/grid.d.ts.map +1 -0
- package/dist/texture/grid.js +38 -0
- package/dist/texture/grid.js.map +1 -0
- package/dist/texture/halftone.d.ts +14 -0
- package/dist/texture/halftone.d.ts.map +1 -0
- package/dist/texture/halftone.js +55 -0
- package/dist/texture/halftone.js.map +1 -0
- package/dist/texture/honeycomb.d.ts +14 -0
- package/dist/texture/honeycomb.d.ts.map +1 -0
- package/dist/texture/honeycomb.js +43 -0
- package/dist/texture/honeycomb.js.map +1 -0
- package/dist/texture/index.d.ts +1 -2
- package/dist/texture/index.d.ts.map +1 -1
- package/dist/texture/index.js +44 -13
- package/dist/texture/index.js.map +1 -1
- package/dist/texture/moire.d.ts +18 -0
- package/dist/texture/moire.d.ts.map +1 -0
- package/dist/texture/moire.js +44 -0
- package/dist/texture/moire.js.map +1 -0
- package/dist/texture/pattern.d.ts +10 -0
- package/dist/texture/pattern.d.ts.map +1 -1
- package/dist/texture/pattern.js +36 -13
- package/dist/texture/pattern.js.map +1 -1
- package/dist/texture/rays.d.ts +13 -0
- package/dist/texture/rays.d.ts.map +1 -0
- package/dist/texture/rays.js +36 -0
- package/dist/texture/rays.js.map +1 -0
- package/dist/texture/scallops.d.ts +14 -0
- package/dist/texture/scallops.d.ts.map +1 -0
- package/dist/texture/scallops.js +29 -0
- package/dist/texture/scallops.js.map +1 -0
- package/dist/texture/tile.d.ts +14 -0
- package/dist/texture/tile.d.ts.map +1 -0
- package/dist/texture/tile.js +23 -0
- package/dist/texture/tile.js.map +1 -0
- package/dist/texture/topographic/contours.d.ts +13 -0
- package/dist/texture/topographic/contours.d.ts.map +1 -0
- package/dist/texture/topographic/contours.js +72 -0
- package/dist/texture/topographic/contours.js.map +1 -0
- package/dist/texture/topographic/field.d.ts +8 -0
- package/dist/texture/topographic/field.d.ts.map +1 -0
- package/dist/texture/topographic/field.js +29 -0
- package/dist/texture/topographic/field.js.map +1 -0
- package/dist/texture/topographic/index.d.ts +17 -0
- package/dist/texture/topographic/index.d.ts.map +1 -0
- package/dist/texture/topographic/index.js +48 -0
- package/dist/texture/topographic/index.js.map +1 -0
- package/dist/theme/presets.d.ts +13 -5
- package/dist/theme/presets.d.ts.map +1 -1
- package/dist/theme/presets.js +16 -5
- package/dist/theme/presets.js.map +1 -1
- package/dist/types.d.ts +231 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/validate/collect.d.ts.map +1 -1
- package/dist/validate/collect.js +2 -1
- package/dist/validate/collect.js.map +1 -1
- package/dist/validate/keys.d.ts +37 -0
- package/dist/validate/keys.d.ts.map +1 -1
- package/dist/validate/keys.js +130 -2
- package/dist/validate/keys.js.map +1 -1
- package/dist/validate/texture.d.ts +4 -5
- package/dist/validate/texture.d.ts.map +1 -1
- package/dist/validate/texture.js +11 -20
- package/dist/validate/texture.js.map +1 -1
- package/dist/validate/values.d.ts +6 -0
- package/dist/validate/values.d.ts.map +1 -1
- package/dist/validate/values.js +16 -1
- package/dist/validate/values.js.map +1 -1
- package/package.json +3 -10
- package/dist/templates/terminal/window.d.ts.map +0 -1
- package/dist/templates/terminal/window.js +0 -84
- package/dist/templates/terminal/window.js.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { fallbackColor } from "./color.js";
|
|
2
|
+
import { tile } from "./tile.js";
|
|
3
|
+
const chevronDefaults = { opacity: 0.07, width: 2, gap: 36 };
|
|
4
|
+
/**
|
|
5
|
+
* Rows of chevrons: one V to a tile, meeting its neighbours at the tile edge.
|
|
6
|
+
*
|
|
7
|
+
* The V spans the whole width and stops short of the top and bottom, so the
|
|
8
|
+
* rows have air between them. Its ends sit at the same height on both edges,
|
|
9
|
+
* which is what makes one tile's chevron continue into the next rather than
|
|
10
|
+
* ending in a corner.
|
|
11
|
+
*/
|
|
12
|
+
export function chevronsSvg(texture, dimensions, id) {
|
|
13
|
+
const gap = texture.gap ?? chevronDefaults.gap;
|
|
14
|
+
const low = String(gap * 0.7);
|
|
15
|
+
const high = String(gap * 0.3);
|
|
16
|
+
const chevron = `<path d="M0 ${low}L${String(gap / 2)} ${high}L${String(gap)} ${low}"` +
|
|
17
|
+
` stroke="${texture.color ?? fallbackColor}"` +
|
|
18
|
+
` stroke-width="${String(texture.width ?? chevronDefaults.width)}"` +
|
|
19
|
+
` fill="none"/>`;
|
|
20
|
+
return tile(id, gap, chevron, "", dimensions, texture.opacity ?? chevronDefaults.opacity);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=chevrons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chevrons.js","sourceRoot":"","sources":["../../src/texture/chevrons.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,GAAG,EAAE,EAAE,EAAE,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CACzB,OAAwD,EACxD,UAAsB,EACtB,EAAU;IAEV,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC;IAC/C,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IAC/B,MAAM,OAAO,GACX,eAAe,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,IAAI,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG;QACtE,YAAY,OAAO,CAAC,KAAK,IAAI,aAAa,GAAG;QAC7C,kBAAkB,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG;QACnE,gBAAgB,CAAC;IAEnB,OAAO,IAAI,CACT,EAAE,EACF,GAAG,EACH,OAAO,EACP,EAAE,EACF,UAAU,EACV,OAAO,CAAC,OAAO,IAAI,eAAe,CAAC,OAAO,CAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Dimensions, Texture } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Squared paper: lines both ways, and a heavier one every so often.
|
|
4
|
+
*
|
|
5
|
+
* The heavy lines are a second tile rather than part of the first, since what
|
|
6
|
+
* makes them heavy is that they repeat at a multiple of the spacing. Drawing
|
|
7
|
+
* both from `<pattern>`s keeps this among the cheap treatments: the tiles are
|
|
8
|
+
* square to the image, so a row of the rendered picture repeats, which is what
|
|
9
|
+
* the compression works on.
|
|
10
|
+
*/
|
|
11
|
+
export declare function gridSvg(texture: Extract<Texture, {
|
|
12
|
+
readonly type: "grid";
|
|
13
|
+
}>, dimensions: Dimensions, id: string): string;
|
|
14
|
+
//# sourceMappingURL=grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../src/texture/grid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA4BvD;;;;;;;;GAQG;AACH,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,CA8BR"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { fallbackColor } from "./color.js";
|
|
2
|
+
import { tile } from "./tile.js";
|
|
3
|
+
const gridDefaults = { opacity: 0.07, width: 1, gap: 32, major: 5 };
|
|
4
|
+
/** How much heavier the every-so-often line is than the rest. */
|
|
5
|
+
const majorScale = 2;
|
|
6
|
+
/** One square's worth of grid: a line along two of its edges. */
|
|
7
|
+
function square(texture, gap, width) {
|
|
8
|
+
const middle = String(gap / 2);
|
|
9
|
+
const size = String(gap);
|
|
10
|
+
// Down the middle of the tile on both axes rather than along its edges, for
|
|
11
|
+
// the reason `rulesSvg` gives: a stroke centred on the edge would have half
|
|
12
|
+
// of itself outside the tile, where the pattern does not repeat it.
|
|
13
|
+
return (`<path d="M0 ${middle}H${size}M${middle} 0V${size}"` +
|
|
14
|
+
` stroke="${texture.color ?? fallbackColor}"` +
|
|
15
|
+
` stroke-width="${String(width)}" fill="none"/>`);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Squared paper: lines both ways, and a heavier one every so often.
|
|
19
|
+
*
|
|
20
|
+
* The heavy lines are a second tile rather than part of the first, since what
|
|
21
|
+
* makes them heavy is that they repeat at a multiple of the spacing. Drawing
|
|
22
|
+
* both from `<pattern>`s keeps this among the cheap treatments: the tiles are
|
|
23
|
+
* square to the image, so a row of the rendered picture repeats, which is what
|
|
24
|
+
* the compression works on.
|
|
25
|
+
*/
|
|
26
|
+
export function gridSvg(texture, dimensions, id) {
|
|
27
|
+
const gap = texture.gap ?? gridDefaults.gap;
|
|
28
|
+
const width = texture.width ?? gridDefaults.width;
|
|
29
|
+
const opacity = texture.opacity ?? gridDefaults.opacity;
|
|
30
|
+
const major = texture.major ?? gridDefaults.major;
|
|
31
|
+
const fine = tile(`${id}a`, gap, square(texture, gap, width), "", dimensions, opacity);
|
|
32
|
+
if (major < 2) {
|
|
33
|
+
return fine;
|
|
34
|
+
}
|
|
35
|
+
return (fine +
|
|
36
|
+
tile(`${id}b`, gap * major, square(texture, gap * major, width * majorScale), "", dimensions, opacity));
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../src/texture/grid.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,YAAY,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAEpE,iEAAiE;AACjE,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB,iEAAiE;AACjE,SAAS,MAAM,CACb,OAAoD,EACpD,GAAW,EACX,KAAa;IAEb,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,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
|
+
* A grid of dots that grow across the image, which is a gradient made out of
|
|
4
|
+
* print.
|
|
5
|
+
*
|
|
6
|
+
* It cannot be a tile: every dot is a different size, which is the whole
|
|
7
|
+
* effect. What keeps it affordable is that the size depends on the position
|
|
8
|
+
* rather than on chance, so a run of dots across the image is a smooth ramp
|
|
9
|
+
* and there is nothing noisy for the compression to choke on.
|
|
10
|
+
*/
|
|
11
|
+
export declare function halftoneSvg(texture: Extract<Texture, {
|
|
12
|
+
readonly type: "halftone";
|
|
13
|
+
}>, dimensions: Dimensions): string;
|
|
14
|
+
//# sourceMappingURL=halftone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"halftone.d.ts","sourceRoot":"","sources":["../../src/texture/halftone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAsCvD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,EACxD,UAAU,EAAE,UAAU,GACrB,MAAM,CAuBR"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { fallbackColor } from "./color.js";
|
|
2
|
+
const halftoneDefaults = {
|
|
3
|
+
opacity: 0.12,
|
|
4
|
+
size: 12,
|
|
5
|
+
gap: 30,
|
|
6
|
+
angle: 90,
|
|
7
|
+
from: 0.1,
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* How far along the growth a point is, from 0 at one edge to 1 at the other.
|
|
11
|
+
*
|
|
12
|
+
* It is the point's distance along the direction the dots grow in, measured
|
|
13
|
+
* from whichever corner is furthest back along it, so the ramp covers the
|
|
14
|
+
* whole image whatever angle it runs at.
|
|
15
|
+
*/
|
|
16
|
+
function ramp(dimensions, angle) {
|
|
17
|
+
const radians = (angle * Math.PI) / 180;
|
|
18
|
+
const dx = Math.cos(radians);
|
|
19
|
+
const dy = Math.sin(radians);
|
|
20
|
+
const { width, height } = dimensions;
|
|
21
|
+
// The four corners projected onto the direction give its full span, so the
|
|
22
|
+
// ends of the ramp land on the image rather than somewhere outside it.
|
|
23
|
+
const corners = [0, width].flatMap((cx) => [0, height].map((cy) => cx * dx + cy * dy));
|
|
24
|
+
const low = Math.min(...corners);
|
|
25
|
+
const span = Math.max(...corners) - low || 1;
|
|
26
|
+
return (px, py) => (px * dx + py * dy - low) / span;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A grid of dots that grow across the image, which is a gradient made out of
|
|
30
|
+
* print.
|
|
31
|
+
*
|
|
32
|
+
* It cannot be a tile: every dot is a different size, which is the whole
|
|
33
|
+
* effect. What keeps it affordable is that the size depends on the position
|
|
34
|
+
* rather than on chance, so a run of dots across the image is a smooth ramp
|
|
35
|
+
* and there is nothing noisy for the compression to choke on.
|
|
36
|
+
*/
|
|
37
|
+
export function halftoneSvg(texture, dimensions) {
|
|
38
|
+
const gap = texture.gap ?? halftoneDefaults.gap;
|
|
39
|
+
const size = texture.size ?? halftoneDefaults.size;
|
|
40
|
+
const from = texture.from ?? halftoneDefaults.from;
|
|
41
|
+
const at = ramp(dimensions, texture.angle ?? halftoneDefaults.angle);
|
|
42
|
+
let dots = "";
|
|
43
|
+
for (let y = gap / 2; y < dimensions.height + gap; y += gap) {
|
|
44
|
+
for (let x = gap / 2; x < dimensions.width + gap; x += gap) {
|
|
45
|
+
const radius = (size / 2) * (from + (1 - from) * at(x, y));
|
|
46
|
+
dots +=
|
|
47
|
+
`<circle cx="${String(Math.round(x))}" cy="${String(Math.round(y))}"` +
|
|
48
|
+
` r="${String(Math.round(radius * 100) / 100)}"/>`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return (`<g fill="${texture.color ?? fallbackColor}"` +
|
|
52
|
+
` opacity="${String(texture.opacity ?? halftoneDefaults.opacity)}">` +
|
|
53
|
+
`${dots}</g>`);
|
|
54
|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G;QAC7C,aAAa,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,IAAI;QACpE,GAAG,IAAI,MAAM,CACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Dimensions, Texture } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A honeycomb of hexagon outlines.
|
|
4
|
+
*
|
|
5
|
+
* The grid repeats every three sides across and every `side * sqrt(3)` down,
|
|
6
|
+
* which is the smallest rectangle a honeycomb fits in. Two hexagons go in it,
|
|
7
|
+
* the second offset by half of each, and the ones that fall outside are drawn
|
|
8
|
+
* anyway so that the tile joins its neighbours: the pattern clips them, and a
|
|
9
|
+
* hexagon cut in half by the tile edge meets its other half in the next tile.
|
|
10
|
+
*/
|
|
11
|
+
export declare function honeycombSvg(texture: Extract<Texture, {
|
|
12
|
+
readonly type: "honeycomb";
|
|
13
|
+
}>, dimensions: Dimensions, id: string): string;
|
|
14
|
+
//# sourceMappingURL=honeycomb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"honeycomb.d.ts","sourceRoot":"","sources":["../../src/texture/honeycomb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA8BvD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC,EACzD,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,MAAM,GACT,MAAM,CAwBR"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { fallbackColor } from "./color.js";
|
|
2
|
+
import { tile } from "./tile.js";
|
|
3
|
+
const combDefaults = { opacity: 0.07, width: 1.5, size: 26 };
|
|
4
|
+
/** Rounded to keep the path short, since it is written out twice a tile. */
|
|
5
|
+
function at(value) {
|
|
6
|
+
return String(Math.round(value * 100) / 100);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* One flat-topped hexagon, from its centre and the length of a side.
|
|
10
|
+
*
|
|
11
|
+
* A hexagon of side `s` is `2s` across the points and `s * sqrt(3)` across the
|
|
12
|
+
* flats, which is where every number below comes from.
|
|
13
|
+
*/
|
|
14
|
+
function hexagon(cx, cy, side) {
|
|
15
|
+
const half = (side * Math.sqrt(3)) / 2;
|
|
16
|
+
return (`M${at(cx - side)} ${at(cy)}` +
|
|
17
|
+
`L${at(cx - side / 2)} ${at(cy - half)}` +
|
|
18
|
+
`L${at(cx + side / 2)} ${at(cy - half)}` +
|
|
19
|
+
`L${at(cx + side)} ${at(cy)}` +
|
|
20
|
+
`L${at(cx + side / 2)} ${at(cy + half)}` +
|
|
21
|
+
`L${at(cx - side / 2)} ${at(cy + half)}Z`);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A honeycomb of hexagon outlines.
|
|
25
|
+
*
|
|
26
|
+
* The grid repeats every three sides across and every `side * sqrt(3)` down,
|
|
27
|
+
* which is the smallest rectangle a honeycomb fits in. Two hexagons go in it,
|
|
28
|
+
* the second offset by half of each, and the ones that fall outside are drawn
|
|
29
|
+
* anyway so that the tile joins its neighbours: the pattern clips them, and a
|
|
30
|
+
* hexagon cut in half by the tile edge meets its other half in the next tile.
|
|
31
|
+
*/
|
|
32
|
+
export function honeycombSvg(texture, dimensions, id) {
|
|
33
|
+
const side = texture.size ?? combDefaults.size;
|
|
34
|
+
const height = side * Math.sqrt(3);
|
|
35
|
+
const width = side * 3;
|
|
36
|
+
const comb = `<path d="${hexagon(side, height / 2, side)}${hexagon(side * 2.5, 0, side)}${hexagon(side * 2.5, height, side)}" stroke="${texture.color ?? fallbackColor}"` +
|
|
37
|
+
` stroke-width="${String(texture.width ?? combDefaults.width)}"` +
|
|
38
|
+
` fill="none"/>`;
|
|
39
|
+
// Not the square tile the others use: a honeycomb's repeat is wider than it
|
|
40
|
+
// is tall, so `tile` takes the two separately here.
|
|
41
|
+
return tile(id, { width, height }, comb, "", dimensions, texture.opacity ?? combDefaults.opacity);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=honeycomb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"honeycomb.js","sourceRoot":"","sources":["../../src/texture/honeycomb.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,YAAY,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AAE7D,4EAA4E;AAC5E,SAAS,EAAE,CAAC,KAAa;IACvB,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;GAKG;AACH,SAAS,OAAO,CAAC,EAAU,EAAE,EAAU,EAAE,IAAY;IACnD,MAAM,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEvC,OAAO,CACL,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE;QAC7B,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE;QACxC,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE;QACxC,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE;QAC7B,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE;QACxC,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,CAC1C,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAyD,EACzD,UAAsB,EACtB,EAAU;IAEV,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC;IAC/C,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC;IAEvB,MAAM,IAAI,GACR,YAAY,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,OAAO,CACnD,IAAI,GAAG,GAAG,EACV,CAAC,EACD,IAAI,CACL,GAAG,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,OAAO,CAAC,KAAK,IAAI,aAAa,GAAG;QACnF,kBAAkB,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,YAAY,CAAC,KAAK,CAAC,GAAG;QAChE,gBAAgB,CAAC;IAEnB,4EAA4E;IAC5E,oDAAoD;IACpD,OAAO,IAAI,CACT,EAAE,EACF,EAAE,KAAK,EAAE,MAAM,EAAE,EACjB,IAAI,EACJ,EAAE,EACF,UAAU,EACV,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,CACxC,CAAC;AACJ,CAAC"}
|
package/dist/texture/index.d.ts
CHANGED
|
@@ -2,8 +2,7 @@ import type { Dimensions, Texture } from "../types.js";
|
|
|
2
2
|
export { resolveTexture } from "./resolve.js";
|
|
3
3
|
/**
|
|
4
4
|
* Render the treatment laid over a background as SVG, naming whatever it needs
|
|
5
|
-
* in `<defs>` after the given `id`.
|
|
6
|
-
* plain elements and names nothing.
|
|
5
|
+
* in `<defs>` after the given `id`.
|
|
7
6
|
*
|
|
8
7
|
* It is drawn between the background and whatever a template draws, so a
|
|
9
8
|
* texture never comes between a headline and the reader.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/texture/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/texture/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAavD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAuC9C;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,MAAM,GACT,MAAM,CAOR"}
|
package/dist/texture/index.js
CHANGED
|
@@ -1,25 +1,56 @@
|
|
|
1
|
+
import { chevronsSvg } from "./chevrons.js";
|
|
1
2
|
import { grainSvg } from "./grain.js";
|
|
2
|
-
import {
|
|
3
|
+
import { halftoneSvg } from "./halftone.js";
|
|
4
|
+
import { gridSvg } from "./grid.js";
|
|
5
|
+
import { honeycombSvg } from "./honeycomb.js";
|
|
6
|
+
import { moireSvg } from "./moire.js";
|
|
7
|
+
import { crossesSvg, dotsSvg, rulesSvg } from "./pattern.js";
|
|
8
|
+
import { raysSvg } from "./rays.js";
|
|
9
|
+
import { scallopsSvg } from "./scallops.js";
|
|
10
|
+
import { topographicSvg } from "./topographic/index.js";
|
|
3
11
|
import { wavesSvg } from "./waves.js";
|
|
4
12
|
export { resolveTexture } from "./resolve.js";
|
|
13
|
+
/**
|
|
14
|
+
* Which function draws which treatment.
|
|
15
|
+
*
|
|
16
|
+
* A table rather than a chain of `if`s, because the chain had a branch per
|
|
17
|
+
* texture and there are ten of them: the file was close to the complexity
|
|
18
|
+
* threshold and every new treatment made it worse. The type is what keeps this
|
|
19
|
+
* honest, and it does the job the chain's final `return` used to do badly: a
|
|
20
|
+
* variant added to `Texture` with no entry here fails to compile, where before
|
|
21
|
+
* it silently came out as ruled lines.
|
|
22
|
+
*
|
|
23
|
+
* `waves` and `rays` name nothing in `<defs>` and take no id. They are wrapped
|
|
24
|
+
* rather than given a parameter to ignore, so each one's own signature still
|
|
25
|
+
* says what it uses.
|
|
26
|
+
*/
|
|
27
|
+
const drawers = {
|
|
28
|
+
grain: grainSvg,
|
|
29
|
+
dots: dotsSvg,
|
|
30
|
+
rules: rulesSvg,
|
|
31
|
+
grid: gridSvg,
|
|
32
|
+
crosses: crossesSvg,
|
|
33
|
+
chevrons: chevronsSvg,
|
|
34
|
+
honeycomb: honeycombSvg,
|
|
35
|
+
moire: moireSvg,
|
|
36
|
+
scallops: scallopsSvg,
|
|
37
|
+
waves: (texture, dimensions) => wavesSvg(texture, dimensions),
|
|
38
|
+
rays: (texture, dimensions) => raysSvg(texture, dimensions),
|
|
39
|
+
halftone: (texture, dimensions) => halftoneSvg(texture, dimensions),
|
|
40
|
+
topographic: (texture, dimensions) => topographicSvg(texture, dimensions),
|
|
41
|
+
};
|
|
5
42
|
/**
|
|
6
43
|
* Render the treatment laid over a background as SVG, naming whatever it needs
|
|
7
|
-
* in `<defs>` after the given `id`.
|
|
8
|
-
* plain elements and names nothing.
|
|
44
|
+
* in `<defs>` after the given `id`.
|
|
9
45
|
*
|
|
10
46
|
* It is drawn between the background and whatever a template draws, so a
|
|
11
47
|
* texture never comes between a headline and the reader.
|
|
12
48
|
*/
|
|
13
49
|
export function textureSvg(texture, dimensions, id) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
if (texture.type === "waves") {
|
|
21
|
-
return wavesSvg(texture, dimensions);
|
|
22
|
-
}
|
|
23
|
-
return rulesSvg(texture, dimensions, id);
|
|
50
|
+
// The value and the lookup narrow separately, so the compiler cannot see
|
|
51
|
+
// that they are the same variant, though the table's type is what makes them
|
|
52
|
+
// so. This is the one line that knows better than the checker.
|
|
53
|
+
const draw = drawers[texture.type];
|
|
54
|
+
return draw(texture, dimensions, id);
|
|
24
55
|
}
|
|
25
56
|
//# sourceMappingURL=index.js.map
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/texture/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAS9C;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,GAAwC;IACnD,KAAK,EAAE,QAAQ;IACf,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,QAAQ;IACf,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,WAAW;IACrB,SAAS,EAAE,YAAY;IACvB,KAAK,EAAE,QAAQ;IACf,QAAQ,EAAE,WAAW;IACrB,KAAK,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7D,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC;IAC3D,QAAQ,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC;IACnE,WAAW,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,UAAU,CAAC;CAC1E,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,OAAgB,EAChB,UAAsB,EACtB,EAAU;IAEV,yEAAyE;IACzE,6EAA6E;IAC7E,+DAA+D;IAC/D,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAA0B,CAAC;IAE5D,OAAO,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;AACvC,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,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,aAAa,GAAG,EAAE,OAAO,EAAE,GAAG,EAA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C,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;
|
|
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"}
|
package/dist/texture/pattern.js
CHANGED
|
@@ -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
|
-
*
|
|
6
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
1
|
+
{"version":3,"file":"pattern.js","sourceRoot":"","sources":["../../src/texture/pattern.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,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;AACrE,MAAM,aAAa,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB,qCAAqC;AACrC,MAAM,UAAU,OAAO,CACrB,OAAoD,EACpD,UAAsB,EACtB,EAAU;IAEV,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC;IAC3C,MAAM,MAAM,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-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":["../../src/texture/rays.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,WAAW,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC;AAO5E,wEAAwE;AACxE,SAAS,KAAK,CAAC,MAAc,EAAE,UAAsB;IACnD,OAAO,IAAI,CAAC,KAAK,CACf,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AAG,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"}
|
|
@@ -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"}
|