how to see tests codes

168 views
Skip to first unread message

Nando Penteado

unread,
Mar 24, 2013, 11:19:43 PM3/24/13
to vex...@googlegroups.com
Hi!
How could I get the vexflow text code that generated tests pages like this one? http://vexflow.com/tests/?testNumber=9
I was looking for a way to write first and second endings.
thanks in advance,
Nando Penteado

LarryKu

unread,
Mar 25, 2013, 8:18:39 AM3/25/13
to vex...@googlegroups.com
The code to generate first and second endings can be found in "stave_tests.js". The function is "Vex.Flow.Test.Stave.drawVoltaTest" bars 3 through 6. The steps are similar for creating any test with multiple staves (measures/bars).

1. Create and concatenate the number of staves (measures) you need.
2. For each stave, specify the the volta type (setVoltaType) as BEGIN, MID, END_REPEAT or END),  You can find the various options in "stavevolta.js".

The code in "stave-tests.js" is well documented, so it should be easy to understand the steps.

LarryKu

unread,
Mar 25, 2013, 11:08:11 AM3/25/13
to vex...@googlegroups.com
The volta types in the previous post were incorrect. Here are the correct types:

BEGIN - draw short vertical line at start of measure
MID - draw horizontal extension line
END - draw short vertical line at end of measure
BEGIN_END - draw short vertical line at start and end of measure.

As you create each stave (measure), set the volta type you want drawn above the measure using the setVoltaType(type, text, vert_offset) function. The parameters of the function are:

type - volta type described above
text - The ending number ("1.", "2.", etc)
vert_offset - moves the volta vertically, negative numbers to raise the voltas, positive numbers to lower the voltas.

To duplicate the example, assuming measures 3 through 6:

stave3.setVoltaType(Vex.Flow.Volta.type.BEGIN, "1.", 0);

stave4.setVoltaType(Vex.Flow.Volta.type.MID, "", 0);

stave5.setVoltaType(Vex.Flow.Volta.type.END, "", 0);
stave5.setEndBarType(Vex.Flow.Barline.type.REPEAT_END);  // draw the end repeat bar line

stave6.setVoltaType(Vex.Flow.Volta.type.BEGIN_END, "2.", 0);
stave6.setEndBarType(Vex.Flow.Barline.type.DOUBLE);          // draw the double ending bar line

Hope this helps.

Nando Penteado

unread,
Mar 26, 2013, 6:53:15 PM3/26/13
to vex...@googlegroups.com
LarryKu,
Thanks so much!
I will have a look at those files, but, by the way, this stavevolta is pointed to http://vexflow.com/src/stavevolta.js, but I cant reach this file, is it on the repository?
regards,
Nando Penteado

LarryKu

unread,
Mar 26, 2013, 9:15:27 PM3/26/13
to vex...@googlegroups.com
Nando,

The source file is in the repository. I don't believe any of the javascript source files are in the vexflow.com/tests directory. The tests are run from the compiled vexflow javascript library.

Larry


Nando Penteado

unread,
Mar 27, 2013, 10:45:38 AM3/27/13
to vex...@googlegroups.com

ah, ok! Now I got it, LarryKu, thanks again, I will have a look at that as sooner as possible. Regards!
Reply all
Reply to author
Forward
0 new messages