Package com.ctre.phoenix6.signals
Class RGBWColor
java.lang.Object
com.ctre.phoenix6.signals.RGBWColor
Represents an RGBW color that can be applied to an LED.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new RGBW color where all components are off.RGBWColor(int red, int green, int blue) Creates a new RGB color from the given 8-bit components.RGBWColor(int red, int green, int blue, int white) Creates a new RGBW color from the given 8-bit components.Creates a new RGBW color from a WPILib color.Creates a new RGBW color from a WPILib 8-bit color. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCreates a new RGBW color from the given hex string.static RGBWColorfromHSV(double h, double s, double v) Creates a new RGBW color from the given HSV color.static RGBWColorCreates a new RGBW color from the given HSV color.inthashCode()scaleBrightness(double brightness) Scales down the components of this color by the given brightness.Returns this RGBW color as a hex string.toString()
-
Field Details
-
Red
The red component of the color, within [0, 255]. -
Green
The green component of the color, within [0, 255]. -
Blue
The blue component of the color, within [0, 255]. -
White
The white component of the color, within [0, 255]. Note that not all LED strips support the white component.
-
-
Constructor Details
-
RGBWColor
public RGBWColor()Creates a new RGBW color where all components are off. -
RGBWColor
Creates a new RGB color from the given 8-bit components.- Parameters:
red- The red component of the color, within [0, 255].green- The green component of the color, within [0, 255].blue- The blue component of the color, within [0, 255].
-
RGBWColor
Creates a new RGBW color from the given 8-bit components.- Parameters:
red- The red component of the color, within [0, 255].green- The green component of the color, within [0, 255].blue- The blue component of the color, within [0, 255].white- The white component of the color, within [0, 255]. Note that not all LED strips support the white component.
-
RGBWColor
Creates a new RGBW color from a WPILib color. The white component will be left 0.- Parameters:
color- The WPILib color
-
RGBWColor
Creates a new RGBW color from a WPILib 8-bit color. The white component will be left 0.- Parameters:
color- The WPILib color
-
-
Method Details
-
fromHex
Creates a new RGBW color from the given hex string.- Parameters:
hex- The color hex in the form "#RRGGBBWW" or "#RRGGBB".- Returns:
- The color if the hex is valid, otherwise
Optional.empty()
-
fromHSV
Creates a new RGBW color from the given HSV color.- Parameters:
h- The hue as an angle from [0, 360) deg, where 0 is red.s- The saturation as a scalar from [0, 1].v- The value as a scalar from [0, 1].- Returns:
- The corresponding RGB color; the white component will be 0.
-
fromHSV
Creates a new RGBW color from the given HSV color.- Parameters:
h- The hue as an angle from [0, 360) deg.s- The saturation as a scalar from [0, 1].v- The value as a scalar from [0, 1].- Returns:
- The corresponding RGB color; the white component will be 0.
-
scaleBrightness
Scales down the components of this color by the given brightness.This function returns a new object every call. As a result, we recommend that this is not called inside a tight loop.
- Parameters:
brightness- The scalar to apply from [0, 1].- Returns:
- New color scaled by the given brightness
-
equals
-
hashCode
-
toString
-
toHexString
Returns this RGBW color as a hex string.- Returns:
- A hex string in the format "#RRGGBBWW"
-