lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A Javascript test code for modifying ties and slurs with mouse


From: Paolo Pr
Subject: A Javascript test code for modifying ties and slurs with mouse
Date: Thu, 12 Dec 2019 17:52:58 +0100

I just created a _javascript_ script to change the slurs of the .svg file produced by Lilypond using the mouse, as I had announced. The coordinates of the control points of the associated Bezier curve can be reported in the corresponding .ly file and this completely avoids the time consuming trial and error process we were talking about. The script is 100% _javascript_ native, without any additional library and I tried it on the Firefox and Chromium browsers. Let's see how it works.

1) Create a score using the template that shows the control points, implemented by Aaron (please, re-indent it); I added a small change to set some attributes on the generated svg tags:

http://lilybin.com/29lnbd/4

2) Generate with Lilypond the .svg file and add to it the _javascript_ script implemented by me. To test everything, let's use JsFiddle:

https://jsfiddle.net/61pb9Le4/

My script is in the lower left pane; in the upper left pane I pasted the .svg file generated by Lilypond. Note that, to make the script work, if you create a new JsFiddle, you need to select  "LOAD TYPE" option =  "No wrap - bottom of <body>".

3) Modify the slurs by moving the control points with the mouse

4) The coordinates of the modified slur can be displayed by right-clicking on one of the slur's control points. A string will appear in the form:

 "shape # '((x1. y1) (x2. y2) (x1. y1) (x3. y3) (x4. y4)) PhrasingSlur"

or

 "shape # '((x1. y1) (x2. y2) (x1. y1) (x3. y3) (x4. y4)) Slur"

or

"shape # '((x1. y1) (x2. y2) (x1. y1) (x3. y3) (x4. y4)) Tie"

This string must be copied to the .ly file, near the slur to be modified.

.....................

I wrote all this really in a hurry, and the code needs to be improved at various points. But the first tests seem to work. Now I'm trying to figure out what is the best (and portable) way to automatically include the _javascript_ script in the .svg file generated by Lilypond ...

HTH
P


reply via email to

[Prev in Thread] Current Thread [Next in Thread]