Make CLEAR-POINT, DRAW-LINE-TO, DRAW-POINT, GRAPHICS-TEXT, and
authorArthur Gleckler <edu/mit/csail/zurich/arthur>
Fri, 12 Apr 1991 00:12:11 +0000 (00:12 +0000)
committerArthur Gleckler <edu/mit/csail/zurich/arthur>
Fri, 12 Apr 1991 00:12:11 +0000 (00:12 +0000)
POSITION-PEN all automatically call INIT-GRAPHICS if graphics hasn't
already been initialized.  CLEAR-GRAPHICS already does this.

v7/src/sicp/graphics.scm

index 454a8fb85eaeff0be79ba3b324166cd0f7d6ca93..bc9c54b102ad7fd914dd812235d8d3fccbf3ce17 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/sicp/graphics.scm,v 1.2 1990/11/14 14:57:58 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/sicp/graphics.scm,v 1.3 1991/04/12 00:12:11 arthur Exp $
 
 Copyright (c) 1987, 1988, 1989, 1990 Massachusetts Institute of Technology
 
@@ -51,23 +51,29 @@ MIT in each case. |#
 
     (define graphics-device #F)
 
+    (define (init-if-necessary)
+      (if (not graphics-device)
+         (init-graphics)))
+
     (set! clear-graphics
          (lambda ()
-           (if (not graphics-device)
-               (init-graphics))
+           (init-if-necessary)
            (graphics-clear graphics-device)
            (graphics-move-cursor graphics-device 0 0)))
 
     (set! clear-point
          (lambda (x y)
+           (init-if-necessary)
            (graphics-erase-point graphics-device x y)))
 
     (set! draw-line-to
          (lambda (x y)
+           (init-if-necessary)
            (graphics-drag-cursor graphics-device x y)))
 
     (set! draw-point
          (lambda (x y)
+           (init-if-necessary)
            (graphics-draw-point graphics-device x y)))
 
     (set! graphics-available?
@@ -76,6 +82,7 @@ MIT in each case. |#
 
     (set! graphics-text
          (lambda (text x y)
+           (init-if-necessary)
            ;; Accepts different parameters on Chipmunks.
            (graphics-draw-text graphics-device x y text)))
 
@@ -90,6 +97,7 @@ MIT in each case. |#
 
     (set! position-pen
          (lambda (x y)
+           (init-if-necessary)
            (graphics-move-cursor graphics-device x y)))
 
 ))
\ No newline at end of file