Class GradientHelper


  • public class GradientHelper
    extends Object
    Gradient utilities.
    Since:
    2.3.0
    • Method Detail

      • blendColors

        public static int blendColors​(int color1,
                                      int color2,
                                      float ratio)
        Computes the color resulting by blending two colors with a ratio.
        Parameters:
        color1 - the first color.
        color2 - the second color.
        ratio - the ratio of the second color which means the ratio of the first color is 1 - ratio. This value is clamped between 0 and 1.
        Returns:
        the blended color.
      • createGradient

        public static int[] createGradient​(Display display,
                                           int startColor,
                                           int endColor)
        Creates a gradient between two colors on a display.

        The result is an array of colors where:

        • the first one is the given start color,
        • the last one is the given end color,
        • all colors are different.
        Beware that if the given colors are identical, the result contains only one element.
        Parameters:
        display - the display where the gradient will be used.
        startColor - the start color of the gradient.
        endColor - the end color of the gradient.
        Returns:
        the gradient.
        See Also:
        Display.getDisplayColor(int)