Created
August 10, 2014 23:54
-
-
Save sander/3ab3d3901b2d2afc5837 to your computer and use it in GitHub Desktop.
p5.js in ClojureScript
This file contains 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
<!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> |
This file contains 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
(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}}]}) |
This file contains 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
; 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