@g20/graphics
Version:
3 lines (2 loc) • 5.21 kB
JavaScript
System.register(["@g20/core","@g20/reactive"],(function(t){"use strict";var s,i,e,o,r,n,a;return{setters:[function(t){s=t.is_color,i=t.Path,e=t.dispose,o=t.Anchor,r=t.G20},function(t){n=t.signal,a=t.effect}],execute:function(){function u(t,i){return s(t)?t:i}function l(t,s){return"number"==typeof t?t:s}function h(t,s){return"number"==typeof t?t:3/s.sx}const c=Math.cos,d=Math.sin;t("RegularPolygon",class extends i{#t=[];#s=n(1);#i=n(0);#e=n(6);constructor(t,s={}){if(super(t,[],!0,!1,!0,function(t,s){const i={id:t.id,attitude:t.attitude,opacity:t.opacity,position:t.position,visibility:t.visibility,fillColor:u(t.fillColor,s.defaults.polygon.fillColor),fillOpacity:l(t.fillOpacity,s.defaults.polygon.fillOpacity),strokeColor:u(t.strokeColor,s.defaults.polygon.strokeColor),strokeOpacity:l(t.strokeOpacity,s.defaults.polygon.strokeOpacity),strokeWidth:h(t.strokeWidth,s)};return i}(s,t)),"number"==typeof s.radius&&(this.radius=s.radius),"number"==typeof s.sides){const t=3,i=24;this.sides=Math.min(Math.max(s.sides,t),i)}"number"==typeof s.twist&&(this.twist=s.twist),this.#t.push(a((()=>{this.update()}))),this.flagReset(!0)}dispose(){e(this.#t),super.dispose()}update(){return function(t,s,i,e){const n=s+1;e.length>n&&e.splice(n,e.length-n);for(;e.length<n;)e.push(new o(r.vector(0,0)));for(let o=0;o<n;o++){const r=2*Math.PI*o/s+i,n=t*c(r),a=t*d(r),u=e.getAt(o);u.origin.set(n,a),u.command=0===o?"M":"L"}}(this.radius,this.sides,this.twist,this.vertices),super.update(),this}flagReset(t=!1){return super.flagReset(t),this}get radius(){return this.#s.get()}set radius(t){this.#s.set(t)}get sides(){return this.#e.get()}set sides(t){this.#e.set(t)}get twist(){return this.#i.get()}set twist(t){this.#i.set(t)}});t("RoundedRectangle",class extends i{#t=[];#o=n(Math.SQRT2);#r=n(Math.SQRT2);#s=n(.2);constructor(t,s={}){void 0===s.radius&&"number"==typeof s.width&&"number"==typeof s.height&&(s.radius=Math.floor(Math.min(s.width,s.height)/12));const i=[];for(let t=0;t<10;t++){const s=r.vector(0,0),e=0===t?"M":"C";i.push(new o(s,e))}super(t,i,!0,!1,!0,function(t,s){const i={id:t.id,attitude:t.attitude,opacity:t.opacity,position:t.position,visibility:t.visibility,fillColor:u(t.fillColor,s.defaults.polygon.fillColor),fillOpacity:l(t.fillOpacity,s.defaults.polygon.fillOpacity),strokeColor:u(t.strokeColor,s.defaults.polygon.strokeColor),strokeOpacity:l(t.strokeOpacity,s.defaults.polygon.strokeOpacity),strokeWidth:h(t.strokeWidth,s)};return i}(s,t)),"number"==typeof s.width&&(this.width=s.width),"number"==typeof s.height&&(this.height=s.height),"number"==typeof s.radius&&(this.radius=s.radius),this.#t.push(a((()=>{this.update()})))}dispose(){e(this.#t),super.dispose()}update(){return function(t,s,i,e){const o=i,r=i;let n;const a=t/2,u=s/2;n=e.getAt(0),n.x=-(a-o),n.y=-u,n=e.getAt(1),n.x=a-o,n.y=-u,n.controls.a.clear(),n.controls.b.x=o,n.controls.b.y=0,n=e.getAt(2),n.x=a,n.y=-(u-r),n.controls.b.clear(),n.controls.a.clear(),n=e.getAt(3),n.x=a,n.y=u-r,n.controls.a.clear(),n.controls.b.x=0,n.controls.b.y=r,n=e.getAt(4),n.x=a-o,n.y=u,n.controls.b.clear(),n.controls.a.clear(),n=e.getAt(5),n.x=-(a-o),n.y=u,n.controls.a.clear(),n.controls.b.x=-o,n.controls.b.y=0,n=e.getAt(6),n.x=-a,n.y=u-r,n.controls.a.clear(),n.controls.b.clear(),n=e.getAt(7),n.x=-a,n.y=-(u-r),n.controls.a.clear(),n.controls.b.x=0,n.controls.b.y=-r,n=e.getAt(8),n.x=-(a-o),n.y=-u,n.controls.a.clear(),n.controls.b.clear(),n=e.getAt(9),n.copy(e.getAt(8))}(this.width,this.height,this.radius,this.vertices),super.update(),this}get width(){return this.#o.get()}set width(t){this.#o.set(t)}get height(){return this.#r.get()}set height(t){this.#r.set(t)}get radius(){return this.#s.get()}set radius(t){this.#s.set(t)}});const p=Math.cos,g=Math.sin;t("Star",class extends i{#t=[];#n=n(.5);#a=n(1);#u=n(8);#i=n(0);constructor(t,s={}){super(t,[],!0,!1,!0,function(t,s){const i={id:t.id,attitude:t.attitude,opacity:t.opacity,position:t.position,visibility:t.visibility,fillColor:u(t.fillColor,s.defaults.polygon.fillColor),fillOpacity:l(t.fillOpacity,s.defaults.polygon.fillOpacity),strokeColor:u(t.strokeColor,s.defaults.polygon.strokeColor),strokeOpacity:l(t.strokeOpacity,s.defaults.polygon.strokeOpacity),strokeWidth:h(t.strokeWidth,s)};return i}(s,t)),"number"==typeof s.innerRadius&&(this.innerRadius=s.innerRadius),"number"==typeof s.outerRadius&&(this.outerRadius=s.outerRadius),"number"==typeof s.points&&(this.points=s.points),"number"==typeof s.twist&&(this.twist=s.twist),this.#t.push(a((()=>{this.update()})))}dispose(){e(this.#t),super.dispose()}update(){return function(t,s,i,e,n){const a=2*t,u=a+1;n.length>u&&n.splice(u,n.length-u);for(;n.length<u;)n.push(new o(r.vector(0,0)));for(let t=0;t<u;t++){const o=2*Math.PI*t/a+e,r=t%2==0?i:s,u=r*p(o),l=r*g(o),h=n.getAt(t);h.origin.set(u,l),h.command=0===t?"M":"L"}}(this.points,this.innerRadius,this.outerRadius,this.twist,this.vertices),super.update(),this}get innerRadius(){return this.#n.get()}set innerRadius(t){this.#n.set(t)}get outerRadius(){return this.#a.get()}set outerRadius(t){this.#a.set(t)}get points(){return this.#u.get()}set points(t){this.#u.set(t)}get twist(){return this.#i.get()}set twist(t){this.#i.set(t)}})}}}));
//# sourceMappingURL=index.min.js.map