-
Notifications
You must be signed in to change notification settings - Fork 0
/
Java Script Code
43 lines (34 loc) · 1.02 KB
/
Java Script Code
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
var points =[];
var mult = 0.005;
function setup() {
createCanvas(800, 800);
background(30);
angleMode(DEGREES);
noiseDetail(1);
frameRate(30);
var density = 50;
var space = width / density;
for (var x=0; x < width; x+= space){
for (var y =0; y< height; y+=space){
var p = createVector(x + random(-10,10), y + random(-10,10));
points.push(p);
}
}
}
function draw() {
noStroke();
if (mouseIsPressed){
for (var i =0; i < points.length; i++){
var r = map(points[i].x, 0, width, 50, 255);
var g = map(points[i].y, 0, height, 50, 255);
var b = map(points[i].x, 0, width, 255, 50);
var alpha = map(dist(width/ 5, height/ 3, points[i].x, points[i].y), 0, 350, 255, 0)
fill(r,g,b, alpha);
var angle = map(noise(points[i].x * mult, points[i].y * mult), 0, 1, 0, 720);
points[i].add(createVector(cos(angle), sin(angle)));
if (dist(width/2, height/2, points[i].x, points[i].y)<200){
ellipse(points[i].x, points[i].y, 1);
}
}
}
}