[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SVG export - how might you add classes for all graphical objects?
From: |
Matt Hood |
Subject: |
Re: SVG export - how might you add classes for all graphical objects? |
Date: |
Wed, 30 Jun 2021 11:21:12 +1000 |
On Wed, Jun 30, 2021 at 2:43 AM Jean Abou Samra <jean@abou-samra.fr> wrote:
>
> Hello,
>
>...
>
> I'm not sure how you got this output. The way
> the code is written, the \applyOutput is separate
> from the main \score, so it is a score of its own
> containing no actual music. If you move it to
> the beginning of the music, you should get at
> least one NoteHead, as illustrated here:
>
> \version "2.22.0"
>
> {
> \applyOutput Score
> #(lambda (grob origin context)
> (ly:message "~s" grob)
> (set! (ly:grob-property grob 'color)
> red))
> <<
> { c d e f }
> \\
> { g a b c' }
> >>
> }
>
> This also shows the reason why \applyOutput
> isn't working as you are expecting. \applyOutput
> applies to one single time step. Think of it
> as a \once \override. I don't think there
> currently exists an equivalent of \applyOutput
> for the whole score (perhaps because there were
> not many use cases before output-attributes).
>
> However, this problem can be solved by writing
> an engraver (those are the powerful tools that
> \applyOutput uses under the hood).
>
> \version "2.22.0"
>
> \layout {
> \context {
> \Score
> \consists
> #(lambda (context)
> (make-engraver
> (acknowledgers
> ((grob-interface engraver grob source-engraver)
> (set! (ly:grob-property grob 'output-attributes)
> `((class . ,(grob::name grob))))))))
> }
> }
>
> <<
> { c d e f }
> \\
> { g a b c' }
> >>
>
>
> Out of curiosity: what tool is this for?
>
> Best,
> Jean
Thanks for picking up on those errors in the scheme function, Jean. I
may have been a little cavelier in copying over the minimal code
examples, and I hadn't picked up the quoting error. The output came
from inserting (display name "\n"), to observe the output in the
compilation process. I tried a variety of locations to place
\applyOutput Score #add-class and this one gave me the most objects.
Thanks for getting the ball rolling with the suggestion of a custom
engraver - it looks like I have some documentation to read! They seem
wonderfully useful.
I really appreciate your response - thank you again.
Cheers,
Matt.
- Re: SVG export - how might you add classes for all graphical objects?, (continued)
- Re: SVG export - how might you add classes for all graphical objects?, Carl Sorensen, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, David Kastrup, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, Aaron Hill, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, David Kastrup, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, Aaron Hill, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, Carl Sorensen, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, David Kastrup, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, Jean Abou Samra, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, Jean Abou Samra, 2021/06/29
- Message not available
- Fwd: SVG export - how might you add classes for all graphical objects?, Matt Hood, 2021/06/29
Re: SVG export - how might you add classes for all graphical objects?,
Matt Hood <=
Re: SVG export - how might you add classes for all graphical objects?, Matt Hood, 2021/06/29