Add draw-pict-centered

This commit is contained in:
Jay McCarthy 2014-06-02 08:56:13 -06:00
parent 97e75cecc9
commit 7a575d67b7
2 changed files with 21 additions and 0 deletions

View File

@ -554,6 +554,13 @@ Creates an arch.
]
}
@section{Drawing}
@addition{Jay McCarthy}
@defproc[(draw-pict-centered [p pict?] [dc (is-a?/c dc<%>)] [w real?] [h real?]) void?]{
Draws the pict @racket[p] on @racket[dc] centered in a @racket[w]x@racket[h] rectangle.
}
@section{Additional combinators}
@addition{Asumu Takikawa}

View File

@ -527,3 +527,17 @@
(-> real? real? real? real?
pict?)])
;; draw
(define (draw-pict-centered p dc aw ah)
(define pw (pict-width p))
(define ph (pict-height p))
(define (inset x y)
(/ (- x y) 2))
(draw-pict p dc (inset aw pw) (inset ah ph)))
(provide
(contract-out
[draw-pict-centered
(-> pict? (is-a?/c dc<%>) real? real?
void?)]))