RosettaCodeData/Task/Superellipse/Processing/superellipse.processing

23 lines
375 B
Plaintext

//Aamrun, 29th June 2022
float a = 200, b = 200, n = 2.5;
float i, incr = 0.001;
int xMul,yMul;
size(500,500);
stroke(#ff0000);
for(i=0;i<2*PI;i+=incr){
if(PI/2<i && i<3*PI/2)
xMul = -1;
else
xMul = 1;
if(PI<i && i<2*PI)
yMul = -1;
else
yMul = 1;
ellipse(width/2 + xMul * a*pow(abs(cos(i)),2/n),height/2 + yMul * b*pow(abs(sin(i)),2/n),1,1);
}