切水果游戏曾经是一款风靡手机的休闲游戏,今天要介绍的就是一款网页版的切水果游戏,由javascript和html5实现,虽然功能和原版的相差很大,但是基本的功能还是具备了,还是模仿挺逼真的。有一定javascript水平的朋友可以看看源代码,相信你的javascript水平会有很大提升。
在线演示源码下载
所有javascript代码
/**
* this file was compiled by jsbuild 0.9.6
* @date fri, 20 jul 2012 16:21:18 utc
* @author dron
* @site http://ucren.com
*/
void function(global){
var mapping = {}, cache = {};
global.startmodule = function(m){
require(m).start();
};
global.define = function(id, func){
mapping[id] = func;
};
global.require = function(id){
if(!/\.js$/.test(id))
id += '.js';
if(cache[id])
return cache[id];
else
return cache[id] = mapping[id]({});
};
}(this);
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\collide.js
*/
define("scripts/collide.js", function(exports){
var fruit = require("scripts/factory/fruit");
var ucren = require("scripts/lib/ucren");
var fruits = fruit.getfruitinview();
/**
* 碰撞检测
*/
exports.check = function( knife ){
var ret = [], index = 0;
fruits.foreach(function( fruit ){
var ck = lineinellipse(
knife.slice( 0, 2 ),
knife.slice( 2, 4 ),
[ fruit.originx, fruit.originy ],
fruit.radius
);
if( ck )
ret[ index ++ ] = fruit;
});
return ret;
};
function sqr(x){
return x * x;
}
function sign(n){
return n < 0 ? -1 : ( n > 0 ? 1 : 0 );
}
function equation12( a, b, c ){
if(a == 0)return;
var delta = b * b - 4 * a * c;
if(delta == 0)
return [ -1 * b / (2 * a), -1 * b / (2 * a) ];
else if(delta > 0)
return [ (-1 * b + math.sqrt(delta)) / (2 * a), (-1 * b - math.sqrt(delta)) / (2 * a) ];
}
// 返回线段和椭圆的两个交点,如果不相交,返回 null
function linexellipse( p1, p2, c, r, e ){
// 线段:p1, p2 圆心:c 半径:r 离心率:e
if (r <= 0) return;
e = e === undefined ? 1 : e;
var t1 = r, t2 = r * e, k;
a = sqr( t2) * sqr(p1[0] - p2[0]) + sqr(t1) * sqr(p1[1] - p2[1]);
if (a <= 0) return;
b = 2 * sqr(t2) * (p2[0] - p1[0]) * (p1[0] - c[0]) + 2 * sqr(t1) * (p2[1] - p1[1]) * (p1[1] - c[1]);
c = sqr(t2) * sqr(p1[0] - c[0]) + sqr(t1) * sqr(p1[1] - c[1]) - sqr(t1) * sqr(t2);
if (!( k = equation12(a, b, c, t1, t2) )) return;
var result = [
[ p1[0] + k[0] * (p2[0] - p1[0]), p1[1] + k[0] * (p2[1] - p1[1]) ],
[ p1[0] + k[1] * (p2[0] - p1[0]), p1[1] + k[1] * (p2[1] - p1[1]) ]
];
if ( !( ( sign( result[0][0] - p1[0] ) * sign( result[0][0] - p2[0] ) <= 0 ) &&
( sign( result[0][1] - p1[1] ) * sign( result[0][1] - p2[1] ) <= 0 ) ) )
result[0] = null;
if ( !( ( sign( result[1][0] - p1[0] ) * sign( result[1][0] - p2[0] ) <= 0 ) &&
( sign( result[1][1] - p1[1] ) * sign( result[1][1] - p2[1] ) <= 0 ) ) )
result[1] = null;
return result;
}
// 判断计算线段和椭圆是否相交
function lineinellipse( p1, p2, c, r, e ){
var t = linexellipse( p1, p2, c, r, e );
return t && ( t[0] || t[1] );
};
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\control.js
*/
define("scripts/control.js", function(exports){
var ucren = require("scripts/lib/ucren");
var knife = require("scripts/object/knife");
var message = require("scripts/message");
var state = require("scripts/state");
var canvasleft, canvastop;
canvasleft = canvastop = 0;
exports.init = function(){
this.fixcanvaspos();
this.installdragger();
this.installclicker();
};
exports.installdragger = function(){
var dragger = new ucren.basicdrag({ type: "calc" });
dragger.on( "returnvalue", function( dx, dy, x, y, kf ){
if( kf = knife.through( x - canvasleft, y - canvastop ) )
message.postmessage( kf, "slice" );
});
dragger.on( "startdrag", function(){
knife.newknife();
});
dragger.bind( document.documentelement );
};
exports.installclicker = function(){
ucren.addevent( document, "click", function(){
if( state( "click-enable" ).ison() )
message.postmessage( "click" );
});
};
exports.fixcanvaspos = function(){
var de = document.documentelement;
var fix = function( e ){
canvasleft = ( de.clientwidth - 640 ) / 2;
canvastop = ( de.clientheight - 480 ) / 2 - 40;
};
fix();
ucren.addevent( window, "resize", fix );
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\game.js
*/
define("scripts/game.js", function(exports){
/**
* game logic
*/
var timeline = require("scripts/timeline");
var ucren = require("scripts/lib/ucren");
var sound = require("scripts/lib/sound");
var fruit = require("scripts/factory/fruit");
var score = require("scripts/object/score");
var message = require("scripts/message");
var state = require("scripts/state");
var lose = require("scripts/object/lose");
var gameover = require("scripts/object/game-over");
var knife = require("scripts/object/knife");
// var sence = require("scripts/sence");
var background = require("scripts/object/background");
var light = require("scripts/object/light");
var scorenumber = 0;
var random = ucren.randomnumber;
var volleynum = 2, volleymultiplenumber = 5;
var fruits = [];
var gameinterval;
var snd;
var boomsnd;
// fruit barbette
var barbette = function(){
if( fruits.length >= volleynum )
return ;
var startx = random( 640 ), endx = random( 640 ), starty = 600;
var f = fruit.create( startx, starty ).shotout( 0, endx );
fruits.push( f );
snd.play();
barbette();
};
// start game
exports.start = function(){
snd = sound.create( "sound/throw" );
boomsnd = sound.create( "sound/boom" );
timeline.settimeout(function(){
state( "game-state" ).set( "playing" );
gameinterval = timeline.setinterval( barbette, 1e3 );
}, 500);
};
exports.gameover = function(){
state( "game-state" ).set( "over" );
gameinterval.stop();
gameover.show();
// timeline.settimeout(function(){
// // sence.switchsence( "home-menu" );
// // todo: require 出现互相引用时,造成死循环,这个问题需要跟进,这里暂时用 postmessage 代替
// message.postmessage( "home-menu", "sence.switchsence" );
// }, 2000);
scorenumber = 0;
volleynum = 2;
fruits.length = 0;
};
exports.applyscore = function( score ){
if( score > volleynum * volleymultiplenumber )
volleynum ++,
volleymultiplenumber += 50;
};
exports.sliceat = function( fruit, angle ){
var index;
if( state( "game-state" ).isnot( "playing" ) )
return;
if( fruit.type != "boom" ){
fruit.broken( angle );
if( index = fruits.indexof( fruit ) )
fruits.splice( index, 1 );
score.number( ++ scorenumber );
this.applyscore( scorenumber );
}else{
boomsnd.play();
this.pauseallfruit();
background.wobble();
light.start( fruit );
}
};
exports.pauseallfruit = function(){
gameinterval.stop();
knife.pause();
fruits.invoke( "pause" );
};
// message.addeventlistener("fruit.falloff", function( fruit ){
// var index;
// if( ( index = fruits.indexof( fruit ) ) > -1 )
// fruits.splice( index, 1 );
// });
message.addeventlistener("fruit.remove", function( fruit ){
var index;
if( ( index = fruits.indexof( fruit ) ) > -1 )
fruits.splice( index, 1 );
});
var eventfruitfalloutofviewer = function( fruit ){
if( fruit.type != "boom" )
lose.showloseat( fruit.originx );
};
state( "game-state" ).hook( function( value ){
if( value == "playing" )
message.addeventlistener( "fruit.falloutofviewer", eventfruitfalloutofviewer );
else
message.removeeventlistener( "fruit.falloutofviewer", eventfruitfalloutofviewer );
} );
message.addeventlistener("game.over", function(){
exports.gameover();
knife.switchon();
});
message.addeventlistener("overwhitelight.show", function(){
knife.endall();
for(var i = fruits.length - 1; i >= 0; i --)
fruits[i].remove();
background.stop();
});
message.addeventlistener("click", function(){
state( "click-enable" ).off();
gameover.hide();
message.postmessage( "home-menu", "sence.switchsence" );
});;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\layer.js
*/
define("scripts/layer.js", function(exports){
/**
* layer manager
*/
var raphael = require("scripts/lib/raphael");
var ucren = require("scripts/lib/ucren");
var layers = {};
var zindexs = {
"default": zi(),
"light": zi(),
"knife": zi(),
"fruit": zi(),
"juice": zi(),
"flash": zi(),
"mask": zi()
};
exports.createimage = function( layer, src, x, y, w, h ){
layer = this.getlayer( layer );
return layer.image( src, x, y, w, h );
};
exports.createtext = function( layer, text, x, y, fill, size ){
layer = this.getlayer( layer );
if( ucren.isie )
y += 2;
return layer.text(x, y, text).attr({
fill: fill || "#fff",
"font-size": size || "14px",
"font-family": "黑体",
"text-anchor": "start"
});
};
exports.getlayer = function( name ){
var p, layer;
name = name || "default";
if( p = layers[name] ){
return p;
}else{
layer = ucren.makeelement( "p", { "class": "layer", "style": "z-index: " + ( zindexs[name] || 0 ) + ";" } );
ucren.element( "extra" ).add( layer );
p = layers[name] = raphael( layer, 640, 480 );
// if( ucren.issafari )
// p.safari();
return p;
}
};
function zi(){
return zi.num = ++ zi.num || 2;
};
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\main.js
*/
define("scripts/main.js", function(exports){
var timeline = require("scripts/timeline");
var tools = require("scripts/tools");
var sence = require("scripts/sence");
var ucren = require("scripts/lib/ucren");
var buzz = require("scripts/lib/buzz");
var control = require("scripts/control");
var csl = require("scripts/object/console");
var message = require("scripts/message");
var state = require("scripts/state");
var game = require("scripts/game");
var collide = require("scripts/collide");
var settimeout = timeline.settimeout.bind( timeline );
var log = function(){
var time = 1e3, add = 300, fn;
fn = function( text ){
settimeout( function(){ csl.log( text ); }, time );
time += add;
};
fn.clear = function(){
settimeout( csl.clear.bind( csl ), time );
time += add;
};
return fn;
}();
exports.start = function(){
[ timeline, sence, control ].invoke( "init" );
log( "正在加载鼠标控制脚本" );
log( "正在加载图像资源" );
log( "正在加载游戏脚本" );
log( "正在加载剧情" );
log( "正在初始化" );
log( "正在启动游戏..." );
log.clear();
settimeout( sence.switchsence.saturate( sence, "home-menu" ), 3000 );
};
message.addeventlistener("slice", function( knife ){
var fruits = collide.check( knife ), angle;
if( fruits.length )
angle = tools.getanglebyradian( tools.pointtoradian( knife.slice(0, 2), knife.slice(2, 4) ) ),
fruits.foreach(function( fruit ){
message.postmessage( fruit, angle, "slice.at" );
});
});
message.addeventlistener("slice.at", function( fruit, angle ){
if( state( "sence-state" ).isnot( "ready" ) )
return ;
if( state( "sence-name" ).is( "game-body" ) ){
game.sliceat( fruit, angle );
return ;
}
if( state( "sence-name" ).is( "home-menu" ) ){
fruit.broken( angle );
if( fruit.ishomemenu )
switch( 1 ){
case fruit.isdojoicon:
sence.switchsence( "dojo-body" ); break;
case fruit.isnewgameicon:
sence.switchsence( "game-body" ); break;
case fruit.isquiticon:
sence.switchsence( "quit-body" ); break;
}
return ;
}
});
var tip = "";
if( !ucren.ischrome )
tip = "$为了获得最佳流畅度,推荐您使用 <span class='b'>google chrome</span> 体验本游戏";
if( !buzz.issupported() )
tip = tip.replace( "$", "您的浏览器不支持 <audio> 播放声效,且" );
tip = tip.replace( "$", "" );
ucren.element( "browser" ).html( tip );;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\message.js
*/
define("scripts/message.js", function(exports){
/**
* a simple message manager
* @author dron
* @date 2012-06-27
*/
var ucren = require("scripts/lib/ucren");
/**
* send a message
* @param {any} message,message... message contents
* @param {string} to message address
*/
exports.postmessage = function( message/*, message, message... */, to ){
var messages = [].slice.call( arguments, 0 ),
splitindex = messages.length - 1;
to = messages[ splitindex ];
messages.slice( 0, splitindex );
ucren.dispatch( to, messages );
};
/**
* bind an message handler
* @param {string} from message address
* @param {function} fn message handler
*/
exports.addeventlistener = function( from, fn ){
ucren.dispatch( from, fn );
};
/**
* remove an message handler
* @param {string} from message address
* @param {function} fn message handler
*/
exports.removeeventlistener = function( from, fn ){
ucren.dispatch.remove( from, fn );
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\sence.js
*/
define("scripts/sence.js", function(exports){
var ucren = require("scripts/lib/ucren");
var sound = require("scripts/lib/sound");
var fruit = require("scripts/factory/fruit");
var flash = require("scripts/object/flash");
var state = require("scripts/state");
var message = require("scripts/message");
// the fixed elements
var background = require("scripts/object/background");
var fps = require("scripts/object/fps");
// the home page elements
var homemask = require("scripts/object/home-mask");
var logo = require("scripts/object/logo");
var ninja = require("scripts/object/ninja")
var homedesc = require("scripts/object/home-desc");
var dojo = require("scripts/object/dojo");
var newgame = require("scripts/object/new-game");
var quit = require("scripts/object/quit");
var newsign = require("scripts/object/new");
var peach, sandia, boom;
// the elements in game body
var score = require("scripts/object/score");
var lose = require("scripts/object/lose");
// the game logic
var game = require("scripts/game");
// the elements in 'developing' module
var developing = require("scripts/object/developing");
var gameover = require("scripts/object/game-over");
// commons
var message = require("scripts/message");
var timeline = require("scripts/timeline");
var settimeout = timeline.settimeout.bind( timeline );
var setinterval = timeline.setinterval.bind( timeline );
var menusnd;
var gamestartsnd;
// initialize sence
exports.init = function(){
menusnd = sound.create( "sound/menu" );
gamestartsnd = sound.create( "sound/start" );
[ background, homemask, logo, ninja, homedesc, dojo, newsign, newgame, quit, score, lose, developing, gameover, flash /*, fps */ ].invoke( "set" );
// setinterval( fps.update.bind( fps ), 500 );
};
// switch sence
exports.switchsence = function( name ){
var cursence = state( "sence-name" );
var sencestate = state( "sence-state" );
if( cursence.is( name ) )
return ;
var onhide = function(){
cursence.set( name );
sencestate.set( "entering" );
switch( name ){
case "home-menu": this.showmenu( onshow ); break;
case "dojo-body": this.showdojo( onshow ); break;
case "game-body": this.shownewgame( onshow ); break;
case "quit-body": this.showquit( onshow ); break;
}
}.bind( this );
var onshow = function(){
sencestate.set( "ready" );
if( name == "dojo-body" || name == "quit-body" ){
exports.switchsence( "home-menu" );
}
};
sencestate.set( "exiting" );
if( cursence.isunset() ) onhide();
else if( cursence.is( "home-menu" ) ) this.hidemenu( onhide );
else if( cursence.is( "dojo-body" ) ) this.hidedojo( onhide );
else if( cursence.is( "game-body" ) ) this.hidenewgame( onhide );
else if( cursence.is( "quit-body" ) ) this.hidequit( onhide );
};
// to enter home page menu
exports.showmenu = function( callback ){
var callee = arguments.callee;
var times = callee.times = ++ callee.times || 1;
peach = fruit.create( "peach", 137, 333, true );
sandia = fruit.create( "sandia", 330, 322, true );
boom = fruit.create( "boom", 552, 367, true, 2500 );
[ peach, sandia, boom ].foreach(function( f ){ f.ishomemenu = 1; });
peach.isdojoicon = sandia.isnewgameicon = boom.isquiticon = 1;
var group = [
[ homemask, 0 ],
[ logo, 0 ],
[ ninja, 500 ],
[ homedesc, 1500 ],
[ dojo, 2000 ],
[ newgame, 2000 ],
[ quit, 2000 ],
[ newsign, 2000 ],
[ peach, 2000 ],
[ sandia, 2000 ],
[ boom, 2000 ]
];
group.invoke( "show" );
[ peach, sandia ].invoke( "rotate", 2500 );
menusnd.play();
settimeout( callback, 2500 );
};
// to exit home page menu
exports.hidemenu = function( callback ){
[ newsign, dojo, newgame, quit ].invoke( "hide" );
[ homemask, logo, ninja, homedesc ].invoke( "hide" );
[ peach, sandia, boom ].invoke( "falloff", 150 );
menusnd.stop();
settimeout( callback, fruit.getdroptimesetting() );
};
// to enter game body
exports.shownewgame = function( callback ){
score.show();
lose.show();
game.start();
gamestartsnd.play();
settimeout( callback, 1000 );
};
// to exit game body
exports.hidenewgame = function( callback ){
score.hide();
lose.hide();
gamestartsnd.stop();
settimeout( callback, 1000 );
};
// to enter dojo mode
exports.showdojo = function( callback ){
developing.show( 250 );
settimeout( callback, 1500 );
};
// to exit dojo mode
exports.hidedojo = function( callback ){
// todo:
settimeout( callback, 1000 );
};
// to enter quit page
exports.showquit = function( callback ){
developing.show( 250 );
settimeout( callback, 1500 );
};
// to exit quit page
exports.hidequit = function( callback ){
// todo:
settimeout( callback, 1000 );
};
message.addeventlistener("sence.switchsence", function( name ){
exports.switchsence( name );
});;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\state.js
*/
define("scripts/state.js", function(exports){
/**
* a simple state manager
* @author dron
* @date 2012-06-28
*/
var ucren = require("scripts/lib/ucren");
var timeline = require("scripts/timeline");
/**
* usage:
* state( key ).is( value ) -> determine if the value of key is the given value
* state( key ).isnot( value ) -> determine if the value of key is not given value
* state( key ).ison() -> determine if the value of key is the boolean value 'true'
* state( key ).isoff() -> determine if the value of key is the boolean value 'false'
* state( key ).isunset() -> determine if the value of key is undefined
* state( key ).set( value ) -> set the value of key to a given value
* state( key ).get() -> get the value of key
* state( key ).on() -> set the value of key to boolean value 'true'
* state( key ).off() -> set the value of key to boolean value 'false'
*/
var stack = {};
var cache = {};
var callbacks = {};
exports = function( key ){
if( cache[ key ] )
return cache[ key ];
return cache[ key ] = {
is: function( value ){
return stack[key] === value;
},
isnot: function( value ){
return stack[key] !== value;
},
ison: function(){
return this.is( true );
},
isoff: function(){
return this.isnot( true );
},
isunset: function(){
return this.is( undefined );
},
set: function(){
var lastvalue = nan;
return function( value ){
var c;
stack[key] = value;
if( lastvalue !== value && ( c = callbacks[ key ] ) )
for(var i = 0, l = c.length; i < l; i ++)
c[i].call( this, value );
lastvalue = value;
}
}(),
get: function(){
return stack[key];
},
on: function(){
var me = this;
me.set( true );
return {
keep: function( time ){
timeline.settimeout( me.set.saturate( me, false ), time );
}
}
},
off: function(){
var me = this;
me.set( false );
return {
keep: function( time ){
timeline.settimeout( me.set.saturate( me, true ), time );
}
}
},
hook: function( fn ){
var c;
if( !( c = callbacks[ key ] ) )
callbacks[ key ] = [ fn ];
else
c.push( fn );
},
unhook: function(){
// todo:
}
}
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\timeline.js
*/
define("scripts/timeline.js", function(exports){
/**
* a easy timeline manager
* @version 1.0
* @author dron
*/
var ucren = require("scripts/lib/ucren");
var timercache = {};
var timeline = {};
// var timer = timeline;
// <or>
// var timer = timeline.use( name ).init( 10 ); // to use a new timeline instance
//
// var t = timer.createtask(...);
// t.stop();
//
// timer.settimeout(...);
// timer.setinterval(...);
// timer.getfps();
function classtimer(){
this.tasks = [];
this.addingtasks = [];
this.adding = 0;
}
/**
* initialize timeline
*/
classtimer.prototype.init = function( ms ){
var me = this;
if( me.inited )
return ;
else
me.inited = 1;
me.starttime = now();
me.intervaltime = ms || 5;
me.count = 0;
me.intervalfn = function(){
me.count ++;
me.update( now() );
};
me.start();
return me;
};
/**
* create a task
* @param {object} conf the config
* @return {task} a task instance
*/
classtimer.prototype.createtask = function( conf ){
/* e.g. timer.createtask({
start: 500, duration: 2000, data: [a, b, c,..], object: module,
ontimeupdate: fn(time, a, b, c,..), ontimestart: fn(a, b, c,..), ontimeend: fn(a, b, c,..),
recycle: []
}); */
var task = createtask( conf );
this.addingtasks.unshift( task );
this.adding = 1;
if( conf.recycle )
this.tasklist( conf.recycle, task );
this.start();
return task;
};
/**
* use a array to recycle the task
* @param {array} queue be use for recycling task
* @param {task} task a task instance
* @return {array} this queue
*/
classtimer.prototype.tasklist = function( queue, task ){
if( !queue.clear )
queue.clear = function(){
var i = this.length;
while( i -- )
task = this[i],
task.stop(),
this.splice( i, 1 );
return this;
};
if( task )
queue.unshift( task );
return queue;
};
/**
* create a timer for once callback
* @param {function} fn callback function
* @param {number} time time, unit: ms
*/
classtimer.prototype.settimeout = function( fn, time ){
// e.g. settimeout(fn, time);
return this.createtask({ start: time, duration: 0, ontimestart: fn });
};
/**
* create a timer for ongoing callback
* @param {function} fn callback function
* @param {number} time time, unit: ms
*/
classtimer.prototype.setinterval = function( fn, time ){
// e.g. setinterval(fn, time);
var timer = setinterval( fn, time );
return {
stop: function(){
clearinterval( timer );
}
};
};
/**
* get the current fps
* @return {number} fps number
*/
classtimer.prototype.getfps = function(){
var t = now(), c = this.count, fps = c / ( t - this.starttime ) * 1e3;
if( c > 1e3 )
this.count = 0,
this.starttime = t;
return fps;
};
// privates
classtimer.prototype.start = function(){
clearinterval( this.interval );
this.interval = setinterval( this.intervalfn, this.intervaltime );
};
classtimer.prototype.stop = function(){
clearinterval( this.interval );
};
classtimer.prototype.update = function( time ){
var tasks = this.tasks, addingtasks = this.addingtasks, adding = this.adding;
var i = tasks.length, t, task, start, duration, data;
while( i -- ){
task = tasks[i];
start = task.start;
duration = task.duration;
if( time >= start ){
if( task.stopped ){
tasks.splice( i, 1 );
continue;
}
checkstarttask( task );
if( ( t = time - start ) < duration )
updatetask( task, t );
else
updatetask( task, duration ),
task.ontimeend.apply( task.object, task.data.slice(1) ),
tasks.splice( i, 1 );
}
}
if( adding )
tasks.unshift.apply( tasks, addingtasks ),
addingtasks.length = adding = 0;
if( !tasks.length )
this.stop();
};
timeline.use = function( name ){
var module;
if( module = timercache[ name ] )
return module;
else
module = timercache[ name ] = new classtimer;
return module;
};
/**
* @functions
*/
var now = function(){
return new date().gettime();
};
var createtask = function( conf ){
var object = conf.object || {};
conf.start = conf.start || 0;
return {
start: conf.start + now(),
duration: conf.duration == -1 ? 86400000 : conf.duration,
data: conf.data ? [ 0 ].concat( conf.data ) : [ 0 ],
started: 0,
object: object,
ontimestart: conf.ontimestart || object.ontimestart || ucren.nul,
ontimeupdate: conf.ontimeupdate || object.ontimeupdate || ucren.nul,
ontimeend: conf.ontimeend || object.ontimeend || ucren.nul,
stop: function(){
this.stopped = 1;
}
}
};
var updatetask = function( task, time ){
var data = task.data;
data[0] = time;
task.ontimeupdate.apply( task.object, data );
};
var checkstarttask = function( task ){
if( !task.started )
task.started = 1,
task.ontimestart.apply( task.object, task.data.slice(1) ),
updatetask( task, 0 );
};
/**
* for compatible the old version
*/
exports = timeline.use( "default" ).init( 10 );
exports.use = function( name ){
if( ucren.isie )
exports;
return timeline.use( name );
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\tools.js
*/
define("scripts/tools.js", function(exports){
exports.unsetobject = function( object ){
for(var i in object)
if(object.hasownproperty(i) && typeof object[i] == "function")
object[i] = function(){};
};
exports.getanglebyradian = function( radian ){
return radian * 180 / math.pi;
}
exports.pointtoradian = function( origin, point ){
var pi = math.pi;
if( point[0] === origin[0] ){
if ( point[1] > origin[1] )
return pi * 0.5;
return pi * 1.5
}else if( point[1] === origin[1] ){
if ( point[0] > origin[0] )
return 0;
return pi;
}
var t = math.atan( ( origin[1] - point[1] ) / ( origin[0] - point[0] ) );
if( point[0] > origin[0] && point[1] < origin[1] )
return t + 2 * pi;
if( point[0] > origin[0] && point[1] > origin[1] )
return t;
return t + pi;
};
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\factory\displacement.js
*/
define("scripts/factory/displacement.js", function(exports){
var layer = require("scripts/layer");
var timeline = require("scripts/timeline");
var tween = require("scripts/lib/tween");
/**
* 位移类模块模型
*/
exports.create = function( imagesrc, width, height, origx, origy, targetx, targety, animmap, animdur ){
var module = {};
var image;
var anim = {};
if( typeof animmap === "function" )
anim.show = anim.hide = animmap;
else
anim = animmap;
var createtask = function( start, duration, sx, sy, ex, ey, anim, mode ){
timeline.createtask({
start: start,
duration: duration,
object: module, data: [ sx, sy, ex, ey, anim, mode ],
ontimeupdate: module.ontimeupdate, ontimestart: module.ontimestart, ontimeend: module.ontimeend,
recycle: module.anims
});
};
module.anims = [];
module.set = function(){
image = layer.createimage( "default", imagesrc, origx, origy, width, height );
};
module.show = function( start ){
createtask( start, animdur, origx, origy, targetx, targety, anim.show, "show" );
};
module.hide = function(){
this.anims.clear();
createtask( 0, animdur, targetx, targety, origx, origy, anim.hide, "hide" );
};
module.ontimeupdate = function( time, sx, sy, ex, ey, anim ){
image.attr( {
x: anim( time, sx, ex - sx, animdur ),
y: anim( time, sy, ey - sy, animdur )
} );
};
module.ontimestart = function(){
};
module.ontimeend = function( sx, sy, ex, ey, anim ){
if( anim === "hide" )
image.hide();
};
return module;
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\factory\fruit.js
*/
define("scripts/factory/fruit.js", function(exports){
var layer = require("scripts/layer");
var ucren = require("scripts/lib/ucren");
var timeline = require("scripts/timeline").use( "fruit" ).init( 1 );
var timeline2 = require("scripts/timeline").use( "fruit-apart" ).init( 1 );
var tween = require("scripts/lib/tween");
var message = require("scripts/message");
var flame = require("scripts/object/flame");
var flash = require("scripts/object/flash");
var juice = require("scripts/factory/juice");
var ie = ucren.isie;
var safari = ucren.issafari;
/**
* 水果模块模型
*/
var zoomanim = tween.exponential.co;
var rotateanim = tween.circular;
var linearanim = tween.linear;
var dropanim = tween.quadratic.ci;
var falloffanim = tween.quadratic.co;
var random = ucren.randomnumber;
var min = math.min;
var average = function( a, b ){ return ( ( a + b ) / 2 ) >> 0; };
var droptime = 1200, dropxscope = 200, shadowpos = 50;
var infos = {
// type: [ imagesrc, width, height, radius, fixangle, isreverse, juicecolor ]
boom: [ "images/fruit/boom.png", 66, 68, 26, 0, 0, null ],
peach: [ "images/fruit/peach.png", 62, 59, 37, -50, 0, "#e6c731" ],
sandia: [ "images/fruit/sandia.png", 98, 85, 38, -100, 0, "#c00" ],
apple: [ "images/fruit/apple.png", 66, 66, 31, -54, 0, "#c8e925" ],
banana: [ "images/fruit/banana.png", 126, 50, 43, 90, 0, null ],
basaha: [ "images/fruit/basaha.png", 68, 72, 32, -135, 0, "#c00" ]
};
// todo: 是否水果全开?
var types = [ "peach", "sandia", "apple", "banana", "basaha" ];
// var types = [ "sandia", "boom" ];
var rotatespeed = [ 60, 50, 40, -40, -50, -60 ];
var fruitcache = [];
function classfruit(conf){
var info = infos[ conf.type ], radius = info[3];
this.type = conf.type;
this.originx = conf.originx;
this.originy = conf.originy;
this.radius = radius;
this.startx = conf.originx;
this.starty = conf.originy;
this.radius = radius;
this.anims = [];
if( this.type === "boom" )
this.flame = flame.create( this.startx - radius + 4, this.starty - radius + 5, conf.flamestart || 0 );
}
classfruit.prototype.set = function( hide ){
var inf = infos[ this.type ], radius = this.radius;
this.shadow = layer.createimage( "fruit", "images/shadow.png", this.startx - radius, this.starty - radius + shadowpos, 106, 77 );
this.image = layer.createimage( "fruit", inf[0], this.startx - radius, this.starty - radius, inf[1], inf[2] );
if( hide )
this.image.hide(),
this.shadow.hide();
return this;
};
classfruit.prototype.pos = function( x, y ){
if( x == this.originx && y == this.originy )
return ;
var r = this.radius;
this.originx = x;
this.originy = y;
this.image.attr({ x: x -= r, y: y -= r });
this.shadow.attr({ x: x, y: y + shadowpos });
if( this.type === "boom" )
this.flame.pos( x + 4, y + 5 );
};
classfruit.prototype.show = function( start ){
timeline.createtask({
start: start, duration: 500, data: [ 1e-5, 1, "show" ],
object: this, ontimeupdate: this.onscaling, ontimestart: this.onshowstart,
recycle: this.anims
});
};
classfruit.prototype.hide = function( start ){
if( this.type !== "boom" ) // if it is not a boom, it can't to be hide.
return ;
this.anims.clear();
this.flame.remove();
timeline.createtask({
start: start, duration: 500, data: [ 1, 1e-5, "hide" ],
object: this, ontimeupdate: this.onscaling, ontimeend: this.onhideend,
recycle: this.anims
});
};
classfruit.prototype.rotate = function( start, speed ){
this.rotatespeed = speed || rotatespeed[ random( 6 ) ];
this.rotateanim = timeline.createtask({
start: start, duration: -1,
object: this, ontimeupdate: this.onrotating,
recycle: this.anims
});
};
classfruit.prototype.broken = function( angle ){
if( this.brokend )return;
this.brokend = true;
var index;
if( ( index = fruitcache.indexof( this ) ) > -1 )
fruitcache.splice( index, 1 );
if( this.type !== "boom" )
flash.showat( this.originx, this.originy, angle ),
juice.create( this.originx, this.originy, infos[ this.type ][6] ),
this.apart( angle );
else
this.hide();
};
classfruit.prototype.pause = function(){
if( this.brokend )
return;
this.anims.clear();
if( this.type == "boom" )
this.flame.remove();
};
// 分开
classfruit.prototype.apart = function( angle ){
this.anims.clear();
this.image.hide();
this.shadow.hide();
this.aparted = true;
var inf = infos[ this.type ], presrc = inf[0].replace( ".png", "" ), radius = this.radius;
var create = layer.createimage.saturate( layer, this.startx - radius, this.starty - radius, inf[1], inf[2] );
angle = ( ( angle % 180 ) + 360 + inf[4] ) % 360;
this.bimage1 = create( "fruit", presrc + "-1.png" );
this.bimage2 = create( "fruit", presrc + "-2.png" );
[ this.bimage1, this.bimage2 ].invoke( "rotate", angle );
this.apartangle = angle;
timeline2.createtask({
start: 0, duration: droptime, object: this,
ontimeupdate: this.onbrokendropupdate, ontimestart: this.onbrokendropstart, ontimeend: this.onbrokendropend,
recycle: this.anims
});
};
// 抛出
classfruit.prototype.shotout = function(){
var sign = [ -1, 1 ];
return function( start, endx ){
this.shotoutstartx = this.originx;
this.shotoutstarty = this.originy;
this.shotoutendx = average( this.originx, endx );
this.shotoutendy = min( this.starty - random( this.starty - 100 ), 200 );
this.fallofftox = endx;
timeline.createtask({
start: start, duration: droptime, object: this,
ontimeupdate: this.onshotouting, ontimestart: this.onshotoutstart, ontimeend: this.onshotoutend,
recycle: this.anims
});
if( this.type != "boom" )
this.rotate( 0, ( random( 180 ) + 90 ) * sign[ random( 2 ) ] );
return this;
};
}();
// 掉落
classfruit.prototype.falloff = function(){
var sign = [ -1, 1 ];
var signindex = 0;
return function( start, x ){
if( this.aparted || this.brokend )
return ;
var y = 600;
if( typeof x !== "number" )
x = this.originx + random( dropxscope ) * sign[ ( signindex ++ ) % 2 ];
this.falltargetx = x;
this.falltargety = y;
timeline.createtask({
start: start, duration: droptime, object: this,
ontimeupdate: this.onfalling, ontimestart: this.onfallstart, ontimeend: this.onfallend,
recycle: this.anims
});
}
}();
classfruit.prototype.remove = function(){
var index;
this.anims.clear();
if( this.image )
this.image.remove(),
this.shadow.remove();
if( this.bimage1 )
this.bimage1.remove(),
this.bimage2.remove();
if( this.type === "boom" )
this.flame.remove();
if( ( index = fruitcache.indexof( this ) ) > -1 )
fruitcache.splice( index, 1 );
for(var name in this)
if( typeof this[name] === "function" )
this[name] = function( name ){
return function(){
throw new error( "method " + name + " has been removed" );
};
}( name );
else delete this[name];
message.postmessage( this, "fruit.remove" );
};
// 显示/隐藏 相关
classfruit.prototype.onshowstart = function(){
this.image.show();
// this.shadow.show();
};
classfruit.prototype.onscaling = function( time, a, b, z ){
this.image.scale( z = zoomanim( time, a, b - a, 500 ), z );
this.shadow.scale( z, z );
};
classfruit.prototype.onhideend = function(){
this.remove();
};
// 旋转相关
classfruit.prototype.onrotatestart = function(){
};
classfruit.prototype.onrotating = function( time ){
this.image.rotate( ( this.rotatespeed * time / 1e3 ) % 360, true );
};
// 裂开相关
classfruit.prototype.onbrokendropupdate = function( time ){
var radius = this.radius;
this.bimage1.attr({
x: linearanim( time, this.brokenposx - radius, this.brokentargetx1, droptime ),
y: dropanim( time, this.brokenposy - radius, this.brokentargety1 - this.brokenposy + radius, droptime )
}).rotate( linearanim( time, this.apartangle, this.bimage1rotateangle, droptime ), true );
this.bimage2.attr({
x: linearanim( time, this.brokenposx - radius, this.brokentargetx2, droptime ),
y: dropanim( time, this.brokenposy - radius, this.brokentargety2 - this.brokenposy + radius, droptime )
}).rotate( linearanim( time, this.apartangle, this.bimage2rotateangle, droptime ), true );
};
classfruit.prototype.onbrokendropstart = function(){
this.brokentargetx1 = -( random( dropxscope ) + 75 );
this.brokentargetx2 = random( dropxscope + 75 );
this.brokentargety1 = 600;
this.brokentargety2 = 600;
this.brokenposx = this.originx;
this.brokenposy = this.originy;
this.bimage1rotateangle = - random( 150 ) - 50;
this.bimage2rotateangle = random( 150 ) + 50;
for(var f, i = fruitcache.length - 1; i >= 0; i --)
if( fruitcache[i] === this )
fruitcache.splice( i, 1 );
};
classfruit.prototype.onbrokendropend = function(){
this.remove();
};
// 抛出相关
classfruit.prototype.onshotouting = function( time ){
this.pos(
linearanim( time, this.shotoutstartx, this.shotoutendx - this.shotoutstartx, droptime ),
falloffanim( time, this.shotoutstarty, this.shotoutendy - this.shotoutstarty, droptime )
);
};
classfruit.prototype.onshotoutstart = function(){
// body...
};
classfruit.prototype.onshotoutend = function(){
this.falloff( 0, this.fallofftox );
};
// 掉落相关
classfruit.prototype.onfalling = function( time ){
var y;
this.pos(
linearanim( time, this.brokenposx, this.falltargetx - this.brokenposx, droptime ),
y = dropanim( time, this.brokenposy, this.falltargety - this.brokenposy, droptime )
);
this.checkforfalloutofviewer( y );
};
classfruit.prototype.onfallstart = function(){
this.brokenposx = this.originx;
this.brokenposy = this.originy;
};
classfruit.prototype.onfallend = function(){
message.postmessage( this, "fruit.falloff" );
this.remove();
};
// privates
classfruit.prototype.checkforfalloutofviewer = function( y ){
if( y > 480 + this.radius )
this.checkforfalloutofviewer = ucren.nul,
this.rotateanim && this.rotateanim.stop(),
message.postmessage( this, "fruit.falloutofviewer" );
};
exports.create = function( type, originx, originy, ishide, flamestart ){
if( typeof type == "number" ) // 缺省 type
ishide = originy,
originy = originx,
originx = type,
type = gettype();
var fruit = new classfruit({ type: type, originx: originx, originy: originy, flamestart: flamestart }).set( ishide );
fruitcache.unshift( fruit );
return fruit;
};
exports.getfruitinview = function(){
return fruitcache;
};
exports.getdroptimesetting = function(){
return droptime;
};
function gettype(){
if( random( 8 ) == 4 )
return "boom";
else
return types[ random( 5 ) ];
};
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\factory\juice.js
*/
define("scripts/factory/juice.js", function(exports){
/**
* 果汁
*/
var ucren = require("scripts/lib/ucren");
var layer = require("scripts/layer").getlayer("juice");
var timeline = require("scripts/timeline").use( "juice" ).init( 10 );
var tween = require("scripts/lib/tween");
var tools = require("scripts/tools");
var random = ucren.randomnumber;
var dur = 1500;
var anim = tween.exponential.co;
var dropanim = tween.quadratic.co;
var sin = math.sin;
var cos = math.cos;
var num = 10;
var radius = 10;
// if( ucren.isie6 || ucren.issafari )
// switchon = false;
// if( ucren.isie || ucren.issafari )
// num = 6;
function classjuice( x, y, color ){
this.originx = x;
this.originy = y;
this.color = color;
this.distance = random( 200 ) + 100;
this.radius = radius;
this.dir = random( 360 ) * math.pi / 180;
}
classjuice.prototype.render = function(){
this.circle = layer.circle( this.originx, this.originy, this.radius ).attr({
fill: this.color,
stroke: "none"
});
};
classjuice.prototype.sputter = function(){
timeline.createtask({
start: 0, duration: dur,
object: this, ontimeupdate: this.ontimeupdate, ontimeend: this.ontimeend
});
};
classjuice.prototype.ontimeupdate = function( time ){
var distance, x, y, z;
distance = anim( time, 0, this.distance, dur );
x = this.originx + distance * cos( this.dir );
y = this.originy + distance * sin( this.dir ) + dropanim( time, 0, 200, dur );
z = anim( time, 1, -1, dur );
this.circle.attr({ cx: x, cy: y }).scale( z, z );
};
classjuice.prototype.ontimeend = function(){
this.circle.remove();
tools.unsetobject( this );
};
exports.create = function( x, y, color ){
for(var i = 0; i < num; i ++)
this.createone( x, y, color );
};
exports.createone = function( x, y, color ){
if( !color )
return;
var juice = new classjuice( x, y, color );
juice.render();
juice.sputter();
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\factory\rotate.js
*/
define("scripts/factory/rotate.js", function(exports){
var layer = require("scripts/layer");
var timeline = require("scripts/timeline");
var ucren = require("scripts/lib/ucren");
/**
* 旋转类模块模型
*/
exports.create = function( imagesrc, x, y, w, h, z, anim, animdur ){
var module = {}, image;
var rotatedire = [12, -12][ucren.randomnumber(2)];
var defaultangle = ucren.randomnumber(360);
module.anims = [];
module.set = function(){
image = layer.createimage( "default", imagesrc, x, y, w, h ).scale( z, z ).rotate( defaultangle, true );
};
module.show = function(start){
timeline.createtask({
start: start,
duration: animdur,
object: this,
data: [z, 1],
ontimeupdate: this.onzooming,
ontimeend: this.onshowend,
recycle: this.anims
});
};
module.hide = function(start){
this.anims.clear();
timeline.createtask({
start: start,
duration: animdur,
object: this,
data: [ 1, z ],
ontimeupdate: this.onzooming,
recycle: this.anims
});
};
module.onshowend = function(name){
this.anims.clear();
timeline.createtask({
start: 0,
duration: -1,
object: this,
ontimeupdate: module.onrotating,
recycle: this.anims
});
};
module.onzooming = function(){
var z;
return function( time, a, b ){
image.scale( z = anim( time, a, b - a, animdur ), z );
}
}();
module.onrotating = function(){
var lasttime = 0, an = defaultangle;
return function( time, name, a, b ){
an = ( an + ( time - lasttime ) / 1e3 * rotatedire ) % 360;
image.rotate( an, true );
lasttime = time;
}
}();
return module;
};
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\lib\buzz.js
*/
define("scripts/lib/buzz.js", function(exports){
// ----------------------------------------------------------------------------
// buzz, a javascript html5 audio library
// v 1.0.x beta
// licensed under the mit license.
// http://buzz.jaysalvat.com/
// ----------------------------------------------------------------------------
// copyright (c) 2011 jay salvat
// http://jaysalvat.com/
// ----------------------------------------------------------------------------
// 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.
// ----------------------------------------------------------------------------
var buzz = {
defaults: {
autoplay: false,
duration: 5000,
formats: [],
loop: false,
placeholder: '--',
preload: 'metadata',
volume: 80
},
types: {
'mp3': 'audio/mpeg',
'ogg': 'audio/ogg',
'wav': 'audio/wav',
'aac': 'audio/aac',
'm4a': 'audio/x-m4a'
},
sounds: [],
el: document.createelement( 'audio' ),
sound: function( src, options ) {
options = options || {};
var pid = 0,
events = [],
eventsonce = {},
supported = buzz.issupported();
// publics
this.load = function() {
if ( !supported ) {
return this;
}
this.sound.load();
return this;
};
this.play = function() {
if ( !supported ) {
return this;
}
this.sound.play();
return this;
};
this.toggleplay = function() {
if ( !supported ) {
return this;
}
if ( this.sound.paused ) {
this.sound.play();
} else {
this.sound.pause();
}
return this;
};
this.pause = function() {
if ( !supported ) {
return this;
}
this.sound.pause();
return this;
};
this.ispaused = function() {
if ( !supported ) {
return null;
}
return this.sound.paused;
};
this.stop = function() {
if ( !supported ) {
return this;
}
this.settime( this.getduration() );
this.sound.pause();
return this;
};
this.isended = function() {
if ( !supported ) {
return null;
}
return this.sound.ended;
};
this.loop = function() {
if ( !supported ) {
return this;
}
this.sound.loop = 'loop';
this.bind( 'ended.buzzloop', function() {
this.currenttime = 0;
this.play();
});
return this;
};
this.unloop = function() {
if ( !supported ) {
return this;
}
this.sound.removeattribute( 'loop' );
this.unbind( 'ended.buzzloop' );
return this;
};
this.mute = function() {
if ( !supported ) {
return this;
}
this.sound.muted = true;
return this;
};
this.unmute = function() {
if ( !supported ) {
return this;
}
this.sound.muted = false;
return this;
};
this.togglemute = function() {
if ( !supported ) {
return this;
}
this.sound.muted = !this.sound.muted;
return this;
};
this.ismuted = function() {
if ( !supported ) {
return null;
}
return this.sound.muted;
};
this.setvolume = function( volume ) {
if ( !supported ) {
return this;
}
if ( volume < 0 ) {
volume = 0;
}
if ( volume > 100 ) {
volume = 100;
}
this.volume = volume;
this.sound.volume = volume / 100;
return this;
};
this.getvolume = function() {
if ( !supported ) {
return this;
}
return this.volume;
};
this.increasevolume = function( value ) {
return this.setvolume( this.volume + ( value || 1 ) );
};
this.decreasevolume = function( value ) {
return this.setvolume( this.volume - ( value || 1 ) );
};
this.settime = function( time ) {
if ( !supported ) {
return this;
}
this.whenready( function() {
this.sound.currenttime = time;
});
return this;
};
this.gettime = function() {
if ( !supported ) {
return null;
}
var time = math.round( this.sound.currenttime * 100 ) / 100;
return isnan( time ) ? buzz.defaults.placeholder : time;
};
this.setpercent = function( percent ) {
if ( !supported ) {
return this;
}
return this.settime( buzz.frompercent( percent, this.sound.duration ) );
};
this.getpercent = function() {
if ( !supported ) {
return null;
}
var percent = math.round( buzz.topercent( this.sound.currenttime, this.sound.duration ) );
return isnan( percent ) ? buzz.defaults.placeholder : percent;
};
this.setspeed = function( duration ) {
if ( !supported ) {
return this;
}
this.sound.playbackrate = duration;
};
this.getspeed = function() {
if ( !supported ) {
return null;
}
return this.sound.playbackrate;
};
this.getduration = function() {
if ( !supported ) {
return null;
}
var duration = math.round( this.sound.duration * 100 ) / 100;
return isnan( duration ) ? buzz.defaults.placeholder : duration;
};
this.getplayed = function() {
if ( !supported ) {
return null;
}
return timerangetoarray( this.sound.played );
};
this.getbuffered = function() {
if ( !supported ) {
return null;
}
return timerangetoarray( this.sound.buffered );
};
this.getseekable = function() {
if ( !supported ) {
return null;
}
return timerangetoarray( this.sound.seekable );
};
this.geterrorcode = function() {
if ( supported && this.sound.error ) {
return this.sound.error.code;
}
return 0;
};
this.geterrormessage = function() {
if ( !supported ) {
return null;
}
switch( this.geterrorcode() ) {
case 1:
return 'media_err_aborted';
case 2:
return 'media_err_network';
case 3:
return 'media_err_decode';
case 4:
return 'media_err_src_not_supported';
default:
return null;
}
};
this.getstatecode = function() {
if ( !supported ) {
return null;
}
return this.sound.readystate;
};
this.getstatemessage = function() {
if ( !supported ) {
return null;
}
switch( this.getstatecode() ) {
case 0:
return 'have_nothing';
case 1:
return 'have_metadata';
case 2:
return 'have_current_data';
case 3:
return 'have_future_data';
case 4:
return 'have_enough_data';
default:
return null;
}
};
this.getnetworkstatecode = function() {
if ( !supported ) {
return null;
}
return this.sound.networkstate;
};
this.getnetworkstatemessage = function() {
if ( !supported ) {
return null;
}
switch( this.getnetworkstatecode() ) {
case 0:
return 'network_empty';
case 1:
return 'network_idle';
case 2:
return 'network_loading';
case 3:
return 'network_no_source';
default:
return null;
}
};
this.set = function( key, value ) {
if ( !supported ) {
return this;
}
this.sound[ key ] = value;
return this;
};
this.get = function( key ) {
if ( !supported ) {
return null;
}
return key ? this.sound[ key ] : this.sound;
};
this.bind = function( types, func ) {
if ( !supported ) {
return this;
}
types = types.split( ' ' );
var that = this,
efunc = function( e ) { func.call( that, e ); };
for( var t = 0; t < types.length; t++ ) {
var type = types[ t ],
idx = type;
type = idx.split( '.' )[ 0 ];
events.push( { idx: idx, func: efunc } );
this.sound.addeventlistener( type, efunc, true );
}
return this;
};
this.unbind = function( types ) {
if ( !supported ) {
return this;
}
types = types.split( ' ' );
for( var t = 0; t < types.length; t++ ) {
var idx = types[ t ],
type = idx.split( '.' )[ 0 ];
for( var i = 0; i < events.length; i++ ) {
var namespace = events[ i ].idx.split( '.' );
if ( events[ i ].idx == idx || ( namespace[ 1 ] && namespace[ 1 ] == idx.replace( '.', '' ) ) ) {
this.sound.removeeventlistener( type, events[ i ].func, true );
// remove event
events.splice(i, 1);
}
}
}
return this;
};
this.bindonce = function( type, func ) {
if ( !supported ) {
return this;
}
var that = this;
eventsonce[ pid++ ] = false;
this.bind( pid + type, function() {
if ( !eventsonce[ pid ] ) {
eventsonce[ pid ] = true;
func.call( that );
}
that.unbind( pid + type );
});
};
this.trigger = function( types ) {
if ( !supported ) {
return this;
}
types = types.split( ' ' );
for( var t = 0; t < types.length; t++ ) {
var idx = types[ t ];
for( var i = 0; i < events.length; i++ ) {
var eventtype = events[ i ].idx.split( '.' );
if ( events[ i ].idx == idx || ( eventtype[ 0 ] && eventtype[ 0 ] == idx.replace( '.', '' ) ) ) {
var evt = document.createevent('htmlevents');
evt.initevent( eventtype[ 0 ], false, true );
this.sound.dispatchevent( evt );
}
}
}
return this;
};
this.fadeto = function( to, duration, callback ) {
if ( !supported ) {
return this;
}
if ( duration instanceof function ) {
callback = duration;
duration = buzz.defaults.duration;
} else {
duration = duration || buzz.defaults.duration;
}
var from = this.volume,
delay = duration / math.abs( from - to ),
that = this;
this.play();
function dofade() {
settimeout( function() {
if ( from < to && that.volume < to ) {
that.setvolume( that.volume += 1 );
dofade();
} else if ( from > to && that.volume > to ) {
that.setvolume( that.volume -= 1 );
dofade();
} else if ( callback instanceof function ) {
callback.apply( that );
}
}, delay );
}
this.whenready( function() {
dofade();
});
return this;
};
this.fadein = function( duration, callback ) {
if ( !supported ) {
return this;
}
return this.setvolume(0).fadeto( 100, duration, callback );
};
this.fadeout = function( duration, callback ) {
if ( !supported ) {
return this;
}
return this.fadeto( 0, duration, callback );
};
this.fadewith = function( sound, duration ) {
if ( !supported ) {
return this;
}
this.fadeout( duration, function() {
this.stop();
});
sound.play().fadein( duration );
return this;
};
this.whenready = function( func ) {
if ( !supported ) {
return null;
}
var that = this;
if ( this.sound.readystate === 0 ) {
this.bind( 'canplay.buzzwhenready', function() {
func.call( that );
});
} else {
func.call( that );
}
};
// privates
function timerangetoarray( timerange ) {
var array = [],
length = timerange.length - 1;
for( var i = 0; i <= length; i++ ) {
array.push({
start: timerange.start( length ),
end: timerange.end( length )
});
}
return array;
}
function getext( filename ) {
return filename.split('.').pop();
}
function addsource( sound, src ) {
var source = document.createelement( 'source' );
source.src = src;
if ( buzz.types[ getext( src ) ] ) {
source.type = buzz.types[ getext( src ) ];
}
sound.appendchild( source );
}
// init
if ( supported && src ) {
for(var i in buzz.defaults ) {
if(buzz.defaults.hasownproperty(i)) {
options[ i ] = options[ i ] || buzz.defaults[ i ];
}
}
this.sound = document.createelement( 'audio' );
if ( src instanceof array ) {
for( var j in src ) {
if(src.hasownproperty(j)) {
addsource( this.sound, src[ j ] );
}
}
} else if ( options.formats.length ) {
for( var k in options.formats ) {
if(options.formats.hasownproperty(k)) {
addsource( this.sound, src + '.' + options.formats[ k ] );
}
}
} else {
addsource( this.sound, src );
}
if ( options.loop ) {
this.loop();
}
if ( options.autoplay ) {
this.sound.autoplay = 'autoplay';
}
if ( options.preload === true ) {
this.sound.preload = 'auto';
} else if ( options.preload === false ) {
this.sound.preload = 'none';
} else {
this.sound.preload = options.preload;
}
this.setvolume( options.volume );
buzz.sounds.push( this );
}
},
group: function( sounds ) {
sounds = argstoarray( sounds, arguments );
// publics
this.getsounds = function() {
return sounds;
};
this.add = function( soundarray ) {
soundarray = argstoarray( soundarray, arguments );
for( var a = 0; a < soundarray.length; a++ ) {
sounds.push( soundarray[ a ] );
}
};
this.remove = function( soundarray ) {
soundarray = argstoarray( soundarray, arguments );
for( var a = 0; a < soundarray.length; a++ ) {
for( var i = 0; i < sounds.length; i++ ) {
if ( sounds[ i ] == soundarray[ a ] ) {
delete sounds[ i ];
break;
}
}
}
};
this.load = function() {
fn( 'load' );
return this;
};
this.play = function() {
fn( 'play' );
return this;
};
this.toggleplay = function( ) {
fn( 'toggleplay' );
return this;
};
this.pause = function( time ) {
fn( 'pause', time );
return this;
};
this.stop = function() {
fn( 'stop' );
return this;
};
this.mute = function() {
fn( 'mute' );
return this;
};
this.unmute = function() {
fn( 'unmute' );
return this;
};
this.togglemute = function() {
fn( 'togglemute' );
return this;
};
this.setvolume = function( volume ) {
fn( 'setvolume', volume );
return this;
};
this.increasevolume = function( value ) {
fn( 'increasevolume', value );
return this;
};
this.decreasevolume = function( value ) {
fn( 'decreasevolume', value );
return this;
};
this.loop = function() {
fn( 'loop' );
return this;
};
this.unloop = function() {
fn( 'unloop' );
return this;
};
this.settime = function( time ) {
fn( 'settime', time );
return this;
};
this.setduration = function( duration ) {
fn( 'setduration', duration );
return this;
};
this.set = function( key, value ) {
fn( 'set', key, value );
return this;
};
this.bind = function( type, func ) {
fn( 'bind', type, func );
return this;
};
this.unbind = function( type ) {
fn( 'unbind', type );
return this;
};
this.bindonce = function( type, func ) {
fn( 'bindonce', type, func );
return this;
};
this.trigger = function( type ) {
fn( 'trigger', type );
return this;
};
this.fade = function( from, to, duration, callback ) {
fn( 'fade', from, to, duration, callback );
return this;
};
this.fadein = function( duration, callback ) {
fn( 'fadein', duration, callback );
return this;
};
this.fadeout = function( duration, callback ) {
fn( 'fadeout', duration, callback );
return this;
};
// privates
function fn() {
var args = argstoarray( null, arguments ),
func = args.shift();
for( var i = 0; i < sounds.length; i++ ) {
sounds[ i ][ func ].apply( sounds[ i ], args );
}
}
function argstoarray( array, args ) {
return ( array instanceof array ) ? array : array.prototype.slice.call( args );
}
},
all: function() {
return new buzz.group( buzz.sounds );
},
issupported: function() {
return !!buzz.el.canplaytype;
},
isoggsupported: function() {
return !!buzz.el.canplaytype && buzz.el.canplaytype( 'audio/ogg; codecs="vorbis"' );
},
iswavsupported: function() {
return !!buzz.el.canplaytype && buzz.el.canplaytype( 'audio/wav; codecs="1"' );
},
ismp3supported: function() {
return !!buzz.el.canplaytype && buzz.el.canplaytype( 'audio/mpeg;' );
},
isaacsupported: function() {
return !!buzz.el.canplaytype && ( buzz.el.canplaytype( 'audio/x-m4a;' ) || buzz.el.canplaytype( 'audio/aac;' ) );
},
totimer: function( time, withhours ) {
var h, m, s;
h = math.floor( time / 3600 );
h = isnan( h ) ? '--' : ( h >= 10 ) ? h : '0' + h;
m = withhours ? math.floor( time / 60 % 60 ) : math.floor( time / 60 );
m = isnan( m ) ? '--' : ( m >= 10 ) ? m : '0' + m;
s = math.floor( time % 60 );
s = isnan( s ) ? '--' : ( s >= 10 ) ? s : '0' + s;
return withhours ? h + ':' + m + ':' + s : m + ':' + s;
},
fromtimer: function( time ) {
var splits = time.tostring().split( ':' );
if ( splits && splits.length == 3 ) {
time = ( parseint( splits[ 0 ], 10 ) * 3600 ) + ( parseint(splits[ 1 ], 10 ) * 60 ) + parseint( splits[ 2 ], 10 );
}
if ( splits && splits.length == 2 ) {
time = ( parseint( splits[ 0 ], 10 ) * 60 ) + parseint( splits[ 1 ], 10 );
}
return time;
},
topercent: function( value, total, decimal ) {
var r = math.pow( 10, decimal || 0 );
return math.round( ( ( value * 100 ) / total ) * r ) / r;
},
frompercent: function( percent, total, decimal ) {
var r = math.pow( 10, decimal || 0 );
return math.round( ( ( total / 100 ) * percent ) * r ) / r;
}
};
exports = buzz;;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\lib\raphael.js
*/
define("scripts/lib/raphael.js", function(exports){
/*
* raphael 1.5.2 - javascript vector library
*
* copyright (c) 2010 dmitry baranovskiy (http://raphaeljs.com)
* licensed under the mit (http://raphaeljs.com/license.html) license.
*/
var raphael;
var window = {};
(function(){
function a(){
if(a.is(arguments[0],g))
{
var b=arguments[0],d=bv[m](a,b.splice(0,3+a.is(b[0],e))),e=d.set();
for(var g=0,h=b[w];g<h;g++){
var i=b[g]||{};c[f](i.type)&&e[l](d[i.type]().attr(i))
}
return e
}
return bv[m](a,arguments)}a.version="1.5.2";
var b=/[, ]+/,
c={circle:1,rect:1,path:1,ellipse:1,text:1,image:1},
d=/\{(\d+)\}/g,
e="prototype",
f="hasownproperty",
g=document,
h=window,
i={was:object[e][f].call(h,"raphael"),is:h.raphael},
j=function(){this.customattributes={}},
k,
l="appendchild",
m="apply",
n="concat",
o="createtouch"in g,
p="",
q=" ",
r=string,
s="split",
t="click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend orientationchange touchcancel gesturestart gesturechange gestureend"[s](q),
u={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},
v="join",
w="length",
x=r[e].tolowercase,
y=math,
z=y.max,
a=y.min,
b=y.abs,
c=y.pow,
d=y.pi,
e="number",
f="string",
g="array",
h="tostring",
i="fill",
j=object[e][h],
k={},
l="push",
m=/^url\(['"]?([^\)]+?)['"]?\)$/i
n=/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i,
o={"nan":1,infinity:1,"-infinity":1},
p=/^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,
q=y.round,
r="setattribute",
s=parsefloat,
t=parseint,
u=" progid:dximagetransform.microsoft",
v=r[e].touppercase,
w={
blur:0,
"clip-rect":"0 0 1e9 1e9",
cursor:"default",
cx:0,
cy:0,
fill:"#fff",
"fill-opacity":1,
font:"10px \"arial\"",
"font-family":"\"arial\"",
"font-size":"10",
"font-style":"normal",
"font-weight":400,
gradient:0,
height:0,
href:"
opacity:1,
path:"m0,0",
r:0,
rotation:0,
rx:0,
ry:0,
scale:"1 1",
src:"",
stroke:"#000",
"stroke-dasharray":"",
"stroke-linecap":"butt",
"stroke-linejoin":"butt",
"stroke-miterlimit":0,
"stroke-opacity":1,
"stroke-width":1,
target:"_blank",
"text-anchor":"middle",
title:"raphael",
translation:"0 0",
width:0,x:0,y:0
},
x={
along:"along",
blur:e,
"clip-rect":"csv",
cx:e,
cy:e,
fill:"colour",
"fill-opacity":e,
"font-size":e,
height:e,
opacity:e,
path:"path",
r:e,
rotation:"csv",
rx:e,
ry:e,
scale:"csv",
stroke:"colour",
"stroke-opacity":e,
"stroke-width":e,
translation:"csv",
width:e,
x:e,
y:e
},
y="replace",
z=/^(from|to|\d+%?)$/,$=/\s*,\s*/,_={hs:1,rg:1},ba=/,?([achlmqrstvxz]),?/gi,bb=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,bc=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig,bd=/^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/,be=function(a,b){return a.key-b.key
};
a.type=h.svgangle||g.implementation.hasfeature(" svg11/feature#basicstructure","1.1")="svg":"vml";
if(a.type=="vml")
{
var bf=g.createelement("p"),bg;
bf.innerhtml="<v:shape adj=\"1\"/>";
bg=bf.firstchild;bg.style.behavior="url(#default#vml)";
if(!(bg&&typeof bg.adj=="object"))
return a.type=null;
bf=null
}
a.svg=!(a.vml=a.type=="vml");
j[e]=a[e];
k=j[e];
a._id=0;
a._oid=0;
a.fn={};
a.is=function(a,b){
b=x.call(b);
if(b=="finite")
return!o[f](+a);
return b=="null"&&a===null||b==typeof a||b=="object"&&a===object(a)||b=="array"&&array.isarray&&array.isarray(a)||j.call(a).slice(8,-1).tolowercase()==b
};
a.angle=function(b,c,d,e,f,g){
{
if(f==null)
{
var h=b-d,i=c-e;
if(!h&&!i)return 0;
return((h<0)*180+y.atan(-i/-h)*180/d+360)%360
}
return a.angle(b,c,f,g)-a.angle(d,e,f,g)
}
};
a.rad=function(a){
return a%360*d/180};
a.deg=function(a){
return a*180/d%360
};
a.snapto=function(b,c,d){
d=a.is(d,"finite")?d:10;
if(a.is(b,g)){
var e=b.length;
while(e--)
if(b(b[e]-c)<=d)
return b[e]
}
else{
b=+b;
var f=c%b;
if(f<d)
return c-f;
if(f>b-d)
return c-f+b
}
return c
};
function bh(){
var a=[],b=0;
for(;b<32;b++)
a[b]=(~(~(y.random()*16)))[h](16);
a[12]=4;
a[16]=(a[16]&3|8)[h](16);
return"r-"+a[v]("")
}
a.setwindow=function(a){
h=a;
g=h.document};
var bi=function(b){
if(a.vml)
{
var c=/^\s+|\s+$/g,d;
try{
var e=new activexobject("htmlfile");
e.write("<body>");
e.close();
d=e.body
}
catch(a){
d=createpopup().document.body
}
var f=d.createtextrange();
bi=bm(function(a){
try{
d.style.color=r(a)[y](c,p);
var b=f.querycommandvalue("forecolor");
b=(b&255)<<16|b&65280|(b&16711680)>>>16;
return"#"+("000000"+b[h](16)).slice(-6)}catch(a){return"none"}})}else{var h=g.createelement("i");
h.title="raphaël colour picker";
h.style.display="none";
g.body[l](h);
bi=bm(function(a){
h.style.color=a;
return g.defaultview.getcomputedstyle(h,p).getpropertyvalue("color")})}return bi(b)},bj=function(){
return"hsb("+[this.h,this.s,this.b]+")"
},
bk=function(){
return"hsl("+[this.h,this.s,this.l]+")"
},
bl=function(){
return this.hex
};
a.hsb2rgb=function(b,c,d,e){
if(a.is(b,"object")&&"h"in b&&"s"in b&&"b"in b)
{
d=b.b;
c=b.s;
b=b.h;
e=b.o
}
return a.hsl2rgb(b,c,d/2,e)
};
a.hsl2rgb=function(b,c,d,e){
if(a.is(b,"object")&&"h"in b&&"s"in b&&"l"in b)
{
d=b.l;
c=b.s;
b=b.h
}
if(b>1||c>1||d>1)
{
b/=360;
c/=100;
d/=100
}
var f={},g=["r","g","b"],h,i,j,k,l,m;
if(c)
{
d<0.5?h=d*(1+c):h=d+c-d*c;
i=2*d-h;
for(var n=0;n<3;n++){
j=b+1/3*-(n-1);
j<0&&j++;
j>1&&j--;
j*6<1?f[g[n]]=i+(h-i)*6*j:j*2<1?f[g[n]]=h:j*3<2?f[g[n]]=i+(h-i)*(2/3-j)*6:f[g[n]]=i
}
}
else f={r:d,g:d,b:d};
f.r*=255;
f.g*=255;
f.b*=255;
f.hex="#"+(16777216|f.b|f.g<<8|f.r<<16).tostring(16).slice(1);
a.is(e,"finite")&&(f.opacity=e);
f.tostring=bl;
return f
};
a.rgb2hsb=function(b,c,d){
if(c==null&&a.is(b,"object")&&"r"in b&&"g"in b&&"b"in b)
{d=b.b;c=b.g;b=b.r}
if(c==null&&a.is(b,f)){
var e=a.getrgb(b);b=e.r;c=e.g;d=e.b}if(b>1||c>1||d>1)
{b/=255;c/=255;d/=255}
var f=z(b,c,d),g=a(b,c,d),h,i,j=f;
{
if(g==f)return{h:0,s:0,b:f,tostring:bj
};
var k=f-g;i=k/f;b==f?h=(c-d)/k:c==f?h=2+(d-b)/k:h=4+(b-c)/k;h/=6;
h<0&&h++;h>1&&h--}return{h:h,s:i,b:j,tostring:bj}};
a.rgb2hsl=function(b,c,d){
if(c==null&&a.is(b,"object")&&"r"in b&&"g"in b&&"b"in b)
{
d=b.b;c=b.g;b=b.r
}
if(c==null&&a.is(b,f))
{
var e=a.getrgb(b);b=e.r;c=e.g;d=e.b}if(b>1||c>1||d>1){b/=255;c/=255;d/=255
}
var f=z(b,c,d),g=a(b,c,d),h,i,j=(f+g)/2,k;
if(g==f)k={h:0,s:0,l:j};
else{
var l=f-g;i=j<0.5?l/(f+g):l/(2-f-g);b==f?h=(c-d)/l:c==f?h=2+(d-b)/l:h=4+(b-c)/l;h/=6;h<0&&h++;h>1&&h--;
k={h:h,s:i,l:j}}k.tostring=bk;return k
};
a._path2string=function(){
return this.join(",")[y](ba,"$1")
};
function bm(a,b,c){
function d(){
var g=array[e].slice.call(arguments,0),h=g[v]("►"),i=d.cache=d.cache||{},j=d.count=d.count||[];
if(i[f](h))
return c?c(i[h]):i[h];j[w]>=1000&&delete i[j.shift()];
j[l](h);i[h]=a[m](b,g);
return c?c(i[h]):i[h]
}
return d
}
a.getrgb=bm(
function(b){
if(!b||!(!((b=r(b)).indexof("-")+1)))
return{r:-1,g:-1,b:-1,hex:"none",error:1};
if(b=="none")
return{r:-1,g:-1,b:-1,hex:"none"};
!(_[f](b.tolowercase().substring(0,2))||b.charat()=="#")&&(b=bi(b));
var c,d,e,g,h,i,j,k=b.match(n);
if(k){if(k[2]){g=t(k[2].substring(5),16);
e=t(k[2].substring(3,5),16);
d=t(k[2].substring(1,3),16)}
if(k[3]){
g=t((i=k[3].charat(3))+i,16);
e=t((i=k[3].charat(2))+i,16);
d=t((i=k[3].charat(1))+i,16)
}
if(k[4]){j=k[4][s]($);
d=s(j[0]);j[0].slice(-1)=="%"&&(d*=2.55);
e=s(j[1]);j[1].slice(-1)=="%"&&(e*=2.55);
g=s(j[2]);
j[2].slice(-1)=="%"&&(g*=2.55);
k[1].tolowercase().slice(0,4)=="rgba"&&(h=s(j[3]));
j[3]&&j[3].slice(-1)=="%"&&(h/=100)}if(k[5]){j=k[5][s]($);
d=s(j[0]);
j[0].slice(-1)=="%"&&(d*=2.55);e=s(j[1]);j[1].slice(-1)=="%"&&(e*=2.55);
g=s(j[2]);j[2].slice(-1)=="%"&&(g*=2.55);
(j[0].slice(-3)=="deg"||j[0].slice(-1)=="°")&&(d/=360);k[1].tolowercase().slice(0,4)=="hsba"&&(h=s(j[3]));
j[3]&&j[3].slice(-1)=="%"&&(h/=100);
return a.hsb2rgb(d,e,g,h)
}
if(k[6])
{
j=k[6][s]($);d=s(j[0]);j[0].slice(-1)=="%"&&(d*=2.55);e=s(j[1]);j[1].slice(-1)=="%"&&(e*=2.55);g=s(j[2]);
j[2].slice(-1)=="%"&&(g*=2.55);
(j[0].slice(-3)=="deg"||j[0].slice(-1)=="°")&&(d/=360);k[1].tolowercase().slice(0,4)=="hsla"&&(h=s(j[3]));
j[3]&&j[3].slice(-1)=="%"&&(h/=100);
return a.hsl2rgb(d,e,g,h)
}
k={
r:d,g:e,b:g
};
k.hex="#"+(16777216|g|e<<8|d<<16).tostring(16).slice(1);
a.is(h,"finite")&&(k.opacity=h);return k}return{r:-1,g:-1,b:-1,hex:"none",error:1}},a);
a.getcolor=function(a){
var b=this.getcolor.start=this.getcolor.start||{h:0,s:1,b:a||0.75},c=this.hsb2rgb(b.h,b.s,b.b);
b.h+=0.075;if(b.h>1){b.h=0;b.s-=0.2;b.s<=0&&(this.getcolor.start={h:0,s:1,b:b.b})
}
return c.hex
};
a.getcolor.reset=function(){
delete this.start
};
a.parsepathstring=bm(function(b){
if(!b)
return null;
var c={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},d=[];a.is(b,g)&&a.is(b[0],g)&&(d=bo(b));
d[w]||r(b)[y](bb,function(a,b,e){var f=[],g=x.call(b);
e[y](bc,function(a,b){
b&&f[l](+b)});
if(g=="m"&&f[w]>2){d[l]([b][n](f.splice(0,2)));
g="l";b=b=="m"?"l":"l"
}
while(f[w]>=c[g]){
d[l]([b][n](f.splice(0,c[g])));
if(!c[g])break}});
d[h]=a._path2string;
return d
});
a.finddotsatsegment=function(a,b,c,d,e,f,g,h,i){
var j=1-i,k=c(j,3)*a+c(j,2)*3*i*c+j*3*i*i*e+c(i,3)*g,l=c(j,3)*b+c(j,2)*3*i*d+j*3*i*i*f+c(i,3)*h,
m=a+2*i*(c-a)+i*i*(e-2*c+a),n=b+2*i*(d-b)+i*i*(f-2*d+b),o=c+2*i*(e-c)+i*i*(g-2*e+c),
p=d+2*i*(f-d)+i*i*(h-2*f+d),q=(1-i)*a+i*c,r=(1-i)*b+i*d,s=(1-i)*e+i*g,t=(1-i)*f+i*h,
u=90-y.atan((m-o)/(n-p))*180/d;(m>o||n<p)&&(u+=180);return{x:k,y:l,m:{x:m,y:n},n:{x:o,y:p},start:{x:q,y:r},
end:{x:s,y:t},alpha:u}};
var bn=bm(function(a){
if(!a)
return{
x:0,y:0,width:0,height:0
};
a=bw(a);
var b=0,c=0,d=[],e=[],f;
for(var g=0,h=a[w];g<h;g++){
f=a[g];if(f[0]=="m"){b=f[1];c=f[2];d[l](b);e[l](c)
}
else{
var i=bv(b,c,f[1],f[2],f[3],f[4],f[5],f[6]);
d=d[n](i.min.x,i.max.x);e=e[n](i.min.y,i.max.y);b=f[5];c=f[6]
}
}
var j=a[m](0,d),k=a[m](0,e);
return{x:j,y:k,width:z[m](0,d)-j,height:z[m](0,e)-k}}),bo=function(b){
var c=[];
if(!a.is(b,g)||!a.is(b&&b[0],g))b=a.parsepathstring(b);
for(var d=0,e=b[w];d<e;d++){
c[d]=[];
for(var f=0,g=b[d][w];f<g;f++)
c[d][f]=b[d][f]}c[h]=a._path2string;
return c},bp=bm(function(b){
if(!a.is(b,g)||!a.is(b&&b[0],g))b=a.parsepathstring(b);
var c=[],d=0,e=0,f=0,g=0,h=0;if(b[0][0]=="m"){
d=b[0][1];e=b[0][2];f=d;g=e;h++;c[l](["m",d,e])
}
for(var i=h,j=b[w];i<j;i++){
var k=c[i]=[],l=b[i];
if(l[0]!=x.call(l[0]))
{
k[0]=x.call(l[0]);
switch(k[0]){
case"a":k[1]=l[1];k[2]=l[2];k[3]=l[3];k[4]=l[4];k[5]=l[5];k[6]=+(l[6]-d).tofixed(3);
k[7]=+(l[7]-e).tofixed(3);break;case"v":k[1]=+(l[1]-e).tofixed(3);break;case"m":f=l[1];g=l[2];
default:
for(var m=1,n=l[w];m<n;m++)k[m]=+(l[m]-(m%2?d:e)).tofixed(3)
}
}else{
k=c[i]=[];
if(l[0]=="m"){
f=l[1]+d;g=l[2]+e}for(var o=0,p=l[w];o<p;o++)c[i][o]=l[o]
}
var q=c[i][w];
switch(c[i][0]){
case"z":d=f;e=g;break;
case"h":d+=+c[i][q-1];break;
case"v":e+=+c[i][q-1];break;
default:d+=+c[i][q-2];
e+=+c[i][q-1]
}
}c[h]=a._path2string;
return c
},0,bo),bq=bm(function(b){
if(!a.is(b,g)||!a.is(b&&b[0],g))b=a.parsepathstring(b);
var c=[],d=0,e=0,f=0,g=0,h=0;if(b[0][0]=="m"){
d=+b[0][1];e=+b[0][2];
f=d;g=e;h++;c[0]=["m",d,e]
}
for(var i=h,j=b[w];i<j;i++){
var k=c[i]=[],l=b[i];
if(l[0]!=v.call(l[0])){
k[0]=v.call(l[0]);
switch(k[0]){
case"a":k[1]=l[1];k[2]=l[2];k[3]=l[3];k[4]=l[4];k[5]=l[5];k[6]=+(l[6]+d);k[7]=+(l[7]+e);break;
case"v":k[1]=+l[1]+e;break;
case"h":k[1]=+l[1]+d;break;
case"m":f=+l[1]+d;g=+l[2]+e;
default:
for(var m=1,n=l[w];m<n;m++)
k[m]=+l[m]+(m%2?d:e)
}
}else for(var o=0,p=l[w];o<p;o++)c[i][o]=l[o];
switch(k[0]){
case"z":d=f;e=g;break;
case"h":d=k[1];break;
case"v":e=k[1];break;
case"m":f=c[i][c[i][w]-2];g=c[i][c[i][w]-1];
default:
d=c[i][c[i][w]-2];e=c[i][c[i][w]-1]}}c[h]=a._path2string;
return c},null,bo
),
br=function(a,b,c,d){
return[a,b,c,d,c,d]},bs=function(a,b,c,d,e,f){
var g=1/3,h=2/3;
return[g*a+h*c,g*b+h*d,g*e+h*c,g*f+h*d,e,f]
},
bt=function(a,b,c,d,e,f,g,h,i,j){
var k=d*120/180,l=d/180*(+e||0),m=[],o,p=bm(function(a,b,c){var d=a*y.cos(c)-b*y.sin(c),e=a*y.sin(c)+b*y.cos(c);
return{x:d,y:e}});
if(j){
g=j[0];h=j[1];e=j[2];f=j[3]}else{o=p(a,b,-l);a=o.x;b=o.y;o=p(h,i,-l);
h=o.x;i=o.y;var q=y.cos(d/180*e),r=y.sin(d/180*e),t=(a-h)/2,u=(b-i)/2,x=t*t/(c*c)+u*u/(d*d);
if(x>1)
{
x=y.sqrt(x);c=x*c;
d=x*d}var z=c*c,a=d*d,c=(f==g?-1:1)*y.sqrt(b((z*a-z*u*u-a*t*t)/(z*u*u+a*t*t))),e=c*c*u/d+(a+h)/2,
f=c*-d*t/c+(b+i)/2,g=y.asin(((b-f)/d).tofixed(9)),h=y.asin(((i-f)/d).tofixed(9));
g=a<e?d-g:g;h=h<e?d-h:h;
g<0&&(g=d*2+g);h<0&&(h=d*2+h);g&&g>h&&(g=g-d*2);!g&&h>g&&(h=h-d*2)}
var i=h-g;
if(b(i)>k)
{
var j=h,k=h,l=i;h=g+k*(g&&h>g?1:-1);h=e+c*y.cos(h);i=f+d*y.sin(h);m=bt(h,i,c,d,e,0,g,k,l,[h,j,e,f])
}
i=h-g;
var m=y.cos(g),n=y.sin(g),o=y.cos(h),p=y.sin(h),q=y.tan(i/4),r=4/3*c*q,s=4/3*d*q,
t=[a,b],u=[a+r*n,b-s*m],v=[h+r*p,i-s*o],w=[h,i];u[0]=2*t[0]-u[0];u[1]=2*t[1]-u[1];{
if(j)
return[u,v,w][n](m);
m=[u,v,w][n](m)[v]()[s](",");
var x=[];
for(var y=0,z=m[w];y<z;y++)
x[y]=y%2?p(m[y-1],m[y],l).y:p(m[y],m[y+1],l).x;return x}},bu=function(a,b,c,d,e,f,g,h,i){
var j=1-i;return{x:c(j,3)*a+c(j,2)*3*i*c+j*3*i*i*e+c(i,3)*g,y:c(j,3)*b+c(j,2)*3*i*d+j*3*i*i*f+c(i,3)*h
}
},bv=bm(function(a,b,c,d,e,f,g,h){
var i=e-2*c+a-(g-2*e+c),j=2*(c-a)-2*(e-c),k=a-c,l=(-j+y.sqrt(j*j-4*i*k))/2/i,n=(-j-y.sqrt(j*j-4*i*k))/2/i,
o=[b,h],p=[a,g],q;b(l)>"1e12"&&(l=0.5);b(n)>"1e12"&&(n=0.5);
if(l>0&&l<1)
{
q=bu(a,b,c,d,e,f,g,h,l);p[l](q.x);o[l](q.y)
}
if(n>0&&n<1)
{
q=bu(a,b,c,d,e,f,g,h,n);p[l](q.x);o[l](q.y)}i=f-2*d+b-(h-2*f+d);j=2*(d-b)-2*(f-d);k=b-d;
l=(-j+y.sqrt(j*j-4*i*k))/2/i;n=(-j-y.sqrt(j*j-4*i*k))/2/i;b(l)>"1e12"&&(l=0.5);b(n)>"1e12"&&(n=0.5);
if(l>0&&l<1)
{
q=bu(a,b,c,d,e,f,g,h,l);p[l](q.x);o[l](q.y)}if(n>0&&n<1){q=bu(a,b,c,d,e,f,g,h,n);p[l](q.x);o[l](q.y)
}
return{min:{x:a[m](0,p),y:a[m](0,o)},max:{x:z[m](0,p),y:z[m](0,o)}}}),bw=bm(function(a,b){var c=bq(a),
d=b&&bq(b),e={x:0,y:0,bx:0,by:0,x:0,y:0,qx:null,qy:null},
f={x:0,y:0,bx:0,by:0,x:0,y:0,qx:null,qy:null},
g=function(a,b){
var c,d;
if(!a)
return["c",b.x,b.y,b.x,b.y,b.x,b.y];!(a[0]in{t:1,q:1})&&(b.qx=b.qy=null);
switch(a[0]){
case"m":b.x=a[1];b.y=a[2];break;
case"a":a=["c"][n](bt[m](0,[b.x,b.y][n](a.slice(1))));break;
case"s":c=b.x+(b.x-(b.bx||b.x));d=b.y+(b.y-(b.by||b.y));a=["c",c,d][n](a.slice(1));break;
case"t":b.qx=b.x+(b.x-(b.qx||b.x));b.qy=b.y+(b.y-(b.qy||b.y));a=["c"][n](bs(b.x,b.y,b.qx,b.qy,a[1],a[2]));break;
case"q":b.qx=a[1];b.qy=a[2];a=["c"][n](bs(b.x,b.y,a[1],a[2],a[3],a[4]));break;
case"l":a=["c"][n](br(b.x,b.y,a[1],a[2]));break;
case"h":a=["c"][n](br(b.x,b.y,a[1],b.y));break;
case"v":a=["c"][n](br(b.x,b.y,b.x,a[1]));break;
case"z":a=["c"][n](br(b.x,b.y,b.x,b.y));break
}
return a
},
h=function(a,b){
if(a[b][w]>7)
{
a[b].shift();
var e=a[b];
while(e[w])
a.splice(b++,0,["c"][n](e.splice(0,6)));
a.splice(b,1);
k=z(c[w],d&&d[w]||0)}},
i=function(a,b,e,f,g){
if(a&&b&&a[g][0]=="m"&&b[g][0]!="m")
{
b.splice(g,0,["m",f.x,f.y]);e.bx=0;e.by=0;e.x=a[g][1];e.y=a[g][2];k=z(c[w],d&&d[w]||0)}};
for(var j=0,k=z(c[w],d&&d[w]||0);j<k;j++)
{
c[j]=g(c[j],e);h(c,j);
d&&(d[j]=g(d[j],f));
d&&h(d,j);i(c,d,e,f,j);
i(d,c,f,e,j);
var l=c[j],o=d&&d[j],p=l[w],q=d&&o[w];
e.x=l[p-2];e.y=l[p-1];
e.bx=s(l[p-4])||e.x;e.by=s(l[p-3])||e.y;
f.bx=d&&(s(o[q-4])||f.x);
f.by=d&&(s(o[q-3])||f.y);
f.x=d&&o[q-2];
f.y=d&&o[q-1]}return d?[c,d]:c},null,bo),
bx=bm(function(b){
var c=[];
for(var d=0,e=b[w];d<e;d++){
var f={},g=b[d].match(/^([^:]*):?([\d\.]*)/);f.color=a.getrgb(g[1]);
if(f.color.error)
return null;
f.color=f.color.hex;g[2]&&(f.offset=g[2]+"%");c[l](f)}for(d=1,e=c[w]-1;d<e;d++){
if(!c[d].offset)
{
var h=s(c[d-1].offset||0),i=0;
for(var j=d+1;j<e;j++){
if(c[j].offset)
{
i=c[j].offset;break
}
}
if(!i)
{
i=100;
j=e
}
i=s(i);
var k=(i-h)/(j-d+1);
for(;d<j;d++)
{
h+=k;c[d].offset=h+"%"
}
}
}
return c
}),
by=function(b,c,d,e){
var f;
if(a.is(b,f)||a.is(b,"object")){
f=a.is(b,f)?g.getelementbyid(b):b;
if(f.tagname)
return c==null?{
container:f,width:f.style.pixelwidth||f.offsetwidth,height:f.style.pixelheight||f.offsetheight}:{container:f,width:c,height:d}}
else return{container:1,x:b,y:c,width:d,height:e}},bz=function(a,b){
var c=this;for(var d in b){
if(b[f](d)&&!(d in a))
switch(typeof b[d]){
case"function":(function(b){a[d]=a===c?b:function(){
return b[m](c,arguments)}})(b[d]);break;
case"object":a[d]=a[d]||{};bz.call(this,a[d],b[d]);break;
default:
a[d]=b[d];break
}}},ba=function(a,b){a==b.top&&(b.top=a.prev);a==b.bottom&&(b.bottom=a.next);
a.next&&(a.next.prev=a.prev);a.prev&&(a.prev.next=a.next)},bb=function(a,b){
if(b.top===a)
return;ba(a,b);a.next=null;a.prev=b.top;b.top.next=a;b.top=a},bc=function(a,b){
if(b.bottom===a)
return;ba(a,b);a.next=b.bottom;a.prev=null;b.bottom.prev=a;b.bottom=a},
bd=function(a,b,c){ba(a,c);b==c.top&&(c.top=a);b.next&&(b.next.prev=a);a.next=b.next;a.prev=b;b.next=a},
be=function(a,b,c){ba(a,c);b==c.bottom&&(c.bottom=a);b.prev&&(b.prev.next=a);a.prev=b.prev;b.prev=a;a.next=b},
bf=function(a){return function(){
throw new error("raphaël: you are calling to method “"+a+"” of removed object")}};a.pathtorelative=bp;
if(a.svg){k.svgns="
return+a+(~(~a)===a)*0.5};var bg=function(a,b){
if(b)for(var c in b)b[f](c)&&a[r](c,r(b[c]));
else{a=g.createelementns(k.svgns,a);a.style.webkittaphighlightcolor="rgba(0,0,0,0)";return a}};
a[h]=function(){return"your browser supports svg.\nyou are running raphaël "+this.version};
var bh=function(a,b){var c=bg("path");b.canvas&&b.canvas[l](c);var d=new bn(c,b);d.type="path";
bk(d,{fill:"none",stroke:"#000",path:a});
return d},bi=function(a,b,c){var d="linear",e=0.5,f=0.5,h=a.style;b=r(b)[y](bd,function(a,b,c){d="radial";
if(b&&c){e=s(b);f=s(c);var g=(f>0.5)*2-1;
c(e-0.5,2)+c(f-0.5,2)>0.25&&(f=y.sqrt(0.25-c(e-0.5,2))*g+0.5)&&f!=0.5&&(f=f.tofixed(5)-0.00001*g)}return p});
b=b[s](/\s*\-\s*/);if(d=="linear"){var i=b.shift();i=-s(i);
if(isnan(i))return null;var j=[0,0,y.cos(i*d/180),y.sin(i*d/180)],k=1/(z(b(j[2]),b(j[3]))||1);
j[2]*=k;j[3]*=k;
if(j[2]<0){j[0]=-j[2];j[2]=0}if(j[3]<0){j[1]=-j[3];j[3]=0}}var m=bx(b);
if(!m)return null;var n=a.getattribute(i);n=n.match(/^url\(#(.*)\)$/);
n&&c.defs.removechild(g.getelementbyid(n[1]));var o=bg(d+"gradient");o.id=bh();
bg(o,d=="radial"?{fx:e,fy:f}:{x1:j[0],y1:j[1],x2:j[2],y2:j[3]});c.defs[l](o);
for(var q=0,t=m[w];q<t;q++){var u=bg("stop");
bg(u,{offset:m[q].offset?m[q].offset:q?"100%":"0%","stop-color":m[q].color||"#fff"});
o[l](u)}bg(a,{fill:"url(#"+o.id+")",opacity:1,"fill-opacity":1});h.fill=p;h.opacity=1;h.fillopacity=1;
return 1},
bj=function(b){var c=b.getbbox();bg(b.pattern,{patterntransform:a.format("translate({0},{1})",c.x,c.y)})},
bk=function(c,d){
var e={"":[0],none:[0],"-":[3,1],".":[1,1],"-.":[3,1,1,1],"-..":[3,1,1,1,1,1],". ":[1,3],"- ":[4,3],"--":[8,3],
"- .":[4,3,1,3],"--.":[8,3,1,3],"--..":[8,3,1,3,1,3]},
h=c.node,i=c.attrs,j=c.rotate(),
k=function(a,b){b=e[x.call(b)];
if(b){var c=a.attrs["stroke-width"]||"1",f=({round:c,square:c,butt:0})
[a.attrs["stroke-linecap"]||d["stroke-linecap"]]||0,g=[],i=b[w];while(i--)g[i]=b[i]*c+(i%2?1:-1)*f;
bg(h,{"stroke-dasharray":g[v](",")})}};
d[f]("rotation")&&(j=d.rotation);
var m=r(j)[s](b);
if(m.length-1){m[1]=+m[1];m[2]=+m[2]}else m=null;s(j)&&c.rotate(0,true);
for(var n in d){if(d[f](n)){
if(!w[f](n))continue;var o=d[n];i[n]=o;
switch(n){case"blur":c.blur(o);break;
case"rotation":c.rotate(o,true);break;case"href":case"title":case"target":var t=h.parentnode;
if(x.call(t.tagname)!="a"){var u=bg("a");t.insertbefore(u,h);u[l](h);
t=u}
n=="target"&&o=="blank"?t.setattributens(c.paper.xlink,"show","new"):t.setattributens(c.paper.xlink,n,o);
break;
case"cursor":h.style.cursor=o;break;case"clip-rect":var y=r(o)[s](b);
if(y[w]==4){c.clip&&c.clip.parentnode.parentnode.removechild(c.clip.parentnode);
var z=bg("clippath"),a=bg("rect");z.id=bh();bg(a,{x:y[0],y:y[1],width:y[2],height:y[3]});z[l](a);
c.paper.defs[l](z);bg(h,{"clip-path":"url(#"+z.id+")"});c.clip=a}
if(!o){
var b=g.getelementbyid(h.getattribute("clip-path")[y](/(^url\(#|\)$)/g,p));
b&&b.parentnode.removechild(b);
bg(h,{"clip-path":p});delete c.clip}break;case"path":c.type=="path"&&bg(h,{d:o?i.path=bq(o):"m0,0"});break;
case"width":h[r](n,o);
if(i.fx){
n="x";o=i.x}else break;case"x":i.fx&&(o=-i.x-(i.width||0));
case"rx":if(n=="rx"&&c.type=="rect")break;
case"cx":m&&(n=="x"||n=="cx")&&(m[1]+=o-i[n]);h[r](n,o);
c.pattern&&bj(c);break;
case"height":h[r](n,o);if(i.fy){n="y";o=i.y}else break;
case"y":i.fy&&(o=-i.y-(i.height||0));case"ry":if(n=="ry"&&c.type=="rect")break;
case"cy":m&&(n=="y"||n=="cy")&&(m[2]+=o-i[n]);h[r](n,o);c.pattern&&bj(c);break;
case"r":c.type=="rect"?bg(h,{rx:o,ry:o}):h[r](n,o);break;
case"src":c.type=="image"&&h.setattributens(c.paper.xlink,"href",o);break;
case"stroke-width":h.style.strokewidth=o;h[r](n,o);i["stroke-dasharray"]&&k(c,i["stroke-dasharray"]);break;
case"stroke-dasharray":k(c,o);break;
case"translation":var c=r(o)[s](b);c[0]=+c[0]||0;c[1]=+c[1]||0;if(m){m[1]+=c[0];m[2]+=c[1]}cz.call(c,c[0],c[1]);break;
case"scale":c=r(o)[s](b);c.scale(+c[0]||1,+c[1]||+c[0]||1,isnan(s(c[2]))?null:+c[2],isnan(s(c[3]))?null:+c[3]);break;
case i:var d=r(o).match(m);
if(d){z=bg("pattern");
var e=bg("image");z.id=bh();
bg(z,{x:0,y:0,patternunits:"userspaceonuse",height:1,width:1});
bg(e,{x:0,y:0});e.setattributens(c.paper.xlink,"href",d[1]);z[l](e);
var f=g.createelement("img");f.style.csstext="position:absolute;left:-9999em;top-9999em";
f.onload=function(){
bg(z,{width:this.offsetwidth,height:this.offsetheight});
bg(e,{width:this.offsetwidth,height:this.offsetheight});
g.body.removechild(this);
c.paper.safari()};
g.body[l](f);f.src=d[1];
c.paper.defs[l](z);h.style.fill="url(#"+z.id+")";
bg(h,{fill:"url(#"+z.id+")"});c.pattern=z;c.pattern&&bj(c);break}
var g=a.getrgb(o);
if(g.error)
if((({circle:1,ellipse:1})[f](c.type)||r(o).charat()!="r")&&bi(h,o,c.paper)){
i.gradient=o;i.fill="none";break}
else{
delete d.gradient;
delete i.gradient;!a.is(i.opacity,"undefined")&&a.is(d.opacity,"undefined")&&bg(h,{opacity:i.opacity});
!a.is(i["fill-opacity"],"undefined")&&a.is(d["fill-opacity"],"undefined")&&bg(h,{
"fill-opacity":i["fill-opacity"]})}g[f]("opacity")&&bg(h,{"fill-opacity":g.opacity>1?g.opacity/100:g.opacity});
case"stroke":g=a.getrgb(o);h[r](n,g.hex);
n=="stroke"&&g[f]("opacity")&&bg(h,{"stroke-opacity":g.opacity>1?g.opacity/100:g.opacity});break;
case"gradient":(({circle:1,ellipse:1})[f](c.type)||r(o).charat()!="r")&&bi(h,o,c.paper);break;
case"opacity":i.gradient&&!i[f]("stroke-opacity")&&bg(h,{"stroke-opacity":o>1?o/100:o});
case"fill-opacity":if(i.gradient){
var h=g.getelementbyid(h.getattribute(i)[y](/^url\(#|\)$/g,p));
if(h){
var j=h.getelementsbytagname("stop");j[j[w]-1][r]("stop-opacity",o)}
break}
default:
n=="font-size"&&(o=t(o,10)+"px");
var k=n[y](/(\-.)/g,function(a){return v.call(a.substring(1))});h.style[k]=o;h[r](n,o);
break}}}
bm(c,d);m?c.rotate(m.join(q)):s(j)&&c.rotate(j,true)},bl=1.2,bm=function(b,c){
if(b.type!="text"||!(c[f]("text")||c[f]("font")||c[f]("font-size")||c[f]("x")||c[f]("y")))return;
var d=b.attrs,e=b.node,h=e.firstchild?t(g.defaultview.getcomputedstyle(e.firstchild,p).getpropertyvalue(
"font-size"),10):10;if(c[f]("text")){
d.text=c.text;while(e.firstchild)e.removechild(e.firstchild);
var i=r(c.text)[s]("\n");
for(var j=0,k=i[w];j<k;j++)
if(i[j]){var m=bg("tspan");
j&&bg(m,{dy:h*bl,x:d.x});
m[l](g.createtextnode(i[j]));
e[l](m)}
}else{
i=e.getelementsbytagname("tspan");for(j=0,k=i[w];j<k;j++)j&&bg(i[j],{dy:h*bl,x:d.x})}bg(e,{y:d.y});
var n=b.getbbox(),o=d.y-(n.y+n.height/2);o&&a.is(o,"finite")&&bg(e,{y:d.y+o})},
bn=function(b,c){
var d=0,e=0;
this[0]=b;
this.id=a._oid++;
this.node=b;b.raphael=this;
this.paper=c;
this.attrs=this.attrs||{};
this.transformations=[];
this._={tx:0,ty:0,rt:{deg:0,cx:0,cy:0},sx:1,sy:1};!c.bottom&&(c.bottom=this);
this.prev=c.top;
c.top&&(c.top.next=this);
c.top=this;
this.next=null},bo=bn[e];
bn[e].rotate=function(c,d,e){
if(this.removed)return this;
if(c==null){
if(this._.rt.cx)
return[this._.rt.deg,this._.rt.cx,this._.rt.cy][v](q);
return this._.rt.deg
}var f=this.getbbox();c=r(c)[s](b);
if(c[w]-1){
d=s(c[1]);
e=s(c[2])}c=s(c[0]);
d!=null&&d!==false?this._.rt.deg=c:this._.rt.deg+=c;
e==null&&(d=null);
this._.rt.cx=d;
this._.rt.cy=e;
d=d==null?f.x+f.width/2:d;e=e==null?f.y+f.height/2:e;
if(this._.rt.deg){
this.transformations[0]=a.format("rotate({0} {1} {2})",this._.rt.deg,d,e);
this.clip&&bg(this.clip,{transform:a.format("rotate({0} {1} {2})",-this._.rt.deg,d,e)})
}else{
this.transformations[0]=p;
this.clip&&bg(this.clip,{transform:p})}
bg(this.node,{transform:this.transformations[v](q)});
return this
};bn[e].hide=function(){!this.removed&&(this.node.style.display="none");
return this};
bn[e].show=function(){!this.removed&&(this.node.style.display="");
return this};
bn[e].remove=function(){
if(this.removed)return;ba(this,this.paper);
this.node.parentnode.removechild(this.node);
for(var a in this)delete this[a];this.removed=true};bn[e].getbbox=function(){
if(this.removed)return this;
if(this.type=="path")return bn(this.attrs.path);
if(this.node.style.display=="none"){this.show();var a=true}var b={};
try{b=this.node.getbbox()}catch(a){}finally{b=b||{}}
if(this.type=="text"){
b={x:b.x,y:infinity,width:0,height:0};
for(var c=0,d=this.node.getnumberofchars();c<d;c++){
var e=this.node.getextentofchar(c);e.y<b.y&&(b.y=e.y);e.y+e.height-b.y>b.height&&(b.height=e.y+e.height-b.y);
e.x+e.width-b.x>b.width&&(b.width=e.x+e.width-b.x)}}a&&this.hide();
return b};
bn[e].attr=function(b,c){
if(this.removed)return this;
if(b==null){
var d={};
for(var e in this.attrs)this.attrs[f](e)&&(d[e]=this.attrs[e]);
this._.rt.deg&&(d.rotation=this.rotate());(this._.sx!=1||this._.sy!=1)&&(d.scale=this.scale());
d.gradient&&d.fill=="none"&&(d.fill=d.gradient)&&delete d.gradient;return d}
if(c==null&&a.is(b,f)){
if(b=="translation")return cz.call(this);
if(b=="rotation")return this.rotate();
if(b=="scale")return this.scale();
if(b==i&&this.attrs.fill=="none"&&this.attrs.gradient)return this.attrs.gradient;return this.attrs[b]}
if(c==null&&a.is(b,g)){var g={};
for(var h=0,i=b.length;h<i;h++)g[b[h]]=this.attr(b[h]);return g}
if(c!=null){var j={};j[b]=c}else b!=null&&a.is(b,"object")&&(j=b);
for(var k in this.paper.customattributes)
if(this.paper.customattributes[f](k)&&j[f](k)&&a.is(this.paper.customattributes[k],"function")){
var l=this.paper.customattributes[k].apply(this,[][n](j[k]));
this.attrs[k]=j[k];for(var m in l)l[f](m)&&(j[m]=l[m])}bk(this,j);
return this};bn[e].tofront=function(){
if(this.removed)return this;this.node.parentnode[l](this.node);var a=this.paper;a.top!=this&&bb(this,a);
return this};bn[e].toback=function(){
if(this.removed)return this;
if(this.node.parentnode.firstchild!=this.node){
this.node.parentnode.insertbefore(this.node,this.node.parentnode.firstchild);bc(this,this.paper);
var a=this.paper}
return this};
bn[e].insertafter=function(a){
if(this.removed)return this;
var b=a.node||a[a.length-1].node;
b.nextsibling?b.parentnode.insertbefore(this.node,b.nextsibling):b.parentnode[l](this.node);
bd(this,a,this.paper);return this};bn[e].insertbefore=function(a){
if(this.removed)return this;var b=a.node||a[0].node;b.parentnode.insertbefore(this.node,b);
be(this,a,this.paper);return this};bn[e].blur=function(a){var b=this;if(+a!==0){
var c=bg("filter"),d=bg("fegaussianblur");
b.attrs.blur=a;c.id=bh();bg(d,{stddeviation:+a||1.5});
c.appendchild(d);b.paper.defs.appendchild(c);
b._blur=c;bg(b.node,{filter:"url(#"+c.id+")"})}else{if(b._blur){b._blur.parentnode.removechild(b._blur);
delete b._blur;
delete b.attrs.blur}b.node.removeattribute("filter")}};
var bp=function(a,b,c,d){var e=bg("circle");
a.canvas&&a.canvas[l](e);
var f=new bn(e,a);f.attrs={cx:b,cy:c,r:d,fill:"none",stroke:"#000"};
f.type="circle";bg(e,f.attrs);return f},bq=function(a,b,c,d,e,f){var g=bg("rect");a.canvas&&a.canvas[l](g);
var h=new bn(g,a);h.attrs={x:b,y:c,width:d,height:e,r:f||0,rx:f||0,ry:f||0,fill:"none",stroke:"#000"};h.type="rect";
bg(g,h.attrs);return h},br=function(a,b,c,d,e){var f=bg("ellipse");
a.canvas&&a.canvas[l](f);var g=new bn(f,a);g.attrs={cx:b,cy:c,rx:d,ry:e,fill:"none",stroke:"#000"};
g.type="ellipse";bg(f,g.attrs);return g},bs=function(a,b,c,d,e,f){var g=bg("image");
bg(g,{x:c,y:d,width:e,height:f,preserveaspectratio:"none"});g.setattributens(a.xlink,"href",b);
a.canvas&&a.canvas[l](g);var h=new bn(g,a);h.attrs={x:c,y:d,width:e,height:f,src:b};h.type="image";
return h},bt=function(a,b,c,d){var e=bg("text");bg(e,{x:b,y:c,"text-anchor":"middle"});
a.canvas&&a.canvas[l](e);var f=new bn(e,a);
f.attrs={x:b,y:c,"text-anchor":"middle",text:d,font:w.font,stroke:"none",fill:"#000"};
f.type="text";bk(f,f.attrs);
return f},bu=function(a,b){
this.width=a||this.width;
this.height=b||this.height;
this.canvas[r]("width",this.width);
this.canvas[r]("height",this.height);
return this},bv=function(){var b=by[m](0,arguments),c=b&&b.container,d=b.x,e=b.y,f=b.width,h=b.height;
if(!c)throw new error("svg container not found.");
var i=bg("svg");d=d||0;e=e||0;f=f||512;h=h||342;
bg(i,{xmlns:"
if(c==1){i.style.csstext="position:absolute;left:"+d+"px;top:"+e+"px";
g.body[l](i)}else c.firstchild?c.insertbefore(i,c.firstchild):c[l](i);c=new j;
c.width=f;c.height=h;c.canvas=i;bz.call(c,c,a.fn);c.clear();return c};
k.clear=function(){var a=this.canvas;while(a.firstchild)a.removechild(a.firstchild);
this.bottom=this.top=null;(this.desc=bg("desc"))[l](g.createtextnode("created with raphaël"));
a[l](this.desc);a[l](this.defs=bg("defs"))};
k.remove=function(){this.canvas.parentnode&&this.canvas.parentnode.removechild(this.canvas);
for(var a in this)this[a]=bf(a)}}
if(a.vml){
var bw={m:"m",l:"l",c:"c",z:"x",m:"t",l:"r",c:"v",z:"x"},
bx=/([clmz]),?([^clmz]*)/gi,by=/ progid:\s+blur\([^\)]+\)/g,bz=/-?[^,\s-]+/g,b$=1000+q+1000,b_=10,
ca={path:1,rect:1},cb=function(a){var b=/[ahqstv]/ig,c=bq;r(a).match(b)&&(c=bw);b=/[clmz]/g;
if(c==bq&&!r(a).match(b)){var d=r(a)[y](bx,function(a,b,c){var d=[],e=x.call(b)=="m",f=bw[b];
c[y](bz,function(a){if(e&&d[w]==2){f+=d+bw[b=="m"?"l":"l"];d=[]}d[l](q(a*b_))});return f+d});
return d}var e=c(a),f,g;d=[];for(var h=0,i=e[w];h<i;h++){f=e[h];g=x.call(e[h][0]);g=="z"&&(g="x");
for(var j=1,k=f[w];j<k;j++)g+=q(f[j]*b_)+(j!=k-1?",":p);d[l](g)}return d[v](q)};
a[h]=function(){
return"your browser doesn’t support svg. falling down to vml.\nyou are running raphaël "+this.version};
bh=function(a,b){var c=cd("group");
c.style.csstext="position:absolute;
left:0;
top:0;
width:"+b.width+"px;
height:"+b.height+"px";
c.coordsize=b.coordsize;c.coordorigin=b.coordorigin;var d=cd("shape"),e=d.style;e.width=b.width+"px";
e.height=b.height+"px";d.coordsize=b$;d.coordorigin=b.coordorigin;
c[l](d);var f=new bn(d,c,b),g={fill:"none",stroke:"#000"};
a&&(g.path=a);f.type="path";f.path=[];f.path=p;bk(f,g);b.canvas[l](c);
return f};bk=function(c,d){c.attrs=c.attrs||{};
var e=c.node,h=c.attrs,i=e.style,j,
k=(d.x!=h.x||d.y!=h.y||d.width!=h.width||d.height!=h.height||d.r!=h.r)&&c.type=="rect",m=c;
for(var n in d)d[f](n)&&(h[n]=d[n]);if(k){h.path=cc(h.x,h.y,h.width,h.height,h.r);
c.x=h.x;c.y=h.y;c.w=h.width;c.h=h.height}d.href&&(e.href=d.href);d.title&&(e.title=d.title);
d.target&&(e.target=d.target);d.cursor&&(i.cursor=d.cursor);"blur"in d&&c.blur(d.blur);
if(d.path&&c.type=="path"||k)e.path=cb(h.path);d.rotation!=null&&c.rotate(d.rotation,true);
if(d.translation){j=r(d.translation)[s](b);cz.call(c,j[0],j[1]);
if(c._.rt.cx!=null){c._.rt.cx+=+j[0];c._.rt.cy+=+j[1];
c.setbox(c.attrs,j[0],j[1])}}if(d.scale){j=r(d.scale)[s](b);
c.scale(+j[0]||1,+j[1]||+j[0]||1,+j[2]||null,+j[3]||null)}if("clip-rect"in d){
var o=r(d["clip-rect"])[s](b);
if(o[w]==4){o[2]=+o[2]+ +o[0];o[3]=+o[3]+ +o[1];
var q=e.cliprect||g.createelement("p"),t=q.style,u=e.parentnode;
t.clip=a.format("rect({1}px {2}px {3}px {0}px)",o);if(!e.cliprect){t.position="absolute";
t.top=0;t.left=0;t.width=c.paper.width+"px";t.height=c.paper.height+"px";
u.parentnode.insertbefore(q,u);q[l](u);
e.cliprect=q}}d["clip-rect"]||e.cliprect&&(e.cliprect.style.clip=p)}c.type=="image"&&d.src&&(e.src=d.src);
if(c.type=="image"&&d.opacity){e.filteropacity=u+".alpha(opacity="+d.opacity*100+")";
i.filter=(e.filtermatrix||p)+(e.filteropacity||p)}d.font&&(i.font=d.font);
d["font-family"]&&(i.fontfamily="\""+d["font-family"][s](",")[0][y](/^['"]+|['"]+$/g,p)+"\"");
d["font-size"]&&(i.fontsize=d["font-size"]);d["font-weight"]&&(i.fontweight=d["font-weight"]);
d["font-style"]&&(i.fontstyle=d["font-style"]);
if(d.opacity!=null||d["stroke-width"]!=null||d.fill!=null||d.stroke!=null||d["stroke-width"]!=null||
d["stroke-opacity"]!=null||d["fill-opacity"]!=null||d["stroke-dasharray"]!=null||d["stroke-miterlimit"]!=null||
d["stroke-linejoin"]!=null||d["stroke-linecap"]!=null){
e=c.shape||e;var v=e.getelementsbytagname(i)&&e.getelementsbytagname(i)[0],x=false;!v&&(x=v=cd(i));
if("fill-opacity"in d||"opacity"in d){
var y=((+h["fill-opacity"]+1||2)-1)*((+h.opacity+1||2)-1)*((+a.getrgb(d.fill).o+1||2)-1);y=a(z(y,0),1);
v.opacity=y}d.fill&&(v.on=true);if(v.on==null||d.fill=="none")v.on=false;if(v.on&&d.fill){
var b=d.fill.match(m);if(b){v.src=b[1];v.type="tile"}else{v.color=a.getrgb(d.fill).hex;v.src=p;
v.type="solid";
if(a.getrgb(d.fill).error&&(m.type in{circle:1,ellipse:1}||r(d.fill).charat()!="r")&&bi(m,d.fill)){
h.fill="none";h.gradient=d.fill}}}x&&e[l](v);
var c=e.getelementsbytagname("stroke")&&e.getelementsbytagname("stroke")[0],d=false;!c&&(d=c=cd("stroke"));
if(d.stroke&&d.stroke!="none"||d["stroke-width"]||d["stroke-opacity"]!=null||d["stroke-dasharray"]||
d["stroke-miterlimit"]||d["stroke-linejoin"]||d["stroke-linecap"])c.on=true;(d.stroke=="none"||
c.on==null||d.stroke==0||d["stroke-width"]==0)&&(c.on=false);var e=a.getrgb(d.stroke);
c.on&&d.stroke&&(c.color=e.hex);y=((+h["stroke-opacity"]+1||2)-1)*((+h.opacity+1||2)-1)*((+e.o+1||2)-1);
var f=(s(d["stroke-width"])||1)*0.75;y=a(z(y,0),1);d["stroke-width"]==null&&(f=h["stroke-width"]);
d["stroke-width"]&&(c.weight=f);
f&&f<1&&(y*=f)&&(c.weight=1);c.opacity=y;d["stroke-linejoin"]&&(c.joinstyle=d["stroke-linejoin"]||"miter");
c.miterlimit=d["stroke-miterlimit"]||8;
d["stroke-linecap"]&&(c.endcap=d["stroke-linecap"]=="butt"?"flat":d["stroke-linecap"]=="square"?"square":"round");
if(d["stroke-dasharray"]){
var g={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":
"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};
c.dashstyle=g[f](d["stroke-dasharray"])?g[d["stroke-dasharray"]]:p}d&&e[l](c)}
if(m.type=="text"){i=m.paper.span.style;h.font&&(i.font=h.font);
h["font-family"]&&(i.fontfamily=h["font-family"]);h["font-size"]&&(i.fontsize=h["font-size"]);
h["font-weight"]&&(i.fontweight=h["font-weight"]);h["font-style"]&&(i.fontstyle=h["font-style"]);
m.node.string&&(m.paper.span.innerhtml=r(m.node.string)[y](/</g,"<")[y](/&/g,"&")[y](/\n/g,"<br>"));
m.w=h.w=m.paper.span.offsetwidth;m.h=h.h=m.paper.span.offsetheight;m.x=h.x;m.y=h.y+q(m.h/2);
switch(h["text-anchor"]){case"start":m.node.style["v-text-align"]="left";m.bbx=q(m.w/2);break;
case"end":m.node.style["v-text-align"]="right";m.bbx=-q(m.w/2);break;
default:m.node.style["v-text-align"]="center";break}}};bi=function(a,b){a.attrs=a.attrs||{};
var c=a.attrs,d,e="linear",f=".5 .5";a.attrs.gradient=b;b=r(b)[y](bd,function(a,b,c){
e="radial";if(b&&c){b=s(b);c=s(c);c(b-0.5,2)+c(c-0.5,2)>0.25&&(c=y.sqrt(0.25-c(b-0.5,2))*((c>0.5)*2-1)+0.5);
f=b+q+c}return p});b=b[s](/\s*\-\s*/);if(e=="linear"){var g=b.shift();g=-s(g);
if(isnan(g))return null}var h=bx(b);if(!h)return null;a=a.shape||a.node;
d=a.getelementsbytagname(i)[0]||cd(i);!d.parentnode&&a.appendchild(d);
if(h[w]){d.on=true;d.method="none";d.color=h[0].color;d.color2=h[h[w]-1].color;var i=[];
for(var j=0,k=h[w];j<k;j++)h[j].offset&&i[l](h[j].offset+q+h[j].color);
d.colors&&(d.colors.value=i[w]?i[v]():"0% "+d.color);if(e=="radial"){d.type="gradientradial";
d.focus="100%";d.focussize=f;d.focusposition=f}else{d.type="gradient";d.angle=(270-g)%360}}return 1};
bn=function(b,c,d){var e=0,f=0,g=0,h=1;this[0]=b;this.id=a._oid++;this.node=b;b.raphael=this;this.x=0;
this.y=0;this.attrs={};this.group=c;
this.paper=d;this._={tx:0,ty:0,rt:{deg:0},sx:1,sy:1};!d.bottom&&(d.bottom=this);
this.prev=d.top;d.top&&(d.top.next=this);d.top=this;this.next=null};bo=bn[e];
bo.rotate=function(a,c,d){
if(this.removed)return this;if(a==null){
if(this._.rt.cx)return[this._.rt.deg,this._.rt.cx,this._.rt.cy][v](q);
return this._.rt.deg}a=r(a)[s](b);if(a[w]-1){c=s(a[1]);d=s(a[2])}a=s(a[0]);
c!=null?this._.rt.deg=a:this._.rt.deg+=a;d==null&&(c=null);this._.rt.cx=c;this._.rt.cy=d;
this.setbox(this.attrs,c,d);this.group.style.rotation=this._.rt.deg;return this};
bo.setbox=function(a,b,c){if(this.removed)return this;
var d=this.group.style,e=this.shape&&this.shape.style||this.node.style;a=a||{};
for(var g in a)a[f](g)&&(this.attrs[g]=a[g]);b=b||this._.rt.cx;c=c||this._.rt.cy;
var h=this.attrs,i,j,k,l;
switch(this.type){case"circle":i=h.cx-h.r;j=h.cy-h.r;k=l=h.r*2;break;
case"ellipse":i=h.cx-h.rx;j=h.cy-h.ry;k=h.rx*2;l=h.ry*2;break;
case"image":i=+h.x;j=+h.y;k=h.width||0;l=h.height||0;break;
case"text":this.textpath.v=["m",q(h.x),", ",q(h.y-2),"l",q(h.x)+1,", ",q(h.y-2)][v](p);i=h.x-q(this.w/2);
j=h.y-this.h/2;k=this.w;l=this.h;break;case"rect":case"path":if(this.attrs.path){var m=bn(this.attrs.path);
i=m.x;j=m.y;k=m.width;l=m.height}else{i=0;j=0;k=this.paper.width;l=this.paper.height}break;
default:i=0;j=0;k=this.paper.width;
l=this.paper.height;break}b=b==null?i+k/2:b;c=c==null?j+l/2:c;
var n=b-this.paper.width/2,o=c-this.paper.height/2,q;d.left!=(q=n+"px")&&(d.left=q);d.top!=(q=o+"px")&&(d.top=q);
this.x=ca[f](this.type)?-n:i;this.y=ca[f](this.type)?-o:j;this.w=k;this.h=l;
if(ca[f](this.type)){
e.left!=(q=-n*b_+"px")&&(e.left=q);e.top!=(q=-o*b_+"px")&&(e.top=q)}
else if(this.type=="text"){e.left!=(q=-n+"px")&&(e.left=q);e.top!=(q=-o+"px")&&(e.top=q)
}else{
d.width!=(q=this.paper.width+"px")&&(d.width=q);
d.height!=(q=this.paper.height+"px")&&(d.height=q);
e.left!=(q=i-n+"px")&&(e.left=q);e.top!=(q=j-o+"px")&&(e.top=q);e.width!=(q=k+"px")&&(e.width=q);
e.height!=(q=l+"px")&&(e.height=q)}};bo.hide=function(){!this.removed&&(this.group.style.display="none");
return this};bo.show=function(){!this.removed&&(this.group.style.display="block");return this};
bo.getbbox=function(){if(this.removed)return this;if(ca[f](this.type))return bn(this.attrs.path);
return{x:this.x+(this.bbx||0),y:this.y,width:this.w,height:this.h}};bo.remove=function(){
if(this.removed)return;ba(this,this.paper);this.node.parentnode.removechild(this.node);
this.group.parentnode.removechild(this.group);this.shape&&this.shape.parentnode.removechild(this.shape);
for(var a in this)delete this[a];this.removed=true};bo.attr=function(b,c){if(this.removed)return this;
if(b==null){var d={};for(var e in this.attrs)this.attrs[f](e)&&(d[e]=this.attrs[e]);
this._.rt.deg&&(d.rotation=this.rotate());(this._.sx!=1||this._.sy!=1)&&(d.scale=this.scale());
d.gradient&&d.fill=="none"&&(d.fill=d.gradient)&&delete d.gradient;return d}if(c==null&&a.is(b,"string")){
if(b=="translation")return cz.call(this);if(b=="rotation")return this.rotate();if(b=="scale")
return this.scale();
if(b==i&&this.attrs.fill=="none"&&this.attrs.gradient)return this.attrs.gradient;return this.attrs[b]
}
if(this.attrs&&c==null&&a.is(b,g)){var g,h={};for(e=0,g=b[w];e<g;e++)h[b[e]]=this.attr(b[e]);
return h}var i;
if(c!=null){i={};i[b]=c}c==null&&a.is(b,"object")&&(i=b);
if(i){for(var j in this.paper.customattributes)
if(this.paper.customattributes[f](j)&&i[f](j)&&a.is(this.paper.customattributes[j],"function")){
var k=this.paper.customattributes[j].apply(this,[][n](i[j]));this.attrs[j]=i[j];
for(var l in k)
k[f](l)&&(i[l]=k[l])}i.text&&this.type=="text"&&(this.node.string=i.text);bk(this,i);
i.gradient&&(({circle:1,ellipse:1})[f](this.type)||r(i.gradient).charat()!="r")&&bi(this,i.gradient);
(!ca[f](this.type)||this._.rt.deg)&&this.setbox(this.attrs)}return this};bo.tofront=function(){
!this.removed&&this.group.parentnode[l](this.group);this.paper.top!=this&&bb(this,this.paper);return this};
bo.toback=function(){if(this.removed)return this;if(this.group.parentnode.firstchild!=this.group){
this.group.parentnode.insertbefore(this.group,this.group.parentnode.firstchild);bc(this,this.paper)}
return this};bo.insertafter=function(a){if(this.removed)return this;a.constructor==cc&&(a=a[a.length-1]);
a.group.nextsibling?a.group.parentnode.insertbefore(this.group,a.group.nextsibling):a.group.parentnode[l](
this.group);bd(this,a,this.paper);return this};bo.insertbefore=function(a){if(this.removed)return this;
a.constructor==cc&&(a=a[0]);a.group.parentnode.insertbefore(this.group,a.group);be(this,a,this.paper);
return this};bo.blur=function(b){var c=this.node.runtimestyle,d=c.filter;d=d.replace(by,p);if(+b!==0){
this.attrs.blur=b;c.filter=d+q+u+".blur(pixelradius="+(+b||1.5)+")";
c.margin=a.format("-{0}px 0 0 -{0}px",q(+b||1.5))}else{c.filter=d;c.margin=0;delete this.attrs.blur}};
bp=function(a,b,c,d){var e=cd("group"),f=cd("oval"),g=f.style;e.style.csstext="position:absolute;left:0;top:0;
width:"+a.width+"px;height:"+a.height+"px";e.coordsize=b$;e.coordorigin=a.coordorigin;e[l](f);
var h=new bn(f,e,a);h.type="circle";bk(h,{stroke:"#000",fill:"none"});
h.attrs.cx=b;h.attrs.cy=c;h.attrs.r=d;h.setbox({x:b-d,y:c-d,width:d*2,height:d*2});
a.canvas[l](e);return h};
function cc(b,c,d,e,f){
return f?a.format("m{0},{1}l{2},0a{3},{3},0,0,1,{3},{3}l0,{5}a{3},{3},0,0,1,{4},{3}l{6},0a{3},{3},0,0,1,{4},
{4}l0,{7}a{3},{3},0,0,1,{3},{4}z",b+f,c,d-f*2,f,-f,e-f*2,f*2-d,f*2-e):a.format("m{0},{1}l{2},0,0,{3},{4},0z",b,c,d,e,-d)}
bq=function(a,b,c,d,e,f){var g=cc(b,c,d,e,f),h=a.path(g),i=h.attrs;h.x=i.x=b;h.y=i.y=c;
h.w=i.width=d;h.h=i.height=e;i.r=f;i.path=g;h.type="rect";return h};br=function(a,b,c,d,e){
var f=cd("group"),g=cd("oval"),h=g.style;f.style.csstext="position:absolute;left:0;top:0;
width:"+a.width+"px;height:"+a.height+"px";f.coordsize=b$;
f.coordorigin=a.coordorigin;f[l](g);var i=new bn(g,f,a);i.type="ellipse";
bk(i,{stroke:"#000"});i.attrs.cx=b;i.attrs.cy=c;i.attrs.rx=d;i.attrs.ry=e;
i.setbox({x:b-d,y:c-e,width:d*2,height:e*2});a.canvas[l](f);return i};
bs=function(a,b,c,d,e,f){var g=cd("group"),h=cd("image");g.style.csstext="position:absolute;left:0;
top:0;width:"+a.width+"px;height:"+a.height+"px";g.coordsize=b$;g.coordorigin=a.coordorigin;
h.src=b;g[l](h);var i=new bn(h,g,a);i.type="image";i.attrs.src=b;i.attrs.x=c;i.attrs.y=d;i.attrs.w=e;
i.attrs.h=f;i.setbox({x:c,y:d,width:e,height:f});a.canvas[l](g);return i};bt=function(b,c,d,e){
var f=cd("group"),g=cd("shape"),h=g.style,i=cd("path"),j=i.style,k=cd("textpath");
f.style.csstext="position:absolute;left:0;top:0;width:"+b.width+"px;height:"+b.height+"px";
f.coordsize=b$;f.coordorigin=b.coordorigin;i.v=a.format("m{0},{1}l{2},{1}",q(c*10),q(d*10),q(c*10)+1);
i.textpathok=true;h.width=b.width;h.height=b.height;k.string=r(e);k.on=true;g[l](k);g[l](i);
f[l](g);var m=new bn(k,f,b);m.shape=g;m.textpath=i;m.type="text";m.attrs.text=e;m.attrs.x=c;m.attrs.y=d;
m.attrs.w=1;m.attrs.h=1;bk(m,{font:w.font,stroke:"none",fill:"#000"});m.setbox();b.canvas[l](f);return m};
bu=function(a,b){var c=this.canvas.style;a==+a&&(a+="px");b==+b&&(b+="px");c.width=a;c.height=b;
c.clip="rect(0 "+a+" "+b+" 0)";return this};var cd;
g.createstylesheet().addrule(".rvml","behavior:url(#default#vml)");
try{!g.namespaces.rvml&&g.namespaces.add("rvml","urn:schemas-microsoft-com:vml");
cd=function(a){return g.createelement("<rvml:"+a+" class=\"rvml\">")}}catch(a){cd=function(a){
return g.createelement("<"+a+" xmlns=\"urn:schemas-microsoft.com:vml\" class=\"rvml\">")}}bv=function(){
var b=by[m](0,arguments),c=b.container,d=b.height,e,f=b.width,h=b.x,i=b.y;
if(!c)
throw new error("vml container not found.");var k=new j,n=k.canvas=g.createelement("p"),o=n.style;h=h||0;i=i||0;
f=f||512;d=d||342;f==+f&&(f+="px");d==+d&&(d+="px");k.width=1000;k.height=1000;k.coordsize=b_*1000+q+b_*1000;
k.coordorigin="0 0";k.span=g.createelement("span");k.span.style.csstext="position:absolute;left:-9999em;
top:-9999em;padding:0;margin:0;line-height:1;display:inline;";n[l](k.span);
o.csstext=a.format("top:0;left:0;width:{0};height:{1};
display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",f,d);
if(c==1){g.body[l](n);o.left=h+"px";o.top=i+"px";o.position="absolute"}
else c.firstchild?c.insertbefore(n,c.firstchild):c[l](n);bz.call(k,k,a.fn);
return k};k.clear=function(){
this.canvas.innerhtml=p;this.span=g.createelement("span");
this.span.style.csstext="position:absolute;left:-9999em;
top:-9999em;padding:0;margin:0;line-height:1;display:inline;";
this.canvas[l](this.span);this.bottom=this.top=null};k.remove=function(){
this.canvas.parentnode.removechild(this.canvas);for(var a in this)this[a]=bf(a);
return true}}var ce=navigator.useragent.match(/version\\x2f(.*?)\s/);
navigator.vendor=="apple computer, inc."&&(ce&&ce[1]<4||navigator.platform.slice(0,2)=="ip")?k.safari=function(){
var a=this.rect(-99,-99,this.width+99,this.height+99).attr({stroke:"none"});
h.settimeout(function(){a.remove()})}:k.safari=function(){};
var cf=function(){this.returnvalue=false},cg=function(){return this.originalevent.preventdefault()},ch=function(){this.cancelbubble=true},ci=function(){return this.originalevent.stoppropagation()},cj=(function(){{if(g.addeventlistener)return function(a,b,c,d){var e=o&&u[b]?u[b]:b,g=function(e){if(o&&u[f](b))for(var g=0,h=e.targettouches&&e.targettouches.length;g<h;g++){
if(e.targettouches[g].target==a){var i=e;e=e.targettouches[g];e.originalevent=i;e.preventdefault=cg;e.stoppropagation=ci;break}}return c.call(d,e)};a.addeventlistener(e,g,false);return function(){a.removeeventlistener(e,g,false);return true}};if(g.attachevent)return function(a,b,c,d){var e=function(a){a=a||h.event;a.preventdefault=a.preventdefault||cf;a.stoppropagation=a.stoppropagation||ch;
return c.call(d,a)};a.attachevent("on"+b,e);var f=function(){a.detachevent("on"+b,e);return true};return f}}})(),ck=[],cl=function(a){var b=a.clientx,c=a.clienty,d=g.documentelement.scrolltop||g.body.scrolltop,e=g.documentelement.scrollleft||g.body.scrollleft,f,h=ck.length;while(h--){f=ck[h];if(o){var i=a.touches.length,j;while(i--){j=a.touches[i];
if(j.identifier==f.el._drag.id){b=j.clientx;c=j.clienty;(a.originalevent?a.originalevent:a).preventdefault();break}}}else a.preventdefault();b+=e;c+=d;f.move&&f.move.call(f.move_scope||f.el,b-f.el._drag.x,c-f.el._drag.y,b,c,a)}},cm=function(b){a.unmousemove(cl).unmouseup(cm);var c=ck.length,d;while(c--){d=ck[c];d.el._drag={};d.end&&d.end.call(d.end_scope||d.start_scope||d.move_scope||d.el,b)}ck=[]};
for(var cn=t[w];cn--;)(function(b){a[b]=bn[e][b]=function(c,d){if(a.is(c,"function")){this.events=this.events||[];this.events.push({name:b,f:c,unbind:cj(this.shape||this.node||g,b,c,d||this)})}return this};a["un"+b]=bn[e]["un"+b]=function(a){var c=this.events,d=c[w];while(d--)if(c[d].name==b&&c[d].f==a){c[d].unbind();c.splice(d,1);!c.length&&delete this.events;return this}return this}})(t[cn]);
bo.hover=function(a,b,c,d){return this.mouseover(a,c).mouseout(b,d||c)};bo.unhover=function(a,b){return this.unmouseover(a).unmouseout(b)};
bo.drag=function(b,c,d,e,f,h){this._drag={};this.mousedown(function(i){(i.originalevent||i).preventdefault();
var j=g.documentelement.scrolltop||g.body.scrolltop,k=g.documentelement.scrollleft||g.body.scrollleft;this._drag.x=i.clientx+k;this._drag.y=i.clienty+j;this._drag.id=i.identifier;
c&&c.call(f||e||this,i.clientx+k,i.clienty+j,i);!ck.length&&a.mousemove(cl).mouseup(cm);ck.push({el:this,move:b,end:d,move_scope:e,start_scope:f,end_scope:h})});return this};bo.undrag=function(b,c,d){var e=ck.length;while(e--)ck[e].el==this&&(ck[e].move==b&&ck[e].end==d)&&ck.splice(e++,1);!ck.length&&a.unmousemove(cl).unmouseup(cm)};k.circle=function(a,b,c){return bp(this,a||0,b||0,c||0)};
k.rect=function(a,b,c,d,e){return bq(this,a||0,b||0,c||0,d||0,e||0)};k.ellipse=function(a,b,c,d){return br(this,a||0,b||0,c||0,d||0)};k.path=function(b){b&&!a.is(b,f)&&!a.is(b[0],g)&&(b+=p);return bh(a.format[m](a,arguments),this)};k.image=function(a,b,c,d,e){return bs(this,a||"about:blank",b||0,c||0,d||0,e||0)};k.text=function(a,b,c){return bt(this,a||0,b||0,r(c))};k.set=function(a){arguments[w]>1&&(a=array[e].splice.call(arguments,0,arguments[w]));return new cc(a)};k.setsize=bu;k.top=k.bottom=null;k.raphael=a;function co(){return this.x+q+this.y}bo.resetscale=function(){
if(this.removed)return this;this._.sx=1;this._.sy=1;this.attrs.scale="1 1"};bo.scale=function(a,b,c,d){if(this.removed)return this;
if(a==null&&b==null)return{x:this._.sx,y:this._.sy,tostring:co};b=b||a;!(+b)&&(b=a);var e,f,g,h,i=this.attrs;if(a!=0){var j=this.getbbox(),k=j.x+j.width/2,l=j.y+j.height/2,m=b(a/this._.sx),o=b(b/this._.sy);c=+c||c==0?c:k;d=+d||d==0?d:l;var r=this._.sx>0,s=this._.sy>0,t=~(~(a/b(a))),u=~(~(b/b(b))),x=m*t,y=o*u,z=this.node.style,a=c+b(k-c)*x*(k>c==r?1:-1),c=d+b(l-d)*y*(l>d==s?1:-1),d=a*t>b*u?o:m;switch(this.type){case"rect":case"image":var e=i.width*m,f=i.height*o;this.attr({height:f,r:i.r*d,width:e,x:a-e/2,y:c-f/2});break;case"circle":case"ellipse":this.attr({rx:i.rx*m,ry:i.ry*o,r:i.r*d,cx:a,cy:c});break;case"text":this.attr({x:a,y:c});break;case"path":var g=bp(i.path),h=true,i=r?x:m,j=s?y:o;for(var k=0,l=g[w];k<l;k++){var m=g[k],n=v.call(m[0]);{if(n=="m"&&h)continue;h=false}if(n=="a"){m[g[k][w]-2]*=i;m[g[k][w]-1]*=j;m[1]*=m;m[2]*=o;m[5]=+(t+u?!(!(+m[5])):!(+m[5]))}else if(n=="h")for(var o=1,p=m[w];o<p;o++)m[o]*=i;else if(n=="v")for(o=1,p=m[w];o<p;o++)m[o]*=j;
else for(o=1,p=m[w];o<p;o++)m[o]*=o%2?i:j}var q=bn(g);e=a-q.x-q.width/2;
f=c-q.y-q.height/2;g[0][1]+=e;g[0][2]+=f;this.attr({path:g});break}if(this.type in{text:1,image:1}&&(t!=1||u!=1))if(this.transformations){this.transformations[2]="scale("[n](t,",",u,")");
this.node[r]("transform",this.transformations[v](q));e=t==-1?-i.x-(e||0):i.x;f=u==-1?-i.y-(f||0):i.y;this.attr({x:e,y:f});i.fx=t-1;i.fy=u-1}else{this.node.filtermatrix=u+".matrix(m11="[n](t,", m12=0, m21=0, m22=",u,", dx=0, dy=0, sizingmethod='auto expand', filtertype='bilinear')");z.filter=(this.node.filtermatrix||p)+(this.node.filteropacity||p)}else if(this.transformations){this.transformations[2]=p;this.node[r]("transform",this.transformations[v](q));i.fx=0;i.fy=0}else{this.node.filtermatrix=p;z.filter=(this.node.filtermatrix||p)+(this.node.filteropacity||p)}i.scale=[a,b,c,d][v](q);this._.sx=a;this._.sy=b}return this};bo.clone=function(){if(this.removed)return null;var a=this.attr();delete a.scale;delete a.translation;return this.paper[this.type]().attr(a)};var cp={},cq=function(b,c,d,e,f,g,h,i,j){var k=0,l=100,m=[b,c,d,e,f,g,h,i].join(),n=cp[m],o,p;!n&&(cp[m]=n={data:[]});n.timer&&cleartimeout(n.timer);n.timer=settimeout(function(){delete cp[m]},2000);
if(j!=null){var q=cq(b,c,d,e,f,g,h,i);l=~(~q)*10}for(var r=0;r<l+1;r++){if(n.data[j]>r)p=n.data[r*l];else{p=a.finddotsatsegment(b,c,d,e,f,g,h,i,r/l);
n.data[r]=p}r&&(k+=c(c(o.x-p.x,2)+c(o.y-p.y,2),0.5));if(j!=null&&k>=j)return p;o=p}if(j==null)return k},cr=function(b,c){return function(d,e,f){d=bw(d);var g,h,i,j,k="",l={},m,n=0;for(var o=0,p=d.length;o<p;o++){i=d[o];if(i[0]=="m"){g=+i[1];h=+i[2]}else{j=cq(g,h,i[1],i[2],i[3],i[4],i[5],i[6]);if(n+j>e){if(c&&!l.start){m=cq(g,h,i[1],i[2],i[3],i[4],i[5],i[6],e-n);k+=["c",m.start.x,m.start.y,m.m.x,m.m.y,m.x,m.y];if(f)return k;l.start=k;k=["m",m.x,m.y+"c",m.n.x,m.n.y,m.end.x,m.end.y,i[5],i[6]][v]();n+=j;g=+i[5];h=+i[6];continue}if(!b&&!c){m=cq(g,h,i[1],i[2],i[3],i[4],i[5],i[6],e-n);return{x:m.x,y:m.y,alpha:m.alpha}}}n+=j;g=+i[5];h=+i[6]}k+=i}l.end=k;m=b?n:c?l:a.finddotsatsegment(g,h,i[1],i[2],i[3],i[4],i[5],i[6],1);m.alpha&&(m={x:m.x,y:m.y,alpha:m.alpha});return m}},cs=cr(1),ct=cr(),cu=cr(0,1);bo.gettotallength=function(){if(this.type!="path")return;if(this.node.gettotallength)return this.node.gettotallength();return cs(this.attrs.path)};
bo.getpointatlength=function(a){if(this.type!="path")return;return ct(this.attrs.path,a)};
bo.getsubpath=function(a,b){if(this.type!="path")return;if(b(this.gettotallength()-b)<"1e-6")return cu(this.attrs.path,a).end;var c=cu(this.attrs.path,b,1);return a?cu(c,a).end:c};
a.easing_formulas={linear:function(a){return a},"<":function(a){return c(a,3)},">":function(a){return c(a-1,3)+1},"<>":function(a){a=a*2;if(a<1)return c(a,3)/2;a-=2;return(c(a,3)+2)/2},backin:function(a){var b=1.70158;return a*a*((b+1)*a-b)},backout:function(a){a=a-1;var b=1.70158;return a*a*((b+1)*a+b)+1},elastic:function(a){if(a==0||a==1)return a;var b=0.3,c=b/4;return c(2,-10*a)*y.sin((a-c)*(2*d)/b)+1},bounce:function(a){var b=7.5625,c=2.75,d;if(a<1/c)d=b*a*a;else if(a<2/c){a-=1.5/c;d=b*a*a+0.75}else if(a<2.5/c){a-=2.25/c;d=b*a*a+0.9375}else{a-=2.625/c;d=b*a*a+0.984375}return d}};var cv=[],cw=function(){var b=+(new date);for(var c=0;c<cv[w];c++){var d=cv[c];if(d.stop||d.el.removed)continue;var e=b-d.start,g=d.ms,h=d.easing,i=d.from,j=d.diff,k=d.to,l=d.t,m=d.el,n={},o;if(e<g){var r=h(e/g);for(var s in i)if(i[f](s)){switch(x[s]){case"along":o=r*g*j[s];k.back&&(o=k.len-o);var t=ct(k[s],o);m.translate(j.sx-j.x||0,j.sy-j.y||0);j.x=t.x;j.y=t.y;m.translate(t.x-j.sx,t.y-j.sy);
k.rot&&m.rotate(j.r+t.alpha,t.x,t.y);break;case e:o=+i[s]+r*g*j[s];break;case"colour":o="rgb("+[cy(q(i[s].r+r*g*j[s].r)),cy(q(i[s].g+r*g*j[s].g)),cy(q(i[s].b+r*g*j[s].b))][v](",")+")";break;case"path":o=[];for(var u=0,x=i[s][w];u<x;u++){o[u]=[i[s][u][0]];for(var y=1,z=i[s][u][w];y<z;y++)o[u][y]=+i[s][u][y]+r*g*j[s][u][y];o[u]=o[u][v](q)}o=o[v](q);break;case"csv":switch(s){case"translation":var a=r*g*j[s][0]-l.x,b=r*g*j[s][1]-l.y;l.x+=a;l.y+=b;o=a+q+b;break;case"rotation":o=+i[s][0]+r*g*j[s][0];i[s][1]&&(o+=","+i[s][1]+","+i[s][2]);break;case"scale":o=[+i[s][0]+r*g*j[s][0],+i[s][1]+r*g*j[s][1],2 in k[s]?k[s][2]:p,3 in k[s]?k[s][3]:p][v](q);break;case"clip-rect":o=[];u=4;while(u--)o[u]=+i[s][u]+r*g*j[s][u];break}break;default:var c=[].concat(i[s]);o=[];u=m.paper.customattributes[s].length;while(u--)o[u]=+c[u]+r*g*j[s][u];break}n[s]=o}m.attr(n);m._run&&m._run.call(m)}else{if(k.along){t=ct(k.along,k.len*!k.back);m.translate(j.sx-(j.x||0)+t.x-j.sx,j.sy-(j.y||0)+t.y-j.sy);
k.rot&&m.rotate(j.r+t.alpha,t.x,t.y)}(l.x||l.y)&&m.translate(-l.x,-l.y);k.scale&&(k.scale+=p);m.attr(k);cv.splice(c--,1)}}a.svg&&m&&m.paper&&m.paper.safari();
cv[w]&&settimeout(cw)},cx=function(b,c,d,e,f){var g=d-e;c.timeouts.push(settimeout(function(){a.is(f,"function")&&f.call(c);c.animate(b,g,b.easing)},e))},cy=function(a){return z(a(a,255),0)},cz=function(a,b){if(a==null)return{x:this._.tx,y:this._.ty,tostring:co};
this._.tx+=+a;this._.ty+=+b;switch(this.type){case"circle":case"ellipse":this.attr({cx:+a+this.attrs.cx,cy:+b+this.attrs.cy});break;case"rect":case"image":case"text":this.attr({x:+a+this.attrs.x,y:+b+this.attrs.y});break;case"path":var c=bp(this.attrs.path);c[0][1]+=+a;c[0][2]+=+b;this.attr({path:c});break}return this};bo.animatewith=function(a,b,c,d,e){
for(var f=0,g=cv.length;f<g;f++)cv[f].el.id==a.id&&(b.start=cv[f].start);return this.animate(b,c,d,e)};bo.animatealong=ca();bo.animatealongback=ca(1);function ca(b){return function(c,d,e,f){var g={back:b};a.is(e,"function")?f=e:g.rot=e;c&&c.constructor==bn&&(c=c.attrs.path);c&&(g.along=c);
return this.animate(g,d,f)}}function cb(a,b,c,d,e,f){var g=3*b,h=3*(d-b)-g,i=1-g-h,j=3*c,k=3*(e-c)-j,l=1-j-k;function m(a){return((i*a+h)*a+g)*a}function n(a,b){var c=o(a,b);return((l*c+k)*c+j)*c}function o(a,b){var c,d,e,f,j,k;for(e=a,k=0;k<8;k++){f=m(e)-a;if(b(f)<b)return e;j=(3*i*e+2*h)*e+g;if(b(j)<0.000001)break;e=e-f/j}c=0;d=1;e=a;
if(e<c)return c;if(e>d)return d;while(c<d){f=m(e);if(b(f-a)<b)return e;a>f?c=e:d=e;e=(d-c)/2+c}return e}return n(a,1/(200*f))}bo.onanimation=function(a){this._run=a||0;return this};bo.animate=function(c,d,e,g){var h=this;h.timeouts=h.timeouts||[];if(a.is(e,"function")||!e)g=e||null;if(h.removed){g&&g.call(h);return h}var i={},j={},k=false,l={};
for(var m in c)if(c[f](m)){if(x[f](m)||h.paper.customattributes[f](m)){k=true;i[m]=h.attr(m);i[m]==null&&(i[m]=w[m]);j[m]=c[m];switch(x[m]){case"along":var n=cs(c[m]),o=ct(c[m],n*!(!c.back)),p=h.getbbox();l[m]=n/d;l.tx=p.x;l.ty=p.y;l.sx=o.x;l.sy=o.y;j.rot=c.rot;j.back=c.back;j.len=n;c.rot&&(l.r=s(h.rotate())||0);break;case e:l[m]=(j[m]-i[m])/d;
break;case"colour":i[m]=a.getrgb(i[m]);var q=a.getrgb(j[m]);l[m]={r:(q.r-i[m].r)/d,g:(q.g-i[m].g)/d,b:(q.b-i[m].b)/d};break;case"path":var t=bw(i[m],j[m]);i[m]=t[0];var u=t[1];l[m]=[];for(var v=0,x=i[m][w];v<x;v++){l[m][v]=[0];for(var y=1,z=i[m][v][w];y<z;y++)l[m][v][y]=(u[v][y]-i[m][v][y])/d}break;case"csv":var a=r(c[m])[s](b),b=r(i[m])[s](b);
switch(m){case"translation":i[m]=[0,0];l[m]=[a[0]/d,a[1]/d];break;case"rotation":i[m]=b[1]==a[1]&&b[2]==a[2]?b:[0,a[1],a[2]];
l[m]=[(a[0]-i[m][0])/d,0,0];break;case"scale":c[m]=a;i[m]=r(i[m])[s](b);l[m]=[(a[0]-i[m][0])/d,(a[1]-i[m][1])/d,0,0];break;case"clip-rect":i[m]=r(i[m])[s](b);l[m]=[];v=4;while(v--)l[m][v]=(a[v]-i[m][v])/d;break}j[m]=a;break;default:a=[].concat(c[m]);b=[].concat(i[m]);l[m]=[];v=h.paper.customattributes[m][w];while(v--)l[m][v]=((a[v]||0)-(b[v]||0))/d;break}}}
if(k){var g=a.easing_formulas[e];
if(!g){g=r(e).match(p);if(g&&g[w]==5){var h=g;g=function(a){return cb(a,+h[1],+h[2],+h[3],+h[4],d)}}else g=function(a){return a}}cv.push({start:c.start||+(new date),ms:d,easing:g,from:i,diff:l,to:j,el:h,t:{x:0,y:0}});
a.is(g,"function")&&(h._ac=settimeout(function(){g.call(h)},d));cv[w]==1&&settimeout(cw)}else{var c=[],d;for(var f in c)if(c[f](f)&&z.test(f)){m={value:c[f]};f=="from"&&(f=0);f=="to"&&(f=100);m.key=t(f,10);c.push(m)}c.sort(be);c[0].key&&c.unshift({key:0,value:h.attrs});
for(v=0,x=c[w];v<x;v++)cx(c[v].value,h,d/100*c[v].key,d/100*(c[v-1]&&c[v-1].key||0),c[v-1]&&c[v-1].value.callback);d=c[c[w]-1].value.callback;
d&&h.timeouts.push(settimeout(function(){d.call(h)},d))}return this};
bo.stop=function(){for(var a=0;a<cv.length;a++)cv[a].el.id==this.id&&cv.splice(a--,1);
for(a=0,ii=this.timeouts&&this.timeouts.length;a<ii;a++)cleartimeout(this.timeouts[a]);
this.timeouts=[];cleartimeout(this._ac);delete this._ac;return this};
bo.translate=function(a,b){return this.attr({translation:a+" "+b})};
bo[h]=function(){return"raphaël’s object"};a.ae=cv;
var cc=function(a){this.items=[];this[w]=0;this.type="set";
if(a)for(var b=0,c=a[w];b<c;b++){if(a[b]&&(a[b].constructor==bn||a[b].constructor==cc)){this[this.items[w]]=this.items[this.items[w]]=a[b];this[w]++}}};cc[e][l]=function(){var a,b;for(var c=0,d=arguments[w];c<d;c++){a=arguments[c];if(a&&(a.constructor==bn||a.constructor==cc)){b=this.items[w];this[b]=this.items[b]=a;
this[w]++}}return this};cc[e].pop=function(){delete this[this[w]--];return this.items.pop()};for(var cd in bo)bo[f](cd)&&(cc[e][cd]=(function(a){return function(){for(var b=0,c=this.items[w];b<c;b++)this.items[b][a][m](this.items[b],arguments);return this}})(cd));cc[e].attr=function(b,c){if(b&&a.is(b,g)&&a.is(b[0],"object"))for(var d=0,e=b[w];d<e;d++)this.items[d].attr(b[d]);else for(var f=0,g=this.items[w];f<g;f++)this.items[f].attr(b,c);return this};cc[e].animate=function(b,c,d,e){(a.is(d,"function")||!d)&&(e=d||null);var f=this.items[w],g=f,h,i=this,j;e&&(j=function(){!(--f)&&e.call(i)});d=a.is(d,f)?d:j;h=this.items[--g].animate(b,c,d,j);
while(g--)this.items[g]&&!this.items[g].removed&&this.items[g].animatewith(h,b,c,d,j);return this};cc[e].insertafter=function(a){var b=this.items[w];while(b--)this.items[b].insertafter(a);return this};cc[e].getbbox=function(){var a=[],b=[],c=[],d=[];for(var e=this.items[w];e--;){var f=this.items[e].getbbox();
a[l](f.x);b[l](f.y);c[l](f.x+f.width);d[l](f.y+f.height)}a=a[m](0,a);b=a[m](0,b);return{x:a,y:b,width:z[m](0,c)-a,height:z[m](0,d)-b}};cc[e].clone=function(a){a=new cc;for(var b=0,c=this.items[w];b<c;b++)a[l](this.items[b].clone());return a};a.registerfont=function(a){if(!a.face)return a;this.fonts=this.fonts||{};var b={w:a.w,face:{},glyphs:{}},c=a.face["font-family"];for(var d in a.face)a.face[f](d)&&(b.face[d]=a.face[d]);this.fonts[c]?this.fonts[c][l](b):this.fonts[c]=[b];if(!a.svg){b.face["units-per-em"]=t(a.face["units-per-em"],10);for(var e in a.glyphs)if(a.glyphs[f](e)){var g=a.glyphs[e];b.glyphs[e]={w:g.w,k:{},d:g.d&&"m"+g.d[y](/[mlcxtrv]/g,function(a){return({l:"l",c:"c",x:"z",t:"m",r:"l",v:"c"})[a]||"m"})+"z"};if(g.k)for(var h in g.k)g[f](h)&&(b.glyphs[e].k[h]=g.k[h])}}return a};k.getfont=function(b,c,d,e){e=e||"normal";d=d||"normal";
c=+c||({normal:400,bold:700,lighter:300,bolder:800})[c]||400;if(!a.fonts)return;var g=a.fonts[b];if(!g){var h=new regexp("(^|\\s)"+b[y](/[^\w\d\s+!~.:_-]/g,p)+"(\\s|$)","i");for(var i in a.fonts)if(a.fonts[f](i)){if(h.test(i)){g=a.fonts[i];break}}}var j;if(g)for(var k=0,l=g[w];k<l;k++){j=g[k];if(j.face["font-weight"]==c&&(j.face["font-style"]==d||!j.face["font-style"])&&j.face["font-stretch"]==e)break}return j};
k.print=function(c,d,e,f,g,h,i){h=h||"middle";i=z(a(i||0,1),-1);var j=this.set(),k=r(e)[s](p),l=0,m=p,n;a.is(f,e)&&(f=this.getfont(f));if(f){n=(g||16)/f.face["units-per-em"];
var o=f.face.bbox.split(b),q=+o[0],t=+o[1]+(h=="baseline"?o[3]-o[1]+ +f.face.descent:(o[3]-o[1])/2);for(var u=0,v=k[w];u<v;u++){var x=u&&f.glyphs[k[u-1]]||{},y=f.glyphs[k[u]];l+=u?(x.w||f.w)+(x.k&&x.k[k[u]]||0)+f.w*i:0;y&&y.d&&j[l](this.path(y.d).attr({fill:"#000",stroke:"none",translation:[l,0]}))}j.scale(n,n,q,t).translate(c-q,d-t)}return j};a.format=function(b,c){var e=a.is(c,g)?[0][n](c):arguments;
b&&a.is(b,f)&&e[w]-1&&(b=b[y](d,function(a,b){return e[++b]==null?p:e[b]}));return b||p};
a.ninja=function(){i.was?h.raphael=i.is:delete raphael;return a};a.el=bo;a.st=cc[e];
i.was?h.raphael=a:raphael=a})();
exports = raphael;;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\lib\sound.js
*/
define("scripts/lib/sound.js", function(exports){
/**
* 简易声效控制
*/
/**
* 使用方法:
*
* var sound = require("scripts/lib/sound/main");
*
* var snd = sound.create("sounds/myfile");
* snd.play();
*/
var buzz = require("scripts/lib/buzz");
var supported = buzz.issupported();
var config = {
formats: [ "ogg", "mp3" ],
preload: true,
autoload: true,
loop: false
};
function classbuzz( src ){
this.sound = new buzz.sound( src, config );
}
classbuzz.prototype.play = function( s ){
s = this.sound;
s.setpercent( 0 );
s.setvolume( 100 );
s.play();
};
classbuzz.prototype.stop = function(){
this.sound.fadeout( 1e3, function(){
this.pause();
} );
};
exports.create = function( src ){
if( !supported )
return unsupported;
else
return new classbuzz( src );
}
function unsupported(){
// todo:
}
unsupported.play =
unsupported.stop = function(){
// todo:
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\lib\tween.js
*/
define("scripts/lib/tween.js", function(exports){
exports.exponential = function(){};
exports.exponential.co = function(index, offset, target, framesnum){
return (index == framesnum) ? offset + target : target * (-math.pow(2, -10 * index / framesnum) + 1) + offset; };
// exports.exponential.ci = function(index, offset, target, framesnum){
return (index == 0) ? offset : target * math.pow(2, 10 * (index / framesnum - 1)) + offset;
}
exports.bounce = function(){};
exports.bounce.co = function(index, offset, target, framesnum){
if((index /= framesnum) < (1 / 2.75))
return target * (7.5625 * index * index) + offset;
else if(index < (2 / 2.75))
return target * (7.5625 * (index -= (1.5 / 2.75)) * index + .75) + offset;
else if(index < (2.5 / 2.75))
return target * (7.5625 * (index -= (2.25 / 2.75)) * index + .9375) + offset;
else return target * (7.5625 * (index -= (2.625 / 2.75)) * index + .984375) + offset;
};
exports.quadratic = function(){};
exports.quadratic.ci = function(index, offset, target, framesnum){
return target * (index /= framesnum) * index + offset;
};
exports.quadratic.co = function(index, offset, target, framesnum){
return - target * (index /= framesnum) * (index - 2) + offset;
}
exports.quadratic.cio = function(index, offset, target, framesnum){
if((index /= framesnum / 2) < 1)
return target / 2 * index * index + offset; else return - target / 2 * ((-- index) * (index - 2) - 1) + offset; };
exports.circular = function(index, offset, target, framesnum){
if((index /= framesnum / 2) < 1) return - target / 2 * (math.sqrt(1 - index * index) - 1) + offset;
else return target / 2 * (math.sqrt(1 - (index -= 2) * index) + 1) + offset;
}
exports.linear = function(index, offset, target, framesnum){
return target * index / framesnum + offset;
};
exports.back = function(){};
exports.back.ci = function(index, offset, target, framesnum, s){
s = 1.70158;
return target * (index /= framesnum) * index * ((s + 1) * index - s) + offset;
};
exports.back.co = function(index, offset, target, framesnum, s){
s = 1.70158;
return target * ((index = index / framesnum - 1) * index * ((s + 1) * index + s) + 1) + offset;
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\lib\ucren.js
*/
define("scripts/lib/ucren.js", function(exports){
/**
* ucren-lite
* filename: boot.js
* author: dron
* version: 5.0.2.20120628
* date: 2009-03-15
* contact: ucren.com
*/
var ucren;
var blankarray = [];
var slice = blankarray.slice;
var join = blankarray.join;
//
// [基本数据类型扩展]
//
// string.prototype.trim
if( !string.prototype.trim )
string.prototype.trim = function(){
return this.replace( /^\s+|\s+$/, "" );
};
// string.prototype.format
string.prototype.format = function( conf ){
var rtn = this, blank = {};
ucren.each( conf, function( item, key ){
item = item.tostring().replace( /\$/g, "$$$$" );
rtn = rtn.replace( regexp( "@{" + key + "}", "g" ), item );
});
return rtn.tostring();
};
// string.prototype.htmlencode
string.prototype.htmlencode = function(){
var p = document.createelement( "p" );
return function(){
var text;
p.appendchild( document.createtextnode( this ));
text = p.innerhtml;
p.innerhtml = "";
return text;
};
}();
// string.prototype.bytelength
string.prototype.bytelength = function(){
return this.replace( /[^\x00-\xff]/g, " " ).length;
};
// string.prototype.subbyte
string.prototype.subbyte = function( len, tail ){
var s = this;
if( s.bytelength() <= len )
return s;
tail = tail || "";
len -= tail.bytelength();
return s = s.slice( 0, len ).replace( /( [^\x00-\xff] )/g, "$1 " )
.slice( 0, len )
.replace( /[^\x00-\xff]$/, "" )
.replace( /( [^\x00-\xff] ) /g, "$1" ) + tail;
}
// function.prototype.defer
function.prototype.defer = function( scope, timeout ){
var me = this;
var fn = function(){
me.apply( scope, arguments );
};
return settimeout( fn, timeout );
};
// function.prototype.bind
if( !function.prototype.bind )
function.prototype.bind = function( scope ){
var me = this;
return function(){
return me.apply( scope, arguments );
}
};
// function.prototype.saturate
function.prototype.saturate = function( scope/*, args */ ){
var fn = this, afters = slice.call( arguments, 1 );
return function(){
return fn.apply( scope, slice.call( arguments, 0 ).concat( afters ) );
}
};
// array.prototype.indexof
// if( !array.prototype.indexof )
array.prototype.indexof = function( item, i ){
var length = this.length;
if( !i )
i = 0;
if( i < 0 )
i = length + i;
for( ; i < length; i ++ )
if( this[i] === item )
return i;
return -1;
};
// array.prototype.every
// if( !array.prototype.every )
array.prototype.every = function( fn, context ) {
for ( var i = 0, len = this.length; i < len; i ++ )
if ( !fn.call( context, this[i], i, this ) )
return false;
return true;
};
// array.prototype.filter
// if( !array.prototype.filter )
array.prototype.filter = function( fn, context ) {
var result = [], val;
for ( var i = 0, len = this.length; i < len; i ++ )
if ( val = this[i], fn.call( context, val, i, this ) )
result.push( val );
return result;
};
// array.prototype.foreach
// if( !array.prototype.foreach )
array.prototype.foreach = function( fn, context ) {
for ( var i = 0, len = this.length; i < len; i ++ )
fn.call( context, this[i], i, this );
};
// array.prototype.map
// if( !array.prototype.map )
array.prototype.map = function( fn, context ) {
var result = [];
for ( var i = 0, len = this.length; i < len; i ++ )
result[i] = fn.call( context, this[i], i, this );
return result;
};
// array.prototype.some
// if( !array.prototype.some )
array.prototype.some = function( fn, context ) {
for ( var i = 0, len = this.length; i < len; i ++ )
if ( fn.call( context, this[i], i, this ) )
return true;
return false;
};
array.prototype.invoke = function( method /*, args */ ){
var args = slice.call( arguments, 1 );
this.foreach( function( item ){
if( item instanceof array )
item[0][method].apply( item[0], item.slice( 1 ) );
else
item[method].apply( item, args );
});
return this;
};
array.prototype.random = function(){
var arr = this.slice( 0 ), ret = [], i = arr.length;
while( i -- )
ret.push( arr.splice( ucren.randomnumber( i + 1 ), 1 )[0] );
return ret;
};
ucren = {
//
// [全局属性]
//
// ucren.isie
isie: /msie/i.test( navigator.useragent ),
// ucren.isie6
isie6: /msie 6/i.test( navigator.useragent ),
// ucren.isfirefox
isfirefox: /firefox/i.test( navigator.useragent ),
// ucren.issafari
issafari: /version\/[\d\.]+\s+safari/i.test( navigator.useragent ),
// ucren.isopera
isopera: /opera/i.test( navigator.useragent ),
// ucren.ischrome
ischrome: /chrome/i.test( navigator.useragent ), //todo ischrome = true, issafari = true
// ucren.isstrict
isstrict: document.compatmode == "css1compat",
// ucren.tempdom
tempdom: document.createelement( "p" ),
//
// [全局方法]
//
// ucren.apply
apply: function( form, to, except ){
if( !to )to = {};
if( except ){
ucren.each( form, function( item, key ){
if( key in except )
return ;
to[key] = item;
});
}else{
ucren.each( form, function( item, key ){
to[key] = item;
});
}
return to;
},
// ucren.appendstyle
appendstyle: function( text ){
var style;
if( arguments.length > 1 )
text = join.call( arguments, "" );
if( document.createstylesheet ){
style = document.createstylesheet();
style.csstext = text;
}else{
style = document.createelement( "style" );
style.type = "text/css";
//style.innerhtml = text; fix chrome bug
style.appendchild( document.createtextnode( text ));
document.getelementsbytagname( "head" )[0].appendchild( style );
}
},
// for copy : )
//
// var addevent = function( target, name, fn ){
// var call = function(){
// fn.apply( target, arguments );
// };
// if( window.attachevent )
// target.attachevent( "on" + name, call );
// else if( window.addeventlistener )
// target.addeventlistener( name, call, false );
// else
// target["on" + name] = call;
// return call;
// }
// ucren.addevent
addevent: function( target, name, fn ){
var call = function(){
fn.apply( target, arguments );
};
if( target.dom ){
target = target.dom;
}
if( window.attachevent ){
target.attachevent( "on" + name, call );
}else if( window.addeventlistener ){
target.addeventlistener( name, call, false );
}else{
target["on" + name] = call;
}
return call;
},
// ucren.delevent
delevent: function( target, name, fn ){
if( window.detachevent ){
target.detachevent( "on" + name, fn );
}else if( window.removeeventlistener ){
target.removeeventlistener( name, fn, false );
}else if( target["on" + name] == fn ){
target["on" + name] = null;
}
},
// ucren.class
class: function( initialize, methods, befores, afters ){
var fn, prototype, blank;
initialize = initialize || function(){};
methods = methods || {};
blank = {};
fn = function(){
this.instanceid = ucren.id();
initialize.apply( this, arguments );
};
prototype = fn.prototype;
ucren.registerclassevent.call( prototype );
ucren.each( methods, function( item, key ){
prototype[key] = function( method, name ){
if( typeof( method ) == "function" ){
return function(){
var args, rtn;
args = slice.call( arguments, 0 );
if( befores &&
befores.apply( this, [name].concat( args )) === false ){
return ;
}
this.fireevent( "before" + name, args );
rtn = method.apply( this, args );
if( afters )
afters.apply( this, [name].concat( args ));
this.fireevent( name, args );
return rtn;
};
}else{
return method;
}
}( item, key );
});
prototype.getoriginmethod = function( name ){
return methods[name];
};
return fn;
},
//private
registerclassevent: function(){
this.on = function( name, fn ){
var instanceid = this.instanceid;
ucren.dispatch( instanceid + name, fn.bind( this ));
};
this.onbefore = function( name, fn ){
var instanceid = this.instanceid;
ucren.dispatch( instanceid + "before" + name, fn.bind( this ));
};
this.un = function( name, fn ){
//todo
};
this.fireevent = function( name, args ){
var instanceid = this.instanceid;
ucren.dispatch( instanceid + name, args );
};
},
// ucren.createfuze
createfuze: function(){
var queue, fn, infire;
queue = [];
fn = function( process ){
if( infire ){
process();
}else{
queue.push( process );
}
};
fn.fire = function(){
while( queue.length ){
queue.shift()();
}
infire = true;
};
fn.extinguish = function(){
infire = false;
};
fn.wettish = function(){
if( queue.length ){
queue.shift()();
}
};
return fn;
},
// ucren.createif
// createif: function( expressionfunction ){
// return function( callback ){
// var expression = expressionfunction();
// var returnvalue = {
// else: function( callback ){
// callback = callback || nul;
// expression || callback();
// }
// };
// callback = callback || nul;
// expression && callback();
// return returnvalue;
// };
// },
// ucren.dispatch
dispatch: function(){
var map = {}, send, incept, ret;
send = function( processid, args, scope ){
var processitems;
if( processitems = map[ processid ] )
ucren.each( processitems, function( item ){
item.apply( scope, args );
});
};
incept = function( processid, fn ){
var m;
if( !( m = map[ processid ] ) )
map[processid] = [ fn ];
else
m.push( fn );
};
ret = function( arg1, arg2, arg3 ){
if( typeof( arg2 ) === "undefined" )
arg2 = [];
if( arg2 instanceof array )
send.apply( this, arguments );
else if( typeof( arg2 ) === "function" )
incept.apply( this, arguments );
};
ret.remove = function( processid, fn ){
var m, i;
if( ( m = map[ processid ] ) && ~( i = m.indexof( fn ) ) )
m.splice( i, 1 );
};
return ret;
}(),
// ucren.each ( not recommended )
each: function( unknown, fn ){
/// unknown 是 array 的,会慢慢退化,建议用 array.prototype.foreach 替代
/// unknown 为其它类似的,短期内将暂时支持
if( unknown instanceof array || ( typeof unknown == "object" &&
typeof unknown[0] != "undefined" && unknown.length )){
if( typeof unknown == "object" && ucren.issafari )
unknown = slice.call( unknown );
// for( var i = 0, l = unknown.length; i < l; i ++ ){
// if( fn( unknown[i], i ) === false ){
// break;
// }
// }
unknown.foreach( fn );
}else if( typeof( unknown ) == "object" ){
var blank = {};
for( var i in unknown ){
if( blank[i] ){
continue;
}
if( fn( unknown[i], i ) === false ){
break;
}
}
}else if( typeof( unknown ) == "number" ){
for( var i = 0; i < unknown; i ++ ){
if( fn( i, i ) === false ){
break;
}
}
}else if( typeof( unknown ) == "string" ){
for( var i = 0, l = unknown.length; i < l; i ++ ){
if( fn( unknown.charat( i ), i ) === false ){
break;
}
}
}
},
// ucren.element
element: function( el, returndom ){
var rtn, handleid;
if( el && el.isucrenelement ){
return returndom ? el.dom : el;
}
el = typeof( el ) == "string" ? document.getelementbyid( el ) : el;
if( !el )
return null;
if( returndom )
return el;
handleid = el.getattribute( "handleid" );
if( typeof handleid == "string" ){
return ucren.handle( handleid - 0 );
}else{
rtn = new ucren.basicelement( el );
handleid = ucren.handle( rtn );
el.setattribute( "handleid", handleid + "" );
return rtn;
}
},
// ucren.event
event: function( e ){
e = e || window.event;
if( !e ){
var c = arguments.callee.caller;
while( c ){
e = c.arguments[0];
if( e && typeof( e.altkey ) == "boolean" ){ // duck typing
break;
}
c = c.caller;
e = null;
}
}
return e;
},
// ucren.fixnumber
fixnumber: function( unknown, defaultvalue ){
return typeof( unknown ) == "number" ? unknown : defaultvalue;
},
// ucren.fixstring
fixstring: function( unknown, defaultvalue ){
return typeof( unknown ) == "string" ? unknown : defaultvalue;
},
// ucren.fixconfig
fixconfig: function( conf ){
var defaultconf;
defaultconf = {};
if( typeof conf == "undefined" ){
return defaultconf;
}else if( typeof conf == "function" ){
return new conf;
}else{
return conf;
}
},
// ucren.handle
handle: function( unknown ){
var fn, type, number;
fn = arguments.callee;
if( !fn.cache ){
fn.cache = {};
}
if( typeof( fn.number ) == "undefined" ){
fn.number = 0;
}
type = typeof( unknown );
if( type == "number" ){
return fn.cache[unknown.tostring()];
}else if( type == "object" || type == "function" ){
number = fn.number ++;
fn.cache[number.tostring()] = unknown;
return number;
}
},
// ucren.id
id: function(){
var id = arguments.callee;
id.number = ++ id.number || 0;
return "_" + id.number;
},
// ucren.loadimage
loadimage: function( urls, onloadcomplete ){
var length = urls.length;
var loaded = 0;
var check = function(){
if( loaded == length )
onloadcomplete && onloadcomplete();
};
ucren.each( urls, function( url ){
var img = document.createelement( "img" );
img.onload = img.onerror = function(){
this.onload = this.onerror = null;
loaded ++;
check();
};
ucren.tempdom.appendchild( img );
img.src = url;
});
},
// ucren.loadscript
loadscript: function( src, callback ){
ucren.request( src, function( text ){
eval( text );
callback && callback( text );
});
},
// ucren.makeelement
makeelement: function( tagname, attributes ){
var el = document.createelement( tagname );
var setstyle = function( unknown ){
if( typeof unknown == "string" )
el.style.csstext = unknown;
else
ucren.apply( unknown, el.style );
};
for ( var prop in attributes ) {
if ( prop === "class" )
el.classname = attributes[prop];
else if ( prop === "for" )
el.htmlfor = attributes[prop];
else if( prop === "style" )
setstyle( attributes[prop] );
else
el.setattribute( prop, attributes[prop] );
}
return el;
},
// ucren.nul
nul: function(){
return false;
},
// ucren.querystring
// querystring: function( name, sourcestring ){
// var source, pattern, result;
// source = sourcestring || location.href;
// pattern = new regexp( "( \\?|& )" + name + "=( [^&#]* )( #|&|$ )", "i" );
// result = source.match( pattern );
// return result ? result[2] : "";
// },
// ucren.randomnumber
randomnumber: function( num ){
return math.floor( math.random() * num );
},
// ucren.randomword
randomword: function(){
var cw = "0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
return function( length, sourcestring ){
var words, re = [];
words = sourcestring || cw;
ucren.each( length, function( index ){
re[index] = words.charat( this.randomnumber( words.length ));
}.bind( this ));
return re.join( "" );
}
}(),
// ucren.request
request: function( url, callback ){
request = ucren.request;
var xhr = request.xhr;
if( !request.xhr ){
if( window.xmlhttprequest ){
xhr = request.xhr = new xmlhttprequest();
}else{
xhr = request.xhr = new activexobject( "microsoft.xmlhttp" );
}
}
xhr.open( "get", url, true );
xhr.onreadystatechange = function(){
if( xhr.readystate == 4 && xhr.status == 200 ){
callback( xhr.responsetext );
}
};
xhr.send( null );
}
// // ucren.decodecolor
// decodecolor: function(){
// var r = /^\#?( \w{2})( \w{2})( \w{2})$/;
// var x = function( x ){
// return parseint( x, 16 );
// };
// return function( color ){
// r.test( color );
// return {
// red: x( regexp.$1 ),
// green: x( regexp.$2 ),
// blue: x( regexp.$3 )
// };
// }
// }(),
// // ucren.encodecolor
// encodecolor: function(){
// var x = function( x ){
// return x.tostring( 16 ).split( "." )[0];
// };
// x = x.improve( function( origin, x ){
// x = origin( x );
// return x.length == 1 ? "0" + x : x;
// });
// return function( data ){
// return ["#", x( data.red ), x( data.green ), x( data.blue )].join( "" );
// }
// }()
};
//
// [底层操作类]
//
// ucren.basicdrag
ucren.basicdrag = ucren.class(
/* constructor */ function( conf ){
conf = ucren.fixconfig( conf );
this.type = ucren.fixstring( conf.type, "normal" );
var istouch = this.istouch = "ontouchstart" in window;
this.touch_start = istouch ? "touchstart" : "mousedown",
this.touch_move = istouch ? "touchmove" : "mousemove",
this.touch_end = istouch ? "touchend" : "mouseup";
},
/* methods */ {
bind: function( el, handle ){
el = ucren.element( el );
handle = ucren.element( handle ) || el;
var evt = {};
evt[this.touch_start] = function( e ){
e = ucren.event( e );
this.startdrag();
e.cancelbubble = true;
e.stoppropagation && e.stoppropagation();
return e.returnvalue = false;
}.bind( this );
handle.addevents( evt );
this.target = el;
},
//private
getcoors: function( e ){
var coors = [];
if ( e.targettouches && e.targettouches.length ) { // iphone
var thistouch = e.targettouches[0];
coors[0] = thistouch.clientx;
coors[1] = thistouch.clienty;
}else{ // all others
coors[0] = e.clientx;
coors[1] = e.clienty;
}
return coors;
},
//private
startdrag: function(){
var target, draging, e;
target = this.target;
draging = target.draging = {};
this.isdraging = true;
draging.x = parseint( target.style( "left" ), 10 ) || 0;
draging.y = parseint( target.style( "top" ), 10 ) || 0;
e = ucren.event();
var coors = this.getcoors( e );
draging.mousex = coors[0];
draging.mousey = coors[1];
this.registerdocumentevent();
},
//private
enddrag: function(){
this.isdraging = false;
this.unregisterdocumentevent();
},
//private
registerdocumentevent: function(){
var target, draging;
target = this.target;
draging = target.draging;
draging.documentselectstart =
ucren.addevent( document, "selectstart", function( e ){
e = e || event;
e.stoppropagation && e.stoppropagation();
e.cancelbubble = true;
return e.returnvalue = false;
});
draging.documentmousemove =
ucren.addevent( document, this.touch_move, function( e ){
var ie, nie;
e = e || event;
ie = ucren.isie && e.button != 1;
nie = !ucren.isie && e.button != 0;
if( (ie || nie ) && !this.istouch )
this.enddrag();
var coors = this.getcoors( e );
draging.newmousex = coors[0];
draging.newmousey = coors[1];
e.stoppropagation && e.stoppropagation();
return e.returnvalue = false;
}.bind( this ));
draging.documentmouseup =
ucren.addevent( document, this.touch_end, function(){
this.enddrag();
}.bind( this ));
var lx, ly;
clearinterval( draging.timer );
draging.timer = setinterval( function(){
var x, y, dx, dy;
if( draging.newmousex != lx && draging.newmousey != ly ){
lx = draging.newmousex;
ly = draging.newmousey;
dx = draging.newmousex - draging.mousex;
dy = draging.newmousey - draging.mousey;
x = draging.x + dx;
y = draging.y + dy;
if( this.type == "calc" ){
this.returnvalue( dx, dy, draging.newmousex, draging.newmousey );
}else{
target.left( x ).top( y );
}
}
}.bind( this ), 10 );
},
//private
unregisterdocumentevent: function(){
var draging = this.target.draging;
ucren.delevent( document, this.touch_move, draging.documentmousemove );
ucren.delevent( document, this.touch_end, draging.documentmouseup );
ucren.delevent( document, "selectstart", draging.documentselectstart );
clearinterval( draging.timer );
},
//private
returnvalue: function( dx, dy, x, y ){
//todo something
}
}
);
// ucren.template
ucren.template = ucren.class(
/* constructor */ function(){
this.string = join.call( arguments, "" );
},
/* methods */ {
apply: function( conf ){
return this.string.format( conf );
}
}
);
// ucren.basicelement
ucren.basicelement = ucren.class(
/* constructor */ function( el ){
this.dom = el;
this.countmapping = {};
},
/* methods */ {
isucrenelement: true,
attr: function( name, value ){
if( typeof value == "string" ){
this.dom.setattribute( name, value );
}else{
return this.dom.getattribute( name );
}
return this;
},
style: function( /* unknown1, unknown2 */ ){
var getstyle = ucren.isie ?
function( name ){
return this.dom.currentstyle[name];
} :
function( name ){
var style;
style = document.defaultview.getcomputedstyle( this.dom, null );
return style.getpropertyvalue( name );
};
return function( unknown1, unknown2 ){
if( typeof unknown1 == "object" ){
ucren.each( unknown1, function( value, key ){
this[key] = value;
}.bind( this.dom.style ));
}else if( typeof unknown1 == "string" && typeof unknown2 == "undefined" ){
return getstyle.call( this, unknown1 );
}else if( typeof unknown1 == "string" && typeof unknown2 != "undefined" ){
this.dom.style[unknown1] = unknown2;
}
return this;
};
}(),
hasclass: function( name ){
var classname = " " + this.dom.classname + " ";
return classname.indexof( " " + name + " " ) > -1;
},
setclass: function( name ){
if( typeof( name ) == "string" )
this.dom.classname = name.trim();
return this;
},
addclass: function( name ){
var el, classname;
el = this.dom;
classname = " " + el.classname + " ";
if( classname.indexof( " " + name + " " ) == -1 ){
classname += name;
classname = classname.trim();
classname = classname.replace( / +/g, " " );
el.classname = classname;
}
return this;
},
delclass: function( name ){
var el, classname;
el = this.dom;
classname = " " + el.classname + " ";
if( classname.indexof( " " + name + " " ) > -1 ){
classname = classname.replace( " " + name + " ", " " );
classname = classname.trim();
classname = classname.replace( / +/g, " " );
el.classname = classname;
}
return this;
},
html: function( html ){
var el = this.dom;
if( typeof html == "string" ){
el.innerhtml = html;
}else if( html instanceof array ){
el.innerhtml = html.join( "" );
}else{
return el.innerhtml;
}
return this;
},
left: function( number ){
var el = this.dom;
if( typeof( number ) == "number" ){
el.style.left = number + "px";
this.fireevent( "infect", [{ left: number }] );
}else{
return this.getpos().x;
}
return this;
},
top: function( number ){
var el = this.dom;
if( typeof( number ) == "number" ){
el.style.top = number + "px";
this.fireevent( "infect", [{ top: number }] );
}else{
return this.getpos().y;
}
return this;
},
width: function( unknown ){
var el = this.dom;
if( typeof unknown == "number" ){
el.style.width = unknown + "px";
this.fireevent( "infect", [{ width: unknown }] );
}else if( typeof unknown == "string" ){
el.style.width = unknown;
this.fireevent( "infect", [{ width: unknown }] );
}else{
return this.getsize().width;
}
return this;
},
height: function( unknown ){
var el = this.dom;
if( typeof unknown == "number" ){
el.style.height = unknown + "px";
this.fireevent( "infect", [{ height: unknown }] );
}else if( typeof unknown == "string" ){
el.style.height = unknown;
this.fireevent( "infect", [{ height: unknown }] );
}else{
return this.getsize().height;
}
return this;
},
count: function( name ){
return this.countmapping[name] = ++ this.countmapping[name] || 1;
},
display: function( bool ){
var dom = this.dom;
if( typeof( bool ) == "boolean" ){
dom.style.display = bool ? "block" : "none";
this.fireevent( "infect", [{ display: bool }] );
}else{
return this.style( "display" ) != "none";
}
return this;
},
first: function(){
var c = this.dom.firstchild;
while( c && !c.tagname && c.nextsibling ){
c = c.nextsibling;
}
return c;
},
add: function( dom ){
var el;
el = ucren.element( dom );
this.dom.appendchild( el.dom );
return this;
},
remove: function( dom ){
var el;
if( dom ){
el = ucren.element( dom );
el.html( "" );
this.dom.removechild( el.dom );
}else{
el = ucren.element( this.dom.parentnode );
el.remove( this );
}
return this;
},
insert: function( dom ){
var tdom;
tdom = this.dom;
if( tdom.firstchild ){
tdom.insertbefore( dom, tdom.firstchild );
}else{
this.add( dom );
}
return this;
},
addevents: function( conf ){
var blank, el, rtn;
blank = {};
rtn = {};
el = this.dom;
ucren.each( conf, function( item, key ){
rtn[key] = ucren.addevent( el, key, item );
});
return rtn;
},
removeevents: function( conf ){
var blank, el;
blank = {};
el = this.dom;
ucren.each( conf, function( item, key ){
ucren.delevent( el, key, item );
});
return this;
},
getpos: function(){
var el, parentnode, pos, box, offset;
el = this.dom;
pos = {};
if( el.getboundingclientrect ){
box = el.getboundingclientrect();
offset = ucren.isie ? 2 : 0;
var doc = document;
var scrolltop = math.max( doc.documentelement.scrolltop,
doc.body.scrolltop );
var scrollleft = math.max( doc.documentelement.scrollleft,
doc.body.scrollleft );
return {
x: box.left + scrollleft - offset,
y: box.top + scrolltop - offset
};
}else{
pos = {
x: el.offsetleft,
y: el.offsettop
};
parentnode = el.offsetparent;
if( parentnode != el ){
while( parentnode ){
pos.x += parentnode.offsetleft;
pos.y += parentnode.offsettop;
parentnode = parentnode.offsetparent;
}
}
if( ucren.issafari && this.style( "position" ) == "absolute" ){ // safari doubles in some cases
pos.x -= document.body.offsetleft;
pos.y -= document.body.offsettop;
}
}
if( el.parentnode ){
parentnode = el.parentnode;
}else{
parentnode = null;
}
while( parentnode && parentnode.tagname.touppercase() != "body" &&
parentnode.tagname.touppercase() != "html" ){ // account for any scrolled ancestors
pos.x -= parentnode.scrollleft;
pos.y -= parentnode.scrolltop;
if( parentnode.parentnode ){
parentnode = parentnode.parentnode;
}else{
parentnode = null;
}
}
return pos;
},
getsize: function(){
var dom = this.dom;
var display = this.style( "display" );
if ( display && display !== "none" ) {
return { width: dom.offsetwidth, height: dom.offsetheight };
}
var style = dom.style;
var originalstyles = {
visibility: style.visibility,
position: style.position,
display: style.display
};
var newstyles = {
visibility: "hidden",
display: "block"
};
if ( originalstyles.position !== "fixed" )
newstyles.position = "absolute";
this.style( newstyles );
var dimensions = {
width: dom.offsetwidth,
height: dom.offsetheight
};
this.style( originalstyles );
return dimensions;
},
observe: function( el, fn ){
el = ucren.element( el );
el.on( "infect", fn.bind( this ));
return this;
},
usepngbackground: function( image ){
var dom;
dom = this.dom;
if( /\.png$/i.test( image ) && ucren.isie6 ){
dom.style.filter =
"progid:dximagetransform.microsoft.alphaimageloader( src='" +
image + "',sizingmethod='scale' );";
/// _background: none;
/// _filter: progid:dximagetransform.microsoft.alphaimageloader( src='images/pic.png',sizingmethod='scale' );
}else{
dom.style.backgroundimage = "url( " + image + " )";
}
return this;
},
setalpha: function(){
var reopacity = /alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/;
return function( value ){
var element = this.dom, es = element.style;
if( !ucren.isie ){
es.opacity = value / 100;
/* }else if( es.filter === "string" ){ */
}else{
if ( element.currentstyle && !element.currentstyle.haslayout )
es.zoom = 1;
if ( reopacity.test( es.filter )) {
value = value >= 99.99 ? "" : ( "alpha( opacity=" + value + " )" );
es.filter = es.filter.replace( reopacity, value );
} else {
es.filter += " alpha( opacity=" + value + " )";
}
}
return this;
};
}(),
fadein: function( callback ){
if( typeof this.fadingnumber == "undefined" )
this.fadingnumber = 0;
this.setalpha( this.fadingnumber );
var fading = function(){
this.setalpha( this.fadingnumber );
if( this.fadingnumber == 100 ){
clearinterval( this.fadinginterval );
callback && callback();
}else
this.fadingnumber += 10;
}.bind( this );
this.display( true );
clearinterval( this.fadinginterval );
this.fadinginterval = setinterval( fading, ucren.isie ? 20 : 30 );
return this;
},
fadeout: function( callback ){
if( typeof this.fadingnumber == "undefined" )
this.fadingnumber = 100;
this.setalpha( this.fadingnumber );
var fading = function(){
this.setalpha( this.fadingnumber );
if( this.fadingnumber == 0 ){
clearinterval( this.fadinginterval );
this.display( false );
callback && callback();
}else
this.fadingnumber -= 10;
}.bind( this );
clearinterval( this.fadinginterval );
this.fadinginterval = setinterval( fading, ucren.isie ? 20 : 30 );
return this;
},
usemouseaction: function( classname, actions ){
/**
* 调用示例: el.usemouseaction( "xbutton", "over,out,down,up" );
* 使用效果: el 会在 "xbutton xbutton-over","xbutton xbutton-out","xbutton xbutton-down","xbutton xbutton-up"
* 等四个 classname 中根据相应的鼠标事件来进行切换。
* 特别提示: usemouseaction 可使用不同参数多次调用。
*/
if( !this.mouseaction )
this.mouseaction = new ucren.mouseaction({ element: this });
this.mouseaction.use( classname, actions );
return this;
}
}
);
if( ucren.isie )
document.execcommand( "backgroundimagecache", false, true );
for( var i in ucren ){
exports[i] = ucren[i];
};
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\background.js
*/
define("scripts/object/background.js", function(exports){
var ucren = require("scripts/lib/ucren");
var layer = require("scripts/layer");
var timeline = require("scripts/timeline");
var image, time;
var random = ucren.randomnumber;
exports.set = function(){
image = layer.createimage( "default", "images/background.jpg", 0, 0, 640, 480 );
};
exports.wobble = function(){
time = timeline.setinterval( wobble, 50 );
};
exports.stop = function(){
time.stop();
image.attr({ x: 0, y: 0 });
};
function wobble(){
var x, y;
x = random( 12 ) - 6;
y = random( 12 ) - 6;
image.attr({ x: x, y: y });
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\console.js
*/
define("scripts/object/console.js", function(exports){
var layer = require("scripts/layer");
var x = 16, y = 0;
var texts = [];
exports.set = function(){
};
exports.clear = function(){
for(var i = 0, l = texts.length; i < l; i ++)
texts[i].remove();
texts.length = y = 0;
};
exports.log = function(text){
y += 20;
texts.push( layer.createtext( "default", text, x, y ) );
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\developing.js
*/
define("scripts/object/developing.js", function(exports){
var layer = require("scripts/layer");
var tween = require("scripts/lib/tween");
var timeline = require("scripts/timeline");
var message = require("scripts/message");
var exponential = tween.exponential.co;
/**
* "coming soon" 模块
*/
exports.anims = [];
exports.set = function(){
this.image = layer.createimage( "default", "images/developing.png", 103, 218, 429, 53 ).hide().scale( 1e-5, 1e-5 );
};
exports.show = function( start ){
timeline.createtask({
start: start, duration: 500, data: [ 1e-5, 1, "show" ],
object: this, ontimeupdate: this.onzooming, ontimestart: this.onzoomstart, ontimeend: this.onzoomend,
recycle: this.anims
});
this.hide( 2000 );
};
exports.hide = function( start ){
timeline.createtask({
start: start, duration: 500, data: [ 1, 1e-5, "hide" ],
object: this, ontimeupdate: this.onzooming, ontimestart: this.onzoomstart, ontimeend: this.onzoomend,
recycle: this.anims
});
};
// 显示/隐藏 相关
exports.onzoomstart = function(){
this.image.show();
};
exports.onzooming = function( time, sz, ez, z ){
this.image.scale( z = exponential( time, sz, ez - sz, 500 ), z );
};
exports.onzoomend = function( sz, ez, mode ){
if( mode === "hide" )
this.image.hide();
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\dojo.js
*/
define("scripts/object/dojo.js", function(exports){
var rotate = require("scripts/factory/rotate");
var tween = require("scripts/lib/tween");
exports = rotate.create("images/dojo.png", 41, 240, 175, 175, 1e-5, tween.exponential.co, 500);;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\flame.js
*/
define("scripts/object/flame.js", function(exports){
/**
* 火焰模块
* @author zswang, dron
*/
var layer = require("scripts/layer").getlayer( "fruit" );
var timeline = require("scripts/timeline");
var ucren = require("scripts/lib/ucren");
/*
raphael.path('m 27,122 q 9,42 27,21 45,42 27,122')
.attr({
stroke: 'none',
fill: '180-#d8d380-#eded7a-#d8d380'
});
*/
// 缩写
var math = math, cos = math.cos, sin = math.sin,
trunc = parseint,
random = math.random,
pi = math.pi;
var guid = 0;
/**
* 添加一个火苗
* @param{array} center 中心位置 单位像素
* @param{number} angle 运动方向 单位幅度
* @param{number} length 运动长度 单位像素
* @param{number} life 存活时间 单位毫秒
*/
function appendflame( center, angle, length, life, flames ){
return flames[guid] = {
id: guid ++,
birthday: new date,
center: center,
angle: angle,
length: length,
life: life,
path: layer.path().attr({ stroke: 'none', fill: trunc( angle * 180 / pi ) + '-#fafad9-#f0ef9c' })
};
}
var radius = 15;
function updateflame( flames, n ){
var item = flames[n];
if ( !item )
return;
var age, center, p1, p2, p3, p4;
age = 1 - (new date - item.birthday) / item.life;
if ( age <= 0 ){
item.path.remove();
delete flames[item.id];
return;
}
var ia, ic, il;
ia = item.angle;
ic = item.center;
il = item.length;
center = [ trunc(ic[0] + cos(ia) * il * (1 - age)), trunc(ic[1] + sin(ia) * il * (1 - age)) ];
p1 = [ trunc(center[0] - cos(ia) * radius * age), trunc(center[1] - sin(ia) * radius * age) ];
p2 = [ trunc(center[0] + cos(ia) * radius * age), trunc(center[1] + sin(ia) * radius * age) ];
p3 = [ trunc(center[0] - cos(ia + .5 * pi) * radius * .4 * age), trunc(center[1] - sin(ia + .5 * pi) * radius * .4 * age) ];
p4 = [ trunc(center[0] - cos(ia - .5 * pi) * radius * .4 * age), trunc(center[1] - sin(ia - .5 * pi) * radius * .4 * age) ];
item.path.attr({ path: 'm' + p1 + ' q' + [ p3, p2, p4, p1 ].join(' ') });
};
function removeflame( flames, n ){
var item = flames[n];
if( !item )
return;
item.path.remove();
delete flames[ n ];
};
exports.create = function( ox, oy, start ){
var timer1, timer2;
var object = {
pos: function( x, y ){
nx = x;
ny = y;
image.attr( "x", nx - 21 ).attr( "y", ny - 21 );
},
remove: function(){
[ timer1, timer2 ].invoke( "stop" );
image.remove();
for (var p in flames)
removeflame( flames, p );
}
};
var nx = ox, ny = oy;
var image = layer.image("images/smoke.png", nx - 21, ny - 21, 43, 43).hide();
var flames = {};
timer1 = timeline.settimeout(function(){
image.show();
timer2 = timeline.setinterval(function(){
if(random() < 0.9)
appendflame( [ nx, ny ], pi * 2 * random(), 60, 200 + 500 * random(), flames );
for (var p in flames)
updateflame( flames, p );
}, ucren.isie ? 20 : 40);
}, start || 0);
return object;
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\flash.js
*/
define("scripts/object/flash.js", function(exports){
/**
*
*/
var layer = require("scripts/layer");
var timeline = require("scripts/timeline").use( "flash" ).init( 10 );
var tween = require("scripts/lib/tween");
var sound = require("scripts/lib/sound");
var image, snd, xdiff = 0, ydiff = 0;
var anim = tween.quadratic.cio;
var anims = [];
var dur = 100;
exports.set = function(){
image = layer.createimage( "flash", "images/flash.png", 0, 0, 358, 20 ).hide();
snd = sound.create( "sound/splatter" );
};
exports.showat = function( x, y, an ){
image.rotate( an, true ).scale( 1e-5, 1e-5 ).attr({
x: x + xdiff,
y: y + ydiff
}).show();
anims.clear && anims.clear();
snd.play();
timeline.createtask({
start: 0, duration: dur, data: [ 1e-5, 1 ],
object: this, ontimeupdate: this.ontimeupdate,
recycle: anims
});
timeline.createtask({
start: dur, duration: dur, data: [ 1, 1e-5 ],
object: this, ontimeupdate: this.ontimeupdate,
recycle: anims
});
};
exports.ontimeupdate = function( time, a, b, z ){
image.scale( z = anim( time, a, b - a, dur ), z );
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\fps.js
*/
define("scripts/object/fps.js", function(exports){
// var layer = require("scripts/layer");
// var timeline =require("scripts/timeline");
// var text, fps = "fps: ";
// exports.set = function(){
// text = layer.createtext( "default", fps + "0", 4, 470 ).attr( "fill", "#ccc" );
// };
// exports.update = function(){
// text.attr( "text", fps + ( timeline.getfps() >> 0 ) );
// };;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\game-over.js
*/
define("scripts/object/game-over.js", function(exports){
var layer = require("scripts/layer");
var tween = require("scripts/lib/tween");
var timeline = require("scripts/timeline");
var message = require("scripts/message");
var state = require("scripts/state");
var exponential = tween.exponential.co;
/**
* "game-over"模块
*/
exports.anims = [];
exports.set = function(){
this.image = layer.createimage( "default", "images/game-over.png", 75, 198, 490, 85 ).hide().scale( 1e-5, 1e-5 );
};
exports.show = function( start ){
timeline.createtask({
start: start, duration: 500, data: [ 1e-5, 1, "show" ],
object: this, ontimeupdate: this.onzooming, ontimestart: this.onzoomstart, ontimeend: this.onzoomend,
recycle: this.anims
});
};
exports.hide = function( start ){
timeline.createtask({
start: start, duration: 500, data: [ 1, 1e-5, "hide" ],
object: this, ontimeupdate: this.onzooming, ontimestart: this.onzoomstart, ontimeend: this.onzoomend,
recycle: this.anims
});
};
// 显示/隐藏 相关
exports.onzoomstart = function( sz, ez, mode ){
if( mode == "show" )
this.image.show();
};
exports.onzooming = function( time, sz, ez, z ){
this.image.scale( z = exponential( time, sz, ez - sz, 500 ), z );
};
exports.onzoomend = function( sz, ez, mode ){
if( mode == "show" )
state( "click-enable" ).on();
else if( mode === "hide" )
this.image.hide();
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\home-desc.js
*/
define("scripts/object/home-desc.js", function(exports){
var displacement = require("scripts/factory/displacement");
var tween = require("scripts/lib/tween");
exports = displacement.create("images/home-desc.png", 161, 91, -161, 140, 7, 127, tween.exponential.co, 500);;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\home-mask.js
*/
define("scripts/object/home-mask.js", function(exports){
var displacement = require("scripts/factory/displacement");
var tween = require("scripts/lib/tween");
exports = displacement.create("images/home-mask.png", 640, 183, 0, -183, 0, 0, tween.exponential.co, 1e3);;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\knife.js
*/
define("scripts/object/knife.js", function(exports){
var timeline = require("scripts/timeline");
var layer = require("scripts/layer").getlayer( "knife" );
var ucren = require("scripts/lib/ucren");
/**
* 刀光模块
*/
var lastx = null, lasty = null;
var abs = math.abs;
var life = 200;
var stroke = 10;
var color = "#cbd3db";
var anims = [];
var switchstate = true;
var knifes = [];
function classknifepart( conf ){
this.sx = conf.sx;
this.sy = conf.sy;
this.ex = conf.ex;
this.ey = conf.ey;
knifes.push( this );
}
classknifepart.prototype.set = function(){
var sx, sy, ex, ey, dx, dy, ax, ay;
sx = this.sx;
sy = this.sy;
ex = this.ex;
ey = this.ey;
dx = sx - ex;
dy = sy - ey;
ax = abs(dx);
ay = abs(dy);
if(ax > ay)
sx += dx < 0 ? -1 : 1,
sy += dy < 0 ? -( 1 * ay / ax ) : 1 * ay / ax;
else
sx += dx < 0 ? -( 1 * ax / ay ) : 1 * ax / ay,
sy += dy < 0 ? -1 : 1;
this.line = layer.path( "m" + sx + "," + sy + "l" + ex + "," + ey ).attr({
"stroke": color,
"stroke-width": stroke + "px"
});
timeline.createtask({ start: 0, duration: life, object: this, ontimeupdate: this.update, ontimeend: this.end, recycle: anims });
return this;
};
classknifepart.prototype.update = function( time ){
this.line.attr( "stroke-width", stroke * (1 - time / life) + "px" );
};
classknifepart.prototype.end = function(){
this.line.remove();
var index;
if( index = knifes.indexof( this ) )
knifes.splice( index, 1 );
};
exports.newknife = function(){
lastx = lasty = null;
};
exports.through = function( x, y ){
if( !switchstate )
return ;
var ret = null;
if( lastx !== null && ( lastx != x || lasty != y ) )
new classknifepart({ sx: lastx, sy: lasty, ex: x, ey: y }).set(),
ret = [ lastx, lasty, x, y ];
lastx = x;
lasty = y;
return ret;
};
exports.pause = function(){
anims.clear();
this.switchoff();
};
exports.switchoff = function(){
switchstate = false;
};
exports.switchon = function(){
switchstate = true;
this.endall();
};
exports.endall = function(){
for(var i = knifes.length - 1; i >= 0; i --)
knifes[i].end();
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\light.js
*/
define("scripts/object/light.js", function(exports){
/**
* 炸弹爆炸时的光线
*/
var layer = require("scripts/layer");
var masklayer = layer.getlayer( "mask" );
layer = layer.getlayer( "light" );
var ucren = require("scripts/lib/ucren");
var timeline = require("scripts/timeline");
var message = require("scripts/message");
var random = ucren.randomnumber;
var pi = math.pi;
var sin = math.sin;
var cos = math.cos;
var lights = [];
var indexs = [];
var lightsnum = 10;
for(var i = 0; i < lightsnum; i ++)
indexs[i] = i;
exports.start = function( boom ){
var x = boom.originx, y = boom.originy, time = 0, idx = indexs.random();
var i = lightsnum, b = function(){
build( x, y, idx[ this ] );
};
while( i -- )
timeline.settimeout( b.bind( i ), time += 100 );
timeline.settimeout(function(){
this.overwhitelight();
}.bind( this ), time + 100);
};
exports.overwhitelight = function(){
message.postmessage( "overwhitelight.show" );
this.removelights();
var dur = 4e3;
var mask = masklayer.rect( 0, 0, 640, 480 ).attr({ fill: "#fff", stroke: "none" });
var control = {
ontimeupdate: function( time ){
mask.attr( "opacity", 1 - time / dur );
},
ontimeend: function(){
mask.remove();
message.postmessage( "game.over" );
}
};
timeline.createtask({
start: 0, duration: dur,
object: control, ontimeupdate: control.ontimeupdate, ontimeend: control.ontimeend
});
};
exports.removelights = function(){
for(var i = 0, l = lights.length; i < l; i ++)
lights[i].remove();
lights.length = 0;
};
function build( x, y, r ){
var a1, a2, x1, y1, x2, y2;
a1 = r * 36 + random( 10 );
a2 = a1 + 5;
a1 = pi * a1 / 180;
a2 = pi * a2 / 180;
x1 = x + 640 * cos( a1 );
y1 = y + 640 * sin( a1 );
x2 = x + 640 * cos( a2 );
y2 = y + 640 * sin( a2 );
var light = layer.path( [ "m", x, y, "l", x1, y1, "l", x2, y2, "z" ] ).attr({
stroke: "none",
fill: "#fff"
});
lights.push( light );
};
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\logo.js
*/
define("scripts/object/logo.js", function(exports){
var displacement = require("scripts/factory/displacement");
var tween = require("scripts/lib/tween");
exports = displacement.create("images/logo.png", 288, 135, 17, -182, 17, 1, tween.exponential.co, 1e3);;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\lose.js
*/
define("scripts/object/lose.js", function(exports){
var layer = require("scripts/layer");
var tween = require("scripts/lib/tween");
var timeline = require("scripts/timeline");
var ucren = require("scripts/lib/ucren");
var message = require("scripts/message");
var anim = tween.exponential.co;
var back = tween.back.co;
/**
*
*/
var o1, o2, o3, animlength = 500;
var conf1 = { src: "images/x.png", sx: 650, ex: 561, y: 5, w: 22, h: 19 };
var conf2 = { src: "images/xx.png", sx: 671, ex: 582, y: 5, w: 27, h: 26 };
var conf3 = { src: "images/xxx.png", sx: 697, ex: 608, y: 6, w: 31, h: 32 };
var number = 0;
exports.anims = [];
exports.set = function(){
o1 = layer.createimage( "default", conf1.src, conf1.sx, conf1.y, conf1.w, conf1.h ).hide();
o2 = layer.createimage( "default", conf2.src, conf2.sx, conf2.y, conf2.w, conf2.h ).hide();
o3 = layer.createimage( "default", conf3.src, conf3.sx, conf3.y, conf3.w, conf3.h ).hide();
};
exports.reset = function(){
number = 0;
[ [ o1, conf1 ], [ o2, conf2 ], [ o3, conf3 ] ].foreach(function( infx ){
infx[0].attr( "src", infx[1].src.replace( "xf.png", "x.png" ) );
})
};
exports.show = function( start ){
timeline.createtask({
start: start, duration: animlength, data: [
"show", conf1.sx, conf1.ex, conf2.sx, conf2.ex, conf3.sx, conf3.ex ],
object: this, ontimeupdate: this.ontimeupdate, ontimestart: this.ontimestart, ontimeend: this.ontimeend,
recycle: this.anims
});
};
exports.hide = function( start ){
timeline.createtask({
start: start, duration: animlength, data: [ "hide", conf1.ex, conf1.sx, conf2.ex, conf2.sx, conf3.ex, conf3.sx ],
object: this, ontimeupdate: this.ontimeupdate, ontimestart: this.ontimestart, ontimeend: this.ontimeend,
recycle: this.anims
});
};
exports.showloseat = function( x ){
var infx, inf = [
[ o1, conf1 ],
[ o2, conf2 ],
[ o3, conf3 ]
];
createposshow( x );
infx = inf[ ( ++ number ) - 1 ];
infx[0].attr( "src", infx[1].src.replace( "x.png", "xf.png" ) ).scale( 1e-5, 1e-5 );
this.scaleimage( infx[0] );
if( number == 3 )
message.postmessage( "game.over" );
};
exports.scaleimage = function( image ){
var dur = 500;
image.myonscaling = image.myonscaling || function( time, z ){
this.scale( z = back( time, 1e-5, 1 - 1e-5, dur ), z );
};
image.myonscaleend = image.myonscaleend || function(){
this.scale( 1, 1 );
};
timeline.createtask({
start: 0, duration: dur,
object: image, ontimeupdate: image.myonscaling, ontimeend: image.myonscaleend,
recycle: this.anims
});
};
// 显示/隐藏 相关
exports.ontimeupdate = function( time, mode, x1s, x1e, x2s, x2e, x3s, x3e ){
o1.attr( "x", anim( time, x1s, x1e - x1s, animlength ) );
o2.attr( "x", anim( time, x2s, x2e - x2s, animlength ) );
o3.attr( "x", anim( time, x3s, x3e - x3s, animlength ) );
};
exports.ontimestart = function( mode ){
if( mode == "show" )
[ o1, o2, o3 ].invoke( "show" );
};
exports.ontimeend = function( mode ){
if( mode == "hide" )
[ o1, o2, o3 ].invoke( "hide" ),
this.reset();
};
function createposshow( x ){
var image = layer.createimage( "default", "images/lose.png", x - 27, 406, 54, 50 ).scale( 1e-5, 1e-5 );
var duration = 500;
var control = {
show: function( start ){
timeline.createtask({
start: start, duration: duration, data: [ tween.back.co, 1e-5, 1 ],
object: this, ontimeupdate: this.onscaling, ontimeend: this.onshowend
// recycle: anims
});
},
hide: function( start ){
timeline.createtask({
start: start, duration: duration, data: [ tween.back.ci, 1, 1e-5 ],
object: this, ontimeupdate: this.onscaling, ontimeend: this.onhideend
// recycle: anims
});
},
onscaling: function( time, anim, a, b, z ){
image.scale( z = anim( time, a, b - a, duration ), z );
},
onshowend: function(){
this.hide( 1500 );
},
onhideend: function(){
image.remove();
}
};
control.show( 200 );
};
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\new-game.js
*/
define("scripts/object/new-game.js", function(exports){
var rotate = require("scripts/factory/rotate");
var tween = require("scripts/lib/tween");
exports = rotate.create("images/new-game.png", 244, 231, 195, 195, 1e-5, tween.exponential.co, 500);;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\new.js
*/
define("scripts/object/new.js", function(exports){
var layer = require("scripts/layer");
var tween = require("scripts/lib/tween");
var timeline = require("scripts/timeline");
var ucren = require("scripts/lib/ucren");
var image;
var cycletime = 300;
var sx = 129, sy = 328, ex = 170, ey = 221, sw = 0, sh = 0, ew = 70, eh = 42, dy = 8;
var showanim = tween.exponential.co;
var jumpanim = tween.quadratic.ci;
exports.anims = [];
exports.set = function(){
image = layer.createimage( "default", "images/new.png", sx, sy, sw, sh );
};
exports.unset = function(){
};
exports.show = function( start ){
timeline.createtask({
start: start, duration: 500,
data: [ sx, ex, sy, ey, sw, ew, sh, eh ],
object: this, ontimeupdate: this.onshowing, ontimestart: this.onshowstart, ontimeend: this.onshowend,
recycle: this.anims
});
};
exports.hide = function( start ){
this.anims.clear();
timeline.createtask({
start: start, duration: 500,
data: [ ex, sx, ey, sy, ew, sw, eh, sh ],
object: this, ontimeupdate: this.onshowing,
recycle: this.anims
});
};
exports.jump = function(){
this.anims.clear();
timeline.createtask({ start: 0, duration: -1, object: this, ontimeupdate: this.onjumping, recycle: this.anims });
};
// 显示相关
exports.onshowstart = function(){
};
exports.onshowing = function( time, sx, ex, sy, ey, sw, ew, sh, eh ){
image.attr({
x: showanim( time, sx, ex - sx, 500 ),
y: showanim( time, sy, ey - sy, 500 ),
width: showanim( time, sw, ew - sw, 500 ),
height: showanim( time, sh, eh - sh, 500 )
});
};
exports.onshowend = function(){
this.jump();
};
// 跳跃相关
exports.onjumping = function(time){
var t = parseint(time / cycletime);
time = time % cycletime;
if( t % 2 ) time = cycletime - time;
image.attr("y", jumpanim( time, ey, dy, cycletime ));
};;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\ninja.js
*/
define("scripts/object/ninja.js", function(exports){
var displacement = require("scripts/factory/displacement");
var tween = require("scripts/lib/tween");
exports = displacement.create("images/ninja.png", 244, 81, 315, -140, 315, 43, {
show: tween.bounce.co,
hide: tween.exponential.co
}, 1e3);;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\quit.js
*/
define("scripts/object/quit.js", function(exports){
var rotate = require("scripts/factory/rotate");
var tween = require("scripts/lib/tween");
exports = rotate.create("images/quit.png", 493, 311, 141, 141, 1e-5, tween.exponential.co, 500);;
return exports;
});
/**
* @source d:\hosting\demos\fruit-ninja\output\scripts\object\score.js
*/
define("scripts/object/score.js", function(exports){
var layer = require("scripts/layer");
var tween = require("scripts/lib/tween");
var timeline = require("scripts/timeline");
var ucren = require("scripts/lib/ucren");
var settimeout = timeline.settimeout.bind( timeline );
var anim = tween.exponential.co;
var message = require("scripts/message");
/**
* 分数模块
*/
var image, text1, text2, animlength = 500;;
var imagesx = -94, imageex = 6;
var text1sx = -59, text1ex = 41;
var text2sx = -93, text2ex = 7;
exports.anims = [];
exports.set = function(){
image = layer.createimage( "default", "images/score.png", imagesx, 8, 29, 31 ).hide();
text1 = layer.createtext( "default", "0", text1sx, 24, "90-#fc7f0c-#ffec53", "30px" ).hide();
text2 = layer.createtext( "default", "best 999", text2sx, 48, "#af7c05", "14px" ).hide();
};
exports.show = function( start ){
timeline.createtask({
start: start, duration: animlength, data: [ "show", imagesx, imageex, text1sx, text1ex, text2sx, text2ex ],
object: this, ontimeupdate: this.ontimeupdate, ontimestart: this.ontimestart, ontimeend: this.ontimeend,
recycle: this.anims
});
};
exports.hide = function( start ){
timeline.createtask({
start: start, duration: animlength, data: [ "hide", imageex, imagesx, text1ex, text1sx, text2ex, text2sx ],
object: this, ontimeupdate: this.ontimeupdate, ontimestart: this.ontimestart, ontimeend: this.ontimeend,
recycle: this.anims
});
};
exports.number = function( number ){
text1.attr( "text", number || 0 );
image.scale( 1.2, 1.2 );
settimeout(function(){
image.scale( 1, 1 );
}, 60);
// message.postmessage( number, "score.change" );
};
// 显示/隐藏 相关
exports.ontimeupdate = function( time, mode, isx, iex, t1sx, t1ex, t2sx, t2ex ){
image.attr( "x", anim( time, isx, iex - isx, animlength ) );
text1.attr( "x", anim( time, t1sx, t1ex - t1sx, animlength ) );
text2.attr( "x", anim( time, t2sx, t2ex - t2sx, animlength ) );
};
exports.ontimestart = function( mode ){
if( mode === "show" )
[ image, text1, text2 ].invoke( "show" );
};
exports.ontimeend = function( mode ){
if( mode === "hide" )
[ image, text1, text2 ].invoke( "hide" ),
text1.attr( "text", 0 );
};;
return exports;
});
startmodule("scripts/main");
以上就是教你如何用html5和js实现切水果游戏的内容。