-
Notifications
You must be signed in to change notification settings - Fork 0
/
DomeFunctions.pde
80 lines (71 loc) · 1.81 KB
/
DomeFunctions.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
68
69
70
71
72
73
74
75
76
77
78
79
float hscale = 0.99;
float vscale = 1.064;
void domeEllipse(float angle, float distance, float w, float h)
{
pushMatrix();
TranslateAndRotate(angle, distance);
ellipse(0, 0, w*hscale, h*vscale);
popMatrix();
}
void domePixel(float angle, float distance)
{
pushMatrix();
TranslateAndRotate(angle, distance);
point(0, 0);
popMatrix();
}
void domeRectangle(float angle, float distance, float w, float h)
{
pushMatrix();
TranslateAndRotate(angle, distance);
rectMode(CENTER);
rect(0, 0, w*hscale, h*vscale);
popMatrix();
}
void domeLine()
{
}
void domeImage(PImage img, float angle, float distance)
{
pushMatrix();
TranslateAndRotate(angle, distance);
imageMode(CENTER);
image(img,0,0);
popMatrix();
}
void domeImage(PImage img, float angle, float distance, float w, float h)
{
pushMatrix();
TranslateAndRotate(angle, distance);
imageMode(CENTER);
image(img,0,0,w*hscale,h*vscale);
popMatrix();
}
void domeLine(float fromAngle, float fromDistance, float toAngle, float toDistance)
{
float fromRads = radians(fromAngle);
float toRads = radians(toAngle);
pushMatrix();
translate(width/2, height/3);
float fromX = fromDistance*((width/2.0)/100.0) * sin(fromRads);
fromX = fromX * hscale;
float fromY = fromDistance*((width/2.0)/100.0) * cos(fromRads);
fromY = fromY * vscale;
float toX = toDistance*((width/2.0)/100.0) * sin(toRads);
toX = toX * hscale;
float toY = toDistance*((width/2.0)/100.0) * cos(toRads);
toY = toY * vscale;
line(fromX,fromY,toX,toY);
popMatrix();
}
void TranslateAndRotate(float angle, float distance)
{
float rads = radians(angle);
translate(width/2, height/3);
float x = distance*((width/2.0)/100.0) * sin(rads);
x = x * hscale;
float y = distance*((width/2.0)/100.0) * cos(rads);
y = y * vscale;
translate(x, y);
rotate(-rads);
}