import '../../../assert/js/assert.js';
import '../../../globals.js';
import { alpenglow } from '../imports.js';
var PolygonFilterType;
(function (PolygonFilterType) {
    PolygonFilterType[PolygonFilterType["Box"] = 0] = "Box";
    PolygonFilterType[PolygonFilterType["Bilinear"] = 1] = "Bilinear";
    PolygonFilterType[PolygonFilterType["MitchellNetravali"] = 2] = "MitchellNetravali";
})(PolygonFilterType || (PolygonFilterType = {}));
export default PolygonFilterType;
export const getPolygonFilterWidth = (filterType) => {
    if (filterType === PolygonFilterType.Box) {
        return 1;
    }
    else if (filterType === PolygonFilterType.Bilinear) {
        return 2;
    }
    else if (filterType === PolygonFilterType.MitchellNetravali) {
        return 4;
    }
    else {
        throw new Error(`Unknown PolygonFilterType: ${filterType}`);
    }
};
export const getPolygonFilterExtraPixels = (filterType) => {
    if (filterType === PolygonFilterType.Box) {
        return 0;
    }
    else if (filterType === PolygonFilterType.Bilinear) {
        return 1;
    }
    else if (filterType === PolygonFilterType.MitchellNetravali) {
        return 3;
    }
    else {
        throw new Error(`Unknown PolygonFilterType: ${filterType}`);
    }
};
export const getPolygonFilterGridOffset = (filterType) => {
    if (filterType === PolygonFilterType.Box) {
        return 0;
    }
    else if (filterType === PolygonFilterType.Bilinear) {
        return -0.5;
    }
    else if (filterType === PolygonFilterType.MitchellNetravali) {
        return -1.5;
    }
    else {
        throw new Error(`Unknown PolygonFilterType: ${filterType}`);
    }
};
export const getPolygonFilterMinExpand = (filterType) => {
    if (filterType === PolygonFilterType.Box) {
        return 0;
    }
    else if (filterType === PolygonFilterType.Bilinear) {
        return 1;
    }
    else if (filterType === PolygonFilterType.MitchellNetravali) {
        return 2;
    }
    else {
        throw new Error(`Unknown PolygonFilterType: ${filterType}`);
    }
};
export const getPolygonFilterMaxExpand = (filterType) => {
    if (filterType === PolygonFilterType.Box) {
        return 1;
    }
    else if (filterType === PolygonFilterType.Bilinear) {
        return 1;
    }
    else if (filterType === PolygonFilterType.MitchellNetravali) {
        return 2;
    }
    else {
        throw new Error(`Unknown PolygonFilterType: ${filterType}`);
    }
};
export const getPolygonFilterGridBounds = (bounds, filterType, filterMultiplier = 1) => {
    const filterWidth = getPolygonFilterWidth(filterType) * filterMultiplier;
    const filterExtension = 0.5 * (filterWidth - 1);
    if (assert && filterMultiplier === 1) {
        const filterAdditionalPixels = getPolygonFilterExtraPixels(filterType);
        const filterGridOffset = getPolygonFilterGridOffset(filterType);
        assert && assert(filterGridOffset === -filterExtension);
        assert && assert(filterGridOffset + filterAdditionalPixels === filterExtension);
    }
    return bounds.dilated(filterExtension);
};
alpenglow.register('PolygonFilterType', PolygonFilterType);
//# sourceMappingURL=PolygonFilterType.js.map