(field)
| 98 | window.addEventListener('resize', resize); |
| 99 | |
| 100 | const draw = (field) => { |
| 101 | if (!field?.values?.length || !field.grid_size) return; |
| 102 | const [gx, , gz] = field.grid_size; |
| 103 | const cols = gx || Math.sqrt(field.values.length) | 0; |
| 104 | const rows = gz || (field.values.length / cols) | 0; |
| 105 | const cw = canvas.width / cols, ch = canvas.height / rows; |
| 106 | for (let z = 0; z < rows; z++) { |
| 107 | for (let x = 0; x < cols; x++) { |
| 108 | ctx.fillStyle = heat(field.values[z * cols + x] || 0); |
| 109 | ctx.fillRect(x * cw, z * ch, cw + 1, ch + 1); |
| 110 | } |
| 111 | } |
| 112 | }; |
| 113 | |
| 114 | // --- Geofence floor-plan --------------------------------------------- |
| 115 | const gfCanvas = $('#gf-canvas'); |
no test coverage detected