Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * This is the source code of VshGap for Android v. 1.4.x.
 * It is licensed under GNU GPL v. 2 or later.
 * You should have received a copy of the license in this archive (see LICENSE).
 *
 * Copyright Nikolai Kudashov, 2013-2014.
 */

import android.graphics.Color;

public class Main {
    public static int setDarkColor(int color, int factor) {
        int red = Color.red(color) - factor;
        int green = Color.green(color) - factor;
        int blue = Color.blue(color) - factor;
        if (factor < 0) {
            red = (red > 0xff) ? 0xff : red;
            green = (green > 0xff) ? 0xff : green;
            blue = (blue > 0xff) ? 0xff : blue;
            if (red == 0xff && green == 0xff && blue == 0xff) {
                red = factor;
                green = factor;
                blue = factor;
            }
        }
        if (factor > 0) {
            red = (red < 0) ? 0 : red;
            green = (green < 0) ? 0 : green;
            blue = (blue < 0) ? 0 : blue;
            if (red == 0 && green == 0 && blue == 0) {
                red = factor;
                green = factor;
                blue = factor;
            }
        }
        return Color.argb(0xff, red, green, blue);
    }
}