Skip to content

Instantly share code, notes, and snippets.

@rm-hull
rm-hull / BIG-BANG-RPS.md
Last active August 29, 2015 13:55
A Rock-Paper-Scissors game in ClojureScript, using core.async and big-bang.

Rock Paper Scissors

A familiar game implemented using Big-Bang, a ClojureScript library inspired by Racket's big-bang. It abstracts the GUI event-loop into a component based system, allowing self-contained big-bang 'worlds' to communicate over core.async channels, in a reactive CSP style.

In this example, the main file builds some DOM elements and fetches various SVG assets for inclusion on the page. Then, three big-bang components are initialized:

@rm-hull
rm-hull / PARAMETRIC-EQUATIONS.md
Last active August 29, 2015 13:55
An animated render of a parametric equation in ClojureScript with big-bang. A curve is swept out where the trajectory of a point is usually represented by a parametric equation with the time as parameter.

Parametric Equations

Using:

x

y

Where t increases monotonically, and k can be varied with the slider below, the (x,y) co-ordinates sweep out the curve of a distressed Cardioid. When k = 0.5 the curve sweeps out a perfect Cardioid.

@rm-hull
rm-hull / chess.cljs
Last active August 29, 2015 13:56
OM version of Garry Kasparov - Veselin Topalov ; Hoogovens A Tournament Wijk aan Zee NED 1999.01.20 - adapted from https://raw2.github.com/danieroux/rubyfuza2014/master/src/rubyfuza/core.cljs
; Adapted from https://raw2.github.com/danieroux/rubyfuza2014/master/src/rubyfuza/core.cljs
(ns rubyfuza.core
(:require-macros
[cljs.core.async.macros :refer [go]])
(:require
[clojure.string :as str]
[om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[cljs.core.async :as async :refer [put! chan <! >! timeout]]))
@rm-hull
rm-hull / polyhedra.cljs
Last active August 29, 2015 13:56
Explore a variety of polyhedric solids: ClojureScript demo using big-bang for orchestration between GUI components, and the wireframes library for 3D rendering. The polygon data files are derived from http://www.netlib.org/polyhedra/, and read using abstractions over XmlHttpRequests and core.async. NOTE: Some of the shape files do not have prope…
(ns polyhedra.examples.demo
(:refer-clojure :exclude [identity])
(:require-macros
[cljs.core.async.macros :refer [go]]
[dommy.macros :refer [sel1 node]])
(:require
[clojure.string :refer [split-lines]]
[cljs.core.async :refer [chan <! >!]]
[dommy.core :refer [insert-after!]]
[enchilada :refer [ctx canvas canvas-size proxy-request]]
@rm-hull
rm-hull / PHOTOSPHERE.md
Last active August 29, 2015 13:57
Mapping panoramic photos (taken with a Nexus 4) onto the inside of a sphere, using PhiloGL and mouse gestures orchestrated (badly) with ClojureScript - the rotation in the Y plane is currently not working as it should...

WebGL & Clojurescript

Ensure that you have a WebGL-capable browser to view this gist

@rm-hull
rm-hull / solar-system.cljs
Last active August 29, 2015 13:57
An example in orbiting bodies in ClojureScript with big-bang, inspired by a 'Translation and Rotation in 2D and 3D' tutorial by David Meredith, Aalborg University
(ns big-bang.examples.solar-system
(:require
[big-bang.core :refer [big-bang]]
[big-bang.components :refer [dropdown slider color-picker]]
[enchilada :refer [ctx canvas canvas-size proxy-request]]
[monet.canvas :refer [circle fill fill-style stroke-style stroke
clear-rect save restore translate rotate]]
[jayq.core :refer [show]]))
(def width (first (canvas-size)))
@rm-hull
rm-hull / mandelbrot.cljs
Last active August 29, 2015 14:04
Mandlebrot & Julia fractal generator, based on clojure code originally described in http://webrot.destructuring-bind.org/mandlebrot. Click the left mouse button to zoom in, and the right button to zoom out. _Recently updated to progressively render the image for better initial performance._ TODO - make use of web-workers to improve render perfor…
(ns webrot.fractal
(:require-macros
[cljs.core.async.macros :refer [go]]
[dommy.macros :refer [sel1 node]])
(:require
[clojure.string :as str]
[cljs.core.async :refer [chan <! >!]]
[dommy.core :refer [insert-after!]]
[jayq.core :refer [$ hide show]]
[big-bang.core :refer [big-bang]]
@rm-hull
rm-hull / barnsley-fern.cljs
Last active August 29, 2015 14:04
The Barnsley Fern is a fractal named after the British mathematician Michael Barnsley who first described it in his book _Fractals Everywhere_. The fern is one of the basic examples of self-similar sets, i.e. it is a mathematically generated pattern that can be reproducible at any magnification or reduction. Like the Sierpinski triangle, the Bar…
(ns big-bang.examples.barnsley-fern
(:require
[jayq.core :refer [show]]
[big-bang.core :refer [big-bang]]
[enchilada :refer [ctx canvas canvas-size]]
[monet.canvas :refer [fill-rect fill-style]]))
(def width (first (canvas-size)))
(def height (second (canvas-size)))
(def scale (/ height 10))
@rm-hull
rm-hull / cellular-automata.cljs
Last active August 29, 2015 14:04
Cellular automata - randomly picks one of: Conways Life, Semi-vote, Vichniac vote (stable & unstable) or Fredkin. Renders using _big-bang_ onto a canvas element, but could probably be written more efficiently using _core.async_ more intelligently.
(ns cellular-automata.core
(:require-macros
[cljs.core.async.macros :refer [go]]
[dommy.macros :refer [sel1 node]])
(:require
[cljs.core.async :refer [chan <! >!]]
[dommy.core :refer [insert-after!]]
[jayq.core :refer [$ hide show]]
[big-bang.core :refer [big-bang]]
[big-bang.components :refer [dropdown slider]]
@rm-hull
rm-hull / recursive-trees.cljs
Last active August 29, 2015 14:05
A recursively generated tree is simply _a branch with a tree on the end of it_.
(ns big-bang.demo.recursive-trees
(:require-macros
[cljs.core.async.macros :refer [go]]
[dommy.macros :refer [sel1 node]])
(:require
[cljs.core.async :refer [chan <! >!]]
[dommy.core :refer [insert-after!]]
[jayq.core :refer [$ hide show]]
[big-bang.core :refer [big-bang]]
[big-bang.components :refer [dropdown slider]]