DeviceRgb extends Color { public static DeviceRgb makeDarker(DeviceRgb rgbColor) { float r = rgbColor.getColorValue()[0]; float g = rgbColor.getColorValue()[1]; float b = rgbColor.getColorValue()[2]; float v = Math.max(r, Math.max(g, b)); float multiplier = Math.max(0f, (v - 0.33f) / v); r = multiplier * r; g = multiplier * g; b = multiplier * b; return new DeviceRgb(r, g, b); } DeviceRgb(int r, int g, int b);  DeviceRgb(float r, float g, float b);  DeviceRgb(java.awt.Color color);  DeviceRgb(); static DeviceRgb makeLighter(DeviceRgb rgbColor); static DeviceRgb makeDarker(DeviceRgb rgbColor); static final Color BLACK; static final Color WHITE; static final Color RED; static final Color GREEN; static final Color BLUE; }
@Test public void makeDarkerTest() { DeviceRgb rgbColor = new DeviceRgb(50, 100, 150); DeviceRgb darkerRgbColor = DeviceRgb.makeDarker(rgbColor); float multiplier = Math.max(0f, (150f / 255 - 0.33f) / (150f / 255)); Assert.assertEquals(multiplier * (50f / 255), darkerRgbColor.getColorValue()[0], 0.0001); Assert.assertEquals(multiplier * (100f / 255), darkerRgbColor.getColorValue()[1], 0.0001); Assert.assertEquals(multiplier * (150f / 255), darkerRgbColor.getColorValue()[2], 0.0001); }