Class PixelColour


  • public class PixelColour
    extends Object
    0x00RRGGBB
    • Constructor Detail

      • PixelColour

        public PixelColour()
    • Method Detail

      • 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:
        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:
        IllegalArgumentException - if hue, saturation, brightness are out of range
      • validateColourComponent

        public static void validateColourComponent​(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)