425689e66be8

Fix non-square circle transformations
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 09 Jun 2019 12:45:59 -0400
parents 4b63cff9f912
children 09e906903662
branches/tags (none)
files src/drawing/api.lisp

Changes

--- a/src/drawing/api.lisp	Sun Jun 09 12:16:43 2019 -0400
+++ b/src/drawing/api.lisp	Sun Jun 09 12:45:59 2019 -0400
@@ -178,7 +178,15 @@
 
 (defmethod ntransform ((circle circle) transformation)
   (ntransform (center circle) transformation)
-  (zapf (radius circle) (ntransform % transformation))
+  ;; For non-aspect-ratio-preserving transformations, we want to keep circles
+  ;; as circles, but ensure they fit within the new bounding box.  So we take
+  ;; the smaller of the two possible radius transformations.
+  (let ((a (vec 0 0 1))
+        (b (vec 1 1 1)))
+    (ntransform a transformation)
+    (ntransform b transformation)
+    (let ((c (v- a b)))
+      (mulf (radius circle) (min (abs (vx c)) (abs (vy c))))))
   circle)