xxxxxxxxxx
76
let ww = 100;
let hh = 100;
let ro = 0;
let arr = [];
function setup() {
createCanvas(400, 400);
rectMode(CENTER);
angleMode(DEGREES);
}
function draw() {
background(155,2);
stroke(255,100);
noFill();
for(let j = 0; j < arr.length; j++){
arr[j].update();
// if(arr[j].w < 0){
// stroke(255,55);
//for(let i = 10; i < width; i += width/20){
// for(let j = 10; j < height; j += height/20){
// fill(255);
// }
//}
//}
}
let randomRadius = random(0,15);
for(let i = 10; i < width; i += width/20){
for(let j = 10; j < height; j += height/20){
ellipse(random(i,i+3),random(j,j+3),randomRadius,randomRadius);
}
}
stroke(255);
noFill();
}
function mouseDragged(){
let a = new AcidRain(mouseX,mouseY,ww,hh,2,mouseX,mouseY,ww,300);
arr.push(a);
}
class AcidRain{
constructor(x,y,w,h,speed,tw,th,osize,opacity){
//constructor(x,y,w,h){
this.x= x;
this.y= y;
this.w= w;
this.h= h;
this.speed = speed;
this.tw = tw;
this.th = th;
this.osize = osize;
this.opacity = opacity;
}
update(){
fill(0,this.opacity);
//translate(300,300);
ellipse(this.x,this.y,this.w,this.h);
if(this.h < 0 ){
fill(0,this.opacity);
this.opacity-=2;
}
if(this.w < -400){
this.w == 0;
this.h ==0;
}
this.w-=.5;
this.h-=.5;
}
}