From a3370be15d7c467010091946a085216c50af54b6 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Wed, 18 Jun 2014 01:20:05 -0500 Subject: [PATCH] fix bitmap rotate/flip interaction closes PR 14585 --- .../htdp-lib/2htdp/private/image-more.rkt | 14 +++++++++----- .../htdp-pkgs/htdp-test/2htdp/tests/test-image.rkt | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pkgs/htdp-pkgs/htdp-lib/2htdp/private/image-more.rkt b/pkgs/htdp-pkgs/htdp-lib/2htdp/private/image-more.rkt index 7937f5f1c4..3440192cd4 100644 --- a/pkgs/htdp-pkgs/htdp-lib/2htdp/private/image-more.rkt +++ b/pkgs/htdp-pkgs/htdp-lib/2htdp/private/image-more.rkt @@ -775,10 +775,9 @@ [flipped? (flip-flipped? atomic-shape)]) (make-flip flipped? (make-ibitmap (ibitmap-raw-bitmap bitmap) - (bring-between (if flipped? - (- (ibitmap-angle bitmap) θ) - (+ (ibitmap-angle bitmap) θ)) - 360) + (bring-between + (+ (ibitmap-angle bitmap) θ) + 360) (ibitmap-x-scale bitmap) (ibitmap-y-scale bitmap) (make-hash))))])) @@ -911,8 +910,13 @@ [(text? atomic-shape) (error 'flip "cannot flip shapes that contain text")] [(flip? atomic-shape) + (define bitmap (flip-shape atomic-shape)) (make-flip (not (flip-flipped? atomic-shape)) - (flip-shape atomic-shape))])) + (make-ibitmap (ibitmap-raw-bitmap bitmap) + (bring-between (- (ibitmap-angle bitmap)) 360) + (ibitmap-x-scale bitmap) + (ibitmap-y-scale bitmap) + (make-hash)))])) (define (flip-point point) (make-point (point-x point) (- (point-y point)))) (define (flip-points points) (map flip-point points)) diff --git a/pkgs/htdp-pkgs/htdp-test/2htdp/tests/test-image.rkt b/pkgs/htdp-pkgs/htdp-test/2htdp/tests/test-image.rkt index 56ac9cbf64..43ec6a60be 100644 --- a/pkgs/htdp-pkgs/htdp-test/2htdp/tests/test-image.rkt +++ b/pkgs/htdp-pkgs/htdp-test/2htdp/tests/test-image.rkt @@ -1603,6 +1603,11 @@ => (to-img (make-object image-snip% green-blue-20x10-bitmap))) +(let ([b (freeze (beside (rectangle 4 8 "solid" "blue") (rectangle 4 8 "solid" "red")))]) + (test (flip-vertical (rotate 90 b)) + => + (rotate -90 b))) + ;; make sure that raw image snips are equal to image snips (let ([i1 (make-object image-snip% (collection-file-path "bug09.png" "icons"))] [i2 (make-object image-snip% (collection-file-path "bug09.png" "icons"))])