Arc Forumnew | comments | leaders | submitlogin
7 points by kens 6133 days ago | link | parent

Here's one way to do graphics in Arc using DrScheme and MrEd.

I loaded "as.scm" into DrScheme.

I added simple make-canvas and draw-point commands to the as.scm code to use the MrEd Graphical Toolbox, and exported these commands to Arc.

I wrote a simple Arc function to draw the Sierpinski triangle using these graphics functions.

Specifically, I added the following code to as.scm.

  (define (make-canvas w h)
    (define frame (instantiate frame% ("Gasket by Ken Shirriff") (width w) (height h)))
    (define canvas (instantiate canvas% (frame)))
    (define dc (send canvas get-dc))
    (send frame show #t)
    dc ;; Return drawing context
    )
   
  ; Export simple drawing functions to Arc
  (xdef 'make-canvas (lambda (w h) (make-canvas w h)))
  (xdef 'draw-point (lambda (dc x y) (send dc draw-point x y)))
Then I clicked "Run" in DrScheme and entered the following into Arc:

  Arc>(def gasket (x y w)
        (if (< w 1)
            (draw-point dc x y)
            (do (gasket x y (/ w 2))
  	        (gasket (+ x (/ w 2)) y (/ w 2))
                (gasket x (+ y (/ w 2)) (/ w 2)))))
  Arc>(= dc (make-canvas 300 300))
  Arc>(gasket 0 0 256)
Supporting additional graphics functions is left as an exercise to the reader. For more information on MrEd, see: http://download.plt-scheme.org/doc/372/html/mred/mred-Z-H-39...

I would be interested in knowing if there is a way to access this library from Arc directly, without needing to hack as.scm.