summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2019-06-15 00:02:37 +0200
committerRicardo Wurmus <rekado@elephly.net>2019-06-15 00:02:37 +0200
commit1b41471534b65d118afffb25106eaef75f537ef0 (patch)
tree3aa5e8369b5191cc94bba5cd02428f0e09b5eea3
parent14f245ca321cb97fc93944dd0f795a72ddb0d35f (diff)
pict: ellipse: Consider the stroke width when computing dimensions.
* pict.scm (ellipse): Offset drawing by half the stroke width.
-rw-r--r--pict.scm28
1 files changed, 15 insertions, 13 deletions
diff --git a/pict.scm b/pict.scm
index e1a6f82..27f8fdd 100644
--- a/pict.scm
+++ b/pict.scm
@@ -707,19 +707,21 @@ the given COLOR."
BORDER-COLOR (a string) and BORDER-WIDTH (a number) are accepted to
override the line color and line thickness."
(make-pict
- `(svg (@ (width ,w)
- (height ,h)
- (x 0)
- (y 0))
- (ellipse (@ (style ,(style-list->string
- `(("fill" "none")
- ("stroke" ,border-color)
- ("stroke-width"
- ,(number->string border-width)))))
- (cx ,(/ w 2))
- (cy ,(/ h 2))
- (rx ,(/ w 2))
- (ry ,(/ h 2)))))))
+ (let ((w* (- w border-width))
+ (h* (- h border-width)))
+ `(svg (@ (width ,w)
+ (height ,h)
+ (x 0)
+ (y 0))
+ (ellipse (@ (style ,(style-list->string
+ `(("fill" "none")
+ ("stroke" ,border-color)
+ ("stroke-width"
+ ,(number->string border-width)))))
+ (cx ,(exact->inexact (+ (/ w* 2) (/ border-width 2))))
+ (cy ,(exact->inexact (+ (/ h* 2) (/ border-width 2))))
+ (rx ,(exact->inexact (/ w* 2)))
+ (ry ,(exact->inexact (/ h* 2)))))))))
(define* (filled-ellipse w h #:key (color "black"))
(remove-outline (fill (ellipse w h) color)))