Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.graphics.Color;

public class Main {
    /**
     * Gets a darker color.
     * @param color the color to darken
     * @return the newly darkened color.
     */
    public static int getDarkerColor(int color) {
        float[] hsv = new float[3];
        Color.colorToHSV(color, hsv);
        hsv[2] *= 0.80f * hsv[2];
        if (hsv[2] > 1) {
            hsv[2] = 1.0f;
        } else if (hsv[2] < 0) {
            hsv[2] = 0.0f;
        }
        return Color.HSVToColor(hsv);
    }
}