shape-text 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +264 -0
  3. package/dist/geometry/get-band-intervals-from-polygon.d.ts +2 -0
  4. package/dist/geometry/get-band-intervals-from-polygon.js +44 -0
  5. package/dist/geometry/get-band-intervals-from-polygon.js.map +1 -0
  6. package/dist/geometry/get-polygon-bounds.d.ts +2 -0
  7. package/dist/geometry/get-polygon-bounds.js +18 -0
  8. package/dist/geometry/get-polygon-bounds.js.map +1 -0
  9. package/dist/geometry/get-x-intersections-at-y.d.ts +2 -0
  10. package/dist/geometry/get-x-intersections-at-y.js +15 -0
  11. package/dist/geometry/get-x-intersections-at-y.js.map +1 -0
  12. package/dist/index.d.ts +11 -0
  13. package/dist/index.js +11 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/layout/layout-dense-fill-pass.d.ts +23 -0
  16. package/dist/layout/layout-dense-fill-pass.js +64 -0
  17. package/dist/layout/layout-dense-fill-pass.js.map +1 -0
  18. package/dist/layout/layout-flow-lines-in-compiled-shape.d.ts +13 -0
  19. package/dist/layout/layout-flow-lines-in-compiled-shape.js +42 -0
  20. package/dist/layout/layout-flow-lines-in-compiled-shape.js.map +1 -0
  21. package/dist/layout/layout-text-in-compiled-shape.d.ts +2 -0
  22. package/dist/layout/layout-text-in-compiled-shape.js +13 -0
  23. package/dist/layout/layout-text-in-compiled-shape.js.map +1 -0
  24. package/dist/layout/layout-text-in-shape.d.ts +2 -0
  25. package/dist/layout/layout-text-in-shape.js +40 -0
  26. package/dist/layout/layout-text-in-shape.js.map +1 -0
  27. package/dist/layout/resolve-flow-layout.d.ts +2 -0
  28. package/dist/layout/resolve-flow-layout.js +31 -0
  29. package/dist/layout/resolve-flow-layout.js.map +1 -0
  30. package/dist/layout/resolve-max-fill-helpers.d.ts +3 -0
  31. package/dist/layout/resolve-max-fill-helpers.js +18 -0
  32. package/dist/layout/resolve-max-fill-helpers.js.map +1 -0
  33. package/dist/layout/resolve-max-fill-layout.d.ts +2 -0
  34. package/dist/layout/resolve-max-fill-layout.js +34 -0
  35. package/dist/layout/resolve-max-fill-layout.js.map +1 -0
  36. package/dist/layout/resolve-sequential-shape-regions.d.ts +3 -0
  37. package/dist/layout/resolve-sequential-shape-regions.js +95 -0
  38. package/dist/layout/resolve-sequential-shape-regions.js.map +1 -0
  39. package/dist/render/escape-xml-text.d.ts +1 -0
  40. package/dist/render/escape-xml-text.js +9 -0
  41. package/dist/render/escape-xml-text.js.map +1 -0
  42. package/dist/render/normalize-shape-decoration.d.ts +2 -0
  43. package/dist/render/normalize-shape-decoration.js +41 -0
  44. package/dist/render/normalize-shape-decoration.js.map +1 -0
  45. package/dist/render/render-layout-to-svg.d.ts +2 -0
  46. package/dist/render/render-layout-to-svg.js +88 -0
  47. package/dist/render/render-layout-to-svg.js.map +1 -0
  48. package/dist/render/render-svg-shadow-filter.d.ts +10 -0
  49. package/dist/render/render-svg-shadow-filter.js +16 -0
  50. package/dist/render/render-svg-shadow-filter.js.map +1 -0
  51. package/dist/shape/build-text-mask-bands-from-alpha.d.ts +8 -0
  52. package/dist/shape/build-text-mask-bands-from-alpha.js +73 -0
  53. package/dist/shape/build-text-mask-bands-from-alpha.js.map +1 -0
  54. package/dist/shape/compile-polygon-shape-for-layout.d.ts +2 -0
  55. package/dist/shape/compile-polygon-shape-for-layout.js +26 -0
  56. package/dist/shape/compile-polygon-shape-for-layout.js.map +1 -0
  57. package/dist/shape/compile-shape-for-layout.d.ts +2 -0
  58. package/dist/shape/compile-shape-for-layout.js +18 -0
  59. package/dist/shape/compile-shape-for-layout.js.map +1 -0
  60. package/dist/shape/compile-text-mask-shape-for-layout.d.ts +2 -0
  61. package/dist/shape/compile-text-mask-shape-for-layout.js +162 -0
  62. package/dist/shape/compile-text-mask-shape-for-layout.js.map +1 -0
  63. package/dist/shape/render-text-mask-raster.d.ts +13 -0
  64. package/dist/shape/render-text-mask-raster.js +29 -0
  65. package/dist/shape/render-text-mask-raster.js.map +1 -0
  66. package/dist/shape/resolve-text-mask-shape-size.d.ts +18 -0
  67. package/dist/shape/resolve-text-mask-shape-size.js +67 -0
  68. package/dist/shape/resolve-text-mask-shape-size.js.map +1 -0
  69. package/dist/shape/segment-text-mask-graphemes.d.ts +6 -0
  70. package/dist/shape/segment-text-mask-graphemes.js +20 -0
  71. package/dist/shape/segment-text-mask-graphemes.js.map +1 -0
  72. package/dist/text/create-browser-canvas-2d-context.d.ts +2 -0
  73. package/dist/text/create-browser-canvas-2d-context.js +21 -0
  74. package/dist/text/create-browser-canvas-2d-context.js.map +1 -0
  75. package/dist/text/create-canvas-text-measurer.d.ts +2 -0
  76. package/dist/text/create-canvas-text-measurer.js +11 -0
  77. package/dist/text/create-canvas-text-measurer.js.map +1 -0
  78. package/dist/text/layout-next-line-from-dense-repeated-text.d.ts +2 -0
  79. package/dist/text/layout-next-line-from-dense-repeated-text.js +63 -0
  80. package/dist/text/layout-next-line-from-dense-repeated-text.js.map +1 -0
  81. package/dist/text/layout-next-line-from-prepared-text.d.ts +2 -0
  82. package/dist/text/layout-next-line-from-prepared-text.js +57 -0
  83. package/dist/text/layout-next-line-from-prepared-text.js.map +1 -0
  84. package/dist/text/layout-next-line-from-repeated-text.d.ts +2 -0
  85. package/dist/text/layout-next-line-from-repeated-text.js +51 -0
  86. package/dist/text/layout-next-line-from-repeated-text.js.map +1 -0
  87. package/dist/text/layout-text-line-helpers.d.ts +4 -0
  88. package/dist/text/layout-text-line-helpers.js +17 -0
  89. package/dist/text/layout-text-line-helpers.js.map +1 -0
  90. package/dist/text/normalize-text-style-to-font.d.ts +6 -0
  91. package/dist/text/normalize-text-style-to-font.js +31 -0
  92. package/dist/text/normalize-text-style-to-font.js.map +1 -0
  93. package/dist/text/prepare-dense-repeat-fill-pattern.d.ts +2 -0
  94. package/dist/text/prepare-dense-repeat-fill-pattern.js +13 -0
  95. package/dist/text/prepare-dense-repeat-fill-pattern.js.map +1 -0
  96. package/dist/text/prepare-stream-repeat-fill-pattern.d.ts +2 -0
  97. package/dist/text/prepare-stream-repeat-fill-pattern.js +16 -0
  98. package/dist/text/prepare-stream-repeat-fill-pattern.js.map +1 -0
  99. package/dist/text/prepare-text-for-layout.d.ts +2 -0
  100. package/dist/text/prepare-text-for-layout.js +22 -0
  101. package/dist/text/prepare-text-for-layout.js.map +1 -0
  102. package/dist/text/segment-text-for-layout.d.ts +3 -0
  103. package/dist/text/segment-text-for-layout.js +43 -0
  104. package/dist/text/segment-text-for-layout.js.map +1 -0
  105. package/dist/types.d.ts +200 -0
  106. package/dist/types.js +2 -0
  107. package/dist/types.js.map +1 -0
  108. package/package.json +79 -0
@@ -0,0 +1,31 @@
1
+ import { resolveLayoutTextStyle } from '../text/normalize-text-style-to-font.js';
2
+ import { prepareTextForLayout } from '../text/prepare-text-for-layout.js';
3
+ import { layoutFlowLinesInCompiledShape } from './layout-flow-lines-in-compiled-shape.js';
4
+ export function resolveFlowLayout(options) {
5
+ const resolvedTextStyle = resolveLayoutTextStyle({
6
+ font: options.font,
7
+ textStyle: options.textStyle,
8
+ });
9
+ const align = options.align ?? 'left';
10
+ const baselineRatio = options.baselineRatio ?? 0.8;
11
+ const prepared = prepareTextForLayout(options.text, resolvedTextStyle.font, options.measurer);
12
+ const { lines, endCursor } = layoutFlowLinesInCompiledShape({
13
+ compiledShape: options.compiledShape,
14
+ prepared,
15
+ align,
16
+ baselineRatio,
17
+ startCursor: { tokenIndex: 0, graphemeIndex: 0 },
18
+ });
19
+ return {
20
+ font: resolvedTextStyle.font,
21
+ textStyle: resolvedTextStyle,
22
+ lineHeight: options.compiledShape.bandHeight,
23
+ shape: options.compiledShape.source,
24
+ compiledShape: options.compiledShape,
25
+ bounds: options.compiledShape.bounds,
26
+ lines,
27
+ exhausted: endCursor.tokenIndex >= prepared.tokens.length,
28
+ autoFill: false,
29
+ };
30
+ }
31
+ //# sourceMappingURL=resolve-flow-layout.js.map
@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AAC,MAAM;QACzD,QAAQ,EAAE,KAAK;KAChB,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CompiledShapeBands } from '../types.js';
2
+ export declare function resolveMaxFillMinSlotWidth(lineHeight: number): number;
3
+ export declare function ensureMaxFillCompiledShape(compiledShape: CompiledShapeBands): CompiledShapeBands;
@@ -0,0 +1,18 @@
1
+ import { compileShapeForLayout } from '../shape/compile-shape-for-layout.js';
2
+ const MAX_FILL_BASE_MIN_SLOT_WIDTH_FACTOR = 0.45;
3
+ const MIN_MAX_FILL_SLOT_WIDTH = 6;
4
+ export function resolveMaxFillMinSlotWidth(lineHeight) {
5
+ return Math.max(MIN_MAX_FILL_SLOT_WIDTH, Math.round(lineHeight * MAX_FILL_BASE_MIN_SLOT_WIDTH_FACTOR));
6
+ }
7
+ export function ensureMaxFillCompiledShape(compiledShape) {
8
+ const recommendedMinSlotWidth = resolveMaxFillMinSlotWidth(compiledShape.bandHeight);
9
+ if (compiledShape.minSlotWidth <= recommendedMinSlotWidth) {
10
+ return compiledShape;
11
+ }
12
+ return compileShapeForLayout({
13
+ shape: compiledShape.source,
14
+ lineHeight: compiledShape.bandHeight,
15
+ minSlotWidth: recommendedMinSlotWidth,
16
+ });
17
+ }
18
+ //# sourceMappingURL=resolve-max-fill-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-max-fill-helpers.js","sourceRoot":"","sources":["../../src/layout/resolve-max-fill-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAE5E,MAAM,mCAAmC,GAAG,IAAI,CAAA;AAChD,MAAM,uBAAuB,GAAG,CAAC,CAAA;AAEjC,MAAM,UAAU,0BAA0B,CAAC,UAAkB;IAC3D,OAAO,IAAI,CAAC,GAAG,CAAC,uBAAuB,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,mCAAmC,CAAC,CAAC,CAAA;AACxG,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,aAAiC;IAC1E,MAAM,uBAAuB,GAAG,0BAA0B,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;IACpF,IAAI,aAAa,CAAC,YAAY,IAAI,uBAAuB,EAAE,CAAC;QAC1D,OAAO,aAAa,CAAA;IACtB,CAAC;IAED,OAAO,qBAAqB,CAAC;QAC3B,KAAK,EAAE,aAAa,CAAC,MAAM;QAC3B,UAAU,EAAE,aAAa,CAAC,UAAU;QACpC,YAAY,EAAE,uBAAuB;KACtC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { LayoutTextInCompiledShapeOptions, ShapeTextLayout } from '../types.js';
2
+ export declare function resolveMaxFillLayout(options: LayoutTextInCompiledShapeOptions): ShapeTextLayout;
@@ -0,0 +1,34 @@
1
+ import { resolveLayoutTextStyle } from '../text/normalize-text-style-to-font.js';
2
+ import { prepareStreamRepeatFillPattern } from '../text/prepare-stream-repeat-fill-pattern.js';
3
+ import { layoutDenseFillPass } from './layout-dense-fill-pass.js';
4
+ import { ensureMaxFillCompiledShape } from './resolve-max-fill-helpers.js';
5
+ export function resolveMaxFillLayout(options) {
6
+ const resolvedTextStyle = resolveLayoutTextStyle({
7
+ font: options.font,
8
+ textStyle: options.textStyle,
9
+ });
10
+ const baselineRatio = options.baselineRatio ?? 0.8;
11
+ const maxCompiledShape = ensureMaxFillCompiledShape(options.compiledShape);
12
+ const streamPattern = prepareStreamRepeatFillPattern(options.text, resolvedTextStyle.font, options.measurer);
13
+ const pass = layoutDenseFillPass({
14
+ compiledShape: maxCompiledShape,
15
+ densePattern: streamPattern,
16
+ startOffset: 0,
17
+ align: 'left',
18
+ baselineRatio,
19
+ allSlots: true,
20
+ fillPass: 1,
21
+ });
22
+ return {
23
+ font: resolvedTextStyle.font,
24
+ textStyle: resolvedTextStyle,
25
+ lineHeight: maxCompiledShape.bandHeight,
26
+ shape: maxCompiledShape.source,
27
+ compiledShape: maxCompiledShape,
28
+ bounds: maxCompiledShape.bounds,
29
+ lines: pass.lines,
30
+ exhausted: false,
31
+ autoFill: true,
32
+ };
33
+ }
34
+ //# sourceMappingURL=resolve-max-fill-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-max-fill-layout.js","sourceRoot":"","sources":["../../src/layout/resolve-max-fill-layout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAA;AAChF,OAAO,EAAE,8BAA8B,EAAE,MAAM,+CAA+C,CAAA;AAC9F,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAA;AAE1E,MAAM,UAAU,oBAAoB,CAClC,OAAyC;IAEzC,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;QAC/C,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAA;IACF,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,GAAG,CAAA;IAClD,MAAM,gBAAgB,GAAG,0BAA0B,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;IAC1E,MAAM,aAAa,GAAG,8BAA8B,CAClD,OAAO,CAAC,IAAI,EACZ,iBAAiB,CAAC,IAAI,EACtB,OAAO,CAAC,QAAQ,CACjB,CAAA;IAED,MAAM,IAAI,GAAG,mBAAmB,CAAC;QAC/B,aAAa,EAAE,gBAAgB;QAC/B,YAAY,EAAE,aAAa;QAC3B,WAAW,EAAE,CAAC;QACd,KAAK,EAAE,MAAM;QACb,aAAa;QACb,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,CAAC;KACZ,CAAC,CAAA;IAEF,OAAO;QACL,IAAI,EAAE,iBAAiB,CAAC,IAAI;QAC5B,SAAS,EAAE,iBAAiB;QAC5B,UAAU,EAAE,gBAAgB,CAAC,UAAU;QACvC,KAAK,EAAE,gBAAgB,CAAC,MAAM;QAC9B,aAAa,EAAE,gBAAgB;QAC/B,MAAM,EAAE,gBAAgB,CAAC,MAAM;QAC/B,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE,IAAI;KACf,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CompiledShapeBands, LayoutTextInCompiledShapeOptions, ShapeTextLayout } from '../types.js';
2
+ export declare function hasSequentialShapeRegions(compiledShape: CompiledShapeBands): boolean;
3
+ export declare function resolveSequentialShapeRegions(options: LayoutTextInCompiledShapeOptions): ShapeTextLayout;
@@ -0,0 +1,95 @@
1
+ import { resolveLayoutTextStyle } from '../text/normalize-text-style-to-font.js';
2
+ import { prepareStreamRepeatFillPattern } from '../text/prepare-stream-repeat-fill-pattern.js';
3
+ import { prepareTextForLayout } from '../text/prepare-text-for-layout.js';
4
+ import { layoutDenseFillPass } from './layout-dense-fill-pass.js';
5
+ import { layoutFlowLinesInCompiledShape } from './layout-flow-lines-in-compiled-shape.js';
6
+ import { ensureMaxFillCompiledShape } from './resolve-max-fill-helpers.js';
7
+ function createCompiledShapeFromRegion(compiledShape, region) {
8
+ return {
9
+ kind: compiledShape.kind,
10
+ source: compiledShape.source,
11
+ bounds: region.bounds,
12
+ bandHeight: compiledShape.bandHeight,
13
+ minSlotWidth: compiledShape.minSlotWidth,
14
+ bands: region.bands,
15
+ debugView: region.debugView,
16
+ };
17
+ }
18
+ export function hasSequentialShapeRegions(compiledShape) {
19
+ return (compiledShape.source.kind === 'text-mask' &&
20
+ (compiledShape.source.shapeTextMode ?? 'whole-text') === 'per-character' &&
21
+ (compiledShape.regions?.some(region => region.bands.some(band => band.intervals.length > 0)) ?? false));
22
+ }
23
+ export function resolveSequentialShapeRegions(options) {
24
+ const autoFill = options.autoFill ?? false;
25
+ const resolvedTextStyle = resolveLayoutTextStyle({
26
+ font: options.font,
27
+ textStyle: options.textStyle,
28
+ });
29
+ const align = options.align ?? 'left';
30
+ const baselineRatio = options.baselineRatio ?? 0.8;
31
+ const compiledShape = autoFill
32
+ ? ensureMaxFillCompiledShape(options.compiledShape)
33
+ : options.compiledShape;
34
+ const regions = compiledShape.regions ?? [];
35
+ if (autoFill) {
36
+ const streamPattern = prepareStreamRepeatFillPattern(options.text, resolvedTextStyle.font, options.measurer);
37
+ const lines = [];
38
+ let offset = 0;
39
+ for (let index = 0; index < regions.length; index++) {
40
+ const regionShape = createCompiledShapeFromRegion(compiledShape, regions[index]);
41
+ const pass = layoutDenseFillPass({
42
+ compiledShape: regionShape,
43
+ densePattern: streamPattern,
44
+ startOffset: offset,
45
+ align: 'left',
46
+ baselineRatio,
47
+ allSlots: true,
48
+ fillPass: 1,
49
+ });
50
+ lines.push(...pass.lines);
51
+ offset = pass.endOffset;
52
+ }
53
+ return {
54
+ font: resolvedTextStyle.font,
55
+ textStyle: resolvedTextStyle,
56
+ lineHeight: compiledShape.bandHeight,
57
+ shape: compiledShape.source,
58
+ compiledShape,
59
+ bounds: compiledShape.bounds,
60
+ lines,
61
+ exhausted: false,
62
+ autoFill: true,
63
+ };
64
+ }
65
+ const prepared = prepareTextForLayout(options.text, resolvedTextStyle.font, options.measurer);
66
+ const lines = [];
67
+ let cursor = { tokenIndex: 0, graphemeIndex: 0 };
68
+ for (let index = 0; index < regions.length; index++) {
69
+ const regionShape = createCompiledShapeFromRegion(compiledShape, regions[index]);
70
+ const result = layoutFlowLinesInCompiledShape({
71
+ compiledShape: regionShape,
72
+ prepared,
73
+ align,
74
+ baselineRatio,
75
+ startCursor: cursor,
76
+ });
77
+ lines.push(...result.lines);
78
+ cursor = result.endCursor;
79
+ if (!autoFill && prepared !== undefined && cursor.tokenIndex >= prepared.tokens.length) {
80
+ break;
81
+ }
82
+ }
83
+ return {
84
+ font: resolvedTextStyle.font,
85
+ textStyle: resolvedTextStyle,
86
+ lineHeight: compiledShape.bandHeight,
87
+ shape: compiledShape.source,
88
+ compiledShape,
89
+ bounds: compiledShape.bounds,
90
+ lines,
91
+ exhausted: cursor.tokenIndex >= prepared.tokens.length,
92
+ autoFill: false,
93
+ };
94
+ }
95
+ //# sourceMappingURL=resolve-sequential-shape-regions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-sequential-shape-regions.js","sourceRoot":"","sources":["../../src/layout/resolve-sequential-shape-regions.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAA;AAChF,OAAO,EAAE,8BAA8B,EAAE,MAAM,+CAA+C,CAAA;AAC9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,0CAA0C,CAAA;AACzF,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAA;AAE1E,SAAS,6BAA6B,CACpC,aAAiC,EACjC,MAA2B;IAE3B,OAAO;QACL,IAAI,EAAE,aAAa,CAAC,IAAI;QACxB,MAAM,EAAE,aAAa,CAAC,MAAM;QAC5B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,UAAU,EAAE,aAAa,CAAC,UAAU;QACpC,YAAY,EAAE,aAAa,CAAC,YAAY;QACxC,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,CAAA;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,aAAiC;IACzE,OAAO,CACL,aAAa,CAAC,MAAM,CAAC,IAAI,KAAK,WAAW;QACzC,CAAC,aAAa,CAAC,MAAM,CAAC,aAAa,IAAI,YAAY,CAAC,KAAK,eAAe;QACxE,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CACpC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CACrD,IAAI,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OAAO;QACL,IAAI,EAAE,iBAAiB,CAAC,IAAI;QAC5B,SAAS,EAAE,iBAAiB;QAC5B,UAAU,EAAE,aAAa,CAAC,UAAU;QACpC,KAAK,EAAE,aAAa,CAAC,MAAM;QAC3B,aAAa;QACb,MAAM,EAAE,aAAa,CAAC,MAAM;QAC5B,KAAK;QACL,SAAS,EAAE,MAAM,CAAC,UAAU,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM;QACtD,QAAQ,EAAE,KAAK;KAChB,CAAA;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function escapeXmlText(value: string): string;
@@ -0,0 +1,9 @@
1
+ export function escapeXmlText(value) {
2
+ return value
3
+ .replaceAll('&', '&amp;')
4
+ .replaceAll('<', '&lt;')
5
+ .replaceAll('>', '&gt;')
6
+ .replaceAll('"', '&quot;')
7
+ .replaceAll("'", '&apos;');
8
+ }
9
+ //# sourceMappingURL=escape-xml-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escape-xml-text.js","sourceRoot":"","sources":["../../src/render/escape-xml-text.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,KAAK;SACT,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;SACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;SACzB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;AAC9B,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { RenderLayoutToSvgOptions, ResolvedShapeStyle } from '../types.js';
2
+ export declare function normalizeShapeDecoration(options: RenderLayoutToSvgOptions): ResolvedShapeStyle;
@@ -0,0 +1,41 @@
1
+ function assertFiniteNonNegative(value, message) {
2
+ if (!Number.isFinite(value) || value < 0) {
3
+ throw new Error(message);
4
+ }
5
+ }
6
+ function normalizeShadow(shadow) {
7
+ if (shadow === undefined) {
8
+ return undefined;
9
+ }
10
+ assertFiniteNonNegative(shadow.blur, 'shapeStyle.shadow.blur must be a finite non-negative number');
11
+ const offsetX = shadow.offsetX ?? 0;
12
+ const offsetY = shadow.offsetY ?? 0;
13
+ if (!Number.isFinite(offsetX) || !Number.isFinite(offsetY)) {
14
+ throw new Error('shapeStyle.shadow offsets must be finite numbers');
15
+ }
16
+ return {
17
+ color: shadow.color ?? 'rgba(15, 23, 42, 0.24)',
18
+ blur: shadow.blur,
19
+ offsetX,
20
+ offsetY,
21
+ };
22
+ }
23
+ export function normalizeShapeDecoration(options) {
24
+ const explicitBorderWidth = options.shapeStyle?.borderWidth;
25
+ if (explicitBorderWidth !== undefined) {
26
+ assertFiniteNonNegative(explicitBorderWidth, 'shapeStyle.borderWidth must be a finite non-negative number');
27
+ }
28
+ const borderWidth = explicitBorderWidth ??
29
+ (options.shapeStyle?.borderColor !== undefined
30
+ ? 1
31
+ : options.shapeStyle === undefined && (options.shapeStroke !== undefined || options.showShape === true)
32
+ ? 1
33
+ : 0);
34
+ return {
35
+ backgroundColor: options.shapeStyle?.backgroundColor ?? options.shapeFill,
36
+ borderColor: options.shapeStyle?.borderColor ?? options.shapeStroke ?? '#d1d5db',
37
+ borderWidth,
38
+ shadow: normalizeShadow(options.shapeStyle?.shadow),
39
+ };
40
+ }
41
+ //# sourceMappingURL=normalize-shape-decoration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-shape-decoration.js","sourceRoot":"","sources":["../../src/render/normalize-shape-decoration.ts"],"names":[],"mappings":"AAMA,SAAS,uBAAuB,CAAC,KAAa,EAAE,OAAe;IAC7D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;IAC1B,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,MAAoC;IAC3D,IAAI,MAAM,KAA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AAW,IAAI,SAAS;QAChF,WAAW;QACX,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC;KACpD,CAAA;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { RenderLayoutToSvgOptions, ShapeTextLayout } from '../types.js';
2
+ export declare function renderLayoutToSvg(layout: ShapeTextLayout, options?: RenderLayoutToSvgOptions): string;
@@ -0,0 +1,88 @@
1
+ import { createSvgShadowFilter } from './render-svg-shadow-filter.js';
2
+ import { normalizeShapeDecoration } from './normalize-shape-decoration.js';
3
+ import { escapeXmlText } from './escape-xml-text.js';
4
+ function renderPoints(points) {
5
+ return points.map(point => `${point.x},${point.y}`).join(' ');
6
+ }
7
+ function getEffectPadding(options) {
8
+ const strokePadding = options.strokeWidth / 2;
9
+ const shadowBlurPadding = options.shadow === undefined ? 0 : options.shadow.blur * 3;
10
+ return {
11
+ left: strokePadding +
12
+ (options.shadow === undefined ? 0 : shadowBlurPadding + Math.max(0, -options.shadow.offsetX)),
13
+ right: strokePadding +
14
+ (options.shadow === undefined ? 0 : shadowBlurPadding + Math.max(0, options.shadow.offsetX)),
15
+ top: strokePadding +
16
+ (options.shadow === undefined ? 0 : shadowBlurPadding + Math.max(0, -options.shadow.offsetY)),
17
+ bottom: strokePadding +
18
+ (options.shadow === undefined ? 0 : shadowBlurPadding + Math.max(0, options.shadow.offsetY)),
19
+ };
20
+ }
21
+ function renderShapeAttributes(debugView, options) {
22
+ const filter = options.filterUrl === undefined ? '' : ` filter="${options.filterUrl}"`;
23
+ const fill = escapeXmlText(options.fill);
24
+ const stroke = escapeXmlText(options.stroke);
25
+ if (debugView.kind === 'polygon') {
26
+ return `<polygon points="${renderPoints(debugView.points)}" fill="${fill}" stroke="${stroke}" stroke-width="${options.strokeWidth}"${filter} />`;
27
+ }
28
+ return `<text x="${debugView.x}" y="${debugView.baseline}" fill="${fill}" stroke="${stroke}" stroke-width="${options.strokeWidth}"${filter} style="font:${escapeXmlText(debugView.font)};">${escapeXmlText(debugView.text)}</text>`;
29
+ }
30
+ export function renderLayoutToSvg(layout, options = {}) {
31
+ const userPadding = options.padding ?? 0;
32
+ const textFill = options.textFill ?? layout.textStyle?.color ?? '#111827';
33
+ const shapeStyle = normalizeShapeDecoration(options);
34
+ const background = options.background;
35
+ const hasVisibleCanonicalShapeDecoration = options.shapeStyle !== undefined &&
36
+ (shapeStyle.backgroundColor !== undefined ||
37
+ shapeStyle.borderWidth > 0 ||
38
+ shapeStyle.shadow !== undefined);
39
+ const showShape = options.showShape ?? hasVisibleCanonicalShapeDecoration;
40
+ const effectPadding = showShape
41
+ ? getEffectPadding({
42
+ strokeWidth: shapeStyle.borderWidth,
43
+ shadow: shapeStyle.shadow,
44
+ })
45
+ : { left: 0, right: 0, top: 0, bottom: 0 };
46
+ const totalPadding = {
47
+ left: userPadding + effectPadding.left,
48
+ right: userPadding + effectPadding.right,
49
+ top: userPadding + effectPadding.top,
50
+ bottom: userPadding + effectPadding.bottom,
51
+ };
52
+ const width = layout.bounds.right - layout.bounds.left + totalPadding.left + totalPadding.right;
53
+ const height = layout.bounds.bottom - layout.bounds.top + totalPadding.top + totalPadding.bottom;
54
+ const viewBoxLeft = layout.bounds.left - totalPadding.left;
55
+ const viewBoxTop = layout.bounds.top - totalPadding.top;
56
+ const shadowFilter = showShape && shapeStyle.shadow !== undefined
57
+ ? createSvgShadowFilter(shapeStyle.shadow, {
58
+ x: viewBoxLeft,
59
+ y: viewBoxTop,
60
+ width,
61
+ height,
62
+ })
63
+ : undefined;
64
+ const pieces = [
65
+ `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${viewBoxLeft} ${viewBoxTop} ${width} ${height}" width="${width}" height="${height}">`,
66
+ ];
67
+ if (shadowFilter !== undefined) {
68
+ pieces.push(shadowFilter.markup);
69
+ }
70
+ if (background !== undefined) {
71
+ pieces.push(`<rect x="${viewBoxLeft}" y="${viewBoxTop}" width="${width}" height="${height}" fill="${escapeXmlText(background)}" />`);
72
+ }
73
+ if (showShape) {
74
+ pieces.push(renderShapeAttributes(layout.compiledShape.debugView, {
75
+ fill: shapeStyle.backgroundColor ?? 'none',
76
+ stroke: shapeStyle.borderColor,
77
+ strokeWidth: shapeStyle.borderWidth,
78
+ filterUrl: shadowFilter === undefined ? undefined : `url(#${shadowFilter.filterId})`,
79
+ }));
80
+ }
81
+ for (let index = 0; index < layout.lines.length; index++) {
82
+ const line = layout.lines[index];
83
+ pieces.push(`<text x="${line.x}" y="${line.baseline}" fill="${escapeXmlText(textFill)}" style="font:${escapeXmlText(line.font ?? layout.font)};">${escapeXmlText(line.text)}</text>`);
84
+ }
85
+ pieces.push('</svg>');
86
+ return pieces.join('');
87
+ }
88
+ //# sourceMappingURL=render-layout-to-svg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-layout-to-svg.js","sourceRoot":"","sources":["../../src/render/render-layout-to-svg.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAA;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD,SAAS,YAAY,CAAC,MAAwB;IAC5C,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC/D,CAAC;AAED,SAAS,gBAAgB,CAAC,OAOzB;IACC,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,GAAG,CAAC,CAAA;IAC7C,MAAM,iBAAiB,GAAG,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAA;IAEpF,OAAO;QACL,IAAI,EACF,aAAa;YACb,CAAC,OAAO,CAAC,MAAM,KA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IACH,CAAC;IAED,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,CAAC,IAAI,CACT,qBAAqB,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE;YACpD,IAAI,EAAE,UAAU,CAAC,eAAe,IAAI,MAAM;YAC1C,MAAM,EAAE,UAAU,CAAC,WAAW;YAC9B,WAAW,EAAE,UAAU,CAAC,WAAW;YACnC,SAAS,EAAE,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,YAAY,CAAC,QAAQ,GAAG;SACrF,CAAC,CACH,CAAA;IACH,CAAC;IAED,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACzD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAE,CAAA;QACjC,MAAM,CAAC,IAAI,CACT,YAAY,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,QAAQ,WAAW,aAAa,CAAC,QAAQ,CAAC,iBAAiB,aAAa,CAAC,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CACzK,CAAA;IACH,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACrB,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACxB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ResolvedShapeShadow } from '../types.js';
2
+ export declare function createSvgShadowFilter(shadow: ResolvedShapeShadow, filterRegion: {
3
+ x: number;
4
+ y: number;
5
+ width: number;
6
+ height: number;
7
+ }): {
8
+ filterId: string;
9
+ markup: string;
10
+ };
@@ -0,0 +1,16 @@
1
+ import { escapeXmlText } from './escape-xml-text.js';
2
+ function hashString(value) {
3
+ let hash = 0;
4
+ for (let index = 0; index < value.length; index++) {
5
+ hash = (hash * 31 + value.charCodeAt(index)) >>> 0;
6
+ }
7
+ return hash.toString(36);
8
+ }
9
+ export function createSvgShadowFilter(shadow, filterRegion) {
10
+ const filterId = `shape-text-shape-shadow-${hashString(JSON.stringify(shadow))}`;
11
+ return {
12
+ filterId,
13
+ markup: `<defs><filter id="${filterId}" filterUnits="userSpaceOnUse" x="${filterRegion.x}" y="${filterRegion.y}" width="${filterRegion.width}" height="${filterRegion.height}"><feDropShadow dx="${shadow.offsetX}" dy="${shadow.offsetY}" stdDeviation="${shadow.blur}" flood-color="${escapeXmlText(shadow.color)}" /></filter></defs>`,
14
+ };
15
+ }
16
+ //# sourceMappingURL=render-svg-shadow-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-svg-shadow-filter.js","sourceRoot":"","sources":["../../src/render/render-svg-shadow-filter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,IAAI,GAAG,CAAC,CAAA;IAEZ,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QAClD,IAAI,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAA;IACpD,CAAC;IAED,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;AAC1B,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,MAA2B,EAC3B,YAKC;IAKD,MAAM,QAAQ,GAAG,2BAA2B,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAA;IAEhF,OAAO;QACL,QAAQ;QACR,MAAM,EAAE,qBAAqB,QAAQ,qCAAqC,YAAY,CAAC,CAAC,QAAQ,YAAY,CAAC,CAAC,YAAY,YAAY,CAAC,KAAK,aAAa,YAAY,CAAC,MAAM,uBAAuB,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,OAAO,mBAAmB,MAAM,CAAC,IAAI,kBAAkB,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,sBAAsB;KAC1U,CAAA;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { CompiledShapeBand } from '../types.js';
2
+ export type TextMaskAlphaBandsOptions = {
3
+ width: number;
4
+ height: number;
5
+ maskScale: number;
6
+ alphaThreshold: number;
7
+ };
8
+ export declare function buildTextMaskBandsFromAlpha(options: TextMaskAlphaBandsOptions, alpha: Uint8ClampedArray, lineHeight: number, minSlotWidth: number): CompiledShapeBand[];
@@ -0,0 +1,73 @@
1
+ function intersectIntervalSets(leftSet, rightSet) {
2
+ const intersections = [];
3
+ let leftIndex = 0;
4
+ let rightIndex = 0;
5
+ while (leftIndex < leftSet.length && rightIndex < rightSet.length) {
6
+ const left = leftSet[leftIndex];
7
+ const right = rightSet[rightIndex];
8
+ const overlapLeft = Math.max(left.left, right.left);
9
+ const overlapRight = Math.min(left.right, right.right);
10
+ if (overlapRight > overlapLeft) {
11
+ intersections.push({ left: overlapLeft, right: overlapRight });
12
+ }
13
+ if (left.right < right.right) {
14
+ leftIndex += 1;
15
+ }
16
+ else {
17
+ rightIndex += 1;
18
+ }
19
+ }
20
+ return intersections;
21
+ }
22
+ function getRowIntervals(alpha, row, width, alphaThreshold) {
23
+ const intervals = [];
24
+ let start = -1;
25
+ const rowOffset = row * width * 4;
26
+ for (let x = 0; x < width; x++) {
27
+ const isSolid = alpha[rowOffset + x * 4 + 3] >= alphaThreshold;
28
+ if (isSolid && start < 0) {
29
+ start = x;
30
+ continue;
31
+ }
32
+ if (!isSolid && start >= 0) {
33
+ intervals.push({ left: start, right: x });
34
+ start = -1;
35
+ }
36
+ }
37
+ if (start >= 0) {
38
+ intervals.push({ left: start, right: width });
39
+ }
40
+ return intervals;
41
+ }
42
+ export function buildTextMaskBandsFromAlpha(options, alpha, lineHeight, minSlotWidth) {
43
+ const pixelWidth = Math.max(1, Math.ceil(options.width * options.maskScale));
44
+ const bands = [];
45
+ for (let bandTop = 0; bandTop + lineHeight <= options.height; bandTop += lineHeight) {
46
+ const startRow = Math.floor(bandTop * options.maskScale);
47
+ const endRow = Math.max(startRow, Math.ceil((bandTop + lineHeight) * options.maskScale) - 1);
48
+ let intervals = null;
49
+ for (let row = startRow; row <= endRow; row++) {
50
+ const rowIntervals = getRowIntervals(alpha, row, pixelWidth, options.alphaThreshold);
51
+ if (rowIntervals.length === 0) {
52
+ intervals = [];
53
+ break;
54
+ }
55
+ intervals = intervals === null ? rowIntervals : intersectIntervalSets(intervals, rowIntervals);
56
+ if (intervals.length === 0) {
57
+ break;
58
+ }
59
+ }
60
+ bands.push({
61
+ top: bandTop,
62
+ bottom: bandTop + lineHeight,
63
+ intervals: (intervals ?? [])
64
+ .map(interval => ({
65
+ left: interval.left / options.maskScale,
66
+ right: interval.right / options.maskScale,
67
+ }))
68
+ .filter(interval => interval.right - interval.left >= minSlotWidth),
69
+ });
70
+ }
71
+ return bands;
72
+ }
73
+ //# sourceMappingURL=build-text-mask-bands-from-alpha.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-text-mask-bands-from-alpha.js","sourceRoot":"","sources":["../../src/shape/build-text-mask-bands-from-alpha.ts"],"names":[],"mappings":"AASA,SAAS,qBAAqB,CAAC,OAAmB,EAAE,QAAoB;IACtE,MAAM,aAAa,GAAe,EAAE,CAAA;IACpC,IAAI,SAAS,GAAG,CAAC,CAAA;IACjB,IAAI,UAAU,GAAG,CAAC,CAAA;IAElB,OAAO,SAAS,GAAG,OAAO,CAAC,MAAM,IAAI,UAAU,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;QAClE,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAE,CAAA;QAChC,MAAM,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAE,CAAA;QACnC,MAAM,WAAW,GAAG,IAAI,CAAC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CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,qBAAqB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAA;YAC9F,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC3B,MAAK;YACP,CAAC;QACH,CAAC;QAED,KAAK,CAAC,IAAI,CAAC;YACT,GAAG,EAAE,OAAO;YACZ,MAAM,EAAE,OAAO,GAAG,UAAU;YAC5B,SAAS,EAAE,CAAC,SAAS,IAAI,EAAE,CAAC;iBACzB,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;gBAChB,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAC,SAAS;gBACvC,KAAK,EAAE,QAAQ,CAAC,KAAK,GAAG,OAAO,CAAC,SAAS;aAC1C,CAAC,CAAC;iBACF,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,IAAI,YAAY,CAAC;SACtE,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { CompiledShapeBands, PolygonShape } from '../types.js';
2
+ export declare function compilePolygonShapeForLayout(shape: PolygonShape, lineHeight: number, minSlotWidth: number): CompiledShapeBands;
@@ -0,0 +1,26 @@
1
+ import { getBandIntervalsFromPolygon } from '../geometry/get-band-intervals-from-polygon.js';
2
+ import { getPolygonBounds } from '../geometry/get-polygon-bounds.js';
3
+ export function compilePolygonShapeForLayout(shape, lineHeight, minSlotWidth) {
4
+ const bounds = getPolygonBounds(shape.points);
5
+ const bands = [];
6
+ for (let bandTop = bounds.top; bandTop + lineHeight <= bounds.bottom; bandTop += lineHeight) {
7
+ bands.push({
8
+ top: bandTop,
9
+ bottom: bandTop + lineHeight,
10
+ intervals: getBandIntervalsFromPolygon(shape.points, bandTop, bandTop + lineHeight, minSlotWidth),
11
+ });
12
+ }
13
+ return {
14
+ kind: shape.kind,
15
+ source: shape,
16
+ bounds,
17
+ bandHeight: lineHeight,
18
+ minSlotWidth,
19
+ bands,
20
+ debugView: {
21
+ kind: 'polygon',
22
+ points: shape.points,
23
+ },
24
+ };
25
+ }
26
+ //# sourceMappingURL=compile-polygon-shape-for-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-polygon-shape-for-layout.js","sourceRoot":"","sources":["../../src/shape/compile-polygon-shape-for-layout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAA;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAEpE,MAAM,UAAU,4BAA4B,CAC1C,KAAmB,EACnB,UAAkB,EAClB,YAAoB;IAEpB,MAAM,MAAM,GAAG,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC7C,MAAM,KAAK,GAAG,EAAE,CAAA;IAEhB,KAAK,IAAI,OAAO,GAAG,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,IAAI,UAAU,EAAE,CAAC;QAC5F,KAAK,CAAC,IAAI,CAAC;YACT,GAAG,EAAE,OAAO;YACZ,MAAM,EAAE,OAAO,GAAG,UAAU;YAC5B,SAAS,EAAE,2BAA2B,CACpC,KAAK,CAAC,MAAM,EACZ,OAAO,EACP,OAAO,GAAG,UAAU,EACpB,YAAY,CACb;SACF,CAAC,CAAA;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,KAAK;QACb,MAAM;QACN,UAAU,EAAE,UAAU;QACtB,YAAY;QACZ,KAAK;QACL,SAAS,EAAE;YACT,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,KAAK,CAAC,MAAM;SACrB;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { CompiledShapeBands, CompileShapeForLayoutOptions } from '../types.js';
2
+ export declare function compileShapeForLayout(options: CompileShapeForLayoutOptions): CompiledShapeBands;
@@ -0,0 +1,18 @@
1
+ import { compilePolygonShapeForLayout } from './compile-polygon-shape-for-layout.js';
2
+ import { compileTextMaskShapeForLayout } from './compile-text-mask-shape-for-layout.js';
3
+ export function compileShapeForLayout(options) {
4
+ if (!Number.isFinite(options.lineHeight) || options.lineHeight <= 0) {
5
+ throw new Error('lineHeight must be a finite positive number');
6
+ }
7
+ const minSlotWidth = options.minSlotWidth ?? Math.max(16, options.lineHeight * 0.8);
8
+ if (!Number.isFinite(minSlotWidth) || minSlotWidth < 0) {
9
+ throw new Error('minSlotWidth must be a finite non-negative number');
10
+ }
11
+ switch (options.shape.kind) {
12
+ case 'polygon':
13
+ return compilePolygonShapeForLayout(options.shape, options.lineHeight, minSlotWidth);
14
+ case 'text-mask':
15
+ return compileTextMaskShapeForLayout(options.shape, options.lineHeight, minSlotWidth);
16
+ }
17
+ }
18
+ //# sourceMappingURL=compile-shape-for-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-shape-for-layout.js","sourceRoot":"","sources":["../../src/shape/compile-shape-for-layout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAA;AACpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAA;AAEvF,MAAM,UAAU,qBAAqB,CACnC,OAAqC;IAErC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,EAAE,CAAC;QACpE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;IAChE,CAAC;IAED,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,UAAU,GAAG,GAAG,CAAC,CAAA;IACnF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAA;IACtE,CAAC;IAED,QAAQ,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAC3B,KAAK,SAAS;YACZ,OAAO,4BAA4B,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;QAEtF,KAAK,WAAW;YACd,OAAO,6BAA6B,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;IACzF,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { CompiledShapeBands, TextMaskShape } from '../types.js';
2
+ export declare function compileTextMaskShapeForLayout(shape: TextMaskShape, lineHeight: number, minSlotWidth: number): CompiledShapeBands;