Class Color
java.lang.Object
io.github.roboblazers7617.buttonbox.Color
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()Copies this Color.booleandoublegetBlue()Gets the blue element of this color [0-1].doublegetGreen()Gets the green element of this color [0-1].doublegetRed()Gets the red element of this color [0-1].scaleBrightness(double brightness) Scales the brightness of the color.setFromString(String hexString) Sets the color from a hex string.Gets this color as a hex string.
-
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
Creates a new Color from a WPILibColor.- 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
Copies this Color.- Returns:
- A copy of this Color.
-
equals
-
setFromString
Sets the color from a hex string.- Parameters:
hexString- Hex string in format #RRGGBB.- Returns:
- The modified object.
-
scaleBrightness
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
Gets this color as a hex string.- Returns:
- Hex string in format #RRGGBB.
-