-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_own_nebula.js
44 lines (37 loc) · 942 Bytes
/
my_own_nebula.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
radius = 0;
r = 255;
g = 255;
b = 255;
var displayWidth, displayHeight;
function setup() {
createCanvas(displayWidth, displayHeight-150);
background(0);
noFill();
stroke(255, 45);
radius = width;
}
function draw() {
var center_x, center_y, noiseFactor, x, y;
center_x = mouseX;
center_y = mouseY;
stroke(r, g, b, 30);
beginShape();
TOTAL_DEGREES = document.getElementById("degrees").value;
for (var i = 0, _pj_a = TOTAL_DEGREES; i < _pj_a; i += 1) {
noiseFactor = noise(i * 0.02, Number.parseFloat(frameCount) / 140);
x = center_x + radius * cos(radians(i)) * noiseFactor;
y = center_y + radius * sin(radians(i)) * noiseFactor;
r = random(255);
g = random(120);
b = random(220);
curveVertex(x, y);
}
endShape();
radius -= 1;
if (radius === -600) {
radius += 1200;
}
}
function keyPressed() {
save("my_own_nebula.tif");
}