[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Stencil questions (adding text and defining line style)
From: |
Thomas Morley |
Subject: |
Re: Stencil questions (adding text and defining line style) |
Date: |
Thu, 22 Sep 2016 00:02:09 +0200 |
Hi Urs,
2016-09-21 23:47 GMT+02:00 David Nalesnik <address@hidden>:
>> The other thing I didn't find is: how can I create a dashed (or
>> otherwise styled) line stencil with make-line-stencil?
I was going to write:
If you regard the basics you'll see something like the following example:
\markup
\box {
\stencil
#(ly:make-stencil
(list
'dashed-line
0.2 ; width
0.5 ;; on
0.5 ; off
10 ;; x-end
10 ;; y-end
0 ;; phase
)
;; x-ext
(cons 0 10)
;; y-ext
(cons 0 10))
\stencil
#(ly:make-stencil
(list
'draw-line
0.2 ; width
0 ; startx
0 ; starty
10 ; endx
10 ;endy
)
'(0 . 10)
'(0 . 10))
}
So there's no direct method to switch between both, because of the
kind and amount of arguments differ.
But you can use some "meta"-functions like:
(and now follow David' reply)
>
> You should use ly:line-interface::line (which is available from
> 2.19.27, off the top of my head).
>
> Here's an example with both text and different line styles.
>
> (Even though TextScript doesn't support line-interface, you can still
> tweak line-related properties!)
>
> \version "2.19.46"
>
> #(define (my-stencil grob)
> (let* ((line (ly:line-interface::line grob 1.5 0 6 0))
> (text (grob-interpret-markup grob "A"))
> (stil (apply ly:stencil-add (list line text))))
> stil))
>
> {
> \override TextScript.stencil = #my-stencil
> c''1 -\tweak style #'dashed-line ^""
> c''1 -\tweak style #'zigzag ^""
> }
>
>>
>> More generally: how can I learn more about these things? Searching
>> lilypond.org seems to only point to snippets and no real explanations.
>
> There's not much to go on.
>
> grob-interpret-markup is mentioned here:
> http://lilypond.org/doc/v2.19/Documentation/extending/callback-functions
>
> The function doesn't have a docstring:
>
> #(display (procedure-documentation grob-interpret-markup))
>
> returns #f ...
>
> ly:line-interface::line is listed in the IR (Scheme functions)
>
> Sorry I can't be more helpful.
>
> David
Cheers,
Harm