vexflow
vexflow copied to clipboard
Have annotations all at the same y level
I am rendering something like

by simply having the following in a loop
var note = new VF.StaveNote({clef: "treble", keys: [upper_note], duration: "q", auto_stem: true });
note.addModifier(0, new VF.Annotation('O'));
note_list.push(note);
and then rendering it with
voice.addTickables(note_list);
var formatter = new VF.Formatter().joinVoices([voice]).format([voice], 600);
voice.draw(ctx, topStaff);
I would like to have all the Os aligned on the same vertical position, which I'd be fine to set manually e.g. by beforehand finding the highest note and set that. Looking at the source code
https://github.com/0xfe/vexflow/blob/a2acedf0b32e7a22718d30fec6e48a5bc2e429f8/src/annotation.js#L193-L202
what I want does not seem possible, but perhaps it is (I am definitely not an expert in javascript and there may be some trick to force some of those variables to a "wrong" value so that I achieve all the Os at the same vertical level).
Alternatively, I could accomplish what I want in a different way, can you suggest options? I thought of:
- Another voice of
TextNotes - Another voice of
StaveNotes with a constant high enough notes (made transparent) and with its own annotation - Another voice of
StaveNotes with a constant high enough notes without (or transparent) ledger lines and stems
Unfortunately neither of those work as I'd want (perhaps it's just me but I will submit separate issues about the problems I am experiencing)
Since I have the various solutions described at the other issues, this one can be closed as far as I am concerned. I am not closing it myself in case you can see another use case where this can be useful