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 RGBColorDefault black RGBColor (0,0,0).static final RGBColorDefault blue RGBColor (0,0,255).static final RGBColorDefault green RGBColor (0,255,0).static final RGBColorDefault indigo RGBColor (111,0,255).static final RGBColorDefault orange RGBColor (204,136,0).static final RGBColorDefault red RGBColor (255,0,0).static final RGBColorDefault violet RGBColor (217,25,255).static final RGBColorDefault white RGBColor (255,255,255).static final RGBColorDefault yellow RGBColor (255,255,0). -
Constructor Summary
ConstructorsConstructorDescriptionRGBColor(int r, int g, int b) Creates an instance of aRGBColorrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintb()Returns the value of thebrecord component.changeSaturation(double proportion) Returns a new RGBColor with a modified saturation, or color intensity, from this.final booleanIndicates whether some other object is "equal to" this one.intg()Returns the value of thegrecord component.final inthashCode()Returns a hash code value for this object.intr()Returns the value of therrecord component.Interpolates a new color somewhere between this color and another.final StringtoString()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 therrecord component.- Returns:
- the value of the
rrecord component
-
g
public int g()Returns the value of thegrecord component.- Returns:
- the value of the
grecord component
-
b
public int b()Returns the value of thebrecord component.- Returns:
- the value of the
brecord component
-