summaryrefslogtreecommitdiff
path: root/js/lib/canvasmx.js
diff options
context:
space:
mode:
authorJules <jules@asdf.us>2016-09-11 10:19:07 -0400
committerJules <jules@asdf.us>2016-09-11 10:19:07 -0400
commitfbf05115c17163d91e9f649a348e3e6800a22d5e (patch)
tree14920be071bce59aa633be8dc47f8281a66a85db /js/lib/canvasmx.js
init latest version of harp
Diffstat (limited to 'js/lib/canvasmx.js')
-rw-r--r--js/lib/canvasmx.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/js/lib/canvasmx.js b/js/lib/canvasmx.js
new file mode 100644
index 0000000..4b53610
--- /dev/null
+++ b/js/lib/canvasmx.js
@@ -0,0 +1,35 @@
+var CanvasMX = (function(){
+
+ function CanvasMX (w, h) {
+ w = w || 100
+ h = h || 100
+ var canvas = this.canvas = document.createElement("canvas")
+ canvas.width = w
+ canvas.height = h
+ this.ctx = canvas.getContext('2d')
+ var mx = this.mx = new MX.Object3D ()
+ this.el = mx.el
+ mx.el.appendChild(canvas)
+ scene.add(mx)
+ }
+ CanvasMX.prototype.resize = function(w, h){
+ this.canvas.width = w
+ this.canvas.height = h
+ this.mx.width = w
+ this.mx.height = h
+ }
+ CanvasMX.prototype.clear = function(){
+ this.snap.clear()
+ }
+ CanvasMX.prototype.show = function(){
+ this.visible = true
+ this.mx.style.display = "block"
+ }
+ CanvasMX.prototype.hide = function(){
+ this.visible = false
+ this.mx.style.display = "hide"
+ }
+
+ return CanvasMX
+
+})() \ No newline at end of file