-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerativePattern.js
54 lines (44 loc) · 1.02 KB
/
generativePattern.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
var circle = [];
var spce;
function setup(){
createCanvas(800, 800);
background(color(18, 6, 16));
circles = [];
space = 50;
for (var i = -2 * space ; i <= (width) + space; i += space) {
for (var j = -2 * space ; j <= (height) + space; j += space) {
circles.push(new Circle(i, j));
}
}
}
function draw(){
fill(color(36, 12, 32), 255);
rect(0, 0, width, height);
for(c in circles){
circles[c].update();
circles[c].draw();
}
}
function Circle(x, y){
this.cx = x;
this.cy = y;
this.rT = 500;
this.offset = random(-PI/8, PI/8);
this.size = 50;
this.rx, this.ry;
}
Circle.prototype.update = function(){
var t = millis()/this.rT;
t += cos(abs(1-(this.cx/(width/2))))*TWO_PI;
t += cos(abs(1-(this.cx/(height/2))))*TWO_PI;
t += this.offset;
this.rx = sin(t) * this.size;
this.ry = this.rx;
}
Circle.prototype.draw = function(){
if (this.rx > 0 && this.ry > 0) {
noStroke();
fill(color(227, 223, 210));
ellipse(this.cx, this.cy, this.rx, this.ry);
}
}