summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2019-06-15 00:00:52 +0200
committerRicardo Wurmus <rekado@elephly.net>2019-06-15 00:00:52 +0200
commit14f245ca321cb97fc93944dd0f795a72ddb0d35f (patch)
treefc140aedd0ff74e88a3f5a2c56a7a86500b768df
parent2bd2fd9dd827285e8aee96ac887961cc00287e5b (diff)
pict: octagon: Consider the border-width in the total dimensions.
* pict.scm (octagon): Do not cut off the edges by considering the line width when computing the outer dimensions; add docstring.
-rw-r--r--pict.scm24
1 files changed, 15 insertions, 9 deletions
diff --git a/pict.scm b/pict.scm
index 1d4777e..e1a6f82 100644
--- a/pict.scm
+++ b/pict.scm
@@ -649,15 +649,21 @@ override the line color and line thickness."
#:key
(border-color "black")
(border-width 1))
- (let ((third (exact->inexact (/ size 3))))
- (polygon `((0 . ,(* 2 third))
- (0 . ,third)
- (,third . 0)
- (,(* 2 third) . 0)
- (,size . ,third)
- (,size . ,(* 2 third))
- (,(* 2 third) . ,size)
- (,third . ,size))
+ "Return an octagon (more accurately a p8 symmetric isogonal octagon)
+with a maximum width of SIZE. The keys BORDER-COLOR (a string) and
+BORDER-WIDTH (a number) are accepted to override the default line
+color and line thickness."
+ (let* ((half-line-width (exact->inexact (/ border-width 2)))
+ (size* (- size half-line-width))
+ (third (exact->inexact (/ size 3))))
+ (polygon `((,half-line-width . ,(* 2 third))
+ (,half-line-width . ,third)
+ (,third . ,half-line-width)
+ (,(* 2 third) . ,half-line-width)
+ (,size* . ,third)
+ (,size* . ,(* 2 third))
+ (,(* 2 third) . ,size*)
+ (,third . ,size*))
#:border-color border-color
#:border-width border-width)))