Skip to content

Instantly share code, notes, and snippets.

@rm-hull
rm-hull / hilbert-curve.cljs
Last active August 29, 2015 14:06
A Hilbert space-filling curve is a fractal first discovered by German mathematician David Hilbert in 1891. It is commonly used in mapping applications because they give a mapping between 1D and 2D space that fairly well preserves locality. Michelle Brush gave an excellent talk at Strangeloop 2014 entitled _Practical Fractals in Space_ (https://w…
(ns enchilada.hilbert-curve
(:require
[big-bang.core :refer [big-bang]]
[big-bang.events.browser :refer [offset-coords]]
[jayq.core :refer [show attr css]]
[enchilada :refer [ctx canvas]]
[inkspot.color-chart :as color-chart]
[monet.canvas :refer [begin-path move-to line-to
fill-rect fill-style
clear-rect stroke stroke-style stroke-width
@rm-hull
rm-hull / bézier-numbers.cljs
Last active August 29, 2015 14:06
A subtle variation of Jack Frigaard's _Bézier Clock_ implemented in ClojureScript. Rather than just rendering the current time, this separates the value generation from interpolating the Bézier control points that go up to make the digits using communicating sequential processes, as supplied by _Big-bang_ and _core.async_ channels. The generator…
(ns enchilada.bezier-numbers
(:require
[jayq.core :refer [show]]
[cljs.core.async :as async]
[dommy.core :refer [insert-after! set-attr! show!]]
[big-bang.core :refer [big-bang]]
[big-bang.components :refer [dropdown]]
[enchilada :refer [canvas ctx canvas-size value-of]]
[enchilada.bezier-numbers.lerp :as lerp]
[enchilada.bezier-numbers.generator :as gen])
@rm-hull
rm-hull / interpolator.cljs
Created September 20, 2014 23:43
A polyline interpolator, implemented in a CSP style: two _big-bang_'s interact - the 'generator' sends pairs of polylines to an 'interpolator' which is responsible for smooth rendering the transitions between the _from_ and _to_ states. The code here will form the basis of future gists: (i) to visualise solving the travelling salesman problem (u…
(ns big-bang.examples.interpolator
(:require
[cljs.core.async :as async]
[enchilada :refer [canvas ctx canvas-size]]
[big-bang.core :refer [big-bang]]
[big-bang.package :refer [make-package]]
[jayq.core :refer [show]]
[monet.canvas :refer [clear-rect fill-style fill fill-rect circle
stroke-style stroke-width stroke-join stroke
begin-path move-to line-to]]))
@rm-hull
rm-hull / unknown-pleasures.cljs
Last active October 10, 2017 06:27
PSR B1919+21 is a pulsar with a period of 1.3373 seconds, and a pulse width of 0.04 second. It was the first radio pulsar discovered (on November 28, 1967 by Jocelyn Bell Burnell and Antony Hewish). The power and regularity of the signals was thought to resemble a beacon, so for a time the source was nicknamed "LGM-1" (for "Little Green Men"). A…
(ns big-bang.examples.unknown-pleasures
(:require
[jayq.core :refer [show]]
[enchilada :refer [ctx canvas canvas-size value-of]]
[big-bang.examples.unknown-pleasures.data :refer [data-points]]
[monet.canvas :refer [begin-path move-to line-to close-path
fill fill-rect fill-style
stroke-join stroke-cap stroke-width stroke-style stroke
translate scale save restore]]))
@rm-hull
rm-hull / SUTCLIFFE-PENTAGON.md
Last active August 29, 2015 14:06
If you draw a pentagon, then plot the midpoints of each of its five sides and extend a line perpendicular to each of these points, you can connect the end of these lines to make another pentagon. In doing this, the remaining area of the shape also ends up being subdivided into further pentagons, meaning that within each pentagon are six subpenta…

Matt Peason, author of Generative Art say in his book (ch.8):

In 2008 I went to a meeting of the Computer Arts Society (CAS) in London, an organization that was (remarkably, for a body devoted to computing) celebrating its fortieth anniversary with that event. There, I heard a short talk by the society’s initiator and first chairman, the artist and mathematician Alan Sutcliffe. Through this talk, he introduced me to a marvellous shape, which I have since mentally dubbed the Sutcliffe Pentagon.

To be clear, I’ve spoken to Alan about this, and he isn’t entirely over the

@rm-hull
rm-hull / nks1.cljs
Last active August 29, 2015 14:06
Stephen Wolfram announced a class of a one-dimensional binary cellular automaton rules in 1983 and published further analysis in his 2002 book _A New Kind of Science_. The most famous instance is "Rule 30": a Class III rule, displaying aperiodic, chaotic behaviour. This rule is of particular interest because it produces complex, seemingly random…
(ns big-bang.examples.nks1
(:require
[jayq.core :refer [show]]
[inkspot.color-chart :as cc]
[big-bang.core :refer [big-bang]]
[enchilada :refer [ctx canvas canvas-size value-of]]
[monet.canvas :refer [clear-rect fill-rect fill-style draw-image]]
[dommy.core :refer [insert-after! set-text!]])
(:require-macros
[dommy.macros :refer [sel1 node]]))
@rm-hull
rm-hull / collatz-orbit.cljs
Last active August 29, 2015 14:06
A force-directed graph (using _arbor.js_) showing the orbits of small numbers under the Collatz map. Lothar Collatz first proposed the following conjecture in 1937: Take any natural number $n$. If $n$ is even, divide it by 2 to get $n / 2$. If $n$ is odd, multiply it by 3 and add 1 to obtain $3n + 1$. Repeat the process indefinitely. The conject…
(ns arbor-demo.collatz-orbit
(:require
[arbor :as arbor]
[jayq.core :refer [show]]
[enchilada :refer [ctx canvas value-of]]
[monet.canvas :refer [begin-path move-to line-to save translate rotate restore
fill-style fill fill-rect circle text text-align text-baseline
stroke-style stroke-width stroke]]))
(defn draw-edge! [edge pt1 pt2]
@rm-hull
rm-hull / 10-print.cljs
Last active August 29, 2015 14:06
_10 PRINT_ is a book about a one-line Commodore 64 BASIC program, published in November 2012. To paraphrase from http://10print.org/ _"... a single line of code—the extremely concise BASIC program for the Commodore 64 inscribed in the title—and uses it as a lens through which to consider the phenomenon of creative computing and the way computer…
; 10 PRINT CHR$(205.5+RND(1)); : GOTO 10
(ns big-bang.examples.ten-print
(:require
[jayq.core :refer [show]]
[inkspot.color-chart :as cc]
[big-bang.core :refer [big-bang]]
[big-bang.events.browser :refer [client-coords]]
[enchilada :refer [ctx canvas canvas-size value-of]]
[monet.canvas :refer [begin-path move-to line-to
@rm-hull
rm-hull / radiant-and-simple.cljs
Last active August 29, 2015 14:06
A clojurescript implementation of http://www.openprocessing.org/sketch/137835 (originally by Ramiz Midani using _processing.js_). Used to test missing arc and ellipse methods from monet.
(ns big-bang.examples.radiant-simple
(:require
[cljs.core.async :as async]
[dommy.core :refer [insert-after!]]
[jayq.core :refer [show]]
[big-bang.core :refer [big-bang]]
[big-bang.components :refer [slider]]
[enchilada :refer [ctx canvas canvas-size value-of]]
[monet.canvas :refer [translate rotate scale save restore
stroke-width stroke-style stroke