phaser/src/renderer/BlendModes.js

334 lines
7.9 KiB
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@phaser.io>
* @copyright 2013-2024 Phaser Studio Inc.
2019-05-10 15:15:04 +00:00
* @license {@link https://opensource.org/licenses/MIT|MIT License}
2018-02-12 16:01:20 +00:00
*/
2018-02-09 13:46:04 +00:00
/**
2018-03-29 15:42:20 +00:00
* Phaser Blend Modes.
2022-02-28 14:29:51 +00:00
*
* @namespace Phaser.BlendModes
2018-03-29 15:42:20 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
module.exports = {
2018-02-09 13:46:04 +00:00
/**
* Skips the Blend Mode check in the renderer.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.SKIP_CHECK
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
2017-10-17 03:17:04 +00:00
SKIP_CHECK: -1,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* Normal blend mode. For Canvas and WebGL.
* This is the default setting and draws new shapes on top of the existing canvas content.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.NORMAL
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
NORMAL: 0,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* Add blend mode. For Canvas and WebGL.
* Where both shapes overlap the color is determined by adding color values.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.ADD
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
ADD: 1,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* 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.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.MULTIPLY
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
MULTIPLY: 2,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* Screen blend mode. For Canvas and WebGL.
* The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply)
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.SCREEN
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
SCREEN: 3,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* 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.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.OVERLAY
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
OVERLAY: 4,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* Darken blend mode. For Canvas only.
* Retains the darkest pixels of both layers.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.DARKEN
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
DARKEN: 5,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* Lighten blend mode. For Canvas only.
* Retains the lightest pixels of both layers.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.LIGHTEN
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
LIGHTEN: 6,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* Color Dodge blend mode. For Canvas only.
* Divides the bottom layer by the inverted top layer.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.COLOR_DODGE
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
COLOR_DODGE: 7,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* Color Burn blend mode. For Canvas only.
* Divides the inverted bottom layer by the top layer, and then inverts the result.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.COLOR_BURN
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
COLOR_BURN: 8,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* Hard Light blend mode. For Canvas only.
* A combination of multiply and screen like overlay, but with top and bottom layer swapped.
2022-02-28 14:29:51 +00:00
*
2018-02-22 01:17:54 +00:00
* @name Phaser.BlendModes.HARD_LIGHT
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
HARD_LIGHT: 9,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* 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.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.SOFT_LIGHT
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
SOFT_LIGHT: 10,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* 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.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.DIFFERENCE
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
DIFFERENCE: 11,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* Exclusion blend mode. For Canvas only.
* Like difference, but with lower contrast.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.EXCLUSION
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
EXCLUSION: 12,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* Hue blend mode. For Canvas only.
* Preserves the luma and chroma of the bottom layer, while adopting the hue of the top layer.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.HUE
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
HUE: 13,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* Saturation blend mode. For Canvas only.
* Preserves the luma and hue of the bottom layer, while adopting the chroma of the top layer.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.SATURATION
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
SATURATION: 14,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* Color blend mode. For Canvas only.
* Preserves the luma of the bottom layer, while adopting the hue and chroma of the top layer.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.COLOR
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
COLOR: 15,
2018-02-09 13:46:04 +00:00
/**
2018-11-13 15:10:25 +00:00
* Luminosity blend mode. For Canvas only.
* Preserves the hue and chroma of the bottom layer, while adopting the luma of the top layer.
2022-02-28 14:29:51 +00:00
*
2018-02-09 13:46:04 +00:00
* @name Phaser.BlendModes.LUMINOSITY
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-02-09 13:46:04 +00:00
*/
2018-11-10 04:22:13 +00:00
LUMINOSITY: 16,
/**
2018-11-13 15:10:25 +00:00
* Alpha erase blend mode. For Canvas and WebGL.
2022-02-28 14:29:51 +00:00
*
2018-11-10 04:22:13 +00:00
* @name Phaser.BlendModes.ERASE
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-11-10 04:22:13 +00:00
*/
2018-11-13 15:10:25 +00:00
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.
2022-02-28 14:29:51 +00:00
*
2018-11-13 15:10:25 +00:00
* @name Phaser.BlendModes.SOURCE_IN
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-11-13 15:10:25 +00:00
*/
SOURCE_IN: 18,
/**
* Source-out blend mode. For Canvas only.
* The new shape is drawn where it doesn't overlap the existing canvas content.
2022-02-28 14:29:51 +00:00
*
2018-11-13 15:10:25 +00:00
* @name Phaser.BlendModes.SOURCE_OUT
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-11-13 15:10:25 +00:00
*/
SOURCE_OUT: 19,
/**
* Source-out blend mode. For Canvas only.
* The new shape is only drawn where it overlaps the existing canvas content.
2022-02-28 14:29:51 +00:00
*
2018-11-13 15:10:25 +00:00
* @name Phaser.BlendModes.SOURCE_ATOP
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-11-13 15:10:25 +00:00
*/
SOURCE_ATOP: 20,
/**
* Destination-over blend mode. For Canvas only.
* New shapes are drawn behind the existing canvas content.
2022-02-28 14:29:51 +00:00
*
2018-11-13 15:10:25 +00:00
* @name Phaser.BlendModes.DESTINATION_OVER
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-11-13 15:10:25 +00:00
*/
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.
2022-02-28 14:29:51 +00:00
*
2018-11-13 15:10:25 +00:00
* @name Phaser.BlendModes.DESTINATION_IN
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-11-13 15:10:25 +00:00
*/
DESTINATION_IN: 22,
/**
* Destination-out blend mode. For Canvas only.
* The existing content is kept where it doesn't overlap the new shape.
2022-02-28 14:29:51 +00:00
*
2018-11-13 15:10:25 +00:00
* @name Phaser.BlendModes.DESTINATION_OUT
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-11-13 15:10:25 +00:00
*/
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.
2022-02-28 14:29:51 +00:00
*
2018-11-13 15:10:25 +00:00
* @name Phaser.BlendModes.DESTINATION_ATOP
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-11-13 15:10:25 +00:00
*/
DESTINATION_ATOP: 24,
/**
* Lighten blend mode. For Canvas only.
* Where both shapes overlap the color is determined by adding color values.
2022-02-28 14:29:51 +00:00
*
2018-11-13 15:10:25 +00:00
* @name Phaser.BlendModes.LIGHTER
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-11-13 15:10:25 +00:00
*/
LIGHTER: 25,
/**
* Copy blend mode. For Canvas only.
* Only the new shape is shown.
2022-02-28 14:29:51 +00:00
*
2018-11-13 15:10:25 +00:00
* @name Phaser.BlendModes.COPY
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-11-13 15:10:25 +00:00
*/
COPY: 26,
/**
* Xor blend mode. For Canvas only.
2018-11-13 15:10:25 +00:00
* Shapes are made transparent where both overlap and drawn normal everywhere else.
2022-02-28 14:29:51 +00:00
*
2018-11-13 15:10:25 +00:00
* @name Phaser.BlendModes.XOR
2020-11-23 10:22:13 +00:00
* @type {number}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-11-13 15:10:25 +00:00
*/
XOR: 27
};