@next2d/display 1.15.0 → 1.17.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.
@@ -1,6 +1,6 @@
1
1
  import type { BitmapData } from "./BitmapData";
2
2
  import type { Matrix } from "@next2d/geom";
3
- import type { GraphicsParentImpl, CapsStyleImpl, JointStyleImpl, FilterArrayImpl, BlendModeImpl, BoundsImpl, PlayerHitObjectImpl, SpreadMethodImpl, GradientTypeImpl, InterpolationMethodImpl } from "@next2d/interface";
3
+ import type { GraphicsParentImpl, CapsStyleImpl, JointStyleImpl, FilterArrayImpl, BlendModeImpl, BoundsImpl, PlayerHitObjectImpl, SpreadMethodImpl, GradientTypeImpl, InterpolationMethodImpl, CachePositionImpl, ShapeModeImpl } from "@next2d/interface";
4
4
  import type { CanvasToWebGLContext } from "@next2d/webgl";
5
5
  /**
6
6
  * Graphics クラスには、ベクターシェイプの作成に使用できる一連のメソッドがあります。
@@ -51,6 +51,12 @@ export declare class Graphics {
51
51
  _$recode: any[] | null;
52
52
  private _$fills;
53
53
  private _$lines;
54
+ private _$uniqueKey;
55
+ private _$cacheKeys;
56
+ private _$cacheParams;
57
+ _$bitmapId: number;
58
+ _$mode: ShapeModeImpl;
59
+ _$posted: boolean;
54
60
  /**
55
61
  * @param {DisplayObject} src
56
62
  *
@@ -491,6 +497,12 @@ export declare class Graphics {
491
497
  * @private
492
498
  */
493
499
  _$draw(context: CanvasToWebGLContext, matrix: Float32Array, color_transform: Float32Array, blend_mode?: BlendModeImpl, filters?: FilterArrayImpl | null): void;
500
+ /**
501
+ * @return {WebGLTexture | null}
502
+ * @method
503
+ * @private
504
+ */
505
+ _$createBitmapTexture(context: CanvasToWebGLContext, position: CachePositionImpl, x_scale: number, y_scale: number, width: number, height: number): WebGLTexture | null;
494
506
  /**
495
507
  * @param {CanvasToWebGLContext} context
496
508
  * @param {Float32Array} [color_transform=null]
@@ -552,6 +564,12 @@ export declare class Graphics {
552
564
  * @private
553
565
  */
554
566
  _$margePath(data: any[]): void;
567
+ /**
568
+ * @return {string}
569
+ * @method
570
+ * @private
571
+ */
572
+ _$createCacheKey(): string;
555
573
  /**
556
574
  * @return {Float32Array}
557
575
  * @method
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,40 @@ 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";
249
+ /**
250
+ * @type {boolean}
251
+ * @default false
252
+ * @private
253
+ */
254
+ this._$posted = false;
221
255
  }
222
256
  /**
223
257
  * @description 指定されたクラスのストリングを返します。
@@ -538,6 +572,9 @@ export class Graphics {
538
572
  this._$pointerX = 0;
539
573
  this._$pointerY = 0;
540
574
  this._$canDraw = false;
575
+ this._$bitmapId = 0;
576
+ this._$mode = "shape";
577
+ this._$posted = false;
541
578
  // fill
542
579
  this._$fillType = 0;
543
580
  this._$fillGradient = null;
@@ -578,6 +615,10 @@ export class Graphics {
578
615
  this._$recode = null;
579
616
  this._$fills = null;
580
617
  this._$lines = null;
618
+ // cache clear
619
+ this._$cacheKeys.length = 0;
620
+ this._$uniqueKey = "";
621
+ this._$cacheParams.fill(0);
581
622
  // restart
582
623
  this._$restart();
583
624
  return this;
@@ -735,6 +776,7 @@ export class Graphics {
735
776
  x = +x || 0;
736
777
  y = +y || 0;
737
778
  radius = +radius || 0;
779
+ radius = $Math.round(radius);
738
780
  this._$setBounds(x - radius, y - radius);
739
781
  this._$setBounds(x + radius, y + radius);
740
782
  this._$margePath($getArray(Graphics.MOVE_TO, x + radius, y, Graphics.ARC, x, y, radius));
@@ -761,6 +803,8 @@ export class Graphics {
761
803
  y = +y || 0;
762
804
  width = +width || 0;
763
805
  height = +height || 0;
806
+ width = $Math.round(width);
807
+ height = $Math.round(height);
764
808
  const hw = width / 2; // half width
765
809
  const hh = height / 2; // half height
766
810
  const x0 = x + hw;
@@ -795,8 +839,8 @@ export class Graphics {
795
839
  y = +y || 0;
796
840
  width = +width || 0;
797
841
  height = +height || 0;
798
- const xMax = x + width;
799
- const yMax = y + height;
842
+ const xMax = $Math.round(x + width);
843
+ const yMax = $Math.round(y + height);
800
844
  return this
801
845
  .moveTo(x, y)
802
846
  .lineTo(x, yMax)
@@ -825,6 +869,10 @@ export class Graphics {
825
869
  height = +height || 0;
826
870
  ellipse_width = +ellipse_width || 0;
827
871
  ellipse_height = +ellipse_height || ellipse_width;
872
+ width = $Math.round(width);
873
+ height = $Math.round(height);
874
+ ellipse_width = $Math.round(ellipse_width);
875
+ ellipse_height = $Math.round(ellipse_height);
828
876
  const hew = ellipse_width / 2;
829
877
  const heh = ellipse_height / 2;
830
878
  const c = 4 / 3 * ($Math.SQRT2 - 1);
@@ -1216,14 +1264,6 @@ export class Graphics {
1216
1264
  default:
1217
1265
  break;
1218
1266
  }
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
1267
  let xScale = +$Math.sqrt(matrix[0] * matrix[0]
1228
1268
  + matrix[1] * matrix[1]);
1229
1269
  if (!$Number.isInteger(xScale)) {
@@ -1244,55 +1284,95 @@ export class Graphics {
1244
1284
  }
1245
1285
  yScale = +yScale.toFixed(4);
1246
1286
  }
1247
- if (0 > xMin + width || 0 > yMin + height) {
1248
- if (filters && filters.length
1249
- && displayObject._$canApply(filters)) {
1250
- let filterBounds = $getBoundsObject(0, width, 0, height);
1251
- for (let idx = 0; idx < filters.length; ++idx) {
1252
- filterBounds = filters[idx]
1253
- ._$generateFilterRect(filterBounds, xScale, yScale);
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;
1287
+ const canApply = filters !== null
1288
+ && filters.length > 0
1289
+ && displayObject._$canApply(filters);
1290
+ let filterBounds = $getBoundsObject(0, width, 0, height);
1291
+ if (canApply && filters) {
1292
+ for (let idx = 0; idx < filters.length; ++idx) {
1293
+ filterBounds = filters[idx]
1294
+ ._$generateFilterRect(filterBounds, xScale, yScale);
1264
1295
  }
1265
1296
  }
1297
+ // cache current buffer
1298
+ const manager = context.frameBuffer;
1299
+ const currentAttachment = manager.currentAttachment;
1300
+ if (!currentAttachment
1301
+ || xMin - filterBounds.xMin > currentAttachment.width
1302
+ || yMin - filterBounds.yMin > currentAttachment.height) {
1303
+ $poolBoundsObject(filterBounds);
1304
+ return;
1305
+ }
1306
+ if (0 > xMin + filterBounds.xMax || 0 > yMin + filterBounds.yMax) {
1307
+ $poolBoundsObject(filterBounds);
1308
+ return;
1309
+ }
1310
+ $poolBoundsObject(filterBounds);
1266
1311
  // get cache
1267
- const keys = $getArray(xScale, yScale);
1268
- let uniqueId = `${displayObject._$instanceId}`;
1269
- if (!hasGrid
1270
- && displayObject._$loaderInfo
1271
- && displayObject._$characterId) {
1272
- uniqueId = `${displayObject._$loaderInfo._$id}@${displayObject._$characterId}`;
1312
+ if (this._$uniqueKey === "") {
1313
+ if (!hasGrid
1314
+ && displayObject._$loaderInfo
1315
+ && displayObject._$characterId) {
1316
+ this._$uniqueKey = `${displayObject._$loaderInfo._$id}@${this._$bitmapId || displayObject._$characterId}`;
1317
+ }
1318
+ else {
1319
+ this._$uniqueKey = this._$createCacheKey();
1320
+ }
1273
1321
  }
1274
1322
  const player = $currentPlayer();
1275
- const cacheStore = player.cacheStore;
1276
- const cacheKeys = cacheStore.generateKeys(uniqueId, keys, color_transform);
1277
- $poolArray(keys);
1278
- let texture = cacheStore.get(cacheKeys);
1279
- if (!texture) {
1323
+ if (this._$mode === "bitmap") {
1324
+ if (!this._$cacheKeys.length) {
1325
+ this._$cacheKeys = $cacheStore.generateKeys(this._$uniqueKey);
1326
+ }
1327
+ }
1328
+ else {
1329
+ if (!this._$cacheKeys.length
1330
+ || this._$cacheParams[0] !== xScale
1331
+ || this._$cacheParams[1] !== yScale
1332
+ || this._$cacheParams[2] !== color_transform[7]) {
1333
+ const keys = $getArray();
1334
+ keys[0] = xScale;
1335
+ keys[1] = yScale;
1336
+ this._$cacheKeys = $cacheStore.generateKeys(this._$uniqueKey, keys, color_transform);
1337
+ $poolArray(keys);
1338
+ this._$cacheParams[0] = xScale;
1339
+ this._$cacheParams[1] = yScale;
1340
+ this._$cacheParams[2] = color_transform[7];
1341
+ }
1342
+ }
1343
+ context.cachePosition = $cacheStore.get(this._$cacheKeys);
1344
+ if (!context.cachePosition) {
1280
1345
  const currentAttachment = manager.currentAttachment;
1281
- // resize
1282
- let width = $Math.ceil($Math.abs(baseBounds.xMax - baseBounds.xMin) * xScale);
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;
1346
+ if (currentAttachment && currentAttachment.mask) {
1347
+ context.stopStencil();
1288
1348
  }
1289
- // create cache buffer
1290
- const attachment = manager
1291
- .createCacheAttachment(width, height, true);
1292
- context._$bind(attachment);
1349
+ let width = 0;
1350
+ let height = 0;
1351
+ if (this._$mode === "shape") {
1352
+ width = $Math.ceil($Math.abs(baseBounds.xMax - baseBounds.xMin) * xScale);
1353
+ height = $Math.ceil($Math.abs(baseBounds.yMax - baseBounds.yMin) * yScale);
1354
+ // resize
1355
+ const textureScale = context._$getTextureScale(width, height);
1356
+ if (textureScale < 1) {
1357
+ width *= textureScale;
1358
+ height *= textureScale;
1359
+ }
1360
+ }
1361
+ else {
1362
+ width = $Math.ceil($Math.abs(baseBounds.xMax - baseBounds.xMin));
1363
+ height = $Math.ceil($Math.abs(baseBounds.yMax - baseBounds.yMin));
1364
+ }
1365
+ // create cache position
1366
+ context.cachePosition = manager.createCachePosition(width, height);
1367
+ context.bindRenderBuffer(context.cachePosition);
1293
1368
  // reset
1294
1369
  context.reset();
1295
- context.setTransform(xScale, 0, 0, yScale, -baseBounds.xMin * xScale, -baseBounds.yMin * yScale);
1370
+ if (this._$mode === "shape") {
1371
+ context.setTransform(xScale, 0, 0, yScale, -baseBounds.xMin * xScale, -baseBounds.yMin * yScale);
1372
+ }
1373
+ else {
1374
+ context.setTransform(1, 0, 0, 1, -baseBounds.xMin, -baseBounds.yMin);
1375
+ }
1296
1376
  if (hasGrid) {
1297
1377
  const mScale = player.scaleX;
1298
1378
  const baseMatrix = $getFloat32Array6(mScale, 0, 0, mScale, 0, 0);
@@ -1303,8 +1383,8 @@ export class Graphics {
1303
1383
  ._$transform
1304
1384
  .concatenatedMatrix
1305
1385
  ._$matrix;
1306
- $poolFloat32Array6(aMatrixBase);
1307
1386
  const aMatrix = $getFloat32Array6(aMatrixBase[0], aMatrixBase[1], aMatrixBase[2], aMatrixBase[3], aMatrixBase[4] * mScale - xMin, aMatrixBase[5] * mScale - yMin);
1387
+ $poolFloat32Array6(aMatrixBase);
1308
1388
  const apMatrix = $multiplicationMatrix(aMatrix, pMatrix);
1309
1389
  const aOffsetX = apMatrix[4] - (matrix[4] - xMin);
1310
1390
  const aOffsetY = apMatrix[5] - (matrix[5] - yMin);
@@ -1317,62 +1397,103 @@ export class Graphics {
1317
1397
  const parentWidth = $Math.ceil($Math.abs(parentXMax - parentXMin));
1318
1398
  const parentHeight = $Math.ceil($Math.abs(parentYMax - parentYMin));
1319
1399
  $poolBoundsObject(parentBounds);
1320
- context.grid.enable(parentXMin, parentYMin, parentWidth, parentHeight, baseBounds, displayObject._$scale9Grid, mScale, pMatrix[0], pMatrix[1], pMatrix[2], pMatrix[3], pMatrix[4], pMatrix[5], aMatrix[0], aMatrix[1], aMatrix[2], aMatrix[3], aMatrix[4] - aOffsetX, aMatrix[5] - aOffsetY);
1400
+ const scale9Grid = displayObject._$scale9Grid;
1401
+ const grid = {
1402
+ "x": scale9Grid.x,
1403
+ "y": scale9Grid.y,
1404
+ "w": scale9Grid.width,
1405
+ "h": scale9Grid.height
1406
+ };
1407
+ context.grid.enable(parentXMin, parentYMin, parentWidth, parentHeight, baseBounds, grid, mScale, pMatrix[0], pMatrix[1], pMatrix[2], pMatrix[3], pMatrix[4], pMatrix[5], aMatrix[0], aMatrix[1], aMatrix[2], aMatrix[3], aMatrix[4] - aOffsetX, aMatrix[5] - aOffsetY);
1321
1408
  $poolFloat32Array6(pMatrix);
1322
1409
  $poolFloat32Array6(aMatrix);
1323
1410
  }
1324
- // plain alpha
1325
- color_transform[3] = 1;
1411
+ // execute
1326
1412
  this._$doDraw(context, color_transform, false);
1327
1413
  if (hasGrid) {
1328
1414
  context.grid.disable();
1329
1415
  }
1330
- texture = manager.getTextureFromCurrentAttachment();
1416
+ manager.transferTexture(context.cachePosition);
1331
1417
  // set cache
1332
- cacheStore.set(cacheKeys, texture);
1333
- // release buffer
1334
- manager.releaseAttachment(attachment, false);
1418
+ $cacheStore.set(this._$cacheKeys, context.cachePosition);
1335
1419
  // end draw and reset current buffer
1336
1420
  context._$bind(currentAttachment);
1337
1421
  }
1338
- let drawFilter = false;
1339
1422
  let offsetX = 0;
1340
1423
  let offsetY = 0;
1341
- if (filters && filters.length
1342
- && displayObject._$canApply(filters)) {
1343
- drawFilter = true;
1344
- texture = displayObject._$drawFilter(context, texture, matrix, filters, width, height);
1345
- if (texture) {
1346
- offsetX = texture._$offsetX;
1347
- offsetY = texture._$offsetY;
1424
+ if (canApply) {
1425
+ const bitmapTexture = this._$createBitmapTexture(context, context.cachePosition, xScale, yScale, width, height);
1426
+ const position = displayObject._$drawFilter(context, matrix, filters, width, height, bitmapTexture);
1427
+ if (position.offsetX) {
1428
+ offsetX = position.offsetX;
1348
1429
  }
1430
+ if (position.offsetY) {
1431
+ offsetY = position.offsetY;
1432
+ }
1433
+ // update
1434
+ context.cachePosition = position;
1349
1435
  }
1350
- const radianX = $Math.atan2(matrix[1], matrix[0]);
1351
- const radianY = $Math.atan2(-matrix[2], matrix[3]);
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]);
1436
+ if (!canApply && this._$mode === "bitmap") {
1437
+ 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
1438
  }
1361
1439
  else {
1362
- context.setTransform(1, 0, 0, 1, xMin - offsetX, yMin - offsetY);
1440
+ const radianX = $Math.atan2(matrix[1], matrix[0]);
1441
+ const radianY = $Math.atan2(-matrix[2], matrix[3]);
1442
+ if (!canApply && (radianX || radianY)) {
1443
+ const tx = baseBounds.xMin * xScale;
1444
+ const ty = baseBounds.yMin * yScale;
1445
+ const cosX = $Math.cos(radianX);
1446
+ const sinX = $Math.sin(radianX);
1447
+ const cosY = $Math.cos(radianY);
1448
+ const sinY = $Math.sin(radianY);
1449
+ context.setTransform(cosX, sinX, -sinY, cosY, tx * cosX - ty * sinY + matrix[4], tx * sinX + ty * cosY + matrix[5]);
1450
+ }
1451
+ else {
1452
+ context.setTransform(1, 0, 0, 1, xMin - offsetX, yMin - offsetY);
1453
+ }
1363
1454
  }
1364
1455
  // draw
1365
- if (texture) {
1366
- context.reset();
1456
+ if (context.cachePosition) {
1367
1457
  context.globalAlpha = alpha;
1368
- context.imageSmoothingEnabled = true;
1458
+ context.imageSmoothingEnabled = this._$mode === "shape";
1369
1459
  context.globalCompositeOperation = blend_mode;
1370
- context.drawImage(texture, 0, 0, texture.width, texture.height, color_transform);
1460
+ context.drawInstance(xMin - offsetX, yMin - offsetY, xMax, yMax, color_transform);
1461
+ // cache position clear
1462
+ context.cachePosition = null;
1371
1463
  }
1372
1464
  // pool
1373
- $poolArray(cacheKeys);
1374
1465
  $poolBoundsObject(baseBounds);
1375
1466
  }
1467
+ /**
1468
+ * @return {WebGLTexture | null}
1469
+ * @method
1470
+ * @private
1471
+ */
1472
+ _$createBitmapTexture(context, position, x_scale, y_scale, width, height) {
1473
+ if (this._$mode !== "bitmap") {
1474
+ return null;
1475
+ }
1476
+ context.drawInstacedArray();
1477
+ const manager = context.frameBuffer;
1478
+ const currentAttachment = manager.currentAttachment;
1479
+ const attachment = manager
1480
+ .createCacheAttachment(width, height);
1481
+ context._$bind(attachment);
1482
+ context.reset();
1483
+ const parentMatrix = $getFloat32Array6(x_scale, 0, 0, y_scale, width / 2, height / 2);
1484
+ const texture = context.getTextureFromRect(position);
1485
+ const baseMatrix = $getFloat32Array6(1, 0, 0, 1, -texture.width / 2, -texture.height / 2);
1486
+ const scaleMatrix = $multiplicationMatrix(parentMatrix, baseMatrix);
1487
+ $poolFloat32Array6(parentMatrix);
1488
+ $poolFloat32Array6(baseMatrix);
1489
+ context.setTransform(scaleMatrix[0], scaleMatrix[1], scaleMatrix[2], scaleMatrix[3], scaleMatrix[4], scaleMatrix[5]);
1490
+ context.drawImage(texture, 0, 0, texture.width, texture.height);
1491
+ const bitmapTexture = manager.getTextureFromCurrentAttachment();
1492
+ context._$bind(currentAttachment);
1493
+ manager.releaseAttachment(attachment);
1494
+ manager.textureManager.release(texture);
1495
+ return bitmapTexture;
1496
+ }
1376
1497
  /**
1377
1498
  * @param {CanvasToWebGLContext} context
1378
1499
  * @param {Float32Array} [color_transform=null]
@@ -1420,16 +1541,14 @@ export class Graphics {
1420
1541
  */
1421
1542
  _$restart() {
1422
1543
  if (this._$displayObject) {
1544
+ // reset
1423
1545
  this._$displayObject._$posted = false;
1424
- this._$buffer = null;
1425
1546
  if (!this._$displayObject._$isUpdated()) {
1426
1547
  this._$displayObject._$doChanged();
1427
1548
  $doUpdated();
1428
- const player = $currentPlayer();
1429
- const cacheStore = player.cacheStore;
1430
- cacheStore.removeCache(this._$displayObject._$instanceId);
1549
+ $cacheStore.removeCache(this._$displayObject._$instanceId);
1431
1550
  if (this._$displayObject._$characterId) {
1432
- cacheStore.removeCache(this._$displayObject._$characterId);
1551
+ $cacheStore.removeCache(this._$displayObject._$characterId);
1433
1552
  }
1434
1553
  }
1435
1554
  }
@@ -1596,6 +1715,31 @@ export class Graphics {
1596
1715
  }
1597
1716
  $poolArray(data);
1598
1717
  }
1718
+ /**
1719
+ * @return {string}
1720
+ * @method
1721
+ * @private
1722
+ */
1723
+ _$createCacheKey() {
1724
+ if (this._$doLine) {
1725
+ this.endLine();
1726
+ }
1727
+ // fixed logic
1728
+ if (this._$doFill) {
1729
+ this.endFill();
1730
+ }
1731
+ if (!this._$recode) {
1732
+ return "";
1733
+ }
1734
+ const recodes = this._$getRecodes();
1735
+ let hash = 0;
1736
+ for (let idx = 0; idx < recodes.length; idx++) {
1737
+ const chr = recodes[idx];
1738
+ hash = (hash << 5) - hash + chr;
1739
+ hash |= 0;
1740
+ }
1741
+ return `${hash}`;
1742
+ }
1599
1743
  /**
1600
1744
  * @return {Float32Array}
1601
1745
  * @method
@@ -1762,9 +1906,7 @@ export class Graphics {
1762
1906
  const bitmapData = recode[idx++];
1763
1907
  let buffer;
1764
1908
  if (bitmapData.image !== null || bitmapData.canvas !== null) {
1765
- const player = $currentPlayer();
1766
- const cacheStore = player.cacheStore;
1767
- const canvas = cacheStore.getCanvas();
1909
+ const canvas = $cacheStore.getCanvas();
1768
1910
  const width = bitmapData.width;
1769
1911
  const height = bitmapData.height;
1770
1912
  canvas.width = width;
@@ -1776,7 +1918,7 @@ export class Graphics {
1776
1918
  // @ts-ignore
1777
1919
  context.drawImage(bitmapData.image || bitmapData.canvas, 0, 0);
1778
1920
  buffer = new Uint8Array(context.getImageData(0, 0, width, height).data);
1779
- cacheStore.destroy(context);
1921
+ $cacheStore.destroy(context);
1780
1922
  }
1781
1923
  else if (bitmapData._$buffer !== null) {
1782
1924
  buffer = bitmapData._$buffer;
@@ -1833,9 +1975,7 @@ export class Graphics {
1833
1975
  const bitmapData = recode[idx++];
1834
1976
  let buffer;
1835
1977
  if (bitmapData.image !== null || bitmapData.canvas !== null) {
1836
- const player = $currentPlayer();
1837
- const cacheStore = player.cacheStore;
1838
- const canvas = cacheStore.getCanvas();
1978
+ const canvas = $cacheStore.getCanvas();
1839
1979
  const width = bitmapData.width;
1840
1980
  const height = bitmapData.height;
1841
1981
  canvas.width = width;
@@ -1847,7 +1987,7 @@ export class Graphics {
1847
1987
  // @ts-ignore
1848
1988
  context.drawImage(bitmapData.image || bitmapData.canvas, 0, 0);
1849
1989
  buffer = new Uint8Array(context.getImageData(0, 0, width, height).data);
1850
- cacheStore.destroy(context);
1990
+ $cacheStore.destroy(context);
1851
1991
  }
1852
1992
  else if (bitmapData._$buffer !== null) {
1853
1993
  buffer = bitmapData._$buffer;
@@ -1929,8 +2069,8 @@ export class Graphics {
1929
2069
  color[2] = recode[idx++] / 255;
1930
2070
  color[3] = recode[idx++] / 255;
1931
2071
  if (color_transform !== null) {
1932
- if (color_transform[3] !== 1 || color_transform[7] !== 0) {
1933
- color[3] = $Math.max(0, $Math.min(color[3] * color_transform[3] + color_transform[7], 255)) / 255;
2072
+ if (color_transform[7] !== 0) {
2073
+ color[3] = $Math.max(0, $Math.min(color[3] * color_transform[7], 255)) / 255;
1934
2074
  }
1935
2075
  }
1936
2076
  context.fillStyle = color;
@@ -1961,8 +2101,8 @@ export class Graphics {
1961
2101
  color[2] = recode[idx++] / 255;
1962
2102
  color[3] = recode[idx++] / 255;
1963
2103
  if (color_transform !== null) {
1964
- if (color_transform[3] !== 1 || color_transform[7] !== 0) {
1965
- color[3] = $Math.max(0, $Math.min(color[3] * color_transform[3] + color_transform[7], 255)) / 255;
2104
+ if (color_transform[7] !== 0) {
2105
+ color[3] = $Math.max(0, $Math.min(color[3] + color_transform[7], 255)) / 255;
1966
2106
  }
1967
2107
  }
1968
2108
  context.strokeStyle = color;
@@ -2018,8 +2158,8 @@ export class Graphics {
2018
2158
  const color = stops[idx];
2019
2159
  let alpha = color.A;
2020
2160
  if (color_transform) {
2021
- if (color_transform[3] !== 1 || color_transform[7] !== 0) {
2022
- alpha = $Math.max(0, $Math.min(color.A * color_transform[3] + color_transform[7], 255)) | 0;
2161
+ if (color_transform[7] !== 0) {
2162
+ alpha = $Math.max(0, $Math.min(color.A + color_transform[7], 255)) | 0;
2023
2163
  }
2024
2164
  }
2025
2165
  css.addColorStop(color.ratio, $getFloat32Array4(color.R, color.G, color.B, alpha));
@@ -2067,8 +2207,8 @@ export class Graphics {
2067
2207
  const color = stops[idx];
2068
2208
  let alpha = color.A;
2069
2209
  if (color_transform) {
2070
- if (color_transform[3] !== 1 || color_transform[7] !== 0) {
2071
- alpha = $Math.max(0, $Math.min(color.A * color_transform[3] + color_transform[7], 255)) | 0;
2210
+ if (color_transform[7] !== 0) {
2211
+ alpha = $Math.max(0, $Math.min(color.A + color_transform[7], 255)) | 0;
2072
2212
  }
2073
2213
  }
2074
2214
  css.addColorStop(color.ratio, $getFloat32Array4(color.R, color.G, color.B, alpha));
@@ -2104,14 +2244,14 @@ export class Graphics {
2104
2244
  if (!texture || !color_transform) {
2105
2245
  break;
2106
2246
  }
2107
- if (!repeat
2108
- && bitmapData.width === this._$xMax - this._$xMin
2109
- && bitmapData.height === this._$yMax - this._$yMin) {
2110
- context.drawImage(texture, 0, 0, bitmapData.width, bitmapData.height);
2247
+ context.imageSmoothingEnabled = smooth;
2248
+ if (this._$bitmapId
2249
+ || bitmapData.width === this._$xMax - this._$xMin
2250
+ && bitmapData.height === this._$yMax - this._$yMin) {
2251
+ context.drawBitmap(texture);
2111
2252
  }
2112
2253
  else {
2113
2254
  context.fillStyle = context.createPattern(texture, repeat, color_transform);
2114
- context.imageSmoothingEnabled = smooth;
2115
2255
  context.fill();
2116
2256
  }
2117
2257
  // restore
package/dist/Loader.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { DisplayObjectContainer } from "./DisplayObjectContainer";
2
2
  import { LoaderInfo } from "./LoaderInfo";
3
3
  import { URLRequest } from "@next2d/net";
4
- import type { NoCodeDataImpl, ParentImpl } from "@next2d/interface";
4
+ import type { NoCodeDataZlibImpl, NoCodeDataImpl, ParentImpl } from "@next2d/interface";
5
5
  /**
6
6
  * Loader クラスは、JSON ファイルまたはイメージ(JPEG、PNG、または GIF)ファイルを読み込むために使用します。
7
7
  * 読み込みを開始するには load() メソッドを使用します。
@@ -92,6 +92,16 @@ export declare class Loader extends DisplayObjectContainer {
92
92
  * @public
93
93
  */
94
94
  load(request: URLRequest): void;
95
+ /**
96
+ * @description NoCodeToolのJSONを直接読み込む
97
+ * Read JSON directly from NoCodeTool
98
+ *
99
+ * @param {string} json
100
+ * @return {void}
101
+ * @method
102
+ * @public
103
+ */
104
+ loadJSON(json: NoCodeDataZlibImpl | NoCodeDataImpl): void;
95
105
  /**
96
106
  * @param {ProgressEvent} event
97
107
  * @return {void}