Package com.diozero.ws281xj
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 intBLUEstatic intCOLOUR_COMPONENT_MAXstatic intGREENstatic intLIGHT_BLUEstatic intORANGEstatic intPINKstatic intPURPLEstatic int[]RAINBOWstatic intREDstatic intYELLOW -
Constructor Summary
Constructors Constructor Description PixelColour() -
Method Summary
Modifier and Type Method Description static intcreateColourHSB(float hue, float saturation, float brightness)Creates a colour based on the specified values in the HSB colour model.static intcreateColourHSL(float hue, float saturation, float luminance)Creates a colour based on the specified values in the HSL colour model.static intcreateColourRGB(float red, float green, float blue)Create a colour from relative RGB valuesstatic intcreateColourRGB(int red, int green, int blue)Create a colour from int RGB valuesstatic intgetBlueComponent(int colour)static intgetGreenComponent(int colour)static intgetRedComponent(int colour)static intsetBlueComponent(int colour, int blue)static intsetGreenComponent(int colour, int green)static intsetRedComponent(int colour, int red)static voidvalidateColourComponent(java.lang.String colour, int value)static intwheel(int wheelPos)Input a value 0 to 255 to get a colour value.
-
Field Details
-
RED
public static final int RED- See Also:
- Constant Field Values
-
ORANGE
public static final int ORANGE- See Also:
- Constant Field Values
-
YELLOW
public static final int YELLOW- See Also:
- Constant Field Values
-
GREEN
public static final int GREEN- See Also:
- Constant Field Values
-
LIGHT_BLUE
public static final int LIGHT_BLUE- See Also:
- Constant Field Values
-
BLUE
public static final int BLUE- See Also:
- Constant Field Values
-
PURPLE
public static final int PURPLE- See Also:
- Constant Field Values
-
PINK
public static final int PINK- See Also:
- Constant Field Values
-
RAINBOW
public static final int[] RAINBOW -
COLOUR_COMPONENT_MAX
public static final int COLOUR_COMPONENT_MAX- See Also:
- Constant Field Values
-
-
Constructor Details
-
PixelColour
public PixelColour()
-
-
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 1green- Green %,0 to 1blue- 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 component0 to 255green- Green component0 to 255blue- Blue component0 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.0saturation- The saturation %,0.0 to 1.0brightness- The brightness %,0.0 to 1.0- Returns:
- RGB colour integer value
- Throws:
java.lang.IllegalArgumentException- ifhue,saturation,brightnessare 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.0saturation- The saturation %,0.0 to 1.0luminance- The luminance %,0.0 to 1.0- Returns:
- RGB colour integer value
- Throws:
java.lang.IllegalArgumentException- ifhue,saturation,brightnessare 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)
-