lilypond-user
[Top][All Lists]
Advanced

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

Re: Line cap style in scheme


From: Thomas Morley
Subject: Re: Line cap style in scheme
Date: Fri, 21 Oct 2016 10:54:59 +0200

2016-10-21 2:31 GMT+02:00 Andrew Bernard <address@hidden>:
> So, in partial answer to my own question, we can achieve control over line
> cap style using a markup context, and the following code works fine:
>
>
>
>           (if is-rest?
>
>               empty-stencil
>
>               (ly:stencil-add
>
>                stil
>
>                (grob-interpret-markup grob
>
>                  (markup
>
>                   #:override (cons (quote line-cap-style) (quote square))
>
>                   (#:path
>
>                    0.2
>
>                    (list (list (quote moveto) start-x start-y)
>
>                      (list (quote lineto) end-x end-y)))))))
>
>
>
> However, I am still interested in the answer to my original question, if
> that is possible at all?
>
>
>
> Andrew
>
>
>
>
>
>
>
> From: Andrew Bernard [mailto:address@hidden
> Sent: Friday, 21 October 2016 11:05 AM
> To: address@hidden
> Subject: Line cap style in scheme
>
>
>
> I’m writing a function to make horizontal slashes through note stems.
>
>
>
> The function make-line-stencil uses round end caps, but I prefer square or
> butt style. I have asked this question before on the list, but the pointers
> to possible answers referred to code for making markups, which is good,
> whereas I want to set the end cap style for a path stencil.
>
>
>
> Here’s a fragment of the code in question (not meant to be a MWE, just to
> give the programming context):
>
>
>
>           (if is-rest?
>
>               empty-stencil
>
>               (ly:stencil-add
>
>                stil
>
>                (make-path-stencil
>
>                 (list
>
>                  'moveto start-x start-y
>
>                  'lineto end-x end-y)
>
>                 thickness 1 1 #t)
>
>                ))
>
>
>
> Is it possible to inject calls here to set the postscript line cap style?
>
>
>
> Andrew


Hi Andrew,

in make-path-stencil line-cap-style and line-join-style are hard-coded
to 'round. So you can't set them yourself.

Possible solutions:
(1) Define a custom make-path-stencil with optional line-cap-style and
line-join-style.
(2) Create a stencil-expression with the underlying list-syntax, then
make a ready-to-use stencil from this
(3) Use ly:round-filled-box

As long as you need only horizontal or vertical lines I'd go for (3).
The third argument of ly:round-filled-box is the blot-diameter.
Setting it zero, mimics line-cap-style 'butt.

Example:

%% path-markup
\markup {
  \override #'(line-cap-style . butt)
  \path #2 #'((moveto 0 0) (lineto 10 0))
}

%% ly:round-filled-box
\markup
  \stencil
  #(ly:round-filled-box '(0 . 10) '(0 . 2) 0)

In case this is not sufficient we could discuss how to do (1) and/or (2) ...

So far, cheers,
  Harm



reply via email to

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