[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automatic coloring clef/key signature changes

From: Jérôme Plût
Subject: Re: Automatic coloring clef/key signature changes
Date: Wed, 2 Jan 2019 17:49:00 +0000
User-agent: Mutt/1.5.23 (2014-03-12)

> Well, since you don't include any example code

Of course, if I had had any example code, I would not have been asking
the question in the first place!

Here is a working example though, thanks to the second part of your
message. Should some variant of this be added to the snippets database?

(define (any->color x) (cond
  ((symbol? x) (x11-color x))
  ((list? x) x)
  (else `(0. 0. 0.))))

(define (callback-when-non-default x) (lambda (grob)
  (or (null? (ly:grob-property grob 'non-default)) x)))

(define (set-color-when-non-default grob-name color)
    (make-grob-property-set grob-name 'color
      (callback-when-non-default (any->color color)))
) %begin

color-signatures = {
  #(set-color-when-non-default 'Clef `(.3 .0 .6))
  #(set-color-when-non-default 'KeySignature `(.5 .2 .0))

\score {
 \new Staff {

  \key g \major \repeat unfold 20 c'4
  \clef C \repeat unfold 20 c'4
  % Amusingly, the naturals are *not* colored here:
  \key c \minor \repeat unfold 20 c'4
  \clef G \repeat unfold 20 c'4

reply via email to

[Prev in Thread] Current Thread [Next in Thread]