"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module WebGL
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.ColorInfo = void 0;
const core_bentley_1 = require("@itwin/core-bentley");
const FloatRGBA_1 = require("./FloatRGBA");
/* Describes a primitive's basic color properties
 * @internal
 */
class ColorInfo {
    _uniform;
    hasTranslucency;
    constructor(hasTranslucency, uniform) {
        this.hasTranslucency = hasTranslucency;
        this._uniform = uniform;
    }
    static createUniform(color) { return new ColorInfo(color.hasTranslucency, color); }
    static createNonUniform(hasTranslucency) { return hasTranslucency ? this._nonUniformTranslucent : this._nonUniformOpaque; }
    static createFromColorDef(color) { return this.createUniform(FloatRGBA_1.FloatRgba.fromColorDef(color)); }
    static createFromColorIndex(colorIndex) {
        return undefined !== colorIndex.uniform ? this.createFromColorDef(colorIndex.uniform) : this.createNonUniform(colorIndex.hasAlpha);
    }
    static createFromVertexTable(vt) {
        return undefined !== vt.uniformColor ? this.createFromColorDef(vt.uniformColor) : this.createNonUniform(vt.hasTranslucency);
    }
    get isUniform() { return undefined !== this._uniform; }
    get isNonUniform() { return !this.isUniform; }
    get uniform() {
        (0, core_bentley_1.assert)(this.isUniform);
        return (0, core_bentley_1.expectDefined)(this._uniform);
    }
    static _nonUniformTranslucent = new ColorInfo(true);
    static _nonUniformOpaque = new ColorInfo(false);
}
exports.ColorInfo = ColorInfo;
//# sourceMappingURL=ColorInfo.js.map