lilypond-user
[Top][All Lists]
Advanced

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

Re: lilypond-user Digest, Vol 119, Issue 90


From: Kevin Patrick Barry
Subject: Re: lilypond-user Digest, Vol 119, Issue 90
Date: Fri, 26 Oct 2012 19:39:44 +0100

Dear David and Harm,

Thank you both for the (super)quick responses - they both work perfectly!

Kevin


>> 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
>> address@hidden
>> 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



reply via email to

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