added image-baseline
svn: r16745
This commit is contained in:
parent
61e5c3e41e
commit
71233bad43
|
@ -90,4 +90,5 @@ and they all have good sample contracts. (It is amazing what we can do with kids
|
|||
side-count?
|
||||
|
||||
image-width
|
||||
image-height)
|
||||
image-height
|
||||
image-baseline)
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
|
||||
(define mapping
|
||||
(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
|
||||
(overlay (circle 20 "solid" "orange") (circle 30 "solid" "purple")))
|
||||
|
|
|
@ -36,11 +36,11 @@
|
|||
(schemeblock #,(schemeresult #,(cadr line)))]
|
||||
[(image)
|
||||
(let ([fn (format "2htdp/scribblings/img/~a" (cadr line))])
|
||||
(if (file-exists? fn)
|
||||
(schemeblock #,(image fn))
|
||||
(make-paragraph
|
||||
error-color
|
||||
(format "missing image! ~a" (cadr line)))))]))))
|
||||
(schemeblock #,(image fn)))]
|
||||
[(missing)
|
||||
(make-paragraph
|
||||
error-color
|
||||
"missing result; need to re-run image-gen.ss")]))))
|
||||
expr-paras
|
||||
val-list+outputs)))))
|
||||
|
||||
|
@ -51,4 +51,4 @@
|
|||
[else
|
||||
(unless (getenv "PLTSHOWIMAGES")
|
||||
(fprintf (current-error-port) "exp->filename: unknown exp ~s\n" exp))
|
||||
(list 'image "unk.png")])))
|
||||
(list 'missing)])))
|
||||
|
|
|
@ -451,6 +451,17 @@ 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?)]{
|
||||
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.
|
||||
|
||||
@image-examples[(image-baseline (text "Hello" 24 "black"))
|
||||
(image-height (text "Hello" 24 "black"))
|
||||
(image-baseline (rectangle 100 100 "solid" "black"))
|
||||
(image-height (rectangle 100 100 "solid" "black"))]
|
||||
}
|
||||
|
||||
@section{Image Predicates}
|
||||
|
||||
This section lists predicates for the basic structures provided by the image library.
|
||||
|
|
Loading…
Reference in New Issue
Block a user