@kensio/colophon 2.3.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -798
- package/dist/background/gradient.d.ts +12 -0
- package/dist/background/gradient.d.ts.map +1 -0
- package/dist/background/gradient.js +21 -0
- package/dist/background/gradient.js.map +1 -0
- package/dist/background/image.d.ts +14 -0
- package/dist/background/image.d.ts.map +1 -0
- package/dist/background/image.js +36 -0
- package/dist/background/image.js.map +1 -0
- package/dist/background/index.d.ts +13 -0
- package/dist/background/index.d.ts.map +1 -0
- package/dist/background/index.js +27 -0
- package/dist/background/index.js.map +1 -0
- package/dist/background/mesh.d.ts +12 -0
- package/dist/background/mesh.d.ts.map +1 -0
- package/dist/background/mesh.js +43 -0
- package/dist/background/mesh.js.map +1 -0
- package/dist/background.d.ts +7 -2
- package/dist/background.d.ts.map +1 -1
- package/dist/background.js +44 -1
- package/dist/background.js.map +1 -1
- package/dist/cli/args.d.ts +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -1
- package/dist/cli/config.d.ts +1 -1
- package/dist/cli/config.js +1 -1
- package/dist/config/defaults.d.ts +8 -7
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +8 -8
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +14 -5
- package/dist/config/index.js.map +1 -1
- package/dist/config/resolve.d.ts +7 -0
- package/dist/config/resolve.d.ts.map +1 -1
- package/dist/config/resolve.js +16 -0
- package/dist/config/resolve.js.map +1 -1
- package/dist/config/size.d.ts +7 -1
- package/dist/config/size.d.ts.map +1 -1
- package/dist/config/size.js +22 -9
- package/dist/config/size.js.map +1 -1
- package/dist/content/props.d.ts +2 -2
- package/dist/content/props.js +2 -2
- package/dist/content/slug.d.ts +5 -5
- package/dist/content/slug.js +6 -6
- package/dist/content/slug.js.map +1 -1
- package/dist/content/walk.d.ts +1 -1
- package/dist/content/walk.js +1 -1
- package/dist/fonts/index.d.ts +3 -2
- package/dist/fonts/index.d.ts.map +1 -1
- package/dist/fonts/index.js +3 -2
- package/dist/fonts/index.js.map +1 -1
- package/dist/fonts/resolve.js +1 -1
- package/dist/generate/extra.js +4 -4
- package/dist/generate/extra.js.map +1 -1
- package/dist/generate/options.d.ts +1 -1
- package/dist/generate/outputs.d.ts +4 -4
- package/dist/generate/outputs.js +4 -4
- package/dist/highlight/language.d.ts +2 -3
- package/dist/highlight/language.d.ts.map +1 -1
- package/dist/highlight/language.js +3 -4
- package/dist/highlight/language.js.map +1 -1
- package/dist/highlight/normalise.d.ts +2 -2
- package/dist/highlight/normalise.js +2 -2
- package/dist/image/index.d.ts +18 -0
- package/dist/image/index.d.ts.map +1 -0
- package/dist/image/index.js +42 -0
- package/dist/image/index.js.map +1 -0
- package/dist/image/jpeg.d.ts +10 -0
- package/dist/image/jpeg.d.ts.map +1 -0
- package/dist/image/jpeg.js +57 -0
- package/dist/image/jpeg.js.map +1 -0
- package/dist/image/load.d.ts +4 -0
- package/dist/image/load.d.ts.map +1 -0
- package/dist/image/load.js +60 -0
- package/dist/image/load.js.map +1 -0
- package/dist/image/media.d.ts +10 -0
- package/dist/image/media.d.ts.map +1 -0
- package/dist/image/media.js +37 -0
- package/dist/image/media.js.map +1 -0
- package/dist/image/resolve.d.ts +13 -0
- package/dist/image/resolve.d.ts.map +1 -0
- package/dist/image/resolve.js +38 -0
- package/dist/image/resolve.js.map +1 -0
- package/dist/image/size.d.ts +22 -0
- package/dist/image/size.d.ts.map +1 -0
- package/dist/image/size.js +60 -0
- package/dist/image/size.js.map +1 -0
- package/dist/image/svg.d.ts +12 -0
- package/dist/image/svg.d.ts.map +1 -0
- package/dist/image/svg.js +61 -0
- package/dist/image/svg.js.map +1 -0
- package/dist/image/uri.d.ts +9 -0
- package/dist/image/uri.d.ts.map +1 -0
- package/dist/image/uri.js +22 -0
- package/dist/image/uri.js.map +1 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/layout/block.d.ts +37 -0
- package/dist/layout/block.d.ts.map +1 -0
- package/dist/layout/block.js +26 -0
- package/dist/layout/block.js.map +1 -0
- package/dist/layout/box.d.ts +20 -0
- package/dist/layout/box.d.ts.map +1 -0
- package/dist/layout/box.js +61 -0
- package/dist/layout/box.js.map +1 -0
- package/dist/layout/distribute.d.ts +15 -0
- package/dist/layout/distribute.d.ts.map +1 -0
- package/dist/layout/distribute.js +30 -0
- package/dist/layout/distribute.js.map +1 -0
- package/dist/layout/image.d.ts +42 -0
- package/dist/layout/image.d.ts.map +1 -0
- package/dist/layout/image.js +34 -0
- package/dist/layout/image.js.map +1 -0
- package/dist/layout/index.d.ts +40 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/index.js +30 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/layout/lines.d.ts +45 -0
- package/dist/layout/lines.d.ts.map +1 -0
- package/dist/layout/lines.js +71 -0
- package/dist/layout/lines.js.map +1 -0
- package/dist/layout/measure.d.ts +11 -0
- package/dist/layout/measure.d.ts.map +1 -0
- package/dist/layout/measure.js +11 -0
- package/dist/layout/measure.js.map +1 -0
- package/dist/layout/panel.d.ts +20 -0
- package/dist/layout/panel.d.ts.map +1 -0
- package/dist/layout/panel.js +22 -0
- package/dist/layout/panel.js.map +1 -0
- package/dist/layout/row.d.ts +15 -0
- package/dist/layout/row.d.ts.map +1 -0
- package/dist/layout/row.js +20 -0
- package/dist/layout/row.js.map +1 -0
- package/dist/layout/scrim.d.ts +23 -0
- package/dist/layout/scrim.d.ts.map +1 -0
- package/dist/layout/scrim.js +38 -0
- package/dist/layout/scrim.js.map +1 -0
- package/dist/layout/stack.d.ts +14 -0
- package/dist/layout/stack.d.ts.map +1 -0
- package/dist/layout/stack.js +19 -0
- package/dist/layout/stack.js.map +1 -0
- package/dist/layout/types.d.ts +49 -0
- package/dist/layout/types.d.ts.map +1 -0
- package/dist/layout/types.js +2 -0
- package/dist/layout/types.js.map +1 -0
- package/dist/manifest/build.d.ts +1 -1
- package/dist/manifest/build.js +1 -1
- package/dist/manifest/index.d.ts +1 -1
- package/dist/manifest/index.js +1 -1
- package/dist/manifest/order.d.ts +1 -1
- package/dist/manifest/order.js +1 -1
- package/dist/manifest/page.d.ts +2 -2
- package/dist/manifest/page.js +3 -3
- package/dist/measure/estimate.d.ts +10 -0
- package/dist/measure/estimate.d.ts.map +1 -0
- package/dist/measure/estimate.js +58 -0
- package/dist/measure/estimate.js.map +1 -0
- package/dist/measure/faces.d.ts +15 -0
- package/dist/measure/faces.d.ts.map +1 -0
- package/dist/measure/faces.js +70 -0
- package/dist/measure/faces.js.map +1 -0
- package/dist/measure/index.d.ts +16 -0
- package/dist/measure/index.d.ts.map +1 -0
- package/dist/measure/index.js +0 -0
- package/dist/measure/index.js.map +1 -0
- package/dist/measure/runs.d.ts +17 -0
- package/dist/measure/runs.d.ts.map +1 -0
- package/dist/measure/runs.js +39 -0
- package/dist/measure/runs.js.map +1 -0
- package/dist/measure/select.d.ts +13 -0
- package/dist/measure/select.d.ts.map +1 -0
- package/dist/measure/select.js +47 -0
- package/dist/measure/select.js.map +1 -0
- package/dist/meta/tags.d.ts +6 -6
- package/dist/meta/tags.js +6 -6
- package/dist/meta/url.d.ts +4 -4
- package/dist/meta/url.js +4 -4
- package/dist/placement/check.d.ts +1 -1
- package/dist/placement/check.js +1 -1
- package/dist/placement/index.js +1 -1
- package/dist/placement/relative.d.ts +3 -3
- package/dist/placement/relative.js +3 -3
- package/dist/pool.d.ts +2 -2
- package/dist/pool.js +3 -3
- package/dist/pool.js.map +1 -1
- package/dist/props.d.ts +7 -0
- package/dist/props.d.ts.map +1 -0
- package/dist/props.js +17 -0
- package/dist/props.js.map +1 -0
- package/dist/render/svg.d.ts +4 -2
- package/dist/render/svg.d.ts.map +1 -1
- package/dist/render/svg.js +28 -6
- package/dist/render/svg.js.map +1 -1
- package/dist/stamp/config-digest.d.ts.map +1 -1
- package/dist/stamp/config-digest.js +21 -1
- package/dist/stamp/config-digest.js.map +1 -1
- package/dist/stamp/index.js +2 -2
- package/dist/stamp/index.js.map +1 -1
- package/dist/stamp/read.d.ts +1 -1
- package/dist/stamp/read.js +4 -4
- package/dist/templates/attribution.d.ts +17 -0
- package/dist/templates/attribution.d.ts.map +1 -0
- package/dist/templates/attribution.js +39 -0
- package/dist/templates/attribution.js.map +1 -0
- package/dist/templates/banner/badge-props.d.ts +16 -0
- package/dist/templates/banner/badge-props.d.ts.map +1 -0
- package/dist/templates/banner/badge-props.js +58 -0
- package/dist/templates/banner/badge-props.js.map +1 -0
- package/dist/templates/banner/badge.d.ts.map +1 -1
- package/dist/templates/banner/badge.js +3 -6
- package/dist/templates/banner/badge.js.map +1 -1
- package/dist/templates/banner/index.d.ts +3 -0
- package/dist/templates/banner/index.d.ts.map +1 -1
- package/dist/templates/banner/index.js +41 -37
- package/dist/templates/banner/index.js.map +1 -1
- package/dist/templates/banner/lines.d.ts +7 -12
- package/dist/templates/banner/lines.d.ts.map +1 -1
- package/dist/templates/banner/lines.js +23 -34
- package/dist/templates/banner/lines.js.map +1 -1
- package/dist/templates/banner/version.d.ts +9 -0
- package/dist/templates/banner/version.d.ts.map +1 -0
- package/dist/templates/banner/version.js +21 -0
- package/dist/templates/banner/version.js.map +1 -0
- package/dist/templates/card/index.d.ts +4 -1
- package/dist/templates/card/index.d.ts.map +1 -1
- package/dist/templates/card/index.js +37 -25
- package/dist/templates/card/index.js.map +1 -1
- package/dist/templates/card/lines.d.ts +17 -13
- package/dist/templates/card/lines.d.ts.map +1 -1
- package/dist/templates/card/lines.js +24 -20
- package/dist/templates/card/lines.js.map +1 -1
- package/dist/templates/code/chrome.d.ts +7 -3
- package/dist/templates/code/chrome.d.ts.map +1 -1
- package/dist/templates/code/chrome.js +12 -11
- package/dist/templates/code/chrome.js.map +1 -1
- package/dist/templates/code/clip.d.ts +1 -1
- package/dist/templates/code/clip.js +1 -1
- package/dist/templates/code/fit.d.ts +2 -2
- package/dist/templates/code/fit.d.ts.map +1 -1
- package/dist/templates/code/fit.js +4 -4
- package/dist/templates/code/fit.js.map +1 -1
- package/dist/templates/code/index.d.ts.map +1 -1
- package/dist/templates/code/index.js +7 -6
- package/dist/templates/code/index.js.map +1 -1
- package/dist/templates/code/layout.d.ts +1 -1
- package/dist/templates/code/layout.d.ts.map +1 -1
- package/dist/templates/code/layout.js +6 -6
- package/dist/templates/code/layout.js.map +1 -1
- package/dist/templates/code/panel.d.ts +13 -0
- package/dist/templates/code/panel.d.ts.map +1 -1
- package/dist/templates/code/panel.js +34 -2
- package/dist/templates/code/panel.js.map +1 -1
- package/dist/templates/code/plate.d.ts +3 -1
- package/dist/templates/code/plate.d.ts.map +1 -1
- package/dist/templates/code/plate.js +11 -9
- package/dist/templates/code/plate.js.map +1 -1
- package/dist/templates/code/spans.js +1 -1
- package/dist/templates/code/spans.js.map +1 -1
- package/dist/templates/code/width.d.ts +10 -0
- package/dist/templates/code/width.d.ts.map +1 -0
- package/dist/templates/code/width.js +26 -0
- package/dist/templates/code/width.js.map +1 -0
- package/dist/templates/footer.d.ts +8 -0
- package/dist/templates/footer.d.ts.map +1 -1
- package/dist/templates/footer.js +11 -1
- package/dist/templates/footer.js.map +1 -1
- package/dist/templates/index.d.ts +1 -1
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +1 -1
- package/dist/templates/index.js.map +1 -1
- package/dist/templates/logo.d.ts +15 -0
- package/dist/templates/logo.d.ts.map +1 -0
- package/dist/templates/logo.js +30 -0
- package/dist/templates/logo.js.map +1 -0
- package/dist/templates/measure.d.ts +11 -0
- package/dist/templates/measure.d.ts.map +1 -0
- package/dist/templates/measure.js +11 -0
- package/dist/templates/measure.js.map +1 -0
- package/dist/templates/props.d.ts +2 -2
- package/dist/templates/props.js +2 -2
- package/dist/templates/text.d.ts +37 -0
- package/dist/templates/text.d.ts.map +1 -0
- package/dist/templates/text.js +26 -0
- package/dist/templates/text.js.map +1 -0
- package/dist/text/break.d.ts +11 -0
- package/dist/text/break.d.ts.map +1 -0
- package/dist/text/break.js +30 -0
- package/dist/text/break.js.map +1 -0
- package/dist/text/fit.d.ts +30 -0
- package/dist/text/fit.d.ts.map +1 -0
- package/dist/text/fit.js +29 -0
- package/dist/text/fit.js.map +1 -0
- package/dist/text/index.d.ts +5 -3
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.js +3 -2
- package/dist/text/index.js.map +1 -1
- package/dist/text/wrap.d.ts +17 -7
- package/dist/text/wrap.d.ts.map +1 -1
- package/dist/text/wrap.js +25 -17
- package/dist/text/wrap.js.map +1 -1
- package/dist/texture/grain.d.ts +17 -0
- package/dist/texture/grain.d.ts.map +1 -0
- package/dist/texture/grain.js +29 -0
- package/dist/texture/grain.js.map +1 -0
- package/dist/texture/index.d.ts +11 -0
- package/dist/texture/index.d.ts.map +1 -0
- package/dist/texture/index.js +20 -0
- package/dist/texture/index.js.map +1 -0
- package/dist/texture/pattern.d.ts +17 -0
- package/dist/texture/pattern.d.ts.map +1 -0
- package/dist/texture/pattern.js +45 -0
- package/dist/texture/pattern.js.map +1 -0
- package/dist/texture/resolve.d.ts +16 -0
- package/dist/texture/resolve.d.ts.map +1 -0
- package/dist/texture/resolve.js +20 -0
- package/dist/texture/resolve.js.map +1 -0
- package/dist/theme/index.d.ts +27 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +41 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/presets.d.ts +38 -0
- package/dist/theme/presets.d.ts.map +1 -0
- package/dist/theme/presets.js +150 -0
- package/dist/theme/presets.js.map +1 -0
- package/dist/types.d.ts +281 -46
- package/dist/types.d.ts.map +1 -1
- package/dist/validate/background.d.ts +12 -0
- package/dist/validate/background.d.ts.map +1 -0
- package/dist/validate/background.js +53 -0
- package/dist/validate/background.js.map +1 -0
- package/dist/validate/collect.d.ts +9 -0
- package/dist/validate/collect.d.ts.map +1 -0
- package/dist/validate/collect.js +34 -0
- package/dist/validate/collect.js.map +1 -0
- package/dist/validate/index.d.ts +1 -1
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +3 -20
- package/dist/validate/index.js.map +1 -1
- package/dist/validate/keys.d.ts +35 -2
- package/dist/validate/keys.d.ts.map +1 -1
- package/dist/validate/keys.js +92 -3
- package/dist/validate/keys.js.map +1 -1
- package/dist/validate/overrides.d.ts.map +1 -1
- package/dist/validate/overrides.js +5 -1
- package/dist/validate/overrides.js.map +1 -1
- package/dist/validate/suggest.d.ts.map +1 -1
- package/dist/validate/suggest.js +21 -3
- package/dist/validate/suggest.js.map +1 -1
- package/dist/validate/texture.d.ts +11 -0
- package/dist/validate/texture.d.ts.map +1 -0
- package/dist/validate/texture.js +34 -0
- package/dist/validate/texture.js.map +1 -0
- package/dist/validate/values.d.ts +10 -10
- package/dist/validate/values.d.ts.map +1 -1
- package/dist/validate/values.js +21 -31
- package/dist/validate/values.js.map +1 -1
- package/package.json +7 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { MeasureText } from "../types.js";
|
|
2
|
+
/** One group of a template's text: the space it has and how it is drawn. */
|
|
3
|
+
export interface TextBlock {
|
|
4
|
+
readonly maxWidth: number;
|
|
5
|
+
readonly maxLines: number;
|
|
6
|
+
readonly fontSize: number;
|
|
7
|
+
/**
|
|
8
|
+
* Fraction of `fontSize` this group may shrink to before it is cut instead.
|
|
9
|
+
* The title of a layout has the furthest to fall, because it is the line
|
|
10
|
+
* worth keeping whole; a subtitle that has shrunk much has stopped being
|
|
11
|
+
* readable in a feed, so it may as well lose its tail.
|
|
12
|
+
*/
|
|
13
|
+
readonly floor: number;
|
|
14
|
+
readonly fontWeight: number;
|
|
15
|
+
}
|
|
16
|
+
/** A block along with how the lines it produces are drawn. */
|
|
17
|
+
export interface StyledBlock extends TextBlock {
|
|
18
|
+
readonly opacity: number;
|
|
19
|
+
/** Space inserted before the group's first line, to separate it from the last. */
|
|
20
|
+
readonly gapBefore?: number;
|
|
21
|
+
}
|
|
22
|
+
/** One line of a template's text block, ready to be stacked and drawn. */
|
|
23
|
+
export interface TextLine {
|
|
24
|
+
readonly text: string;
|
|
25
|
+
readonly fontSize: number;
|
|
26
|
+
readonly fontWeight: number;
|
|
27
|
+
readonly opacity: number;
|
|
28
|
+
readonly gapBefore?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Fit one group of a template's text, from a prop that may not be there, and
|
|
32
|
+
* return its lines. Each group is fitted on its own, so a long title shrinking
|
|
33
|
+
* does not drag the subtitle down with it. A group whose prop is absent or
|
|
34
|
+
* empty produces no lines at all.
|
|
35
|
+
*/
|
|
36
|
+
export declare function blockLines(value: unknown, measure: MeasureText, fontFamily: string, block: StyledBlock): TextLine[];
|
|
37
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/templates/text.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,4EAA4E;AAC5E,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,8DAA8D;AAC9D,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,kFAAkF;IAClF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,0EAA0E;AAC1E,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,WAAW,GACjB,QAAQ,EAAE,CAoBZ"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { fitText } from "../text/index.js";
|
|
2
|
+
import { measureIn } from "./measure.js";
|
|
3
|
+
import { optionalString } from "./props.js";
|
|
4
|
+
/**
|
|
5
|
+
* Fit one group of a template's text, from a prop that may not be there, and
|
|
6
|
+
* return its lines. Each group is fitted on its own, so a long title shrinking
|
|
7
|
+
* does not drag the subtitle down with it. A group whose prop is absent or
|
|
8
|
+
* empty produces no lines at all.
|
|
9
|
+
*/
|
|
10
|
+
export function blockLines(value, measure, fontFamily, block) {
|
|
11
|
+
const fitted = fitText(optionalString(value) ?? "", measureIn(measure, fontFamily, block.fontWeight), {
|
|
12
|
+
maxWidth: block.maxWidth,
|
|
13
|
+
maxLines: block.maxLines,
|
|
14
|
+
fontSize: block.fontSize,
|
|
15
|
+
minFontSize: Math.round(block.fontSize * block.floor),
|
|
16
|
+
});
|
|
17
|
+
return fitted.lines.map((text, index) => ({
|
|
18
|
+
text,
|
|
19
|
+
fontSize: fitted.fontSize,
|
|
20
|
+
fontWeight: block.fontWeight,
|
|
21
|
+
opacity: block.opacity,
|
|
22
|
+
...(index === 0 &&
|
|
23
|
+
block.gapBefore !== undefined && { gapBefore: block.gapBefore }),
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/templates/text.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAiC5C;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,KAAc,EACd,OAAoB,EACpB,UAAkB,EAClB,KAAkB;IAElB,MAAM,MAAM,GAAe,OAAO,CAChC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,EAC3B,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,EAChD;QACE,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC;KACtD,CACF,CAAC;IAEF,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACxC,IAAI;QACJ,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,GAAG,CAAC,KAAK,KAAK,CAAC;YACb,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;KACnE,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MeasureLine } from "./wrap.js";
|
|
2
|
+
/**
|
|
3
|
+
* Break one word across as many lines as it takes, for a word that is wider
|
|
4
|
+
* than the line it has to fit on. A URL, a compound German noun, or a whole
|
|
5
|
+
* Japanese sentence, which has no spaces to break at in the first place.
|
|
6
|
+
*
|
|
7
|
+
* Always returns at least one piece, even where a single character is wider
|
|
8
|
+
* than the line: overflowing by one glyph beats looping forever.
|
|
9
|
+
*/
|
|
10
|
+
export declare function breakWord(word: string, maxWidth: number, measure: MeasureLine): string[];
|
|
11
|
+
//# sourceMappingURL=break.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"break.d.ts","sourceRoot":"","sources":["../../src/text/break.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAS7C;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,WAAW,GACnB,MAAM,EAAE,CAgBV"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grapheme segmentation, so a break never lands inside an emoji or between a
|
|
3
|
+
* letter and the accent that belongs to it. Built once, since a build breaks
|
|
4
|
+
* a great many words and the segmenter carries locale data with it.
|
|
5
|
+
*/
|
|
6
|
+
const graphemes = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
7
|
+
/**
|
|
8
|
+
* Break one word across as many lines as it takes, for a word that is wider
|
|
9
|
+
* than the line it has to fit on. A URL, a compound German noun, or a whole
|
|
10
|
+
* Japanese sentence, which has no spaces to break at in the first place.
|
|
11
|
+
*
|
|
12
|
+
* Always returns at least one piece, even where a single character is wider
|
|
13
|
+
* than the line: overflowing by one glyph beats looping forever.
|
|
14
|
+
*/
|
|
15
|
+
export function breakWord(word, maxWidth, measure) {
|
|
16
|
+
const pieces = [];
|
|
17
|
+
let current = "";
|
|
18
|
+
for (const { segment } of graphemes.segment(word)) {
|
|
19
|
+
const next = current + segment;
|
|
20
|
+
if (current !== "" && measure(next) > maxWidth) {
|
|
21
|
+
pieces.push(current);
|
|
22
|
+
current = segment;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
current = next;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return current === "" ? [word] : [...pieces, current];
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=break.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"break.js","sourceRoot":"","sources":["../../src/text/break.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CACvB,IAAY,EACZ,QAAgB,EAChB,OAAoB;IAEpB,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,KAAK,MAAM,EAAE,OAAO,EAAE,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC;QAE/B,IAAI,OAAO,KAAK,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC;YAC/C,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACrB,OAAO,GAAG,OAAO,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;IAED,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** The width a run of text would be drawn at, at a given font size. */
|
|
2
|
+
export type MeasureAt = (text: string, fontSize: number) => number;
|
|
3
|
+
/** The space a block of text has, and the sizes it may be drawn at. */
|
|
4
|
+
export interface FitOptions {
|
|
5
|
+
readonly maxWidth: number;
|
|
6
|
+
readonly maxLines: number;
|
|
7
|
+
/** The size to draw at when the text fits at it. */
|
|
8
|
+
readonly fontSize: number;
|
|
9
|
+
/** The size below which shrinking costs more legibility than it is worth. */
|
|
10
|
+
readonly minFontSize: number;
|
|
11
|
+
}
|
|
12
|
+
/** A block of text with the size it turned out to fit at. */
|
|
13
|
+
export interface FittedText {
|
|
14
|
+
readonly lines: readonly string[];
|
|
15
|
+
readonly fontSize: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Wrap text into the space it has, shrinking it until it fits.
|
|
19
|
+
*
|
|
20
|
+
* The alternative, and what Colophon did before it could measure anything, is
|
|
21
|
+
* to wrap at one size and drop whatever is left over. That reads as a mistake
|
|
22
|
+
* rather than a design: a long title loses its last few words, and the image
|
|
23
|
+
* says something the post does not. Shrinking keeps the words.
|
|
24
|
+
*
|
|
25
|
+
* It only shrinks so far, because a title small enough to fit anything is a
|
|
26
|
+
* title nobody reads in a feed. Text that still does not fit at the floor is
|
|
27
|
+
* cut to `maxLines` as before.
|
|
28
|
+
*/
|
|
29
|
+
export declare function fitText(text: string, measure: MeasureAt, options: FitOptions): FittedText;
|
|
30
|
+
//# sourceMappingURL=fit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fit.d.ts","sourceRoot":"","sources":["../../src/text/fit.ts"],"names":[],"mappings":"AAEA,uEAAuE;AACvE,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;AAEnE,uEAAuE;AACvE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,6EAA6E;IAC7E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,6DAA6D;AAC7D,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAKD;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,UAAU,GAClB,UAAU,CAiBZ"}
|
package/dist/text/fit.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { wrapText } from "./wrap.js";
|
|
2
|
+
/** How much of the size is given up each time the text does not fit. */
|
|
3
|
+
const shrinkStep = 0.94;
|
|
4
|
+
/**
|
|
5
|
+
* Wrap text into the space it has, shrinking it until it fits.
|
|
6
|
+
*
|
|
7
|
+
* The alternative, and what Colophon did before it could measure anything, is
|
|
8
|
+
* to wrap at one size and drop whatever is left over. That reads as a mistake
|
|
9
|
+
* rather than a design: a long title loses its last few words, and the image
|
|
10
|
+
* says something the post does not. Shrinking keeps the words.
|
|
11
|
+
*
|
|
12
|
+
* It only shrinks so far, because a title small enough to fit anything is a
|
|
13
|
+
* title nobody reads in a feed. Text that still does not fit at the floor is
|
|
14
|
+
* cut to `maxLines` as before.
|
|
15
|
+
*/
|
|
16
|
+
export function fitText(text, measure, options) {
|
|
17
|
+
const { maxWidth, maxLines, minFontSize } = options;
|
|
18
|
+
let fontSize = options.fontSize;
|
|
19
|
+
let lines = wrapText(text, maxWidth, (line) => measure(line, fontSize));
|
|
20
|
+
while (lines.length > maxLines && fontSize > minFontSize) {
|
|
21
|
+
// Both terms are here to guarantee progress: the proportional step is what
|
|
22
|
+
// makes the search short, and the whole pixel is what stops it stalling
|
|
23
|
+
// once the sizes are small enough for rounding to swallow the step.
|
|
24
|
+
fontSize = Math.max(minFontSize, Math.min(fontSize - 1, Math.floor(fontSize * shrinkStep)));
|
|
25
|
+
lines = wrapText(text, maxWidth, (line) => measure(line, fontSize));
|
|
26
|
+
}
|
|
27
|
+
return { lines: lines.slice(0, maxLines), fontSize };
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=fit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fit.js","sourceRoot":"","sources":["../../src/text/fit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAqBrC,wEAAwE;AACxE,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,OAAO,CACrB,IAAY,EACZ,OAAkB,EAClB,OAAmB;IAEnB,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IACpD,IAAI,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAChC,IAAI,KAAK,GAAG,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;IAExE,OAAO,KAAK,CAAC,MAAM,GAAG,QAAQ,IAAI,QAAQ,GAAG,WAAW,EAAE,CAAC;QACzD,2EAA2E;QAC3E,wEAAwE;QACxE,oEAAoE;QACpE,QAAQ,GAAG,IAAI,CAAC,GAAG,CACjB,WAAW,EACX,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC,CAAC,CAC1D,CAAC;QACF,KAAK,GAAG,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;AACvD,CAAC"}
|
package/dist/text/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export { escapeXml } from "./escape.js";
|
|
2
2
|
export { textElement } from "./element.js";
|
|
3
3
|
export type { TextAttributes } from "./element.js";
|
|
4
|
-
export {
|
|
5
|
-
export
|
|
6
|
-
export {
|
|
4
|
+
export { breakWord } from "./break.js";
|
|
5
|
+
export { fitText } from "./fit.js";
|
|
6
|
+
export type { FitOptions, FittedText, MeasureAt } from "./fit.js";
|
|
7
|
+
export { wrapText } from "./wrap.js";
|
|
8
|
+
export type { MeasureLine } from "./wrap.js";
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/text/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/text/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { escapeXml } from "./escape.js";
|
|
2
2
|
export { textElement } from "./element.js";
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { breakWord } from "./break.js";
|
|
4
|
+
export { fitText } from "./fit.js";
|
|
5
|
+
export { wrapText } from "./wrap.js";
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/dist/text/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/text/wrap.d.ts
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* The width a run of text will be drawn at, in the same units as the space it
|
|
3
|
+
* has to fit. Bound to a font and a size by whoever is doing the wrapping.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type MeasureLine = (text: string) => number;
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Greedy word-wrap to a width rather than to a character count.
|
|
8
|
+
*
|
|
9
|
+
* Wrapping by characters means assuming every glyph is the same fraction of
|
|
10
|
+
* the font size, which is wrong by a little for Latin text and wrong by half
|
|
11
|
+
* for anything wider. Measuring the words is what puts the break where it
|
|
12
|
+
* belongs.
|
|
13
|
+
*
|
|
14
|
+
* A single word too wide for the line is broken, since the alternative is a
|
|
15
|
+
* line that runs off the image. Text written without spaces, which is most of
|
|
16
|
+
* how Japanese and Chinese are set, is one long word by this reckoning and so
|
|
17
|
+
* breaks at whatever character reaches the edge. That is a plain wrap rather
|
|
18
|
+
* than a correct one: it does not know that a line should not begin with
|
|
19
|
+
* closing punctuation.
|
|
10
20
|
*/
|
|
11
|
-
export declare function
|
|
21
|
+
export declare function wrapText(text: string, maxWidth: number, measure: MeasureLine): string[];
|
|
12
22
|
//# sourceMappingURL=wrap.d.ts.map
|
package/dist/text/wrap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../../src/text/wrap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../../src/text/wrap.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAEnD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,WAAW,GACnB,MAAM,EAAE,CA6BV"}
|
package/dist/text/wrap.js
CHANGED
|
@@ -1,33 +1,41 @@
|
|
|
1
|
+
import { breakWord } from "./break.js";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
3
|
+
* Greedy word-wrap to a width rather than to a character count.
|
|
4
|
+
*
|
|
5
|
+
* Wrapping by characters means assuming every glyph is the same fraction of
|
|
6
|
+
* the font size, which is wrong by a little for Latin text and wrong by half
|
|
7
|
+
* for anything wider. Measuring the words is what puts the break where it
|
|
8
|
+
* belongs.
|
|
9
|
+
*
|
|
10
|
+
* A single word too wide for the line is broken, since the alternative is a
|
|
11
|
+
* line that runs off the image. Text written without spaces, which is most of
|
|
12
|
+
* how Japanese and Chinese are set, is one long word by this reckoning and so
|
|
13
|
+
* breaks at whatever character reaches the edge. That is a plain wrap rather
|
|
14
|
+
* than a correct one: it does not know that a line should not begin with
|
|
15
|
+
* closing punctuation.
|
|
4
16
|
*/
|
|
5
|
-
export function wrapText(text,
|
|
6
|
-
const limit = Math.max(1, Math.floor(charactersPerLine));
|
|
17
|
+
export function wrapText(text, maxWidth, measure) {
|
|
7
18
|
const words = text.split(/\s+/).filter((word) => word !== "");
|
|
8
19
|
const lines = [];
|
|
9
20
|
let currentLine = "";
|
|
10
21
|
for (const word of words) {
|
|
11
22
|
const nextLine = currentLine === "" ? word : `${currentLine} ${word}`;
|
|
12
|
-
if (nextLine
|
|
13
|
-
lines.push(currentLine);
|
|
14
|
-
currentLine = word;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
23
|
+
if (measure(nextLine) <= maxWidth) {
|
|
17
24
|
currentLine = nextLine;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (currentLine !== "") {
|
|
28
|
+
lines.push(currentLine);
|
|
18
29
|
}
|
|
30
|
+
// The word starts a line of its own, and is only broken up if it cannot
|
|
31
|
+
// fit on one even there.
|
|
32
|
+
const pieces = breakWord(word, maxWidth, measure);
|
|
33
|
+
lines.push(...pieces.slice(0, -1));
|
|
34
|
+
currentLine = pieces.at(-1) ?? "";
|
|
19
35
|
}
|
|
20
36
|
if (currentLine !== "") {
|
|
21
37
|
lines.push(currentLine);
|
|
22
38
|
}
|
|
23
39
|
return lines;
|
|
24
40
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Estimate how many characters of the given font size fit within `widthPx`.
|
|
27
|
-
* The `widthFactor` approximates average glyph width as a fraction of the font
|
|
28
|
-
* size (bolder/wider faces want a larger factor).
|
|
29
|
-
*/
|
|
30
|
-
export function estimateCharsPerLine(widthPx, fontSize, widthFactor = 0.58) {
|
|
31
|
-
return Math.max(1, Math.floor(widthPx / (fontSize * widthFactor)));
|
|
32
|
-
}
|
|
33
41
|
//# sourceMappingURL=wrap.js.map
|
package/dist/text/wrap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap.js","sourceRoot":"","sources":["../../src/text/wrap.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"wrap.js","sourceRoot":"","sources":["../../src/text/wrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAQvC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,QAAQ,CACtB,IAAY,EACZ,QAAgB,EAChB,OAAoB;IAEpB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,WAAW,GAAG,EAAE,CAAC;IAErB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,WAAW,IAAI,IAAI,EAAE,CAAC;QAEtE,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,EAAE,CAAC;YAClC,WAAW,GAAG,QAAQ,CAAC;YACvB,SAAS;QACX,CAAC;QAED,IAAI,WAAW,KAAK,EAAE,EAAE,CAAC;YACvB,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC1B,CAAC;QAED,wEAAwE;QACxE,yBAAyB;QACzB,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClD,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,WAAW,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACpC,CAAC;IAED,IAAI,WAAW,KAAK,EAAE,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1B,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Dimensions, Texture } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Film grain, from one turbulence filter.
|
|
4
|
+
*
|
|
5
|
+
* `scale` is roughly the size of a speck in pixels, which is what someone
|
|
6
|
+
* tuning this actually wants to think about; the filter wants the reciprocal
|
|
7
|
+
* of that, so the two are inverses of each other. Three octaves is enough to
|
|
8
|
+
* stop the noise looking regular and cheap enough not to notice.
|
|
9
|
+
*
|
|
10
|
+
* The noise is desaturated to grey, since coloured specks over a brand colour
|
|
11
|
+
* read as a rendering fault rather than as grain. Grey does lighten what is
|
|
12
|
+
* under it a little, which is why the default opacity is as low as it is.
|
|
13
|
+
*/
|
|
14
|
+
export declare function grainSvg(texture: Extract<Texture, {
|
|
15
|
+
readonly type: "grain";
|
|
16
|
+
}>, dimensions: Dimensions, id: string): string;
|
|
17
|
+
//# sourceMappingURL=grain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grain.d.ts","sourceRoot":"","sources":["../../src/texture/grain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAKvD;;;;;;;;;;;GAWG;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,CAgBR"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const defaultOpacity = 0.1;
|
|
2
|
+
const defaultScale = 1.4;
|
|
3
|
+
/**
|
|
4
|
+
* Film grain, from one turbulence filter.
|
|
5
|
+
*
|
|
6
|
+
* `scale` is roughly the size of a speck in pixels, which is what someone
|
|
7
|
+
* tuning this actually wants to think about; the filter wants the reciprocal
|
|
8
|
+
* of that, so the two are inverses of each other. Three octaves is enough to
|
|
9
|
+
* stop the noise looking regular and cheap enough not to notice.
|
|
10
|
+
*
|
|
11
|
+
* The noise is desaturated to grey, since coloured specks over a brand colour
|
|
12
|
+
* read as a rendering fault rather than as grain. Grey does lighten what is
|
|
13
|
+
* under it a little, which is why the default opacity is as low as it is.
|
|
14
|
+
*/
|
|
15
|
+
export function grainSvg(texture, dimensions, id) {
|
|
16
|
+
const { width, height } = dimensions;
|
|
17
|
+
const frequency = 1 / (texture.scale ?? defaultScale);
|
|
18
|
+
return (`<defs>` +
|
|
19
|
+
`<filter id="${id}" x="0" y="0" width="100%" height="100%">` +
|
|
20
|
+
`<feTurbulence type="fractalNoise" baseFrequency="${frequency.toFixed(3)}"` +
|
|
21
|
+
` numOctaves="3" stitchTiles="stitch"/>` +
|
|
22
|
+
`<feColorMatrix type="saturate" values="0"/>` +
|
|
23
|
+
`</filter>` +
|
|
24
|
+
`</defs>` +
|
|
25
|
+
`<rect width="${String(width)}" height="${String(height)}"` +
|
|
26
|
+
` filter="url(#${id})"` +
|
|
27
|
+
` opacity="${String(texture.opacity ?? defaultOpacity)}"/>`);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=grain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grain.js","sourceRoot":"","sources":["../../src/texture/grain.ts"],"names":[],"mappings":"AAEA,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ,CACtB,OAAqD,EACrD,UAAsB,EACtB,EAAU;IAEV,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IACrC,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,YAAY,CAAC,CAAC;IAEtD,OAAO,CACL,QAAQ;QACR,eAAe,EAAE,2CAA2C;QAC5D,oDAAoD,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;QAC3E,wCAAwC;QACxC,6CAA6C;QAC7C,WAAW;QACX,SAAS;QACT,gBAAgB,MAAM,CAAC,KAAK,CAAC,aAAa,MAAM,CAAC,MAAM,CAAC,GAAG;QAC3D,iBAAiB,EAAE,IAAI;QACvB,aAAa,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,cAAc,CAAC,KAAK,CAC5D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Dimensions, Texture } from "../types.js";
|
|
2
|
+
export { resolveTexture } from "./resolve.js";
|
|
3
|
+
/**
|
|
4
|
+
* Render the treatment laid over a background as SVG, naming whatever it needs
|
|
5
|
+
* in `<defs>` after the given `id`.
|
|
6
|
+
*
|
|
7
|
+
* It is drawn between the background and whatever a template draws, so a
|
|
8
|
+
* texture never comes between a headline and the reader.
|
|
9
|
+
*/
|
|
10
|
+
export declare function textureSvg(texture: Texture, dimensions: Dimensions, id: string): string;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;AAIvD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,MAAM,GACT,MAAM,CAUR"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { grainSvg } from "./grain.js";
|
|
2
|
+
import { dotsSvg, rulesSvg } from "./pattern.js";
|
|
3
|
+
export { resolveTexture } from "./resolve.js";
|
|
4
|
+
/**
|
|
5
|
+
* Render the treatment laid over a background as SVG, naming whatever it needs
|
|
6
|
+
* in `<defs>` after the given `id`.
|
|
7
|
+
*
|
|
8
|
+
* It is drawn between the background and whatever a template draws, so a
|
|
9
|
+
* texture never comes between a headline and the reader.
|
|
10
|
+
*/
|
|
11
|
+
export function textureSvg(texture, dimensions, id) {
|
|
12
|
+
if (texture.type === "grain") {
|
|
13
|
+
return grainSvg(texture, dimensions, id);
|
|
14
|
+
}
|
|
15
|
+
if (texture.type === "dots") {
|
|
16
|
+
return dotsSvg(texture, dimensions, id);
|
|
17
|
+
}
|
|
18
|
+
return rulesSvg(texture, dimensions, id);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,OAAgB,EAChB,UAAsB,EACtB,EAAU;IAEV,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC7B,OAAO,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC5B,OAAO,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Dimensions, Texture } from "../types.js";
|
|
2
|
+
/** A grid of dots, one to a tile. */
|
|
3
|
+
export declare function dotsSvg(texture: Extract<Texture, {
|
|
4
|
+
readonly type: "dots";
|
|
5
|
+
}>, dimensions: Dimensions, id: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Ruled lines, one to a tile, rotated as a set.
|
|
8
|
+
*
|
|
9
|
+
* The line runs down the middle of its tile rather than along the edge, so
|
|
10
|
+
* that the whole of its width is inside the tile: a stroke centred on the edge
|
|
11
|
+
* would have half of itself outside the tile, where the pattern does not
|
|
12
|
+
* repeat it, and the lines would come out half as thick as asked for.
|
|
13
|
+
*/
|
|
14
|
+
export declare function rulesSvg(texture: Extract<Texture, {
|
|
15
|
+
readonly type: "rules";
|
|
16
|
+
}>, dimensions: Dimensions, id: string): string;
|
|
17
|
+
//# sourceMappingURL=pattern.d.ts.map
|
|
@@ -0,0 +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;AAiCvD,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"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Used where the palette did not supply one, so a texture always draws. */
|
|
2
|
+
const fallbackColor = "#ffffff";
|
|
3
|
+
const dotDefaults = { opacity: 0.08, size: 5, gap: 44 };
|
|
4
|
+
const ruleDefaults = { opacity: 0.06, width: 2, gap: 28, angle: 45 };
|
|
5
|
+
/**
|
|
6
|
+
* A tiled pattern over the whole image: the `<pattern>` under the given `id`,
|
|
7
|
+
* and the rect that fills with it.
|
|
8
|
+
*/
|
|
9
|
+
function tile(id, gap, contents, transform, dimensions, opacity) {
|
|
10
|
+
const { width, height } = dimensions;
|
|
11
|
+
const size = String(gap);
|
|
12
|
+
return (`<defs>` +
|
|
13
|
+
`<pattern id="${id}" width="${size}" height="${size}"` +
|
|
14
|
+
` patternUnits="userSpaceOnUse"${transform}>${contents}</pattern>` +
|
|
15
|
+
`</defs>` +
|
|
16
|
+
`<rect width="${String(width)}" height="${String(height)}"` +
|
|
17
|
+
` fill="url(#${id})" opacity="${String(opacity)}"/>`);
|
|
18
|
+
}
|
|
19
|
+
/** A grid of dots, one to a tile. */
|
|
20
|
+
export function dotsSvg(texture, dimensions, id) {
|
|
21
|
+
const gap = texture.gap ?? dotDefaults.gap;
|
|
22
|
+
const centre = String(gap / 2);
|
|
23
|
+
const dot = `<circle cx="${centre}" cy="${centre}"` +
|
|
24
|
+
` r="${String((texture.size ?? dotDefaults.size) / 2)}"` +
|
|
25
|
+
` fill="${texture.color ?? fallbackColor}"/>`;
|
|
26
|
+
return tile(id, gap, dot, "", dimensions, texture.opacity ?? dotDefaults.opacity);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Ruled lines, one to a tile, rotated as a set.
|
|
30
|
+
*
|
|
31
|
+
* The line runs down the middle of its tile rather than along the edge, so
|
|
32
|
+
* that the whole of its width is inside the tile: a stroke centred on the edge
|
|
33
|
+
* would have half of itself outside the tile, where the pattern does not
|
|
34
|
+
* repeat it, and the lines would come out half as thick as asked for.
|
|
35
|
+
*/
|
|
36
|
+
export function rulesSvg(texture, dimensions, id) {
|
|
37
|
+
const gap = texture.gap ?? ruleDefaults.gap;
|
|
38
|
+
const x = String(gap / 2);
|
|
39
|
+
const line = `<line x1="${x}" y1="0" x2="${x}" y2="${String(gap)}"` +
|
|
40
|
+
` stroke="${texture.color ?? fallbackColor}"` +
|
|
41
|
+
` stroke-width="${String(texture.width ?? ruleDefaults.width)}"/>`;
|
|
42
|
+
const angle = texture.angle ?? ruleDefaults.angle;
|
|
43
|
+
return tile(id, gap, line, ` patternTransform="rotate(${String(angle)})"`, dimensions, texture.opacity ?? ruleDefaults.opacity);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=pattern.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern.js","sourceRoot":"","sources":["../../src/texture/pattern.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,MAAM,aAAa,GAAG,SAAS,CAAC;AAEhC,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;IAEV,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC;IAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC/B,MAAM,GAAG,GACP,eAAe,MAAM,SAAS,MAAM,GAAG;QACvC,OAAO,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG;QACxD,UAAU,OAAO,CAAC,KAAK,IAAI,aAAa,KAAK,CAAC;IAEhD,OAAO,IAAI,CACT,EAAE,EACF,GAAG,EACH,GAAG,EACH,EAAE,EACF,UAAU,EACV,OAAO,CAAC,OAAO,IAAI,WAAW,CAAC,OAAO,CACvC,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CACtB,OAAqD,EACrD,UAAsB,EACtB,EAAU;IAEV,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC;IAC5C,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAC1B,MAAM,IAAI,GACR,aAAa,CAAC,gBAAgB,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG;QACtD,YAAY,OAAO,CAAC,KAAK,IAAI,aAAa,GAAG;QAC7C,kBAAkB,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC;IACrE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,YAAY,CAAC,KAAK,CAAC;IAElD,OAAO,IAAI,CACT,EAAE,EACF,GAAG,EACH,IAAI,EACJ,6BAA6B,MAAM,CAAC,KAAK,CAAC,IAAI,EAC9C,UAAU,EACV,OAAO,CAAC,OAAO,IAAI,YAAY,CAAC,OAAO,CACxC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BrandColors, Texture } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Fill in the colour a texture left open, from the palette it will be drawn
|
|
4
|
+
* over.
|
|
5
|
+
*
|
|
6
|
+
* A dot grid or a set of rules has to be the foreground colour by default,
|
|
7
|
+
* because that is the one colour known to contrast with the background: a
|
|
8
|
+
* fixed white would disappear on a light theme, which is a texture that
|
|
9
|
+
* silently does nothing. Grain has no colour to fill in, being noise.
|
|
10
|
+
*
|
|
11
|
+
* It happens here rather than while drawing so that the resolved config says
|
|
12
|
+
* what will actually be drawn, which is also what the rebuild stamp hashes: a
|
|
13
|
+
* palette change then re-renders the texture that follows it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveTexture(texture: Texture | undefined, colors: Required<BrandColors>): Texture | undefined;
|
|
16
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +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;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAC5B,OAAO,GAAG,SAAS,CAMrB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fill in the colour a texture left open, from the palette it will be drawn
|
|
3
|
+
* over.
|
|
4
|
+
*
|
|
5
|
+
* A dot grid or a set of rules has to be the foreground colour by default,
|
|
6
|
+
* because that is the one colour known to contrast with the background: a
|
|
7
|
+
* fixed white would disappear on a light theme, which is a texture that
|
|
8
|
+
* silently does nothing. Grain has no colour to fill in, being noise.
|
|
9
|
+
*
|
|
10
|
+
* It happens here rather than while drawing so that the resolved config says
|
|
11
|
+
* what will actually be drawn, which is also what the rebuild stamp hashes: a
|
|
12
|
+
* palette change then re-renders the texture that follows it.
|
|
13
|
+
*/
|
|
14
|
+
export function resolveTexture(texture, colors) {
|
|
15
|
+
if (texture === undefined || texture.type === "grain") {
|
|
16
|
+
return texture;
|
|
17
|
+
}
|
|
18
|
+
return { color: colors.foreground, ...texture };
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/texture/resolve.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;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"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BrandColors, ColophonConfig, ThemeName } from "../types.js";
|
|
2
|
+
export { themeNames } from "./presets.js";
|
|
3
|
+
/**
|
|
4
|
+
* The palette a theme brings, or `undefined` where there is no theme.
|
|
5
|
+
*
|
|
6
|
+
* It is what a partial override merges over, so that a size asking for one
|
|
7
|
+
* darker shade keeps the rest of the look rather than dropping back to the
|
|
8
|
+
* neutral default palette.
|
|
9
|
+
*/
|
|
10
|
+
export declare function themePalette(theme: ThemeName | undefined): Required<BrandColors> | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Fill in the fields a theme supplies and the config did not name.
|
|
13
|
+
*
|
|
14
|
+
* A theme is applied by merging rather than by resolving, so that everything
|
|
15
|
+
* downstream sees an ordinary config and nothing else in the package has to
|
|
16
|
+
* know that themes exist. Whatever the config sets wins, field by field: this
|
|
17
|
+
* is `colors`, `background` and `texture` as defaults, not as a look that
|
|
18
|
+
* cannot be argued with.
|
|
19
|
+
*
|
|
20
|
+
* The consequence worth knowing is that a config naming its own `colors`
|
|
21
|
+
* alongside a theme keeps the theme's background as it was written, so the
|
|
22
|
+
* accent colour changes and the picture behind it does not. That follows from
|
|
23
|
+
* the merge, and it is the honest reading of a theme: the background is part
|
|
24
|
+
* of the look rather than something derived from the palette.
|
|
25
|
+
*/
|
|
26
|
+
export declare function applyTheme(config: ColophonConfig): ColophonConfig;
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG1E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,GAAG,SAAS,GAC3B,QAAQ,CAAC,WAAW,CAAC,GAAG,SAAS,CAEnC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAcjE"}
|