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 {
    /**
     * Get a darker version of a color
     * @param color the color to be darkened
     * @param factor the factor by which to darken the color
     * @return an integer representation of the darkened color
     */
    private static int darker(int color, double factor) {
        int a = Color.alpha(color);
        int r = Color.red(color);
        int g = Color.green(color);
        int b = Color.blue(color);

        return Color.argb(a, Math.max((int) (r * factor), 0), Math.max((int) (g * factor), 0),
                Math.max((int) (b * factor), 0));
    }
}