pixi.js 7.1.2 → 7.2.0-beta

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/pixi.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * pixi.js - v7.1.2
3
- * Compiled Tue, 31 Jan 2023 14:52:16 UTC
2
+ * pixi.js - v7.2.0-beta
3
+ * Compiled Fri, 17 Feb 2023 17:04:30 UTC
4
4
  *
5
5
  * pixi.js is licensed under the MIT License.
6
6
  * http://www.opensource.org/licenses/mit-license
@@ -222,19 +222,6 @@ var PIXI = (function (exports) {
222
222
  const settings = {
223
223
  ADAPTER: BrowserAdapter,
224
224
  RESOLUTION: 1,
225
- RENDER_OPTIONS: {
226
- view: null,
227
- width: 800,
228
- height: 600,
229
- autoDensity: false,
230
- backgroundColor: 0,
231
- backgroundAlpha: 1,
232
- clearBeforeRender: true,
233
- antialias: false,
234
- premultipliedAlpha: true,
235
- preserveDrawingBuffer: false,
236
- hello: false
237
- },
238
225
  CREATE_IMAGE_BITMAP: false,
239
226
  ROUND_PIXELS: false
240
227
  };
@@ -3332,331 +3319,210 @@ Deprecated since v${version}`);
3332
3319
  return supported;
3333
3320
  }
3334
3321
 
3335
- var aliceblue = "#f0f8ff";
3336
- var antiquewhite = "#faebd7";
3337
- var aqua = "#00ffff";
3338
- var aquamarine = "#7fffd4";
3339
- var azure = "#f0ffff";
3340
- var beige = "#f5f5dc";
3341
- var bisque = "#ffe4c4";
3342
- var black = "#000000";
3343
- var blanchedalmond = "#ffebcd";
3344
- var blue = "#0000ff";
3345
- var blueviolet = "#8a2be2";
3346
- var brown = "#a52a2a";
3347
- var burlywood = "#deb887";
3348
- var cadetblue = "#5f9ea0";
3349
- var chartreuse = "#7fff00";
3350
- var chocolate = "#d2691e";
3351
- var coral = "#ff7f50";
3352
- var cornflowerblue = "#6495ed";
3353
- var cornsilk = "#fff8dc";
3354
- var crimson = "#dc143c";
3355
- var cyan = "#00ffff";
3356
- var darkblue = "#00008b";
3357
- var darkcyan = "#008b8b";
3358
- var darkgoldenrod = "#b8860b";
3359
- var darkgray = "#a9a9a9";
3360
- var darkgreen = "#006400";
3361
- var darkgrey = "#a9a9a9";
3362
- var darkkhaki = "#bdb76b";
3363
- var darkmagenta = "#8b008b";
3364
- var darkolivegreen = "#556b2f";
3365
- var darkorange = "#ff8c00";
3366
- var darkorchid = "#9932cc";
3367
- var darkred = "#8b0000";
3368
- var darksalmon = "#e9967a";
3369
- var darkseagreen = "#8fbc8f";
3370
- var darkslateblue = "#483d8b";
3371
- var darkslategray = "#2f4f4f";
3372
- var darkslategrey = "#2f4f4f";
3373
- var darkturquoise = "#00ced1";
3374
- var darkviolet = "#9400d3";
3375
- var deeppink = "#ff1493";
3376
- var deepskyblue = "#00bfff";
3377
- var dimgray = "#696969";
3378
- var dimgrey = "#696969";
3379
- var dodgerblue = "#1e90ff";
3380
- var firebrick = "#b22222";
3381
- var floralwhite = "#fffaf0";
3382
- var forestgreen = "#228b22";
3383
- var fuchsia = "#ff00ff";
3384
- var gainsboro = "#dcdcdc";
3385
- var ghostwhite = "#f8f8ff";
3386
- var goldenrod = "#daa520";
3387
- var gold = "#ffd700";
3388
- var gray = "#808080";
3389
- var green = "#008000";
3390
- var greenyellow = "#adff2f";
3391
- var grey = "#808080";
3392
- var honeydew = "#f0fff0";
3393
- var hotpink = "#ff69b4";
3394
- var indianred = "#cd5c5c";
3395
- var indigo = "#4b0082";
3396
- var ivory = "#fffff0";
3397
- var khaki = "#f0e68c";
3398
- var lavenderblush = "#fff0f5";
3399
- var lavender = "#e6e6fa";
3400
- var lawngreen = "#7cfc00";
3401
- var lemonchiffon = "#fffacd";
3402
- var lightblue = "#add8e6";
3403
- var lightcoral = "#f08080";
3404
- var lightcyan = "#e0ffff";
3405
- var lightgoldenrodyellow = "#fafad2";
3406
- var lightgray = "#d3d3d3";
3407
- var lightgreen = "#90ee90";
3408
- var lightgrey = "#d3d3d3";
3409
- var lightpink = "#ffb6c1";
3410
- var lightsalmon = "#ffa07a";
3411
- var lightseagreen = "#20b2aa";
3412
- var lightskyblue = "#87cefa";
3413
- var lightslategray = "#778899";
3414
- var lightslategrey = "#778899";
3415
- var lightsteelblue = "#b0c4de";
3416
- var lightyellow = "#ffffe0";
3417
- var lime = "#00ff00";
3418
- var limegreen = "#32cd32";
3419
- var linen = "#faf0e6";
3420
- var magenta = "#ff00ff";
3421
- var maroon = "#800000";
3422
- var mediumaquamarine = "#66cdaa";
3423
- var mediumblue = "#0000cd";
3424
- var mediumorchid = "#ba55d3";
3425
- var mediumpurple = "#9370db";
3426
- var mediumseagreen = "#3cb371";
3427
- var mediumslateblue = "#7b68ee";
3428
- var mediumspringgreen = "#00fa9a";
3429
- var mediumturquoise = "#48d1cc";
3430
- var mediumvioletred = "#c71585";
3431
- var midnightblue = "#191970";
3432
- var mintcream = "#f5fffa";
3433
- var mistyrose = "#ffe4e1";
3434
- var moccasin = "#ffe4b5";
3435
- var navajowhite = "#ffdead";
3436
- var navy = "#000080";
3437
- var oldlace = "#fdf5e6";
3438
- var olive = "#808000";
3439
- var olivedrab = "#6b8e23";
3440
- var orange = "#ffa500";
3441
- var orangered = "#ff4500";
3442
- var orchid = "#da70d6";
3443
- var palegoldenrod = "#eee8aa";
3444
- var palegreen = "#98fb98";
3445
- var paleturquoise = "#afeeee";
3446
- var palevioletred = "#db7093";
3447
- var papayawhip = "#ffefd5";
3448
- var peachpuff = "#ffdab9";
3449
- var peru = "#cd853f";
3450
- var pink = "#ffc0cb";
3451
- var plum = "#dda0dd";
3452
- var powderblue = "#b0e0e6";
3453
- var purple = "#800080";
3454
- var rebeccapurple = "#663399";
3455
- var red = "#ff0000";
3456
- var rosybrown = "#bc8f8f";
3457
- var royalblue = "#4169e1";
3458
- var saddlebrown = "#8b4513";
3459
- var salmon = "#fa8072";
3460
- var sandybrown = "#f4a460";
3461
- var seagreen = "#2e8b57";
3462
- var seashell = "#fff5ee";
3463
- var sienna = "#a0522d";
3464
- var silver = "#c0c0c0";
3465
- var skyblue = "#87ceeb";
3466
- var slateblue = "#6a5acd";
3467
- var slategray = "#708090";
3468
- var slategrey = "#708090";
3469
- var snow = "#fffafa";
3470
- var springgreen = "#00ff7f";
3471
- var steelblue = "#4682b4";
3472
- var tan = "#d2b48c";
3473
- var teal = "#008080";
3474
- var thistle = "#d8bfd8";
3475
- var tomato = "#ff6347";
3476
- var turquoise = "#40e0d0";
3477
- var violet = "#ee82ee";
3478
- var wheat = "#f5deb3";
3479
- var white = "#ffffff";
3480
- var whitesmoke = "#f5f5f5";
3481
- var yellow = "#ffff00";
3482
- var yellowgreen = "#9acd32";
3483
- var cssColorNames = {
3484
- aliceblue: aliceblue,
3485
- antiquewhite: antiquewhite,
3486
- aqua: aqua,
3487
- aquamarine: aquamarine,
3488
- azure: azure,
3489
- beige: beige,
3490
- bisque: bisque,
3491
- black: black,
3492
- blanchedalmond: blanchedalmond,
3493
- blue: blue,
3494
- blueviolet: blueviolet,
3495
- brown: brown,
3496
- burlywood: burlywood,
3497
- cadetblue: cadetblue,
3498
- chartreuse: chartreuse,
3499
- chocolate: chocolate,
3500
- coral: coral,
3501
- cornflowerblue: cornflowerblue,
3502
- cornsilk: cornsilk,
3503
- crimson: crimson,
3504
- cyan: cyan,
3505
- darkblue: darkblue,
3506
- darkcyan: darkcyan,
3507
- darkgoldenrod: darkgoldenrod,
3508
- darkgray: darkgray,
3509
- darkgreen: darkgreen,
3510
- darkgrey: darkgrey,
3511
- darkkhaki: darkkhaki,
3512
- darkmagenta: darkmagenta,
3513
- darkolivegreen: darkolivegreen,
3514
- darkorange: darkorange,
3515
- darkorchid: darkorchid,
3516
- darkred: darkred,
3517
- darksalmon: darksalmon,
3518
- darkseagreen: darkseagreen,
3519
- darkslateblue: darkslateblue,
3520
- darkslategray: darkslategray,
3521
- darkslategrey: darkslategrey,
3522
- darkturquoise: darkturquoise,
3523
- darkviolet: darkviolet,
3524
- deeppink: deeppink,
3525
- deepskyblue: deepskyblue,
3526
- dimgray: dimgray,
3527
- dimgrey: dimgrey,
3528
- dodgerblue: dodgerblue,
3529
- firebrick: firebrick,
3530
- floralwhite: floralwhite,
3531
- forestgreen: forestgreen,
3532
- fuchsia: fuchsia,
3533
- gainsboro: gainsboro,
3534
- ghostwhite: ghostwhite,
3535
- goldenrod: goldenrod,
3536
- gold: gold,
3537
- gray: gray,
3538
- green: green,
3539
- greenyellow: greenyellow,
3540
- grey: grey,
3541
- honeydew: honeydew,
3542
- hotpink: hotpink,
3543
- indianred: indianred,
3544
- indigo: indigo,
3545
- ivory: ivory,
3546
- khaki: khaki,
3547
- lavenderblush: lavenderblush,
3548
- lavender: lavender,
3549
- lawngreen: lawngreen,
3550
- lemonchiffon: lemonchiffon,
3551
- lightblue: lightblue,
3552
- lightcoral: lightcoral,
3553
- lightcyan: lightcyan,
3554
- lightgoldenrodyellow: lightgoldenrodyellow,
3555
- lightgray: lightgray,
3556
- lightgreen: lightgreen,
3557
- lightgrey: lightgrey,
3558
- lightpink: lightpink,
3559
- lightsalmon: lightsalmon,
3560
- lightseagreen: lightseagreen,
3561
- lightskyblue: lightskyblue,
3562
- lightslategray: lightslategray,
3563
- lightslategrey: lightslategrey,
3564
- lightsteelblue: lightsteelblue,
3565
- lightyellow: lightyellow,
3566
- lime: lime,
3567
- limegreen: limegreen,
3568
- linen: linen,
3569
- magenta: magenta,
3570
- maroon: maroon,
3571
- mediumaquamarine: mediumaquamarine,
3572
- mediumblue: mediumblue,
3573
- mediumorchid: mediumorchid,
3574
- mediumpurple: mediumpurple,
3575
- mediumseagreen: mediumseagreen,
3576
- mediumslateblue: mediumslateblue,
3577
- mediumspringgreen: mediumspringgreen,
3578
- mediumturquoise: mediumturquoise,
3579
- mediumvioletred: mediumvioletred,
3580
- midnightblue: midnightblue,
3581
- mintcream: mintcream,
3582
- mistyrose: mistyrose,
3583
- moccasin: moccasin,
3584
- navajowhite: navajowhite,
3585
- navy: navy,
3586
- oldlace: oldlace,
3587
- olive: olive,
3588
- olivedrab: olivedrab,
3589
- orange: orange,
3590
- orangered: orangered,
3591
- orchid: orchid,
3592
- palegoldenrod: palegoldenrod,
3593
- palegreen: palegreen,
3594
- paleturquoise: paleturquoise,
3595
- palevioletred: palevioletred,
3596
- papayawhip: papayawhip,
3597
- peachpuff: peachpuff,
3598
- peru: peru,
3599
- pink: pink,
3600
- plum: plum,
3601
- powderblue: powderblue,
3602
- purple: purple,
3603
- rebeccapurple: rebeccapurple,
3604
- red: red,
3605
- rosybrown: rosybrown,
3606
- royalblue: royalblue,
3607
- saddlebrown: saddlebrown,
3608
- salmon: salmon,
3609
- sandybrown: sandybrown,
3610
- seagreen: seagreen,
3611
- seashell: seashell,
3612
- sienna: sienna,
3613
- silver: silver,
3614
- skyblue: skyblue,
3615
- slateblue: slateblue,
3616
- slategray: slategray,
3617
- slategrey: slategrey,
3618
- snow: snow,
3619
- springgreen: springgreen,
3620
- steelblue: steelblue,
3621
- tan: tan,
3622
- teal: teal,
3623
- thistle: thistle,
3624
- tomato: tomato,
3625
- turquoise: turquoise,
3626
- violet: violet,
3627
- wheat: wheat,
3628
- white: white,
3629
- whitesmoke: whitesmoke,
3630
- yellow: yellow,
3631
- yellowgreen: yellowgreen
3322
+ var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return "string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},e=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},u=function(r){return (r=isFinite(r)?r%360:0)>0?r:r+360},a=function(r){return {r:e(r.r,0,255),g:e(r.g,0,255),b:e(r.b,0,255),a:e(r.a)}},o=function(r){return {r:n(r.r),g:n(r.g),b:n(r.b),a:n(r.a,3)}},i=/^#([0-9a-f]{3,8})$/i,s=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},h=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,a=Math.max(t,n,e),o=a-Math.min(t,n,e),i=o?a===t?(n-e)/o:a===n?2+(e-t)/o:4+(t-n)/o:0;return {h:60*(i<0?i+6:i),s:a?o/a*100:0,v:a/255*100,a:u}},b=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var a=Math.floor(t),o=e*(1-n),i=e*(1-(t-a)*n),s=e*(1-(1-t+a)*n),h=a%6;return {r:255*[e,i,o,o,s,e][h],g:255*[s,e,e,i,o,o][h],b:255*[o,o,s,e,e,i][h],a:u}},g=function(r){return {h:u(r.h),s:e(r.s,0,100),l:e(r.l,0,100),a:e(r.a)}},d=function(r){return {h:n(r.h),s:n(r.s),l:n(r.l),a:n(r.a,3)}},f=function(r){return b((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e;},c=function(r){return {h:(t=h(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u;},l=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,p=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y={string:[[function(r){var t=i.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?n(parseInt(r[3]+r[3],16)/255,2):1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?n(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=v.exec(r)||m.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(t){var n=l.exec(t)||p.exec(t);if(!n)return null;var e,u,a=g({h:(e=n[1],u=n[2],void 0===u&&(u="deg"),Number(e)*(r[u]||1)),s:Number(n[3]),l:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return f(a)},"hsl"]],object:[[function(r){var n=r.r,e=r.g,u=r.b,o=r.a,i=void 0===o?1:o;return t(n)&&t(e)&&t(u)?a({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},"rgb"],[function(r){var n=r.h,e=r.s,u=r.l,a=r.a,o=void 0===a?1:a;if(!t(n)||!t(e)||!t(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(o)});return f(i)},"hsl"],[function(r){var n=r.h,a=r.s,o=r.v,i=r.a,s=void 0===i?1:i;if(!t(n)||!t(a)||!t(o))return null;var h=function(r){return {h:u(r.h),s:e(r.s,0,100),v:e(r.v,0,100),a:e(r.a)}}({h:Number(n),s:Number(a),v:Number(o),a:Number(s)});return b(h)},"hsv"]]},N=function(r,t){for(var n=0;n<t.length;n++){var e=t[n][0](r);if(e)return [e,t[n][1]]}return [null,void 0]},x=function(r){return "string"==typeof r?N(r.trim(),y.string):"object"==typeof r&&null!==r?N(r,y.object):[null,void 0]},I=function(r){return x(r)[1]},M=function(r,t){var n=c(r);return {h:n.h,s:e(n.s+100*t,0,100),l:n.l,a:n.a}},H=function(r){return (299*r.r+587*r.g+114*r.b)/1e3/255},$=function(r,t){var n=c(r);return {h:n.h,s:n.s,l:e(n.l+100*t,0,100),a:n.a}},j=function(){function r(r){this.parsed=x(r)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1};}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return n(H(this.rgba),2)},r.prototype.isDark=function(){return H(this.rgba)<.5},r.prototype.isLight=function(){return H(this.rgba)>=.5},r.prototype.toHex=function(){return r=o(this.rgba),t=r.r,e=r.g,u=r.b,i=(a=r.a)<1?s(n(255*a)):"","#"+s(t)+s(e)+s(u)+i;var r,t,e,u,a,i;},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return r=o(this.rgba),t=r.r,n=r.g,e=r.b,(u=r.a)<1?"rgba("+t+", "+n+", "+e+", "+u+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,u;},r.prototype.toHsl=function(){return d(c(this.rgba))},r.prototype.toHslString=function(){return r=d(c(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u;},r.prototype.toHsv=function(){return r=h(this.rgba),{h:n(r.h),s:n(r.s),v:n(r.v),a:n(r.a,3)};var r;},r.prototype.invert=function(){return w({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r;},r.prototype.saturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,-r))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),w($(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),w($(this.rgba,-r))},r.prototype.rotate=function(r){return void 0===r&&(r=15),this.hue(this.hue()+r)},r.prototype.alpha=function(r){return "number"==typeof r?w({r:(t=this.rgba).r,g:t.g,b:t.b,a:r}):n(this.rgba.a,3);var t;},r.prototype.hue=function(r){var t=c(this.rgba);return "number"==typeof r?w({h:r,s:t.s,l:t.l,a:t.a}):n(t.h)},r.prototype.isEqual=function(r){return this.toHex()===w(r).toHex()},r}(),w=function(r){return r instanceof j?r:new j(r)},S=[],k=function(r){r.forEach(function(r){S.indexOf(r)<0&&(r(j,y),S.push(r));});},E=function(){return new j({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};
3323
+
3324
+ function namesPlugin(e,f){var a={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var d in a)r[a[d]]=d;var l={};e.prototype.toName=function(f){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return "transparent";var d,i,n=r[this.toHex()];if(n)return n;if(null==f?void 0:f.closest){var o=this.toRgb(),t=1/0,b="black";if(!l.length)for(var c in a)l[c]=new e(a[c]).toRgb();for(var g in a){var u=(d=o,i=l[g],Math.pow(d.r-i.r,2)+Math.pow(d.g-i.g,2)+Math.pow(d.b-i.b,2));u<t&&(t=u,b=g);}return b}};f.string.push([function(f){var r=f.toLowerCase(),d="transparent"===r?"#0000":a[r];return d?new e(d).toRgb():null},"name"]);}
3325
+
3326
+ k([namesPlugin]);
3327
+ const _Color = class {
3328
+ constructor(value = 16777215) {
3329
+ this._components = new Float32Array(4);
3330
+ this._components.fill(1);
3331
+ this.value = value;
3332
+ }
3333
+ get red() {
3334
+ return this._components[0];
3335
+ }
3336
+ get green() {
3337
+ return this._components[1];
3338
+ }
3339
+ get blue() {
3340
+ return this._components[2];
3341
+ }
3342
+ get alpha() {
3343
+ return this._components[3];
3344
+ }
3345
+ setValue(value) {
3346
+ this.value = value;
3347
+ return this;
3348
+ }
3349
+ set value(value) {
3350
+ if (value instanceof _Color) {
3351
+ this._value = value._value;
3352
+ this._int = value._int;
3353
+ this._components.set(value._components);
3354
+ } else if (this._value !== value) {
3355
+ this.normalize(value);
3356
+ this._value = value;
3357
+ }
3358
+ }
3359
+ get value() {
3360
+ return this._value;
3361
+ }
3362
+ toRgba() {
3363
+ const [r, g, b, a] = this._components;
3364
+ return { r, g, b, a };
3365
+ }
3366
+ toRgb() {
3367
+ const [r, g, b] = this._components;
3368
+ return { r, g, b };
3369
+ }
3370
+ toRgbaString() {
3371
+ const [r, g, b] = this.toUint8RgbArray();
3372
+ return `rgba(${r},${g},${b},${this.alpha})`;
3373
+ }
3374
+ toUint8RgbArray(out) {
3375
+ const [r, g, b] = this._components;
3376
+ out = out ?? [];
3377
+ out[0] = Math.round(r * 255);
3378
+ out[1] = Math.round(g * 255);
3379
+ out[2] = Math.round(b * 255);
3380
+ return out;
3381
+ }
3382
+ toRgbArray(out) {
3383
+ out = out ?? [];
3384
+ const [r, g, b] = this._components;
3385
+ out[0] = r;
3386
+ out[1] = g;
3387
+ out[2] = b;
3388
+ return out;
3389
+ }
3390
+ toNumber() {
3391
+ return this._int;
3392
+ }
3393
+ toLittleEndianNumber() {
3394
+ const value = this._int;
3395
+ return (value >> 16) + (value & 65280) + ((value & 255) << 16);
3396
+ }
3397
+ multiply(value) {
3398
+ const [r, g, b, a] = _Color.temp.setValue(value)._components;
3399
+ this._components[0] *= r;
3400
+ this._components[1] *= g;
3401
+ this._components[2] *= b;
3402
+ this._components[3] *= a;
3403
+ this.refreshInt();
3404
+ this._value = null;
3405
+ return this;
3406
+ }
3407
+ premultiply(alpha, applyToRGB = true) {
3408
+ if (applyToRGB) {
3409
+ this._components[0] *= alpha;
3410
+ this._components[1] *= alpha;
3411
+ this._components[2] *= alpha;
3412
+ }
3413
+ this._components[3] = alpha;
3414
+ this.refreshInt();
3415
+ this._value = null;
3416
+ return this;
3417
+ }
3418
+ toPremultiplied(alpha) {
3419
+ if (alpha === 1) {
3420
+ return (alpha * 255 << 24) + this._int;
3421
+ }
3422
+ if (alpha === 0) {
3423
+ return 0;
3424
+ }
3425
+ let r = this._int >> 16 & 255;
3426
+ let g = this._int >> 8 & 255;
3427
+ let b = this._int & 255;
3428
+ r = r * alpha + 0.5 | 0;
3429
+ g = g * alpha + 0.5 | 0;
3430
+ b = b * alpha + 0.5 | 0;
3431
+ return (alpha * 255 << 24) + (r << 16) + (g << 8) + b;
3432
+ }
3433
+ toHex() {
3434
+ const hexString = this._int.toString(16);
3435
+ return `#${"000000".substring(0, 6 - hexString.length) + hexString}`;
3436
+ }
3437
+ toHexa() {
3438
+ const alphaValue = Math.round(this._components[3] * 255);
3439
+ const alphaString = alphaValue.toString(16);
3440
+ return this.toHex() + "00".substring(0, 2 - alphaString.length) + alphaString;
3441
+ }
3442
+ setAlpha(alpha) {
3443
+ this._components[3] = alpha;
3444
+ return this;
3445
+ }
3446
+ round(step) {
3447
+ const [r, g, b] = this._components;
3448
+ this._components.set([
3449
+ Math.min(255, r / step * step),
3450
+ Math.min(255, g / step * step),
3451
+ Math.min(255, b / step * step)
3452
+ ]);
3453
+ this.refreshInt();
3454
+ this._value = null;
3455
+ return this;
3456
+ }
3457
+ toArray(out) {
3458
+ out = out ?? [];
3459
+ const [r, g, b, a] = this._components;
3460
+ out[0] = r;
3461
+ out[1] = g;
3462
+ out[2] = b;
3463
+ out[3] = a;
3464
+ return out;
3465
+ }
3466
+ normalize(value) {
3467
+ let components;
3468
+ if ((Array.isArray(value) || value instanceof Float32Array) && value.length >= 3 && value.length <= 4 && value.every((v) => v <= 1 && v >= 0)) {
3469
+ const [r, g, b, a = 1] = value;
3470
+ components = [r, g, b, a];
3471
+ } else if ((value instanceof Uint8Array || value instanceof Uint8ClampedArray) && value.length >= 3 && value.length <= 4) {
3472
+ const [r, g, b, a = 255] = value;
3473
+ components = [r / 255, g / 255, b / 255, a / 255];
3474
+ } else if (typeof value === "string" || typeof value === "object") {
3475
+ if (typeof value === "string") {
3476
+ const match = _Color.HEX_PATTERN.exec(value);
3477
+ if (match) {
3478
+ value = `#${match[2]}`;
3479
+ }
3480
+ }
3481
+ const color = w(value);
3482
+ if (color.isValid()) {
3483
+ const { r, g, b, a } = color.rgba;
3484
+ components = [r / 255, g / 255, b / 255, a];
3485
+ }
3486
+ } else if (typeof value === "number" && value >= 0 && value <= 16777215) {
3487
+ components = [
3488
+ (value >> 16 & 255) / 255,
3489
+ (value >> 8 & 255) / 255,
3490
+ (value & 255) / 255,
3491
+ 1
3492
+ ];
3493
+ }
3494
+ if (components) {
3495
+ this._components.set(components);
3496
+ this.refreshInt();
3497
+ } else {
3498
+ throw new Error(`Unable to convert color ${value}`);
3499
+ }
3500
+ }
3501
+ refreshInt() {
3502
+ const [r, g, b] = this._components;
3503
+ this._int = (r * 255 << 16) + (g * 255 << 8) + (b * 255 | 0);
3504
+ }
3632
3505
  };
3506
+ let Color = _Color;
3507
+ Color.shared = new _Color();
3508
+ Color.temp = new _Color();
3509
+ Color.HEX_PATTERN = /^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;
3633
3510
 
3634
3511
  function hex2rgb(hex, out = []) {
3635
- out[0] = (hex >> 16 & 255) / 255;
3636
- out[1] = (hex >> 8 & 255) / 255;
3637
- out[2] = (hex & 255) / 255;
3638
- return out;
3512
+ deprecation("7.2.0", "utils.hex2rgb is deprecated, use Color#toRgbArray instead");
3513
+ return Color.shared.setValue(hex).toRgbArray(out);
3639
3514
  }
3640
3515
  function hex2string(hex) {
3641
- let hexString = hex.toString(16);
3642
- hexString = "000000".substring(0, 6 - hexString.length) + hexString;
3643
- return `#${hexString}`;
3516
+ deprecation("7.2.0", "utils.hex2string is deprecated, use Color#toHex instead");
3517
+ return Color.shared.setValue(hex).toHex();
3644
3518
  }
3645
3519
  function string2hex(string) {
3646
- if (typeof string === "string") {
3647
- string = cssColorNames[string.toLowerCase()] || string;
3648
- if (string[0] === "#") {
3649
- string = string.slice(1);
3650
- }
3651
- if (string.length === 3) {
3652
- const [r, g, b] = string;
3653
- string = r + r + g + g + b + b;
3654
- }
3655
- }
3656
- return parseInt(string, 16);
3520
+ deprecation("7.2.0", "utils.string2hex is deprecated, use Color#toNumber instead");
3521
+ return Color.shared.setValue(string).toNumber();
3657
3522
  }
3658
3523
  function rgb2hex(rgb) {
3659
- return (rgb[0] * 255 << 16) + (rgb[1] * 255 << 8) + (rgb[2] * 255 | 0);
3524
+ deprecation("7.2.0", "utils.rgb2hex is deprecated, use Color#toNumber instead");
3525
+ return Color.shared.setValue(rgb).toNumber();
3660
3526
  }
3661
3527
 
3662
3528
  function mapPremultipliedBlendModes() {
@@ -3681,47 +3547,17 @@ Deprecated since v${version}`);
3681
3547
  function correctBlendMode(blendMode, premultiplied) {
3682
3548
  return premultiplyBlendMode[premultiplied ? 1 : 0][blendMode];
3683
3549
  }
3684
- function premultiplyRgba(rgb, alpha, out, premultiply) {
3685
- out = out || new Float32Array(4);
3686
- if (premultiply || premultiply === void 0) {
3687
- out[0] = rgb[0] * alpha;
3688
- out[1] = rgb[1] * alpha;
3689
- out[2] = rgb[2] * alpha;
3690
- } else {
3691
- out[0] = rgb[0];
3692
- out[1] = rgb[1];
3693
- out[2] = rgb[2];
3694
- }
3695
- out[3] = alpha;
3696
- return out;
3550
+ function premultiplyRgba(rgb, alpha, out, premultiply = true) {
3551
+ deprecation("7.2.0", `utils.premultiplyRgba has moved to Color.premultiply`);
3552
+ return Color.shared.setValue(rgb).premultiply(alpha, premultiply).toArray(out ?? new Float32Array(4));
3697
3553
  }
3698
3554
  function premultiplyTint(tint, alpha) {
3699
- if (alpha === 1) {
3700
- return (alpha * 255 << 24) + tint;
3701
- }
3702
- if (alpha === 0) {
3703
- return 0;
3704
- }
3705
- let R = tint >> 16 & 255;
3706
- let G = tint >> 8 & 255;
3707
- let B = tint & 255;
3708
- R = R * alpha + 0.5 | 0;
3709
- G = G * alpha + 0.5 | 0;
3710
- B = B * alpha + 0.5 | 0;
3711
- return (alpha * 255 << 24) + (R << 16) + (G << 8) + B;
3712
- }
3713
- function premultiplyTintToRgba(tint, alpha, out, premultiply) {
3714
- out = out || new Float32Array(4);
3715
- out[0] = (tint >> 16 & 255) / 255;
3716
- out[1] = (tint >> 8 & 255) / 255;
3717
- out[2] = (tint & 255) / 255;
3718
- if (premultiply || premultiply === void 0) {
3719
- out[0] *= alpha;
3720
- out[1] *= alpha;
3721
- out[2] *= alpha;
3722
- }
3723
- out[3] = alpha;
3724
- return out;
3555
+ deprecation("7.2.0", `utils.premultiplyTint has moved to Color.toPremultiplied`);
3556
+ return Color.shared.setValue(tint).toPremultiplied(alpha);
3557
+ }
3558
+ function premultiplyTintToRgba(tint, alpha, out, premultiply = true) {
3559
+ deprecation("7.2.0", `utils.premultiplyTintToRgba has moved to Color.premultiply`);
3560
+ return Color.shared.setValue(tint).premultiply(alpha, premultiply).toArray(out ?? new Float32Array(4));
3725
3561
  }
3726
3562
 
3727
3563
  const DATA_URI = /^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;
@@ -6108,6 +5944,51 @@ Deprecated since v${version}`);
6108
5944
  data[offset+3] = v.height;
6109
5945
  `
6110
5946
  },
5947
+ {
5948
+ test: (data, uniform) => data.type === "vec4" && data.size === 1 && !data.isArray && uniform.red !== void 0,
5949
+ code: (name) => `
5950
+ cv = ud["${name}"].value;
5951
+ v = uv["${name}"];
5952
+
5953
+ if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha)
5954
+ {
5955
+ cv[0] = v.red;
5956
+ cv[1] = v.green;
5957
+ cv[2] = v.blue;
5958
+ cv[3] = v.alpha;
5959
+ gl.uniform4f(ud["${name}"].location, v.red, v.green, v.blue, v.alpha)
5960
+ }`,
5961
+ codeUbo: (name) => `
5962
+ v = uv.${name};
5963
+
5964
+ data[offset] = v.red;
5965
+ data[offset+1] = v.green;
5966
+ data[offset+2] = v.blue;
5967
+ data[offset+3] = v.alpha;
5968
+ `
5969
+ },
5970
+ {
5971
+ test: (data, uniform) => data.type === "vec3" && data.size === 1 && !data.isArray && uniform.red !== void 0,
5972
+ code: (name) => `
5973
+ cv = ud["${name}"].value;
5974
+ v = uv["${name}"];
5975
+
5976
+ if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a)
5977
+ {
5978
+ cv[0] = v.red;
5979
+ cv[1] = v.green;
5980
+ cv[2] = v.blue;
5981
+
5982
+ gl.uniform3f(ud["${name}"].location, v.red, v.green, v.blue)
5983
+ }`,
5984
+ codeUbo: (name) => `
5985
+ v = uv.${name};
5986
+
5987
+ data[offset] = v.red;
5988
+ data[offset+1] = v.green;
5989
+ data[offset+2] = v.blue;
5990
+ `
5991
+ },
6111
5992
  {
6112
5993
  test: (data) => data.type === "vec4" && data.size === 1 && !data.isArray,
6113
5994
  code: (name) => `
@@ -7098,7 +6979,7 @@ ${this.fragmentSrc}`;
7098
6979
  const vertexData = element.vertexData;
7099
6980
  const textureId = element._texture.baseTexture._batchLocation;
7100
6981
  const alpha = Math.min(element.worldAlpha, 1);
7101
- const argb = alpha < 1 && element._texture.baseTexture.alphaMode ? premultiplyTint(element._tintRGB, alpha) : element._tintRGB + (alpha * 255 << 24);
6982
+ const argb = Color.shared.setValue(element._tintRGB).toPremultiplied(alpha);
7102
6983
  for (let i = 0; i < vertexData.length; i += 2) {
7103
6984
  float32View[aIndex++] = vertexData[i];
7104
6985
  float32View[aIndex++] = vertexData[i + 1];
@@ -7166,42 +7047,41 @@ ${this.fragmentSrc}`;
7166
7047
  class BackgroundSystem {
7167
7048
  constructor() {
7168
7049
  this.clearBeforeRender = true;
7169
- this._backgroundColor = 0;
7170
- this._backgroundColorRgba = [0, 0, 0, 1];
7171
- this._backgroundColorString = "#000000";
7172
- this.color = this._backgroundColor;
7050
+ this._backgroundColor = new Color(0);
7173
7051
  this.alpha = 1;
7174
7052
  }
7175
7053
  init(options) {
7176
7054
  this.clearBeforeRender = options.clearBeforeRender;
7177
- if (options.color) {
7178
- this.color = typeof options.color === "string" ? string2hex(options.color) : options.color;
7055
+ const { backgroundColor, background, backgroundAlpha } = options;
7056
+ const color = background ?? backgroundColor;
7057
+ if (color !== void 0) {
7058
+ this.color = color;
7179
7059
  }
7180
- this.alpha = options.alpha;
7060
+ this.alpha = backgroundAlpha;
7181
7061
  }
7182
7062
  get color() {
7183
- return this._backgroundColor;
7063
+ return this._backgroundColor.value;
7184
7064
  }
7185
7065
  set color(value) {
7186
- this._backgroundColor = value;
7187
- this._backgroundColorString = hex2string(value);
7188
- hex2rgb(value, this._backgroundColorRgba);
7066
+ this._backgroundColor.setValue(value);
7189
7067
  }
7190
7068
  get alpha() {
7191
- return this._backgroundColorRgba[3];
7069
+ return this._backgroundColor.alpha;
7192
7070
  }
7193
7071
  set alpha(value) {
7194
- this._backgroundColorRgba[3] = value;
7195
- }
7196
- get colorRgba() {
7197
- return this._backgroundColorRgba;
7072
+ this._backgroundColor.setAlpha(value);
7198
7073
  }
7199
- get colorString() {
7200
- return this._backgroundColorString;
7074
+ get backgroundColor() {
7075
+ return this._backgroundColor;
7201
7076
  }
7202
7077
  destroy() {
7203
7078
  }
7204
7079
  }
7080
+ BackgroundSystem.defaultOptions = {
7081
+ backgroundAlpha: 1,
7082
+ backgroundColor: 0,
7083
+ clearBeforeRender: true
7084
+ };
7205
7085
  BackgroundSystem.extension = {
7206
7086
  type: [
7207
7087
  ExtensionType.RendererSystem,
@@ -7421,6 +7301,13 @@ ${this.fragmentSrc}`;
7421
7301
  }
7422
7302
  }
7423
7303
  }
7304
+ ContextSystem.defaultOptions = {
7305
+ context: null,
7306
+ antialias: false,
7307
+ premultipliedAlpha: true,
7308
+ preserveDrawingBuffer: false,
7309
+ powerPreference: "default"
7310
+ };
7424
7311
  ContextSystem.extension = {
7425
7312
  type: ExtensionType.RendererSystem,
7426
7313
  name: "context"
@@ -7547,12 +7434,21 @@ ${this.fragmentSrc}`;
7547
7434
  super(null, options);
7548
7435
  this.mipmap = MIPMAP_MODES.OFF;
7549
7436
  this.valid = true;
7550
- this.clearColor = [0, 0, 0, 0];
7437
+ this._clear = new Color([0, 0, 0, 0]);
7551
7438
  this.framebuffer = new Framebuffer(this.realWidth, this.realHeight).addColorTexture(0, this);
7552
7439
  this.framebuffer.multisample = options.multisample;
7553
7440
  this.maskStack = [];
7554
7441
  this.filterStack = [{}];
7555
7442
  }
7443
+ set clearColor(value) {
7444
+ this._clear.setValue(value);
7445
+ }
7446
+ get clearColor() {
7447
+ return this._clear.value;
7448
+ }
7449
+ get clear() {
7450
+ return this._clear;
7451
+ }
7556
7452
  resize(desiredWidth, desiredHeight) {
7557
7453
  this.framebuffer.resize(desiredWidth * this.resolution, desiredHeight * this.resolution);
7558
7454
  this.setRealSize(this.framebuffer.width, this.framebuffer.height);
@@ -7826,7 +7722,7 @@ ${this.fragmentSrc}`;
7826
7722
  };
7827
7723
  }
7828
7724
  class Texture extends eventemitter3 {
7829
- constructor(baseTexture, frame, orig, trim, rotate, anchor) {
7725
+ constructor(baseTexture, frame, orig, trim, rotate, anchor, borders) {
7830
7726
  super();
7831
7727
  this.noFrame = false;
7832
7728
  if (!frame) {
@@ -7850,6 +7746,7 @@ ${this.fragmentSrc}`;
7850
7746
  throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");
7851
7747
  }
7852
7748
  this.defaultAnchor = anchor ? new Point(anchor.x, anchor.y) : new Point(0, 0);
7749
+ this.defaultBorders = borders;
7853
7750
  this._updateID = 0;
7854
7751
  this.textureCacheIds = [];
7855
7752
  if (!baseTexture.valid) {
@@ -7908,7 +7805,7 @@ ${this.fragmentSrc}`;
7908
7805
  clone() {
7909
7806
  const clonedFrame = this._frame.clone();
7910
7807
  const clonedOrig = this._frame === this.orig ? clonedFrame : this.orig.clone();
7911
- const clonedTexture = new Texture(this.baseTexture, !this.noFrame && clonedFrame, clonedOrig, this.trim?.clone(), this.rotate, this.defaultAnchor);
7808
+ const clonedTexture = new Texture(this.baseTexture, !this.noFrame && clonedFrame, clonedOrig, this.trim?.clone(), this.rotate, this.defaultAnchor, this.defaultBorders);
7912
7809
  if (this.noFrame) {
7913
7810
  clonedTexture._frame = clonedFrame;
7914
7811
  }
@@ -9810,7 +9707,8 @@ ${this.fragmentSrc}`;
9810
9707
  }
9811
9708
  });
9812
9709
  }
9813
- init(staticMap) {
9710
+ init() {
9711
+ const staticMap = this.rendererPlugins;
9814
9712
  for (const o in staticMap) {
9815
9713
  this.plugins[o] = new staticMap[o](this.renderer);
9816
9714
  }
@@ -9984,11 +9882,8 @@ ${this.fragmentSrc}`;
9984
9882
  this.destinationFrame.copyFrom(destinationFrame);
9985
9883
  }
9986
9884
  clear(clearColor, mask) {
9987
- if (this.current) {
9988
- clearColor = clearColor || this.current.baseTexture.clearColor;
9989
- } else {
9990
- clearColor = clearColor || this.renderer.background.colorRgba;
9991
- }
9885
+ const fallbackColor = this.current ? this.current.baseTexture.clear : this.renderer.background.backgroundColor;
9886
+ const color = clearColor ? Color.shared.setValue(clearColor) : fallbackColor;
9992
9887
  const destinationFrame = this.destinationFrame;
9993
9888
  const baseFrame = this.current ? this.current.baseTexture : this.renderer._view.screen;
9994
9889
  const clearMask = destinationFrame.width !== baseFrame.width || destinationFrame.height !== baseFrame.height;
@@ -10001,7 +9896,7 @@ ${this.fragmentSrc}`;
10001
9896
  this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST);
10002
9897
  this.renderer.gl.scissor(x, y, width, height);
10003
9898
  }
10004
- this.renderer.framebuffer.clear(clearColor[0], clearColor[1], clearColor[2], clearColor[3], mask);
9899
+ this.renderer.framebuffer.clear(color.red, color.green, color.blue, color.alpha, mask);
10005
9900
  if (clearMask) {
10006
9901
  this.renderer.scissor.pop();
10007
9902
  }
@@ -10454,16 +10349,19 @@ ${this.fragmentSrc}`;
10454
10349
  this.renderer = renderer;
10455
10350
  }
10456
10351
  run(options) {
10457
- const renderer = this.renderer;
10458
- renderer.emitWithCustomOptions(renderer.runners.init, options);
10352
+ const { renderer } = this;
10353
+ renderer.runners.init.emit(renderer.options);
10459
10354
  if (options.hello) {
10460
- console.log(`PixiJS ${"7.1.2"} - ${renderer.rendererLogId} - https://pixijs.com`);
10355
+ console.log(`PixiJS ${"7.2.0-beta"} - ${renderer.rendererLogId} - https://pixijs.com`);
10461
10356
  }
10462
- renderer.resize(this.renderer.screen.width, this.renderer.screen.height);
10357
+ renderer.resize(renderer.screen.width, renderer.screen.height);
10463
10358
  }
10464
10359
  destroy() {
10465
10360
  }
10466
10361
  }
10362
+ StartupSystem.defaultOptions = {
10363
+ hello: false
10364
+ };
10467
10365
  StartupSystem.extension = {
10468
10366
  type: [
10469
10367
  ExtensionType.RendererSystem,
@@ -11223,6 +11121,12 @@ ${this.fragmentSrc}`;
11223
11121
  this.screen = null;
11224
11122
  }
11225
11123
  }
11124
+ ViewSystem.defaultOptions = {
11125
+ width: 800,
11126
+ height: 600,
11127
+ resolution: settings.RESOLUTION,
11128
+ autoDensity: false
11129
+ };
11226
11130
  ViewSystem.extension = {
11227
11131
  type: [
11228
11132
  ExtensionType.RendererSystem,
@@ -11234,6 +11138,12 @@ ${this.fragmentSrc}`;
11234
11138
 
11235
11139
  settings.PREFER_ENV = ENV.WEBGL2;
11236
11140
  settings.STRICT_TEXTURE_CACHE = false;
11141
+ settings.RENDER_OPTIONS = {
11142
+ ...ContextSystem.defaultOptions,
11143
+ ...BackgroundSystem.defaultOptions,
11144
+ ...ViewSystem.defaultOptions,
11145
+ ...StartupSystem.defaultOptions
11146
+ };
11237
11147
  Object.defineProperties(settings, {
11238
11148
  WRAP_MODE: {
11239
11149
  get() {
@@ -11364,6 +11274,7 @@ ${this.fragmentSrc}`;
11364
11274
  });
11365
11275
 
11366
11276
  var UPDATE_PRIORITY = /* @__PURE__ */ ((UPDATE_PRIORITY2) => {
11277
+ UPDATE_PRIORITY2[UPDATE_PRIORITY2["INTERACTION"] = 50] = "INTERACTION";
11367
11278
  UPDATE_PRIORITY2[UPDATE_PRIORITY2["HIGH"] = 25] = "HIGH";
11368
11279
  UPDATE_PRIORITY2[UPDATE_PRIORITY2["NORMAL"] = 0] = "NORMAL";
11369
11280
  UPDATE_PRIORITY2[UPDATE_PRIORITY2["LOW"] = -25] = "LOW";
@@ -11940,31 +11851,9 @@ ${this.fragmentSrc}`;
11940
11851
  options.premultipliedAlpha = options.useContextAlpha && options.useContextAlpha !== "notMultiplied";
11941
11852
  options.backgroundAlpha = options.useContextAlpha === false ? 1 : options.backgroundAlpha;
11942
11853
  }
11943
- const startupOptions = {
11944
- hello: options.hello,
11945
- _plugin: _Renderer.__plugins,
11946
- background: {
11947
- alpha: options.backgroundAlpha,
11948
- color: options.background ?? options.backgroundColor,
11949
- clearBeforeRender: options.clearBeforeRender
11950
- },
11951
- _view: {
11952
- height: options.height,
11953
- width: options.width,
11954
- autoDensity: options.autoDensity,
11955
- resolution: options.resolution,
11956
- view: options.view
11957
- },
11958
- context: {
11959
- antialias: options.antialias,
11960
- context: options.context,
11961
- powerPreference: options.powerPreference,
11962
- premultipliedAlpha: options.premultipliedAlpha,
11963
- preserveDrawingBuffer: options.preserveDrawingBuffer
11964
- }
11965
- };
11854
+ this._plugin.rendererPlugins = _Renderer.__plugins;
11966
11855
  this.options = options;
11967
- this.startup.run(startupOptions);
11856
+ this.startup.run(this.options);
11968
11857
  }
11969
11858
  static test(options) {
11970
11859
  if (options?.forceCanvas) {
@@ -12052,7 +11941,7 @@ ${this.fragmentSrc}`;
12052
11941
  }
12053
11942
  get backgroundAlpha() {
12054
11943
  deprecation("7.0.0", "renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead.");
12055
- return this.background.color;
11944
+ return this.background.alpha;
12056
11945
  }
12057
11946
  set backgroundAlpha(value) {
12058
11947
  deprecation("7.0.0", "renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead.");
@@ -12648,7 +12537,7 @@ ${this.fragmentSrc}`;
12648
12537
  }
12649
12538
  }
12650
12539
 
12651
- const VERSION = "7.1.2";
12540
+ const VERSION = "7.2.0-beta";
12652
12541
 
12653
12542
  class Bounds {
12654
12543
  constructor() {
@@ -13043,7 +12932,7 @@ ${this.fragmentSrc}`;
13043
12932
  this.filters = null;
13044
12933
  this.filterArea = null;
13045
12934
  this.hitArea = null;
13046
- this.interactive = false;
12935
+ this.eventMode = "auto";
13047
12936
  this.interactiveChildren = false;
13048
12937
  this.emit("destroyed");
13049
12938
  this.removeAllListeners();
@@ -13753,7 +13642,7 @@ ${this.fragmentSrc}`;
13753
13642
  }
13754
13643
  set tint(value) {
13755
13644
  this._tint = value;
13756
- this._tintRGB = (value >> 16) + (value & 65280) + ((value & 255) << 16);
13645
+ this._tintRGB = Color.shared.setValue(value).toLittleEndianNumber();
13757
13646
  }
13758
13647
  get texture() {
13759
13648
  return this._texture;
@@ -14392,23 +14281,21 @@ ${this.fragmentSrc}`;
14392
14281
  this._loadMatrix(matrix, multiply);
14393
14282
  }
14394
14283
  tint(color, multiply) {
14395
- const r = color >> 16 & 255;
14396
- const g = color >> 8 & 255;
14397
- const b = color & 255;
14284
+ const [r, g, b] = Color.shared.setValue(color).toArray();
14398
14285
  const matrix = [
14399
- r / 255,
14286
+ r,
14400
14287
  0,
14401
14288
  0,
14402
14289
  0,
14403
14290
  0,
14404
14291
  0,
14405
- g / 255,
14292
+ g,
14406
14293
  0,
14407
14294
  0,
14408
14295
  0,
14409
14296
  0,
14410
14297
  0,
14411
- b / 255,
14298
+ b,
14412
14299
  0,
14413
14300
  0,
14414
14301
  0,
@@ -14771,12 +14658,9 @@ ${this.fragmentSrc}`;
14771
14658
  toned = toned || 0.15;
14772
14659
  lightColor = lightColor || 16770432;
14773
14660
  darkColor = darkColor || 3375104;
14774
- const lR = (lightColor >> 16 & 255) / 255;
14775
- const lG = (lightColor >> 8 & 255) / 255;
14776
- const lB = (lightColor & 255) / 255;
14777
- const dR = (darkColor >> 16 & 255) / 255;
14778
- const dG = (darkColor >> 8 & 255) / 255;
14779
- const dB = (darkColor & 255) / 255;
14661
+ const temp = Color.shared;
14662
+ const [lR, lG, lB] = temp.setValue(lightColor).toArray();
14663
+ const [dR, dG, dB] = temp.setValue(darkColor).toArray();
14780
14664
  const matrix = [
14781
14665
  0.3,
14782
14666
  0.59,
@@ -15014,6 +14898,74 @@ ${this.fragmentSrc}`;
15014
14898
  });
15015
14899
  });
15016
14900
 
14901
+ class EventsTickerClass {
14902
+ constructor() {
14903
+ this.interactionFrequency = 10;
14904
+ this._deltaTime = 0;
14905
+ this._didMove = false;
14906
+ this.tickerAdded = false;
14907
+ this._pauseUpdate = true;
14908
+ }
14909
+ init(events) {
14910
+ this.removeTickerListener();
14911
+ this.events = events;
14912
+ this.interactionFrequency = 10;
14913
+ this._deltaTime = 0;
14914
+ this._didMove = false;
14915
+ this.tickerAdded = false;
14916
+ this._pauseUpdate = true;
14917
+ }
14918
+ get pauseUpdate() {
14919
+ return this._pauseUpdate;
14920
+ }
14921
+ set pauseUpdate(paused) {
14922
+ this._pauseUpdate = paused;
14923
+ }
14924
+ addTickerListener() {
14925
+ if (this.tickerAdded || !this.domElement) {
14926
+ return;
14927
+ }
14928
+ Ticker.system.add(this.tickerUpdate, this, UPDATE_PRIORITY.INTERACTION);
14929
+ this.tickerAdded = true;
14930
+ }
14931
+ removeTickerListener() {
14932
+ if (!this.tickerAdded) {
14933
+ return;
14934
+ }
14935
+ Ticker.system.remove(this.tickerUpdate, this);
14936
+ this.tickerAdded = false;
14937
+ }
14938
+ pointerMoved() {
14939
+ this._didMove = true;
14940
+ }
14941
+ update() {
14942
+ if (!this.domElement || this._pauseUpdate) {
14943
+ return;
14944
+ }
14945
+ if (this._didMove) {
14946
+ this._didMove = false;
14947
+ return;
14948
+ }
14949
+ const rootPointerEvent = this.events["rootPointerEvent"];
14950
+ if (this.events.supportsTouchEvents && rootPointerEvent.pointerType === "touch") {
14951
+ return;
14952
+ }
14953
+ globalThis.document.dispatchEvent(new PointerEvent("pointermove", {
14954
+ clientX: rootPointerEvent.clientX,
14955
+ clientY: rootPointerEvent.clientY
14956
+ }));
14957
+ }
14958
+ tickerUpdate(deltaTime) {
14959
+ this._deltaTime += deltaTime;
14960
+ if (this._deltaTime < this.interactionFrequency) {
14961
+ return;
14962
+ }
14963
+ this._deltaTime = 0;
14964
+ this.update();
14965
+ }
14966
+ }
14967
+ const EventsTicker = new EventsTickerClass();
14968
+
15017
14969
  class FederatedEvent {
15018
14970
  constructor(manager) {
15019
14971
  this.bubbles = true;
@@ -15118,6 +15070,9 @@ ${this.fragmentSrc}`;
15118
15070
  get screenY() {
15119
15071
  return this.screen.y;
15120
15072
  }
15073
+ getLocalPosition(displayObject, point, globalPos) {
15074
+ return displayObject.worldTransform.applyInverse(globalPos || this.global, point);
15075
+ }
15121
15076
  getModifierState(key) {
15122
15077
  return "getModifierState" in this.nativeEvent && this.nativeEvent.getModifierState(key);
15123
15078
  }
@@ -15147,11 +15102,14 @@ ${this.fragmentSrc}`;
15147
15102
  class FederatedWheelEvent extends FederatedMouseEvent {
15148
15103
  constructor() {
15149
15104
  super(...arguments);
15150
- this.DOM_DELTA_LINE = 0;
15151
- this.DOM_DELTA_PAGE = 1;
15152
- this.DOM_DELTA_PIXEL = 2;
15105
+ this.DOM_DELTA_PIXEL = 0;
15106
+ this.DOM_DELTA_LINE = 1;
15107
+ this.DOM_DELTA_PAGE = 2;
15153
15108
  }
15154
15109
  }
15110
+ FederatedWheelEvent.DOM_DELTA_PIXEL = 0;
15111
+ FederatedWheelEvent.DOM_DELTA_LINE = 1;
15112
+ FederatedWheelEvent.DOM_DELTA_PAGE = 2;
15155
15113
 
15156
15114
  const PROPAGATION_LIMIT = 2048;
15157
15115
  const tempHitLocation = new Point();
@@ -15214,7 +15172,8 @@ ${this.fragmentSrc}`;
15214
15172
  }
15215
15173
  }
15216
15174
  hitTest(x, y) {
15217
- const invertedPath = this.hitTestRecursive(this.rootTarget, this.rootTarget.interactive, tempHitLocation.set(x, y), this.hitTestFn, this.hitPruneFn);
15175
+ EventsTicker.pauseUpdate = true;
15176
+ const invertedPath = this.hitTestRecursive(this.rootTarget, this.rootTarget.eventMode, tempHitLocation.set(x, y), this.hitTestFn, this.hitPruneFn);
15218
15177
  return invertedPath && invertedPath[0];
15219
15178
  }
15220
15179
  propagate(e, type) {
@@ -15245,9 +15204,15 @@ ${this.fragmentSrc}`;
15245
15204
  all(e, type, target = this.rootTarget) {
15246
15205
  e.eventPhase = e.BUBBLING_PHASE;
15247
15206
  const children = target.children;
15248
- if (children) {
15249
- for (let i = 0; i < children.length; i++) {
15250
- this.all(e, type, children[i]);
15207
+ const interactionNone = target.eventMode === "none";
15208
+ const interactionPassive = target.eventMode === "passive" && !target.interactiveChildren;
15209
+ const interactiveChildren = target.interactiveChildren;
15210
+ const shouldIterateChildren = !interactionNone && interactiveChildren && !interactionPassive;
15211
+ if (children && children.length > 0) {
15212
+ if (shouldIterateChildren) {
15213
+ for (let i = 0; i < children.length; i++) {
15214
+ this.all(e, type, children[i]);
15215
+ }
15251
15216
  }
15252
15217
  }
15253
15218
  e.currentTarget = target;
@@ -15265,35 +15230,50 @@ ${this.fragmentSrc}`;
15265
15230
  propagationPath.reverse();
15266
15231
  return propagationPath;
15267
15232
  }
15268
- hitTestRecursive(currentTarget, interactive, location, testFn, pruneFn) {
15233
+ hitTestRecursive(currentTarget, eventMode, location, testFn, pruneFn) {
15269
15234
  if (!currentTarget || !currentTarget.visible) {
15270
15235
  return null;
15271
15236
  }
15272
15237
  if (pruneFn(currentTarget, location)) {
15273
15238
  return null;
15274
15239
  }
15240
+ if (currentTarget.eventMode === "dynamic" || eventMode === "dynamic") {
15241
+ EventsTicker.pauseUpdate = false;
15242
+ }
15275
15243
  if (currentTarget.interactiveChildren && currentTarget.children) {
15276
15244
  const children = currentTarget.children;
15277
15245
  for (let i = children.length - 1; i >= 0; i--) {
15278
15246
  const child = children[i];
15279
- const nestedHit = this.hitTestRecursive(child, interactive || child.interactive, location, testFn, pruneFn);
15247
+ const nestedHit = this.hitTestRecursive(child, this._isInteractive(eventMode) ? eventMode : child.eventMode, location, testFn, pruneFn);
15280
15248
  if (nestedHit) {
15281
15249
  if (nestedHit.length > 0 && !nestedHit[nestedHit.length - 1].parent) {
15282
15250
  continue;
15283
15251
  }
15284
- if (nestedHit.length > 0 || currentTarget.interactive) {
15252
+ if (nestedHit.length > 0 || currentTarget.isInteractive()) {
15285
15253
  nestedHit.push(currentTarget);
15286
15254
  }
15287
15255
  return nestedHit;
15288
15256
  }
15289
15257
  }
15290
15258
  }
15291
- if (interactive && testFn(currentTarget, location)) {
15292
- return currentTarget.interactive ? [currentTarget] : [];
15259
+ if (this._isInteractive(eventMode) && testFn(currentTarget, location)) {
15260
+ return currentTarget.isInteractive() ? [currentTarget] : [];
15293
15261
  }
15294
15262
  return null;
15295
15263
  }
15264
+ _isInteractive(int) {
15265
+ return int === "static" || int === "dynamic";
15266
+ }
15296
15267
  hitPruneFn(displayObject, location) {
15268
+ if (displayObject.eventMode === "none") {
15269
+ return true;
15270
+ }
15271
+ if (displayObject.eventMode === "passive" && !displayObject.interactiveChildren) {
15272
+ return true;
15273
+ }
15274
+ if (displayObject.isMask) {
15275
+ return true;
15276
+ }
15297
15277
  if (displayObject.hitArea) {
15298
15278
  displayObject.worldTransform.applyInverse(location, tempLocalMapping);
15299
15279
  if (!displayObject.hitArea.contains(tempLocalMapping.x, tempLocalMapping.y)) {
@@ -15309,6 +15289,9 @@ ${this.fragmentSrc}`;
15309
15289
  return false;
15310
15290
  }
15311
15291
  hitTestFn(displayObject, location) {
15292
+ if (displayObject.eventMode === "passive") {
15293
+ return false;
15294
+ }
15312
15295
  if (displayObject.hitArea) {
15313
15296
  return true;
15314
15297
  }
@@ -15692,6 +15675,8 @@ ${this.fragmentSrc}`;
15692
15675
  const listeners = e.currentTarget._events[type];
15693
15676
  if (!listeners)
15694
15677
  return;
15678
+ if (!e.currentTarget.isInteractive())
15679
+ return;
15695
15680
  if ("fn" in listeners) {
15696
15681
  listeners.fn.call(listeners.context, e);
15697
15682
  } else {
@@ -15710,7 +15695,7 @@ ${this.fragmentSrc}`;
15710
15695
  touchmove: "pointermove",
15711
15696
  touchcancel: "pointercancel"
15712
15697
  };
15713
- class EventSystem {
15698
+ const _EventSystem = class {
15714
15699
  constructor(renderer) {
15715
15700
  this.supportsTouchEvents = "ontouchstart" in globalThis;
15716
15701
  this.supportsPointerEvents = !!globalThis.PointerEvent;
@@ -15718,6 +15703,7 @@ ${this.fragmentSrc}`;
15718
15703
  this.resolution = 1;
15719
15704
  this.renderer = renderer;
15720
15705
  this.rootBoundary = new EventBoundary(null);
15706
+ EventsTicker.init(this);
15721
15707
  this.autoPreventDefault = true;
15722
15708
  this.eventsAdded = false;
15723
15709
  this.rootPointerEvent = new FederatedPointerEvent(null);
@@ -15732,10 +15718,14 @@ ${this.fragmentSrc}`;
15732
15718
  this.onPointerOverOut = this.onPointerOverOut.bind(this);
15733
15719
  this.onWheel = this.onWheel.bind(this);
15734
15720
  }
15735
- init() {
15721
+ static get defaultEventMode() {
15722
+ return this._defaultEventMode;
15723
+ }
15724
+ init(options) {
15736
15725
  const { view, resolution } = this.renderer;
15737
15726
  this.setTargetElement(view);
15738
15727
  this.resolution = resolution;
15728
+ _EventSystem._defaultEventMode = options.eventMode ?? "auto";
15739
15729
  }
15740
15730
  resolutionChange(resolution) {
15741
15731
  this.resolution = resolution;
@@ -15797,6 +15787,7 @@ ${this.fragmentSrc}`;
15797
15787
  this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
15798
15788
  if (this.supportsTouchEvents && nativeEvent.pointerType === "touch")
15799
15789
  return;
15790
+ EventsTicker.pointerMoved();
15800
15791
  const normalizedEvents = this.normalizeToPointerData(nativeEvent);
15801
15792
  for (let i = 0, j = normalizedEvents.length; i < j; i++) {
15802
15793
  const event = this.bootstrapEvent(this.rootPointerEvent, normalizedEvents[i]);
@@ -15840,12 +15831,14 @@ ${this.fragmentSrc}`;
15840
15831
  setTargetElement(element) {
15841
15832
  this.removeEvents();
15842
15833
  this.domElement = element;
15834
+ EventsTicker.domElement = element;
15843
15835
  this.addEvents();
15844
15836
  }
15845
15837
  addEvents() {
15846
15838
  if (this.eventsAdded || !this.domElement) {
15847
15839
  return;
15848
15840
  }
15841
+ EventsTicker.addTickerListener();
15849
15842
  const style = this.domElement.style;
15850
15843
  if (style) {
15851
15844
  if (globalThis.navigator.msPointerEnabled) {
@@ -15883,6 +15876,7 @@ ${this.fragmentSrc}`;
15883
15876
  if (!this.eventsAdded || !this.domElement) {
15884
15877
  return;
15885
15878
  }
15879
+ EventsTicker.removeTickerListener();
15886
15880
  const style = this.domElement.style;
15887
15881
  if (globalThis.navigator.msPointerEnabled) {
15888
15882
  style.msContentZooming = "";
@@ -16059,7 +16053,8 @@ ${this.fragmentSrc}`;
16059
16053
  event.relatedTarget = null;
16060
16054
  event.shiftKey = nativeEvent.shiftKey;
16061
16055
  }
16062
- }
16056
+ };
16057
+ let EventSystem = _EventSystem;
16063
16058
  EventSystem.extension = {
16064
16059
  name: "events",
16065
16060
  type: [
@@ -16069,6 +16064,9 @@ ${this.fragmentSrc}`;
16069
16064
  };
16070
16065
  extensions$1.add(EventSystem);
16071
16066
 
16067
+ function convertEventModeToInteractiveMode(mode) {
16068
+ return mode === "dynamic" || mode === "static";
16069
+ }
16072
16070
  const FederatedDisplayObject = {
16073
16071
  onclick: null,
16074
16072
  onmousedown: null,
@@ -16103,7 +16101,26 @@ ${this.fragmentSrc}`;
16103
16101
  onglobaltouchmove: null,
16104
16102
  ontouchstart: null,
16105
16103
  onwheel: null,
16106
- interactive: false,
16104
+ _internalInteractive: void 0,
16105
+ get interactive() {
16106
+ return this._internalInteractive ?? convertEventModeToInteractiveMode(EventSystem.defaultEventMode);
16107
+ },
16108
+ set interactive(value) {
16109
+ deprecation("7.2.0", `Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead.`);
16110
+ this._internalInteractive = value;
16111
+ this.eventMode = value ? "static" : "auto";
16112
+ },
16113
+ _internalEventMode: void 0,
16114
+ get eventMode() {
16115
+ return this._internalEventMode ?? EventSystem.defaultEventMode;
16116
+ },
16117
+ set eventMode(value) {
16118
+ this._internalInteractive = convertEventModeToInteractiveMode(value);
16119
+ this._internalEventMode = value;
16120
+ },
16121
+ isInteractive() {
16122
+ return this.eventMode === "static" || this.eventMode === "dynamic";
16123
+ },
16107
16124
  interactiveChildren: true,
16108
16125
  hitArea: null,
16109
16126
  addEventListener(type, listener, options) {
@@ -16238,7 +16255,7 @@ ${this.fragmentSrc}`;
16238
16255
  if (!displayObject.visible || !displayObject.accessibleChildren) {
16239
16256
  return;
16240
16257
  }
16241
- if (displayObject.accessible && displayObject.interactive) {
16258
+ if (displayObject.accessible && displayObject.isInteractive()) {
16242
16259
  if (!displayObject._accessibleActive) {
16243
16260
  this.addChild(displayObject);
16244
16261
  }
@@ -17115,14 +17132,16 @@ ${e}`);
17115
17132
  priority: LoaderParserPriority.High
17116
17133
  },
17117
17134
  config: {
17118
- preferWorkers: true
17135
+ preferWorkers: true,
17136
+ preferCreateImageBitmap: true,
17137
+ crossOrigin: "anonymous"
17119
17138
  },
17120
17139
  test(url) {
17121
17140
  return checkDataUrl(url, validImageMIMEs) || checkExtension(url, validImageExtensions);
17122
17141
  },
17123
17142
  async load(url, asset, loader) {
17124
17143
  let src = null;
17125
- if (globalThis.createImageBitmap) {
17144
+ if (globalThis.createImageBitmap && this.config.preferCreateImageBitmap) {
17126
17145
  if (this.config.preferWorkers && await WorkerManager.isImageBitmapSupported()) {
17127
17146
  src = await WorkerManager.loadImageBitmap(url);
17128
17147
  } else {
@@ -17131,7 +17150,7 @@ ${e}`);
17131
17150
  } else {
17132
17151
  src = await new Promise((resolve) => {
17133
17152
  src = new Image();
17134
- src.crossOrigin = "anonymous";
17153
+ src.crossOrigin = this.config.crossOrigin;
17135
17154
  src.src = url;
17136
17155
  if (src.complete) {
17137
17156
  resolve(src);
@@ -19803,11 +19822,11 @@ ${e}`);
19803
19822
  }
19804
19823
  }
19805
19824
  addColors(colors, color, alpha, size, offset = 0) {
19806
- const rgb = (color >> 16) + (color & 65280) + ((color & 255) << 16);
19807
- const rgba = premultiplyTint(rgb, alpha);
19825
+ const bgr = Color.shared.setValue(color).toLittleEndianNumber();
19826
+ const result = Color.shared.setValue(bgr).toPremultiplied(alpha);
19808
19827
  colors.length = Math.max(colors.length, offset + size);
19809
19828
  for (let i = 0; i < size; i++) {
19810
- colors[offset + i] = rgba;
19829
+ colors[offset + i] = result;
19811
19830
  }
19812
19831
  }
19813
19832
  addTextureIds(textureIds, id, size, offset = 0) {
@@ -19975,25 +19994,26 @@ ${e}`);
19975
19994
  get line() {
19976
19995
  return this._lineStyle;
19977
19996
  }
19978
- lineStyle(options = null, color = 0, alpha = 1, alignment = 0.5, native = false) {
19997
+ lineStyle(options = null, color = 0, alpha, alignment = 0.5, native = false) {
19979
19998
  if (typeof options === "number") {
19980
19999
  options = { width: options, color, alpha, alignment, native };
19981
20000
  }
19982
20001
  return this.lineTextureStyle(options);
19983
20002
  }
19984
20003
  lineTextureStyle(options) {
19985
- options = Object.assign({
20004
+ const defaultLineStyleOptions = {
19986
20005
  width: 0,
19987
20006
  texture: Texture.WHITE,
19988
20007
  color: options?.texture ? 16777215 : 0,
19989
- alpha: 1,
19990
20008
  matrix: null,
19991
20009
  alignment: 0.5,
19992
20010
  native: false,
19993
20011
  cap: LINE_CAP.BUTT,
19994
20012
  join: LINE_JOIN.MITER,
19995
20013
  miterLimit: 10
19996
- }, options);
20014
+ };
20015
+ options = Object.assign(defaultLineStyleOptions, options);
20016
+ this.normalizeColor(options);
19997
20017
  if (this.currentPath) {
19998
20018
  this.startPoly();
19999
20019
  }
@@ -20116,16 +20136,22 @@ ${e}`);
20116
20136
  ArcUtils.arc(startX, startY, cx, cy, radius, startAngle, endAngle, anticlockwise, points);
20117
20137
  return this;
20118
20138
  }
20119
- beginFill(color = 0, alpha = 1) {
20139
+ beginFill(color = 0, alpha) {
20120
20140
  return this.beginTextureFill({ texture: Texture.WHITE, color, alpha });
20121
20141
  }
20142
+ normalizeColor(options) {
20143
+ const temp2 = Color.shared.setValue(options.color ?? 0);
20144
+ options.color = temp2.toNumber();
20145
+ options.alpha ?? (options.alpha = temp2.alpha);
20146
+ }
20122
20147
  beginTextureFill(options) {
20123
- options = Object.assign({
20148
+ const defaultOptions = {
20124
20149
  texture: Texture.WHITE,
20125
20150
  color: 16777215,
20126
- alpha: 1,
20127
20151
  matrix: null
20128
- }, options);
20152
+ };
20153
+ options = Object.assign(defaultOptions, options);
20154
+ this.normalizeColor(options);
20129
20155
  if (this.currentPath) {
20130
20156
  this.startPoly();
20131
20157
  }
@@ -20231,7 +20257,7 @@ ${e}`);
20231
20257
  blendMode,
20232
20258
  indices,
20233
20259
  uvs,
20234
- _batchRGB: hex2rgb(color),
20260
+ _batchRGB: Color.shared.setValue(color).toRgbArray(),
20235
20261
  _tintRGB: color,
20236
20262
  _texture: gI.style.texture,
20237
20263
  alpha: gI.style.alpha,
@@ -20261,10 +20287,7 @@ ${e}`);
20261
20287
  const uniforms = shader.uniforms;
20262
20288
  const drawCalls = geometry.drawCalls;
20263
20289
  uniforms.translationMatrix = this.transform.worldTransform;
20264
- uniforms.tint[0] = (tint >> 16 & 255) / 255 * worldAlpha;
20265
- uniforms.tint[1] = (tint >> 8 & 255) / 255 * worldAlpha;
20266
- uniforms.tint[2] = (tint & 255) / 255 * worldAlpha;
20267
- uniforms.tint[3] = worldAlpha;
20290
+ Color.shared.setValue(tint).multiply([worldAlpha, worldAlpha, worldAlpha]).setAlpha(worldAlpha).toArray(uniforms.tint);
20268
20291
  renderer.shader.bind(shader);
20269
20292
  renderer.geometry.bind(geometry, shader);
20270
20293
  renderer.state.set(this.state);
@@ -20318,15 +20341,10 @@ ${e}`);
20318
20341
  calculateTints() {
20319
20342
  if (this.batchTint !== this.tint) {
20320
20343
  this.batchTint = this.tint;
20321
- const tintRGB = hex2rgb(this.tint, temp);
20344
+ const tintRGB = Color.shared.setValue(this.tint).toRgbArray(temp);
20322
20345
  for (let i = 0; i < this.batches.length; i++) {
20323
20346
  const batch = this.batches[i];
20324
- const batchTint = batch._batchRGB;
20325
- const r = tintRGB[0] * batchTint[0] * 255;
20326
- const g = tintRGB[1] * batchTint[1] * 255;
20327
- const b = tintRGB[2] * batchTint[2] * 255;
20328
- const color = (r << 16) + (g << 8) + (b | 0);
20329
- batch._tintRGB = (color >> 16) + (color & 65280) + ((color & 255) << 16);
20347
+ batch._tintRGB = Color.shared.setValue(tintRGB).multiply(batch._batchRGB).toLittleEndianNumber();
20330
20348
  }
20331
20349
  }
20332
20350
  }
@@ -20712,7 +20730,7 @@ ${e}`);
20712
20730
  if (value === this._tint)
20713
20731
  return;
20714
20732
  this._tint = value;
20715
- this._tintRGB = (value >> 16) + (value & 65280) + ((value & 255) << 16);
20733
+ this._tintRGB = Color.shared.setValue(value).toLittleEndianNumber();
20716
20734
  this._colorDirty = true;
20717
20735
  }
20718
20736
  get tint() {
@@ -20722,7 +20740,8 @@ ${e}`);
20722
20740
  if (this._colorDirty) {
20723
20741
  this._colorDirty = false;
20724
20742
  const baseTexture = this.texture.baseTexture;
20725
- premultiplyTintToRgba(this._tint, this._alpha, this.uniforms.uColor, baseTexture.alphaMode);
20743
+ const applyToChannels = baseTexture.alphaMode;
20744
+ Color.shared.setValue(this._tint).premultiply(this._alpha, applyToChannels).toArray(this.uniforms.uColor);
20726
20745
  }
20727
20746
  if (this.uvMatrix.update()) {
20728
20747
  this.uniforms.uTextureMatrix = this.uvMatrix.mapCoord;
@@ -20934,16 +20953,16 @@ ${e}`);
20934
20953
 
20935
20954
  const DEFAULT_BORDER_SIZE = 10;
20936
20955
  class NineSlicePlane extends SimplePlane {
20937
- constructor(texture, leftWidth = DEFAULT_BORDER_SIZE, topHeight = DEFAULT_BORDER_SIZE, rightWidth = DEFAULT_BORDER_SIZE, bottomHeight = DEFAULT_BORDER_SIZE) {
20956
+ constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) {
20938
20957
  super(Texture.WHITE, 4, 4);
20939
20958
  this._origWidth = texture.orig.width;
20940
20959
  this._origHeight = texture.orig.height;
20941
20960
  this._width = this._origWidth;
20942
20961
  this._height = this._origHeight;
20943
- this._leftWidth = leftWidth;
20944
- this._rightWidth = rightWidth;
20945
- this._topHeight = topHeight;
20946
- this._bottomHeight = bottomHeight;
20962
+ this._leftWidth = leftWidth ?? texture.defaultBorders?.left ?? DEFAULT_BORDER_SIZE;
20963
+ this._rightWidth = rightWidth ?? texture.defaultBorders?.right ?? DEFAULT_BORDER_SIZE;
20964
+ this._topHeight = topHeight ?? texture.defaultBorders?.top ?? DEFAULT_BORDER_SIZE;
20965
+ this._bottomHeight = bottomHeight ?? texture.defaultBorders?.bottom ?? DEFAULT_BORDER_SIZE;
20947
20966
  this.texture = texture;
20948
20967
  }
20949
20968
  textureUpdated() {
@@ -21124,7 +21143,7 @@ ${e}`);
21124
21143
  }
21125
21144
  set tint(value) {
21126
21145
  this._tint = value;
21127
- hex2rgb(value, this.tintRgb);
21146
+ Color.shared.setValue(value).toRgbArray(this.tintRgb);
21128
21147
  }
21129
21148
  render(renderer) {
21130
21149
  if (!this.visible || this.worldAlpha <= 0 || !this.children.length || !this.renderable) {
@@ -21330,7 +21349,7 @@ ${e}`);
21330
21349
  const m = container.worldTransform.copyTo(this.tempMatrix);
21331
21350
  m.prepend(renderer.globalUniforms.uniforms.projectionMatrix);
21332
21351
  this.shader.uniforms.translationMatrix = m.toArray(true);
21333
- this.shader.uniforms.uColor = premultiplyRgba(container.tintRgb, container.worldAlpha, this.shader.uniforms.uColor, premultiplied);
21352
+ this.shader.uniforms.uColor = Color.shared.setValue(container.tintRgb).premultiply(container.worldAlpha, premultiplied).toArray(this.shader.uniforms.uColor);
21334
21353
  this.shader.uniforms.uSampler = baseTexture;
21335
21354
  this.renderer.shader.bind(this.shader);
21336
21355
  let updateStatic = false;
@@ -21456,13 +21475,11 @@ ${e}`);
21456
21475
  uploadTint(children, startIndex, amount, array, stride, offset) {
21457
21476
  for (let i = 0; i < amount; ++i) {
21458
21477
  const sprite = children[startIndex + i];
21459
- const premultiplied = sprite._texture.baseTexture.alphaMode > 0;
21460
- const alpha = sprite.alpha;
21461
- const argb = alpha < 1 && premultiplied ? premultiplyTint(sprite._tintRGB, alpha) : sprite._tintRGB + (alpha * 255 << 24);
21462
- array[offset] = argb;
21463
- array[offset + stride] = argb;
21464
- array[offset + stride * 2] = argb;
21465
- array[offset + stride * 3] = argb;
21478
+ const result = Color.shared.setValue(sprite._tintRGB).toPremultiplied(sprite.alpha);
21479
+ array[offset] = result;
21480
+ array[offset + stride] = result;
21481
+ array[offset + stride * 2] = result;
21482
+ array[offset + stride * 3] = result;
21466
21483
  offset += stride * 4;
21467
21484
  }
21468
21485
  }
@@ -22204,24 +22221,12 @@ ${e}`);
22204
22221
  wordWrap: false,
22205
22222
  wordWrapWidth: 100
22206
22223
  };
22207
- function getSingleColor(color) {
22208
- if (typeof color === "number") {
22209
- return hex2string(color);
22210
- } else if (typeof color === "string") {
22211
- if (color.startsWith("0x")) {
22212
- color = color.replace("0x", "#");
22213
- }
22214
- }
22215
- return color;
22216
- }
22217
22224
  function getColor(color) {
22225
+ const temp = Color.shared;
22218
22226
  if (!Array.isArray(color)) {
22219
- return getSingleColor(color);
22227
+ return temp.setValue(color).toHex();
22220
22228
  } else {
22221
- for (let i = 0; i < color.length; ++i) {
22222
- color[i] = getSingleColor(color[i]);
22223
- }
22224
- return color;
22229
+ return color.map((c) => temp.setValue(c).toHex());
22225
22230
  }
22226
22231
  }
22227
22232
  function areArraysEqual(array1, array2) {
@@ -22327,10 +22332,9 @@ ${e}`);
22327
22332
  context.fillStyle = "black";
22328
22333
  context.strokeStyle = "black";
22329
22334
  const dropShadowColor = style.dropShadowColor;
22330
- const rgb = hex2rgb(typeof dropShadowColor === "number" ? dropShadowColor : string2hex(dropShadowColor));
22331
22335
  const dropShadowBlur = style.dropShadowBlur * this._resolution;
22332
22336
  const dropShadowDistance = style.dropShadowDistance * this._resolution;
22333
- context.shadowColor = `rgba(${rgb[0] * 255},${rgb[1] * 255},${rgb[2] * 255},${style.dropShadowAlpha})`;
22337
+ context.shadowColor = Color.shared.setValue(dropShadowColor).setAlpha(style.dropShadowAlpha).toRgbaString();
22334
22338
  context.shadowBlur = dropShadowBlur;
22335
22339
  context.shadowOffsetX = Math.cos(style.dropShadowAngle) * dropShadowDistance;
22336
22340
  context.shadowOffsetY = Math.sin(style.dropShadowAngle) * dropShadowDistance + dsOffsetShadow;
@@ -23238,7 +23242,7 @@ ${e}`);
23238
23242
  shader.uniforms.uClampOffset = uv.uClampOffset;
23239
23243
  }
23240
23244
  shader.uniforms.uTransform = tempMat.toArray(true);
23241
- shader.uniforms.uColor = premultiplyTintToRgba(ts.tint, ts.worldAlpha, shader.uniforms.uColor, premultiplied);
23245
+ shader.uniforms.uColor = Color.shared.setValue(ts.tint).premultiply(ts.worldAlpha, premultiplied).toArray(shader.uniforms.uColor);
23242
23246
  shader.uniforms.translationMatrix = ts.transform.worldTransform.toArray(true);
23243
23247
  shader.uniforms.uSampler = tex;
23244
23248
  renderer.shader.bind(shader);
@@ -23313,7 +23317,7 @@ ${e}`);
23313
23317
  if (data.trimmed !== false && data.spriteSourceSize) {
23314
23318
  trim = new Rectangle(Math.floor(data.spriteSourceSize.x) / this.resolution, Math.floor(data.spriteSourceSize.y) / this.resolution, Math.floor(rect.w) / this.resolution, Math.floor(rect.h) / this.resolution);
23315
23319
  }
23316
- this.textures[i] = new Texture(this.baseTexture, frame, orig, trim, data.rotated ? 2 : 0, data.anchor);
23320
+ this.textures[i] = new Texture(this.baseTexture, frame, orig, trim, data.rotated ? 2 : 0, data.anchor, data.borders);
23317
23321
  Texture.addToCache(this.textures[i], i);
23318
23322
  }
23319
23323
  frameIndex++;
@@ -23704,10 +23708,9 @@ ${e}`);
23704
23708
  context.strokeStyle = style.stroke;
23705
23709
  if (style.dropShadow) {
23706
23710
  const dropShadowColor = style.dropShadowColor;
23707
- const rgb = hex2rgb(typeof dropShadowColor === "number" ? dropShadowColor : string2hex(dropShadowColor));
23708
23711
  const dropShadowBlur = style.dropShadowBlur * resolution;
23709
23712
  const dropShadowDistance = style.dropShadowDistance * resolution;
23710
- context.shadowColor = `rgba(${rgb[0] * 255},${rgb[1] * 255},${rgb[2] * 255},${style.dropShadowAlpha})`;
23713
+ context.shadowColor = Color.shared.setValue(dropShadowColor).setAlpha(style.dropShadowAlpha).toRgbaString();
23711
23714
  context.shadowBlur = dropShadowBlur;
23712
23715
  context.shadowOffsetX = Math.cos(style.dropShadowAngle) * dropShadowDistance;
23713
23716
  context.shadowOffsetY = Math.sin(style.dropShadowAngle) * dropShadowDistance;
@@ -24493,6 +24496,493 @@ ${e}`);
24493
24496
  };
24494
24497
  extensions$1.add(loadBitmapFont);
24495
24498
 
24499
+ const _HTMLTextStyle = class extends TextStyle {
24500
+ constructor() {
24501
+ super(...arguments);
24502
+ this._fonts = [];
24503
+ this._overrides = [];
24504
+ this._stylesheet = "";
24505
+ this.fontsDirty = false;
24506
+ }
24507
+ static from(originalStyle) {
24508
+ return new _HTMLTextStyle(Object.keys(_HTMLTextStyle.defaultOptions).reduce((obj, prop) => ({ ...obj, [prop]: originalStyle[prop] }), {}));
24509
+ }
24510
+ cleanFonts() {
24511
+ if (this._fonts.length > 0) {
24512
+ this._fonts.forEach((font) => {
24513
+ URL.revokeObjectURL(font.src);
24514
+ font.refs--;
24515
+ if (font.refs === 0) {
24516
+ if (font.fontFace) {
24517
+ document.fonts.delete(font.fontFace);
24518
+ }
24519
+ delete _HTMLTextStyle.availableFonts[font.originalUrl];
24520
+ }
24521
+ });
24522
+ this.fontFamily = "Arial";
24523
+ this._fonts.length = 0;
24524
+ this.styleID++;
24525
+ this.fontsDirty = true;
24526
+ }
24527
+ }
24528
+ loadFont(url, options = {}) {
24529
+ const { availableFonts } = _HTMLTextStyle;
24530
+ if (availableFonts[url]) {
24531
+ const font = availableFonts[url];
24532
+ this._fonts.push(font);
24533
+ font.refs++;
24534
+ this.styleID++;
24535
+ this.fontsDirty = true;
24536
+ return Promise.resolve();
24537
+ }
24538
+ return settings.ADAPTER.fetch(url).then((response) => response.blob()).then(async (blob) => new Promise((resolve, reject) => {
24539
+ const src = URL.createObjectURL(blob);
24540
+ const reader = new FileReader();
24541
+ reader.onload = () => resolve([src, reader.result]);
24542
+ reader.onerror = reject;
24543
+ reader.readAsDataURL(blob);
24544
+ })).then(async ([src, dataSrc]) => {
24545
+ const font = Object.assign({
24546
+ family: path.basename(url, path.extname(url)),
24547
+ weight: "normal",
24548
+ style: "normal",
24549
+ src,
24550
+ dataSrc,
24551
+ refs: 1,
24552
+ originalUrl: url,
24553
+ fontFace: null
24554
+ }, options);
24555
+ availableFonts[url] = font;
24556
+ this._fonts.push(font);
24557
+ this.styleID++;
24558
+ const fontFace = new FontFace(font.family, `url(${font.src})`, {
24559
+ weight: font.weight,
24560
+ style: font.style
24561
+ });
24562
+ font.fontFace = fontFace;
24563
+ await fontFace.load();
24564
+ document.fonts.add(fontFace);
24565
+ await document.fonts.ready;
24566
+ this.styleID++;
24567
+ this.fontsDirty = true;
24568
+ });
24569
+ }
24570
+ addOverride(...value) {
24571
+ const toAdd = value.filter((v) => !this._overrides.includes(v));
24572
+ if (toAdd.length > 0) {
24573
+ this._overrides.push(...toAdd);
24574
+ this.styleID++;
24575
+ }
24576
+ }
24577
+ removeOverride(...value) {
24578
+ const toRemove = value.filter((v) => this._overrides.includes(v));
24579
+ if (toRemove.length > 0) {
24580
+ this._overrides = this._overrides.filter((v) => !toRemove.includes(v));
24581
+ this.styleID++;
24582
+ }
24583
+ }
24584
+ toCSS(scale) {
24585
+ return [
24586
+ "display: inline-block",
24587
+ `color: ${this.normalizeColor(this.fill)}`,
24588
+ `font-size: ${this.fontSize * scale}px`,
24589
+ `font-family: ${this.fontFamily}`,
24590
+ `font-weight: ${this.fontWeight}`,
24591
+ `font-style: ${this.fontStyle}`,
24592
+ `font-variant: ${this.fontVariant}`,
24593
+ `letter-spacing: ${this.letterSpacing * scale}px`,
24594
+ `text-align: ${this.align}`,
24595
+ `padding: ${this.padding * scale}px`,
24596
+ `white-space: ${this.whiteSpace}`,
24597
+ ...this.lineHeight ? [`line-height: ${this.lineHeight * scale}px`] : [],
24598
+ ...this.wordWrap ? [
24599
+ `word-wrap: ${this.breakWords ? "break-all" : "break-word"}`,
24600
+ `max-width: ${this.wordWrapWidth * scale}px`
24601
+ ] : [],
24602
+ ...this.strokeThickness ? [
24603
+ `-webkit-text-stroke-width: ${this.strokeThickness * scale}px`,
24604
+ `-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,
24605
+ `text-stroke-width: ${this.strokeThickness * scale}px`,
24606
+ `text-stroke-color: ${this.normalizeColor(this.stroke)}`,
24607
+ "paint-order: stroke"
24608
+ ] : [],
24609
+ ...this.dropShadow ? [this.dropShadowToCSS(scale)] : [],
24610
+ ...this._overrides
24611
+ ].join(";");
24612
+ }
24613
+ toGlobalCSS() {
24614
+ return this._fonts.reduce((result, font) => `${result}
24615
+ @font-face {
24616
+ font-family: "${font.family}";
24617
+ src: url('${font.dataSrc}');
24618
+ font-weight: ${font.weight};
24619
+ font-style: ${font.style};
24620
+ }`, this._stylesheet);
24621
+ }
24622
+ get stylesheet() {
24623
+ return this._stylesheet;
24624
+ }
24625
+ set stylesheet(value) {
24626
+ if (this._stylesheet !== value) {
24627
+ this._stylesheet = value;
24628
+ this.styleID++;
24629
+ }
24630
+ }
24631
+ normalizeColor(color) {
24632
+ if (Array.isArray(color)) {
24633
+ color = rgb2hex(color);
24634
+ }
24635
+ if (typeof color === "number") {
24636
+ return hex2string(color);
24637
+ }
24638
+ return color;
24639
+ }
24640
+ dropShadowToCSS(scale) {
24641
+ let color = this.normalizeColor(this.dropShadowColor);
24642
+ const alpha = this.dropShadowAlpha;
24643
+ const x = Math.round(Math.cos(this.dropShadowAngle) * this.dropShadowDistance);
24644
+ const y = Math.round(Math.sin(this.dropShadowAngle) * this.dropShadowDistance);
24645
+ if (color.startsWith("#") && alpha < 1) {
24646
+ color += (alpha * 255 | 0).toString(16).padStart(2, "0");
24647
+ }
24648
+ const position = `${x * scale}px ${y * scale}px`;
24649
+ if (this.dropShadowBlur > 0) {
24650
+ return `text-shadow: ${position} ${this.dropShadowBlur}px ${color}`;
24651
+ }
24652
+ return `text-shadow: ${position} ${color}`;
24653
+ }
24654
+ reset() {
24655
+ Object.assign(this, _HTMLTextStyle.defaultOptions);
24656
+ }
24657
+ onBeforeDraw() {
24658
+ const { fontsDirty: prevFontsDirty } = this;
24659
+ this.fontsDirty = false;
24660
+ if (this.isSafari && this._fonts.length > 0 && prevFontsDirty) {
24661
+ return new Promise((resolve) => setTimeout(resolve, 100));
24662
+ }
24663
+ return Promise.resolve();
24664
+ }
24665
+ get isSafari() {
24666
+ const { userAgent } = settings.ADAPTER.getNavigator();
24667
+ return /^((?!chrome|android).)*safari/i.test(userAgent);
24668
+ }
24669
+ set fillGradientStops(_value) {
24670
+ console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText");
24671
+ }
24672
+ get fillGradientStops() {
24673
+ return super.fillGradientStops;
24674
+ }
24675
+ set fillGradientType(_value) {
24676
+ console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText");
24677
+ }
24678
+ get fillGradientType() {
24679
+ return super.fillGradientType;
24680
+ }
24681
+ set miterLimit(_value) {
24682
+ console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText");
24683
+ }
24684
+ get miterLimit() {
24685
+ return super.miterLimit;
24686
+ }
24687
+ set trim(_value) {
24688
+ console.warn("[HTMLTextStyle] trim is not supported by HTMLText");
24689
+ }
24690
+ get trim() {
24691
+ return super.trim;
24692
+ }
24693
+ set textBaseline(_value) {
24694
+ console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText");
24695
+ }
24696
+ get textBaseline() {
24697
+ return super.textBaseline;
24698
+ }
24699
+ set leading(_value) {
24700
+ console.warn("[HTMLTextStyle] leading is not supported by HTMLText");
24701
+ }
24702
+ get leading() {
24703
+ return super.leading;
24704
+ }
24705
+ set lineJoin(_value) {
24706
+ console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText");
24707
+ }
24708
+ get lineJoin() {
24709
+ return super.lineJoin;
24710
+ }
24711
+ };
24712
+ let HTMLTextStyle = _HTMLTextStyle;
24713
+ HTMLTextStyle.availableFonts = {};
24714
+ HTMLTextStyle.defaultOptions = {
24715
+ align: "left",
24716
+ breakWords: false,
24717
+ dropShadow: false,
24718
+ dropShadowAlpha: 1,
24719
+ dropShadowAngle: Math.PI / 6,
24720
+ dropShadowBlur: 0,
24721
+ dropShadowColor: "black",
24722
+ dropShadowDistance: 5,
24723
+ fill: "black",
24724
+ fontFamily: "Arial",
24725
+ fontSize: 26,
24726
+ fontStyle: "normal",
24727
+ fontVariant: "normal",
24728
+ fontWeight: "normal",
24729
+ letterSpacing: 0,
24730
+ lineHeight: 0,
24731
+ padding: 0,
24732
+ stroke: "black",
24733
+ strokeThickness: 0,
24734
+ whiteSpace: "normal",
24735
+ wordWrap: false,
24736
+ wordWrapWidth: 100
24737
+ };
24738
+
24739
+ const _HTMLText = class extends Sprite {
24740
+ constructor(text = "", style = {}) {
24741
+ super(Texture.EMPTY);
24742
+ this._text = null;
24743
+ this._style = null;
24744
+ this._autoResolution = true;
24745
+ this._loading = false;
24746
+ this.localStyleID = -1;
24747
+ this.dirty = false;
24748
+ this.ownsStyle = false;
24749
+ const image = new Image();
24750
+ const texture = Texture.from(image, {
24751
+ scaleMode: settings.SCALE_MODE,
24752
+ resourceOptions: {
24753
+ autoLoad: false
24754
+ }
24755
+ });
24756
+ texture.orig = new Rectangle();
24757
+ texture.trim = new Rectangle();
24758
+ this.texture = texture;
24759
+ const nssvg = "http://www.w3.org/2000/svg";
24760
+ const nsxhtml = "http://www.w3.org/1999/xhtml";
24761
+ const svgRoot = document.createElementNS(nssvg, "svg");
24762
+ const foreignObject = document.createElementNS(nssvg, "foreignObject");
24763
+ const domElement = document.createElementNS(nsxhtml, "div");
24764
+ const styleElement = document.createElementNS(nsxhtml, "style");
24765
+ foreignObject.setAttribute("width", "10000");
24766
+ foreignObject.setAttribute("height", "10000");
24767
+ foreignObject.style.overflow = "hidden";
24768
+ svgRoot.appendChild(foreignObject);
24769
+ this.maxWidth = _HTMLText.defaultMaxWidth;
24770
+ this.maxHeight = _HTMLText.defaultMaxHeight;
24771
+ this._domElement = domElement;
24772
+ this._styleElement = styleElement;
24773
+ this._svgRoot = svgRoot;
24774
+ this._foreignObject = foreignObject;
24775
+ this._foreignObject.appendChild(styleElement);
24776
+ this._foreignObject.appendChild(domElement);
24777
+ this._image = image;
24778
+ this._autoResolution = _HTMLText.defaultAutoResolution;
24779
+ this._resolution = _HTMLText.defaultResolution ?? settings.RESOLUTION;
24780
+ this.text = text;
24781
+ this.style = style;
24782
+ }
24783
+ measureText(overrides) {
24784
+ const { text, style, resolution } = Object.assign({
24785
+ text: this._text,
24786
+ style: this._style,
24787
+ resolution: this._resolution
24788
+ }, overrides);
24789
+ Object.assign(this._domElement, {
24790
+ innerHTML: text,
24791
+ style: style.toCSS(resolution)
24792
+ });
24793
+ this._styleElement.textContent = style.toGlobalCSS();
24794
+ document.body.appendChild(this._svgRoot);
24795
+ const contentBounds = this._domElement.getBoundingClientRect();
24796
+ this._svgRoot.remove();
24797
+ const contentWidth = Math.min(this.maxWidth, Math.ceil(contentBounds.width));
24798
+ const contentHeight = Math.min(this.maxHeight, Math.ceil(contentBounds.height));
24799
+ this._svgRoot.setAttribute("width", contentWidth.toString());
24800
+ this._svgRoot.setAttribute("height", contentHeight.toString());
24801
+ if (text !== this._text) {
24802
+ this._domElement.innerHTML = this._text;
24803
+ }
24804
+ if (style !== this._style) {
24805
+ Object.assign(this._domElement, { style: this._style?.toCSS(resolution) });
24806
+ this._styleElement.textContent = this._style?.toGlobalCSS();
24807
+ }
24808
+ return {
24809
+ width: contentWidth + style.padding * 2,
24810
+ height: contentHeight + style.padding * 2
24811
+ };
24812
+ }
24813
+ async updateText(respectDirty = true) {
24814
+ const { style, _image: image } = this;
24815
+ if (this.localStyleID !== style.styleID) {
24816
+ this.dirty = true;
24817
+ this.localStyleID = style.styleID;
24818
+ }
24819
+ if (!this.dirty && respectDirty) {
24820
+ return;
24821
+ }
24822
+ const { width, height } = this.measureText();
24823
+ image.width = Math.ceil(Math.max(1, width));
24824
+ image.height = Math.ceil(Math.max(1, height));
24825
+ if (!this._loading) {
24826
+ this._loading = true;
24827
+ await new Promise((resolve) => {
24828
+ image.onload = async () => {
24829
+ await style.onBeforeDraw();
24830
+ this._loading = false;
24831
+ this.updateTexture();
24832
+ resolve();
24833
+ };
24834
+ const svgURL = new XMLSerializer().serializeToString(this._svgRoot);
24835
+ image.src = `data:image/svg+xml;charset=utf8,${encodeURIComponent(svgURL)}`;
24836
+ });
24837
+ }
24838
+ }
24839
+ get source() {
24840
+ return this._image;
24841
+ }
24842
+ updateTexture() {
24843
+ const { style, texture, _image: image, resolution } = this;
24844
+ const { padding } = style;
24845
+ const { baseTexture } = texture;
24846
+ texture.trim.width = texture._frame.width = image.width / resolution;
24847
+ texture.trim.height = texture._frame.height = image.height / resolution;
24848
+ texture.trim.x = -padding;
24849
+ texture.trim.y = -padding;
24850
+ texture.orig.width = texture._frame.width - padding * 2;
24851
+ texture.orig.height = texture._frame.height - padding * 2;
24852
+ this._onTextureUpdate();
24853
+ baseTexture.setRealSize(image.width, image.height, resolution);
24854
+ this.dirty = false;
24855
+ }
24856
+ _render(renderer) {
24857
+ if (this._autoResolution && this._resolution !== renderer.resolution) {
24858
+ this._resolution = renderer.resolution;
24859
+ this.dirty = true;
24860
+ }
24861
+ this.updateText(true);
24862
+ super._render(renderer);
24863
+ }
24864
+ _renderCanvas(renderer) {
24865
+ if (this._autoResolution && this._resolution !== renderer.resolution) {
24866
+ this._resolution = renderer.resolution;
24867
+ this.dirty = true;
24868
+ }
24869
+ this.updateText(true);
24870
+ super._renderCanvas(renderer);
24871
+ }
24872
+ getLocalBounds(rect) {
24873
+ this.updateText(true);
24874
+ return super.getLocalBounds(rect);
24875
+ }
24876
+ _calculateBounds() {
24877
+ this.updateText(true);
24878
+ this.calculateVertices();
24879
+ this._bounds.addQuad(this.vertexData);
24880
+ }
24881
+ _onStyleChange() {
24882
+ this.dirty = true;
24883
+ }
24884
+ destroy(options) {
24885
+ if (typeof options === "boolean") {
24886
+ options = { children: options };
24887
+ }
24888
+ options = Object.assign({}, _HTMLText.defaultDestroyOptions, options);
24889
+ super.destroy(options);
24890
+ const forceClear = null;
24891
+ if (this.ownsStyle) {
24892
+ this._style?.cleanFonts();
24893
+ }
24894
+ this._style = forceClear;
24895
+ this._svgRoot?.remove();
24896
+ this._svgRoot = forceClear;
24897
+ this._domElement?.remove();
24898
+ this._domElement = forceClear;
24899
+ this._foreignObject?.remove();
24900
+ this._foreignObject = forceClear;
24901
+ this._styleElement?.remove();
24902
+ this._styleElement = forceClear;
24903
+ this._image.onload = null;
24904
+ this._image.src = "";
24905
+ this._image = forceClear;
24906
+ }
24907
+ get width() {
24908
+ this.updateText(true);
24909
+ return Math.abs(this.scale.x) * this._image.width / this.resolution;
24910
+ }
24911
+ set width(value) {
24912
+ this.updateText(true);
24913
+ const s = sign(this.scale.x) || 1;
24914
+ this.scale.x = s * value / this._image.width / this.resolution;
24915
+ this._width = value;
24916
+ }
24917
+ get height() {
24918
+ this.updateText(true);
24919
+ return Math.abs(this.scale.y) * this._image.height / this.resolution;
24920
+ }
24921
+ set height(value) {
24922
+ this.updateText(true);
24923
+ const s = sign(this.scale.y) || 1;
24924
+ this.scale.y = s * value / this._image.height / this.resolution;
24925
+ this._height = value;
24926
+ }
24927
+ get style() {
24928
+ return this._style;
24929
+ }
24930
+ set style(style) {
24931
+ if (this._style === style) {
24932
+ return;
24933
+ }
24934
+ style = style || {};
24935
+ if (style instanceof HTMLTextStyle) {
24936
+ this.ownsStyle = false;
24937
+ this._style = style;
24938
+ } else if (style instanceof TextStyle) {
24939
+ console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle");
24940
+ this.ownsStyle = true;
24941
+ this._style = HTMLTextStyle.from(style);
24942
+ } else {
24943
+ this.ownsStyle = true;
24944
+ this._style = new HTMLTextStyle(style);
24945
+ }
24946
+ this.localStyleID = -1;
24947
+ this.dirty = true;
24948
+ }
24949
+ get text() {
24950
+ return this._text;
24951
+ }
24952
+ set text(text) {
24953
+ text = String(text === "" || text === null || text === void 0 ? " " : text);
24954
+ text = this.sanitiseText(text);
24955
+ if (this._text === text) {
24956
+ return;
24957
+ }
24958
+ this._text = text;
24959
+ this.dirty = true;
24960
+ }
24961
+ get resolution() {
24962
+ return this._resolution;
24963
+ }
24964
+ set resolution(value) {
24965
+ this._autoResolution = false;
24966
+ if (this._resolution === value) {
24967
+ return;
24968
+ }
24969
+ this._resolution = value;
24970
+ this.dirty = true;
24971
+ }
24972
+ sanitiseText(text) {
24973
+ return text.replace(/<br>/gi, "<br/>").replace(/<hr>/gi, "<hr/>").replace(/&nbsp;/gi, "&#160;");
24974
+ }
24975
+ };
24976
+ let HTMLText = _HTMLText;
24977
+ HTMLText.defaultDestroyOptions = {
24978
+ texture: true,
24979
+ children: false,
24980
+ baseTexture: true
24981
+ };
24982
+ HTMLText.defaultMaxWidth = 2024;
24983
+ HTMLText.defaultMaxHeight = 2024;
24984
+ HTMLText.defaultAutoResolution = true;
24985
+
24496
24986
  exports.ALPHA_MODES = ALPHA_MODES;
24497
24987
  exports.AbstractMultiResource = AbstractMultiResource;
24498
24988
  exports.AccessibilityManager = AccessibilityManager;
@@ -24533,6 +25023,7 @@ ${e}`);
24533
25023
  exports.Cache = Cache;
24534
25024
  exports.CanvasResource = CanvasResource;
24535
25025
  exports.Circle = Circle;
25026
+ exports.Color = Color;
24536
25027
  exports.ColorMatrixFilter = ColorMatrixFilter;
24537
25028
  exports.CompressedTextureResource = CompressedTextureResource;
24538
25029
  exports.Container = Container;
@@ -24574,6 +25065,8 @@ ${e}`);
24574
25065
  exports.Graphics = Graphics;
24575
25066
  exports.GraphicsData = GraphicsData;
24576
25067
  exports.GraphicsGeometry = GraphicsGeometry;
25068
+ exports.HTMLText = HTMLText;
25069
+ exports.HTMLTextStyle = HTMLTextStyle;
24577
25070
  exports.IGLUniformData = IGLUniformData;
24578
25071
  exports.INSTALLED = INSTALLED;
24579
25072
  exports.INTERNAL_FORMATS = INTERNAL_FORMATS;