[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: circle around stem
From: |
Orm Finnendahl |
Subject: |
Re: circle around stem |
Date: |
Fri, 8 Jul 2022 18:40:03 +0200 |
Hi,
FYI: I mostly solved it by setting Stem.details.lengths (see below).
Setting this property within the stencil function doesn't seem to work
(it's the line: "(ly:grob-set-nested-property! grob '(details lengths)
'(3.5 3.5 4.25 5 6 7 8))" in #'damp-stem).
I assume this happens because the stencil function is called after the
length already has been determined, or because I misunderstand the
syntax and I'd be interested if someone can shed a light on that (and
maybe even provide a solution), but this already is very usable the
way it is.
--
Orm
8<-----------------------------------------------------------------------
#(define (damp-stem grob)
(if (ly:stencil? (ly:stem::print grob))
(let* ((stencil (ly:stem::print grob))
(X-ext (ly:stencil-extent stencil X))
(Y-ext (ly:stencil-extent stencil Y))
(dir (ly:grob-property grob 'direction))
(width (interval-length X-ext))
(len (interval-length Y-ext))
(y-offs (if (= dir 1) 1.29 (- len 1.29))))
(ly:grob-set-nested-property! grob '(details lengths) '(3.5 3.5 4.25 5 6 7
8))
(ly:stencil-translate
(grob-interpret-markup grob
(markup
(#:path width
(list (list 'moveto -0 0)
(list 'lineto -0 len)))
(#:hspace -1.19)
(#:raise y-offs
(#:draw-circle 0.45 width #f))))
(cons 0 (interval-start Y-ext))))
#f))
damp = { \once \override Stem.details.lengths = #'(3.5 3.5 4.25 5 6 7 8)
\once \override Stem.stencil = #damp-stem }
{\autoBeamOff
\override Stem.details.lengths = #'(3.5 3.5 4.25 5 6 7 8)
\override Stem.stencil = #damp-stem c'4 c'8 c'16 c'32 c'64 c'128 s32 c''4 c''8
c''16 c''32 c''64 c''128
\revert Stem.details.lengths
\revert Stem.stencil
\damp c'32
\damp c''32
c''32
}
8<-----------------------------------------------------------------------
Am Freitag, den 08. Juli 2022 um 16:22:22 Uhr (+0200) schrieb Orm Finnendahl:
> Hi,
>
> trying to define an overwrite to draw a circle around a stem I came
> up with the code below. Unfortunately it doesn't automagically work
> for all use cases as can be seen in the attached image: The code
> doesn't take the number of flags into account. I know that the stem
> length can be altered with a tweak, but I'd prefer this to be
> corrected without manual intervention. Is there a way within the
> damp-stem function to force a minimum stem-length depending on the
> number of flags if notes aren't beamed?
>
> --
> Orm
>
> 8<-----------------------------------------------------------------------
> #(define (damp-stem grob)
> (if (ly:stencil? (ly:stem::print grob))
> (let* ((stencil (ly:stem::print grob))
> (X-ext (ly:stencil-extent stencil X))
> (Y-ext (ly:stencil-extent stencil Y))
> (dir (ly:grob-property grob 'direction))
> (width (interval-length X-ext))
> (len (interval-length Y-ext))
> (y-offs (if (= dir 1) 1.29 (- len 1.29))))
> (ly:stencil-translate
> (grob-interpret-markup grob
> (markup
> (#:path width
> (list (list 'moveto -0 0)
> (list 'lineto -0 len)))
> (#:hspace -1.13)
> (#:circle
> (#:path 0.15
> (list
> (list 'moveto 0 y-offs))))))
> (cons 0 (interval-start Y-ext))))
> #f))
>
> damp = { \once \override Stem.stencil = #damp-stem }
>
> {\autoBeamOff
> \override Stem.stencil = #damp-stem c'4 c'8 c'16 c'32 c'64 s32 c''4 c''8
> c''16 c''32 c''64 }
> 8<-----------------------------------------------------------------------