import '../../assert/js/assert.js';
import '../../globals.js';
// Copyright 2013-2024, University of Colorado Boulder
/**
 * A 3D-looking sphere with a specular highlight.
 *
 * @author Chris Malley (PixelZoom, Inc.)
 */
import optionize from '../../phet-core/js/optionize.js';
import { Circle, RadialGradient } from '../../scenery/js/imports.js';
import sceneryPhet from './sceneryPhet.js';
export default class ShadedSphereNode extends Circle {
    constructor(diameter, providedOptions) {
        const options = optionize()({
            // SelfOptions
            mainColor: 'gray',
            highlightColor: 'white',
            shadowColor: 'black',
            highlightDiameterRatio: 0.5,
            highlightXOffset: -0.4,
            highlightYOffset: -0.4
        }, providedOptions);
        // validate option values
        assert && assert(options.highlightDiameterRatio < 1, `highlightDiameterRatio must be < diameter: ${options.highlightDiameterRatio}`);
        assert && assert(options.highlightXOffset >= -1 && options.highlightXOffset <= 1, `highlightXOffset out of range: ${options.highlightXOffset}`);
        assert && assert(options.highlightYOffset >= -1 && options.highlightYOffset <= 1, `highlightYOffset out of range: ${options.highlightYOffset}`);
        super(diameter / 2, options);
        this.updateShadedSphereFill = () => {
            const radius = this.radius;
            const highlightX = radius * options.highlightXOffset;
            const highlightY = radius * options.highlightYOffset;
            this.fill = new RadialGradient(highlightX, highlightY, 0, highlightX, highlightY, radius * 2)
                .addColorStop(0, options.highlightColor)
                .addColorStop(options.highlightDiameterRatio, options.mainColor)
                .addColorStop(1, options.shadowColor);
        };
        this.updateShadedSphereFill();
    }
    invalidatePath() {
        super.invalidatePath();
        // Called during the super() call, so we may not be defined yet. We'll call this during the constructor
        // manually.
        this.updateShadedSphereFill && this.updateShadedSphereFill();
    }
}
sceneryPhet.register('ShadedSphereNode', ShadedSphereNode);
//# sourceMappingURL=ShadedSphereNode.js.map