Initial commit w/ rudimentary visualization
This commit is contained in:
commit
9abd736f13
5 changed files with 162 additions and 0 deletions
13
.envrc
Normal file
13
.envrc
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
if type lorri &>/dev/null; then
|
||||||
|
echo "direnv: using lorri from PATH ($(type -p lorri))"
|
||||||
|
eval "$(lorri direnv)"
|
||||||
|
else
|
||||||
|
# fall back to using direnv's builtin nix support
|
||||||
|
# to prevent bootstrapping problems.
|
||||||
|
use nix
|
||||||
|
fi
|
||||||
|
|
||||||
|
# source an additional user-specific .envrc in ./.envrc-local
|
||||||
|
if [ -e .envrc-local ]; then
|
||||||
|
source .envrc-local
|
||||||
|
fi
|
||||||
73
.gitignore
vendored
Normal file
73
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/clojure,emacs
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=clojure,emacs
|
||||||
|
|
||||||
|
### Clojure ###
|
||||||
|
pom.xml
|
||||||
|
pom.xml.asc
|
||||||
|
*.jar
|
||||||
|
*.class
|
||||||
|
/lib/
|
||||||
|
/classes/
|
||||||
|
/target/
|
||||||
|
/checkouts/
|
||||||
|
.lein-deps-sum
|
||||||
|
.lein-repl-history
|
||||||
|
.lein-plugins/
|
||||||
|
.lein-failures
|
||||||
|
.nrepl-port
|
||||||
|
.cpcache/
|
||||||
|
|
||||||
|
### Emacs ###
|
||||||
|
# -*- mode: gitignore; -*-
|
||||||
|
*~
|
||||||
|
\#*\#
|
||||||
|
/.emacs.desktop
|
||||||
|
/.emacs.desktop.lock
|
||||||
|
*.elc
|
||||||
|
auto-save-list
|
||||||
|
tramp
|
||||||
|
.\#*
|
||||||
|
|
||||||
|
# Org-mode
|
||||||
|
.org-id-locations
|
||||||
|
*_archive
|
||||||
|
ltximg/**
|
||||||
|
|
||||||
|
# flymake-mode
|
||||||
|
*_flymake.*
|
||||||
|
|
||||||
|
# eshell files
|
||||||
|
/eshell/history
|
||||||
|
/eshell/lastdir
|
||||||
|
|
||||||
|
# elpa packages
|
||||||
|
/elpa/
|
||||||
|
|
||||||
|
# reftex files
|
||||||
|
*.rel
|
||||||
|
|
||||||
|
# AUCTeX auto folder
|
||||||
|
/auto/
|
||||||
|
|
||||||
|
# cask packages
|
||||||
|
.cask/
|
||||||
|
dist/
|
||||||
|
|
||||||
|
# Flycheck
|
||||||
|
flycheck_*.el
|
||||||
|
|
||||||
|
# server auth directory
|
||||||
|
/server/
|
||||||
|
|
||||||
|
# projectiles files
|
||||||
|
.projectile
|
||||||
|
|
||||||
|
# directory configuration
|
||||||
|
.dir-locals.el
|
||||||
|
|
||||||
|
# network security
|
||||||
|
/network-security.data
|
||||||
|
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/clojure,emacs
|
||||||
7
deps.edn
Normal file
7
deps.edn
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{:deps {org.clojure/clojure {:mvn/version "1.10.0"}
|
||||||
|
cheshire/cheshire {:mvn/version "5.1.0"}
|
||||||
|
camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.2"}
|
||||||
|
quil/quil {:mvn/version "3.1.0"}
|
||||||
|
thi.ng/geom {:mvn/version "1.0.0-RC3"
|
||||||
|
:exclusions [org.jogamp.jogl/jogl-all
|
||||||
|
org.jogamp.gluegen/gluegen-rt]}}}
|
||||||
8
shell.nix
Normal file
8
shell.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
with import <nixpkgs> { };
|
||||||
|
mkShell rec {
|
||||||
|
name = "quil-env";
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
xorg_sys_opengl
|
||||||
|
];
|
||||||
|
LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}";
|
||||||
|
}
|
||||||
61
src/heyarne/all_my_friends/core.cljc
Normal file
61
src/heyarne/all_my_friends/core.cljc
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
(ns heyarne.all-my-friends.core
|
||||||
|
(:require [quil.core :as q]
|
||||||
|
[quil.middlewares.pause-on-error :refer [pause-on-error]]
|
||||||
|
[camel-snake-kebab.core :refer [->kebab-case]]
|
||||||
|
[cheshire.core :as json]
|
||||||
|
[thi.ng.geom.vector :as v]
|
||||||
|
[thi.ng.geom.core :as g]
|
||||||
|
[thi.ng.math.core :as m]
|
||||||
|
[clojure.java.io :as io]
|
||||||
|
[clojure.string :as str]))
|
||||||
|
|
||||||
|
;; TODO All PNGs are missing an extension
|
||||||
|
(def uploads
|
||||||
|
#?(:clj (->>
|
||||||
|
(map bean (file-seq (io/file "../uploads")))
|
||||||
|
(filter :file)
|
||||||
|
(remove :hidden)
|
||||||
|
(sort-by :name)
|
||||||
|
(partition-by #(first (str/split (:name %) #"\."))))
|
||||||
|
:cljs [])) ;; TODO
|
||||||
|
|
||||||
|
(def key-fn (comp keyword ->kebab-case))
|
||||||
|
|
||||||
|
(defn parse-most-recent [uploads]
|
||||||
|
(when-let [most-recent (last uploads)]
|
||||||
|
(let [[_image computational-gaze] most-recent]
|
||||||
|
#?(:clj
|
||||||
|
(with-open [rdr (io/reader (:path computational-gaze))]
|
||||||
|
(json/parse-stream rdr key-fn))
|
||||||
|
:cljs nil)))) ;; TODO
|
||||||
|
|
||||||
|
(def most-recent (parse-most-recent uploads))
|
||||||
|
|
||||||
|
;; "most-recent" now contains a seq of all faces detected in the most recently
|
||||||
|
;; uploaded picture
|
||||||
|
|
||||||
|
(defn setup []
|
||||||
|
(q/frame-rate 60)
|
||||||
|
(q/color-mode :hsb))
|
||||||
|
|
||||||
|
(defn draw []
|
||||||
|
(q/clear)
|
||||||
|
(q/background 40 80 255)
|
||||||
|
(q/stroke 240 100 255)
|
||||||
|
(q/stroke-weight 1)
|
||||||
|
(q/no-fill)
|
||||||
|
|
||||||
|
(doseq [face most-recent
|
||||||
|
:let [mesh (:mesh face)]]
|
||||||
|
(doseq [[[x1 y1 z1] pt2] (partition 2 mesh)]
|
||||||
|
(q/line x1 y1 (+ (q/random -2 2) x1) (+ (q/random -2 2) y1))
|
||||||
|
#_(apply q/line pt1 pt2))))
|
||||||
|
|
||||||
|
#_:clj-kondo/ignore
|
||||||
|
(q/defsketch all-my-friends
|
||||||
|
:title "These are all my friends"
|
||||||
|
:settings #(q/smooth 2)
|
||||||
|
:middleware [pause-on-error]
|
||||||
|
:setup setup
|
||||||
|
:draw draw
|
||||||
|
:size [500 500])
|
||||||
Loading…
Add table
Add a link
Reference in a new issue