Java examples for 2D Graphics:Color RGB
Gets the complementary color to a given rgb set.
//package com.java2s; import java.awt.Color; public class Main { /**/*from w w w. j a v a 2 s. c o m*/ * Gets the complementary color to a given rgb set. * @param r The red value of the color. * @param g The green value of the color. * @param b The blue value of the color. * @return The complementary color. */ public static Color getComplementary(final int r, final int g, final int b) { return new Color(255 - r, 255 - g, 255 - b); } /** * Gets the complementary color to a given color. * @param color The color to complement. * @return The complementary color. */ public static Color getComplementary(final Color color) { return new Color(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue()); } }