Re: SVG output - Group multiple grobs together
Thanks. I will work through the example. It seems it isn't possible to embed more than one item within a group and one group per grob is the only approach for the time being. If this is the case then why use groups rather than adding the attributes to the grob itself? James From: David Nalesnik <david.nales...@gmail.com> Sent: 10 January 2018 15:21 To: James Opstad Cc: lilypond-user@gnu.org Subject: Re: SVG output - Group multiple grobs together Hi James, On Wed, Jan 10, 2018 at 5:51 AM, James Opstad <jamesops...@hotmail.com> wrote: > Hello, > > > I have been experimenting with the new output-attributes grob property for > SVG output. For example, the following code creates a group with id="noteC" > around the C notehead. > > > \version "2.19.80" > \pointAndClickOff > \relative c' { > \once \override NoteHead.output-attributes = #'((id . noteC)) > c4 d e f | > } > > How would I include multiple grobs within the same group e.g. all the grobs > associated with a single note (NoteHead, Stem, Accidental etc.)? > All grobs have pointers to other single grobs or arrays of other grobs. You gain access to these through such functions as ly:grob-parent, ly:grob-object, ly:grob-array, ly:item-get-column. The idea of "multiple grobs within the same group e.g. all the grobs associated with a single note" can prove to be complex since your idea of a grouping is not necesarily LilyPond's. You may have to follow chains of pointers--as I did below to arrive at the Stem grob from NoteHead: i.e, through NoteColumn, the Y-parent of the NoteHead. So here is something quickly hacked together from your code example: \version "2.19.65" \pointAndClickOff \relative c' { \once \override NoteHead.output-attributes = #(lambda (grob) (let* ((acc (ly:grob-object grob 'accidental-grob)) (acc-name (if (ly:grob? acc) (grob::name acc) "none")) ; we need a NoteColumn object for access to other grobs (nc (ly:grob-parent grob Y)) (stem (ly:grob-object nc 'stem)) (stem-name (if (ly:grob? stem) (grob::name stem) "none")) (pc (ly:item-get-column grob)) (pc-name (if (ly:grob? pc) (grob::name pc) "none")) (elts (ly:grob-object pc 'elements))) (display elts) ; just so you see a grob array (list (cons 'id 'noteC) (cons 'accidental acc-name) (cons 'stem stem-name) (cons 'column pc-name c4 d e f | } %%% Here is a link to something you might find useful. It stores data about every grob encountered. https://www.mail-archive.com/lilypond-user@gnu.org/msg117645.html HTH, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: SVG output - Group multiple grobs together
Hi James, I'm cc'ing the user list, as per the usual custom. On 01/11/2018 08:13 AM, James Opstad wrote: Thanks. I will work through David's example. It seems it isn't possible to embed more than one item within a group and one group per grob is the only approach for the time being. If this is the case then why use groups rather than adding the attributes to the grob itself? Good question. I think it's because some grobs produce more than one glyph, path, or shape in the SVG, so the groups group these together as one thing. Might be interesting to explore feasibility of conditionally adding groups only when needed (for grobs with multiple shapes) and otherwise adding properties to the (single) SVG shapes themselves. Cheers, Paul ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: SVG output - Group multiple grobs together
On 01/10/2018 06:51 AM, James Opstad wrote: How would I include multiple grobs within the same group e.g. all the grobs associated with a single note (NoteHead, Stem, Accidental etc.)? Hi, I don't think there is currently a way to do that. You could give each grob you want to group together the same id. Your SVG will not be as concise or elegant (one group per grob), but it might be a way to get the job done. -Paul ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: SVG output - Group multiple grobs together
Hi James, On Wed, Jan 10, 2018 at 5:51 AM, James Opstadwrote: > Hello, > > > I have been experimenting with the new output-attributes grob property for > SVG output. For example, the following code creates a group with id="noteC" > around the C notehead. > > > \version "2.19.80" > \pointAndClickOff > \relative c' { > \once \override NoteHead.output-attributes = #'((id . noteC)) > c4 d e f | > } > > How would I include multiple grobs within the same group e.g. all the grobs > associated with a single note (NoteHead, Stem, Accidental etc.)? > All grobs have pointers to other single grobs or arrays of other grobs. You gain access to these through such functions as ly:grob-parent, ly:grob-object, ly:grob-array, ly:item-get-column. The idea of "multiple grobs within the same group e.g. all the grobs associated with a single note" can prove to be complex since your idea of a grouping is not necesarily LilyPond's. You may have to follow chains of pointers--as I did below to arrive at the Stem grob from NoteHead: i.e, through NoteColumn, the Y-parent of the NoteHead. So here is something quickly hacked together from your code example: \version "2.19.65" \pointAndClickOff \relative c' { \once \override NoteHead.output-attributes = #(lambda (grob) (let* ((acc (ly:grob-object grob 'accidental-grob)) (acc-name (if (ly:grob? acc) (grob::name acc) "none")) ; we need a NoteColumn object for access to other grobs (nc (ly:grob-parent grob Y)) (stem (ly:grob-object nc 'stem)) (stem-name (if (ly:grob? stem) (grob::name stem) "none")) (pc (ly:item-get-column grob)) (pc-name (if (ly:grob? pc) (grob::name pc) "none")) (elts (ly:grob-object pc 'elements))) (display elts) ; just so you see a grob array (list (cons 'id 'noteC) (cons 'accidental acc-name) (cons 'stem stem-name) (cons 'column pc-name c4 d e f | } %%% Here is a link to something you might find useful. It stores data about every grob encountered. https://www.mail-archive.com/lilypond-user@gnu.org/msg117645.html HTH, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
SVG output - Group multiple grobs together
Hello, I have been experimenting with the new output-attributes grob property for SVG output. For example, the following code creates a group with id="noteC" around the C notehead. \version "2.19.80" \pointAndClickOff \relative c' { \once \override NoteHead.output-attributes = #'((id . noteC)) c4 d e f | } How would I include multiple grobs within the same group e.g. all the grobs associated with a single note (NoteHead, Stem, Accidental etc.)? Thanks, James ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user