Add some gemometry point classes in math\geometry package and standard draw libaray

This commit is contained in:
2014-03-15 10:34:20 +01:00
parent a3762a99e6
commit c0033f60be
6 changed files with 1598 additions and 0 deletions

105
src/stdlib/Color.java Normal file
View File

@@ -0,0 +1,105 @@
package stdlib;
public class Color extends java.awt.Color{
/**
* UID
*/
private static final long serialVersionUID = -6866051674205095467L;
// Color from java.awt.Color
public static final Color WHITE = new Color(255, 255, 255);
public static final Color LIGHT_GRAY = new Color(192, 192, 192);
public static final Color GRAY = new Color(128, 128, 128);
public static final Color DARK_GRAY = new Color( 64, 64, 64);
public static final Color BLACK = new Color( 0, 0, 0);
public static final Color RED = new Color(255, 0, 0);
public static final Color PINK = new Color(255, 175, 175);
public static final Color ORANGE = new Color(255, 200, 0);
public static final Color YELLOW = new Color(255, 255, 0);
public static final Color GREEN = new Color( 0, 255, 0);
public static final Color MAGENTA = new Color(255, 0, 255);
public static final Color CYAN = new Color( 0, 255, 255);
public static final Color BLUE = new Color( 0, 0, 255);
public static final Color DIM_GRAY = new Color(105, 105, 105);
public static final Color JET = new Color( 52, 52, 52);
public static final Color BROWN = new Color(165, 42, 42);
public static final Color DARK_RED = new Color(139, 0, 0);
public static final Color DEEPSKYBLUE = new Color( 0, 191, 255);
public static final Color PURPLE = new Color(160, 32, 240);
public static final Color BLUE_GREEN = new Color( 9, 90, 166);
public static final Color LIGHT_BLUE = new Color(103, 198, 243);
public static final Color LIGHT_RED = new Color(150, 35, 31);
public Color(int rgb){
super(rgb);
}
public Color(int r, int g, int b) {
super(r, g, b);
}
public Color(float h, float s, float b){
super(h, s, b);
}
public Color(int i, int j, int k, int l) {
super(i, j, k, l);
}
public static Color getHSBColor(float h, float s, float b) {
return new Color(HSBtoRGB(h, s, b));
}
public static int HSBtoRGB(float hue, float saturation, float brightness) {
int r = 0, g = 0, b = 0;
if (saturation == 0) {
r = g = b = (int) (brightness * 255.0f + 0.5f);
} else {
float h = (hue - (float)Math.floor(hue)) * 6.0f;
float f = h - (float)java.lang.Math.floor(h);
float p = brightness * (1.0f - saturation);
float q = brightness * (1.0f - saturation * f);
float t = brightness * (1.0f - (saturation * (1.0f - f)));
switch ((int) h) {
case 0:
r = (int) (brightness * 255.0f + 0.5f);
g = (int) (t * 255.0f + 0.5f);
b = (int) (p * 255.0f + 0.5f);
break;
case 1:
r = (int) (q * 255.0f + 0.5f);
g = (int) (brightness * 255.0f + 0.5f);
b = (int) (p * 255.0f + 0.5f);
break;
case 2:
r = (int) (p * 255.0f + 0.5f);
g = (int) (brightness * 255.0f + 0.5f);
b = (int) (t * 255.0f + 0.5f);
break;
case 3:
r = (int) (p * 255.0f + 0.5f);
g = (int) (q * 255.0f + 0.5f);
b = (int) (brightness * 255.0f + 0.5f);
break;
case 4:
r = (int) (t * 255.0f + 0.5f);
g = (int) (p * 255.0f + 0.5f);
b = (int) (brightness * 255.0f + 0.5f);
break;
case 5:
r = (int) (brightness * 255.0f + 0.5f);
g = (int) (p * 255.0f + 0.5f);
b = (int) (q * 255.0f + 0.5f);
break;
}
}
return 0xff000000 | (r << 16) | (g << 8) | (b << 0);
}
}

1147
src/stdlib/StdDraw.java Normal file

File diff suppressed because it is too large Load Diff