Package toxi.color
Interface ReadonlyTColor
- All Known Implementing Classes:
TColor
public interface ReadonlyTColor
Defines an immutable API for the TColor class. This is used to define the
preset color constants in
NamedColor
, but also throughout other parts
of this package wherever immutable behaviour is required or encouraged.-
Method Summary
Modifier and TypeMethodDescriptionfloat
alpha()
float
black()
float
blue()
float
copy()
float
cyan()
float
Calculates the CMYK distance to the given color.float
Calculates the HSV distance to the given color.float
Calculates the RGB distance to the given color.getAnalog
(float theta, float delta) getAnalog
(int angle, float delta) getBlended
(ReadonlyTColor c, float t) getClosestHue
(boolean primaryOnly) float
getComponentValue
(AccessCriteria criteria) getDarkened
(float step) getDesaturated
(float step) getLightened
(float step) getRotatedRYB
(float theta) getRotatedRYB
(int angle) getSaturated
(float step) float
green()
float
hue()
boolean
isBlack()
boolean
isGrey()
boolean
boolean
isWhite()
float
Computes the color's luminance using this formula: lum=0.299*red + 0.587*green + 0.114 *bluefloat
magenta()
float
red()
float
int
toARGB()
Converts the color into a packed ARGB int.float[]
toCMYKAArray
(float[] cmyka) Copies the current CMYKA values into the given array (or constucts a new one with these values).float[]
toHSVAArray
(float[] hsva) float[]
toRGBAArray
(float[] rgba) Copies the current RGBA value into the given array (or constucts a new one with these values).float[]
toRGBAArray
(float[] rgba, int offset) Copies the current RGBA value into the given array starting the given offset.float
yellow()
-
Method Details
-
alpha
float alpha()- Returns:
- the color's alpha component
-
black
float black()- Returns:
- the color's black component
-
blue
float blue()- Returns:
- the color's blue component
-
brightness
float brightness()- Returns:
- color HSV brightness (not luminance!)
-
copy
TColor copy()- Returns:
- a mutable copy of the current color
-
cyan
float cyan()- Returns:
- the color's cyan component
-
distanceToCMYK
Calculates the CMYK distance to the given color.- Parameters:
c
- target color- Returns:
- distance
-
distanceToHSV
Calculates the HSV distance to the given color.- Parameters:
c
- target color- Returns:
- distance
-
distanceToRGB
Calculates the RGB distance to the given color.- Parameters:
c
- target color- Returns:
- distance
-
getAnalog
-
getAnalog
-
getBlended
-
getClosestHue
Hue getClosestHue()- Returns:
- an instance of the closest named hue to this color.
-
getClosestHue
- Parameters:
primaryOnly
- if true, only primary color hues are considered- Returns:
- an instance of the closest named (primary) hue to this color.
-
getComplement
TColor getComplement() -
getComponentValue
-
getDarkened
- Parameters:
step
-- Returns:
- a darkened copy
-
getDesaturated
- Parameters:
step
-- Returns:
- a desaturated copy
-
getInverted
TColor getInverted()- Returns:
- an inverted copy
-
getLightened
- Parameters:
step
-- Returns:
- a lightened copy
-
getRotatedRYB
- Parameters:
theta
- rotation angle in radians- Returns:
- a RYB rotated copy
-
getRotatedRYB
- Parameters:
angle
- rotation angle in degrees- Returns:
- a RYB rotated copy
-
getSaturated
- Parameters:
step
-- Returns:
- a saturated copy
-
green
float green()- Returns:
- the color's green component
-
hue
float hue()- Returns:
- the color's hue
-
isBlack
boolean isBlack()- Returns:
- true, if all rgb component values are equal and less than
TColor.BLACK_POINT
-
isGrey
boolean isGrey()- Returns:
- true, if the saturation component value is less than
TColor.GREY_THRESHOLD
-
isPrimary
boolean isPrimary()- Returns:
- true, if this colors hue is matching one of the 7 defined primary hues.
-
isWhite
boolean isWhite()- Returns:
- true, if all rgb component values are equal and greater than
TColor.WHITE_POINT
-
luminance
float luminance()Computes the color's luminance using this formula: lum=0.299*red + 0.587*green + 0.114 *blue- Returns:
- luminance
-
magenta
float magenta()- Returns:
- the color's magenta component
-
red
float red()- Returns:
- the color's red component
-
saturation
float saturation()- Returns:
- the color's saturation
-
toARGB
int toARGB()Converts the color into a packed ARGB int.- Returns:
- color as int
-
toCMYKAArray
float[] toCMYKAArray(float[] cmyka) Copies the current CMYKA values into the given array (or constucts a new one with these values).- Parameters:
cmyka
- result array (or null)- Returns:
- array in this order: c,m,y,k,a
-
toHSVAArray
float[] toHSVAArray(float[] hsva) - Parameters:
hsva
- result array (or null)- Returns:
- Copies the the current HSV values into the given array (or constucts a new one with these values).
-
toRGBAArray
float[] toRGBAArray(float[] rgba) Copies the current RGBA value into the given array (or constucts a new one with these values).- Parameters:
rgba
- result array (or null)- Returns:
- array in this order: r,g,b,a (OpenGL format)
-
toRGBAArray
float[] toRGBAArray(float[] rgba, int offset) Copies the current RGBA value into the given array starting the given offset. If the array is null, the method constucts a new one with these values and the offset value is ignored (set to zero).- Parameters:
rgba
-offset
-- Returns:
- float array
-
yellow
float yellow()- Returns:
- the color's yellow component
-