@next2d/player 1.14.9 → 1.14.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/player/index.js +5 -3
- package/dist/player/next2d/display/GraphicsGradientFill.d.ts +1 -1
- package/dist/player/next2d/display/GraphicsGradientFill.js +6 -2
- package/dist/player/next2d/display/Loader.d.ts +1 -1
- package/dist/player/player/Next2D.d.ts +1 -2
- package/dist/player/player/Next2D.js +7 -11
- package/package.json +1 -1
- package/dist/interface/ClassNameMap.d.ts +0 -4
- package/dist/interface/ClassNameMap.js +0 -1
- package/dist/interface/RenderDisplayObjectImpl.d.ts +0 -2
- package/dist/interface/RenderDisplayObjectImpl.js +0 -1
- package/dist/interface/TextFormatImpl.d.ts +0 -16
- package/dist/interface/TextFormatImpl.js +0 -1
- package/dist/interface/TextModeImpl.d.ts +0 -1
- package/dist/interface/TextModeImpl.js +0 -1
- package/dist/renderer/RenderDisplayObject.d.ts +0 -129
- package/dist/renderer/RenderDisplayObject.js +0 -567
- package/dist/renderer/RenderDisplayObjectContainer.d.ts +0 -70
- package/dist/renderer/RenderDisplayObjectContainer.js +0 -670
- package/dist/renderer/RenderGlobal.d.ts +0 -76
- package/dist/renderer/RenderGlobal.js +0 -88
- package/dist/renderer/RenderGraphics.d.ts +0 -90
- package/dist/renderer/RenderGraphics.js +0 -597
- package/dist/renderer/RenderPlayer.d.ts +0 -164
- package/dist/renderer/RenderPlayer.js +0 -421
- package/dist/renderer/RenderShape.d.ts +0 -32
- package/dist/renderer/RenderShape.js +0 -104
- package/dist/renderer/RenderTextField.d.ts +0 -119
- package/dist/renderer/RenderTextField.js +0 -709
- package/dist/renderer/RenderVideo.d.ts +0 -59
- package/dist/renderer/RenderVideo.js +0 -272
|
@@ -1,709 +0,0 @@
|
|
|
1
|
-
import { RenderDisplayObject } from "./RenderDisplayObject";
|
|
2
|
-
import { Rectangle } from "../player/next2d/geom/Rectangle";
|
|
3
|
-
import { $isSafari, $renderPlayer, $textFields } from "./RenderGlobal";
|
|
4
|
-
import { $boundsMatrix, $clamp, $generateFontStyle, $getArray, $Infinity, $intToRGBA, $Math, $multiplicationColor, $multiplicationMatrix, $Number, $poolArray, $poolBoundsObject, $poolFloat32Array6, $poolFloat32Array8 } from "../player/util/RenderUtil";
|
|
5
|
-
/**
|
|
6
|
-
* @class
|
|
7
|
-
*/
|
|
8
|
-
export class RenderTextField extends RenderDisplayObject {
|
|
9
|
-
_$background;
|
|
10
|
-
_$backgroundColor;
|
|
11
|
-
_$border;
|
|
12
|
-
_$borderColor;
|
|
13
|
-
_$textData;
|
|
14
|
-
_$textAreaActive;
|
|
15
|
-
_$thickness;
|
|
16
|
-
_$thicknessColor;
|
|
17
|
-
_$limitWidth;
|
|
18
|
-
_$limitHeight;
|
|
19
|
-
_$autoSize;
|
|
20
|
-
_$widthTable;
|
|
21
|
-
_$heightTable;
|
|
22
|
-
_$objectTable;
|
|
23
|
-
_$textHeightTable;
|
|
24
|
-
_$scrollV;
|
|
25
|
-
_$maxScrollV;
|
|
26
|
-
_$textHeight;
|
|
27
|
-
_$verticalAlign;
|
|
28
|
-
_$wordWrap;
|
|
29
|
-
/**
|
|
30
|
-
* @constructor
|
|
31
|
-
* @public
|
|
32
|
-
*/
|
|
33
|
-
constructor() {
|
|
34
|
-
super();
|
|
35
|
-
/**
|
|
36
|
-
* @type {boolean}
|
|
37
|
-
* @default false
|
|
38
|
-
* @private
|
|
39
|
-
*/
|
|
40
|
-
this._$background = false;
|
|
41
|
-
/**
|
|
42
|
-
* @type {number}
|
|
43
|
-
* @default 0xffffff
|
|
44
|
-
* @private
|
|
45
|
-
*/
|
|
46
|
-
this._$backgroundColor = 0xffffff;
|
|
47
|
-
/**
|
|
48
|
-
* @type {boolean}
|
|
49
|
-
* @default false
|
|
50
|
-
* @private
|
|
51
|
-
*/
|
|
52
|
-
this._$border = false;
|
|
53
|
-
/**
|
|
54
|
-
* @type {number}
|
|
55
|
-
* @default 0x000000
|
|
56
|
-
* @private
|
|
57
|
-
*/
|
|
58
|
-
this._$borderColor = 0x000000;
|
|
59
|
-
/**
|
|
60
|
-
* @type {boolean}
|
|
61
|
-
* @default false
|
|
62
|
-
* @private
|
|
63
|
-
*/
|
|
64
|
-
this._$wordWrap = false;
|
|
65
|
-
/**
|
|
66
|
-
* @type {array}
|
|
67
|
-
* @private
|
|
68
|
-
*/
|
|
69
|
-
this._$textData = $getArray();
|
|
70
|
-
/**
|
|
71
|
-
* @type {boolean}
|
|
72
|
-
* @default false
|
|
73
|
-
* @private
|
|
74
|
-
*/
|
|
75
|
-
this._$textAreaActive = false;
|
|
76
|
-
/**
|
|
77
|
-
* @type {number}
|
|
78
|
-
* @default 0
|
|
79
|
-
* @private
|
|
80
|
-
*/
|
|
81
|
-
this._$thickness = 0;
|
|
82
|
-
/**
|
|
83
|
-
* @type {number}
|
|
84
|
-
* @default 0
|
|
85
|
-
* @private
|
|
86
|
-
*/
|
|
87
|
-
this._$thicknessColor = 0;
|
|
88
|
-
/**
|
|
89
|
-
* @type {number}
|
|
90
|
-
* @default 0
|
|
91
|
-
* @private
|
|
92
|
-
*/
|
|
93
|
-
this._$limitWidth = 0;
|
|
94
|
-
/**
|
|
95
|
-
* @type {number}
|
|
96
|
-
* @default 0
|
|
97
|
-
* @private
|
|
98
|
-
*/
|
|
99
|
-
this._$limitHeight = 0;
|
|
100
|
-
/**
|
|
101
|
-
* @type {string}
|
|
102
|
-
* @default TextFieldAutoSize.NONE
|
|
103
|
-
* @private
|
|
104
|
-
*/
|
|
105
|
-
this._$autoSize = "none";
|
|
106
|
-
/**
|
|
107
|
-
* @type {array}
|
|
108
|
-
* @default null
|
|
109
|
-
* @private
|
|
110
|
-
*/
|
|
111
|
-
this._$widthTable = $getArray();
|
|
112
|
-
/**
|
|
113
|
-
* @type {array}
|
|
114
|
-
* @default null
|
|
115
|
-
* @private
|
|
116
|
-
*/
|
|
117
|
-
this._$heightTable = $getArray();
|
|
118
|
-
/**
|
|
119
|
-
* @type {array}
|
|
120
|
-
* @default null
|
|
121
|
-
* @private
|
|
122
|
-
*/
|
|
123
|
-
this._$objectTable = $getArray();
|
|
124
|
-
/**
|
|
125
|
-
* @type {array}
|
|
126
|
-
* @default null
|
|
127
|
-
* @private
|
|
128
|
-
*/
|
|
129
|
-
this._$textHeightTable = $getArray();
|
|
130
|
-
/**
|
|
131
|
-
* @type {number}
|
|
132
|
-
* @default 0
|
|
133
|
-
* @private
|
|
134
|
-
*/
|
|
135
|
-
this._$xMin = 0;
|
|
136
|
-
/**
|
|
137
|
-
* @type {number}
|
|
138
|
-
* @default 0
|
|
139
|
-
* @private
|
|
140
|
-
*/
|
|
141
|
-
this._$yMin = 0;
|
|
142
|
-
/**
|
|
143
|
-
* @type {number}
|
|
144
|
-
* @default 0
|
|
145
|
-
* @private
|
|
146
|
-
*/
|
|
147
|
-
this._$xMax = 0;
|
|
148
|
-
/**
|
|
149
|
-
* @type {number}
|
|
150
|
-
* @default 0
|
|
151
|
-
* @private
|
|
152
|
-
*/
|
|
153
|
-
this._$yMax = 0;
|
|
154
|
-
/**
|
|
155
|
-
* @type {number}
|
|
156
|
-
* @default null
|
|
157
|
-
* @private
|
|
158
|
-
*/
|
|
159
|
-
this._$maxScrollV = null;
|
|
160
|
-
/**
|
|
161
|
-
* @type {number}
|
|
162
|
-
* @default 1
|
|
163
|
-
* @private
|
|
164
|
-
*/
|
|
165
|
-
this._$scrollV = 1;
|
|
166
|
-
/**
|
|
167
|
-
* @type {number}
|
|
168
|
-
* @default 0
|
|
169
|
-
* @private
|
|
170
|
-
*/
|
|
171
|
-
this._$textHeight = 0;
|
|
172
|
-
/**
|
|
173
|
-
* @type {string}
|
|
174
|
-
* @default TextFormatVerticalAlign.TOP
|
|
175
|
-
* @private
|
|
176
|
-
*/
|
|
177
|
-
this._$verticalAlign = "top";
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* @description 表示オブジェクトの幅を示します(ピクセル単位)。
|
|
181
|
-
* Indicates the width of the display object, in pixels.
|
|
182
|
-
*
|
|
183
|
-
* @member {number}
|
|
184
|
-
* @public
|
|
185
|
-
*/
|
|
186
|
-
get width() {
|
|
187
|
-
const bounds = $boundsMatrix(this._$getBounds(null), this._$matrix);
|
|
188
|
-
const width = $Math.abs(bounds.xMax - bounds.xMin);
|
|
189
|
-
$poolBoundsObject(bounds);
|
|
190
|
-
switch (true) {
|
|
191
|
-
case width === 0:
|
|
192
|
-
case width === $Infinity:
|
|
193
|
-
case width === 0 - $Infinity:
|
|
194
|
-
return 0;
|
|
195
|
-
default:
|
|
196
|
-
return width;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* @description 表示オブジェクトの高さを示します(ピクセル単位)。
|
|
201
|
-
* Indicates the height of the display object, in pixels.
|
|
202
|
-
*
|
|
203
|
-
* @member {number}
|
|
204
|
-
* @public
|
|
205
|
-
*/
|
|
206
|
-
get height() {
|
|
207
|
-
const bounds = $boundsMatrix(this._$getBounds(null), this._$matrix);
|
|
208
|
-
const height = $Math.abs(bounds.yMax - bounds.yMin);
|
|
209
|
-
// object pool
|
|
210
|
-
$poolBoundsObject(bounds);
|
|
211
|
-
switch (height) {
|
|
212
|
-
case 0:
|
|
213
|
-
case $Infinity:
|
|
214
|
-
case 0 - $Infinity:
|
|
215
|
-
return 0;
|
|
216
|
-
default:
|
|
217
|
-
return height;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* @description scrollV の最大値です。
|
|
222
|
-
* The maximum value of scrollV.
|
|
223
|
-
*
|
|
224
|
-
* @member {number}
|
|
225
|
-
* @readonly
|
|
226
|
-
* @public
|
|
227
|
-
*/
|
|
228
|
-
get maxScrollV() {
|
|
229
|
-
if (this._$maxScrollV === null) {
|
|
230
|
-
this._$maxScrollV = 1;
|
|
231
|
-
const length = this._$textHeightTable.length;
|
|
232
|
-
const maxHeight = this.height;
|
|
233
|
-
if (maxHeight > this._$textHeight) {
|
|
234
|
-
return this._$maxScrollV;
|
|
235
|
-
}
|
|
236
|
-
let textHeight = 0;
|
|
237
|
-
let idx = 0;
|
|
238
|
-
while (length > idx) {
|
|
239
|
-
textHeight += this._$textHeightTable[idx++];
|
|
240
|
-
if (textHeight > maxHeight) {
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
this._$maxScrollV++;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return this._$maxScrollV;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* @param {CanvasToWebGLContext} context
|
|
250
|
-
* @param {Float32Array} matrix
|
|
251
|
-
* @return {void}
|
|
252
|
-
* @method
|
|
253
|
-
* @private
|
|
254
|
-
*/
|
|
255
|
-
_$clip(context, matrix) {
|
|
256
|
-
// size
|
|
257
|
-
const bounds = this._$getBounds();
|
|
258
|
-
const xMax = bounds.xMax;
|
|
259
|
-
const xMin = bounds.xMin;
|
|
260
|
-
const yMax = bounds.yMax;
|
|
261
|
-
const yMin = bounds.yMin;
|
|
262
|
-
$poolBoundsObject(bounds);
|
|
263
|
-
const width = $Math.ceil($Math.abs(xMax - xMin));
|
|
264
|
-
const height = $Math.ceil($Math.abs(yMax - yMin));
|
|
265
|
-
if (!width || !height) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
let multiMatrix = matrix;
|
|
269
|
-
const rawMatrix = this._$matrix;
|
|
270
|
-
if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
|
|
271
|
-
|| rawMatrix[2] !== 0 || rawMatrix[3] !== 1
|
|
272
|
-
|| rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
|
|
273
|
-
multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
|
|
274
|
-
}
|
|
275
|
-
context.reset();
|
|
276
|
-
context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
|
|
277
|
-
context.beginPath();
|
|
278
|
-
context.moveTo(0, 0);
|
|
279
|
-
context.lineTo(width, 0);
|
|
280
|
-
context.lineTo(width, height);
|
|
281
|
-
context.lineTo(0, height);
|
|
282
|
-
context.lineTo(0, 0);
|
|
283
|
-
context.clip();
|
|
284
|
-
if (multiMatrix !== matrix) {
|
|
285
|
-
$poolFloat32Array6(multiMatrix);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* @param {CanvasToWebGLContext} context
|
|
290
|
-
* @param {Float32Array} matrix
|
|
291
|
-
* @param {Float32Array} color_transform
|
|
292
|
-
* @return {void}
|
|
293
|
-
* @method
|
|
294
|
-
* @private
|
|
295
|
-
*/
|
|
296
|
-
_$draw(context, matrix, color_transform) {
|
|
297
|
-
if (!this._$visible || this._$textAreaActive) {
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
if (!this._$background && !this._$border
|
|
301
|
-
&& 2 > this._$textData.length) {
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
let multiColor = color_transform;
|
|
305
|
-
const rawColor = this._$colorTransform;
|
|
306
|
-
if (rawColor[0] !== 1 || rawColor[1] !== 1
|
|
307
|
-
|| rawColor[2] !== 1 || rawColor[3] !== 1
|
|
308
|
-
|| rawColor[4] !== 0 || rawColor[5] !== 0
|
|
309
|
-
|| rawColor[6] !== 0 || rawColor[7] !== 0) {
|
|
310
|
-
multiColor = $multiplicationColor(color_transform, rawColor);
|
|
311
|
-
}
|
|
312
|
-
const alpha = $clamp(multiColor[3] + multiColor[7] / 255, 0, 1);
|
|
313
|
-
if (!alpha) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
let multiMatrix = matrix;
|
|
317
|
-
const rawMatrix = this._$matrix;
|
|
318
|
-
if (rawMatrix[0] !== 1 || rawMatrix[1] !== 0
|
|
319
|
-
|| rawMatrix[2] !== 0 || rawMatrix[3] !== 1
|
|
320
|
-
|| rawMatrix[4] !== 0 || rawMatrix[5] !== 0) {
|
|
321
|
-
multiMatrix = $multiplicationMatrix(matrix, rawMatrix);
|
|
322
|
-
}
|
|
323
|
-
const baseBounds = this._$getBounds(null);
|
|
324
|
-
baseBounds.xMin -= this._$thickness;
|
|
325
|
-
baseBounds.xMax += this._$thickness;
|
|
326
|
-
baseBounds.yMin -= this._$thickness;
|
|
327
|
-
baseBounds.yMax += this._$thickness;
|
|
328
|
-
const bounds = $boundsMatrix(baseBounds, multiMatrix);
|
|
329
|
-
const xMax = +bounds.xMax;
|
|
330
|
-
const xMin = +bounds.xMin;
|
|
331
|
-
const yMax = +bounds.yMax;
|
|
332
|
-
const yMin = +bounds.yMin;
|
|
333
|
-
$poolBoundsObject(bounds);
|
|
334
|
-
const width = $Math.ceil($Math.abs(xMax - xMin));
|
|
335
|
-
const height = $Math.ceil($Math.abs(yMax - yMin));
|
|
336
|
-
switch (true) {
|
|
337
|
-
case width === 0:
|
|
338
|
-
case height === 0:
|
|
339
|
-
case width === 0 - $Infinity:
|
|
340
|
-
case height === 0 - $Infinity:
|
|
341
|
-
case width === $Infinity:
|
|
342
|
-
case height === $Infinity:
|
|
343
|
-
return;
|
|
344
|
-
default:
|
|
345
|
-
break;
|
|
346
|
-
}
|
|
347
|
-
if (0 > xMin + width || 0 > yMin + height) {
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
// cache current buffer
|
|
351
|
-
const manager = context.frameBuffer;
|
|
352
|
-
const currentAttachment = manager.currentAttachment;
|
|
353
|
-
if (!currentAttachment
|
|
354
|
-
|| xMin > currentAttachment.width
|
|
355
|
-
|| yMin > currentAttachment.height) {
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
let xScale = +$Math.sqrt(multiMatrix[0] * multiMatrix[0]
|
|
359
|
-
+ multiMatrix[1] * multiMatrix[1]);
|
|
360
|
-
if (!$Number.isInteger(xScale)) {
|
|
361
|
-
const value = xScale.toString();
|
|
362
|
-
const index = value.indexOf("e");
|
|
363
|
-
if (index !== -1) {
|
|
364
|
-
xScale = +value.slice(0, index);
|
|
365
|
-
}
|
|
366
|
-
xScale = +xScale.toFixed(4);
|
|
367
|
-
}
|
|
368
|
-
let yScale = +$Math.sqrt(multiMatrix[2] * multiMatrix[2]
|
|
369
|
-
+ multiMatrix[3] * multiMatrix[3]);
|
|
370
|
-
if (!$Number.isInteger(yScale)) {
|
|
371
|
-
const value = yScale.toString();
|
|
372
|
-
const index = value.indexOf("e");
|
|
373
|
-
if (index !== -1) {
|
|
374
|
-
yScale = +value.slice(0, index);
|
|
375
|
-
}
|
|
376
|
-
yScale = +yScale.toFixed(4);
|
|
377
|
-
}
|
|
378
|
-
if (0 > xMin + width || 0 > yMin + height) {
|
|
379
|
-
if (this._$filters
|
|
380
|
-
&& this._$filters.length
|
|
381
|
-
&& this._$canApply(this._$filters)) {
|
|
382
|
-
let rect = new Rectangle(0, 0, width, height);
|
|
383
|
-
for (let idx = 0; idx < this._$filters.length; ++idx) {
|
|
384
|
-
rect = this._$filters[idx]._$generateFilterRect(rect, xScale, yScale);
|
|
385
|
-
}
|
|
386
|
-
if (0 > rect.x + rect.width || 0 > rect.y + rect.height) {
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
const keys = $getArray(xScale, yScale);
|
|
395
|
-
const instanceId = this._$instanceId;
|
|
396
|
-
const cacheStore = $renderPlayer.cacheStore;
|
|
397
|
-
const cacheKeys = cacheStore.generateKeys(instanceId, keys);
|
|
398
|
-
$poolArray(keys);
|
|
399
|
-
let texture = cacheStore.get(cacheKeys);
|
|
400
|
-
// texture is small or renew
|
|
401
|
-
if (this._$isUpdated()) {
|
|
402
|
-
cacheStore.removeCache(instanceId);
|
|
403
|
-
texture = null;
|
|
404
|
-
}
|
|
405
|
-
if (!texture) {
|
|
406
|
-
// resize
|
|
407
|
-
const lineWidth = $Math.min(1, $Math.max(xScale, yScale));
|
|
408
|
-
const baseWidth = $Math.ceil($Math.abs(baseBounds.xMax - baseBounds.xMin) * xScale);
|
|
409
|
-
const baseHeight = $Math.ceil($Math.abs(baseBounds.yMax - baseBounds.yMin) * yScale);
|
|
410
|
-
// alpha reset
|
|
411
|
-
multiColor[3] = 1;
|
|
412
|
-
// new canvas
|
|
413
|
-
const canvas = new OffscreenCanvas(baseWidth + lineWidth * 2, baseHeight + lineWidth * 2);
|
|
414
|
-
const ctx = canvas.getContext("2d");
|
|
415
|
-
if (!ctx) {
|
|
416
|
-
return;
|
|
417
|
-
}
|
|
418
|
-
// border and background
|
|
419
|
-
if (this._$background || this._$border) {
|
|
420
|
-
ctx.beginPath();
|
|
421
|
-
ctx.moveTo(0, 0);
|
|
422
|
-
ctx.lineTo(baseWidth, 0);
|
|
423
|
-
ctx.lineTo(baseWidth, baseHeight);
|
|
424
|
-
ctx.lineTo(0, baseHeight);
|
|
425
|
-
ctx.lineTo(0, 0);
|
|
426
|
-
if (this._$background) {
|
|
427
|
-
const color = $intToRGBA(this._$backgroundColor);
|
|
428
|
-
const alpha = $Math.max(0, $Math.min(color.A * 255 * color_transform[3] + color_transform[7], 255)) / 255;
|
|
429
|
-
ctx.fillStyle = `rgba(${color.R},${color.G},${color.B},${alpha})`;
|
|
430
|
-
ctx.fill();
|
|
431
|
-
}
|
|
432
|
-
if (this._$border) {
|
|
433
|
-
const color = $intToRGBA(this._$borderColor);
|
|
434
|
-
const alpha = $Math.max(0, $Math.min(color.A * 255 * color_transform[3] + color_transform[7], 255)) / 255;
|
|
435
|
-
ctx.lineWidth = lineWidth;
|
|
436
|
-
ctx.strokeStyle = `rgba(${color.R},${color.G},${color.B},${alpha})`;
|
|
437
|
-
ctx.stroke();
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
// mask start
|
|
441
|
-
ctx.save();
|
|
442
|
-
ctx.beginPath();
|
|
443
|
-
ctx.moveTo(2, 2);
|
|
444
|
-
ctx.lineTo(baseWidth - 2, 2);
|
|
445
|
-
ctx.lineTo(baseWidth - 2, baseHeight - 2);
|
|
446
|
-
ctx.lineTo(2, baseHeight - 2);
|
|
447
|
-
ctx.lineTo(2, 2);
|
|
448
|
-
ctx.clip();
|
|
449
|
-
ctx.beginPath();
|
|
450
|
-
ctx.setTransform(xScale, 0, 0, yScale, 0, 0);
|
|
451
|
-
this._$doDraw(ctx, matrix, color_transform, baseWidth / xScale);
|
|
452
|
-
ctx.restore();
|
|
453
|
-
texture = manager.createTextureFromCanvas(ctx.canvas);
|
|
454
|
-
// set cache
|
|
455
|
-
cacheStore.set(cacheKeys, texture);
|
|
456
|
-
}
|
|
457
|
-
let drawFilter = false;
|
|
458
|
-
let offsetX = 0;
|
|
459
|
-
let offsetY = 0;
|
|
460
|
-
if (this._$filters
|
|
461
|
-
&& this._$filters.length
|
|
462
|
-
&& this._$canApply(this._$filters)) {
|
|
463
|
-
drawFilter = true;
|
|
464
|
-
texture = this._$drawFilter(context, texture, multiMatrix, this._$filters, width, height);
|
|
465
|
-
offsetX = texture._$offsetX;
|
|
466
|
-
offsetY = texture._$offsetY;
|
|
467
|
-
}
|
|
468
|
-
const radianX = $Math.atan2(multiMatrix[1], multiMatrix[0]);
|
|
469
|
-
const radianY = $Math.atan2(0 - multiMatrix[2], multiMatrix[3]);
|
|
470
|
-
if (!drawFilter && (radianX || radianY)) {
|
|
471
|
-
const tx = baseBounds.xMin * xScale;
|
|
472
|
-
const ty = baseBounds.yMin * yScale;
|
|
473
|
-
const cosX = $Math.cos(radianX);
|
|
474
|
-
const sinX = $Math.sin(radianX);
|
|
475
|
-
const cosY = $Math.cos(radianY);
|
|
476
|
-
const sinY = $Math.sin(radianY);
|
|
477
|
-
context.setTransform(cosX, sinX, 0 - sinY, cosY, tx * cosX - ty * sinY + multiMatrix[4], tx * sinX + ty * cosY + multiMatrix[5]);
|
|
478
|
-
}
|
|
479
|
-
else {
|
|
480
|
-
context.setTransform(1, 0, 0, 1, xMin - offsetX, yMin - offsetY);
|
|
481
|
-
}
|
|
482
|
-
// draw
|
|
483
|
-
context.reset();
|
|
484
|
-
context.globalAlpha = alpha;
|
|
485
|
-
context.imageSmoothingEnabled = true;
|
|
486
|
-
context.globalCompositeOperation = this._$blendMode;
|
|
487
|
-
context.drawImage(texture, 0, 0, texture.width, texture.height, multiColor);
|
|
488
|
-
// get cache
|
|
489
|
-
$poolArray(cacheKeys);
|
|
490
|
-
$poolBoundsObject(baseBounds);
|
|
491
|
-
// pool
|
|
492
|
-
if (multiMatrix !== matrix) {
|
|
493
|
-
$poolFloat32Array6(multiMatrix);
|
|
494
|
-
}
|
|
495
|
-
if (multiColor !== color_transform) {
|
|
496
|
-
$poolFloat32Array8(multiColor);
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
/**
|
|
500
|
-
* @param {CanvasRenderingContext2D} context
|
|
501
|
-
* @param {Float32Array} matrix
|
|
502
|
-
* @param {Float32Array} color_transform
|
|
503
|
-
* @param {number} width
|
|
504
|
-
* @return {void}
|
|
505
|
-
* @method
|
|
506
|
-
* @private
|
|
507
|
-
*/
|
|
508
|
-
_$doDraw(context, matrix, color_transform, width) {
|
|
509
|
-
const limitWidth = this.width;
|
|
510
|
-
const limitHeight = this.height;
|
|
511
|
-
// setup
|
|
512
|
-
let xOffset = 0;
|
|
513
|
-
let offsetHeight = 0;
|
|
514
|
-
let currentV = 0;
|
|
515
|
-
let yOffset = 0;
|
|
516
|
-
if (this._$verticalAlign !== "top"
|
|
517
|
-
&& this.height > this._$textHeight) {
|
|
518
|
-
switch (this._$verticalAlign) {
|
|
519
|
-
case "middle":
|
|
520
|
-
yOffset = (this.height - this._$textHeight + 2) / 2;
|
|
521
|
-
break;
|
|
522
|
-
case "bottom":
|
|
523
|
-
yOffset = this.height - this._$textHeight + 2;
|
|
524
|
-
break;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
const length = this._$textData.length;
|
|
528
|
-
for (let idx = 0; idx < length; ++idx) {
|
|
529
|
-
const obj = this._$textData[idx];
|
|
530
|
-
if (obj.width === 0) {
|
|
531
|
-
continue;
|
|
532
|
-
}
|
|
533
|
-
// check
|
|
534
|
-
const offsetWidth = xOffset + obj.x;
|
|
535
|
-
if (this._$autoSize === "none"
|
|
536
|
-
&& (offsetHeight > limitHeight || offsetWidth > limitWidth)) {
|
|
537
|
-
continue;
|
|
538
|
-
}
|
|
539
|
-
const tf = obj.textFormat;
|
|
540
|
-
// color
|
|
541
|
-
const color = $intToRGBA(obj.textFormat._$color);
|
|
542
|
-
const alpha = $Math.max(0, $Math.min(color.A * 255 * color_transform[3] + color_transform[7], 255)) / 255;
|
|
543
|
-
context.fillStyle = `rgba(${color.R},${color.G},${color.B},${alpha})`;
|
|
544
|
-
if (this._$thickness) {
|
|
545
|
-
const color = $intToRGBA(this._$thicknessColor);
|
|
546
|
-
const alpha = $Math.max(0, $Math.min(color.A * 255 * color_transform[3] + color_transform[7], 255)) / 255;
|
|
547
|
-
context.lineWidth = this._$thickness;
|
|
548
|
-
context.strokeStyle = `rgba(${color.R},${color.G},${color.B},${alpha})`;
|
|
549
|
-
}
|
|
550
|
-
const yIndex = obj.yIndex;
|
|
551
|
-
switch (obj.mode) {
|
|
552
|
-
case "break":
|
|
553
|
-
case "wrap":
|
|
554
|
-
currentV++;
|
|
555
|
-
if (this._$scrollV > currentV) {
|
|
556
|
-
continue;
|
|
557
|
-
}
|
|
558
|
-
offsetHeight += this._$textHeightTable[yIndex];
|
|
559
|
-
xOffset = this._$getAlignOffset(this._$objectTable[yIndex], width);
|
|
560
|
-
if (tf._$underline) {
|
|
561
|
-
const offset = obj.textFormat._$size / 12;
|
|
562
|
-
const color = $intToRGBA(tf._$color);
|
|
563
|
-
const alpha = $Math.max(0, $Math.min(color.A * 255 * color_transform[3] + color_transform[7], 255)) / 255;
|
|
564
|
-
context.lineWidth = $Math.max(1, 1 / $Math.min(matrix[0], matrix[3]));
|
|
565
|
-
context.strokeStyle = `rgba(${color.R},${color.G},${color.B},${alpha})`;
|
|
566
|
-
context.beginPath();
|
|
567
|
-
context.moveTo(xOffset, yOffset + offsetHeight - offset);
|
|
568
|
-
context.lineTo(xOffset + this._$widthTable[yIndex], yOffset + offsetHeight - offset);
|
|
569
|
-
context.stroke();
|
|
570
|
-
}
|
|
571
|
-
break;
|
|
572
|
-
case "text":
|
|
573
|
-
{
|
|
574
|
-
if (this._$scrollV > currentV) {
|
|
575
|
-
continue;
|
|
576
|
-
}
|
|
577
|
-
let offsetY = offsetHeight - this._$heightTable[0];
|
|
578
|
-
if (!$isSafari) {
|
|
579
|
-
offsetY += 2 * (obj.textFormat._$size / 12);
|
|
580
|
-
}
|
|
581
|
-
context.beginPath();
|
|
582
|
-
context.textBaseline = "top";
|
|
583
|
-
context.font = $generateFontStyle(tf._$font, tf._$size, tf._$italic, tf._$bold);
|
|
584
|
-
if (this._$thickness) {
|
|
585
|
-
context.strokeText(obj.text, offsetWidth, yOffset + offsetY);
|
|
586
|
-
}
|
|
587
|
-
context.fillText(obj.text, offsetWidth, yOffset + offsetY);
|
|
588
|
-
}
|
|
589
|
-
break;
|
|
590
|
-
case "image":
|
|
591
|
-
if (!obj.loaded) {
|
|
592
|
-
continue;
|
|
593
|
-
}
|
|
594
|
-
context.beginPath();
|
|
595
|
-
context.drawImage(obj.image, obj.hspace, yOffset + obj.y, obj.width, obj.height);
|
|
596
|
-
break;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
/**
|
|
601
|
-
* @param {object} obj
|
|
602
|
-
* @param {number} width
|
|
603
|
-
* @return {number}
|
|
604
|
-
* @private
|
|
605
|
-
*/
|
|
606
|
-
_$getAlignOffset(obj, width) {
|
|
607
|
-
// default
|
|
608
|
-
const totalWidth = this._$widthTable[obj.yIndex];
|
|
609
|
-
const textFormat = obj.textFormat;
|
|
610
|
-
const indent = textFormat._$blockIndent + textFormat._$leftMargin > 0
|
|
611
|
-
? textFormat._$blockIndent + textFormat._$leftMargin
|
|
612
|
-
: 0;
|
|
613
|
-
switch (true) {
|
|
614
|
-
// wordWrap case
|
|
615
|
-
case !this._$wordWrap && totalWidth > width:
|
|
616
|
-
return $Math.max(0, indent);
|
|
617
|
-
case textFormat._$align === "center": // format CENTER
|
|
618
|
-
case this._$autoSize === "center": // autoSize CENTER
|
|
619
|
-
return $Math.max(0, width / 2 - indent - textFormat._$rightMargin - totalWidth / 2);
|
|
620
|
-
case textFormat._$align === "right": // format RIGHT
|
|
621
|
-
case this._$autoSize === "right": // autoSize RIGHT
|
|
622
|
-
return $Math.max(0, width - indent - totalWidth - textFormat._$rightMargin - 2);
|
|
623
|
-
// autoSize LEFT
|
|
624
|
-
// format LEFT
|
|
625
|
-
default:
|
|
626
|
-
return $Math.max(0, indent + 2);
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
/**
|
|
630
|
-
* @description Playerから登録を削除
|
|
631
|
-
*
|
|
632
|
-
* @return {void}
|
|
633
|
-
* @method
|
|
634
|
-
* @private
|
|
635
|
-
*/
|
|
636
|
-
_$remove() {
|
|
637
|
-
this._$xMin = 0;
|
|
638
|
-
this._$yMin = 0;
|
|
639
|
-
this._$xMax = 0;
|
|
640
|
-
this._$yMax = 0;
|
|
641
|
-
// array reset
|
|
642
|
-
this._$textData.length = 0;
|
|
643
|
-
this._$widthTable.length = 0;
|
|
644
|
-
this._$heightTable.length = 0;
|
|
645
|
-
this._$objectTable.length = 0;
|
|
646
|
-
this._$textHeightTable.length = 0;
|
|
647
|
-
this._$textAreaActive = false;
|
|
648
|
-
super._$remove();
|
|
649
|
-
$textFields.push(this);
|
|
650
|
-
}
|
|
651
|
-
/**
|
|
652
|
-
* @description 情報を更新
|
|
653
|
-
*
|
|
654
|
-
* @param {object} object
|
|
655
|
-
* @return {void}
|
|
656
|
-
* @method
|
|
657
|
-
* @private
|
|
658
|
-
*/
|
|
659
|
-
_$updateProperty(object) {
|
|
660
|
-
// update property
|
|
661
|
-
this._$textAreaActive = !!object.textAreaActive;
|
|
662
|
-
// set array
|
|
663
|
-
this._$textData.push(...object.textData);
|
|
664
|
-
this._$widthTable.push(...object.widthTable);
|
|
665
|
-
this._$heightTable.push(...object.heightTable);
|
|
666
|
-
this._$objectTable.push(...object.objectTable);
|
|
667
|
-
this._$textHeightTable.push(...object.textHeightTable);
|
|
668
|
-
// format
|
|
669
|
-
this._$wordWrap = object.wordWrap;
|
|
670
|
-
this._$limitWidth = object.limitWidth;
|
|
671
|
-
this._$limitHeight = object.limitHeight;
|
|
672
|
-
this._$autoSize = object.autoSize;
|
|
673
|
-
this._$scrollV = object.scrollV;
|
|
674
|
-
this._$textHeight = object.textHeight;
|
|
675
|
-
this._$verticalAlign = object.verticalAlign;
|
|
676
|
-
// color
|
|
677
|
-
this._$border = object.border;
|
|
678
|
-
if (this._$border) {
|
|
679
|
-
this._$borderColor = object.borderColor;
|
|
680
|
-
}
|
|
681
|
-
this._$background = object.background;
|
|
682
|
-
if (this._$background) {
|
|
683
|
-
this._$backgroundColor = object.backgroundColor;
|
|
684
|
-
}
|
|
685
|
-
if ("thickness" in object) {
|
|
686
|
-
this._$thickness = object.thickness;
|
|
687
|
-
this._$thicknessColor = object.thicknessColor;
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
/**
|
|
691
|
-
* @description 描画情報を更新
|
|
692
|
-
*
|
|
693
|
-
* @param {object} object
|
|
694
|
-
* @return {void}
|
|
695
|
-
* @method
|
|
696
|
-
* @private
|
|
697
|
-
*/
|
|
698
|
-
_$update(object) {
|
|
699
|
-
super._$update(object);
|
|
700
|
-
this._$textAreaActive = !!object.textAreaActive;
|
|
701
|
-
this._$xMin = object.xMin;
|
|
702
|
-
this._$yMin = object.yMin;
|
|
703
|
-
this._$xMax = object.xMax;
|
|
704
|
-
this._$yMax = object.yMax;
|
|
705
|
-
if (object.textData) {
|
|
706
|
-
this._$updateProperty(object);
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
}
|