[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SVG export - how might you add classes for all graphical objects?
From: |
Matt Hood |
Subject: |
SVG export - how might you add classes for all graphical objects? |
Date: |
Tue, 29 Jun 2021 18:42:55 +1000 |
Hi everyone,
I'm working with lilypond output in the browser, using its SVG export
function. Lilypond permits attaching attributes to particular kinds of
grobs, e.g.:
{
\override NoteHead.output-attributes =
#'((class . "NoteHead"))
c
}
The above will cause all NoteHead objects to have the following SVG:
<g class="NoteHead">
...NoteHead grob SVG elements...
</g>
My question is: how can I make it so that all graphical objects have
their name in the class attribute?
I've tried using the following scheme function:
#(define (add-class grob grob-origin context)
(let (name (cdr (assoc 'name
(ly:grob-property grob 'meta))))
(set! (ly:grob-property grob 'output-attributes) '((class
. name)))))
This successfully (I believe) extracts the correct name, and assigns
it to the output-attributes field. As per the instructions in the
lilypond documentation, I then attempted to use \applyOutput Score
#add-class to apply this function to all graphical objects, but it
didn't supply all of the required objects. My attempted code is below:
\applyOutput Score #add-class
\score {
\new RhythmicStaff {
c'2 c'16 c' c' c' \tuplet 5/4 { c'16 c' c' c' c' }
}
}
If I add a print call to the add-class function, I can see that it was
called for the objects with the following names from which crucial
objects such as NoteHead are missing:
NonMusicalPaperColumn
PaperColumn
Clef
TimeSignature
LedgerLineSpanner
StaffSymbol
VerticalAxisGroup
SystemStartBar
SpacingSpanner
VerticalAlignment
StaffSpacing
BreakAlignment
LeftEdge
BreakAlignGroup
BreakAlignGroup
BreakAlignGroup
If there were a way to run add-class on all graphical objects, that
might be a good solution to the problem.
Any help would be much appreciated!
Thanks,
Matt.
- 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?, Carl Sorensen, 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?, 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