I've been having some fun recently making visual art with Clojure and Quil, especially animated GIFs. In the course of doing this, I've come into contact with many GIFs made by other artist-programmers, some of which have included source code. I'm republishing one of them, called rainbow kiss,
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
;; this function is included in modern emacs, but here it is in case you haven't upgraded | |
(defun count-words (start end) | |
"Count words between START and END. | |
If called interactively, START and END are normally the start and | |
end of the buffer; but if the region is active, START and END are | |
the start and end of the region. Print a message reporting the | |
number of lines, words, and chars. | |
If called from Lisp, return the number of words between START and |
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
(defn hex-to-rgb [hex] | |
(map (comp #(Integer/parseInt % 16) (partial apply str)) | |
(partition 2 (.replace hex "#" "")))) | |
(def palette [(hex-to-rgb "#FF1E35") | |
(hex-to-rgb "#F9F33B") | |
(hex-to-rgb "#3B3EF9") | |
(hex-to-rgb "#E54ED8") | |
(hex-to-rgb "#84E54E")]) |
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
(defn setup [] | |
(frame-rate 4) | |
(no-fill) | |
(stroke 0 0 0 128) | |
(smooth)) | |
(def rotor (atom 0)) | |
(defn draw [] | |
(frame-rate 30) |
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
(defn setup [] | |
(smooth) | |
(no-fill)) | |
(defn superformula-point [m n1 n2 n3 phi] | |
(let [t1 (pow (abs (cos (/ (* m phi) 4.0))) n2) | |
t2 (pow (abs (sin (/ (* m phi) 4.0))) n3) | |
r (pow (+ t1 t2) (/ 1 n1))] | |
(if (= 0 (abs r)) | |
[0 0] |
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
(def palette [(hex-to-rgb "#e0e0e0") | |
(hex-to-rgb "#B6B081") | |
(hex-to-rgb "#CAA13C") | |
(hex-to-rgb "#AB5008") | |
(hex-to-rgb "#2E524E")]) | |
(defn setup [] | |
(frame-rate 4) | |
(no-fill) | |
(smooth)) |
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 overtone-playground.heart-murmur | |
(:use overtone.core | |
overtone.inst.sampled-piano | |
overtone.samples.piano)) | |
;; (boot-server) | |
;; (sampled-piano) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Reproducible randomness |
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
;;; cider-eval-sexp-fu.el --- Tiny functionality enhancements for evaluating sexps. | |
;; Copyright (C) 2009 Takeshi Banse <[email protected]> | |
;; Author: Takeshi Banse <[email protected]> | |
;; Modified to add cider support by Sam Aaron <[email protected]> | |
;; Keywords: lisp, highlight, convenience | |
;; Package-Requires: ((highlight "0.0.0") (smartparens "0.0.0") (thingatpt "0.0.0") | |
;; This program is free software; you can redistribute it and/or modify |
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
(def rhyme-txt | |
(map #(string/split % #"[ ]+") (string/split-lines (slurp "cmudict.txt")))) | |
(def word-to-rhyme | |
(reduce (fn [m [word & rhyme]] | |
(assoc m | |
(string/lower-case word) | |
(mapv #(keyword (string/replace %1 #"[0-9]" "")) (reverse rhyme)))) | |
{} rhyme-txt)) |
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
(def parent {:x1 0 :y1 0 :x2 600 :y2 400}) | |
(def rs [{:x1 0 :y1 0 :x2 300 :y2 200 } | |
{:x1 0 :y1 200 :x2 300 :y2 400 }]) | |
(defn negative-space [parent rs] | |
(let [x (apply max (map :x2 rs)) | |
y (apply min (map :y1 (filter (comp (partial = x) :x2) rs)))] | |
{:x1 x :y1 y :x2 (parent :x2) :y2 (parent :y2)})) | |
(negative-space parent rs) |