Logo-ish drawing environment
Some months ago I bought a copy of "Turtle Geometry". I am looking for a LOGO environment to follow along and do the exsercises, but I could not find anything good enough for Mac OS X (which is quite surprising, if you ask me). So I decided to write my own version. The first usable thing I produced is not quite LOGO, but enough to do fancy drawings and (I'm guessing) translate most of the exercises without efforts. Code is on github.

Update
One thing I'm not sure how I could do is the interactive environment, but I discovered I have something acceptable at no cost, thanks to how Lisp and the lispbuilder-sdl package work.
Here a piece of code from my project:
;; [...] (with-events () (:quit-event () t) (:key-down-event (:key key) (when (sdl:key= key :sdl-key-escape)) (sdl:push-quit-event)) (:idle (reset-turtle) (fancy 20) (draw-turtle *position-x* *position-y* *direction*) (update-display)))))
Since we're implicitly using the :poll
event mechanism, the :idle
event is triggered at each "game loop" iteration. Thus, if I redefine
the functions used in the body associated to the :idle
event while
the program is running, I obtain a different drawing. What I do, at
the end, is:
- evaluate
(main)
(the SDL window appear) - focus in the Emacs window
- edit some relevant functions (for example the body of
fancy
) C-x C-e
to re-evaluate the definition- voilĂ , new picture is drawn