<|start_filename|>src/Layers/outline.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* outline
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

(function() { 

/**
* @class region
* @extends Layer
* @constructor
* @param {Object} parent The parent of the Layer
* @param {Object} data The data for the Layer
**/	
function outline(sifobj, data) {
	'use strict'
	this.region_constructor(sifobj, data);
	
}

var p = createjs.extend(outline, easelSif.region);


p.makeShape = function () {
	var e = this.entries;
	var g = this.graphics;
	
	var aabb = easelSif.aabbFromEntries(this.entries , this.width.getValue());
	this.setBounds(aabb[0] , aabb[1], aabb[2] - aabb[0], aabb[3] - aabb[1]);
	
	g.clear();
	g.setStrokeStyle( this.width.getValue() , "round" ); //To change
	g.s( createjs.Graphics.getRGB( Math.round(this.color.r * 256),Math.round(this.color.g * 256),Math.round(this.color.b * 256), this.color.a) );
	
	g.mt( e[0][0], e[0][1] );
	for (var i = 1, ii = e.length; i !== ii; i++) {			
		g.bt(e[i][0], e[i][1], e[i][2], e[i][3], e[i][4], e[i][5]);
		
	}
	g.es();
	
}




easelSif.outline = createjs.promote(outline, 'region');
}());


<|start_filename|>src/Layers/skeleton.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* skeleton
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
(function() { 

/**
* @class skeleton
* @extends Layer
* @constructor
* @param {Object} parent The parent of the Layer
* @param {Object} data The data for the Layer
**/	

 
function skeleton(sifobj , data) {
	this.DisplayObject_constructor();
	this.type = 'skeleton';
	if (data) this.init(sifobj , data);
}

var p = createjs.extend(skeleton, createjs.DisplayObject);

	p.init = function (sifobj, data) {
		this.sifobj = sifobj;
		var _set = easelSif.param._set;

		_set(this, 'amount', 'real', this, data.amount);

		//console.log(JSON.stringify(data));
		this._getBones(data.bones);
		easelSif._addToDesc(this, data);
		//this.setPosition(0);

	}
	
	p._getBones = function (data) {
		//this.bones = {};
		var eout = [];
		var e = data.static_list.entry;
		for (var i = 0, ii = e.length; i < ii; i++) {
			eout[i] = e[i].bone[0]._guid;
		}

		this.bones = eout;
		
	}
	
	
	
	p.setPosition = function (position) {
		//console.log(this.sifobj);
		var guid = this.sifobj.sif.bones.guid;
		var bones = this.bones;
		var check = false;
		for (var i = bones.length - 1, ii = 0; i >= ii; i--) {
			guid[bones[i]].setPosition(position);
			//check = guid[bones[i]].animated = easelSif._checkTimeline(guid[bones[i]].timeline);
		}
		this.animated = true;
		return position;
		
	}
	



easelSif.skeleton = createjs.promote(skeleton , 'DisplayObject');
}());


<|start_filename|>src/sifobject.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* SifObject
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
//requires easelSif
(function() { 

/**
* @class SifObject
* @constructor
* @param {XmlDocument} xmlDoc The xml document that represents the synfig animation
* @param {Number} x The x of the SifObject
* @param {Number} y The y of the SifObject
* @param {Number} width The width of the SifObject
* @param {Number} height The height of the SifObject
* @param {String} sifPath The path of the sif.xml this is needed for import layer
**/
function SifObject(filename , width, height) {
	'use strict'
	this.Container_constructor();
	this.sifobj = this;
	this.sifPath = '';
	p.desc = {};
	this.width = (width)?width:64;
	this.height = (height)?height:64;
	
	this.timeline = new createjs.Timeline();

	if (filename) this.init(filename);

}

var p = createjs.extend(SifObject, createjs.Container);

// public properties:




	p._getData = function (node) {

		var	data = {};

		// append a value
		function Add(name, value) {

			if (data[name]) {
				if (data[name].constructor != Array) {
					data[name] = [data[name]];
				}
				data[name][data[name].length] = value;
			}
			else {
				data[name] = value;
			}
		};
		
		// element attributes
		var c, cn, cname;
		for (c = 0; cn = node.attributes[c]; c++) {
			Add("_" + cn.name, easelSif._toSifValue(cn.value));
		}
		
		// child elements
		for (c = 0; cn = node.childNodes[c]; c++) {
			if (cn.nodeType == 1) {
				cname = cn.nodeName;
				if (cn.childNodes.length == 1 && cn.firstChild.nodeType == 3) {
					// text value
					Add(cn.nodeName, easelSif._toSifValue(cn.firstChild.nodeValue));
				}
				else {
					// A switch to help catch the changes we wand
					
					switch (cname) {
						
							
							
						case 'param':
							/* To get the params out the param array 
							*and set the name as propertie we will get
							* the ugly: 
							* bline.bline.entry[0].point.vector.x
							* canvas.canvas.layer for the PasteCanvas
							* color.color.a
							* and some more but it's the best solution for
							* a clean json 
							* */
							data[cn.getAttribute('name')] = this._getData(cn);
							break;
							
							
						case 'layer':
							/* layer and waypoint must always be array
							 * 
							 * */
							
							if (typeof data[cname] == 'undefined') data[cname] = [];
							var layer_type = cn.getAttribute('type');

							/*		Switch Layer Type
							*	Push a fake layer of type restore and unshift the layer
							* 	This is needed for rendering.
							* */
							switch (layer_type) {
								case 'rotate': case 'translate': case 'zoom': case 'stretch':
									//Add('layer', {_type: 'restore'});
									Add(cn.nodeName, this._getData(cn));
									break;

								case 'timeloop':
									data.layer.unshift(this._getData(cn));
									break;
									

								default:
									Add(cn.nodeName, this._getData(cn));						
									break;
										
								
									
									
							} //Switch Layer Type Over
							break; //layer

								
						case 'waypoint': case 'entry': case 'bone_root': case 'bone':
							/*  To be sure that it will be an array
							 * */
								if (typeof data[cname] == 'undefined') data[cname] = [];
								//No break here just wanted to be sure that it will be an array.
									
						default:
							Add(cname, this._getData(cn))
							break
					} //Switch (cn.nodeName) END
				}
			}
		}

		return data;

	}


	/** 
	 * Initialization method.
	 * @method init
	 * @param {XmlDocument} xmlDoc The xml document that represents the synfig animation
	 **/
	 p.init = function (filename) {
		var xmlDoc = easelSif.preload.getResult(filename);
		//console.log(filename);
		this.sifPath = filename.slice(0,(filename.search('/'))?filename.search('/') + 1:0 );
		
		//this.initialize();
		this.sifobj = this;
		var data = this._getData(xmlDoc.getElementsByTagName('canvas')[0]);		
		this.timeline.setPaused(true);	
		this._getCanvasData(data);
		
		
	}
	


	
	// private methods:

	/**
	 * @method _getCanvasData
	 * @protected
	 * @param {Object} data the data to get the contruct the SifObject
	 **/
	p._getCanvasData = function (data) {

		//console.log(JSON.stringify(data));
		this.sif = {};
		this.sif.canvas = {};
		
		this.sif.canvas.version = data._version;
		this.sif.canvas.width = data._width;
		this.sif.canvas.height = data._height;
		var _vb = data['_view-box'].split(" ");
		this.sif.canvas.view_box = [parseFloat(_vb[0]), parseFloat(_vb[1]), parseFloat(_vb[2]), parseFloat(_vb[3])];
		this.sif.canvas.antialias = data._antialias;
		this.sif.canvas.fps = data._fps;
		//convert the time to millis cause it's more common for computers...
		this.sif.canvas.begin_time = easelSif._canvasTimeToMillis(data['_begin-time'], this.sif.canvas.fps);
		this.sif.canvas.end_time = easelSif._canvasTimeToMillis(data['_end-time'], this.sif.canvas.fps);
		var _bgcolor = data._bgcolor.split(" ");
		this.sif.canvas.bgcolor = {};
		//convert the color to 256 to much html5 ... I think so...
		this.sif.canvas.bgcolor.r = Math.round(parseFloat(_bgcolor[0]) * 256);
		this.sif.canvas.bgcolor.g = Math.round(parseFloat(_bgcolor[1]) * 256);
		this.sif.canvas.bgcolor.b = Math.round(parseFloat(_bgcolor[2]) * 256);
		this.sif.canvas.bgcolor.a = parseFloat(_bgcolor[3]);
		this.sif.canvas.name = data.name;
		
		
		
		this.sif.canvas.defs = this._getDefs(data.defs);
		this._getBones(data);
		//this._getBones(data);

		
		this.timeline.duration = this.sif.canvas.end_time;
		
		this.scaleX = this.width / (this.sif.canvas.view_box[2] - this.sif.canvas.view_box[0]);
		this.scaleY = this.height / (this.sif.canvas.view_box[3] - this.sif.canvas.view_box[1]);
		
		if (this.sif.canvas.view_box[0]) this.x = this.width / 2;
		if (this.sif.canvas.view_box[1]) this.y = this.height / 2;

		//Get the layers
		this._getLayers(data.layer);



	}
	
	/**
	 * @method _getDefs
	 * @protected
	 * @param {Object} data the data to get defs for SifObj
	 * @return {Object} the defs for the SifObject
	 **/
	p._getDefs = function (data) {
		var defs = {};
		var def_type;
		for (name in data) {

			if (data[name].constructor != Array) {
				if (name === 'animated') {
					defs[data[name]._id]  = {};
					defs[data[name]._id].animated = data[name];
				} else {			
					defs[data[name]._id] = {};
					defs[data[name]._id][name] = data[name];
					defs[data[name]._id]._type = name;							
				}
			} else {
				
					
				for (var j = 0; j < data[name].length; j++) {
					if (name === 'animated') {
						defs[data[name][j]._id] = {};
						defs[data[name][j]._id].animated = data[name][j];
					} else {
						defs[data[name][j]._id] = {};
						defs[data[name][j]._id][name] = data[name][j];
						defs[data[name][j]._id]._type = name
					}
				}			
			}
		}
		//alert(JSON.stringify(defs));
		return defs;
	}
	
	p._getBones = function (data) {
		var sifobj = this;
		var b = data.bones;
		if (!b) return;
		this.sif.bones = {};
		var guid = this.sif.bones.guid = {};
		var g;
		
		for (var i = 0, ii = b.bone.length; i < ii; i++) {
			guid[b.bone[i]._guid] = new easelSif.Bone(sifobj, b.bone[i]);

		}	
		
			
		
	}
	
	p._getLayers = function (_layer) {
		var o = this;
		var sifobj = this.sifobj;
		var _lt;
		var _l;
		if (_layer) {
			
			for (var i = 0, ii = _layer.length; i < ii; i++) {	
				_lt = _layer[i]._type;
				_l = easelSif._getLayer(sifobj, _layer[i]);

				
				if (_lt === 'rotate' || _lt === 'translate' || _lt === 'stretch' || _lt === 'zoom') {
					this.moveChildrenTo(_l);
				}
				
				o.addChild(_l);
				
			}
		}
		
	}
	
	p.moveChildrenTo = function (o) {
		var ch = [];
		for (var i = 0, ii = this.children.length; i < ii; i++) {
			ch.push(this.children[i]);
		}
		
		for (var i = 0, ii = ch.length; i < ii; i++) {
			o.addChild(ch[i]);
		}
	}
	

	/**
	 * 
	 * @method tick
	 * @param {Integer} delta
	 **/		
	p.tick = function (delta) {
		this.setPosition(this.timeline.position + delta);

	}

	
	/**
	 * 
	 * @method setPosition
	 * @param {Integer} time
	 **/	
	p.setPosition = function (position) {
		
		var delta = position - this.timeline.position;
		this.animated = false;
		this.timeline.setPosition(position);
		var new_pos = this.timeline.position;
		var ch = this.children;
		for (var i = 0, ii = this.children.length; i < ii; i++) {
			if (ch[i].unsynced) {
				new_pos = ch[i].setPosition( ch[i].timeline.position + delta , delta);					
			} else {
				new_pos = ch[i].setPosition(new_pos, delta);
				
			}
			if (ch[i].animated) this.childAnimated = this.animated = true;
		}
	}
	
	//this method is for ovveride and setup objects of the sifobj after it's creation
	p.setup = function () {
		
		return true;
	}


easelSif.SifObject = createjs.promote(SifObject, "Container");
}());



<|start_filename|>src/easelSif.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* easelSif
* version 0.1.
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

this.easelSif = this.easelSif || {};
(function() { 	
//Common functions
var easelSif = {};
	



	
	easelSif.getTotalScale = function (o) {
		var sx = 1;
		var sy = 1;
		while (o != null) {
			sx *= o.scaleX;
			sy *= o.scaleY;
			o = o.parent;

		}
		return Math.sqrt(sx * sx  + sy * sy);
	}

	
	/**
	 * This function creates and return a new layer for the sifObject
	 * @function _getLayer
	 * @param {Object} parent The parent of new Layer
	 * @param {Object} data the data for the layer
	 * @return {Object} the a sif layer
	 **/	
	easelSif._getLayer = function (sifobj, data) {
		var o;
		if (easelSif[data._type]) {
			o = new easelSif[data._type](sifobj, data);
			return o;
		}
		if (data._type === 'import') {
			o = new easelSif.Import(sifobj, data);
			return o;
		}
		
		if (data._type === 'switch') {
			o = new easelSif.Switch(sifobj , data);
			return o;
		}
		// Not supported LAYER
		console.log("EERRROOR  "  + data._type + " layer it's not supported");
		//var bad_layer = new easelSif.Layer();
		//bad_layer.initLayer(parent, data);
		//return bad_layer;
	}
	
	easelSif._setTimeline = function (o) {
		o.timeline = new createjs.Timeline();
		o.timeline.setPaused(true);
	}
	
	easelSif._getBlend = function (blend) {
	
		switch (blend) {
			case 0:
				//Composite
				return 'source-over';

			case 1:
				//Straight 
				return 'copy';

			case 13:
				//Onto
				return 'source-atop';

			case 21:
				//Straight Onto
				return 'source-in';

			case 12:
				//Behind
				return 'destination-over';

			case 19:
				//Alpha Over
				return 'destination-out';
				break;
			case 14:
				//Alpha Brighter
				return 'destination-in';
				break;
				
				
			default:
				return 'source-over';
				
		}
	}
	
	easelSif.aabbFromEntries = function (e , width) {
		var a = [e[0][0], e[0][1], e[0][0], e[0][1]];
		for (var i = 0, ii = e.length; i < ii; i++) {
			if (e[i][0] < a[0]) {
				a[0] = e[i][0]
			} 
			else if (e[i][0] > a[2]) {
				a[2] = e[i][0];
			}
			
			if (e[i][2] < a[0]) {
				a[0] = e[i][2]
			} 
			else if (e[i][2] > a[2]) {
				a[2] = e[i][2];
			}
			
			if (e[i][4] < a[0]) {
				a[0] = e[i][4]
			} 
			else if (e[i][4] > a[2]) {
				a[2] = e[i][4];
			}
			
			
			//Y
			
			if (e[i][1] < a[1]) {
				a[1] = e[i][1]
			} 
			else if (e[i][1] > a[3]) {
				a[3] = e[i][1];
			}
			
			if (e[i][3] < a[1]) {
				a[1] = e[i][3]
			} 
			else if (e[i][3] > a[3]) {
				a[3] = e[i][3];
			}
			
			if (e[i][5] < a[1]) {
				a[1] = e[i][5]
			} 
			else if (e[i][5] > a[3]) {
				a[3] = e[i][5];
			}
			

			if (width) {
				a[0] -= width;
				a[1] -= width;
				a[2] += width;
				a[3] += width;
			}

		}
		return a;
	}



	/**
	 * Gets the time in seconds and returns it to milliseconds
	 * 
	 * @function easelSif._secsToMillis
	 * @param {String} _s The time in seconds
	 * @return {Number} the millisecs
	 **/	
	easelSif._secsToMillis = function (_s) {
			return parseFloat(_s.replace("s",""))*1000;
	}
	
	/**
	 * Gets the time in seconds and returns it to milliseconds
	 * 
	 * @function easelSif._canvasTimeToMillis
	 * @param {String} _s The time in seconds and frames
	 * @param {Integer} fps The frames per seccond
	 * @return {Number} the millisecs
	 **/	
	easelSif._canvasTimeToMillis = function (_s, fps) {
		var millis = 0;
		var t;
		if (_s.search('h') > 0 ) {
			t = _s.split('h');
			millis += t[0] * 3600000;
			_s = t[1];
		}
		
		if (_s.search('m') > 0 ) {
			t = _s.split('m');
			millis += t[0] * 60000;
			_s = t[1];
		}

		if (_s.search('s') > 0 ) {
			t = _s.split('s');
			millis += t[0] * 1000;
			_s = t[1];			
		}
		
		if (_s.search('f') > 0 ) {
			t = _s.split('f');
			millis += t[0] * 1000/fps;	
		}
		return millis;
	}
	
	
	/**
	 * Returns a string to a sif value
	 * 
	 * @function easelSif._toSifValue
	 * @param {String} value The value to be converted to a sif value
	 * @return {Number || String} the sif value
	 **/		
	easelSif._toSifValue = function ( value ) {
		var num = Number(value);
		if (!isNaN(num)) return num;
		if (value === 'true') return true;
		if (value === 'false') return false;
		//if a value or vector is using a def the first letter is ':' so we check to remove it.
		if (value[0] === ":") return value.substr(1);
		return value;
	}
	
	/**
	 * Returns a cteatejs.Ease to be used
	 * @function easelSif._getEase
	 * @param {String} ease_type the type of ease to catch
	 * @param {Object} ease_type the data to check the value type
	 * @return {object} returns a cteatejs.Ease to be used
	 **/	
	easelSif._getEase = function (ease_type) {

		if (ease_type === 'linear') return createjs.Ease.none;
		if (ease_type === 'clamped') return createjs.Ease.sineInOut;
		if (ease_type === 'halt') return createjs.Ease.sineInOut;

		if (ease_type === 'constant') return easelSif.Ease.constant;
		//TCB
		if (ease_type === 'auto') return createjs.Ease.sineInOut;

		return false;
	}
	
	easelSif.aabbFromEntries = function (e , width) {
		var a = [e[0][0], e[0][1], e[0][0], e[0][1]];
		for (var i = 0, ii = e.length; i < ii; i++) {
			if (e[i][0] < a[0]) {
				a[0] = e[i][0]
			} 
			else if (e[i][0] > a[2]) {
				a[2] = e[i][0];
			}
			
			if (e[i][2] < a[0]) {
				a[0] = e[i][2]
			} 
			else if (e[i][2] > a[2]) {
				a[2] = e[i][2];
			}
			
			if (e[i][4] < a[0]) {
				a[0] = e[i][4]
			} 
			else if (e[i][4] > a[2]) {
				a[2] = e[i][4];
			}
			
			
			//Y
			
			if (e[i][1] < a[1]) {
				a[1] = e[i][1]
			} 
			else if (e[i][1] > a[3]) {
				a[3] = e[i][1];
			}
			
			if (e[i][3] < a[1]) {
				a[1] = e[i][3]
			} 
			else if (e[i][3] > a[3]) {
				a[3] = e[i][3];
			}
			
			if (e[i][5] < a[1]) {
				a[1] = e[i][5]
			} 
			else if (e[i][5] > a[3]) {
				a[3] = e[i][5];
			}
			

			if (width) {
				a[0] -= width;
				a[1] -= width;
				a[2] += width;
				a[3] += width;
			}

		}
		return a;
	}


	easelSif._addToDesc = function (o, data) {
		var desc = o.sifobj.desc;
		if (data._desc) {
			o.name = data._desc;
			//keep refernce of the layer to the sifobj so we can reach it.
			if (desc[o.name]) {
				if (desc[o.name].constructor != Array) {
					var r = desc[o.name]
					desc[o.name] = [];
					desc[o.name].push(r);					
				}
				desc[o.name].push(o);
			} else {
				desc[o.name] = o;
			}
			
		}
	}
	
	
	easelSif._checkTimeline = function (timeline) {	
		var tw = timeline._tweens;
		var pos = timeline.position;
		var check = false;
		if (tw) {	

			for (var i = 0, ii = tw.length; i < ii; i++) {
				if (easelSif._checkTween(tw[i])) {check = true;}
				
			}

		}
		return check;
	}
	
	easelSif._checkTween = function (tw) {
		var props = tw._curQueueProps;
		var target = tw._target;
		var preprops = (target.preprops)?target.preprops : {};
		var check = false;
		
		
		for (var n in props) {
			if (target[n] !== preprops[n]) check = true;
			preprops[n] = target[n];
		}
		target.preprops = preprops;
		return check;		
	}	

	easelSif.loadfile = function (filename) {
		if (!easelSif.preload) easelSif.preload = new createjs.LoadQueue(true);
		easelSif.preload.on("fileload", easelSif.handleFileLoad);
		easelSif.preload.on("complete", easelSif.handleComplete);
		easelSif.preload.loadFile({id:filename, src:filename, type:createjs.LoadQueue.XML});
		
	}
	
	easelSif._getFiles = function (xmlDoc , sifPath) {
		sifPath = (sifPath)?sifPath:'';
		var preload = easelSif.preload;
		var params = xmlDoc.getElementsByTagName('param');
		
		for (var i = 0, ii = params.length; i < ii; i++) {
			var r = params[i].getAttribute('name');
			if (r === 'filename') {
				//console.log(r.slice('.'));
				var rr = sifPath + params[i].getElementsByTagName('string')[0].childNodes[0].nodeValue;
				if (!preload.getItem(rr)) {					
					preload.loadFile({src:rr});
				}
				//console.log(preload);
			} else if (r === 'canvas') {
				var rr = params[i].getAttribute('use');
					if (rr) {
						if (rr.search('#') > 0) {
							rr = sifPath + rr.slice(0, rr.length - 1);
							if (!preload.getItem(rr)) {
								preload.loadFile({src:rr, type: createjs.LoadQueue.XML});
							}
							
						}
					}
			}
			
			
		}
		
	}
	
		
	easelSif.handleFileLoad = function(event) {
		var item = event.item; // A reference to the item that was passed in to the LoadQueue
		var type = item.type;
		var id = item.id;
		//console.log(type);
		if (type === createjs.LoadQueue.XML) {
			if (id) {
				easelSif._getFiles(event.result , id.slice(0,(id.search('/'))?id.search('/') + 1:0 ));
			}
		}
		 
	}
	
	easelSif.handleComplete = function(event) {
		console.log('main');
		main()
	}

	
	


window.easelSif = easelSif;
}());



<|start_filename|>src/Layers/fakeswitch.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* fakeswitch
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
(function() { 

/**
* @class region
* @extends Shape
* @constructor
**/	
function FakeSwitch(group, frame_rate) {
	this.type = 'fakeswitch';
	this.init(group, frame_rate);
}

var p = FakeSwitch.prototype = new createjs.Bitmap();
p.getConcatenatedMatrix = easelSif.group.prototype.getConcatenatedMatrix;
//p.getConcatenatedMatrix = easelSif.group.prototype.getConcatenatedMatrix;
	
	/** 
	 * Initialization method.
	 * @method init
	 * @param {Object} parent The parent of the Layer
	 * @param {Object} data The data for the Layer
	 **/
	p.init = function (group, frame_rate) {
		frame_rate = (frame_rate)? frame_rate:30;
		this.timeline = new createjs.Timeline();
		this.timeline.duration = group.timeline.duration;
		var secs = 1000 / frame_rate;
		this.animated = true;
		this.frame_rate = frame_rate;
		this.frames = [];
		group.setPosition(0);
		for (var i = 0, ii = group.timeline.duration; i < ii; i = i + secs) {
			var f = {};
			var canvas = f.cacheCanvas = document.createElement('canvas');
			var ctx = canvas.getContext('2d');
			group.setPosition(i);
			if (group.animated) {
				var ab = group.getBounds();
				var scale = Math.abs(easelSif.getTotalScale(group));
				group.cache(ab.x , ab.y, ab.width, ab.height, scale);
				
				this._setFrameData(ab.x, ab.y, ab.width, ab.height, scale, f);
				var cacheCanvas = group.cacheCanvas;
				
				canvas.height = cacheCanvas.height;
				canvas.width = cacheCanvas.width;
				ctx.drawImage(cacheCanvas, 0, 0);
				this.frames.push(f);
			} else {
				this.frames.push(this.frames[this.frames.length - 1]);
			}
			
		}
		this.frame = this.frames[0];
		this.image = this.frame.cacheCanvas;
		
		
		//this._setCacheData(this.frames[0]);

		
		console.log(this);
	}
	
	p.setPosition = function (position) {
		this.timeline.setPosition(position);
		var npos = this.timeline.position;
		var f = Math.floor(this.frame_rate / 1000 * npos );
		this.frame = this.frames[f]
		this.image = this.frame.cacheCanvas;
		return position;
	}
	
	p._setFrameData = function (x, y, width, height, scale, that) {
		that = (that)?that:this;
		if (isNaN(x)) {
			that.width = x._cacheWidth;
			that.height = x._cacheHeight;
			that.x = x._cacheOffsetX;
			that.y = x._cacheOffsetY;
			that.scale = x._cacheScale;

		} else {
			
			that.width = width;
			that.height = height;
			that.x = x;
			that.y = y;
			that.scale = scale;
		}
	}
	
	p.getMatrix = function (matrix) {
		var that = this;		
		var orx = -this.frame.x;
		var ory = -this.frame.y;
		var scale = 1 / this.frame.scale;
		var width = this.frame.width;
		var height = this.frame.height;
		
		return (matrix ? matrix.identity() : new createjs.Matrix2D()).appendTransform(-orx + this.x, -ory + this.y, scale, scale, 0, 0,0,0,0);	
	}
	
	/*
	 * this is a copy of the method from easeljs.DisplayObject the only dif is the line mtx = o.getMatrix()
	 */
	p.updateContext = function(ctx) {
		var mtx, mask=this.mask, o=this;
		
		if (mask && mask.graphics && !mask.graphics.isEmpty()) {
			mtx = mask.getMatrix(mask._matrix);
			ctx.transform(mtx.a,  mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty);
			
			mask.graphics.drawAsPath(ctx);
			ctx.clip();
			
			mtx.invert();
			ctx.transform(mtx.a,  mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty);
		}
		
		mtx = o.getMatrix();
		// TODO: should be a better way to manage this setting. For now, using dynamic access to avoid circular dependencies:
		if (createjs["Stage"]._snapToPixelEnabled && o.snapToPixel) { ctx.transform(mtx.a,  mtx.b, mtx.c, mtx.d, mtx.tx+0.5|0, mtx.ty+0.5|0); }
		else { ctx.transform(mtx.a,  mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty); }
		ctx.globalAlpha *= o.alpha;
		if (o.compositeOperation) { ctx.globalCompositeOperation = o.compositeOperation; }
		if (o.shadow) { this._applyShadow(ctx, o.shadow); }
	};




	


easelSif.FakeSwitch = FakeSwitch;
}());


<|start_filename|>src/Param/param.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* param
* version 0.1.
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
this.easelSif = this.easelSif || {};
this.easelSif.param = this.easelSif.param||{};
 (function() { 
var param = easelSif.param;

	/**
	 * VECTOR
	 * @function param._getVector
	 * @param {Object} layer the layer that contains the param
	 * @param {String} param_name the name of the param
	 * @param {String} wanted_type the type that the param wands to be
	 * @param {Object} that the holder of the values
	 * @param {Object} data the data that holds the values.
	 **/		
	param._set = function(layer, param_name, wanted_type, that, data) { 
		var param_type;
		
		if (!data) alert(JSON.stringify(data) + this.type + "  " + param_name);
		if (data.animated) param_type = data.animated._type;
		if (data._type) param_type = data._type;
		
		if (data._use) {
			//To change
			param._set(layer, param_name, wanted_type, that, layer.sifobj.sif.canvas.defs[data._use]);
		}		//VECTOR
		else if (data.vector || param_type === 'vector') {
			param.vector._get( layer, param_name, wanted_type, that, data );
		}		//INTEGER
		else if (data.integer || param_type === 'integer') {
			param._getNumber( layer, param_name, wanted_type, that, data, 'integer' );
		}
		else if (data.real || param_type === 'real') {
			param._getNumber( layer, param_name, wanted_type, that, data, 'real' );
		}
		else if (data.angle || param_type === 'angle') {
			param._getNumber( layer, param_name, wanted_type, that, data, 'angle' );
		}
		else if (data.bool || param_type === 'bool') {
			param.bool._get( layer, param_name, wanted_type, that, data);
		}
		else if (data.time || param_type === 'time') {
			param._getTime( layer, param_name, wanted_type, that, data);
		}

		else if (data.color || param_type === 'color') {
			param._getColor( layer, param_name, wanted_type, that, data );
		}
		else if (data.gradient || param_type === 'gradient') {
			param._getGradient( layer, param_name, wanted_type, that, data );
		}		//COMPOSITE
		else if (data.composite) {
			param.composite._get(layer, param_name, wanted_type, that, data);
		}		//BLINE POINT => VERTEX
		else if (data.bline_point) {
			//This is a special conversion cause the bline_points are always passed as composite types
			// so here is the place where all the converted bline points are going to be handled
			// The trick here is to make any other type to look like a regular bline point
			that[param_name] = {};
			that[param_name].composite = {};
			if (data.bline_point.vertex) { //This is a vertex bline point
				param._set(layer, 'point', 'vector', that[param_name].composite, data.bline_point.vertex);
				param._set(layer, 't1', 'vector', that[param_name].composite, data.bline_point.t1);
				that[param_name].composite.split = {};
				that[param_name].composite.split.getValue = function () {return false};
				param.convert._set(layer, that[param_name].composite, wanted_type, 'bline_point');
			} else {
				alert('not converted bline point');
			}

		}	
				// CONVERT TYPES
				//SCALE
		else if (data.scale || param_type === 'scale') {
			that[param_name] = {};
			that[param_name].scale = {};
			if (data.scale._link) data.scale.link = layer.sifobj.sif.canvas.defs[data.scale._link];
			if (data.scale._scalar) data.scale.scalar = layer.sifobj.sif.canvas.defs[data.scale._scalar];
			param._set(layer, 'link', data.scale._type, that[param_name].scale, data.scale.link);
			param._set(layer, 'scalar', 'real', that[param_name].scale, data.scale.scalar);
			param.convert._set( layer, that[param_name], wanted_type, 'scale');		
		}
		else if (data.radial_composite || param_type === 'radial_composite') {
			param._getRadial_composite( layer, param_name, wanted_type, that, data );
		}		//ADD
		else if (data.add) {
			param_type = data.add._type;
			that[param_name] = {};
			that[param_name].add = {};
			if (data.add._lhs) data.add.lhs = layer.sifobj.sif.canvas.defs[data.add._lhs];
			if (data.add._rhs) data.add.rhs = layer.sifobj.sif.canvas.defs[data.add._rhs];
			if (data.add._scaler) data.add.scaler = layer.sifobj.sif.canvas.defs[data.add._scaler];
			param._set(layer, 'lhs', param_type, that[param_name].add, data.add.lhs);
			param._set(layer, 'rhs', param_type, that[param_name].add, data.add.rhs);
			param._set(layer, 'scalar', 'real', that[param_name].add, data.add.scalar);
				
			param.convert._set( layer, that[param_name], wanted_type, 'add');
			
		}		//AND
		else if (data.and) {
			param_type = data.and._type;
			
			that[param_name] = {};
			that[param_name].and = {};
			param._set(layer, 'link1', param_type, that[param_name].and, data.and.link1);
			param._set(layer, 'link2', param_type, that[param_name].and, data.and.link2);
				
			param.convert._set( layer, that[param_name], wanted_type, 'and');
			
		}		//ATAN2
		else if (data.atan2) {
			param_type = data.atan2._type;
			that[param_name] = {};
			that[param_name].atan2 = {};
			if (data.atan2._x) data.atan2.x = layer.sifobj.sif.canvas.defs[data.atan2._x];
			if (data.atan2._y) data.atan2.y = layer.sifobj.sif.canvas.defs[data.atan2._y];
			param._set(layer, 'x', 'real', that[param_name].atan2, data.atan2.x);
			param._set(layer, 'y', 'real', that[param_name].atan2, data.atan2.y);
			param.convert._set( layer, that[param_name], wanted_type, 'atan2');
			
		}		//COS
		else if (data.cos) {
			param_type = data.cos._type;
			that[param_name] = {};
			that[param_name].cos = {};
			if (data.cos._angle) data.cos.angle = layer.sifobj.sif.canvas.defs[data.cos._angle];
			if (data.cos._amp) data.cos.amp = layer.sifobj.sif.canvas.defs[data.cos._amp];
			param._set(layer, 'angle', 'angle', that[param_name].cos, data.cos.angle);
			param._set(layer, 'amp', 'real', that[param_name].cos, data.cos.amp);
			param.convert._set( layer, that[param_name], wanted_type, 'cos');
			
		}		//DOT PRODUCT
		else if (data.dotproduct) {
			param_type = data.dotproduct._type;
			that[param_name] = {};
			that[param_name].dotproduct = {};
			if (data.dotproduct._lhs) data.dotproduct.lhs = layer.sifobj.sif.canvas.defs[data.dotproduct._lhs];
			if (data.dotproduct._rhs) data.dotproduct.rhs = layer.sifobj.sif.canvas.defs[data.dotproduct._rhs];
			param._set(layer, 'lhs', 'vector', that[param_name].dotproduct, data.dotproduct.lhs);
			param._set(layer, 'rhs', 'vector', that[param_name].dotproduct, data.dotproduct.rhs);
				
			param.convert._set( layer, that[param_name], wanted_type, 'dotproduct');
			
		}		//EXPONENTIAL
		else if (data.exp) {
			param_type = data.exp._type;
			that[param_name] = {};
			that[param_name].exp = {};
			if (data.exp._exp) data.exp.exp = layer.sifobj.sif.canvas.defs[data.exp._exp];
			if (data.exp._scale) data.exp.scale = layer.sifobj.sif.canvas.defs[data.exp._scale];
			param._set(layer, 'exp', 'real', that[param_name].exp, data.exp.exp);
			param._set(layer, 'scale', 'real', that[param_name].exp, data.exp.scale);
				
			param.convert._set( layer, that[param_name], wanted_type, 'exp');
			
		}		//LOGARITHM
		else if (data.logarithm) {
			param_type = data.logarithm._type;
			that[param_name] = {};
			that[param_name].logarithm = {};
			if (data.logarithm._link) data.logarithm.link = layer.sifobj.sif.canvas.defs[data.logarithm._link];

			param._set(layer, 'link', 'real', that[param_name].logarithm, data.logarithm.link);
			param._set(layer, 'epsilon', 'real', that[param_name].logarithm, data.logarithm.epsilon);
			param._set(layer, 'infinite', 'real', that[param_name].logarithm, data.logarithm.infinite);	
			param.convert._set( layer, that[param_name], wanted_type, 'logarithm');
			
		}		//RECIPROCAL
		else if (data.reciprocal) {
			param_type = data.reciprocal._type;
			that[param_name] = {};
			that[param_name].reciprocal = {};
			if (data.reciprocal._link) data.reciprocal.link = layer.sifobj.sif.canvas.defs[data.reciprocal._link];

			param._set(layer, 'link', 'real', that[param_name].reciprocal, data.reciprocal.link);
			param._set(layer, 'epsilon', 'real', that[param_name].reciprocal, data.reciprocal.epsilon);
			param._set(layer, 'infinite', 'real', that[param_name].reciprocal, data.reciprocal.infinite);	
			param.convert._set( layer, that[param_name], wanted_type, 'reciprocal');
			
		}		//SUBTRACT
		else if (data.subtract) {
			param_type = data.subtract._type;
			that[param_name] = {};
			that[param_name].subtract = {};
			if (data.subtract._lhs) data.subtract.lhs = layer.sifobj.sif.canvas.defs[data.subtract._lhs];
			if (data.subtract._rhs) data.subtract.rhs = layer.sifobj.sif.canvas.defs[data.subtract._rhs];
			if (data.subtract._scalar) data.subtract.scalar = layer.sifobj.sif.canvas.defs[data.subtract._scalar];
			param._set(layer, 'lhs', param_type, that[param_name].subtract, data.subtract.lhs);
			param._set(layer, 'rhs', param_type, that[param_name].subtract, data.subtract.rhs);
			param._set(layer, 'scalar', 'real', that[param_name].subtract, data.subtract.scalar);
				
			param.convert._set( layer, that[param_name], wanted_type, 'subtract');
			
		}		//SINE
		else if (data.sine) {
			param_type = data.sine._type;
			that[param_name] = {};
			that[param_name].sine = {};
			if (data.sine._angle) data.sine.angle = layer.sifobj.sif.canvas.defs[data.sine._angle];
			if (data.sine._amp) data.sine.amp = layer.sifobj.sif.canvas.defs[data.sine._amp];
			param._set(layer, 'angle', 'angle', that[param_name].sine, data.sine.angle);
			param._set(layer, 'amp', 'real', that[param_name].sine, data.sine.amp);
			param.convert._set( layer, that[param_name], wanted_type, 'sine');
			
		}	//vectorangle
		else if (data.vectorangle) {
			param_type = data.vectorangle._type;
			that[param_name] = {};
			that[param_name].vectorangle = {};
			param._set(layer, 'vector', 'vector', that[param_name].vectorangle, data.vectorangle.vector);
			param.convert._set( layer, that[param_name], wanted_type, 'vectorangle');
		}		
		else if (data.greyed) {
			param._set(layer, param_name, wanted_type, that, data.greyed.link);
		}
		else {
			alert('no param type');
			alert(JSON.stringify(data) + ' layer type : ' + layer.type);
		}

	}

//CONVERTED 	

	

	/**
	 * animates the angle real integer and checks for convert 
	 * @function param._getNumber
	 * @param {Object} layer the layer that contains the param
	 * @param {String} param_name the name of the param
	 * @param {String} wanted_type the type that the param wands to be
	 * @param {Object} that the holder of the values
	 * @param {Object} data the data that holds the values.
	 * @param {Object} param_type the type of the data param.
	 **/	
	param._getNumber = function (layer, param_name, wanted_type, that, data, param_type) {	
		var w, tw, time;
		var tw_def = {paused: true, useTick: true};
		var timeline = layer.timeline;
		var ease;
		var stm = easelSif._secsToMillis;
		that[param_name] = {};
		
		
		
		if (data.animated) {

			w = data.animated.waypoint
			that[param_name].value = w[0][param_type]._value

			tw = createjs.Tween.get(that[param_name], tw_def);


			if (w[0]._time !== "0s") {
				ease = easelSif._getEase(w[0]._before);
				time = stm(w[0]._time);
				tw.to( {value: w[0][param_type]._value},
					time, ease);
			}

					
			for (var i = 0; i < w.length - 1; i++) {
				ease = easelSif._getEase(w[i + 1]._before);
				time = stm(w[i + 1]._time) - stm(w[i]._time);						
				tw.to( {value: w[i + 1][param_type]._value},
					time, ease );
			}


			
			
			timeline.addTween(tw);


			param.convert._set( layer, that[param_name], wanted_type, param_type);
		} else {
			if (!data[param_type]) alert(JSON.stringify(data) + "param_type : " + param_type + ' param_name : ' + param_name + ' layer type : ' + this.type);
			that[param_name].value = data[param_type]._value;
			param.convert._set( layer, that[param_name], wanted_type, param_type);
		}
	}
	
	/**
	 * TIME
	 * @function param._getRadial_composite
	 * @param {Object} layer the layer that contains the param
	 * @param {String} param_name the name of the param
	 * @param {String} wanted_type the type that the param wands to be
	 * @param {Object} that the holder of the values
	 * @param {Object} data the data that holds the values.
	 * @param {Object} param_type the type of the data param.
	 **/
	param._getTime = function (layer, param_name, wanted_type, that, data) {
		var param_type = 'time'; //We will get the time as millisecs..
		var w, tw, time;
		var tw_def = {paused: true, useTick: true};
		var timeline = layer.timeline;
		var ease;
		
		var stm = easelSif._secsToMillis;
		that[param_name] = {};
		
		
		
		if (data.animated) {

			w = data.animated.waypoint
			that[param_name].value = stm(w[0][param_type]._value);

			tw = createjs.Tween.get(that[param_name], tw_def);


			if (w[0]._time !== "0s") {
				ease = easelSif._getEase(w[0]._before);
				time = stm(w[0]._time);
				tw.to( {value: stm(w[0][param_type]._value)},
					time, ease);
				
			}

					
			for (var i = 0; i < w.length - 1; i++) {
				ease = easelSif._getEase(w[i + 1]._before);
				time = stm(w[i + 1]._time) - stm(w[i]._time);						
				tw.to( {value: stm(w[i + 1][param_type]._value)},
					time, ease );
				
			}
			
			
			
			timeline.addTween(tw);

			
			param.convert._set( layer, that[param_name], wanted_type, 'integer');
		} else {
			if (!data[param_type]) alert(JSON.stringify(data) + "param_type : " + param_type + ' param_name : ' + param_name + ' layer type : ' + this.type);
			that[param_name].value = stm(data[param_type]._value);
			param.convert._set( layer, that[param_name], wanted_type, 'integer');
		}
	}
	
		
	/**
	 * RADIAL COMPOSITE
	 * @function param._getRadial_composite
	 * @param {Object} layer the layer that contains the param
	 * @param {String} param_name the name of the param
	 * @param {String} wanted_type the type that the param wands to be
	 * @param {Object} that the holder of the values
	 * @param {Object} data the data that holds the values.
	 * @param {Object} param_type the type of the data param.
	 **/
	param._getRadial_composite = function (layer, param_name, wanted_type, that, data) {	
		param_type = 'radial_composite';
		that[param_name] = {};
		that[param_name]._type = param_type;
		that[param_name].radial_composite = {};
		// get the defs
		if (data[param_type]._radius) {
			data[param_type].radius = layer.sifobj.sif.canvas.defs[ data[param_type]._radius ];
		}
		if (data[param_type]._theta) {
			data[param_type].theta = layer.sifobj.sif.canvas.defs[ data[param_type]._theta ];
		}
		
		param._set(layer, 'radius', 'real', that[param_name][param_type], data[param_type].radius);
		param._set(layer,'theta', 'angle', that[param_name][param_type], data[param_type].theta);
		param.convert._set( layer, that[param_name], wanted_type, param_type);
	}
	
//UNCONVERTED	
	/**
	 * COLOR
	 * @function param._getColor
	 * @param {Object} layer the layer that contains the param
	 * @param {String} param_name the name of the param
	 * @param {String} wanted_type the type that the param wands to be
	 * @param {Object} that the holder of the values
	 * @param {Object} data the data that holds the values.
	 * @param {Object} param_type the type of the data param.
	 **/
	param._getColor = function (layer, param_name, wanted_type, that, data) {
		//NOT CONVERTED.
		var param_type = 'color';
		var tw_def = {paused: true, useTick: true};
		var timeline = layer.timeline;
		that[param_name] = {};
		that[param_name].animated = true;
		
		if (data.animated) {
			w = data.animated.waypoint
			that[param_name].r = w[0][param_type].r;
			that[param_name].g = w[0][param_type].g;
			that[param_name].b = w[0][param_type].b;
			that[param_name].a = w[0][param_type].a;
			tw = createjs.Tween.get(that[param_name], tw_def);
				
			if (w[0]._time !== "0s") {
					tw.to( {r: w[0][param_type].r, g: w[0][param_type].g, b: w[0][param_type].b, a: w[0][param_type].a},
						easelSif._secsToMillis(w[0]._time), 
						easelSif._getEase(w[0]._before) );
			}

					
			for (var i = 0; i < w.length - 1; i++) {
				tw.to( {r: w[i + 1][param_type].r, g: w[i + 1][param_type].g, b: w[i + 1][param_type].b, a: w[i + 1][param_type].a},
					easelSif._secsToMillis(w[i + 1]._time) - easelSif._secsToMillis(w[i]._time),
					easelSif._getEase(w[i + 1]._before) );
			}
			
			timeline.addTween(tw);
		} else {
			that[param_name].r = data[param_type].r;
			that[param_name].g = data[param_type].g;
			that[param_name].b = data[param_type].b;
			that[param_name].a = data[param_type].a;
		}
	}
	
	/**
	 * GRADIENT
	 * @function param._getGradient
	 * @param {Object} layer the layer that contains the param
	 * @param {String} param_name the name of the param
	 * @param {String} wanted_type the type that the param wands to be
	 * @param {Object} that the holder of the values
	 * @param {Object} data the data that holds the values.
	 * @param {Object} param_type the type of the data param.
	 **/
	param._getGradient = function (layer, param_name, wanted_type, that, data, param_type) {
		//NOT CONVERTED.
		var param_type = 'gradient';
		var tw_def = {paused: true, useTick: true};
		var timeline = layer.timeline;
		that[param_name] = {};
		
		var pcolor,dcolor;
		if (data.animated) {
			w = data.animated.waypoint
			that[param_type] = {};
			that[param_type].color = [];
			for (var i = 0, ii = w[0].gradient.color.length; i < ii; i++) {
				that[param_type].color.push({});
				pcolor = that[param_type].color[i];
				dcolor = w[0].gradient.color[i];
				pcolor.pos = dcolor._pos;
				pcolor.r = dcolor.r;
				pcolor.g = dcolor.g;
				pcolor.b = dcolor.b;
				pcolor.a = dcolor.a;
				
				tw = createjs.Tween.get(pcolor, tw_def);
				if (w[0]._time !== "0s") {
					tw.to( {pos: dcolor._pos, r: dcolor.r, g: dcolor.g, b: dcolor.b, a: dcolor.a},
						easelSif._secsToMillis(w[0]._time), 
						easelSif._getEase(w[0]._before) );
					
				}
				for (var j = 0, jj = w.length - 1; j < jj; j++) {
					dcolor = w[j + 1].gradient.color[i];
					tw.to( {pos: dcolor._pos, r: dcolor.r, g: dcolor.g, b: dcolor.b, a: dcolor.a},
						easelSif._secsToMillis(w[j + 1]._time) - easelSif._secsToMillis(w[j]._time), 
						easelSif._getEase(w[j + 1]._before) );
					
				}
				timeline.addTween(tw);
			}
						
		} else {
			that[param_type] = {};
			that[param_type].color = [];
			for (var i = 0, ii = data[param_type].color.length; i < ii; i++) {
				that[param_type].color.push({});
				pcolor = that[param_type].color[i];
				dcolor = data[param_type].color[i];
				pcolor.pos = dcolor._pos;
				pcolor.r = dcolor.r;
				pcolor.g = dcolor.g;
				pcolor.b = dcolor.b;
				pcolor.a = dcolor.a;		
			}									
		}
	}
	
		
}());


<|start_filename|>src/Layers/import.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* import
* version 0.1.3
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
 (function() { 


/**
* It's the import layer but it's name Imoprt cause import is reserved word
* @class Import
* @extends Layer
* @constructor
* @param {Object} parent The parent of the Layer
* @param {Object} data The data for the Layer
**/	 
function Import (sifobj , data) {
	this.Bitmap_constructor();
	
	if (data) this.init(sifobj , data);
}

var p = createjs.extend(Import , createjs.Bitmap);

p.getConcatenatedMatrix = easelSif.group.prototype.getConcatenatedMatrix;
	/** 
	 * Initialization method.
	 * @method init
	 * @param {Object} parent The parent of the Layer
	 * @param {Object} data The data for the Layer
	 **/
	p.init = function (sifobj, data) {
		this.sifobj = sifobj;
		var preload = this.sifobj.preload;
		var _set = easelSif.param._set;
		var filename = data.filename.string;
		this.image = preload.getResult(this.sifobj.sifPath + filename);
		
		
		this.timeline = new createjs.Timeline();
		this.timeline.setPaused(true);
		
		_set(this, 'amount', 'real', this, data.amount);
		_set(this, 'blend_method', 'integer', this, data.blend_method);
		_set(this, 'tl', 'vector', this, data.tl);
		_set(this, 'br', 'vector', this, data.br);
		
		easelSif._addToDesc(this, data);
		
	}
	
// public methods:

	p.setPosition = function (position, delta) {
		this.timeline.setPosition(position);
		return position;
	}
	
	p.updateContext = function (ctx) {
		var that = this;
		var mtx = this.getMatrix(this._matrix);
		ctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty);
		ctx.globalAlpha *= that.amount.getValue();
		ctx.globalCompositeOperation = easelSif._getBlend( that.blend_method.getValue() );

		
	}
	
	p.getMatrix = function (matrix) {
		var that = this;
		var brx = this.br.getX();
		var bry = this.br.getY();
		var tlx = this.tl.getX();
		var tly = this.tl.getY();
		var w,h,sx,sy;
		
		w =  (brx - tlx);
		h = (tly - bry)

		if (w <= 0) {
			sx = -1;
			w *=-1;
		} else {
			sx = 1;
		}
		
		if (h <= 0) {
			sy = 1
			h *=-1;
		} else {
			sy = -1;
		}
		

		sx = sx / this.image.width * w;
		sy = sy / this.image.height * h;
			
			

		matrix = (matrix ? matrix.identity() : new createjs.Matrix2D())
		matrix.appendTransform(tlx, tly, sx, sy, 0, 0,0,0,0);

		return matrix;		
	}

	
easelSif.Import = createjs.promote(Import, 'Bitmap');
}());


<|start_filename|>libs/groupsat.js<|end_filename|>
/*
* @preserve Copyright (c) 2014 haramanai.
* bone
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
this.easelSif = this.easelSif || {};
(function() { 	
		

	
	function Bone(sifobj, data) {
		this.init(sifobj, data);
	}
	
	var p = Bone.prototype;
	
	p.init = function (sifobj, data) {
	
		var _set = easelSif.param._set;
		
		this.name = data.name.string;
		this.parent = data.parent.bone_valuenode._guid;
		this.sifobj = sifobj;
		this.timeline = new createjs.Timeline();
		this.guid = data._guid;
		
		_set(this, 'origin', 'vector', this, data.origin);
		_set(this, 'angle', 'angle', this, data.angle);
		_set(this, 'scalelx', 'real', this, data.scalelx);
		_set(this, 'width', 'real', this, data.width);
		_set(this, 'scalex', 'real', this, data.scalex);
		_set(this, 'tipwidth', 'real', this, data.tipwidth);
		_set(this, 'length', 'real', this, data.length);
		
		
		
		
		this._m = new createjs.Matrix2D(); 
		this._lm = new createjs.Matrix2D(); //different scale

		
		
		
		//console.log(this.guid);
		
	}
	

	
	p.setMatrix = function () {
		var parent = this.sifobj.sif.bones.guid[this.parent];
		var x = this.origin.getX();
		var y = this.origin.getY();
		var scalelx = this.scalelx.getValue();		
		var scalex = this.scalex.getValue();
		var angle = this.angle.getValue();
		var length = this.length.getValue();

		var sx = 1;

		if (parent) {
			this._m.copy(parent._lm);
			sx = parent.scalelx.getValue();
			a = parent.angle.getValue();
			
		} else {
			this._m.identity();

		}
		
		
		this._lm.copy(this._m);
		this._m.appendTransform(x *sx ,y  , scalelx * scalex , 1 , angle , 0, 0 , 0, 0);


		this._lm.appendTransform( x *sx  , y   , scalex  , 1, angle, 0, 0 , 0, 0);
		
	
		
	}
	
	
	p.setPosition = function (position) {
		var t = this.timeline;
		//console.log(this.name);
		t.setPosition(position);

		
		this.setMatrix();
		return position;
	}




easelSif.Bone = Bone;
}());



<|start_filename|>src/Layers/group.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* PasteCanvas
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
(function() { 

/**
* @class group
* @extends Layer
* @constructor
* @param {Object} parent The parent of the Layer
* @param {Object} data The data for the Layer
**/	 	
function group(sifobj, data) {
	'use strict'
	this.type = 'group';
	this.Container_constructor();
	this.sifobj = sifobj;	
	this.timeline = new createjs.Timeline();
	this.timeline.setPaused(true);
	this.transformMatrix = new createjs.Matrix2D();
	this.transformation = {group:this};
	this.unsynced = false;
	this.bone = ''; //keep reference even if there is no bone
	this.animated = true;
	
	if (data) this.init(sifobj , data);
}

var p = createjs.extend(group, createjs.Container);
	
	/** 
	 * Initialization method.
	 * @method init
	 * @param {Object} parent The parent of the Layer
	 * @param {Object} data The data for the Layer
	 **/
	p.init = function (sifobj, data) {
		var _set = easelSif.param._set;	
		this.timeline.duration = sifobj.timeline.duration;
		


		_set(this, 'amount', 'real', this, data.amount);
		_set(this, 'blend_method', 'integer', this, data.blend_method);
		_set(this, 'origin', 'vector', this, data.origin);


		var composite = data.transformation.composite;
		
		//COMPOSIT TRANSORMATION
		if (composite) {
			_set(this, 'offset', 'vector', this.transformation, composite.offset);
			_set(this, 'angle', 'angle', this.transformation, composite.angle);
			_set(this, 'scale', 'vector', this.transformation, composite.scale);
			_set(this, 'skew_angle', 'angle', this.transformation, composite.skew_angle);

			this.transformation.setTransformMatrix = group.setTransformMatrixComposite;
			this.scaleX = this.transformation.scale.getX();
		}
		
		//BONE TRANSFORMATION
		var bone_link = data.transformation.bone_link;
		if (bone_link) {
			this.bone = bone_link.bone[0].bone_valuenode._guid;
			bone_link = data.transformation.bone_link.base_value.composite;
			var base_value = {};
			
			_set(this, 'offset', 'vector', base_value, bone_link.offset);
			_set(this, 'angle', 'angle', base_value, bone_link.angle);
			_set(this, 'skew_angle', 'angle', base_value, bone_link.skew_angle);
			_set(this, 'scale', 'vector', base_value, bone_link.scale);
			
			this.transformation.base_value = base_value;

			this.transformation.setTransformMatrix = group.setTransformMatrixBone;

		}
		
		
		
		easelSif._addToDesc(this, data);

		if (data.canvas) {
			if (data.canvas.canvas) {
				this._getLayers(data.canvas.canvas.layer , this.sifPath);
			} else {
				var use = data.canvas._use;
				//console.log(use);
				if (use.search('#') > 0) {
					
					var r = this.sifobj.sifPath + use.slice(0,use.length - 1);
					//console.log(r);
					this._use = new easelSif.SifObject(r);

					this._use.sifPath = this.sifPath

					this.name = r;
					r = this._use.children;
					
					var list = this._use.children.slice(0);
					for (var i=0,l=list.length; i<l; i++) {
						this.addChild(list[i]);
					}
									
					this._use.removeAllChildren();
					
				} else {					
					this._getLayers(this.sifobj.sif.canvas.defs[data.canvas._use].canvas.layer);
				}
			}
		}

		this.transformation.setTransformMatrix();
	}
	
	p._getLayers = easelSif.SifObject.prototype._getLayers;
	
	p.moveChildrenTo = easelSif.SifObject.prototype.moveChildrenTo;
	


	/**
	 * moves the time line of the layer to the position
	 * @method setPosition
	 * param {Integer}
	 **/		
	p.setPosition = function (position, delta) {
		this.childAnimated = this.forcedAnimation;
		//For now the canvas
		this.animated = (this.bone)? true : easelSif._checkTimeline(this.timeline) || this.forcedAnimation;
		var scale;
		this.timeline.setPosition(position);
		this.transformation.setTransformMatrix();
		var new_pos = this.timeline.position;
		var ch = this.children;
		var ab;

		for (var i = 0, ii = ch.length; i < ii; i++) {
			if (ch[i].unsynced) {
				new_pos = ch[i].setPosition( ch[i].timeline.position + delta , delta);
			} else {
				new_pos = ch[i].setPosition(new_pos, delta);
			}
			
			if (ch[i].animated) {
				//ch[i].uncache();
				this.childAnimated = this.animated = true;
			}
			//console.log(ch[i].getBounds());
		}
		
		
		
		if (this.childAnimated) {this.uncache();}
		if (!this.childAnimated && !this.cacheID && this.type === 'group') {
			//this._bounds = null;
			scale = Math.abs(easelSif.getTotalScale(this));
			ab = this.getBounds();
			if (ab) {
				this.cache(ab.x , ab.y, ab.width, ab.height, scale);
				
			}
			
		}
		
		this.forcedAnimation = false;
		return position;
	}

	
	p.updateContext = function (ctx) {
		//This step is done from easeljs anyway.
		var mtx = this.getMatrix();
		ctx.globalAlpha *= this.amount.getValue();
		ctx.globalCompositeOperation = easelSif._getBlend( this.blend_method.getValue() );		
		ctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty);
		
	}
	
		
	
	group.setTransformMatrixBone = function () {
		var group = this.group;
		var bone = group.sifobj.sif.bones.guid[this.group.bone];
		var base = this.base_value;

		var orx = group.origin.getX() + base.offset.getX();
		var ory = group.origin.getY()+ base.offset.getY();

	
		
		var sx = base.scale.getX();
		var sy = base.scale.getY();
		var skew = base.skew_angle.getValue();

		var a = base.angle.getValue();
		
		//var matrix = bone._m.copy(bone._m);
		var matrix = group.transformMatrix.copy(bone._m);
		//console.log(JSON.stringify(matrix));
		//console.log(this.desc);
		if(bone.angle.getValue() <= a){ //I have no isea why is that so
			matrix.appendTransform(orx, ory, sx , sy, a, 0, skew ,0,0);
		} else {
			matrix.appendTransform(orx, ory, sx , sy, a, 0, 0 ,0,0);
			if (skew) matrix.appendTransform(0, 0, 1, 1, 0, skew , 0 , 0 , 0);
		}

	}
	
	group.setTransformMatrixComposite = function () {
		var tr = this;
		var group = this.group;
		var orx = group.origin.getX() + tr.offset.getX();
		var ory = group.origin.getY()+ tr.offset.getY();

	
		
		var sx = tr.scale.getX();
		var sy = tr.scale.getY();
		var skew = tr.skew_angle.getValue();

		var a = tr.angle.getValue();
		var matrix = group.transformMatrix;
		matrix.identity()
		matrix.appendTransform(orx, ory, sx, sy, a, 0,0,0,0);
		if (skew) matrix.appendTransform(0, 0, 1, 1, 0, skew , 0 , 0 , 0);
	}




easelSif.group = createjs.promote(group, 'Container');
}());


<|start_filename|>src/Layers/linear_gradient.js<|end_filename|>
/*
* Copyright (c) 2012 haramanai.
* linear_gradient
* version 0.2.
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
 (function() { 

/**
* @class circle
* @extends Layer
* @constructor
* @param {Object} parent The parent of the Layer
* @param {Object} data The data for the Layer
**/	 	
function linear_gradient(sifobj, data) {
	this.DisplayObject_constructor();
	this.sifobj = sifobj;
	this.animated = true;
	if (data) this.init(data);
}

var p = createjs.extend(linear_gradient, createjs.DisplayObject);

	/** 
	 * Initialization method.
	 * @method init
	 * @param {Object} parent The parent of the Layer
	 * @param {Object} data The data for the Layer
	 **/
	p.init = function (data) {
		var _set = easelSif.param._set;
		this.timeline = new createjs.Timeline();
		this.timeline.setPaused(true);
		this.timeline.duration = this.sifobj.timeline.duration;
		//this.initLayer(parent, data);
		_set(this, 'amount', 'real', this, data.amount);
		_set(this, 'blend_method', 'integer', this, data.blend_method);
		_set(this, 'p1', 'vector', this, data.p1);	
		_set(this, 'p2', 'vector', this, data.p2);
		_set(this, 'gradient', 'gradient', this, data.gradient);
	}

	/**
	 * Draws the layer
	 * @method draw
	 **/
	p.draw = function (ctx) {
		var grd = ctx.createLinearGradient(this.p1.getX(), this.p1.getY(), this.p2.getX(), this.p2.getY() );
		var color = this.gradient.color;
		
		for (var i = 0, ii = color.length; i < ii; i++) {
			grd.addColorStop(color[i].pos, 'rgba('+ Math.round(color[i].r * 256) + ', ' + Math.round(color[i].g * 256)  + ', ' + Math.round(color[i].b * 256)  + ', ' + color[i].a  + ')');
		}
		
		ctx.globalAlpha = this.amount.getValue();
		ctx.globalCompositeOperation = easelSif._getBlend(this.blend_method.getValue());		
		ctx.fillStyle = grd;

		var ab = this.parent.getBounds();
		ctx.fillRect(ab.x , ab.y, ab.width , ab.height);
		//ctx.fillRect(-1000, -1000, 2000 , 2000);
	}
	
	p.setPosition = function (position) {
		this.timeline.setPosition(position);
		this.animated = easelSif._checkTimeline(this.timeline);
		return position;
	}


easelSif.linear_gradient = createjs.promote(linear_gradient, "DisplayObject");
}());


<|start_filename|>src/Layers/rotate.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* rotate
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
 (function() { 

/**
* @class rotate
* @extends Layer
* @constructor
* @param {Object} parent The parent of the Layer
* @param {Object} data The data for the Layer
**/	 	
function rotate(sifobj, data) {
	this.Container_constructor();
	this.type = 'rotate';
	this.sifobj = sifobj;
	
	this.timeline = new createjs.Timeline();
	this.transformMatrix = new createjs.Matrix2D();
	
	if (data) this.init(sifobj , data);
}

var p = createjs.extend(rotate , createjs.Container);

	/** 
	 * Initialization method.
	 * @method init
	 * @param {Object} parent The parent of the Layer
	 * @param {Object} data The data for the Layer
	 **/
	p.init = function (sifobj, data) {
		var _set = easelSif.param._set;

		this.timeline.setPaused(true);
		this.timeline.duration = this.sifobj.timeline.duration;
		this._setParams(data);
		easelSif._addToDesc(this, data);
		
		this.getMatrix();

	}
	
	p._setParams = function (data) {
		var _set = easelSif.param._set;
		_set(this, 'origin', 'vector', this, data.origin);
		_set(this, 'amount', 'angle', this, data.amount);		
	}
	
	p.setPosition = easelSif.group.prototype.setPosition;

	
	p.setTransformMatrix = function () {
		var orx = this.origin.getX();
		var ory = this.origin.getY();
		var angle = this.amount.getValue();
		this.transformMatrix.identity().appendTransform(orx, ory, 1, 1, angle, 0,0,orx,orx);
	}

easelSif.rotate = createjs.promote(rotate, 'Container');
}());


<|start_filename|>libs/bodysat.js<|end_filename|>
/*
* @preserve Copyright (c) 2014 haramanai.
* BodySat
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

(function() { 	
		

	
	function BodySat(group, collisionLayer) {
		var V = SAT.Vector;
		var P = SAT.Polygon;
		this.collisionLayerName = (collisionLayer)?collisionLayer:'easelSif_collision';
		this.group = group;
		this.polygon = null;
		this.response = new SAT.Response();
		
		if (group) {
			var e = group.getChildByName(this.collisionLayerName).bline.entry;
			var offset = group.transformation.offset;
			
			// A square
			this.polygon = new P(new V(offset.x,offset.y), [
			  new V(e[0].composite.point.x,e[0].composite.point.y), 
			  new V(e[1].composite.point.x,e[1].composite.point.y), 
			  new V(e[2].composite.point.x,e[2].composite.point.y), 
			  new V(e[3].composite.point.x,e[3].composite.point.y)
			]);
		}

	}
	
	var p = BodySat.prototype;
	
	p.updateGroupPos = function() {
		var p = this.polygon.pos;
		var o = this.group.transformation.offset;
		o.x = p.x;
		o.y = p.y;
	}
	
	p.boundFromColliders = function (colliders) {
		var collided;
		for (var i =0; i < colliders.length; i++) {
			//colliders[i].checkAnim();
			collided = SAT.testPolygonPolygon(this.polygon, colliders[i].polygon, this.response);
			if (collided) {
				this.response.clear();
				this.polygon.pos.sub(this.response.overlapV);
			}
		}
		
	}
	
	p.checkAnim = function() {
		var offset = this.group.transformation.offset;
		var pos = this.polygon.pos;
		if (offset.x !== pos.x || offset.y !== pos.y) {
			console.log('wrong');
			pos.x = offset.x; pos.y = offset.y;
		}
	}



window.BodySat = BodySat;
}());



<|start_filename|>src/Param/real.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* real
* version 0.2.
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
this.easelSif.param = this.easelSif.param||{};
 (function() { 

var real =  {};

real.degsToRad = 0.0174532925;

real._setConvert = function (layer, param, wanted_type, is_type) {
	var type = easelSif.param.real;
	if (wanted_type === is_type) {
		param.getValue = type.getValue;
		param.setValue = type.setValue;
	}
	else if (type[is_type]){
		param.getValue = type[is_type];
	}
	else {
		alert('no convert for real to ' + is_type);
	}
	

}

real.setValue = function (v) {
	this.value = v;
}

real.getValue = function () {
	return this.value;
}

real.add = function () {
	return ( this.add.lhs.getValue() + this.add.rhs.getValue() ) * this.add.scalar.getValue();
}

real.subtract = function () {
	return ( this.subtract.lhs.getValue() - this.subtract.rhs.getValue() ) * this.subtract.scalar.getValue();
}

real.scale = function () {
	return this.scale.link.getValue() * this.scale.scalar.getValue();
}

real.cos = function () {
	return this.cos.amp.getValue() * Math.cos(this.cos.angle.getValue() * real.degsToRad);
}

real.sine = function () {
	return this.sine.amp.getValue() * Math.sin(this.sine.angle.getValue() * real.degsToRad);
}

real.dotproduct = function () {
	var x1,y1,x2,y2;
	x1 = this.dotproduct.lhs.getX();
	y1 = this.dotproduct.lhs.getY();
	x2 = this.dotproduct.rhs.getX();
	y2 = this.dotproduct.rhs.getY();
	return x1*x2 + y1*y2;
}
	
real.exp = function () {
	return Math.exp(this.exp.exp.getValue()) * this.exp.scale.getValue();
}

real.logarithm = function () {
	var link = this.logarithm.link.getValue();
	if (link >= this.logarithm.epsilon.getValue()) {
		return Math.log( link );
	}
	return -this.logarithm.infinite.getValue();
}

real.reciprocal = function () {
	var link = this.reciprocal.link.getValue();
	if (link >= this.reciprocal.epsilon.getValue()) {
		return 1/link;
	}
	return -this.reciprocal.infinite.getValue();
}



easelSif.param.real = real;
}());


<|start_filename|>src/Layers/text.js<|end_filename|>
/*
* Copyright (c) 2012 haramanai.
* version 0.1.
* text
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
 (function() { 

/**
* @class circle
* @extends Layer
* @constructor
* @param {Object} parent The parent of the Layer
* @param {Object} data The data for the Layer
**/	 	
function text(sifobj, data) {
	this.sifobj = sifobj;
	this.init(data);
}

var p = text.prototype = new createjs.Text();

	/** 
	 * Initialization method.
	 * @method init
	 * @param {Object} parent The parent of the Layer
	 * @param {Object} data The data for the Layer
	 **/
	p.init = function (data) {
		var _set = sifPlayer.param._set;
		
		this.timeline = new createjs.Timeline();
		this.timeline.setPaused(true);

		_set(this, 'amount', 'real', this, data.amount);
		_set(this, 'blend_method', 'integer', this, data.blend_method);
		_set(this, 'text', 'string', this, data.text);	
		_set(this, 'color', 'color', this, data.color);
		_set(this, 'family', 'string', this, data.family);
		_set(this, 'style', 'integer', this, data.style);
		_set(this, 'weight', 'integer', this, data.weight);
		_set(this, 'compress', 'real', this, data.compress);
		_set(this, 'vcompress', 'real', this, data.vcompress);
		_set(this, 'size', 'vector', this, data.size);
		_set(this, 'orient', 'vector', this, data.orient);
		_set(this, 'origin', 'vector', this, data.origin);
		
		easelSif._addToDesc(this, data);
		
		var s = easelSif.getTotalScale(this);
		this.initialize(this.text.string, '10px ' + this.family.string, "#ff7700");
		this.textAlign = 'center';
		this.textBaseline = 'middle';
		//float sizex=1.75*fabs(size[0])*fabs(wsx);
		//float sizey=1.75*fabs(size[1])*fabs(wsy);
		//float vscale=sizey/sizex;
		this.scaleX = 1.75 * Math.abs(this.size.getX()) * this.scaleX /  10;
		this.scaleY = -1.75 * Math.abs(this.size.getY()) * this.scaleY /  10;
		this.x = this.origin.getX();
		this.y = this.origin.getY();
		this.regX = -this.orient.getX() * this.scaleX * 10;
		this.regY = this.orient.getY() * this.scaleY * 10;
		//this.scaleX = this.size.getX();
		//this.scaleY = -this.size.getY();
		this.updateValues();
		
	}

	
	p.getAlling = function () {
		// New expanded workdesc values
		var obj = this.sifobj;
		var ww = this.sifobj.width;
		var wh = this.get_h();
		var wtlx=workdesc.get_tl()[0];
		var wtly=workdesc.get_tl()[1];
		var wpw=workdesc.get_pw();
		var wph=workdesc.get_ph();
		var wsx=1/wpw;
		var wsy=1/wph;
		var wtx=(-wtlx+origin[0])*wsx;
		var wty=(-wtly+origin[1])*wsy;
				
	}
	
	p.setPosition = function (position) {
		this.timeline.setPosition(position);
		this.updateValues();
		return position;
	}
	
	p.updateValues = function () {
		//this.x = this.origin.getX();
		//this.y = this.origin.getY();
		this.alpha = this.amount.getValue();
		this.compositeOperation = easelSif._getBlend( this.blend_method.getValue() );
		
	}


sifPlayer.easelSif.text = text;
}());


<|start_filename|>src/Layers/stretch.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* stretch
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
 (function() { 

/**
* @class rotate
* @extends Layer
* @constructor
* @param {Object} parent The parent of the Layer
* @param {Object} data The data for the Layer
**/	 	
function stretch(sifobj, data) {
	this.type = 'stretch';
	this.rotate_constructor(sifobj , data);

}

var p = createjs.extend(stretch, easelSif.rotate);

	
	p._setParams = function (data) {
		var _set = easelSif.param._set;
		_set(this, 'amount', 'vector', this, data.amount);
		_set(this, 'center', 'vector', this, data.center);
		
		
	}
	
	
	p.getMatrix = function (matrix) {
		var that = this;		
		var orx = this.center.getX();
		var ory = this.center.getY();
		var sx = this.scaleX = this.amount.getX();
		var sy = this.amount.getY();
		matrix = (matrix ? matrix.identity() : new createjs.Matrix2D())
		matrix.appendTransform(orx, ory, sx, sy, 0, 0,0,orx,orx);

		return matrix;
	}
		

easelSif.stretch = createjs.promote(stretch, 'rotate');
}());


<|start_filename|>src/Param/angle.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* angle
* version 0.2.
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
this.easelSif.param = this.easelSif.param||{};
 (function() { 

var angle =  {};


angle._setConvert = function (layer, param, wanted_type, is_type) {
	var type = easelSif.param.angle;
	
	if (wanted_type === is_type) {
		param.getValue = type.getValue;
		param.setValue = type.setValue;
	}
	else if (type[is_type]){
		param.getValue = type[is_type];
	}
	else {
		alert('no convert for angle to ' + is_type);
	}
	
	
}
	
angle.setValue = function (v) {
	this.value = v;
}


angle.getValue = function () {
	return this.value;
}

angle.add = function () {
	return ( this.add.lhs.getValue() + this.add.rhs.getValue() ) * this.add.scalar.getValue();
}

angle.subtract = function () {
	return ( this.subtract.lhs.getValue() - this.subtract.rhs.getValue() ) * this.subtract.scalar.getValue();
}


angle.scale = function () {
	return this.scale.link.getValue() * this.scale.scalar.getValue();
}

angle.atan2 = function () {
	return Math.atan2(this.atan2.y.getValue(), this.atan2.x.getValue()) / Math.PI * 180.0;
}
	
angle.dotproduct = function () {
	var x1,y1,x2,y2, l;
	x1 = this.dotproduct.lhs.getX();
	y1 = this.dotproduct.lhs.getY();
	x2 = this.dotproduct.rhs.getX();
	y2 = this.dotproduct.rhs.getY();

	return Math.acos( (x1*x2 + y1*y2) / (Math.sqrt(x1*x1 + y1*y1) * Math.sqrt(x2*x2 + y2*y2))) / Math.PI * 180.0;
}

angle.vectorangle = function () {
	return Math.atan2(this.vectorangle.vector.getY(), this.vectorangle.vector.getX()) / Math.PI * 180.0;
}




easelSif.param.angle = angle;
}());


<|start_filename|>src/Param/composite.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* composite
* version 0.2.
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
this.easelSif.param = this.easelSif.param||{};
 (function() { 

var composite =  {};
	/**
	 * COMPOSITE
	 * @function param._getComposite
	 * @param {Object} layer the layer that contains the param
	 * @param {String} param_name the name of the param
	 * @param {String} wanted_type the type that the param wands to be
	 * @param {Object} that the holder of the values
	 * @param {Object} data the data that holds the values.
	 * @param {Object} param_type the type of the data param.
	 **/
composite._get = function (layer, param_name, wanted_type, that, data) {
	var param = easelSif.param;
	var _set = param._set;
	
	param_type = 'composite';
	
	that[param_name] = {};
	that[param_name]._type = param_type;

	that[param_name].composite = {};
	
	if (data.composite._type === 'vector') {

				// get the defs
		if (data[param_type]._x) {
			data[param_type].x = layer.sifobj.sif.canvas.defs[ data[param_type]._x ];
		}
		if (data[param_type]._y) {
			data[param_type].y = layer.sifobj.sif.canvas.defs[ data[param_type]._y ];
		}


		_set(layer, 'x', 'real', that[param_name].composite, data.composite.x);
		_set(layer, 'y', 'real', that[param_name].composite, data.composite.y);
		
		param.convert._set( layer, that[param_name], wanted_type, param_type);

		
	}
	else if (data.composite._type === 'bline_point') {
		var composite = that[param_name].composite;
		var param_type = data.composite._type;
		if (data.composite._point) data.composite.point = layer.sifobj.sif.canvas.defs[data.composite._point];
		_set(layer, 'point', 'vector', composite, data.composite.point);
		_set(layer, 'width', 'real', composite, data.composite.width);
		_set(layer, 'origin', 'real', composite, data.composite.origin);
		_set(layer, 'split', 'bool', composite, data.composite.split);
		_set(layer, 't1', 'vector', composite, data.composite.t1);
		_set(layer, 't2', 'vector', composite, data.composite.t2);
		param.convert._set( layer, that[param_name].composite, wanted_type, param_type, data.composite.point.animated || data.composite.width.animated || data.composite.origin.animated || data.composite.t1.animated || data.composite.t2.animated);

	}
}	



composite._setConvert = function (layer, param, wanted_type, is_type) {
	var type = composite;
	
	if ( is_type === 'bline_point' ) {
		param.getPoint = type.getPoint;
		param.getT1 = type.bline_point_getT1;
		param.getT2 = type.bline_point_getT2;
	} else {
		alert('new type of point');
	}
	
	
}
composite.getPoint = function () {
	//if (this.point.composite) alert(this.point.getX());	
	return this.point;
}

composite.bline_point_getPoint = function () {
	//alert(JSON.stringify(this.point));
	return this.point;
}

//Extra for rendering
composite.bline_point_getT1 = function () {
	
	return {x: this.t1.getX() / 3, y: this.t1.getY() / 3};
}

composite.bline_point_getT2 = function () {
	return {x: this.t2.getX() / 3, y: this.t2.getY() / 3};
}

	
	




easelSif.param.composite = composite;
}());


<|start_filename|>src/Layers/timeloop.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* timeloop
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
 (function() { 

/**
* @class timeloop
* @extends Layer
* @constructor
* @param {Object} parent The parent of the Layer
* @param {Object} data The data for the Layer
**/	 	
function timeloop(sifobj , data) {
	this.DisplayObject_constructor();
	this.type = 'timeloop';
	if (data) this.init(sifobj , data);
}

var p = createjs.extend(timeloop, createjs.DisplayObject);


	/** 
	 * Initialization method.
	 * @method init
	 * @param {Object} parent The parent of the Layer
	 * @param {Object} data The data for the Layer
	 **/
	p.init = function (sifobj, data) {
		this.sifobj = sifobj;
		var _set = easelSif.param._set;	
		this.name = (data._desc)?data._desc:data._type;
		this.timeline = new createjs.Timeline();
		this.timeline.setPaused(true);
		this.timeline.duration = this.sifobj.timeline.duration;
		
		
		_set(this, 'link_time', 'integer', this, data.link_time);
		_set(this, 'local_time', 'integer', this, data.local_time);
		_set(this, 'duration', 'integer', this, data.duration);
		
		easelSif._addToDesc(this, data);
		
	};
	
	
	/**
	 * moves the time line of the layer to the position
	 * @method goto
	 **/		
	p.setPosition = function (position) {
		this.timeline.tick( position - this.timeline.position);
		
		var duration = this.duration.getValue();
		var link_time = this.link_time.getValue();
		var local_time = this.local_time.getValue();
		var new_pos = (position + local_time) % duration;
		if (duration != 0) {
			if (duration > 0) {	
				new_pos += link_time;
			} else {
				new_pos = link_time - new_pos;
			}
		} else {
			new_pos = link_time;
		}

		
		return new_pos;
	}
	
	
	



easelSif.timeloop = createjs.promote(timeloop , 'DisplayObject');
}());



<|start_filename|>src/Layers/region.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* region
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
(function() { 

/**
* @class region
* @extends Shape
* @constructor
**/	
function region(sifobj, data) {
	'use strict'
	var _set = easelSif.param._set;
	this.Shape_constructor();
	this.timeline = new createjs.Timeline();
	this.timeline.setPaused(true);
	this.bline = {};
	this.bline.sifobj = null;
	this.bline.timeline = new createjs.Timeline();
	this.bline.timeline.setPaused(true);
	this.bline.entry = [];
	this.transformMatrix = new createjs.Matrix2D();
	this.entries = null;
	this.unsynced = false;
	
	if (data) {

		this.sifobj = sifobj;
		this.bline.sifobj = this.sifobj;
		this.visible = data._active;

	
		this._getBline(data.bline);
		
		
		_set(this, 'blend_method', 'integer', this, data.blend_method);
		_set(this, 'amount', 'real', this, data.amount);
		_set(this, 'origin', 'vector', this, data.origin);
		_set(this.bline, 'color', 'color', this, data.color);
		if (data.width) { _set(this.bline, 'width', 'real', this, data.width); }
		
		
		easelSif._addToDesc(this, data);

		this.entries = this.collectEntries();
		this.makeShape();
		this.setTransformMatrix();

	}

}

var p = createjs.extend(region, createjs.Shape);



	/**
	 * Gets the bline data
	 * @method _getBline
	 **/		
	p._getBline = function (data) {
		var _set = easelSif.param._set;

		var w, tw;

		//LOOP
		this.bline.loop = data.bline._loop;
		
		for (var i = 0, ii = data.bline.entry.length; i < ii; i++) {
			
			var e = {};
			//if (data.bline.entry[i].composite.point.composite) alert('in');
			_set(this.bline, 'composite', 'composite', e, data.bline.entry[i]);
			this.bline.entry.push(e.composite);
			
		}
		//alert(JSON.stringify(this.bline.entry[2]));
	}
	
		/**
	 * Collect the Entries of the bline and sets aabb
	 * @method draw
	 * @param {CanvasRenderingContext2D} } ctx The canvas 2D context object to draw into.
	 **/	
	p.collectEntries = function () {
		var e = [];
		var e1, e2;
		
		e1 = this.bline.entry[0].composite.getPoint();
		e.push([e1.getX(), e1.getY()]);
	
		for (var i = 0, ii = this.bline.entry.length - 1; i !== ii; i++) {
			
			e1 = this.bline.entry[i].composite;
			e2 = this.bline.entry[i + 1].composite;
			

			if (e1.split.getValue()) {
				e.push(this._bezierEntry( e1.getPoint(), e2.getPoint(), e1.getT2(), e2.getT1()));
			} else {
				e.push(this._bezierEntry( e1.getPoint(), e2.getPoint(), e1.getT1(), e2.getT1()));

			}

		}
		if (this.bline.loop) {
			e1 = this.bline.entry[ this.bline.entry.length - 1 ].composite;
			e2 = this.bline.entry[0].composite;
			
			if (e1.split.getValue()) {
				e.push(this._bezierEntry( e1.getPoint(), e2.getPoint(), e1.getT2(), e2.getT1()));
			} else {
				e.push(this._bezierEntry( e1.getPoint(), e2.getPoint(), e1.getT1(), e2.getT1()));
			}
		}

		return e;
	}
	
	p._bezierEntry= function (_p1, _p2, _t1, _t2) {
		
		var _cp1 = {};
		var _cp2 = {};

		_cp1.x = _t1.x + _p1.getX();
		_cp1.y = _t1.y + _p1.getY();

		_cp2.x = -_t2.x + _p2.getX();
		_cp2.y = -_t2.y + _p2.getY();

		//ctx.bezierCurveTo(_cp1.x, _cp1.y, _cp2.x, _cp2.y, _p2.getX(), _p2.getY());
		return [_cp1.x, _cp1.y, _cp2.x, _cp2.y, _p2.getX(), _p2.getY()];
	}

	p.makeShape = function () {
		var e = this.entries;
		var g = this.graphics;
		
		
		g.clear();
		g.f( createjs.Graphics.getRGB( Math.round(this.color.r * 256),Math.round(this.color.g * 256),Math.round(this.color.b * 256), this.color.a) );
		
		g.mt( e[0][0], e[0][1] );
		for (var i = 1, ii = e.length; i !== ii; i++) {			
			g.bt(e[i][0], e[i][1], e[i][2], e[i][3], e[i][4], e[i][5]);
			
		}
		g.ef();
		
	}
	
	p.setPosition = function (position, delta) {
		this.timeline.setPosition(position);
		this.bline.timeline.setPosition(position);
		this.animated = easelSif._checkTimeline(this.timeline);	
		this.updateShape();
		return position;
	}
	
	p.updateShape = function () {
		var e;
		
		var width = (this.width) ? this.width.getValue() : null; 
		if (easelSif._checkTimeline(this.bline.timeline)) {			
				this.entries = this.collectEntries();
				this.makeShape();
				this.uncache();
				this.animated = true;
		} else {
			if (!this.cacheID) {
				var aabb = easelSif.aabbFromEntries(this.entries , (this.width)?this.width.getValue():0);
				this.setBounds(aabb[0] , aabb[1], aabb[2] - aabb[0], aabb[3] - aabb[1]);
				var scale = Math.abs(easelSif.getTotalScale(this));
				this.cache(this._bounds.x, this._bounds.y, this._bounds.width, this._bounds.height, scale);
				//console.log(scale);
			}
		}

	}
	
	
	
	p.setTransformMatrix = function () {
		this.transformMatrix.identity().appendTransform(this.origin.getX(), this.origin.getY(), 1, 1, 0, 0,0,0,0);
	}
	



easelSif.region = createjs.promote(region, "Shape");
}());


<|start_filename|>src/Layers/zoom.js<|end_filename|>
/*
* Copyright (c) 2014 haramanai.
* zoom
* version 0.2
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

 (function() { 

/**
* @class zoom
* @constructor
* @param {Object} parent The parent of the Layer
* @param {Object} data The data for the Layer
**/	 	
function zoom(sifobj, data) {
	this.type = 'zoom';
	this.rotate_constructor(sifobj, data);
}

var p = createjs.extend(zoom , easelSif.rotate);

	/** 
	 * Initialization method.
	 * @method init
	 * @param {Object} parent The parent of the Layer
	 * @param {Object} data The data for the Layer
	 **/
	p._setParams = function (data) {
		var _set = easelSif.param._set;
		_set(this, 'center', 'vector', this, data.center);
		_set(this, 'amount', 'real', this, data.amount);
	}

	p.getMatrix = function (matrix) {
	
		var orx = this.center.getX();
		var ory = this.center.getY();
		var zoom = this.scaleX = Math.exp(this.amount.getValue());
		matrix = (matrix ? matrix.identity() : new createjs.Matrix2D())
		matrix.appendTransform(orx, ory, zoom, zoom, 0, 0,0,orx/zoom,orx/zoom);
		
		return matrix;
		
	}


easelSif.zoom = createjs.promote(zoom , 'rotate');
}());
