@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 907 B
JavaScript
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 e=document.createElement("canvas"),a=i*2*devicePixelRatio+1*2;e.width=a,e.height=a;const s=e.getContext("2d");s.fillStyle=n,s.beginPath(),s.arc(a/2,a/2,i*devicePixelRatio,0,2*Math.PI),s.fill(),r.set(c,e)}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 e=i,o=e*1.4,a=Math.ceil(e*n),s=Math.ceil(o*n),l=document.createElement("canvas");l.width=a,l.height=s;const t=l.getContext("2d");return t.scale(n,n),t.fillStyle="#fdbf2b",t.strokeStyle="#fff",t.lineWidth=4/n,t.beginPath(),t.moveTo(0,0),t.lineTo(0,o),t.lineTo(e/2,o-e/2),t.lineTo(e,o),t.lineTo(e,0),t.lineTo(0,0),t.fill(),t.stroke(),h.set(c,l),l}export function getBounds(i,n,c,e,o=1,a,s){const l=c*o,t=e*o;return new d({x:i,y:n},{x:l,y:t},a,s)}