Fixed running on normal Clojure; added some notes
This commit is contained in:
parent
124be0cd54
commit
9829d13e8b
@ -3,8 +3,8 @@
|
|||||||
:url "http://example.com/FIXME"
|
:url "http://example.com/FIXME"
|
||||||
:license {:name "Eclipse Public License"
|
:license {:name "Eclipse Public License"
|
||||||
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
||||||
;; :aot [curlnoise.core]
|
:aot [curlnoise.core]
|
||||||
;; :main curlnoise.core
|
:main curlnoise.core
|
||||||
:dependencies [[org.clojure/clojure "1.10.1"]
|
:dependencies [[org.clojure/clojure "1.10.1"]
|
||||||
[quil "3.1.0"]
|
[quil "3.1.0"]
|
||||||
[org.clojure/clojurescript "1.10.520"]]
|
[org.clojure/clojurescript "1.10.520"]]
|
||||||
|
|||||||
@ -3,10 +3,10 @@
|
|||||||
[quil.middleware :as m]))
|
[quil.middleware :as m]))
|
||||||
|
|
||||||
(def framerate 30)
|
(def framerate 30)
|
||||||
(def res-x 800)
|
(def res-x 500)
|
||||||
(def res-y res-x)
|
(def res-y res-x)
|
||||||
;; Lower grid size produces more points
|
;; Lower grid size produces more points
|
||||||
(def grid-size 50)
|
(def grid-size 20)
|
||||||
;; Lower alpha produces *longer* particle trails
|
;; Lower alpha produces *longer* particle trails
|
||||||
(def alpha 10)
|
(def alpha 10)
|
||||||
|
|
||||||
@ -99,10 +99,8 @@
|
|||||||
;; potential modulation function - takes (x,y):
|
;; potential modulation function - takes (x,y):
|
||||||
amp-fn #(ramp (min (/ (d-mouse %1 %2) d0)
|
amp-fn #(ramp (min (/ (d-mouse %1 %2) d0)
|
||||||
(/ (d-border %1 %2) d0)))
|
(/ (d-border %1 %2) d0)))
|
||||||
;;amp-fn (fn [x y] 1.0)
|
|
||||||
;; Noise function - must take 3 arguments, (x,y,z):
|
;; Noise function - must take 3 arguments, (x,y,z):
|
||||||
n-fn #(* noise-scale (q/noise (* f-inv %1) (* f-inv %2) (* f-inv %3)))
|
n-fn #(* noise-scale (q/noise (* f-inv %1) (* f-inv %2) (* f-inv %3)))
|
||||||
;;n-fn (fn [x y z] (* x f-inv))
|
|
||||||
;; Overall amplitude function:
|
;; Overall amplitude function:
|
||||||
p-fn #(* vf (amp-fn %1 %2) (n-fn %1 %2 %3))
|
p-fn #(* vf (amp-fn %1 %2) (n-fn %1 %2 %3))
|
||||||
points
|
points
|
||||||
@ -129,12 +127,12 @@
|
|||||||
(assoc :grid points))))
|
(assoc :grid points))))
|
||||||
|
|
||||||
(defn draw-state [state]
|
(defn draw-state [state]
|
||||||
;;(q/background 255)
|
(q/background 255)
|
||||||
(q/fill 255 255 255 alpha)
|
;;(q/fill 255 255 255 alpha)
|
||||||
(q/translate (- (/ res-x 2)) (- (/ res-y 2)))
|
#?(:cljs (q/translate (- (/ res-x 2)) (- (/ res-y 2))))
|
||||||
(q/rect 0 0 (q/width) (q/height))
|
;;(q/rect 0 0 (q/width) (q/height))
|
||||||
(q/stroke 0)
|
(q/stroke 0)
|
||||||
(q/stroke-weight 3)
|
(q/stroke-weight 5)
|
||||||
(let [pix (q/pixels)
|
(let [pix (q/pixels)
|
||||||
w (q/width)
|
w (q/width)
|
||||||
color (+ 255 (* 256 255) (* 256 256 255))
|
color (+ 255 (* 256 255) (* 256 256 255))
|
||||||
@ -142,6 +140,7 @@
|
|||||||
(doseq [point (:grid state)]
|
(doseq [point (:grid state)]
|
||||||
(let [[i j px py] point
|
(let [[i j px py] point
|
||||||
;;pix (q/pixels)
|
;;pix (q/pixels)
|
||||||
|
;; TODO: What am I doing wrong with accessing 'pix'?
|
||||||
]
|
]
|
||||||
;;(aset-int pix (+ px (* py w)) color)
|
;;(aset-int pix (+ px (* py w)) color)
|
||||||
(q/point px py)
|
(q/point px py)
|
||||||
@ -154,11 +153,17 @@
|
|||||||
:title "Curl Noise"
|
:title "Curl Noise"
|
||||||
:host "curlnoise"
|
:host "curlnoise"
|
||||||
:size [res-x res-y]
|
:size [res-x res-y]
|
||||||
:renderer :p3d
|
:renderer #?(:clj :java2d
|
||||||
|
:cljs :p3d)
|
||||||
|
;; TODO: Figure out my own test setup issues with p3d
|
||||||
:setup setup
|
:setup setup
|
||||||
:update update-state
|
:update update-state
|
||||||
:draw draw-state
|
:draw draw-state
|
||||||
:features [:keep-on-top]
|
:features [:keep-on-top]
|
||||||
:middleware [m/fun-mode
|
:middleware #?(:clj [m/fun-mode m/pause-on-error]
|
||||||
;;m/pause-on-error
|
:cljs [m/fun-mode])
|
||||||
]))
|
))
|
||||||
|
;; TODO: Should I run with q/sketch rather than q/defsketch?
|
||||||
|
|
||||||
|
(defn -main [& args]
|
||||||
|
(run-sketch))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user