-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathColorScheme.java
45 lines (40 loc) · 1.36 KB
/
ColorScheme.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package mandelbrot;
/**
* A color scheme.
* @author Eric Mosher
*/
public class ColorScheme {
// Store the maximum iterations as a number to use in the calculations
// of color.
private int maxIterations;
/**
* Construct a color scheme object
* @param maxIterations for use in calculation
*/
public ColorScheme(int maxIterations){
this.maxIterations = maxIterations;
}
/**
* Get the color of a point
* @param i the number to color
* @return the color in this color scheme
*/
public int getColor(int i) {
// A color scheme
int a = (int) (255 * ((double) i) / (maxIterations / 4));
return
// Red & black with fade, a classic!
// ( (2*a<<16) );
// Other options of varying qualities...
// Hot pink bar & black
// ( (255 * (i/15)) << 16 | (255 * (i/15)) );
// Red bars & black
// ((255 * (i/20)) << 16 | 0 | 0 );
// The cow level! Black & white bars
// ((255 * (i/10)) << 16 | (255 * (i/10)) << 8 | (255 * (i/10)) );
// Blue, blue-green fade, and black
// (65536 + i*256 + i/2+128);
// Black & purple/pink fade
( (0) | (2*a<<16) | (a<<8) | ((a*2)<<0) );
}
}