Class ColourUtils


  • public class ColourUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ColourUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void blue_to_magenta​(float value, float[] rgba)  
      static void blue_white_red​(float value, float[] rgba)
      Converts a scalar normalized to the range [0:1] into a blue-white-red rgba color, with blue at 0, white at 0.5 and red at 1
      static float[] brighten​(float[] rgb, float luminosity)
      Returns a copy of the RGB colour brightened up by the given amount
      static float[] BVtoRGB​(double bv)
      Converts the color index B-V to RGB model.
      static int getBlue​(int rgb)  
      static int getGreen​(int rgb)  
      static int getRed​(int rgb)  
      static void grayscale​(float value, float[] rgba)
      Converts a scalar value that is normalized to [0:1] into a grayscale color vector rgba.
      static int HSBtoRGB​(float hue, float saturation, float brightness)  
      static float[] hslToRgb​(float[] hsl)
      Converts an HSL color value to RGB.
      static boolean isZero​(com.badlogic.gdx.graphics.Color c)  
      static void long_rainbow​(float value, float[] rgba)
      Converts a scalar in [0..1] to a long rainbow of rgba values.
      static float normalize​(float value, float min, float max)  
      static float[] rgbToHsl​(float[] rgb)
      Converts an RGB color value to HSL.
      static void short_rainbow​(float value, float[] rgba)
      Converts a scalar normalized to the range [0:1] into a short rainbow of rgba values.
      static float[] teffToRGB​(double teff)
      Converts effective temperature in Kelvin (1000-40000) to RGB
      static void yellow_to_red​(float value, float[] rgba)
      Converts a scalar in [0..1] to a yellow to red map.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ColourUtils

        public ColourUtils()
    • Method Detail

      • normalize

        public static float normalize​(float value,
                                      float min,
                                      float max)
      • grayscale

        public static void grayscale​(float value,
                                     float[] rgba)
        Converts a scalar value that is normalized to [0:1] into a grayscale color vector rgba. See: http://www.particleincell.com/blog/2014/colormap/
        Parameters:
        value -
      • blue_white_red

        public static void blue_white_red​(float value,
                                          float[] rgba)
        Converts a scalar normalized to the range [0:1] into a blue-white-red rgba color, with blue at 0, white at 0.5 and red at 1
        Parameters:
        value - The value
        rgba - The color
      • short_rainbow

        public static void short_rainbow​(float value,
                                         float[] rgba)
        Converts a scalar normalized to the range [0:1] into a short rainbow of rgba values. See: http://www.particleincell.com/blog/2014/colormap/
        Parameters:
        value -
      • long_rainbow

        public static void long_rainbow​(float value,
                                        float[] rgba)
        Converts a scalar in [0..1] to a long rainbow of rgba values. See here
        Parameters:
        value - The value in [0..1]
      • yellow_to_red

        public static void yellow_to_red​(float value,
                                         float[] rgba)
        Converts a scalar in [0..1] to a yellow to red map. See here
        Parameters:
        value - The value to convert
      • blue_to_magenta

        public static void blue_to_magenta​(float value,
                                           float[] rgba)
      • teffToRGB

        public static float[] teffToRGB​(double teff)
        Converts effective temperature in Kelvin (1000-40000) to RGB
        Parameters:
        teff - Effective temperature
        Returns:
        The RGB color in a float array
        See Also:
        Temperature to RGB, Color temperature conversion
      • BVtoRGB

        public static float[] BVtoRGB​(double bv)
        Converts the color index B-V to RGB model. See here
        Parameters:
        bv - The B-V color index
        Returns:
        The RGB as a float array in [0..1]
      • brighten

        public static float[] brighten​(float[] rgb,
                                       float luminosity)
        Returns a copy of the RGB colour brightened up by the given amount
        Parameters:
        rgb - The RGB color
        luminosity - The new luminosity amount in [0..1]
        Returns:
        The new RGB array
      • rgbToHsl

        public static float[] rgbToHsl​(float[] rgb)
        Converts an RGB color value to HSL. Conversion formula adapted from http://en.wikipedia.org/wiki/HSL_color_space. Assumes r, g, and b are contained in the set [0..255] and returns h, s, and l in the set [0..1]
        Parameters:
        rgb - Float array with the RGB values
        Returns:
        Array The HSL representation
      • hslToRgb

        public static float[] hslToRgb​(float[] hsl)
        Converts an HSL color value to RGB. Conversion formula adapted from http://en.wikipedia.org/wiki/HSL_color_space. Assumes h, s, and l are contained in the set [0..1] and returns r, g, and b in the set [0..255].
        Parameters:
        hsl - Float array with the HSL values
        Returns:
        Array The RGB representation
      • HSBtoRGB

        public static int HSBtoRGB​(float hue,
                                   float saturation,
                                   float brightness)
      • getRed

        public static int getRed​(int rgb)
      • getGreen

        public static int getGreen​(int rgb)
      • getBlue

        public static int getBlue​(int rgb)
      • isZero

        public static boolean isZero​(com.badlogic.gdx.graphics.Color c)