import '../../../assert/js/assert.js';
import '../../../globals.js';
// Copyright 2020-2024, University of Colorado Boulder
/**
 * Opacity filter
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import toSVGNumber from '../../../dot/js/toSVGNumber.js';
import { Filter, scenery } from '../imports.js';
export default class Opacity extends Filter {
    /**
     * NOTE: Generally prefer setting a Node's opacity, unless this is required for stacking of filters.
     *
     * @param amount - The amount of opacity, from 0 (invisible) to 1 (fully visible)
     */
    constructor(amount) {
        assert && assert(isFinite(amount), 'Opacity amount should be finite');
        assert && assert(amount >= 0, 'Opacity amount should be non-negative');
        assert && assert(amount <= 1, 'Opacity amount should be no greater than 1');
        super();
        this.amount = amount;
    }
    /**
     * Returns the CSS-style filter substring specific to this single filter, e.g. `grayscale(1)`. This should be used for
     * both DOM elements (https://developer.mozilla.org/en-US/docs/Web/CSS/filter) and when supported, Canvas
     * (https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter).
     */
    getCSSFilterString() {
        return `opacity(${toSVGNumber(this.amount)})`;
    }
    isDOMCompatible() {
        return true;
    }
    applyCanvasFilter(wrapper) {
        throw new Error('unimplemented');
    }
    applySVGFilter(svgFilter, inName, resultName) {
        throw new Error('unimplemented');
    }
}
scenery.register('Opacity', Opacity);
//# sourceMappingURL=Opacity.js.map