Class TrcColor

java.lang.Object
trclib.dataprocessor.TrcColor

public class TrcColor extends Object
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
    Modifier and Type
    Field
    Description
    private final double[]
     
    private final double[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    TrcColor(int red, int green, int blue)
    Constructor: Create an instance of the object.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    This method returns the normalized blue value.
    double
    This method returns the normalized green value.
    double[]
    This method returns the HSV values in an array.
    double
    This method returns the hue of the HSV color.
    double
    This method returns the normalized red value.
    double[]
    This method returns the normalized RGB values in an array.
    double
    This method returns the saturation of the HSV color.
    double
    This method returns the value of the HSV color.
    static double[]
    rgbToHsv(double... rgb)
    This method translates the RGB color values into HSV.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.