-
Notifications
You must be signed in to change notification settings - Fork 7.1k
/
BlendModes.js
333 lines (301 loc) · 7.94 KB
/
BlendModes.js
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013-2023 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Phaser Blend Modes.
*
* @namespace Phaser.BlendModes
* @since 3.0.0
*/
module.exports = {
/**
* Skips the Blend Mode check in the renderer.
*
* @name Phaser.BlendModes.SKIP_CHECK
* @type {number}
* @const
* @since 3.0.0
*/
SKIP_CHECK: -1,
/**
* Normal blend mode. For Canvas and WebGL.
* This is the default setting and draws new shapes on top of the existing canvas content.
*
* @name Phaser.BlendModes.NORMAL
* @type {number}
* @const
* @since 3.0.0
*/
NORMAL: 0,
/**
* Add blend mode. For Canvas and WebGL.
* Where both shapes overlap the color is determined by adding color values.
*
* @name Phaser.BlendModes.ADD
* @type {number}
* @const
* @since 3.0.0
*/
ADD: 1,
/**
* Multiply blend mode. For Canvas and WebGL.
* The pixels are of the top layer are multiplied with the corresponding pixel of the bottom layer. A darker picture is the result.
*
* @name Phaser.BlendModes.MULTIPLY
* @type {number}
* @const
* @since 3.0.0
*/
MULTIPLY: 2,
/**
* Screen blend mode. For Canvas and WebGL.
* The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply)
*
* @name Phaser.BlendModes.SCREEN
* @type {number}
* @const
* @since 3.0.0
*/
SCREEN: 3,
/**
* Overlay blend mode. For Canvas only.
* A combination of multiply and screen. Dark parts on the base layer become darker, and light parts become lighter.
*
* @name Phaser.BlendModes.OVERLAY
* @type {number}
* @const
* @since 3.0.0
*/
OVERLAY: 4,
/**
* Darken blend mode. For Canvas only.
* Retains the darkest pixels of both layers.
*
* @name Phaser.BlendModes.DARKEN
* @type {number}
* @const
* @since 3.0.0
*/
DARKEN: 5,
/**
* Lighten blend mode. For Canvas only.
* Retains the lightest pixels of both layers.
*
* @name Phaser.BlendModes.LIGHTEN
* @type {number}
* @const
* @since 3.0.0
*/
LIGHTEN: 6,
/**
* Color Dodge blend mode. For Canvas only.
* Divides the bottom layer by the inverted top layer.
*
* @name Phaser.BlendModes.COLOR_DODGE
* @type {number}
* @const
* @since 3.0.0
*/
COLOR_DODGE: 7,
/**
* Color Burn blend mode. For Canvas only.
* Divides the inverted bottom layer by the top layer, and then inverts the result.
*
* @name Phaser.BlendModes.COLOR_BURN
* @type {number}
* @const
* @since 3.0.0
*/
COLOR_BURN: 8,
/**
* Hard Light blend mode. For Canvas only.
* A combination of multiply and screen like overlay, but with top and bottom layer swapped.
*
* @name Phaser.BlendModes.HARD_LIGHT
* @type {number}
* @const
* @since 3.0.0
*/
HARD_LIGHT: 9,
/**
* Soft Light blend mode. For Canvas only.
* A softer version of hard-light. Pure black or white does not result in pure black or white.
*
* @name Phaser.BlendModes.SOFT_LIGHT
* @type {number}
* @const
* @since 3.0.0
*/
SOFT_LIGHT: 10,
/**
* Difference blend mode. For Canvas only.
* Subtracts the bottom layer from the top layer or the other way round to always get a positive value.
*
* @name Phaser.BlendModes.DIFFERENCE
* @type {number}
* @const
* @since 3.0.0
*/
DIFFERENCE: 11,
/**
* Exclusion blend mode. For Canvas only.
* Like difference, but with lower contrast.
*
* @name Phaser.BlendModes.EXCLUSION
* @type {number}
* @const
* @since 3.0.0
*/
EXCLUSION: 12,
/**
* Hue blend mode. For Canvas only.
* Preserves the luma and chroma of the bottom layer, while adopting the hue of the top layer.
*
* @name Phaser.BlendModes.HUE
* @type {number}
* @const
* @since 3.0.0
*/
HUE: 13,
/**
* Saturation blend mode. For Canvas only.
* Preserves the luma and hue of the bottom layer, while adopting the chroma of the top layer.
*
* @name Phaser.BlendModes.SATURATION
* @type {number}
* @const
* @since 3.0.0
*/
SATURATION: 14,
/**
* Color blend mode. For Canvas only.
* Preserves the luma of the bottom layer, while adopting the hue and chroma of the top layer.
*
* @name Phaser.BlendModes.COLOR
* @type {number}
* @const
* @since 3.0.0
*/
COLOR: 15,
/**
* Luminosity blend mode. For Canvas only.
* Preserves the hue and chroma of the bottom layer, while adopting the luma of the top layer.
*
* @name Phaser.BlendModes.LUMINOSITY
* @type {number}
* @const
* @since 3.0.0
*/
LUMINOSITY: 16,
/**
* Alpha erase blend mode. For Canvas and WebGL.
*
* @name Phaser.BlendModes.ERASE
* @type {number}
* @const
* @since 3.0.0
*/
ERASE: 17,
/**
* Source-in blend mode. For Canvas only.
* The new shape is drawn only where both the new shape and the destination canvas overlap. Everything else is made transparent.
*
* @name Phaser.BlendModes.SOURCE_IN
* @type {number}
* @const
* @since 3.0.0
*/
SOURCE_IN: 18,
/**
* Source-out blend mode. For Canvas only.
* The new shape is drawn where it doesn't overlap the existing canvas content.
*
* @name Phaser.BlendModes.SOURCE_OUT
* @type {number}
* @const
* @since 3.0.0
*/
SOURCE_OUT: 19,
/**
* Source-out blend mode. For Canvas only.
* The new shape is only drawn where it overlaps the existing canvas content.
*
* @name Phaser.BlendModes.SOURCE_ATOP
* @type {number}
* @const
* @since 3.0.0
*/
SOURCE_ATOP: 20,
/**
* Destination-over blend mode. For Canvas only.
* New shapes are drawn behind the existing canvas content.
*
* @name Phaser.BlendModes.DESTINATION_OVER
* @type {number}
* @const
* @since 3.0.0
*/
DESTINATION_OVER: 21,
/**
* Destination-in blend mode. For Canvas only.
* The existing canvas content is kept where both the new shape and existing canvas content overlap. Everything else is made transparent.
*
* @name Phaser.BlendModes.DESTINATION_IN
* @type {number}
* @const
* @since 3.0.0
*/
DESTINATION_IN: 22,
/**
* Destination-out blend mode. For Canvas only.
* The existing content is kept where it doesn't overlap the new shape.
*
* @name Phaser.BlendModes.DESTINATION_OUT
* @type {number}
* @const
* @since 3.0.0
*/
DESTINATION_OUT: 23,
/**
* Destination-out blend mode. For Canvas only.
* The existing canvas is only kept where it overlaps the new shape. The new shape is drawn behind the canvas content.
*
* @name Phaser.BlendModes.DESTINATION_ATOP
* @type {number}
* @const
* @since 3.0.0
*/
DESTINATION_ATOP: 24,
/**
* Lighten blend mode. For Canvas only.
* Where both shapes overlap the color is determined by adding color values.
*
* @name Phaser.BlendModes.LIGHTER
* @type {number}
* @const
* @since 3.0.0
*/
LIGHTER: 25,
/**
* Copy blend mode. For Canvas only.
* Only the new shape is shown.
*
* @name Phaser.BlendModes.COPY
* @type {number}
* @const
* @since 3.0.0
*/
COPY: 26,
/**
* Xor blend mode. For Canvas only.
* Shapes are made transparent where both overlap and drawn normal everywhere else.
*
* @name Phaser.BlendModes.XOR
* @type {number}
* @const
* @since 3.0.0
*/
XOR: 27
};