-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHorseshoe.pde
More file actions
161 lines (124 loc) · 2.96 KB
/
Horseshoe.pde
File metadata and controls
161 lines (124 loc) · 2.96 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
Coded by Víctor Doval.
Title: Horseshoe Arches Cristal's Land.
Description: Loop throught horseshoe arches' geometry with a double draw to get wireframe and filled geometry
and some post-processing.
Created: 2014 Nov.
Pusblished at http://lightprocesses.tumblr.com/
This work is licensed under the MIT License
(It lets people do anything they want with your code as long as they provide attribution
back to you and don't hold you liable)
*/
PImage bas, basWire, fir;
float mar=0.25;
float diag;
color cl=#1C1616;
PShape pr;
float camx, camy;
int co;
float siz=500;
void setup() {
size(500, 500, P3D);
diag=width*sqrt(2)/2;
camx=width/2.0-80;
camy=height/2.0+225;
frameRate(1);
// noLoop();
smooth(16);
fir=loadImage("fir.png");
bas= new PImage(width, height);
basWire= new PImage(width, height);
}
void draw() {
co=frameCount%15;
background(255);
camSet();
geomdraw();
post();
}
void camSet() {
float fov = PI/3.0;
float cameraZ = (height/2.0) / tan(fov/2.0);
perspective(fov, float(width)/float(height),
cameraZ/100.0, cameraZ*50.0);
camera(camx, camy, (height/2.0) / tan(PI*30.0 / 180.0),
width/2.0, height/2.0+50, 0,
0, 1, 0);
}
void geomdraw() {
for (int k=0; k<2; k++) {
if (k==0)noFill();
if (k==1) fill(cl);
pushMatrix();
translate(width/2, height/2, -250);
for (int j=-5; j<5; j++) {
for (int i=0; i<15; i++) {
pushMatrix();
float zp=siz-i*siz+co*siz/15.0;
translate(j*siz, 0, zp);
float d=dist(j*siz, zp, camx, 0);
float col=map(d, 10, 5000, 255, 0);
stroke(cl, col);
portic(siz);
rotateY(HALF_PI);
translate(siz/2, 0, -siz/2);
portic(siz);
popMatrix();
}
}
popMatrix();
if (k==0) basWire=get();
if (k==1) bas=get();
}
camera();
}
void portic(float s) {
pushMatrix();
translate(-s/2, -s/2);
for (int i=0; i<2; i++) {
translate(0, 0, s/100*i);
beginShape();
vertex(0, 0);
vertex(s, 0);
vertex(s, s);
vertex(s-s*mar, s);
for (int j=0; j<=40; j++) {
float arq=3*TAU/4;
float rad=(1-2*mar)*s*cos(PI/4);
vertex(s/2+rad*sin(j*arq/40+PI-arq/2), s/1.5+rad*cos(j*arq/40+PI-arq/2));
}
vertex(s*mar, s);
vertex(0, s);
endShape(CLOSE);
}
popMatrix();
}
void post() {
background(cl);
tint(255, 255);
image(basWire, 0, 0);
tint(255, 127);
image(bas, 0, 0);
filter(BLUR, 3);
blendMode(ADD);
tint(255, 64);
image(basWire, 0, 0);
tint(255, 127);
image(bas, 0, 0);
blendMode(BLEND);
filt(cl);
blendMode(ADD);
image(fir, width-fir.width, height-fir.height);
blendMode(BLEND);
saveFrame("im/###.jpg");
if (frameCount==15)exit();
}
void filt(color c) {
loadPixels();
for (int i=0; i<pixels.length; i++) {
float d=dist(width/2, height/2, i%width, int(i/width));
// pixels[i]=color(255-min(d,255));
pixels[i]=lerpColor(pixels[i], c, d/diag);
}
updatePixels();
}