Re: Dashed Stem Fontsize !
Thank you very much for your help Harm !!! Gilles Le vendredi 22 juillet 2022 à 19:27:50 UTC+2, Thomas Morley a écrit : Am Fr., 22. Juli 2022 um 13:04 Uhr schrieb Ya Gloops : > > > Hello ! I try to keep the proportion of the "dashed-stem" but I can't... If > someone can help me. > Gilles > > \version "2.23.10" > > > %#(set-global-staff-size 30) > > > #(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 (build-pos-list len on off) > (let ((lst '(0))) > > (define (helper) > (let ((bottom (+ (car lst) on))) > (if (< bottom len) > (begin > (set! lst (cons bottom lst)) > (let ((top (+ (car lst) off))) > (if (< top len) > (begin > (set! lst (cons top lst)) > (helper)) > (set! lst (cons len lst) > (set! lst (cons len lst) > (helper) > (reverse lst))) > > > #(define (dashed-stem on off) > (lambda (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)) > (Y-ext (ly:stencil-extent stencil Y)) > (len (interval-length Y-ext)) > (new-stencil empty-stencil) > (factors (build-pos-list len on off))) > > (define (helper args) > (if (<= 2 (length args)) > (begin > (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 Y-ext) > Y))) > (helper (cddr args))) > new-stencil)) > > > (if (or (zero? on) (zero? off)) > stencil > (helper factors) > > > dashedStems = > #(define-music-function (on off) (number? number?) > #{ > \override Stem.stencil = #(dashed-stem on off) > #}) > > > > > \relative c'' { > \dashedStems #0.5 #0.4 > c4 > } > > > \score > { > \relative c'' { \magnifyStaff #(magstep 10) > \dashedStems #0.5 #0.4 > c4 > } > } > Scale on/off with staff-space, (ly:staff-symbol-staff-space grob). HTH, Harm
Re: Dashed Stem Fontsize !
Am Fr., 22. Juli 2022 um 13:04 Uhr schrieb Ya Gloops : > > > Hello ! I try to keep the proportion of the "dashed-stem" but I can't... If > someone can help me. > Gilles > > \version "2.23.10" > > > %#(set-global-staff-size 30) > > > #(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 (build-pos-list len on off) >(let ((lst '(0))) > > (define (helper) >(let ((bottom (+ (car lst) on))) > (if (< bottom len) > (begin > (set! lst (cons bottom lst)) > (let ((top (+ (car lst) off))) > (if (< top len) > (begin > (set! lst (cons top lst)) > (helper)) > (set! lst (cons len lst) > (set! lst (cons len lst) > (helper) > (reverse lst))) > > > #(define (dashed-stem on off) >(lambda (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)) > (Y-ext (ly:stencil-extent stencil Y)) > (len (interval-length Y-ext)) > (new-stencil empty-stencil) > (factors (build-pos-list len on off))) > >(define (helper args) > (if (<= 2 (length args)) > (begin > (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 Y-ext) > Y))) > (helper (cddr args))) > new-stencil)) > > >(if (or (zero? on) (zero? off)) >stencil >(helper factors) > > > dashedStems = > #(define-music-function (on off) (number? number?) >#{ > \override Stem.stencil = #(dashed-stem on off) >#}) > > > > > \relative c'' { > \dashedStems #0.5 #0.4 > c4 > } > > > \score > { > \relative c'' { \magnifyStaff #(magstep 10) > \dashedStems #0.5 #0.4 > c4 > } > } > Scale on/off with staff-space, (ly:staff-symbol-staff-space grob). HTH, Harm
Dashed Stem Fontsize !
Hello ! I try to keep the proportion of the "dashed-stem" but I can't... If someone can help me. Gilles \version "2.23.10" %#(set-global-staff-size 30) #(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 (build-pos-list len on off) (let ((lst '(0))) (define (helper) (let ((bottom (+ (car lst) on))) (if (< bottom len) (begin (set! lst (cons bottom lst)) (let ((top (+ (car lst) off))) (if (< top len) (begin (set! lst (cons top lst)) (helper)) (set! lst (cons len lst) (set! lst (cons len lst) (helper) (reverse lst))) #(define (dashed-stem on off) (lambda (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)) (Y-ext (ly:stencil-extent stencil Y)) (len (interval-length Y-ext)) (new-stencil empty-stencil) (factors (build-pos-list len on off))) (define (helper args) (if (<= 2 (length args)) (begin (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 Y-ext) Y))) (helper (cddr args))) new-stencil)) (if (or (zero? on) (zero? off)) stencil (helper factors) dashedStems = #(define-music-function (on off) (number? number?) #{ \override Stem.stencil = #(dashed-stem on off) #}) \relative c'' { \dashedStems #0.5 #0.4 c4 } \score { \relative c'' { \magnifyStaff #(magstep 10) \dashedStems #0.5 #0.4 c4 } }
Re: Dashed Stem
On Sat, May 12, 2012 at 1:39 PM, David Kastrup wrote: > I don't really understand the function, but maybe something like > > (define (build-pos-list len on off) > (let helper ((lst '()) (next 0) (on on) (off off)) >(if (< next len) >(helper (cons next lst) (+ next on) off on) >(reverse! lst (list len) > > will do. No idea whether this should have an even number of elements > always or not. Thank you, David. This works like a charm! -David N. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Dashed Stem
David Nalesnik writes: > OK! This should do it. > > > Those functions using 'round-filled-box could be tailored to match > the capabilities of 'dashed-line. > > > > The rewrite combines both of the approaches above: it uses > 'round-filled-box for the stencil, and allows you to specify the > length of the dashes and the spaces in between the dashes. The > trade-off is that you may need to play around with the values to get > the stem to end with a dash, or to end with a dash which isn't cut off > too much. > > I incorporated the alterations that Harm made because I think they > make the code clearer. > > I imagine the function build-pos-list could be done more elegantly, > but at least it works. Any suggestions for doing this more artfully > are welcome! I don't really understand the function, but maybe something like (define (build-pos-list len on off) (let helper ((lst '()) (next 0) (on on) (off off)) (if (< next len) (helper (cons next lst) (+ next on) off on) (reverse! lst (list len) will do. No idea whether this should have an even number of elements always or not. -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Dashed Stem
OK! This should do it. Those functions using 'round-filled-box could be tailored to match the > capabilities of 'dashed-line. > > The rewrite combines both of the approaches above: it uses 'round-filled-box for the stencil, and allows you to specify the length of the dashes and the spaces in between the dashes. The trade-off is that you may need to play around with the values to get the stem to end with a dash, or to end with a dash which isn't cut off too much. I incorporated the alterations that Harm made because I think they make the code clearer. I imagine the function build-pos-list could be done more elegantly, but at least it works. Any suggestions for doing this more artfully are welcome! Thanks, David \version "2.15.38" %#(set-global-staff-size 30) #(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 (build-pos-list len on off) (let ((lst '(0))) (define (helper) (let ((bottom (+ (car lst) on))) (if (< bottom len) (begin (set! lst (cons bottom lst)) (let ((top (+ (car lst) off))) (if (< top len) (begin (set! lst (cons top lst)) (helper)) (set! lst (cons len lst) (set! lst (cons len lst) (helper) (reverse lst))) #(define (dashed-stem on off) (lambda (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)) (Y-ext (ly:stencil-extent stencil Y)) (len (interval-length Y-ext)) (new-stencil empty-stencil) (factors (build-pos-list len on off))) (define (helper args) (if (<= 2 (length args)) (begin (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 Y-ext) Y))) (helper (cddr args))) new-stencil)) (if (or (zero? on) (zero? off)) stencil (helper factors) dashedStems = #(define-music-function (parser location on off) (number? number?) #{ \override Stem #'stencil = #(dashed-stem on off) #}) \relative c'' { \dashedStems #0.5 #0.4 c d e f,, a'8 g' f' g, } ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Dashed Stem
Hi again, > Hmmm, Setting 'blot-diameter like I did actually affects regular stems > and the newly-drawn stems not at all... > So remove this line if you use the newer function: (ly:output-def-set-variable! (ly:grob-layout grob) 'blot-diameter 0.8) -David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Dashed Stem
On Sat, May 12, 2012 at 7:32 AM, David Nalesnik wrote: I've come up with a simpler variant which makes use of the 'dashed-line > function. (I didn't use this initially because I couldn't figure out how > to get the roundedness of the line segments to match the ordinary stem's > and also because I wanted to ensure a full-length dash at top and bottom.) > Hmmm, Setting 'blot-diameter like I did actually affects regular stems and the newly-drawn stems not at all... So I guess the earlier method is the way to go. (That is, unless there is a way to change the rounding of the 'dashed-line stencil, or if such things really don't matter!) Those functions using 'round-filled-box could be tailored to match the capabilities of 'dashed-line. Best, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Dashed Stem
Hi, On Sat, May 12, 2012 at 3:05 AM, Urs Liska wrote: > Hi David, Hi Thomas, > > thank you very much! > I'm increasingly fascinated by LilyPond - and this mailing list. > And I'll definitely have to learn how to write Scheme functions myself ... > > With your suggestions I can really solve the problem at hand, so thanks. > What I especially like about the new solution is that it automatically > uses the original Stem's thickness (so it's independent from overrides. > > Maybe it would be nice to be able to use this more generally (as a > \stemDashed command). But for this it shouldn't have a fixed number of > dashes but rather a consistent dash pattern (independent from the Stem's > length. Although I don't really understand the function, I assume that the > original Stem's length is already used. So it should be quite simple to use > this and calculate the dashes from that? > I don't expect to be able to apply such complex operations as curve's > 'dash-definition. But if one would use two variables that are defined in > the function's file one could then redefine them in the music file. > > I've come up with a simpler variant which makes use of the 'dashed-line function. (I didn't use this initially because I couldn't figure out how to get the roundedness of the line segments to match the ordinary stem's and also because I wanted to ensure a full-length dash at top and bottom.) These functions require two arguments: one for the length of the dash and one for the length of the spaces in between. Setting values might require some trial and error. Some combinations won't fit the length of the stem such that a segment appears at its end. See what you think! \version "2.15.38" #(define (dashed-stem on off) (lambda (grob) (let* ((stencil (ly:stem::print grob)) (X-ext (ly:stencil-extent stencil X)) (Y-ext (ly:stencil-extent stencil Y)) (width (interval-length X-ext)) (len (interval-length Y-ext))) (ly:output-def-set-variable! (ly:grob-layout grob) 'blot-diameter 0.08) (ly:stencil-translate (ly:make-stencil `(dashed-line ,width ,on ,off 0 ,len 0)) (cons 0 (interval-start Y-ext)) dashedStem = #(define-music-function (parser location on off) (number? number?) #{ \once \override Stem #'stencil = #(dashed-stem on off) #}) \relative c'' { \dashedStem #0.5 #0.75 c \dashedStem #0.5 #0.5 c \dashedStem #0.25 #0.5 c \dashedStem #0.25 #0.25 c } -David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Dashed Stem
Hi David, Hi Thomas, thank you very much! I'm increasingly fascinated by LilyPond - and this mailing list. And I'll definitely have to learn how to write Scheme functions myself ... With your suggestions I can really solve the problem at hand, so thanks. What I especially like about the new solution is that it automatically uses the original Stem's thickness (so it's independent from overrides. Maybe it would be nice to be able to use this more generally (as a \stemDashed command). But for this it shouldn't have a fixed number of dashes but rather a consistent dash pattern (independent from the Stem's length. Although I don't really understand the function, I assume that the original Stem's length is already used. So it should be quite simple to use this and calculate the dashes from that? I don't expect to be able to apply such complex operations as curve's 'dash-definition. But if one would use two variables that are defined in the function's file one could then redefine them in the music file. But as said, for my actual task I can very well use it as it is and just decide upon the number of dashes manually. Best Urs Am 12.05.2012 04:57, schrieb David Nalesnik: Hi Harm, I suggest the code below. It's very close to your own but it seems to avoid the problems. When I tried your code out, the same problems happened for me! I concluded that this is an issue with the viewer in LilyPondTool, and sure enough, when I "view PDF with external PDF-viewer," the problem disappears, and I see all 20 line segments with both your version and mine too. Certain aspects of your rewrite are clearer than mine--thank you! Best, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Dashed Stem
Hi Harm, I suggest the code below. It's very close to your own but it seems to > avoid the problems. > > When I tried your code out, the same problems happened for me! I concluded that this is an issue with the viewer in LilyPondTool, and sure enough, when I "view PDF with external PDF-viewer," the problem disappears, and I see all 20 line segments with both your version and mine too. Certain aspects of your rewrite are clearer than mine--thank you! Best, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Dashed Stem
2012/5/12 David Nalesnik : > 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' 32 \compare \transpose c d' \compare \transpose c e' \compare \transpose c f' \compare \transpose c g' \compare \transpose c a' \compare \transpose c b' \compare \transpose c c'' } Best, Harm ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Dashed Stem
Hi again, On Fri, May 11, 2012 at 11:24 AM, David Nalesnik wrote: > Hi Urs, > > On Fri, May 11, 2012 at 7:06 AM, Urs Liska wrote: > >> Am I right that you can't make a Stem dashed? I didn"t find anything in >> the IR. >> >> What would then be the proper way to attach a dashed line to a note in >> place of the Stem? >> >> > Here's something I came up with. It's not ideal. If you compare the > substitute stems with ordinary stems, you'll find differences. (These > relate, I think, to how rounded the lines are--to 'blot-diameter.) But > hopefully this will do. > > The argument allows you to specify the number of dashes in your stem. > 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. Anyway, here it is: \version "2.15.38" %#(set-global-staff-size 14) #(define (dashed-stem num) (lambda (grob) (let* ((stencil (ly:stem::print grob)) (X-ext (ly:stencil-extent stencil X)) (Y-ext (ly:stencil-extent stencil Y)) (b-d (ly:output-def-lookup (ly:grob-layout grob) 'blot-diameter)) (len (interval-length Y-ext)) (lst '()) (factors (map (lambda (x) (* (/ len (1- (* 2 num))) x)) (iota (* 2 num) (define (helper args) (set! lst (cons (ly:make-stencil `(round-filled-box (- ,(car X-ext)) ,(cdr X-ext) (- ,(+ (car Y-ext) (car args))) ,(+ (car Y-ext) (cadr args)) ,b-d) X-ext Y-ext) lst)) (if (null? (cddr args)) lst (helper (cddr args)))) (if (zero? num) stencil (apply ly:stencil-add (helper factors)) \relative c'' { \once \override Stem #'stencil = #(dashed-stem 2) c \once \override Stem #'stencil = #(dashed-stem 3) d \once \override Stem #'stencil = #(dashed-stem 5) e \once \override Stem #'stencil = #(dashed-stem 6) f } ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Dashed Stem
Hi Urs, On Fri, May 11, 2012 at 7:06 AM, Urs Liska wrote: > Am I right that you can't make a Stem dashed? I didn"t find anything in > the IR. > > What would then be the proper way to attach a dashed line to a note in > place of the Stem? > > Here's something I came up with. It's not ideal. If you compare the substitute stems with ordinary stems, you'll find differences. (These relate, I think, to how rounded the lines are--to 'blot-diameter.) But hopefully this will do. The argument allows you to specify the number of dashes in your stem. \version "2.15.38" #(define (dashed-stem num) (lambda (grob) (let* ((stencil (ly:stem::print grob)) (ext (ly:stencil-extent stencil Y)) (len (interval-length ext)) (lst '()) (factors (map (lambda (x) (* (/ len (1- (* 2 num))) x)) (iota (* 2 num) (define (helper args) (set! lst (cons (make-line-stencil 0.13 ;; thickness 0 (+ (car ext) (car args)) 0 (+ (car ext) (cadr args))) lst)) (if (null? (cddr args)) lst (helper (cddr args (if (zero? num) stencil (apply ly:stencil-add (helper factors)) \relative c'' { \once \override Stem #'stencil = #(dashed-stem 2) c \once \override Stem #'stencil = #(dashed-stem 3) d \once \override Stem #'stencil = #(dashed-stem 4) e \once \override Stem #'stencil = #(dashed-stem 5) f } HTH, David ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Dashed Stem
Am I right that you can't make a Stem dashed? I didn"t find anything in the IR. What would then be the proper way to attach a dashed line to a note in place of the Stem? Thanks Urs -- Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user