aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Ponce2024-03-30 13:59:41 +0100
committerEli Zaretskii2024-03-30 16:35:11 +0300
commitcc212ea314d45c98761ae7f68600ad8bf799ea36 (patch)
treedb4479c9e02708a62ca6ec786002a806e818a8af /test
parent87be53846bfbf5a6387cb5a40105bd0fc5b48b38 (diff)
downloademacs-cc212ea314d45c98761ae7f68600ad8bf799ea36.tar.gz
emacs-cc212ea314d45c98761ae7f68600ad8bf799ea36.zip
bug#69992: Minor improvement to image map transformation logic
* lisp/image.el (image--compute-rotation): New function. (image--compute-map, image--compute-original-map): Use it. Ensure all transformations are applied or undone according to what Emacs does internally. Call a transformation function only when needed. Fix doc string. (image--scale-map, image--rotate-map): Assume effective scale argument. (image--rotate-coord): Improve doc string. (image--flip-map): Remove no more used argument FLIP. * test/lisp/image-tests.el (image-create-image-with-map): Use a valid SVG image otherwise `image-size' will not return a valid value and calculation of scale could fail. (image-transform-map): Update according to changed signature of `image--flip-map'.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/image-tests.el6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/lisp/image-tests.el b/test/lisp/image-tests.el
index 6a5f03e38a0..020781eff50 100644
--- a/test/lisp/image-tests.el
+++ b/test/lisp/image-tests.el
@@ -158,7 +158,7 @@
158(ert-deftest image-create-image-with-map () 158(ert-deftest image-create-image-with-map ()
159 "Test that `create-image' correctly adds :map and/or :original-map." 159 "Test that `create-image' correctly adds :map and/or :original-map."
160 (skip-unless (display-images-p)) 160 (skip-unless (display-images-p))
161 (let ((data "foo") 161 (let ((data "<svg width=\"30\" height=\"30\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"></svg>")
162 (map '(((circle (1 . 1) . 1) a))) 162 (map '(((circle (1 . 1) . 1) a)))
163 (original-map '(((circle (2 . 2) . 2) a))) 163 (original-map '(((circle (2 . 2) . 2) a)))
164 (original-map-other '(((circle (3 . 3) . 3) a)))) 164 (original-map-other '(((circle (3 . 3) . 3) a))))
@@ -282,7 +282,7 @@ corresponding coordinate in B. When nil, TOLERANCE defaults to 5."
282 '(((circle (12 . 4) . 2) "circle") 282 '(((circle (12 . 4) . 2) "circle")
283 ((rect (7 . 3) 9 . 8) "rect") 283 ((rect (7 . 3) 9 . 8) "rect")
284 ((poly . [4 6 2 7 1 2]) "poly")))) 284 ((poly . [4 6 2 7 1 2]) "poly"))))
285 (should (equal (image--flip-map (copy-tree map t) t `(,width . ,height)) 285 (should (equal (image--flip-map (copy-tree map t) `(,width . ,height))
286 '(((circle (6 . 3) . 2) "circle") 286 '(((circle (6 . 3) . 2) "circle")
287 ((rect (2 . 6) 7 . 8) "rect") 287 ((rect (2 . 6) 7 . 8) "rect")
288 ((poly . [4 11 3 13 8 14]) "poly")))) 288 ((poly . [4 11 3 13 8 14]) "poly"))))
@@ -291,7 +291,7 @@ corresponding coordinate in B. When nil, TOLERANCE defaults to 5."
291 ;; Scale size because the map has been scaled. 291 ;; Scale size because the map has been scaled.
292 (image--rotate-map copy 90 `(,(* 2 width) . ,(* 2 height))) 292 (image--rotate-map copy 90 `(,(* 2 width) . ,(* 2 height)))
293 ;; Swap width and height because the map has been flipped. 293 ;; Swap width and height because the map has been flipped.
294 (image--flip-map copy t `(,(* 2 height) . ,(* 2 width))) 294 (image--flip-map copy `(,(* 2 height) . ,(* 2 width)))
295 (should (equal copy 295 (should (equal copy
296 '(((circle (6 . 8) . 4) "circle") 296 '(((circle (6 . 8) . 4) "circle")
297 ((rect (12 . 6) 16 . 16) "rect") 297 ((rect (12 . 6) 16 . 16) "rect")