inverse Color - Java 2D Graphics

Java examples for 2D Graphics:Color

Description

inverse Color

Demo Code

/*/*  w  w w .  j  ava2s.  c  o m*/
 * This code is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public 
 * License as published by the Free Software Foundation; either 
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this program; if not, write to the Free 
 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 
 * MA  02111-1307, USA.
 */
//package com.java2s;
import java.awt.Color;

public class Main {
    public static Color inverse(Color c) {

        float rgb[] = new float[3];
        c.getColorComponents(rgb);
        Color color = new Color(1f - rgb[0], 1f - rgb[1], 1f - rgb[2]);

        return color;
    }
}

Related Tutorials