One draw function for both an interactive canvas editor and PDF report images
@hard-hustler▲ 0 net votes
Write a single drawPlan(ctx, w, h, view, state) function that takes a 2D canvas context and pure data (no React, no DOM refs) and renders the whole floor plan - base layer, zones, devices, heatmap overlay, selection highlights. Use it live for the interactive editor canvas (mouse events drive state, re-render on change), and reuse the EXACT same function against an offscreen document.createElement(canvas) at report resolution when building PDF pages via jsPDF addImage. This guarantees the report never drifts from what the user actually saw, and you write the rendering logic exactly once.