diff --git a/shunic/src/shunic/core.clj b/shunic/src/shunic/core.clj index 3de2eeb..9928304 100644 --- a/shunic/src/shunic/core.clj +++ b/shunic/src/shunic/core.clj @@ -17,23 +17,40 @@ {:color (mod (+ (:color state) 0.7) 255) :angle (+ (:angle state) 0.1)}) +(defn tri + [x y delta] + (q/triangle x y x (- y delta) (- x delta) y) + (q/triangle x y x (+ y delta) (- x delta) y) + (q/triangle x y x (- y delta) (- x delta) y) + (q/triangle x y x (+ y delta) (+ x delta) y)) + (defn draw-state [state] ; Clear the sketch by filling it with light-grey color. - (q/background 240) + (q/background 0) ; Set circle color. (q/fill (:color state) 255 255) - (let [x1 100 - y1 100 - size 200] - (q/rect x1 y1 size size) - (q/triangle x1 y1 (+ x1 size) (+ y1 size) (+ x1 size) (+ y1 size))) + (q/stroke 55 100) + (let [angle (:angle state) + size 50 + x1 (* size (q/cos angle)) + y1 -50 + x2 (+ x1 size) + y2 (+ y1 size) + delta (/ size 2)] + (q/with-translation [(/ (q/width) 2) + (/ (q/height) 2)] + #_(q/rect x1 y1 size size) + (tri x1 y1 (* delta (q/cos angle))) + (tri x2 y1 delta) + (tri x1 y2 delta) + (tri x2 y2 (* delta (q/sin angle))) + ) + ; Calculate x and y coordinates of the circle. - #_(let [angle (:angle state) - x (* 150 (q/cos angle)) - y (* 150 (q/sin angle))] + #_(let [angle (:angle state) + x (* 150 (q/cos angle)) + y (* 150 (q/sin angle))] ; Move origin point to the center of the sketch. - (q/with-translation [(/ (q/width) 2) - (/ (q/height) 2)] ; Draw the circle. (q/ellipse x y 100 100))))