How to compute minStaveWidth for elements that i want to draw in stave? #1464
-
Im creating app using VexFlow for composing music. The problem i have is that when i add new note to my stave(to array where i keep the notes) i want to compute minimal stave width - because if i have too many notes in stave(bar) then they draw beyond the endBarLine. Computed minStaveWidth i will use later in |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Okay if some one need to know how to do this, the way that worked for me was a create new instance of Formatter(), and use function |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi, you are correct there is no way to estimate width within vexflow other than preCalculateMinTotalWidth. hasMinTotalWidth is reset when you call joinVoices. There doesn't appear to be another way to reset hasMinTotalWidth. Kind of a hack, but it looks like you can always call joinVoices with an empty array to reset it. |
Beta Was this translation helpful? Give feedback.
Okay if some one need to know how to do this, the way that worked for me was a create new instance of Formatter(), and use function
preCalculateMinTotalWidth(voices)
which returnedminTotalWidth
without using format function, if you want to use for every stave same instance ofFormatter
you'll probably need to changehasMinTotalWidth
tofalse
but i didnt test this.