UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) 903 B
import{Rect as d}from"@expofp/geometry";const r=new Map;export function createCircleCanvas(i,n){const c=n.toUpperCase();if(!r.has(c)){const t=document.createElement("canvas"),a=i*2*devicePixelRatio+1*2;t.width=a,t.height=a;const s=t.getContext("2d");s.fillStyle=n,s.beginPath(),s.arc(a/2,a/2,i*devicePixelRatio,0,2*Math.PI),s.fill(),r.set(c,t)}return r.get(c)}const h=new Map;export function createBookmarkCanvas(i,n){const c=i;if(h.has(c))return h.get(c);const t=i,o=t*1.4,a=Math.ceil(t*n),s=Math.ceil(o*n),l=document.createElement("canvas");l.width=a,l.height=s;const e=l.getContext("2d");return e.scale(n,n),e.fillStyle="#fdbf2b",e.strokeStyle="#fff",e.lineWidth=4/n,e.beginPath(),e.moveTo(0,0),e.lineTo(0,o),e.lineTo(t/2,o-t/2),e.lineTo(t,o),e.lineTo(t,0),e.lineTo(0,0),e.fill(),e.stroke(),h.set(c,l),l}export function getBounds(i,n,c,t,o=1,a){const s=c*o,l=t*o;return new d({x:i,y:n},{x:s,y:l},a)}