xxxxxxxxxx
41
var p =[];
var n = 320;
function setup() {
createCanvas(450, 450);
fill(255);noStroke();
textSize(90);
textFont("Helvetica, Futura, Futura PT");
for(var i=0;i<n;i++){
var r = random(TWO_PI);
p[i] = new PingPong(random(width),random(height),3*cos(r),3*sin(r));
}
background(0);
}
function draw() {
background(0,127);
for(var i=0;i<n;i++){
p[i].draw();
}
fill(0,0);//fill(0,192);
rect(60,60,280,70);
fill(255);
text("😌🙄😴",width/2-textWidth("😌🙄😴")/2,height/2+40);
}
class PingPong{
constructor(_x,_y,_vx,_vy){
this.loc = createVector(_x,_y);
this.speed = createVector(_vx,_vy);
this.radius = 8;
this.c = 0;
}
draw(){
fill(255,(this.c*15)%255,(this.c*25)%255);
circle(this.loc.x,this.loc.y,this.radius);
this.loc.add(this.speed);
if(this.loc.x<=0||this.loc.x>=width){this.speed.x=-this.speed.x;this.c++;}
if(this.loc.y<=0||this.loc.y>=height){this.speed.y=-this.speed.y;this.c++;}
}
}