@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
90 lines (72 loc) • 1.65 kB
JavaScript
import { Color } from "../../../../core/color/Color.js";
export class HighlightDefinition {
/**
* @readonly
* @type {Color}
*/
color = new Color();
/**
* @deprecated use {@link Color#a} instead
* @returns {number}
*/
get opacity() {
return this.color.a;
}
/**
* @deprecated use {@link Color#a} instead
* @param {number} v
*/
set opacity(v) {
this.color.a = v;
}
/**
*
* @param {HighlightDefinition} other
* @returns {boolean}
*/
equals(other) {
return this.color.equals(other.color);
}
/**
*
* @returns {number}
*/
hash() {
return this.color.hash()
}
fromJSON({ opacity, color }) {
this.color.fromJSON(color);
if (opacity !== undefined) {
// Deprecated behavior for backwards compatibility
this.color.setA(opacity);
}
}
toJSON() {
return {
color: this.color.toJSON()
};
}
/**
*
* @param j
* @return {HighlightDefinition}
*/
static fromJSON(j) {
const r = new HighlightDefinition();
r.fromJSON(j);
return r;
}
/**
*
* @param {number} r
* @param {number} g
* @param {number} b
* @param {number} [a]
* @return {HighlightDefinition}
*/
static rgba(r, g, b, a = 1) {
const result = new HighlightDefinition();
result.color.set(r, g, b, a);
return result;
}
}