make Color Darker - Java 2D Graphics

Java examples for 2D Graphics:Color Dark

Description

make Color Darker

Demo Code


//package com.java2s;
import java.awt.Color;

public class Main {
    public static Color makeDarker(Color curColor, int distance) {
        int red = curColor.getRed();
        int green = curColor.getGreen();
        int blue = curColor.getBlue();

        red -= distance;//  ww w .j a  v a  2  s . c  om
        green -= distance;
        blue -= distance;

        if (red < 0)
            red = 0;
        if (green < 0)
            green = 0;
        if (blue < 0)
            blue = 0;

        return new Color(red, green, blue);
    }
}

Related Tutorials