import { CellFilterUnaryOperation } from "../../core/CellFilterUnaryOperation.js";
import { assert } from "../../../../core/assert.js";
import { clamp01 } from "../../../../core/math/clamp01.js";

export class CellFilterSaturate extends CellFilterUnaryOperation {
    operation(v) {
        return clamp01(v);
    }

    /**
     *
     * @param {CellFilter} v
     * @return {CellFilterUnaryOperation}
     */
    static from(v) {
        assert.equal(v.isCellFilter, true, "v.isCellFilter !== true");

        const r = new CellFilterSaturate();

        r.source = v;

        return r;
    }
}
