Class ColorUtils

  • All Implemented Interfaces:

    
    public final class ColorUtils
    
                        
    • Constructor Detail

    • Method Detail

      • toColor

         final static PolyColor toColor(String $self)

        Turn the given hex string into a color.

        • If it is 8 characters long, it is assumed to be in the format #RRGGBBAA (alpha optional)

        • If there is a leading #, it will be removed.

        • If it is 1 character long, the character is repeated e.g. #f ->#ffffff

        • If it is 2 characters long, the character is repeated e.g. #0f ->#0f0f0f

        • If it is 3 characters long, the character is repeated e.g. #0fe ->#00ffee

      • toPolyColor

         final static PolyColor toPolyColor(Color $self)

        Return a PolyUI compatible color object representative of this Java color object.

        Since:

        1.1.51

      • toJavaColor

         final static Color toJavaColor(PolyColor $self)

        Return a static java Color object of this color at the instant this method is called.

        Future changes to this color will not be reflected in the returned object.

        Since:

        1.1.51

      • HSBtoRGB

         final static Integer HSBtoRGB(Float hue, Float saturation, Float brightness, Float alpha)

        Converts the components of a color, as specified by the HSB model, to an equivalent set of values for the default RGB model.

        The saturation and brightness components should be floating-point values between zero and one (numbers in the range 0.0-1.0). The hue component can be any floating-point number. The floor of this number is subtracted from it to create a fraction between 0 and 1. This fractional number is then multiplied by 360 to produce the hue angle in the HSB color model.

        The integer that is returned by HSBtoRGB encodes the value of a color in bits 0-23 of an integer value that is the same format used by the method getARGB(). This integer can be supplied as an argument to the toColor method that takes a single integer argument to create a PolyColor.

        Parameters:
        hue - the hue component of the color
        saturation - the saturation of the color
        brightness - the brightness of the color
        alpha - (since 1.
        Returns:

        the RGB value of the color with the indicated hue, saturation, and brightness.

      • RGBtoHSB

         final static FloatArray RGBtoHSB(Integer r, Integer g, Integer b, FloatArray out)

        Converts the components of a color, as specified by the default RGB model, to an equivalent set of values for hue, saturation, and brightness that are the three components of the HSB model.

        If the out argument is null, then a new array is allocated to return the result. Otherwise, the method returns the array out, with the values put into that array.

        Parameters:
        r - the red component of the color
        g - the green component of the color
        b - the blue component of the color
        out - the array used to return the three HSB values, or null
        Returns:

        an array of three elements containing the hue, saturation, and brightness (in that order), of the color with the indicated red, green, and blue components.

        Since:

        0.18.2