forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlendMode.js
More file actions
116 lines (102 loc) · 3.26 KB
/
Copy pathBlendMode.js
File metadata and controls
116 lines (102 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var BlendModes = require('../../renderer/BlendModes');
/**
* Provides methods used for setting the blend mode of a Game Object.
* Should be applied as a mixin and not used directly.
*
* @namespace Phaser.GameObjects.Components.BlendMode
* @since 3.0.0
*/
var BlendMode = {
/**
* Private internal value. Holds the current blend mode.
*
* @name Phaser.GameObjects.Components.BlendMode#_blendMode
* @type {integer}
* @private
* @default 0
* @since 3.0.0
*/
_blendMode: BlendModes.NORMAL,
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency of which blend modes
* are used.
*
* @name Phaser.GameObjects.Components.BlendMode#blendMode
* @type {(Phaser.BlendModes|string)}
* @since 3.0.0
*/
blendMode: {
get: function ()
{
return this._blendMode;
},
set: function (value)
{
if (typeof value === 'string')
{
value = BlendModes[value];
}
value |= 0;
if (value >= -1)
{
this._blendMode = value;
}
}
},
/**
* Sets the Blend Mode being used by this Game Object.
*
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
*
* Under WebGL only the following Blend Modes are available:
*
* * ADD
* * MULTIPLY
* * SCREEN
* * ERASE (only works when rendering to a framebuffer, like a Render Texture)
*
* Canvas has more available depending on browser support.
*
* You can also create your own custom Blend Modes in WebGL.
*
* Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending
* on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these
* reasons try to be careful about the construction of your Scene and the frequency in which blend modes
* are used.
*
* @method Phaser.GameObjects.Components.BlendMode#setBlendMode
* @since 3.0.0
*
* @param {(string|Phaser.BlendModes)} value - The BlendMode value. Either a string or a CONST.
*
* @return {this} This Game Object instance.
*/
setBlendMode: function (value)
{
this.blendMode = value;
return this;
}
};
module.exports = BlendMode;