Class RGBColor

java.lang.Object
org.chsrobotics.lib.hardware.ledStrip.RGBColor

public class RGBColor extends Object
Represents a color in Red-Green-Blue space, with methods for manipulating said color.
  • Field Details

    • r

      public final int r
    • g

      public final int g
    • b

      public final int b
    • RED

      public static final RGBColor RED
    • GREEN

      public static final RGBColor GREEN
    • BLUE

      public static final RGBColor BLUE
    • ORANGE

      public static final RGBColor ORANGE
    • YELLOW

      public static final RGBColor YELLOW
    • INDIGO

      public static final RGBColor INDIGO
    • VIOLET

      public static final RGBColor VIOLET
    • WHITE

      public static final RGBColor WHITE
    • BLACK

      public static final RGBColor BLACK
  • Constructor Details

    • RGBColor

      public RGBColor(int r, int g, int b)
      Constructs an RGBColor.
      Parameters:
      r - Red value of the color, in the interval [0,255] (inclusive). If too big or small, changed to the closest valid value.
      g - Green value of the color, in the interval [0,255] (inclusive). If too big or small, changed to the closest valid value.
      b - Blue value of the color, in the interval [0,255] (inclusive). If too big or small, changed to the closest value value.
  • 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.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object