lilypond-user
[Top][All Lists]
Advanced

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

Re: improving whiteout


From: EdBeesley
Subject: Re: improving whiteout
Date: Wed, 16 Oct 2013 16:03:40 -0700 (PDT)

karol wrote
> Here's another example of an ugly output (whiteout.png)
> 
> \override DynamicText.whiteout = ##t
> 
> 
> Something has to be done to prevent situations like this.
> 
> As a workaround I use this solution:
> 
> ------begin------
> 
> #(define-public
>   (stencil-with-color stencil color)
>   (ly:make-stencil
>     (list 'color color
>       (ly:stencil-expr stencil))
>     (ly:stencil-extent stencil X)
>     (ly:stencil-extent stencil Y)))
> 
> #(define
>   (stencil-padded-whiteout stencil padding)
>   (let*
>     ((x-ext
>         (ly:stencil-extent stencil X))
>       (y-ext
>         (ly:stencil-extent stencil Y)))
>     (ly:stencil-add
>       (stencil-with-color
>         (ly:round-filled-box
>           (interval-widen x-ext padding)
>           (interval-widen y-ext padding) 0) white) stencil)))
> 
> #(define
>   (text-in-white-box grob)
>   (stencil-padded-whiteout
>     (ly:text-interface::print grob) 0.2))
> 
> \layout {
>   \context {
>     \Score
>     \override DynamicText.stencil = #text-in-white-box
>   }
> }
> 
> -------end-------
> 
> This code does the job, but i'm not sure if it has any drawbacks. Any
> thoughts?
> 
> -Karol

Hi Karol, 

I had a similar question last week and Thomas Morley generated this
fantastic little function which lets you increase the extent of the whiteout
box by your own values. Originally this was for the DynamicTextSpanner but
it's easy to change that for other Spanners.

moreVerticalDynamicTextSpannerWhiteoutII = 
  #(define-music-function (parser location adds)(pair?) 

    (define (flexible-stencil-whiteout add stencil) 
      (let* 
          ((x-ext (ly:stencil-extent stencil X)) 
           (y-ext (ly:stencil-extent stencil Y))) 
        (ly:stencil-add 
         (stencil-with-color 
            (ly:round-filled-box 
               (interval-widen x-ext (car add)) 
               (interval-widen y-ext (cdr add)) 
               0.0) 
            white) 
         stencil))) 

    (define more-stencil-whiteout 
      (lambda (grob) 
           (let* ((stil (ly:line-spanner::print grob)) 
                  (x-ext (ly:stencil-extent stil X)) 
                  (y-ext (ly:stencil-extent stil Y)) 
                  (whiteout-stil (flexible-stencil-whiteout adds stil))) 
             (ly:make-stencil 
                (ly:stencil-expr whiteout-stil) 
                x-ext 
                y-ext)))) 
    #{ 
      %% Needed for 2.17.x: 
      \override DynamicTextSpanner #'vertical-skylines = #'() 
      \once \override DynamicTextSpanner #'stencil = 
         #more-stencil-whiteout 
    #}) 

\score { 
  \new GrandStaff << 
    \new Staff 
      \relative c' { 
         c d e 
         \moreVerticalDynamicTextSpannerWhiteoutII #'(0 . 1.5) 
         f \cresc c  d e f \! 
      } 
    \new Staff 
      \relative c' { 
         c d e f \cresc c  d e f \! 
      } 
  >> 
}

Give it a try, I find the ability to set your own values for the extent of
the whiteout absolutely invaluable. 



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/improving-whiteout-tp152429p152434.html
Sent from the User mailing list archive at Nabble.com.



reply via email to

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