Add draw-pict-centered
This commit is contained in:
parent
97e75cecc9
commit
7a575d67b7
|
@ -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}
|
||||
|
|
|
@ -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?)]))
|
||||
|
|
Loading…
Reference in New Issue
Block a user