[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: \path in markup dashed line
From: |
Aaron Hill |
Subject: |
Re: \path in markup dashed line |
Date: |
Mon, 07 Sep 2020 16:38:16 -0700 |
User-agent: |
Roundcube Webmail/1.4.2 |
On 2020-09-07 1:20 pm, Aaron Hill wrote:
Given a cursory glance, it would seem doable. One would need to
copy/borrow the existing logic for \path and then add a suitable
"setdash" command to the PostScript output and an equivalent
"stroke-dasharray" attribute to the SVG output. Looking at how
\draw-dashed-line works should provide a useful reference.
Here is an attempt that covers only PostScript:
%%%%
\version "2.20.0"
#(define* (dashed-path-ps thickness on off phase exps
#:optional (cap 'round) (join 'round))
(string-append
(ly:format "[ ~4f ~4f ] ~4f setdash\n" on off phase)
((module-ref (resolve-module '(scm output-ps)) 'path #f)
thickness exps cap join)))
#(module-define! (resolve-module '(scm output-ps))
'dashed-path dashed-path-ps)
#(ly:register-stencil-expression 'dashed-path)
#(define-markup-command
(dashed-path layout props thickness commands)
(number? list?)
#:category graphic
#:properties ((line-cap-style 'round)
(line-join-style 'round)
(on 1) (off 1) (phase 0))
(let ((sten (path-markup layout props thickness commands))
(command-list (fold-right append '() commands)))
(ly:make-stencil
`(dashed-path ,thickness ,on ,off ,phase
`(,@',command-list)
',line-cap-style ',line-join-style)
(ly:stencil-extent sten X)
(ly:stencil-extent sten Y))))
samplePath =
#'((moveto 0 0)
(lineto -1 1)
(lineto 1 1)
(lineto 1 -1)
(curveto -5 -5 -5 5 -1 0)
(closepath))
\markup \path #0.25 #samplePath
\markup \dashed-path #0.25 #samplePath
\markup
\override #'(on . 0.2)
\override #'(off . 0.2)
\override #'(line-cap-style . butt)
\dashed-path #0.25 #samplePath
%%%%
-- Aaron Hill
dashed-path.cropped.png
Description: PNG image