21st Century Smalltalk

February 8, 2007

Flex Graphics Test

Filed under: Adobe, Lisp — pfisk @ 7:10 pm

lisptest4
Vista Smalltalk Site

This is a graphics test using the Lisp interpreter running in IE7 using Adobe Flash 9 - it should work on most versions of Windows, Macintosh and Linux. There is a link to the executable (about 240 kb) on the main Vista Smalltalk site.

There are three functions: “add-shape”, “add-shapes”, and “test-shapes”.
Highlight each one separately, and use “Do It” or “Show It”.
Then highlight “(test-shapes)” and “Do It” – the shapes should appear in the right panel.

The interpreter has progressed substantially:
– closures are implemented
– macros are implemented (still some bugs)
– class structure partially implemented
– method calling partially implemented

Next steps are:
– add functions for building classes
– test Smalltalk semantics using Lisp syntax
– implement Smalltalk reader

Below is the Lisp code for the above sample.

(defun add-shape (type size x y)
  (sprite-add *canvas* type size x y)
  (sprite-add *canvas* type (* size 2)
                            (+ x (/ size 4))
                            (+ y (/ size 4)))
  (sprite-add *canvas* type (* size 3)
                            (+ x (/ size 2))
                            (+ y (/ size 2))))

(defun add-shapes (size x y)
  (add-shape "circle" size x y)
  (add-shape "square" size (+ x (/ size 3)) y)
  (add-shape "triangle" size (+ x (* 2 (/ size 3))) y))

(defun test-shapes ()
  (add-shapes 10 0 0)
  (add-shapes 30 50 50)
  (add-shapes 10 100 50)
  (add-shapes 20 50 100)
  (add-shapes 70 150 10)
  (add-shapes 30 0 230)
  (add-shapes 45 100 150))

(test-shapes)

6 Comments »

  1. “Do It” and “Show It” selections on the context menu seem to missing on the new executable. Thanks for all the wonderful work, by the way.

    Comment by Noodles — February 8, 2007 @ 8:10 pm

  2. Regarding the context menu problem, it seems to be a Safari bug, since it works fine in Firefox on a Mac.

    Comment by Noodles — February 8, 2007 @ 9:32 pm

  3. Great to hear that it works on a Mac!
    Thanks

    Comment by pfisk — February 8, 2007 @ 9:44 pm

  4. Peter,

    Please forgive my ignorance here but I am very interested in both VST and Flex. I am running XP with the 3.0 framework and IE7 installed but think I need some more information as I cannot get a result from the Lisp code above. I attempted to copy and paste the above into the lisp.swf page and then highlighted the text and attempted to “Do it” but nothing happened. Using “Show it” produced an “add-shape” to the end of the code.

    Am I not using this correctly or do I need to “RTM” (Read the tutorial).

    Thanks!

    Comment by dataZephyr — February 9, 2007 @ 5:59 am

  5. I have reformatted the code to make it clearer.

    There are three functions: “add-shape”, “add-shapes”, and “test-shapes”.
    Highlight each one separately, and use “Do It” or “Show It”.
    Then highlight “(test-shapes)” and “Do It” – the shapes should appear in the right panel.

    For now, there is no manual – I will try to put some documentation up next week.

    Thanks for pointing out the problem

    Comment by pfisk — February 9, 2007 @ 2:53 pm

  6. Ah, much better!

    I now have the code working in both IE7 and Firefox 2.0.0.1!

    Can’t wait for the Vst version. This stuff rocks!!!

    Thanks again!

    Comment by dataZephyr — February 10, 2007 @ 6:20 am


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.