<commit_before>(ns goya.canvasdrawing)


;; =============================================================================
;; Blitting routines. Javascript interop is so easy!


(defn draw-image-to-canvas [pixels canvas width height zoom-factor]
  (let [context (.getContext canvas "2d")
        screen-canvas-width (* width zoom-factor)
        screen-canvas-height (* height zoom-factor)
        pixel-size zoom-factor
        pixel-count (count pixels)]
    (set! (.-width canvas) screen-canvas-width)
    (set! (.-height canvas) screen-canvas-height)
    (set! (.-fillStyle context) "#ff0000")
    (.fillRect context 0 0 screen-canvas-width screen-canvas-height)
    (doseq [x (range 0 pixel-count)]
      (let [pix-x (* (mod x width) pixel-size)
            pix-y (* (quot x height) pixel-size)
            color (nth pixels x)]
        (set! (.-fillStyle context) color)
        (.fillRect context pix-x pix-y pixel-size pixel-size)))))


(defn draw-pixel-grid [canvas width height zoom-factor]
  (let [context (.getContext canvas "2d")
        screen-canvas-width (* width zoom-factor)<commit_msg>don't use doseq while blitting<commit_after>(ns goya.canvasdrawing)


;; =============================================================================
;; Blitting routines. Javascript interop is so easy!


(defn draw-image-to-canvas [pixels canvas width height zoom-factor]
  (let [context (.getContext canvas "2d")
        screen-canvas-width (* width zoom-factor)
        screen-canvas-height (* height zoom-factor)
        pixel-size zoom-factor
        pixel-count (count pixels)]
    (set! (.-width canvas) screen-canvas-width)
    (set! (.-height canvas) screen-canvas-height)
    (set! (.-fillStyle context) "#ff0000")
    (.fillRect context 0 0 screen-canvas-width screen-canvas-height)
    (dotimes [x pixel-count]
      (let [pix-x (* (mod x width) pixel-size)
            pix-y (* (quot x height) pixel-size)
            color (nth pixels x)]
        (set! (.-fillStyle context) color)
        (.fillRect context pix-x pix-y pixel-size pixel-size)))))


(defn draw-pixel-grid [canvas width height zoom-factor]
  (let [context (.getContext canvas "2d")
        screen-canvas-width (* width zoom-factor)
{'fraction_non_alphanumeric': 0.1963882618510158, 'fraction_numerical': 0.007674943566591422, 'mean_word_length': 3.1266294227188083, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3808976', 'n_tokens_mistral': 674, 'n_tokens_neox': 629, 'n_words': 189}