Created
February 24, 2011 17:21
-
-
Save RobinRamael/842487 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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