mirror of https://github.com/rusefi/RomRaider.git
color scaler utility class added for determining color based on a scale from 0 to 1
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@162 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
799990e270
commit
c6d3fc8907
|
@ -0,0 +1,26 @@
|
|||
package enginuity.util;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public final class ColorScaler {
|
||||
private static final int MAX_COLOR_INTENSITY = 200;
|
||||
|
||||
private ColorScaler() {
|
||||
}
|
||||
|
||||
public static Color getScaledColor(double scale) {
|
||||
int r = (int) ((Math.cos(Math.toRadians(180 + scale * 180)) + 1) * MAX_COLOR_INTENSITY / 2) + 30;
|
||||
int g = (int) ((Math.cos(Math.toRadians(180 + scale * 360)) + 1) * MAX_COLOR_INTENSITY / 2) + 60;
|
||||
int b = (int) ((Math.cos(Math.toRadians(scale * 180)) + 1) * MAX_COLOR_INTENSITY / 2) + 20;
|
||||
|
||||
if (r > MAX_COLOR_INTENSITY) r = MAX_COLOR_INTENSITY;
|
||||
if (g > MAX_COLOR_INTENSITY) g = MAX_COLOR_INTENSITY;
|
||||
if (b > MAX_COLOR_INTENSITY) b = MAX_COLOR_INTENSITY;
|
||||
|
||||
if (r < 0) r = 0;
|
||||
if (g < 0) g = 0;
|
||||
if (b < 0) b = 0;
|
||||
|
||||
return new Color(r, g, b);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue