import { assert } from "../../../../core/assert.js";
import { Sampler2D } from "../../../../engine/graphics/texture/sampler/Sampler2D.js";
import { populateSampler2DFromCellFilter } from "./populateSampler2DFromCellFilter.js";

/**
 *
 * @param {GridData} grid
 * @param {CellFilter} filter
 * @param {number} resolution_scale must be a positive integer
 */
export function sampler_from_filter(grid, filter, resolution_scale = 1) {
    assert.isNonNegativeInteger(resolution_scale, 'scale');
    assert.defined(grid, 'grid');
    assert.defined(filter, 'filter');


    const result = Sampler2D.uint8(1, grid.width * resolution_scale, grid.height * resolution_scale);

    populateSampler2DFromCellFilter({
        result: result,
        filter: filter,
        grid
    })

    return result;
}
