[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Dashed Stem
From: |
Thomas Morley |
Subject: |
Re: Dashed Stem |
Date: |
Sat, 12 May 2012 04:24:05 +0200 |
2012/5/12 David Nalesnik <address@hidden>:
> Looking at this some more, I've come up with an alternate which more closely
> duplicates an ordinary stem. Instead of using line segments, I used
> round-filled-box stencils, which is what Lily uses to draw stems.
>
> Everything is fine when the dashes aren't too small. If you ask for more
> than 6 at staff-size 20, though, some dashes won't appear. You see similar
> behavior if the staff size is reduced. (To see this, uncomment the line at
> the top of the function.) I'm not sure what's going on here, if this is a
> limitation of 'round-filled-box, or something I'm doing wrong.
Hi David,
I suggest the code below. It's very close to your own but it seems to
avoid the problems.
\version "2.15.36"
%#(set-global-staff-size 14)
#(define (make-round-filled-box x1 x2 y1 y2 blot-diameter)
(ly:make-stencil (list 'round-filled-box (- x1) x2 (- y1) y2 blot-diameter)
(cons x1 x2)
(cons y1 y2)))
#(define ((dashed-stem num) grob)
(let* ((blot (ly:output-def-lookup (ly:grob-layout grob) 'blot-diameter))
(stencil (ly:stem::print grob))
(X-ext (ly:stencil-extent stencil X))
(thickness (interval-length X-ext))
(ext (ly:stencil-extent stencil Y))
(len (interval-length ext))
(new-stencil empty-stencil)
(factors
(map
(lambda (x) (* (/ len (1- (* 2 num))) x))
(iota (* 2 num)))))
(define (helper args)
(set! new-stencil
(ly:stencil-add new-stencil
(ly:stencil-translate-axis
(make-round-filled-box (/ thickness -2) (/ thickness 2)
(car args) (cadr args) blot)
(interval-start ext)
Y)))
(if (null? (cddr args))
new-stencil
(helper (cddr args))))
(if (zero? num)
stencil
(helper factors))))
%---- test
% compare only avoids too much typing :)
compare =
#(define-music-function (parser location music)(ly:music?)
(let* ((new-music (ly:music-deep-copy music)))
#{
$music
\override Stem #'stencil = #(dashed-stem 20)
$new-music
\revert Stem #'stencil
#}))
\relative c' {
\compare g
\compare a
\compare b
\compare c
\compare d
\compare e
\compare f
\compare g
\compare a
\compare b
\compare c
\compare d
\compare e
\compare f
\compare g
\compare a
}
\relative c' {
\compare \transpose c c' <c e g b>32
\compare \transpose c d' <c e g b>
\compare \transpose c e' <c e g b>
\compare \transpose c f' <c e g b>
\compare \transpose c g' <c e g b>
\compare \transpose c a' <c e g b>
\compare \transpose c b' <c e g b>
\compare \transpose c c'' <c e g b>
}
Best,
Harm
- Dashed Stem, Urs Liska, 2012/05/11
- Re: Dashed Stem, David Nalesnik, 2012/05/11
- Re: Dashed Stem, David Nalesnik, 2012/05/11
- Re: Dashed Stem,
Thomas Morley <=
- Re: Dashed Stem, David Nalesnik, 2012/05/11
- Re: Dashed Stem, Urs Liska, 2012/05/12
- Re: Dashed Stem, David Nalesnik, 2012/05/12
- Re: Dashed Stem, David Nalesnik, 2012/05/12
- Re: Dashed Stem, David Nalesnik, 2012/05/12
- Re: Dashed Stem, David Nalesnik, 2012/05/12
- Re: Dashed Stem, David Kastrup, 2012/05/12
- Re: Dashed Stem, David Nalesnik, 2012/05/12