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 in a couple of hours :-), and you want to say "And here's how you can > draw a circle in a graphics window..." and (for pedagogical reasons into > which I won't digress here) you don't want to use any additional libraries or > open a file with pre-written code that does magic that you haven't explained. > You want to start with an empty file and literally type in the code needed to > draw shapes, from scratch. You want to provide functionality sufficient to do > the kind or random-shape-drawing example that I have at the bottom of the > code. How little code can you get away with writing to do this? > > [etc removed] > > ;;; simple shape drawing code > > [removed]
I neglected to clear the window prior to each re-render, which shows up with intermediate alpha values. Easily remedied (changed fragment below) but this is yet another thing moving away from the "code minimality" that I'm angling for. -Lee (def panel (let [jp (proxy [javax.swing.JPanel] [] (getPreferredSize [] (java.awt.Dimension. max-x max-y)) (paint [g] (render-shape g (list 'rect 0 0 max-x max-y java.awt.Color/WHITE)) (doall (map #(render-shape g %) @shapes))))] (doto (new javax.swing.JFrame "My graphics window") (.setSize max-x max-y) (.add jp) (.setVisible true)) jp)) -- Lee Spector, Professor of Computer Science School of Cognitive Science, Hampshire College 893 West Street, Amherst, MA 01002-3359 lspec...@hampshire.edu, http://hampshire.edu/lspector/ Phone: 413-559-5352, Fax: 413-559-5438 Check out Genetic Programming and Evolvable Machines: http://www.springer.com/10710 - http://gpemjournal.blogspot.com/ -- 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