Newsgroups: comp.lang.scheme.c
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!bloom-beacon!dont-send-mail-to-path-lines
From: markf@altdorf.ai.mit.EDU
Subject: Re: X Graphics Using MIT SCHEME 7.0
Message-ID: <9103211731.AA26595@bloom-beacon.MIT.EDU>
Sender: daemon@athena.mit.edu (Mr Background)
Reply-To: markf@zurich.ai.mit.edu
Organization: The Internet
References: <2449@borg.cs.unc.edu>
Date: 21 Mar 91 16:47:57 GMT
Lines: 69

There are a set of device independent graphics commands defined in
runtime/graphics.scm. When you make a graphics device you pass in a
specific graphics device type. MIT Scheme currently supports starbase
graphics (an HP creation) and X window graphics. For X window
graphics you should use the x-graphics-device-type wich is defined in
runtime/x11graph.scm. Here is a very simple graphics package which
shows the use of some of the graphics stuff.

-Mark

;;;; Simple graphics Interface
;;;; implemented for X Windows

(define clear-graphics)
(define clear-point)
(define draw-line-to)
(define draw-point)
(define graphics-available?)
(define graphics-text)
(define init-graphics)
(define position-pen)

(define graphics-package
  (make-environment

    (define graphics-device #F)

    (set! clear-graphics
	  (lambda ()
	    (if (not graphics-device)
		(init-graphics))
	    (graphics-clear graphics-device)
	    (graphics-move-cursor graphics-device 0 0)))

    (set! clear-point
	  (lambda (x y)
	    (graphics-erase-point graphics-device x y)))

    (set! draw-line-to
	  (lambda (x y)
	    (graphics-drag-cursor graphics-device x y)))

    (set! draw-point
	  (lambda (x y)
	    (graphics-draw-point graphics-device x y)))

    (set! graphics-available?
	  (lambda ()
	    (graphics-type-available? x-graphics-device-type)))

    (set! graphics-text
	  (lambda (text x y)
	    ;; Accepts different parameters on Chipmunks.
	    (graphics-draw-text graphics-device x y text)))

    (set! init-graphics
	  (lambda ()
	    (let ((display (x-open-display #f)))
	      (set! graphics-device
		    (make-graphics-device x-graphics-device-type
					  display "512x388" #f)))
	    (graphics-set-coordinate-limits graphics-device -256 -195 255 194)
	    (graphics-move-cursor graphics-device 0 0)))

    (set! position-pen
	  (lambda (x y)
	    (graphics-move-cursor graphics-device x y)))

))
