-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsketch_smooth_curves.pde
More file actions
126 lines (95 loc) · 2.2 KB
/
Copy pathsketch_smooth_curves.pde
File metadata and controls
126 lines (95 loc) · 2.2 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
int SIZE=1000;
int W = 750;
int H = 1000;
int SEED = getSeed();
int getSeed() {
return floor(random(999999999));
}
String getFilename(int scale) {
if (scale > 1) {
return "smooth_curves_"+ SEED +"-HD-"+ scale +".png";
}
return "smooth_curves_"+ SEED +".png";
}
void setup() {
size(750, 1000);
seededRender();
}
void draw() {}
void seededRender() {
randomSeed(SEED);
noiseSeed(SEED);
println("SEED: "+ SEED);
render();
}
void render() {
background(255);
//background(0);
noFill();
// background texture
//stroke(255, 100, 0, 20);
stroke(0, 20);
for (float y=-H*.01; y<H*1.2; y+=H*.005) {
beginShape();
for (float x=-W*.001; x<W*1.3; x+=W*.001) {
float o=noise(x*.01, y*.015) * H*.01 - H*.005;
vertex(x, y+o);
}
endShape();
}
// end
// add frame
//stroke(0);
//strokeWeight(SIZE*.002);
//rect(SIZE*.04, SIZE*.04, SIZE*.92, SIZE*.92);
// end frame
stroke(0, 20);
//stroke(255, 20);
//strokeWeight(random(1) > .5 ? 3 : 1);
strokeWeight(3);
for (float x=-W*.01; x<W*1.01; x+=.25) {
float v=0, w=x;
for (float y=H*1.01; y>-H*.01; y--) {
// Red-orange to pink
//stroke(225, map(x, 0, SIZE, 0, 150), map(x, 0, SIZE, 0, 255), 20);
// Blue to purple
//stroke(map(x, 0, SIZE, 0, 175), 0, map(x, 0, SIZE, 175, 255), 20);
// Deep Blue to Pink
//stroke(map(x, 0, SIZE, 0, 255), map(x, 0, SIZE, 25, 50), map(x, 0, SIZE, 100, 125), 20);
w+=v;
point(w, y);
v+=map(noise(w*.001, y*.002), 0, 1, -.009, .009);
v=constrain(v, -2, 2);
if (w<0) {
w+=W*1.01;
}
if (w>W*1.01) {
w-=W*0.01;
}
}
}
}
void saveHighRes(int scaleFactor) {
PGraphics hires = createGraphics(
width * scaleFactor,
height * scaleFactor,
JAVA2D);
println("Generating high-resolution image...");
beginRecord(hires);
hires.scale(scaleFactor);
seededRender();
endRecord();
hires.save(getFilename(scaleFactor));
println("Finished");
}
void keyPressed() {
println("Key pressed: "+ key);
if (key == 's') {
saveFrame(getFilename(1));
} else if (key == 'h') {
saveHighRes(14);
} else {
SEED = getSeed();
seededRender();
}
}