-
Notifications
You must be signed in to change notification settings - Fork 13
/
p5.Polar.min.js
2 lines (2 loc) · 3.85 KB
/
p5.Polar.min.js
1
2
// p5.Polar.min.js, version 2.3 Sep 5th 2023, created by Liz Peng
p5.prototype.setCenter=function(t,s){void 0===this.center&&(this.center={x:t,y:s}),this.translate(this.center.x=t,this.center.y=s)},p5.prototype.shiftRotate=function(t,s){const i=this.radians(t);this.translate(this.sin(i)*s,this.cos(i)*-s),this.rotate(this.radians(t))},p5.prototype.polarDrawCallback=function(t,s,i,o){const h=360/t;for(let p=1;p<=t;p++)this.push(),this.shiftRotate(p*h,i),o(p,h,s,i),this.pop()},p5.prototype.polarTriangle=function(t,s,i){this.push(),this.shiftRotate(t,i),this.triangle(this.sin(0),this.cos(0)*-s,this.sin(1*this.TWO_PI/3)*s,this.cos(1*this.TWO_PI/3)*-s,this.sin(2*this.TWO_PI/3)*s,this.cos(2*this.TWO_PI/3)*-s),this.pop()},p5.prototype.polarTriangles=function(t,s,i,o){const h=360/t;for(let p=1;p<=t;p++)if(o){const t=o(p,h,s,i);this.polarTriangle(t[0]*t[1],t[2],t[3])}else this.polarTriangle(p*h,s,i)},p5.prototype.polarEllipse=function(t,s,i,o){this.push(),this.shiftRotate(t,o),this.ellipse(0,0,2*s,2*i),this.pop()},p5.prototype.polarEllipses=function(t,s,i,o,h){const p=360/t;for(let e=1;e<=t;e++)if(h){const t=h(e,p,s,i,o);this.polarEllipse(t[0]*t[1],t[2],t[3],t[4])}else this.polarEllipse(e*p,s,i,o)},p5.prototype.polarLine=function(t,s,i){this.push(),this.shiftRotate(t,i),this.line(0,s,0,-s),this.pop()},p5.prototype.polarLines=function(t,s,i,o){const h=360/t;for(let p=1;p<=t;p++)if(o){const t=o(p,h,s,i);this.polarLine(t[0]*t[1],t[2],t[3])}else this.polarLine(p*h,s,i)},p5.prototype.polarSquare=function(t,s,i){this.push(),this.shiftRotate(t,i),this.square(-s,-s,2*s),this.pop()},p5.prototype.polarSquares=function(t,s,i,o){const h=360/t;for(let p=1;p<=t;p++)if(o){const t=o(p,h,s,i);this.polarSquare(t[0]*t[1],t[2],t[3])}else this.polarSquare(p*h,s,i)},p5.prototype.polarPentagon=function(t,s,i){this.push();const o=this.radians(t);this.translate(this.sin(o)*i,this.cos(o)*-i),this.rotate(this.radians(t)+60),this.beginShape();for(let t=1;t<=5;t++)this.vertex(this.cos(this.TWO_PI*t/5)*s,this.sin(this.TWO_PI*t/5)*s);this.endShape(this.CLOSE),this.pop()},p5.prototype.polarPentagons=function(t,s,i,o){const h=360/t;for(let p=1;p<=t;p++)if(o){const t=o(p,h,s,i);this.polarPentagon(t[0]*t[1],t[2],t[3])}else this.polarPentagon(p*h,s,i)},p5.prototype.polarHexagon=function(t,s,i){this.push(),this.shiftRotate(t,i),this.beginShape();for(let t=0;t<6;t++)this.vertex(this.cos(this.TWO_PI*t/6)*s,this.sin(this.TWO_PI*t/6)*s);this.endShape(this.CLOSE),this.pop()},p5.prototype.polarHexagons=function(t,s,i,o){const h=360/t;for(let p=1;p<=t;p++)if(o){const t=o(p,h,s,i);this.polarHexagon(t[0]*t[1],t[2],t[3])}else this.polarHexagon(p*h,s,i)},p5.prototype.polarHeptagon=function(t,s,i){this.push();const o=this.radians(t);this.translate(this.sin(o)*i,this.cos(o)*-i),this.rotate(this.radians(t)+11),this.beginShape();for(let t=1;t<=7;t++)this.vertex(this.cos(this.TWO_PI*t/7)*s,this.sin(this.TWO_PI*t/7)*s);this.endShape(this.CLOSE),this.pop()},p5.prototype.polarHeptagons=function(t,s,i,o){const h=360/t;for(let p=1;p<=t;p++)if(o){const t=o(p,h,s,i);this.polarHeptagon(t[0]*t[1],t[2],t[3])}else this.polarHeptagon(p*h,s,i)},p5.prototype.polarOctagon=function(t,s,i){this.push(),this.shiftRotate(t,i),this.beginShape();for(let t=1;t<=8;t++)this.vertex(this.cos(this.TWO_PI*t/8)*s,this.sin(this.TWO_PI*t/8)*s);this.endShape(this.CLOSE),this.pop()},p5.prototype.polarOctagons=function(t,s,i,o){const h=360/t;for(let p=1;p<=t;p++)if(o){const t=o(p,h,s,i);this.polarOctagon(t[0]*t[1],t[2],t[3])}else this.polarOctagon(p*h,s,i)},p5.prototype.polarPolygon=function(t,s,i,o){this.push(),this.shiftRotate(s,o),this.beginShape();for(let s=1;s<=t;s++)this.vertex(this.cos(this.TWO_PI*s/t)*i,this.sin(this.TWO_PI*s/t)*i);this.endShape(this.CLOSE),this.pop()},p5.prototype.polarPolygons=function(t,s,i,o,h){const p=360/t;for(let e=1;e<=t;e++)if(h){const t=h(e,p,s,i,o);this.polarPolygon(t[2],t[0]*t[1],t[3],t[4])}else this.polarPolygon(s,e*p,i,o)};