Thanks David! Yes, it provides the exactly the desired result!
With this kind of approach, where the note height in the staff is being used instead of the pitch of the note, the Staff.keySignature.stencil needs to be redefined on each clef change: \override Staff.KeySignature.stencil = #(key-signature::special-print *treble-key-signature-colors*) \override Staff.KeyCancellation.stencil = #(key-signature::special-print *treble-key-signature-colors*) \clef *treble* \override Staff.KeySignature.stencil = #(key-signature::special-print *bass-key-signature-colors*) \override Staff.KeyCancellation.stencil = #(key-signature::special-print *bass-key-signature-colors*) \clef *bass* Would there be any idea in developing the idea even a bit further, and to connect the accidentals in the signature to their pitch in stead of their vertical position? So instead of \override Staff.KeySignature.stencil = #(key-signature::special-print `((4 . ,green) (-3 . ,red) (1 . ,blue))) \override Staff.KeyCancellation.stencil = #(key-signature::special-print `((-3 . ,magenta) (1 . ,cyan))) One could have something more explicit which would work with all clefs, like #(define key-signature-colors `( (ly:make-pitch 2 3 SHARP) . ,green) (ly:make-pitch 1 3 SHARP) . ,green) (ly:make-pitch 0 3 SHARP) . ,green) (ly:make-pitch -1 3 SHARP) . ,green) (ly:make-pitch 2 3 FLAT) . ,red) (ly:make-pitch 1 3 FLAT) . ,red) (ly:make-pitch 0 3 FLAT) . ,red) (ly:make-pitch -1 3 FLAT) . ,red) (ly:make-pitch 2 0 SHARP) . ,blue) (ly:make-pitch 1 0 SHARP) . ,blue) (ly:make-pitch 0 0 SHARP) . ,blue) (ly:make-pitch -1 0 SHARP) . ,blue) (ly:make-pitch 2 0 FLAT) . ,blue) (ly:make-pitch 1 0 FLAT) . ,blue) (ly:make-pitch 0 0 FLAT) . ,blue) (ly:make-pitch -1 0 FLAT) . ,blue) (ly:make-pitch 2 3 NATURAL) . ,magenta) (ly:make-pitch 1 3 NATURAL) . ,magenta) (ly:make-pitch 0 3 NATURAL) . ,magenta) (ly:make-pitch -1 3 NATURAL) . ,magenta) (ly:make-pitch 2 0 NATURAL) . ,cyan) (ly:make-pitch 1 0 NATURAL) . ,cyan) (ly:make-pitch 0 0 NATURAL) . ,cyan) (ly:make-pitch -1 0 NATURAL) . ,cyan) )) \override Staff.KeySignature.stencil = #(key-signature::special-print key-signature-colors) \override Staff.KeyCancellation.stencil = #(key-signature::special-print key-signature-colors ) ? Br, Heikki 2015-08-18 16:20 GMT+03:00 David Nalesnik <david.nales...@gmail.com>: > Hi Heikki, > > On Mon, Aug 17, 2015 at 7:47 AM, Heikki Junes <heikki.ju...@gmail.com> > wrote: > >> >> 2015-08-17 15:34 GMT+03:00 David Kastrup <d...@gnu.org>: >>> >>> >>> Key signature is a single grob. Your best bet probably is recoding the >>> print routine in lily/key-signature-interface.cc in Scheme (it appears >>> rather straightforward) and then add the desired color changes to it. >>> The alternative, namely calling the print routine and post-processing >>> the stencil is probably less robust against future changes in LilyPond. >> >> >> This recoding the print routine in scheme sound exactly the kind of >> solution I was looking at. >> Then that scheme code could be updated with a scheme script in the >> preamble of a .ly file, >> which would allow "\override Staff.KeySignature #'color = >> #color-keysignature". >> >> I would be very grateful, if somebody for whom this recoding is an easy >> job >> could take a catch on this idea. >> > > In the attached file, I've recoded the print routine in Scheme, adding the > ability to color individual alterations based on their position relative to > the central line (= 0). Note that signatures for KeySignature and > KeyCancellation are handled independently. > > I ran out of steam before I duplicated everything in the C++ function, but > hopefully this will give you what you need. > > Best, > David > >
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user