
/g,">").replace(/"/g,""").replace(/'/g,"'")}let o={},s=[];function g(e,n,t){o={...o,dynamic:e,core:n,leinProject:t}}function m(){s=["wh","with-style"]}window.onload=()=>{let{dynamic:n,core:t,leinProject:r}=o;if(n&&(document.getElementById("code-dynamic").innerHTML=c(n)),t&&(document.getElementById("code-core").innerHTML=c(t)),r&&(document.getElementById("code-lein-project").innerHTML=c(r)),s){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=s.map(n=>e[n]).join("\n");document.getElementById("code-helpers").innerHTML=c(n)}e(i).addPlugin((0,l.number)()),e(i).highlightAll()}}),l("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 i=r.length.toString().length,a=r.map((e,n)=>{let t=(n+1).toString().padStart(i);return`${e}`}).join("\n");e.innerHTML=a}})}),a("d3dEA"),a("7Y8VX");var c=a("dZ8Um");(0,c.make)("(ns sketch.dynamic\n (:import\n [java.awt Color])\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 [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;; https://github.com/northern-bites/tool/blob/master/TOOL/Image/YCbCrColorSpace.java\n(defn rgb->ycbcr [r g b]\n (let [y (+ 16 (bit-shift-right (int (+ (* r 65.738) (* g 129.057) (* b 25.064))) 8))\n cb (+ 128 (bit-shift-right (int (+ (* r -37.945) (* g -74.49) (* b 112.439))) 8))\n cr (+ 128 (bit-shift-right (int (+ (* r 112.439) (* g -97.154) (* b -18.28))) 9))]\n [y cb cr]))\n\n;; https://github.com/northern-bites/tool/blob/master/TOOL/Image/YCbCrColorSpace.java\n(defn ycbcr->rgb [y cb cr]\n (let [y (- y 16)\n cb (- cb 128)\n cr (- cr 128)\n r (int (* 256 (+ (* y 0.00456621) (* cr 0.00625893))))\n g (int (* 256 (+ (* y 0.00456621) (* cb -0.00153632) (* cr -0.00318811))))\n b (int (* 256 (+ (* y 0.00456621) (* cb 0.0079107))))]\n [r g b]))\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\n(defn draw [state]\n (if (nil? @img)\n (let [new-img (load-image-sync \"bird.jpg\")] \n (q/resize new-img 0 (h))\n (reset! img new-img)))\n\n (q/background 0 0 100)\n\n (let [frame (:frame state)\n f (/ frame 300)\n gr (q/create-graphics (w 1) (h 1))\n im (q/create-image (w 1) (h 1) :rgb)]\n\n (q/with-graphics gr\n (q/color-mode :hsb 360 100 100 1.0)\n (with-style\n (q/stroke 0 0 0)\n (q/fill (* f 360) 30 70)\n\n (q/rect (w 0.1) (h 0.1) (w 0.8) (h 0.8))))\n \n ;; convert to Y'CbCr color space\n (doseq [x (range 0 (w))]\n (doseq [y (range 0 (h))]\n (let [x (int x)\n y (int y)\n [r g b] (->components (q/get-pixel @img x y))\n [yp cb cr] (rgb->ycbcr r g b)\n new-px (->composite yp cb cr)]\n (q/set-pixel im x y new-px))))\n\n ;; x:2:0 subsampling\n (let [f2 (+ 1 (Math/sin (* f Math/PI 2)))\n f3 (+ 1 (Math/sin (* f Math/PI 2)))\n size (int (+ 1 (* 50 f)))]\n (doseq [x (range 0 (w) size)] \n (doseq [y (range 0 (h) size)]\n (let [x (int x)\n y (int y)\n [_ cb cr] (->components (q/get-pixel im x y))]\n (doseq [x2 (range x (+ x size))]\n (doseq [y2 (range y (+ y size))]\n (let [scale (* f 25)\n\n n (q/noise (* 0.01 f2) (* 0.01 x2))\n n (int (- (* n 2 scale) scale))\n n (q/lerp 0 n f)\n y2 (+ y2 n)\n\n n (q/noise (* 0.01 f3) (* 0.01 y2))\n n (int (- (* n 2 scale) scale))\n n (q/lerp 0 n f)\n x2 (+ x2 n)\n\n [yp2] (->components (q/get-pixel im x2 y2))\n new-px (->composite yp2 cr cb)]\n (q/set-pixel im x2 y2 new-px))))))))\n\n ;; convert to Y'CbCr color space\n (doseq [x (range 0 (w))]\n (doseq [y (range 0 (h))]\n (let [x (int x)\n y (int y)\n [yp cb cr] (->components (q/get-pixel im x y))\n [r g b] (ycbcr->rgb yp cb cr)\n new-px (->composite r g b)]\n (q/set-pixel im x y new-px))))\n\n (q/image gr 0 0)\n (q/image im (w 0) (h 0))\n ))\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-04"\n :setup (fn [] {})\n :draw dynamic/draw\n :update identity\n :size [720 720]\n :animation {:render? true :dirname "2"}\n :middleware [qm/fun-mode animation-mode])\n\n','(defproject genuary-2024-04 "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 :aot :all)\n'),(0,c.withDefaultHelpers)();
dynamic.clj
core.clj
helpers
project.clj