Hi Pierre,

thanks for taking the time to think about it.
Meanwhile, after some sleepless nights ;-) I've found another way to get some results:

% -------------------------------------------------------
\version "2.18.0"

colorSpan =

#(define-music-function (parser location y-lower y-upper color) (number? number? color?)

#{

\override Staff.HorizontalBracket #'stencil =

$(lambda (grob)

(let* (

(area (ly:horizontal-bracket::print grob))

(X-ext (ly:stencil-extent area X))

(Y-ext (ly:stencil-extent area Y))

)

(set! Y-ext (cons y-lower y-upper)

)

(ly:grob-set-property! grob 'layer -10)

(ly:make-stencil (list 'color color

(ly:stencil-expr (ly:round-filled-box X-ext Y-ext 0))

X-ext Y-ext))

))

#})

{

<< { R1

\colorSpan #-5 #5 #(rgb-color 1.0 0.9 0.5) c'2\startGroup g' c' \stopGroup

\colorSpan #0 #5 #(rgb-color 0.5 1.0 0.5)

r4\startGroup r \stopGroup

\colorSpan #-5 #0 #(rgb-color 0.9 1.0 0.5) r\startGroup r\stopGroup }

\\

{

\override Voice.ClusterSpanner.color = #(rgb-color 0.5 0.6 1)

\override Voice.ClusterSpanner.layer = #-1

\makeClusters { s1 c'2 g' c' s s1 }

}

>>

}

\layout {

\context {

\Voice

\consists "Horizontal_bracket_engraver"

\override HorizontalBracket #'thickness = #0

\override HorizontalBracket #'bracket-flare = #'(0 . 0)

\override HorizontalBracket #'Y-extent = #'(0 . 0)

\override HorizontalBracket #'edge-height = #'(0 . 0)

\override HorizontalBracket #'Y-offset = #0

\override HorizontalBracket #'shorten-pair = #'(-1 . -0.75)

}

}

% -------------------------------------------------------

Result: http://4.bp.blogspot.com/-THmAQWfqDaw/VHztoaE6N2I/AAAAAAAAACs/9Sqgl4ViMBc/s1600/ly-ex3.gif

This time, I "abused" the Horizontal_bracket_engraver that is used for \startGroup and \stopGroup and replaced it's stencil by a rectangle. Because it's not attached to the StaffSymbol, it can be placed in a different layer, so the blue cluster and the staff lines both stay visible. Anyway, LilyPond does the horizontal spacing without the need for manual work.

This might make life easier for doing crazy things like this:
http://4.bp.blogspot.com/-kEXoxAx6HG0/VHzvH9GW9KI/AAAAAAAAAC8/48vNguVdp2A/s1600/ly-ex4.gif
http://4.bp.blogspot.com/-ChtL4-lGKoE/VHzvHuNU76I/AAAAAAAAAC4/Do8L81Al19I/s1600/ly-ex5.gif


Cheers,
Klaus Blum




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

2014-11-29 10:30 GMT+01:00 Big Noise <[email protected] <mailto:[email protected]>>:

    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.


Right ! Now I see the problem, 'seems that I've replied without thinking...

    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...


Actually I've made this one (which is more or less a draft). I'll try to see what I can do with it. No promise though :(

Cheers,
Pierre


_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to