add scale-to-fit to slideshow/pict
This commit is contained in:
parent
f40277df89
commit
7647e94eee
|
@ -543,6 +543,18 @@ Scales a pict drawing, as well as its @tech{bounding box}. The drawing
|
|||
is scaled by adjusting the destination @racket[dc<%>]'s scale while
|
||||
drawing the original @racket[pict].}
|
||||
|
||||
@defproc*[([(scale-to-fit [pict pict?] [size-pict pict?]) pict?]
|
||||
[(scale-to-fit [pict pict?] [width real?] [height real?]) pict?])]{
|
||||
Scales @racket[pict] so that it fits within the bounding box of
|
||||
@racket[size-pict] (if two arguments are supplied) or
|
||||
into a box of size @racket[width] by @racket[height]
|
||||
(if three arguments are supplied).
|
||||
|
||||
The aspect ratio of the pict is preserved, so the resulting pict
|
||||
will have either the width or the height of the @racket[size-pict]
|
||||
(or @racket[width] by @racket[height] box), but not necessarily
|
||||
both.
|
||||
}
|
||||
|
||||
@defproc[(rotate [pict pict?] [theta real?]) pict?]{
|
||||
|
||||
|
|
|
@ -71,6 +71,8 @@
|
|||
(provide/contract
|
||||
[scale (case-> (-> pict? number? number? pict?)
|
||||
(-> pict? number? pict?))]
|
||||
[scale-to-fit (case-> (-> pict? number? number? pict?)
|
||||
(-> pict? pict? pict?))]
|
||||
[rotate (case-> (-> pict? number? pict?))]
|
||||
[pin-line (->* (pict?
|
||||
pict-path? (-> pict? pict-path? (values number? number?))
|
||||
|
@ -1068,6 +1070,14 @@
|
|||
(s (send c green))
|
||||
(s (send c blue))))))
|
||||
|
||||
(define scale-to-fit
|
||||
(case-lambda
|
||||
[(main-pict size-pict)
|
||||
(scale-to-fit main-pict (pict-width size-pict) (pict-height size-pict))]
|
||||
[(main-pict w h)
|
||||
(scale main-pict (min (/ w (pict-width main-pict))
|
||||
(/ h (pict-height main-pict))))]))
|
||||
|
||||
(define scale
|
||||
(case-lambda
|
||||
[(p x-factor y-factor)
|
||||
|
|
Loading…
Reference in New Issue
Block a user