-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDomeStarMap.pde
67 lines (54 loc) · 1.21 KB
/
DomeStarMap.pde
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
class DomeStarMap {
class MapEntry {
int x;
int y;
float d;
}
MapEntry[] lookup;
color[] buffer;
public DomeStarMap() {
lookup = new MapEntry[360*360];
buffer = new color[160*40];
this.buildMap();
}
public void buildMap() {
float f;
float dist;
int x,y,dx,dy;
int i,j,idx;
for (i=0; i<lookup.length; i++) {
lookup[i] = new MapEntry();
}
for (i=0; i<3200; i++) {
f = TWO_PI/3200*i;
dx = i/80;
dist = (1-(i%80/80.0));
for (j=20; j<180; j++) {
x = int(180+sin(f)*j);
y = int(180+cos(f)*j);
dy = j-20;
idx = (y*360+x);
lookup[idx].x = dx;
lookup[idx].y = dy;
lookup[idx].d = dist;
}
}
}
public color[] applyMap() {
PImage image = get(0,0,360,360);
image.loadPixels();
MapEntry m;
int idx,x,y,z;
color c;
for (int i=0; i<image.pixels.length; i++) {
m = lookup[i];
x = m.x;
c = image.pixels[i];
buffer[m.y*40+x] = lerpColor(buffer[m.y*40+x],c,m.d);
x++;
if (x>39) x = 0;
buffer[m.y*40+x] = lerpColor(buffer[m.y*40+x],c,1.0-m.d);
}
return buffer;
}
}