From 9028e7281315383ef9128ffec6f73c421556efd3 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Tue, 15 Jul 2014 08:56:40 -0500 Subject: [PATCH] make the code in the contract have a nicer name. Thanks to Matthias --- pkgs/pict-pkgs/pict-lib/pict/main.rkt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pkgs/pict-pkgs/pict-lib/pict/main.rkt b/pkgs/pict-pkgs/pict-lib/pict/main.rkt index ef838db13e..8b150cab4c 100644 --- a/pkgs/pict-pkgs/pict-lib/pict/main.rkt +++ b/pkgs/pict-pkgs/pict-lib/pict/main.rkt @@ -30,13 +30,7 @@ [h real?]) ([d (or/c #f real?)] [a (or/c #f real?)]) - #:pre (draw) - (let () - (define bdc (new bitmap-dc% [bitmap (make-bitmap 1 1)])) - (randomize-state bdc) - (define old-state (get-dc-state bdc)) - (draw bdc 0 0) - (equal? (get-dc-state bdc) old-state)) + #:pre (draw) (does-draw-restore-the-state-after-being-called? draw) [p pict?])] [cellophane (-> pict? (real-in 0 1) pict?)] [vl-append *-append/c] @@ -83,6 +77,13 @@ [result pict?])] [disk (->* ((and/c rational? (not/c negative?))) (#:draw-border? any/c) pict?)])) +(define (does-draw-restore-the-state-after-being-called? draw) + (define bdc (new bitmap-dc% [bitmap (make-bitmap 1 1)])) + (randomize-state bdc) + (define old-state (get-dc-state bdc)) + (draw bdc 0 0) + (equal? (get-dc-state bdc) old-state)) + ;; randomizes some portions of the state of the given dc; ;; doesn't pick random values for things that the 'dc' ;; function promises not to change (e.g. the pen/brush style).