UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

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