Skip to content

Instantly share code, notes, and snippets.

@RobinRamael
Created February 24, 2011 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobinRamael/842487 to your computer and use it in GitHub Desktop.
Save RobinRamael/842487 to your computer and use it in GitHub Desktop.
(ns sier.core
(:import (javax.swing JFrame JPanel JButton)
(java.awt Dimension)))
(defstruct coord :x :y)
(defstruct triangle :c1 :c2 :c3)
(defn draw-line [g c1 c2]
(.drawLine g (:x c1) (:y c1) (:x c2) (:y c2)))
(defn draw-triangle [panel fig]
(doto (.getGraphics panel)
(draw-line (:c1 fig) (:c2 fig))
(draw-line (:c2 fig) (:c3 fig))
(draw-line (:c3 fig) (:c1 fig)))
fig)
(defn make-frame [w h]
"Create a frame with width w and height h and return the panel"
(let [panel (doto (JPanel.)
(.setPreferredSize (Dimension. w h))
(.setLayout nil))]
(do (doto (JFrame.)
(.setContentPane panel)
(.pack)
(.setVisible true)))
panel))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment