towards Gray Color - Java 2D Graphics

Java examples for 2D Graphics:Color

Description

towards Gray Color

Demo Code


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

public class Main {
    public static Color towardsGray(Color c, double frac) {
        int er = c.getRed() - 128;
        int eg = c.getGreen() - 128;
        int eb = c.getBlue() - 128;
        return new Color(c.getRed() - ((int) (er * frac)), c.getGreen()
                - ((int) (eg * frac)), c.getBlue() - ((int) (eb * frac)));
    }//from www  . j a v  a 2 s  . c  om
}

Related Tutorials