-
Notifications
You must be signed in to change notification settings - Fork 0
/
P_1_1_1_01.clj
45 lines (38 loc) · 1022 Bytes
/
P_1_1_1_01.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
; P_1_1_1_01.clj
;
; Licensed under the Apache License, Version 2.0
; draw the color spectrum by moving the mouse
;
; MOUSE
; position x/y : resolution
;
; KEYS
; s : save png
(ns generative-design-clojure.principles.P_1_1_1_01.P_1_1_1_01
(:use quil.core)
(:import java.util.Calendar))
(defn setup []
(background 0))
(defn draw []
(no-stroke)
(color-mode :hsb (width) (height) 100)
(let
[step-x (+ (mouse-x) 2),
step-y (+ (mouse-y) 2)]
(doseq
[grid-y (range 0 (height) step-y),
grid-x (range 0 (width) step-x)]
(fill grid-x (- (height) grid-y) 100)
(rect grid-x grid-y step-x step-y))))
(defn timestamp []
(let [now (Calendar/getInstance)]
(format "%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS" now)))
(defn key-press []
(if (= (str (raw-key)) "s")
(save-frame (str (timestamp) "_##.png"))))
(defsketch P_1_1_1_01
:title "P_1_1_1_01"
:setup setup
:draw draw
:key-pressed key-press
:size [800 400])