lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dashed \draw-line


From: David Nalesnik
Subject: Re: dashed \draw-line
Date: Thu, 25 Oct 2012 18:24:02 -0500

Hi Kevin,

On Thu, Oct 25, 2012 at 4:55 PM, Kevin Patrick Barry <address@hidden> 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]