Package com.diozero.ws281xj
Class PixelColour
java.lang.Object
com.diozero.ws281xj.PixelColour
0x00RRGGBB
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int[]static final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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(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:
-
ORANGE
public static final int ORANGE- See Also:
-
YELLOW
public static final int YELLOW- See Also:
-
GREEN
public static final int GREEN- See Also:
-
LIGHT_BLUE
public static final int LIGHT_BLUE- See Also:
-
BLUE
public static final int BLUE- See Also:
-
PURPLE
public static final int PURPLE- See Also:
-
PINK
public static final int PINK- See Also:
-
RAINBOW
public static final int[] RAINBOW -
COLOUR_COMPONENT_MAX
public static final int COLOUR_COMPONENT_MAX- See Also:
-
-
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:
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:
IllegalArgumentException- ifhue,saturation,brightnessare out of range
-
validateColourComponent
-
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)
-