Record Class RGBColor
java.lang.Object
java.lang.Record
org.chsrobotics.lib.hardware.ledStrip.RGBColor
- Record Components:
r
- Red channel value, as a byte [0,255].g
- Green channel value, as a byte [0,255].b
- Blue channel value, as a byte [0,255].
Represents a color in Red-Green-Blue space, with methods for manipulating said color.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RGBColor
Default black RGBColor (0,0,0).static final RGBColor
Default blue RGBColor (0,0,255).static final RGBColor
Default green RGBColor (0,255,0).static final RGBColor
Default indigo RGBColor (111,0,255).static final RGBColor
Default orange RGBColor (204,136,0).static final RGBColor
Default red RGBColor (255,0,0).static final RGBColor
Default violet RGBColor (217,25,255).static final RGBColor
Default white RGBColor (255,255,255).static final RGBColor
Default yellow RGBColor (255,255,0). -
Constructor Summary
ConstructorsConstructorDescriptionRGBColor
(int r, int g, int b) Creates an instance of aRGBColor
record class. -
Method Summary
Modifier and TypeMethodDescriptionint
b()
Returns the value of theb
record component.changeSaturation
(double proportion) Returns a new RGBColor with a modified saturation, or color intensity, from this.final boolean
Indicates whether some other object is "equal to" this one.int
g()
Returns the value of theg
record component.final int
hashCode()
Returns a hash code value for this object.int
r()
Returns the value of ther
record component.Interpolates a new color somewhere between this color and another.final String
toString()
Returns a string representation of this record class.
-
Field Details
-
RED
Default red RGBColor (255,0,0). -
GREEN
Default green RGBColor (0,255,0). -
BLUE
Default blue RGBColor (0,0,255). -
ORANGE
Default orange RGBColor (204,136,0). -
YELLOW
Default yellow RGBColor (255,255,0). -
INDIGO
Default indigo RGBColor (111,0,255). -
VIOLET
Default violet RGBColor (217,25,255). -
WHITE
Default white RGBColor (255,255,255). -
BLACK
Default black RGBColor (0,0,0).
-
-
Constructor Details
-
Method Details
-
smear
Interpolates a new color somewhere between this color and another.- Parameters:
reference
- Number in [0,1] (inclusive) indicating where to sample the new color. Smaller values indicate a color closest to this color, larger closer to the other color.other
- Other color to smear towards.- Returns:
- A new, interpolated color.
-
changeSaturation
Returns a new RGBColor with a modified saturation, or color intensity, from this.- Parameters:
proportion
- The amount to multiply each color value by.- Returns:
- A new RGBColor with modified saturation.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
r
public int r()Returns the value of ther
record component.- Returns:
- the value of the
r
record component
-
g
public int g()Returns the value of theg
record component.- Returns:
- the value of the
g
record component
-
b
public int b()Returns the value of theb
record component.- Returns:
- the value of the
b
record component
-