Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.graphics.Color;

public class Main {
    /**
     * Darken a color by the given percentage
     * @param color the color to darken
     * @param percent the amount to darken the color by. In range 0-1
     * @return the darkened colour
     */
    public static int darken(int color, float percent) {
        float[] hsv = new float[3];
        Color.colorToHSV(color, hsv);
        hsv[2] *= 1 - percent;
        return Color.HSVToColor(hsv);
    }
}