
/g,">").replace(/"/g,""").replace(/'/g,"'")}let s={},c=[];function d(e,n,t){s={...s,dynamic:e,core:n,leinProject:t}}function m(){c=["wh","with-style"]}window.onload=()=>{let{dynamic:n,core:t,leinProject:i}=s;if(n&&(document.getElementById("code-dynamic").innerHTML=o(n)),t&&(document.getElementById("code-core").innerHTML=o(t)),i&&(document.getElementById("code-lein-project").innerHTML=o(i)),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=o(n)}e(r).addPlugin((0,l.number)()),e(r).highlightAll()}}),l("3PmhV",function(e,t){n(e.exports,"number",()=>i);let i=e=>({"after:highlightElement":({el:e,result:n,text:t})=>{let i=n.value.split("\n");i.pop();let r=i.length.toString().length,a=i.map((e,n)=>{let t=(n+1).toString().padStart(r);return`${e}`}).join("\n");e.innerHTML=a}})}),a("d3dEA"),a("7Y8VX");var o=a("dZ8Um");(0,o.make)('(ns sketch.dynamic\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.string :as string]\n [clojure.core.matrix :as mat]\n [clojure.java.io :refer [resource]]\n [genartlib.quil-util :refer [load-image-sync]]\n [artlib.quil.global :refer :all]\n [genartlib.util :refer [w h]]\n [quil.core :as q]))\n\n(defn cart \n "Cartesian product of colls."\n [colls]\n (if (empty? colls)\n \'(())\n (for [more (cart (rest colls))\n x (first colls)]\n (cons x more))))\n\n(defn ->components [x]\n (let [a (bit-and (bit-shift-right x 16) 0xFF)\n b (bit-and (bit-shift-right x 8) 0xFF)\n c (bit-and (bit-shift-right x 0) 0xFF)]\n [a b c]))\n\n(defn ->composite [a b c] \n (bit-or a (bit-shift-left b 8) (bit-shift-left c 16)))\n\n(def img (atom nil))\n(def font (atom nil))\n(defn draw [state]\n (when (nil? @font)\n (let [f (q/create-font "Unifont" 64 true)]\n (q/text-font f))\n (reset! font true))\n\n (when (nil? @img)\n (let [new-img (load-image-sync "bird.jpg")\n region 0.02\n region (int (Math/round (w region)))]\n (q/resize new-img 0 (h))\n (let [pixels (q/pixels new-img)\n width (.width new-img)\n height (.height new-img)\n num-pixels (count pixels)\n greyscale (map (fn [y-idx]\n (map (fn [x-idx]\n (let [x-idxs (range x-idx (+ region x-idx))\n y-idxs (range y-idx (+ region y-idx))\n indices (->> (cart [x-idxs y-idxs])\n (map (fn [[x y]] (+ x (* y width))))\n (filter #(< % num-pixels)))\n num-indices (count indices)\n pixels (->> indices\n (map #(aget pixels %))\n (map #(->components %))\n (reduce (fn [acc [r g b]] (+ acc r g b)) 0))\n avg (if (zero? num-indices) 0 (/ pixels num-indices))\n norm (/ avg 255 3)]\n norm))\n (range 0 width region)))\n (range 0 height region))]\n (reset! img greyscale))))\n\n (let [frame (:frame state)\n f (/ frame 300)]\n (q/background 0 0 0)\n (q/fill 0 0 100)\n (q/text-size (w 0.023))\n (q/text-align :center :center)\n (let [size (count @img)\n size (int (* size (+ 1.5 (* (Math/cos (* f Math/PI 2)) 0.2))))\n all (->> (range 38 100)\n (map char)\n (map str))\n possible (take \n 10 \n (drop \n (* 150 f #_(q/noise (* 2 (Math/sin (* f Math/PI 2))))) \n (cycle all)))\n text (->> @img\n flatten\n (map #(nth possible (* % (count possible))))\n (partition size)\n (map #(concat % ["\\n"]))\n (drop 25)\n flatten\n (apply str))]\n (q/text text (w 0.5) (h 0.5)))))\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-09"\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-09 "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 [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,o.withDefaultHelpers)();
dynamic.clj
core.clj
helpers
project.clj