[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A Javascript test code for modifying ties and slurs with mouse
From: |
Aaron Hill |
Subject: |
Re: A Javascript test code for modifying ties and slurs with mouse |
Date: |
Fri, 13 Dec 2019 19:26:03 -0800 |
User-agent: |
Roundcube Webmail/1.3.8 |
On 2019-12-13 5:59 pm, Paolo Pr wrote:
First of all, I need to add with Lilypond a <script> tag to the svg
file
just before the ending </svg> tag in the following way:
1)
....
<script xlink:href="lilyEasySlurs.js"></script>
</svg>
OR in the following way:
2)
....
<script>
<![CDATA[
...javascript code...
]]>
</script>
</svg>
Well, one could use (abuse?) the embedded-svg stencil command:
%%%%
\version "2.19.83"
svg-script = #(define-scheme-function (body) (string?)
(markup #:stencil (ly:make-stencil (list 'embedded-svg
(string-join (list "<script type=\"text/javascript\"><![CDATA["
body "]]></script>") "\n")) '(0 . 0) '(0 . 0))))
{ g'4 a' \tweak Accidental.output-attributes #'((id . "flat")) bes'2 }
\svg-script
#"var flat = document.getElementById('flat');
flat.style.color = 'red';
function spin(what, amount) {
let angle = 0.0;
return function () {
const bbox = what.getBBox();
const xform = ['rotate(',
(angle = (angle + amount) % 360.0),
bbox.x + 0.5 * bbox.width,
bbox.y + 0.75 * bbox.height, ')'];
what.setAttribute('transform', xform.join(' '));
}
}
setInterval(spin(flat, 5), 100);"
%%%%
This adds a top-level \markup that contains a stencil to instruct
output-svg.scm to write the specified string to the output.
-- Aaron Hill
- A Javascript test code for modifying ties and slurs with mouse, Paolo Pr, 2019/12/12
- Re: A Javascript test code for modifying ties and slurs with mouse, Flaming Hakama by Elaine, 2019/12/13
- Re: A Javascript test code for modifying ties and slurs with mouse, Urs Liska, 2019/12/13
- Re: A Javascript test code for modifying ties and slurs with mouse, Paolo Pr, 2019/12/13
- Re: A Javascript test code for modifying ties and slurs with mouse,
Aaron Hill <=
- Re: A Javascript test code for modifying ties and slurs with mouse, Paolo Prete, 2019/12/14
- Re: A Javascript test code for modifying ties and slurs with mouse, Stefano Troncaro, 2019/12/14
- Re: A Javascript test code for modifying ties and slurs with mouse, Paolo Prete, 2019/12/14
- Re: A Javascript test code for modifying ties and slurs with mouse, Paolo Prete, 2019/12/14
- Re: A Javascript test code for modifying ties and slurs with mouse, Stefano Troncaro, 2019/12/14
- Re: A Javascript test code for modifying ties and slurs with mouse, Paolo Prete, 2019/12/14
- Re: A Javascript test code for modifying ties and slurs with mouse, Aaron Hill, 2019/12/14
- Re: A Javascript test code for modifying ties and slurs with mouse, Paolo Prete, 2019/12/14
- Re: A Javascript test code for modifying ties and slurs with mouse, Carl Sorensen, 2019/12/13
- Re: A Javascript test code for modifying ties and slurs with mouse, Paolo Pr, 2019/12/13