@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 1.28 kB
JavaScript
import{Polygon as c}from"@expofp/renderer";import g from"color";import{reaction as w}from"mobx";import B from"../../../../core/Polygon";import P from"../../../../core/Rect";import{createShapeDef as W}from"../../../../renderer";import{boothStore as d,layersStore as h}from"../../../../store";import a from"../../../../tools/settings";import{BoothDrawerBaseWithoutPainter as C}from"./BoothDrawerBase";export default function D(r,e){if(a.EXPO!=="confex20"&&!(e.poiType||e.borderColor==="none"||e.borderWidth===0&&!d.borderWidth||e.paths&&!e.pathsWithRect))return new b(r,e)}function S(r){const e=[{x:r.x1,y:r.y1},{x:r.x2,y:r.y2},{x:r.x3,y:r.y3},{x:r.x4,y:r.y4}],s=[[0,1,2],[2,3,0]];return new c(e,s)}class b extends C{shape;constructor(e,s){super(s);const y=g(s.selected?a.colors.booths.selectedBorder:s.borderColor),o=this.booth.rect,t=s.borderWidth||d.borderWidth,n=[],i=(p,f,l,x)=>{const u=S(B.fromRect(P.fromCxcywh(p,f,l,x)).rotate(s.rotate,o.cx,o.cy));n.push(u)};i(o.cx,o.cy-o.h/2,o.w+t,t),i(o.cx,o.cy+o.h/2,o.w+t,t),i(o.cx-o.w/2,o.cy,t,o.h+t),i(o.cx+o.w/2,o.cy,t,o.h+t);const m=c.merge(...n);this.shape=W(m,y.string()),w(()=>[this.booth.skipDim,h.layersLoaded],()=>{h.layersLoaded&&(this.shape.dim=this.booth.skipDim?!1:void 0,e.update(this.shape))})}getShape(){return this.shape}}