-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
116 lines (92 loc) · 2.11 KB
/
sketch.js
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
var organics = [];
var change;
var myr = 24;
var yoff = 0.0;
var r1 = 50;
var rough = 18;
var the_x, the_y;
function setup() {
createCanvas(1024, 768);
angleMode(DEGREES);
//frameRate(32);
change = 0;
for (var i = 0; i < 660; i += 11) {
organics.push(new Organic(0.1 + 1 * i, width - 70, 70, i*0.7, i * random(180)));
}
}
function draw() {
background(0);
push();
translate(0, height);
beginShape();
noStroke();
var xoff = 0;
var offset;
for (var a = -180; a < 180; a += 8) {
offset = map(noise(xoff, yoff), 0, 1, -rough, rough);
//var offset = map(noise(sin(xoff)*a+0.5, cos(yoff)*a+0.5), 0, 1, -25, 25);
var r2 = r1 + offset;
var x = r2 * cos(a);
var y = r2 * sin(a);
if (a == -44) {
the_x = x;
the_y = y;
//ellipse(the_x, the_y, 6);
}
curveVertex(x, y);
xoff += 0.1;
//ellipse(x, y, 4, 4);
}
endShape(CLOSE);
yoff += 0.02;
var k = random(-2, 3);
if (r1 <= 600 ) {
r1 += k;
}
if (rough < 300) {
rough += k;
}
pop();
push();
for (var i = 0; i < organics.length; i++) {
organics[i].show(change);
}
change += 0.005;
pop();
}
function Organic(radius, xpos, ypos, roughness, angle) {
this.radius = radius;
this.xpos = xpos;
this.ypos = ypos;
this.roughness = roughness;
this.angle = angle;
this.show = function(change) {
//noStroke();
strokeWeight(0.5);
stroke(200);
noFill();
push();
translate(xpos, ypos);
rotate(this.angle + change);
beginShape();
var xoff = 0;
for (var i = 0; i < 360; i += 6) {
//var offset = map(sin(i*10+frameCount*0.01), -1, 1, -this.roughness, this.roughness);
var offset = map(noise(xoff, change), 0, 1, -this.roughness, this.roughness);
var dis = floor(dist(width - 70, 70, the_x, the_y));
var r;
if (dis > this.radius + myr) {
r = this.radius + offset;
} else {
r = (dis - myr - 300) + offset;
console.log("r" + r);
}
var x = r * cos(i);
var y = r * sin(i);
curveVertex(x, y);
xoff += 0.1;
}
endShape(CLOSE);
pop();
}
}