-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlowField
58 lines (43 loc) · 1.06 KB
/
FlowField
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
var points = []
var mult
var r1
var r2
var g1
var g2
var b1
var b2
function setup() {
createCanvas(windowWidth, windowHeight);
background(30)
angleMode(DEGREES)
noiseDetail(1)
var density = 30
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)
}
}
shuffle(points,true)
r1 = random(255)
r2 = random(255)
g1 = random(255)
g2 = random(255)
b1 = random(255)
b2 = random(255)
mult=random(0.002,0.01)
}
function draw() {
noStroke()
for (var i=0; i< points.length; i++){
var r =map(points[i].x,0,width,r1,r2)
var g =map(points[i].x,0,height,g1,g2)
var b =map(points[i].x,0,width,b1,b2)
var alpha = map(dist(width/2, height/2,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)))
ellipse(points[i].x,points[i].y, 1)
}
}