xxxxxxxxxx
89
class JellyFish {
constructor(x,y,size){
this.x = x;
this.y = y;
this.size = size;
this.inc = 0.05//random(0.01,0.009);
}
display(){
angleMode(DEGREES);
push();
translate(this.x,this.y);
strokeWeight(this.size * 0.009);
let step = this.size * 0.025;
rotate(270);
stroke(255);
fill(0);
let angleOffset = 0;
let nOffset;
for(let i=angleOffset; i<180 - angleOffset; i+=step){
let posx = cos(i) * this.size;
let posy = sin(i) * this.size;
let negx = cos(-i) * this.size;
let negy = sin(-i) * this.size;
let p1 = createVector(posx, posy);
let p2 = createVector(negx, negy);
let d = abs(p2.dist(p1));
nOffset = frameCount * sin(d * 0.009);
beginShape();
for(let j=0; j<d; j+=2){
let _x = posx + cos(-90) * j;
let _y = posy + sin(-90) * j;
let c = createVector(posx,posy - d/2);
let dFromC = c.dist(createVector(_x,_y));
let m;
// strokeWeight(d * 0.005);
if(dFromC < (d * 0.25)){
let perlin = noise(nOffset);
m = _x + (perlin * d * 0.09);
nOffset+=this.inc;
}else{
m = _x;
}
vertex(m,_y);
}
endShape();
}
pop();
}
}