thickness))
(x (car dest))
(y (cdr dest)))
- (ly:make-stencil
- `(draw-line
- ,th
- 0 0
- ,x ,y)
- (cons (min x 0) (max x 0))
- (cons (min y 0) (max y 0)))))
+ (make-line-stencil th 0 0 x y)))
(define-builtin-markup-command (draw-circle layout props radius thickness fill)
(number? number? boolean?)
(x1 (car (ly:stencil-extent markup X)))
(x2 (cdr (ly:stencil-extent markup X)))
(y (* thick -2))
- (line (ly:make-stencil
- `(draw-line ,thick ,x1 ,y ,x2 ,y)
- (cons (min x1 0) (max x2 0))
- (cons thick thick))))
+ (line (make-line-stencil thick x1 y x2 y)))
(ly:stencil-add markup line)))
(define-builtin-markup-command (box layout props arg)
(num-y (interval-widen (cons center center) (abs dy)))
(is-sane (and (interval-sane? num-x) (interval-sane? num-y)))
(slash-stencil (if is-sane
- (ly:make-stencil
- `(draw-line ,thickness
- ,(car num-x) ,(- (interval-center num-y) dy)
- ,(cdr num-x) ,(+ (interval-center num-y) dy))
- num-x num-y)
+ (make-line-stencil thickness
+ (car num-x) (- (interval-center num-y) dy)
+ (cdr num-x) (+ (interval-center num-y) dy))
#f)))
(if (ly:stencil? slash-stencil)
(begin
(let* ((fret-count (+ (- (cadr fret-range) (car fret-range)) 1))
(sl (* (+ fret-count 1) size))
(sth (* size th))
- (half-thickness (* sth 0.5))
(gap (- size sth))
(string-stencil
(if (eq? orientation 'normal)
- (ly:make-stencil
- (list 'draw-line sth 0 0 0 sl)
- (cons (- half-thickness) half-thickness)
- (cons (- half-thickness) (+ sl half-thickness)))
- (ly:make-stencil
- (list 'draw-line sth 0 0 sl 0)
- (cons (- half-thickness) (+ sl half-thickness))
- (cons (- half-thickness) half-thickness)))))
+ (make-line-stencil sth 0 0 0 sl)
+ (make-line-stencil sth 0 0 sl 0))))
(if (= string-count 1)
string-stencil
(if (eq? orientation 'normal)
(sth (* size th))
(half-thickness (* sth 0.5)))
(if (eq? orientation 'normal)
- (ly:make-stencil
- (list 'draw-line sth half-thickness size
+ (make-line-stencil sth half-thickness size
(- fret-length half-thickness) size)
- (cons 0 fret-length)
- (cons (- half-thickness) half-thickness))
- (ly:make-stencil
- (list 'draw-line sth 0 half-thickness
- 0 (- fret-length half-thickness))
- (cons (- half-thickness) half-thickness)
- (cons 0 fret-length)))))
+ (make-line-stencil sth 0 half-thickness
+ 0 (- fret-length half-thickness)))))
(define (draw-thick-zero-fret details string-count th size orientation)
"Draw a thick zeroth fret for a fret diagram whose base fret is not 1."
(barre-stencil
(if (eq? barre-type 'straight)
(if (eq? orientation 'normal)
- (ly:make-stencil
- (list
- 'draw-line (* size dot-radius) left dot-center-y
- right dot-center-y)
- (cons left right)
- (cons (- dot-center-y scale-dot-radius)
- (+ dot-center-y scale-dot-radius)))
- (ly:make-stencil
- (list 'draw-line (* size dot-radius)
+ (make-line-stencil scale-dot-radius left dot-center-y
+ right dot-center-y)
+ (make-line-stencil scale-dot-radius
(* size barre-fret-coordinate)
(* size barre-start-string-coordinate)
(* size barre-fret-coordinate)
- (* size barre-end-string-coordinate))
- (cons (- (* size barre-fret-coordinate)
- scale-dot-radius)
- (+ (* size barre-fret-coordinate)
- scale-dot-radius))
- (cons (* size barre-start-string-coordinate)
- (* size barre-end-string-coordinate))))
+ (* size barre-end-string-coordinate)))
(if (eq? orientation 'normal)
(ly:make-stencil
(list 'bezier-sandwich
(ly:stencil-combine-at-edge stil (other-axis axis) -1 rb padding))
stil))
+(define-public (make-line-stencil width startx starty endx endy)
+ "Make a line stencil of given linewidth and set its extents accordingly"
+ (let ((xext (cons (min startx endx) (max startx endx)))
+ (yext (cons (min starty endy) (max starty endy))))
+ (ly:make-stencil
+ (list 'draw-line width startx starty endx endy)
+ ; Since the line has rounded edges, we have to / can safely add half the
+ ; width to all coordinates!
+ (interval-widen xext (/ width 2))
+ (interval-widen yext (/ width 2)))))
+
(define-public (make-filled-box-stencil xext yext)
"Make a filled box."