Class Rgb
- Direct Known Subclasses:
Rgba
- Since:
- 2.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intA mask for an sRGB color's alpha value.static intA mask for an sRGB color's blue value.static intA mask for an sRGB color's green value.static intA mask for an sRGB color's red value. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintblue()Returns the color's blue component.doubleReturns the color's blue component, scaled between the range[0, 1].floatReturns the color's brightness.intgreen()Returns the color's green component.doubleReturns the color's green component, scaled between the range[0, 1].floathue()Returns the color's hue.intinteger()Returns the color as an integer.map(IntUnaryOperator map) Maps each RGB color component using the given method.mix(Rgb other, IntBinaryOperator mix) Mixes two colors together by combining their color components.intred()Returns the color's red component.doubleReturns the color's red component, scaled between the range[0, 1].floatReturns the color's saturation.withBlue(double blue) Sets the color's blue component.withBlue(int blue) Sets the color's blue component.withBrightness(float brightness) Sets the color's brightness.withGreen(double green) Sets the color's green component.withGreen(int green) Sets the color's green component.withHue(float hue) Sets the color's hue.withRed(double red) Sets the color's red component.withRed(int red) Sets the color's red component.withSaturation(float saturation) Sets the color's saturation.
-
Field Details
-
ALPHA_MASK
public static int ALPHA_MASKA mask for an sRGB color's alpha value.- Since:
- 2.0.0
-
RED_MASK
public static int RED_MASKA mask for an sRGB color's red value.- Since:
- 2.0.0
-
GREEN_MASK
public static int GREEN_MASKA mask for an sRGB color's green value.- Since:
- 2.0.0
-
BLUE_MASK
public static int BLUE_MASKA mask for an sRGB color's blue value.- Since:
- 2.0.0
-
-
Constructor Details
-
Rgb
public Rgb(int red, int green, int blue) Creates a new RGB 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.- Since:
- 2.0.0
-
Rgb
public Rgb(double red, double green, double blue) Creates a new RGB 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.- Since:
- 2.0.0
-
Rgb
public Rgb(int rgb) Creates a new RGB value.- Parameters:
rgb- The color as an integer.- Since:
- 2.0.0
-
-
Method Details
-
integer
public int integer()Returns the color as an integer.- Returns:
- The color.
- Since:
- 2.0.0
-
red
public int red()Returns the color's red component.- Returns:
- The red component.
- Since:
- 2.0.0
-
green
public int green()Returns the color's green component.- Returns:
- The green component.
- Since:
- 2.0.0
-
blue
public int blue()Returns the color's blue component.- Returns:
- The blue component.
- Since:
- 2.0.0
-
redScaled
public double redScaled()Returns the color's red component, scaled between the range[0, 1].- Returns:
- The red component.
- Since:
- 2.0.0
-
greenScaled
public double greenScaled()Returns the color's green component, scaled between the range[0, 1].- Returns:
- The green component.
- Since:
- 2.0.0
-
blueScaled
public double blueScaled()Returns the color's blue component, scaled between the range[0, 1].- Returns:
- The blue component.
- Since:
- 2.0.0
-
hue
public float hue()Returns the color's hue.This value will be within a range of
[0, 1].- Returns:
- The hue.
- Since:
- 2.0.0
-
saturation
public float saturation()Returns the color's saturation.This value will be within a range of
[0, 1].- Returns:
- The saturation.
- Since:
- 2.0.0
-
brightness
public float brightness()Returns the color's brightness.This value will be within a range of
[0, 1].- Returns:
- The brightness.
- Since:
- 2.0.0
-
withRed
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.- Parameters:
red- The new red component.- Returns:
- A new color.
- Since:
- 2.0.0
-
withGreen
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.- Parameters:
green- The new green component.- Returns:
- A new color.
- Since:
- 2.0.0
-
withBlue
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.- Parameters:
blue- The new blue component.- Returns:
- A new color.
- Since:
- 2.0.0
-
withRed
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.- Parameters:
red- The new red component.- Returns:
- A new color.
- Since:
- 2.0.0
-
withGreen
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.- Parameters:
green- The new green component.- Returns:
- A new color.
- Since:
- 2.0.0
-
withBlue
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.- Parameters:
blue- The new blue component.- Returns:
- A new color.
- Since:
- 2.0.0
-
withHue
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.- Parameters:
hue- The new hue.- Returns:
- A new color.
- Since:
- 2.0.0
-
withSaturation
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.- Parameters:
saturation- The new saturation.- Returns:
- A new color.
- Since:
- 2.0.0
-
withBrightness
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.- Parameters:
brightness- The new brightness.- Returns:
- A new color.
- Since:
- 2.0.0
-
map
Maps each RGB color component using the given method.- Parameters:
map- The mapping method.- Returns:
- A new, mapped color.
- Since:
- 2.0.0
-
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
-