[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
drawing lines (new markups with parameters)
From: |
Germain G. Ivanoff-Trinadtzaty |
Subject: |
drawing lines (new markups with parameters) |
Date: |
Mon, 14 Jun 2010 21:00:07 +0200 |
Dear all,
please help me with these markups.
Thanks,
Germain
\version 2.12.3
----------------
1) Creating a new markup with two (number-pair?) parameters.
- calling :
{ a4-\myline #'(x . y) #'(dx . dy) }
- should produce the same result as :
{ a4-\markup {\postscript #"[0.2 0.4] 0 setdash x y moveto dx dy rline
stroke"} }
where x, y, dx and dy are numbers.
Tip : reading the file "output-ps.scm" could be of interest (I'm not sure).
Here I have another question : what is the starting point ? (ie, from where
do we "moveto" (x y) ?
That starting point seems not to change with respect to :
\override TextScript #'self-alignment-X = #CENTER %or #RIGHT or #LEFT
while {a4-"azerty"} does.
----------------
2) Creating another new markup with two (number-pair?) parameters.
- calling :
{a4-\mydraw-line #'(x . y) #'(dx . dy) } % maybe the name cannot contain
a "-"
- should produce the same result as :
{ a4-\draw-line #'(dx . dy) } but starting from #'(x . y) instead of #'(0 .
0)
dx and dy should be offsets from x and y.
For this second function, there is a (inconvenient) work-around :
{
\override TextScript #'extra-offset = #'(x . y)
a4-\markup \with-dimensions #'(0 . 0) #'(0 . 0) {
%\override #'(style . dashed-line) % doesn't work
%\override #'(thickness . 2) % ok
%\override #'(X-offset . 2) % doesn't work
\draw-line #'(dx . dy) }
}
Tip : this is the definition of built-in "draw-line", from
"define-markup-commands.scm" :
(define-builtin-markup-command (draw-line layout props dest)
(number-pair?)
graphic
((thickness 1))
"drawing lines within text /.../"
(let ((th (* (ly:output-def-lookup layout 'line-thickness)
thickness))
(x (car dest))
(y (cdr dest)))
(make-line-stencil th 0 0 x y)))
So I wrote this in my .ly file :
#(define-markup-command (zdraw layout props from dest)
(number-pair? number-pair?)
graphic
;((thickness 1)) ;; because Lilypond complains about "unbounded
variable thickness"
"drawing lines within text /.../"
(let ((th (* (ly:output-def-lookup layout 'line-thickness)
1)) ;; was "thickness"
(x (car from))
(y (cdr from))
(dx (car dest))
(dy (cdr dest)))
(make-line-stencil th x y (+ x dx) (+ y dy))))
But it works as expected only with this calling :
{a4-\markup \with-dimensions #'(0 . 0) #'(0 . 0) { \zdraw #'(5 . 0) #'(10 .
5) }
How to get rid of this "with-dimensions" ?
Is there a way to specify that the line should be dashed ?
Besides this, typing :
{a4-\markup \with-dimensions #'(0 . 0) #'(0 . 0) { \override #'(thickness .
3) \zdraw #'(5 . 0) #'(10 . 5) }
has no effect on the thickness of the line.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- drawing lines (new markups with parameters),
Germain G. Ivanoff-Trinadtzaty <=