-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLinea.js
66 lines (55 loc) · 1.71 KB
/
Linea.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
function Linea(_escala, _color, _behavior) {
this.escala = _escala;
this.pos = createVector(random(this.escala/2), random(this.escala/2));
this.sioNo = _behavior[6];
this.tam;
this.tamMaximo = _behavior[5];
this.vel = createVector(0, 0.1);
this.t = _behavior[0];
this.t2 = _behavior[1];
this.rRot = _behavior[2]; //rango de rotación para cambiar la dirección;
this.velT = _behavior[3]; // velocidad de cambio de dirección
this.velT2 = _behavior[4]; // velocidad de cambio de tamaño
this.c = _color;
}
Linea.prototype.test = function() {
if (this.pos.mag() >= this.escala) {
this.pos.normalize()
this.pos.mult(this.escala);
this.vel.mult(-1);
}
}
Linea.prototype.upDate = function() {
this.tam = map(noise(this.t2), 0, 1, 0.1, this.tamMaximo);
this.vel.rotate(map(noise(this.t), 0, 1, -this.rRot, this.rRot));
this.pos.add(this.vel);
this.t += this.velT;
this.t2 += this.velT2;
}
Linea.prototype.dibujar = function() {
if (this.sioNo) {
noStroke();
fill(this.c);
ellipse(this.pos.x, this.pos.y, this.tam, this.tam);
noFill();
stroke(0, 20);
strokeWeight(this.tam / 3);
ellipse(this.pos.x, this.pos.y, this.tam, this.tam);
stroke(hue(this.c), 50, 100, 3);
strokeWeight(this.tam / 7);
ellipse(this.pos.x, this.pos.y, this.tam * 10, this.tam/3);
}else{
noStroke();
fill(hue(this.c), saturation(this.c), 100, 10);
ellipse(this.pos.x, this.pos.y, this.tam, this.tam);
}
}
Linea.prototype.resize = function(_escala) {
this.pos.div(this.escala);
this.tam /= this.escala;
this.vel.div(this.escala);
this.escala = _escala; //cambio de escala
this.pos.mult(this.escala);
this.tam *= this.escala;
this.vel.mul(this.escala);
}