phaser/src/renderer/BlendModes.js

334 lines
8 KiB
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2020-01-15 12:07:09 +00:00
* @copyright 2020 Photon Storm Ltd.
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.
*
* @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.
*
* @name Phaser.BlendModes.SKIP_CHECK
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.NORMAL
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.ADD
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.MULTIPLY
* @type {integer}
* @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)
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.SCREEN
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.OVERLAY
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.DARKEN
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.LIGHTEN
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.COLOR_DODGE
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.COLOR_BURN
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
2018-02-22 01:17:54 +00:00
* @name Phaser.BlendModes.HARD_LIGHT
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.SOFT_LIGHT
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.DIFFERENCE
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.EXCLUSION
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.HUE
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.SATURATION
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.COLOR
* @type {integer}
* @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.
2018-02-09 13:46:04 +00:00
*
* @name Phaser.BlendModes.LUMINOSITY
* @type {integer}
* @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.
2018-11-10 04:22:13 +00:00
*
* @name Phaser.BlendModes.ERASE
* @type {integer}
* @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.
*
* @name Phaser.BlendModes.SOURCE_IN
* @type {integer}
* @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.
*
* @name Phaser.BlendModes.SOURCE_OUT
* @type {integer}
* @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.
*
* @name Phaser.BlendModes.SOURCE_ATOP
* @type {integer}
* @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.
*
* @name Phaser.BlendModes.DESTINATION_OVER
* @type {integer}
* @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.
*
* @name Phaser.BlendModes.DESTINATION_IN
* @type {integer}
* @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.
*
* @name Phaser.BlendModes.DESTINATION_OUT
* @type {integer}
* @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.
*
* @name Phaser.BlendModes.DESTINATION_ATOP
* @type {integer}
* @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.
*
* @name Phaser.BlendModes.LIGHTER
* @type {integer}
* @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.
*
* @name Phaser.BlendModes.COPY
* @type {integer}
* @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.
*
* @name Phaser.BlendModes.XOR
* @type {integer}
* @const
2019-02-12 12:22:25 +00:00
* @since 3.0.0
2018-11-13 15:10:25 +00:00
*/
XOR: 27
};