Class Rgba

java.lang.Object
dev.jaxydog.astral.utility.color.Rgb
dev.jaxydog.astral.utility.color.Rgba

public class Rgba extends Rgb
Stores and allows for the manipulation of an RGBA value.
Since:
2.0.0
  • Constructor Details

    • Rgba

      public Rgba(int red, int green, int blue, int alpha)
      Creates a new RGBA value.

      The provided values are expected to be within a range of [0, 255]. If a value exceeds this, it will be clamped.

      Parameters:
      red - The red component.
      green - The green component.
      blue - The blue component.
      alpha - The alpha component.
      Since:
      2.0.0
    • Rgba

      public Rgba(double red, double green, double blue, double alpha)
      Creates a new RGBA value.

      The provided values are expected to be within a range of [0, 1]. If a value exceed this, it will be clamped.

      Parameters:
      red - The red component.
      green - The green component.
      blue - The blue component.
      alpha - The alpha component.
      Since:
      2.0.0
    • Rgba

      public Rgba(int rgba)
      Creates a new RGBA value.
      Parameters:
      rgba - The color as an integer.
      Since:
      2.0.0
    • Rgba

      public Rgba(Rgb rgb, int alpha)
      Creates a new RGBA value.
      Parameters:
      rgb - The RBG value.
      alpha - The alpha component.
      Since:
      2.0.0
    • Rgba

      public Rgba(Rgb rgb, double alpha)
      Creates a new RGBA value.
      Parameters:
      rgb - The RBG value.
      alpha - The alpha component.
      Since:
      2.0.0
  • Method Details

    • alpha

      public int alpha()
      Returns the color's alpha component.
      Returns:
      The alpha component.
      Since:
      2.0.0
    • alphaScaled

      public double alphaScaled()
      Returns the color's alpha component, scaled between the range [0, 1].
      Returns:
      The alpha component.
      Since:
      2.0.0
    • withAlpha

      public Rgba withAlpha(int alpha)
      Sets the color's alpha component.

      The given hue should be within a range of [0, 255]. If the value exceeds this, it will be clamped.

      Parameters:
      alpha - The new alpha component.
      Returns:
      A new color.
      Since:
      2.0.0
    • withAlpha

      public Rgba withAlpha(double alpha)
      Sets the color's alpha component.

      The given hue should be within a range of [0, 1]. If the value exceeds this, it will be clamped.

      Parameters:
      alpha - The new alpha component.
      Returns:
      A new color.
      Since:
      2.0.0
    • mix

      public Rgba mix(Rgba other, IntBinaryOperator mix)
      Mixes two colors together by combining their color components.
      Parameters:
      other - The other color.
      mix - The mixing method.
      Returns:
      A new, mixed color.
      Since:
      2.0.0
    • integer

      public int integer()
      Description copied from class: Rgb
      Returns the color as an integer.
      Overrides:
      integer in class Rgb
      Returns:
      The color.
    • withRed

      public Rgba withRed(int red)
      Description copied from class: Rgb
      Sets the color's red component.

      The given hue should be within a range of [0, 255]. If the value exceeds this, it will be clamped.

      Overrides:
      withRed in class Rgb
      Parameters:
      red - The new red component.
      Returns:
      A new color.
    • withRed

      public Rgba withRed(double red)
      Description copied from class: Rgb
      Sets the color's red component.

      The given hue should be within a range of [0, 1]. If the value exceeds this, it will be clamped.

      Overrides:
      withRed in class Rgb
      Parameters:
      red - The new red component.
      Returns:
      A new color.
    • withGreen

      public Rgba withGreen(int green)
      Description copied from class: Rgb
      Sets the color's green component.

      The given hue should be within a range of [0, 255]. If the value exceeds this, it will be clamped.

      Overrides:
      withGreen in class Rgb
      Parameters:
      green - The new green component.
      Returns:
      A new color.
    • withGreen

      public Rgba withGreen(double green)
      Description copied from class: Rgb
      Sets the color's green component.

      The given hue should be within a range of [0, 1]. If the value exceeds this, it will be clamped.

      Overrides:
      withGreen in class Rgb
      Parameters:
      green - The new green component.
      Returns:
      A new color.
    • withBlue

      public Rgba withBlue(int blue)
      Description copied from class: Rgb
      Sets the color's blue component.

      The given hue should be within a range of [0, 255]. If the value exceeds this, it will be clamped.

      Overrides:
      withBlue in class Rgb
      Parameters:
      blue - The new blue component.
      Returns:
      A new color.
    • withBlue

      public Rgba withBlue(double blue)
      Description copied from class: Rgb
      Sets the color's blue component.

      The given hue should be within a range of [0, 1]. If the value exceeds this, it will be clamped.

      Overrides:
      withBlue in class Rgb
      Parameters:
      blue - The new blue component.
      Returns:
      A new color.
    • withHue

      public Rgba withHue(float hue)
      Description copied from class: Rgb
      Sets the color's hue.

      The given hue should be within a range of [0, 1]. If the value exceeds this, it will be wrapped.

      Overrides:
      withHue in class Rgb
      Parameters:
      hue - The new hue.
      Returns:
      A new color.
    • withSaturation

      public Rgba withSaturation(float saturation)
      Description copied from class: Rgb
      Sets the color's saturation.

      The given saturation should be within a range of [0, 1]. If the value exceeds this, it will be wrapped.

      Overrides:
      withSaturation in class Rgb
      Parameters:
      saturation - The new saturation.
      Returns:
      A new color.
    • withBrightness

      public Rgba withBrightness(float brightness)
      Description copied from class: Rgb
      Sets the color's brightness.

      The given brightness should be within a range of [0, 1]. If the value exceeds this, it will be wrapped.

      Overrides:
      withBrightness in class Rgb
      Parameters:
      brightness - The new brightness.
      Returns:
      A new color.
    • map

      public Rgba map(IntUnaryOperator map)
      Description copied from class: Rgb
      Maps each RGB color component using the given method.
      Overrides:
      map in class Rgb
      Parameters:
      map - The mapping method.
      Returns:
      A new, mapped color.