@stringsync/vexml
Version:
MusicXML to Vexflow
32 lines (31 loc) • 932 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.NumberRange = void 0;
const math_1 = require("./math");
class NumberRange {
start;
end;
constructor(start, end) {
if (start > end) {
throw new Error('Invalid range: start bound must be less than or equal to end bound.');
}
this.start = start;
this.end = end;
}
getSize() {
return this.end - this.start;
}
lerp(alpha) {
return (0, math_1.lerp)(this.start, this.end, alpha);
}
includes(value) {
return value >= this.start && value <= this.end;
}
contains(range) {
return this.includes(range.start) && this.includes(range.end);
}
overlaps(range) {
return (this.includes(range.start) || this.includes(range.end) || range.includes(this.start) || range.includes(this.end));
}
}
exports.NumberRange = NumberRange;