
/g,">").replace(/"/g,""").replace(/'/g,"'")}let l={},c=[];function d(e,n,t){l={...l,dynamic:e,core:n,leinProject:t}}function p(){c=["wh","with-style"]}window.onload=()=>{let{dynamic:n,core:t,leinProject:r}=l;if(n&&(document.getElementById("code-dynamic").innerHTML=o(n)),t&&(document.getElementById("code-core").innerHTML=o(t)),r&&(document.getElementById("code-lein-project").innerHTML=o(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=o(n)}e(s).addPlugin((0,a.number)()),e(s).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 s=r.length.toString().length,i=r.map((e,n)=>{let t=(n+1).toString().padStart(s);return`${e}`}).join("\n");e.innerHTML=i}})}),i("d3dEA"),i("7Y8VX");var o=i("dZ8Um");(0,o.make)('(ns sketch.dynamic\n (:import [org.locationtech.jts.geom GeometryFactory Coordinate]\n [org.locationtech.jts.algorithm RobustLineIntersector])\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 [artlib.quil.global :refer :all]\n [genartlib.util :refer [w h]]\n [quil.core :as q]))\n\n(def gf (new GeometryFactory))\n(def tau (* Math/PI 2))\n\n(defn ngon [n [cx cy] r]\n (for [theta (range 0 tau (/ tau n))]\n [(+ cx (* r (Math/cos theta)))\n (+ cy (* r (Math/sin theta)))]))\n\n(defn gamma [n t]\n [(Math/cos (/ (* tau t) n))\n (Math/sin (/ (* tau t) n))])\n\n(defn cut-segment-by-segment \n "Cuts the line segment defined by points [p1 p2] using \n the line segment defined by poinst [p3 p4]. Returns a \n list of line segments."\n [[p1 p2] [p3 p4]]\n (let [intersector (RobustLineIntersector.)\n [x1 y1] p1\n [x2 y2] p2\n [x3 y3] p3\n [x4 y4] p4\n c1 (Coordinate. x1 y1)\n c2 (Coordinate. x2 y2)\n c3 (Coordinate. x3 y3)\n c4 (Coordinate. x4 y4)]\n (.computeIntersection intersector c1 c2 c3 c4)\n (if-not (.isProper intersector)\n [[p1 p2]]\n (let [cn (.getIntersection intersector 0)\n xn (.getX cn)\n yn (.getY cn)\n pn [xn yn]]\n [[p1 pn] [pn p2]]))))\n\n(defn cut-segment-by-collection\n "Cuts the line segment seg, defined by Coordinates [p1 p2], \n using the collection of line segments col. Returns a list \n of line segments."\n [seg col]\n (if (and (seq col) (seq seg))\n (let [cut-by (first col)\n new-segments (cut-segment-by-segment seg cut-by)\n cut-next (rest col)]\n (mapcat #(cut-segment-by-collection % cut-next) new-segments))\n [seg]))\n\n(defn nstar [n d s [cx cy] r]\n (let [g (partial gamma n)\n segments (->> (range n)\n (map (fn [i] [(gamma n i) (gamma n (+ i d))]))\n (map (fn [[[x1 y1] [x2 y2]]]\n [[(+ cx (* x1 r)) \n (+ cy (* y1 r))] \n [(+ cx (* x2 r))\n (+ cy (* y2 r))]])))\n splits (->> segments\n (mapcat (fn [seg] \n (let [others (filter #(not= seg %) segments) \n splits (cut-segment-by-collection seg others)\n head (take s splits)\n tail (take-last s splits)\n splits (concat head tail)]\n splits))))]\n splits))\n\n(defn round-to [f n]\n (/ (Math/floor (* n f)) f))\n\n(def round (partial round-to 10))\n\n(defn tri [t]\n (+ 1 (* (/ -2 Math/PI)\n (- Math/PI (abs (- (mod t (* Math/PI 2)) Math/PI))))))\n\n(defn draw [state]\n (q/background 0 0 100)\n\n (let [frame (:frame state)\n f (/ frame 300)\n rows 5\n step (/ 1 rows)\n r (* step 1/2)\n\n n 8\n d (+ 2 (* 1 (tri (* f tau))))\n s 2 #_(+ 2 (* 2 (tri (* f tau 1/2))))]\n\n (q/stroke-weight (w 0.005))\n (q/stroke-cap :square)\n (doseq [[idx x] (map-indexed vector (range (/ step 2) (+ 1 1e-5) step))]\n (doseq [y (range (/ step 2) (+ 1 1e-5) step)]\n (let [s (+ s (if (even? idx) 1 0))]\n (with-style\n (q/stroke 0 0 0)\n (q/begin-shape :lines)\n (doseq [[x y] (apply concat (nstar n d s [x y] r))]\n (q/vertex (w x) (h y)))\n (q/end-shape)))))))\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-17"\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-17 "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 [org.locationtech.jts/jts-core "1.16.1"]\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