On Sep 16, 2010, at 12:13 PM, Alan wrote:
> I think you may have misunderstood the first suggestion I made, about
> keeping (shape, color) pairs in your atomic vector. I really meant
> java.awt.Shape and java.awt.Color objects, rather than a symbol
> (keyword is better as Christophe suggests) and a bunch of numbers.
> Like so:
> (defn render-shape [g shape color]
>  (doto g
>    (.setColor color)
>    (.fill shape)))
> 
> (draw-shape (Rectangle. 50 50 200 100) (Color. 0 0 255 75))
> 
> Java already has the "multi-method" Christophe suggests, in the form
> of Graphics.fill(Shape); you don't have to implement it yourself.

Ah -- I didn't misunderstand, but I also didn't know about Graphics.fill(Shape) 
so I didn't see the full picture or the real benefit. This should indeed help 
to neaten things up a bit. 

(And thanks Christophe for the keyword advice -- my use of symbols is another 
old Lisp habit, which wasn't great even there.)

I guess the main remaining issue is just the code to create the window and 
panel, which is still pretty big and cumbersome to be part of the sort of 
ultra-simple graphical "hello world" that I had in mind. But if there's no 
simpler way to do that with the built-in java libraries then I guess I'm stuck 
with that.

Thanks, -Lee

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to