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].

public record RGBColor(int r, int g, int b) extends Record
Represents a color in Red-Green-Blue space, with methods for manipulating said color.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static 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

    Constructors
    Constructor
    Description
    RGBColor(int r, int g, int b)
    Creates an instance of a RGBColor record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    b()
    Returns the value of the b 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 the g record component.
    final int
    Returns a hash code value for this object.
    int
    r()
    Returns the value of the r record component.
    smear(double reference, RGBColor other)
    Interpolates a new color somewhere between this color and another.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • RED

      public static final RGBColor RED
      Default red RGBColor (255,0,0).
    • GREEN

      public static final RGBColor GREEN
      Default green RGBColor (0,255,0).
    • BLUE

      public static final RGBColor BLUE
      Default blue RGBColor (0,0,255).
    • ORANGE

      public static final RGBColor ORANGE
      Default orange RGBColor (204,136,0).
    • YELLOW

      public static final RGBColor YELLOW
      Default yellow RGBColor (255,255,0).
    • INDIGO

      public static final RGBColor INDIGO
      Default indigo RGBColor (111,0,255).
    • VIOLET

      public static final RGBColor VIOLET
      Default violet RGBColor (217,25,255).
    • WHITE

      public static final RGBColor WHITE
      Default white RGBColor (255,255,255).
    • BLACK

      public static final RGBColor BLACK
      Default black RGBColor (0,0,0).
  • Constructor Details

    • RGBColor

      public RGBColor(int r, int g, int b)
      Creates an instance of a RGBColor record class.
      Parameters:
      r - the value for the r record component
      g - the value for the g record component
      b - the value for the b record component
  • Method Details

    • smear

      public RGBColor smear(double reference, RGBColor other)
      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

      public RGBColor changeSaturation(double proportion)
      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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • r

      public int r()
      Returns the value of the r record component.
      Returns:
      the value of the r record component
    • g

      public int g()
      Returns the value of the g record component.
      Returns:
      the value of the g record component
    • b

      public int b()
      Returns the value of the b record component.
      Returns:
      the value of the b record component