From 7196bb0e2e96f10b66575ed6bb036a2c01d90bcd Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Mon, 18 Aug 2008 01:45:17 +0200 Subject: [PATCH 1/1] Add a make-line-stencil function, which correctly sets stencil extents So far, one had to create line stencils manually using (ly:make-stencil (list 'draw-line ...) xext yext) Unfortunately that meant that one had to specify the x- and y- coordinates twice. This new make-line-stencil function takes the coordinates once, creates the stencil and properly sets its extent (adding half the line width to all coordinates of the x- and y-intervals). --- scm/stencil.scm | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/scm/stencil.scm b/scm/stencil.scm index 6a4b88d..311c1d8 100644 --- a/scm/stencil.scm +++ b/scm/stencil.scm @@ -70,6 +70,17 @@ (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." -- 1.5.4.3