├── .gitignore ├── 01-pressure-draw └── cljs_draw │ ├── LinearStroke.js │ ├── RadialStroke.js │ ├── core.cljs │ ├── radial.png │ └── util.cljs ├── README.md ├── build ├── build.clj ├── index.html ├── localforage.nopromises.js ├── main.js ├── out ├── cljs │ ├── core.cljs │ ├── core.js │ ├── core.js.map │ ├── core │ │ ├── async.cljs │ │ ├── async.cljs.cache.edn │ │ ├── async.js │ │ ├── async.js.map │ │ └── async │ │ │ └── impl │ │ │ ├── buffers.cljs │ │ │ ├── buffers.cljs.cache.edn │ │ │ ├── buffers.js │ │ │ ├── buffers.js.map │ │ │ ├── channels.cljs │ │ │ ├── channels.cljs.cache.edn │ │ │ ├── channels.js │ │ │ ├── channels.js.map │ │ │ ├── dispatch.cljs │ │ │ ├── dispatch.cljs.cache.edn │ │ │ ├── dispatch.js │ │ │ ├── dispatch.js.map │ │ │ ├── ioc_helpers.cljs │ │ │ ├── ioc_helpers.cljs.cache.edn │ │ │ ├── ioc_helpers.js │ │ │ ├── ioc_helpers.js.map │ │ │ ├── protocols.cljs │ │ │ ├── protocols.cljs.cache.edn │ │ │ ├── protocols.js │ │ │ ├── protocols.js.map │ │ │ ├── timers.cljs │ │ │ ├── timers.cljs.cache.edn │ │ │ ├── timers.js │ │ │ └── timers.js.map │ ├── pprint.cljs │ ├── pprint.cljs.cache.edn │ ├── pprint.js │ ├── pprint.js.map │ ├── repl.cljs │ ├── repl.cljs.cache.edn │ ├── repl.js │ └── repl.js.map ├── cljs_deps.js ├── cljs_draw │ ├── core.cljs │ ├── core.cljs.cache.edn │ ├── core.js │ ├── core.js.map │ ├── util.cljs │ ├── util.cljs.cache.edn │ ├── util.js │ └── util.js.map ├── clojure │ ├── browser │ │ ├── event.cljs │ │ ├── event.cljs.cache.edn │ │ ├── event.js │ │ ├── event.js.map │ │ ├── net.cljs │ │ ├── net.cljs.cache.edn │ │ ├── net.js │ │ ├── net.js.map │ │ ├── repl.cljs │ │ ├── repl.cljs.cache.edn │ │ ├── repl.js │ │ └── repl.js.map │ ├── core │ │ ├── reducers.cljs │ │ ├── reducers.cljs.cache.edn │ │ ├── reducers.js │ │ ├── reducers.js.map │ │ ├── rrb_vector.cljs │ │ ├── rrb_vector.cljs.cache.edn │ │ ├── rrb_vector.js │ │ ├── rrb_vector.js.map │ │ └── rrb_vector │ │ │ ├── interop.cljs │ │ │ ├── interop.cljs.cache.edn │ │ │ ├── interop.js │ │ │ ├── interop.js.map │ │ │ ├── nodes.cljs │ │ │ ├── nodes.cljs.cache.edn │ │ │ ├── nodes.js │ │ │ ├── nodes.js.map │ │ │ ├── protocols.cljs │ │ │ ├── protocols.cljs.cache.edn │ │ │ ├── protocols.js │ │ │ ├── protocols.js.map │ │ │ ├── rrbt.cljs │ │ │ ├── rrbt.cljs.cache.edn │ │ │ ├── rrbt.js │ │ │ ├── rrbt.js.map │ │ │ ├── transients.cljs │ │ │ ├── transients.cljs.cache.edn │ │ │ ├── transients.js │ │ │ ├── transients.js.map │ │ │ ├── trees.cljs │ │ │ ├── trees.cljs.cache.edn │ │ │ ├── trees.js │ │ │ └── trees.js.map │ ├── set.cljs │ ├── set.cljs.cache.edn │ ├── set.js │ ├── set.js.map │ ├── string.cljs │ ├── string.cljs.cache.edn │ ├── string.js │ ├── string.js.map │ ├── walk.cljs │ ├── walk.cljs.cache.edn │ ├── walk.js │ └── walk.js.map ├── fipp │ ├── deque.cljc │ ├── deque.cljc.cache.edn │ ├── deque.js │ ├── deque.js.map │ ├── engine.cljc │ ├── engine.cljc.cache.edn │ ├── engine.js │ └── engine.js.map ├── frontend.js ├── gamma │ ├── api.cljs │ ├── api.cljs.cache.edn │ ├── api.js │ ├── api.js.map │ ├── ast.cljs │ ├── ast.cljs.cache.edn │ ├── ast.js │ ├── ast.js.map │ ├── compiler │ │ ├── bubble_term.cljs │ │ ├── bubble_term.cljs.cache.edn │ │ ├── bubble_term.js │ │ ├── bubble_term.js.map │ │ ├── common.cljs │ │ ├── common.cljs.cache.edn │ │ ├── common.js │ │ ├── common.js.map │ │ ├── core.cljs │ │ ├── core.cljs.cache.edn │ │ ├── core.js │ │ ├── core.js.map │ │ ├── flatten_ast.cljs │ │ ├── flatten_ast.cljs.cache.edn │ │ ├── flatten_ast.js │ │ ├── flatten_ast.js.map │ │ ├── insert_assignments.cljs │ │ ├── insert_assignments.cljs.cache.edn │ │ ├── insert_assignments.js │ │ ├── insert_assignments.js.map │ │ ├── insert_variables.cljs │ │ ├── insert_variables.cljs.cache.edn │ │ ├── insert_variables.js │ │ ├── insert_variables.js.map │ │ ├── lift_assignments.cljs │ │ ├── lift_assignments.cljs.cache.edn │ │ ├── lift_assignments.js │ │ ├── lift_assignments.js.map │ │ ├── move_assignments.cljs │ │ ├── move_assignments.cljs.cache.edn │ │ ├── move_assignments.js │ │ ├── move_assignments.js.map │ │ ├── separate_usages.cljs │ │ ├── separate_usages.cljs.cache.edn │ │ ├── separate_usages.js │ │ └── separate_usages.js.map │ ├── emit │ │ ├── construct.cljs │ │ ├── construct.cljs.cache.edn │ │ ├── construct.js │ │ ├── construct.js.map │ │ ├── emit.cljs │ │ ├── emit.cljs.cache.edn │ │ ├── emit.js │ │ ├── emit.js.map │ │ ├── fun.cljs │ │ ├── fun.cljs.cache.edn │ │ ├── fun.js │ │ ├── fun.js.map │ │ ├── operator.cljs │ │ ├── operator.cljs.cache.edn │ │ ├── operator.js │ │ ├── operator.js.map │ │ ├── statement.cljs │ │ ├── statement.cljs.cache.edn │ │ ├── statement.js │ │ ├── statement.js.map │ │ ├── tag.cljs │ │ ├── tag.cljs.cache.edn │ │ ├── tag.js │ │ └── tag.js.map │ ├── program.cljs │ ├── program.cljs.cache.edn │ ├── program.js │ └── program.js.map ├── gamma_driver │ ├── api.cljs │ ├── api.cljs.cache.edn │ ├── api.js │ ├── api.js.map │ ├── drivers │ │ ├── basic.cljs │ │ ├── basic.cljs.cache.edn │ │ ├── basic.js │ │ └── basic.js.map │ ├── impl │ │ ├── bind.cljs │ │ ├── bind.cljs.cache.edn │ │ ├── bind.js │ │ ├── bind.js.map │ │ ├── context.cljs │ │ ├── context.cljs.cache.edn │ │ ├── context.js │ │ ├── context.js.map │ │ ├── draw.cljs │ │ ├── draw.cljs.cache.edn │ │ ├── draw.js │ │ ├── draw.js.map │ │ ├── resource.cljs │ │ ├── resource.cljs.cache.edn │ │ ├── resource.js │ │ ├── resource.js.map │ │ ├── variable.cljs │ │ ├── variable.cljs.cache.edn │ │ ├── variable.js │ │ └── variable.js.map │ ├── protocols.cljs │ ├── protocols.cljs.cache.edn │ ├── protocols.js │ └── protocols.js.map ├── goog │ ├── array │ │ └── array.js │ ├── asserts │ │ └── asserts.js │ ├── async │ │ ├── delay.js │ │ ├── freelist.js │ │ ├── nexttick.js │ │ ├── run.js │ │ └── workqueue.js │ ├── base.js │ ├── color │ │ ├── color.js │ │ └── names.js │ ├── debug │ │ ├── debug.js │ │ ├── entrypointregistry.js │ │ ├── error.js │ │ ├── logbuffer.js │ │ ├── logger.js │ │ └── logrecord.js │ ├── deps.js │ ├── disposable │ │ ├── disposable.js │ │ └── idisposable.js │ ├── dom │ │ ├── browserfeature.js │ │ ├── dom.js │ │ ├── nodetype.js │ │ ├── safe.js │ │ ├── tagname.js │ │ └── tags.js │ ├── events │ │ ├── browserevent.js │ │ ├── browserfeature.js │ │ ├── event.js │ │ ├── eventhandler.js │ │ ├── eventid.js │ │ ├── events.js │ │ ├── eventtarget.js │ │ ├── eventtype.js │ │ ├── listenable.js │ │ ├── listener.js │ │ └── listenermap.js │ ├── fs │ │ └── url.js │ ├── functions │ │ └── functions.js │ ├── html │ │ ├── safehtml.js │ │ ├── safescript.js │ │ ├── safestyle.js │ │ ├── safestylesheet.js │ │ ├── safeurl.js │ │ ├── trustedresourceurl.js │ │ └── uncheckedconversions.js │ ├── i18n │ │ └── bidi.js │ ├── iter │ │ └── iter.js │ ├── json │ │ └── json.js │ ├── labs │ │ └── useragent │ │ │ ├── browser.js │ │ │ ├── engine.js │ │ │ ├── platform.js │ │ │ └── util.js │ ├── log │ │ └── log.js │ ├── math │ │ ├── coordinate.js │ │ ├── math.js │ │ └── size.js │ ├── messaging │ │ ├── abstractchannel.js │ │ └── messagechannel.js │ ├── mochikit │ │ └── async │ │ │ └── deferred.js │ ├── net │ │ ├── errorcode.js │ │ ├── eventtype.js │ │ ├── httpstatus.js │ │ ├── websocket.js │ │ ├── wrapperxmlhttpfactory.js │ │ ├── xhrio.js │ │ ├── xhrlike.js │ │ ├── xmlhttp.js │ │ ├── xmlhttpfactory.js │ │ └── xpc │ │ │ ├── crosspagechannel.js │ │ │ ├── crosspagechannelrole.js │ │ │ ├── directtransport.js │ │ │ ├── frameelementmethodtransport.js │ │ │ ├── iframepollingtransport.js │ │ │ ├── iframerelaytransport.js │ │ │ ├── nativemessagingtransport.js │ │ │ ├── nixtransport.js │ │ │ ├── transport.js │ │ │ └── xpc.js │ ├── object │ │ └── object.js │ ├── promise │ │ ├── promise.js │ │ ├── resolver.js │ │ └── thenable.js │ ├── reflect │ │ └── reflect.js │ ├── string │ │ ├── const.js │ │ ├── string.js │ │ ├── stringbuffer.js │ │ └── typedstring.js │ ├── structs │ │ ├── collection.js │ │ ├── map.js │ │ ├── set.js │ │ └── structs.js │ ├── testing │ │ └── watchers.js │ ├── timer │ │ └── timer.js │ ├── ui │ │ └── idgenerator.js │ ├── uri │ │ ├── uri.js │ │ └── utils.js │ ├── useragent │ │ ├── product.js │ │ └── useragent.js │ └── webgl │ │ └── webgl.js ├── main.js ├── om │ ├── core.cljs │ ├── core.cljs.cache.edn │ ├── core.js │ ├── core.js.map │ ├── dom.cljs │ ├── dom.cljs.cache.edn │ ├── dom.js │ └── dom.js.map ├── react.inc.js ├── thi │ └── ng │ │ ├── common │ │ ├── data │ │ │ ├── core.cljs │ │ │ ├── core.cljs.cache.edn │ │ │ ├── core.js │ │ │ └── core.js.map │ │ ├── error.cljs │ │ ├── error.cljs.cache.edn │ │ ├── error.js │ │ ├── error.js.map │ │ └── math │ │ │ ├── core.cljs │ │ │ ├── core.cljs.cache.edn │ │ │ ├── core.js │ │ │ └── core.js.map │ │ ├── geom │ │ ├── core.cljs │ │ ├── core.cljs.cache.edn │ │ ├── core.js │ │ ├── core.js.map │ │ └── core │ │ │ ├── matrix.cljs │ │ │ ├── matrix.cljs.cache.edn │ │ │ ├── matrix.js │ │ │ ├── matrix.js.map │ │ │ ├── utils.cljs │ │ │ ├── utils.cljs.cache.edn │ │ │ ├── utils.js │ │ │ ├── utils.js.map │ │ │ ├── vector.cljs │ │ │ ├── vector.cljs.cache.edn │ │ │ ├── vector.js │ │ │ └── vector.js.map │ │ └── math │ │ ├── core.cljc │ │ ├── core.cljc.cache.edn │ │ ├── core.js │ │ └── core.js.map └── watch.log ├── project.clj ├── style.css └── target └── stale └── extract-native.dependencies /.gitignore: -------------------------------------------------------------------------------- 1 | .repl* 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /01-pressure-draw/cljs_draw/LinearStroke.js: -------------------------------------------------------------------------------- 1 | // This is ugly, hacked-together-quickly code 2 | 3 | function LinearStroke(color, brush) { 4 | this._vertices = new Float32Array(200); 5 | this._values = new Float32Array(200); 6 | this._numVertices = 0; 7 | this._color = color && goog.color.hexToRgb(color).map(function(x) { return x / 255; }); 8 | this._rawColor = color; 9 | this._brush = brush; 10 | } 11 | 12 | LinearStroke.prototype.addVertex = function(x, y, value) { 13 | this._vertices = this._maybeResize(this._vertices, 14 | (this._numVertices * 2) + 2); 15 | this._values = this._maybeResize(this._values, 16 | this._numVertices + 1); 17 | 18 | var ptr = this._numVertices * 2; 19 | this._vertices[ptr] = x; 20 | this._vertices[ptr + 1] = y; 21 | 22 | ptr = this._numVertices; 23 | this._values[ptr] = value; 24 | 25 | this._numVertices++; 26 | }; 27 | 28 | LinearStroke.prototype._maybeResize = function(vec, count) { 29 | if(vec.length < count) { 30 | var next = new Float32Array(vec.length + 31 | (count < 1000 ? 1000 : count)); 32 | next.set(vec); 33 | return next; 34 | } 35 | return vec; 36 | }; 37 | 38 | LinearStroke.prototype.setCurrentPos = function(x1, y1, x2, y2) { 39 | this._currentPos = [x1, y1, x2, y2]; 40 | } 41 | 42 | LinearStroke.prototype.getCurrentPos = function() { 43 | return this._currentPos; 44 | }; 45 | 46 | LinearStroke.prototype.getValues = function() { 47 | return this._values; 48 | } 49 | 50 | // Generic mesh methods 51 | 52 | LinearStroke.prototype.getNumVertices = function() { 53 | return this._numVertices; 54 | } 55 | 56 | LinearStroke.prototype.setNumVertices = function(num) { 57 | this._numVertices = num; 58 | } 59 | 60 | LinearStroke.prototype.getVertices = function() { 61 | return this._vertices; 62 | }; 63 | 64 | LinearStroke.prototype.getColor = function() { 65 | return this._color; 66 | }; 67 | 68 | LinearStroke.prototype.getBrush = function() { 69 | return this._brush; 70 | }; 71 | 72 | LinearStroke.prototype.isColor = function(color) { 73 | return this._rawColor === color; 74 | }; 75 | 76 | LinearStroke.prototype.serialize = function() { 77 | return ["linear", this._vertices, this._values, this._numVertices, 78 | this._color, this._rawColor, this._brush]; 79 | } 80 | 81 | LinearStroke.unserialize = function(data) { 82 | var mesh = new LinearStroke(); 83 | mesh._vertices = data[1]; 84 | mesh._values = data[2]; 85 | mesh._numVertices = data[3]; 86 | mesh._color = data[4]; 87 | mesh._rawColor = data[5]; 88 | mesh._brush = data[6]; 89 | return mesh; 90 | } 91 | -------------------------------------------------------------------------------- /01-pressure-draw/cljs_draw/RadialStroke.js: -------------------------------------------------------------------------------- 1 | // This is ugly, hacked-together-quickly code 2 | 3 | function RadialStroke(color, brush) { 4 | this._vertices = new Float32Array(200); 5 | this._texcoords = new Float32Array(200); 6 | this._numVertices = 0; 7 | this._color = color && goog.color.hexToRgb(color).map(function(x) { return x / 255; }); 8 | this._rawColor = color; 9 | this._brush = brush; 10 | } 11 | 12 | RadialStroke.prototype.addVertex = function(x, y, tx, ty) { 13 | this._vertices = this._maybeResize(this._vertices, 14 | (this._numVertices * 2) + 2); 15 | this._texcoords = this._maybeResize(this._texcoords, 16 | (this._numVertices * 2) + 2); 17 | 18 | var ptr = this._numVertices * 2; 19 | this._vertices[ptr] = x; 20 | this._vertices[ptr + 1] = y; 21 | 22 | ptr = this._numVertices * 2; 23 | this._texcoords[ptr] = tx; 24 | this._texcoords[ptr + 1] = ty; 25 | 26 | this._numVertices++; 27 | }; 28 | 29 | RadialStroke.prototype._maybeResize = function(vec, count) { 30 | if(vec.length < count) { 31 | var next = new Float32Array(vec.length + 32 | (count < 1000 ? 1000 : count)); 33 | next.set(vec); 34 | return next; 35 | } 36 | return vec; 37 | }; 38 | 39 | RadialStroke.prototype.setCurrentPos = function(x, y) { 40 | this._currentPos = [x, y]; 41 | } 42 | 43 | RadialStroke.prototype.getCurrentPos = function() { 44 | return this._currentPos; 45 | }; 46 | 47 | RadialStroke.prototype.getTexCoords = function() { 48 | return this._texcoords; 49 | } 50 | 51 | // Generic mesh methods 52 | 53 | RadialStroke.prototype.getNumVertices = function() { 54 | return this._numVertices; 55 | } 56 | 57 | RadialStroke.prototype.setNumVertices = function(num) { 58 | this._numVertices = num; 59 | } 60 | 61 | RadialStroke.prototype.getVertices = function() { 62 | return this._vertices; 63 | }; 64 | 65 | RadialStroke.prototype.getColor = function() { 66 | return this._color; 67 | }; 68 | 69 | RadialStroke.prototype.getBrush = function() { 70 | return this._brush; 71 | }; 72 | 73 | RadialStroke.prototype.isColor = function(color) { 74 | return this._rawColor === color; 75 | }; 76 | 77 | RadialStroke.prototype.serialize = function() { 78 | return ["radial", this._vertices, this._texcoords, this._numVertices, 79 | this._color, this._rawColor, this._brush]; 80 | } 81 | 82 | RadialStroke.unserialize = function(data) { 83 | var mesh = new RadialStroke(); 84 | mesh._vertices = data[1]; 85 | mesh._texcoords = data[2]; 86 | mesh._numVertices = data[3]; 87 | mesh._color = data[4]; 88 | mesh._rawColor = data[5]; 89 | mesh._brush = data[6]; 90 | return mesh; 91 | } 92 | -------------------------------------------------------------------------------- /01-pressure-draw/cljs_draw/radial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jlongster/learning-clojurescript/c403a077dfeac01bf82b7d56edfca676dfc888c3/01-pressure-draw/cljs_draw/radial.png -------------------------------------------------------------------------------- /01-pressure-draw/cljs_draw/util.cljs: -------------------------------------------------------------------------------- 1 | (ns cljs_draw.util 2 | (:require [goog.events :as events] 3 | [cljs.core.async :refer [ 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |