lilypond-user
[Top][All Lists]
Advanced

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

Re: scheme problem: colored background, layers


From: Big Noise
Subject: Re: scheme problem: colored background, layers
Date: Sat, 29 Nov 2014 10:30:31 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

Salut Pierre,

thanks for your reply.
Unfortunately, changing the layer value from -10 to -2 doesn't help. The problem is that the function places the staff lines and the colored rectangle into the *same* layer, whereas I need to leave the staff lines in layer 0 and put the rectangle into layer -2 (or even less).
This would allow me to put other clusters *between* them like in the first example.

I have already found another interesting snippet: http://lsr.di.unimi.it/LSR/Item?id=953
But in that case, I would have to find the dimensions for the rectangle by trial-and-error, whereas overriding the StaffSymbol seems to be a very easy way...

Cordialement,
Klaus Blum


Am 29.11.2014 um 10:05 schrieb Pierre Perol-Schneider:
Hi,

2014-11-29 1:15 GMT+01:00 Big Noise <address@hidden>:
 
Here is my problem:
Now the staff lines and the yellow rectangle are located in the same layer, so it's not possible to place the blue cluster between them.
Is there a way to make the scheme function put the staff lines ("StaffSymbol") and the yellow rectangle into different layers?


How about changing the layer value from -10 to -2 ?

bgColor =
#(define-music-function (parser location y-lower y-upper color) (number? number? string?)
   #{
     \stopStaff
     \override Staff.StaffSymbol.stencil =
     $(lambda (grob)
        (let* ((staff (ly:staff-symbol::print grob))
               (X-ext (ly:stencil-extent staff X))
               (Y-ext (ly:stencil-extent staff Y)))
          (set! Y-ext (cons
                       (- (car Y-ext) y-lower)
                       (+ (cdr Y-ext) y-upper)))
          ;; change layer's value to -2
          (ly:grob-set-property! grob 'layer -2)
          (ly:stencil-add
           (ly:make-stencil (list 'color (eval-string color)
                              (ly:stencil-expr (ly:round-filled-box X-ext Y-ext 0))
                              X-ext Y-ext))
           staff)))
     \startStaff
   #})


HTH
Pierre


reply via email to

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