Skip to content

Commit

Permalink
Major style overhaul.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Morris-Pearce committed Dec 16, 2011
1 parent 6eef34e commit 7352a7e
Show file tree
Hide file tree
Showing 34 changed files with 1,966 additions and 2,135 deletions.
3 changes: 2 additions & 1 deletion examples/cache1.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
You will need to enable Javascript to run this demo.
</noscript>

<script type="text/javascript" src="meta2d.js"></script>
<script type="text/javascript" src="../meta2d.js"></script>

<script type="text/javascript">

var loaded,
Expand Down
2 changes: 1 addition & 1 deletion examples/cache2.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
You will need to enable Javascript to run this demo.
</noscript>

<script src="meta2d.js"></script>
<script src="../meta2d.js"></script>
<script>

// In this demonstration, we want to draw some entities outside of the screen
Expand Down
2 changes: 1 addition & 1 deletion examples/drawing.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
You will need to enable Javascript to run this demo.
</noscript>

<script type="text/javascript" src="meta2d.js"></script>
<script type="text/javascript" src="../meta2d.js"></script>

<script type="text/javascript">

Expand Down
2 changes: 1 addition & 1 deletion examples/entity.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
You will need to enable Javascript to run this demo.
</noscript>

<script type="text/javascript" src="meta2d.js"></script>
<script type="text/javascript" src="../meta2d.js"></script>

<script type="text/javascript">

Expand Down
2 changes: 1 addition & 1 deletion examples/layer.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
You will need to enable Javascript to run this demo.
</noscript>

<script type="text/javascript" src="meta2d.js"></script>
<script type="text/javascript" src="../meta2d.js"></script>

<script type="text/javascript">

Expand Down
2 changes: 1 addition & 1 deletion examples/mouse.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
You will need to enable Javascript to run this demo.
</noscript>

<script type="text/javascript" src="meta2d.js"></script>
<script type="text/javascript" src="../meta2d.js"></script>

<script type="text/javascript">

Expand Down
3 changes: 2 additions & 1 deletion examples/text.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
You will need to enable Javascript to run this demo.
</noscript>

<script type="text/javascript" src="meta2d.js"></script>
<script type="text/javascript" src="../meta2d.js"></script>

<script type="text/javascript">

document.addEventListener('DOMContentLoaded', function() {

var mcx = meta2d.create('demo', {
Expand Down
2 changes: 1 addition & 1 deletion examples/ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
You will need to enable Javascript to run this demo.
</noscript>

<script type="text/javascript" src="meta2d.js"></script>
<script type="text/javascript" src="../meta2d.js"></script>

<script type="text/javascript">

Expand Down
13 changes: 6 additions & 7 deletions rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
#
# Instructions:
#
# (1) Install rake build system.
# (1) Install rake build utility.
#
# (2) Run 'rake' to generate the following:
# ++ /meta2d.js
# ++ /docs/api/index.html
# (2) Run 'rake' to generate the following files:
# ++ meta2d.js
# ++ docs/api/index.html
#
# (3) Run 'rake clean':
# -- Removes generated files.
# (3) Run 'rake clean' to remove all generated files.

directory "docs/api"

Expand All @@ -29,7 +28,6 @@ sourcefiles = [
"src/layer.js",
"src/lru.js",
"src/metacontext.js",
"src/process.js",
"src/projection.js",
"src/rcache.js",
"src/rtree.js",
Expand Down Expand Up @@ -68,4 +66,5 @@ end

desc "Generate Javascript library, build documentation."
task :default => [:merge, :document] do
puts "All done."
end
89 changes: 43 additions & 46 deletions src/animation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------
* https://gitorious.org/meta2d/core/trees/master/
/* -----------------------------------------------------------------------------
* <https://gitorious.org/meta2d/core/trees/master/>
* src/animation.js
* ----------------------------------------------------------------------------
* -----------------------------------------------------------------------------
* Copyright 2011 Michael Morris-Pearce
*
* This file is part of Meta2D.
Expand All @@ -20,12 +20,9 @@
* along with Meta2D. If not, see <http://www.gnu.org/licenses/>.
*----------------------------------------------------------------------------*/

!function(root) {
!function(meta) {

'use strict';

var meta = root.meta2d;
if (!meta) throw 'Could not find main namespace.';
'use strict'

/**
* @class Animation
Expand Down Expand Up @@ -59,20 +56,20 @@
var Animation = function() {
var frames_ = {},
tweens_ = [],
data_ = {};
data_ = {}

// take a base frame and apply tweens on top of it
var apply_tweens = function(frame, tweens, index) {
if (!tweens || meta.undef(index)) return frame;
var merged = meta.mix({}, frame);
if (!tweens || meta.undef(index)) return frame
var merged = meta.mix({}, frame)

tweens.forEach(function(t) {
var f = t.tween.call(this, index);
meta.mix(merged, f);
}, this);
var f = t.tween.call(this, index)
meta.mix(merged, f)
}, this)

return merged;
};
return merged
}

/**
* @method putFrame
Expand All @@ -93,12 +90,12 @@
* thisArg
*/
this.putFrame = function(index, data) {
if (meta.undef(index) || !data) return this;
if (meta.undef(index) || !data) return this

frames_[index] = meta.declareSafely(frames_[index], data);
frames_[index] = meta.declareSafely(frames_[index], data)

return this;
};
return this
}

/**
* @method getFrame
Expand All @@ -118,14 +115,14 @@
* @return Object
*/
this.getFrame = function(index) {
if (meta.undef(index)) return null;
if (meta.undef(index)) return null
var f = frames_[index] || {},
intersecting_tweens = tweens_.filter(function(t) {
return meta.segment.includes(t.segment, index);
});
return meta.segment.includes(t.segment, index)
})

return apply_tweens(f, intersecting_tweens, index);
};
return apply_tweens(f, intersecting_tweens, index)
}

/**
* @method deleteFrame
Expand All @@ -146,9 +143,9 @@
* thisArg
*/
this.deleteFrame = function(index) {
delete frames_[index];
return this;
};
delete frames_[index]
return this
}

/**
* @method applyTween
Expand Down Expand Up @@ -190,26 +187,26 @@
* thisArg
*/
this.applyTween = function(tween, segment) {
if (!segment) segment = meta.segment.ALWAYS;
if (!tween) throw new meta.exception.InvalidParameterException();
if (!segment) segment = meta.segment.ALWAYS
if (!tween) throw new meta.exception.InvalidParameterException()
if (arguments.length < 4) {
if (arguments.length < 3) {
arguments[2] = this.getFrame(segment[0]);
arguments[2] = this.getFrame(segment[0])
}
arguments[3] = this.getFrame(segment[1]);
arguments[3] = this.getFrame(segment[1])
}
var keyframes = meta.args(arguments).slice(2),
fixed = tween.fix.bind(this, segment).apply(this, keyframes);
if (!fixed) return this;
if (segment[0] === segment[1]) return this;
fixed = tween.fix.bind(this, segment).apply(this, keyframes)
if (!fixed) return this
if (segment[0] === segment[1]) return this

tweens_.push({
segment: segment,
tween: fixed
});
})

return this;
};
return this
}

/**
* @method undoTweens
Expand All @@ -233,19 +230,19 @@
* thisArg
*/
this.undoTweens = function(segment) {
if (!segment) return this;
if (!segment) return this

tweens_.forEach(function(t, i, array) {
if (meta.segment.intersects(t.segment, segment))
delete array[i];
});
delete array[i]
})

return this;
};
};
return this
}
}

meta.mixSafely(meta, {
Animation: Animation
});
})

}(this);
}(this.meta2d);
Loading

0 comments on commit 7352a7e

Please sign in to comment.