diff --git a/collects/2htdp/private/picture.ss b/collects/2htdp/private/picture.ss index 8f75bfd853..fa34499fdf 100644 --- a/collects/2htdp/private/picture.ss +++ b/collects/2htdp/private/picture.ss @@ -203,8 +203,8 @@ and they all have good sample contracts. (It is amazing what we can do with kids (+ dy (posn-y posn)) θ)]) (set! left (min new-x left)) - (set! right (max new-x right)) (set! top (min new-y top)) + (set! right (max new-x right)) (set! bottom (max new-y bottom)))) (cdr points)) (values left top right bottom))))] @@ -398,8 +398,8 @@ and they all have good sample contracts. (It is amazing what we can do with kids (λ (f) (send sl set-value (max min-scale (min max-scale (f (send sl get-value))))) (send c refresh))]) - (new button% [label "√"] [callback (λ x (scale-adjust sub1))] [parent bp]) - (new button% [label "²"] [callback (λ x (scale-adjust add1))] [parent bp]) + (send (new button% [label "√"] [callback (λ x (scale-adjust sub1))] [parent bp]) min-width 100) + (send (new button% [label "²"] [callback (λ x (scale-adjust add1))] [parent bp]) min-width 100) (send f show #t))) ;; render-picture : normalized-shape dc dx dy -> void @@ -603,6 +603,9 @@ and they all have good sample contracts. (It is amazing what we can do with kids ;; rotate/places : string string I number -> I ;; rotates the I around the given point inside the I, using ;; the strings like overlay does. + +;; this function is bogus! It doesn't matter where you rotate it around. it still looks the same! + (define/chk (rotate/places x-place y-place angle picture) (rotate/internal x-place y-place angle picture)) @@ -618,7 +621,7 @@ and they all have good sample contracts. (It is amazing what we can do with kids (set! top (if top (min this-top top) this-top)) (set! right (if right (max this-right right) this-right)) (set! bottom (if bottom (max this-bottom bottom) this-bottom)))) - (let ([rotated (normalize-shape (make-rotate angle (picture-shape picture)) add-to-bounding-box)]) + (let* ([rotated (normalize-shape (make-rotate angle (picture-shape picture)) add-to-bounding-box)]) (make-picture (make-translate (- left) (- top) rotated) (make-bb (- right left) (- bottom top) (- bottom top)) #f))) @@ -690,3 +693,20 @@ and they all have good sample contracts. (It is amazing what we can do with kids ;; see pin-line in slideshow ;; the initial strings in the second instance of add-curve are like the strings in add-line +(let* ([first (rectangle 100 10 'solid 'red)] + [second + (overlay/places 'center + 'center + first + (rotate/places 'center 'center + (* pi 1/4) + first))] + [third + (overlay/places 'center + 'center + (frame second) + (rotate/places 'center 'center + (* pi 1/8) + (frame second)))]) + (show-picture (frame (rotate (* pi 1/8) + (rotate (* pi 1/8) first))))) diff --git a/collects/2htdp/private/test-picture.ss b/collects/2htdp/private/test-picture.ss index 4ba600748d..c331ed850e 100644 --- a/collects/2htdp/private/test-picture.ss +++ b/collects/2htdp/private/test-picture.ss @@ -18,7 +18,8 @@ (rotate/places 'center 'center (* pi 1/8) (frame second)))]) - (show-picture (frame third))) + (show-picture second + #;(frame third))) (define (round-numbers x) (let loop ([x x]) @@ -290,3 +291,76 @@ void)) => (round-numbers (make-translate 50 -100 (make-rotate (* pi 1/2) (picture-shape (rectangle 50 100 'solid 'blue)))))) + + +(test (round-numbers + (normalize-shape + (make-rotate + (* pi 1/4) + (make-translate + 100 100 + (picture-shape (rectangle 100 10 'solid 'red)))) + void)) + => + (round-numbers + (make-translate + (* 100 (sqrt 2)) + 0.0 + (make-rotate + (* pi 1/4) + (picture-shape (rectangle 100 10 'solid 'red)))))) + +(test (round-numbers + (normalize-shape + (make-rotate + (* pi 1/4) + (make-translate + 100 100 + (make-rotate + (* pi 1/4) + (make-translate + 100 100 + (picture-shape (rectangle 100 10 'solid 'red)))))) + void)) + => + (round-numbers + (make-translate + 200 + 0 + (make-rotate + (* pi 1/2) + (picture-shape (rectangle 100 10 'solid 'red)))))) + +(test (round-numbers + (normalize-shape + (make-rotate + (* pi 1/4) + (make-translate + 100 100 + (make-rotate + (* pi 1/4) + (make-translate + 100 100 + (picture-shape (rectangle 100 10 'solid 'red)))))) + void)) + => + (round-numbers + (make-translate + (* (sqrt 2) 100 2) + 0 + (make-rotate + (* pi 1/2) + (picture-shape (rectangle 100 10 'solid 'red)))))) + +(test (round-numbers + (normalize-shape + (picture-shape + (rotate (* pi 1/8) (rotate (* pi 1/8) (rectangle 100 10 'solid 'red)))) + void)) + => + (round-numbers + (normalize-shape + (picture-shape + (rotate (* pi 1/4) (rectangle 100 10 'solid 'red))) + void))) +