Package trclib.dataprocessor
Class TrcColor
java.lang.Object
trclib.dataprocessor.TrcColor
This class implements a platform independent color object. The color object describes color in either RGB or HSV
formats. It also provides methods to convert between the two formats.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTrcColor(int red, int green, int blue) Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetBlue()This method returns the normalized blue value.doublegetGreen()This method returns the normalized green value.double[]getHSV()This method returns the HSV values in an array.doublegetHue()This method returns the hue of the HSV color.doublegetRed()This method returns the normalized red value.double[]getRGB()This method returns the normalized RGB values in an array.doubleThis method returns the saturation of the HSV color.doublegetValue()This method returns the value of the HSV color.static double[]rgbToHsv(double... rgb) This method translates the RGB color values into HSV.
-
Field Details
-
rgb
private final double[] rgb -
hsv
private final double[] hsv
-
-
Constructor Details
-
TrcColor
public TrcColor(int red, int green, int blue) Constructor: Create an instance of the object.- Parameters:
red- specifies the red value (0-255).green- specifies the green value (0-255).blue- specifies the blue value (0-255).
-
-
Method Details
-
getRed
public double getRed()This method returns the normalized red value.- Returns:
- normalized red value (0.0-1.0).
-
getGreen
public double getGreen()This method returns the normalized green value.- Returns:
- normalized green value (0.0-1.0).
-
getBlue
public double getBlue()This method returns the normalized blue value.- Returns:
- normalized blue value (0.0-1.0).
-
getRGB
public double[] getRGB()This method returns the normalized RGB values in an array.- Returns:
- normalized RGB values (0.0-1.0).
-
getHue
public double getHue()This method returns the hue of the HSV color.- Returns:
- HSV hue.
-
getSaturation
public double getSaturation()This method returns the saturation of the HSV color.- Returns:
- HSV saturation.
-
getValue
public double getValue()This method returns the value of the HSV color.- Returns:
- HSV value.
-
getHSV
public double[] getHSV()This method returns the HSV values in an array.- Returns:
- HSV values.
-
rgbToHsv
public static double[] rgbToHsv(double... rgb) This method translates the RGB color values into HSV.- Returns:
- HSV values of the color object as an array of doubles.
-