lilypond-user
[Top][All Lists]
Advanced

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

Re: id's for svg elements


From: Bric
Subject: Re: id's for svg elements
Date: Sat, 26 Oct 2013 17:57:52 -0400
User-agent: PlutoMail 2.0

On 10/26/2013 04:15 AM, Mike Solomon wrote:
On Oct 26, 2013, at 10:51 AM, Bric <address@hidden> wrote:

can someone help scope out the task of adding semantically sound unique 
identifiers to the svg elements?

Such that the id bears info on, at least, the staff, (maybe bar), and 
note/chord index (consecutive integer index, for instance)

the "output-svg.scm" script has various routines to build the svg 
elements/tags/attributes, and these are implemented by other scm scripts (e.g., 
"round-filled-box")...

Before I spend hours (days?) trying to figure out the precise subroutine 
chain/tree , perhaps someone can lead me directly to the top-level code that 
feeds lilypond info into these scripts? And whereby one can feed staff/movement 
info, along with note index down to the final svg output?

And is this a realistic goal, I wonder?  I think even just identifying CLASS information in the 
"id=..." attribute might help. Just to set the stem "rect" apart from the staff line 
"rect", for instance, would already be an improvement; but, of course, I prefer even more 
specifics, as I described above.

thanks.

There is a grob property that is called "id" that is called far downstream 
(right when the backends are getting the last information about the grobs before drawing 
them).  That means that, if you create a callback for this property, you can feed it all 
sorts of info.  The resulting SVG object will be wrapped in a group with this id.

For example…

\version "2.17.30"

#(define (note-number grob)
   (string-concatenate
     (list
       "NoteHead/"
       (number->string
         (ly:pitch-semitones
           (ly:event-property (ly:grob-property grob 'cause) 'pitch))))))

\relative c' {
   \override NoteHead.id = #note-number
   a
}

Then

lilypond -dbackend=svg yourfilename.ly

Then open the SVG and look for id="NoteHead/-3"

Cheers,
MS
Hi! I see it. And I can see that you're doing some sort of awesome magic here, but it remains a total mystery... looking at the code, and looking at the result, alike.

(what's a "grob property"?  I guess it's time to hit the fine manual...)

I can see that your code above generates this in the resulting *.svg file:

<g id="NoteHead/-3">
<path transform="translate(24.1197, 21.1727) scale(0.0040, -0.0040)" d="M217 139c57 0 112 -31 112 -94c0 -72 -55 -121 -102 -149c-35 -21 -74 -35 -115 -35c-57 0 -112 31 -112 94c0 72 55 121 102 149c35 21 74 35 115 35z" fill="currentColor"/>
</g>

but I have no idea why this is so, and why there's a group with only one member in it. I presume you are suggesting to group the notehead, the stem, and maybe accidentals, and what not, under the same group and group id?


thanks!

(PS: how is it that you have 2.17.30, when the latest version is 2.17.29 ? http://download.linuxaudio.org/lilypond/source/v2.17/ )





reply via email to

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