Einem Grob die gleiche Eigenschaft eines anderen Grobs zuweisen - wie?

Begonnen von Manuela, Sonntag, 28. Oktober 2018, 19:28

« vorheriges - nächstes »

Manuela

Wenn ich z.B. Text gleich einfärben will wie die Noten, geht das durch Direktzuweisung?

\override TextScript.color = #'NoteHead.color

funktioniert nicht, ich habe verschiedene Varianten mit und ohne Klammern, Hochkomma etc. probiert.
Danke für eure Hilfe
viele Grüße
-- Manuela

harm6

So direkt wie Du es Dir vorstellst geht es nicht, aber Du kannst folgendes tun:


#(define get-text-script-color-from-note-head
  (lambda (grob)
    (let* ((nc (ly:grob-parent grob X))
           (nhs-array (ly:grob-object nc 'note-heads))
           (nh-ls
             (if (ly:grob-array? nhs-array)
                 (ly:grob-array->list nhs-array)
                 '()))
           ;; what to do with different colors in a chord?
           (nh-props
             (ly:grob-basic-properties (car nh-ls))))
    (assoc-get 'color nh-props))))

{
  \override TextScript.color = #get-text-script-color-from-note-head
  b-"xy"
  \override NoteHead.color = #red
  c'1-"foo"
  \override NoteHead.color = #green
  d'-"bar"
  \override NoteHead.color = #blue
  e'-"buzz"
}


Allerdings wäre das Verfahren für andere grobs als TextScript möglicherweise wieder anders.


Gruß,
  Harm

Manuela

Danke für eure Hilfe
viele Grüße
-- Manuela