phaser/src/gameobjects/fx/Bloom.js

136 lines
3.4 KiB
JavaScript
Raw Normal View History

2023-02-15 00:50:26 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013-2023 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var BaseFX = require('./BaseFX');
var Class = require('../../utils/Class');
var FX_CONST = require('./const');
/**
* @classdesc
*
* @class Bloom
* @extends Phaser.GameObjects.FX.BaseFX
* @memberof Phaser.GameObjects.FX
* @constructor
* @since 3.60.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - A reference to the Game Object that has this fx.
*/
var Bloom = new Class({
Extends: BaseFX,
initialize:
2023-02-16 22:15:22 +00:00
function Bloom (gameObject, color, offsetX, offsetY, blurStrength, strength, steps)
2023-02-15 00:50:26 +00:00
{
2023-02-16 22:15:22 +00:00
if (offsetX === undefined) { offsetX = 1; }
if (offsetY === undefined) { offsetY = 1; }
if (blurStrength === undefined) { blurStrength = 1; }
if (strength === undefined) { strength = 1; }
if (steps === undefined) { steps = 4; }
2023-02-15 00:50:26 +00:00
BaseFX.call(this, FX_CONST.BLOOM, gameObject);
2023-02-16 22:15:22 +00:00
/**
* The number of steps to run the Bloom effect for.
*
* This value should always be an integer.
*
* It defaults to 4. The higher the value, the smoother the Bloom,
* but at the cost of exponentially more gl operations.
*
* Keep this to the lowest possible number you can have it, while
* still looking correct for your game.
*
* @name Phaser.GameObjects.FX.Bloom#steps
* @type {number}
* @since 3.60.0
*/
this.steps = steps;
/**
* The horizontal offset of the bloom effect.
*
* @name Phaser.GameObjects.FX.Bloom#offsetX
* @type {number}
* @since 3.60.0
*/
this.offsetX = offsetX;
/**
* The vertical offset of the bloom effect.
*
* @name Phaser.GameObjects.FX.Bloom#offsetY
* @type {number}
* @since 3.60.0
*/
this.offsetY = offsetY;
/**
* The strength of the blur process of the bloom effect.
*
* @name Phaser.GameObjects.FX.Bloom#blurStrength
* @type {number}
* @since 3.60.0
*/
this.blurStrength = blurStrength;
/**
* The strength of the blend process of the bloom effect.
*
* @name Phaser.GameObjects.FX.Bloom#strength
* @type {number}
* @since 3.60.0
*/
this.strength = strength;
/**
* The internal gl color array.
*
* @name Phaser.GameObjects.FX.Bloom#glcolor
* @type {number[]}
* @since 3.60.0
*/
2023-02-15 00:50:26 +00:00
this.glcolor = [ 1, 1, 1 ];
2023-02-16 22:15:22 +00:00
if (color !== undefined && color !== null)
{
this.color = color;
}
},
/**
* The color of the bloom as a number value.
*
* @name Phaser.GameObjects.FX.Bloom#color
* @type {number}
* @since 3.60.0
*/
color: {
get: function ()
{
var color = this.glcolor;
return (((color[0] * 255) << 16) + ((color[1] * 255) << 8) + (color[2] * 255 | 0));
},
set: function (value)
{
var color = this.glcolor;
color[0] = ((value >> 16) & 0xFF) / 255;
color[1] = ((value >> 8) & 0xFF) / 255;
color[2] = (value & 0xFF) / 255;
}
2023-02-15 00:50:26 +00:00
}
});
module.exports = Bloom;