@next2d/display 1.15.0 → 1.16.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/dist/BitmapData.d.ts +10 -1
- package/dist/BitmapData.js +55 -25
- package/dist/DisplayObject.d.ts +10 -11
- package/dist/DisplayObject.js +164 -125
- package/dist/DisplayObjectContainer.d.ts +2 -2
- package/dist/DisplayObjectContainer.js +158 -249
- package/dist/Graphics.d.ts +18 -1
- package/dist/Graphics.js +233 -107
- package/dist/Loader.js +8 -18
- package/dist/MovieClip.js +1 -1
- package/dist/Shape.d.ts +0 -2
- package/dist/Shape.js +15 -13
- package/dist/Stage.js +1 -2
- package/package.json +10 -10
package/dist/Graphics.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GraphicsBitmapFill } from "./GraphicsBitmapFill";
|
|
2
2
|
import { GraphicsGradientFill } from "./GraphicsGradientFill";
|
|
3
3
|
import { $currentPlayer } from "@next2d/util";
|
|
4
|
-
import { $doUpdated, $Math, $Number, $getArray, $poolArray, $toColorInt, $intToRGBA, $clamp, $boundsMatrix, $poolBoundsObject, $Infinity, $getFloat32Array6, $multiplicationMatrix, $poolFloat32Array6, $getBoundsObject, $Float32Array, $getFloat32Array4, $linearGradientXY } from "@next2d/share";
|
|
4
|
+
import { $cacheStore, $doUpdated, $Math, $Number, $getArray, $poolArray, $toColorInt, $intToRGBA, $clamp, $boundsMatrix, $poolBoundsObject, $Infinity, $getFloat32Array6, $multiplicationMatrix, $poolFloat32Array6, $getBoundsObject, $Float32Array, $getFloat32Array4, $linearGradientXY } from "@next2d/share";
|
|
5
5
|
/**
|
|
6
6
|
* Graphics クラスには、ベクターシェイプの作成に使用できる一連のメソッドがあります。
|
|
7
7
|
* 描画をサポートする表示オブジェクトには、Sprite および Shape オブジェクトがあります。
|
|
@@ -218,6 +218,34 @@ export class Graphics {
|
|
|
218
218
|
* @private
|
|
219
219
|
*/
|
|
220
220
|
this._$lines = null;
|
|
221
|
+
/**
|
|
222
|
+
* @type {string}
|
|
223
|
+
* @default ""
|
|
224
|
+
* @private
|
|
225
|
+
*/
|
|
226
|
+
this._$uniqueKey = "";
|
|
227
|
+
/**
|
|
228
|
+
* @type {array}
|
|
229
|
+
* @private
|
|
230
|
+
*/
|
|
231
|
+
this._$cacheKeys = $getArray();
|
|
232
|
+
/**
|
|
233
|
+
* @type {array}
|
|
234
|
+
* @private
|
|
235
|
+
*/
|
|
236
|
+
this._$cacheParams = $getArray(0, 0, 0);
|
|
237
|
+
/**
|
|
238
|
+
* @type {number}
|
|
239
|
+
* @default 0
|
|
240
|
+
* @private
|
|
241
|
+
*/
|
|
242
|
+
this._$bitmapId = 0;
|
|
243
|
+
/**
|
|
244
|
+
* @type {string}
|
|
245
|
+
* @default "shape"
|
|
246
|
+
* @private
|
|
247
|
+
*/
|
|
248
|
+
this._$mode = "shape";
|
|
221
249
|
}
|
|
222
250
|
/**
|
|
223
251
|
* @description 指定されたクラスのストリングを返します。
|
|
@@ -538,6 +566,8 @@ export class Graphics {
|
|
|
538
566
|
this._$pointerX = 0;
|
|
539
567
|
this._$pointerY = 0;
|
|
540
568
|
this._$canDraw = false;
|
|
569
|
+
this._$bitmapId = 0;
|
|
570
|
+
this._$mode = "shape";
|
|
541
571
|
// fill
|
|
542
572
|
this._$fillType = 0;
|
|
543
573
|
this._$fillGradient = null;
|
|
@@ -578,6 +608,10 @@ export class Graphics {
|
|
|
578
608
|
this._$recode = null;
|
|
579
609
|
this._$fills = null;
|
|
580
610
|
this._$lines = null;
|
|
611
|
+
// cache clear
|
|
612
|
+
this._$cacheKeys.length = 0;
|
|
613
|
+
this._$uniqueKey = "";
|
|
614
|
+
this._$cacheParams.fill(0);
|
|
581
615
|
// restart
|
|
582
616
|
this._$restart();
|
|
583
617
|
return this;
|
|
@@ -735,6 +769,7 @@ export class Graphics {
|
|
|
735
769
|
x = +x || 0;
|
|
736
770
|
y = +y || 0;
|
|
737
771
|
radius = +radius || 0;
|
|
772
|
+
radius = $Math.round(radius);
|
|
738
773
|
this._$setBounds(x - radius, y - radius);
|
|
739
774
|
this._$setBounds(x + radius, y + radius);
|
|
740
775
|
this._$margePath($getArray(Graphics.MOVE_TO, x + radius, y, Graphics.ARC, x, y, radius));
|
|
@@ -761,6 +796,8 @@ export class Graphics {
|
|
|
761
796
|
y = +y || 0;
|
|
762
797
|
width = +width || 0;
|
|
763
798
|
height = +height || 0;
|
|
799
|
+
width = $Math.round(width);
|
|
800
|
+
height = $Math.round(height);
|
|
764
801
|
const hw = width / 2; // half width
|
|
765
802
|
const hh = height / 2; // half height
|
|
766
803
|
const x0 = x + hw;
|
|
@@ -795,8 +832,8 @@ export class Graphics {
|
|
|
795
832
|
y = +y || 0;
|
|
796
833
|
width = +width || 0;
|
|
797
834
|
height = +height || 0;
|
|
798
|
-
const xMax = x + width;
|
|
799
|
-
const yMax = y + height;
|
|
835
|
+
const xMax = $Math.round(x + width);
|
|
836
|
+
const yMax = $Math.round(y + height);
|
|
800
837
|
return this
|
|
801
838
|
.moveTo(x, y)
|
|
802
839
|
.lineTo(x, yMax)
|
|
@@ -825,6 +862,10 @@ export class Graphics {
|
|
|
825
862
|
height = +height || 0;
|
|
826
863
|
ellipse_width = +ellipse_width || 0;
|
|
827
864
|
ellipse_height = +ellipse_height || ellipse_width;
|
|
865
|
+
width = $Math.round(width);
|
|
866
|
+
height = $Math.round(height);
|
|
867
|
+
ellipse_width = $Math.round(ellipse_width);
|
|
868
|
+
ellipse_height = $Math.round(ellipse_height);
|
|
828
869
|
const hew = ellipse_width / 2;
|
|
829
870
|
const heh = ellipse_height / 2;
|
|
830
871
|
const c = 4 / 3 * ($Math.SQRT2 - 1);
|
|
@@ -1216,14 +1257,6 @@ export class Graphics {
|
|
|
1216
1257
|
default:
|
|
1217
1258
|
break;
|
|
1218
1259
|
}
|
|
1219
|
-
// cache current buffer
|
|
1220
|
-
const manager = context.frameBuffer;
|
|
1221
|
-
const currentAttachment = manager.currentAttachment;
|
|
1222
|
-
if (!currentAttachment
|
|
1223
|
-
|| xMin > currentAttachment.width
|
|
1224
|
-
|| yMin > currentAttachment.height) {
|
|
1225
|
-
return;
|
|
1226
|
-
}
|
|
1227
1260
|
let xScale = +$Math.sqrt(matrix[0] * matrix[0]
|
|
1228
1261
|
+ matrix[1] * matrix[1]);
|
|
1229
1262
|
if (!$Number.isInteger(xScale)) {
|
|
@@ -1244,55 +1277,95 @@ export class Graphics {
|
|
|
1244
1277
|
}
|
|
1245
1278
|
yScale = +yScale.toFixed(4);
|
|
1246
1279
|
}
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
if (0 > filterBounds.xMin + filterBounds.xMax
|
|
1256
|
-
|| 0 > filterBounds.yMin + filterBounds.yMax) {
|
|
1257
|
-
$poolBoundsObject(filterBounds);
|
|
1258
|
-
return;
|
|
1259
|
-
}
|
|
1260
|
-
$poolBoundsObject(filterBounds);
|
|
1261
|
-
}
|
|
1262
|
-
else {
|
|
1263
|
-
return;
|
|
1280
|
+
const canApply = filters !== null
|
|
1281
|
+
&& filters.length > 0
|
|
1282
|
+
&& displayObject._$canApply(filters);
|
|
1283
|
+
let filterBounds = $getBoundsObject(0, width, 0, height);
|
|
1284
|
+
if (canApply && filters) {
|
|
1285
|
+
for (let idx = 0; idx < filters.length; ++idx) {
|
|
1286
|
+
filterBounds = filters[idx]
|
|
1287
|
+
._$generateFilterRect(filterBounds, xScale, yScale);
|
|
1264
1288
|
}
|
|
1265
1289
|
}
|
|
1290
|
+
// cache current buffer
|
|
1291
|
+
const manager = context.frameBuffer;
|
|
1292
|
+
const currentAttachment = manager.currentAttachment;
|
|
1293
|
+
if (!currentAttachment
|
|
1294
|
+
|| xMin - filterBounds.xMin > currentAttachment.width
|
|
1295
|
+
|| yMin - filterBounds.yMin > currentAttachment.height) {
|
|
1296
|
+
$poolBoundsObject(filterBounds);
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
if (0 > xMin + filterBounds.xMax || 0 > yMin + filterBounds.yMax) {
|
|
1300
|
+
$poolBoundsObject(filterBounds);
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
$poolBoundsObject(filterBounds);
|
|
1266
1304
|
// get cache
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1305
|
+
if (this._$uniqueKey === "") {
|
|
1306
|
+
if (!hasGrid
|
|
1307
|
+
&& displayObject._$loaderInfo
|
|
1308
|
+
&& displayObject._$characterId) {
|
|
1309
|
+
this._$uniqueKey = `${displayObject._$loaderInfo._$id}@${this._$bitmapId || displayObject._$characterId}`;
|
|
1310
|
+
}
|
|
1311
|
+
else {
|
|
1312
|
+
this._$uniqueKey = this._$createCacheKey();
|
|
1313
|
+
}
|
|
1273
1314
|
}
|
|
1274
1315
|
const player = $currentPlayer();
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1316
|
+
if (this._$mode === "bitmap") {
|
|
1317
|
+
if (!this._$cacheKeys.length) {
|
|
1318
|
+
this._$cacheKeys = $cacheStore.generateKeys(this._$uniqueKey);
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
else {
|
|
1322
|
+
if (!this._$cacheKeys.length
|
|
1323
|
+
|| this._$cacheParams[0] !== xScale
|
|
1324
|
+
|| this._$cacheParams[1] !== yScale
|
|
1325
|
+
|| this._$cacheParams[2] !== color_transform[7]) {
|
|
1326
|
+
const keys = $getArray();
|
|
1327
|
+
keys[0] = xScale;
|
|
1328
|
+
keys[1] = yScale;
|
|
1329
|
+
this._$cacheKeys = $cacheStore.generateKeys(this._$uniqueKey, keys, color_transform);
|
|
1330
|
+
$poolArray(keys);
|
|
1331
|
+
this._$cacheParams[0] = xScale;
|
|
1332
|
+
this._$cacheParams[1] = yScale;
|
|
1333
|
+
this._$cacheParams[2] = color_transform[7];
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
context.cachePosition = $cacheStore.get(this._$cacheKeys);
|
|
1337
|
+
if (!context.cachePosition) {
|
|
1280
1338
|
const currentAttachment = manager.currentAttachment;
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
let height = $Math.ceil($Math.abs(baseBounds.yMax - baseBounds.yMin) * yScale);
|
|
1284
|
-
const textureScale = context._$getTextureScale(width, height);
|
|
1285
|
-
if (textureScale < 1) {
|
|
1286
|
-
width *= textureScale;
|
|
1287
|
-
height *= textureScale;
|
|
1339
|
+
if (currentAttachment && currentAttachment.mask) {
|
|
1340
|
+
context.stopStencil();
|
|
1288
1341
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1342
|
+
let width = 0;
|
|
1343
|
+
let height = 0;
|
|
1344
|
+
if (this._$mode === "shape") {
|
|
1345
|
+
width = $Math.ceil($Math.abs(baseBounds.xMax - baseBounds.xMin) * xScale);
|
|
1346
|
+
height = $Math.ceil($Math.abs(baseBounds.yMax - baseBounds.yMin) * yScale);
|
|
1347
|
+
// resize
|
|
1348
|
+
const textureScale = context._$getTextureScale(width, height);
|
|
1349
|
+
if (textureScale < 1) {
|
|
1350
|
+
width *= textureScale;
|
|
1351
|
+
height *= textureScale;
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
else {
|
|
1355
|
+
width = $Math.ceil($Math.abs(baseBounds.xMax - baseBounds.xMin));
|
|
1356
|
+
height = $Math.ceil($Math.abs(baseBounds.yMax - baseBounds.yMin));
|
|
1357
|
+
}
|
|
1358
|
+
// create cache position
|
|
1359
|
+
context.cachePosition = manager.createCachePosition(width, height);
|
|
1360
|
+
context.bindRenderBuffer(context.cachePosition);
|
|
1293
1361
|
// reset
|
|
1294
1362
|
context.reset();
|
|
1295
|
-
|
|
1363
|
+
if (this._$mode === "shape") {
|
|
1364
|
+
context.setTransform(xScale, 0, 0, yScale, -baseBounds.xMin * xScale, -baseBounds.yMin * yScale);
|
|
1365
|
+
}
|
|
1366
|
+
else {
|
|
1367
|
+
context.setTransform(1, 0, 0, 1, -baseBounds.xMin, -baseBounds.yMin);
|
|
1368
|
+
}
|
|
1296
1369
|
if (hasGrid) {
|
|
1297
1370
|
const mScale = player.scaleX;
|
|
1298
1371
|
const baseMatrix = $getFloat32Array6(mScale, 0, 0, mScale, 0, 0);
|
|
@@ -1321,58 +1394,92 @@ export class Graphics {
|
|
|
1321
1394
|
$poolFloat32Array6(pMatrix);
|
|
1322
1395
|
$poolFloat32Array6(aMatrix);
|
|
1323
1396
|
}
|
|
1324
|
-
//
|
|
1325
|
-
color_transform[3] = 1;
|
|
1397
|
+
// execute
|
|
1326
1398
|
this._$doDraw(context, color_transform, false);
|
|
1327
1399
|
if (hasGrid) {
|
|
1328
1400
|
context.grid.disable();
|
|
1329
1401
|
}
|
|
1330
|
-
|
|
1402
|
+
manager.transferTexture(context.cachePosition);
|
|
1331
1403
|
// set cache
|
|
1332
|
-
cacheStore.set(cacheKeys,
|
|
1333
|
-
// release buffer
|
|
1334
|
-
manager.releaseAttachment(attachment, false);
|
|
1404
|
+
$cacheStore.set(this._$cacheKeys, context.cachePosition);
|
|
1335
1405
|
// end draw and reset current buffer
|
|
1336
1406
|
context._$bind(currentAttachment);
|
|
1337
1407
|
}
|
|
1338
|
-
let drawFilter = false;
|
|
1339
1408
|
let offsetX = 0;
|
|
1340
1409
|
let offsetY = 0;
|
|
1341
|
-
if (
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1410
|
+
if (canApply) {
|
|
1411
|
+
const bitmapTexture = this._$createBitmapTexture(context, context.cachePosition, xScale, yScale, width, height);
|
|
1412
|
+
const position = displayObject._$drawFilter(context, matrix, filters, width, height, bitmapTexture);
|
|
1413
|
+
if (position.offsetX) {
|
|
1414
|
+
offsetX = position.offsetX;
|
|
1415
|
+
}
|
|
1416
|
+
if (position.offsetY) {
|
|
1417
|
+
offsetY = position.offsetY;
|
|
1348
1418
|
}
|
|
1419
|
+
// update
|
|
1420
|
+
context.cachePosition = position;
|
|
1349
1421
|
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
if (!drawFilter && (radianX || radianY)) {
|
|
1353
|
-
const tx = baseBounds.xMin * xScale;
|
|
1354
|
-
const ty = baseBounds.yMin * yScale;
|
|
1355
|
-
const cosX = $Math.cos(radianX);
|
|
1356
|
-
const sinX = $Math.sin(radianX);
|
|
1357
|
-
const cosY = $Math.cos(radianY);
|
|
1358
|
-
const sinY = $Math.sin(radianY);
|
|
1359
|
-
context.setTransform(cosX, sinX, -sinY, cosY, tx * cosX - ty * sinY + matrix[4], tx * sinX + ty * cosY + matrix[5]);
|
|
1422
|
+
if (!canApply && this._$mode === "bitmap") {
|
|
1423
|
+
context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], baseBounds.xMin * matrix[0] + baseBounds.yMin * matrix[2] + matrix[4], baseBounds.xMin * matrix[1] + baseBounds.yMin * matrix[3] + matrix[5]);
|
|
1360
1424
|
}
|
|
1361
1425
|
else {
|
|
1362
|
-
|
|
1426
|
+
const radianX = $Math.atan2(matrix[1], matrix[0]);
|
|
1427
|
+
const radianY = $Math.atan2(-matrix[2], matrix[3]);
|
|
1428
|
+
if (!canApply && (radianX || radianY)) {
|
|
1429
|
+
const tx = baseBounds.xMin * xScale;
|
|
1430
|
+
const ty = baseBounds.yMin * yScale;
|
|
1431
|
+
const cosX = $Math.cos(radianX);
|
|
1432
|
+
const sinX = $Math.sin(radianX);
|
|
1433
|
+
const cosY = $Math.cos(radianY);
|
|
1434
|
+
const sinY = $Math.sin(radianY);
|
|
1435
|
+
context.setTransform(cosX, sinX, -sinY, cosY, tx * cosX - ty * sinY + matrix[4], tx * sinX + ty * cosY + matrix[5]);
|
|
1436
|
+
}
|
|
1437
|
+
else {
|
|
1438
|
+
context.setTransform(1, 0, 0, 1, xMin - offsetX, yMin - offsetY);
|
|
1439
|
+
}
|
|
1363
1440
|
}
|
|
1364
1441
|
// draw
|
|
1365
|
-
if (
|
|
1366
|
-
context.reset();
|
|
1442
|
+
if (context.cachePosition) {
|
|
1367
1443
|
context.globalAlpha = alpha;
|
|
1368
|
-
context.imageSmoothingEnabled =
|
|
1444
|
+
context.imageSmoothingEnabled = this._$mode === "shape";
|
|
1369
1445
|
context.globalCompositeOperation = blend_mode;
|
|
1370
|
-
context.
|
|
1446
|
+
context.drawInstance(xMin - offsetX, yMin - offsetY, xMax, yMax, color_transform);
|
|
1447
|
+
// cache position clear
|
|
1448
|
+
context.cachePosition = null;
|
|
1371
1449
|
}
|
|
1372
1450
|
// pool
|
|
1373
|
-
$poolArray(cacheKeys);
|
|
1374
1451
|
$poolBoundsObject(baseBounds);
|
|
1375
1452
|
}
|
|
1453
|
+
/**
|
|
1454
|
+
* @return {WebGLTexture | null}
|
|
1455
|
+
* @method
|
|
1456
|
+
* @private
|
|
1457
|
+
*/
|
|
1458
|
+
_$createBitmapTexture(context, position, x_scale, y_scale, width, height) {
|
|
1459
|
+
if (this._$mode !== "bitmap") {
|
|
1460
|
+
return null;
|
|
1461
|
+
}
|
|
1462
|
+
context.drawInstacedArray();
|
|
1463
|
+
const manager = context.frameBuffer;
|
|
1464
|
+
const currentAttachment = manager.currentAttachment;
|
|
1465
|
+
const attachment = manager
|
|
1466
|
+
.createCacheAttachment(width, height);
|
|
1467
|
+
context._$bind(attachment);
|
|
1468
|
+
context.reset();
|
|
1469
|
+
const parentMatrix = $getFloat32Array6(x_scale, 0, 0, y_scale, width / 2, height / 2);
|
|
1470
|
+
const texture = context.getTextureFromRect(position);
|
|
1471
|
+
const baseMatrix = $getFloat32Array6(1, 0, 0, 1, -texture.width / 2, -texture.height / 2);
|
|
1472
|
+
const scaleMatrix = $multiplicationMatrix(parentMatrix, baseMatrix);
|
|
1473
|
+
$poolFloat32Array6(parentMatrix);
|
|
1474
|
+
$poolFloat32Array6(baseMatrix);
|
|
1475
|
+
context.setTransform(scaleMatrix[0], scaleMatrix[1], scaleMatrix[2], scaleMatrix[3], scaleMatrix[4], scaleMatrix[5]);
|
|
1476
|
+
context.drawImage(texture, 0, 0, texture.width, texture.height);
|
|
1477
|
+
const bitmapTexture = manager.getTextureFromCurrentAttachment();
|
|
1478
|
+
context._$bind(currentAttachment);
|
|
1479
|
+
manager.releaseAttachment(attachment);
|
|
1480
|
+
manager.textureManager.release(texture);
|
|
1481
|
+
return bitmapTexture;
|
|
1482
|
+
}
|
|
1376
1483
|
/**
|
|
1377
1484
|
* @param {CanvasToWebGLContext} context
|
|
1378
1485
|
* @param {Float32Array} [color_transform=null]
|
|
@@ -1420,16 +1527,14 @@ export class Graphics {
|
|
|
1420
1527
|
*/
|
|
1421
1528
|
_$restart() {
|
|
1422
1529
|
if (this._$displayObject) {
|
|
1530
|
+
// reset
|
|
1423
1531
|
this._$displayObject._$posted = false;
|
|
1424
|
-
this._$buffer = null;
|
|
1425
1532
|
if (!this._$displayObject._$isUpdated()) {
|
|
1426
1533
|
this._$displayObject._$doChanged();
|
|
1427
1534
|
$doUpdated();
|
|
1428
|
-
|
|
1429
|
-
const cacheStore = player.cacheStore;
|
|
1430
|
-
cacheStore.removeCache(this._$displayObject._$instanceId);
|
|
1535
|
+
$cacheStore.removeCache(this._$displayObject._$instanceId);
|
|
1431
1536
|
if (this._$displayObject._$characterId) {
|
|
1432
|
-
cacheStore.removeCache(this._$displayObject._$characterId);
|
|
1537
|
+
$cacheStore.removeCache(this._$displayObject._$characterId);
|
|
1433
1538
|
}
|
|
1434
1539
|
}
|
|
1435
1540
|
}
|
|
@@ -1596,6 +1701,31 @@ export class Graphics {
|
|
|
1596
1701
|
}
|
|
1597
1702
|
$poolArray(data);
|
|
1598
1703
|
}
|
|
1704
|
+
/**
|
|
1705
|
+
* @return {string}
|
|
1706
|
+
* @method
|
|
1707
|
+
* @private
|
|
1708
|
+
*/
|
|
1709
|
+
_$createCacheKey() {
|
|
1710
|
+
if (this._$doLine) {
|
|
1711
|
+
this.endLine();
|
|
1712
|
+
}
|
|
1713
|
+
// fixed logic
|
|
1714
|
+
if (this._$doFill) {
|
|
1715
|
+
this.endFill();
|
|
1716
|
+
}
|
|
1717
|
+
if (!this._$recode) {
|
|
1718
|
+
return "";
|
|
1719
|
+
}
|
|
1720
|
+
const recodes = this._$getRecodes();
|
|
1721
|
+
let hash = 0;
|
|
1722
|
+
for (let idx = 0; idx < recodes.length; idx++) {
|
|
1723
|
+
const chr = recodes[idx];
|
|
1724
|
+
hash = (hash << 5) - hash + chr;
|
|
1725
|
+
hash |= 0;
|
|
1726
|
+
}
|
|
1727
|
+
return `${hash}`;
|
|
1728
|
+
}
|
|
1599
1729
|
/**
|
|
1600
1730
|
* @return {Float32Array}
|
|
1601
1731
|
* @method
|
|
@@ -1762,9 +1892,7 @@ export class Graphics {
|
|
|
1762
1892
|
const bitmapData = recode[idx++];
|
|
1763
1893
|
let buffer;
|
|
1764
1894
|
if (bitmapData.image !== null || bitmapData.canvas !== null) {
|
|
1765
|
-
const
|
|
1766
|
-
const cacheStore = player.cacheStore;
|
|
1767
|
-
const canvas = cacheStore.getCanvas();
|
|
1895
|
+
const canvas = $cacheStore.getCanvas();
|
|
1768
1896
|
const width = bitmapData.width;
|
|
1769
1897
|
const height = bitmapData.height;
|
|
1770
1898
|
canvas.width = width;
|
|
@@ -1776,7 +1904,7 @@ export class Graphics {
|
|
|
1776
1904
|
// @ts-ignore
|
|
1777
1905
|
context.drawImage(bitmapData.image || bitmapData.canvas, 0, 0);
|
|
1778
1906
|
buffer = new Uint8Array(context.getImageData(0, 0, width, height).data);
|
|
1779
|
-
cacheStore.destroy(context);
|
|
1907
|
+
$cacheStore.destroy(context);
|
|
1780
1908
|
}
|
|
1781
1909
|
else if (bitmapData._$buffer !== null) {
|
|
1782
1910
|
buffer = bitmapData._$buffer;
|
|
@@ -1833,9 +1961,7 @@ export class Graphics {
|
|
|
1833
1961
|
const bitmapData = recode[idx++];
|
|
1834
1962
|
let buffer;
|
|
1835
1963
|
if (bitmapData.image !== null || bitmapData.canvas !== null) {
|
|
1836
|
-
const
|
|
1837
|
-
const cacheStore = player.cacheStore;
|
|
1838
|
-
const canvas = cacheStore.getCanvas();
|
|
1964
|
+
const canvas = $cacheStore.getCanvas();
|
|
1839
1965
|
const width = bitmapData.width;
|
|
1840
1966
|
const height = bitmapData.height;
|
|
1841
1967
|
canvas.width = width;
|
|
@@ -1847,7 +1973,7 @@ export class Graphics {
|
|
|
1847
1973
|
// @ts-ignore
|
|
1848
1974
|
context.drawImage(bitmapData.image || bitmapData.canvas, 0, 0);
|
|
1849
1975
|
buffer = new Uint8Array(context.getImageData(0, 0, width, height).data);
|
|
1850
|
-
cacheStore.destroy(context);
|
|
1976
|
+
$cacheStore.destroy(context);
|
|
1851
1977
|
}
|
|
1852
1978
|
else if (bitmapData._$buffer !== null) {
|
|
1853
1979
|
buffer = bitmapData._$buffer;
|
|
@@ -1929,8 +2055,8 @@ export class Graphics {
|
|
|
1929
2055
|
color[2] = recode[idx++] / 255;
|
|
1930
2056
|
color[3] = recode[idx++] / 255;
|
|
1931
2057
|
if (color_transform !== null) {
|
|
1932
|
-
if (color_transform[
|
|
1933
|
-
color[3] = $Math.max(0, $Math.min(color[3] * color_transform[
|
|
2058
|
+
if (color_transform[7] !== 0) {
|
|
2059
|
+
color[3] = $Math.max(0, $Math.min(color[3] * color_transform[7], 255)) / 255;
|
|
1934
2060
|
}
|
|
1935
2061
|
}
|
|
1936
2062
|
context.fillStyle = color;
|
|
@@ -1961,8 +2087,8 @@ export class Graphics {
|
|
|
1961
2087
|
color[2] = recode[idx++] / 255;
|
|
1962
2088
|
color[3] = recode[idx++] / 255;
|
|
1963
2089
|
if (color_transform !== null) {
|
|
1964
|
-
if (color_transform[
|
|
1965
|
-
color[3] = $Math.max(0, $Math.min(color[3]
|
|
2090
|
+
if (color_transform[7] !== 0) {
|
|
2091
|
+
color[3] = $Math.max(0, $Math.min(color[3] + color_transform[7], 255)) / 255;
|
|
1966
2092
|
}
|
|
1967
2093
|
}
|
|
1968
2094
|
context.strokeStyle = color;
|
|
@@ -2018,8 +2144,8 @@ export class Graphics {
|
|
|
2018
2144
|
const color = stops[idx];
|
|
2019
2145
|
let alpha = color.A;
|
|
2020
2146
|
if (color_transform) {
|
|
2021
|
-
if (color_transform[
|
|
2022
|
-
alpha = $Math.max(0, $Math.min(color.A
|
|
2147
|
+
if (color_transform[7] !== 0) {
|
|
2148
|
+
alpha = $Math.max(0, $Math.min(color.A + color_transform[7], 255)) | 0;
|
|
2023
2149
|
}
|
|
2024
2150
|
}
|
|
2025
2151
|
css.addColorStop(color.ratio, $getFloat32Array4(color.R, color.G, color.B, alpha));
|
|
@@ -2067,8 +2193,8 @@ export class Graphics {
|
|
|
2067
2193
|
const color = stops[idx];
|
|
2068
2194
|
let alpha = color.A;
|
|
2069
2195
|
if (color_transform) {
|
|
2070
|
-
if (color_transform[
|
|
2071
|
-
alpha = $Math.max(0, $Math.min(color.A
|
|
2196
|
+
if (color_transform[7] !== 0) {
|
|
2197
|
+
alpha = $Math.max(0, $Math.min(color.A + color_transform[7], 255)) | 0;
|
|
2072
2198
|
}
|
|
2073
2199
|
}
|
|
2074
2200
|
css.addColorStop(color.ratio, $getFloat32Array4(color.R, color.G, color.B, alpha));
|
|
@@ -2104,14 +2230,14 @@ export class Graphics {
|
|
|
2104
2230
|
if (!texture || !color_transform) {
|
|
2105
2231
|
break;
|
|
2106
2232
|
}
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2233
|
+
context.imageSmoothingEnabled = smooth;
|
|
2234
|
+
if (this._$bitmapId
|
|
2235
|
+
|| bitmapData.width === this._$xMax - this._$xMin
|
|
2236
|
+
&& bitmapData.height === this._$yMax - this._$yMin) {
|
|
2237
|
+
context.drawBitmap(texture);
|
|
2111
2238
|
}
|
|
2112
2239
|
else {
|
|
2113
2240
|
context.fillStyle = context.createPattern(texture, repeat, color_transform);
|
|
2114
|
-
context.imageSmoothingEnabled = smooth;
|
|
2115
2241
|
context.fill();
|
|
2116
2242
|
}
|
|
2117
2243
|
// restore
|
package/dist/Loader.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { DisplayObjectContainer } from "./DisplayObjectContainer";
|
|
11
2
|
import { LoaderInfo } from "./LoaderInfo";
|
|
12
3
|
import { MovieClip } from "./MovieClip";
|
|
@@ -177,18 +168,15 @@ export class Loader extends DisplayObjectContainer {
|
|
|
177
168
|
const json = target.response;
|
|
178
169
|
if (json.type === "zlib") {
|
|
179
170
|
if ($useUnzipWorker()) {
|
|
180
|
-
$unzipQueues.push(
|
|
181
|
-
"json": json,
|
|
182
|
-
"scope": this
|
|
183
|
-
});
|
|
171
|
+
$unzipQueues.push(json);
|
|
184
172
|
return;
|
|
185
173
|
}
|
|
186
174
|
$updateUnzipWorkerStatus(true);
|
|
187
175
|
const unzipWorker = $getUnzipWorker();
|
|
188
176
|
const buffer = new Uint8Array(json.buffer);
|
|
189
|
-
unzipWorker.onmessage = (event) =>
|
|
177
|
+
unzipWorker.onmessage = (event) => {
|
|
190
178
|
this._$unzipHandler(event);
|
|
191
|
-
}
|
|
179
|
+
};
|
|
192
180
|
unzipWorker.postMessage(buffer, [buffer.buffer]);
|
|
193
181
|
}
|
|
194
182
|
else {
|
|
@@ -196,7 +184,9 @@ export class Loader extends DisplayObjectContainer {
|
|
|
196
184
|
}
|
|
197
185
|
}
|
|
198
186
|
else {
|
|
199
|
-
|
|
187
|
+
if (loaderInfo.willTrigger(IOErrorEvent.IO_ERROR)) {
|
|
188
|
+
loaderInfo.dispatchEvent(new IOErrorEvent(IOErrorEvent.IO_ERROR, false, false, "LoaderInfo format is `json`"));
|
|
189
|
+
}
|
|
200
190
|
}
|
|
201
191
|
}
|
|
202
192
|
else {
|
|
@@ -218,10 +208,10 @@ export class Loader extends DisplayObjectContainer {
|
|
|
218
208
|
if (!object) {
|
|
219
209
|
return;
|
|
220
210
|
}
|
|
221
|
-
const buffer = new Uint8Array(object.
|
|
211
|
+
const buffer = new Uint8Array(object.buffer);
|
|
222
212
|
const unzipWorker = $getUnzipWorker();
|
|
223
213
|
unzipWorker.onmessage = (event) => {
|
|
224
|
-
|
|
214
|
+
this._$unzipHandler(event);
|
|
225
215
|
};
|
|
226
216
|
unzipWorker.postMessage(buffer, [buffer.buffer]);
|
|
227
217
|
}
|
package/dist/MovieClip.js
CHANGED
|
@@ -249,7 +249,7 @@ export class MovieClip extends Sprite {
|
|
|
249
249
|
if (this._$loopConfig) {
|
|
250
250
|
return this._$loopConfig;
|
|
251
251
|
}
|
|
252
|
-
const place = this._$getPlaceObject();
|
|
252
|
+
const place = this._$placeObject || this._$getPlaceObject();
|
|
253
253
|
if (!place || !place.loop) {
|
|
254
254
|
return null;
|
|
255
255
|
}
|
package/dist/Shape.d.ts
CHANGED