Here you can find the source of inverse(Color color)
Parameter | Description |
---|---|
color | the color to invert. |
public static Color inverse(Color color)
//package com.java2s; /*/* w ww . j a v a 2 s .c om*/ * ColorUtilities.java (Class: com.madphysicist.tools.util.ColorUtilities) * * Mad Physicist JTools Project (General Purpose Utilities) * * The MIT License (MIT) * * Copyright (c) 2013 by Joseph Fox-Rabinovitz * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ import java.awt.Color; public class Main { /** * Returns the inverse of a color, preserving the opacity. Each of the RGB * components of the color are inverted individually. The alpha value * remains intact. * * @param color the color to invert. * @return the inverse of the color. The alpha of the return value is the * same as the alpha of the input. * @since 1.0.0 */ public static Color inverse(Color color) { return new Color(0xFF - color.getRed(), 0xFF - color.getGreen(), 0xFF - color.getBlue(), color.getAlpha()); } }