xxxxxxxxxx
function setup() {
createCanvas(windowWidth, windowHeight);
textAlign(CENTER,CENTER);
line(windowWidth/2, 0, windowWidth/2, windowHeight);
line(0, windowHeight/2, windowWidth, windowHeight/2);
origin = createVector(windowWidth/2, windowHeight/2);
strokeWeight(3);
stroke(0);
fill(255);
frameRate(60);
background(0);
}
var active = [];
var speed = 3;
var speedsize = 1;
var origin;
var t = 0;
var colors = ["#ff0000", "#ee82ee", "#008000", "#0000ff"]
class Cls {
constructor(text, pos, mov, color) {
this.text = text;
this.pos = pos;
this.mov = mov.normalize().mult(speed);
this.size = 32
this.color = color;
}
draw() {
textSize(this.size);
stroke(this.color);
text(this.text, this.pos.x, this.pos.y);
this.pos.add(this.mov);
this.size += speedsize;
this.mov.mult(0.9999);
}
}
function draw() {
t += 1
if (t%20 == 1) {
angle = random()*TWO_PI;
var v = new Cls("MPSI", createVector(origin.x, origin.y), createVector(cos(angle), sin(angle)), colors[floor(random()*colors.length)]);
active.push(v);
}
print(active[0].pos.x);
for (var i = active.length-1; i > 0; i--) {
v = active[i];
if (v != null) {
v.draw();
if (v.pos.x < -100 || v.pos.x > windowWidth+100 || v.pos.y < -100 || v.pos.y > windowHeight+100) {
active[i] = null;
}
}
}
}