 (ns quil.snippet
   (:require [quil.core :as q]
             [quil.snippets.all-snippets :as as]
-            [clojure.edn :as edn]
             [clojure.java.io :as io]
             [clojure.test :as t]
             [clojure.java.shell :as sh]

  ;; see https://imagemagick.org/script/compare.php
  (let [{:keys [err]} (sh/sh "compare" "-metric" "mae" expected actual difference)
        result        (second (re-find #"\((.*)\)" err))]
    (edn/read-string result)))

(defn- replace-suffix [file-name suffix]
  (string/replace file-name #"(\w+)\.(\w+)$" (str suffix ".$2")))

               "save"
               "time-and-date"} snippet-name))

(defn- imagemagick-installed? []
  (try
    (sh/sh "compare" "-version")
    true
    (catch java.io.IOException e false)))

(defn- compare-images
  "Compares images at file paths `expected` and `actual` and produces another
  image at path `difference` which highlights any differences in the images.
