lilypond-user
[Top][All Lists]
Advanced

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

Translating stencils


From: Michael Käppler
Subject: Translating stencils
Date: Mon, 23 Sep 2019 18:00:32 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

Hi all,
I'm trying to understand the way one can translate / stack stencils in
LilyPond.
Consider the following code:

#(define-markup-command (draw-line-mod layout props startpos endpos)
   (number-pair? number-pair?)
   #:properties ((thickness 1))

  (let ((th (* (ly:output-def-lookup layout 'line-thickness)
               thickness))
        (startx (car startpos))
        (starty (cdr startpos))
        (endx (car endpos))
        (endy (cdr endpos)))
    (make-line-stencil th startx starty endx endy)))

#(define hlineone (markup #:draw-line-mod '(0 . 0) '(10 . 0)))
#(define hlinetwo (markup #:draw-line-mod '(0 . 10) '(10 . 10)))

#(define vlineone (markup #:draw-line-mod '(0 . 0) '(0 . 10)))
#(define vlinetwo (markup #:draw-line-mod '(10 . 0) '(10 . 10)))

\markup \hlineone
% \markup \hlinetwo
% \markup \vlineone
% \markup \vlinetwo

The ordinary draw-line markup function calls (make-line-stencil) with
startx/starty 0 0.
So I wrote the custom draw-line-mod function to figure out what happens
when I set the startx / starty to different values.
What I understand is that these values do not specify "absolute
coordinates" somewhere on the paper, but are somehow relative
to each other. But how exactly?

\markup \hlinetwo gives a line positioned exactly like \hlineone, though
the stencil has different starty.
\markup \vlinetwo, however,  gives a line starting at a different
vertical position than \vlineone.

Eventually I want to draw a kind of grid with horizontal and vertical
lines, placing little "scores" in them.
Attached is an example of what I want to achieve. But I do not want a
quick solution, instead I would be glad to understand
the stencil positioning better than now.

Kind regards,
Michael

Attachment: Scores_grid.jpg
Description: JPEG image


reply via email to

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