lilypond-user
[Top][All Lists]
Advanced

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

Re: Key signature color one item


From: Simon Albrecht
Subject: Re: Key signature color one item
Date: Tue, 7 Feb 2017 21:37:43 +0100

On 07.02.2017 21:25, Tiago Morin wrote:
Hi David,

Thank's for the reply. It doesn't seem to work on 2.18.2:

That’s because the code from that linked-to post isn’t in the LilyPond core. You have to paste it into your input file, or save it as a library file and use \include.
Here it is once more:

%%%%%%%%%%%%%%%%

#(define (key-signature::special-print alt-color-list)
   (lambda (grob)
     (let* ((inter (/ (ly:staff-symbol-staff-space grob) 2.0))
            (mol empty-stencil)
            (c0s (ly:grob-property grob 'c0-position))
            (is-cancellation? (grob::has-interface grob 
'key-cancellation-interface))
            (padding-pairs (ly:grob-property grob 'padding-pairs))
            (fm (ly:grob-default-font grob))
            (alist (ly:grob-property grob 'glyph-name-alist)))
       (let loop ((s (ly:grob-property grob 'alteration-alist))
                  (stil mol)
                  (last-glyph-name #f))
         (if (pair? s)
             (let* ((alt (if is-cancellation? 0 (cdar s)))
                    (glyph-name (ly:assoc-get alt alist))
                    (acc (ly:font-get-glyph fm glyph-name))
                    (pos-list
                     (key-signature-interface::alteration-positions (car s) c0s 
grob))
                    (p (car pos-list))
                    (color (assoc-get p alt-color-list))
                    (acc
                     (if (color? color)
                         (stencil-with-color acc color)
                         acc))
                    (padding (ly:grob-property grob 'padding 0.0))
                    (handle (assoc (cons glyph-name last-glyph-name) 
padding-pairs))
                    (padding
                     (cond
                      ((pair? handle) (cdr handle))
                      ((and
                        (string=? glyph-name "accidentals.natural")
                        ; ...
                        )
                       (+ padding 0.3))
                      (else padding))))
(loop (cdr s)
                 (ly:stencil-combine-at-edge
                  stil
                  X
                  LEFT
                  (ly:stencil-translate-axis acc (* p inter) Y)
                  padding)
                 glyph-name))
             (ly:stencil-aligned-to stil X LEFT))))))
%%%%%%%%%%%%%%%%%%%%%%%%%%%

Best, Simon



error: GUILE signaled an error for the expression beginning here
  #
   (key-signature::special-print `((2 . ,red)))
Unbound variable: key-signature::special-print


Any guess?

Thank's

Tiago

On 7 February 2017 at 13:14, David Nalesnik <address@hidden <mailto:address@hidden>> wrote:

    Tiago,

    On Tue, Feb 7, 2017 at 6:39 AM, Tiago Morin <address@hidden
    <mailto:address@hidden>> wrote:
    > Is there a way to color just one of the accidentals of a key
    signature?
    > For example: I'd like to color in red the d sharp of the "\key e
    \major" ,
    > leaving the rest of the accidentals in default color.
    >

    Try the code here:
    http://www.mail-archive.com/address@hidden/msg104047.html
    <http://www.mail-archive.com/address@hidden/msg104047.html>

    For your example, you'd write

     \override Staff.KeySignature.stencil =
      #(key-signature::special-print `((2 . ,red)))
     \key e \major

    Hope this helps!

    David




_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user




reply via email to

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