From 63c917fd8fefd1c8f381c1467fe751e3a64949df Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Mon, 4 Jan 2010 12:36:04 +0000 Subject: [PATCH] made the image sizing functions always return exact, positive integers svn: r17476 --- collects/2htdp/private/image-more.ss | 4 ++-- collects/2htdp/tests/test-image.ss | 18 +++++++++--------- .../teachpack/2htdp/scribblings/image-toc.ss | 4 ++-- .../teachpack/2htdp/scribblings/image.scrbl | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/collects/2htdp/private/image-more.ss b/collects/2htdp/private/image-more.ss index 70cebcd30e..16ed89f7d7 100644 --- a/collects/2htdp/private/image-more.ss +++ b/collects/2htdp/private/image-more.ss @@ -756,8 +756,8 @@ ;; see pin-line in slideshow ;; the initial strings in the second instance of add-curve are like the strings in add-line -(define/chk (image-width image) (image-right image)) -(define/chk (image-height image) (image-bottom image)) +(define/chk (image-width image) (inexact->exact (ceiling (image-right image)))) +(define/chk (image-height image) (inexact->exact (ceiling (image-bottom image)))) (define-syntax (bitmap stx) (syntax-case stx () diff --git a/collects/2htdp/tests/test-image.ss b/collects/2htdp/tests/test-image.ss index 513e7f0bae..83cc4da712 100644 --- a/collects/2htdp/tests/test-image.ss +++ b/collects/2htdp/tests/test-image.ss @@ -148,27 +148,27 @@ 0) (check-close (image-width (rotate 45 (rectangle 100 0 'solid 'blue))) - (* (sin (* pi 1/4)) 100)) + (inexact->exact (ceiling (* (sin (* pi 1/4)) 100)))) (check-close (image-height (rotate 45 (rectangle 100 0 'solid 'blue))) - (* (sin (* pi 1/4)) 100)) + (inexact->exact (ceiling (* (sin (* pi 1/4)) 100)))) (check-close (image-width (rotate 45 (rectangle 0 100 'solid 'blue))) - (* (sin (* pi 1/4)) 100)) + (inexact->exact (ceiling (* (sin (* pi 1/4)) 100)))) (check-close (image-height (rotate 45 (rectangle 0 100 'solid 'blue))) - (* (sin (* pi 1/4)) 100)) + (inexact->exact (ceiling (* (sin (* pi 1/4)) 100)))) (test (image-width (scale 4 (rectangle 10 10 'outline 'black))) => 40) (test (image-width (rotate 90 (scale 4 (rectangle 10 10 'outline 'black)))) => - 40.0) + 40) (test (image-width (scale 4 (rectangle 10 10 'solid 'black))) => 40) (test (image-width (rotate 90 (scale 4 (rectangle 10 10 'solid 'black)))) => - 40.0) + 40) (test (image-width (ellipse 10 20 'solid 'blue)) @@ -192,14 +192,14 @@ (test (image-width (rotate 30 (ellipse 100 0 'solid 'blue))) => - (* (cos (* pi 1/6)) 100)) + (inexact->exact (ceiling (* (cos (* pi 1/6)) 100)))) (test (image-height (rotate 30 (ellipse 100 0 'solid 'blue))) => - (* (sin (* pi 1/6)) 100)) + (inexact->exact (ceiling (* (sin (* pi 1/6)) 100)))) (check-close (image-width (rotate 30 (ellipse 0 100 'solid 'blue))) (* (sin (* pi 1/6)) 100)) (check-close (image-height (rotate 30 (ellipse 0 100 'solid 'blue))) - (* (cos (* pi 1/6)) 100)) + (ceiling (* (cos (* pi 1/6)) 100))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; diff --git a/collects/teachpack/2htdp/scribblings/image-toc.ss b/collects/teachpack/2htdp/scribblings/image-toc.ss index b3bd0c0cda..b70120fdcf 100644 --- a/collects/teachpack/2htdp/scribblings/image-toc.ss +++ b/collects/teachpack/2htdp/scribblings/image-toc.ss @@ -8,8 +8,8 @@ (list (list '(image-height (rectangle 100 100 "solid" "black")) 'val 100) (list '(image-baseline (rectangle 100 100 "solid" "black")) 'val 100) - (list '(image-height (text "Hello" 24 "black")) 'val 24.0) - (list '(image-baseline (text "Hello" 24 "black")) 'val 18.0) + (list '(image-height (text "Hello" 24 "black")) 'val 24) + (list '(image-baseline (text "Hello" 24 "black")) 'val 18) (list '(image-height (overlay (circle 20 "solid" "orange") (circle 30 "solid" "purple"))) diff --git a/collects/teachpack/2htdp/scribblings/image.scrbl b/collects/teachpack/2htdp/scribblings/image.scrbl index 3e4a15ef98..594110a38a 100644 --- a/collects/teachpack/2htdp/scribblings/image.scrbl +++ b/collects/teachpack/2htdp/scribblings/image.scrbl @@ -527,7 +527,7 @@ other. The top and bottom pair of angles is @scheme[angle] and the left and righ @section{Image Properties} -@defproc[(image-width [i image?]) (and/c number? positive?)]{ +@defproc[(image-width [i image?]) (and/c integer? positive? exact?)]{ Returns the width of @scheme[i]. @image-examples[(image-width (ellipse 30 40 "solid" "orange")) @@ -536,7 +536,7 @@ other. The top and bottom pair of angles is @scheme[angle] and the left and righ (circle 20 "solid" "purple")))] } -@defproc[(image-height [i image?]) (and/c number? positive?)]{ +@defproc[(image-height [i image?]) (and/c integer? positive? exact?)]{ Returns the height of @scheme[i]. @image-examples[(image-height (ellipse 30 40 "solid" "orange")) @@ -545,7 +545,7 @@ other. The top and bottom pair of angles is @scheme[angle] and the left and righ (circle 30 "solid" "purple")))] } -@defproc[(image-baseline [i image?]) (and/c number? positive?)]{ +@defproc[(image-baseline [i image?]) (and/c integer? positive? exact?)]{ Returns the distance from the top of the image to its baseline. Unless the image was constructed with @scheme[text] or @scheme[text/font], this will be the same as its height.