phaser4-rex-plugins
Version:
2 lines (1 loc) • 1.35 kB
JavaScript
var t,n;t=void 0,n=function(){var t=function(t){return t>>16&255},n=function(t){return t>>8&255},e=function(t){return 255&t};class r extends Phaser.Plugins.BasePlugin{constructor(t){super(t)}start(){this.game.events.on("destroy",this.destroy,this)}add(r,o){return function(r,o){if(r.hasOwnProperty("tintR"))return r;void 0===o&&(o=16777215);var i=t(o),f=n(o),u=e(o);return Object.defineProperty(r,"tint",{get:function(){return o},set:function(s){s=16777215&Math.floor(s),r.setTint&&r.setTint(s),o!==s&&(i=t(o=s),f=n(o),u=e(o))}}),Object.defineProperty(r,"tintR",{get:function(){return i},set:function(t){t=255&Math.floor(t),i!==t&&(i=t,r.tint=(255&t)<<16|65535&o)}}),Object.defineProperty(r,"tintG",{get:function(){return f},set:function(t){t=255&Math.floor(t),f!==t&&(f=t,r.tint=(255&t)<<8|16711935&o)}}),Object.defineProperty(r,"tintB",{get:function(){return u},set:function(t){t=255&Math.floor(t),u!==t&&(u=t,r.tint=255&t|16776960&o)}}),Object.defineProperty(r,"tintGray",{get:function(){return Math.floor((i+f+u)/3)},set:function(t){t=255&Math.floor(t),i===t&&f===t&&u===t||(i=t,f=t,u=t,r.tint=(255&t)<<16|(255&t)<<8|255&t)}}),r.tint=o,r}(r,o)}}return r},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).rextintrgbplugin=n();