                          "random-3d"
                          "random"
                          "random-gaussian"
+                         "resize-sketch"
                          "time-and-date"} name)
-    (let [n (str "snippet-snapshots/" name)
-          _ (q/save (str "resources/" n "-actual.png"))
-          e (slurp (io/resource (str n "-expected.png")))
-          a (slurp (io/resource (str n "-actual.png")))
-          c (compare e a)]
-      (when (zero? c)
-        (clojure.java.io/delete-file (io/resource (str n "-actual.png"))))
-      (t/is (zero? c)))))
+    (let [n          (str "snippet-snapshots/" name)
+          _          (q/save (str "resources/" n "-actual.png"))
+          expected   (.getAbsolutePath (io/file (io/resource (str n "-expected.png"))))
+          actual     (replace-suffix expected "actual")
+          difference (replace-suffix expected "difference")
+          result     (compare-images expected actual difference)
+          threshold  0.02]
+      (when (<= result threshold)
+        (io/delete-file (io/file actual))
+        (io/delete-file (io/file difference)))
+      (t/is (<= result threshold)))))
 
 (defn run-snippet-as-test [{:keys [ns name opts setup body body-str mouse-clicked]}]
   (let [result (promise)

(def tests-in-set 50)
(def current-test (atom -1))

(defn assert-unchanged-snippet-output [name]
  (when-not (contains? #{"current-frame-rate-target-frame-rate"
                         "noise"

(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]
            [clojure.string :as string]
            clojure.pprint))

(def default-size [500 500])
