Re: simplest graphics?

2010-09-16 Thread Lee Spector
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

Re: simplest graphics?

2010-09-16 Thread Alan
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

Re: simplest graphics?

2010-09-16 Thread Christophe Grand
Hi Lee, On Thu, Sep 16, 2010 at 5:15 AM, Lee Spector wrote: > Also, this would have a smaller impact but I'm curious about it: is there a > way to treat method names as data and then make calls to them, as one can > with clojure functions? Then I could pass things like fillRect, or map rect > to

Re: simplest graphics?

2010-09-16 Thread Michael Gardner
On Sep 15, 2010, at 10:15 PM, Lee Spector wrote: > Also, this would have a smaller impact but I'm curious about it: is there a > way to treat method names as data and then make calls to them, as one can > with clojure functions? Then I could pass things like fillRect, or map rect > to fillRect,

Re: simplest graphics?

2010-09-15 Thread Lee Spector
On Sep 15, 2010, at 1:57 PM, Alan wrote: > This looks a lot like what I would do - I'm afraid I don't have any > brilliant insights for you. I do have a couple ways you could make > this smaller, though: > > - Instead of (atom ()) and convoluted swap! logic, what about (atom > []) and (swap! sha

Re: simplest graphics?

2010-09-15 Thread Alan
This looks a lot like what I would do - I'm afraid I don't have any brilliant insights for you. I do have a couple ways you could make this smaller, though: - Instead of (atom ()) and convoluted swap! logic, what about (atom []) and (swap! shapes conj new-shape)? - Similarly don't use (list shape-

Re: simplest graphics?

2010-09-15 Thread Lee Spector
On Sep 15, 2010, at 8:32 AM, Lee Spector wrote: > > The code below is still more than I would like, and I'm wondering if there's > a more concise way to do this (again, without additional libraries). One way > to reframe my question is to imagine that you're in front of a class (as I > will be

Re: simplest graphics?

2010-09-15 Thread Lee Spector
On Sep 14, 2010, at 4:59 PM, Alan wrote: > I think you could just keep a vector of (color,shape) pairs as an > atom, and reify a subclass of JPanel whose paint() method closes > around that atom, calling (.draw shape color). Then as long as you > call repaint every time you modify the atom, you s

Re: simplest graphics?

2010-09-14 Thread Alan
I think you could just keep a vector of (color,shape) pairs as an atom, and reify a subclass of JPanel whose paint() method closes around that atom, calling (.draw shape color). Then as long as you call repaint every time you modify the atom, you should be done. Seems like it's hard to see a librar

Re: simplest graphics?

2010-09-14 Thread Lee Spector
On Sep 14, 2010, at 2:13 PM, Miki wrote: > Maybe the ants demo will help - http://tinyurl.com/29rqe5r Thanks Miki -- I've seen that code, and the video of Rich discussing it, and I've been toying with some of the elements that it uses (JFrames etc.). But that is in a more elaborate context wit

Re: simplest graphics?

2010-09-14 Thread Miki
Maybe the ants demo will help - http://tinyurl.com/29rqe5r On Sep 14, 9:55 am, Lee Spector wrote: > I'm looking for a way to do simple colored-lines-and-shapes graphics in a > window that requires: > > - No libraries beyond what is built into java, clojure 1.2, and > clojure-contrib (which is w

simplest graphics?

2010-09-14 Thread Lee Spector
I'm looking for a way to do simple colored-lines-and-shapes graphics in a window that requires: - No libraries beyond what is built into java, clojure 1.2, and clojure-contrib (which is what one gets automatically in a new Eclipse/Counterclockwise project). - As little additional code as poss