Class PixelColour

java.lang.Object
com.diozero.ws281xj.PixelColour

public class PixelColour
extends java.lang.Object
0x00RRGGBB
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static int BLUE  
    static int COLOUR_COMPONENT_MAX  
    static int GREEN  
    static int LIGHT_BLUE  
    static int ORANGE  
    static int PINK  
    static int PURPLE  
    static int[] RAINBOW  
    static int RED  
    static int YELLOW  
  • Constructor Summary

    Constructors 
    Constructor Description
    PixelColour()  
  • Method Summary

    Modifier and Type Method Description
    static int createColourHSB​(float hue, float saturation, float brightness)
    Creates a colour based on the specified values in the HSB colour model.
    static int createColourHSL​(float hue, float saturation, float luminance)
    Creates a colour based on the specified values in the HSL colour model.
    static int createColourRGB​(float red, float green, float blue)
    Create a colour from relative RGB values
    static int createColourRGB​(int red, int green, int blue)
    Create a colour from int RGB values
    static int getBlueComponent​(int colour)  
    static int getGreenComponent​(int colour)  
    static int getRedComponent​(int colour)  
    static int setBlueComponent​(int colour, int blue)  
    static int setGreenComponent​(int colour, int green)  
    static int setRedComponent​(int colour, int red)  
    static void validateColourComponent​(java.lang.String colour, int value)  
    static int wheel​(int wheelPos)
    Input a value 0 to 255 to get a colour value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • wheel

      public static int wheel​(int wheelPos)
      Input a value 0 to 255 to get a colour value. The colours are a transition r - g - b - back to r.
      Parameters:
      wheelPos - Position on the colour wheel (range 0..255).
      Returns:
      24-bit RGB colour value
    • createColourRGB

      public static int createColourRGB​(float red, float green, float blue)
      Create a colour from relative RGB values
      Parameters:
      red - Red %, 0 to 1
      green - Green %, 0 to 1
      blue - Blue %, 0 to 1
      Returns:
      RGB colour integer value
    • createColourRGB

      public static int createColourRGB​(int red, int green, int blue)
      Create a colour from int RGB values
      Parameters:
      red - Red component 0 to 255
      green - Green component 0 to 255
      blue - Blue component 0 to 255
      Returns:
      RGB colour integer value
    • createColourHSB

      public static int createColourHSB​(float hue, float saturation, float brightness)
      Creates a colour based on the specified values in the HSB colour model.
      Parameters:
      hue - The hue, in degrees, 0.0 to 1.0
      saturation - The saturation %, 0.0 to 1.0
      brightness - The brightness %, 0.0 to 1.0
      Returns:
      RGB colour integer value
      Throws:
      java.lang.IllegalArgumentException - if hue, saturation, brightness are out of range
    • createColourHSL

      public static int createColourHSL​(float hue, float saturation, float luminance)
      Creates a colour based on the specified values in the HSL colour model.
      Parameters:
      hue - The hue, in degrees, 0.0 to 360.0
      saturation - The saturation %, 0.0 to 1.0
      luminance - The luminance %, 0.0 to 1.0
      Returns:
      RGB colour integer value
      Throws:
      java.lang.IllegalArgumentException - if hue, saturation, brightness are out of range
    • validateColourComponent

      public static void validateColourComponent​(java.lang.String colour, int value)
    • getRedComponent

      public static int getRedComponent​(int colour)
    • setRedComponent

      public static int setRedComponent​(int colour, int red)
    • getGreenComponent

      public static int getGreenComponent​(int colour)
    • setGreenComponent

      public static int setGreenComponent​(int colour, int green)
    • getBlueComponent

      public static int getBlueComponent​(int colour)
    • setBlueComponent

      public static int setBlueComponent​(int colour, int blue)