Draw graphics using the MIT scheme

I want to graphically build a function using the MIT circuit. In the manual for the scheme there is a section "Graphics" - quote:

MIT Scheme has a simple two-dimensional line-graphics interface that is suitable for many graphics application. 

If you have experienced this, please help me by inserting a minimal working code (KISS principle) that works with the MIT / circuit and that does something.

+6
source share
4 answers

This seems to contain documentation for each individual function, but comprehensive examples of each function do not appear to exist in any documentation on the Internet. The only way I was able to find working code is through Google's actual function names and a careful review of each result for possible code samples.

In any case, to satisfy your question and give you a simple example of how this library works, here is a sample code.

  (let ((device (make-graphics-device (car (enumerate-graphics-types)))) (x-start 0) (y-start 0) (x-end 5) (y-end 5)) (graphics-draw-line device x-start y-start x-end y-end) (graphics-close device)) 

If you need more samples, let me know, but there should be enough code and documents to get you started.

+6
source

I just would like to add that the code given by seisvelas (1/11/12), although correct, does not work on my 64-bit Linux system.
(Edited after observing alinsoar) This is because the window closes within the scope of the let, so it actually works, but happens too quickly for observation.

Try it like this:

 (define device (make-graphics-device (car (enumerate-graphics-types)))) (graphics-draw-line device 0 0 5 5) ;; when you're good and ready (graphics-close device) 
+5
source

For Mac OSX users, it’s worth noting that you need to install and run XQuartz or (enumerate-graphics-types) will always be empty.

+2
source

I am working on a print utility for Windows source users

It is simply created from the primitives provided by the “graphics” in the mit-scheme, but it allows you to create plot functions and vector fields.

0
source

All Articles