From 1b41471534b65d118afffb25106eaef75f537ef0 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sat, 15 Jun 2019 00:02:37 +0200 Subject: pict: ellipse: Consider the stroke width when computing dimensions. * pict.scm (ellipse): Offset drawing by half the stroke width. --- pict.scm | 28 +++++++++++++++------------- 1 file 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))) -- cgit v1.2.3