@next2d/renderer 2.0.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 (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -0
  3. package/package.json +31 -0
  4. package/src/Command/service/CommandInitializeContextService.d.ts +11 -0
  5. package/src/Command/service/CommandInitializeContextService.js +27 -0
  6. package/src/Command/service/CommandRemoveCacheService.d.ts +10 -0
  7. package/src/Command/service/CommandRemoveCacheService.js +24 -0
  8. package/src/Command/service/CommandResizeService.d.ts +12 -0
  9. package/src/Command/service/CommandResizeService.js +27 -0
  10. package/src/Command/usecase/CommandCaptureUseCase.d.ts +13 -0
  11. package/src/Command/usecase/CommandCaptureUseCase.js +53 -0
  12. package/src/Command/usecase/CommandRenderUseCase.d.ts +11 -0
  13. package/src/Command/usecase/CommandRenderUseCase.js +70 -0
  14. package/src/CommandController.d.ts +38 -0
  15. package/src/CommandController.js +102 -0
  16. package/src/DisplayObject/service/DisplayObjectGetBlendModeService.d.ts +11 -0
  17. package/src/DisplayObject/service/DisplayObjectGetBlendModeService.js +45 -0
  18. package/src/DisplayObjectContainer/usecase/DisplayObjectContainerClipRenderUseCase.d.ts +11 -0
  19. package/src/DisplayObjectContainer/usecase/DisplayObjectContainerClipRenderUseCase.js +29 -0
  20. package/src/DisplayObjectContainer/usecase/DisplayObjectContainerRenderUseCase.d.ts +12 -0
  21. package/src/DisplayObjectContainer/usecase/DisplayObjectContainerRenderUseCase.js +120 -0
  22. package/src/RendererUtil.d.ts +136 -0
  23. package/src/RendererUtil.js +214 -0
  24. package/src/Shape/service/ShapeCommandService.d.ts +11 -0
  25. package/src/Shape/service/ShapeCommandService.js +252 -0
  26. package/src/Shape/usecase/ShapeClipRenderUseCase.d.ts +11 -0
  27. package/src/Shape/usecase/ShapeClipRenderUseCase.js +33 -0
  28. package/src/Shape/usecase/ShapeRenderUseCase.d.ts +11 -0
  29. package/src/Shape/usecase/ShapeRenderUseCase.js +154 -0
  30. package/src/TextField/service/TextFieldGenerateFontStyleService.d.ts +11 -0
  31. package/src/TextField/service/TextFieldGenerateFontStyleService.js +19 -0
  32. package/src/TextField/service/TextFiledGetAlignOffsetService.d.ts +15 -0
  33. package/src/TextField/service/TextFiledGetAlignOffsetService.js +33 -0
  34. package/src/TextField/usecase/TextFieldDrawOffscreenCanvasUseCase.d.ts +15 -0
  35. package/src/TextField/usecase/TextFieldDrawOffscreenCanvasUseCase.js +272 -0
  36. package/src/TextField/usecase/TextFieldRenderUseCase.d.ts +11 -0
  37. package/src/TextField/usecase/TextFieldRenderUseCase.js +150 -0
  38. package/src/Video/usecase/VideoRenderUseCase.d.ts +12 -0
  39. package/src/Video/usecase/VideoRenderUseCase.js +88 -0
  40. package/src/index.d.ts +2 -0
  41. package/src/index.js +26 -0
  42. package/src/interface/IBlendMode.d.ts +1 -0
  43. package/src/interface/IBlendMode.js +1 -0
  44. package/src/interface/IMessage.d.ts +11 -0
  45. package/src/interface/IMessage.js +1 -0
  46. package/src/interface/INode.d.ts +7 -0
  47. package/src/interface/INode.js +1 -0
  48. package/src/interface/IRGBA.d.ts +6 -0
  49. package/src/interface/IRGBA.js +1 -0
  50. package/src/interface/ITextData.d.ts +8 -0
  51. package/src/interface/ITextData.js +1 -0
  52. package/src/interface/ITextFieldAutoSize.d.ts +1 -0
  53. package/src/interface/ITextFieldAutoSize.js +1 -0
  54. package/src/interface/ITextFormat.d.ts +14 -0
  55. package/src/interface/ITextFormat.js +1 -0
  56. package/src/interface/ITextFormatAlign.d.ts +1 -0
  57. package/src/interface/ITextFormatAlign.js +1 -0
  58. package/src/interface/ITextObject.d.ts +12 -0
  59. package/src/interface/ITextObject.js +1 -0
  60. package/src/interface/ITextObjectMode.d.ts +1 -0
  61. package/src/interface/ITextObjectMode.js +1 -0
  62. package/src/interface/ITextSetting.d.ts +25 -0
  63. package/src/interface/ITextSetting.js +1 -0
@@ -0,0 +1,252 @@
1
+ import { $context, $getArray } from "../../RendererUtil";
2
+ /**
3
+ * @type {number}
4
+ * @private
5
+ */
6
+ const MOVE_TO = 0;
7
+ /**
8
+ * @type {number}
9
+ * @private
10
+ */
11
+ const CURVE_TO = 1;
12
+ /**
13
+ * @type {number}
14
+ * @private
15
+ */
16
+ const LINE_TO = 2;
17
+ /**
18
+ * @type {number}
19
+ * @private
20
+ */
21
+ const CUBIC = 3;
22
+ /**
23
+ * @type {number}
24
+ * @private
25
+ */
26
+ const ARC = 4;
27
+ /**
28
+ * @type {number}
29
+ * @private
30
+ */
31
+ const FILL_STYLE = 5;
32
+ /**
33
+ * @type {number}
34
+ * @private
35
+ */
36
+ const STROKE_STYLE = 6;
37
+ /**
38
+ * @type {number}
39
+ * @private
40
+ */
41
+ const END_FILL = 7;
42
+ /**
43
+ * @type {number}
44
+ * @private
45
+ */
46
+ const END_STROKE = 8;
47
+ /**
48
+ * @type {number}
49
+ * @private
50
+ */
51
+ const BEGIN_PATH = 9;
52
+ /**
53
+ * @type {number}
54
+ * @private
55
+ */
56
+ const GRADIENT_FILL = 10;
57
+ /**
58
+ * @type {number}
59
+ * @private
60
+ */
61
+ const GRADIENT_STROKE = 11;
62
+ /**
63
+ * @type {number}
64
+ * @private
65
+ */
66
+ const CLOSE_PATH = 12;
67
+ /**
68
+ * @type {number}
69
+ * @private
70
+ */
71
+ const BITMAP_FILL = 13;
72
+ /**
73
+ * @type {number}
74
+ * @private
75
+ */
76
+ const BITMAP_STROKE = 14;
77
+ /**
78
+ * @description Shapeのグラフィックコマンドを実行します。
79
+ * Execute the graphic commands of Shape.
80
+ *
81
+ * @param {Float32Array} commands
82
+ * @param {boolean} [is_clip=false]
83
+ * @return {void}
84
+ * @method
85
+ * @protected
86
+ */
87
+ export const execute = (commands, is_clip = false) => {
88
+ let index = 0;
89
+ while (commands.length > index) {
90
+ switch (commands[index++]) {
91
+ case BEGIN_PATH:
92
+ $context.beginPath();
93
+ break;
94
+ case MOVE_TO:
95
+ $context.moveTo(commands[index++], commands[index++]);
96
+ break;
97
+ case LINE_TO:
98
+ $context.lineTo(commands[index++], commands[index++]);
99
+ break;
100
+ case CURVE_TO:
101
+ $context.quadraticCurveTo(commands[index++], commands[index++], commands[index++], commands[index++]);
102
+ break;
103
+ case FILL_STYLE:
104
+ if (is_clip) {
105
+ index += 4;
106
+ break;
107
+ }
108
+ $context.fillStyle(commands[index++] / 255, commands[index++] / 255, commands[index++] / 255, commands[index++] / 255);
109
+ break;
110
+ case END_FILL:
111
+ $context.fill();
112
+ break;
113
+ case STROKE_STYLE:
114
+ if (is_clip) {
115
+ index += 8;
116
+ break;
117
+ }
118
+ $context.thickness = commands[index++];
119
+ $context.caps = commands[index++];
120
+ $context.joints = commands[index++];
121
+ $context.miterLimit = commands[index++];
122
+ $context.strokeStyle(commands[index++] / 255, commands[index++] / 255, commands[index++] / 255, commands[index++] / 255);
123
+ break;
124
+ case END_STROKE:
125
+ if (is_clip) {
126
+ break;
127
+ }
128
+ $context.stroke();
129
+ break;
130
+ case CLOSE_PATH:
131
+ $context.closePath();
132
+ break;
133
+ case ARC:
134
+ $context.arc(commands[index++], commands[index++], commands[index++]);
135
+ break;
136
+ case CUBIC:
137
+ $context.bezierCurveTo(commands[index++], commands[index++], commands[index++], commands[index++], commands[index++], commands[index++]);
138
+ break;
139
+ case GRADIENT_FILL:
140
+ {
141
+ if (is_clip) {
142
+ index += 1;
143
+ const length = commands[index++];
144
+ index += length * 5;
145
+ index += 9;
146
+ $context.fill();
147
+ break;
148
+ }
149
+ const type = commands[index++];
150
+ const stops = $getArray();
151
+ const length = commands[index++];
152
+ for (let idx = 0; idx < length; ++idx) {
153
+ stops.push(commands[index++], // ratio
154
+ commands[index++], // red
155
+ commands[index++], // green
156
+ commands[index++], // blue
157
+ commands[index++] // alpha
158
+ );
159
+ }
160
+ const matrix = new Float32Array([
161
+ commands[index++], commands[index++], commands[index++],
162
+ commands[index++], commands[index++], commands[index++]
163
+ ]);
164
+ const spread = commands[index++];
165
+ const interpolation = commands[index++];
166
+ const focal = commands[index++];
167
+ $context.gradientFill(type, stops, matrix, spread, interpolation, focal);
168
+ }
169
+ break;
170
+ case BITMAP_FILL:
171
+ {
172
+ if (is_clip) {
173
+ index += 2;
174
+ const length = commands[index++];
175
+ index += length;
176
+ index += 8;
177
+ $context.fill();
178
+ break;
179
+ }
180
+ const width = commands[index++];
181
+ const height = commands[index++];
182
+ const length = commands[index++];
183
+ const buffer = new Uint8Array(commands.subarray(index, index + length));
184
+ index += length;
185
+ const matrix = new Float32Array([
186
+ commands[index++], commands[index++], commands[index++],
187
+ commands[index++], commands[index++], commands[index++]
188
+ ]);
189
+ $context.bitmapFill(buffer, matrix, width, height, Boolean(commands[index++]), Boolean(commands[index++]));
190
+ }
191
+ break;
192
+ case GRADIENT_STROKE:
193
+ {
194
+ if (is_clip) {
195
+ index += 20;
196
+ $context.fill();
197
+ break;
198
+ }
199
+ $context.thickness = commands[index++];
200
+ $context.caps = commands[index++];
201
+ $context.joints = commands[index++];
202
+ $context.miterLimit = commands[index++];
203
+ const type = commands[index++];
204
+ const stops = $getArray();
205
+ const length = commands[index++];
206
+ for (let idx = 0; idx < length; ++idx) {
207
+ stops.push(commands[index++], // ratio
208
+ commands[index++], // red
209
+ commands[index++], // green
210
+ commands[index++], // blue
211
+ commands[index++] // alpha
212
+ );
213
+ }
214
+ const matrix = new Float32Array([
215
+ commands[index++], commands[index++], commands[index++],
216
+ commands[index++], commands[index++], commands[index++]
217
+ ]);
218
+ const spread = commands[index++];
219
+ const interpolation = commands[index++];
220
+ const focal = commands[index++];
221
+ $context.gradientStroke(type, stops, matrix, spread, interpolation, focal);
222
+ }
223
+ break;
224
+ case BITMAP_STROKE:
225
+ {
226
+ if (is_clip) {
227
+ index += 6;
228
+ const length = commands[index++];
229
+ index += length;
230
+ index += 8;
231
+ $context.fill();
232
+ break;
233
+ }
234
+ $context.thickness = commands[index++];
235
+ $context.caps = commands[index++];
236
+ $context.joints = commands[index++];
237
+ $context.miterLimit = commands[index++];
238
+ const width = commands[index++];
239
+ const height = commands[index++];
240
+ const length = commands[index++];
241
+ const buffer = new Uint8Array(commands.subarray(index, index + length));
242
+ index += length;
243
+ const matrix = new Float32Array([
244
+ commands[index++], commands[index++], commands[index++],
245
+ commands[index++], commands[index++], commands[index++]
246
+ ]);
247
+ $context.bitmapStroke(buffer, matrix, width, height, Boolean(commands[index++]), Boolean(commands[index++]));
248
+ }
249
+ break;
250
+ }
251
+ }
252
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @description シェイプクリップの描画を実行
3
+ * Execute drawing of shape clip
4
+ *
5
+ * @param {Float32Array} render_queue
6
+ * @param {number} index
7
+ * @return {number}
8
+ * @method
9
+ * @protected
10
+ */
11
+ export declare const execute: (render_queue: Float32Array, index: number) => number;
@@ -0,0 +1,33 @@
1
+ import { execute as shapeCommandService } from "../service/ShapeCommandService";
2
+ import { $context } from "../../RendererUtil";
3
+ /**
4
+ * @description シェイプクリップの描画を実行
5
+ * Execute drawing of shape clip
6
+ *
7
+ * @param {Float32Array} render_queue
8
+ * @param {number} index
9
+ * @return {number}
10
+ * @method
11
+ * @protected
12
+ */
13
+ export const execute = (render_queue, index) => {
14
+ const matrix = render_queue.subarray(index, index + 6);
15
+ index += 6;
16
+ $context.reset();
17
+ $context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
18
+ const isGridEnabled = Boolean(render_queue[index++]);
19
+ const gridData = isGridEnabled
20
+ ? new Float32Array(28)
21
+ : null;
22
+ $context.useGrid(gridData);
23
+ if (gridData) {
24
+ gridData.set(render_queue.subarray(index, index + 24));
25
+ index += 24;
26
+ }
27
+ const length = render_queue[index++];
28
+ const commands = render_queue.subarray(index, index + length);
29
+ shapeCommandService(commands, true);
30
+ index += length;
31
+ $context.clip();
32
+ return index;
33
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @description Shapeの描画を実行します。
3
+ * Execute the drawing of Shape.
4
+ *
5
+ * @param {Float32Array} render_queue
6
+ * @param {number} index
7
+ * @return {number}
8
+ * @method
9
+ * @protected
10
+ */
11
+ export declare const execute: (render_queue: Float32Array, index: number) => number;
@@ -0,0 +1,154 @@
1
+ import { $cacheStore } from "@next2d/cache";
2
+ import { execute as shapeCommandService } from "../service/ShapeCommandService";
3
+ import { execute as displayObjectGetBlendModeService } from "../../DisplayObject/service/DisplayObjectGetBlendModeService";
4
+ import { $context } from "../../RendererUtil";
5
+ /**
6
+ * @description Shapeの描画を実行します。
7
+ * Execute the drawing of Shape.
8
+ *
9
+ * @param {Float32Array} render_queue
10
+ * @param {number} index
11
+ * @return {number}
12
+ * @method
13
+ * @protected
14
+ */
15
+ export const execute = (render_queue, index) => {
16
+ const matrix = render_queue.subarray(index, index + 6);
17
+ index += 6;
18
+ const colorTransform = render_queue.subarray(index, index + 8);
19
+ index += 8;
20
+ const bounds = render_queue.subarray(index, index + 4);
21
+ index += 4;
22
+ // baseBounds
23
+ const xMin = render_queue[index++];
24
+ const yMin = render_queue[index++];
25
+ const xMax = render_queue[index++];
26
+ const yMax = render_queue[index++];
27
+ const isGridEnabled = Boolean(render_queue[index++]);
28
+ const isDrawable = Boolean(render_queue[index++]);
29
+ const isBitmap = Boolean(render_queue[index++]);
30
+ // cache uniqueKey
31
+ const uniqueKey = `${render_queue[index++]}`;
32
+ const cacheKey = render_queue[index++];
33
+ const xScale = Math.round(Math.sqrt(matrix[0] * matrix[0]
34
+ + matrix[1] * matrix[1]) * 10000) / 10000;
35
+ const yScale = Math.round(Math.sqrt(matrix[2] * matrix[2]
36
+ + matrix[3] * matrix[3]) * 10000) / 10000;
37
+ let node;
38
+ const hasCache = render_queue[index++];
39
+ if (!hasCache) {
40
+ const gridData = isGridEnabled
41
+ ? new Float32Array(28)
42
+ : null;
43
+ if (gridData) {
44
+ gridData.set(render_queue.subarray(index, index + 24));
45
+ index += 24;
46
+ }
47
+ $context.useGrid(gridData);
48
+ const length = render_queue[index++];
49
+ const commands = render_queue.subarray(index, index + length);
50
+ if (isBitmap && !isGridEnabled) {
51
+ // Bitmapなので、スケールなし
52
+ const width = Math.ceil(Math.abs(xMax - xMin));
53
+ const height = Math.ceil(Math.abs(yMax - yMin));
54
+ // fixed logic
55
+ node = $context.createNode(width, height);
56
+ $cacheStore.set(uniqueKey, `${cacheKey}`, node);
57
+ // fixed logic
58
+ const currentAttachment = $context.currentAttachmentObject;
59
+ $context.bind($context.atlasAttachmentObject);
60
+ $context.reset();
61
+ $context.beginNodeRendering(node);
62
+ const offsetY = $context.atlasAttachmentObject.height - node.y - height;
63
+ $context.setTransform(1, 0, 0, 1, node.x, offsetY);
64
+ if (isDrawable) {
65
+ shapeCommandService(commands);
66
+ $context.drawFill();
67
+ }
68
+ else {
69
+ $context.drawPixels(node, new Uint8Array(commands));
70
+ }
71
+ $context.endNodeRendering();
72
+ if (currentAttachment) {
73
+ $context.bind(currentAttachment);
74
+ }
75
+ }
76
+ else {
77
+ const width = Math.ceil(Math.abs(xMax - xMin) * xScale);
78
+ const height = Math.ceil(Math.abs(yMax - yMin) * yScale);
79
+ // fixed logic
80
+ node = $context.createNode(width, height);
81
+ $cacheStore.set(uniqueKey, `${cacheKey}`, node);
82
+ // fixed logic
83
+ const currentAttachment = $context.currentAttachmentObject;
84
+ $context.bind($context.atlasAttachmentObject);
85
+ // 初期化して、描画範囲を初期化
86
+ $context.reset();
87
+ $context.beginNodeRendering(node);
88
+ // matrix設定
89
+ const offsetY = $context.atlasAttachmentObject.height - node.y - height;
90
+ $context.setTransform(xScale, 0, 0, yScale, -xMin * xScale + node.x, -yMin * yScale + offsetY);
91
+ if (gridData) {
92
+ gridData[24] = node.x;
93
+ gridData[25] = offsetY;
94
+ }
95
+ // 描画コマンドを実行
96
+ shapeCommandService(commands);
97
+ // 描画実行
98
+ $context.drawFill();
99
+ // 描画終了
100
+ $context.endNodeRendering();
101
+ if (currentAttachment) {
102
+ $context.bind(currentAttachment);
103
+ }
104
+ }
105
+ index += length;
106
+ }
107
+ else {
108
+ node = $cacheStore.get(uniqueKey, `${cacheKey}`);
109
+ if (!node) {
110
+ return index;
111
+ }
112
+ }
113
+ const blendMode = render_queue[index++];
114
+ // フィルター設定があればフィルターを実行
115
+ const useFilfer = Boolean(render_queue[index++]);
116
+ if (useFilfer) {
117
+ const updated = Boolean(render_queue[index++]);
118
+ const filterBounds = render_queue.subarray(index, index + 4);
119
+ index += 4;
120
+ const length = render_queue[index++];
121
+ const params = render_queue.subarray(index, index + length);
122
+ const width = Math.ceil(Math.abs(bounds[2] - bounds[0]));
123
+ const height = Math.ceil(Math.abs(bounds[3] - bounds[1]));
124
+ $context.applyFilter(node, uniqueKey, updated, width, height, isBitmap, matrix, colorTransform, displayObjectGetBlendModeService(blendMode), filterBounds, params);
125
+ index += length;
126
+ return index;
127
+ }
128
+ $context.globalAlpha = Math.min(Math.max(0, colorTransform[3] + colorTransform[7] / 255), 1);
129
+ $context.imageSmoothingEnabled = true;
130
+ $context.globalCompositeOperation = displayObjectGetBlendModeService(blendMode);
131
+ if (isBitmap && !isGridEnabled) {
132
+ $context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
133
+ $context.drawDisplayObject(node, bounds[0], bounds[1], bounds[2], bounds[3], colorTransform);
134
+ }
135
+ else {
136
+ const radianX = Math.atan2(matrix[1], matrix[0]);
137
+ const radianY = Math.atan2(-matrix[2], matrix[3]);
138
+ if (radianX || radianY) {
139
+ const tx = xMin * xScale;
140
+ const ty = yMin * yScale;
141
+ const cosX = Math.cos(radianX);
142
+ const sinX = Math.sin(radianX);
143
+ const cosY = Math.cos(radianY);
144
+ const sinY = Math.sin(radianY);
145
+ $context.setTransform(cosX, sinX, -sinY, cosY, tx * cosX - ty * sinY + matrix[4], tx * sinX + ty * cosY + matrix[5]);
146
+ }
147
+ else {
148
+ $context.setTransform(1, 0, 0, 1, bounds[0], bounds[1]);
149
+ }
150
+ // 描画範囲をinstanced arrayに設定
151
+ $context.drawDisplayObject(node, bounds[0], bounds[1], bounds[2], bounds[3], colorTransform);
152
+ }
153
+ return index;
154
+ };
@@ -0,0 +1,11 @@
1
+ import type { ITextFormat } from "../../interface/ITextFormat";
2
+ /**
3
+ * @description テキストフォーマットを元にフォントスタイルを生成します。
4
+ * Generate font style based on text format.
5
+ *
6
+ * @param {ITextFormat} text_format
7
+ * @return {string}
8
+ * @method
9
+ * @protected
10
+ */
11
+ export declare const execute: (text_format: ITextFormat) => string;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @description テキストフォーマットを元にフォントスタイルを生成します。
3
+ * Generate font style based on text format.
4
+ *
5
+ * @param {ITextFormat} text_format
6
+ * @return {string}
7
+ * @method
8
+ * @protected
9
+ */
10
+ export const execute = (text_format) => {
11
+ let fontStyle = "";
12
+ if (text_format.italic) {
13
+ fontStyle += "italic ";
14
+ }
15
+ if (text_format.bold) {
16
+ fontStyle += "bold ";
17
+ }
18
+ return `${fontStyle}${text_format.size}px '${text_format.font}','sans-serif'`;
19
+ };
@@ -0,0 +1,15 @@
1
+ import type { ITextData } from "../../interface/ITextData";
2
+ import type { ITextObject } from "../../interface/ITextObject";
3
+ import type { ITextSetting } from "../../interface/ITextSetting";
4
+ /**
5
+ * @description テキストの揃え位置のオフセット値を取得します。
6
+ * Get the offset value of the alignment position of the text.
7
+ *
8
+ * @param {ITextData} text_data
9
+ * @param {ITextObject} text_object
10
+ * @param {ITextSetting} text_setting
11
+ * @return {number}
12
+ * @method
13
+ * @protected
14
+ */
15
+ export declare const execute: (text_data: ITextData, text_object: ITextObject, text_setting: ITextSetting) => number;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @description テキストの揃え位置のオフセット値を取得します。
3
+ * Get the offset value of the alignment position of the text.
4
+ *
5
+ * @param {ITextData} text_data
6
+ * @param {ITextObject} text_object
7
+ * @param {ITextSetting} text_setting
8
+ * @return {number}
9
+ * @method
10
+ * @protected
11
+ */
12
+ export const execute = (text_data, text_object, text_setting) => {
13
+ const lineWidth = text_data.widthTable[text_object.line] || 0;
14
+ const textFormat = text_object.textFormat;
15
+ const leftMargin = textFormat.leftMargin || 0;
16
+ if (!text_setting.wordWrap && lineWidth > text_setting.rawWidth) {
17
+ return Math.max(0, leftMargin);
18
+ }
19
+ const rightMargin = textFormat.rightMargin || 0;
20
+ if (textFormat.align === "center" // format CENTER
21
+ || text_setting.autoSize === "center" // autoSize CENTER
22
+ ) {
23
+ return Math.max(0, text_setting.rawWidth / 2 - leftMargin - rightMargin - lineWidth / 2 - 2);
24
+ }
25
+ if (textFormat.align === "right" // format RIGHT
26
+ || text_setting.autoSize === "right" // autoSize RIGHT
27
+ ) {
28
+ return Math.max(0, text_setting.rawWidth - leftMargin - lineWidth - rightMargin - 4);
29
+ }
30
+ // autoSize LEFT
31
+ // format LEFT
32
+ return Math.max(0, leftMargin);
33
+ };
@@ -0,0 +1,15 @@
1
+ import type { ITextData } from "../../interface/ITextData";
2
+ import type { ITextSetting } from "../../interface/ITextSetting";
3
+ /**
4
+ * @description TextDataを元にOffscreenCanvasにテキストを描画
5
+ * Draw text in OffscreenCanvas based on TextData
6
+ *
7
+ * @param {ITextData} text_data
8
+ * @param {object} text_setting
9
+ * @param {number} x_scale
10
+ * @param {number} y_scale
11
+ * @return {OffscreenCanvas}
12
+ * @method
13
+ * @protected
14
+ */
15
+ export declare const execute: (text_data: ITextData | null, text_setting: ITextSetting, x_scale: number, y_scale: number) => OffscreenCanvas;