Search code examples
schememit-scheme

draw graphics with MIT scheme


I wish to plot graphically a function using MIT scheme. In the manual of scheme, there is a section called "Graphics" -- quote:

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

If you experienced this, please help me by pasting a minimal working code (KISS principle) that works with MIT/scheme, and which plots something.


Solution

  • It looks like this manual contains documentation of each individual function, but full out examples of every function do not appear to exist in any documentation online. The only way I was able to find working code was to Google the actual function names and arduously review each result for possible code samples.

    Anyway, to satisfy your question and give you a simple example of how this library works, here is 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 the code and docs should be enough to get you going.