xxxxxxxxxx
83
var centervec
function setup() {
createCanvas(400, 400);
centervec =createVector(width/2,height/2);
strokeWeight(2);
filter(BLUR, 10);
}
smoothie = 10;
function pentip(t){
let px = noise(t/smoothie) * width;
let py = noise(t*2/smoothie) * height;
let v = createVector(px, py)
let direction = p5.Vector.sub(v, centervec).setMag(4.7);
lines.push([v, direction])
push();
translate(px,py);
rotate(a);
triangle(0, 0, -10, 20, 10, 20)
pop();
}
var t = 0;
var a = 3.14;
var r = 0;
const TA = 0.0002
var thet = 0.0005;
const TB = 0.00005
var d = 0.00005;
const lines = [];
function draw() {
background(222);
pentip(t);
t += thet;
for (var i = lines.length-2; i > -1; i--) {
var [v1, direction] = lines[i]
var v2 = lines[i+1]
line(v1.x, v1.y, v2.x, v2.y)
v2.x = v1.x
v2.y = v1.y;
v1.add(direction);
if (v1.x < 0 || v1.y < 0 || v1.x > width || v1.y > height){
lines.splice(i,1)
}
}
thet +=d;
if (thet < TA && thet > TB ){
d = -d;
}
// yeah TODO KEEP IT UPRIGHT
a = (Math.random() >= 0.5) ? a+30*d : a-30*d;
}