Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created March 8, 2013 00:01
Show Gist options
  • Select an option

  • Save practicingruby/5113047 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/5113047 to your computer and use it in GitHub Desktop.
(ns weiqi.core
(:use seesaw.core
seesaw.graphics
seesaw.color))
(def rect-width 30)
(def board-size 19)
(def border-width 1)
(def black-stone-style (style :background (color :black)))
(def white-stone-style
(style :background (color :white)
:foreground (color :black)
:stroke 2))
(defn stone [x y]
(circle (* rect-width x) (* rect-width y) (/ rect-width 2)))
(defn paint [c g]
(dorun
(for [x (range 1 board-size) y (range 1 board-size)]
(draw g
(rect (* x rect-width) (* y rect-width) rect-width)
(style :background ( color :white )
:foreground ( color :black )
:stroke 2 ))))
(draw g
(stone 3 3) white-stone-style
(stone 2 3) black-stone-style
(stone 4 3) black-stone-style
(stone 3 4) black-stone-style))
(defn -main [& args]
(invoke-later
(-> (frame :title "Weiqi"
:width (+ (* rect-width (+ board-size 1)) (* 2 border-width))
:height (+ (* rect-width (+ board-size 2)) (* 2 border-width))
:content
(canvas :id :canvas :background "#BBBBDD" :paint paint)
:on-close :exit)
show!)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment