darken color by rate - Android Graphics

Android examples for Graphics:Color Darken

Description

darken color by rate

Demo Code


//package com.java2s;

import android.graphics.Color;

public class Main {
    public static final int darken(int color, float rate) {
        float[] hsv = new float[3];
        Color.colorToHSV(color, hsv);
        hsv[2] = hsv[2] * rate;//from w w  w  .j  av a 2s.c om
        return Color.HSVToColor(hsv);
    }

    public static final int darken(int color) {
        return darken(color, 0.8f);
    }
}

Related Tutorials