org.richfaces.renderkit.html.images

## Class ColorUtils

- java.lang.Object
- - org.richfaces.renderkit.html.images.ColorUtils

-     public abstract class ColorUtils
      extends java.lang.Object

  Utility methods that are useful for color processing.
  Author:
    carcasser

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ColorUtils()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.awt.Color` | `adjustBrightness(java.awt.Color c, float difference)` Increases/decreases brightness of the given color by the specified `difference`.
    `static java.awt.Color` | `adjustLightness(java.awt.Color c, float difference)` Increases/decreases lightness of the given color by the specified `difference`.
    `static java.awt.Color` | `HSLtoRGB(float h, float s, float l)` Converts the components of a color, as specified by the HSL model, to an equivalent set of values for the default RGB model.
    `static java.awt.Color` | `overwriteAlpha(java.awt.Color c, float alpha)` Overwrites alpha value for given color.
    `static float[]` | `RGBtoHSL(int r, int g, int b)` Converts the components of a color, as specified by the default RGB model, to an equivalent set of values for hue, saturation, and lightness that are the three components of the HSL model.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ColorUtils

          public ColorUtils()

  - ### Method Detail

    - #### RGBtoHSL

          public static float[] RGBtoHSL(int r,
                         int g,
                         int b)

      Converts the components of a color, as specified by the default RGB model, to an equivalent set of values for hue, saturation, and lightness that are the three components of the HSL model.
      Parameters:
        `r` - the red component of the color
        `g` - the green component of the color
        `b` - the blue component of the color
      Returns:
        an array of three elements containing the hue, saturation, and lightness (in that order), of the color with the indicated red, green, and blue components.

    - #### HSLtoRGB

          public static java.awt.Color HSLtoRGB(float h,
                                float s,
                                float l)

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

      The `saturation` and `lightness` 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.

      Parameters:
        `h` - the hue component of the color
        `s` - the saturation of the color
        `l` - the lightness of the color
      Returns:
        the RGB value of the color with the indicated hue, saturation, and lightness

    - #### adjustBrightness

          public static java.awt.Color adjustBrightness(java.awt.Color c,
                                        float difference)

      Increases/decreases brightness of the given color by the specified `difference`.

      The `difference` values in the range (-1.0, 1.0): 1.0 - the brightest value; -1.0 - the dimmest value.

      Parameters:
        `c` - color to adjust
        `difference` - value to be added to the current brightness
      Returns:
        a new `Color` instance with increased/decreased brightness by specified `difference`
      Throws:
        `java.lang.IllegalArgumentException` - if difference is outside of the range -1.0 to 1.0, inclusive

    - #### adjustLightness

          public static java.awt.Color adjustLightness(java.awt.Color c,
                                       float difference)

      Increases/decreases lightness of the given color by the specified `difference`.

      The `difference` values in the range (-1.0, 1.0): 1.0 - the lightest value; -1.0 - on the contrary.

      Parameters:
        `c` - color to adjust
        `difference` - value to be added to the current lightness
      Returns:
        a new `Color` instance with increased/decreased lightness by specified `difference`
      Throws:
        `java.lang.IllegalArgumentException` - if difference is outside of the range -1.0 to 1.0, inclusive

    - #### overwriteAlpha

          public static java.awt.Color overwriteAlpha(java.awt.Color c,
                                      float alpha)

      Overwrites alpha value for given color.
      Parameters:
        `c` - color to overwrite
        `alpha` - a new value of alpha
      Returns:
        a new `Color` object with a new specified alpha value

Copyright © 2013. All Rights Reserved.