Created
February 22, 2016 01:22
-
-
Save harold/8866e07526e427d67b11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns hackathon.core | |
(:require [mikera.image.core :as i])) | |
(defn get-img | |
[] | |
(i/load-image-resource "galaxy.jpg")) | |
(defn get-?-block | |
[] | |
(i/sub-image (get-img) (* 16 16) (* 16 9) 16 16)) | |
(defn get-gap | |
[] | |
(int (Math/floor (+ 32 (* 32 (rand)))))) | |
(defn sort-img-row | |
[img i] | |
(let [w (i/width img)] | |
(loop [x 0 | |
gap (get-gap)] | |
(let [pixels (i/get-pixels (i/sub-image img x i gap 1)) | |
sorted-pixels (sort pixels)] | |
(doseq [n (range gap)] | |
(i/set-pixel img (+ x n) i (nth sorted-pixels n)))) | |
(if (< (+ x gap) w) | |
(recur (+ x gap) (min (- w (+ x gap)) (get-gap))))))) | |
(defn go | |
[] | |
(let [img (get-img) | |
h (range (i/height img))] | |
(doseq [i h] | |
(println (str i "/" (i/height img))) | |
(sort-img-row img i) | |
) | |
(i/show img))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment