Skip to content

Instantly share code, notes, and snippets.

@sander sander/index.html
Created Aug 10, 2014

Embed
What would you like to do?
p5.js in ClojureScript
<!doctype html>
<style>body { padding: 0; }</style>
<script src='https://cdn.jsdelivr.net/p5.js/0.3.2/p5.min.js'></script>
<script src='out/goog/base.js'></script>
<script src='myproject.js'></script>
<script>goog.require('myproject.core')</script>
(defproject publisher "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/clojurescript "0.0-2280"]]
:plugins [[lein-cljsbuild "1.0.4-SNAPSHOT"]]
:source-paths ["src"]
:cljsbuild {
:builds [{:id "myproject"
:source-paths ["src"]
:compiler {
:output-to "myproject.js"
:output-dir "out"
:optimizations :none
:source-map true}}]})
; src/myproject/sketch.cljs
(ns myproject.sketch)
(defn setup []
(js/createCanvas 640 480))
(defn draw []
(js/fill (if js/mouseIsPressed 0 255))
(js/ellipse js/mouseX js/mouseY 80 80))
(doto js/window
(aset "setup" setup)
(aset "draw" draw))
; For live reloading in e.g. LightTable, evaluate the defn and the doto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.