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 {
    private static final float SATURATION_DARKEN = 1.1f;
    private static final float INTENSITY_DARKEN = 0.9f;

    public static int darkenColor(int color) {
        float[] hsv = new float[3];
        int alpha = Color.alpha(color);
        Color.colorToHSV(color, hsv);
        hsv[1] = Math.min(hsv[1] * SATURATION_DARKEN, 1.0f);
        hsv[2] = hsv[2] * INTENSITY_DARKEN;
        int tempColor = Color.HSVToColor(hsv);
        return Color.argb(alpha, Color.red(tempColor), Color.green(tempColor), Color.blue(tempColor));
    }
}