From ebf5dd3b3162e37fc88bfae1b6dd7e14d7524fb7 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sat, 15 Jun 2019 00:03:38 +0200 Subject: pict: rectangle: Consider the stroke width when computing dimensions. * pict.scm (rectangle): Use half of the line width as an edge offset. --- pict.scm | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/pict.scm b/pict.scm index 27f8fdd..4e30f6b 100644 --- a/pict.scm +++ b/pict.scm @@ -737,21 +737,22 @@ BORDER-COLOR (a string) and BORDER-WIDTH (a number) are accepted to override the line color and line thickness, respectively. The keys RX and RY can be provided to round off the corners." (make-pict - `(svg (@ (width ,w) - (height ,h) - (x 0) - (y 0)) - (rect (@ (style ,(style-list->string - `(("fill" "none") - ("stroke" ,border-color) - ("stroke-width" - ,(number->string border-width))))) - (x 0) - (y 0) - (width ,w) - (height ,h) - (rx ,rx) - (ry ,ry)))))) + (let ((half-line-width (exact->inexact (/ border-width 2)))) + `(svg (@ (width ,w) + (height ,h) + (x 0) + (y 0)) + (rect (@ (style ,(style-list->string + `(("fill" "none") + ("stroke" ,border-color) + ("stroke-width" + ,(number->string border-width))))) + (x ,half-line-width) + (y ,half-line-width) + (width ,(- w border-width)) + (height ,(- h border-width)) + (rx ,rx) + (ry ,ry))))))) (define* (filled-rectangle w h #:key (color "black") -- cgit v1.2.3