jcanvas
Version:
jCanvas brings jQuery's powerful syntax and capability to the HTML5 canvas. Quickly create canvas-based apps that can utilize layers, animations, events, and much more. jCanvas works on all modern browsers and platforms, including iOS and Android.
3 lines (2 loc) • 807 B
JavaScript
import p from"jquery";const c=Math.pow,x=Math.sqrt,u=Math.PI;function m(n,s,r,o,d,h){const i=o-n,t=d-s,a=x(c(i,2)+c(t,2)),l=(c(a,2)+c(r,2)-c(h,2))/(2*a),y=n+i*l/a,v=s+t*l/a,f=x(c(r,2)-c(l,2)),C=-t*(f/a),M=i*(f/a),e=y+C,j=v+M;return a>r+h||a<Math.abs(r-h)?null:[e,j]}p.jCanvas.extend({name:"drawCrescent",type:"crescent",props:{eclipse:.5},fn:function(n,s){const r=2*s.radius*(1-s.eclipse),o=m(s.x,s.y,s.radius,s.x+r,s.y,s.radius);if(!o)return;const d=o[0]-s.x,h=o[1]-s.y,i=Math.atan2(h,d);let t,a;s.eclipse<=0?(t=0,a=2*u):(t=i,a=-i),s.eclipse<1&&(p.jCanvas.transformShape(this,n,s),n.beginPath(),n.arc(s.x,s.y,s.radius,t,a,!1),s.eclipse>0&&n.arc(s.x+r,s.y,s.radius,u+t,u+a,!0),p.jCanvas.detectEvents(this,n,s),s.closed=!0,p.jCanvas.closePath(this,n,s))}});
//# sourceMappingURL=jcanvas-crescents.min.js.map