something
This commit is contained in:
parent
23874250dd
commit
fa330a3e2d
|
@ -17,23 +17,40 @@
|
||||||
{:color (mod (+ (:color state) 0.7) 255)
|
{:color (mod (+ (:color state) 0.7) 255)
|
||||||
:angle (+ (:angle state) 0.1)})
|
: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]
|
(defn draw-state [state]
|
||||||
; Clear the sketch by filling it with light-grey color.
|
; Clear the sketch by filling it with light-grey color.
|
||||||
(q/background 240)
|
(q/background 0)
|
||||||
; Set circle color.
|
; Set circle color.
|
||||||
(q/fill (:color state) 255 255)
|
(q/fill (:color state) 255 255)
|
||||||
(let [x1 100
|
(q/stroke 55 100)
|
||||||
y1 100
|
(let [angle (:angle state)
|
||||||
size 200]
|
size 50
|
||||||
(q/rect x1 y1 size size)
|
x1 (* size (q/cos angle))
|
||||||
(q/triangle x1 y1 (+ x1 size) (+ y1 size) (+ x1 size) (+ y1 size)))
|
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.
|
; Calculate x and y coordinates of the circle.
|
||||||
#_(let [angle (:angle state)
|
#_(let [angle (:angle state)
|
||||||
x (* 150 (q/cos angle))
|
x (* 150 (q/cos angle))
|
||||||
y (* 150 (q/sin angle))]
|
y (* 150 (q/sin angle))]
|
||||||
; Move origin point to the center of the sketch.
|
; Move origin point to the center of the sketch.
|
||||||
(q/with-translation [(/ (q/width) 2)
|
|
||||||
(/ (q/height) 2)]
|
|
||||||
; Draw the circle.
|
; Draw the circle.
|
||||||
(q/ellipse x y 100 100))))
|
(q/ellipse x y 100 100))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue