
/g,">").replace(/"/g,""").replace(/'/g,"'")}let s={},c=[];function d(e,n,t){s={...s,dynamic:e,core:n,leinProject:t}}function u(){c=["wh","with-style"]}window.onload=()=>{let{dynamic:n,core:t,leinProject:r}=s;if(n&&(document.getElementById("code-dynamic").innerHTML=i(n)),t&&(document.getElementById("code-core").innerHTML=i(t)),r&&(document.getElementById("code-lein-project").innerHTML=i(r)),c){let e={wh:';; Copyright (c) 2016 Tyler Hobbs\n;; MIT License\n;; https://github.com/thobbs/genartlib/\n(defn h\n "Returns a given percentage of the height Quil-specific."\n ([] (h 1.0))\n ([percentage] (* (height) percentage)))\n\n;; Copyright (c) 2016 Tyler Hobbs\n;; MIT License\n;; https://github.com/thobbs/genartlib/\n(defn w\n "Returns a given percentage of the width. Quil-specific."\n ([] (w 1.0))\n ([percentage] (* (width) percentage)))\n',"with-style":"(defmacro with-style [& body]\n `(do\n (q/push-style)\n (try\n ~@body\n (finally (q/pop-style)))))\n"},n=c.map(n=>e[n]).join("\n");document.getElementById("code-helpers").innerHTML=i(n)}e(l).addPlugin((0,a.number)()),e(l).highlightAll()}}),a("3PmhV",function(e,t){n(e.exports,"number",()=>r);let r=e=>({"after:highlightElement":({el:e,result:n,text:t})=>{let r=n.value.split("\n");r.pop();let l=r.length.toString().length,o=r.map((e,n)=>{let t=(n+1).toString().padStart(l);return`${e}`}).join("\n");e.innerHTML=o}})}),o("d3dEA"),o("7Y8VX");var i=o("dZ8Um");(0,i.make)("(ns sketch.dynamic\n (:import [org.locationtech.jts.geom GeometryFactory Coordinate PrecisionModel]\n [org.locationtech.jts.operation.buffer OffsetCurveBuilder BufferParameters]\n [org.locationtech.jts.simplify DouglasPeuckerSimplifier])\n (:require ; [clojure.java.shell :refer [sh]]\n ; [genartlib.algebra :refer :all]\n ; [genartlib.curves :refer :all]\n ; [genartlib.geometry :refer :all]\n ; [genartlib.random :refer :all]\n ; [kdtree :as kd]\n [clojure.set :refer :all]\n [artlib.quil.global :refer :all]\n [genartlib.util :refer [w h]]\n [quil.core :as q]))\n\n\n(def gf (new GeometryFactory))\n(def ocb (new OffsetCurveBuilder (PrecisionModel.) (BufferParameters.)))\n\n(defrecord LavaBlob [n center radius vel geom])\n(defn make-blob-ring [{[cx cy] :center radius :radius :as blob}]\n (let [steps 50\n tau (* Math/PI 2)\n coordinate-array (->> (range 0 (- tau 1e-5) (/ tau steps))\n (map (fn [theta]\n (let [\n ;;theta (gauss theta 0.01)\n radius (gauss radius 0.00)\n x (+ cx (* radius (Math/cos theta)))\n y (+ cy (* radius (Math/sin theta)))]\n [x y]))) \n (map (fn [[x y]] (Coordinate. x y)))\n cycle\n (take (inc steps))\n into-array) \n geom (.createPolygon gf coordinate-array)]\n (assoc blob :geom geom)))\n\n\n(defn recur-intersect [curr all hop]\n (let [is (filter #(.intersects (:geom curr) (:geom %)) all)]\n (if (seq is)\n (let [next-hop (difference (set all) (set (concat is [curr])))\n new-all (mapcat #(recur-intersect % next-hop (inc hop)) is)]\n (concat [curr] new-all))\n [curr])))\n\n(defn make-blob-tree [f all]\n (let [r (filter #(not= f %) all)\n i (recur-intersect f r 0)\n geoms (->> (concat i [f])\n (map #(:geom %))\n into-array)\n collection (.createGeometryCollection gf geoms)\n new-poly (.union collection)]\n new-poly))\n\n(defn geom->points [geom]\n (let [coords (.getCoordinates geom)\n coords (.getOffsetCurve ocb coords -0.03)\n points (map (fn [coord] [(.getX coord) (.getY coord)]) coords)]\n points))\n\n(defn gen-vel []\n (let [frames 300\n theta (rand (* Math/PI 2))\n xvel (/ (Math/cos theta) 300)\n yvel (/ (Math/sin theta) 300)]\n [xvel yvel]))\n\n(def blobs (atom nil))\n(def default-blobs [(LavaBlob. :a [0.1 0.9] 0.20 (gen-vel) nil)\n (LavaBlob. :b [0.2 0.9] 0.13 (gen-vel) nil)\n (LavaBlob. :c [0.3 0.7] 0.17 (gen-vel) nil)\n (LavaBlob. :d [0.4 0.7] 0.09 (gen-vel) nil)\n (LavaBlob. :e [0.5 0.5] 0.18 (gen-vel) nil)\n (LavaBlob. :e [0.5 0.3] 0.18 (gen-vel) nil)\n (LavaBlob. :e [0.5 0.1] 0.18 (gen-vel) nil)\n (LavaBlob. :f [0.6 0.6] 0.13 (gen-vel) nil)\n (LavaBlob. :g [0.7 0.2] 0.13 (gen-vel) nil)\n (LavaBlob. :h [0.8 0.1] 0.11 (gen-vel) nil)\n (LavaBlob. :i [0.9 0.5] 0.13 (gen-vel) nil)])\n\n(defn blob-physics [{[x y] :center [vx vy] :vel r :radius :as blob}]\n (let [new-x (+ x vx)\n new-y (+ y vy)\n \n new-x (if (> new-x (+ 1 r)) (- r) new-x)\n new-x (if (< new-x (- r)) (+ 1 r) new-x)\n new-y (if (> new-y (+ 1 r)) (- r) new-y)\n new-y (if (< new-y (- r)) (+ 1 r) new-y)\n ]\n (assoc blob :center [new-x new-y])))\n\n(defn draw [state]\n (q/ellipse-mode :radius)\n (q/background 300 10 90)\n\n (when (nil? @blobs) \n (reset! blobs default-blobs))\n\n (reset! blobs (map (fn [b] (->> b \n blob-physics\n make-blob-ring))\n @blobs))\n\n (let [frame (:frame state)\n f (/ frame 300)]\n (dotimes [idx (count @blobs)]\n (with-style\n (q/stroke-weight (w 0.001))\n (q/stroke 0 80 80)\n (let [new-poly (make-blob-tree (nth @blobs idx) @blobs)\n mult (min (* 0.02 (+ 0.5 (* 0.5 (Math/cos (+ (* idx 5)\n (* f Math/PI 4)))))) 0.3)\n new-poly (DouglasPeuckerSimplifier/simplify new-poly mult) \n new-poly (geom->points new-poly)\n new-poly (take (count new-poly) (drop (rand-int 3) (cycle new-poly)))\n ]\n (dotimes [n 5]\n (q/begin-shape)\n (doseq [[x y] new-poly]\n (q/vertex (w (gauss x 0.003)) (h (gauss y 0.002))))\n (q/end-shape :close)))))))\n",'(ns sketch.core\n (:require [artlib.quil.middleware :refer [animation-mode]]\n [clojure.core.matrix :refer [set-current-implementation]]\n [quil.middleware :as qm]\n [sketch.dynamic :as dynamic]\n [quil.core :as q]))\n\n(set-current-implementation :vectorz)\n(println)\n\n(q/defsketch example\n :title "genuary-2024-12"\n :setup (fn [] {})\n :draw dynamic/draw\n :update identity\n :size [1080 1080]\n :animation {:render? true :dirname "1"}\n :middleware [qm/fun-mode animation-mode])\n\n','(defproject genuary-2024-12 "0.1.0-SNAPSHOT"\n :description "FIXME: write description"\n :url "https://example.com/FIXME"\n :license {:name "Apache License, Version 2.0"\n :url "https://www.apache.org/licenses/LICENSE-2.0.html"}\n :dependencies [[org.clojure/clojure "1.11.1"]\n\n [org.locationtech.jts/jts-core "1.16.1"]\n\n [com.dedovic/artlib-core "0.0.10"]\n [genartlib/genartlib "1.0.0"]] ; utility functions\n :jvm-opts ["-Xms4000m" "-Xmx4000M" ; 4GB heap size\n "-server"\n "-Dsun.java2d.uiScale=1.0"] ; adjust scaling for high DPI displays\n :source-paths ["src/clj"]\n :java-source-paths ["src/java"]\n :resource-paths ["resources"])\n'),(0,i.withDefaultHelpers)();
dynamic.clj
core.clj
helpers
project.clj