diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2019-06-15 00:03:38 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2019-06-15 00:03:38 +0200 |
commit | ebf5dd3b3162e37fc88bfae1b6dd7e14d7524fb7 (patch) | |
tree | fb858facca131848bd8918fb7a64f69461736c45 | |
parent | 1b41471534b65d118afffb25106eaef75f537ef0 (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.scm | 31 |
1 files changed, 16 insertions, 15 deletions
@@ -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") |