Package icyllis.modernui.graphics

# Enum Class BlendMode

java.lang.Object
java.lang.Enum<BlendMode>
icyllis.modernui.graphics.BlendMode

All Implemented Interfaces:
  `Serializable`, `Comparable<BlendMode>`, `Constable`

public enum BlendMode extends Enum<BlendMode>
Blends are operators that take in two colors (source, destination) and return a new color. Many of these operate the same on all 4 components: red, green, blue, alpha. For these, we just document what happens to one component, rather than naming each one separately.

Since:
  3.0

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class java.lang.Enum

  `Enum.EnumDesc<E extends Enum<E>>`

- ## Enum Constant Summary

  Enum Constants
  Enum Constant
  Description
  `CLEAR`
  Destination pixels covered by the source are cleared to 0.
  `COLOR`
  Replaces hue and saturation of destination with hue and saturation of source, leaving luminosity unchanged.
  `COLOR_BURN`
  Makes destination darker to reflect source.
  `COLOR_DODGE`
  Makes destination brighter to reflect source.
  `DARKEN`
  Retains the smallest component of the source and destination pixels.
  `DARKER_COLOR`
  Similar to `DARKEN`, but darkens on the composite channel, instead of separate RGB color channels.
  `DIFFERENCE`
  Subtracts darker from lighter with higher contrast.
  `DIVIDE`
  Divides the destination pixels by the source pixels and saturates the result.
  `DST`
  The source pixels are discarded, leaving the destination intact.
  `DST_ATOP`
  Discards the destination pixels that are not covered by source pixels.
  `DST_IN`
  Keeps the destination pixels that cover source pixels, discards the remaining source and destination pixels.
  `DST_OUT`
  Keeps the destination pixels that are not covered by source pixels.
  `DST_OVER`
  The source pixels are drawn behind the destination pixels.
  `EXCLUSION`
  Subtracts darker from lighter with lower contrast.
  `HARD_LIGHT`
  Makes destination lighter or darker, depending on source.
  `HARD_MIX`
  Adds two images together, setting each color channel value to either 0 or 1.
  `HUE`
  Replaces hue of destination with hue of source, leaving saturation and luminosity unchanged.
  `LIGHTEN`
  Retains the largest component of the source and destination pixel.
  `LIGHTER_COLOR`
  Similar to `LIGHTEN`, but lightens on the composite channel, instead of separate RGB color channels.
  `LINEAR_BURN`
  Darkens the destination pixels to reflect the source pixels while also increasing contrast.
  `LINEAR_DODGE`
  Lightens the destination pixels to reflect the source pixels while also increasing contrast.
  `LINEAR_LIGHT`
  Burns or dodges colors by changing brightness, depending on the blend color.
  `LUMINOSITY`
  Replaces luminosity of destination with luminosity of source, leaving hue and saturation unchanged.
  `MINUS`
  Subtracts the source pixels from the destination pixels, without alpha blending.
  `MINUS_CLAMPED`
  Subtracts the source pixels from the destination pixels and saturates the result, without alpha blending.
  `MODULATE`
  Multiplies the source and destination pixels.
  `MULTIPLY`
  Multiplies the source and destination pixels. This is `MODULATE` with alpha blending.
  `OVERLAY`
  Multiplies or screens the source and destination depending on the destination color.
  `PIN_LIGHT`
  Conditionally replaces destination pixels with source pixels depending on the brightness of the source pixels.
  `PLUS`
  Adds the source pixels to the destination pixels. For floating-point textures, color components may be greater than 1.0.
  `PLUS_CLAMPED`
  Adds the source pixels to the destination pixels and saturates the result. For unsigned fixed-point textures, this is the same as `PLUS`.
  `SATURATION`
  Replaces saturation of destination saturation hue of source, leaving hue and luminosity unchanged.
  `SCREEN`
  Adds the source and destination pixels, then subtracts the source pixels multiplied by the destination.
  `SOFT_LIGHT`
  Makes destination lighter or darker, depending on source.
  `SRC`
  The source pixels replace the destination pixels.
  `SRC_ATOP`
  Discards the source pixels that do not cover destination pixels.
  `SRC_IN`
  Keeps the source pixels that cover the destination pixels, discards the remaining source and destination pixels.
  `SRC_OUT`
  Keeps the source pixels that do not cover destination pixels.
  `SRC_OVER`
  The source pixels are drawn over the destination pixels.
  `SUBTRACT`
  Subtracts the source pixels from the destination pixels and saturates the result, with alpha blending.
  `VIVID_LIGHT`
  Burns or dodges colors by changing contrast, depending on the blend color.
  `XOR`
  Discards the source and destination pixels where source pixels cover destination pixels.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final BlendMode`
  `ADD`
  Name alias of `LINEAR_DODGE`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static BlendMode`
  `valueOf(String name)`
  Returns the enum constant of this class with the specified name.
  `static BlendMode[]`
  `values()`
  Returns an array containing the constants of this enum class, in the order they are declared.

  ### Methods inherited from class java.lang.Enum

  `clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

  ### Methods inherited from class java.lang.Object

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Enum Constant Details

  - ### CLEAR

    public static final BlendMode CLEAR

    Destination pixels covered by the source are cleared to 0.

    aout = 0

    Cout = 0

  - ### SRC

    public static final BlendMode SRC

    The source pixels replace the destination pixels.

    aout = asrc

    Cout = Csrc

  - ### DST

    public static final BlendMode DST

    The source pixels are discarded, leaving the destination intact.

    aout = adst

    Cout = Cdst

  - ### SRC_OVER

    public static final BlendMode SRC_OVER

    The source pixels are drawn over the destination pixels.

    aout = asrc + (1 - asrc) * adst

    Cout = Csrc + (1 - asrc) * Cdst

  - ### DST_OVER

    public static final BlendMode DST_OVER

    The source pixels are drawn behind the destination pixels.

    aout = adst + (1 - adst) * asrc

    Cout = Cdst + (1 - adst) * Csrc

  - ### SRC_IN

    public static final BlendMode SRC_IN

    Keeps the source pixels that cover the destination pixels, discards the remaining source and destination pixels.

    aout = asrc * adst

    Cout = Csrc * adst

  - ### DST_IN

    public static final BlendMode DST_IN

    Keeps the destination pixels that cover source pixels, discards the remaining source and destination pixels.

    aout = adst * asrc

    Cout = Cdst * asrc

  - ### SRC_OUT

    public static final BlendMode SRC_OUT

    Keeps the source pixels that do not cover destination pixels. Discards source pixels that cover destination pixels. Discards all destination pixels.

    aout = (1 - adst) * asrc

    Cout = (1 - adst) * Csrc

  - ### DST_OUT

    public static final BlendMode DST_OUT

    Keeps the destination pixels that are not covered by source pixels. Discards destination pixels that are covered by source pixels. Discards all source pixels.

    aout = (1 - asrc) * adst

    Cout = (1 - asrc) * Cdst

  - ### SRC_ATOP

    public static final BlendMode SRC_ATOP

    Discards the source pixels that do not cover destination pixels. Draws remaining source pixels over destination pixels.

    aout = adst

    Cout = adst * Csrc + (1 - asrc) * Cdst

  - ### DST_ATOP

    public static final BlendMode DST_ATOP

    Discards the destination pixels that are not covered by source pixels. Draws remaining destination pixels over source pixels.

    aout = asrc

    Cout = asrc * Cdst + (1 - adst) * Csrc

  - ### XOR

    public static final BlendMode XOR

    Discards the source and destination pixels where source pixels cover destination pixels. Draws remaining source pixels.

    aout = (1 - adst) * asrc + (1 - asrc) * adst

    Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

  - ### PLUS

    public static final BlendMode PLUS

    Adds the source pixels to the destination pixels.
    For floating-point textures, color components may be greater than 1.0.

    aout = asrc + adst

    Cout = Csrc + Cdst

    See Also:
      - `PLUS_CLAMPED`
      - `LINEAR_DODGE`

  - ### PLUS_CLAMPED

    public static final BlendMode PLUS_CLAMPED

    Adds the source pixels to the destination pixels and saturates the result.
    For unsigned fixed-point textures, this is the same as `PLUS`. This is an advanced blend equation.

    aout = max(0, min(asrc + adst, 1))

    Cout = max(0, min(Csrc + Cdst, 1))

    See Also:
      - `PLUS`
      - `LINEAR_DODGE`

  - ### MINUS

    public static final BlendMode MINUS

    Subtracts the source pixels from the destination pixels, without alpha blending. For floating-point textures, color components may be less than 0.0.

    aout = adst - asrc

    Cout = Cdst - Csrc

    See Also:
      - `MINUS_CLAMPED`
      - `SUBTRACT`

  - ### MINUS_CLAMPED

    public static final BlendMode MINUS_CLAMPED

    Subtracts the source pixels from the destination pixels and saturates the result, without alpha blending. For unsigned fixed-point textures, this is the same as `MINUS`. This is an advanced blend equation.

    aout = max(0, min(adst - asrc, 1))

    Cout = max(0, min(Cdst - Csrc, 1))

    See Also:
      - `MINUS`
      - `SUBTRACT`

  - ### MODULATE

    public static final BlendMode MODULATE

    Multiplies the source and destination pixels.

    aout = asrc * adst

    Cout = Csrc * Cdst

    See Also:
      - `MULTIPLY`

  - ### MULTIPLY

    public static final BlendMode MULTIPLY

    Multiplies the source and destination pixels.
    This is `MODULATE` with alpha blending. If both the source and destination are opaque, then this is the same as `MODULATE`. This is an advanced blend equation.

    aout = asrc + adst - asrc * adst

    Cout = Csrc * Cdst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    See Also:
      - `MODULATE`

  - ### SCREEN

    public static final BlendMode SCREEN

    Adds the source and destination pixels, then subtracts the source pixels multiplied by the destination.

    aout = asrc + adst - asrc * adst

    Cout = Csrc + Cdst - Csrc * Cdst

  - ### OVERLAY

    public static final BlendMode OVERLAY

    Multiplies or screens the source and destination depending on the destination color.

    aout = asrc + adst - asrc * adst

    if Cdst ≤ 0.5 * adst:
    Cout = 2 * Csrc * Cdst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    otherwise:
    Cout = asrc * adst - 2 * (asrc - Csrc) * (adst - Cdst) + (1 - adst) * Csrc + (1 - asrc) * Cdst

  - ### DARKEN

    public static final BlendMode DARKEN

    Retains the smallest component of the source and destination pixels.

    aout = asrc + adst - asrc * adst

    Cout = min(Csrc, Cdst) + (1 - adst) * Csrc + (1 - asrc) * Cdst

  - ### LIGHTEN

    public static final BlendMode LIGHTEN

    Retains the largest component of the source and destination pixel.

    aout = asrc + adst - asrc * adst

    Cout = max(Csrc, Cdst) + (1 - adst) * Csrc + (1 - asrc) * Cdst

  - ### COLOR_DODGE

    public static final BlendMode COLOR_DODGE

    Makes destination brighter to reflect source.

    aout = asrc + adst - asrc * adst

    if Cdst ≤ 0:
    Cout = Csrc * (1 - adst)

    if Csrc ≥ asrc:
    Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    otherwise:
    Cout = asrc * min(adst, Cdst * asrc / (asrc - Csrc)) + (1 - adst) * Csrc + (1 - asrc) * Cdst

  - ### COLOR_BURN

    public static final BlendMode COLOR_BURN

    Makes destination darker to reflect source.

    aout = asrc + adst - asrc * adst

    if Cdst ≥ adst:
    Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    if Csrc ≤ 0:
    Cout = Csrc * (1 - adst)

    otherwise:
    Cout = asrc * (adst - min(adst, (adst - Cdst) * asrc / Cdst)) + (1 - adst) * Csrc + (1 - asrc) * Cdst

  - ### HARD_LIGHT

    public static final BlendMode HARD_LIGHT

    Makes destination lighter or darker, depending on source.

    aout = asrc + adst - asrc * adst

    if Csrc ≤ 0.5 * asrc:
    Cout = 2 * Csrc * Cdst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    otherwise:
    Cout = asrc * adst - 2 * (asrc - Csrc) * (adst - Cdst) + (1 - adst) * Csrc + (1 - asrc) * Cdst

  - ### SOFT_LIGHT

    public static final BlendMode SOFT_LIGHT

    Makes destination lighter or darker, depending on source.

    aout = asrc + adst - asrc * adst

    if Csrc ≤ 0.5 * asrc:
    Cout = Cdst * Cdst * (asrc - 2 * Csrc) / adst + (1 - adst) * Csrc + Cdst * (2 * Csrc + 1 - asrc)

    if Cdst ≤ 0.25 * adst:
    Cout = (adst * adst * (Csrc + Cdst * (6 * Csrc - 3 * asrc + 1)) + 12 * adst * Cdst * Cdst * (asrc - 2 * Csrc) - 16 * Cdst * Cdst * Cdst * (asrc - 2 * Csrc) - adst * adst * adst * Csrc) / adst * adst

    otherwise:
    Cout = Cdst * (asrc - 2 * Csrc + 1) + Csrc * (1 - adst) - sqrt(Cdst * adst) * (asrc - 2 * Csrc)

  - ### DIFFERENCE

    public static final BlendMode DIFFERENCE

    Subtracts darker from lighter with higher contrast.

    aout = asrc + adst - asrc * adst

    Cout = Csrc + Cdst - 2 * min(Csrc * adst, Cdst * asrc)

  - ### EXCLUSION

    public static final BlendMode EXCLUSION

    Subtracts darker from lighter with lower contrast.

    aout = asrc + adst - asrc * adst

    Cout = Csrc + Cdst - 2 * Csrc * Cdst

  - ### SUBTRACT

    public static final BlendMode SUBTRACT

    Subtracts the source pixels from the destination pixels and saturates the result, with alpha blending. If both the source and destination are opaque, then this is the same as `MINUS_CLAMPED`. This is a custom blend equation.

    aout = asrc + adst - asrc * adst

    if Cdst / adst - Csrc / asrc ≥ 0:
    Cout = Csrc + Cdst - 2 * Csrc * adst

    otherwise:
    Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

    See Also:
      - `MINUS`
      - `MINUS_CLAMPED`

  - ### DIVIDE

    public static final BlendMode DIVIDE

    Divides the destination pixels by the source pixels and saturates the result. For negative and NaN values, the result color is black (XOR). This is a custom blend equation.

    aout = asrc + adst - asrc * adst

    Cout = pin((Cdst * asrc) / (Csrc * adst), 0, 1) * asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

  - ### LINEAR_DODGE

    public static final BlendMode LINEAR_DODGE

    Lightens the destination pixels to reflect the source pixels while also increasing contrast. This is `PLUS_CLAMPED` with alpha blending. If both the source and destination are opaque, then this is the same as `PLUS_CLAMPED`. This is an extended advanced blend equation.

    aout = asrc + adst - asrc * adst

    if Csrc / asrc + Cdst / adst ≤ 1:
    Cout = Csrc + Cdst

    otherwise:
    Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    See Also:
      - `PLUS`
      - `PLUS_CLAMPED`

  - ### LINEAR_BURN

    public static final BlendMode LINEAR_BURN

    Darkens the destination pixels to reflect the source pixels while also increasing contrast. This is an extended advanced blend equation.

    aout = asrc + adst - asrc * adst

    if Csrc / asrc + Cdst / adst > 1:
    Cout = Csrc + Cdst - asrc * adst

    otherwise:
    Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

  - ### VIVID_LIGHT

    public static final BlendMode VIVID_LIGHT

    Burns or dodges colors by changing contrast, depending on the blend color. This is an extended advanced blend equation.

    aout = asrc + adst - asrc * adst

    if Csrc ≤ 0:
    Cout = Cdst * (1 - asrc)

    if Csrc < 0.5 * asrc:
    Cout = asrc * (adst - min(adst, (adst - Cdst) * asrc / (2 * Cdst))) + (1 - adst) * Csrc + (1 - asrc) * Cdst

    if Csrc ≥ asrc:
    Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    otherwise:
    Cout = asrc * min(adst, Cdst * asrc / (2 * (asrc - Csrc))) + (1 - adst) * Csrc + (1 - asrc) * Cdst

  - ### LINEAR_LIGHT

    public static final BlendMode LINEAR_LIGHT

    Burns or dodges colors by changing brightness, depending on the blend color. This is an extended advanced blend equation.

    aout = asrc + adst - asrc * adst

    if 2 * Csrc / asrc + Cdst / adst > 2:
    Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    if 2 * Csrc / asrc + Cdst / adst ≤ 1:
    Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

    otherwise:
    Cout = 2 * Csrc * adst + Cdst * asrc - asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

  - ### PIN_LIGHT

    public static final BlendMode PIN_LIGHT

    Conditionally replaces destination pixels with source pixels depending on the brightness of the source pixels. This is an extended advanced blend equation.

    aout = asrc + adst - asrc * adst

    if 2 * Csrc / asrc - Cdst / adst > 1 && Csrc < 0.5 * asrc:
    Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

    if 2 * Csrc / asrc - Cdst / adst > 1 && Csrc ≥ 0.5 * asrc:
    Cout = 2 * Csrc * adst - asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    if 2 * Csrc / asrc - Cdst / adst ≤ 1 && Csrc * adst < 0.5 * Cdst * asrc:
    Cout = 2 * Csrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

    otherwise:
    Cout = Cdst * asrc + (1 - adst) * Csrc + (1 - asrc) * Cdst

  - ### HARD_MIX

    public static final BlendMode HARD_MIX

    Adds two images together, setting each color channel value to either 0 or 1. This is an extended advanced blend equation.

    aout = asrc + adst - asrc * adst

    if Csrc / asrc + Cdst / adst < 1:
    Cout = (1 - adst) * Csrc + (1 - asrc) * Cdst

    otherwise:
    Cout = asrc * adst + (1 - adst) * Csrc + (1 - asrc) * Cdst

  - ### DARKER_COLOR

    public static final BlendMode DARKER_COLOR

    Similar to `DARKEN`, but darkens on the composite channel, instead of separate RGB color channels. It compares the source and destination color, and keep the one with lower luminosity between the two.

    if lum(Csrc) ≤ lum(Cdst):
    Equivalent to `SRC_OVER`

    otherwise:
    Equivalent to `DST_OVER`

  - ### LIGHTER_COLOR

    public static final BlendMode LIGHTER_COLOR

    Similar to `LIGHTEN`, but lightens on the composite channel, instead of separate RGB color channels. It compares the source and destination color, and keep the one with higher luminosity between the two.

    if lum(Csrc) ≥ lum(Cdst):
    Equivalent to `SRC_OVER`

    otherwise:
    Equivalent to `DST_OVER`

  - ### HUE

    public static final BlendMode HUE

    Replaces hue of destination with hue of source, leaving saturation and luminosity unchanged.

  - ### SATURATION

    public static final BlendMode SATURATION

    Replaces saturation of destination saturation hue of source, leaving hue and luminosity unchanged.

  - ### COLOR

    public static final BlendMode COLOR

    Replaces hue and saturation of destination with hue and saturation of source, leaving luminosity unchanged.

  - ### LUMINOSITY

    public static final BlendMode LUMINOSITY

    Replaces luminosity of destination with luminosity of source, leaving hue and saturation unchanged.

- ## Field Details

  - ### ADD

    public static final BlendMode ADD
    Name alias of `LINEAR_DODGE`.

- ## Method Details

  - ### values

    public static BlendMode[] values()
    Returns an array containing the constants of this enum class, in the order they are declared.
    Returns:
      an array containing the constants of this enum class, in the order they are declared

  - ### valueOf

    public static BlendMode valueOf(String name)
    Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
    Parameters:
      `name` - the name of the enum constant to be returned.
    Returns:
      the enum constant with the specified name
    Throws:
      `IllegalArgumentException` - if this enum class has no constant with the specified name
      `NullPointerException` - if the argument is null