made the image sizing functions always return exact, positive integers

svn: r17476
This commit is contained in:
Robby Findler 2010-01-04 12:36:04 +00:00
parent 5b17c403d4
commit 63c917fd8f
4 changed files with 16 additions and 16 deletions

View File

@ -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 ()

View File

@ -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)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;

View File

@ -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")))

View File

@ -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.