Compare commits
No commits in common. "5937c7d14f1f36473c8cdf6717cfc7b3a9858b6f" and "1dbde7b1c3e40b9ce094bf7239404407d9877cc2" have entirely different histories.
5937c7d14f
...
1dbde7b1c3
7 changed files with 10 additions and 203 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,8 +1,5 @@
|
|||
/.direnv/
|
||||
/.cpcache/
|
||||
/exports
|
||||
/resources
|
||||
.rebel_readline_history
|
||||
|
||||
# Created by https://www.gitignore.io/api/clojure
|
||||
|
||||
|
|
|
|||
23
deps.edn
23
deps.edn
|
|
@ -1,24 +1,7 @@
|
|||
{#_#_ :mvn/repos {"jogl" {:url "https://jogamp.org/deployment/maven/"}}
|
||||
:deps {#_#_ org.clojure/clojure {:mvn/version "1.11.1"}
|
||||
quil/quil {:mvn/version "4.3.1563"
|
||||
#_#_ :exclusions [org.jogamp.jogl/jogl-all
|
||||
org.jogamp.gluegen/gluegen-rt]}
|
||||
{:deps {#_#_ org.clojure/clojure {:mvn/version "1.11.1"}
|
||||
quil/quil {:mvn/version "4.3.1563"}
|
||||
thi.ng/geom {:mvn/version "1.0.0-RC3"
|
||||
:exclusions [org.jogamp.jogl/jogl-all
|
||||
org.jogamp.gluegen/gluegen-rt]}
|
||||
com.cnuernber/charred {:mvn/version "1.034"}
|
||||
overtone/osc-clj {:mvn/version "0.9.0"}
|
||||
|
||||
;; ;; native display code
|
||||
;; org.jogamp.gluegen/gluegen-rt {:mvn/version "2.5.0"}
|
||||
;; org.jogamp.gluegen/gluegen-rt$natives-macosx-universal {:mvn/version "2.5.0"}
|
||||
;; org.jogamp.gluegen/gluegen-rt$natives-linux-amd64 {:mvn/version "2.5.0"}
|
||||
;; org.jogamp.gluegen/gluegen-rt$natives-linux-aarch64 {:mvn/version "2.5.0"}
|
||||
;; org.jogamp.gluegen/gluegen-rt$natives-windows-amd64 {:mvn/version "2.5.0"}
|
||||
|
||||
;; org.jogamp.jogl/jogl-all {:mvn/version "2.5.0"}
|
||||
;; org.jogamp.jogl/jogl-all$natives-macosx-universal {:mvn/version "2.5.0"}
|
||||
;; org.jogamp.jogl/jogl-all$natives-linux-amd64 {:mvn/version "2.5.0"}
|
||||
;; org.jogamp.jogl/jogl-all$natives-linux-aarch64 {:mvn/version "2.5.0"}
|
||||
;; org.jogamp.jogl/jogl-all$natives-windows-amd64 {:mvn/version "2.5.0"}
|
||||
}}
|
||||
overtone/osc-clj {:mvn/version "0.9.0"}}}
|
||||
|
|
|
|||
6
flake.lock
generated
6
flake.lock
generated
|
|
@ -2,11 +2,11 @@
|
|||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1771432645,
|
||||
"narHash": "sha256-ZqRiU5/c+1+QoeaMJJgpqjwimCSNnIl0AUW4z7Md6Ps=",
|
||||
"lastModified": 1741513245,
|
||||
"narHash": "sha256-7rTAMNTY1xoBwz0h7ZMtEcd8LELk9R5TzBPoHuhNSCk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "02263f46911178e286242786fd6ea1d229583fbb",
|
||||
"rev": "e3e32b642a31e6714ec1b712de8c91a3352ce7e1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
|||
|
|
@ -10,14 +10,13 @@
|
|||
devShells.${system}.default = pkgs.mkShell rec {
|
||||
name = "quil-env";
|
||||
buildInputs = [
|
||||
pkgs.xorg_sys_opengl
|
||||
pkgs.xorg.libXxf86vm
|
||||
pkgs.xwayland
|
||||
pkgs.clojure
|
||||
|
||||
pkgs.libGL
|
||||
pkgs.libxxf86vm
|
||||
# pkgs.jogl
|
||||
];
|
||||
LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}";
|
||||
JAVA_OPTS = "-Dawt.useSystemAAFontSettings=lcd";
|
||||
|
||||
# wayland compat
|
||||
# see https://discourse.ubuntu.com/t/environment-variables-for-wayland-hackers/12750
|
||||
|
|
|
|||
|
|
@ -1,73 +0,0 @@
|
|||
(ns aphorisms.fourty
|
||||
(:require [thi.ng.geom.core :as g]
|
||||
[thi.ng.geom.vector :as v]
|
||||
[quil.core :as q]
|
||||
[quil.middleware :as qm]
|
||||
[thi.ng.geom.rect :as r]
|
||||
[aphorisms.utils.middleware :refer [screenshottable]]
|
||||
))
|
||||
|
||||
;; Getting a feeling for the `thi.ng` API again; mostly playing around with how
|
||||
;; to partition geometries into a grid and how to position things relative to
|
||||
;; each other.
|
||||
|
||||
(def height 500 #_(int (* width (Math/sqrt 2))))
|
||||
(def width #_500 (int (* height (Math/sqrt 2))))
|
||||
(def padding (* height 0.1))
|
||||
(def canvas (r/rect width height))
|
||||
|
||||
(defn center-in
|
||||
"Centers `r2` in or around `r1`."
|
||||
[r1 r2]
|
||||
(g/translate (assoc r2 :p (:p r1))
|
||||
(v/vec2 (* 0.5 (- (g/width r1) (g/width r2)))
|
||||
(* 0.5 (- (g/height r1) (g/height r2))))))
|
||||
|
||||
(def bounds (center-in canvas (r/rect (- width (* 2 padding)) (- height (* 2 padding)))))
|
||||
|
||||
(defn as-grid [rect cell-size]
|
||||
(let [n-x (int (/ (g/width rect) cell-size))
|
||||
n-y (int (/ (g/height rect) cell-size))
|
||||
t (v/vec2 (* (mod (g/width rect) n-x) 0.5)
|
||||
(* (mod (g/height rect) n-x) 0.5))]
|
||||
(for [x (range n-x)
|
||||
y (range n-y)]
|
||||
(-> (r/rect (* x cell-size) (* y cell-size) cell-size)
|
||||
(g/translate (:p rect))
|
||||
(g/translate t )))))
|
||||
|
||||
(def grid (as-grid bounds 20))
|
||||
|
||||
;; below is the rendering logic
|
||||
|
||||
(defn setup []
|
||||
(q/frame-rate 30)
|
||||
(q/color-mode :hsb 360 100 100)
|
||||
(q/rect-mode :center)
|
||||
(q/ellipse-mode :center)
|
||||
(q/background 350)
|
||||
{})
|
||||
|
||||
(defn update-state [state]
|
||||
state)
|
||||
|
||||
(defn draw-state [state]
|
||||
(q/translate -0.5)
|
||||
(q/background 180 0 98)
|
||||
(q/stroke-weight 0.5)
|
||||
(q/no-fill)
|
||||
(q/stroke 320 100 70)
|
||||
(doseq [cell grid
|
||||
:let [[x y] (g/centroid cell)]]
|
||||
(q/ellipse x y 10 10)))
|
||||
|
||||
#_:clj-kondo/ignore
|
||||
(q/defsketch fourty
|
||||
:title "Fourty"
|
||||
:size [width height]
|
||||
:settings #(q/pixel-density (q/display-density))
|
||||
:setup setup
|
||||
:update update-state
|
||||
:draw draw-state
|
||||
:features [:keep-on-top :no-bind-output]
|
||||
:middleware [qm/pause-on-error qm/fun-mode (screenshottable)])
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
(ns aphorisms.fourty-one
|
||||
(:require [thi.ng.geom.core :as g]
|
||||
[thi.ng.geom.vector :as v]
|
||||
[quil.core :as q]
|
||||
[quil.middleware :as qm]
|
||||
[thi.ng.geom.rect :as r]
|
||||
[aphorisms.utils.middleware :refer [screenshottable]]
|
||||
|
||||
[thi.ng.geom.line :as l]
|
||||
[thi.ng.math.core :as m]
|
||||
[thi.ng.geom.utils.intersect :as isec]))
|
||||
|
||||
;; More practice to get a feeling for the `thi.ng` API again
|
||||
;; Resizing cells in the grid, generating random lines and playing with intersections
|
||||
|
||||
(def height 500 #_(int (* width (Math/sqrt 2))))
|
||||
(def width #_500 (int (* height (Math/sqrt 2))))
|
||||
(def padding (* height 0.1))
|
||||
(def canvas (r/rect width height))
|
||||
|
||||
(defn center-in
|
||||
"Centers `r2` in or around `r1`."
|
||||
[r1 r2]
|
||||
(g/translate (assoc r2 :p (:p r1))
|
||||
(v/vec2 (* 0.5 (- (g/width r1) (g/width r2)))
|
||||
(* 0.5 (- (g/height r1) (g/height r2))))))
|
||||
|
||||
(def bounds (center-in canvas (r/rect (- width (* 2 padding)) (- height (* 2 padding)))))
|
||||
|
||||
(defn as-grid [rect cell-size]
|
||||
(let [n-x (int (/ (g/width rect) cell-size))
|
||||
n-y (int (/ (g/height rect) cell-size))
|
||||
t (v/vec2 (* (mod (g/width rect) (* cell-size n-x)) 0.5)
|
||||
(* (mod (g/height rect) (* cell-size n-x)) 0.5))]
|
||||
(for [x (range n-x)
|
||||
y (range n-y)]
|
||||
(-> (r/rect (* x cell-size) (* y cell-size) cell-size)
|
||||
(g/translate (:p rect))
|
||||
(g/translate t )))))
|
||||
|
||||
(def grid (map #(g/scale-size % 0.92) (as-grid bounds 50)))
|
||||
|
||||
(defn line-inside [rect]
|
||||
(l/line2 (g/random-point-inside rect) (g/random-point-inside rect)))
|
||||
|
||||
;; below is the rendering logic
|
||||
|
||||
(defn setup []
|
||||
(q/frame-rate 30)
|
||||
(q/color-mode :hsb 360 100 100)
|
||||
(q/rect-mode :center)
|
||||
(q/ellipse-mode :center)
|
||||
(q/background 350)
|
||||
{:lines (repeatedly 5 #(line-inside bounds))})
|
||||
|
||||
(defn update-state [state]
|
||||
state)
|
||||
|
||||
(defn mouse-pressed [state _]
|
||||
(assoc state :lines (repeatedly 20 #(line-inside bounds))))
|
||||
|
||||
(let [l (l/line2 50 50 200 210)]
|
||||
(g/intersect-line l (first (g/edges (first grid)))))
|
||||
|
||||
(defn draw-state [state]
|
||||
(q/translate -0.5 -0.5)
|
||||
(q/background 180 0 98)
|
||||
(q/stroke-weight 0.5)
|
||||
(q/no-fill)
|
||||
(q/stroke 320 100 70)
|
||||
(doseq [line (:lines state)
|
||||
:let [[a b] (g/vertices line)]]
|
||||
(q/line a b))
|
||||
(doseq [cell grid
|
||||
[a b] (g/edges cell)]
|
||||
(q/line a b))
|
||||
(q/no-stroke)
|
||||
(q/fill 320 100 70)
|
||||
(doseq [cell grid
|
||||
line (:lines state)
|
||||
isecs (->>
|
||||
(map #(g/intersect-line line %) (g/edges cell))
|
||||
(keep #(when (= (:type %) :intersect) (:p %))))
|
||||
:let [[i1 i2] isecs]]
|
||||
(q/ellipse i1 i2 5 5)))
|
||||
|
||||
#_:clj-kondo/ignore
|
||||
(q/defsketch fourty-one
|
||||
:title "Fourty One"
|
||||
:size [width height]
|
||||
:settings (fn []
|
||||
(q/smooth 2)
|
||||
(q/pixel-density (q/display-density)))
|
||||
:setup setup
|
||||
:update #'update-state
|
||||
:mouse-pressed #'mouse-pressed
|
||||
:draw #'draw-state
|
||||
:features [:keep-on-top :no-bind-output]
|
||||
:middleware [qm/pause-on-error qm/fun-mode (screenshottable)])
|
||||
|
|
@ -31,4 +31,4 @@
|
|||
(q/save path)))
|
||||
(when (fn? key-pressed)
|
||||
(key-pressed state ev))
|
||||
state))))))
|
||||
{}))))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue