ColorUtilspublic final class ColorUtils extends Object Facilitates utility methods for handling SWT Colors |
Methods Summary |
---|
public static final org.eclipse.swt.graphics.Color | getBoundedShade(org.eclipse.swt.graphics.Color original, int delta)Gets a new SWT color that has been uniformly added with delta
If the a RGB value goes out of bounds, the delta will be applied negatively
final RGB newRGB = new RGB(
getBoundedShade(original.getRed(), delta),
getBoundedShade(original.getGreen(), delta),
getBoundedShade(original.getBlue(), delta)
);
return new Color(Display.getDefault(), newRGB);
| private static int | getBoundedShade(int origValue, int delta)Gets a 8bit RGB value that has been added with delta
If the RGB value goes out of bounds, the delta will be applied negatively
int result = origValue + delta;
if(result > 255)
{
result = origValue - delta;
if(result < 0)
{
result = origValue;
}
}
else if(result < 0)
{
result = origValue - delta;
if(result > 255)
{
result = origValue;
}
}
return result;
| public static final org.eclipse.swt.graphics.Color | getShade(org.eclipse.swt.graphics.Color original, int delta)Gets a new SWT color that has been uniformly added with delta
There is range checking such that the new RGB values are 0 <= x <= 255
final RGB newRGB = new RGB(
Math.min(255, Math.max(0, original.getRed() + delta)),
Math.min(255, Math.max(0, original.getGreen() + delta)),
Math.min(255, Math.max(0, original.getBlue() + delta))
);
return new Color(Display.getDefault(), newRGB);
|
|