g2o-graphics
Version:
3 lines (2 loc) • 4.63 kB
JavaScript
System.register(["g2o","g2o-reactive"],(function(t){"use strict";var s,i,e,r,o,n;return{setters:[function(t){s=t.Path,i=t.dispose,e=t.Anchor,r=t.G20},function(t){o=t.state,n=t.effect}],execute:function(){const h=Math.cos,a=Math.sin;t("RegularPolygon",class extends s{#t=[];#s=o(1);#i=o(0);#e=o(6);constructor(t,s={}){if(super(t,[],!0,!1,!0,function(t){const s={id:t.id,attitude:t.attitude,opacity:t.opacity,position:t.position,visibility:t.visibility,fillColor:t.fillColor,fillOpacity:t.fillOpacity,strokeColor:t.strokeColor,strokeOpacity:t.strokeOpacity,strokeWidth:t.strokeWidth};return s}(s)),"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(n((()=>{this.update()}))),this.flagReset(!0)}dispose(){i(this.#t),super.dispose()}update(){return function(t,s,i,o){const n=s+1;o.length>n&&o.splice(n,o.length-n);for(;o.length<n;)o.push(new e(r.vector(0,0)));for(let e=0;e<n;e++){const r=2*Math.PI*e/s+i,n=t*h(r),u=t*a(r),c=o.getAt(e);c.origin.set(n,u),c.command=0===e?"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 s{#t=[];#r=o(Math.SQRT2);#o=o(Math.SQRT2);#s=o(.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),o=0===t?"M":"C";i.push(new e(s,o))}super(t,i,!0,!1,!0,function(t){const s={id:t.id,attitude:t.attitude,opacity:t.opacity,position:t.position,visibility:t.visibility,fillColor:t.fillColor,fillOpacity:t.fillOpacity,strokeColor:t.strokeColor,strokeOpacity:t.strokeOpacity,strokeWidth:t.strokeWidth};return s}(s)),"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(n((()=>{this.update()})))}dispose(){i(this.#t),super.dispose()}update(){return function(t,s,i,e){const r=i,o=i;let n;const h=t/2,a=s/2;n=e.getAt(0),n.x=-(h-r),n.y=-a,n=e.getAt(1),n.x=h-r,n.y=-a,n.controls.a.clear(),n.controls.b.x=r,n.controls.b.y=0,n=e.getAt(2),n.x=h,n.y=-(a-o),n.controls.b.clear(),n.controls.a.clear(),n=e.getAt(3),n.x=h,n.y=a-o,n.controls.a.clear(),n.controls.b.x=0,n.controls.b.y=o,n=e.getAt(4),n.x=h-r,n.y=a,n.controls.b.clear(),n.controls.a.clear(),n=e.getAt(5),n.x=-(h-r),n.y=a,n.controls.a.clear(),n.controls.b.x=-r,n.controls.b.y=0,n=e.getAt(6),n.x=-h,n.y=a-o,n.controls.a.clear(),n.controls.b.clear(),n=e.getAt(7),n.x=-h,n.y=-(a-o),n.controls.a.clear(),n.controls.b.x=0,n.controls.b.y=-o,n=e.getAt(8),n.x=-(h-r),n.y=-a,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.#r.get()}set width(t){this.#r.set(t)}get height(){return this.#o.get()}set height(t){this.#o.set(t)}get radius(){return this.#s.get()}set radius(t){this.#s.set(t)}});const u=Math.cos,c=Math.sin;t("Star",class extends s{#t=[];#n=o(.5);#h=o(1);#a=o(8);#i=o(0);constructor(t,s={}){super(t,[],!0,!1,!0,function(t){const s={id:t.id,attitude:t.attitude,opacity:t.opacity,position:t.position,visibility:t.visibility,fillColor:t.fillColor,fillOpacity:t.fillOpacity,strokeColor:t.strokeColor,strokeOpacity:t.strokeOpacity,strokeWidth:t.strokeWidth};return s}(s)),"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(n((()=>{this.update()})))}dispose(){i(this.#t),super.dispose()}update(){return function(t,s,i,o,n){const h=2*t,a=h+1;n.length>a&&n.splice(a,n.length-a);for(;n.length<a;)n.push(new e(r.vector(0,0)));for(let t=0;t<a;t++){const e=2*Math.PI*t/h+o,r=t%2==0?i:s,a=r*u(e),d=r*c(e),l=n.getAt(t);l.origin.set(a,d),l.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.#h.get()}set outerRadius(t){this.#h.set(t)}get points(){return this.#a.get()}set points(t){this.#a.set(t)}get twist(){return this.#i.get()}set twist(t){this.#i.set(t)}})}}}));
//# sourceMappingURL=index.min.js.map