/**
 *
 * @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;
}
