summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2019-06-15 00:03:38 +0200
committerRicardo Wurmus <rekado@elephly.net>2019-06-15 00:03:38 +0200
commitebf5dd3b3162e37fc88bfae1b6dd7e14d7524fb7 (patch)
treefb858facca131848bd8918fb7a64f69461736c45
parent1b41471534b65d118afffb25106eaef75f537ef0 (diff)
pict: rectangle: Consider the stroke width when computing dimensions.
* pict.scm (rectangle): Use half of the line width as an edge offset.
-rw-r--r--pict.scm31
1 files 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")