lilypond-user
[Top][All Lists]
Advanced

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

Re: Modyfing bracketify-stencil


From: Marcin Damianiak
Subject: Re: Modyfing bracketify-stencil
Date: Wed, 1 Sep 2021 15:50:49 +0200

Lukas,

Thank you so much, it works perfectly! That's exactly what I've been looking for :)

Best,
Marcin

śr., 1 wrz 2021 o 10:54 Lukas-Fabian Moser <lfm@gmx.de> napisał(a):
Hi Marcin,

Am 01.09.21 um 02:11 schrieb Marcin Damianiak:
> Dear All,
>
> I have two questions regarding the bracketify-stencil function. When I
> use the following snippet:
>
> \relative c' {
> \time 4/4
> \once\override Staff.MultiMeasureRest.stencil = #(lambda (grob)
> (bracketify-stencil (ly:multi-measure-rest::print grob) Y 0.1 0.2 0.1))
> R1
> }

Just an unrelated hint: By now, I prefer using grob-transformer as it
enables me to use bracketify-stencil without having to resort to ::print
routines, which means the routine can be used generically:

bracketizer =
#(grob-transformer 'stencil
                    (lambda (grob default)
                      (bracketify-stencil default Y 0.2 0.5 0.3)))
% usage:
% \once\override Rest.stencil = \bracketizer

bracketify =
#(define-music-function (grob-path) (key-list?)
    #{ \once\override $grob-path . stencil = \bracketizer #})

% usage:
% \bracketify Score.TimeSignature

> it creates brackets of the inner object's exact height. I'd like to
> ask whether it is possible to:
> 1. make them longer on both ends, to extend beyond the parenthesized
> object
> 2. disable one of the brackets (to keep only left or right)

I think it might be easiest to take the source code of
bracketify-stencil and add the necessary options.

\version "2.22.0"

#(define (other-axis a)
    (remainder (+ a 1) 2))

#(define (flex-bracketify-stencil stil axis thick protrusion
Y-protrusion padding left? right?)
    "Add brackets around @var{stil}, producing a new stencil."

    (let* ((ext (interval-widen (ly:stencil-extent stil axis) Y-protrusion))
           (lb (ly:bracket axis ext thick protrusion))
           (rb (ly:bracket axis ext thick (- protrusion))))
      (if right?
          (set! stil
                (ly:stencil-combine-at-edge stil (other-axis axis) 1 rb
padding)))
      (if left?
          (set! stil
                (ly:stencil-combine-at-edge stil (other-axis axis) -1 lb
padding)))
      stil))

{
   \once \override Rest.stencil =
   #(grob-transformer
     'stencil
     (lambda (grob default)
       (flex-bracketify-stencil default Y 0.1 0.2 0.3 0.1 #t #f)))
   r4
   \once \override Rest.stencil =
   #(grob-transformer
     'stencil
     (lambda (grob default)
       (flex-bracketify-stencil default Y 0.1 0.2 1.5 0.1 #f #t)))
   r4
}

Lukas


reply via email to

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