Vexflow: question: how to render a multi-line scores ?

Created on 4 Nov 2016  路  2Comments  路  Source: 0xfe/vexflow

Hi there ! Vexflow is really nice looking, thanks for this incredible software :-)

My question may look silly but I parsed all tests and docs and did not find any mention on how to create a multi-line score. The only multi-line score I saw uses Vextab on the vexflow.com first page...

How do I create a score with multiple lines (just rendering staves puts them on top of each other) ?

question

Most helpful comment

Simply add new VF.Stave, with increasing y_offset (second argument) for each new line. Sample code:

lines.forEach((line, idx) => {
  const voice = new VF.Voice({num_beats: line.numBeats, beat_value: beatValue})
  voice.addTickables(line.allNotes)

  new VF.Formatter().joinVoices([voice]).format([voice], 400)
  // VF.Formatter.FormatAndDraw(context, stave, line.allNotes)

  const stave = new VF.Stave(10, linePadding + idx * lineHeight, 400 + 80)
  stave.addClef(score.clef)
  .addTimeSignature(score.signature)

  stave.setContext(this.VFcontext).draw()
  voice.draw(context, stave)
  line.beams.forEach(beam => {
    beam.setContext(context).draw()
  })
})

All 2 comments

Simply add new VF.Stave, with increasing y_offset (second argument) for each new line. Sample code:

lines.forEach((line, idx) => {
  const voice = new VF.Voice({num_beats: line.numBeats, beat_value: beatValue})
  voice.addTickables(line.allNotes)

  new VF.Formatter().joinVoices([voice]).format([voice], 400)
  // VF.Formatter.FormatAndDraw(context, stave, line.allNotes)

  const stave = new VF.Stave(10, linePadding + idx * lineHeight, 400 + 80)
  stave.addClef(score.clef)
  .addTimeSignature(score.signature)

  stave.setContext(this.VFcontext).draw()
  voice.draw(context, stave)
  line.beams.forEach(beam => {
    beam.setContext(context).draw()
  })
})

@gaspard Can you put this in documentation?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jeroenlammerts picture jeroenlammerts  路  3Comments

jeroenlammerts picture jeroenlammerts  路  4Comments

HollyJHuber picture HollyJHuber  路  5Comments

graciano picture graciano  路  4Comments

amitgur picture amitgur  路  4Comments