<commit_before>(ns fractals-clojurescript.core
  (:use-macros [fractals-clojurescript.macros :only [forloop << >> local]]))

(enable-console-print!)

; TODO: allow changing of this dynamically..
(def app-state (atom {:max-iterations 100
                      :escape-radius  10000
                      :dimensions {:x0 -3   :x1 1
                                   :y0 -1.5 :y1 1.5}}))

(def canvas (.getElementById js/document "app"))

(aset canvas "width"(.-innerWidth js/window))
(aset canvas "height"(.-innerHeight js/window))


(def width (.-width canvas))
(def height (.-height canvas))

(def context (.getContext canvas "2d"))

(def idata (.createImageData context width height))
(def data (.-data idata))


(defn smoothed-count
  [iterations final-modulus]
  (- iterations
     (/
      (Math/log (Math/log (Math/sqrt final-modulus)))
      (Math/log 2.0))))

(defn iteration-count
  "Gets us a continous analogue of the classic discrete iteration count"
  [escape-radius-squared max-iterations initial-z]
  (let [mod-z             (local)
        real              (local)
        imaginary         (local)
        iterations        (local)

        initial-real      (first initial-z)
        initial-imaginary (second initial-z)]
<commit_msg>Minor: comment explaining smoothing<commit_after>(ns fractals-clojurescript.core
  (:use-macros [fractals-clojurescript.macros :only [forloop << >> local]]))

(enable-console-print!)

; TODO: allow changing of this dynamically..
(def app-state (atom {:max-iterations 100
                      :escape-radius  10000
                      :dimensions {:x0 -3   :x1 1
                                   :y0 -1.5 :y1 1.5}}))

(def canvas (.getElementById js/document "app"))

(aset canvas "width"(.-innerWidth js/window))
(aset canvas "height"(.-innerHeight js/window))


(def width (.-width canvas))
(def height (.-height canvas))

(def context (.getContext canvas "2d"))

(def idata (.createImageData context width height))
(def data (.-data idata))


(defn smoothed-count
  "Smooth the iterations to a continuous value
  (a la http://linas.org/art-gallery/escape/escape.html)"
  [iterations final-modulus]
  (- iterations
     (/
      (Math/log (Math/log (Math/sqrt final-modulus)))
      (Math/log 2.0))))

(defn iteration-count
  "Gets us a continous analogue of the classic discrete iteration count"
  [escape-radius-squared max-iterations initial-z]
  (let [mod-z             (local)
        real              (local)
        imaginary         (local)
        iterations        (local)

        initial-real      (first initial-z)
        initial-imaginary (second initial-z)]

{'fraction_non_alphanumeric': 0.13055028462998103, 'fraction_numerical': 0.015939278937381403, 'mean_word_length': 2.4145077720207255, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '120397', 'n_tokens_mistral': 854, 'n_tokens_neox': 788, 'n_words': 229}