How about drawing all the rectangles with .fillRect()<http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html#fillRect%28int,%20int,%20int,%20int%29>and before each call alternate between black and white by calling .setColor()<http://docs.oracle.com/javase/7/docs/api/java/awt/Graphics.html#setColor%28java.awt.Color%29>. You can alternate between the colours by taking the first of the following seq every time you set the color:
(cycle [java.awt.Color.black java.awt.Color.white]) Stathis On Thursday, 9 August 2012 09:37:48 UTC+1, Jim foo.bar wrote: > > Hey all, > > Spent most of yesterday trying to draw a chessboard on a paintable > canvas, however I'm stuck after drawing the lines of the grid...I mean > the grid is there but its all one colour (the background colour of the > panel)! The fn that draws the lines is simply this: > > (defn draw-grid [c g] > (let [w (width c) > h (height c)] > (doseq [x (range 0 w 50)] > (.drawLine g x 0 x h)) > (doseq [y (range 0 h 50)] > (.drawLine g 0 y w y)))) > > Does anyone have any suggestions as to how to do the black-white > alteration on the grid? I know how to do it imperatively using loop(s) > and a couple of flags but I'm really struggling to tweak the 'draw-grid' > accordingly to paint the colours as well... > > Any seesaw gurus? -> please help... > > cheers, > Jim > -- 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