2012/10/26 David Nalesnik <david.nales...@gmail.com>: > Hi Kevin, > > On Thu, Oct 25, 2012 at 4:55 PM, Kevin Patrick Barry <barr...@tcd.ie> wrote: >> Dear LilyPond users, >> >> I would like the markup function \draw-line to produce a dashed line, but I >> can't find it in the internals reference to see what overrides to use. I >> tried TextScript #'style, Glissando #'style and \tweak #'style. I'm just >> fumbling in the dark really; none of the grobs involving lines seem to be >> it, and the spanner documentation doesn't tell me which either. Perhaps >> there's some way to change the line-spanner-interface? >> >> Thanks in advance, >> Kevin Barry >> > > I'm not aware of a markup command which draws dashed lines, and it > appears that \draw-line is tied to a solid line. Its possible, > however, to adapt the definition of \draw-line (found in > scm/define-markup-commands.scm) and `make-line-stencil' (in > scm/stencil.scm) to create a similar command. Here you can control > the thickness, length of the dashes (by overriding on and off). I'm > not sure what "phase" is for. Anyway, hope this helps! > > \version "2.17.5" > > #(define (make-dashed-line-stencil width startx starty endx endy on off phase) > (let ((xext (cons (min startx endx) (max startx endx))) > (yext (cons (min starty endy) (max starty endy)))) > (ly:make-stencil > (list 'dashed-line > ; thick on off dx dy phase > width on off (- endx startx) (- endy starty) phase) > ; Since the line has rounded edges, we have to / can safely add half the > ; width to all coordinates! > (interval-widen xext (/ width 2)) > (interval-widen yext (/ width 2))))) > > #(define-markup-command (draw-dashed-line layout props dest) > (number-pair?) > #:properties ((thickness 1) > (on 1) > (off 1) > (phase 0)) > (let ((th (* (ly:output-def-lookup layout 'line-thickness) > thickness)) > (x (car dest)) > (y (cdr dest))) > (make-dashed-line-stencil th 0 0 x y on off phase))) > > \markup \draw-dashed-line #'(11 . 0) > \markup \override #'(off . 4) \override #'(on . 2) \override #'(thickness . 3) > \draw-dashed-line #'(20 . 0) > > _______________________________________________ > lilypond-user mailing list > lilypond-user@gnu.org > https://lists.gnu.org/mailman/listinfo/lilypond-user
Hi David, you were faster. :) Nevertheless, here's my slightly different coding (including your examples): \version "2.16.0" #(define-markup-command (draw-dashed-line layout props dest) (number-pair?) #:category graphic #:properties ((thickness 1) (on 1) (off 1) (phase 0)) (let* ((th (* (ly:output-def-lookup layout 'line-thickness) thickness)) (half-thick (/ th 2)) (x (car dest)) (y (cdr dest))) (ly:make-stencil (list 'dashed-line th on off x y phase) (interval-widen (ordered-cons 0 x) half-thick) (interval-widen (ordered-cons 0 y) half-thick)))) \markup \fill-line { \column { \box \draw-dashed-line #'(-15 . 2) \box \draw-line #'(15 . 2) } } \markup \draw-dashed-line #'(11 . 0) \markup \override #'(off . 4) \override #'(on . 2) \override #'(thickness . 3) \draw-dashed-line #'(20 . 0) @Kevin See Davids post for explanations. Regards, Harm _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user