Inspired by Tyler Hobbs post about his setup for Quil, I started working on an own setup for a simple workflow.

…and here is, what I’ve come up with so far:



https://github.com/jaminalder/staticart

Requirements / Ideas:

Quick update of the, otherwise static image after a code change

Respect the DRY principle (don’t repeat yourself), structure code in logically grouped, reusable junks

Minimal changes needed to scale image

Support various sketches without code duplication

Abstract from the Quil Processing wrapper so I might be able to switch to an other graphics lib later

Make good use of emacs and it’s excellent Clojure support with cider and paredit

…

This is, what my workbench looks like right now. Full screen emacs with an always on top processing canvas at the side:

emacs with quil sketch

After a change in the draw function or any other function, F8 is evaluating the current defn and redraws the sketch.

The core file just contains the setup function and the defsketch macro call. To switch the sketch, I just have to update the :require block:

(ns staticart.core (:require [quil.core :as q] [quil.middleware :as mid] [staticart.settings :refer [settings]] [staticart.sketch-1 :as sketch])) (defn setup [] (q/no-loop) (q/smooth) (q/color-mode :hsb 360 100 100 1.0)) (q/defsketch staticart :title "My Quil Sketch" :features [:no-bind-output] :size [(:width settings) (:height settings)] :setup setup :draw sketch/draw :features [:keep-on-top] :middleware [mid/pause-on-error] )

I have added two elisp functions, one to eval current defn and redraw and one to fully restart the cider repl, which also loads the canvas (e.g. for when you change the size or something else gets out of sync):

init-quil.el (defun quil-eval-defn-and-redraw () "Evaluates the current defun and redraws the static quil sketch" (interactive) (cider-eval-defun-at-point) (cider-interactive-eval "(.redraw staticart.core/staticart) nil nil nil")) (defun cider-full-restart () "quits and jacks in cider" (interactive) (cider-quit) (cider-jack-in-clj nil)) (global-set-key (kbd "<f8>") 'quil-eval-defn-and-redraw) (global-set-key (kbd "<f9>") 'cider-full-restart) (provide 'init-quil)

…to be improved