@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 1.5 kB
JavaScript
import{Polygon as S,Rect as W}from"@expofp/geometry";import p from"color";import{reaction as k}from"mobx";import{createShapeDef as D}from"../../../../renderer";import{boothStore as m,heatmapStore as P,layersStore as f,uiState as u}from"../../../../store";import a from"../../../../tools/settings";import{BoothDrawerBaseWithoutPainter as L}from"./BoothDrawerBase";export default function v(c,o){if(a.EXPO!=="confex20"&&!(o.poiType||o.borderColor==="none"||o.borderWidth===0&&!m.borderWidth||o.paths&&!o.pathsWithRect))return new R(c,o)}class R extends L{constructor(o,s){super(s);const t=this.booth.rect,{x:e,y:i}=t.center,{width:n,height:h}=t.size,r=s.borderWidth||m.borderWidth,l=[],d=(B,b,C,x)=>{const w=new W({x:B,y:b},{x:C,y:x}).toPolygon();l.push(w.rotate(s.rotate??0,{x:e,y:i}))};d(e,i-h/2,n+r,r),d(e,i+h/2,n+r,r),d(e-n/2,i,r,h+r),d(e+n/2,i,r,h+r);const g=S.merge(...l),y=this.getBorderColor();this.shape=D(g,y.string()),k(()=>[this.booth.skipDim,f.layersLoaded,this.booth.hover,this.booth.selected,u.heatmap],()=>{f.layersLoaded&&(this.shape.dim=this.booth.skipDim?!1:void 0,this.shape.color=this.getBorderColor().string(),o.update(this.shape))})}getBorderColor(){const o=this.booth;if(u.heatmap){const t=P.getHeatmapColorForBooth(o);if(o.selected){const e=a.colors.booths.selectedBorder;return e?p(e):t.darken(.4)}return o.hover?t.darken(.3):t.darken(.2)}const s=o.selected?a.colors.booths.selectedBorder:o.borderColor;return p(s||a.colors.booths.default)}getShape(){return this.shape}}