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.mjs 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
@@ -219,19 +219,6 @@ const BrowserAdapter = {
219
219
  const settings = {
220
220
  ADAPTER: BrowserAdapter,
221
221
  RESOLUTION: 1,
222
- RENDER_OPTIONS: {
223
- view: null,
224
- width: 800,
225
- height: 600,
226
- autoDensity: false,
227
- backgroundColor: 0,
228
- backgroundAlpha: 1,
229
- clearBeforeRender: true,
230
- antialias: false,
231
- premultipliedAlpha: true,
232
- preserveDrawingBuffer: false,
233
- hello: false
234
- },
235
222
  CREATE_IMAGE_BITMAP: false,
236
223
  ROUND_PIXELS: false
237
224
  };
@@ -3329,331 +3316,210 @@ function isWebGLSupported() {
3329
3316
  return supported;
3330
3317
  }
3331
3318
 
3332
- var aliceblue = "#f0f8ff";
3333
- var antiquewhite = "#faebd7";
3334
- var aqua = "#00ffff";
3335
- var aquamarine = "#7fffd4";
3336
- var azure = "#f0ffff";
3337
- var beige = "#f5f5dc";
3338
- var bisque = "#ffe4c4";
3339
- var black = "#000000";
3340
- var blanchedalmond = "#ffebcd";
3341
- var blue = "#0000ff";
3342
- var blueviolet = "#8a2be2";
3343
- var brown = "#a52a2a";
3344
- var burlywood = "#deb887";
3345
- var cadetblue = "#5f9ea0";
3346
- var chartreuse = "#7fff00";
3347
- var chocolate = "#d2691e";
3348
- var coral = "#ff7f50";
3349
- var cornflowerblue = "#6495ed";
3350
- var cornsilk = "#fff8dc";
3351
- var crimson = "#dc143c";
3352
- var cyan = "#00ffff";
3353
- var darkblue = "#00008b";
3354
- var darkcyan = "#008b8b";
3355
- var darkgoldenrod = "#b8860b";
3356
- var darkgray = "#a9a9a9";
3357
- var darkgreen = "#006400";
3358
- var darkgrey = "#a9a9a9";
3359
- var darkkhaki = "#bdb76b";
3360
- var darkmagenta = "#8b008b";
3361
- var darkolivegreen = "#556b2f";
3362
- var darkorange = "#ff8c00";
3363
- var darkorchid = "#9932cc";
3364
- var darkred = "#8b0000";
3365
- var darksalmon = "#e9967a";
3366
- var darkseagreen = "#8fbc8f";
3367
- var darkslateblue = "#483d8b";
3368
- var darkslategray = "#2f4f4f";
3369
- var darkslategrey = "#2f4f4f";
3370
- var darkturquoise = "#00ced1";
3371
- var darkviolet = "#9400d3";
3372
- var deeppink = "#ff1493";
3373
- var deepskyblue = "#00bfff";
3374
- var dimgray = "#696969";
3375
- var dimgrey = "#696969";
3376
- var dodgerblue = "#1e90ff";
3377
- var firebrick = "#b22222";
3378
- var floralwhite = "#fffaf0";
3379
- var forestgreen = "#228b22";
3380
- var fuchsia = "#ff00ff";
3381
- var gainsboro = "#dcdcdc";
3382
- var ghostwhite = "#f8f8ff";
3383
- var goldenrod = "#daa520";
3384
- var gold = "#ffd700";
3385
- var gray = "#808080";
3386
- var green = "#008000";
3387
- var greenyellow = "#adff2f";
3388
- var grey = "#808080";
3389
- var honeydew = "#f0fff0";
3390
- var hotpink = "#ff69b4";
3391
- var indianred = "#cd5c5c";
3392
- var indigo = "#4b0082";
3393
- var ivory = "#fffff0";
3394
- var khaki = "#f0e68c";
3395
- var lavenderblush = "#fff0f5";
3396
- var lavender = "#e6e6fa";
3397
- var lawngreen = "#7cfc00";
3398
- var lemonchiffon = "#fffacd";
3399
- var lightblue = "#add8e6";
3400
- var lightcoral = "#f08080";
3401
- var lightcyan = "#e0ffff";
3402
- var lightgoldenrodyellow = "#fafad2";
3403
- var lightgray = "#d3d3d3";
3404
- var lightgreen = "#90ee90";
3405
- var lightgrey = "#d3d3d3";
3406
- var lightpink = "#ffb6c1";
3407
- var lightsalmon = "#ffa07a";
3408
- var lightseagreen = "#20b2aa";
3409
- var lightskyblue = "#87cefa";
3410
- var lightslategray = "#778899";
3411
- var lightslategrey = "#778899";
3412
- var lightsteelblue = "#b0c4de";
3413
- var lightyellow = "#ffffe0";
3414
- var lime = "#00ff00";
3415
- var limegreen = "#32cd32";
3416
- var linen = "#faf0e6";
3417
- var magenta = "#ff00ff";
3418
- var maroon = "#800000";
3419
- var mediumaquamarine = "#66cdaa";
3420
- var mediumblue = "#0000cd";
3421
- var mediumorchid = "#ba55d3";
3422
- var mediumpurple = "#9370db";
3423
- var mediumseagreen = "#3cb371";
3424
- var mediumslateblue = "#7b68ee";
3425
- var mediumspringgreen = "#00fa9a";
3426
- var mediumturquoise = "#48d1cc";
3427
- var mediumvioletred = "#c71585";
3428
- var midnightblue = "#191970";
3429
- var mintcream = "#f5fffa";
3430
- var mistyrose = "#ffe4e1";
3431
- var moccasin = "#ffe4b5";
3432
- var navajowhite = "#ffdead";
3433
- var navy = "#000080";
3434
- var oldlace = "#fdf5e6";
3435
- var olive = "#808000";
3436
- var olivedrab = "#6b8e23";
3437
- var orange = "#ffa500";
3438
- var orangered = "#ff4500";
3439
- var orchid = "#da70d6";
3440
- var palegoldenrod = "#eee8aa";
3441
- var palegreen = "#98fb98";
3442
- var paleturquoise = "#afeeee";
3443
- var palevioletred = "#db7093";
3444
- var papayawhip = "#ffefd5";
3445
- var peachpuff = "#ffdab9";
3446
- var peru = "#cd853f";
3447
- var pink = "#ffc0cb";
3448
- var plum = "#dda0dd";
3449
- var powderblue = "#b0e0e6";
3450
- var purple = "#800080";
3451
- var rebeccapurple = "#663399";
3452
- var red = "#ff0000";
3453
- var rosybrown = "#bc8f8f";
3454
- var royalblue = "#4169e1";
3455
- var saddlebrown = "#8b4513";
3456
- var salmon = "#fa8072";
3457
- var sandybrown = "#f4a460";
3458
- var seagreen = "#2e8b57";
3459
- var seashell = "#fff5ee";
3460
- var sienna = "#a0522d";
3461
- var silver = "#c0c0c0";
3462
- var skyblue = "#87ceeb";
3463
- var slateblue = "#6a5acd";
3464
- var slategray = "#708090";
3465
- var slategrey = "#708090";
3466
- var snow = "#fffafa";
3467
- var springgreen = "#00ff7f";
3468
- var steelblue = "#4682b4";
3469
- var tan = "#d2b48c";
3470
- var teal = "#008080";
3471
- var thistle = "#d8bfd8";
3472
- var tomato = "#ff6347";
3473
- var turquoise = "#40e0d0";
3474
- var violet = "#ee82ee";
3475
- var wheat = "#f5deb3";
3476
- var white = "#ffffff";
3477
- var whitesmoke = "#f5f5f5";
3478
- var yellow = "#ffff00";
3479
- var yellowgreen = "#9acd32";
3480
- var cssColorNames = {
3481
- aliceblue: aliceblue,
3482
- antiquewhite: antiquewhite,
3483
- aqua: aqua,
3484
- aquamarine: aquamarine,
3485
- azure: azure,
3486
- beige: beige,
3487
- bisque: bisque,
3488
- black: black,
3489
- blanchedalmond: blanchedalmond,
3490
- blue: blue,
3491
- blueviolet: blueviolet,
3492
- brown: brown,
3493
- burlywood: burlywood,
3494
- cadetblue: cadetblue,
3495
- chartreuse: chartreuse,
3496
- chocolate: chocolate,
3497
- coral: coral,
3498
- cornflowerblue: cornflowerblue,
3499
- cornsilk: cornsilk,
3500
- crimson: crimson,
3501
- cyan: cyan,
3502
- darkblue: darkblue,
3503
- darkcyan: darkcyan,
3504
- darkgoldenrod: darkgoldenrod,
3505
- darkgray: darkgray,
3506
- darkgreen: darkgreen,
3507
- darkgrey: darkgrey,
3508
- darkkhaki: darkkhaki,
3509
- darkmagenta: darkmagenta,
3510
- darkolivegreen: darkolivegreen,
3511
- darkorange: darkorange,
3512
- darkorchid: darkorchid,
3513
- darkred: darkred,
3514
- darksalmon: darksalmon,
3515
- darkseagreen: darkseagreen,
3516
- darkslateblue: darkslateblue,
3517
- darkslategray: darkslategray,
3518
- darkslategrey: darkslategrey,
3519
- darkturquoise: darkturquoise,
3520
- darkviolet: darkviolet,
3521
- deeppink: deeppink,
3522
- deepskyblue: deepskyblue,
3523
- dimgray: dimgray,
3524
- dimgrey: dimgrey,
3525
- dodgerblue: dodgerblue,
3526
- firebrick: firebrick,
3527
- floralwhite: floralwhite,
3528
- forestgreen: forestgreen,
3529
- fuchsia: fuchsia,
3530
- gainsboro: gainsboro,
3531
- ghostwhite: ghostwhite,
3532
- goldenrod: goldenrod,
3533
- gold: gold,
3534
- gray: gray,
3535
- green: green,
3536
- greenyellow: greenyellow,
3537
- grey: grey,
3538
- honeydew: honeydew,
3539
- hotpink: hotpink,
3540
- indianred: indianred,
3541
- indigo: indigo,
3542
- ivory: ivory,
3543
- khaki: khaki,
3544
- lavenderblush: lavenderblush,
3545
- lavender: lavender,
3546
- lawngreen: lawngreen,
3547
- lemonchiffon: lemonchiffon,
3548
- lightblue: lightblue,
3549
- lightcoral: lightcoral,
3550
- lightcyan: lightcyan,
3551
- lightgoldenrodyellow: lightgoldenrodyellow,
3552
- lightgray: lightgray,
3553
- lightgreen: lightgreen,
3554
- lightgrey: lightgrey,
3555
- lightpink: lightpink,
3556
- lightsalmon: lightsalmon,
3557
- lightseagreen: lightseagreen,
3558
- lightskyblue: lightskyblue,
3559
- lightslategray: lightslategray,
3560
- lightslategrey: lightslategrey,
3561
- lightsteelblue: lightsteelblue,
3562
- lightyellow: lightyellow,
3563
- lime: lime,
3564
- limegreen: limegreen,
3565
- linen: linen,
3566
- magenta: magenta,
3567
- maroon: maroon,
3568
- mediumaquamarine: mediumaquamarine,
3569
- mediumblue: mediumblue,
3570
- mediumorchid: mediumorchid,
3571
- mediumpurple: mediumpurple,
3572
- mediumseagreen: mediumseagreen,
3573
- mediumslateblue: mediumslateblue,
3574
- mediumspringgreen: mediumspringgreen,
3575
- mediumturquoise: mediumturquoise,
3576
- mediumvioletred: mediumvioletred,
3577
- midnightblue: midnightblue,
3578
- mintcream: mintcream,
3579
- mistyrose: mistyrose,
3580
- moccasin: moccasin,
3581
- navajowhite: navajowhite,
3582
- navy: navy,
3583
- oldlace: oldlace,
3584
- olive: olive,
3585
- olivedrab: olivedrab,
3586
- orange: orange,
3587
- orangered: orangered,
3588
- orchid: orchid,
3589
- palegoldenrod: palegoldenrod,
3590
- palegreen: palegreen,
3591
- paleturquoise: paleturquoise,
3592
- palevioletred: palevioletred,
3593
- papayawhip: papayawhip,
3594
- peachpuff: peachpuff,
3595
- peru: peru,
3596
- pink: pink,
3597
- plum: plum,
3598
- powderblue: powderblue,
3599
- purple: purple,
3600
- rebeccapurple: rebeccapurple,
3601
- red: red,
3602
- rosybrown: rosybrown,
3603
- royalblue: royalblue,
3604
- saddlebrown: saddlebrown,
3605
- salmon: salmon,
3606
- sandybrown: sandybrown,
3607
- seagreen: seagreen,
3608
- seashell: seashell,
3609
- sienna: sienna,
3610
- silver: silver,
3611
- skyblue: skyblue,
3612
- slateblue: slateblue,
3613
- slategray: slategray,
3614
- slategrey: slategrey,
3615
- snow: snow,
3616
- springgreen: springgreen,
3617
- steelblue: steelblue,
3618
- tan: tan,
3619
- teal: teal,
3620
- thistle: thistle,
3621
- tomato: tomato,
3622
- turquoise: turquoise,
3623
- violet: violet,
3624
- wheat: wheat,
3625
- white: white,
3626
- whitesmoke: whitesmoke,
3627
- yellow: yellow,
3628
- yellowgreen: yellowgreen
3319
+ 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()})};
3320
+
3321
+ 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"]);}
3322
+
3323
+ k([namesPlugin]);
3324
+ const _Color = class {
3325
+ constructor(value = 16777215) {
3326
+ this._components = new Float32Array(4);
3327
+ this._components.fill(1);
3328
+ this.value = value;
3329
+ }
3330
+ get red() {
3331
+ return this._components[0];
3332
+ }
3333
+ get green() {
3334
+ return this._components[1];
3335
+ }
3336
+ get blue() {
3337
+ return this._components[2];
3338
+ }
3339
+ get alpha() {
3340
+ return this._components[3];
3341
+ }
3342
+ setValue(value) {
3343
+ this.value = value;
3344
+ return this;
3345
+ }
3346
+ set value(value) {
3347
+ if (value instanceof _Color) {
3348
+ this._value = value._value;
3349
+ this._int = value._int;
3350
+ this._components.set(value._components);
3351
+ } else if (this._value !== value) {
3352
+ this.normalize(value);
3353
+ this._value = value;
3354
+ }
3355
+ }
3356
+ get value() {
3357
+ return this._value;
3358
+ }
3359
+ toRgba() {
3360
+ const [r, g, b, a] = this._components;
3361
+ return { r, g, b, a };
3362
+ }
3363
+ toRgb() {
3364
+ const [r, g, b] = this._components;
3365
+ return { r, g, b };
3366
+ }
3367
+ toRgbaString() {
3368
+ const [r, g, b] = this.toUint8RgbArray();
3369
+ return `rgba(${r},${g},${b},${this.alpha})`;
3370
+ }
3371
+ toUint8RgbArray(out) {
3372
+ const [r, g, b] = this._components;
3373
+ out = out ?? [];
3374
+ out[0] = Math.round(r * 255);
3375
+ out[1] = Math.round(g * 255);
3376
+ out[2] = Math.round(b * 255);
3377
+ return out;
3378
+ }
3379
+ toRgbArray(out) {
3380
+ out = out ?? [];
3381
+ const [r, g, b] = this._components;
3382
+ out[0] = r;
3383
+ out[1] = g;
3384
+ out[2] = b;
3385
+ return out;
3386
+ }
3387
+ toNumber() {
3388
+ return this._int;
3389
+ }
3390
+ toLittleEndianNumber() {
3391
+ const value = this._int;
3392
+ return (value >> 16) + (value & 65280) + ((value & 255) << 16);
3393
+ }
3394
+ multiply(value) {
3395
+ const [r, g, b, a] = _Color.temp.setValue(value)._components;
3396
+ this._components[0] *= r;
3397
+ this._components[1] *= g;
3398
+ this._components[2] *= b;
3399
+ this._components[3] *= a;
3400
+ this.refreshInt();
3401
+ this._value = null;
3402
+ return this;
3403
+ }
3404
+ premultiply(alpha, applyToRGB = true) {
3405
+ if (applyToRGB) {
3406
+ this._components[0] *= alpha;
3407
+ this._components[1] *= alpha;
3408
+ this._components[2] *= alpha;
3409
+ }
3410
+ this._components[3] = alpha;
3411
+ this.refreshInt();
3412
+ this._value = null;
3413
+ return this;
3414
+ }
3415
+ toPremultiplied(alpha) {
3416
+ if (alpha === 1) {
3417
+ return (alpha * 255 << 24) + this._int;
3418
+ }
3419
+ if (alpha === 0) {
3420
+ return 0;
3421
+ }
3422
+ let r = this._int >> 16 & 255;
3423
+ let g = this._int >> 8 & 255;
3424
+ let b = this._int & 255;
3425
+ r = r * alpha + 0.5 | 0;
3426
+ g = g * alpha + 0.5 | 0;
3427
+ b = b * alpha + 0.5 | 0;
3428
+ return (alpha * 255 << 24) + (r << 16) + (g << 8) + b;
3429
+ }
3430
+ toHex() {
3431
+ const hexString = this._int.toString(16);
3432
+ return `#${"000000".substring(0, 6 - hexString.length) + hexString}`;
3433
+ }
3434
+ toHexa() {
3435
+ const alphaValue = Math.round(this._components[3] * 255);
3436
+ const alphaString = alphaValue.toString(16);
3437
+ return this.toHex() + "00".substring(0, 2 - alphaString.length) + alphaString;
3438
+ }
3439
+ setAlpha(alpha) {
3440
+ this._components[3] = alpha;
3441
+ return this;
3442
+ }
3443
+ round(step) {
3444
+ const [r, g, b] = this._components;
3445
+ this._components.set([
3446
+ Math.min(255, r / step * step),
3447
+ Math.min(255, g / step * step),
3448
+ Math.min(255, b / step * step)
3449
+ ]);
3450
+ this.refreshInt();
3451
+ this._value = null;
3452
+ return this;
3453
+ }
3454
+ toArray(out) {
3455
+ out = out ?? [];
3456
+ const [r, g, b, a] = this._components;
3457
+ out[0] = r;
3458
+ out[1] = g;
3459
+ out[2] = b;
3460
+ out[3] = a;
3461
+ return out;
3462
+ }
3463
+ normalize(value) {
3464
+ let components;
3465
+ if ((Array.isArray(value) || value instanceof Float32Array) && value.length >= 3 && value.length <= 4 && value.every((v) => v <= 1 && v >= 0)) {
3466
+ const [r, g, b, a = 1] = value;
3467
+ components = [r, g, b, a];
3468
+ } else if ((value instanceof Uint8Array || value instanceof Uint8ClampedArray) && value.length >= 3 && value.length <= 4) {
3469
+ const [r, g, b, a = 255] = value;
3470
+ components = [r / 255, g / 255, b / 255, a / 255];
3471
+ } else if (typeof value === "string" || typeof value === "object") {
3472
+ if (typeof value === "string") {
3473
+ const match = _Color.HEX_PATTERN.exec(value);
3474
+ if (match) {
3475
+ value = `#${match[2]}`;
3476
+ }
3477
+ }
3478
+ const color = w(value);
3479
+ if (color.isValid()) {
3480
+ const { r, g, b, a } = color.rgba;
3481
+ components = [r / 255, g / 255, b / 255, a];
3482
+ }
3483
+ } else if (typeof value === "number" && value >= 0 && value <= 16777215) {
3484
+ components = [
3485
+ (value >> 16 & 255) / 255,
3486
+ (value >> 8 & 255) / 255,
3487
+ (value & 255) / 255,
3488
+ 1
3489
+ ];
3490
+ }
3491
+ if (components) {
3492
+ this._components.set(components);
3493
+ this.refreshInt();
3494
+ } else {
3495
+ throw new Error(`Unable to convert color ${value}`);
3496
+ }
3497
+ }
3498
+ refreshInt() {
3499
+ const [r, g, b] = this._components;
3500
+ this._int = (r * 255 << 16) + (g * 255 << 8) + (b * 255 | 0);
3501
+ }
3629
3502
  };
3503
+ let Color = _Color;
3504
+ Color.shared = new _Color();
3505
+ Color.temp = new _Color();
3506
+ Color.HEX_PATTERN = /^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;
3630
3507
 
3631
3508
  function hex2rgb(hex, out = []) {
3632
- out[0] = (hex >> 16 & 255) / 255;
3633
- out[1] = (hex >> 8 & 255) / 255;
3634
- out[2] = (hex & 255) / 255;
3635
- return out;
3509
+ deprecation("7.2.0", "utils.hex2rgb is deprecated, use Color#toRgbArray instead");
3510
+ return Color.shared.setValue(hex).toRgbArray(out);
3636
3511
  }
3637
3512
  function hex2string(hex) {
3638
- let hexString = hex.toString(16);
3639
- hexString = "000000".substring(0, 6 - hexString.length) + hexString;
3640
- return `#${hexString}`;
3513
+ deprecation("7.2.0", "utils.hex2string is deprecated, use Color#toHex instead");
3514
+ return Color.shared.setValue(hex).toHex();
3641
3515
  }
3642
3516
  function string2hex(string) {
3643
- if (typeof string === "string") {
3644
- string = cssColorNames[string.toLowerCase()] || string;
3645
- if (string[0] === "#") {
3646
- string = string.slice(1);
3647
- }
3648
- if (string.length === 3) {
3649
- const [r, g, b] = string;
3650
- string = r + r + g + g + b + b;
3651
- }
3652
- }
3653
- return parseInt(string, 16);
3517
+ deprecation("7.2.0", "utils.string2hex is deprecated, use Color#toNumber instead");
3518
+ return Color.shared.setValue(string).toNumber();
3654
3519
  }
3655
3520
  function rgb2hex(rgb) {
3656
- return (rgb[0] * 255 << 16) + (rgb[1] * 255 << 8) + (rgb[2] * 255 | 0);
3521
+ deprecation("7.2.0", "utils.rgb2hex is deprecated, use Color#toNumber instead");
3522
+ return Color.shared.setValue(rgb).toNumber();
3657
3523
  }
3658
3524
 
3659
3525
  function mapPremultipliedBlendModes() {
@@ -3678,47 +3544,17 @@ const premultiplyBlendMode = mapPremultipliedBlendModes();
3678
3544
  function correctBlendMode(blendMode, premultiplied) {
3679
3545
  return premultiplyBlendMode[premultiplied ? 1 : 0][blendMode];
3680
3546
  }
3681
- function premultiplyRgba(rgb, alpha, out, premultiply) {
3682
- out = out || new Float32Array(4);
3683
- if (premultiply || premultiply === void 0) {
3684
- out[0] = rgb[0] * alpha;
3685
- out[1] = rgb[1] * alpha;
3686
- out[2] = rgb[2] * alpha;
3687
- } else {
3688
- out[0] = rgb[0];
3689
- out[1] = rgb[1];
3690
- out[2] = rgb[2];
3691
- }
3692
- out[3] = alpha;
3693
- return out;
3547
+ function premultiplyRgba(rgb, alpha, out, premultiply = true) {
3548
+ deprecation("7.2.0", `utils.premultiplyRgba has moved to Color.premultiply`);
3549
+ return Color.shared.setValue(rgb).premultiply(alpha, premultiply).toArray(out ?? new Float32Array(4));
3694
3550
  }
3695
3551
  function premultiplyTint(tint, alpha) {
3696
- if (alpha === 1) {
3697
- return (alpha * 255 << 24) + tint;
3698
- }
3699
- if (alpha === 0) {
3700
- return 0;
3701
- }
3702
- let R = tint >> 16 & 255;
3703
- let G = tint >> 8 & 255;
3704
- let B = tint & 255;
3705
- R = R * alpha + 0.5 | 0;
3706
- G = G * alpha + 0.5 | 0;
3707
- B = B * alpha + 0.5 | 0;
3708
- return (alpha * 255 << 24) + (R << 16) + (G << 8) + B;
3709
- }
3710
- function premultiplyTintToRgba(tint, alpha, out, premultiply) {
3711
- out = out || new Float32Array(4);
3712
- out[0] = (tint >> 16 & 255) / 255;
3713
- out[1] = (tint >> 8 & 255) / 255;
3714
- out[2] = (tint & 255) / 255;
3715
- if (premultiply || premultiply === void 0) {
3716
- out[0] *= alpha;
3717
- out[1] *= alpha;
3718
- out[2] *= alpha;
3719
- }
3720
- out[3] = alpha;
3721
- return out;
3552
+ deprecation("7.2.0", `utils.premultiplyTint has moved to Color.toPremultiplied`);
3553
+ return Color.shared.setValue(tint).toPremultiplied(alpha);
3554
+ }
3555
+ function premultiplyTintToRgba(tint, alpha, out, premultiply = true) {
3556
+ deprecation("7.2.0", `utils.premultiplyTintToRgba has moved to Color.premultiply`);
3557
+ return Color.shared.setValue(tint).premultiply(alpha, premultiply).toArray(out ?? new Float32Array(4));
3722
3558
  }
3723
3559
 
3724
3560
  const DATA_URI = /^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;
@@ -6105,6 +5941,51 @@ const uniformParsers = [
6105
5941
  data[offset+3] = v.height;
6106
5942
  `
6107
5943
  },
5944
+ {
5945
+ test: (data, uniform) => data.type === "vec4" && data.size === 1 && !data.isArray && uniform.red !== void 0,
5946
+ code: (name) => `
5947
+ cv = ud["${name}"].value;
5948
+ v = uv["${name}"];
5949
+
5950
+ if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha)
5951
+ {
5952
+ cv[0] = v.red;
5953
+ cv[1] = v.green;
5954
+ cv[2] = v.blue;
5955
+ cv[3] = v.alpha;
5956
+ gl.uniform4f(ud["${name}"].location, v.red, v.green, v.blue, v.alpha)
5957
+ }`,
5958
+ codeUbo: (name) => `
5959
+ v = uv.${name};
5960
+
5961
+ data[offset] = v.red;
5962
+ data[offset+1] = v.green;
5963
+ data[offset+2] = v.blue;
5964
+ data[offset+3] = v.alpha;
5965
+ `
5966
+ },
5967
+ {
5968
+ test: (data, uniform) => data.type === "vec3" && data.size === 1 && !data.isArray && uniform.red !== void 0,
5969
+ code: (name) => `
5970
+ cv = ud["${name}"].value;
5971
+ v = uv["${name}"];
5972
+
5973
+ if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a)
5974
+ {
5975
+ cv[0] = v.red;
5976
+ cv[1] = v.green;
5977
+ cv[2] = v.blue;
5978
+
5979
+ gl.uniform3f(ud["${name}"].location, v.red, v.green, v.blue)
5980
+ }`,
5981
+ codeUbo: (name) => `
5982
+ v = uv.${name};
5983
+
5984
+ data[offset] = v.red;
5985
+ data[offset+1] = v.green;
5986
+ data[offset+2] = v.blue;
5987
+ `
5988
+ },
6108
5989
  {
6109
5990
  test: (data) => data.type === "vec4" && data.size === 1 && !data.isArray,
6110
5991
  code: (name) => `
@@ -7095,7 +6976,7 @@ const _BatchRenderer = class extends ObjectRenderer {
7095
6976
  const vertexData = element.vertexData;
7096
6977
  const textureId = element._texture.baseTexture._batchLocation;
7097
6978
  const alpha = Math.min(element.worldAlpha, 1);
7098
- const argb = alpha < 1 && element._texture.baseTexture.alphaMode ? premultiplyTint(element._tintRGB, alpha) : element._tintRGB + (alpha * 255 << 24);
6979
+ const argb = Color.shared.setValue(element._tintRGB).toPremultiplied(alpha);
7099
6980
  for (let i = 0; i < vertexData.length; i += 2) {
7100
6981
  float32View[aIndex++] = vertexData[i];
7101
6982
  float32View[aIndex++] = vertexData[i + 1];
@@ -7163,42 +7044,41 @@ Filter.defaultMultisample = MSAA_QUALITY.NONE;
7163
7044
  class BackgroundSystem {
7164
7045
  constructor() {
7165
7046
  this.clearBeforeRender = true;
7166
- this._backgroundColor = 0;
7167
- this._backgroundColorRgba = [0, 0, 0, 1];
7168
- this._backgroundColorString = "#000000";
7169
- this.color = this._backgroundColor;
7047
+ this._backgroundColor = new Color(0);
7170
7048
  this.alpha = 1;
7171
7049
  }
7172
7050
  init(options) {
7173
7051
  this.clearBeforeRender = options.clearBeforeRender;
7174
- if (options.color) {
7175
- this.color = typeof options.color === "string" ? string2hex(options.color) : options.color;
7052
+ const { backgroundColor, background, backgroundAlpha } = options;
7053
+ const color = background ?? backgroundColor;
7054
+ if (color !== void 0) {
7055
+ this.color = color;
7176
7056
  }
7177
- this.alpha = options.alpha;
7057
+ this.alpha = backgroundAlpha;
7178
7058
  }
7179
7059
  get color() {
7180
- return this._backgroundColor;
7060
+ return this._backgroundColor.value;
7181
7061
  }
7182
7062
  set color(value) {
7183
- this._backgroundColor = value;
7184
- this._backgroundColorString = hex2string(value);
7185
- hex2rgb(value, this._backgroundColorRgba);
7063
+ this._backgroundColor.setValue(value);
7186
7064
  }
7187
7065
  get alpha() {
7188
- return this._backgroundColorRgba[3];
7066
+ return this._backgroundColor.alpha;
7189
7067
  }
7190
7068
  set alpha(value) {
7191
- this._backgroundColorRgba[3] = value;
7192
- }
7193
- get colorRgba() {
7194
- return this._backgroundColorRgba;
7069
+ this._backgroundColor.setAlpha(value);
7195
7070
  }
7196
- get colorString() {
7197
- return this._backgroundColorString;
7071
+ get backgroundColor() {
7072
+ return this._backgroundColor;
7198
7073
  }
7199
7074
  destroy() {
7200
7075
  }
7201
7076
  }
7077
+ BackgroundSystem.defaultOptions = {
7078
+ backgroundAlpha: 1,
7079
+ backgroundColor: 0,
7080
+ clearBeforeRender: true
7081
+ };
7202
7082
  BackgroundSystem.extension = {
7203
7083
  type: [
7204
7084
  ExtensionType.RendererSystem,
@@ -7418,6 +7298,13 @@ class ContextSystem {
7418
7298
  }
7419
7299
  }
7420
7300
  }
7301
+ ContextSystem.defaultOptions = {
7302
+ context: null,
7303
+ antialias: false,
7304
+ premultipliedAlpha: true,
7305
+ preserveDrawingBuffer: false,
7306
+ powerPreference: "default"
7307
+ };
7421
7308
  ContextSystem.extension = {
7422
7309
  type: ExtensionType.RendererSystem,
7423
7310
  name: "context"
@@ -7544,12 +7431,21 @@ class BaseRenderTexture extends BaseTexture {
7544
7431
  super(null, options);
7545
7432
  this.mipmap = MIPMAP_MODES.OFF;
7546
7433
  this.valid = true;
7547
- this.clearColor = [0, 0, 0, 0];
7434
+ this._clear = new Color([0, 0, 0, 0]);
7548
7435
  this.framebuffer = new Framebuffer(this.realWidth, this.realHeight).addColorTexture(0, this);
7549
7436
  this.framebuffer.multisample = options.multisample;
7550
7437
  this.maskStack = [];
7551
7438
  this.filterStack = [{}];
7552
7439
  }
7440
+ set clearColor(value) {
7441
+ this._clear.setValue(value);
7442
+ }
7443
+ get clearColor() {
7444
+ return this._clear.value;
7445
+ }
7446
+ get clear() {
7447
+ return this._clear;
7448
+ }
7553
7449
  resize(desiredWidth, desiredHeight) {
7554
7450
  this.framebuffer.resize(desiredWidth * this.resolution, desiredHeight * this.resolution);
7555
7451
  this.setRealSize(this.framebuffer.width, this.framebuffer.height);
@@ -7823,7 +7719,7 @@ function removeAllHandlers(tex) {
7823
7719
  };
7824
7720
  }
7825
7721
  class Texture extends eventemitter3 {
7826
- constructor(baseTexture, frame, orig, trim, rotate, anchor) {
7722
+ constructor(baseTexture, frame, orig, trim, rotate, anchor, borders) {
7827
7723
  super();
7828
7724
  this.noFrame = false;
7829
7725
  if (!frame) {
@@ -7847,6 +7743,7 @@ class Texture extends eventemitter3 {
7847
7743
  throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");
7848
7744
  }
7849
7745
  this.defaultAnchor = anchor ? new Point(anchor.x, anchor.y) : new Point(0, 0);
7746
+ this.defaultBorders = borders;
7850
7747
  this._updateID = 0;
7851
7748
  this.textureCacheIds = [];
7852
7749
  if (!baseTexture.valid) {
@@ -7905,7 +7802,7 @@ class Texture extends eventemitter3 {
7905
7802
  clone() {
7906
7803
  const clonedFrame = this._frame.clone();
7907
7804
  const clonedOrig = this._frame === this.orig ? clonedFrame : this.orig.clone();
7908
- const clonedTexture = new Texture(this.baseTexture, !this.noFrame && clonedFrame, clonedOrig, this.trim?.clone(), this.rotate, this.defaultAnchor);
7805
+ const clonedTexture = new Texture(this.baseTexture, !this.noFrame && clonedFrame, clonedOrig, this.trim?.clone(), this.rotate, this.defaultAnchor, this.defaultBorders);
7909
7806
  if (this.noFrame) {
7910
7807
  clonedTexture._frame = clonedFrame;
7911
7808
  }
@@ -9807,7 +9704,8 @@ class PluginSystem {
9807
9704
  }
9808
9705
  });
9809
9706
  }
9810
- init(staticMap) {
9707
+ init() {
9708
+ const staticMap = this.rendererPlugins;
9811
9709
  for (const o in staticMap) {
9812
9710
  this.plugins[o] = new staticMap[o](this.renderer);
9813
9711
  }
@@ -9981,11 +9879,8 @@ class RenderTextureSystem {
9981
9879
  this.destinationFrame.copyFrom(destinationFrame);
9982
9880
  }
9983
9881
  clear(clearColor, mask) {
9984
- if (this.current) {
9985
- clearColor = clearColor || this.current.baseTexture.clearColor;
9986
- } else {
9987
- clearColor = clearColor || this.renderer.background.colorRgba;
9988
- }
9882
+ const fallbackColor = this.current ? this.current.baseTexture.clear : this.renderer.background.backgroundColor;
9883
+ const color = clearColor ? Color.shared.setValue(clearColor) : fallbackColor;
9989
9884
  const destinationFrame = this.destinationFrame;
9990
9885
  const baseFrame = this.current ? this.current.baseTexture : this.renderer._view.screen;
9991
9886
  const clearMask = destinationFrame.width !== baseFrame.width || destinationFrame.height !== baseFrame.height;
@@ -9998,7 +9893,7 @@ class RenderTextureSystem {
9998
9893
  this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST);
9999
9894
  this.renderer.gl.scissor(x, y, width, height);
10000
9895
  }
10001
- this.renderer.framebuffer.clear(clearColor[0], clearColor[1], clearColor[2], clearColor[3], mask);
9896
+ this.renderer.framebuffer.clear(color.red, color.green, color.blue, color.alpha, mask);
10002
9897
  if (clearMask) {
10003
9898
  this.renderer.scissor.pop();
10004
9899
  }
@@ -10451,16 +10346,19 @@ class StartupSystem {
10451
10346
  this.renderer = renderer;
10452
10347
  }
10453
10348
  run(options) {
10454
- const renderer = this.renderer;
10455
- renderer.emitWithCustomOptions(renderer.runners.init, options);
10349
+ const { renderer } = this;
10350
+ renderer.runners.init.emit(renderer.options);
10456
10351
  if (options.hello) {
10457
- console.log(`PixiJS ${"7.1.2"} - ${renderer.rendererLogId} - https://pixijs.com`);
10352
+ console.log(`PixiJS ${"7.2.0-beta"} - ${renderer.rendererLogId} - https://pixijs.com`);
10458
10353
  }
10459
- renderer.resize(this.renderer.screen.width, this.renderer.screen.height);
10354
+ renderer.resize(renderer.screen.width, renderer.screen.height);
10460
10355
  }
10461
10356
  destroy() {
10462
10357
  }
10463
10358
  }
10359
+ StartupSystem.defaultOptions = {
10360
+ hello: false
10361
+ };
10464
10362
  StartupSystem.extension = {
10465
10363
  type: [
10466
10364
  ExtensionType.RendererSystem,
@@ -11220,6 +11118,12 @@ class ViewSystem {
11220
11118
  this.screen = null;
11221
11119
  }
11222
11120
  }
11121
+ ViewSystem.defaultOptions = {
11122
+ width: 800,
11123
+ height: 600,
11124
+ resolution: settings.RESOLUTION,
11125
+ autoDensity: false
11126
+ };
11223
11127
  ViewSystem.extension = {
11224
11128
  type: [
11225
11129
  ExtensionType.RendererSystem,
@@ -11231,6 +11135,12 @@ extensions$1.add(ViewSystem);
11231
11135
 
11232
11136
  settings.PREFER_ENV = ENV.WEBGL2;
11233
11137
  settings.STRICT_TEXTURE_CACHE = false;
11138
+ settings.RENDER_OPTIONS = {
11139
+ ...ContextSystem.defaultOptions,
11140
+ ...BackgroundSystem.defaultOptions,
11141
+ ...ViewSystem.defaultOptions,
11142
+ ...StartupSystem.defaultOptions
11143
+ };
11234
11144
  Object.defineProperties(settings, {
11235
11145
  WRAP_MODE: {
11236
11146
  get() {
@@ -11361,6 +11271,7 @@ Object.defineProperties(settings, {
11361
11271
  });
11362
11272
 
11363
11273
  var UPDATE_PRIORITY = /* @__PURE__ */ ((UPDATE_PRIORITY2) => {
11274
+ UPDATE_PRIORITY2[UPDATE_PRIORITY2["INTERACTION"] = 50] = "INTERACTION";
11364
11275
  UPDATE_PRIORITY2[UPDATE_PRIORITY2["HIGH"] = 25] = "HIGH";
11365
11276
  UPDATE_PRIORITY2[UPDATE_PRIORITY2["NORMAL"] = 0] = "NORMAL";
11366
11277
  UPDATE_PRIORITY2[UPDATE_PRIORITY2["LOW"] = -25] = "LOW";
@@ -11937,31 +11848,9 @@ const _Renderer = class extends SystemManager {
11937
11848
  options.premultipliedAlpha = options.useContextAlpha && options.useContextAlpha !== "notMultiplied";
11938
11849
  options.backgroundAlpha = options.useContextAlpha === false ? 1 : options.backgroundAlpha;
11939
11850
  }
11940
- const startupOptions = {
11941
- hello: options.hello,
11942
- _plugin: _Renderer.__plugins,
11943
- background: {
11944
- alpha: options.backgroundAlpha,
11945
- color: options.background ?? options.backgroundColor,
11946
- clearBeforeRender: options.clearBeforeRender
11947
- },
11948
- _view: {
11949
- height: options.height,
11950
- width: options.width,
11951
- autoDensity: options.autoDensity,
11952
- resolution: options.resolution,
11953
- view: options.view
11954
- },
11955
- context: {
11956
- antialias: options.antialias,
11957
- context: options.context,
11958
- powerPreference: options.powerPreference,
11959
- premultipliedAlpha: options.premultipliedAlpha,
11960
- preserveDrawingBuffer: options.preserveDrawingBuffer
11961
- }
11962
- };
11851
+ this._plugin.rendererPlugins = _Renderer.__plugins;
11963
11852
  this.options = options;
11964
- this.startup.run(startupOptions);
11853
+ this.startup.run(this.options);
11965
11854
  }
11966
11855
  static test(options) {
11967
11856
  if (options?.forceCanvas) {
@@ -12049,7 +11938,7 @@ const _Renderer = class extends SystemManager {
12049
11938
  }
12050
11939
  get backgroundAlpha() {
12051
11940
  deprecation("7.0.0", "renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead.");
12052
- return this.background.color;
11941
+ return this.background.alpha;
12053
11942
  }
12054
11943
  set backgroundAlpha(value) {
12055
11944
  deprecation("7.0.0", "renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead.");
@@ -12645,7 +12534,7 @@ class TransformFeedback {
12645
12534
  }
12646
12535
  }
12647
12536
 
12648
- const VERSION = "7.1.2";
12537
+ const VERSION = "7.2.0-beta";
12649
12538
 
12650
12539
  class Bounds {
12651
12540
  constructor() {
@@ -13040,7 +12929,7 @@ class DisplayObject extends eventemitter3 {
13040
12929
  this.filters = null;
13041
12930
  this.filterArea = null;
13042
12931
  this.hitArea = null;
13043
- this.interactive = false;
12932
+ this.eventMode = "auto";
13044
12933
  this.interactiveChildren = false;
13045
12934
  this.emit("destroyed");
13046
12935
  this.removeAllListeners();
@@ -13750,7 +13639,7 @@ class Sprite extends Container {
13750
13639
  }
13751
13640
  set tint(value) {
13752
13641
  this._tint = value;
13753
- this._tintRGB = (value >> 16) + (value & 65280) + ((value & 255) << 16);
13642
+ this._tintRGB = Color.shared.setValue(value).toLittleEndianNumber();
13754
13643
  }
13755
13644
  get texture() {
13756
13645
  return this._texture;
@@ -14389,23 +14278,21 @@ class ColorMatrixFilter extends Filter {
14389
14278
  this._loadMatrix(matrix, multiply);
14390
14279
  }
14391
14280
  tint(color, multiply) {
14392
- const r = color >> 16 & 255;
14393
- const g = color >> 8 & 255;
14394
- const b = color & 255;
14281
+ const [r, g, b] = Color.shared.setValue(color).toArray();
14395
14282
  const matrix = [
14396
- r / 255,
14283
+ r,
14397
14284
  0,
14398
14285
  0,
14399
14286
  0,
14400
14287
  0,
14401
14288
  0,
14402
- g / 255,
14289
+ g,
14403
14290
  0,
14404
14291
  0,
14405
14292
  0,
14406
14293
  0,
14407
14294
  0,
14408
- b / 255,
14295
+ b,
14409
14296
  0,
14410
14297
  0,
14411
14298
  0,
@@ -14768,12 +14655,9 @@ class ColorMatrixFilter extends Filter {
14768
14655
  toned = toned || 0.15;
14769
14656
  lightColor = lightColor || 16770432;
14770
14657
  darkColor = darkColor || 3375104;
14771
- const lR = (lightColor >> 16 & 255) / 255;
14772
- const lG = (lightColor >> 8 & 255) / 255;
14773
- const lB = (lightColor & 255) / 255;
14774
- const dR = (darkColor >> 16 & 255) / 255;
14775
- const dG = (darkColor >> 8 & 255) / 255;
14776
- const dB = (darkColor & 255) / 255;
14658
+ const temp = Color.shared;
14659
+ const [lR, lG, lB] = temp.setValue(lightColor).toArray();
14660
+ const [dR, dG, dB] = temp.setValue(darkColor).toArray();
14777
14661
  const matrix = [
14778
14662
  0.3,
14779
14663
  0.59,
@@ -15011,6 +14895,74 @@ Object.entries(filters).forEach(([key, FilterClass]) => {
15011
14895
  });
15012
14896
  });
15013
14897
 
14898
+ class EventsTickerClass {
14899
+ constructor() {
14900
+ this.interactionFrequency = 10;
14901
+ this._deltaTime = 0;
14902
+ this._didMove = false;
14903
+ this.tickerAdded = false;
14904
+ this._pauseUpdate = true;
14905
+ }
14906
+ init(events) {
14907
+ this.removeTickerListener();
14908
+ this.events = events;
14909
+ this.interactionFrequency = 10;
14910
+ this._deltaTime = 0;
14911
+ this._didMove = false;
14912
+ this.tickerAdded = false;
14913
+ this._pauseUpdate = true;
14914
+ }
14915
+ get pauseUpdate() {
14916
+ return this._pauseUpdate;
14917
+ }
14918
+ set pauseUpdate(paused) {
14919
+ this._pauseUpdate = paused;
14920
+ }
14921
+ addTickerListener() {
14922
+ if (this.tickerAdded || !this.domElement) {
14923
+ return;
14924
+ }
14925
+ Ticker.system.add(this.tickerUpdate, this, UPDATE_PRIORITY.INTERACTION);
14926
+ this.tickerAdded = true;
14927
+ }
14928
+ removeTickerListener() {
14929
+ if (!this.tickerAdded) {
14930
+ return;
14931
+ }
14932
+ Ticker.system.remove(this.tickerUpdate, this);
14933
+ this.tickerAdded = false;
14934
+ }
14935
+ pointerMoved() {
14936
+ this._didMove = true;
14937
+ }
14938
+ update() {
14939
+ if (!this.domElement || this._pauseUpdate) {
14940
+ return;
14941
+ }
14942
+ if (this._didMove) {
14943
+ this._didMove = false;
14944
+ return;
14945
+ }
14946
+ const rootPointerEvent = this.events["rootPointerEvent"];
14947
+ if (this.events.supportsTouchEvents && rootPointerEvent.pointerType === "touch") {
14948
+ return;
14949
+ }
14950
+ globalThis.document.dispatchEvent(new PointerEvent("pointermove", {
14951
+ clientX: rootPointerEvent.clientX,
14952
+ clientY: rootPointerEvent.clientY
14953
+ }));
14954
+ }
14955
+ tickerUpdate(deltaTime) {
14956
+ this._deltaTime += deltaTime;
14957
+ if (this._deltaTime < this.interactionFrequency) {
14958
+ return;
14959
+ }
14960
+ this._deltaTime = 0;
14961
+ this.update();
14962
+ }
14963
+ }
14964
+ const EventsTicker = new EventsTickerClass();
14965
+
15014
14966
  class FederatedEvent {
15015
14967
  constructor(manager) {
15016
14968
  this.bubbles = true;
@@ -15115,6 +15067,9 @@ class FederatedMouseEvent extends FederatedEvent {
15115
15067
  get screenY() {
15116
15068
  return this.screen.y;
15117
15069
  }
15070
+ getLocalPosition(displayObject, point, globalPos) {
15071
+ return displayObject.worldTransform.applyInverse(globalPos || this.global, point);
15072
+ }
15118
15073
  getModifierState(key) {
15119
15074
  return "getModifierState" in this.nativeEvent && this.nativeEvent.getModifierState(key);
15120
15075
  }
@@ -15144,11 +15099,14 @@ class FederatedPointerEvent extends FederatedMouseEvent {
15144
15099
  class FederatedWheelEvent extends FederatedMouseEvent {
15145
15100
  constructor() {
15146
15101
  super(...arguments);
15147
- this.DOM_DELTA_LINE = 0;
15148
- this.DOM_DELTA_PAGE = 1;
15149
- this.DOM_DELTA_PIXEL = 2;
15102
+ this.DOM_DELTA_PIXEL = 0;
15103
+ this.DOM_DELTA_LINE = 1;
15104
+ this.DOM_DELTA_PAGE = 2;
15150
15105
  }
15151
15106
  }
15107
+ FederatedWheelEvent.DOM_DELTA_PIXEL = 0;
15108
+ FederatedWheelEvent.DOM_DELTA_LINE = 1;
15109
+ FederatedWheelEvent.DOM_DELTA_PAGE = 2;
15152
15110
 
15153
15111
  const PROPAGATION_LIMIT = 2048;
15154
15112
  const tempHitLocation = new Point();
@@ -15211,7 +15169,8 @@ class EventBoundary {
15211
15169
  }
15212
15170
  }
15213
15171
  hitTest(x, y) {
15214
- const invertedPath = this.hitTestRecursive(this.rootTarget, this.rootTarget.interactive, tempHitLocation.set(x, y), this.hitTestFn, this.hitPruneFn);
15172
+ EventsTicker.pauseUpdate = true;
15173
+ const invertedPath = this.hitTestRecursive(this.rootTarget, this.rootTarget.eventMode, tempHitLocation.set(x, y), this.hitTestFn, this.hitPruneFn);
15215
15174
  return invertedPath && invertedPath[0];
15216
15175
  }
15217
15176
  propagate(e, type) {
@@ -15242,9 +15201,15 @@ class EventBoundary {
15242
15201
  all(e, type, target = this.rootTarget) {
15243
15202
  e.eventPhase = e.BUBBLING_PHASE;
15244
15203
  const children = target.children;
15245
- if (children) {
15246
- for (let i = 0; i < children.length; i++) {
15247
- this.all(e, type, children[i]);
15204
+ const interactionNone = target.eventMode === "none";
15205
+ const interactionPassive = target.eventMode === "passive" && !target.interactiveChildren;
15206
+ const interactiveChildren = target.interactiveChildren;
15207
+ const shouldIterateChildren = !interactionNone && interactiveChildren && !interactionPassive;
15208
+ if (children && children.length > 0) {
15209
+ if (shouldIterateChildren) {
15210
+ for (let i = 0; i < children.length; i++) {
15211
+ this.all(e, type, children[i]);
15212
+ }
15248
15213
  }
15249
15214
  }
15250
15215
  e.currentTarget = target;
@@ -15262,35 +15227,50 @@ class EventBoundary {
15262
15227
  propagationPath.reverse();
15263
15228
  return propagationPath;
15264
15229
  }
15265
- hitTestRecursive(currentTarget, interactive, location, testFn, pruneFn) {
15230
+ hitTestRecursive(currentTarget, eventMode, location, testFn, pruneFn) {
15266
15231
  if (!currentTarget || !currentTarget.visible) {
15267
15232
  return null;
15268
15233
  }
15269
15234
  if (pruneFn(currentTarget, location)) {
15270
15235
  return null;
15271
15236
  }
15237
+ if (currentTarget.eventMode === "dynamic" || eventMode === "dynamic") {
15238
+ EventsTicker.pauseUpdate = false;
15239
+ }
15272
15240
  if (currentTarget.interactiveChildren && currentTarget.children) {
15273
15241
  const children = currentTarget.children;
15274
15242
  for (let i = children.length - 1; i >= 0; i--) {
15275
15243
  const child = children[i];
15276
- const nestedHit = this.hitTestRecursive(child, interactive || child.interactive, location, testFn, pruneFn);
15244
+ const nestedHit = this.hitTestRecursive(child, this._isInteractive(eventMode) ? eventMode : child.eventMode, location, testFn, pruneFn);
15277
15245
  if (nestedHit) {
15278
15246
  if (nestedHit.length > 0 && !nestedHit[nestedHit.length - 1].parent) {
15279
15247
  continue;
15280
15248
  }
15281
- if (nestedHit.length > 0 || currentTarget.interactive) {
15249
+ if (nestedHit.length > 0 || currentTarget.isInteractive()) {
15282
15250
  nestedHit.push(currentTarget);
15283
15251
  }
15284
15252
  return nestedHit;
15285
15253
  }
15286
15254
  }
15287
15255
  }
15288
- if (interactive && testFn(currentTarget, location)) {
15289
- return currentTarget.interactive ? [currentTarget] : [];
15256
+ if (this._isInteractive(eventMode) && testFn(currentTarget, location)) {
15257
+ return currentTarget.isInteractive() ? [currentTarget] : [];
15290
15258
  }
15291
15259
  return null;
15292
15260
  }
15261
+ _isInteractive(int) {
15262
+ return int === "static" || int === "dynamic";
15263
+ }
15293
15264
  hitPruneFn(displayObject, location) {
15265
+ if (displayObject.eventMode === "none") {
15266
+ return true;
15267
+ }
15268
+ if (displayObject.eventMode === "passive" && !displayObject.interactiveChildren) {
15269
+ return true;
15270
+ }
15271
+ if (displayObject.isMask) {
15272
+ return true;
15273
+ }
15294
15274
  if (displayObject.hitArea) {
15295
15275
  displayObject.worldTransform.applyInverse(location, tempLocalMapping);
15296
15276
  if (!displayObject.hitArea.contains(tempLocalMapping.x, tempLocalMapping.y)) {
@@ -15306,6 +15286,9 @@ class EventBoundary {
15306
15286
  return false;
15307
15287
  }
15308
15288
  hitTestFn(displayObject, location) {
15289
+ if (displayObject.eventMode === "passive") {
15290
+ return false;
15291
+ }
15309
15292
  if (displayObject.hitArea) {
15310
15293
  return true;
15311
15294
  }
@@ -15689,6 +15672,8 @@ class EventBoundary {
15689
15672
  const listeners = e.currentTarget._events[type];
15690
15673
  if (!listeners)
15691
15674
  return;
15675
+ if (!e.currentTarget.isInteractive())
15676
+ return;
15692
15677
  if ("fn" in listeners) {
15693
15678
  listeners.fn.call(listeners.context, e);
15694
15679
  } else {
@@ -15707,7 +15692,7 @@ const TOUCH_TO_POINTER = {
15707
15692
  touchmove: "pointermove",
15708
15693
  touchcancel: "pointercancel"
15709
15694
  };
15710
- class EventSystem {
15695
+ const _EventSystem = class {
15711
15696
  constructor(renderer) {
15712
15697
  this.supportsTouchEvents = "ontouchstart" in globalThis;
15713
15698
  this.supportsPointerEvents = !!globalThis.PointerEvent;
@@ -15715,6 +15700,7 @@ class EventSystem {
15715
15700
  this.resolution = 1;
15716
15701
  this.renderer = renderer;
15717
15702
  this.rootBoundary = new EventBoundary(null);
15703
+ EventsTicker.init(this);
15718
15704
  this.autoPreventDefault = true;
15719
15705
  this.eventsAdded = false;
15720
15706
  this.rootPointerEvent = new FederatedPointerEvent(null);
@@ -15729,10 +15715,14 @@ class EventSystem {
15729
15715
  this.onPointerOverOut = this.onPointerOverOut.bind(this);
15730
15716
  this.onWheel = this.onWheel.bind(this);
15731
15717
  }
15732
- init() {
15718
+ static get defaultEventMode() {
15719
+ return this._defaultEventMode;
15720
+ }
15721
+ init(options) {
15733
15722
  const { view, resolution } = this.renderer;
15734
15723
  this.setTargetElement(view);
15735
15724
  this.resolution = resolution;
15725
+ _EventSystem._defaultEventMode = options.eventMode ?? "auto";
15736
15726
  }
15737
15727
  resolutionChange(resolution) {
15738
15728
  this.resolution = resolution;
@@ -15794,6 +15784,7 @@ class EventSystem {
15794
15784
  this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
15795
15785
  if (this.supportsTouchEvents && nativeEvent.pointerType === "touch")
15796
15786
  return;
15787
+ EventsTicker.pointerMoved();
15797
15788
  const normalizedEvents = this.normalizeToPointerData(nativeEvent);
15798
15789
  for (let i = 0, j = normalizedEvents.length; i < j; i++) {
15799
15790
  const event = this.bootstrapEvent(this.rootPointerEvent, normalizedEvents[i]);
@@ -15837,12 +15828,14 @@ class EventSystem {
15837
15828
  setTargetElement(element) {
15838
15829
  this.removeEvents();
15839
15830
  this.domElement = element;
15831
+ EventsTicker.domElement = element;
15840
15832
  this.addEvents();
15841
15833
  }
15842
15834
  addEvents() {
15843
15835
  if (this.eventsAdded || !this.domElement) {
15844
15836
  return;
15845
15837
  }
15838
+ EventsTicker.addTickerListener();
15846
15839
  const style = this.domElement.style;
15847
15840
  if (style) {
15848
15841
  if (globalThis.navigator.msPointerEnabled) {
@@ -15880,6 +15873,7 @@ class EventSystem {
15880
15873
  if (!this.eventsAdded || !this.domElement) {
15881
15874
  return;
15882
15875
  }
15876
+ EventsTicker.removeTickerListener();
15883
15877
  const style = this.domElement.style;
15884
15878
  if (globalThis.navigator.msPointerEnabled) {
15885
15879
  style.msContentZooming = "";
@@ -16056,7 +16050,8 @@ class EventSystem {
16056
16050
  event.relatedTarget = null;
16057
16051
  event.shiftKey = nativeEvent.shiftKey;
16058
16052
  }
16059
- }
16053
+ };
16054
+ let EventSystem = _EventSystem;
16060
16055
  EventSystem.extension = {
16061
16056
  name: "events",
16062
16057
  type: [
@@ -16066,6 +16061,9 @@ EventSystem.extension = {
16066
16061
  };
16067
16062
  extensions$1.add(EventSystem);
16068
16063
 
16064
+ function convertEventModeToInteractiveMode(mode) {
16065
+ return mode === "dynamic" || mode === "static";
16066
+ }
16069
16067
  const FederatedDisplayObject = {
16070
16068
  onclick: null,
16071
16069
  onmousedown: null,
@@ -16100,7 +16098,26 @@ const FederatedDisplayObject = {
16100
16098
  onglobaltouchmove: null,
16101
16099
  ontouchstart: null,
16102
16100
  onwheel: null,
16103
- interactive: false,
16101
+ _internalInteractive: void 0,
16102
+ get interactive() {
16103
+ return this._internalInteractive ?? convertEventModeToInteractiveMode(EventSystem.defaultEventMode);
16104
+ },
16105
+ set interactive(value) {
16106
+ deprecation("7.2.0", `Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead.`);
16107
+ this._internalInteractive = value;
16108
+ this.eventMode = value ? "static" : "auto";
16109
+ },
16110
+ _internalEventMode: void 0,
16111
+ get eventMode() {
16112
+ return this._internalEventMode ?? EventSystem.defaultEventMode;
16113
+ },
16114
+ set eventMode(value) {
16115
+ this._internalInteractive = convertEventModeToInteractiveMode(value);
16116
+ this._internalEventMode = value;
16117
+ },
16118
+ isInteractive() {
16119
+ return this.eventMode === "static" || this.eventMode === "dynamic";
16120
+ },
16104
16121
  interactiveChildren: true,
16105
16122
  hitArea: null,
16106
16123
  addEventListener(type, listener, options) {
@@ -16235,7 +16252,7 @@ class AccessibilityManager {
16235
16252
  if (!displayObject.visible || !displayObject.accessibleChildren) {
16236
16253
  return;
16237
16254
  }
16238
- if (displayObject.accessible && displayObject.interactive) {
16255
+ if (displayObject.accessible && displayObject.isInteractive()) {
16239
16256
  if (!displayObject._accessibleActive) {
16240
16257
  this.addChild(displayObject);
16241
16258
  }
@@ -17112,14 +17129,16 @@ const loadTextures = {
17112
17129
  priority: LoaderParserPriority.High
17113
17130
  },
17114
17131
  config: {
17115
- preferWorkers: true
17132
+ preferWorkers: true,
17133
+ preferCreateImageBitmap: true,
17134
+ crossOrigin: "anonymous"
17116
17135
  },
17117
17136
  test(url) {
17118
17137
  return checkDataUrl(url, validImageMIMEs) || checkExtension(url, validImageExtensions);
17119
17138
  },
17120
17139
  async load(url, asset, loader) {
17121
17140
  let src = null;
17122
- if (globalThis.createImageBitmap) {
17141
+ if (globalThis.createImageBitmap && this.config.preferCreateImageBitmap) {
17123
17142
  if (this.config.preferWorkers && await WorkerManager.isImageBitmapSupported()) {
17124
17143
  src = await WorkerManager.loadImageBitmap(url);
17125
17144
  } else {
@@ -17128,7 +17147,7 @@ const loadTextures = {
17128
17147
  } else {
17129
17148
  src = await new Promise((resolve) => {
17130
17149
  src = new Image();
17131
- src.crossOrigin = "anonymous";
17150
+ src.crossOrigin = this.config.crossOrigin;
17132
17151
  src.src = url;
17133
17152
  if (src.complete) {
17134
17153
  resolve(src);
@@ -19800,11 +19819,11 @@ const _GraphicsGeometry = class extends BatchGeometry {
19800
19819
  }
19801
19820
  }
19802
19821
  addColors(colors, color, alpha, size, offset = 0) {
19803
- const rgb = (color >> 16) + (color & 65280) + ((color & 255) << 16);
19804
- const rgba = premultiplyTint(rgb, alpha);
19822
+ const bgr = Color.shared.setValue(color).toLittleEndianNumber();
19823
+ const result = Color.shared.setValue(bgr).toPremultiplied(alpha);
19805
19824
  colors.length = Math.max(colors.length, offset + size);
19806
19825
  for (let i = 0; i < size; i++) {
19807
- colors[offset + i] = rgba;
19826
+ colors[offset + i] = result;
19808
19827
  }
19809
19828
  }
19810
19829
  addTextureIds(textureIds, id, size, offset = 0) {
@@ -19972,25 +19991,26 @@ const _Graphics = class extends Container {
19972
19991
  get line() {
19973
19992
  return this._lineStyle;
19974
19993
  }
19975
- lineStyle(options = null, color = 0, alpha = 1, alignment = 0.5, native = false) {
19994
+ lineStyle(options = null, color = 0, alpha, alignment = 0.5, native = false) {
19976
19995
  if (typeof options === "number") {
19977
19996
  options = { width: options, color, alpha, alignment, native };
19978
19997
  }
19979
19998
  return this.lineTextureStyle(options);
19980
19999
  }
19981
20000
  lineTextureStyle(options) {
19982
- options = Object.assign({
20001
+ const defaultLineStyleOptions = {
19983
20002
  width: 0,
19984
20003
  texture: Texture.WHITE,
19985
20004
  color: options?.texture ? 16777215 : 0,
19986
- alpha: 1,
19987
20005
  matrix: null,
19988
20006
  alignment: 0.5,
19989
20007
  native: false,
19990
20008
  cap: LINE_CAP.BUTT,
19991
20009
  join: LINE_JOIN.MITER,
19992
20010
  miterLimit: 10
19993
- }, options);
20011
+ };
20012
+ options = Object.assign(defaultLineStyleOptions, options);
20013
+ this.normalizeColor(options);
19994
20014
  if (this.currentPath) {
19995
20015
  this.startPoly();
19996
20016
  }
@@ -20113,16 +20133,22 @@ const _Graphics = class extends Container {
20113
20133
  ArcUtils.arc(startX, startY, cx, cy, radius, startAngle, endAngle, anticlockwise, points);
20114
20134
  return this;
20115
20135
  }
20116
- beginFill(color = 0, alpha = 1) {
20136
+ beginFill(color = 0, alpha) {
20117
20137
  return this.beginTextureFill({ texture: Texture.WHITE, color, alpha });
20118
20138
  }
20139
+ normalizeColor(options) {
20140
+ const temp2 = Color.shared.setValue(options.color ?? 0);
20141
+ options.color = temp2.toNumber();
20142
+ options.alpha ?? (options.alpha = temp2.alpha);
20143
+ }
20119
20144
  beginTextureFill(options) {
20120
- options = Object.assign({
20145
+ const defaultOptions = {
20121
20146
  texture: Texture.WHITE,
20122
20147
  color: 16777215,
20123
- alpha: 1,
20124
20148
  matrix: null
20125
- }, options);
20149
+ };
20150
+ options = Object.assign(defaultOptions, options);
20151
+ this.normalizeColor(options);
20126
20152
  if (this.currentPath) {
20127
20153
  this.startPoly();
20128
20154
  }
@@ -20228,7 +20254,7 @@ const _Graphics = class extends Container {
20228
20254
  blendMode,
20229
20255
  indices,
20230
20256
  uvs,
20231
- _batchRGB: hex2rgb(color),
20257
+ _batchRGB: Color.shared.setValue(color).toRgbArray(),
20232
20258
  _tintRGB: color,
20233
20259
  _texture: gI.style.texture,
20234
20260
  alpha: gI.style.alpha,
@@ -20258,10 +20284,7 @@ const _Graphics = class extends Container {
20258
20284
  const uniforms = shader.uniforms;
20259
20285
  const drawCalls = geometry.drawCalls;
20260
20286
  uniforms.translationMatrix = this.transform.worldTransform;
20261
- uniforms.tint[0] = (tint >> 16 & 255) / 255 * worldAlpha;
20262
- uniforms.tint[1] = (tint >> 8 & 255) / 255 * worldAlpha;
20263
- uniforms.tint[2] = (tint & 255) / 255 * worldAlpha;
20264
- uniforms.tint[3] = worldAlpha;
20287
+ Color.shared.setValue(tint).multiply([worldAlpha, worldAlpha, worldAlpha]).setAlpha(worldAlpha).toArray(uniforms.tint);
20265
20288
  renderer.shader.bind(shader);
20266
20289
  renderer.geometry.bind(geometry, shader);
20267
20290
  renderer.state.set(this.state);
@@ -20315,15 +20338,10 @@ const _Graphics = class extends Container {
20315
20338
  calculateTints() {
20316
20339
  if (this.batchTint !== this.tint) {
20317
20340
  this.batchTint = this.tint;
20318
- const tintRGB = hex2rgb(this.tint, temp);
20341
+ const tintRGB = Color.shared.setValue(this.tint).toRgbArray(temp);
20319
20342
  for (let i = 0; i < this.batches.length; i++) {
20320
20343
  const batch = this.batches[i];
20321
- const batchTint = batch._batchRGB;
20322
- const r = tintRGB[0] * batchTint[0] * 255;
20323
- const g = tintRGB[1] * batchTint[1] * 255;
20324
- const b = tintRGB[2] * batchTint[2] * 255;
20325
- const color = (r << 16) + (g << 8) + (b | 0);
20326
- batch._tintRGB = (color >> 16) + (color & 65280) + ((color & 255) << 16);
20344
+ batch._tintRGB = Color.shared.setValue(tintRGB).multiply(batch._batchRGB).toLittleEndianNumber();
20327
20345
  }
20328
20346
  }
20329
20347
  }
@@ -20709,7 +20727,7 @@ class MeshMaterial extends Shader {
20709
20727
  if (value === this._tint)
20710
20728
  return;
20711
20729
  this._tint = value;
20712
- this._tintRGB = (value >> 16) + (value & 65280) + ((value & 255) << 16);
20730
+ this._tintRGB = Color.shared.setValue(value).toLittleEndianNumber();
20713
20731
  this._colorDirty = true;
20714
20732
  }
20715
20733
  get tint() {
@@ -20719,7 +20737,8 @@ class MeshMaterial extends Shader {
20719
20737
  if (this._colorDirty) {
20720
20738
  this._colorDirty = false;
20721
20739
  const baseTexture = this.texture.baseTexture;
20722
- premultiplyTintToRgba(this._tint, this._alpha, this.uniforms.uColor, baseTexture.alphaMode);
20740
+ const applyToChannels = baseTexture.alphaMode;
20741
+ Color.shared.setValue(this._tint).premultiply(this._alpha, applyToChannels).toArray(this.uniforms.uColor);
20723
20742
  }
20724
20743
  if (this.uvMatrix.update()) {
20725
20744
  this.uniforms.uTextureMatrix = this.uvMatrix.mapCoord;
@@ -20931,16 +20950,16 @@ class SimplePlane extends Mesh {
20931
20950
 
20932
20951
  const DEFAULT_BORDER_SIZE = 10;
20933
20952
  class NineSlicePlane extends SimplePlane {
20934
- constructor(texture, leftWidth = DEFAULT_BORDER_SIZE, topHeight = DEFAULT_BORDER_SIZE, rightWidth = DEFAULT_BORDER_SIZE, bottomHeight = DEFAULT_BORDER_SIZE) {
20953
+ constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) {
20935
20954
  super(Texture.WHITE, 4, 4);
20936
20955
  this._origWidth = texture.orig.width;
20937
20956
  this._origHeight = texture.orig.height;
20938
20957
  this._width = this._origWidth;
20939
20958
  this._height = this._origHeight;
20940
- this._leftWidth = leftWidth;
20941
- this._rightWidth = rightWidth;
20942
- this._topHeight = topHeight;
20943
- this._bottomHeight = bottomHeight;
20959
+ this._leftWidth = leftWidth ?? texture.defaultBorders?.left ?? DEFAULT_BORDER_SIZE;
20960
+ this._rightWidth = rightWidth ?? texture.defaultBorders?.right ?? DEFAULT_BORDER_SIZE;
20961
+ this._topHeight = topHeight ?? texture.defaultBorders?.top ?? DEFAULT_BORDER_SIZE;
20962
+ this._bottomHeight = bottomHeight ?? texture.defaultBorders?.bottom ?? DEFAULT_BORDER_SIZE;
20944
20963
  this.texture = texture;
20945
20964
  }
20946
20965
  textureUpdated() {
@@ -21121,7 +21140,7 @@ class ParticleContainer extends Container {
21121
21140
  }
21122
21141
  set tint(value) {
21123
21142
  this._tint = value;
21124
- hex2rgb(value, this.tintRgb);
21143
+ Color.shared.setValue(value).toRgbArray(this.tintRgb);
21125
21144
  }
21126
21145
  render(renderer) {
21127
21146
  if (!this.visible || this.worldAlpha <= 0 || !this.children.length || !this.renderable) {
@@ -21327,7 +21346,7 @@ class ParticleRenderer extends ObjectRenderer {
21327
21346
  const m = container.worldTransform.copyTo(this.tempMatrix);
21328
21347
  m.prepend(renderer.globalUniforms.uniforms.projectionMatrix);
21329
21348
  this.shader.uniforms.translationMatrix = m.toArray(true);
21330
- this.shader.uniforms.uColor = premultiplyRgba(container.tintRgb, container.worldAlpha, this.shader.uniforms.uColor, premultiplied);
21349
+ this.shader.uniforms.uColor = Color.shared.setValue(container.tintRgb).premultiply(container.worldAlpha, premultiplied).toArray(this.shader.uniforms.uColor);
21331
21350
  this.shader.uniforms.uSampler = baseTexture;
21332
21351
  this.renderer.shader.bind(this.shader);
21333
21352
  let updateStatic = false;
@@ -21453,13 +21472,11 @@ class ParticleRenderer extends ObjectRenderer {
21453
21472
  uploadTint(children, startIndex, amount, array, stride, offset) {
21454
21473
  for (let i = 0; i < amount; ++i) {
21455
21474
  const sprite = children[startIndex + i];
21456
- const premultiplied = sprite._texture.baseTexture.alphaMode > 0;
21457
- const alpha = sprite.alpha;
21458
- const argb = alpha < 1 && premultiplied ? premultiplyTint(sprite._tintRGB, alpha) : sprite._tintRGB + (alpha * 255 << 24);
21459
- array[offset] = argb;
21460
- array[offset + stride] = argb;
21461
- array[offset + stride * 2] = argb;
21462
- array[offset + stride * 3] = argb;
21475
+ const result = Color.shared.setValue(sprite._tintRGB).toPremultiplied(sprite.alpha);
21476
+ array[offset] = result;
21477
+ array[offset + stride] = result;
21478
+ array[offset + stride * 2] = result;
21479
+ array[offset + stride * 3] = result;
21463
21480
  offset += stride * 4;
21464
21481
  }
21465
21482
  }
@@ -22201,24 +22218,12 @@ TextStyle.defaultStyle = {
22201
22218
  wordWrap: false,
22202
22219
  wordWrapWidth: 100
22203
22220
  };
22204
- function getSingleColor(color) {
22205
- if (typeof color === "number") {
22206
- return hex2string(color);
22207
- } else if (typeof color === "string") {
22208
- if (color.startsWith("0x")) {
22209
- color = color.replace("0x", "#");
22210
- }
22211
- }
22212
- return color;
22213
- }
22214
22221
  function getColor(color) {
22222
+ const temp = Color.shared;
22215
22223
  if (!Array.isArray(color)) {
22216
- return getSingleColor(color);
22224
+ return temp.setValue(color).toHex();
22217
22225
  } else {
22218
- for (let i = 0; i < color.length; ++i) {
22219
- color[i] = getSingleColor(color[i]);
22220
- }
22221
- return color;
22226
+ return color.map((c) => temp.setValue(c).toHex());
22222
22227
  }
22223
22228
  }
22224
22229
  function areArraysEqual(array1, array2) {
@@ -22324,10 +22329,9 @@ const _Text = class extends Sprite {
22324
22329
  context.fillStyle = "black";
22325
22330
  context.strokeStyle = "black";
22326
22331
  const dropShadowColor = style.dropShadowColor;
22327
- const rgb = hex2rgb(typeof dropShadowColor === "number" ? dropShadowColor : string2hex(dropShadowColor));
22328
22332
  const dropShadowBlur = style.dropShadowBlur * this._resolution;
22329
22333
  const dropShadowDistance = style.dropShadowDistance * this._resolution;
22330
- context.shadowColor = `rgba(${rgb[0] * 255},${rgb[1] * 255},${rgb[2] * 255},${style.dropShadowAlpha})`;
22334
+ context.shadowColor = Color.shared.setValue(dropShadowColor).setAlpha(style.dropShadowAlpha).toRgbaString();
22331
22335
  context.shadowBlur = dropShadowBlur;
22332
22336
  context.shadowOffsetX = Math.cos(style.dropShadowAngle) * dropShadowDistance;
22333
22337
  context.shadowOffsetY = Math.sin(style.dropShadowAngle) * dropShadowDistance + dsOffsetShadow;
@@ -23235,7 +23239,7 @@ class TilingSpriteRenderer extends ObjectRenderer {
23235
23239
  shader.uniforms.uClampOffset = uv.uClampOffset;
23236
23240
  }
23237
23241
  shader.uniforms.uTransform = tempMat.toArray(true);
23238
- shader.uniforms.uColor = premultiplyTintToRgba(ts.tint, ts.worldAlpha, shader.uniforms.uColor, premultiplied);
23242
+ shader.uniforms.uColor = Color.shared.setValue(ts.tint).premultiply(ts.worldAlpha, premultiplied).toArray(shader.uniforms.uColor);
23239
23243
  shader.uniforms.translationMatrix = ts.transform.worldTransform.toArray(true);
23240
23244
  shader.uniforms.uSampler = tex;
23241
23245
  renderer.shader.bind(shader);
@@ -23310,7 +23314,7 @@ const _Spritesheet = class {
23310
23314
  if (data.trimmed !== false && data.spriteSourceSize) {
23311
23315
  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);
23312
23316
  }
23313
- this.textures[i] = new Texture(this.baseTexture, frame, orig, trim, data.rotated ? 2 : 0, data.anchor);
23317
+ this.textures[i] = new Texture(this.baseTexture, frame, orig, trim, data.rotated ? 2 : 0, data.anchor, data.borders);
23314
23318
  Texture.addToCache(this.textures[i], i);
23315
23319
  }
23316
23320
  frameIndex++;
@@ -23701,10 +23705,9 @@ function drawGlyph(canvas, context, metrics, x, y, resolution, style) {
23701
23705
  context.strokeStyle = style.stroke;
23702
23706
  if (style.dropShadow) {
23703
23707
  const dropShadowColor = style.dropShadowColor;
23704
- const rgb = hex2rgb(typeof dropShadowColor === "number" ? dropShadowColor : string2hex(dropShadowColor));
23705
23708
  const dropShadowBlur = style.dropShadowBlur * resolution;
23706
23709
  const dropShadowDistance = style.dropShadowDistance * resolution;
23707
- context.shadowColor = `rgba(${rgb[0] * 255},${rgb[1] * 255},${rgb[2] * 255},${style.dropShadowAlpha})`;
23710
+ context.shadowColor = Color.shared.setValue(dropShadowColor).setAlpha(style.dropShadowAlpha).toRgbaString();
23708
23711
  context.shadowBlur = dropShadowBlur;
23709
23712
  context.shadowOffsetX = Math.cos(style.dropShadowAngle) * dropShadowDistance;
23710
23713
  context.shadowOffsetY = Math.sin(style.dropShadowAngle) * dropShadowDistance;
@@ -24490,5 +24493,492 @@ const loadBitmapFont = {
24490
24493
  };
24491
24494
  extensions$1.add(loadBitmapFont);
24492
24495
 
24493
- export { ALPHA_MODES, AbstractMultiResource, AccessibilityManager, AlphaFilter, AnimatedSprite, Application, ArrayResource, Assets, AssetsClass, Attribute, BLEND_MODES, BUFFER_BITS, BUFFER_TYPE, BackgroundSystem, BaseImageResource, BasePrepare, BaseRenderTexture, BaseTexture, BatchDrawCall, BatchGeometry, BatchRenderer, BatchShaderGenerator, BatchSystem, BatchTextureArray, BitmapFont, BitmapFontData, BitmapText, BlobResource, BlurFilter, BlurFilterPass, Bounds, BrowserAdapter, Buffer, BufferResource, BufferSystem, CLEAR_MODES, COLOR_MASK_BITS, Cache, CanvasResource, Circle, ColorMatrixFilter, CompressedTextureResource, Container, ContextSystem, CountLimiter, CubeResource, DEG_TO_RAD, DRAW_MODES, DisplacementFilter, DisplayObject, ENV, Ellipse, EventBoundary, EventSystem, ExtensionType, Extract, FORMATS, FORMATS_TO_COMPONENTS, FXAAFilter, FederatedDisplayObject, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, FillStyle, Filter, FilterState, FilterSystem, Framebuffer, FramebufferSystem, GC_MODES, GLFramebuffer, GLProgram, GLTexture, GRAPHICS_CURVES, GenerateTextureSystem, Geometry, GeometrySystem, Graphics, GraphicsData, GraphicsGeometry, IGLUniformData, INSTALLED, INTERNAL_FORMATS, INTERNAL_FORMAT_TO_BYTES_PER_PIXEL, ImageBitmapResource, ImageResource, LINE_CAP, LINE_JOIN, LineStyle, LoaderParserPriority, MASK_TYPES, MIPMAP_MODES, MSAA_QUALITY, MaskData, MaskSystem, Matrix, Mesh, MeshBatchUvs, MeshGeometry, MeshMaterial, MultisampleSystem, NineSlicePlane, NoiseFilter, ObjectRenderer, ObjectRendererSystem, ObservablePoint, PI_2, PRECISION, ParticleContainer, ParticleRenderer, PlaneGeometry, PluginSystem, Point, Polygon, Prepare, Program, ProjectionSystem, Quad, QuadUv, RAD_TO_DEG, RENDERER_TYPE, Rectangle, RenderTexture, RenderTexturePool, RenderTextureSystem, Renderer, ResizePlugin, Resource, RopeGeometry, RoundedRectangle, Runner, SAMPLER_TYPES, SCALE_MODES, SHAPES, SVGResource, ScissorSystem, Shader, ShaderSystem, SimpleMesh, SimplePlane, SimpleRope, Sprite, SpriteMaskFilter, Spritesheet, StartupSystem, State, StateSystem, StencilSystem, SystemManager, TARGETS, TEXT_GRADIENT, TYPES, TYPES_TO_BYTES_PER_COMPONENT, TYPES_TO_BYTES_PER_PIXEL, TemporaryDisplayObject, Text, TextFormat, TextMetrics, TextStyle, Texture, TextureGCSystem, TextureMatrix, TextureSystem, TextureUvs, Ticker, TickerPlugin, TilingSprite, TilingSpriteRenderer, TimeLimiter, Transform, TransformFeedback, TransformFeedbackSystem, UPDATE_PRIORITY, UniformGroup, VERSION, VideoResource, ViewSystem, ViewableBuffer, WRAP_MODES, XMLFormat, XMLStringFormat, accessibleTarget, autoDetectFormat, autoDetectRenderer, autoDetectResource, cacheTextureArray, checkDataUrl, checkExtension, checkMaxIfStatementsInShader, convertToList, copySearchParams, createStringVariations, createTexture, createUBOElements, curves, defaultFilterVertex, defaultVertex, detectAvif, detectCompressedTextures, detectDefaults, detectWebp, extensions$1 as extensions, filters, generateProgram, generateUniformBufferSync, getFontFamilyName, getTestContext, getUBOData, graphicsUtils, groupD8, isMobile, isSingleItem, loadBitmapFont, loadDDS, loadImageBitmap, loadJson, loadKTX, loadSVG, loadTextures, loadTxt, loadWebFont, parseDDS, parseKTX, resolveCompressedTextureUrl, resolveTextureUrl, settings, spritesheetAsset, uniformParsers, unsafeEvalSupported, index as utils };
24496
+ const _HTMLTextStyle = class extends TextStyle {
24497
+ constructor() {
24498
+ super(...arguments);
24499
+ this._fonts = [];
24500
+ this._overrides = [];
24501
+ this._stylesheet = "";
24502
+ this.fontsDirty = false;
24503
+ }
24504
+ static from(originalStyle) {
24505
+ return new _HTMLTextStyle(Object.keys(_HTMLTextStyle.defaultOptions).reduce((obj, prop) => ({ ...obj, [prop]: originalStyle[prop] }), {}));
24506
+ }
24507
+ cleanFonts() {
24508
+ if (this._fonts.length > 0) {
24509
+ this._fonts.forEach((font) => {
24510
+ URL.revokeObjectURL(font.src);
24511
+ font.refs--;
24512
+ if (font.refs === 0) {
24513
+ if (font.fontFace) {
24514
+ document.fonts.delete(font.fontFace);
24515
+ }
24516
+ delete _HTMLTextStyle.availableFonts[font.originalUrl];
24517
+ }
24518
+ });
24519
+ this.fontFamily = "Arial";
24520
+ this._fonts.length = 0;
24521
+ this.styleID++;
24522
+ this.fontsDirty = true;
24523
+ }
24524
+ }
24525
+ loadFont(url, options = {}) {
24526
+ const { availableFonts } = _HTMLTextStyle;
24527
+ if (availableFonts[url]) {
24528
+ const font = availableFonts[url];
24529
+ this._fonts.push(font);
24530
+ font.refs++;
24531
+ this.styleID++;
24532
+ this.fontsDirty = true;
24533
+ return Promise.resolve();
24534
+ }
24535
+ return settings.ADAPTER.fetch(url).then((response) => response.blob()).then(async (blob) => new Promise((resolve, reject) => {
24536
+ const src = URL.createObjectURL(blob);
24537
+ const reader = new FileReader();
24538
+ reader.onload = () => resolve([src, reader.result]);
24539
+ reader.onerror = reject;
24540
+ reader.readAsDataURL(blob);
24541
+ })).then(async ([src, dataSrc]) => {
24542
+ const font = Object.assign({
24543
+ family: path.basename(url, path.extname(url)),
24544
+ weight: "normal",
24545
+ style: "normal",
24546
+ src,
24547
+ dataSrc,
24548
+ refs: 1,
24549
+ originalUrl: url,
24550
+ fontFace: null
24551
+ }, options);
24552
+ availableFonts[url] = font;
24553
+ this._fonts.push(font);
24554
+ this.styleID++;
24555
+ const fontFace = new FontFace(font.family, `url(${font.src})`, {
24556
+ weight: font.weight,
24557
+ style: font.style
24558
+ });
24559
+ font.fontFace = fontFace;
24560
+ await fontFace.load();
24561
+ document.fonts.add(fontFace);
24562
+ await document.fonts.ready;
24563
+ this.styleID++;
24564
+ this.fontsDirty = true;
24565
+ });
24566
+ }
24567
+ addOverride(...value) {
24568
+ const toAdd = value.filter((v) => !this._overrides.includes(v));
24569
+ if (toAdd.length > 0) {
24570
+ this._overrides.push(...toAdd);
24571
+ this.styleID++;
24572
+ }
24573
+ }
24574
+ removeOverride(...value) {
24575
+ const toRemove = value.filter((v) => this._overrides.includes(v));
24576
+ if (toRemove.length > 0) {
24577
+ this._overrides = this._overrides.filter((v) => !toRemove.includes(v));
24578
+ this.styleID++;
24579
+ }
24580
+ }
24581
+ toCSS(scale) {
24582
+ return [
24583
+ "display: inline-block",
24584
+ `color: ${this.normalizeColor(this.fill)}`,
24585
+ `font-size: ${this.fontSize * scale}px`,
24586
+ `font-family: ${this.fontFamily}`,
24587
+ `font-weight: ${this.fontWeight}`,
24588
+ `font-style: ${this.fontStyle}`,
24589
+ `font-variant: ${this.fontVariant}`,
24590
+ `letter-spacing: ${this.letterSpacing * scale}px`,
24591
+ `text-align: ${this.align}`,
24592
+ `padding: ${this.padding * scale}px`,
24593
+ `white-space: ${this.whiteSpace}`,
24594
+ ...this.lineHeight ? [`line-height: ${this.lineHeight * scale}px`] : [],
24595
+ ...this.wordWrap ? [
24596
+ `word-wrap: ${this.breakWords ? "break-all" : "break-word"}`,
24597
+ `max-width: ${this.wordWrapWidth * scale}px`
24598
+ ] : [],
24599
+ ...this.strokeThickness ? [
24600
+ `-webkit-text-stroke-width: ${this.strokeThickness * scale}px`,
24601
+ `-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,
24602
+ `text-stroke-width: ${this.strokeThickness * scale}px`,
24603
+ `text-stroke-color: ${this.normalizeColor(this.stroke)}`,
24604
+ "paint-order: stroke"
24605
+ ] : [],
24606
+ ...this.dropShadow ? [this.dropShadowToCSS(scale)] : [],
24607
+ ...this._overrides
24608
+ ].join(";");
24609
+ }
24610
+ toGlobalCSS() {
24611
+ return this._fonts.reduce((result, font) => `${result}
24612
+ @font-face {
24613
+ font-family: "${font.family}";
24614
+ src: url('${font.dataSrc}');
24615
+ font-weight: ${font.weight};
24616
+ font-style: ${font.style};
24617
+ }`, this._stylesheet);
24618
+ }
24619
+ get stylesheet() {
24620
+ return this._stylesheet;
24621
+ }
24622
+ set stylesheet(value) {
24623
+ if (this._stylesheet !== value) {
24624
+ this._stylesheet = value;
24625
+ this.styleID++;
24626
+ }
24627
+ }
24628
+ normalizeColor(color) {
24629
+ if (Array.isArray(color)) {
24630
+ color = rgb2hex(color);
24631
+ }
24632
+ if (typeof color === "number") {
24633
+ return hex2string(color);
24634
+ }
24635
+ return color;
24636
+ }
24637
+ dropShadowToCSS(scale) {
24638
+ let color = this.normalizeColor(this.dropShadowColor);
24639
+ const alpha = this.dropShadowAlpha;
24640
+ const x = Math.round(Math.cos(this.dropShadowAngle) * this.dropShadowDistance);
24641
+ const y = Math.round(Math.sin(this.dropShadowAngle) * this.dropShadowDistance);
24642
+ if (color.startsWith("#") && alpha < 1) {
24643
+ color += (alpha * 255 | 0).toString(16).padStart(2, "0");
24644
+ }
24645
+ const position = `${x * scale}px ${y * scale}px`;
24646
+ if (this.dropShadowBlur > 0) {
24647
+ return `text-shadow: ${position} ${this.dropShadowBlur}px ${color}`;
24648
+ }
24649
+ return `text-shadow: ${position} ${color}`;
24650
+ }
24651
+ reset() {
24652
+ Object.assign(this, _HTMLTextStyle.defaultOptions);
24653
+ }
24654
+ onBeforeDraw() {
24655
+ const { fontsDirty: prevFontsDirty } = this;
24656
+ this.fontsDirty = false;
24657
+ if (this.isSafari && this._fonts.length > 0 && prevFontsDirty) {
24658
+ return new Promise((resolve) => setTimeout(resolve, 100));
24659
+ }
24660
+ return Promise.resolve();
24661
+ }
24662
+ get isSafari() {
24663
+ const { userAgent } = settings.ADAPTER.getNavigator();
24664
+ return /^((?!chrome|android).)*safari/i.test(userAgent);
24665
+ }
24666
+ set fillGradientStops(_value) {
24667
+ console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText");
24668
+ }
24669
+ get fillGradientStops() {
24670
+ return super.fillGradientStops;
24671
+ }
24672
+ set fillGradientType(_value) {
24673
+ console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText");
24674
+ }
24675
+ get fillGradientType() {
24676
+ return super.fillGradientType;
24677
+ }
24678
+ set miterLimit(_value) {
24679
+ console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText");
24680
+ }
24681
+ get miterLimit() {
24682
+ return super.miterLimit;
24683
+ }
24684
+ set trim(_value) {
24685
+ console.warn("[HTMLTextStyle] trim is not supported by HTMLText");
24686
+ }
24687
+ get trim() {
24688
+ return super.trim;
24689
+ }
24690
+ set textBaseline(_value) {
24691
+ console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText");
24692
+ }
24693
+ get textBaseline() {
24694
+ return super.textBaseline;
24695
+ }
24696
+ set leading(_value) {
24697
+ console.warn("[HTMLTextStyle] leading is not supported by HTMLText");
24698
+ }
24699
+ get leading() {
24700
+ return super.leading;
24701
+ }
24702
+ set lineJoin(_value) {
24703
+ console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText");
24704
+ }
24705
+ get lineJoin() {
24706
+ return super.lineJoin;
24707
+ }
24708
+ };
24709
+ let HTMLTextStyle = _HTMLTextStyle;
24710
+ HTMLTextStyle.availableFonts = {};
24711
+ HTMLTextStyle.defaultOptions = {
24712
+ align: "left",
24713
+ breakWords: false,
24714
+ dropShadow: false,
24715
+ dropShadowAlpha: 1,
24716
+ dropShadowAngle: Math.PI / 6,
24717
+ dropShadowBlur: 0,
24718
+ dropShadowColor: "black",
24719
+ dropShadowDistance: 5,
24720
+ fill: "black",
24721
+ fontFamily: "Arial",
24722
+ fontSize: 26,
24723
+ fontStyle: "normal",
24724
+ fontVariant: "normal",
24725
+ fontWeight: "normal",
24726
+ letterSpacing: 0,
24727
+ lineHeight: 0,
24728
+ padding: 0,
24729
+ stroke: "black",
24730
+ strokeThickness: 0,
24731
+ whiteSpace: "normal",
24732
+ wordWrap: false,
24733
+ wordWrapWidth: 100
24734
+ };
24735
+
24736
+ const _HTMLText = class extends Sprite {
24737
+ constructor(text = "", style = {}) {
24738
+ super(Texture.EMPTY);
24739
+ this._text = null;
24740
+ this._style = null;
24741
+ this._autoResolution = true;
24742
+ this._loading = false;
24743
+ this.localStyleID = -1;
24744
+ this.dirty = false;
24745
+ this.ownsStyle = false;
24746
+ const image = new Image();
24747
+ const texture = Texture.from(image, {
24748
+ scaleMode: settings.SCALE_MODE,
24749
+ resourceOptions: {
24750
+ autoLoad: false
24751
+ }
24752
+ });
24753
+ texture.orig = new Rectangle();
24754
+ texture.trim = new Rectangle();
24755
+ this.texture = texture;
24756
+ const nssvg = "http://www.w3.org/2000/svg";
24757
+ const nsxhtml = "http://www.w3.org/1999/xhtml";
24758
+ const svgRoot = document.createElementNS(nssvg, "svg");
24759
+ const foreignObject = document.createElementNS(nssvg, "foreignObject");
24760
+ const domElement = document.createElementNS(nsxhtml, "div");
24761
+ const styleElement = document.createElementNS(nsxhtml, "style");
24762
+ foreignObject.setAttribute("width", "10000");
24763
+ foreignObject.setAttribute("height", "10000");
24764
+ foreignObject.style.overflow = "hidden";
24765
+ svgRoot.appendChild(foreignObject);
24766
+ this.maxWidth = _HTMLText.defaultMaxWidth;
24767
+ this.maxHeight = _HTMLText.defaultMaxHeight;
24768
+ this._domElement = domElement;
24769
+ this._styleElement = styleElement;
24770
+ this._svgRoot = svgRoot;
24771
+ this._foreignObject = foreignObject;
24772
+ this._foreignObject.appendChild(styleElement);
24773
+ this._foreignObject.appendChild(domElement);
24774
+ this._image = image;
24775
+ this._autoResolution = _HTMLText.defaultAutoResolution;
24776
+ this._resolution = _HTMLText.defaultResolution ?? settings.RESOLUTION;
24777
+ this.text = text;
24778
+ this.style = style;
24779
+ }
24780
+ measureText(overrides) {
24781
+ const { text, style, resolution } = Object.assign({
24782
+ text: this._text,
24783
+ style: this._style,
24784
+ resolution: this._resolution
24785
+ }, overrides);
24786
+ Object.assign(this._domElement, {
24787
+ innerHTML: text,
24788
+ style: style.toCSS(resolution)
24789
+ });
24790
+ this._styleElement.textContent = style.toGlobalCSS();
24791
+ document.body.appendChild(this._svgRoot);
24792
+ const contentBounds = this._domElement.getBoundingClientRect();
24793
+ this._svgRoot.remove();
24794
+ const contentWidth = Math.min(this.maxWidth, Math.ceil(contentBounds.width));
24795
+ const contentHeight = Math.min(this.maxHeight, Math.ceil(contentBounds.height));
24796
+ this._svgRoot.setAttribute("width", contentWidth.toString());
24797
+ this._svgRoot.setAttribute("height", contentHeight.toString());
24798
+ if (text !== this._text) {
24799
+ this._domElement.innerHTML = this._text;
24800
+ }
24801
+ if (style !== this._style) {
24802
+ Object.assign(this._domElement, { style: this._style?.toCSS(resolution) });
24803
+ this._styleElement.textContent = this._style?.toGlobalCSS();
24804
+ }
24805
+ return {
24806
+ width: contentWidth + style.padding * 2,
24807
+ height: contentHeight + style.padding * 2
24808
+ };
24809
+ }
24810
+ async updateText(respectDirty = true) {
24811
+ const { style, _image: image } = this;
24812
+ if (this.localStyleID !== style.styleID) {
24813
+ this.dirty = true;
24814
+ this.localStyleID = style.styleID;
24815
+ }
24816
+ if (!this.dirty && respectDirty) {
24817
+ return;
24818
+ }
24819
+ const { width, height } = this.measureText();
24820
+ image.width = Math.ceil(Math.max(1, width));
24821
+ image.height = Math.ceil(Math.max(1, height));
24822
+ if (!this._loading) {
24823
+ this._loading = true;
24824
+ await new Promise((resolve) => {
24825
+ image.onload = async () => {
24826
+ await style.onBeforeDraw();
24827
+ this._loading = false;
24828
+ this.updateTexture();
24829
+ resolve();
24830
+ };
24831
+ const svgURL = new XMLSerializer().serializeToString(this._svgRoot);
24832
+ image.src = `data:image/svg+xml;charset=utf8,${encodeURIComponent(svgURL)}`;
24833
+ });
24834
+ }
24835
+ }
24836
+ get source() {
24837
+ return this._image;
24838
+ }
24839
+ updateTexture() {
24840
+ const { style, texture, _image: image, resolution } = this;
24841
+ const { padding } = style;
24842
+ const { baseTexture } = texture;
24843
+ texture.trim.width = texture._frame.width = image.width / resolution;
24844
+ texture.trim.height = texture._frame.height = image.height / resolution;
24845
+ texture.trim.x = -padding;
24846
+ texture.trim.y = -padding;
24847
+ texture.orig.width = texture._frame.width - padding * 2;
24848
+ texture.orig.height = texture._frame.height - padding * 2;
24849
+ this._onTextureUpdate();
24850
+ baseTexture.setRealSize(image.width, image.height, resolution);
24851
+ this.dirty = false;
24852
+ }
24853
+ _render(renderer) {
24854
+ if (this._autoResolution && this._resolution !== renderer.resolution) {
24855
+ this._resolution = renderer.resolution;
24856
+ this.dirty = true;
24857
+ }
24858
+ this.updateText(true);
24859
+ super._render(renderer);
24860
+ }
24861
+ _renderCanvas(renderer) {
24862
+ if (this._autoResolution && this._resolution !== renderer.resolution) {
24863
+ this._resolution = renderer.resolution;
24864
+ this.dirty = true;
24865
+ }
24866
+ this.updateText(true);
24867
+ super._renderCanvas(renderer);
24868
+ }
24869
+ getLocalBounds(rect) {
24870
+ this.updateText(true);
24871
+ return super.getLocalBounds(rect);
24872
+ }
24873
+ _calculateBounds() {
24874
+ this.updateText(true);
24875
+ this.calculateVertices();
24876
+ this._bounds.addQuad(this.vertexData);
24877
+ }
24878
+ _onStyleChange() {
24879
+ this.dirty = true;
24880
+ }
24881
+ destroy(options) {
24882
+ if (typeof options === "boolean") {
24883
+ options = { children: options };
24884
+ }
24885
+ options = Object.assign({}, _HTMLText.defaultDestroyOptions, options);
24886
+ super.destroy(options);
24887
+ const forceClear = null;
24888
+ if (this.ownsStyle) {
24889
+ this._style?.cleanFonts();
24890
+ }
24891
+ this._style = forceClear;
24892
+ this._svgRoot?.remove();
24893
+ this._svgRoot = forceClear;
24894
+ this._domElement?.remove();
24895
+ this._domElement = forceClear;
24896
+ this._foreignObject?.remove();
24897
+ this._foreignObject = forceClear;
24898
+ this._styleElement?.remove();
24899
+ this._styleElement = forceClear;
24900
+ this._image.onload = null;
24901
+ this._image.src = "";
24902
+ this._image = forceClear;
24903
+ }
24904
+ get width() {
24905
+ this.updateText(true);
24906
+ return Math.abs(this.scale.x) * this._image.width / this.resolution;
24907
+ }
24908
+ set width(value) {
24909
+ this.updateText(true);
24910
+ const s = sign(this.scale.x) || 1;
24911
+ this.scale.x = s * value / this._image.width / this.resolution;
24912
+ this._width = value;
24913
+ }
24914
+ get height() {
24915
+ this.updateText(true);
24916
+ return Math.abs(this.scale.y) * this._image.height / this.resolution;
24917
+ }
24918
+ set height(value) {
24919
+ this.updateText(true);
24920
+ const s = sign(this.scale.y) || 1;
24921
+ this.scale.y = s * value / this._image.height / this.resolution;
24922
+ this._height = value;
24923
+ }
24924
+ get style() {
24925
+ return this._style;
24926
+ }
24927
+ set style(style) {
24928
+ if (this._style === style) {
24929
+ return;
24930
+ }
24931
+ style = style || {};
24932
+ if (style instanceof HTMLTextStyle) {
24933
+ this.ownsStyle = false;
24934
+ this._style = style;
24935
+ } else if (style instanceof TextStyle) {
24936
+ console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle");
24937
+ this.ownsStyle = true;
24938
+ this._style = HTMLTextStyle.from(style);
24939
+ } else {
24940
+ this.ownsStyle = true;
24941
+ this._style = new HTMLTextStyle(style);
24942
+ }
24943
+ this.localStyleID = -1;
24944
+ this.dirty = true;
24945
+ }
24946
+ get text() {
24947
+ return this._text;
24948
+ }
24949
+ set text(text) {
24950
+ text = String(text === "" || text === null || text === void 0 ? " " : text);
24951
+ text = this.sanitiseText(text);
24952
+ if (this._text === text) {
24953
+ return;
24954
+ }
24955
+ this._text = text;
24956
+ this.dirty = true;
24957
+ }
24958
+ get resolution() {
24959
+ return this._resolution;
24960
+ }
24961
+ set resolution(value) {
24962
+ this._autoResolution = false;
24963
+ if (this._resolution === value) {
24964
+ return;
24965
+ }
24966
+ this._resolution = value;
24967
+ this.dirty = true;
24968
+ }
24969
+ sanitiseText(text) {
24970
+ return text.replace(/<br>/gi, "<br/>").replace(/<hr>/gi, "<hr/>").replace(/&nbsp;/gi, "&#160;");
24971
+ }
24972
+ };
24973
+ let HTMLText = _HTMLText;
24974
+ HTMLText.defaultDestroyOptions = {
24975
+ texture: true,
24976
+ children: false,
24977
+ baseTexture: true
24978
+ };
24979
+ HTMLText.defaultMaxWidth = 2024;
24980
+ HTMLText.defaultMaxHeight = 2024;
24981
+ HTMLText.defaultAutoResolution = true;
24982
+
24983
+ export { ALPHA_MODES, AbstractMultiResource, AccessibilityManager, AlphaFilter, AnimatedSprite, Application, ArrayResource, Assets, AssetsClass, Attribute, BLEND_MODES, BUFFER_BITS, BUFFER_TYPE, BackgroundSystem, BaseImageResource, BasePrepare, BaseRenderTexture, BaseTexture, BatchDrawCall, BatchGeometry, BatchRenderer, BatchShaderGenerator, BatchSystem, BatchTextureArray, BitmapFont, BitmapFontData, BitmapText, BlobResource, BlurFilter, BlurFilterPass, Bounds, BrowserAdapter, Buffer, BufferResource, BufferSystem, CLEAR_MODES, COLOR_MASK_BITS, Cache, CanvasResource, Circle, Color, ColorMatrixFilter, CompressedTextureResource, Container, ContextSystem, CountLimiter, CubeResource, DEG_TO_RAD, DRAW_MODES, DisplacementFilter, DisplayObject, ENV, Ellipse, EventBoundary, EventSystem, ExtensionType, Extract, FORMATS, FORMATS_TO_COMPONENTS, FXAAFilter, FederatedDisplayObject, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, FillStyle, Filter, FilterState, FilterSystem, Framebuffer, FramebufferSystem, GC_MODES, GLFramebuffer, GLProgram, GLTexture, GRAPHICS_CURVES, GenerateTextureSystem, Geometry, GeometrySystem, Graphics, GraphicsData, GraphicsGeometry, HTMLText, HTMLTextStyle, IGLUniformData, INSTALLED, INTERNAL_FORMATS, INTERNAL_FORMAT_TO_BYTES_PER_PIXEL, ImageBitmapResource, ImageResource, LINE_CAP, LINE_JOIN, LineStyle, LoaderParserPriority, MASK_TYPES, MIPMAP_MODES, MSAA_QUALITY, MaskData, MaskSystem, Matrix, Mesh, MeshBatchUvs, MeshGeometry, MeshMaterial, MultisampleSystem, NineSlicePlane, NoiseFilter, ObjectRenderer, ObjectRendererSystem, ObservablePoint, PI_2, PRECISION, ParticleContainer, ParticleRenderer, PlaneGeometry, PluginSystem, Point, Polygon, Prepare, Program, ProjectionSystem, Quad, QuadUv, RAD_TO_DEG, RENDERER_TYPE, Rectangle, RenderTexture, RenderTexturePool, RenderTextureSystem, Renderer, ResizePlugin, Resource, RopeGeometry, RoundedRectangle, Runner, SAMPLER_TYPES, SCALE_MODES, SHAPES, SVGResource, ScissorSystem, Shader, ShaderSystem, SimpleMesh, SimplePlane, SimpleRope, Sprite, SpriteMaskFilter, Spritesheet, StartupSystem, State, StateSystem, StencilSystem, SystemManager, TARGETS, TEXT_GRADIENT, TYPES, TYPES_TO_BYTES_PER_COMPONENT, TYPES_TO_BYTES_PER_PIXEL, TemporaryDisplayObject, Text, TextFormat, TextMetrics, TextStyle, Texture, TextureGCSystem, TextureMatrix, TextureSystem, TextureUvs, Ticker, TickerPlugin, TilingSprite, TilingSpriteRenderer, TimeLimiter, Transform, TransformFeedback, TransformFeedbackSystem, UPDATE_PRIORITY, UniformGroup, VERSION, VideoResource, ViewSystem, ViewableBuffer, WRAP_MODES, XMLFormat, XMLStringFormat, accessibleTarget, autoDetectFormat, autoDetectRenderer, autoDetectResource, cacheTextureArray, checkDataUrl, checkExtension, checkMaxIfStatementsInShader, convertToList, copySearchParams, createStringVariations, createTexture, createUBOElements, curves, defaultFilterVertex, defaultVertex, detectAvif, detectCompressedTextures, detectDefaults, detectWebp, extensions$1 as extensions, filters, generateProgram, generateUniformBufferSync, getFontFamilyName, getTestContext, getUBOData, graphicsUtils, groupD8, isMobile, isSingleItem, loadBitmapFont, loadDDS, loadImageBitmap, loadJson, loadKTX, loadSVG, loadTextures, loadTxt, loadWebFont, parseDDS, parseKTX, resolveCompressedTextureUrl, resolveTextureUrl, settings, spritesheetAsset, uniformParsers, unsafeEvalSupported, index as utils };
24494
24984
  //# sourceMappingURL=pixi.mjs.map