@kensio/colophon 2.11.1 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- 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 +24 -0
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +29 -0
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +2 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/size.d.ts.map +1 -1
- package/dist/config/size.js +3 -0
- package/dist/config/size.js.map +1 -1
- package/dist/layout/fill.d.ts +32 -0
- package/dist/layout/fill.d.ts.map +1 -0
- package/dist/layout/fill.js +34 -0
- package/dist/layout/fill.js.map +1 -0
- package/dist/layout/index.d.ts +4 -2
- package/dist/layout/index.d.ts.map +1 -1
- package/dist/layout/index.js +2 -1
- package/dist/layout/index.js.map +1 -1
- package/dist/measure/faces.d.ts.map +1 -1
- package/dist/measure/faces.js.map +1 -1
- package/dist/render/svg.js +1 -1
- package/dist/render/svg.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/index.d.ts +1 -0
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +3 -0
- package/dist/templates/index.js.map +1 -1
- package/dist/templates/terminal/index.js +4 -4
- package/dist/templates/terminal/index.js.map +1 -1
- package/dist/templates/thumbnail/index.d.ts +21 -0
- package/dist/templates/thumbnail/index.d.ts.map +1 -0
- package/dist/templates/thumbnail/index.js +68 -0
- package/dist/templates/thumbnail/index.js.map +1 -0
- package/dist/templates/thumbnail/lines.d.ts +38 -0
- package/dist/templates/thumbnail/lines.d.ts.map +1 -0
- package/dist/templates/thumbnail/lines.js +76 -0
- package/dist/templates/thumbnail/lines.js.map +1 -0
- 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/text/fill.d.ts +34 -0
- package/dist/text/fill.d.ts.map +1 -0
- package/dist/text/fill.js +57 -0
- package/dist/text/fill.js.map +1 -0
- package/dist/text/fit.d.ts.map +1 -1
- package/dist/text/fit.js +2 -6
- package/dist/text/fit.js.map +1 -1
- package/dist/text/index.d.ts +2 -0
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.js +1 -0
- package/dist/text/index.js.map +1 -1
- package/dist/text/step.d.ts +13 -0
- package/dist/text/step.d.ts.map +1 -0
- package/dist/text/step.js +17 -0
- package/dist/text/step.js.map +1 -0
- package/dist/text/unbroken.d.ts +22 -0
- package/dist/text/unbroken.d.ts.map +1 -0
- package/dist/text/unbroken.js +29 -0
- package/dist/text/unbroken.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 +15 -4
- package/dist/texture/index.d.ts.map +1 -1
- package/dist/texture/index.js +64 -14
- 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/resolve.d.ts +10 -0
- package/dist/texture/resolve.d.ts.map +1 -1
- package/dist/texture/resolve.js +15 -0
- package/dist/texture/resolve.js.map +1 -1
- 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 +259 -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 +132 -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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"footer.js","sourceRoot":"","sources":["../../src/templates/footer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"footer.js","sourceRoot":"","sources":["../../src/templates/footer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAG9D,8DAA8D;AAC9D,MAAM,WAAW,GAAG,KAAK,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,UAAsB;IACnD,OAAO,IAAI,CAAC,KAAK,CACf,IAAI,CAAC,GAAG,CACN,UAAU,CAAC,MAAM,GAAG,WAAW,EAC/B,UAAU,CAAC,KAAK,GAAG,gBAAgB,CACpC,CACF,CAAC;AACJ,CAAC;AAeD;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAc,EACd,GAAW,EACX,QAAgB;IAEhB,OAAO,WAAW,CAAC,MAAM,GAAG,GAAG,GAAG,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACxD,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,SAAS,CAAC,MAAsB;IAC9C,OAAO,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,EAAE,CAAC;AAC7D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAsB,EACtB,SAA0B;IAE1B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE;QACtC,CAAC,EAAE,SAAS,CAAC,CAAC;QACd,CAAC,EAAE,SAAS,CAAC,CAAC;QACd,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,UAAU,EAAE,GAAG;QACf,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU;QAC9B,WAAW,EAAE,SAAS,CAAC,OAAO;QAC9B,GAAG,CAAC,SAAS,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC;KACpE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../src/templates/frame.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../src/templates/frame.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQ1E;;;;;;;;GAQG;AACH,MAAM,WAAW,KAAK;IACpB,yCAAyC;IACzC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,uDAAuD;AACvD,MAAM,WAAW,YAAY;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,UAAU,GAAG,SAAS,EAC9B,OAAO,GAAE,YAAiB,GACzB,KAAK,CAcP;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAExE;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,SAAI,GAAG,IAAI,CAOvD;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1D"}
|
package/dist/templates/frame.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { footerBaseline, hasFooter } from "./footer.js";
|
|
1
|
+
import { footerBaseline, footerFontSize, hasFooter } from "./footer.js";
|
|
2
2
|
import { inset } from "../layout/index.js";
|
|
3
3
|
/** Margin from the image edge, as a fraction of its width. */
|
|
4
4
|
const defaultPadScale = 0.075;
|
|
5
|
-
/** The footer's size, as a fraction of the image's height. */
|
|
6
|
-
const footerScale = 0.032;
|
|
7
5
|
/** Clear space between the content and the footer line, as a fraction of it. */
|
|
8
6
|
const footerGap = 0.02;
|
|
9
7
|
/**
|
|
@@ -14,14 +12,14 @@ const footerGap = 0.02;
|
|
|
14
12
|
export function imageFrame(dimensions, config, avatar, options = {}) {
|
|
15
13
|
const { width, height } = dimensions;
|
|
16
14
|
const pad = Math.round(width * (options.padScale ?? defaultPadScale));
|
|
17
|
-
const
|
|
15
|
+
const fontSize = footerFontSize(dimensions);
|
|
18
16
|
const isDrawn = options.footer === true || hasFooter(config) || avatar !== undefined;
|
|
19
17
|
return {
|
|
20
18
|
pad,
|
|
21
|
-
footerFontSize,
|
|
19
|
+
footerFontSize: fontSize,
|
|
22
20
|
full: { x: 0, y: 0, width, height },
|
|
23
|
-
footerRoom: isDrawn ?
|
|
24
|
-
footerY: footerBaseline(height, pad,
|
|
21
|
+
footerRoom: isDrawn ? fontSize + Math.round(height * footerGap) : 0,
|
|
22
|
+
footerY: footerBaseline(height, pad, fontSize),
|
|
25
23
|
};
|
|
26
24
|
}
|
|
27
25
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/templates/frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/templates/frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAI3C,8DAA8D;AAC9D,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B,gFAAgF;AAChF,MAAM,SAAS,G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,CAAC,GAAG;QAChB,IAAI,EAAE,KAAK,CAAC,GAAG;QACf,MAAM,EAAE,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,UAAU;KACrC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,GAAW;IAChD,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAC9B,CAAC"}
|
|
@@ -15,6 +15,7 @@ export { quoteTemplate } from "./quote/index.js";
|
|
|
15
15
|
export { releaseTemplate } from "./release/index.js";
|
|
16
16
|
export { statTemplate } from "./stat/index.js";
|
|
17
17
|
export { terminalTemplate } from "./terminal/index.js";
|
|
18
|
+
export { thumbnailTemplate } from "./thumbnail/index.js";
|
|
18
19
|
export { wordmarkTemplate } from "./wordmark/index.js";
|
|
19
20
|
export { optionalString } from "../props.js";
|
|
20
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAe5C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAc/D,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/templates/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import { quoteTemplate } from "./quote/index.js";
|
|
|
9
9
|
import { releaseTemplate } from "./release/index.js";
|
|
10
10
|
import { statTemplate } from "./stat/index.js";
|
|
11
11
|
import { terminalTemplate } from "./terminal/index.js";
|
|
12
|
+
import { thumbnailTemplate } from "./thumbnail/index.js";
|
|
12
13
|
import { wordmarkTemplate } from "./wordmark/index.js";
|
|
13
14
|
/**
|
|
14
15
|
* Templates registered out of the box. Projects can add to or override these
|
|
@@ -26,6 +27,7 @@ export const builtinTemplates = {
|
|
|
26
27
|
[releaseTemplate.name]: releaseTemplate,
|
|
27
28
|
[statTemplate.name]: statTemplate,
|
|
28
29
|
[terminalTemplate.name]: terminalTemplate,
|
|
30
|
+
[thumbnailTemplate.name]: thumbnailTemplate,
|
|
29
31
|
[wordmarkTemplate.name]: wordmarkTemplate,
|
|
30
32
|
};
|
|
31
33
|
export { articleTemplate } from "./article/index.js";
|
|
@@ -39,6 +41,7 @@ export { quoteTemplate } from "./quote/index.js";
|
|
|
39
41
|
export { releaseTemplate } from "./release/index.js";
|
|
40
42
|
export { statTemplate } from "./stat/index.js";
|
|
41
43
|
export { terminalTemplate } from "./terminal/index.js";
|
|
44
|
+
export { thumbnailTemplate } from "./thumbnail/index.js";
|
|
42
45
|
export { wordmarkTemplate } from "./wordmark/index.js";
|
|
43
46
|
export { optionalString } from "../props.js";
|
|
44
47
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAuC;IAClE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,eAAe;IACvC,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,cAAc;IACrC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY;IACjC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY;IACjC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY;IACjC,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,aAAa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,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -7,9 +7,9 @@ import { hugPanel, panelSvg } from "../code/plate.js";
|
|
|
7
7
|
import { codeBody } from "../code/spans.js";
|
|
8
8
|
import { warnIfTruncated } from "../code/warn.js";
|
|
9
9
|
import { charWidthRatio } from "../code/width.js";
|
|
10
|
-
import { hasFooter } from "../footer.js";
|
|
10
|
+
import { footerFontSize, hasFooter } from "../footer.js";
|
|
11
|
+
import { barHeight, titleBar } from "../window/index.js";
|
|
11
12
|
import { terminalSession } from "./session.js";
|
|
12
|
-
import { barHeight, titleBar } from "./window.js";
|
|
13
13
|
/**
|
|
14
14
|
* A command and what it printed, in a terminal window.
|
|
15
15
|
*
|
|
@@ -27,7 +27,7 @@ export const terminalTemplate = {
|
|
|
27
27
|
name: "terminal",
|
|
28
28
|
async render({ props, config, dimensions, measure }) {
|
|
29
29
|
const { width, height } = dimensions;
|
|
30
|
-
const footerFs =
|
|
30
|
+
const footerFs = footerFontSize(dimensions);
|
|
31
31
|
const session = await terminalSession(props, config);
|
|
32
32
|
const available = layoutPanel(dimensions, config, 0, footerFs, false, hasFooter(config));
|
|
33
33
|
// The bar is measured against the space the window was allotted rather
|
|
@@ -45,7 +45,7 @@ export const terminalTemplate = {
|
|
|
45
45
|
height: bar + body + fitted.padding * 2,
|
|
46
46
|
});
|
|
47
47
|
const shadow = Math.max(1, Math.round(Math.min(width, height) * 0.01));
|
|
48
|
-
return (panelSvg(window, session.background, shadow) +
|
|
48
|
+
return (panelSvg(window, session.background, shadow, config) +
|
|
49
49
|
titleBar(window, bar, optionalString(props.title) ?? "", config, measure) +
|
|
50
50
|
codeBody(fitted.lines, {
|
|
51
51
|
originX: window.x + fitted.padding,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/terminal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/terminal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAA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,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO;gBAClC,OAAO,EAAE,MAAM,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;gBAC1D,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU;gBAClC,UAAU,EAAE,OAAO,CAAC,UAAU;aAC/B,CAAC;YACF,UAAU,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CACzC,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Template } from "../../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A video thumbnail: one title, set as large as it will go, with an optional
|
|
4
|
+
* line under it.
|
|
5
|
+
*
|
|
6
|
+
* It is meant for YouTube, whose own recommendation is 1280x720, and
|
|
7
|
+
* `SIZE_PRESETS.thumbnail` is that size. What makes it a template of its own
|
|
8
|
+
* rather than a `card` at other proportions is where it is looked at. A share
|
|
9
|
+
* image is seen more or less at the size it was rendered; a thumbnail is seen
|
|
10
|
+
* in a list, a sidebar or a phone, at something between a third and a sixth of
|
|
11
|
+
* it. So the title is grown to fill the frame rather than set at a fraction of
|
|
12
|
+
* the height, there is one text field by default rather than three, and the
|
|
13
|
+
* margins are tighter than elsewhere.
|
|
14
|
+
*
|
|
15
|
+
* Everything the other centred templates draw is still drawn: the logo above,
|
|
16
|
+
* the footer along the bottom. Both are worth having on a channel's images,
|
|
17
|
+
* and a size can drop the footer with `footer: ""` where the title should have
|
|
18
|
+
* the whole frame.
|
|
19
|
+
*/
|
|
20
|
+
export declare const thumbnailTemplate: Template;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/thumbnail/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,gBAAgB,CAAC;AAoBhE;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAsD/B,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { linesHeight, stack } from "../../layout/index.js";
|
|
2
|
+
import { drawSlot, footerLine } from "../bottom.js";
|
|
3
|
+
import { contentArea, imageFrame, markRoom } from "../frame.js";
|
|
4
|
+
import { logoElement, logoRect } from "../logo.js";
|
|
5
|
+
import { subtitleGap, subtitleLineHeight, subtitleRoom, thumbnailSubtitle, thumbnailTitle, titleLineHeight, } from "./lines.js";
|
|
6
|
+
/**
|
|
7
|
+
* The margin, as a fraction of the width. Tighter than any of the other
|
|
8
|
+
* centred layouts, because the room the margins give back is the whole point
|
|
9
|
+
* of this one.
|
|
10
|
+
*/
|
|
11
|
+
const padScale = 0.055;
|
|
12
|
+
/**
|
|
13
|
+
* A video thumbnail: one title, set as large as it will go, with an optional
|
|
14
|
+
* line under it.
|
|
15
|
+
*
|
|
16
|
+
* It is meant for YouTube, whose own recommendation is 1280x720, and
|
|
17
|
+
* `SIZE_PRESETS.thumbnail` is that size. What makes it a template of its own
|
|
18
|
+
* rather than a `card` at other proportions is where it is looked at. A share
|
|
19
|
+
* image is seen more or less at the size it was rendered; a thumbnail is seen
|
|
20
|
+
* in a list, a sidebar or a phone, at something between a third and a sixth of
|
|
21
|
+
* it. So the title is grown to fill the frame rather than set at a fraction of
|
|
22
|
+
* the height, there is one text field by default rather than three, and the
|
|
23
|
+
* margins are tighter than elsewhere.
|
|
24
|
+
*
|
|
25
|
+
* Everything the other centred templates draw is still drawn: the logo above,
|
|
26
|
+
* the footer along the bottom. Both are worth having on a channel's images,
|
|
27
|
+
* and a size can drop the footer with `footer: ""` where the title should have
|
|
28
|
+
* the whole frame.
|
|
29
|
+
*/
|
|
30
|
+
export const thumbnailTemplate = {
|
|
31
|
+
name: "thumbnail",
|
|
32
|
+
render({ props, config, dimensions, measure, logo, avatar, }) {
|
|
33
|
+
const { width, height } = dimensions;
|
|
34
|
+
const frame = imageFrame(dimensions, config, avatar, { padScale });
|
|
35
|
+
const { pad } = frame;
|
|
36
|
+
const mark = logoRect(logo, dimensions, pad, "middle");
|
|
37
|
+
const area = contentArea(frame, markRoom(mark?.height, pad / 2));
|
|
38
|
+
const text = {
|
|
39
|
+
measure,
|
|
40
|
+
fontFamily: config.fontFamily,
|
|
41
|
+
contentWidth: area.width,
|
|
42
|
+
contentHeight: area.height,
|
|
43
|
+
height,
|
|
44
|
+
};
|
|
45
|
+
const subtitle = thumbnailSubtitle(props, text);
|
|
46
|
+
const title = thumbnailTitle(props, text, subtitleRoom(subtitle, height));
|
|
47
|
+
const [titleSlot, subtitleSlot] = stack([
|
|
48
|
+
{ size: linesHeight(title, titleLineHeight) },
|
|
49
|
+
{
|
|
50
|
+
size: linesHeight(subtitle, subtitleLineHeight),
|
|
51
|
+
gapBefore: subtitle.length === 0 ? 0 : subtitleGap(height),
|
|
52
|
+
},
|
|
53
|
+
], area);
|
|
54
|
+
const style = {
|
|
55
|
+
fontFamily: config.fontFamily,
|
|
56
|
+
fill: config.colors.foreground,
|
|
57
|
+
anchor: "middle",
|
|
58
|
+
};
|
|
59
|
+
return (logoElement(logo, mark) +
|
|
60
|
+
drawSlot(title, titleSlot, { ...style, lineHeight: titleLineHeight }) +
|
|
61
|
+
drawSlot(subtitle, subtitleSlot, {
|
|
62
|
+
...style,
|
|
63
|
+
lineHeight: subtitleLineHeight,
|
|
64
|
+
}) +
|
|
65
|
+
footerLine(config, frame, width, avatar, measure, "middle"));
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src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;QAEF,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAChD,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QAE1E,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CACrC;YACE,EAAE,IAAI,EAAE,WAAW,CAAC,KAAK,EAAE,eAAe,CAAC,EAAE;YAC7C;gBACE,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE,kBAAkB,CAAC;gBAC/C,SAAS,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC;aAC3D;SACF,EACD,IAAI,CACL,CAAC;QAEF,MAAM,KAAK,GAAG;YACZ,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU;YAC9B,MAAM,EAAE,QAAiB;SAC1B,CAAC;QAEF,OAAO,CACL,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC;YACvB,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;YACrE,QAAQ,CAAC,QAAQ,EAAE,YAAY,EAAE;gBAC/B,GAAG,KAAK;gBACR,UAAU,EAAE,kBAAkB;aAC/B,CAAC;YACF,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAC5D,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { TextLine } from "../../layout/index.js";
|
|
2
|
+
import type { MeasureText, MetaImageProps } from "../../types.js";
|
|
3
|
+
/** How tightly the title's own lines are stacked. */
|
|
4
|
+
export declare const titleLineHeight = 1.08;
|
|
5
|
+
/** And the subtitle's, which is set at a readable size rather than a large one. */
|
|
6
|
+
export declare const subtitleLineHeight = 1.25;
|
|
7
|
+
/** The space the thumbnail's text has, and how to measure text into it. */
|
|
8
|
+
export interface ThumbnailText {
|
|
9
|
+
readonly measure: MeasureText;
|
|
10
|
+
readonly fontFamily: string;
|
|
11
|
+
readonly contentWidth: number;
|
|
12
|
+
readonly contentHeight: number;
|
|
13
|
+
readonly height: number;
|
|
14
|
+
}
|
|
15
|
+
/** The gap between the title and the subtitle under it. */
|
|
16
|
+
export declare function subtitleGap(height: number): number;
|
|
17
|
+
/**
|
|
18
|
+
* The optional second line: a series name, a channel, the episode number.
|
|
19
|
+
*
|
|
20
|
+
* It is fitted first because the title takes whatever height it leaves, which
|
|
21
|
+
* is the order this layout is built in: the title is the picture, and what is
|
|
22
|
+
* under it is a caption on it.
|
|
23
|
+
*/
|
|
24
|
+
export declare function thumbnailSubtitle(props: MetaImageProps, text: ThumbnailText): TextLine[];
|
|
25
|
+
/**
|
|
26
|
+
* The title, grown until it fills the room the subtitle left it.
|
|
27
|
+
*
|
|
28
|
+
* This is the one built-in whose text is sized by the box rather than by the
|
|
29
|
+
* image, and the format is the reason. Everything else here is drawn to be read
|
|
30
|
+
* at something near the size it was rendered at, where a heading that swelled
|
|
31
|
+
* to fill its space would stop looking like a heading. A video thumbnail is
|
|
32
|
+
* seen in a list at a fraction of that size, so the only thing on it that
|
|
33
|
+
* matters is that the words are as large as they can be.
|
|
34
|
+
*/
|
|
35
|
+
export declare function thumbnailTitle(props: MetaImageProps, text: ThumbnailText, subtitleRoom: number): TextLine[];
|
|
36
|
+
/** The room the subtitle takes, including the gap above it, or none at all. */
|
|
37
|
+
export declare function subtitleRoom(lines: readonly TextLine[], height: number): number;
|
|
38
|
+
//# sourceMappingURL=lines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lines.d.ts","sourceRoot":"","sources":["../../../src/templates/thumbnail/lines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAElE,qDAAqD;AACrD,eAAO,MAAM,eAAe,OAAO,CAAC;AAEpC,mFAAmF;AACnF,eAAO,MAAM,kBAAkB,OAAO,CAAC;AA6BvC,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,aAAa,GAClB,QAAQ,EAAE,CASZ;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,aAAa,EACnB,YAAY,EAAE,MAAM,GACnB,QAAQ,EAAE,CAUZ;AAED,+EAA+E;AAC/E,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,QAAQ,EAAE,EAC1B,MAAM,EAAE,MAAM,GACb,MAAM,CAIR"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { blockLines, fillLines, linesHeight } from "../../layout/index.js";
|
|
2
|
+
/** How tightly the title's own lines are stacked. */
|
|
3
|
+
export const titleLineHeight = 1.08;
|
|
4
|
+
/** And the subtitle's, which is set at a readable size rather than a large one. */
|
|
5
|
+
export const subtitleLineHeight = 1.25;
|
|
6
|
+
const maxSubtitleLines = 2;
|
|
7
|
+
const subtitleFloor = 0.8;
|
|
8
|
+
/**
|
|
9
|
+
* The title's ceiling, as a fraction of the image's height.
|
|
10
|
+
*
|
|
11
|
+
* Nothing longer than a word or two ever reaches it, since the width runs out
|
|
12
|
+
* first: at 16:9 a two-word title settles around 0.45 of the height on its own.
|
|
13
|
+
* What the ceiling is for is the one-word case, where the width would allow
|
|
14
|
+
* something enormous, and half the height is where a single word stops reading
|
|
15
|
+
* as writing and starts reading as a graphic.
|
|
16
|
+
*/
|
|
17
|
+
const maxTitleScale = 0.5;
|
|
18
|
+
/**
|
|
19
|
+
* And its floor, below which the title is cut instead.
|
|
20
|
+
*
|
|
21
|
+
* Around 90px at 720 tall. A thumbnail is shown at something like a third of
|
|
22
|
+
* the width it was rendered at, so this is roughly the smallest text a reader
|
|
23
|
+
* scrolling past can still take in, and a title that will not fit at it is one
|
|
24
|
+
* with too much in it for the format.
|
|
25
|
+
*/
|
|
26
|
+
const minTitleScale = 0.125;
|
|
27
|
+
/** The subtitle's size, which does not change with how long the title is. */
|
|
28
|
+
const subtitleScale = 0.055;
|
|
29
|
+
/** The gap between the title and the subtitle under it. */
|
|
30
|
+
export function subtitleGap(height) {
|
|
31
|
+
return Math.round(height * 0.035);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The optional second line: a series name, a channel, the episode number.
|
|
35
|
+
*
|
|
36
|
+
* It is fitted first because the title takes whatever height it leaves, which
|
|
37
|
+
* is the order this layout is built in: the title is the picture, and what is
|
|
38
|
+
* under it is a caption on it.
|
|
39
|
+
*/
|
|
40
|
+
export function thumbnailSubtitle(props, text) {
|
|
41
|
+
return blockLines(props.subtitle, text.measure, text.fontFamily, {
|
|
42
|
+
maxWidth: text.contentWidth,
|
|
43
|
+
maxLines: maxSubtitleLines,
|
|
44
|
+
fontSize: Math.round(text.height * subtitleScale),
|
|
45
|
+
floor: subtitleFloor,
|
|
46
|
+
fontWeight: 600,
|
|
47
|
+
opacity: 0.85,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The title, grown until it fills the room the subtitle left it.
|
|
52
|
+
*
|
|
53
|
+
* This is the one built-in whose text is sized by the box rather than by the
|
|
54
|
+
* image, and the format is the reason. Everything else here is drawn to be read
|
|
55
|
+
* at something near the size it was rendered at, where a heading that swelled
|
|
56
|
+
* to fill its space would stop looking like a heading. A video thumbnail is
|
|
57
|
+
* seen in a list at a fraction of that size, so the only thing on it that
|
|
58
|
+
* matters is that the words are as large as they can be.
|
|
59
|
+
*/
|
|
60
|
+
export function thumbnailTitle(props, text, subtitleRoom) {
|
|
61
|
+
return fillLines(props.title, text.measure, text.fontFamily, {
|
|
62
|
+
maxWidth: text.contentWidth,
|
|
63
|
+
maxHeight: Math.max(1, text.contentHeight - subtitleRoom),
|
|
64
|
+
lineHeight: titleLineHeight,
|
|
65
|
+
maxFontSize: Math.round(text.height * maxTitleScale),
|
|
66
|
+
minFontSize: Math.round(text.height * minTitleScale),
|
|
67
|
+
fontWeight: 800,
|
|
68
|
+
opacity: 1,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** The room the subtitle takes, including the gap above it, or none at all. */
|
|
72
|
+
export function subtitleRoom(lines, height) {
|
|
73
|
+
const stacked = linesHeight(lines, subtitleLineHeight);
|
|
74
|
+
return stacked === 0 ? 0 : stacked + subtitleGap(height);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=lines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lines.js","sourceRoot":"","sources":["../../../src/templates/thumbnail/lines.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAG3E,qDAAqD;AACrD,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AAEpC,mFAAmF;AACnF,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEvC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,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,UAAU,EAAE,GAAG;QACf,OAAO,EAAE,CAAC;KACX,CAAC,CAAC;AACL,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,YAAY,CAC1B,KAA0B,EAC1B,MAAc;IAEd,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;IAEvD,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Which buttons a window's bar carries. */
|
|
2
|
+
export type WindowDots = "mono" | "macos";
|
|
3
|
+
/** Where the buttons sit in the bar, and how big they are. */
|
|
4
|
+
export interface DotsLayout {
|
|
5
|
+
readonly left: number;
|
|
6
|
+
readonly middle: number;
|
|
7
|
+
readonly diameter: number;
|
|
8
|
+
}
|
|
9
|
+
/** The row of buttons at the left of the bar. */
|
|
10
|
+
export declare function windowDots(dots: WindowDots, layout: DotsLayout): string;
|
|
11
|
+
//# sourceMappingURL=dots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dots.d.ts","sourceRoot":"","sources":["../../../src/templates/window/dots.ts"],"names":[],"mappings":"AAGA,4CAA4C;AAC5C,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AAuB1C,8DAA8D;AAC9D,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,iDAAiD;AACjD,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAevE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { box } from "../../layout/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* The three buttons, in the colours every reader has seen on a window.
|
|
4
|
+
*
|
|
5
|
+
* They are not the site's colours and are not meant to be. The point of the
|
|
6
|
+
* chrome is that the image is recognised as a window before a word of it is
|
|
7
|
+
* read, and these are what does the recognising.
|
|
8
|
+
*
|
|
9
|
+
* The neutral set says the same thing without borrowing an operating system's
|
|
10
|
+
* colours, which is what a snippet on a site with a palette of its own usually
|
|
11
|
+
* wants. The terminal draws the coloured ones, since a terminal is a window
|
|
12
|
+
* somebody has seen rather than a decorated panel.
|
|
13
|
+
*/
|
|
14
|
+
const macosButtons = ["#ff5f57", "#febc2e", "#28c840"];
|
|
15
|
+
/** One button's fill, which for the neutral set is the bar's own tone. */
|
|
16
|
+
function buttonStyle(dots, index) {
|
|
17
|
+
return dots === "macos"
|
|
18
|
+
? { fill: macosButtons[index] ?? "#ffffff" }
|
|
19
|
+
: { fill: "#ffffff", fillOpacity: 0.28 };
|
|
20
|
+
}
|
|
21
|
+
/** The row of buttons at the left of the bar. */
|
|
22
|
+
export function windowDots(dots, layout) {
|
|
23
|
+
const { left, middle, diameter } = layout;
|
|
24
|
+
const gap = Math.round(diameter * 1.7);
|
|
25
|
+
return Array.from({ length: macosButtons.length }, (_unused, index) => box({
|
|
26
|
+
x: left + index * gap,
|
|
27
|
+
y: middle - Math.round(diameter / 2),
|
|
28
|
+
width: diameter,
|
|
29
|
+
height: diameter,
|
|
30
|
+
}, { radius: Math.round(diameter / 2), ...buttonStyle(dots, index) })).join("");
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=dots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dots.js","sourceRoot":"","sources":["../../../src/templates/window/dots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAM5C;;;;;;;;;;;GAWG;AACH,MAAM,YAAY,GAAsB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAE1E,0EAA0E;AAC1E,SAAS,WAAW,CAAC,IAAgB,EAAE,KAAa;IAClD,OAAO,IAAI,KAAK,OAAO;QACrB,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,IAAI,SAAS,EAAE;QAC5C,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AAC7C,CAAC;AASD,iDAAiD;AACjD,MAAM,UAAU,UAAU,CAAC,IAAgB,EAAE,MAAkB;IAC7D,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;IAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC;IAEvC,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CACpE,GAAG,CACD;QACE,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,GAAG;QACrB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC;QACpC,KAAK,EAAE,QAAQ;QACf,MAAM,EAAE,QAAQ;KACjB,EACD,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAClE,CACF,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACb,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { MeasureText, ResolvedConfig } from "../../types.js";
|
|
2
2
|
import type { Panel } from "../code/panel.js";
|
|
3
|
+
import type { WindowDots } from "./dots.js";
|
|
4
|
+
export type { WindowDots } from "./dots.js";
|
|
3
5
|
/** How tall the title bar is on a window of this width. */
|
|
4
6
|
export declare function barHeight(windowWidth: number): number;
|
|
5
7
|
/**
|
|
@@ -10,5 +12,5 @@ export declare function barHeight(windowWidth: number): number;
|
|
|
10
12
|
* lifts whatever the code theme's background happens to be instead of having
|
|
11
13
|
* to be chosen against it.
|
|
12
14
|
*/
|
|
13
|
-
export declare function titleBar(window: Panel, height: number, title: string, config: ResolvedConfig, measure: MeasureText): string;
|
|
14
|
-
//# sourceMappingURL=
|
|
15
|
+
export declare function titleBar(window: Panel, height: number, title: string, config: ResolvedConfig, measure: MeasureText, dots?: WindowDots): string;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/window/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAG5C,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAQ5C,2DAA2D;AAC3D,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAErD;AAwBD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,WAAW,EACpB,IAAI,GAAE,UAAoB,GACzB,MAAM,CAeR"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { box } from "../../layout/index.js";
|
|
2
|
+
import { windowDots } from "./dots.js";
|
|
3
|
+
import { windowTitle } from "./title.js";
|
|
4
|
+
/** The title bar's height, as a fraction of the window's width. */
|
|
5
|
+
const barScale = 0.055;
|
|
6
|
+
/** The buttons' diameter, as a fraction of the bar's height. */
|
|
7
|
+
const buttonScale = 0.26;
|
|
8
|
+
/** How tall the title bar is on a window of this width. */
|
|
9
|
+
export function barHeight(windowWidth) {
|
|
10
|
+
return Math.round(windowWidth * barScale);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A rectangle with its top corners rounded and its bottom ones square, which
|
|
14
|
+
* is the shape of a title bar sitting in the top of a rounded window.
|
|
15
|
+
*
|
|
16
|
+
* It has to be one shape rather than a rounded rectangle with a square one
|
|
17
|
+
* over its bottom half, which is the obvious way to do it and the wrong one:
|
|
18
|
+
* the band is drawn at low opacity, so anywhere the two overlapped would be
|
|
19
|
+
* painted twice and come out as a lighter block with a curve through it.
|
|
20
|
+
*/
|
|
21
|
+
function roundedTop(rect, radius) {
|
|
22
|
+
const { x, y, width, height } = rect;
|
|
23
|
+
const r = Math.min(radius, Math.round(width / 2), height);
|
|
24
|
+
return (`M${String(x)} ${String(y + r)}` +
|
|
25
|
+
`a${String(r)} ${String(r)} 0 0 1 ${String(r)} ${String(-r)}` +
|
|
26
|
+
`h${String(width - r * 2)}` +
|
|
27
|
+
`a${String(r)} ${String(r)} 0 0 1 ${String(r)} ${String(r)}` +
|
|
28
|
+
`v${String(height - r)}h${String(-width)}z`);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The bar across the top of the window: a lighter band, the buttons, and the
|
|
32
|
+
* title in the middle of what is left.
|
|
33
|
+
*
|
|
34
|
+
* The band is white at low opacity rather than a colour of its own, so it
|
|
35
|
+
* lifts whatever the code theme's background happens to be instead of having
|
|
36
|
+
* to be chosen against it.
|
|
37
|
+
*/
|
|
38
|
+
export function titleBar(window, height, title, config, measure, dots = "macos") {
|
|
39
|
+
const band = `<path d="${roundedTop({ x: window.x, y: window.y, width: window.width, height }, window.radius)}"` +
|
|
40
|
+
` fill="#ffffff" fill-opacity="0.07"/>${box({ x: window.x, y: window.y + height, width: window.width, height: 1 }, { fill: "#ffffff", fillOpacity: 0.1 })}`;
|
|
41
|
+
const lights = windowDots(dots, {
|
|
42
|
+
left: window.x + Math.round(height * 0.6),
|
|
43
|
+
middle: window.y + Math.round(height / 2),
|
|
44
|
+
diameter: Math.round(height * buttonScale),
|
|
45
|
+
});
|
|
46
|
+
return band + lights + windowTitle(title, window, height, config, measure);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/window/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAI5C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAIzC,mEAAmE;AACnE,MAAM,QAAQ,GAAG,KAAK,CAAC;AAEvB,gEAAgE;AAChE,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,2DAA2D;AAC3D,MAAM,UAAU,SAAS,CAAC,WAAmB;IAC3C,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,QAAQ,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,UAAU,CAAC,IAAU,EAAE,MAAc;IAC5C,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACrC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAE1D,OAAO,CACL,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE;QAChC,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,UAAU,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;QAC7D,IAAI,MAAM,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,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AE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MeasureText, ResolvedConfig } from "../../types.js";
|
|
2
|
+
import type { Panel } from "../code/panel.js";
|
|
3
|
+
/**
|
|
4
|
+
* The window's title, centred in the bar. It is cut to the room between the
|
|
5
|
+
* buttons and the far edge, taking the buttons' width off both sides so that
|
|
6
|
+
* it stays centred in the bar rather than in what the buttons left.
|
|
7
|
+
*/
|
|
8
|
+
export declare function windowTitle(title: string, window: Panel, height: number, config: ResolvedConfig, measure: MeasureText): string;
|
|
9
|
+
//# sourceMappingURL=title.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"title.d.ts","sourceRoot":"","sources":["../../../src/templates/window/title.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,WAAW,GACnB,MAAM,CA0BR"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { baselineFor, clampLine, measureIn, textElement, } from "../../layout/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* The window's title, centred in the bar. It is cut to the room between the
|
|
4
|
+
* buttons and the far edge, taking the buttons' width off both sides so that
|
|
5
|
+
* it stays centred in the bar rather than in what the buttons left.
|
|
6
|
+
*/
|
|
7
|
+
export function windowTitle(title, window, height, config, measure) {
|
|
8
|
+
if (title === "") {
|
|
9
|
+
return "";
|
|
10
|
+
}
|
|
11
|
+
const fontSize = Math.round(height * 0.42);
|
|
12
|
+
const reserved = Math.round(height * 2.4);
|
|
13
|
+
return textElement(clampLine(title, window.width - reserved * 2, measureIn(measure, config.fontFamily, 600), fontSize), {
|
|
14
|
+
x: Math.round(window.x + window.width / 2),
|
|
15
|
+
y: baselineFor(window.y + (height - fontSize) / 2, fontSize),
|
|
16
|
+
fontFamily: config.fontFamily,
|
|
17
|
+
fontSize,
|
|
18
|
+
fontWeight: 600,
|
|
19
|
+
fill: "#ffffff",
|
|
20
|
+
fillOpacity: 0.6,
|
|
21
|
+
anchor: "middle",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=title.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"title.js","sourceRoot":"","sources":["../../../src/templates/window/title.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,SAAS,EACT,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAI/B;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,KAAa,EACb,MAAa,EACb,MAAc,EACd,MAAsB,EACtB,OAAoB;IAEpB,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;IAE1C,OAAO,WAAW,CAChB,SAAS,CACP,KAAK,EACL,MAAM,CAAC,KAAK,GAAG,QAAQ,GAAG,CAAC,EAC3B,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,EAC1C,QAAQ,CACT,EACD;QACE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QAC1C,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC;QAC5D,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,QAAQ;QACR,UAAU,EAAE,GAAG;QACf,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,GAAG;QAChB,MAAM,EAAE,QAAQ;KACjB,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FittedText, MeasureAt } from "./fit.js";
|
|
2
|
+
/** The box a block of text has to fill, and the sizes it may be drawn at. */
|
|
3
|
+
export interface FillOptions {
|
|
4
|
+
readonly maxWidth: number;
|
|
5
|
+
readonly maxHeight: number;
|
|
6
|
+
/** Each line's advance down the box, as a multiple of its font size. */
|
|
7
|
+
readonly lineHeight: number;
|
|
8
|
+
/** A ceiling on the size, however much room the box turns out to have. */
|
|
9
|
+
readonly maxFontSize: number;
|
|
10
|
+
/** The size below which the text is cut rather than shrunk any further. */
|
|
11
|
+
readonly minFontSize: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Wrap text into a box, at the largest size the whole of it fits at.
|
|
15
|
+
*
|
|
16
|
+
* This is {@link fitText} with the question turned round. `fitText` is given a
|
|
17
|
+
* size and shrinks only when the words need more lines than the layout allows,
|
|
18
|
+
* so a short title is drawn at whatever size the template named and no larger.
|
|
19
|
+
* That is right where the text sits in a group with other things, since a
|
|
20
|
+
* heading that grew to fill the space would stop looking like a heading.
|
|
21
|
+
*
|
|
22
|
+
* It is wrong where the text is the picture. A YouTube thumbnail is looked at
|
|
23
|
+
* in a fraction of the space it was rendered at, so its words have to take the
|
|
24
|
+
* room they are given rather than sit in the middle of it, and how much room
|
|
25
|
+
* that is depends on how many words there are: three of them should be drawn
|
|
26
|
+
* much larger than twelve. So the search comes down from the largest size the
|
|
27
|
+
* box could hold until the wrapped block fits both the width and the height.
|
|
28
|
+
*
|
|
29
|
+
* Text that will not fit even at the floor is cut to the lines there is room
|
|
30
|
+
* for, which is what `fitText` does at its own floor and for the same reason:
|
|
31
|
+
* below a certain size the image has stopped saying anything anybody can read.
|
|
32
|
+
*/
|
|
33
|
+
export declare function fillText(text: string, measure: MeasureAt, options: FillOptions): FittedText;
|
|
34
|
+
//# sourceMappingURL=fill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill.d.ts","sourceRoot":"","sources":["../../src/text/fill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAKtD,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,wEAAwE;IACxE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAkCD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,WAAW,GACnB,UAAU,CAiBZ"}
|