ranui
Version:
A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.
2 lines (1 loc) • 2.49 kB
JavaScript
var c=Math.PI,M=2*c,l=1e-6,E=M-l;function P(t){this._+=t[0];for(let i=1,e=t.length;i<e;++i)this._+=arguments[i]+t[i]}function T(t){let i=Math.floor(t);if(!(i>=0))throw new Error(`invalid digits: ${t}`);if(i>15)return P;const e=10**i;return function(n){this._+=n[0];for(let h=1,s=n.length;h<s;++h)this._+=Math.round(arguments[h]*e)/e+n[h]}}var y=class{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?P:T(t)}moveTo(t,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+i}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,i){this._append`L${this._x1=+t},${this._y1=+i}`}quadraticCurveTo(t,i,e,n){this._append`Q${+t},${+i},${this._x1=+e},${this._y1=+n}`}bezierCurveTo(t,i,e,n,h,s){this._append`C${+t},${+i},${+e},${+n},${this._x1=+h},${this._y1=+s}`}arcTo(t,i,e,n,h){if(t=+t,i=+i,e=+e,n=+n,h=+h,h<0)throw new Error(`negative radius: ${h}`);let s=this._x1,u=this._y1,r=e-t,$=n-i,a=s-t,o=u-i,_=a*a+o*o;if(this._x1===null)this._append`M${this._x1=t},${this._y1=i}`;else if(_>l)if(!(Math.abs(o*r-$*a)>l)||!h)this._append`L${this._x1=t},${this._y1=i}`;else{let p=e-s,f=n-u,v=r*r+$*$,m=p*p+f*f,x=Math.sqrt(v),g=Math.sqrt(_),b=h*Math.tan((c-Math.acos((v+_-m)/(2*x*g)))/2),d=b/g,w=b/x;Math.abs(d-1)>l&&this._append`L${t+d*a},${i+d*o}`,this._append`A${h},${h},0,0,${+(o*p>a*f)},${this._x1=t+w*r},${this._y1=i+w*$}`}}arc(t,i,e,n,h,s){if(t=+t,i=+i,e=+e,s=!!s,e<0)throw new Error(`negative radius: ${e}`);let u=e*Math.cos(n),r=e*Math.sin(n),$=t+u,a=i+r,o=1^s,_=s?n-h:h-n;this._x1===null?this._append`M${$},${a}`:(Math.abs(this._x1-$)>l||Math.abs(this._y1-a)>l)&&this._append`L${$},${a}`,e&&(_<0&&(_=_%M+M),_>E?this._append`A${e},${e},0,1,${o},${t-u},${i-r}A${e},${e},0,1,${o},${this._x1=$},${this._y1=a}`:_>l&&this._append`A${e},${e},0,${+(_>=c)},${o},${this._x1=t+e*Math.cos(h)},${this._y1=i+e*Math.sin(h)}`)}rect(t,i,e,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+i}h${e=+e}v${+n}h${-e}Z`}toString(){return this._}};function A(){return new y}A.prototype=y.prototype;function L(t){return function(){return t}}function q(t){let i=3;return t.digits=function(e){if(!arguments.length)return i;if(e==null)i=null;else{const n=Math.floor(e);if(!(n>=0))throw new RangeError(`invalid digits: ${e}`);i=n}return t},()=>new y(i)}Object.defineProperty(exports,"constant_default",{enumerable:!0,get:function(){return L}});Object.defineProperty(exports,"withPath",{enumerable:!0,get:function(){return q}});