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
    Destination pixels covered by the source are cleared to 0.
    Replaces hue and saturation of destination with hue and saturation of source, leaving luminosity unchanged.
    Makes destination darker to reflect source.
    Makes destination brighter to reflect source.
    Retains the smallest component of the source and destination pixels.
    Similar to DARKEN, but darkens on the composite channel, instead of separate RGB color channels.
    Subtracts darker from lighter with higher contrast.
    Divides the destination pixels by the source pixels and saturates the result.
    The source pixels are discarded, leaving the destination intact.
    Discards the destination pixels that are not covered by source pixels.
    Keeps the destination pixels that cover source pixels, discards the remaining source and destination pixels.
    Keeps the destination pixels that are not covered by source pixels.
    The source pixels are drawn behind the destination pixels.
    Subtracts darker from lighter with lower contrast.
    Makes destination lighter or darker, depending on source.
    Adds two images together, setting each color channel value to either 0 or 1.
    Replaces hue of destination with hue of source, leaving saturation and luminosity unchanged.
    Retains the largest component of the source and destination pixel.
    Similar to LIGHTEN, but lightens on the composite channel, instead of separate RGB color channels.
    Darkens the destination pixels to reflect the source pixels while also increasing contrast.
    Lightens the destination pixels to reflect the source pixels while also increasing contrast.
    Burns or dodges colors by changing brightness, depending on the blend color.
    Replaces luminosity of destination with luminosity of source, leaving hue and saturation unchanged.
    Subtracts the source pixels from the destination pixels, without alpha blending.
    Subtracts the source pixels from the destination pixels and saturates the result, without alpha blending.
    Multiplies the source and destination pixels.
    Multiplies the source and destination pixels. This is MODULATE with alpha blending.
    Multiplies or screens the source and destination depending on the destination color.
    Conditionally replaces destination pixels with source pixels depending on the brightness of the source pixels.
    Adds the source pixels to the destination pixels. For floating-point textures, color components may be greater than 1.0.
    Adds the source pixels to the destination pixels and saturates the result. For unsigned fixed-point textures, this is the same as PLUS.
    Replaces saturation of destination saturation hue of source, leaving hue and luminosity unchanged.
    Adds the source and destination pixels, then subtracts the source pixels multiplied by the destination.
    Makes destination lighter or darker, depending on source.
    The source pixels replace the destination pixels.
    Discards the source pixels that do not cover destination pixels.
    Keeps the source pixels that cover the destination pixels, discards the remaining source and destination pixels.
    Keeps the source pixels that do not cover destination pixels.
    The source pixels are drawn over the destination pixels.
    Subtracts the source pixels from the destination pixels and saturates the result, with alpha blending.
    Burns or dodges colors by changing contrast, depending on the blend color.
    Discards the source and destination pixels where source pixels cover destination pixels.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BlendMode
    Name alias of LINEAR_DODGE.
  • Method Summary

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

    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

      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:
    • 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

      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:
    • MODULATE

      public static final BlendMode MODULATE

      Multiplies the source and destination pixels.

      aout = asrc * adst

      Cout = Csrc * Cdst

      See Also:
    • 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:
    • 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:
    • 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:
    • 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

  • 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