home *** CD-ROM | disk | FTP | other *** search
- ;;; -*- Scheme -*-
-
- #|
-
- Copyright (c) 1991 Massachusetts Institute of Technology
-
- This material was developed by the Scheme project at the Massachusetts
- Institute of Technology, Department of Electrical Engineering and
- Computer Science. Permission to copy this software, to redistribute
- it, and to use it for any purpose is granted, subject to the following
- restrictions and understandings.
-
- 1. Any copy made of this software must include this copyright notice
- in full.
-
- 2. Users of this software agree to make their best efforts (a) to
- return to the MIT Scheme project any improvements or extensions that
- they make, so that these may be included in future releases; and (b)
- to inform MIT of noteworthy uses of this software.
-
- 3. All materials developed as a consequence of the use of this
- software shall duly acknowledge such use, in accordance with the usual
- standards of acknowledging credit in academic research.
-
- 4. MIT has made no warrantee or representation that the operation of
- this software will be error-free, and MIT is under no obligation to
- provide any services, by way of maintenance, update, or otherwise.
-
- 5. In conjunction with products arising from the use of this material,
- there shall be no use of the name of the Massachusetts Institute of
- Technology nor of any adaptation thereof in any advertising,
- promotional, or sales literature without prior written consent from
- MIT in each case.
-
- |#
-
- (declare (usual-integrations)
- (integrate-external "squares"))
-
- ;;;; System dependent stuff for box and pointer diagram printer.
- ;;; MIT CScheme version 7.1 (using X).
-
- (define box&pointer-window)
-
- (define screen)
-
- (define character-width 6)
- (define character-height 10)
-
- (define (initialize-graphics)
- (set! box&pointer-window
- (make-graphics-device x-graphics-device-type
- (x-open-display false)
- false))
- (with-values
- (lambda () (graphics-device-coordinate-limits box&pointer-window))
- (lambda (x-left y-bottom x-right y-top)
- ;; In X top is lower than bottom, switch for this program.
- (graphics-set-coordinate-limits box&pointer-window
- x-left y-top x-right y-bottom)
- (set! screen
- (make-rect (make-vect x-left y-top)
- (make-vect (- x-right x-left) 0)
- (make-vect 0 (- y-bottom y-top))))))
- (graphics-operation box&pointer-window 'set-font
- (string-append (number->string character-width)
- "x"
- (number->string character-height)))
- 'done)
-
- (define (drawline start-point end-point)
- (graphics-draw-line box&pointer-window
- (exact->inexact (xcor start-point))
- (exact->inexact (ycor start-point))
- (exact->inexact (xcor end-point))
- (exact->inexact (ycor end-point))))
-
- (define (sign x)
- (if (< x 0)
- -1
- 1))
-
- (define (text-picture string)
- (let ((width (* character-width (string-length string)))
- (height character-height))
- (lambda (rectangle)
- (let ((rwidth (abs (xcor (horiz rectangle))))
- (rheight (abs (ycor (vert rectangle)))))
- (if (or (< rwidth width) (< rheight height))
- (default-text-picture rectangle)
- (graphics-draw-text box&pointer-window
- (exact->inexact
- (+ (xcor (origin rectangle))
- (* (sign (xcor (horiz rectangle)))
- (/ (- rwidth width) 2))))
- (exact->inexact
- (+ (ycor (origin rectangle))
- (* (sign (ycor (vert rectangle)))
- (/ (- rheight height) 2))))
- string))))))
-
- (define (clear-graphics)
- (graphics-clear box&pointer-window))
-
- (define (draw picture)
- (clear-graphics)
- (picture screen))
-
- (define draw-permanent draw)
-
- ;;;; Dialect dependencies
-
- (define (atom? x)
- (not (pair? x)))
-
- (define mapc for-each)
-
- (define mapcar map)