summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/mx/primitives/mx.text.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-10-06 16:01:13 -0400
committerJules Laplace <jules@okfoc.us>2014-10-06 16:01:13 -0400
commitc19fbc87676404636a2f5df304ddd7875fc98e66 (patch)
tree7e46b018e7abb7a982bcedb40024c0ca70e6c755 /public/assets/javascripts/mx/primitives/mx.text.js
parent0250ce5260ce75f7c4337693b4e8e7f434e29458 (diff)
new scenery type: text
Diffstat (limited to 'public/assets/javascripts/mx/primitives/mx.text.js')
-rw-r--r--public/assets/javascripts/mx/primitives/mx.text.js67
1 files changed, 41 insertions, 26 deletions
diff --git a/public/assets/javascripts/mx/primitives/mx.text.js b/public/assets/javascripts/mx/primitives/mx.text.js
index 9c7af5c..7b8e595 100644
--- a/public/assets/javascripts/mx/primitives/mx.text.js
+++ b/public/assets/javascripts/mx/primitives/mx.text.js
@@ -3,34 +3,49 @@ MX.Text = MX.Object3D.extend({
init: function (ops) {
this.type = "Text"
-
- var layer = new MX.Object3D('text')
- layer.width = ops.width || 100
- layer.height = ops.height || 50
- layer.x = ops.x || 0
- layer.y = ops.y || 0
- layer.z = ops.z || 0
- layer.scale = ops.scale || 1
- layer.el.innerHTML = ops.value || ""
- if (ops.id) layer.el.id = ops.id;
- if (ops.background) layer.el.style.background = ops.background;
- if (ops.color) layer.el.style.color = ops.color;
- if (ops.fontSize) layer.el.style.fontSize = ops.fontSize + "px";
- this.add(layer)
+ this.type = "Image"
+ this.media = ops.media
+ this.width = 0
+ this.height = 0
+ this.x = ops.x || 0
+ this.y = ops.y || 0
+ this.z = ops.z || 0
+ this.scale = ops.scale || 1
+ this.backface = ops.backface || false
- this.children.forEach(function (c, i) {
- if (ops.classname) {
- c.el.classList.add(ops.classname)
- }
- else {
- }
- c.el.style.backgroundRepeat = 'no-repeat'
- })
+ this.scale = ops.scale || 1
+ this.width = ops.media.width
+ this.height = ops.media.height
+ this.x = ops.x || 0
+ this.y = ops.y || 0
+ this.z = ops.z || 0
+ this.rotationX = ops.rotationX || 0
+ this.rotationY = ops.rotationY || 0
+ this.rotationZ = ops.rotationZ || 0
+
+ ops.className && this.el.classList.add(ops.className)
+ this.backface && this.el.classList.add("backface-visible")
+ this.el.classList.add("text")
+ this.el.classList.add("mx-scenery")
+
+ this.inner = document.createElement("div")
+ this.inner.style.width = "100%"
+ this.el.appendChild(this.inner)
+
+ this.load(ops)
+ },
+
+ load: function(ops){
+ if (ops.color) this.el.style.color = ops.color;
+ if (ops.fontFamily) this.el.style.fontFamily = "'" + ops.fontFamily + "',sans-serif";
+ if (ops.fontSize) this.el.style.fontSize = ops.fontSize + "px";
- this.dirty = true
- this.updateChildren = true
- this.update()
- }
+ this.inner.innerHTML = ops.media.description || ""
+ },
+
+ setText: function(text){
+ this.inner.innerHTML = text
+ },
})