Permalink
Browse files

Added global transforms, very basic, needs some love.

  • Loading branch information...
1 parent c108d17 commit 7ffbf2c1677613b02f443a82715ef58436b4e2fd @rsandor committed Aug 9, 2011
Showing with 35 additions and 0 deletions.
  1. +35 −0 gury.js
View
35 gury.js
@@ -419,6 +419,7 @@ window.$g = window.Gury = (function(window, jQuery) {
this._objects = new Set(true);
this._tags = new TagSpace('__global');
+ this._transforms = new Set(true);
this._paused = false;
this._loop_interval = null;
@@ -536,6 +537,29 @@ window.$g = window.Gury = (function(window, jQuery) {
return this;
},
+ /*
+ * TODO Document me
+ * TODO Add Tagging
+ *
+ * for adding global transformations to all objects
+ *
+ * {
+ * up : // runs before drawing all other objects,
+ * down: // runs after all other objects
+ * }
+ *
+ */
+ addTransform: function(object) {
+ this._transforms.add(object);
+ },
+
+ /*
+ * TODO Document me, add tagging.
+ */
+ removeTransform: function(object) {
+ this._transforms.remove(object);
+ },
+
remove: function(object) {
if (isDefined(object)) {
var gury = this;
@@ -574,6 +598,12 @@ window.$g = window.Gury = (function(window, jQuery) {
var gury = this;
+ // Transforms up
+ gury._transforms.each(function(tr) {
+ tr.up(gury.ctx, gury.canvas);
+ });
+
+ // Draw the objects
gury._objects.each(function(ob) {
if (!ob._gury.visible || !isObjectOrFunction(ob)) {
return;
@@ -587,6 +617,11 @@ window.$g = window.Gury = (function(window, jQuery) {
}
});
+ // Transforms down
+ gury._transforms.each(function(tr) {
+ tr.down(gury.ctx, gury.canvas);
+ });
+
return this;
},

0 comments on commit 7ffbf2c

Please sign in to comment.