@stringsync/vexml
Version:
MusicXML to Vexflow
50 lines (49 loc) • 1.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Stave = void 0;
const voice_1 = require("./voice");
const util_1 = require("../util");
class Stave {
config;
log;
document;
staveRender;
voices;
constructor(config, log, document, staveRender, voices) {
this.config = config;
this.log = log;
this.document = document;
this.staveRender = staveRender;
this.voices = voices;
}
static create(config, log, document, staveRender) {
const voices = staveRender.voiceRenders.map((voiceRender) => voice_1.Voice.create(config, log, document, voiceRender));
return new Stave(config, log, document, staveRender, voices);
}
/** The name of the element, which can be used as a type discriminant. */
name = 'stave';
/** Returns the bounding box of the element. */
rect() {
return this.staveRender.rect;
}
/** Returns the intrinsic rect of the stave. */
intrinsicRect() {
return this.staveRender.intrinsicRect;
}
/** Returns the playable rect of the stave. */
playableRect() {
return this.staveRender.playableRect;
}
/** Returns the voices of the stave. */
getVoices() {
return this.voices;
}
/** Returns the start measure beat for the stave. */
getStartMeasureBeat() {
return (this.voices
.map((voice) => voice.getStartMeasureBeat())
.sort((a, b) => a.toDecimal() - b.toDecimal())
.at(0) ?? util_1.Fraction.zero());
}
}
exports.Stave = Stave;