Add working cljs version
Use 'lein compile' or 'lein figwheel'. Still figuring out details like how to make it compatible with normal Clojure simultaneously. However, code changes were pretty minimal.
This commit is contained in:
parent
5a36660d65
commit
124be0cd54
32
project.clj
32
project.clj
@ -3,7 +3,33 @@
|
||||
:url "http://example.com/FIXME"
|
||||
:license {:name "Eclipse Public License"
|
||||
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
||||
:aot [curlnoise.core]
|
||||
:main curlnoise.core
|
||||
;; :aot [curlnoise.core]
|
||||
;; :main curlnoise.core
|
||||
:dependencies [[org.clojure/clojure "1.10.1"]
|
||||
[quil "3.1.0"]])
|
||||
[quil "3.1.0"]
|
||||
[org.clojure/clojurescript "1.10.520"]]
|
||||
|
||||
:plugins [[lein-cljsbuild "1.1.7"]
|
||||
[lein-figwheel "0.5.19"]]
|
||||
:hooks [leiningen.cljsbuild]
|
||||
|
||||
:clean-targets ^{:protect false} ["resources/public/js"]
|
||||
:cljsbuild
|
||||
{:builds [; development build with figwheel hot swap
|
||||
{:id "development"
|
||||
:source-paths ["src"]
|
||||
:figwheel true
|
||||
:compiler
|
||||
{:main "curlnoise.core"
|
||||
:output-to "resources/public/js/main.js"
|
||||
:output-dir "resources/public/js/development"
|
||||
:asset-path "js/development"}}
|
||||
; minified and bundled build for deployment
|
||||
{:id "optimized"
|
||||
:source-paths ["src"]
|
||||
:compiler
|
||||
{:main "curlnoise.core"
|
||||
:output-to "resources/public/js/main.js"
|
||||
:output-dir "resources/public/js/optimized"
|
||||
:asset-path "js/optimized"
|
||||
:optimizations :advanced}}]})
|
||||
|
||||
11
resources/public/index.html
Normal file
11
resources/public/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>curlnoise</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="curlnoise"></div>
|
||||
<script src="js/main.js"></script>
|
||||
<script>curlnoise.core.run_sketch()</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,12 +1,12 @@
|
||||
(ns curlnoise.core
|
||||
(:require [quil.core :as q]
|
||||
(:require [quil.core :as q :include-macros true]
|
||||
[quil.middleware :as m]))
|
||||
|
||||
(def framerate 30)
|
||||
(def res-x 800)
|
||||
(def res-y res-x)
|
||||
;; Lower grid size produces more points
|
||||
(def grid-size 25)
|
||||
(def grid-size 50)
|
||||
;; Lower alpha produces *longer* particle trails
|
||||
(def alpha 10)
|
||||
|
||||
@ -131,6 +131,7 @@
|
||||
(defn draw-state [state]
|
||||
;;(q/background 255)
|
||||
(q/fill 255 255 255 alpha)
|
||||
(q/translate (- (/ res-x 2)) (- (/ res-y 2)))
|
||||
(q/rect 0 0 (q/width) (q/height))
|
||||
(q/stroke 0)
|
||||
(q/stroke-weight 3)
|
||||
@ -148,35 +149,16 @@
|
||||
;;(q/update-pixels)
|
||||
))
|
||||
|
||||
(defn update-state-circles [state]
|
||||
(update state :frame inc))
|
||||
|
||||
(defn draw-state-circles [state]
|
||||
(q/background 240)
|
||||
(q/fill 0 0 0)
|
||||
(doseq [point (:grid state)]
|
||||
(let [[i j px py] point
|
||||
z (/ (:frame state) 50.0)
|
||||
x (/ i 10.0)
|
||||
y (/ j 10.0)
|
||||
rad (int (* (q/noise x y z) grid-size))]
|
||||
(q/ellipse px py rad rad))))
|
||||
|
||||
(defn ^:export run-sketch []
|
||||
(q/defsketch curlnoise
|
||||
:title "Curl Noise"
|
||||
:host "curlnoise"
|
||||
:size [res-x res-y]
|
||||
:renderer :p3d
|
||||
:setup setup
|
||||
:update update-state
|
||||
:draw draw-state
|
||||
:features [:keep-on-top]
|
||||
:middleware [m/fun-mode m/pause-on-error])
|
||||
|
||||
(defn -main [& args]
|
||||
(q/sketch
|
||||
:title "Curl Noise"
|
||||
:size [res-x res-y]
|
||||
:setup setup
|
||||
:update update-state
|
||||
:draw draw-state
|
||||
:features []
|
||||
:middleware [m/fun-mode]))
|
||||
:middleware [m/fun-mode
|
||||
;;m/pause-on-error
|
||||
]))
|
||||
Loading…
x
Reference in New Issue
Block a user