Skip to content

Instantly share code, notes, and snippets.

@triss
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save triss/1a83c8f130f0003a337c to your computer and use it in GitHub Desktop.
Save triss/1a83c8f130f0003a337c to your computer and use it in GitHub Desktop.
(ns pictures.core
(:use mikera.image.colours)
(:use mikera.image.core)
(:use mikera.image.filters)
(:use mikera.image.spectrum)
(:require [clojure.java.io :refer [resource]]))
(def width 1280)
(def height 600)
(def image (new-image width height))
(def pixels (get-pixels image))
(defn abssin [x] (Math/abs (Math/sin (* Math/PI 3 x))))
(defn pic [x y]
(let [v (abssin (* x y))]
(rgb (/ x 2) (abssin (* y v 2)) v)))
(dotimes [i (* width height)]
(let [x (/ (mod i width) width)
y (/ (/ i width) height)]
(aset pixels i (pic x y))))
(set-pixels image pixels)
(show image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment