lilypond-user
[Top][All Lists]
Advanced

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

Re: \path in markup dashed line


From: Dimitris Marinakis
Subject: Re: \path in markup dashed line
Date: Thu, 28 Jan 2021 16:57:54 +0200

Thanks it works now! This code is a "game-changer" for dashed stencils. Amazing work again.
I've seen a lot of questions over the years about dashed grid lines, arpeggios etc. Happy to report that they are all possible with this piece of code.
Maybe an LSR snippet demonstrating all the possibilities with this code is a good idea.

On Thu, Jan 28, 2021 at 4:49 PM Aaron Hill <lilypond@hillvisions.com> wrote:
On 2021-01-28 6:39 am, Dimitris Marinakis wrote:
> Both systems report this error
>
> warning: unknown line-cap-style: (quote round)
>
> /Applications/LilyPond23.app/Contents/Resources/share/lilypond/current/scm/output-ps.scm:275:49
> <0>: In procedure symbol->string in _expression_ (symbol->string join):
>
> /Applications/LilyPond23.app/Contents/Resources/share/lilypond/current/scm/output-ps.scm:275:49
> <1>: Wrong type argument in position 1 (expecting symbol): (quote
> round)
>

My apologies.  I made another change in the dashed-path markup command
that mattered.  Here's the complete code for reference:

%%%%
\version "2.22.0"

#(define* (dashed-path-ps thickness on off phase exps
                           #:optional (cap 'round) (join 'round))
   (let* ((path (module-ref (resolve-module '(scm output-ps)) 'path #f))
          (ps (path thickness exps cap join))
          (lines (string-split ps #\nl)))
     (set! lines (cons (car lines)
       (cons (ly:format "[ ~4f ~4f ] ~4f setdash" on off phase)
             (cdr lines))))
     (string-join lines "\n")))

#(let* ((module (resolve-module '(scm output-ps)))
         (alist (module-ref module 'stencil-dispatch-alist '())))
   (module-define! module 'stencil-dispatch-alist
    (acons 'dashed-path dashed-path-ps alist)))

#(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

reply via email to

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