Lukas,

On Mon, Jan 9, 2017 at 8:43 AM, David Nalesnik <david.nales...@gmail.com> wrote:

> The new output-attibutes property allows you to create multiple
> attributes, so why not adapt the labeling routines to return something
> like
>
> value of output-attributes = '((name . someGrob) (moment . whenIAm)
> (x-pos . xCoordinate) (y-pos . yCoordinate))

A way to do this is attached.

An excerpt from the SVG:

<g name="StaffSymbol" when="[Mom 0]" x-pos="8.53582677165354" y-pos="-7.552">

-David
\version "2.19.49"

% angle brackets cause SVG error so reformat:
% #<Mom 1> becomes [Mom 1]
#(define (reformat-moment mom)
   (let* ((mom (format #f "~a" mom))
          (mom (string-drop mom 2))
          (mom (string-drop-right mom 1)))
     (string-concatenate (list "[" mom "]"))))

% grob name + absolute moment + (system) coordinates should be enough for a unique id...
#(define (get-unique-id grob)
   (let ((sys (ly:grob-system grob)))
     (list
      (cons 'name
        (symbol->string (grob::name grob)))
      (cons 'when
        (reformat-moment (grob::when grob)))
      (cons 'x-pos
        (number->string (ly:grob-relative-coordinate grob sys X)))
      (cons 'y-pos
        (number->string (ly:grob-relative-coordinate grob sys Y))))))

assignIDs =
#(let ((grob-names (map car all-grob-descriptions)))
   #{
     #@(map (lambda (x) #{
       \override #(list 'Score x 'output-attributes) = #get-unique-id
       #})
     grob-names)
   #})
{
  \assignIDs
  a1
  \break
  a
  \break
  a
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to