@m2c2kit/core 0.3.11 → 0.3.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +116 -92
  2. package/dist/index.js +386 -183
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ var ActionType = /* @__PURE__ */ ((ActionType2) => {
5
5
  ActionType2["Custom"] = "Custom";
6
6
  ActionType2["Move"] = "Move";
7
7
  ActionType2["Scale"] = "Scale";
8
+ ActionType2["FadeAlpha"] = "FadeAlpha";
8
9
  return ActionType2;
9
10
  })(ActionType || {});
10
11
 
@@ -218,6 +219,21 @@ class Action {
218
219
  options.runDuringTransition
219
220
  );
220
221
  }
222
+ /**
223
+ * Creates an action that will change the entity's alpha (opacity).
224
+ *
225
+ * @remarks Alpha has multiplicative inheritance. For example, if the entity's parent is alpha .5 and this entity's action fades alpha to .4, then the entity will appear with alpha .2.
226
+ *
227
+ * @param options - {@link FadeAlphaActionOptions}
228
+ * @returns The fadeAlpha action
229
+ */
230
+ static fadeAlpha(options) {
231
+ return new FadeAlphaAction(
232
+ options.alpha,
233
+ options.duration,
234
+ options.runDuringTransition
235
+ );
236
+ }
221
237
  /**
222
238
  * Creates an array of actions that will be run in order.
223
239
  *
@@ -304,6 +320,15 @@ class Action {
304
320
  });
305
321
  break;
306
322
  }
323
+ case ActionType.FadeAlpha: {
324
+ const fadeAlpha = action;
325
+ cloned = Action.fadeAlpha({
326
+ alpha: fadeAlpha.alpha,
327
+ duration: fadeAlpha.duration,
328
+ runDuringTransition: fadeAlpha.runDuringTransition
329
+ });
330
+ break;
331
+ }
307
332
  case ActionType.Wait: {
308
333
  const wait = action;
309
334
  cloned = Action.wait({
@@ -391,6 +416,20 @@ class Action {
391
416
  scaleAction.completed = true;
392
417
  }
393
418
  }
419
+ if (action.type === ActionType.FadeAlpha) {
420
+ const fadeAlphaAction = action;
421
+ if (!fadeAlphaAction.started) {
422
+ fadeAlphaAction.delta = fadeAlphaAction.alpha - entity.alpha;
423
+ fadeAlphaAction.started = true;
424
+ }
425
+ if (elapsed < fadeAlphaAction.duration) {
426
+ entity.alpha = entity.alpha + fadeAlphaAction.delta * (dt / fadeAlphaAction.duration);
427
+ } else {
428
+ entity.alpha = fadeAlphaAction.alpha;
429
+ fadeAlphaAction.running = false;
430
+ fadeAlphaAction.completed = true;
431
+ }
432
+ }
394
433
  }
395
434
  /**
396
435
  * Calculates the duration of an action, including any children actions
@@ -572,6 +611,17 @@ class ScaleAction extends Action {
572
611
  this.isParent = false;
573
612
  }
574
613
  }
614
+ class FadeAlphaAction extends Action {
615
+ constructor(alpha, duration, runDuringTransition = false) {
616
+ super(runDuringTransition);
617
+ __publicField$j(this, "type", ActionType.FadeAlpha);
618
+ __publicField$j(this, "alpha");
619
+ __publicField$j(this, "delta", 0);
620
+ this.duration = duration;
621
+ this.alpha = alpha;
622
+ this.isParent = false;
623
+ }
624
+ }
575
625
 
576
626
  var ActivityType = /* @__PURE__ */ ((ActivityType2) => {
577
627
  ActivityType2["Game"] = "Game";
@@ -588,7 +638,7 @@ class CanvasKitHelpers {
588
638
  * free these wasm objects.
589
639
  */
590
640
  static Dispose(objects) {
591
- objects.filter((o) => !(o == null ? void 0 : o.isDeleted)).forEach((o) => o == null ? void 0 : o.delete());
641
+ objects.filter((o) => !(o == null ? void 0 : o.isDeleted())).forEach((o) => o == null ? void 0 : o.delete());
592
642
  }
593
643
  static makePaint(canvasKit, color, style, isAntialiased) {
594
644
  const paint = new canvasKit.Paint();
@@ -749,28 +799,28 @@ class Uuid {
749
799
  }
750
800
  }
751
801
 
752
- var EventType = /* @__PURE__ */ ((EventType2) => {
753
- EventType2["SessionInitialize"] = "SessionInitialize";
754
- EventType2["SessionStart"] = "SessionStart";
755
- EventType2["SessionEnd"] = "SessionEnd";
756
- EventType2["ActivityStart"] = "ActivityStart";
757
- EventType2["ActivityEnd"] = "ActivityEnd";
758
- EventType2["ActivityCancel"] = "ActivityCancel";
759
- EventType2["ActivityData"] = "ActivityData";
760
- EventType2["TapDown"] = "TapDown";
761
- EventType2["TapUp"] = "TapUp";
762
- EventType2["TapUpAny"] = "TapUpAny";
763
- EventType2["TapLeave"] = "TapLeave";
764
- EventType2["PointerDown"] = "PointerDown";
765
- EventType2["PointerUp"] = "PointerUp";
766
- EventType2["PointerMove"] = "PointerMove";
767
- EventType2["Drag"] = "Drag";
768
- EventType2["DragStart"] = "DragStart";
769
- EventType2["DragEnd"] = "DragEnd";
770
- EventType2["CompositeCustom"] = "CompositeCustom";
771
- EventType2["FrameDidSimulatePhysics"] = "FrameDidSimulatePhysics";
772
- return EventType2;
773
- })(EventType || {});
802
+ const EventType = {
803
+ SessionInitialize: "SessionInitialize",
804
+ SessionStart: "SessionStart",
805
+ SessionEnd: "SessionEnd",
806
+ ActivityStart: "ActivityStart",
807
+ ActivityEnd: "ActivityEnd",
808
+ ActivityCancel: "ActivityCancel",
809
+ ActivityData: "ActivityData",
810
+ TapDown: "TapDown",
811
+ TapUp: "TapUp",
812
+ TapUpAny: "TapUpAny",
813
+ TapLeave: "TapLeave",
814
+ PointerDown: "PointerDown",
815
+ PointerUp: "PointerUp",
816
+ PointerMove: "PointerMove",
817
+ PointerLeave: "PointerLeave",
818
+ Drag: "Drag",
819
+ DragStart: "DragStart",
820
+ DragEnd: "DragEnd",
821
+ CompositeCustom: "CompositeCustom",
822
+ FrameDidSimulatePhysics: "FrameDidSimulatePhysics"
823
+ };
774
824
 
775
825
  var __defProp$g = Object.defineProperty;
776
826
  var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -782,21 +832,21 @@ function handleDrawableOptions(drawable, options) {
782
832
  if (options.anchorPoint) {
783
833
  drawable.anchorPoint = options.anchorPoint;
784
834
  }
785
- if (options.zPosition) {
835
+ if (options.zPosition !== void 0) {
786
836
  drawable.zPosition = options.zPosition;
787
837
  }
788
838
  }
789
839
  function handleTextOptions(text, options) {
790
- if (options.text) {
840
+ if (options.text !== void 0) {
791
841
  text.text = options.text;
792
842
  }
793
- if (options.fontName) {
843
+ if (options.fontName !== void 0) {
794
844
  text.fontName = options.fontName;
795
845
  }
796
846
  if (options.fontColor) {
797
847
  text.fontColor = options.fontColor;
798
848
  }
799
- if (options.fontSize) {
849
+ if (options.fontSize !== void 0) {
800
850
  text.fontSize = options.fontSize;
801
851
  }
802
852
  }
@@ -822,6 +872,7 @@ class Entity {
822
872
  __publicField$g(this, "position", { x: 0, y: 0 });
823
873
  // position of the entity in the parent coordinate system
824
874
  __publicField$g(this, "scale", 1);
875
+ __publicField$g(this, "alpha", 1);
825
876
  __publicField$g(this, "isUserInteractionEnabled", false);
826
877
  __publicField$g(this, "draggable", false);
827
878
  __publicField$g(this, "hidden", false);
@@ -833,6 +884,8 @@ class Entity {
833
884
  // position within the root coordinate system
834
885
  __publicField$g(this, "size", { width: 0, height: 0 });
835
886
  __publicField$g(this, "absoluteScale", 1);
887
+ __publicField$g(this, "absoluteAlpha", 1);
888
+ __publicField$g(this, "absoluteAlphaChange", 0);
836
889
  __publicField$g(this, "actions", new Array());
837
890
  __publicField$g(this, "queuedAction");
838
891
  __publicField$g(this, "originalActions", new Array());
@@ -846,6 +899,7 @@ class Entity {
846
899
  /** Is the entity in a pressed state? E.g., did the user put the pointer
847
900
  * down on the entity and not yet release it? */
848
901
  __publicField$g(this, "pressed", false);
902
+ __publicField$g(this, "withinHitArea", false);
849
903
  /** Is the entity in a pressed state AND is the pointer within the entity's
850
904
  * hit area? For example, a user may put the pointer down on the entity, but
851
905
  * then move the pointer, while still down, beyond the entity's hit area. In
@@ -881,22 +935,25 @@ class Entity {
881
935
  } else {
882
936
  this.name = options.name;
883
937
  }
884
- if (options.position) {
938
+ if (options.position !== void 0) {
885
939
  this.position = options.position;
886
940
  }
887
- if (options.scale) {
941
+ if (options.scale !== void 0) {
888
942
  this.scale = options.scale;
889
943
  }
890
- if (options.isUserInteractionEnabled) {
944
+ if (options.alpha !== void 0) {
945
+ this.alpha = options.alpha;
946
+ }
947
+ if (options.isUserInteractionEnabled !== void 0) {
891
948
  this.isUserInteractionEnabled = options.isUserInteractionEnabled;
892
949
  }
893
- if (options.draggable) {
950
+ if (options.draggable !== void 0) {
894
951
  this.draggable = options.draggable;
895
952
  }
896
- if (options.hidden) {
953
+ if (options.hidden !== void 0) {
897
954
  this.hidden = options.hidden;
898
955
  }
899
- if (options.layout) {
956
+ if (options.layout !== void 0) {
900
957
  this.layout = options.layout;
901
958
  }
902
959
  }
@@ -1130,17 +1187,13 @@ class Entity {
1130
1187
  * the bounds of the entity.
1131
1188
  *
1132
1189
  * @param callback - function to execute
1133
- * @param replaceExistingCallback - should the provided callback replace
1134
- * any existing callbacks of the same event type on this entity? Usually
1135
- * there should be only one callback defined, instead of chaining multiple
1136
- * ones. It is strongly recommended not to change this, unless you have a
1137
- * special use case. Default is true.
1190
+ * @param options - {@link CallbackOptions}
1138
1191
  */
1139
- onTapDown(callback, callbackOptions) {
1192
+ onTapDown(callback, options) {
1140
1193
  this.addEventListener(
1141
1194
  EventType.TapDown,
1142
1195
  callback,
1143
- callbackOptions
1196
+ options
1144
1197
  );
1145
1198
  }
1146
1199
  /**
@@ -1152,17 +1205,13 @@ class Entity {
1152
1205
  * beyond the bounds of the entity.
1153
1206
  *
1154
1207
  * @param callback - function to execute
1155
- * @param replaceExistingCallback - should the provided callback replace
1156
- * any existing callbacks of the same event type on this entity? Usually
1157
- * there should be only one callback defined, instead of chaining multiple
1158
- * ones. It is strongly recommended not to change this, unless you have a
1159
- * special use case. Default is true.
1208
+ * @param options - {@link CallbackOptions}ue.
1160
1209
  */
1161
- onTapUp(callback, callbackOptions) {
1210
+ onTapUp(callback, options) {
1162
1211
  this.addEventListener(
1163
1212
  EventType.TapUp,
1164
1213
  callback,
1165
- callbackOptions
1214
+ options
1166
1215
  );
1167
1216
  }
1168
1217
  /**
@@ -1175,17 +1224,13 @@ class Entity {
1175
1224
  * release.
1176
1225
  *
1177
1226
  * @param callback - function to execute
1178
- * @param replaceExistingCallback - should the provided callback replace
1179
- * any existing callbacks of the same event type on this entity? Usually
1180
- * there should be only one callback defined, instead of chaining multiple
1181
- * ones. It is strongly recommended not to change this, unless you have a
1182
- * special use case. Default is true.
1227
+ * @param options - {@link CallbackOptions}
1183
1228
  */
1184
- onTapUpAny(callback, callbackOptions) {
1229
+ onTapUpAny(callback, options) {
1185
1230
  this.addEventListener(
1186
1231
  EventType.TapUpAny,
1187
1232
  callback,
1188
- callbackOptions
1233
+ options
1189
1234
  );
1190
1235
  }
1191
1236
  /**
@@ -1197,17 +1242,13 @@ class Entity {
1197
1242
  * before the press release.
1198
1243
  *
1199
1244
  * @param callback - function to execute
1200
- * @param replaceExistingCallback - should the provided callback replace
1201
- * any existing callbacks of the same event type on this entity? Usually
1202
- * there should be only one callback defined, instead of chaining multiple
1203
- * ones. It is strongly recommended not to change this, unless you have a
1204
- * special use case. Default is true.
1245
+ * @param options - {@link CallbackOptions}
1205
1246
  */
1206
- onTapLeave(callback, callbackOptions) {
1247
+ onTapLeave(callback, options) {
1207
1248
  this.addEventListener(
1208
1249
  EventType.TapLeave,
1209
1250
  callback,
1210
- callbackOptions
1251
+ options
1211
1252
  );
1212
1253
  }
1213
1254
  /**
@@ -1217,17 +1258,13 @@ class Entity {
1217
1258
  * the bounds of the entity. It occurs under the same conditions as TapDown.
1218
1259
  *
1219
1260
  * @param callback - function to execute
1220
- * @param replaceExistingCallback - should the provided callback replace
1221
- * any existing callbacks of the same event type on this entity? Usually
1222
- * there should be only one callback defined, instead of chaining multiple
1223
- * ones. It is strongly recommended not to change this, unless you have a
1224
- * special use case. Default is true.
1261
+ * @param options - {@link CallbackOptions}
1225
1262
  */
1226
- onPointerDown(callback, callbackOptions) {
1263
+ onPointerDown(callback, options) {
1227
1264
  this.addEventListener(
1228
1265
  EventType.PointerDown,
1229
1266
  callback,
1230
- callbackOptions
1267
+ options
1231
1268
  );
1232
1269
  }
1233
1270
  /**
@@ -1239,17 +1276,13 @@ class Entity {
1239
1276
  * previous PointerDown on the entity.
1240
1277
  *
1241
1278
  * @param callback - function to execute
1242
- * @param replaceExistingCallback - should the provided callback replace
1243
- * any existing callbacks of the same event type on this entity? Usually
1244
- * there should be only one callback defined, instead of chaining multiple
1245
- * ones. It is strongly recommended not to change this, unless you have a
1246
- * special use case. Default is true.
1279
+ * @param options - {@link CallbackOptions}
1247
1280
  */
1248
- onPointerUp(callback, callbackOptions) {
1281
+ onPointerUp(callback, options) {
1249
1282
  this.addEventListener(
1250
1283
  EventType.PointerUp,
1251
1284
  callback,
1252
- callbackOptions
1285
+ options
1253
1286
  );
1254
1287
  }
1255
1288
  /**
@@ -1257,68 +1290,66 @@ class Entity {
1257
1290
  * within the bounds of the entity.
1258
1291
  *
1259
1292
  * @param callback - function to execute
1260
- * @param replaceExistingCallback - should the provided callback replace
1261
- * any existing callbacks of the same event type on this entity? Usually
1262
- * there should be only one callback defined, instead of chaining multiple
1263
- * ones. It is strongly recommended not to change this, unless you have a
1264
- * special use case. Default is true.
1293
+ * @param options - {@link CallbackOptions}
1265
1294
  */
1266
- onPointerMove(callback, callbackOptions) {
1295
+ onPointerMove(callback, options) {
1267
1296
  this.addEventListener(
1268
1297
  EventType.PointerMove,
1269
1298
  callback,
1270
- callbackOptions
1299
+ options
1300
+ );
1301
+ }
1302
+ /**
1303
+ * Executes a callback when the user moves the pointer (mouse or touches)
1304
+ * outside the bounds of the entity.
1305
+ *
1306
+ * @param callback - function to execute
1307
+ * @param options - {@link CallbackOptions}
1308
+ */
1309
+ onPointerLeave(callback, options) {
1310
+ this.addEventListener(
1311
+ EventType.PointerLeave,
1312
+ callback,
1313
+ options
1271
1314
  );
1272
1315
  }
1273
1316
  /**
1274
1317
  * Executes a callback when the user begins dragging an entity.
1275
1318
  *
1276
1319
  * @param callback - function to execute
1277
- * @param replaceExistingCallback - should the provided callback replace
1278
- * any existing callbacks of the same event type on this entity? Usually
1279
- * there should be only one callback defined, instead of chaining multiple
1280
- * ones. It is strongly recommended not to change this, unless you have a
1281
- * special use case. Default is true.
1320
+ * @param options - {@link CallbackOptions}
1282
1321
  */
1283
- onDragStart(callback, callbackOptions) {
1322
+ onDragStart(callback, options) {
1284
1323
  this.addEventListener(
1285
1324
  EventType.DragStart,
1286
1325
  callback,
1287
- callbackOptions
1326
+ options
1288
1327
  );
1289
1328
  }
1290
1329
  /**
1291
1330
  * Executes a callback when the user continues dragging an entity.
1292
1331
  *
1293
1332
  * @param callback - function to execute
1294
- * @param replaceExistingCallback - should the provided callback replace
1295
- * any existing callbacks of the same event type on this entity? Usually
1296
- * there should be only one callback defined, instead of chaining multiple
1297
- * ones. It is strongly recommended not to change this, unless you have a
1298
- * special use case. Default is true.
1333
+ * @param options - {@link CallbackOptions}
1299
1334
  */
1300
- onDrag(callback, callbackOptions) {
1335
+ onDrag(callback, options) {
1301
1336
  this.addEventListener(
1302
1337
  EventType.Drag,
1303
1338
  callback,
1304
- callbackOptions
1339
+ options
1305
1340
  );
1306
1341
  }
1307
1342
  /**
1308
1343
  * Executes a callback when the user stop dragging an entity.
1309
1344
  *
1310
1345
  * @param callback - function to execute
1311
- * @param replaceExistingCallback - should the provided callback replace
1312
- * any existing callbacks of the same event type on this entity? Usually
1313
- * there should be only one callback defined, instead of chaining multiple
1314
- * ones. It is strongly recommended not to change this, unless you have a
1315
- * special use case. Default is true.
1346
+ * @param options - {@link CallbackOptions}
1316
1347
  */
1317
- onDragEnd(callback, callbackOptions) {
1348
+ onDragEnd(callback, options) {
1318
1349
  this.addEventListener(
1319
1350
  EventType.DragEnd,
1320
1351
  callback,
1321
- callbackOptions
1352
+ options
1322
1353
  );
1323
1354
  }
1324
1355
  addEventListener(type, callback, callbackOptions) {
@@ -1408,12 +1439,30 @@ class Entity {
1408
1439
  }
1409
1440
  return x;
1410
1441
  }
1442
+ /**
1443
+ * Calculates the absolute alpha of the entity, taking into account the
1444
+ * alpha of all ancestor parent entities.
1445
+ *
1446
+ * @remarks Alpha has multiplicative inheritance from all ancestors.
1447
+ *
1448
+ * @param alpha - Opacity of the entity
1449
+ * @param ancestors - Array of ancestor parent entities
1450
+ * @returns
1451
+ */
1452
+ calculateAbsoluteAlpha(alpha, ancestors) {
1453
+ const inheritedAlpha = ancestors.reduce((acc, ancestor) => {
1454
+ return acc * ancestor.alpha;
1455
+ }, 1);
1456
+ return alpha * inheritedAlpha;
1457
+ }
1411
1458
  update() {
1412
1459
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
1413
1460
  if (this.needsInitialization) {
1414
1461
  this.initialize();
1415
1462
  this.needsInitialization = false;
1416
1463
  }
1464
+ this.absoluteAlphaChange = this.calculateAbsoluteAlpha(this.alpha, this.ancestors) - this.absoluteAlpha;
1465
+ this.absoluteAlpha += this.absoluteAlphaChange;
1417
1466
  if (this.parent === void 0) {
1418
1467
  this.absolutePosition.x = this.position.x * this.scale;
1419
1468
  this.absolutePosition.y = this.position.y * this.scale;
@@ -2368,8 +2417,9 @@ class Sprite extends Entity {
2368
2417
  __publicField$b(this, "_imageName", "");
2369
2418
  // public getter/setter is below
2370
2419
  __publicField$b(this, "loadedImage");
2420
+ __publicField$b(this, "_paint");
2371
2421
  handleInterfaceOptions(this, options);
2372
- if (options.imageName) {
2422
+ if (options.imageName !== void 0) {
2373
2423
  this.imageName = options.imageName;
2374
2424
  }
2375
2425
  }
@@ -2388,11 +2438,14 @@ class Sprite extends Entity {
2388
2438
  }
2389
2439
  this.size.width = this.loadedImage.width;
2390
2440
  this.size.height = this.loadedImage.height;
2441
+ if (!this._paint) {
2442
+ this.paint = new this.canvasKit.Paint();
2443
+ }
2391
2444
  this.needsInitialization = false;
2392
2445
  }
2393
2446
  dispose() {
2394
2447
  var _a;
2395
- CanvasKitHelpers.Dispose([(_a = this.loadedImage) == null ? void 0 : _a.image]);
2448
+ CanvasKitHelpers.Dispose([(_a = this.loadedImage) == null ? void 0 : _a.image, this._paint]);
2396
2449
  }
2397
2450
  set imageName(imageName) {
2398
2451
  this._imageName = imageName;
@@ -2401,6 +2454,17 @@ class Sprite extends Entity {
2401
2454
  get imageName() {
2402
2455
  return this._imageName;
2403
2456
  }
2457
+ set paint(paint) {
2458
+ this._paint = paint;
2459
+ }
2460
+ get paint() {
2461
+ if (!this._paint) {
2462
+ throw new Error(
2463
+ `in paint getter: Sprite entity ${this.toString()} paint is undefined.`
2464
+ );
2465
+ }
2466
+ return this._paint;
2467
+ }
2404
2468
  /**
2405
2469
  * Duplicates an entity using deep copy.
2406
2470
  *
@@ -2436,7 +2500,10 @@ class Sprite extends Entity {
2436
2500
  canvas.scale(1 / drawScale, 1 / drawScale);
2437
2501
  const x = (this.absolutePosition.x - this.size.width * this.anchorPoint.x * this.absoluteScale) * drawScale;
2438
2502
  const y = (this.absolutePosition.y - this.size.height * this.anchorPoint.y * this.absoluteScale) * drawScale;
2439
- canvas.drawImage(this.loadedImage.image, x, y);
2503
+ if (this.absoluteAlphaChange !== 0) {
2504
+ this.paint.setAlphaf(this.absoluteAlpha);
2505
+ }
2506
+ canvas.drawImage(this.loadedImage.image, x, y, this.paint);
2440
2507
  canvas.restore();
2441
2508
  }
2442
2509
  super.drawChildren(canvas);
@@ -2521,16 +2588,15 @@ class Scene extends Entity {
2521
2588
  this.scale = Globals.rootScale;
2522
2589
  this.size.width = this.game.canvasCssWidth;
2523
2590
  this.size.height = this.game.canvasCssHeight;
2524
- this.backgroundPaint = new this.canvasKit.Paint();
2525
- this.backgroundPaint.setColor(
2526
- this.canvasKit.Color(
2527
- this.backgroundColor[0],
2528
- this.backgroundColor[1],
2529
- this.backgroundColor[2],
2530
- this.backgroundColor[3]
2531
- )
2591
+ if (this.backgroundPaint) {
2592
+ this.backgroundPaint.delete();
2593
+ }
2594
+ this.backgroundPaint = CanvasKitHelpers.makePaint(
2595
+ this.canvasKit,
2596
+ this.backgroundColor,
2597
+ this.canvasKit.PaintStyle.Fill,
2598
+ false
2532
2599
  );
2533
- this.backgroundPaint.setStyle(this.canvasKit.PaintStyle.Fill);
2534
2600
  this.needsInitialization = false;
2535
2601
  }
2536
2602
  dispose() {
@@ -2607,6 +2673,9 @@ class Scene extends Entity {
2607
2673
  onAppear(callback) {
2608
2674
  this._appearCallback = callback;
2609
2675
  }
2676
+ update() {
2677
+ super.update();
2678
+ }
2610
2679
  draw(canvas) {
2611
2680
  canvas.save();
2612
2681
  const drawScale = Globals.canvasScale / this.absoluteScale;
@@ -2614,6 +2683,9 @@ class Scene extends Entity {
2614
2683
  if (!this.backgroundPaint) {
2615
2684
  throw new Error(`in Scene ${this}, background paint is undefined.`);
2616
2685
  }
2686
+ if (this.absoluteAlphaChange !== 0) {
2687
+ this.backgroundPaint.setAlphaf(this.absoluteAlpha);
2688
+ }
2617
2689
  canvas.drawRect(
2618
2690
  [
2619
2691
  this.position.x * drawScale * Globals.rootScale,
@@ -5338,6 +5410,17 @@ class Game {
5338
5410
  domPointerEvent.offsetY
5339
5411
  )) {
5340
5412
  this.raiseM2PointerMoveEvent(entity, m2Event, domPointerEvent);
5413
+ entity.withinHitArea = true;
5414
+ }
5415
+ if (!this.IsCanvasPointWithinEntityBounds(
5416
+ entity,
5417
+ domPointerEvent.offsetX,
5418
+ domPointerEvent.offsetY
5419
+ )) {
5420
+ if (entity.withinHitArea) {
5421
+ this.raiseM2PointerLeaveEvent(entity, m2Event, domPointerEvent);
5422
+ entity.withinHitArea = false;
5423
+ }
5341
5424
  }
5342
5425
  if (entity.children) {
5343
5426
  entity.children.filter((entity2) => !entity2.hidden).filter((entity2) => entity2.isDrawable).sort(
@@ -5410,6 +5493,15 @@ class Game {
5410
5493
  domPointerEvent
5411
5494
  );
5412
5495
  }
5496
+ raiseM2PointerLeaveEvent(entity, m2Event, domPointerEvent) {
5497
+ m2Event.target = entity;
5498
+ m2Event.type = EventType.PointerLeave;
5499
+ this.raiseEventOnListeningEntities(
5500
+ entity,
5501
+ m2Event,
5502
+ domPointerEvent
5503
+ );
5504
+ }
5413
5505
  raiseM2DragStartEvent(entity, m2Event, domPointerEvent) {
5414
5506
  m2Event.target = entity;
5415
5507
  m2Event.type = EventType.DragStart;
@@ -5524,6 +5616,7 @@ class Game {
5524
5616
  case EventType.PointerDown:
5525
5617
  case EventType.PointerMove:
5526
5618
  case EventType.PointerUp:
5619
+ case EventType.PointerLeave:
5527
5620
  m2Event.point = this.calculatePointWithinEntityFromDomPointerEvent(
5528
5621
  entity,
5529
5622
  domEvent
@@ -5582,11 +5675,14 @@ class Game {
5582
5675
  if (!radius) {
5583
5676
  throw "circleOfRadius is undefined";
5584
5677
  }
5585
- const center = { x: bb2.xMin + radius, y: bb2.yMin + radius };
5678
+ const center = {
5679
+ x: bb2.xMin + radius * entity.absoluteScale,
5680
+ y: bb2.yMin + radius * entity.absoluteScale
5681
+ };
5586
5682
  const distance = Math.sqrt(
5587
5683
  Math.pow(x - center.x, 2) + Math.pow(y - center.y, 2)
5588
5684
  );
5589
- return distance <= radius;
5685
+ return distance <= radius * entity.absoluteScale;
5590
5686
  }
5591
5687
  if (entity.size.width === 0 || entity.size.height === 0) {
5592
5688
  return false;
@@ -6081,6 +6177,8 @@ class Label extends Entity {
6081
6177
  __publicField$4(this, "paragraph");
6082
6178
  __publicField$4(this, "paraStyle");
6083
6179
  __publicField$4(this, "builder");
6180
+ __publicField$4(this, "_fontPaint");
6181
+ __publicField$4(this, "_backgroundPaint");
6084
6182
  __publicField$4(this, "_translatedText", "");
6085
6183
  handleInterfaceOptions(this, options);
6086
6184
  if (options.horizontalAlignmentMode) {
@@ -6189,24 +6287,63 @@ class Label extends Entity {
6189
6287
  fontFamilies.push(defaultTypeface.fontFamily);
6190
6288
  }
6191
6289
  this.paraStyle = new this.canvasKit.ParagraphStyle({
6192
- textStyle: {
6193
- color: textColor,
6194
- backgroundColor: this.backgroundColor ? this.canvasKit.Color(
6195
- this.backgroundColor[0],
6196
- this.backgroundColor[1],
6197
- this.backgroundColor[2],
6198
- this.backgroundColor[3]
6199
- ) : void 0,
6200
- fontFamilies,
6201
- fontSize: this.fontSize * Globals.canvasScale
6202
- },
6290
+ textStyle: {},
6203
6291
  textAlign: ckTextAlign
6204
6292
  });
6293
+ if (this.builder) {
6294
+ this.builder.delete();
6295
+ }
6205
6296
  this.builder = this.canvasKit.ParagraphBuilder.Make(
6206
6297
  this.paraStyle,
6207
6298
  fontManager.fontMgr
6208
6299
  );
6300
+ if (!this._backgroundPaint) {
6301
+ this._backgroundPaint = new this.canvasKit.Paint();
6302
+ }
6303
+ if (!this._fontPaint) {
6304
+ this._fontPaint = new this.canvasKit.Paint();
6305
+ }
6306
+ this.fontPaint.setColor(textColor);
6307
+ this.fontPaint.setAlphaf(this.absoluteAlpha);
6308
+ if (this.backgroundColor) {
6309
+ this.backgroundPaint.setColor(this.backgroundColor);
6310
+ this.backgroundPaint.setAlphaf(this.absoluteAlpha);
6311
+ } else {
6312
+ this.backgroundPaint.setColor(this.canvasKit.Color(0, 0, 0, 0));
6313
+ }
6314
+ this.builder.pushPaintStyle(
6315
+ {
6316
+ fontFamilies,
6317
+ fontSize: this.fontSize * Globals.canvasScale,
6318
+ // set default values for below properties as well.
6319
+ fontStyle: {
6320
+ weight: this.canvasKit.FontWeight.Normal,
6321
+ width: this.canvasKit.FontWidth.Normal,
6322
+ slant: this.canvasKit.FontSlant.Oblique
6323
+ },
6324
+ // Normal font style
6325
+ decoration: 0,
6326
+ // No decoration
6327
+ decorationThickness: 1,
6328
+ // Default decoration thickness
6329
+ decorationStyle: this.canvasKit.DecorationStyle.Solid,
6330
+ // Solid decoration style
6331
+ heightMultiplier: -1,
6332
+ // Providing -1, rather than 1.0, gives default height multiplier
6333
+ halfLeading: false,
6334
+ // Default half leading
6335
+ letterSpacing: 0,
6336
+ // Default letter spacing
6337
+ wordSpacing: 0
6338
+ // Default word spacing
6339
+ },
6340
+ this.fontPaint,
6341
+ this.backgroundPaint
6342
+ );
6209
6343
  this.builder.addText(textForParagraph);
6344
+ if (this.paragraph) {
6345
+ this.paragraph.delete();
6346
+ }
6210
6347
  this.paragraph = this.builder.build();
6211
6348
  const preferredWidth = (
6212
6349
  //this.preferredMaxLayoutWidth ?? this.parentScene.game.canvasCssWidth;
@@ -6234,7 +6371,14 @@ class Label extends Entity {
6234
6371
  this.needsInitialization = false;
6235
6372
  }
6236
6373
  dispose() {
6237
- CanvasKitHelpers.Dispose([this.paragraph, this.builder]);
6374
+ CanvasKitHelpers.Dispose([
6375
+ this.paragraph,
6376
+ this.builder,
6377
+ this._fontPaint,
6378
+ // use backing field since it may be undefined
6379
+ this._backgroundPaint
6380
+ // use backing field since it may be undefined
6381
+ ]);
6238
6382
  }
6239
6383
  get text() {
6240
6384
  return this._text;
@@ -6295,6 +6439,24 @@ class Label extends Entity {
6295
6439
  this._backgroundColor = backgroundColor;
6296
6440
  this.needsInitialization = true;
6297
6441
  }
6442
+ get backgroundPaint() {
6443
+ if (!this._backgroundPaint) {
6444
+ throw new Error("backgroundPaint cannot be undefined");
6445
+ }
6446
+ return this._backgroundPaint;
6447
+ }
6448
+ set backgroundPaint(backgroundPaint) {
6449
+ this._backgroundPaint = backgroundPaint;
6450
+ }
6451
+ get fontPaint() {
6452
+ if (!this._fontPaint) {
6453
+ throw new Error("fontPaint cannot be undefined");
6454
+ }
6455
+ return this._fontPaint;
6456
+ }
6457
+ set fontPaint(fontPaint) {
6458
+ this._fontPaint = fontPaint;
6459
+ }
6298
6460
  /**
6299
6461
  * Duplicates an entity using deep copy.
6300
6462
  *
@@ -6323,6 +6485,9 @@ class Label extends Entity {
6323
6485
  }
6324
6486
  update() {
6325
6487
  super.update();
6488
+ if (this.absoluteAlphaChange !== 0) {
6489
+ this.initialize();
6490
+ }
6326
6491
  }
6327
6492
  draw(canvas) {
6328
6493
  if (this.parent && this.text !== "") {
@@ -7104,7 +7269,7 @@ class Session {
7104
7269
  __publicField$2(this, "sessionDictionary", /* @__PURE__ */ new Map());
7105
7270
  __publicField$2(this, "canvasKit");
7106
7271
  __publicField$2(this, "initialized", false);
7107
- __publicField$2(this, "version", "0.3.11 (25099410)");
7272
+ __publicField$2(this, "version", "0.3.13 (f05b4c6d)");
7108
7273
  this.options = options;
7109
7274
  for (const activity of this.options.activities) {
7110
7275
  if (this.options.activities.filter((a) => a === activity).length > 1) {
@@ -7621,7 +7786,6 @@ class Shape extends Entity {
7621
7786
  * @param options - {@link ShapeOptions}
7622
7787
  */
7623
7788
  constructor(options = {}) {
7624
- var _a;
7625
7789
  super(options);
7626
7790
  __publicField$1(this, "type", EntityType.Shape);
7627
7791
  __publicField$1(this, "isDrawable", true);
@@ -7638,7 +7802,6 @@ class Shape extends Entity {
7638
7802
  __publicField$1(this, "ckPath", null);
7639
7803
  __publicField$1(this, "ckPathWidth");
7640
7804
  __publicField$1(this, "ckPathHeight");
7641
- __publicField$1(this, "pathSvgString");
7642
7805
  __publicField$1(this, "cornerRadius", 0);
7643
7806
  __publicField$1(this, "_fillColor", Constants.DEFAULT_SHAPE_FILL_COLOR);
7644
7807
  __publicField$1(this, "_strokeColor");
@@ -7653,15 +7816,17 @@ class Shape extends Entity {
7653
7816
  __publicField$1(this, "svgPathScaleForResizing", 1);
7654
7817
  __publicField$1(this, "svgPathWidth", 0);
7655
7818
  __publicField$1(this, "svgPathHeight", 0);
7656
- __publicField$1(this, "svgPreviousAbsoluteScale", NaN);
7657
7819
  __publicField$1(this, "svgPreviousAbsoluteX", NaN);
7658
7820
  __publicField$1(this, "svgPreviousAbsoluteY", NaN);
7659
- __publicField$1(this, "pathIsSvgStringPath", false);
7821
+ __publicField$1(this, "svgFirstPathDraw", true);
7660
7822
  handleInterfaceOptions(this, options);
7661
- if (((_a = options == null ? void 0 : options.path) == null ? void 0 : _a.svgPathString) !== void 0) {
7823
+ if (options.path !== void 0) {
7824
+ this.path = options.path;
7662
7825
  this.shapeType = ShapeType.Path;
7663
- this.pathIsSvgStringPath = true;
7664
- this.pathSvgString = options.path.svgPathString;
7826
+ if (this.path.size !== void 0) {
7827
+ this.size.height = this.path.size.height;
7828
+ this.size.width = this.path.size.width;
7829
+ }
7665
7830
  this.svgPathRequestedWidth = options.path.width;
7666
7831
  this.svgPathRequestedHeight = options.path.height;
7667
7832
  if (this.svgPathRequestedHeight !== void 0 && this.svgPathRequestedWidth !== void 0) {
@@ -7712,7 +7877,7 @@ class Shape extends Entity {
7712
7877
  throw new Error("Size cannot be specified for rectangle shape");
7713
7878
  }
7714
7879
  }
7715
- if (options.cornerRadius) {
7880
+ if (options.cornerRadius !== void 0) {
7716
7881
  this.cornerRadius = options.cornerRadius;
7717
7882
  }
7718
7883
  if (options.fillColor) {
@@ -7727,9 +7892,9 @@ class Shape extends Entity {
7727
7892
  if (options.isAntialiased !== void 0) {
7728
7893
  this.isAntialiased = options.isAntialiased;
7729
7894
  }
7730
- if (options.strokeColor && options.lineWidth === void 0) {
7895
+ if (options.strokeColor && !options.lineWidth) {
7731
7896
  console.warn(
7732
- `warning: for entity ${this}, strokeColor = ${options.strokeColor} but lineWidth is undefined. In normal usage, both would be set or both would be undefined.`
7897
+ `warning: for entity ${this}, strokeColor = ${options.strokeColor} but lineWidth is non-zero. In normal usage, both would be set or both would be undefined.`
7733
7898
  );
7734
7899
  }
7735
7900
  if (options.strokeColor === void 0 && options.lineWidth) {
@@ -7739,28 +7904,29 @@ class Shape extends Entity {
7739
7904
  }
7740
7905
  }
7741
7906
  initialize() {
7742
- var _a, _b;
7743
- if (this.shapeType === ShapeType.Path && this.pathIsSvgStringPath) {
7744
- if (!this.pathSvgString) {
7745
- throw new Error("SVG Path string is null/undefined");
7746
- }
7747
- this.ckPath = this.canvasKit.Path.MakeFromSVGString(this.pathSvgString);
7748
- if (!this.ckPath) {
7749
- throw new Error("could not make CanvasKit Path from SVG string");
7750
- }
7751
- const bounds = this.ckPath.getBounds();
7752
- this.svgPathWidth = bounds[2] + (bounds[0] < 0 ? Math.abs(bounds[0]) : 0);
7753
- this.svgPathHeight = bounds[3] + (bounds[1] < 0 ? Math.abs(bounds[1]) : 0);
7754
- this.size.width = (_a = this.size.width) != null ? _a : this.svgPathWidth;
7755
- this.size.height = (_b = this.size.height) != null ? _b : this.svgPathHeight;
7756
- if (this.svgPathRequestedHeight !== void 0) {
7757
- this.svgPathScaleForResizing = this.svgPathRequestedHeight / this.svgPathHeight;
7758
- } else if (this.svgPathRequestedWidth !== void 0) {
7759
- this.svgPathScaleForResizing = this.svgPathRequestedWidth / this.svgPathWidth;
7760
- }
7761
- this.svgPreviousAbsoluteScale = 1;
7762
- this.svgPreviousAbsoluteX = 0;
7763
- this.svgPreviousAbsoluteY = 0;
7907
+ if (this.shapeType === ShapeType.Path) {
7908
+ if (this.shapeIsSvgStringPath()) {
7909
+ const pathSvgString = this.path.svgPathString;
7910
+ if (!pathSvgString) {
7911
+ throw new Error("SVG Path string is null/undefined");
7912
+ }
7913
+ this.ckPath = this.canvasKit.Path.MakeFromSVGString(pathSvgString);
7914
+ if (!this.ckPath) {
7915
+ throw new Error("could not make CanvasKit Path from SVG string");
7916
+ }
7917
+ const bounds = this.ckPath.getBounds();
7918
+ this.svgPathWidth = bounds[2] + (bounds[0] < 0 ? Math.abs(bounds[0]) : 0);
7919
+ this.svgPathHeight = bounds[3] + (bounds[1] < 0 ? Math.abs(bounds[1]) : 0);
7920
+ if (this.svgPathRequestedHeight !== void 0) {
7921
+ this.svgPathScaleForResizing = this.svgPathRequestedHeight / this.svgPathHeight;
7922
+ } else if (this.svgPathRequestedWidth !== void 0) {
7923
+ this.svgPathScaleForResizing = this.svgPathRequestedWidth / this.svgPathWidth;
7924
+ }
7925
+ this.size.width = this.svgPathWidth * this.svgPathScaleForResizing;
7926
+ this.size.height = this.svgPathHeight * this.svgPathScaleForResizing;
7927
+ this.svgPreviousAbsoluteX = 0;
7928
+ this.svgPreviousAbsoluteY = 0;
7929
+ }
7764
7930
  }
7765
7931
  if (this.fillColor) {
7766
7932
  this.fillColorPaintAntialiased = CanvasKitHelpers.makePaint(
@@ -7790,10 +7956,12 @@ class Shape extends Entity {
7790
7956
  false
7791
7957
  );
7792
7958
  }
7959
+ this.svgFirstPathDraw = true;
7793
7960
  this.needsInitialization = false;
7794
7961
  }
7795
7962
  dispose() {
7796
7963
  CanvasKitHelpers.Dispose([
7964
+ // use backing fields, since paints may be undefined
7797
7965
  this._strokeColorPaintAntialiased,
7798
7966
  this._strokeColorPaintNotAntialiased,
7799
7967
  this._fillColorPaintAntialiased,
@@ -7838,10 +8006,18 @@ class Shape extends Entity {
7838
8006
  canvas.save();
7839
8007
  const drawScale = Globals.canvasScale / this.absoluteScale;
7840
8008
  canvas.scale(1 / drawScale, 1 / drawScale);
7841
- if (this.shapeType === ShapeType.Path && !this.pathIsSvgStringPath) {
8009
+ if (this.absoluteAlphaChange !== 0) {
8010
+ this.applyAlphaToPaints(this.absoluteAlpha, [
8011
+ this._fillColorPaintAntialiased,
8012
+ this._fillColorPaintNotAntialiased,
8013
+ this._strokeColorPaintAntialiased,
8014
+ this._strokeColorPaintNotAntialiased
8015
+ ]);
8016
+ }
8017
+ if (this.shapeIsM2Path()) {
7842
8018
  this.drawPathFromM2Path(canvas);
7843
8019
  }
7844
- if (this.shapeType === ShapeType.Path && this.pathIsSvgStringPath) {
8020
+ if (this.shapeIsSvgStringPath()) {
7845
8021
  this.drawPathFromSvgString(canvas);
7846
8022
  }
7847
8023
  if (this.shapeType === ShapeType.Circle) {
@@ -7853,23 +8029,28 @@ class Shape extends Entity {
7853
8029
  canvas.restore();
7854
8030
  super.drawChildren(canvas);
7855
8031
  }
8032
+ applyAlphaToPaints(alpha, paints) {
8033
+ paints.forEach((paint) => {
8034
+ if (paint) {
8035
+ paint.setAlphaf(alpha);
8036
+ }
8037
+ });
8038
+ }
7856
8039
  drawPathFromM2Path(canvas) {
7857
8040
  const drawScale = Globals.canvasScale / this.absoluteScale;
7858
8041
  const pathOriginX = (this.absolutePosition.x - this.anchorPoint.x * this.size.width * this.absoluteScale) * drawScale;
7859
8042
  const pathOriginY = (this.absolutePosition.y - this.anchorPoint.y * this.size.height * this.absoluteScale) * drawScale;
7860
8043
  if (this.strokeColor && this.strokeColorPaintAntialiased && this.lineWidth) {
7861
- this.strokeColorPaintAntialiased.setStrokeWidth(
7862
- this.lineWidth * drawScale
7863
- );
8044
+ this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth);
7864
8045
  const subpaths = this.path.subpaths;
7865
8046
  for (const subpath of subpaths) {
7866
8047
  const points = subpath.flat();
7867
8048
  for (let i = 0; i < points.length - 1; i++) {
7868
8049
  canvas.drawLine(
7869
- pathOriginX + points[i].x * drawScale,
7870
- pathOriginY + points[i].y * drawScale,
7871
- pathOriginX + points[i + 1].x * drawScale,
7872
- pathOriginY + points[i + 1].y * drawScale,
8050
+ pathOriginX + points[i].x * Globals.canvasScale,
8051
+ pathOriginY + points[i].y * Globals.canvasScale,
8052
+ pathOriginX + points[i + 1].x * Globals.canvasScale,
8053
+ pathOriginY + points[i + 1].y * Globals.canvasScale,
7873
8054
  this.strokeColorPaintAntialiased
7874
8055
  );
7875
8056
  }
@@ -7882,12 +8063,12 @@ class Shape extends Entity {
7882
8063
  }
7883
8064
  const x = this.calculateSvgPathX();
7884
8065
  const y = this.calculateSvgPathY();
7885
- const drawScale = Globals.canvasScale / this.absoluteScale;
7886
- const pathScale = drawScale * this.svgPathScaleForResizing * Globals.rootScale;
7887
- if (this.pathNeedsTransform(pathScale, x, y)) {
8066
+ if (this.pathNeedsTransform(x, y)) {
8067
+ const drawScale = Globals.canvasScale / this.absoluteScale;
8068
+ const pathScale = drawScale * this.svgPathScaleForResizing * Globals.rootScale;
7888
8069
  const matrix = this.calculateTransformationMatrix(pathScale, x, y);
7889
8070
  this.ckPath = this.ckPath.transform(matrix);
7890
- this.saveSvgPathDrawParameters(pathScale, x, y);
8071
+ this.saveSvgPathAbsolutePosition(x, y);
7891
8072
  }
7892
8073
  if (this.fillColor) {
7893
8074
  const paint = this.getFillPaint();
@@ -7900,25 +8081,38 @@ class Shape extends Entity {
7900
8081
  }
7901
8082
  calculateSvgPathY() {
7902
8083
  const drawScale = Globals.canvasScale / this.absoluteScale;
7903
- return (this.absolutePosition.y + (this.size.height - this.svgPathHeight * this.svgPathScaleForResizing * Globals.rootScale) / 2 - this.anchorPoint.y * this.size.height) * drawScale;
8084
+ return (this.absolutePosition.y - this.size.height * this.absoluteScale / 2) * drawScale;
7904
8085
  }
7905
8086
  calculateSvgPathX() {
7906
8087
  const drawScale = Globals.canvasScale / this.absoluteScale;
7907
- return (this.absolutePosition.x + (this.size.width - this.svgPathWidth * this.svgPathScaleForResizing * Globals.rootScale) / 2 - this.anchorPoint.x * this.size.width) * drawScale;
8088
+ return (this.absolutePosition.x - this.size.width * this.absoluteScale / 2) * drawScale;
7908
8089
  }
7909
- saveSvgPathDrawParameters(pathScale, x, y) {
7910
- this.svgPreviousAbsoluteScale = pathScale;
8090
+ saveSvgPathAbsolutePosition(x, y) {
7911
8091
  this.svgPreviousAbsoluteX = x;
7912
8092
  this.svgPreviousAbsoluteY = y;
7913
8093
  }
7914
8094
  calculateTransformationMatrix(pathScale, x, y) {
7915
- const dScale = pathScale / this.svgPreviousAbsoluteScale;
8095
+ let dScale;
8096
+ if (this.svgFirstPathDraw) {
8097
+ dScale = pathScale;
8098
+ this.svgFirstPathDraw = false;
8099
+ } else {
8100
+ dScale = 1;
8101
+ }
7916
8102
  const dX = x - this.svgPreviousAbsoluteX;
7917
8103
  const dY = y - this.svgPreviousAbsoluteY;
7918
8104
  return [dScale, 0, dX, 0, dScale, dY, 0, 0, 1];
7919
8105
  }
7920
- pathNeedsTransform(pathScale, x, y) {
7921
- return pathScale !== this.svgPreviousAbsoluteScale || x !== this.svgPreviousAbsoluteX || y !== this.svgPreviousAbsoluteY;
8106
+ pathNeedsTransform(x, y) {
8107
+ return this.svgFirstPathDraw === true || x !== this.svgPreviousAbsoluteX || y !== this.svgPreviousAbsoluteY;
8108
+ }
8109
+ shapeIsSvgStringPath() {
8110
+ var _a;
8111
+ return ((_a = this.path) == null ? void 0 : _a.svgPathString) !== void 0;
8112
+ }
8113
+ shapeIsM2Path() {
8114
+ var _a;
8115
+ return ((_a = this.path) == null ? void 0 : _a.subpaths) !== void 0;
7922
8116
  }
7923
8117
  drawCircle(canvas) {
7924
8118
  if (!this.circleOfRadius) {
@@ -8215,6 +8409,9 @@ class TextLine extends Entity {
8215
8409
  super.update();
8216
8410
  }
8217
8411
  initialize() {
8412
+ if (this.paint) {
8413
+ this.paint.delete();
8414
+ }
8218
8415
  this.paint = new this.canvasKit.Paint();
8219
8416
  this.paint.setColor(
8220
8417
  this.canvasKit.Color(
@@ -8254,6 +8451,9 @@ class TextLine extends Entity {
8254
8451
  this.typeface = fontManager.getTypeface(gameUuid, fontNames[0]);
8255
8452
  }
8256
8453
  }
8454
+ if (this.font) {
8455
+ this.font.delete();
8456
+ }
8257
8457
  this.font = new this.canvasKit.Font(
8258
8458
  this.typeface,
8259
8459
  this.fontSize * Globals.canvasScale
@@ -8329,6 +8529,9 @@ class TextLine extends Entity {
8329
8529
  `in TextLine entity ${this}, Paint or Font is undefined.`
8330
8530
  );
8331
8531
  }
8532
+ if (this.absoluteAlphaChange !== 0) {
8533
+ paintForDraw.setAlphaf(this.absoluteAlpha);
8534
+ }
8332
8535
  canvas.drawText(textForDraw, x, y, paintForDraw, this.font);
8333
8536
  canvas.restore();
8334
8537
  }
@@ -8345,5 +8548,5 @@ class TextLine extends Entity {
8345
8548
  }
8346
8549
  }
8347
8550
 
8348
- export { Action, ActivityType, CanvasKitHelpers, Composite, Constants, ConstraintType, CustomAction, Dimensions, Easings, Entity, EntityType, Equals, EventType, FontManager, Game, GlobalVariables, GroupAction, I18n, ImageManager, Label, LabelHorizontalAlignmentMode, LayoutConstraint, LoadedImage, MoveAction, MutablePath, NoneTransition, RandomDraws, ScaleAction, Scene, SceneTransition, SequenceAction, Session, Shape, ShapeType, SlideTransition, Sprite, Story, TextLine, Timer, Transition, TransitionDirection, TransitionType, Uuid, WaitAction, WebColors, WebGlInfo, handleInterfaceOptions };
8551
+ export { Action, ActivityType, CanvasKitHelpers, Composite, Constants, ConstraintType, CustomAction, Dimensions, Easings, Entity, EntityType, Equals, EventType, FadeAlphaAction, FontManager, Game, GlobalVariables, GroupAction, I18n, ImageManager, Label, LabelHorizontalAlignmentMode, LayoutConstraint, LoadedImage, MoveAction, MutablePath, NoneTransition, RandomDraws, ScaleAction, Scene, SceneTransition, SequenceAction, Session, Shape, ShapeType, SlideTransition, Sprite, Story, TextLine, Timer, Transition, TransitionDirection, TransitionType, Uuid, WaitAction, WebColors, WebGlInfo, handleInterfaceOptions };
8349
8552
  //# sourceMappingURL=index.js.map