Am Sa., 8. Feb. 2020 um 22:20 Uhr schrieb Paolo Prete <address@hidden>:
>
>
You could redefine box-stencil to take an additional color-argument.
Also stencil-boxer to take an optional color-argument:
#(define (box-stencil stencil thickness padding color)
"Add a box around @var{stencil}, producing a new stencil."
(let* ((x-ext (interval-widen (ly:stencil-extent stencil 0) padding))
(y-ext (interval-widen (ly:stencil-extent stencil 1) padding))
(y-rule
(stencil-with-color
(make-filled-box-stencil (cons 0 thickness) y-ext) color))
(x-rule
(stencil-with-color
(make-filled-box-stencil
(interval-widen x-ext thickness) (cons 0 thickness)) color)))
(set! stencil (ly:stencil-combine-at-edge stencil X 1 y-rule padding))
(set! stencil (ly:stencil-combine-at-edge stencil X -1 y-rule padding))
(set! stencil (ly:stencil-combine-at-edge stencil Y 1 x-rule 0.0))
(set! stencil (ly:stencil-combine-at-edge stencil Y -1 x-rule 0.0))
stencil))
#(define* (make-stencil-boxer thickness padding callback #:optional (color red))
"Return function that adds a box around the grob passed as argument."
(lambda (grob)
(box-stencil (callback grob) thickness padding color)))
{
\override TextScript.stencil =
#(make-stencil-boxer 0.1 0.3 ly:text-interface::print)
\override Script.stencil =
#(make-stencil-boxer 0.1 0.3 ly:script-interface::print)
\override NoteHead.stencil =
#(make-stencil-boxer 0.1 0.3 ly:note-head::print cyan)
c'4^"foo"->
\override TupletBracket.stencil =
#(make-stencil-boxer 0.1 0.8 ly:tuplet-bracket::print)
\tuplet 3/2 { b4 4 4 }
}
Cheers,
Harm
Thanks to Harm and Aaron.
At this point, is there a way to extend the box by setting four parameters separately:
top, bottom, left, right
..., instead of the "padding" one ?
Something like:
#(make-stencil-boxer 0.1 #paddingLeft #paddingRight #paddingTop #paddingBottom ly:script-interface::print cyan)