Java Color Inverse inverse(Color c)

Here you can find the source of inverse(Color c)

Description

inverse

License

Open Source License

Declaration

public static Color inverse(Color c) 

Method Source Code


//package com.java2s;
/*//  w w  w. j  a  v a  2  s . 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.
 */

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

  1. fillInverseHorGradient(Graphics g, Color[] colors, int x, int y, int w, int h)
  2. inverse(Color color)