Example usage for android.support.v4.graphics ColorUtils colorToHSL

List of usage examples for android.support.v4.graphics ColorUtils colorToHSL

Introduction

In this page you can find the example usage for android.support.v4.graphics ColorUtils colorToHSL.

Prototype

public static void colorToHSL(@ColorInt int color, @NonNull float[] outHsl) 

Source Link

Document

Convert the ARGB color to its HSL (hue-saturation-lightness) components.

Usage

From source file:com.pixby.texo.EditTools.ColorTool.java

private @ColorInt int createTintOrShade(@ColorInt int color, float factor) {
    float[] hsl = new float[3];
    ColorUtils.colorToHSL(color, hsl);
    hsl[2] *= factor;/*from  w ww . j ava  2 s  . c om*/
    return ColorUtils.HSLToColor(hsl);
}

From source file:android.support.v7.graphics.ColorCutQuantizer.java

private boolean shouldIgnoreColor(int color565) {
    final int rgb = approximateToRgb888(color565);
    ColorUtils.colorToHSL(rgb, mTempHsl);
    return shouldIgnoreColor(rgb, mTempHsl);
}

From source file:com.google.samples.apps.iosched.util.UIUtils.java

/**
 * Calculate a darker variant of the given color to make it suitable for setting as the status
 * bar background./*from w  ww .  j av  a2  s .  c  o  m*/
 *
 * @param color the color to adjust.
 * @return the adjusted color.
 */
public static @ColorInt int adjustColorForStatusBar(@ColorInt int color) {
    float[] hsl = new float[3];
    ColorUtils.colorToHSL(color, hsl);

    // darken the color by 7.5%
    float lightness = hsl[2] * 0.925f;
    // constrain lightness to be within [01]
    lightness = Math.max(0f, Math.min(1f, lightness));
    hsl[2] = lightness;
    return ColorUtils.HSLToColor(hsl);
}