UNPKG

@stringsync/vexml

Version:

MusicXML to Vexflow

39 lines (38 loc) 1.33 kB
import { Fraction } from '../util'; export class Rest { config; log; document; restRender; constructor(config, log, document, restRender) { this.config = config; this.log = log; this.document = document; this.restRender = restRender; } static create(config, log, document, restRender) { return new Rest(config, log, document, restRender); } /** The name of the element, which can be used as a type discriminant. */ name = 'rest'; /** Returns the bounding box of the element. */ rect() { return this.restRender.rect; } /** Returns the measure beat that this note starts on. */ getStartMeasureBeat() { return Fraction.fromFractionLike(this.document.getVoiceEntry(this.restRender.key).measureBeat); } /** Returns the number of beats that this note takes. */ getBeatCount() { return Fraction.fromFractionLike(this.document.getVoiceEntry(this.restRender.key).duration); } /** Returns the system index that this rest resides in. */ getSystemIndex() { return this.restRender.key.systemIndex; } /** Returns the absolute measure index that this rest resides in. */ getAbsoluteMeasureIndex() { return this.document.getAbsoluteMeasureIndex(this.restRender.key); } }