Files
havox/tutorials/summed_area/snippets/defineCount.js
2026-03-16 18:03:17 +00:00

17 lines
553 B
JavaScript

// where br is the cell we're calculating
function defineCount(br) {
let c = 0;
// br.x is the column number
// br.y is the row number
for (y = 0; y <= br.y; y++) { // loop through all rows above br (and the row br is on)
for (x = 0; x <= br.x; x++) { // loop through all columns to the left of br (and br column)
var i = x + n * y; // convert 2d array format to 1d index
if (t[i].s) { // if cell[i].status==true then increase count
c++;
}
}
}
return c;
}