<commit_before>(ns paint.extra.gui
  (gen-class)
  (:require [quil.core :as quil]
            [paint.core :as paint]
            [paint.brush :as brush]))


(def substrate-state (atom {}))
(def brush-state (atom [{:width 3 :height 3
                         :fn (brush/block [0 0 0])}
                        {:width 3 :height 3
                         :fn (brush/block [255 0 0])}
                        {:width 3 :height 3
                         :fn (brush/block [0 255 0])}
                        {:width 3 :height 3
                         :fn (brush/block [0 0 255])}]))
(def selected-brush (atom 0))


(defn engine [substrate-state]
  ;; width and height invariant throughout the life time of the painting
  (let [{max-i :width max-j :height} @substrate-state]
    (println "Starting engine...")
    (doseq [[i j] (repeatedly #(vector (rand-int max-i)
                                       (rand-int max-j)))]
      (swap! substrate-state paint/engine-cycle i j))))


(defn setup []
  (comment (.start (Thread. (partial engine substrate-state)))))


(defn memoized-color []
  (let [mem (atom {})]
    (fn [{color :color paint-color :paint-color}]
      (let [[r g b] (if (nil? paint-color) color paint-color)
            int-val (bit-or (bit-shift-left r 0)
                            (bit-shift-left g 8)
                            (bit-shift-left b 16))]
        (if-let [e (find @mem int-val)]
          (val e)
          (let [ret (quil/color r g b)]
            (swap! mem assoc int-val ret)<commit_msg>Make the brushes bigger<commit_after>(ns paint.extra.gui
  (gen-class)
  (:require [quil.core :as quil]
            [paint.core :as paint]
            [paint.brush :as brush]))


(def substrate-state (atom {}))
(def brush-state (atom [{:width 10 :height 10
                         :fn (brush/block [0 0 0])}
                        {:width 10 :height 10
                         :fn (brush/block [255 0 0])}
                        {:width 10 :height 10
                         :fn (brush/block [0 255 0])}
                        {:width 10 :height 10
                         :fn (brush/block [0 0 255])}]))
(def selected-brush (atom 0))


(defn engine [substrate-state]
  ;; width and height invariant throughout the life time of the painting
  (let [{max-i :width max-j :height} @substrate-state]
    (println "Starting engine...")
    (doseq [[i j] (repeatedly #(vector (rand-int max-i)
                                       (rand-int max-j)))]
      (swap! substrate-state paint/engine-cycle i j))))


(defn setup []
  (comment (.start (Thread. (partial engine substrate-state)))))


(defn memoized-color []
  (let [mem (atom {})]
    (fn [{color :color paint-color :paint-color}]
      (let [[r g b] (if (nil? paint-color) color paint-color)
            int-val (bit-or (bit-shift-left r 0)
                            (bit-shift-left g 8)
                            (bit-shift-left b 16))]
        (if-let [e (find @mem int-val)]
          (val e)
          (let [ret (quil/color r g b)]
            (swap! mem assoc int-val ret)
{'fraction_non_alphanumeric': 0.1422976501305483, 'fraction_numerical': 0.022845953002610966, 'mean_word_length': 1.5886824324324325, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7451927', 'n_tokens_mistral': 1045, 'n_tokens_neox': 930, 'n_words': 306}