Am Mo., 23. Sept. 2019 um 18:04 Uhr schrieb Michael Käppler <address@hidden>:
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
If I understand correctly:
If you place a bunch of stencils on a page, then lilyponds
spacing-engine will drop in and white space may be disregarded. See:
\paper { markup-markup-spacing.padding = 5 }
\markup \hlineone
\markup \hlinetwo
\markup \vlineone
\markup \vlinetwo
And compare with:
\markup {
\hlineone
\hlinetwo
\vlineone
\vlinetwo
}
With the latter you can observe all the different settings (relative
to the previous stencil)
For your final goal, checkout the table-markup-list-command.
No lines implemented there, but probably a starting point.
Cheers,
Harm