UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

25 lines (19 loc) 531 B
/** * * @param {Sampler2D} sampler * @param {(sampler:Sampler2D,x:number, y:number)=>boolean} matcher * @returns {number[]} flat array of x,y coordinates */ export function sampler2d_find_pixels(sampler, matcher) { const result = []; const h = sampler.height; const w = sampler.width; for (let y = 0; y < h; y++) { for (let x = 0; x < w; x++) { if (matcher(sampler, x, y)) { result.push(x, y); } } } return result; }