[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: |
David Kastrup |
Subject: |
Re: SVG export - how might you add classes for all graphical objects? |
Date: |
Tue, 29 Jun 2021 22:20:22 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Aaron Hill <lilypond@hillvisions.com> writes:
> On 2021-06-29 9:43 am, Jean Abou Samra wrote:
>> 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' }
>>>>
>
> NOTE: You might want this engraver to *append* to the class attribute,
> so you can still specify classes on an individual basis:
>
> %%%%
> \version "2.22.0"
>
> SvgAddClassName =
> #(lambda (ctxt)
> (define (add-class-name grob)
> (let* ((attribs (ly:grob-property grob 'output-attributes '()))
> (class (ly:assoc-get 'class attribs '()))
> (name (grob::name grob)))
> (set! class (if (null? class) name (format #f "~a ~a" class name)))
> (set! attribs (assoc-set! attribs 'class class))
> (ly:grob-set-property! grob 'output-attributes attribs)))
> (make-engraver
> (acknowledgers
> ((grob-interface engraver grob source)
> (add-class-name grob)))))
That assoc-set! looks like a stinker. Doesn't it mess with shared data
structures?
>
> \layout { \context { \Score \consists \SvgAddClassName } }
>
> { \tweak output-attributes #'((class . foo)) b'4 }
> %%%%
>
>
> -- Aaron Hill
>
>
--
David Kastrup
- 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?, 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 <=
- 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, 2021/06/29
Re: SVG export - how might you add classes for all graphical objects?, Matt Hood, 2021/06/29