lilypond-user
[Top][All Lists]
Advanced

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

Re: TupletBrackets edge thickness


From: Lukas-Fabian Moser
Subject: Re: TupletBrackets edge thickness
Date: Sat, 10 Aug 2024 19:11:09 +0200
User-agent: Mozilla Thunderbird

Hi Kieren,

Left to do: We probably also should modify the extents of the resulting stencil to avoid collisions...
If the thickness of the edge lines are expanded *inwards*, wouldn’t the original extent still be accurate enough to use?

Yes, good idea. But then we see that for thick lines, LilyPond's rounded line tips become a problem (actually, the problem wouldn't be just as serious with box-formed line tips):

So we should probably replace the edge line by a box, more precisely: by a polygon with the correct slope at least on the connecting side. Sigh.

Re-posting the source nevertheless, since in my first attempt I forgot that TupletBrackets can point upwards or downwards.

\version "2.24.0"

#(define (list-add! lst k x)
   (list-set! lst k (+ (list-ref lst k) x)))

{
  \override TupletBracket.stencil =
  #(grob-transformer
    'stencil
    (lambda (grob stil)
      (let*
       ((expr (ly:stencil-expr stil))
        (xext (ly:stencil-extent stil X))
        (yext (ly:stencil-extent stil Y))
        (lines (cdaddr expr))
        (right (first lines))
        (left (second lines))
        (thick (second right))
        (dir (- (ly:grob-property grob 'direction)))
        (new-thick 0.7)  ;; adjust at will
        (offset (/ (- new-thick thick) 2)))
       
       (list-set! right 1 new-thick)
       (list-add! right 2 (- offset))         ; x1
       (list-add! right 3 (* dir offset))     ; y1
       (list-add! right 4 (- offset))         ; x2

       (list-set! left 1 new-thick)
       (list-add! left 2 offset)              ; x1
       (list-add! left 3 (* dir offset))      ; y1
       (list-add! left 4 offset)              ; x2

       (ly:make-stencil expr xext yext))))

  \tupletDown
  \tuplet 3/2 { c'4 d' c''' }
  \tupletUp
  \tuplet 3/2 { c'4 d' e' }
}

And of course: The proper way to handle all of this would be to just swallow the pill and re-implement the a modified TupletBracket stencil in Scheme.

Lukas


reply via email to

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