package org.coffeeshop.awt;

import java.awt.Color;

public class Colors {

    /*public static Color brighter(Color c, double factor) {
        int r = c.getRed();
        int g = c.getGreen();
        int b = c.getBlue();

        factor = Math.max(0, factor);
        
        * From 2D group:
         * 1. black.brighter() should return grey
         * 2. applying brighter to blue will always return blue, brighter
         * 3. non pure color (non zero rgb) will eventually return white
         *
        int i = (int)(1.0/(1.0-factor));
        if ( r == 0 && g == 0 && b == 0) {
           return new Color(i, i, i);
        }
        if ( r > 0 && r < i ) r = i;
        if ( g > 0 && g < i ) g = i;
        if ( b > 0 && b < i ) b = i;

        return new Color(Math.min((int)(r/factor), 255),
                         Math.min((int)(g/factor), 255),
                         Math.min((int)(b/factor), 255));
    }*/
        

    public static Color changeBrightness(Color c, double factor) {
    	
    	float hsv[] = new float[3];
    	
    	Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsv);

        factor = Math.max(0, factor);
    	
    	hsv[2] = (float)factor;
        
        return new Color(Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]));
    }
    
}

@@ -1269,10 +1269,347 @@
  %7D%0A    %0A
+    public static Color changeSaturation(Color c, double factor) %7B%0A    %09%0A    %09float hsv%5B%5D = new float%5B3%5D;%0A    %09%0A    %09Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsv);%0A%0A        factor = Math.max(0, factor);%0A    %09%0A    %09hsv%5B1%5D = (float)factor;%0A        %0A        return new Color(Color.HSBtoRGB(hsv%5B0%5D, hsv%5B1%5D, hsv%5B2%5D));%0A    %7D%0A    %0A
 %7D%0A

Change color saturation method.