summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/mx/primitives/mx.face.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-06-03 17:51:34 -0400
committerJules Laplace <jules@okfoc.us>2014-06-03 17:51:34 -0400
commit90142bd07f926ef8a7f3ea86a563ec0ca648ca5d (patch)
tree2851e990b4b71e215ad2fff4dbcaf80229953c35 /public/assets/javascripts/mx/primitives/mx.face.js
parent607f69c67a5b4dc72d2754192e3cdf67d0ad11d0 (diff)
pulling in more stuff from posthang
Diffstat (limited to 'public/assets/javascripts/mx/primitives/mx.face.js')
-rw-r--r--public/assets/javascripts/mx/primitives/mx.face.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/public/assets/javascripts/mx/primitives/mx.face.js b/public/assets/javascripts/mx/primitives/mx.face.js
new file mode 100644
index 0000000..ac47ab4
--- /dev/null
+++ b/public/assets/javascripts/mx/primitives/mx.face.js
@@ -0,0 +1,41 @@
+MX.Face = MX.Object3D.extend({
+
+ // this will be called within the contructor
+ init: function (size, color, borderColor) {
+
+ size = size || 100
+ color = color || 'rgba(0, 255, 122, .1)'
+ borderColor = borderColor || '#0f3'
+
+ // an Object3D's associated DOM node is the "el" property
+ this.el.classList.add('face')
+
+ var angle = MX.rotationUnit === 'deg' ? 90 : (Math.PI / 2)
+
+ var top = this.top = new MX.Object3D('.face')
+ top.rotationX = angle
+ top.y = size / 2
+
+ // adding children, must also be instances of Object3D
+ this.add(top)
+
+ this.children.forEach(function (face) {
+ face.width = size - 2
+ face.height = size - 2
+ face.el.style.backgroundColor = color
+ face.el.style.border = '1px solid ' + borderColor
+ })
+
+ // this applies the updated CSS style
+ // required for any change to take effect
+ // when a parent object's update() is called
+ // all its children will be updated as well
+ this.update()
+
+ // if this object's children won't move by themselves
+ this.updateChildren = false
+ }
+
+ // other properties will be mixed into the prototype of the new constructor
+
+})