java.lang.Object
io.github.roboblazers7617.buttonbox.Color

public class Color extends Object
Class that represents an RGB color. This is designed to be higher-performance than Java and WPILib's Color classes, since the same object can be reused multiple times.
  • Constructor Details

    • Color

      public Color(double red, double green, double blue)
      Creates a new Color with provided values.
      Parameters:
      red - The red element [0-1].
      green - The green element [0-1].
      blue - The blue element [0-1].
    • Color

      public Color(Color color)
      Creates a new Color from a WPILib Color.
      Parameters:
      color - The color to pull from.
    • Color

      public Color()
      Creates a new Color with default values.
  • Method Details

    • getRed

      public double getRed()
      Gets the red element of this color [0-1].
      Returns:
      The red element of this color [0-1].
    • getGreen

      public double getGreen()
      Gets the green element of this color [0-1].
      Returns:
      The green element of this color [0-1].
    • getBlue

      public double getBlue()
      Gets the blue element of this color [0-1].
      Returns:
      The blue element of this color [0-1].
    • copy

      public Color copy()
      Copies this Color.
      Returns:
      A copy of this Color.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • setFromString

      public Color setFromString(String hexString)
      Sets the color from a hex string.
      Parameters:
      hexString - Hex string in format #RRGGBB.
      Returns:
      The modified object.
    • scaleBrightness

      public Color scaleBrightness(double brightness)
      Scales the brightness of the color. Just multiplies the color elements by the scalar instead of doing fancy HSV stuff, so the colors might not look perfect.
      Parameters:
      brightness - The scalar to set. Usually [0-1], but setting it larger will make the color brighter.
      Returns:
      The modified object.
      API Note:
      Color elements are clamped to [0-1].
    • toHexString

      public String toHexString()
      Gets this color as a hex string.
      Returns:
      Hex string in format #RRGGBB.