MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / draw

Function draw

web/rusense/app/views/sensing.js:100–112  ·  view source on GitHub ↗
(field)

Source from the content-addressed store, hash-verified

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');

Callers 3

_edit_int_dialogMethod · 0.85
_edit_choice_dialogMethod · 0.85
mountFunction · 0.85

Calls 1

heatFunction · 0.85

Tested by

no test coverage detected