You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

18 lines
546 KiB

  1. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.PIXI=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){(function(process,global){(function(){var async={};function noop(){}function identity(v){return v}function toBool(v){return!!v}function notId(v){return!v}var previous_async;var root=typeof self==="object"&&self.self===self&&self||typeof global==="object"&&global.global===global&&global||this;if(root!=null){previous_async=root.async}async.noConflict=function(){root.async=previous_async;return async};function only_once(fn){return function(){if(fn===null)throw new Error("Callback was already called.");fn.apply(this,arguments);fn=null}}function _once(fn){return function(){if(fn===null)return;fn.apply(this,arguments);fn=null}}var _toString=Object.prototype.toString;var _isArray=Array.isArray||function(obj){return _toString.call(obj)==="[object Array]"};var _isObject=function(obj){var type=typeof obj;return type==="function"||type==="object"&&!!obj};function _isArrayLike(arr){return _isArray(arr)||typeof arr.length==="number"&&arr.length>=0&&arr.length%1===0}function _arrayEach(arr,iterator){var index=-1,length=arr.length;while(++index<length){iterator(arr[index],index,arr)}}function _map(arr,iterator){var index=-1,length=arr.length,result=Array(length);while(++index<length){result[index]=iterator(arr[index],index,arr)}return result}function _range(count){return _map(Array(count),function(v,i){return i})}function _reduce(arr,iterator,memo){_arrayEach(arr,function(x,i,a){memo=iterator(memo,x,i,a)});return memo}function _forEachOf(object,iterator){_arrayEach(_keys(object),function(key){iterator(object[key],key)})}function _indexOf(arr,item){for(var i=0;i<arr.length;i++){if(arr[i]===item)return i}return-1}var _keys=Object.keys||function(obj){var keys=[];for(var k in obj){if(obj.hasOwnProperty(k)){keys.push(k)}}return keys};function _keyIterator(coll){var i=-1;var len;var keys;if(_isArrayLike(coll)){len=coll.length;return function next(){i++;return i<len?i:null}}else{keys=_keys(coll);len=keys.length;return function next(){i++;return i<len?keys[i]:null}}}function _restParam(func,startIndex){startIndex=startIndex==null?func.length-1:+startIndex;return function(){var length=Math.max(arguments.length-startIndex,0);var rest=Array(length);for(var index=0;index<length;index++){rest[index]=arguments[index+startIndex]}switch(startIndex){case 0:return func.call(this,rest);case 1:return func.call(this,arguments[0],rest)}}}function _withoutIndex(iterator){return function(value,index,callback){return iterator(value,callback)}}var _setImmediate=typeof setImmediate==="function"&&setImmediate;var _delay=_setImmediate?function(fn){_setImmediate(fn)}:function(fn){setTimeout(fn,0)};if(typeof process==="object"&&typeof process.nextTick==="function"){async.nextTick=process.nextTick}else{async.nextTick=_delay}async.setImmediate=_setImmediate?_delay:async.nextTick;async.forEach=async.each=function(arr,iterator,callback){return async.eachOf(arr,_withoutIndex(iterator),callback)};async.forEachSeries=async.eachSeries=function(arr,iterator,callback){return async.eachOfSeries(arr,_withoutIndex(iterator),callback)};async.forEachLimit=async.eachLimit=function(arr,limit,iterator,callback){return _eachOfLimit(limit)(arr,_withoutIndex(iterator),callback)};async.forEachOf=async.eachOf=function(object,iterator,callback){callback=_once(callback||noop);object=object||[];var iter=_keyIterator(object);var key,completed=0;while((key=iter())!=null){completed+=1;iterator(object[key],key,only_once(done))}if(completed===0)callback(null);function done(err){completed--;if(err){callback(err)}else if(key===null&&completed<=0){callback(null)}}};async.forEachOfSeries=async.eachOfSeries=function(obj,iterator,callback){callback=_once(callback||noop);obj=obj||[];var nextKey=_keyIterator(obj);var key=nextKey();function iterate(){var sync=true;if(key===null){return callback(null)}iterator(obj[key],key,only_once(function(err){if(err){callback(err)}else{key=nextKey();if(key===null){return callback(null)}else{if(sync){async.setImmediate(iterate)}else{iterate()}}}}));sync=false}iterate()};async.forEachOfLimit=async.eachOfLimit=function(obj,limit,iterator,callback){_eachOfLimit(limit)(obj,iterator,callback)};function _eachOfLimit(limit){return function(obj,iterator,callback){callback=_once(callback||noop);obj=obj||[];var nextKey=_keyIterator(obj);if(limit<=0){return callback(null)}var done=false;var running=0;var errored=false;(function replenish(){if(done&&running<=0){return callback(null)}while(running<limit&&!errored){var key=nextKey();if(key===null){done=true;if(running<=0){callback(null)}return}running+=1;iterator(obj[key],key,only_once(function(err){running-=1;if(err){callback(err);errored=true}else{replenish()}}))}})()}}function doParallel(fn){return function(obj,iterator,callback){return fn(async.eachOf,obj,iterator,callback)}}function doParallelLimit(fn){return function(obj,limit,iterator,callback){return fn(_eachOfLimit(limit),obj,iterator,callback)}}function doSeries(fn){return function(obj,iterator,callback){return fn(async.eachOfSeries,obj,iterator,callback)}}function _asyncMap(eachfn,arr,iterator,callback){callback=_once(callback||noop);arr=arr||[];var results=_isArrayLike(arr)?[]:{};eachfn(arr,function(value,index,callback){iterator(value,function(err,v){results[index]=v;callback(err)})},function(err){callback(err,results)})}async.map=doParallel(_asyncMap);async.mapSeries=doSeries(_asyncMap);async.mapLimit=doParallelLimit(_asyncMap);async.inject=async.foldl=async.reduce=function(arr,memo,iterator,callback){async.eachOfSeries(arr,function(x,i,callback){iterator(memo,x,function(err,v){memo=v;callback(err)})},function(err){callback(err,memo)})};async.foldr=async.reduceRight=function(arr,memo,iterator,callback){var reversed=_map(arr,identity).reverse();async.reduce(reversed,memo,iterator,callback)};async.transform=function(arr,memo,iterator,callback){if(arguments.length===3){callback=iterator;iterator=memo;memo=_isArray(arr)?[]:{}}async.eachOf(arr,function(v,k,cb){iterator(memo,v,k,cb)},function(err){callback(err,memo)})};function _filter(eachfn,arr,iterator,callback){var results=[];eachfn(arr,function(x,index,callback){iterator(x,function(v){if(v){results.push({index:index,value:x})}callback()})},function(){callback(_map(results.sort(function(a,b){return a.index-b.index}),function(x){return x.value}))})}async.select=async.filter=doParallel(_filter);async.selectLimit=async.filterLimit=doParallelLimit(_filter);async.selectSeries=async.filterSeries=doSeries(_filter);function _reject(eachfn,arr,iterator,callback){_filter(eachfn,arr,function(value,cb){iterator(value,function(v){cb(!v)})},callback)}async.reject=doParallel(_reject);async.rejectLimit=doParallelLimit(_reject);async.rejectSeries=doSeries(_reject);function _createTester(eachfn,check,getResult){return function(arr,limit,iterator,cb){function done(){if(cb)cb(getResult(false,void 0))}function iteratee(x,_,callback){if(!cb)return callback();iterator(x,function(v){if(cb&&check(v)){cb(getResult(true,x));cb=iterator=false}callback()})}if(arguments.length>3){eachfn(arr,limit,iteratee,done)}else{cb=iterator;iterator=limit;eachfn(arr,iteratee,done)}}}async.any=async.some=_createTester(async.eachOf,toBool,identity);async.someLimit=_createTester(async.eachOfLimit,toBool,identity);async.all=async.every=_createTester(async.eachOf,notId,notId);async.everyLimit=_createTester(async.eachOfLimit,notId,notId);function _findGetResult(v,x){return x}async.detect=_createTester(async.eachOf,identity,_findGetResult);async.detectSeries=_createTester(async.eachOfSeries,identity,_findGetResult);async.detectLimit=_createTester(async.eachOfLimit,identity,_findGetResult);async.sortBy=function(arr,iterator,callback){async.map(arr,function(x,callback){iterator(x,function(err,criteria){if(err){callback(err)}else{callback(null,{value:x,criteria:criteria})}})},function(err,results){if(err){return callback(err)}else{callback(null,_map(results.sort(comparator),function(x){return x.value}))}});function comparator(left,right){var a=left.criteria,b=right.criteria;return a<b?-1:a>b?1:0}};async.auto=function(tasks,concurrency,callback){if(typeof arguments[1]==="function"){callback=concurrency;concurrency=null}callback=_once(callback||noop);var keys=_keys(tasks);var remainingTasks=keys.length;if(!remainingTasks){return callback(null)}if(!concurrency){concurrency=remainingTasks}var results={};var runningTasks=0;var hasError=false;var listeners=[];function addListener(fn){listeners.unshift(fn)}function removeListener(fn){var idx=_indexOf(listeners,fn);if(idx>=0)listeners.splice(idx,1)}function taskComplete(){remainingTasks--;_arrayEach(listeners.slice(0),function(fn){fn()})}addListener(function(){if(!remainingTasks){callback(null,results)}});_arrayEach(keys,function(k){if(hasError)return;var task=_isArray(tasks[k])?tasks[k]:[tasks[k]];var taskCallback=_restParam(function(err,args){runningTasks--;if(args.length<=1){args=args[0]}if(err){var safeResults={};_forEachOf(results,function(val,rkey){safeResults[rkey]=val});safeResults[k]=args;hasError=true;callback(err,safeResults)}else{results[k]=args;async.setImmediate(taskComplete)}});var requires=task.slice(0,task.length-1);var len=requires.length;var dep;while(len--){if(!(dep=tasks[requires[len]])){throw new Error("Has nonexistent dependency in "+requires.join(", "))}if(_isArray(dep)&&_indexOf(dep,k)>=0){throw new Error("Has cyclic dependencies")}}function ready(){return runningTasks<concurrency&&_reduce(requires,function(a,x){return a&&results.hasOwnProperty(x)},true)&&!results.hasOwnProperty(k)}if(ready()){runningTasks++;task[task.length-1](taskCallback,results)}else{addListener(listener)}function listener(){if(ready()){runningTasks++;removeListener(listener);task[task.length-1](taskCallback,results)}}})};async.retry=function(times,task,callback){var DEFAULT_TIMES=5;var DEFAULT_INTERVAL=0;var attempts=[];var opts={times:DEFAULT_TIMES,interval:DEFAULT_INTERVAL};function parseTimes(acc,t){if(typeof t==="number"){acc.times=parseInt(t,10)||DEFAULT_TIMES}else if(typeof t==="object"){acc.times=parseInt(t.times,10)||DEFAULT_TIMES;acc.interval=parseInt(t.interval,10)||DEFAULT_INTERVAL}else{throw new Error("Unsupported argument type for 'times': "+typeof t)}}var length=arguments.length;if(length<1||length>3){throw new Error("Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)")}else if(length<=2&&typeof times==="function"){callback=task;task=times}if(typeof times!=="function"){parseTimes(opts,times)}opts.callback=callback;opts.task=task;function wrappedTask(wrappedCallback,wrappedResults){function retryAttempt(task,finalAttempt){return function(seriesCallback){task(function(err,result){seriesCallback(!err||finalAttempt,{err:err,result:result})},wrappedResults)}}function retryInterval(interval){return function(seriesCallback){setTimeout(function(){seriesCallback(null)},interval)}}while(opts.times){var finalAttempt=!(opts.times-=1);attempts.push(retryAttempt(opts.task,finalAttempt));if(!finalAttempt&&opts.interval>0){attempts.push(retryInterval(opts.interval))}}async.series(attempts,function(done,data){data=data[data.length-1];(wrappedCallback||opts.callback)(data.err,data.result)})}return opts.callback?wrappedTask():wrappedTask};async.waterfall=function(tasks,callback){callback=_once(callback||noop);if(!_isArray(tasks)){var err=new Error("First argument to waterfall must be an array of functions");return callback(err)}if(!tasks.length){return callback()}function wrapIterator(iterator){return _restParam(function(err,args){if(err){callback.apply(null,[err].concat(args))}else{var next=iterator.next();if(next){args.push(wrapIterator(next))}else{args.push(callback)}ensureAsync(iterator).apply(null,args)}})}wrapIterator(async.iterator(tasks))()};function _parallel(eachfn,tasks,callback){callback=callback||noop;var results=_isArrayLike(tasks)?[]:{};eachfn(tasks,function(task,key,callback){task(_restParam(function(err,args){if(args.length<=1){args=args[0]}results[key]=args;callback(err)}))},function(err){callback(err,results)})}async.parallel=function(tasks,callback){_parallel(async.eachOf,tasks,callback)};async.parallelLimit=function(tasks,limit,callback){_parallel(_eachOfLimit(limit),tasks,callback)};async.series=function(tasks,callback){_parallel(async.eachOfSeries,tasks,callback)};async.iterator=function(tasks){function makeCallback(index){function fn(){if(tasks.length){tasks[index].apply(null,arguments)}return fn.next()}fn.next=function(){return index<tasks.length-1?makeCallback(index+1):null};return fn}return makeCallback(0)};async.apply=_restParam(function(fn,args){return _restParam(function(callArgs){return fn.apply(null,args.concat(callArgs))})});function _concat(eachfn,arr,fn,callback){var result=[];eachfn(arr,function(x,index,cb){fn(x,function(err,y){result=result.concat(y||[]);cb(err)})},function(err){callback(err,result)})}async.concat=doParallel(_concat);async.concatSeries=doSeries(_concat);async.whilst=function(test,iterator,callback){callback=callback||noop;if(test()){var next=_restParam(function(err,args){if(err){callback(err)}else if(test.apply(this,args)){iterator(next)}else{callback.apply(null,[null].concat(args))}});iterator(next)}else{callback(null)}};async.doWhilst=function(iterator,test,callback){var calls=0;return async.whilst(function(){return++calls<=1||test.apply(this,arguments)},iterator,callback)};async.until=function(test,iterator,callback){return async.whilst(function(){return!test.apply(this,arguments)},iterator,callback)};async.doUntil=function(iterator,test,callback){return async.doWhilst(iterator,function(){return!test.apply(this,arguments)},callback)};async.during=function(test,iterator,callback){callback=callback||noop;var next=_restParam(function(err,args){if(err){callback(err)}else{args.push(check);test.apply(this,args)}});var check=function(err,truth){if(err){callback(err)}else if(truth){iterator(next)}else{callback(null)}};test(check)};async.doDuring=function(iterator,test,callback){var calls=0;async.during(function(next){if(calls++<1){next(null,true)}else{test.apply(this,arguments)}},iterator,callback)};function _queue(worker,concurrency,payload){if(concurrency==null){concurrency=1}else if(concurrency===0){throw new Error("Concurrency must not be zero")}function _insert(q,data,pos,callback){if(callback!=null&&typeof callback!=="function"){throw new Error("task callback must be a function")}q.started=true;if(!_isArray(data)){data=[data]}if(data.length===0&&q.idle()){return async.setImmediate(function(){q.drain()})}_arrayEach(data,function(task){var item={data:task,callback:callback||noop};if(pos){q.tasks.unshift(item)}else{q.tasks.push(item)}if(q.tasks.length===q.concurrency){q.saturated()}});async.setImmediate(q.process)}function _next(q,tasks){return function(){workers-=1;var removed=false;var args=arguments;_arrayEach(tasks,function(task){_arrayEach(workersList,function(worker,index){if(worker===task&&!removed){workersList.splice(index,1);removed=true}});task.callback.apply(task,args)});if(q.tasks.length+workers===0){q.drain()}q.process()}}var workers=0;var workersList=[];var q={tasks:[],concurrency:concurrency,payload:payload,saturated:noop,empty:noop,drain:noop,started:false,paused:false,push:function(data,callback){_insert(q,data,false,callback)},kill:function(){q.drain=noop;q.tasks=[]},unshift:function(data,callback){_insert(q,data,true,callback)},process:function(){while(!q.paused&&workers<q.concurrency&&q.tasks.length){var tasks=q.payload?q.tasks.splice(0,q.payload):q.tasks.splice(0,q.tasks.length);var data=_map(tasks,function(task){return task.data});if(q.tasks.length===0){q.empty()}workers+=1;workersList.push(tasks[0]);var cb=only_once(_next(q,tasks));worker(data,cb)}},length:function(){return q.tasks.length},running:function(){return workers},workersList:function(){return workersList},idle:function(){return q.tasks.length+workers===0},pause:function(){q.paused=true},resume:function(){if(q.paused===false){return}q.paused=false;var resumeCount=Math.min(q.concurrency,q.tasks.length);for(var w=1;w<=resumeCount;w++){async.setImmediate(q.process)}}};return q}async.queue=function(worker,concurrency){var q=_queue(function(items,cb){worker(items[0],cb)},concurrency,1);return q};async.priorityQueue=function(worker,concurrency){function _compareTasks(a,b){return a.priority-b.priority}function _binarySearch(sequence,item,compare){var beg=-1,end=sequence.length-1;while(beg<end){var mid=beg+(end-beg+1>>>1);if(compare(item,sequence[mid])>=0){beg=mid}else{end=mid-1}}return beg}function _insert(q,data,priority,callback){if(callback!=null&&typeof callback!=="function"){throw new Error("task callback must be a function")}q.started=true;if(!_isArray(data)){data=[data]}if(data.length===0){return async.setImmediate(function(){q.drain()})}_arrayEach(data,function(task){var item={data:task,priority:priority,callback:typeof callback==="function"?callback:noop};q.tasks.splice(_binarySearch(q.tasks,item,_compareTasks)+1,0,item);if(q.tasks.length===q.concurrency){q.saturated()}async.setImmediate(q.process)})}var q=async.queue(worker,concurrency);q.push=function(data,priority,callback){_insert(q,data,priority,callback)};delete q.unshift;return q};async.cargo=function(worker,payload){return _queue(worker,1,payload)};function _console_fn(name){return _restParam(function(fn,args){fn.apply(null,args.concat([_restParam(function(err,args){if(typeof console==="object"){if(err){if(console.error){console.error(err)}}else if(console[name]){_arrayEach(args,function(x){console[name](x)})}}})]))})}async.log=_console_fn("log");async.dir=_console_fn("dir");async.memoize=function(fn,hasher){var memo={};var queues={};var has=Object.prototype.hasOwnProperty;hasher=hasher||identity;var memoized=_restParam(function memoized(args){var callback=args.pop();var key=hasher.apply(null,args);if(has.call(memo,key)){async.setImmediate(function(){callback.apply(null,memo[key])})}else if(has.call(queues,key)){queues[key].push(callback)}else{queues[key]=[callback];fn.apply(null,args.concat([_restParam(function(args){memo[key]=args;var q=queues[key];delete queues[key];for(var i=0,l=q.length;i<l;i++){q[i].apply(null,args)}})]))}});memoized.memo=memo;memoized.unmemoized=fn;return memoized};async.unmemoize=function(fn){return function(){return(fn.unmemoized||fn).apply(null,arguments)}};function _times(mapper){return function(count,iterator,callback){mapper(_range(count),iterator,callback)}}async.times=_times(async.map);async.timesSeries=_times(async.mapSeries);async.timesLimit=function(count,limit,iterator,callback){return async.mapLimit(_range(count),limit,iterator,callback)};async.seq=function(){var fns=arguments;return _restParam(function(args){var that=this;var callback=args[args.length-1];if(typeof callback=="function"){args.pop()}else{callback=noop}async.reduce(fns,args,function(newargs,fn,cb){fn.apply(that,newargs.concat([_restParam(function(err,nextargs){cb(err,nextargs)})]))},function(err,results){callback.apply(that,[err].concat(results))})})};async.compose=function(){return async.seq.apply(null,Array.prototype.reverse.call(arguments))};function _applyEach(eachfn){return _restParam(function(fns,args){var go=_restParam(function(args){var that=this;var callback=args.pop();return eachfn(fns,function(fn,_,cb){fn.apply(that,args.concat([cb]))},callback)});if(args.length){return go.apply(this,args)}else{return go}})}async.applyEach=_applyEach(async.eachOf);async.applyEachSeries=_applyEach(async.eachOfSeries);async.forever=function(fn,callback){var done=only_once(callback||noop);var task=ensureAsync(fn);function next(err){if(err){return done(err)}task(next)}next()};function ensureAsync(fn){return _restParam(function(args){var callback=args.pop();args.push(function(){var innerArgs=arguments;if(sync){async.setImmediate(function(){callback.apply(null,innerArgs)})}else{callback.apply(null,innerArgs)}});var sync=true;fn.apply(this,args);sync=false})}async.ensureAsync=ensureAsync;async.constant=_restParam(function(values){var args=[null].concat(values);return function(callback){return callback.apply(this,args)}});async.wrapSync=async.asyncify=function asyncify(func){return _restParam(function(args){var callback=args.pop();var result;try{result=func.apply(this,args)}catch(e){return callback(e)}if(_isObject(result)&&typeof result.then==="function"){result.then(function(value){callback(null,value)})["catch"](function(err){callback(err.message?err:new Error(err))})}else{callback(null,result)}})};if(typeof module==="object"&&module.exports){module.exports=async}else if(typeof define==="function"&&define.amd){define([],function(){return async})}else{root.async=async}})()}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{_process:3}],2:[function(require,module,exports){(function(process){function normalizeArray(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up--;up){parts.unshift("..")}}return parts}var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var splitPath=function(filename){return splitPathRe.exec(filename).slice(1)};exports.resolve=function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:process.cwd();if(typeof path!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){continue}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=path.charAt(0)==="/"}resolvedPath=normalizeArray(filter(resolvedPath.split("/"),function(p){return!!p}),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."};exports.normalize=function(path){var isAbsolute=exports.isAbsolute(path),trailingSlash=substr(path,-1)==="/";path=normalizeArray(filter(path.split("/"),function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path};exports.isAbsolute=function(path){return path.charAt(0)==="/"};exports.join=function(){var paths=Array.prototype.slice.call(arguments,0);return exports.normalize(filter(paths,function(p,index){if(typeof p!=="string"){throw new TypeError("Arguments to path.join must be strings")}return p}).join("/"))};exports.relative=function(from,to){from=exports.resolve(from).substr(1);to=exports.resolve(to).substr(1);function trim(arr){var start=0;for(;start<arr.length;start++){if(arr[start]!=="")break}var end=arr.length-1;for(;end>=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i<length;i++){if(fromParts[i]!==toParts[i]){samePartsLength=i;break}}var outputParts=[];for(var i=samePartsLength;i<fromParts.length;i++){outputParts.push("..")}outputParts=outputParts.concat(toParts.slice(samePartsLength));return outputParts.join("/")};exports.sep="/";exports.delimiter=":";exports.dirname=function(path){var result=splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir};exports.basename=function(path,ext){var f=splitPath(path)[2];if(ext&&f.substr(-1*ext.length)===ext){f=f.substr(0,f.length-ext.length)}return f};exports.extname=function(path){return splitPath(path)[3]};function filter(xs,f){if(xs.filter)return xs.filter(f);var res=[];for(var i=0;i<xs.length;i++){if(f(xs[i],i,xs))res.push(xs[i])}return res}var substr="ab".substr(-1)==="b"?function(str,start,len){return str.substr(start,len)}:function(str,start,len){if(start<0)start=str.length+start;return str.substr(start,len)}}).call(this,require("_process"))},{_process:3}],3:[function(require,module,exports){var process=module.exports={};var queue=[];var draining=false;var currentQueue;var queueIndex=-1;function cleanUpNextTick(){draining=false;if(currentQueue.length){queue=currentQueue.concat(queue)}else{queueIndex=-1}if(queue.length){drainQueue()}}function drainQueue(){if(draining){return}var timeout=setTimeout(cleanUpNextTick);draining=true;var len=queue.length;while(len){currentQueue=queue;queue=[];while(++queueIndex<len){if(currentQueue){currentQueue[queueIndex].run()}}queueIndex=-1;len=queue.length}currentQueue=null;draining=false;clearTimeout(timeout)}process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1){for(var i=1;i<arguments.length;i++){args[i-1]=arguments[i]}}queue.push(new Item(fun,args));if(queue.length===1&&!draining){setTimeout(drainQueue,0)}};function Item(fun,array){this.fun=fun;this.array=array}Item.prototype.run=function(){this.fun.apply(null,this.array)};process.title="browser";process.browser=true;process.env={};process.argv=[];process.version="";process.versions={};function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")};process.umask=function(){return 0}},{}],4:[function(require,module,exports){(function(global){(function(root){var freeExports=typeof exports=="object"&&exports&&!exports.nodeType&&exports;var freeModule=typeof module=="object"&&module&&!module.nodeType&&module;var freeGlobal=typeof global=="object"&&global;if(freeGlobal.global===freeGlobal||freeGlobal.window===freeGlobal||freeGlobal.self===freeGlobal){root=freeGlobal}var punycode,maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexPunycode=/^xn--/,regexNonASCII=/[^\x20-\x7E]/,regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode,key;function error(type){throw new RangeError(errors[type])}function map(array,fn){var length=array.length;var result=[];while(length--){result[length]=fn(array[length])}return result}function mapDomain(string,fn){var parts=string.split("@");var result="";if(parts.length>1){result=parts[0]+"@";string=parts[1]}string=string.replace(regexSeparators,".");var labels=string.split(".");var encoded=map(labels,fn).join(".");return result+encoded}function ucs2decode(string){var output=[],counter=0,length=string.length,value,extra;while(counter<length){value=string.charCodeAt(counter++);if(value>=55296&&value<=56319&&counter<length){extra=string.charCodeAt(counter++);if((extra&64512)==56320){output.push(((value&1023)<<10)+(extra&1023)+65536)}else{output.push(value);counter--}}else{output.push(value)}}return output}function ucs2encode(array){return map(array,function(value){var output="";if(value>65535){value-=65536;output+=stringFromCharCode(value>>>10&1023|55296);value=56320|value&1023}output+=stringFromCharCode(value);return output}).join("")}function basicToDigit(codePoint){if(codePoint-48<10){return codePoint-22}if(codePoint-65<26){return codePoint-65}if(codePoint-97<26){return codePoint-97}return base}function digitToBasic(digit,flag){return digit+22+75*(digit<26)-((flag!=0)<<5)}function adapt(delta,numPoints,firstTime){var k=0;delta=firstTime?floor(delta/damp):delta>>1;delta+=floor(delta/numPoints);for(;delta>baseMinusTMin*tMax>>1;k+=base){delta=floor(delta/baseMinusTMin)}return floor(k+(baseMinusTMin+1)*delta/(delta+skew))}function decode(input){var output=[],inputLength=input.length,out,i=0,n=initialN,bias=initialBias,basic,j,index,oldi,w,k,digit,t,baseMinusT;basic=input.lastIndexOf(delimiter);if(basic<0){basic=0}for(j=0;j<basic;++j){if(input.charCodeAt(j)>=128){error("not-basic")}output.push(input.charCodeAt(j))}for(index=basic>0?basic+1:0;index<inputLength;){for(oldi=i,w=1,k=base;;k+=base){if(index>=inputLength){error("invalid-input")}digit=basicToDigit(input.charCodeAt(index++));if(digit>=base||digit>floor((maxInt-i)/w)){error("overflow")}i+=digit*w;t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias;if(digit<t){break}baseMinusT=base-t;if(w>floor(maxInt/baseMinusT)){error("overflow")}w*=baseMinusT}out=output.length+1;bias=adapt(i-oldi,out,oldi==0);if(floor(i/out)>maxInt-n){error("overflow")}n+=floor(i/out);i%=out;output.splice(i++,0,n)}return ucs2encode(output)}function encode(input){var n,delta,handledCPCount,basicLength,bias,j,m,q,k,t,currentValue,output=[],inputLength,handledCPCountPlusOne,baseMinusT,qMinusT;input=ucs2decode(input);inputLength=input.length;n=initialN;delta=0;bias=initialBias;for(j=0;j<inputLength;++j){currentValue=input[j];if(currentValue<128){output.push(stringFromCharCode(currentValue))}}handledCPCount=basicLength=output.length;if(basicLength){output.push(delimiter)}while(handledCPCount<inputLength){for(m=maxInt,j=0;j<inputLength;++j){currentValue=input[j];if(currentValue>=n&&currentValue<m){m=currentValue}}handledCPCountPlusOne=handledCPCount+1;if(m-n>floor((maxInt-delta)/handledCPCountPlusOne)){error("overflow")}delta+=(m-n)*handledCPCountPlusOne;n=m;for(j=0;j<inputLength;++j){currentValue=input[j];if(currentValue<n&&++delta>maxInt){error("overflow")}if(currentValue==n){for(q=delta,k=base;;k+=base){t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias;if(q<t){break}qMinusT=q-t;baseMinusT=base-t;output.push(stringFromCharCode(digitToBasic(t+qMinusT%baseMinusT,0)));q=floor(qMinusT/baseMinusT)}output.push(stringFromCharCode(digitToBasic(q,0)));bias=adapt(delta,handledCPCountPlusOne,handledCPCount==basicLength);delta=0;++handledCPCount}}++delta;++n}return output.join("")}function toUnicode(input){return mapDomain(input,function(string){return regexPunycode.test(string)?decode(string.slice(4).toLowerCase()):string})}function toASCII(input){return mapDomain(input,function(string){return regexNonASCII.test(string)?"xn--"+encode(string):string})}punycode={version:"1.3.2",ucs2:{decode:ucs2decode,encode:ucs2encode},decode:decode,encode:encode,toASCII:toASCII,toUnicode:toUnicode};if(typeof define=="function"&&typeof define.amd=="object"&&define.amd){define("punycode",function(){return punycode})}else if(freeExports&&freeModule){if(module.exports==freeExports){freeModule.exports=punycode}else{for(key in punycode){punycode.hasOwnProperty(key)&&(freeExports[key]=punycode[key])}}}else{root.punycode=punycode}})(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],5:[function(require,module,exports){"use strict";function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}module.exports=function(qs,sep,eq,options){sep=sep||"&";eq=eq||"=";var obj={};if(typeof qs!=="string"||qs.length===0){return obj}var regexp=/\+/g;qs=qs.split(sep);var maxKeys=1e3;if(options&&typeof options.maxKeys==="number"){maxKeys=options.maxKeys}var len=qs.length;if(maxKeys>0&&len>maxKeys){len=maxKeys}for(var i=0;i<len;++i){var x=qs[i].replace(regexp,"%20"),idx=x.indexOf(eq),kstr,vstr,k,v;
  2. if(idx>=0){kstr=x.substr(0,idx);vstr=x.substr(idx+1)}else{kstr=x;vstr=""}k=decodeURIComponent(kstr);v=decodeURIComponent(vstr);if(!hasOwnProperty(obj,k)){obj[k]=v}else if(isArray(obj[k])){obj[k].push(v)}else{obj[k]=[obj[k],v]}}return obj};var isArray=Array.isArray||function(xs){return Object.prototype.toString.call(xs)==="[object Array]"}},{}],6:[function(require,module,exports){"use strict";var stringifyPrimitive=function(v){switch(typeof v){case"string":return v;case"boolean":return v?"true":"false";case"number":return isFinite(v)?v:"";default:return""}};module.exports=function(obj,sep,eq,name){sep=sep||"&";eq=eq||"=";if(obj===null){obj=undefined}if(typeof obj==="object"){return map(objectKeys(obj),function(k){var ks=encodeURIComponent(stringifyPrimitive(k))+eq;if(isArray(obj[k])){return map(obj[k],function(v){return ks+encodeURIComponent(stringifyPrimitive(v))}).join(sep)}else{return ks+encodeURIComponent(stringifyPrimitive(obj[k]))}}).join(sep)}if(!name)return"";return encodeURIComponent(stringifyPrimitive(name))+eq+encodeURIComponent(stringifyPrimitive(obj))};var isArray=Array.isArray||function(xs){return Object.prototype.toString.call(xs)==="[object Array]"};function map(xs,f){if(xs.map)return xs.map(f);var res=[];for(var i=0;i<xs.length;i++){res.push(f(xs[i],i))}return res}var objectKeys=Object.keys||function(obj){var res=[];for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))res.push(key)}return res}},{}],7:[function(require,module,exports){"use strict";exports.decode=exports.parse=require("./decode");exports.encode=exports.stringify=require("./encode")},{"./decode":5,"./encode":6}],8:[function(require,module,exports){var punycode=require("punycode");exports.parse=urlParse;exports.resolve=urlResolve;exports.resolveObject=urlResolveObject;exports.format=urlFormat;exports.Url=Url;function Url(){this.protocol=null;this.slashes=null;this.auth=null;this.host=null;this.port=null;this.hostname=null;this.hash=null;this.search=null;this.query=null;this.pathname=null;this.path=null;this.href=null}var protocolPattern=/^([a-z0-9.+-]+:)/i,portPattern=/:[0-9]*$/,delims=["<",">",'"',"`"," ","\r","\n"," "],unwise=["{","}","|","\\","^","`"].concat(delims),autoEscape=["'"].concat(unwise),nonHostChars=["%","/","?",";","#"].concat(autoEscape),hostEndingChars=["/","?","#"],hostnameMaxLen=255,hostnamePartPattern=/^[a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:true,"javascript:":true},hostlessProtocol={javascript:true,"javascript:":true},slashedProtocol={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true},querystring=require("querystring");function urlParse(url,parseQueryString,slashesDenoteHost){if(url&&isObject(url)&&url instanceof Url)return url;var u=new Url;u.parse(url,parseQueryString,slashesDenoteHost);return u}Url.prototype.parse=function(url,parseQueryString,slashesDenoteHost){if(!isString(url)){throw new TypeError("Parameter 'url' must be a string, not "+typeof url)}var rest=url;rest=rest.trim();var proto=protocolPattern.exec(rest);if(proto){proto=proto[0];var lowerProto=proto.toLowerCase();this.protocol=lowerProto;rest=rest.substr(proto.length)}if(slashesDenoteHost||proto||rest.match(/^\/\/[^@\/]+@[^@\/]+/)){var slashes=rest.substr(0,2)==="//";if(slashes&&!(proto&&hostlessProtocol[proto])){rest=rest.substr(2);this.slashes=true}}if(!hostlessProtocol[proto]&&(slashes||proto&&!slashedProtocol[proto])){var hostEnd=-1;for(var i=0;i<hostEndingChars.length;i++){var hec=rest.indexOf(hostEndingChars[i]);if(hec!==-1&&(hostEnd===-1||hec<hostEnd))hostEnd=hec}var auth,atSign;if(hostEnd===-1){atSign=rest.lastIndexOf("@")}else{atSign=rest.lastIndexOf("@",hostEnd)}if(atSign!==-1){auth=rest.slice(0,atSign);rest=rest.slice(atSign+1);this.auth=decodeURIComponent(auth)}hostEnd=-1;for(var i=0;i<nonHostChars.length;i++){var hec=rest.indexOf(nonHostChars[i]);if(hec!==-1&&(hostEnd===-1||hec<hostEnd))hostEnd=hec}if(hostEnd===-1)hostEnd=rest.length;this.host=rest.slice(0,hostEnd);rest=rest.slice(hostEnd);this.parseHost();this.hostname=this.hostname||"";var ipv6Hostname=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!ipv6Hostname){var hostparts=this.hostname.split(/\./);for(var i=0,l=hostparts.length;i<l;i++){var part=hostparts[i];if(!part)continue;if(!part.match(hostnamePartPattern)){var newpart="";for(var j=0,k=part.length;j<k;j++){if(part.charCodeAt(j)>127){newpart+="x"}else{newpart+=part[j]}}if(!newpart.match(hostnamePartPattern)){var validParts=hostparts.slice(0,i);var notHost=hostparts.slice(i+1);var bit=part.match(hostnamePartStart);if(bit){validParts.push(bit[1]);notHost.unshift(bit[2])}if(notHost.length){rest="/"+notHost.join(".")+rest}this.hostname=validParts.join(".");break}}}}if(this.hostname.length>hostnameMaxLen){this.hostname=""}else{this.hostname=this.hostname.toLowerCase()}if(!ipv6Hostname){var domainArray=this.hostname.split(".");var newOut=[];for(var i=0;i<domainArray.length;++i){var s=domainArray[i];newOut.push(s.match(/[^A-Za-z0-9_-]/)?"xn--"+punycode.encode(s):s)}this.hostname=newOut.join(".")}var p=this.port?":"+this.port:"";var h=this.hostname||"";this.host=h+p;this.href+=this.host;if(ipv6Hostname){this.hostname=this.hostname.substr(1,this.hostname.length-2);if(rest[0]!=="/"){rest="/"+rest}}}if(!unsafeProtocol[lowerProto]){for(var i=0,l=autoEscape.length;i<l;i++){var ae=autoEscape[i];var esc=encodeURIComponent(ae);if(esc===ae){esc=escape(ae)}rest=rest.split(ae).join(esc)}}var hash=rest.indexOf("#");if(hash!==-1){this.hash=rest.substr(hash);rest=rest.slice(0,hash)}var qm=rest.indexOf("?");if(qm!==-1){this.search=rest.substr(qm);this.query=rest.substr(qm+1);if(parseQueryString){this.query=querystring.parse(this.query)}rest=rest.slice(0,qm)}else if(parseQueryString){this.search="";this.query={}}if(rest)this.pathname=rest;if(slashedProtocol[lowerProto]&&this.hostname&&!this.pathname){this.pathname="/"}if(this.pathname||this.search){var p=this.pathname||"";var s=this.search||"";this.path=p+s}this.href=this.format();return this};function urlFormat(obj){if(isString(obj))obj=urlParse(obj);if(!(obj instanceof Url))return Url.prototype.format.call(obj);return obj.format()}Url.prototype.format=function(){var auth=this.auth||"";if(auth){auth=encodeURIComponent(auth);auth=auth.replace(/%3A/i,":");auth+="@"}var protocol=this.protocol||"",pathname=this.pathname||"",hash=this.hash||"",host=false,query="";if(this.host){host=auth+this.host}else if(this.hostname){host=auth+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]");if(this.port){host+=":"+this.port}}if(this.query&&isObject(this.query)&&Object.keys(this.query).length){query=querystring.stringify(this.query)}var search=this.search||query&&"?"+query||"";if(protocol&&protocol.substr(-1)!==":")protocol+=":";if(this.slashes||(!protocol||slashedProtocol[protocol])&&host!==false){host="//"+(host||"");if(pathname&&pathname.charAt(0)!=="/")pathname="/"+pathname}else if(!host){host=""}if(hash&&hash.charAt(0)!=="#")hash="#"+hash;if(search&&search.charAt(0)!=="?")search="?"+search;pathname=pathname.replace(/[?#]/g,function(match){return encodeURIComponent(match)});search=search.replace("#","%23");return protocol+host+pathname+search+hash};function urlResolve(source,relative){return urlParse(source,false,true).resolve(relative)}Url.prototype.resolve=function(relative){return this.resolveObject(urlParse(relative,false,true)).format()};function urlResolveObject(source,relative){if(!source)return relative;return urlParse(source,false,true).resolveObject(relative)}Url.prototype.resolveObject=function(relative){if(isString(relative)){var rel=new Url;rel.parse(relative,false,true);relative=rel}var result=new Url;Object.keys(this).forEach(function(k){result[k]=this[k]},this);result.hash=relative.hash;if(relative.href===""){result.href=result.format();return result}if(relative.slashes&&!relative.protocol){Object.keys(relative).forEach(function(k){if(k!=="protocol")result[k]=relative[k]});if(slashedProtocol[result.protocol]&&result.hostname&&!result.pathname){result.path=result.pathname="/"}result.href=result.format();return result}if(relative.protocol&&relative.protocol!==result.protocol){if(!slashedProtocol[relative.protocol]){Object.keys(relative).forEach(function(k){result[k]=relative[k]});result.href=result.format();return result}result.protocol=relative.protocol;if(!relative.host&&!hostlessProtocol[relative.protocol]){var relPath=(relative.pathname||"").split("/");while(relPath.length&&!(relative.host=relPath.shift()));if(!relative.host)relative.host="";if(!relative.hostname)relative.hostname="";if(relPath[0]!=="")relPath.unshift("");if(relPath.length<2)relPath.unshift("");result.pathname=relPath.join("/")}else{result.pathname=relative.pathname}result.search=relative.search;result.query=relative.query;result.host=relative.host||"";result.auth=relative.auth;result.hostname=relative.hostname||relative.host;result.port=relative.port;if(result.pathname||result.search){var p=result.pathname||"";var s=result.search||"";result.path=p+s}result.slashes=result.slashes||relative.slashes;result.href=result.format();return result}var isSourceAbs=result.pathname&&result.pathname.charAt(0)==="/",isRelAbs=relative.host||relative.pathname&&relative.pathname.charAt(0)==="/",mustEndAbs=isRelAbs||isSourceAbs||result.host&&relative.pathname,removeAllDots=mustEndAbs,srcPath=result.pathname&&result.pathname.split("/")||[],relPath=relative.pathname&&relative.pathname.split("/")||[],psychotic=result.protocol&&!slashedProtocol[result.protocol];if(psychotic){result.hostname="";result.port=null;if(result.host){if(srcPath[0]==="")srcPath[0]=result.host;else srcPath.unshift(result.host)}result.host="";if(relative.protocol){relative.hostname=null;relative.port=null;if(relative.host){if(relPath[0]==="")relPath[0]=relative.host;else relPath.unshift(relative.host)}relative.host=null}mustEndAbs=mustEndAbs&&(relPath[0]===""||srcPath[0]==="")}if(isRelAbs){result.host=relative.host||relative.host===""?relative.host:result.host;result.hostname=relative.hostname||relative.hostname===""?relative.hostname:result.hostname;result.search=relative.search;result.query=relative.query;srcPath=relPath}else if(relPath.length){if(!srcPath)srcPath=[];srcPath.pop();srcPath=srcPath.concat(relPath);result.search=relative.search;result.query=relative.query}else if(!isNullOrUndefined(relative.search)){if(psychotic){result.hostname=result.host=srcPath.shift();var authInHost=result.host&&result.host.indexOf("@")>0?result.host.split("@"):false;if(authInHost){result.auth=authInHost.shift();result.host=result.hostname=authInHost.shift()}}result.search=relative.search;result.query=relative.query;if(!isNull(result.pathname)||!isNull(result.search)){result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")}result.href=result.format();return result}if(!srcPath.length){result.pathname=null;if(result.search){result.path="/"+result.search}else{result.path=null}result.href=result.format();return result}var last=srcPath.slice(-1)[0];var hasTrailingSlash=(result.host||relative.host)&&(last==="."||last==="..")||last==="";var up=0;for(var i=srcPath.length;i>=0;i--){last=srcPath[i];if(last=="."){srcPath.splice(i,1)}else if(last===".."){srcPath.splice(i,1);up++}else if(up){srcPath.splice(i,1);up--}}if(!mustEndAbs&&!removeAllDots){for(;up--;up){srcPath.unshift("..")}}if(mustEndAbs&&srcPath[0]!==""&&(!srcPath[0]||srcPath[0].charAt(0)!=="/")){srcPath.unshift("")}if(hasTrailingSlash&&srcPath.join("/").substr(-1)!=="/"){srcPath.push("")}var isAbsolute=srcPath[0]===""||srcPath[0]&&srcPath[0].charAt(0)==="/";if(psychotic){result.hostname=result.host=isAbsolute?"":srcPath.length?srcPath.shift():"";var authInHost=result.host&&result.host.indexOf("@")>0?result.host.split("@"):false;if(authInHost){result.auth=authInHost.shift();result.host=result.hostname=authInHost.shift()}}mustEndAbs=mustEndAbs||result.host&&srcPath.length;if(mustEndAbs&&!isAbsolute){srcPath.unshift("")}if(!srcPath.length){result.pathname=null;result.path=null}else{result.pathname=srcPath.join("/")}if(!isNull(result.pathname)||!isNull(result.search)){result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")}result.auth=relative.auth||result.auth;result.slashes=result.slashes||relative.slashes;result.href=result.format();return result};Url.prototype.parseHost=function(){var host=this.host;var port=portPattern.exec(host);if(port){port=port[0];if(port!==":"){this.port=port.substr(1)}host=host.substr(0,host.length-port.length)}if(host)this.hostname=host};function isString(arg){return typeof arg==="string"}function isObject(arg){return typeof arg==="object"&&arg!==null}function isNull(arg){return arg===null}function isNullOrUndefined(arg){return arg==null}},{punycode:4,querystring:7}],9:[function(require,module,exports){"use strict";module.exports=earcut;function earcut(data,holeIndices,dim){dim=dim||2;var hasHoles=holeIndices&&holeIndices.length,outerLen=hasHoles?holeIndices[0]*dim:data.length,outerNode=linkedList(data,0,outerLen,dim,true),triangles=[];if(!outerNode)return triangles;var minX,minY,maxX,maxY,x,y,size;if(hasHoles)outerNode=eliminateHoles(data,holeIndices,outerNode,dim);if(data.length>80*dim){minX=maxX=data[0];minY=maxY=data[1];for(var i=dim;i<outerLen;i+=dim){x=data[i];y=data[i+1];if(x<minX)minX=x;if(y<minY)minY=y;if(x>maxX)maxX=x;if(y>maxY)maxY=y}size=Math.max(maxX-minX,maxY-minY)}earcutLinked(outerNode,triangles,dim,minX,minY,size);return triangles}function linkedList(data,start,end,dim,clockwise){var sum=0,i,j,last;for(i=start,j=end-dim;i<end;i+=dim){sum+=(data[j]-data[i])*(data[i+1]+data[j+1]);j=i}if(clockwise===sum>0){for(i=start;i<end;i+=dim)last=insertNode(i,data[i],data[i+1],last)}else{for(i=end-dim;i>=start;i-=dim)last=insertNode(i,data[i],data[i+1],last)}return last}function filterPoints(start,end){if(!start)return start;if(!end)end=start;var p=start,again;do{again=false;if(!p.steiner&&(equals(p,p.next)||area(p.prev,p,p.next)===0)){removeNode(p);p=end=p.prev;if(p===p.next)return null;again=true}else{p=p.next}}while(again||p!==end);return end}function earcutLinked(ear,triangles,dim,minX,minY,size,pass){if(!ear)return;if(!pass&&size)indexCurve(ear,minX,minY,size);var stop=ear,prev,next;while(ear.prev!==ear.next){prev=ear.prev;next=ear.next;if(size?isEarHashed(ear,minX,minY,size):isEar(ear)){triangles.push(prev.i/dim);triangles.push(ear.i/dim);triangles.push(next.i/dim);removeNode(ear);ear=next.next;stop=next.next;continue}ear=next;if(ear===stop){if(!pass){earcutLinked(filterPoints(ear),triangles,dim,minX,minY,size,1)}else if(pass===1){ear=cureLocalIntersections(ear,triangles,dim);earcutLinked(ear,triangles,dim,minX,minY,size,2)}else if(pass===2){splitEarcut(ear,triangles,dim,minX,minY,size)}break}}}function isEar(ear){var a=ear.prev,b=ear,c=ear.next;if(area(a,b,c)>=0)return false;var p=ear.next.next;while(p!==ear.prev){if(pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.next}return true}function isEarHashed(ear,minX,minY,size){var a=ear.prev,b=ear,c=ear.next;if(area(a,b,c)>=0)return false;var minTX=a.x<b.x?a.x<c.x?a.x:c.x:b.x<c.x?b.x:c.x,minTY=a.y<b.y?a.y<c.y?a.y:c.y:b.y<c.y?b.y:c.y,maxTX=a.x>b.x?a.x>c.x?a.x:c.x:b.x>c.x?b.x:c.x,maxTY=a.y>b.y?a.y>c.y?a.y:c.y:b.y>c.y?b.y:c.y;var minZ=zOrder(minTX,minTY,minX,minY,size),maxZ=zOrder(maxTX,maxTY,minX,minY,size);var p=ear.nextZ;while(p&&p.z<=maxZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.nextZ}p=ear.prevZ;while(p&&p.z>=minZ){if(p!==ear.prev&&p!==ear.next&&pointInTriangle(a.x,a.y,b.x,b.y,c.x,c.y,p.x,p.y)&&area(p.prev,p,p.next)>=0)return false;p=p.prevZ}return true}function cureLocalIntersections(start,triangles,dim){var p=start;do{var a=p.prev,b=p.next.next;if(intersects(a,p,p.next,b)&&locallyInside(a,b)&&locallyInside(b,a)){triangles.push(a.i/dim);triangles.push(p.i/dim);triangles.push(b.i/dim);removeNode(p);removeNode(p.next);p=start=b}p=p.next}while(p!==start);return p}function splitEarcut(start,triangles,dim,minX,minY,size){var a=start;do{var b=a.next.next;while(b!==a.prev){if(a.i!==b.i&&isValidDiagonal(a,b)){var c=splitPolygon(a,b);a=filterPoints(a,a.next);c=filterPoints(c,c.next);earcutLinked(a,triangles,dim,minX,minY,size);earcutLinked(c,triangles,dim,minX,minY,size);return}b=b.next}a=a.next}while(a!==start)}function eliminateHoles(data,holeIndices,outerNode,dim){var queue=[],i,len,start,end,list;for(i=0,len=holeIndices.length;i<len;i++){start=holeIndices[i]*dim;end=i<len-1?holeIndices[i+1]*dim:data.length;list=linkedList(data,start,end,dim,false);if(list===list.next)list.steiner=true;queue.push(getLeftmost(list))}queue.sort(compareX);for(i=0;i<queue.length;i++){eliminateHole(queue[i],outerNode);outerNode=filterPoints(outerNode,outerNode.next)}return outerNode}function compareX(a,b){return a.x-b.x}function eliminateHole(hole,outerNode){outerNode=findHoleBridge(hole,outerNode);if(outerNode){var b=splitPolygon(outerNode,hole);filterPoints(b,b.next)}}function findHoleBridge(hole,outerNode){var p=outerNode,hx=hole.x,hy=hole.y,qx=-Infinity,m;do{if(hy<=p.y&&hy>=p.next.y){var x=p.x+(hy-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(x<=hx&&x>qx){qx=x;m=p.x<p.next.x?p:p.next}}p=p.next}while(p!==outerNode);if(!m)return null;if(hole.x===m.x)return m.prev;var stop=m,tanMin=Infinity,tan;p=m.next;while(p!==stop){if(hx>=p.x&&p.x>=m.x&&pointInTriangle(hy<m.y?hx:qx,hy,m.x,m.y,hy<m.y?qx:hx,hy,p.x,p.y)){tan=Math.abs(hy-p.y)/(hx-p.x);if((tan<tanMin||tan===tanMin&&p.x>m.x)&&locallyInside(p,hole)){m=p;tanMin=tan}}p=p.next}return m}function indexCurve(start,minX,minY,size){var p=start;do{if(p.z===null)p.z=zOrder(p.x,p.y,minX,minY,size);p.prevZ=p.prev;p.nextZ=p.next;p=p.next}while(p!==start);p.prevZ.nextZ=null;p.prevZ=null;sortLinked(p)}function sortLinked(list){var i,p,q,e,tail,numMerges,pSize,qSize,inSize=1;do{p=list;list=null;tail=null;numMerges=0;while(p){numMerges++;q=p;pSize=0;for(i=0;i<inSize;i++){pSize++;q=q.nextZ;if(!q)break}qSize=inSize;while(pSize>0||qSize>0&&q){if(pSize===0){e=q;q=q.nextZ;qSize--}else if(qSize===0||!q){e=p;p=p.nextZ;pSize--}else if(p.z<=q.z){e=p;p=p.nextZ;pSize--}else{e=q;q=q.nextZ;qSize--}if(tail)tail.nextZ=e;else list=e;e.prevZ=tail;tail=e}p=q}tail.nextZ=null;inSize*=2}while(numMerges>1);return list}function zOrder(x,y,minX,minY,size){x=32767*(x-minX)/size;y=32767*(y-minY)/size;x=(x|x<<8)&16711935;x=(x|x<<4)&252645135;x=(x|x<<2)&858993459;x=(x|x<<1)&1431655765;y=(y|y<<8)&16711935;y=(y|y<<4)&252645135;y=(y|y<<2)&858993459;y=(y|y<<1)&1431655765;return x|y<<1}function getLeftmost(start){var p=start,leftmost=start;do{if(p.x<leftmost.x)leftmost=p;p=p.next}while(p!==start);return leftmost}function pointInTriangle(ax,ay,bx,by,cx,cy,px,py){return(cx-px)*(ay-py)-(ax-px)*(cy-py)>=0&&(ax-px)*(by-py)-(bx-px)*(ay-py)>=0&&(bx-px)*(cy-py)-(cx-px)*(by-py)>=0}function isValidDiagonal(a,b){return equals(a,b)||a.next.i!==b.i&&a.prev.i!==b.i&&!intersectsPolygon(a,b)&&locallyInside(a,b)&&locallyInside(b,a)&&middleInside(a,b)}function area(p,q,r){return(q.y-p.y)*(r.x-q.x)-(q.x-p.x)*(r.y-q.y)}function equals(p1,p2){return p1.x===p2.x&&p1.y===p2.y}function intersects(p1,q1,p2,q2){return area(p1,q1,p2)>0!==area(p1,q1,q2)>0&&area(p2,q2,p1)>0!==area(p2,q2,q1)>0}function intersectsPolygon(a,b){var p=a;do{if(p.i!==a.i&&p.next.i!==a.i&&p.i!==b.i&&p.next.i!==b.i&&intersects(p,p.next,a,b))return true;p=p.next}while(p!==a);return false}function locallyInside(a,b){return area(a.prev,a,a.next)<0?area(a,b,a.next)>=0&&area(a,a.prev,b)>=0:area(a,b,a.prev)<0||area(a,a.next,b)<0}function middleInside(a,b){var p=a,inside=false,px=(a.x+b.x)/2,py=(a.y+b.y)/2;do{if(p.y>py!==p.next.y>py&&px<(p.next.x-p.x)*(py-p.y)/(p.next.y-p.y)+p.x)inside=!inside;p=p.next}while(p!==a);return inside}function splitPolygon(a,b){var a2=new Node(a.i,a.x,a.y),b2=new Node(b.i,b.x,b.y),an=a.next,bp=b.prev;a.next=b;b.prev=a;a2.next=an;an.prev=a2;b2.next=a2;a2.prev=b2;bp.next=b2;b2.prev=bp;return b2}function insertNode(i,x,y,last){var p=new Node(i,x,y);if(!last){p.prev=p;p.next=p}else{p.next=last.next;p.prev=last;last.next.prev=p;last.next=p}return p}function removeNode(p){p.next.prev=p.prev;p.prev.next=p.next;if(p.prevZ)p.prevZ.nextZ=p.nextZ;if(p.nextZ)p.nextZ.prevZ=p.prevZ}function Node(i,x,y){this.i=i;this.x=x;this.y=y;this.prev=null;this.next=null;this.z=null;this.prevZ=null;this.nextZ=null;this.steiner=false}},{}],10:[function(require,module,exports){"use strict";var prefix=typeof Object.create!=="function"?"~":false;function EE(fn,context,once){this.fn=fn;this.context=context;this.once=once||false}function EventEmitter(){}EventEmitter.prototype._events=undefined;EventEmitter.prototype.listeners=function listeners(event,exists){var evt=prefix?prefix+event:event,available=this._events&&this._events[evt];if(exists)return!!available;if(!available)return[];if(available.fn)return[available.fn];for(var i=0,l=available.length,ee=new Array(l);i<l;i++){ee[i]=available[i].fn}return ee};EventEmitter.prototype.emit=function emit(event,a1,a2,a3,a4,a5){var evt=prefix?prefix+event:event;if(!this._events||!this._events[evt])return false;var listeners=this._events[evt],len=arguments.length,args,i;if("function"===typeof listeners.fn){if(listeners.once)this.removeListener(event,listeners.fn,undefined,true);switch(len){case 1:return listeners.fn.call(listeners.context),true;case 2:return listeners.fn.call(listeners.context,a1),true;case 3:return listeners.fn.call(listeners.context,a1,a2),true;case 4:return listeners.fn.call(listeners.context,a1,a2,a3),true;case 5:return listeners.fn.call(listeners.context,a1,a2,a3,a4),true;case 6:return listeners.fn.call(listeners.context,a1,a2,a3,a4,a5),true}for(i=1,args=new Array(len-1);i<len;i++){args[i-1]=arguments[i]}listeners.fn.apply(listeners.context,args)}else{var length=listeners.length,j;for(i=0;i<length;i++){if(listeners[i].once)this.removeListener(event,listeners[i].fn,undefined,true);switch(len){case 1:listeners[i].fn.call(listeners[i].context);break;case 2:listeners[i].fn.call(listeners[i].context,a1);break;case 3:listeners[i].fn.call(listeners[i].context,a1,a2);break;default:if(!args)for(j=1,args=new Array(len-1);j<len;j++){args[j-1]=arguments[j]}listeners[i].fn.apply(listeners[i].context,args)}}}return true};EventEmitter.prototype.on=function on(event,fn,context){var listener=new EE(fn,context||this),evt=prefix?prefix+event:event;if(!this._events)this._events=prefix?{}:Object.create(null);if(!this._events[evt])this._events[evt]=listener;else{if(!this._events[evt].fn)this._events[evt].push(listener);else this._events[evt]=[this._events[evt],listener]}return this};EventEmitter.prototype.once=function once(event,fn,context){var listener=new EE(fn,context||this,true),evt=prefix?prefix+event:event;if(!this._events)this._events=prefix?{}:Object.create(null);if(!this._events[evt])this._events[evt]=listener;else{if(!this._events[evt].fn)this._events[evt].push(listener);else this._events[evt]=[this._events[evt],listener]}return this};EventEmitter.prototype.removeListener=function removeListener(event,fn,context,once){var evt=prefix?prefix+event:event;if(!this._events||!this._events[evt])return this;var listeners=this._events[evt],events=[];if(fn){if(listeners.fn){if(listeners.fn!==fn||once&&!listeners.once||context&&listeners.context!==context){events.push(listeners)}}else{for(var i=0,length=listeners.length;i<length;i++){if(listeners[i].fn!==fn||once&&!listeners[i].once||context&&listeners[i].context!==context){events.push(listeners[i])}}}}if(events.length){this._events[evt]=events.length===1?events[0]:events}else{delete this._events[evt]}return this};EventEmitter.prototype.removeAllListeners=function removeAllListeners(event){if(!this._events)return this;if(event)delete this._events[prefix?prefix+event:event];else this._events=prefix?{}:Object.create(null);return this};EventEmitter.prototype.off=EventEmitter.prototype.removeListener;EventEmitter.prototype.addListener=EventEmitter.prototype.on;EventEmitter.prototype.setMaxListeners=function setMaxListeners(){return this};EventEmitter.prefixed=prefix;if("undefined"!==typeof module){module.exports=EventEmitter}},{}],11:[function(require,module,exports){"use strict";var hasOwnProperty=Object.prototype.hasOwnProperty;var propIsEnumerable=Object.prototype.propertyIsEnumerable;function toObject(val){if(val===null||val===undefined){throw new TypeError("Object.assign cannot be called with null or undefined")}return Object(val)}module.exports=Object.assign||function(target,source){var from;var to=toObject(target);var symbols;for(var s=1;s<arguments.length;s++){from=Object(arguments[s]);for(var key in from){if(hasOwnProperty.call(from,key)){to[key]=from[key]}}if(Object.getOwnPropertySymbols){symbols=Object.getOwnPropertySymbols(from);for(var i=0;i<symbols.length;i++){if(propIsEnumerable.call(from,symbols[i])){to[symbols[i]]=from[symbols[i]]}}}}return to}},{}],12:[function(require,module,exports){(function(process){(function(){var async={};var root,previous_async;root=this;if(root!=null){previous_async=root.async}async.noConflict=function(){root.async=previous_async;return async};function only_once(fn){var called=false;return function(){if(called)throw new Error("Callback was already called.");called=true;fn.apply(root,arguments)}}var _toString=Object.prototype.toString;var _isArray=Array.isArray||function(obj){return _toString.call(obj)==="[object Array]"};var _each=function(arr,iterator){for(var i=0;i<arr.length;i+=1){iterator(arr[i],i,arr)}};var _map=function(arr,iterator){if(arr.map){return arr.map(iterator)}var results=[];_each(arr,function(x,i,a){results.push(iterator(x,i,a))});return results};var _reduce=function(arr,iterator,memo){if(arr.reduce){return arr.reduce(iterator,memo)}_each(arr,function(x,i,a){memo=iterator(memo,x,i,a)});return memo};var _keys=function(obj){if(Object.keys){return Object.keys(obj)}var keys=[];for(var k in obj){if(obj.hasOwnProperty(k)){keys.push(k)}}return keys};if(typeof process==="undefined"||!process.nextTick){if(typeof setImmediate==="function"){async.nextTick=function(fn){setImmediate(fn)};async.setImmediate=async.nextTick}else{async.nextTick=function(fn){setTimeout(fn,0)};async.setImmediate=async.nextTick}}else{async.nextTick=process.nextTick;if(typeof setImmediate!=="undefined"){async.setImmediate=function(fn){setImmediate(fn)}}else{async.setImmediate=async.nextTick}}async.each=function(arr,iterator,callback){callback=callback||function(){};if(!arr.length){return callback()}var completed=0;_each(arr,function(x){iterator(x,only_once(done))});function done(err){if(err){callback(err);callback=function(){}}else{completed+=1;if(completed>=arr.length){callback()}}}};async.forEach=async.each;async.eachSeries=function(arr,iterator,callback){callback=callback||function(){};if(!arr.length){return callback()}var completed=0;var iterate=function(){iterator(arr[completed],function(err){if(err){callback(err);callback=function(){}}else{completed+=1;if(completed>=arr.length){callback()}else{iterate()}}})};iterate()};async.forEachSeries=async.eachSeries;async.eachLimit=function(arr,limit,iterator,callback){var fn=_eachLimit(limit);fn.apply(null,[arr,iterator,callback])};async.forEachLimit=async.eachLimit;var _eachLimit=function(limit){return function(arr,iterator,callback){callback=callback||function(){};if(!arr.length||limit<=0){return callback()}var completed=0;var started=0;var running=0;(function replenish(){if(completed>=arr.length){return callback()}while(running<limit&&started<arr.length){started+=1;running+=1;iterator(arr[started-1],function(err){if(err){callback(err);callback=function(){}}else{completed+=1;running-=1;if(completed>=arr.length){callback()}else{replenish()}}})}})()}};var doParallel=function(fn){return function(){var args=Array.prototype.slice.call(arguments);return fn.apply(null,[async.each].concat(args))}};var doParallelLimit=function(limit,fn){return function(){var args=Array.prototype.slice.call(arguments);return fn.apply(null,[_eachLimit(limit)].concat(args))}};var doSeries=function(fn){return function(){var args=Array.prototype.slice.call(arguments);return fn.apply(null,[async.eachSeries].concat(args))}};var _asyncMap=function(eachfn,arr,iterator,callback){arr=_map(arr,function(x,i){return{index:i,value:x}});if(!callback){eachfn(arr,function(x,callback){iterator(x.value,function(err){callback(err)})})}else{var results=[];eachfn(arr,function(x,callback){iterator(x.value,function(err,v){results[x.index]=v;callback(err)})},function(err){callback(err,results)})}};async.map=doParallel(_asyncMap);async.mapSeries=doSeries(_asyncMap);async.mapLimit=function(arr,limit,iterator,callback){return _mapLimit(limit)(arr,iterator,callback)};var _mapLimit=function(limit){return doParallelLimit(limit,_asyncMap)};async.reduce=function(arr,memo,iterator,callback){async.eachSeries(arr,function(x,callback){iterator(memo,x,function(err,v){memo=v;callback(err)})},function(err){callback(err,memo)})};async.inject=async.reduce;async.foldl=async.reduce;async.reduceRight=function(arr,memo,iterator,callback){var reversed=_map(arr,function(x){return x}).reverse();async.reduce(reversed,memo,iterator,callback)};async.foldr=async.reduceRight;var _filter=function(eachfn,arr,iterator,callback){var results=[];arr=_map(arr,function(x,i){return{index:i,value:x}});eachfn(arr,function(x,callback){iterator(x.value,function(v){if(v){results.push(x)}callback()})},function(err){callback(_map(results.sort(function(a,b){return a.index-b.index}),function(x){return x.value}))})};async.filter=doParallel(_filter);async.filterSeries=doSeries(_filter);async.select=async.filter;async.selectSeries=async.filterSeries;var _reject=function(eachfn,arr,iterator,callback){var results=[];arr=_map(arr,function(x,i){return{index:i,value:x}});eachfn(arr,function(x,callback){iterator(x.value,function(v){if(!v){results.push(x)}callback()})},function(err){callback(_map(results.sort(function(a,b){return a.index-b.index}),function(x){return x.value}))})};async.reject=doParallel(_reject);async.rejectSeries=doSeries(_reject);var _detect=function(eachfn,arr,iterator,main_callback){eachfn(arr,function(x,callback){iterator(x,function(result){if(result){main_callback(x);main_callback=function(){}}else{callback()}})},function(err){main_callback()})};async.detect=doParallel(_detect);async.detectSeries=doSeries(_detect);async.some=function(arr,iterator,main_callback){async.each(arr,function(x,callback){iterator(x,function(v){if(v){main_callback(true);main_callback=function(){}}callback()})},function(err){main_callback(false)})};async.any=async.some;async.every=function(arr,iterator,main_callback){async.each(arr,function(x,callback){iterator(x,function(v){if(!v){main_callback(false);main_callback=function(){}}callback()})},function(err){main_callback(true)})};async.all=async.every;async.sortBy=function(arr,iterator,callback){async.map(arr,function(x,callback){iterator(x,function(err,criteria){if(err){callback(err)}else{callback(null,{value:x,criteria:criteria})}})},function(err,results){if(err){return callback(err)}else{var fn=function(left,right){var a=left.criteria,b=right.criteria;return a<b?-1:a>b?1:0};callback(null,_map(results.sort(fn),function(x){return x.value}))}})};async.auto=function(tasks,callback){callback=callback||function(){};var keys=_keys(tasks);var remainingTasks=keys.length;if(!remainingTasks){return callback()}var results={};var listeners=[];var addListener=function(fn){listeners.unshift(fn)};var removeListener=function(fn){for(var i=0;i<listeners.length;i+=1){if(listeners[i]===fn){listeners.splice(i,1);return}}};var taskComplete=function(){remainingTasks--;_each(listeners.slice(0),function(fn){fn()})};addListener(function(){if(!remainingTasks){var theCallback=callback;callback=function(){};theCallback(null,results)}});_each(keys,function(k){var task=_isArray(tasks[k])?tasks[k]:[tasks[k]];var taskCallback=function(err){var args=Array.prototype.slice.call(arguments,1);if(args.length<=1){
  3. args=args[0]}if(err){var safeResults={};_each(_keys(results),function(rkey){safeResults[rkey]=results[rkey]});safeResults[k]=args;callback(err,safeResults);callback=function(){}}else{results[k]=args;async.setImmediate(taskComplete)}};var requires=task.slice(0,Math.abs(task.length-1))||[];var ready=function(){return _reduce(requires,function(a,x){return a&&results.hasOwnProperty(x)},true)&&!results.hasOwnProperty(k)};if(ready()){task[task.length-1](taskCallback,results)}else{var listener=function(){if(ready()){removeListener(listener);task[task.length-1](taskCallback,results)}};addListener(listener)}})};async.retry=function(times,task,callback){var DEFAULT_TIMES=5;var attempts=[];if(typeof times==="function"){callback=task;task=times;times=DEFAULT_TIMES}times=parseInt(times,10)||DEFAULT_TIMES;var wrappedTask=function(wrappedCallback,wrappedResults){var retryAttempt=function(task,finalAttempt){return function(seriesCallback){task(function(err,result){seriesCallback(!err||finalAttempt,{err:err,result:result})},wrappedResults)}};while(times){attempts.push(retryAttempt(task,!(times-=1)))}async.series(attempts,function(done,data){data=data[data.length-1];(wrappedCallback||callback)(data.err,data.result)})};return callback?wrappedTask():wrappedTask};async.waterfall=function(tasks,callback){callback=callback||function(){};if(!_isArray(tasks)){var err=new Error("First argument to waterfall must be an array of functions");return callback(err)}if(!tasks.length){return callback()}var wrapIterator=function(iterator){return function(err){if(err){callback.apply(null,arguments);callback=function(){}}else{var args=Array.prototype.slice.call(arguments,1);var next=iterator.next();if(next){args.push(wrapIterator(next))}else{args.push(callback)}async.setImmediate(function(){iterator.apply(null,args)})}}};wrapIterator(async.iterator(tasks))()};var _parallel=function(eachfn,tasks,callback){callback=callback||function(){};if(_isArray(tasks)){eachfn.map(tasks,function(fn,callback){if(fn){fn(function(err){var args=Array.prototype.slice.call(arguments,1);if(args.length<=1){args=args[0]}callback.call(null,err,args)})}},callback)}else{var results={};eachfn.each(_keys(tasks),function(k,callback){tasks[k](function(err){var args=Array.prototype.slice.call(arguments,1);if(args.length<=1){args=args[0]}results[k]=args;callback(err)})},function(err){callback(err,results)})}};async.parallel=function(tasks,callback){_parallel({map:async.map,each:async.each},tasks,callback)};async.parallelLimit=function(tasks,limit,callback){_parallel({map:_mapLimit(limit),each:_eachLimit(limit)},tasks,callback)};async.series=function(tasks,callback){callback=callback||function(){};if(_isArray(tasks)){async.mapSeries(tasks,function(fn,callback){if(fn){fn(function(err){var args=Array.prototype.slice.call(arguments,1);if(args.length<=1){args=args[0]}callback.call(null,err,args)})}},callback)}else{var results={};async.eachSeries(_keys(tasks),function(k,callback){tasks[k](function(err){var args=Array.prototype.slice.call(arguments,1);if(args.length<=1){args=args[0]}results[k]=args;callback(err)})},function(err){callback(err,results)})}};async.iterator=function(tasks){var makeCallback=function(index){var fn=function(){if(tasks.length){tasks[index].apply(null,arguments)}return fn.next()};fn.next=function(){return index<tasks.length-1?makeCallback(index+1):null};return fn};return makeCallback(0)};async.apply=function(fn){var args=Array.prototype.slice.call(arguments,1);return function(){return fn.apply(null,args.concat(Array.prototype.slice.call(arguments)))}};var _concat=function(eachfn,arr,fn,callback){var r=[];eachfn(arr,function(x,cb){fn(x,function(err,y){r=r.concat(y||[]);cb(err)})},function(err){callback(err,r)})};async.concat=doParallel(_concat);async.concatSeries=doSeries(_concat);async.whilst=function(test,iterator,callback){if(test()){iterator(function(err){if(err){return callback(err)}async.whilst(test,iterator,callback)})}else{callback()}};async.doWhilst=function(iterator,test,callback){iterator(function(err){if(err){return callback(err)}var args=Array.prototype.slice.call(arguments,1);if(test.apply(null,args)){async.doWhilst(iterator,test,callback)}else{callback()}})};async.until=function(test,iterator,callback){if(!test()){iterator(function(err){if(err){return callback(err)}async.until(test,iterator,callback)})}else{callback()}};async.doUntil=function(iterator,test,callback){iterator(function(err){if(err){return callback(err)}var args=Array.prototype.slice.call(arguments,1);if(!test.apply(null,args)){async.doUntil(iterator,test,callback)}else{callback()}})};async.queue=function(worker,concurrency){if(concurrency===undefined){concurrency=1}function _insert(q,data,pos,callback){if(!q.started){q.started=true}if(!_isArray(data)){data=[data]}if(data.length==0){return async.setImmediate(function(){if(q.drain){q.drain()}})}_each(data,function(task){var item={data:task,callback:typeof callback==="function"?callback:null};if(pos){q.tasks.unshift(item)}else{q.tasks.push(item)}if(q.saturated&&q.tasks.length===q.concurrency){q.saturated()}async.setImmediate(q.process)})}var workers=0;var q={tasks:[],concurrency:concurrency,saturated:null,empty:null,drain:null,started:false,paused:false,push:function(data,callback){_insert(q,data,false,callback)},kill:function(){q.drain=null;q.tasks=[]},unshift:function(data,callback){_insert(q,data,true,callback)},process:function(){if(!q.paused&&workers<q.concurrency&&q.tasks.length){var task=q.tasks.shift();if(q.empty&&q.tasks.length===0){q.empty()}workers+=1;var next=function(){workers-=1;if(task.callback){task.callback.apply(task,arguments)}if(q.drain&&q.tasks.length+workers===0){q.drain()}q.process()};var cb=only_once(next);worker(task.data,cb)}},length:function(){return q.tasks.length},running:function(){return workers},idle:function(){return q.tasks.length+workers===0},pause:function(){if(q.paused===true){return}q.paused=true},resume:function(){if(q.paused===false){return}q.paused=false;for(var w=1;w<=q.concurrency;w++){async.setImmediate(q.process)}}};return q};async.priorityQueue=function(worker,concurrency){function _compareTasks(a,b){return a.priority-b.priority}function _binarySearch(sequence,item,compare){var beg=-1,end=sequence.length-1;while(beg<end){var mid=beg+(end-beg+1>>>1);if(compare(item,sequence[mid])>=0){beg=mid}else{end=mid-1}}return beg}function _insert(q,data,priority,callback){if(!q.started){q.started=true}if(!_isArray(data)){data=[data]}if(data.length==0){return async.setImmediate(function(){if(q.drain){q.drain()}})}_each(data,function(task){var item={data:task,priority:priority,callback:typeof callback==="function"?callback:null};q.tasks.splice(_binarySearch(q.tasks,item,_compareTasks)+1,0,item);if(q.saturated&&q.tasks.length===q.concurrency){q.saturated()}async.setImmediate(q.process)})}var q=async.queue(worker,concurrency);q.push=function(data,priority,callback){_insert(q,data,priority,callback)};delete q.unshift;return q};async.cargo=function(worker,payload){var working=false,tasks=[];var cargo={tasks:tasks,payload:payload,saturated:null,empty:null,drain:null,drained:true,push:function(data,callback){if(!_isArray(data)){data=[data]}_each(data,function(task){tasks.push({data:task,callback:typeof callback==="function"?callback:null});cargo.drained=false;if(cargo.saturated&&tasks.length===payload){cargo.saturated()}});async.setImmediate(cargo.process)},process:function process(){if(working)return;if(tasks.length===0){if(cargo.drain&&!cargo.drained)cargo.drain();cargo.drained=true;return}var ts=typeof payload==="number"?tasks.splice(0,payload):tasks.splice(0,tasks.length);var ds=_map(ts,function(task){return task.data});if(cargo.empty)cargo.empty();working=true;worker(ds,function(){working=false;var args=arguments;_each(ts,function(data){if(data.callback){data.callback.apply(null,args)}});process()})},length:function(){return tasks.length},running:function(){return working}};return cargo};var _console_fn=function(name){return function(fn){var args=Array.prototype.slice.call(arguments,1);fn.apply(null,args.concat([function(err){var args=Array.prototype.slice.call(arguments,1);if(typeof console!=="undefined"){if(err){if(console.error){console.error(err)}}else if(console[name]){_each(args,function(x){console[name](x)})}}}]))}};async.log=_console_fn("log");async.dir=_console_fn("dir");async.memoize=function(fn,hasher){var memo={};var queues={};hasher=hasher||function(x){return x};var memoized=function(){var args=Array.prototype.slice.call(arguments);var callback=args.pop();var key=hasher.apply(null,args);if(key in memo){async.nextTick(function(){callback.apply(null,memo[key])})}else if(key in queues){queues[key].push(callback)}else{queues[key]=[callback];fn.apply(null,args.concat([function(){memo[key]=arguments;var q=queues[key];delete queues[key];for(var i=0,l=q.length;i<l;i++){q[i].apply(null,arguments)}}]))}};memoized.memo=memo;memoized.unmemoized=fn;return memoized};async.unmemoize=function(fn){return function(){return(fn.unmemoized||fn).apply(null,arguments)}};async.times=function(count,iterator,callback){var counter=[];for(var i=0;i<count;i++){counter.push(i)}return async.map(counter,iterator,callback)};async.timesSeries=function(count,iterator,callback){var counter=[];for(var i=0;i<count;i++){counter.push(i)}return async.mapSeries(counter,iterator,callback)};async.seq=function(){var fns=arguments;return function(){var that=this;var args=Array.prototype.slice.call(arguments);var callback=args.pop();async.reduce(fns,args,function(newargs,fn,cb){fn.apply(that,newargs.concat([function(){var err=arguments[0];var nextargs=Array.prototype.slice.call(arguments,1);cb(err,nextargs)}]))},function(err,results){callback.apply(that,[err].concat(results))})}};async.compose=function(){return async.seq.apply(null,Array.prototype.reverse.call(arguments))};var _applyEach=function(eachfn,fns){var go=function(){var that=this;var args=Array.prototype.slice.call(arguments);var callback=args.pop();return eachfn(fns,function(fn,cb){fn.apply(that,args.concat([cb]))},callback)};if(arguments.length>2){var args=Array.prototype.slice.call(arguments,2);return go.apply(this,args)}else{return go}};async.applyEach=doParallel(_applyEach);async.applyEachSeries=doSeries(_applyEach);async.forever=function(fn,callback){function next(err){if(err){if(callback){return callback(err)}throw err}fn(next)}next()};if(typeof module!=="undefined"&&module.exports){module.exports=async}else if(typeof define!=="undefined"&&define.amd){define([],function(){return async})}else{root.async=async}})()}).call(this,require("_process"))},{_process:3}],13:[function(require,module,exports){var async=require("async"),urlParser=require("url"),Resource=require("./Resource"),EventEmitter=require("eventemitter3");function Loader(baseUrl,concurrency){EventEmitter.call(this);concurrency=concurrency||10;this.baseUrl=baseUrl||"";this.progress=0;this.loading=false;this._progressChunk=0;this._beforeMiddleware=[];this._afterMiddleware=[];this._boundLoadResource=this._loadResource.bind(this);this._boundOnLoad=this._onLoad.bind(this);this._buffer=[];this._numToLoad=0;this._queue=async.queue(this._boundLoadResource,concurrency);this.resources={}}Loader.prototype=Object.create(EventEmitter.prototype);Loader.prototype.constructor=Loader;module.exports=Loader;Loader.prototype.add=Loader.prototype.enqueue=function(name,url,options,cb){if(Array.isArray(name)){for(var i=0;i<name.length;++i){this.add(name[i])}return this}if(typeof name==="object"){cb=url||name.callback||name.onComplete;options=name;url=name.url;name=name.name||name.key||name.url}if(typeof url!=="string"){cb=options;options=url;url=name}if(typeof url!=="string"){throw new Error("No url passed to add resource to loader.")}if(typeof options==="function"){cb=options;options=null}if(this.resources[name]){throw new Error('Resource with name "'+name+'" already exists.')}url=this._handleBaseUrl(url);this.resources[name]=new Resource(name,url,options);if(typeof cb==="function"){this.resources[name].once("afterMiddleware",cb)}this._numToLoad++;if(this._queue.started){this._queue.push(this.resources[name]);this._progressChunk=(100-this.progress)/(this._queue.length()+this._queue.running())}else{this._buffer.push(this.resources[name]);this._progressChunk=100/this._buffer.length}return this};Loader.prototype._handleBaseUrl=function(url){var parsedUrl=urlParser.parse(url);if(parsedUrl.protocol||parsedUrl.pathname.indexOf("//")===0){return url}if(this.baseUrl.length&&this.baseUrl.lastIndexOf("/")!==this.baseUrl.length-1&&url.charAt(0)!=="/"){return this.baseUrl+"/"+url}else{return this.baseUrl+url}};Loader.prototype.before=Loader.prototype.pre=function(fn){this._beforeMiddleware.push(fn);return this};Loader.prototype.after=Loader.prototype.use=function(fn){this._afterMiddleware.push(fn);return this};Loader.prototype.reset=function(){this.progress=0;this.loading=false;this._progressChunk=0;this._buffer.length=0;this._numToLoad=0;this._queue.kill();this._queue.started=false;this.resources={}};Loader.prototype.load=function(cb){if(typeof cb==="function"){this.once("complete",cb)}if(this._queue.started){return this}this.emit("start",this);for(var i=0;i<this._buffer.length;++i){this._queue.push(this._buffer[i])}this._buffer.length=0;return this};Loader.prototype._loadResource=function(resource,dequeue){var self=this;resource._dequeue=dequeue;this._runMiddleware(resource,this._beforeMiddleware,function(){resource.load(self._boundOnLoad)})};Loader.prototype._onComplete=function(){this.emit("complete",this,this.resources)};Loader.prototype._onLoad=function(resource){this.progress+=this._progressChunk;this.emit("progress",this,resource);this._runMiddleware(resource,this._afterMiddleware,function(){resource.emit("afterMiddleware",resource);this._numToLoad--;if(this._numToLoad===0){this.progress=100;this._onComplete()}if(resource.error){this.emit("error",resource.error,this,resource)}else{this.emit("load",this,resource)}});resource._dequeue()};Loader.prototype._runMiddleware=function(resource,fns,cb){var self=this;async.eachSeries(fns,function(fn,next){fn.call(self,resource,next)},cb.bind(this,resource))};Loader.LOAD_TYPE=Resource.LOAD_TYPE;Loader.XHR_READY_STATE=Resource.XHR_READY_STATE;Loader.XHR_RESPONSE_TYPE=Resource.XHR_RESPONSE_TYPE},{"./Resource":14,async:12,eventemitter3:10,url:8}],14:[function(require,module,exports){var EventEmitter=require("eventemitter3"),_url=require("url"),useXdr=!!(window.XDomainRequest&&!("withCredentials"in new XMLHttpRequest)),tempAnchor=null;function Resource(name,url,options){EventEmitter.call(this);options=options||{};if(typeof name!=="string"||typeof url!=="string"){throw new Error("Both name and url are required for constructing a resource.")}this.name=name;this.url=url;this.isDataUrl=this.url.indexOf("data:")===0;this.data=null;this.crossOrigin=options.crossOrigin===true?"anonymous":options.crossOrigin;this.loadType=options.loadType||this._determineLoadType();this.xhrType=options.xhrType;this.metadata=options.metadata||{};this.error=null;this.xhr=null;this.isJson=false;this.isXml=false;this.isImage=false;this.isAudio=false;this.isVideo=false;this._dequeue=null;this._boundComplete=this.complete.bind(this);this._boundOnError=this._onError.bind(this);this._boundOnProgress=this._onProgress.bind(this);this._boundXhrOnError=this._xhrOnError.bind(this);this._boundXhrOnAbort=this._xhrOnAbort.bind(this);this._boundXhrOnLoad=this._xhrOnLoad.bind(this);this._boundXdrOnTimeout=this._xdrOnTimeout.bind(this)}Resource.prototype=Object.create(EventEmitter.prototype);Resource.prototype.constructor=Resource;module.exports=Resource;Resource.prototype.complete=function(){if(this.data&&this.data.removeEventListener){this.data.removeEventListener("error",this._boundOnError);this.data.removeEventListener("load",this._boundComplete);this.data.removeEventListener("progress",this._boundOnProgress);this.data.removeEventListener("canplaythrough",this._boundComplete)}if(this.xhr){if(this.xhr.removeEventListener){this.xhr.removeEventListener("error",this._boundXhrOnError);this.xhr.removeEventListener("abort",this._boundXhrOnAbort);this.xhr.removeEventListener("progress",this._boundOnProgress);this.xhr.removeEventListener("load",this._boundXhrOnLoad)}else{this.xhr.onerror=null;this.xhr.ontimeout=null;this.xhr.onprogress=null;this.xhr.onload=null}}this.emit("complete",this)};Resource.prototype.load=function(cb){this.emit("start",this);if(cb){this.once("complete",cb)}if(this.crossOrigin===false||typeof this.crossOrigin!=="string"){this.crossOrigin=this._determineCrossOrigin(this.url)}switch(this.loadType){case Resource.LOAD_TYPE.IMAGE:this._loadImage();break;case Resource.LOAD_TYPE.AUDIO:this._loadElement("audio");break;case Resource.LOAD_TYPE.VIDEO:this._loadElement("video");break;case Resource.LOAD_TYPE.XHR:default:if(useXdr&&this.crossOrigin){this._loadXdr()}else{this._loadXhr()}break}};Resource.prototype._loadImage=function(){this.data=new Image;if(this.crossOrigin){this.data.crossOrigin=this.crossOrigin}this.data.src=this.url;this.isImage=true;this.data.addEventListener("error",this._boundOnError,false);this.data.addEventListener("load",this._boundComplete,false);this.data.addEventListener("progress",this._boundOnProgress,false)};Resource.prototype._loadElement=function(type){if(type==="audio"&&typeof Audio!=="undefined"){this.data=new Audio}else{this.data=document.createElement(type)}if(this.data===null){this.error=new Error("Unsupported element "+type);this.complete();return}if(navigator.isCocoonJS){this.data.src=Array.isArray(this.url)?this.url[0]:this.url}else{if(Array.isArray(this.url)){for(var i=0;i<this.url.length;++i){this.data.appendChild(this._createSource(type,this.url[i]))}}else{this.data.appendChild(this._createSource(type,this.url))}}this["is"+type[0].toUpperCase()+type.substring(1)]=true;this.data.addEventListener("error",this._boundOnError,false);this.data.addEventListener("load",this._boundComplete,false);this.data.addEventListener("progress",this._boundOnProgress,false);this.data.addEventListener("canplaythrough",this._boundComplete,false);this.data.load()};Resource.prototype._loadXhr=function(){if(typeof this.xhrType!=="string"){this.xhrType=this._determineXhrType()}var xhr=this.xhr=new XMLHttpRequest;xhr.open("GET",this.url,true);if(this.xhrType===Resource.XHR_RESPONSE_TYPE.JSON||this.xhrType===Resource.XHR_RESPONSE_TYPE.DOCUMENT){xhr.responseType=Resource.XHR_RESPONSE_TYPE.TEXT}else{xhr.responseType=this.xhrType}xhr.addEventListener("error",this._boundXhrOnError,false);xhr.addEventListener("abort",this._boundXhrOnAbort,false);xhr.addEventListener("progress",this._boundOnProgress,false);xhr.addEventListener("load",this._boundXhrOnLoad,false);xhr.send()};Resource.prototype._loadXdr=function(){if(typeof this.xhrType!=="string"){this.xhrType=this._determineXhrType()}var xdr=this.xhr=new XDomainRequest;xdr.timeout=5e3;xdr.onerror=this._boundXhrOnError;xdr.ontimeout=this._boundXdrOnTimeout;xdr.onprogress=this._boundOnProgress;xdr.onload=this._boundXhrOnLoad;xdr.open("GET",this.url,true);setTimeout(function(){xdr.send()},0)};Resource.prototype._createSource=function(type,url,mime){if(!mime){mime=type+"/"+url.substr(url.lastIndexOf(".")+1)}var source=document.createElement("source");source.src=url;source.type=mime;return source};Resource.prototype._onError=function(event){this.error=new Error("Failed to load element using "+event.target.nodeName);this.complete()};Resource.prototype._onProgress=function(event){if(event&&event.lengthComputable){this.emit("progress",this,event.loaded/event.total)}};Resource.prototype._xhrOnError=function(){this.error=new Error(reqType(this.xhr)+" Request failed. "+"Status: "+this.xhr.status+', text: "'+this.xhr.statusText+'"');this.complete()};Resource.prototype._xhrOnAbort=function(){this.error=new Error(reqType(this.xhr)+" Request was aborted by the user.");this.complete()};Resource.prototype._xdrOnTimeout=function(){this.error=new Error(reqType(this.xhr)+" Request timed out.");this.complete()};Resource.prototype._xhrOnLoad=function(){var xhr=this.xhr,status=xhr.status!==undefined?xhr.status:200;if(status===200||status===204||status===0&&xhr.responseText.length>0){if(this.xhrType===Resource.XHR_RESPONSE_TYPE.TEXT){this.data=xhr.responseText}else if(this.xhrType===Resource.XHR_RESPONSE_TYPE.JSON){try{this.data=JSON.parse(xhr.responseText);this.isJson=true}catch(e){this.error=new Error("Error trying to parse loaded json:",e)}}else if(this.xhrType===Resource.XHR_RESPONSE_TYPE.DOCUMENT){try{if(window.DOMParser){var domparser=new DOMParser;this.data=domparser.parseFromString(xhr.responseText,"text/xml")}else{var div=document.createElement("div");div.innerHTML=xhr.responseText;this.data=div}this.isXml=true}catch(e){this.error=new Error("Error trying to parse loaded xml:",e)}}else{this.data=xhr.response||xhr.responseText}}else{this.error=new Error("["+xhr.status+"]"+xhr.statusText+":"+xhr.responseURL)}this.complete()};function reqType(xhr){return xhr.toString().replace("object ","")}Resource.prototype._determineCrossOrigin=function(url,loc){if(url.indexOf("data:")===0){return""}loc=loc||window.location;if(!tempAnchor){tempAnchor=document.createElement("a")}tempAnchor.href=url;url=_url.parse(tempAnchor.href);var samePort=!url.port&&loc.port===""||url.port===loc.port;if(url.hostname!==loc.hostname||!samePort||url.protocol!==loc.protocol){return"anonymous"}return""};Resource.prototype._determineXhrType=function(){return Resource._xhrTypeMap[this._getExtension()]||Resource.XHR_RESPONSE_TYPE.TEXT};Resource.prototype._determineLoadType=function(){return Resource._loadTypeMap[this._getExtension()]||Resource.LOAD_TYPE.XHR};Resource.prototype._getExtension=function(){var url=this.url,ext;if(this.isDataUrl){var slashIndex=url.indexOf("/");ext=url.substring(slashIndex+1,url.indexOf(";",slashIndex))}else{var queryStart=url.indexOf("?");if(queryStart!==-1){url=url.substring(0,queryStart)}ext=url.substring(url.lastIndexOf(".")+1)}return ext};Resource.prototype._getMimeFromXhrType=function(type){switch(type){case Resource.XHR_RESPONSE_TYPE.BUFFER:return"application/octet-binary";case Resource.XHR_RESPONSE_TYPE.BLOB:return"application/blob";case Resource.XHR_RESPONSE_TYPE.DOCUMENT:return"application/xml";case Resource.XHR_RESPONSE_TYPE.JSON:return"application/json";case Resource.XHR_RESPONSE_TYPE.DEFAULT:case Resource.XHR_RESPONSE_TYPE.TEXT:default:return"text/plain"}};Resource.LOAD_TYPE={XHR:1,IMAGE:2,AUDIO:3,VIDEO:4};Resource.XHR_READY_STATE={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4};Resource.XHR_RESPONSE_TYPE={DEFAULT:"text",BUFFER:"arraybuffer",BLOB:"blob",DOCUMENT:"document",JSON:"json",TEXT:"text"};Resource._loadTypeMap={gif:Resource.LOAD_TYPE.IMAGE,png:Resource.LOAD_TYPE.IMAGE,bmp:Resource.LOAD_TYPE.IMAGE,jpg:Resource.LOAD_TYPE.IMAGE,jpeg:Resource.LOAD_TYPE.IMAGE,tif:Resource.LOAD_TYPE.IMAGE,tiff:Resource.LOAD_TYPE.IMAGE,webp:Resource.LOAD_TYPE.IMAGE,tga:Resource.LOAD_TYPE.IMAGE};Resource._xhrTypeMap={xhtml:Resource.XHR_RESPONSE_TYPE.DOCUMENT,html:Resource.XHR_RESPONSE_TYPE.DOCUMENT,htm:Resource.XHR_RESPONSE_TYPE.DOCUMENT,xml:Resource.XHR_RESPONSE_TYPE.DOCUMENT,tmx:Resource.XHR_RESPONSE_TYPE.DOCUMENT,tsx:Resource.XHR_RESPONSE_TYPE.DOCUMENT,svg:Resource.XHR_RESPONSE_TYPE.DOCUMENT,gif:Resource.XHR_RESPONSE_TYPE.BLOB,png:Resource.XHR_RESPONSE_TYPE.BLOB,bmp:Resource.XHR_RESPONSE_TYPE.BLOB,jpg:Resource.XHR_RESPONSE_TYPE.BLOB,jpeg:Resource.XHR_RESPONSE_TYPE.BLOB,tif:Resource.XHR_RESPONSE_TYPE.BLOB,tiff:Resource.XHR_RESPONSE_TYPE.BLOB,webp:Resource.XHR_RESPONSE_TYPE.BLOB,tga:Resource.XHR_RESPONSE_TYPE.BLOB,json:Resource.XHR_RESPONSE_TYPE.JSON,text:Resource.XHR_RESPONSE_TYPE.TEXT,txt:Resource.XHR_RESPONSE_TYPE.TEXT};Resource.setExtensionLoadType=function(extname,loadType){setExtMap(Resource._loadTypeMap,extname,loadType)};Resource.setExtensionXhrType=function(extname,xhrType){setExtMap(Resource._xhrTypeMap,extname,xhrType)};function setExtMap(map,extname,val){if(extname&&extname.indexOf(".")===0){extname=extname.substring(1)}if(!extname){return}map[extname]=val}},{eventemitter3:10,url:8}],15:[function(require,module,exports){module.exports={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encodeBinary:function(input){var output="";var bytebuffer;var encodedCharIndexes=new Array(4);var inx=0;var jnx=0;var paddingBytes=0;while(inx<input.length){bytebuffer=new Array(3);for(jnx=0;jnx<bytebuffer.length;jnx++){if(inx<input.length){bytebuffer[jnx]=input.charCodeAt(inx++)&255}else{bytebuffer[jnx]=0}}encodedCharIndexes[0]=bytebuffer[0]>>2;encodedCharIndexes[1]=(bytebuffer[0]&3)<<4|bytebuffer[1]>>4;encodedCharIndexes[2]=(bytebuffer[1]&15)<<2|bytebuffer[2]>>6;encodedCharIndexes[3]=bytebuffer[2]&63;paddingBytes=inx-(input.length-1);switch(paddingBytes){case 2:encodedCharIndexes[3]=64;encodedCharIndexes[2]=64;break;case 1:encodedCharIndexes[3]=64;break;default:break}for(jnx=0;jnx<encodedCharIndexes.length;jnx++){output+=this._keyStr.charAt(encodedCharIndexes[jnx])}}return output}}},{}],16:[function(require,module,exports){module.exports=require("./Loader");module.exports.Resource=require("./Resource");module.exports.middleware={caching:{memory:require("./middlewares/caching/memory")},parsing:{blob:require("./middlewares/parsing/blob")}}},{"./Loader":13,"./Resource":14,"./middlewares/caching/memory":17,"./middlewares/parsing/blob":18}],17:[function(require,module,exports){var cache={};module.exports=function(){return function(resource,next){if(cache[resource.url]){resource.data=cache[resource.url];resource.complete()}else{resource.once("complete",function(){cache[this.url]=this.data})}next()}}},{}],18:[function(require,module,exports){var Resource=require("../../Resource"),b64=require("../../b64");window.URL=window.URL||window.webkitURL;module.exports=function(){return function(resource,next){if(!resource.data){return next()}if(resource.xhr&&resource.xhrType===Resource.XHR_RESPONSE_TYPE.BLOB){if(!window.Blob||typeof resource.data==="string"){var type=resource.xhr.getResponseHeader("content-type");if(type&&type.indexOf("image")===0){resource.data=new Image;resource.data.src="data:"+type+";base64,"+b64.encodeBinary(resource.xhr.responseText);resource.isImage=true;resource.data.onload=function(){resource.data.onload=null;next()}}}else if(resource.data.type.indexOf("image")===0){var src=URL.createObjectURL(resource.data);resource.blob=resource.data;resource.data=new Image;resource.data.src=src;resource.isImage=true;resource.data.onload=function(){URL.revokeObjectURL(src);resource.data.onload=null;next()}}}else{next()}}}},{"../../Resource":14,"../../b64":15}],19:[function(require,module,exports){var core=require("../core");Object.assign(core.DisplayObject.prototype,require("./accessibleTarget"));function AccessibilityManager(renderer){var div=document.createElement("div");div.style.width=100+"px";div.style.height=100+"px";div.style.position="absolute";div.style.top=0;div.style.left=0;div.style.zIndex=2;this.div=div;this.pool=[];this.renderId=0;this.debug=false;this.renderer=renderer;this.children=[];this._onKeyDown=this._onKeyDown.bind(this);this._onMouseMove=this._onMouseMove.bind(this);this.isActive=false;window.addEventListener("keydown",this._onKeyDown,false)}AccessibilityManager.prototype.constructor=AccessibilityManager;module.exports=AccessibilityManager;AccessibilityManager.prototype.activate=function(){if(this.isActive){return}this.isActive=true;window.document.addEventListener("mousemove",this._onMouseMove,true);window.removeEventListener("keydown",this._onKeyDown,false);this.renderer.on("postrender",this.update,this);this.renderer.view.parentNode.appendChild(this.div)};AccessibilityManager.prototype.deactivate=function(){if(!this.isActive){return}this.isActive=false;window.document.removeEventListener("mousemove",this._onMouseMove);window.addEventListener("keydown",this._onKeyDown,false);this.renderer.off("postrender",this.update);this.div.parentNode.removeChild(this.div)};AccessibilityManager.prototype.updateAccessibleObjects=function(displayObject){if(!displayObject.visible){return}if(displayObject.accessible&&displayObject.interactive){if(!displayObject._accessibleActive){this.addChild(displayObject)}displayObject.renderId=this.renderId}if(displayObject.interactiveChildren){var children=displayObject.children;for(var i=children.length-1;i>=0;i--){this.updateAccessibleObjects(children[i])}}};AccessibilityManager.prototype.update=function(){this.updateAccessibleObjects(this.renderer._lastObjectRendered);var rect=this.renderer.view.getBoundingClientRect();var sx=rect.width/this.renderer.width;var sy=rect.height/this.renderer.height;var div=this.div;div.style.left=rect.left+"px";div.style.top=rect.top+"px";div.style.width=this.renderer.width+"px";div.style.height=this.renderer.height+"px";for(var i=0;i<this.children.length;i++){var child=this.children[i];if(child.renderId!==this.renderId){child._accessibleActive=false;core.utils.removeItems(this.children,i,1);this.div.removeChild(child._accessibleDiv);this.pool.push(child._accessibleDiv);child._accessibleDiv=null;i--;if(this.children.length===0){this.deactivate()}}else{div=child._accessibleDiv;var hitArea=child.hitArea;var wt=child.worldTransform;if(child.hitArea){div.style.left=(wt.tx+hitArea.x*wt.a)*sx+"px";div.style.top=(wt.ty+hitArea.y*wt.d)*sy+"px";div.style.width=hitArea.width*wt.a*sx+"px";div.style.height=hitArea.height*wt.d*sy+"px"}else{hitArea=child.getBounds();this.capHitArea(hitArea);div.style.left=hitArea.x*sx+"px";div.style.top=hitArea.y*sy+"px";div.style.width=hitArea.width*sx+"px";div.style.height=hitArea.height*sy+"px"}}}this.renderId++};AccessibilityManager.prototype.capHitArea=function(hitArea){if(hitArea.x<0){hitArea.width+=hitArea.x;hitArea.x=0}if(hitArea.y<0){hitArea.height+=hitArea.y;hitArea.y=0}if(hitArea.x+hitArea.width>this.renderer.width){hitArea.width=this.renderer.width-hitArea.x}if(hitArea.y+hitArea.height>this.renderer.height){hitArea.height=this.renderer.height-hitArea.y}};AccessibilityManager.prototype.addChild=function(displayObject){var div=this.pool.pop();if(!div){div=document.createElement("button");div.style.width=100+"px";div.style.height=100+"px";div.style.backgroundColor=this.debug?"rgba(255,0,0,0.5)":"transparent";div.style.position="absolute";div.style.zIndex=2;div.style.borderStyle="none";div.addEventListener("click",this._onClick.bind(this));div.addEventListener("focus",this._onFocus.bind(this));div.addEventListener("focusout",this._onFocusOut.bind(this))}div.title=displayObject.accessibleTitle||"displayObject "+this.tabIndex;displayObject._accessibleActive=true;displayObject._accessibleDiv=div;div.displayObject=displayObject;this.children.push(displayObject);this.div.appendChild(displayObject._accessibleDiv);displayObject._accessibleDiv.tabIndex=displayObject.tabIndex};AccessibilityManager.prototype._onClick=function(e){var interactionManager=this.renderer.plugins.interaction;interactionManager.dispatchEvent(e.target.displayObject,"click",interactionManager.eventData)};AccessibilityManager.prototype._onFocus=function(e){var interactionManager=this.renderer.plugins.interaction;interactionManager.dispatchEvent(e.target.displayObject,"mouseover",interactionManager.eventData)};AccessibilityManager.prototype._onFocusOut=function(e){var interactionManager=this.renderer.plugins.interaction;interactionManager.dispatchEvent(e.target.displayObject,"mouseout",interactionManager.eventData)};AccessibilityManager.prototype._onKeyDown=function(e){if(e.keyCode!==9){return}this.activate()};AccessibilityManager.prototype._onMouseMove=function(){this.deactivate()};AccessibilityManager.prototype.destroy=function(){this.div=null;for(var i=0;i<this.children.length;i++){this.children[i].div=null}window.document.removeEventListener("mousemove",this._onMouseMove);window.removeEventListener("keydown",this._onKeyDown);this.pool=null;this.children=null;this.renderer=null};core.WebGLRenderer.registerPlugin("accessibility",AccessibilityManager);core.CanvasRenderer.registerPlugin("accessibility",AccessibilityManager);
  4. },{"../core":29,"./accessibleTarget":20}],20:[function(require,module,exports){var accessibleTarget={accessible:false,accessibleTitle:null,tabIndex:0,_accessibleActive:false,_accessibleDiv:false};module.exports=accessibleTarget},{}],21:[function(require,module,exports){module.exports={accessibleTarget:require("./accessibleTarget"),AccessibilityManager:require("./AccessibilityManager")}},{"./AccessibilityManager":19,"./accessibleTarget":20}],22:[function(require,module,exports){var CONST={VERSION:"3.0.10",PI_2:Math.PI*2,RAD_TO_DEG:180/Math.PI,DEG_TO_RAD:Math.PI/180,TARGET_FPMS:.06,RENDERER_TYPE:{UNKNOWN:0,WEBGL:1,CANVAS:2},BLEND_MODES:{NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16},DRAW_MODES:{POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},SCALE_MODES:{DEFAULT:0,LINEAR:0,NEAREST:1},RETINA_PREFIX:/@(.+)x/,RESOLUTION:1,FILTER_RESOLUTION:1,DEFAULT_RENDER_OPTIONS:{view:null,resolution:1,antialias:false,forceFXAA:false,autoResize:false,transparent:false,backgroundColor:0,clearBeforeRender:true,preserveDrawingBuffer:false,roundPixels:false},SHAPES:{POLY:0,RECT:1,CIRC:2,ELIP:3,RREC:4},SPRITE_BATCH_SIZE:2e3};module.exports=CONST},{}],23:[function(require,module,exports){var math=require("../math"),utils=require("../utils"),DisplayObject=require("./DisplayObject"),RenderTexture=require("../textures/RenderTexture"),_tempMatrix=new math.Matrix;function Container(){DisplayObject.call(this);this.children=[]}Container.prototype=Object.create(DisplayObject.prototype);Container.prototype.constructor=Container;module.exports=Container;Object.defineProperties(Container.prototype,{width:{get:function(){return this.scale.x*this.getLocalBounds().width},set:function(value){var width=this.getLocalBounds().width;if(width!==0){this.scale.x=value/width}else{this.scale.x=1}this._width=value}},height:{get:function(){return this.scale.y*this.getLocalBounds().height},set:function(value){var height=this.getLocalBounds().height;if(height!==0){this.scale.y=value/height}else{this.scale.y=1}this._height=value}}});Container.prototype.onChildrenChange=function(){};Container.prototype.addChild=function(child){var argumentsLength=arguments.length;if(argumentsLength>1){for(var i=0;i<argumentsLength;i++){this.addChild(arguments[i])}}else{if(child.parent){child.parent.removeChild(child)}child.parent=this;this.children.push(child);this.onChildrenChange(this.children.length-1);child.emit("added",this)}return child};Container.prototype.addChildAt=function(child,index){if(index>=0&&index<=this.children.length){if(child.parent){child.parent.removeChild(child)}child.parent=this;this.children.splice(index,0,child);this.onChildrenChange(index);child.emit("added",this);return child}else{throw new Error(child+"addChildAt: The index "+index+" supplied is out of bounds "+this.children.length)}};Container.prototype.swapChildren=function(child,child2){if(child===child2){return}var index1=this.getChildIndex(child);var index2=this.getChildIndex(child2);if(index1<0||index2<0){throw new Error("swapChildren: Both the supplied DisplayObjects must be children of the caller.")}this.children[index1]=child2;this.children[index2]=child;this.onChildrenChange(index1<index2?index1:index2)};Container.prototype.getChildIndex=function(child){var index=this.children.indexOf(child);if(index===-1){throw new Error("The supplied DisplayObject must be a child of the caller")}return index};Container.prototype.setChildIndex=function(child,index){if(index<0||index>=this.children.length){throw new Error("The supplied index is out of bounds")}var currentIndex=this.getChildIndex(child);utils.removeItems(this.children,currentIndex,1);this.children.splice(index,0,child);this.onChildrenChange(index)};Container.prototype.getChildAt=function(index){if(index<0||index>=this.children.length){throw new Error("getChildAt: Supplied index "+index+" does not exist in the child list, or the supplied DisplayObject is not a child of the caller")}return this.children[index]};Container.prototype.removeChild=function(child){var argumentsLength=arguments.length;if(argumentsLength>1){for(var i=0;i<argumentsLength;i++){this.removeChild(arguments[i])}}else{var index=this.children.indexOf(child);if(index===-1){return}child.parent=null;utils.removeItems(this.children,index,1);this.onChildrenChange(index);child.emit("removed",this)}return child};Container.prototype.removeChildAt=function(index){var child=this.getChildAt(index);child.parent=null;utils.removeItems(this.children,index,1);this.onChildrenChange(index);child.emit("removed",this);return child};Container.prototype.removeChildren=function(beginIndex,endIndex){var begin=beginIndex||0;var end=typeof endIndex==="number"?endIndex:this.children.length;var range=end-begin;var removed,i;if(range>0&&range<=end){removed=this.children.splice(begin,range);for(i=0;i<removed.length;++i){removed[i].parent=null}this.onChildrenChange(beginIndex);for(i=0;i<removed.length;++i){removed[i].emit("removed",this)}return removed}else if(range===0&&this.children.length===0){return[]}else{throw new RangeError("removeChildren: numeric values are outside the acceptable range.")}};Container.prototype.generateTexture=function(renderer,resolution,scaleMode){var bounds=this.getLocalBounds();var renderTexture=new RenderTexture(renderer,bounds.width|0,bounds.height|0,scaleMode,resolution);_tempMatrix.tx=-bounds.x;_tempMatrix.ty=-bounds.y;renderTexture.render(this,_tempMatrix);return renderTexture};Container.prototype.updateTransform=function(){if(!this.visible){return}this.displayObjectUpdateTransform();for(var i=0,j=this.children.length;i<j;++i){this.children[i].updateTransform()}};Container.prototype.containerUpdateTransform=Container.prototype.updateTransform;Container.prototype.getBounds=function(){if(!this._currentBounds){if(this.children.length===0){return math.Rectangle.EMPTY}var minX=Infinity;var minY=Infinity;var maxX=-Infinity;var maxY=-Infinity;var childBounds;var childMaxX;var childMaxY;var childVisible=false;for(var i=0,j=this.children.length;i<j;++i){var child=this.children[i];if(!child.visible){continue}childVisible=true;childBounds=this.children[i].getBounds();minX=minX<childBounds.x?minX:childBounds.x;minY=minY<childBounds.y?minY:childBounds.y;childMaxX=childBounds.width+childBounds.x;childMaxY=childBounds.height+childBounds.y;maxX=maxX>childMaxX?maxX:childMaxX;maxY=maxY>childMaxY?maxY:childMaxY}if(!childVisible){return math.Rectangle.EMPTY}var bounds=this._bounds;bounds.x=minX;bounds.y=minY;bounds.width=maxX-minX;bounds.height=maxY-minY;this._currentBounds=bounds}return this._currentBounds};Container.prototype.containerGetBounds=Container.prototype.getBounds;Container.prototype.getLocalBounds=function(){var matrixCache=this.worldTransform;this.worldTransform=math.Matrix.IDENTITY;for(var i=0,j=this.children.length;i<j;++i){this.children[i].updateTransform()}this.worldTransform=matrixCache;this._currentBounds=null;return this.getBounds(math.Matrix.IDENTITY)};Container.prototype.renderWebGL=function(renderer){if(!this.visible||this.worldAlpha<=0||!this.renderable){return}var i,j;if(this._mask||this._filters){renderer.currentRenderer.flush();if(this._filters&&this._filters.length){renderer.filterManager.pushFilter(this,this._filters)}if(this._mask){renderer.maskManager.pushMask(this,this._mask)}renderer.currentRenderer.start();this._renderWebGL(renderer);for(i=0,j=this.children.length;i<j;i++){this.children[i].renderWebGL(renderer)}renderer.currentRenderer.flush();if(this._mask){renderer.maskManager.popMask(this,this._mask)}if(this._filters){renderer.filterManager.popFilter()}renderer.currentRenderer.start()}else{this._renderWebGL(renderer);for(i=0,j=this.children.length;i<j;++i){this.children[i].renderWebGL(renderer)}}};Container.prototype._renderWebGL=function(renderer){};Container.prototype._renderCanvas=function(renderer){};Container.prototype.renderCanvas=function(renderer){if(!this.visible||this.alpha<=0||!this.renderable){return}if(this._mask){renderer.maskManager.pushMask(this._mask,renderer)}this._renderCanvas(renderer);for(var i=0,j=this.children.length;i<j;++i){this.children[i].renderCanvas(renderer)}if(this._mask){renderer.maskManager.popMask(renderer)}};Container.prototype.destroy=function(destroyChildren){DisplayObject.prototype.destroy.call(this);if(destroyChildren){for(var i=0,j=this.children.length;i<j;++i){this.children[i].destroy(destroyChildren)}}this.removeChildren();this.children=null}},{"../math":33,"../textures/RenderTexture":71,"../utils":77,"./DisplayObject":24}],24:[function(require,module,exports){var math=require("../math"),RenderTexture=require("../textures/RenderTexture"),EventEmitter=require("eventemitter3"),CONST=require("../const"),_tempMatrix=new math.Matrix,_tempDisplayObjectParent={worldTransform:new math.Matrix,worldAlpha:1,children:[]};function DisplayObject(){EventEmitter.call(this);this.position=new math.Point;this.scale=new math.Point(1,1);this.pivot=new math.Point(0,0);this.skew=new math.Point(0,0);this.rotation=0;this.alpha=1;this.visible=true;this.renderable=true;this.parent=null;this.worldAlpha=1;this.worldTransform=new math.Matrix;this.filterArea=null;this._sr=0;this._cr=1;this._bounds=new math.Rectangle(0,0,1,1);this._currentBounds=null;this._mask=null}DisplayObject.prototype=Object.create(EventEmitter.prototype);DisplayObject.prototype.constructor=DisplayObject;module.exports=DisplayObject;Object.defineProperties(DisplayObject.prototype,{x:{get:function(){return this.position.x},set:function(value){this.position.x=value}},y:{get:function(){return this.position.y},set:function(value){this.position.y=value}},worldVisible:{get:function(){var item=this;do{if(!item.visible){return false}item=item.parent}while(item);return true}},mask:{get:function(){return this._mask},set:function(value){if(this._mask){this._mask.renderable=true}this._mask=value;if(this._mask){this._mask.renderable=false}}},filters:{get:function(){return this._filters&&this._filters.slice()},set:function(value){this._filters=value&&value.slice()}}});DisplayObject.prototype.updateTransform=function(){var pt=this.parent.worldTransform;var wt=this.worldTransform;var a,b,c,d,tx,ty;if(this.skew.x||this.skew.y){_tempMatrix.setTransform(this.position.x,this.position.y,this.pivot.x,this.pivot.y,this.scale.x,this.scale.y,this.rotation,this.skew.x,this.skew.y);wt.a=_tempMatrix.a*pt.a+_tempMatrix.b*pt.c;wt.b=_tempMatrix.a*pt.b+_tempMatrix.b*pt.d;wt.c=_tempMatrix.c*pt.a+_tempMatrix.d*pt.c;wt.d=_tempMatrix.c*pt.b+_tempMatrix.d*pt.d;wt.tx=_tempMatrix.tx*pt.a+_tempMatrix.ty*pt.c+pt.tx;wt.ty=_tempMatrix.tx*pt.b+_tempMatrix.ty*pt.d+pt.ty}else{if(this.rotation%CONST.PI_2){if(this.rotation!==this.rotationCache){this.rotationCache=this.rotation;this._sr=Math.sin(this.rotation);this._cr=Math.cos(this.rotation)}a=this._cr*this.scale.x;b=this._sr*this.scale.x;c=-this._sr*this.scale.y;d=this._cr*this.scale.y;tx=this.position.x;ty=this.position.y;if(this.pivot.x||this.pivot.y){tx-=this.pivot.x*a+this.pivot.y*c;ty-=this.pivot.x*b+this.pivot.y*d}wt.a=a*pt.a+b*pt.c;wt.b=a*pt.b+b*pt.d;wt.c=c*pt.a+d*pt.c;wt.d=c*pt.b+d*pt.d;wt.tx=tx*pt.a+ty*pt.c+pt.tx;wt.ty=tx*pt.b+ty*pt.d+pt.ty}else{a=this.scale.x;d=this.scale.y;tx=this.position.x-this.pivot.x*a;ty=this.position.y-this.pivot.y*d;wt.a=a*pt.a;wt.b=a*pt.b;wt.c=d*pt.c;wt.d=d*pt.d;wt.tx=tx*pt.a+ty*pt.c+pt.tx;wt.ty=tx*pt.b+ty*pt.d+pt.ty}}this.worldAlpha=this.alpha*this.parent.worldAlpha;this._currentBounds=null};DisplayObject.prototype.displayObjectUpdateTransform=DisplayObject.prototype.updateTransform;DisplayObject.prototype.getBounds=function(matrix){return math.Rectangle.EMPTY};DisplayObject.prototype.getLocalBounds=function(){return this.getBounds(math.Matrix.IDENTITY)};DisplayObject.prototype.toGlobal=function(position){if(!this.parent){this.parent=_tempDisplayObjectParent;this.displayObjectUpdateTransform();this.parent=null}else{this.displayObjectUpdateTransform()}return this.worldTransform.apply(position)};DisplayObject.prototype.toLocal=function(position,from,point){if(from){position=from.toGlobal(position)}if(!this.parent){this.parent=_tempDisplayObjectParent;this.displayObjectUpdateTransform();this.parent=null}else{this.displayObjectUpdateTransform()}return this.worldTransform.applyInverse(position,point)};DisplayObject.prototype.renderWebGL=function(renderer){};DisplayObject.prototype.renderCanvas=function(renderer){};DisplayObject.prototype.generateTexture=function(renderer,scaleMode,resolution){var bounds=this.getLocalBounds();var renderTexture=new RenderTexture(renderer,bounds.width|0,bounds.height|0,scaleMode,resolution);_tempMatrix.tx=-bounds.x;_tempMatrix.ty=-bounds.y;renderTexture.render(this,_tempMatrix);return renderTexture};DisplayObject.prototype.setParent=function(container){if(!container||!container.addChild){throw new Error("setParent: Argument must be a Container")}container.addChild(this);return container};DisplayObject.prototype.setTransform=function(x,y,scaleX,scaleY,rotation,skewX,skewY,pivotX,pivotY){this.position.x=x||0;this.position.y=y||0;this.scale.x=!scaleX?1:scaleX;this.scale.y=!scaleY?1:scaleY;this.rotation=rotation||0;this.skew.x=skewX||0;this.skew.y=skewY||0;this.pivot.x=pivotX||0;this.pivot.y=pivotY||0;return this};DisplayObject.prototype.destroy=function(){this.position=null;this.scale=null;this.pivot=null;this.skew=null;this.parent=null;this._bounds=null;this._currentBounds=null;this._mask=null;this.worldTransform=null;this.filterArea=null}},{"../const":22,"../math":33,"../textures/RenderTexture":71,eventemitter3:10}],25:[function(require,module,exports){var Container=require("../display/Container"),Texture=require("../textures/Texture"),CanvasBuffer=require("../renderers/canvas/utils/CanvasBuffer"),CanvasGraphics=require("../renderers/canvas/utils/CanvasGraphics"),GraphicsData=require("./GraphicsData"),math=require("../math"),CONST=require("../const"),tempPoint=new math.Point;function Graphics(){Container.call(this);this.fillAlpha=1;this.lineWidth=0;this.lineColor=0;this.graphicsData=[];this.tint=16777215;this._prevTint=16777215;this.blendMode=CONST.BLEND_MODES.NORMAL;this.currentPath=null;this._webGL={};this.isMask=false;this.boundsPadding=0;this._localBounds=new math.Rectangle(0,0,1,1);this.dirty=true;this.glDirty=false;this.boundsDirty=true;this.cachedSpriteDirty=false}Graphics.prototype=Object.create(Container.prototype);Graphics.prototype.constructor=Graphics;module.exports=Graphics;Graphics.prototype.clone=function(){var clone=new Graphics;clone.renderable=this.renderable;clone.fillAlpha=this.fillAlpha;clone.lineWidth=this.lineWidth;clone.lineColor=this.lineColor;clone.tint=this.tint;clone.blendMode=this.blendMode;clone.isMask=this.isMask;clone.boundsPadding=this.boundsPadding;clone.dirty=true;clone.glDirty=true;clone.cachedSpriteDirty=this.cachedSpriteDirty;for(var i=0;i<this.graphicsData.length;++i){clone.graphicsData.push(this.graphicsData[i].clone())}clone.currentPath=clone.graphicsData[clone.graphicsData.length-1];clone.updateLocalBounds();return clone};Graphics.prototype.lineStyle=function(lineWidth,color,alpha){this.lineWidth=lineWidth||0;this.lineColor=color||0;this.lineAlpha=alpha===undefined?1:alpha;if(this.currentPath){if(this.currentPath.shape.points.length){var shape=new math.Polygon(this.currentPath.shape.points.slice(-2));shape.closed=false;this.drawShape(shape)}else{this.currentPath.lineWidth=this.lineWidth;this.currentPath.lineColor=this.lineColor;this.currentPath.lineAlpha=this.lineAlpha}}return this};Graphics.prototype.moveTo=function(x,y){var shape=new math.Polygon([x,y]);shape.closed=false;this.drawShape(shape);return this};Graphics.prototype.lineTo=function(x,y){this.currentPath.shape.points.push(x,y);this.dirty=true;return this};Graphics.prototype.quadraticCurveTo=function(cpX,cpY,toX,toY){if(this.currentPath){if(this.currentPath.shape.points.length===0){this.currentPath.shape.points=[0,0]}}else{this.moveTo(0,0)}var xa,ya,n=20,points=this.currentPath.shape.points;if(points.length===0){this.moveTo(0,0)}var fromX=points[points.length-2];var fromY=points[points.length-1];var j=0;for(var i=1;i<=n;++i){j=i/n;xa=fromX+(cpX-fromX)*j;ya=fromY+(cpY-fromY)*j;points.push(xa+(cpX+(toX-cpX)*j-xa)*j,ya+(cpY+(toY-cpY)*j-ya)*j)}this.dirty=this.boundsDirty=true;return this};Graphics.prototype.bezierCurveTo=function(cpX,cpY,cpX2,cpY2,toX,toY){if(this.currentPath){if(this.currentPath.shape.points.length===0){this.currentPath.shape.points=[0,0]}}else{this.moveTo(0,0)}var n=20,dt,dt2,dt3,t2,t3,points=this.currentPath.shape.points;var fromX=points[points.length-2];var fromY=points[points.length-1];var j=0;for(var i=1;i<=n;++i){j=i/n;dt=1-j;dt2=dt*dt;dt3=dt2*dt;t2=j*j;t3=t2*j;points.push(dt3*fromX+3*dt2*j*cpX+3*dt*t2*cpX2+t3*toX,dt3*fromY+3*dt2*j*cpY+3*dt*t2*cpY2+t3*toY)}this.dirty=this.boundsDirty=true;return this};Graphics.prototype.arcTo=function(x1,y1,x2,y2,radius){if(this.currentPath){if(this.currentPath.shape.points.length===0){this.currentPath.shape.points.push(x1,y1)}}else{this.moveTo(x1,y1)}var points=this.currentPath.shape.points,fromX=points[points.length-2],fromY=points[points.length-1],a1=fromY-y1,b1=fromX-x1,a2=y2-y1,b2=x2-x1,mm=Math.abs(a1*b2-b1*a2);if(mm<1e-8||radius===0){if(points[points.length-2]!==x1||points[points.length-1]!==y1){points.push(x1,y1)}}else{var dd=a1*a1+b1*b1,cc=a2*a2+b2*b2,tt=a1*a2+b1*b2,k1=radius*Math.sqrt(dd)/mm,k2=radius*Math.sqrt(cc)/mm,j1=k1*tt/dd,j2=k2*tt/cc,cx=k1*b2+k2*b1,cy=k1*a2+k2*a1,px=b1*(k2+j1),py=a1*(k2+j1),qx=b2*(k1+j2),qy=a2*(k1+j2),startAngle=Math.atan2(py-cy,px-cx),endAngle=Math.atan2(qy-cy,qx-cx);this.arc(cx+x1,cy+y1,radius,startAngle,endAngle,b1*a2>b2*a1)}this.dirty=this.boundsDirty=true;return this};Graphics.prototype.arc=function(cx,cy,radius,startAngle,endAngle,anticlockwise){anticlockwise=anticlockwise||false;if(startAngle===endAngle){return this}if(!anticlockwise&&endAngle<=startAngle){endAngle+=Math.PI*2}else if(anticlockwise&&startAngle<=endAngle){startAngle+=Math.PI*2}var sweep=anticlockwise?(startAngle-endAngle)*-1:endAngle-startAngle;var segs=Math.ceil(Math.abs(sweep)/(Math.PI*2))*40;if(sweep===0){return this}var startX=cx+Math.cos(startAngle)*radius;var startY=cy+Math.sin(startAngle)*radius;if(this.currentPath){this.currentPath.shape.points.push(startX,startY)}else{this.moveTo(startX,startY)}var points=this.currentPath.shape.points;var theta=sweep/(segs*2);var theta2=theta*2;var cTheta=Math.cos(theta);var sTheta=Math.sin(theta);var segMinus=segs-1;var remainder=segMinus%1/segMinus;for(var i=0;i<=segMinus;i++){var real=i+remainder*i;var angle=theta+startAngle+theta2*real;var c=Math.cos(angle);var s=-Math.sin(angle);points.push((cTheta*c+sTheta*s)*radius+cx,(cTheta*-s+sTheta*c)*radius+cy)}this.dirty=this.boundsDirty=true;return this};Graphics.prototype.beginFill=function(color,alpha){this.filling=true;this.fillColor=color||0;this.fillAlpha=alpha===undefined?1:alpha;if(this.currentPath){if(this.currentPath.shape.points.length<=2){this.currentPath.fill=this.filling;this.currentPath.fillColor=this.fillColor;this.currentPath.fillAlpha=this.fillAlpha}}return this};Graphics.prototype.endFill=function(){this.filling=false;this.fillColor=null;this.fillAlpha=1;return this};Graphics.prototype.drawRect=function(x,y,width,height){this.drawShape(new math.Rectangle(x,y,width,height));return this};Graphics.prototype.drawRoundedRect=function(x,y,width,height,radius){this.drawShape(new math.RoundedRectangle(x,y,width,height,radius));return this};Graphics.prototype.drawCircle=function(x,y,radius){this.drawShape(new math.Circle(x,y,radius));return this};Graphics.prototype.drawEllipse=function(x,y,width,height){this.drawShape(new math.Ellipse(x,y,width,height));return this};Graphics.prototype.drawPolygon=function(path){var points=path;var closed=true;if(points instanceof math.Polygon){closed=points.closed;points=points.points}if(!Array.isArray(points)){points=new Array(arguments.length);for(var i=0;i<points.length;++i){points[i]=arguments[i]}}var shape=new math.Polygon(points);shape.closed=closed;this.drawShape(shape);return this};Graphics.prototype.clear=function(){this.lineWidth=0;this.filling=false;this.dirty=true;this.clearDirty=true;this.graphicsData=[];return this};Graphics.prototype.generateTexture=function(renderer,resolution,scaleMode){resolution=resolution||1;var bounds=this.getLocalBounds();var canvasBuffer=new CanvasBuffer(bounds.width*resolution,bounds.height*resolution);var texture=Texture.fromCanvas(canvasBuffer.canvas,scaleMode);texture.baseTexture.resolution=resolution;canvasBuffer.context.scale(resolution,resolution);canvasBuffer.context.translate(-bounds.x,-bounds.y);CanvasGraphics.renderGraphics(this,canvasBuffer.context);return texture};Graphics.prototype._renderWebGL=function(renderer){if(this.glDirty){this.dirty=true;this.glDirty=false}renderer.setObjectRenderer(renderer.plugins.graphics);renderer.plugins.graphics.render(this)};Graphics.prototype._renderCanvas=function(renderer){if(this.isMask===true){return}if(this._prevTint!==this.tint){this.dirty=true}var context=renderer.context;var transform=this.worldTransform;var compositeOperation=renderer.blendModes[this.blendMode];if(compositeOperation!==context.globalCompositeOperation){context.globalCompositeOperation=compositeOperation}var resolution=renderer.resolution;context.setTransform(transform.a*resolution,transform.b*resolution,transform.c*resolution,transform.d*resolution,transform.tx*resolution,transform.ty*resolution);CanvasGraphics.renderGraphics(this,context)};Graphics.prototype.getBounds=function(matrix){if(!this._currentBounds){if(!this.renderable){return math.Rectangle.EMPTY}if(this.boundsDirty){this.updateLocalBounds();this.glDirty=true;this.cachedSpriteDirty=true;this.boundsDirty=false}var bounds=this._localBounds;var w0=bounds.x;var w1=bounds.width+bounds.x;var h0=bounds.y;var h1=bounds.height+bounds.y;var worldTransform=matrix||this.worldTransform;var a=worldTransform.a;var b=worldTransform.b;var c=worldTransform.c;var d=worldTransform.d;var tx=worldTransform.tx;var ty=worldTransform.ty;var x1=a*w1+c*h1+tx;var y1=d*h1+b*w1+ty;var x2=a*w0+c*h1+tx;var y2=d*h1+b*w0+ty;var x3=a*w0+c*h0+tx;var y3=d*h0+b*w0+ty;var x4=a*w1+c*h0+tx;var y4=d*h0+b*w1+ty;var maxX=x1;var maxY=y1;var minX=x1;var minY=y1;minX=x2<minX?x2:minX;minX=x3<minX?x3:minX;minX=x4<minX?x4:minX;minY=y2<minY?y2:minY;minY=y3<minY?y3:minY;minY=y4<minY?y4:minY;maxX=x2>maxX?x2:maxX;maxX=x3>maxX?x3:maxX;maxX=x4>maxX?x4:maxX;maxY=y2>maxY?y2:maxY;maxY=y3>maxY?y3:maxY;maxY=y4>maxY?y4:maxY;this._bounds.x=minX;this._bounds.width=maxX-minX;this._bounds.y=minY;this._bounds.height=maxY-minY;this._currentBounds=this._bounds}return this._currentBounds};Graphics.prototype.containsPoint=function(point){this.worldTransform.applyInverse(point,tempPoint);var graphicsData=this.graphicsData;for(var i=0;i<graphicsData.length;i++){var data=graphicsData[i];if(!data.fill){continue}if(data.shape){if(data.shape.contains(tempPoint.x,tempPoint.y)){return true}}}return false};Graphics.prototype.updateLocalBounds=function(){var minX=Infinity;var maxX=-Infinity;var minY=Infinity;var maxY=-Infinity;if(this.graphicsData.length){var shape,points,x,y,w,h;for(var i=0;i<this.graphicsData.length;i++){var data=this.graphicsData[i];var type=data.type;var lineWidth=data.lineWidth;shape=data.shape;if(type===CONST.SHAPES.RECT||type===CONST.SHAPES.RREC){x=shape.x-lineWidth/2;y=shape.y-lineWidth/2;w=shape.width+lineWidth;h=shape.height+lineWidth;minX=x<minX?x:minX;maxX=x+w>maxX?x+w:maxX;minY=y<minY?y:minY;maxY=y+h>maxY?y+h:maxY}else if(type===CONST.SHAPES.CIRC){x=shape.x;y=shape.y;w=shape.radius+lineWidth/2;h=shape.radius+lineWidth/2;minX=x-w<minX?x-w:minX;maxX=x+w>maxX?x+w:maxX;minY=y-h<minY?y-h:minY;maxY=y+h>maxY?y+h:maxY}else if(type===CONST.SHAPES.ELIP){x=shape.x;y=shape.y;w=shape.width+lineWidth/2;h=shape.height+lineWidth/2;minX=x-w<minX?x-w:minX;maxX=x+w>maxX?x+w:maxX;minY=y-h<minY?y-h:minY;maxY=y+h>maxY?y+h:maxY}else{points=shape.points;for(var j=0;j<points.length;j+=2){x=points[j];y=points[j+1];minX=x-lineWidth<minX?x-lineWidth:minX;maxX=x+lineWidth>maxX?x+lineWidth:maxX;minY=y-lineWidth<minY?y-lineWidth:minY;maxY=y+lineWidth>maxY?y+lineWidth:maxY}}}}else{minX=0;maxX=0;minY=0;maxY=0}var padding=this.boundsPadding;this._localBounds.x=minX-padding;this._localBounds.width=maxX-minX+padding*2;this._localBounds.y=minY-padding;this._localBounds.height=maxY-minY+padding*2};Graphics.prototype.drawShape=function(shape){if(this.currentPath){if(this.currentPath.shape.points.length<=2){this.graphicsData.pop()}}this.currentPath=null;var data=new GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,shape);this.graphicsData.push(data);if(data.type===CONST.SHAPES.POLY){data.shape.closed=data.shape.closed||this.filling;this.currentPath=data}this.dirty=this.boundsDirty=true;return data};Graphics.prototype.destroy=function(){Container.prototype.destroy.apply(this,arguments);for(var i=0;i<this.graphicsData.length;++i){this.graphicsData[i].destroy()}for(var id in this._webgl){for(var j=0;j<this._webgl[id].data.length;++j){this._webgl[id].data[j].destroy()}}this.graphicsData=null;this.currentPath=null;this._webgl=null;this._localBounds=null}},{"../const":22,"../display/Container":23,"../math":33,"../renderers/canvas/utils/CanvasBuffer":45,"../renderers/canvas/utils/CanvasGraphics":46,"../textures/Texture":72,"./GraphicsData":26}],26:[function(require,module,exports){function GraphicsData(lineWidth,lineColor,lineAlpha,fillColor,fillAlpha,fill,shape){this.lineWidth=lineWidth;this.lineColor=lineColor;this.lineAlpha=lineAlpha;this._lineTint=lineColor;this.fillColor=fillColor;this.fillAlpha=fillAlpha;this._fillTint=fillColor;this.fill=fill;this.shape=shape;this.type=shape.type}GraphicsData.prototype.constructor=GraphicsData;module.exports=GraphicsData;GraphicsData.prototype.clone=function(){return new GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)};GraphicsData.prototype.destroy=function(){this.shape=null}},{}],27:[function(require,module,exports){var utils=require("../../utils"),math=require("../../math"),CONST=require("../../const"),ObjectRenderer=require("../../renderers/webgl/utils/ObjectRenderer"),WebGLRenderer=require("../../renderers/webgl/WebGLRenderer"),WebGLGraphicsData=require("./WebGLGraphicsData"),earcut=require("earcut");function GraphicsRenderer(renderer){ObjectRenderer.call(this,renderer);this.graphicsDataPool=[];this.primitiveShader=null;this.complexPrimitiveShader=null;this.maximumSimplePolySize=200}GraphicsRenderer.prototype=Object.create(ObjectRenderer.prototype);GraphicsRenderer.prototype.constructor=GraphicsRenderer;module.exports=GraphicsRenderer;WebGLRenderer.registerPlugin("graphics",GraphicsRenderer);GraphicsRenderer.prototype.onContextChange=function(){};GraphicsRenderer.prototype.destroy=function(){ObjectRenderer.prototype.destroy.call(this);for(var i=0;i<this.graphicsDataPool.length;++i){this.graphicsDataPool[i].destroy()}this.graphicsDataPool=null};GraphicsRenderer.prototype.render=function(graphics){var renderer=this.renderer;var gl=renderer.gl;var shader=renderer.shaderManager.plugins.primitiveShader,webGLData;if(graphics.dirty||!graphics._webGL[gl.id]){this.updateGraphics(graphics)}var webGL=graphics._webGL[gl.id];renderer.blendModeManager.setBlendMode(graphics.blendMode);for(var i=0,n=webGL.data.length;i<n;i++){webGLData=webGL.data[i];if(webGL.data[i].mode===1){renderer.stencilManager.pushStencil(graphics,webGLData);gl.uniform1f(renderer.shaderManager.complexPrimitiveShader.uniforms.alpha._location,graphics.worldAlpha*webGLData.alpha);gl.drawElements(gl.TRIANGLE_FAN,4,gl.UNSIGNED_SHORT,(webGLData.indices.length-4)*2);renderer.stencilManager.popStencil(graphics,webGLData)}else{shader=renderer.shaderManager.primitiveShader;renderer.shaderManager.setShader(shader);gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location,false,graphics.worldTransform.toArray(true));gl.uniformMatrix3fv(shader.uniforms.projectionMatrix._location,false,renderer.currentRenderTarget.projectionMatrix.toArray(true));gl.uniform3fv(shader.uniforms.tint._location,utils.hex2rgb(graphics.tint));gl.uniform1f(shader.uniforms.alpha._location,graphics.worldAlpha);gl.bindBuffer(gl.ARRAY_BUFFER,webGLData.buffer);gl.vertexAttribPointer(shader.attributes.aVertexPosition,2,gl.FLOAT,false,4*6,0);gl.vertexAttribPointer(shader.attributes.aColor,4,gl.FLOAT,false,4*6,2*4);gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,webGLData.indexBuffer);gl.drawElements(gl.TRIANGLE_STRIP,webGLData.indices.length,gl.UNSIGNED_SHORT,0)}renderer.drawCount++}};GraphicsRenderer.prototype.updateGraphics=function(graphics){var gl=this.renderer.gl;var webGL=graphics._webGL[gl.id];if(!webGL){webGL=graphics._webGL[gl.id]={lastIndex:0,data:[],gl:gl}}graphics.dirty=false;var i;if(graphics.clearDirty){graphics.clearDirty=false;for(i=0;i<webGL.data.length;i++){var graphicsData=webGL.data[i];graphicsData.reset();this.graphicsDataPool.push(graphicsData)}webGL.data=[];webGL.lastIndex=0}var webGLData;for(i=webGL.lastIndex;i<graphics.graphicsData.length;i++){var data=graphics.graphicsData[i];if(data.type===CONST.SHAPES.POLY){data.points=data.shape.points.slice();if(data.shape.closed){if(data.points[0]!==data.points[data.points.length-2]||data.points[1]!==data.points[data.points.length-1]){data.points.push(data.points[0],data.points[1])}}if(data.fill){if(data.points.length>=6){if(data.points.length<this.maximumSimplePolySize*2){webGLData=this.switchMode(webGL,0);var canDrawUsingSimple=this.buildPoly(data,webGLData);if(!canDrawUsingSimple){webGLData=this.switchMode(webGL,1);this.buildComplexPoly(data,webGLData)}}else{webGLData=this.switchMode(webGL,1);this.buildComplexPoly(data,webGLData)}}}if(data.lineWidth>0){webGLData=this.switchMode(webGL,0);this.buildLine(data,webGLData)}}else{webGLData=this.switchMode(webGL,0);if(data.type===CONST.SHAPES.RECT){this.buildRectangle(data,webGLData)}else if(data.type===CONST.SHAPES.CIRC||data.type===CONST.SHAPES.ELIP){this.buildCircle(data,webGLData)}else if(data.type===CONST.SHAPES.RREC){this.buildRoundedRectangle(data,webGLData)}}webGL.lastIndex++}for(i=0;i<webGL.data.length;i++){webGLData=webGL.data[i];if(webGLData.dirty){webGLData.upload()}}};GraphicsRenderer.prototype.switchMode=function(webGL,type){var webGLData;if(!webGL.data.length){webGLData=this.graphicsDataPool.pop()||new WebGLGraphicsData(webGL.gl);webGLData.mode=type;webGL.data.push(webGLData)}else{webGLData=webGL.data[webGL.data.length-1];if(webGLData.points.length>32e4||webGLData.mode!==type||type===1){webGLData=this.graphicsDataPool.pop()||new WebGLGraphicsData(webGL.gl);webGLData.mode=type;webGL.data.push(webGLData)}}webGLData.dirty=true;return webGLData};GraphicsRenderer.prototype.buildRectangle=function(graphicsData,webGLData){var rectData=graphicsData.shape;var x=rectData.x;var y=rectData.y;var width=rectData.width;var height=rectData.height;if(graphicsData.fill){var color=utils.hex2rgb(graphicsData.fillColor);var alpha=graphicsData.fillAlpha;var r=color[0]*alpha;var g=color[1]*alpha;var b=color[2]*alpha;var verts=webGLData.points;var indices=webGLData.indices;var vertPos=verts.length/6;verts.push(x,y);verts.push(r,g,b,alpha);verts.push(x+width,y);verts.push(r,g,b,alpha);verts.push(x,y+height);verts.push(r,g,b,alpha);verts.push(x+width,y+height);verts.push(r,g,b,alpha);indices.push(vertPos,vertPos,vertPos+1,vertPos+2,vertPos+3,vertPos+3)}if(graphicsData.lineWidth){var tempPoints=graphicsData.points;graphicsData.points=[x,y,x+width,y,x+width,y+height,x,y+height,x,y];this.buildLine(graphicsData,webGLData);graphicsData.points=tempPoints}};GraphicsRenderer.prototype.buildRoundedRectangle=function(graphicsData,webGLData){var rrectData=graphicsData.shape;var x=rrectData.x;var y=rrectData.y;var width=rrectData.width;var height=rrectData.height;var radius=rrectData.radius;var recPoints=[];recPoints.push(x,y+radius);this.quadraticBezierCurve(x,y+height-radius,x,y+height,x+radius,y+height,recPoints);
  5. this.quadraticBezierCurve(x+width-radius,y+height,x+width,y+height,x+width,y+height-radius,recPoints);this.quadraticBezierCurve(x+width,y+radius,x+width,y,x+width-radius,y,recPoints);this.quadraticBezierCurve(x+radius,y,x,y,x,y+radius+1e-10,recPoints);if(graphicsData.fill){var color=utils.hex2rgb(graphicsData.fillColor);var alpha=graphicsData.fillAlpha;var r=color[0]*alpha;var g=color[1]*alpha;var b=color[2]*alpha;var verts=webGLData.points;var indices=webGLData.indices;var vecPos=verts.length/6;var triangles=earcut(recPoints,null,2);var i=0;for(i=0;i<triangles.length;i+=3){indices.push(triangles[i]+vecPos);indices.push(triangles[i]+vecPos);indices.push(triangles[i+1]+vecPos);indices.push(triangles[i+2]+vecPos);indices.push(triangles[i+2]+vecPos)}for(i=0;i<recPoints.length;i++){verts.push(recPoints[i],recPoints[++i],r,g,b,alpha)}}if(graphicsData.lineWidth){var tempPoints=graphicsData.points;graphicsData.points=recPoints;this.buildLine(graphicsData,webGLData);graphicsData.points=tempPoints}};GraphicsRenderer.prototype.quadraticBezierCurve=function(fromX,fromY,cpX,cpY,toX,toY,out){var xa,ya,xb,yb,x,y,n=20,points=out||[];function getPt(n1,n2,perc){var diff=n2-n1;return n1+diff*perc}var j=0;for(var i=0;i<=n;i++){j=i/n;xa=getPt(fromX,cpX,j);ya=getPt(fromY,cpY,j);xb=getPt(cpX,toX,j);yb=getPt(cpY,toY,j);x=getPt(xa,xb,j);y=getPt(ya,yb,j);points.push(x,y)}return points};GraphicsRenderer.prototype.buildCircle=function(graphicsData,webGLData){var circleData=graphicsData.shape;var x=circleData.x;var y=circleData.y;var width;var height;if(graphicsData.type===CONST.SHAPES.CIRC){width=circleData.radius;height=circleData.radius}else{width=circleData.width;height=circleData.height}var totalSegs=Math.floor(30*Math.sqrt(circleData.radius))||Math.floor(15*Math.sqrt(circleData.width+circleData.height));var seg=Math.PI*2/totalSegs;var i=0;if(graphicsData.fill){var color=utils.hex2rgb(graphicsData.fillColor);var alpha=graphicsData.fillAlpha;var r=color[0]*alpha;var g=color[1]*alpha;var b=color[2]*alpha;var verts=webGLData.points;var indices=webGLData.indices;var vecPos=verts.length/6;indices.push(vecPos);for(i=0;i<totalSegs+1;i++){verts.push(x,y,r,g,b,alpha);verts.push(x+Math.sin(seg*i)*width,y+Math.cos(seg*i)*height,r,g,b,alpha);indices.push(vecPos++,vecPos++)}indices.push(vecPos-1)}if(graphicsData.lineWidth){var tempPoints=graphicsData.points;graphicsData.points=[];for(i=0;i<totalSegs+1;i++){graphicsData.points.push(x+Math.sin(seg*i)*width,y+Math.cos(seg*i)*height)}this.buildLine(graphicsData,webGLData);graphicsData.points=tempPoints}};GraphicsRenderer.prototype.buildLine=function(graphicsData,webGLData){var i=0;var points=graphicsData.points;if(points.length===0){return}var firstPoint=new math.Point(points[0],points[1]);var lastPoint=new math.Point(points[points.length-2],points[points.length-1]);if(firstPoint.x===lastPoint.x&&firstPoint.y===lastPoint.y){points=points.slice();points.pop();points.pop();lastPoint=new math.Point(points[points.length-2],points[points.length-1]);var midPointX=lastPoint.x+(firstPoint.x-lastPoint.x)*.5;var midPointY=lastPoint.y+(firstPoint.y-lastPoint.y)*.5;points.unshift(midPointX,midPointY);points.push(midPointX,midPointY)}var verts=webGLData.points;var indices=webGLData.indices;var length=points.length/2;var indexCount=points.length;var indexStart=verts.length/6;var width=graphicsData.lineWidth/2;var color=utils.hex2rgb(graphicsData.lineColor);var alpha=graphicsData.lineAlpha;var r=color[0]*alpha;var g=color[1]*alpha;var b=color[2]*alpha;var px,py,p1x,p1y,p2x,p2y,p3x,p3y;var perpx,perpy,perp2x,perp2y,perp3x,perp3y;var a1,b1,c1,a2,b2,c2;var denom,pdist,dist;p1x=points[0];p1y=points[1];p2x=points[2];p2y=points[3];perpx=-(p1y-p2y);perpy=p1x-p2x;dist=Math.sqrt(perpx*perpx+perpy*perpy);perpx/=dist;perpy/=dist;perpx*=width;perpy*=width;verts.push(p1x-perpx,p1y-perpy,r,g,b,alpha);verts.push(p1x+perpx,p1y+perpy,r,g,b,alpha);for(i=1;i<length-1;i++){p1x=points[(i-1)*2];p1y=points[(i-1)*2+1];p2x=points[i*2];p2y=points[i*2+1];p3x=points[(i+1)*2];p3y=points[(i+1)*2+1];perpx=-(p1y-p2y);perpy=p1x-p2x;dist=Math.sqrt(perpx*perpx+perpy*perpy);perpx/=dist;perpy/=dist;perpx*=width;perpy*=width;perp2x=-(p2y-p3y);perp2y=p2x-p3x;dist=Math.sqrt(perp2x*perp2x+perp2y*perp2y);perp2x/=dist;perp2y/=dist;perp2x*=width;perp2y*=width;a1=-perpy+p1y-(-perpy+p2y);b1=-perpx+p2x-(-perpx+p1x);c1=(-perpx+p1x)*(-perpy+p2y)-(-perpx+p2x)*(-perpy+p1y);a2=-perp2y+p3y-(-perp2y+p2y);b2=-perp2x+p2x-(-perp2x+p3x);c2=(-perp2x+p3x)*(-perp2y+p2y)-(-perp2x+p2x)*(-perp2y+p3y);denom=a1*b2-a2*b1;if(Math.abs(denom)<.1){denom+=10.1;verts.push(p2x-perpx,p2y-perpy,r,g,b,alpha);verts.push(p2x+perpx,p2y+perpy,r,g,b,alpha);continue}px=(b1*c2-b2*c1)/denom;py=(a2*c1-a1*c2)/denom;pdist=(px-p2x)*(px-p2x)+(py-p2y)*(py-p2y);if(pdist>140*140){perp3x=perpx-perp2x;perp3y=perpy-perp2y;dist=Math.sqrt(perp3x*perp3x+perp3y*perp3y);perp3x/=dist;perp3y/=dist;perp3x*=width;perp3y*=width;verts.push(p2x-perp3x,p2y-perp3y);verts.push(r,g,b,alpha);verts.push(p2x+perp3x,p2y+perp3y);verts.push(r,g,b,alpha);verts.push(p2x-perp3x,p2y-perp3y);verts.push(r,g,b,alpha);indexCount++}else{verts.push(px,py);verts.push(r,g,b,alpha);verts.push(p2x-(px-p2x),p2y-(py-p2y));verts.push(r,g,b,alpha)}}p1x=points[(length-2)*2];p1y=points[(length-2)*2+1];p2x=points[(length-1)*2];p2y=points[(length-1)*2+1];perpx=-(p1y-p2y);perpy=p1x-p2x;dist=Math.sqrt(perpx*perpx+perpy*perpy);perpx/=dist;perpy/=dist;perpx*=width;perpy*=width;verts.push(p2x-perpx,p2y-perpy);verts.push(r,g,b,alpha);verts.push(p2x+perpx,p2y+perpy);verts.push(r,g,b,alpha);indices.push(indexStart);for(i=0;i<indexCount;i++){indices.push(indexStart++)}indices.push(indexStart-1)};GraphicsRenderer.prototype.buildComplexPoly=function(graphicsData,webGLData){var points=graphicsData.points.slice();if(points.length<6){return}var indices=webGLData.indices;webGLData.points=points;webGLData.alpha=graphicsData.fillAlpha;webGLData.color=utils.hex2rgb(graphicsData.fillColor);var minX=Infinity;var maxX=-Infinity;var minY=Infinity;var maxY=-Infinity;var x,y;for(var i=0;i<points.length;i+=2){x=points[i];y=points[i+1];minX=x<minX?x:minX;maxX=x>maxX?x:maxX;minY=y<minY?y:minY;maxY=y>maxY?y:maxY}points.push(minX,minY,maxX,minY,maxX,maxY,minX,maxY);var length=points.length/2;for(i=0;i<length;i++){indices.push(i)}};GraphicsRenderer.prototype.buildPoly=function(graphicsData,webGLData){var points=graphicsData.points;if(points.length<6){return}var verts=webGLData.points;var indices=webGLData.indices;var length=points.length/2;var color=utils.hex2rgb(graphicsData.fillColor);var alpha=graphicsData.fillAlpha;var r=color[0]*alpha;var g=color[1]*alpha;var b=color[2]*alpha;var triangles=earcut(points,null,2);if(!triangles){return false}var vertPos=verts.length/6;var i=0;for(i=0;i<triangles.length;i+=3){indices.push(triangles[i]+vertPos);indices.push(triangles[i]+vertPos);indices.push(triangles[i+1]+vertPos);indices.push(triangles[i+2]+vertPos);indices.push(triangles[i+2]+vertPos)}for(i=0;i<length;i++){verts.push(points[i*2],points[i*2+1],r,g,b,alpha)}return true}},{"../../const":22,"../../math":33,"../../renderers/webgl/WebGLRenderer":49,"../../renderers/webgl/utils/ObjectRenderer":63,"../../utils":77,"./WebGLGraphicsData":28,earcut:9}],28:[function(require,module,exports){function WebGLGraphicsData(gl){this.gl=gl;this.color=[0,0,0];this.points=[];this.indices=[];this.buffer=gl.createBuffer();this.indexBuffer=gl.createBuffer();this.mode=1;this.alpha=1;this.dirty=true;this.glPoints=null;this.glIndices=null}WebGLGraphicsData.prototype.constructor=WebGLGraphicsData;module.exports=WebGLGraphicsData;WebGLGraphicsData.prototype.reset=function(){this.points.length=0;this.indices.length=0};WebGLGraphicsData.prototype.upload=function(){var gl=this.gl;this.glPoints=new Float32Array(this.points);gl.bindBuffer(gl.ARRAY_BUFFER,this.buffer);gl.bufferData(gl.ARRAY_BUFFER,this.glPoints,gl.STATIC_DRAW);this.glIndices=new Uint16Array(this.indices);gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,this.indexBuffer);gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,this.glIndices,gl.STATIC_DRAW);this.dirty=false};WebGLGraphicsData.prototype.destroy=function(){this.color=null;this.points=null;this.indices=null;this.gl.deleteBuffer(this.buffer);this.gl.deleteBuffer(this.indexBuffer);this.gl=null;this.buffer=null;this.indexBuffer=null;this.glPoints=null;this.glIndices=null}},{}],29:[function(require,module,exports){var core=module.exports=Object.assign(require("./const"),require("./math"),{utils:require("./utils"),ticker:require("./ticker"),DisplayObject:require("./display/DisplayObject"),Container:require("./display/Container"),Sprite:require("./sprites/Sprite"),ParticleContainer:require("./particles/ParticleContainer"),SpriteRenderer:require("./sprites/webgl/SpriteRenderer"),ParticleRenderer:require("./particles/webgl/ParticleRenderer"),Text:require("./text/Text"),Graphics:require("./graphics/Graphics"),GraphicsData:require("./graphics/GraphicsData"),GraphicsRenderer:require("./graphics/webgl/GraphicsRenderer"),Texture:require("./textures/Texture"),BaseTexture:require("./textures/BaseTexture"),RenderTexture:require("./textures/RenderTexture"),VideoBaseTexture:require("./textures/VideoBaseTexture"),TextureUvs:require("./textures/TextureUvs"),CanvasRenderer:require("./renderers/canvas/CanvasRenderer"),CanvasGraphics:require("./renderers/canvas/utils/CanvasGraphics"),CanvasBuffer:require("./renderers/canvas/utils/CanvasBuffer"),WebGLRenderer:require("./renderers/webgl/WebGLRenderer"),WebGLManager:require("./renderers/webgl/managers/WebGLManager"),ShaderManager:require("./renderers/webgl/managers/ShaderManager"),Shader:require("./renderers/webgl/shaders/Shader"),TextureShader:require("./renderers/webgl/shaders/TextureShader"),PrimitiveShader:require("./renderers/webgl/shaders/PrimitiveShader"),ComplexPrimitiveShader:require("./renderers/webgl/shaders/ComplexPrimitiveShader"),ObjectRenderer:require("./renderers/webgl/utils/ObjectRenderer"),RenderTarget:require("./renderers/webgl/utils/RenderTarget"),AbstractFilter:require("./renderers/webgl/filters/AbstractFilter"),FXAAFilter:require("./renderers/webgl/filters/FXAAFilter"),SpriteMaskFilter:require("./renderers/webgl/filters/SpriteMaskFilter"),autoDetectRenderer:function(width,height,options,noWebGL){width=width||800;height=height||600;if(!noWebGL&&core.utils.isWebGLSupported()){return new core.WebGLRenderer(width,height,options)}return new core.CanvasRenderer(width,height,options)}})},{"./const":22,"./display/Container":23,"./display/DisplayObject":24,"./graphics/Graphics":25,"./graphics/GraphicsData":26,"./graphics/webgl/GraphicsRenderer":27,"./math":33,"./particles/ParticleContainer":39,"./particles/webgl/ParticleRenderer":41,"./renderers/canvas/CanvasRenderer":44,"./renderers/canvas/utils/CanvasBuffer":45,"./renderers/canvas/utils/CanvasGraphics":46,"./renderers/webgl/WebGLRenderer":49,"./renderers/webgl/filters/AbstractFilter":50,"./renderers/webgl/filters/FXAAFilter":51,"./renderers/webgl/filters/SpriteMaskFilter":52,"./renderers/webgl/managers/ShaderManager":56,"./renderers/webgl/managers/WebGLManager":58,"./renderers/webgl/shaders/ComplexPrimitiveShader":59,"./renderers/webgl/shaders/PrimitiveShader":60,"./renderers/webgl/shaders/Shader":61,"./renderers/webgl/shaders/TextureShader":62,"./renderers/webgl/utils/ObjectRenderer":63,"./renderers/webgl/utils/RenderTarget":65,"./sprites/Sprite":67,"./sprites/webgl/SpriteRenderer":68,"./text/Text":69,"./textures/BaseTexture":70,"./textures/RenderTexture":71,"./textures/Texture":72,"./textures/TextureUvs":73,"./textures/VideoBaseTexture":74,"./ticker":76,"./utils":77}],30:[function(require,module,exports){var ux=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1];var uy=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1];var vx=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1];var vy=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1];var tempMatrices=[];var Matrix=require("./Matrix");var mul=[];function signum(x){if(x<0){return-1}if(x>0){return 1}return 0}function init(){for(var i=0;i<16;i++){var row=[];mul.push(row);for(var j=0;j<16;j++){var _ux=signum(ux[i]*ux[j]+vx[i]*uy[j]);var _uy=signum(uy[i]*ux[j]+vy[i]*uy[j]);var _vx=signum(ux[i]*vx[j]+vx[i]*vy[j]);var _vy=signum(uy[i]*vx[j]+vy[i]*vy[j]);for(var k=0;k<16;k++){if(ux[k]===_ux&&uy[k]===_uy&&vx[k]===_vx&&vy[k]===_vy){row.push(k);break}}}}for(i=0;i<16;i++){var mat=new Matrix;mat.set(ux[i],uy[i],vx[i],vy[i],0,0);tempMatrices.push(mat)}}init();var GroupD8={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MIRROR_HORIZONTAL:12,uX:function(ind){return ux[ind]},uY:function(ind){return uy[ind]},vX:function(ind){return vx[ind]},vY:function(ind){return vy[ind]},inv:function(rotation){if(rotation&8){return rotation&15}return-rotation&7},add:function(rotationSecond,rotationFirst){return mul[rotationSecond][rotationFirst]},sub:function(rotationSecond,rotationFirst){return mul[rotationSecond][GroupD8.inv(rotationFirst)]},rotate180:function(rotation){return rotation^4},isSwapWidthHeight:function(rotation){return(rotation&3)===2},byDirection:function(dx,dy){if(Math.abs(dx)*2<=Math.abs(dy)){if(dy>=0){return GroupD8.S}else{return GroupD8.N}}else if(Math.abs(dy)*2<=Math.abs(dx)){if(dx>0){return GroupD8.E}else{return GroupD8.W}}else{if(dy>0){if(dx>0){return GroupD8.SE}else{return GroupD8.SW}}else if(dx>0){return GroupD8.NE}else{return GroupD8.NW}}},matrixAppendRotationInv:function(matrix,rotation,tx,ty){var mat=tempMatrices[GroupD8.inv(rotation)];tx=tx||0;ty=ty||0;mat.tx=tx;mat.ty=ty;matrix.append(mat)}};module.exports=GroupD8},{"./Matrix":31}],31:[function(require,module,exports){var Point=require("./Point");function Matrix(){this.a=1;this.b=0;this.c=0;this.d=1;this.tx=0;this.ty=0}Matrix.prototype.constructor=Matrix;module.exports=Matrix;Matrix.prototype.fromArray=function(array){this.a=array[0];this.b=array[1];this.c=array[3];this.d=array[4];this.tx=array[2];this.ty=array[5]};Matrix.prototype.set=function(a,b,c,d,tx,ty){this.a=a;this.b=b;this.c=c;this.d=d;this.tx=tx;this.ty=ty;return this};Matrix.prototype.toArray=function(transpose,out){if(!this.array){this.array=new Float32Array(9)}var array=out||this.array;if(transpose){array[0]=this.a;array[1]=this.b;array[2]=0;array[3]=this.c;array[4]=this.d;array[5]=0;array[6]=this.tx;array[7]=this.ty;array[8]=1}else{array[0]=this.a;array[1]=this.c;array[2]=this.tx;array[3]=this.b;array[4]=this.d;array[5]=this.ty;array[6]=0;array[7]=0;array[8]=1}return array};Matrix.prototype.apply=function(pos,newPos){newPos=newPos||new Point;var x=pos.x;var y=pos.y;newPos.x=this.a*x+this.c*y+this.tx;newPos.y=this.b*x+this.d*y+this.ty;return newPos};Matrix.prototype.applyInverse=function(pos,newPos){newPos=newPos||new Point;var id=1/(this.a*this.d+this.c*-this.b);var x=pos.x;var y=pos.y;newPos.x=this.d*id*x+-this.c*id*y+(this.ty*this.c-this.tx*this.d)*id;newPos.y=this.a*id*y+-this.b*id*x+(-this.ty*this.a+this.tx*this.b)*id;return newPos};Matrix.prototype.translate=function(x,y){this.tx+=x;this.ty+=y;return this};Matrix.prototype.scale=function(x,y){this.a*=x;this.d*=y;this.c*=x;this.b*=y;this.tx*=x;this.ty*=y;return this};Matrix.prototype.rotate=function(angle){var cos=Math.cos(angle);var sin=Math.sin(angle);var a1=this.a;var c1=this.c;var tx1=this.tx;this.a=a1*cos-this.b*sin;this.b=a1*sin+this.b*cos;this.c=c1*cos-this.d*sin;this.d=c1*sin+this.d*cos;this.tx=tx1*cos-this.ty*sin;this.ty=tx1*sin+this.ty*cos;return this};Matrix.prototype.append=function(matrix){var a1=this.a;var b1=this.b;var c1=this.c;var d1=this.d;this.a=matrix.a*a1+matrix.b*c1;this.b=matrix.a*b1+matrix.b*d1;this.c=matrix.c*a1+matrix.d*c1;this.d=matrix.c*b1+matrix.d*d1;this.tx=matrix.tx*a1+matrix.ty*c1+this.tx;this.ty=matrix.tx*b1+matrix.ty*d1+this.ty;return this};Matrix.prototype.setTransform=function(x,y,pivotX,pivotY,scaleX,scaleY,rotation,skewX,skewY){var a,b,c,d,sr,cr,cy,sy,nsx,cx;sr=Math.sin(rotation);cr=Math.cos(rotation);cy=Math.cos(skewY);sy=Math.sin(skewY);nsx=-Math.sin(skewX);cx=Math.cos(skewX);a=cr*scaleX;b=sr*scaleX;c=-sr*scaleY;d=cr*scaleY;this.a=cy*a+sy*c;this.b=cy*b+sy*d;this.c=nsx*a+cx*c;this.d=nsx*b+cx*d;this.tx=x+(pivotX*a+pivotY*c);this.ty=y+(pivotX*b+pivotY*d);return this};Matrix.prototype.prepend=function(matrix){var tx1=this.tx;if(matrix.a!==1||matrix.b!==0||matrix.c!==0||matrix.d!==1){var a1=this.a;var c1=this.c;this.a=a1*matrix.a+this.b*matrix.c;this.b=a1*matrix.b+this.b*matrix.d;this.c=c1*matrix.a+this.d*matrix.c;this.d=c1*matrix.b+this.d*matrix.d}this.tx=tx1*matrix.a+this.ty*matrix.c+matrix.tx;this.ty=tx1*matrix.b+this.ty*matrix.d+matrix.ty;return this};Matrix.prototype.invert=function(){var a1=this.a;var b1=this.b;var c1=this.c;var d1=this.d;var tx1=this.tx;var n=a1*d1-b1*c1;this.a=d1/n;this.b=-b1/n;this.c=-c1/n;this.d=a1/n;this.tx=(c1*this.ty-d1*tx1)/n;this.ty=-(a1*this.ty-b1*tx1)/n;return this};Matrix.prototype.identity=function(){this.a=1;this.b=0;this.c=0;this.d=1;this.tx=0;this.ty=0;return this};Matrix.prototype.clone=function(){var matrix=new Matrix;matrix.a=this.a;matrix.b=this.b;matrix.c=this.c;matrix.d=this.d;matrix.tx=this.tx;matrix.ty=this.ty;return matrix};Matrix.prototype.copy=function(matrix){matrix.a=this.a;matrix.b=this.b;matrix.c=this.c;matrix.d=this.d;matrix.tx=this.tx;matrix.ty=this.ty;return matrix};Matrix.IDENTITY=new Matrix;Matrix.TEMP_MATRIX=new Matrix},{"./Point":32}],32:[function(require,module,exports){function Point(x,y){this.x=x||0;this.y=y||0}Point.prototype.constructor=Point;module.exports=Point;Point.prototype.clone=function(){return new Point(this.x,this.y)};Point.prototype.copy=function(p){this.set(p.x,p.y)};Point.prototype.equals=function(p){return p.x===this.x&&p.y===this.y};Point.prototype.set=function(x,y){this.x=x||0;this.y=y||(y!==0?this.x:0)}},{}],33:[function(require,module,exports){module.exports={Point:require("./Point"),Matrix:require("./Matrix"),GroupD8:require("./GroupD8"),Circle:require("./shapes/Circle"),Ellipse:require("./shapes/Ellipse"),Polygon:require("./shapes/Polygon"),Rectangle:require("./shapes/Rectangle"),RoundedRectangle:require("./shapes/RoundedRectangle")}},{"./GroupD8":30,"./Matrix":31,"./Point":32,"./shapes/Circle":34,"./shapes/Ellipse":35,"./shapes/Polygon":36,"./shapes/Rectangle":37,"./shapes/RoundedRectangle":38}],34:[function(require,module,exports){var Rectangle=require("./Rectangle"),CONST=require("../../const");function Circle(x,y,radius){this.x=x||0;this.y=y||0;this.radius=radius||0;this.type=CONST.SHAPES.CIRC}Circle.prototype.constructor=Circle;module.exports=Circle;Circle.prototype.clone=function(){return new Circle(this.x,this.y,this.radius)};Circle.prototype.contains=function(x,y){if(this.radius<=0){return false}var dx=this.x-x,dy=this.y-y,r2=this.radius*this.radius;dx*=dx;dy*=dy;return dx+dy<=r2};Circle.prototype.getBounds=function(){return new Rectangle(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)}},{"../../const":22,"./Rectangle":37}],35:[function(require,module,exports){var Rectangle=require("./Rectangle"),CONST=require("../../const");function Ellipse(x,y,width,height){this.x=x||0;this.y=y||0;this.width=width||0;this.height=height||0;this.type=CONST.SHAPES.ELIP}Ellipse.prototype.constructor=Ellipse;module.exports=Ellipse;Ellipse.prototype.clone=function(){return new Ellipse(this.x,this.y,this.width,this.height)};Ellipse.prototype.contains=function(x,y){if(this.width<=0||this.height<=0){return false}var normx=(x-this.x)/this.width,normy=(y-this.y)/this.height;normx*=normx;normy*=normy;return normx+normy<=1};Ellipse.prototype.getBounds=function(){return new Rectangle(this.x-this.width,this.y-this.height,this.width,this.height)}},{"../../const":22,"./Rectangle":37}],36:[function(require,module,exports){var Point=require("../Point"),CONST=require("../../const");function Polygon(points_){var points=points_;if(!Array.isArray(points)){points=new Array(arguments.length);for(var a=0;a<points.length;++a){points[a]=arguments[a]}}if(points[0]instanceof Point){var p=[];for(var i=0,il=points.length;i<il;i++){p.push(points[i].x,points[i].y)}points=p}this.closed=true;this.points=points;this.type=CONST.SHAPES.POLY}Polygon.prototype.constructor=Polygon;module.exports=Polygon;Polygon.prototype.clone=function(){return new Polygon(this.points.slice())};Polygon.prototype.contains=function(x,y){var inside=false;var length=this.points.length/2;for(var i=0,j=length-1;i<length;j=i++){var xi=this.points[i*2],yi=this.points[i*2+1],xj=this.points[j*2],yj=this.points[j*2+1],intersect=yi>y!==yj>y&&x<(xj-xi)*(y-yi)/(yj-yi)+xi;if(intersect){inside=!inside}}return inside}},{"../../const":22,"../Point":32}],37:[function(require,module,exports){var CONST=require("../../const");function Rectangle(x,y,width,height){this.x=x||0;this.y=y||0;this.width=width||0;this.height=height||0;this.type=CONST.SHAPES.RECT}Rectangle.prototype.constructor=Rectangle;module.exports=Rectangle;Rectangle.EMPTY=new Rectangle(0,0,0,0);Rectangle.prototype.clone=function(){return new Rectangle(this.x,this.y,this.width,this.height)};Rectangle.prototype.contains=function(x,y){if(this.width<=0||this.height<=0){return false}if(x>=this.x&&x<this.x+this.width){if(y>=this.y&&y<this.y+this.height){return true}}return false}},{"../../const":22}],38:[function(require,module,exports){var CONST=require("../../const");function RoundedRectangle(x,y,width,height,radius){this.x=x||0;this.y=y||0;this.width=width||0;this.height=height||0;this.radius=radius||20;this.type=CONST.SHAPES.RREC}RoundedRectangle.prototype.constructor=RoundedRectangle;module.exports=RoundedRectangle;RoundedRectangle.prototype.clone=function(){return new RoundedRectangle(this.x,this.y,this.width,this.height,this.radius)};RoundedRectangle.prototype.contains=function(x,y){if(this.width<=0||this.height<=0){return false}if(x>=this.x&&x<=this.x+this.width){if(y>=this.y&&y<=this.y+this.height){return true}}return false}},{"../../const":22}],39:[function(require,module,exports){var Container=require("../display/Container"),CONST=require("../const");function ParticleContainer(maxSize,properties,batchSize){Container.call(this);batchSize=batchSize||15e3;maxSize=maxSize||15e3;var maxBatchSize=16384;if(batchSize>maxBatchSize){batchSize=maxBatchSize}if(batchSize>maxSize){batchSize=maxSize}this._properties=[false,true,false,false,false];this._maxSize=maxSize;this._batchSize=batchSize;this._buffers=null;this._bufferToUpdate=0;this.interactiveChildren=false;this.blendMode=CONST.BLEND_MODES.NORMAL;this.roundPixels=true;this.setProperties(properties)}ParticleContainer.prototype=Object.create(Container.prototype);ParticleContainer.prototype.constructor=ParticleContainer;module.exports=ParticleContainer;ParticleContainer.prototype.setProperties=function(properties){if(properties){this._properties[0]="scale"in properties?!!properties.scale:this._properties[0];this._properties[1]="position"in properties?!!properties.position:this._properties[1];this._properties[2]="rotation"in properties?!!properties.rotation:this._properties[2];this._properties[3]="uvs"in properties?!!properties.uvs:this._properties[3];this._properties[4]="alpha"in properties?!!properties.alpha:this._properties[4]}};ParticleContainer.prototype.updateTransform=function(){this.displayObjectUpdateTransform()};ParticleContainer.prototype.renderWebGL=function(renderer){if(!this.visible||this.worldAlpha<=0||!this.children.length||!this.renderable){return}renderer.setObjectRenderer(renderer.plugins.particle);renderer.plugins.particle.render(this)};ParticleContainer.prototype.onChildrenChange=function(smallestChildIndex){var bufferIndex=Math.floor(smallestChildIndex/this._batchSize);if(bufferIndex<this._bufferToUpdate){this._bufferToUpdate=bufferIndex}};ParticleContainer.prototype.renderCanvas=function(renderer){if(!this.visible||this.worldAlpha<=0||!this.children.length||!this.renderable){return}var context=renderer.context;var transform=this.worldTransform;var isRotated=true;var positionX=0;var positionY=0;var finalWidth=0;var finalHeight=0;var compositeOperation=renderer.blendModes[this.blendMode];if(compositeOperation!==context.globalCompositeOperation){context.globalCompositeOperation=compositeOperation}context.globalAlpha=this.worldAlpha;this.displayObjectUpdateTransform();for(var i=0;i<this.children.length;++i){var child=this.children[i];if(!child.visible){continue}var frame=child.texture.frame;context.globalAlpha=this.worldAlpha*child.alpha;if(child.rotation%(Math.PI*2)===0){if(isRotated){context.setTransform(transform.a,transform.b,transform.c,transform.d,transform.tx,transform.ty);isRotated=false}positionX=child.anchor.x*(-frame.width*child.scale.x)+child.position.x+.5;positionY=child.anchor.y*(-frame.height*child.scale.y)+child.position.y+.5;finalWidth=frame.width*child.scale.x;finalHeight=frame.height*child.scale.y}else{if(!isRotated){isRotated=true}child.displayObjectUpdateTransform();var childTransform=child.worldTransform;if(renderer.roundPixels){context.setTransform(childTransform.a,childTransform.b,childTransform.c,childTransform.d,childTransform.tx|0,childTransform.ty|0)}else{context.setTransform(childTransform.a,childTransform.b,childTransform.c,childTransform.d,childTransform.tx,childTransform.ty)}positionX=child.anchor.x*-frame.width+.5;positionY=child.anchor.y*-frame.height+.5;finalWidth=frame.width;finalHeight=frame.height}context.drawImage(child.texture.baseTexture.source,frame.x,frame.y,frame.width,frame.height,positionX,positionY,finalWidth,finalHeight)}};ParticleContainer.prototype.destroy=function(){Container.prototype.destroy.apply(this,arguments);if(this._buffers){for(var i=0;i<this._buffers.length;++i){this._buffers[i].destroy()}}this._properties=null;this._buffers=null}},{"../const":22,"../display/Container":23}],40:[function(require,module,exports){function ParticleBuffer(gl,properties,dynamicPropertyFlags,size){this.gl=gl;this.vertSize=2;this.vertByteSize=this.vertSize*4;this.size=size;this.dynamicProperties=[];this.staticProperties=[];for(var i=0;i<properties.length;i++){var property=properties[i];if(dynamicPropertyFlags[i]){this.dynamicProperties.push(property)}else{this.staticProperties.push(property)}}this.staticStride=0;this.staticBuffer=null;this.staticData=null;this.dynamicStride=0;this.dynamicBuffer=null;this.dynamicData=null;this.initBuffers()}ParticleBuffer.prototype.constructor=ParticleBuffer;module.exports=ParticleBuffer;ParticleBuffer.prototype.initBuffers=function(){var gl=this.gl;var i;var property;var dynamicOffset=0;this.dynamicStride=0;for(i=0;i<this.dynamicProperties.length;i++){property=this.dynamicProperties[i];property.offset=dynamicOffset;dynamicOffset+=property.size;this.dynamicStride+=property.size}this.dynamicData=new Float32Array(this.size*this.dynamicStride*4);this.dynamicBuffer=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,this.dynamicBuffer);gl.bufferData(gl.ARRAY_BUFFER,this.dynamicData,gl.DYNAMIC_DRAW);var staticOffset=0;this.staticStride=0;for(i=0;i<this.staticProperties.length;i++){property=this.staticProperties[i];property.offset=staticOffset;staticOffset+=property.size;this.staticStride+=property.size}this.staticData=new Float32Array(this.size*this.staticStride*4);this.staticBuffer=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,this.staticBuffer);gl.bufferData(gl.ARRAY_BUFFER,this.staticData,gl.DYNAMIC_DRAW)};ParticleBuffer.prototype.uploadDynamic=function(children,startIndex,amount){var gl=this.gl;for(var i=0;i<this.dynamicProperties.length;i++){var property=this.dynamicProperties[i];property.uploadFunction(children,startIndex,amount,this.dynamicData,this.dynamicStride,property.offset)}gl.bindBuffer(gl.ARRAY_BUFFER,this.dynamicBuffer);gl.bufferSubData(gl.ARRAY_BUFFER,0,this.dynamicData)};ParticleBuffer.prototype.uploadStatic=function(children,startIndex,amount){var gl=this.gl;for(var i=0;i<this.staticProperties.length;i++){var property=this.staticProperties[i];property.uploadFunction(children,startIndex,amount,this.staticData,this.staticStride,property.offset)}gl.bindBuffer(gl.ARRAY_BUFFER,this.staticBuffer);gl.bufferSubData(gl.ARRAY_BUFFER,0,this.staticData)};ParticleBuffer.prototype.bind=function(){var gl=this.gl;var i,property;gl.bindBuffer(gl.ARRAY_BUFFER,this.dynamicBuffer);for(i=0;i<this.dynamicProperties.length;i++){property=this.dynamicProperties[i];gl.vertexAttribPointer(property.attribute,property.size,gl.FLOAT,false,this.dynamicStride*4,property.offset*4)}gl.bindBuffer(gl.ARRAY_BUFFER,this.staticBuffer);for(i=0;i<this.staticProperties.length;i++){property=this.staticProperties[i];gl.vertexAttribPointer(property.attribute,property.size,gl.FLOAT,false,this.staticStride*4,property.offset*4)}};ParticleBuffer.prototype.destroy=function(){this.dynamicProperties=null;this.dynamicData=null;this.gl.deleteBuffer(this.dynamicBuffer);this.staticProperties=null;this.staticData=null;this.gl.deleteBuffer(this.staticBuffer)}},{}],41:[function(require,module,exports){var ObjectRenderer=require("../../renderers/webgl/utils/ObjectRenderer"),WebGLRenderer=require("../../renderers/webgl/WebGLRenderer"),ParticleShader=require("./ParticleShader"),ParticleBuffer=require("./ParticleBuffer"),math=require("../../math");function ParticleRenderer(renderer){ObjectRenderer.call(this,renderer);var numIndices=98304;this.indices=new Uint16Array(numIndices);for(var i=0,j=0;i<numIndices;i+=6,j+=4){this.indices[i+0]=j+0;this.indices[i+1]=j+1;this.indices[i+2]=j+2;this.indices[i+3]=j+0;this.indices[i+4]=j+2;this.indices[i+5]=j+3}this.shader=null;this.indexBuffer=null;this.properties=null;this.tempMatrix=new math.Matrix}ParticleRenderer.prototype=Object.create(ObjectRenderer.prototype);ParticleRenderer.prototype.constructor=ParticleRenderer;module.exports=ParticleRenderer;WebGLRenderer.registerPlugin("particle",ParticleRenderer);ParticleRenderer.prototype.onContextChange=function(){var gl=this.renderer.gl;this.shader=new ParticleShader(this.renderer.shaderManager);this.indexBuffer=gl.createBuffer();gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,this.indexBuffer);gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,this.indices,gl.STATIC_DRAW);this.properties=[{attribute:this.shader.attributes.aVertexPosition,size:2,uploadFunction:this.uploadVertices,offset:0},{attribute:this.shader.attributes.aPositionCoord,size:2,uploadFunction:this.uploadPosition,offset:0},{attribute:this.shader.attributes.aRotation,size:1,uploadFunction:this.uploadRotation,offset:0},{attribute:this.shader.attributes.aTextureCoord,size:2,uploadFunction:this.uploadUvs,offset:0},{attribute:this.shader.attributes.aColor,size:1,uploadFunction:this.uploadAlpha,offset:0}]};ParticleRenderer.prototype.start=function(){var gl=this.renderer.gl;gl.activeTexture(gl.TEXTURE0);gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var shader=this.shader;this.renderer.shaderManager.setShader(shader)};ParticleRenderer.prototype.render=function(container){var children=container.children,totalChildren=children.length,maxSize=container._maxSize,batchSize=container._batchSize;if(totalChildren===0){return}else if(totalChildren>maxSize){totalChildren=maxSize}if(!container._buffers){container._buffers=this.generateBuffers(container)}this.renderer.blendModeManager.setBlendMode(container.blendMode);var gl=this.renderer.gl;var m=container.worldTransform.copy(this.tempMatrix);m.prepend(this.renderer.currentRenderTarget.projectionMatrix);gl.uniformMatrix3fv(this.shader.uniforms.projectionMatrix._location,false,m.toArray(true));gl.uniform1f(this.shader.uniforms.uAlpha._location,container.worldAlpha);var baseTexture=children[0]._texture.baseTexture;if(!baseTexture._glTextures[gl.id]){if(!this.renderer.updateTexture(baseTexture)){return}if(!container._properties[0]||!container._properties[3]){container._bufferToUpdate=0}}else{gl.bindTexture(gl.TEXTURE_2D,baseTexture._glTextures[gl.id])}for(var i=0,j=0;i<totalChildren;i+=batchSize,j+=1){var amount=totalChildren-i;if(amount>batchSize){amount=batchSize}var buffer=container._buffers[j];buffer.uploadDynamic(children,i,amount);if(container._bufferToUpdate===j){buffer.uploadStatic(children,i,amount);container._bufferToUpdate=j+1}buffer.bind(this.shader);gl.drawElements(gl.TRIANGLES,amount*6,gl.UNSIGNED_SHORT,0);this.renderer.drawCount++}};ParticleRenderer.prototype.generateBuffers=function(container){
  6. var gl=this.renderer.gl,buffers=[],size=container._maxSize,batchSize=container._batchSize,dynamicPropertyFlags=container._properties,i;for(i=0;i<size;i+=batchSize){buffers.push(new ParticleBuffer(gl,this.properties,dynamicPropertyFlags,batchSize))}return buffers};ParticleRenderer.prototype.uploadVertices=function(children,startIndex,amount,array,stride,offset){var sprite,texture,trim,sx,sy,w0,w1,h0,h1;for(var i=0;i<amount;i++){sprite=children[startIndex+i];texture=sprite._texture;sx=sprite.scale.x;sy=sprite.scale.y;if(texture.trim){trim=texture.trim;w1=trim.x-sprite.anchor.x*trim.width;w0=w1+texture.crop.width;h1=trim.y-sprite.anchor.y*trim.height;h0=h1+texture.crop.height}else{w0=texture._frame.width*(1-sprite.anchor.x);w1=texture._frame.width*-sprite.anchor.x;h0=texture._frame.height*(1-sprite.anchor.y);h1=texture._frame.height*-sprite.anchor.y}array[offset]=w1*sx;array[offset+1]=h1*sy;array[offset+stride]=w0*sx;array[offset+stride+1]=h1*sy;array[offset+stride*2]=w0*sx;array[offset+stride*2+1]=h0*sy;array[offset+stride*3]=w1*sx;array[offset+stride*3+1]=h0*sy;offset+=stride*4}};ParticleRenderer.prototype.uploadPosition=function(children,startIndex,amount,array,stride,offset){for(var i=0;i<amount;i++){var spritePosition=children[startIndex+i].position;array[offset]=spritePosition.x;array[offset+1]=spritePosition.y;array[offset+stride]=spritePosition.x;array[offset+stride+1]=spritePosition.y;array[offset+stride*2]=spritePosition.x;array[offset+stride*2+1]=spritePosition.y;array[offset+stride*3]=spritePosition.x;array[offset+stride*3+1]=spritePosition.y;offset+=stride*4}};ParticleRenderer.prototype.uploadRotation=function(children,startIndex,amount,array,stride,offset){for(var i=0;i<amount;i++){var spriteRotation=children[startIndex+i].rotation;array[offset]=spriteRotation;array[offset+stride]=spriteRotation;array[offset+stride*2]=spriteRotation;array[offset+stride*3]=spriteRotation;offset+=stride*4}};ParticleRenderer.prototype.uploadUvs=function(children,startIndex,amount,array,stride,offset){for(var i=0;i<amount;i++){var textureUvs=children[startIndex+i]._texture._uvs;if(textureUvs){array[offset]=textureUvs.x0;array[offset+1]=textureUvs.y0;array[offset+stride]=textureUvs.x1;array[offset+stride+1]=textureUvs.y1;array[offset+stride*2]=textureUvs.x2;array[offset+stride*2+1]=textureUvs.y2;array[offset+stride*3]=textureUvs.x3;array[offset+stride*3+1]=textureUvs.y3;offset+=stride*4}else{array[offset]=0;array[offset+1]=0;array[offset+stride]=0;array[offset+stride+1]=0;array[offset+stride*2]=0;array[offset+stride*2+1]=0;array[offset+stride*3]=0;array[offset+stride*3+1]=0;offset+=stride*4}}};ParticleRenderer.prototype.uploadAlpha=function(children,startIndex,amount,array,stride,offset){for(var i=0;i<amount;i++){var spriteAlpha=children[startIndex+i].alpha;array[offset]=spriteAlpha;array[offset+stride]=spriteAlpha;array[offset+stride*2]=spriteAlpha;array[offset+stride*3]=spriteAlpha;offset+=stride*4}};ParticleRenderer.prototype.destroy=function(){if(this.renderer.gl){this.renderer.gl.deleteBuffer(this.indexBuffer)}ObjectRenderer.prototype.destroy.apply(this,arguments);this.shader.destroy();this.indices=null;this.tempMatrix=null}},{"../../math":33,"../../renderers/webgl/WebGLRenderer":49,"../../renderers/webgl/utils/ObjectRenderer":63,"./ParticleBuffer":40,"./ParticleShader":42}],42:[function(require,module,exports){var TextureShader=require("../../renderers/webgl/shaders/TextureShader");function ParticleShader(shaderManager){TextureShader.call(this,shaderManager,["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","uniform mat3 projectionMatrix;","varying vec2 vTextureCoord;","varying float vColor;","void main(void){"," vec2 v = aVertexPosition;"," v.x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);"," v.y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);"," v = v + aPositionCoord;"," gl_Position = vec4((projectionMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = aColor;","}"].join("\n"),["precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","uniform float uAlpha;","void main(void){"," vec4 color = texture2D(uSampler, vTextureCoord) * vColor * uAlpha;"," if (color.a == 0.0) discard;"," gl_FragColor = color;","}"].join("\n"),{uAlpha:{type:"1f",value:1}},{aPositionCoord:0,aRotation:0})}ParticleShader.prototype=Object.create(TextureShader.prototype);ParticleShader.prototype.constructor=ParticleShader;module.exports=ParticleShader},{"../../renderers/webgl/shaders/TextureShader":62}],43:[function(require,module,exports){var utils=require("../utils"),math=require("../math"),CONST=require("../const"),EventEmitter=require("eventemitter3");function SystemRenderer(system,width,height,options){EventEmitter.call(this);utils.sayHello(system);if(options){for(var i in CONST.DEFAULT_RENDER_OPTIONS){if(typeof options[i]==="undefined"){options[i]=CONST.DEFAULT_RENDER_OPTIONS[i]}}}else{options=CONST.DEFAULT_RENDER_OPTIONS}this.type=CONST.RENDERER_TYPE.UNKNOWN;this.width=width||800;this.height=height||600;this.view=options.view||document.createElement("canvas");this.resolution=options.resolution;this.transparent=options.transparent;this.autoResize=options.autoResize||false;this.blendModes=null;this.preserveDrawingBuffer=options.preserveDrawingBuffer;this.clearBeforeRender=options.clearBeforeRender;this.roundPixels=options.roundPixels;this._backgroundColor=0;this._backgroundColorRgb=[0,0,0];this._backgroundColorString="#000000";this.backgroundColor=options.backgroundColor||this._backgroundColor;this._tempDisplayObjectParent={worldTransform:new math.Matrix,worldAlpha:1,children:[]};this._lastObjectRendered=this._tempDisplayObjectParent}SystemRenderer.prototype=Object.create(EventEmitter.prototype);SystemRenderer.prototype.constructor=SystemRenderer;module.exports=SystemRenderer;Object.defineProperties(SystemRenderer.prototype,{backgroundColor:{get:function(){return this._backgroundColor},set:function(val){this._backgroundColor=val;this._backgroundColorString=utils.hex2string(val);utils.hex2rgb(val,this._backgroundColorRgb)}}});SystemRenderer.prototype.resize=function(width,height){this.width=width*this.resolution;this.height=height*this.resolution;this.view.width=this.width;this.view.height=this.height;if(this.autoResize){this.view.style.width=this.width/this.resolution+"px";this.view.style.height=this.height/this.resolution+"px"}};SystemRenderer.prototype.destroy=function(removeView){if(removeView&&this.view.parentNode){this.view.parentNode.removeChild(this.view)}this.type=CONST.RENDERER_TYPE.UNKNOWN;this.width=0;this.height=0;this.view=null;this.resolution=0;this.transparent=false;this.autoResize=false;this.blendModes=null;this.preserveDrawingBuffer=false;this.clearBeforeRender=false;this.roundPixels=false;this._backgroundColor=0;this._backgroundColorRgb=null;this._backgroundColorString=null}},{"../const":22,"../math":33,"../utils":77,eventemitter3:10}],44:[function(require,module,exports){var SystemRenderer=require("../SystemRenderer"),CanvasMaskManager=require("./utils/CanvasMaskManager"),utils=require("../../utils"),math=require("../../math"),CONST=require("../../const");function CanvasRenderer(width,height,options){options=options||{};SystemRenderer.call(this,"Canvas",width,height,options);this.type=CONST.RENDERER_TYPE.CANVAS;this.context=this.view.getContext("2d",{alpha:this.transparent});this.refresh=true;this.maskManager=new CanvasMaskManager;this.smoothProperty="imageSmoothingEnabled";if(!this.context.imageSmoothingEnabled){if(this.context.webkitImageSmoothingEnabled){this.smoothProperty="webkitImageSmoothingEnabled"}else if(this.context.mozImageSmoothingEnabled){this.smoothProperty="mozImageSmoothingEnabled"}else if(this.context.oImageSmoothingEnabled){this.smoothProperty="oImageSmoothingEnabled"}else if(this.context.msImageSmoothingEnabled){this.smoothProperty="msImageSmoothingEnabled"}}this.initPlugins();this._mapBlendModes();this._tempDisplayObjectParent={worldTransform:new math.Matrix,worldAlpha:1};this.resize(width,height)}CanvasRenderer.prototype=Object.create(SystemRenderer.prototype);CanvasRenderer.prototype.constructor=CanvasRenderer;module.exports=CanvasRenderer;utils.pluginTarget.mixin(CanvasRenderer);CanvasRenderer.prototype.render=function(object){this.emit("prerender");var cacheParent=object.parent;this._lastObjectRendered=object;object.parent=this._tempDisplayObjectParent;object.updateTransform();object.parent=cacheParent;this.context.setTransform(1,0,0,1,0,0);this.context.globalAlpha=1;this.context.globalCompositeOperation=this.blendModes[CONST.BLEND_MODES.NORMAL];if(navigator.isCocoonJS&&this.view.screencanvas){this.context.fillStyle="black";this.context.clear()}if(this.clearBeforeRender){if(this.transparent){this.context.clearRect(0,0,this.width,this.height)}else{this.context.fillStyle=this._backgroundColorString;this.context.fillRect(0,0,this.width,this.height)}}this.renderDisplayObject(object,this.context);this.emit("postrender")};CanvasRenderer.prototype.destroy=function(removeView){this.destroyPlugins();SystemRenderer.prototype.destroy.call(this,removeView);this.context=null;this.refresh=true;this.maskManager.destroy();this.maskManager=null;this.smoothProperty=null};CanvasRenderer.prototype.renderDisplayObject=function(displayObject,context){var tempContext=this.context;this.context=context;displayObject.renderCanvas(this);this.context=tempContext};CanvasRenderer.prototype.resize=function(w,h){SystemRenderer.prototype.resize.call(this,w,h);if(this.smoothProperty){this.context[this.smoothProperty]=CONST.SCALE_MODES.DEFAULT===CONST.SCALE_MODES.LINEAR}};CanvasRenderer.prototype._mapBlendModes=function(){if(!this.blendModes){this.blendModes={};if(utils.canUseNewCanvasBlendModes()){this.blendModes[CONST.BLEND_MODES.NORMAL]="source-over";this.blendModes[CONST.BLEND_MODES.ADD]="lighter";this.blendModes[CONST.BLEND_MODES.MULTIPLY]="multiply";this.blendModes[CONST.BLEND_MODES.SCREEN]="screen";this.blendModes[CONST.BLEND_MODES.OVERLAY]="overlay";this.blendModes[CONST.BLEND_MODES.DARKEN]="darken";this.blendModes[CONST.BLEND_MODES.LIGHTEN]="lighten";this.blendModes[CONST.BLEND_MODES.COLOR_DODGE]="color-dodge";this.blendModes[CONST.BLEND_MODES.COLOR_BURN]="color-burn";this.blendModes[CONST.BLEND_MODES.HARD_LIGHT]="hard-light";this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT]="soft-light";this.blendModes[CONST.BLEND_MODES.DIFFERENCE]="difference";this.blendModes[CONST.BLEND_MODES.EXCLUSION]="exclusion";this.blendModes[CONST.BLEND_MODES.HUE]="hue";this.blendModes[CONST.BLEND_MODES.SATURATION]="saturate";this.blendModes[CONST.BLEND_MODES.COLOR]="color";this.blendModes[CONST.BLEND_MODES.LUMINOSITY]="luminosity"}else{this.blendModes[CONST.BLEND_MODES.NORMAL]="source-over";this.blendModes[CONST.BLEND_MODES.ADD]="lighter";this.blendModes[CONST.BLEND_MODES.MULTIPLY]="source-over";this.blendModes[CONST.BLEND_MODES.SCREEN]="source-over";this.blendModes[CONST.BLEND_MODES.OVERLAY]="source-over";this.blendModes[CONST.BLEND_MODES.DARKEN]="source-over";this.blendModes[CONST.BLEND_MODES.LIGHTEN]="source-over";this.blendModes[CONST.BLEND_MODES.COLOR_DODGE]="source-over";this.blendModes[CONST.BLEND_MODES.COLOR_BURN]="source-over";this.blendModes[CONST.BLEND_MODES.HARD_LIGHT]="source-over";this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT]="source-over";this.blendModes[CONST.BLEND_MODES.DIFFERENCE]="source-over";this.blendModes[CONST.BLEND_MODES.EXCLUSION]="source-over";this.blendModes[CONST.BLEND_MODES.HUE]="source-over";this.blendModes[CONST.BLEND_MODES.SATURATION]="source-over";this.blendModes[CONST.BLEND_MODES.COLOR]="source-over";this.blendModes[CONST.BLEND_MODES.LUMINOSITY]="source-over"}}}},{"../../const":22,"../../math":33,"../../utils":77,"../SystemRenderer":43,"./utils/CanvasMaskManager":47}],45:[function(require,module,exports){function CanvasBuffer(width,height){this.canvas=document.createElement("canvas");this.context=this.canvas.getContext("2d");this.canvas.width=width;this.canvas.height=height}CanvasBuffer.prototype.constructor=CanvasBuffer;module.exports=CanvasBuffer;Object.defineProperties(CanvasBuffer.prototype,{width:{get:function(){return this.canvas.width},set:function(val){this.canvas.width=val}},height:{get:function(){return this.canvas.height},set:function(val){this.canvas.height=val}}});CanvasBuffer.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0);this.context.clearRect(0,0,this.canvas.width,this.canvas.height)};CanvasBuffer.prototype.resize=function(width,height){this.canvas.width=width;this.canvas.height=height};CanvasBuffer.prototype.destroy=function(){this.context=null;this.canvas=null}},{}],46:[function(require,module,exports){var CONST=require("../../../const");var CanvasGraphics={};module.exports=CanvasGraphics;CanvasGraphics.renderGraphics=function(graphics,context){var worldAlpha=graphics.worldAlpha;if(graphics.dirty){this.updateGraphicsTint(graphics);graphics.dirty=false}for(var i=0;i<graphics.graphicsData.length;i++){var data=graphics.graphicsData[i];var shape=data.shape;var fillColor=data._fillTint;var lineColor=data._lineTint;context.lineWidth=data.lineWidth;if(data.type===CONST.SHAPES.POLY){context.beginPath();var points=shape.points;context.moveTo(points[0],points[1]);for(var j=1;j<points.length/2;j++){context.lineTo(points[j*2],points[j*2+1])}if(shape.closed){context.lineTo(points[0],points[1])}if(points[0]===points[points.length-2]&&points[1]===points[points.length-1]){context.closePath()}if(data.fill){context.globalAlpha=data.fillAlpha*worldAlpha;context.fillStyle="#"+("00000"+(fillColor|0).toString(16)).substr(-6);context.fill()}if(data.lineWidth){context.globalAlpha=data.lineAlpha*worldAlpha;context.strokeStyle="#"+("00000"+(lineColor|0).toString(16)).substr(-6);context.stroke()}}else if(data.type===CONST.SHAPES.RECT){if(data.fillColor||data.fillColor===0){context.globalAlpha=data.fillAlpha*worldAlpha;context.fillStyle="#"+("00000"+(fillColor|0).toString(16)).substr(-6);context.fillRect(shape.x,shape.y,shape.width,shape.height)}if(data.lineWidth){context.globalAlpha=data.lineAlpha*worldAlpha;context.strokeStyle="#"+("00000"+(lineColor|0).toString(16)).substr(-6);context.strokeRect(shape.x,shape.y,shape.width,shape.height)}}else if(data.type===CONST.SHAPES.CIRC){context.beginPath();context.arc(shape.x,shape.y,shape.radius,0,2*Math.PI);context.closePath();if(data.fill){context.globalAlpha=data.fillAlpha*worldAlpha;context.fillStyle="#"+("00000"+(fillColor|0).toString(16)).substr(-6);context.fill()}if(data.lineWidth){context.globalAlpha=data.lineAlpha*worldAlpha;context.strokeStyle="#"+("00000"+(lineColor|0).toString(16)).substr(-6);context.stroke()}}else if(data.type===CONST.SHAPES.ELIP){var w=shape.width*2;var h=shape.height*2;var x=shape.x-w/2;var y=shape.y-h/2;context.beginPath();var kappa=.5522848,ox=w/2*kappa,oy=h/2*kappa,xe=x+w,ye=y+h,xm=x+w/2,ym=y+h/2;context.moveTo(x,ym);context.bezierCurveTo(x,ym-oy,xm-ox,y,xm,y);context.bezierCurveTo(xm+ox,y,xe,ym-oy,xe,ym);context.bezierCurveTo(xe,ym+oy,xm+ox,ye,xm,ye);context.bezierCurveTo(xm-ox,ye,x,ym+oy,x,ym);context.closePath();if(data.fill){context.globalAlpha=data.fillAlpha*worldAlpha;context.fillStyle="#"+("00000"+(fillColor|0).toString(16)).substr(-6);context.fill()}if(data.lineWidth){context.globalAlpha=data.lineAlpha*worldAlpha;context.strokeStyle="#"+("00000"+(lineColor|0).toString(16)).substr(-6);context.stroke()}}else if(data.type===CONST.SHAPES.RREC){var rx=shape.x;var ry=shape.y;var width=shape.width;var height=shape.height;var radius=shape.radius;var maxRadius=Math.min(width,height)/2|0;radius=radius>maxRadius?maxRadius:radius;context.beginPath();context.moveTo(rx,ry+radius);context.lineTo(rx,ry+height-radius);context.quadraticCurveTo(rx,ry+height,rx+radius,ry+height);context.lineTo(rx+width-radius,ry+height);context.quadraticCurveTo(rx+width,ry+height,rx+width,ry+height-radius);context.lineTo(rx+width,ry+radius);context.quadraticCurveTo(rx+width,ry,rx+width-radius,ry);context.lineTo(rx+radius,ry);context.quadraticCurveTo(rx,ry,rx,ry+radius);context.closePath();if(data.fillColor||data.fillColor===0){context.globalAlpha=data.fillAlpha*worldAlpha;context.fillStyle="#"+("00000"+(fillColor|0).toString(16)).substr(-6);context.fill()}if(data.lineWidth){context.globalAlpha=data.lineAlpha*worldAlpha;context.strokeStyle="#"+("00000"+(lineColor|0).toString(16)).substr(-6);context.stroke()}}}};CanvasGraphics.renderGraphicsMask=function(graphics,context){var len=graphics.graphicsData.length;if(len===0){return}context.beginPath();for(var i=0;i<len;i++){var data=graphics.graphicsData[i];var shape=data.shape;if(data.type===CONST.SHAPES.POLY){var points=shape.points;context.moveTo(points[0],points[1]);for(var j=1;j<points.length/2;j++){context.lineTo(points[j*2],points[j*2+1])}if(points[0]===points[points.length-2]&&points[1]===points[points.length-1]){context.closePath()}}else if(data.type===CONST.SHAPES.RECT){context.rect(shape.x,shape.y,shape.width,shape.height);context.closePath()}else if(data.type===CONST.SHAPES.CIRC){context.arc(shape.x,shape.y,shape.radius,0,2*Math.PI);context.closePath()}else if(data.type===CONST.SHAPES.ELIP){var w=shape.width*2;var h=shape.height*2;var x=shape.x-w/2;var y=shape.y-h/2;var kappa=.5522848,ox=w/2*kappa,oy=h/2*kappa,xe=x+w,ye=y+h,xm=x+w/2,ym=y+h/2;context.moveTo(x,ym);context.bezierCurveTo(x,ym-oy,xm-ox,y,xm,y);context.bezierCurveTo(xm+ox,y,xe,ym-oy,xe,ym);context.bezierCurveTo(xe,ym+oy,xm+ox,ye,xm,ye);context.bezierCurveTo(xm-ox,ye,x,ym+oy,x,ym);context.closePath()}else if(data.type===CONST.SHAPES.RREC){var rx=shape.x;var ry=shape.y;var width=shape.width;var height=shape.height;var radius=shape.radius;var maxRadius=Math.min(width,height)/2|0;radius=radius>maxRadius?maxRadius:radius;context.moveTo(rx,ry+radius);context.lineTo(rx,ry+height-radius);context.quadraticCurveTo(rx,ry+height,rx+radius,ry+height);context.lineTo(rx+width-radius,ry+height);context.quadraticCurveTo(rx+width,ry+height,rx+width,ry+height-radius);context.lineTo(rx+width,ry+radius);context.quadraticCurveTo(rx+width,ry,rx+width-radius,ry);context.lineTo(rx+radius,ry);context.quadraticCurveTo(rx,ry,rx,ry+radius);context.closePath()}}};CanvasGraphics.updateGraphicsTint=function(graphics){if(graphics.tint===16777215&&graphics._prevTint===graphics.tint){return}graphics._prevTint=graphics.tint;var tintR=(graphics.tint>>16&255)/255;var tintG=(graphics.tint>>8&255)/255;var tintB=(graphics.tint&255)/255;for(var i=0;i<graphics.graphicsData.length;i++){var data=graphics.graphicsData[i];var fillColor=data.fillColor|0;var lineColor=data.lineColor|0;data._fillTint=((fillColor>>16&255)/255*tintR*255<<16)+((fillColor>>8&255)/255*tintG*255<<8)+(fillColor&255)/255*tintB*255;data._lineTint=((lineColor>>16&255)/255*tintR*255<<16)+((lineColor>>8&255)/255*tintG*255<<8)+(lineColor&255)/255*tintB*255}}},{"../../../const":22}],47:[function(require,module,exports){var CanvasGraphics=require("./CanvasGraphics");function CanvasMaskManager(){}CanvasMaskManager.prototype.constructor=CanvasMaskManager;module.exports=CanvasMaskManager;CanvasMaskManager.prototype.pushMask=function(maskData,renderer){renderer.context.save();var cacheAlpha=maskData.alpha;var transform=maskData.worldTransform;var resolution=renderer.resolution;renderer.context.setTransform(transform.a*resolution,transform.b*resolution,transform.c*resolution,transform.d*resolution,transform.tx*resolution,transform.ty*resolution);if(!maskData.texture){CanvasGraphics.renderGraphicsMask(maskData,renderer.context);renderer.context.clip()}maskData.worldAlpha=cacheAlpha};CanvasMaskManager.prototype.popMask=function(renderer){renderer.context.restore()};CanvasMaskManager.prototype.destroy=function(){}},{"./CanvasGraphics":46}],48:[function(require,module,exports){var utils=require("../../../utils");var CanvasTinter={};module.exports=CanvasTinter;CanvasTinter.getTintedTexture=function(sprite,color){var texture=sprite.texture;color=CanvasTinter.roundColor(color);var stringColor="#"+("00000"+(color|0).toString(16)).substr(-6);texture.tintCache=texture.tintCache||{};if(texture.tintCache[stringColor]){return texture.tintCache[stringColor]}var canvas=CanvasTinter.canvas||document.createElement("canvas");CanvasTinter.tintMethod(texture,color,canvas);if(CanvasTinter.convertTintToImage){var tintImage=new Image;tintImage.src=canvas.toDataURL();texture.tintCache[stringColor]=tintImage}else{texture.tintCache[stringColor]=canvas;CanvasTinter.canvas=null}return canvas};CanvasTinter.tintWithMultiply=function(texture,color,canvas){var context=canvas.getContext("2d");var resolution=texture.baseTexture.resolution;var crop=texture.crop.clone();crop.x*=resolution;crop.y*=resolution;crop.width*=resolution;crop.height*=resolution;canvas.width=crop.width;canvas.height=crop.height;context.fillStyle="#"+("00000"+(color|0).toString(16)).substr(-6);context.fillRect(0,0,crop.width,crop.height);context.globalCompositeOperation="multiply";context.drawImage(texture.baseTexture.source,crop.x,crop.y,crop.width,crop.height,0,0,crop.width,crop.height);context.globalCompositeOperation="destination-atop";context.drawImage(texture.baseTexture.source,crop.x,crop.y,crop.width,crop.height,0,0,crop.width,crop.height)};CanvasTinter.tintWithOverlay=function(texture,color,canvas){var context=canvas.getContext("2d");var resolution=texture.baseTexture.resolution;var crop=texture.crop.clone();crop.x*=resolution;crop.y*=resolution;crop.width*=resolution;crop.height*=resolution;canvas.width=crop.width;canvas.height=crop.height;context.globalCompositeOperation="copy";context.fillStyle="#"+("00000"+(color|0).toString(16)).substr(-6);context.fillRect(0,0,crop.width,crop.height);context.globalCompositeOperation="destination-atop";context.drawImage(texture.baseTexture.source,crop.x,crop.y,crop.width,crop.height,0,0,crop.width,crop.height)};CanvasTinter.tintWithPerPixel=function(texture,color,canvas){var context=canvas.getContext("2d");var resolution=texture.baseTexture.resolution;var crop=texture.crop.clone();crop.x*=resolution;crop.y*=resolution;crop.width*=resolution;crop.height*=resolution;canvas.width=crop.width;canvas.height=crop.height;context.globalCompositeOperation="copy";context.drawImage(texture.baseTexture.source,crop.x,crop.y,crop.width,crop.height,0,0,crop.width,crop.height);var rgbValues=utils.hex2rgb(color);var r=rgbValues[0],g=rgbValues[1],b=rgbValues[2];var pixelData=context.getImageData(0,0,crop.width,crop.height);var pixels=pixelData.data;for(var i=0;i<pixels.length;i+=4){pixels[i+0]*=r;pixels[i+1]*=g;pixels[i+2]*=b}context.putImageData(pixelData,0,0)};CanvasTinter.roundColor=function(color){var step=CanvasTinter.cacheStepsPerColorChannel;var rgbValues=utils.hex2rgb(color);rgbValues[0]=Math.min(255,rgbValues[0]/step*step);rgbValues[1]=Math.min(255,rgbValues[1]/step*step);rgbValues[2]=Math.min(255,rgbValues[2]/step*step);return utils.rgb2hex(rgbValues)};CanvasTinter.cacheStepsPerColorChannel=8;CanvasTinter.convertTintToImage=false;CanvasTinter.canUseMultiply=utils.canUseNewCanvasBlendModes();CanvasTinter.tintMethod=CanvasTinter.canUseMultiply?CanvasTinter.tintWithMultiply:CanvasTinter.tintWithPerPixel},{"../../../utils":77}],49:[function(require,module,exports){var SystemRenderer=require("../SystemRenderer"),ShaderManager=require("./managers/ShaderManager"),MaskManager=require("./managers/MaskManager"),StencilManager=require("./managers/StencilManager"),FilterManager=require("./managers/FilterManager"),BlendModeManager=require("./managers/BlendModeManager"),RenderTarget=require("./utils/RenderTarget"),ObjectRenderer=require("./utils/ObjectRenderer"),FXAAFilter=require("./filters/FXAAFilter"),utils=require("../../utils"),CONST=require("../../const");function WebGLRenderer(width,height,options){options=options||{};SystemRenderer.call(this,"WebGL",width,height,options);this.type=CONST.RENDERER_TYPE.WEBGL;this.handleContextLost=this.handleContextLost.bind(this);this.handleContextRestored=this.handleContextRestored.bind(this);this.view.addEventListener("webglcontextlost",this.handleContextLost,false);this.view.addEventListener("webglcontextrestored",this.handleContextRestored,false);this._useFXAA=!!options.forceFXAA&&options.antialias;this._FXAAFilter=null;this._contextOptions={alpha:this.transparent,antialias:options.antialias,premultipliedAlpha:this.transparent&&this.transparent!=="notMultiplied",stencil:true,preserveDrawingBuffer:options.preserveDrawingBuffer};this.drawCount=0;this.shaderManager=new ShaderManager(this);this.maskManager=new MaskManager(this);this.stencilManager=new StencilManager(this);this.filterManager=new FilterManager(this);this.blendModeManager=new BlendModeManager(this);this.currentRenderTarget=null;this.currentRenderer=new ObjectRenderer(this);this.initPlugins();this._createContext();this._initContext();this._mapGlModes();this._managedTextures=[];this._renderTargetStack=[]}WebGLRenderer.prototype=Object.create(SystemRenderer.prototype);WebGLRenderer.prototype.constructor=WebGLRenderer;module.exports=WebGLRenderer;utils.pluginTarget.mixin(WebGLRenderer);WebGLRenderer.glContextId=0;WebGLRenderer.prototype._createContext=function(){var gl=this.view.getContext("webgl",this._contextOptions)||this.view.getContext("experimental-webgl",this._contextOptions);this.gl=gl;if(!gl){throw new Error("This browser does not support webGL. Try using the canvas renderer")}this.glContextId=WebGLRenderer.glContextId++;gl.id=this.glContextId;gl.renderer=this};WebGLRenderer.prototype._initContext=function(){var gl=this.gl;gl.disable(gl.DEPTH_TEST);gl.disable(gl.CULL_FACE);gl.enable(gl.BLEND);this.renderTarget=new RenderTarget(gl,this.width,this.height,null,this.resolution,true);this.setRenderTarget(this.renderTarget);this.emit("context",gl);this.resize(this.width,this.height);if(!this._useFXAA){this._useFXAA=this._contextOptions.antialias&&!gl.getContextAttributes().antialias}if(this._useFXAA){window.console.warn("FXAA antialiasing being used instead of native antialiasing");this._FXAAFilter=[new FXAAFilter]}};WebGLRenderer.prototype.render=function(object){this.emit("prerender");if(this.gl.isContextLost()){return}this.drawCount=0;this._lastObjectRendered=object;if(this._useFXAA){this._FXAAFilter[0].uniforms.resolution.value.x=this.width;this._FXAAFilter[0].uniforms.resolution.value.y=this.height;object.filterArea=this.renderTarget.size;object.filters=this._FXAAFilter}var cacheParent=object.parent;object.parent=this._tempDisplayObjectParent;object.updateTransform();object.parent=cacheParent;var gl=this.gl;this.setRenderTarget(this.renderTarget);if(this.clearBeforeRender){if(this.transparent){gl.clearColor(0,0,0,0)}else{gl.clearColor(this._backgroundColorRgb[0],this._backgroundColorRgb[1],this._backgroundColorRgb[2],1)}gl.clear(gl.COLOR_BUFFER_BIT)}this.renderDisplayObject(object,this.renderTarget);this.emit("postrender")};WebGLRenderer.prototype.renderDisplayObject=function(displayObject,renderTarget,clear){this.setRenderTarget(renderTarget);if(clear){renderTarget.clear()}this.filterManager.setFilterStack(renderTarget.filterStack);displayObject.renderWebGL(this);this.currentRenderer.flush()};WebGLRenderer.prototype.setObjectRenderer=function(objectRenderer){if(this.currentRenderer===objectRenderer){return}this.currentRenderer.stop();this.currentRenderer=objectRenderer;this.currentRenderer.start()};WebGLRenderer.prototype.setRenderTarget=function(renderTarget){if(this.currentRenderTarget===renderTarget){return}this.currentRenderTarget=renderTarget;this.currentRenderTarget.activate();this.stencilManager.setMaskStack(renderTarget.stencilMaskStack)};WebGLRenderer.prototype.resize=function(width,height){SystemRenderer.prototype.resize.call(this,width,height);this.filterManager.resize(width,height);this.renderTarget.resize(width,height);if(this.currentRenderTarget===this.renderTarget){this.renderTarget.activate();this.gl.viewport(0,0,this.width,this.height)}};WebGLRenderer.prototype.updateTexture=function(texture){texture=texture.baseTexture||texture;if(!texture.hasLoaded){return}var gl=this.gl;if(!texture._glTextures[gl.id]){texture._glTextures[gl.id]=gl.createTexture();texture.on("update",this.updateTexture,this);texture.on("dispose",this.destroyTexture,this);this._managedTextures.push(texture)}gl.bindTexture(gl.TEXTURE_2D,texture._glTextures[gl.id]);gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,texture.premultipliedAlpha);gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,texture.source);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,texture.scaleMode===CONST.SCALE_MODES.LINEAR?gl.LINEAR:gl.NEAREST);if(texture.mipmap&&texture.isPowerOfTwo){gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,texture.scaleMode===CONST.SCALE_MODES.LINEAR?gl.LINEAR_MIPMAP_LINEAR:gl.NEAREST_MIPMAP_NEAREST);gl.generateMipmap(gl.TEXTURE_2D)}else{gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,texture.scaleMode===CONST.SCALE_MODES.LINEAR?gl.LINEAR:gl.NEAREST)}if(!texture.isPowerOfTwo){gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE)}else{gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.REPEAT);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.REPEAT)}return texture._glTextures[gl.id]};WebGLRenderer.prototype.destroyTexture=function(texture,_skipRemove){texture=texture.baseTexture||texture;if(!texture.hasLoaded){return}if(texture._glTextures[this.gl.id]){this.gl.deleteTexture(texture._glTextures[this.gl.id]);delete texture._glTextures[this.gl.id];if(!_skipRemove){var i=this._managedTextures.indexOf(texture);if(i!==-1){utils.removeItems(this._managedTextures,i,1)}}}};WebGLRenderer.prototype.handleContextLost=function(event){event.preventDefault()};WebGLRenderer.prototype.handleContextRestored=function(){this._initContext();for(var i=0;i<this._managedTextures.length;++i){var texture=this._managedTextures[i];if(texture._glTextures[this.gl.id]){delete texture._glTextures[this.gl.id]}}};WebGLRenderer.prototype.destroy=function(removeView){this.destroyPlugins();this.view.removeEventListener("webglcontextlost",this.handleContextLost);this.view.removeEventListener("webglcontextrestored",this.handleContextRestored);for(var i=0;i<this._managedTextures.length;++i){var texture=this._managedTextures[i];this.destroyTexture(texture,true);texture.off("update",this.updateTexture,this);texture.off("dispose",this.destroyTexture,this)}SystemRenderer.prototype.destroy.call(this,removeView);this.uid=0;this.shaderManager.destroy();this.maskManager.destroy();this.stencilManager.destroy();this.filterManager.destroy();this.blendModeManager.destroy();this.shaderManager=null;this.maskManager=null;this.filterManager=null;this.blendModeManager=null;this.currentRenderer=null;this.handleContextLost=null;this.handleContextRestored=null;this._contextOptions=null;this._managedTextures=null;this.drawCount=0;this.gl.useProgram(null);this.gl.flush();this.gl=null};WebGLRenderer.prototype._mapGlModes=function(){var gl=this.gl;if(!this.blendModes){this.blendModes={};this.blendModes[CONST.BLEND_MODES.NORMAL]=[gl.ONE,gl.ONE_MINUS_SRC_ALPHA];this.blendModes[CONST.BLEND_MODES.ADD]=[gl.ONE,gl.DST_ALPHA];this.blendModes[CONST.BLEND_MODES.MULTIPLY]=[gl.DST_COLOR,gl.ONE_MINUS_SRC_ALPHA];this.blendModes[CONST.BLEND_MODES.SCREEN]=[gl.ONE,gl.ONE_MINUS_SRC_COLOR];this.blendModes[CONST.BLEND_MODES.OVERLAY]=[gl.ONE,gl.ONE_MINUS_SRC_ALPHA];this.blendModes[CONST.BLEND_MODES.DARKEN]=[gl.ONE,gl.ONE_MINUS_SRC_ALPHA];this.blendModes[CONST.BLEND_MODES.LIGHTEN]=[gl.ONE,gl.ONE_MINUS_SRC_ALPHA];this.blendModes[CONST.BLEND_MODES.COLOR_DODGE]=[gl.ONE,gl.ONE_MINUS_SRC_ALPHA];this.blendModes[CONST.BLEND_MODES.COLOR_BURN]=[gl.ONE,gl.ONE_MINUS_SRC_ALPHA];this.blendModes[CONST.BLEND_MODES.HARD_LIGHT]=[gl.ONE,gl.ONE_MINUS_SRC_ALPHA];this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT]=[gl.ONE,gl.ONE_MINUS_SRC_ALPHA];this.blendModes[CONST.BLEND_MODES.DIFFERENCE]=[gl.ONE,gl.ONE_MINUS_SRC_ALPHA];
  7. this.blendModes[CONST.BLEND_MODES.EXCLUSION]=[gl.ONE,gl.ONE_MINUS_SRC_ALPHA];this.blendModes[CONST.BLEND_MODES.HUE]=[gl.ONE,gl.ONE_MINUS_SRC_ALPHA];this.blendModes[CONST.BLEND_MODES.SATURATION]=[gl.ONE,gl.ONE_MINUS_SRC_ALPHA];this.blendModes[CONST.BLEND_MODES.COLOR]=[gl.ONE,gl.ONE_MINUS_SRC_ALPHA];this.blendModes[CONST.BLEND_MODES.LUMINOSITY]=[gl.ONE,gl.ONE_MINUS_SRC_ALPHA]}if(!this.drawModes){this.drawModes={};this.drawModes[CONST.DRAW_MODES.POINTS]=gl.POINTS;this.drawModes[CONST.DRAW_MODES.LINES]=gl.LINES;this.drawModes[CONST.DRAW_MODES.LINE_LOOP]=gl.LINE_LOOP;this.drawModes[CONST.DRAW_MODES.LINE_STRIP]=gl.LINE_STRIP;this.drawModes[CONST.DRAW_MODES.TRIANGLES]=gl.TRIANGLES;this.drawModes[CONST.DRAW_MODES.TRIANGLE_STRIP]=gl.TRIANGLE_STRIP;this.drawModes[CONST.DRAW_MODES.TRIANGLE_FAN]=gl.TRIANGLE_FAN}}},{"../../const":22,"../../utils":77,"../SystemRenderer":43,"./filters/FXAAFilter":51,"./managers/BlendModeManager":53,"./managers/FilterManager":54,"./managers/MaskManager":55,"./managers/ShaderManager":56,"./managers/StencilManager":57,"./utils/ObjectRenderer":63,"./utils/RenderTarget":65}],50:[function(require,module,exports){var DefaultShader=require("../shaders/TextureShader");function AbstractFilter(vertexSrc,fragmentSrc,uniforms){this.shaders=[];this.padding=0;this.uniforms=uniforms||{};this.vertexSrc=vertexSrc||DefaultShader.defaultVertexSrc;this.fragmentSrc=fragmentSrc||DefaultShader.defaultFragmentSrc}AbstractFilter.prototype.constructor=AbstractFilter;module.exports=AbstractFilter;AbstractFilter.prototype.getShader=function(renderer){var gl=renderer.gl;var shader=this.shaders[gl.id];if(!shader){shader=new DefaultShader(renderer.shaderManager,this.vertexSrc,this.fragmentSrc,this.uniforms,this.attributes);this.shaders[gl.id]=shader}return shader};AbstractFilter.prototype.applyFilter=function(renderer,input,output,clear){var shader=this.getShader(renderer);renderer.filterManager.applyFilter(shader,input,output,clear)};AbstractFilter.prototype.syncUniform=function(uniform){for(var i=0,j=this.shaders.length;i<j;++i){this.shaders[i].syncUniform(uniform)}}},{"../shaders/TextureShader":62}],51:[function(require,module,exports){var AbstractFilter=require("./AbstractFilter");function FXAAFilter(){AbstractFilter.call(this,"\nprecision mediump float;\n\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform mat3 projectionMatrix;\nuniform vec2 resolution;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nvarying vec2 vResolution;\n\n//texcoords computed in vertex step\n//to avoid dependent texture reads\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\n\nvoid texcoords(vec2 fragCoord, vec2 resolution,\n out vec2 v_rgbNW, out vec2 v_rgbNE,\n out vec2 v_rgbSW, out vec2 v_rgbSE,\n out vec2 v_rgbM) {\n vec2 inverseVP = 1.0 / resolution.xy;\n v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\n v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\n v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\n v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\n v_rgbM = vec2(fragCoord * inverseVP);\n}\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n vResolution = resolution;\n\n //compute the texture coords and send them to varyings\n texcoords(aTextureCoord * resolution, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}\n",'precision lowp float;\n\n\n/**\nBasic FXAA implementation based on the code on geeks3d.com with the\nmodification that the texture2DLod stuff was removed since it\'s\nunsupported by WebGL.\n\n--\n\nFrom:\nhttps://github.com/mitsuhiko/webgl-meincraft\n\nCopyright (c) 2011 by Armin Ronacher.\n\nSome rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n\n * Redistributions in binary form must reproduce the above\n copyright notice, this list of conditions and the following\n disclaimer in the documentation and/or other materials provided\n with the distribution.\n\n * The names of the contributors may not be used to endorse or\n promote products derived from this software without specific\n prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef FXAA_REDUCE_MIN\n #define FXAA_REDUCE_MIN (1.0/ 128.0)\n#endif\n#ifndef FXAA_REDUCE_MUL\n #define FXAA_REDUCE_MUL (1.0 / 8.0)\n#endif\n#ifndef FXAA_SPAN_MAX\n #define FXAA_SPAN_MAX 8.0\n#endif\n\n//optimized version for mobile, where dependent\n//texture reads can be a bottleneck\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,\n vec2 v_rgbNW, vec2 v_rgbNE,\n vec2 v_rgbSW, vec2 v_rgbSE,\n vec2 v_rgbM) {\n vec4 color;\n mediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\n vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;\n vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;\n vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;\n vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;\n vec4 texColor = texture2D(tex, v_rgbM);\n vec3 rgbM = texColor.xyz;\n vec3 luma = vec3(0.299, 0.587, 0.114);\n float lumaNW = dot(rgbNW, luma);\n float lumaNE = dot(rgbNE, luma);\n float lumaSW = dot(rgbSW, luma);\n float lumaSE = dot(rgbSE, luma);\n float lumaM = dot(rgbM, luma);\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n mediump vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * inverseVP;\n\n vec3 rgbA = 0.5 * (\n texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\n vec3 rgbB = rgbA * 0.5 + 0.25 * (\n texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\n\n float lumaB = dot(rgbB, luma);\n if ((lumaB < lumaMin) || (lumaB > lumaMax))\n color = vec4(rgbA, texColor.a);\n else\n color = vec4(rgbB, texColor.a);\n return color;\n}\n\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying vec2 vResolution;\n\n//texcoords computed in vertex step\n//to avoid dependent texture reads\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\nuniform sampler2D uSampler;\n\n\nvoid main(void){\n\n gl_FragColor = fxaa(uSampler, vTextureCoord * vResolution, vResolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n\n}\n',{resolution:{type:"v2",value:{x:1,y:1}}})}FXAAFilter.prototype=Object.create(AbstractFilter.prototype);FXAAFilter.prototype.constructor=FXAAFilter;module.exports=FXAAFilter;FXAAFilter.prototype.applyFilter=function(renderer,input,output){var filterManager=renderer.filterManager;var shader=this.getShader(renderer);filterManager.applyFilter(shader,input,output)}},{"./AbstractFilter":50}],52:[function(require,module,exports){var AbstractFilter=require("./AbstractFilter"),math=require("../../../math");function SpriteMaskFilter(sprite){var maskMatrix=new math.Matrix;AbstractFilter.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;\n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}\n","precision lowp float;\n\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform sampler2D uSampler;\nuniform float alpha;\nuniform sampler2D mask;\n\nvoid main(void)\n{\n // check clip! this will stop the mask bleeding out from the edges\n vec2 text = abs( vMaskCoord - 0.5 );\n text = step(0.5, text);\n float clip = 1.0 - max(text.y, text.x);\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, vMaskCoord);\n original *= (masky.r * masky.a * alpha * clip);\n gl_FragColor = original;\n}\n",{mask:{type:"sampler2D",value:sprite._texture},alpha:{type:"f",value:1},otherMatrix:{type:"mat3",value:maskMatrix.toArray(true)}});this.maskSprite=sprite;this.maskMatrix=maskMatrix}SpriteMaskFilter.prototype=Object.create(AbstractFilter.prototype);SpriteMaskFilter.prototype.constructor=SpriteMaskFilter;module.exports=SpriteMaskFilter;SpriteMaskFilter.prototype.applyFilter=function(renderer,input,output){var filterManager=renderer.filterManager;this.uniforms.mask.value=this.maskSprite._texture;filterManager.calculateMappedMatrix(input.frame,this.maskSprite,this.maskMatrix);this.uniforms.otherMatrix.value=this.maskMatrix.toArray(true);this.uniforms.alpha.value=this.maskSprite.worldAlpha;var shader=this.getShader(renderer);filterManager.applyFilter(shader,input,output)};Object.defineProperties(SpriteMaskFilter.prototype,{map:{get:function(){return this.uniforms.mask.value},set:function(value){this.uniforms.mask.value=value}},offset:{get:function(){return this.uniforms.offset.value},set:function(value){this.uniforms.offset.value=value}}})},{"../../../math":33,"./AbstractFilter":50}],53:[function(require,module,exports){var WebGLManager=require("./WebGLManager");function BlendModeManager(renderer){WebGLManager.call(this,renderer);this.currentBlendMode=99999}BlendModeManager.prototype=Object.create(WebGLManager.prototype);BlendModeManager.prototype.constructor=BlendModeManager;module.exports=BlendModeManager;BlendModeManager.prototype.setBlendMode=function(blendMode){if(this.currentBlendMode===blendMode){return false}this.currentBlendMode=blendMode;var mode=this.renderer.blendModes[this.currentBlendMode];this.renderer.gl.blendFunc(mode[0],mode[1]);return true}},{"./WebGLManager":58}],54:[function(require,module,exports){var WebGLManager=require("./WebGLManager"),RenderTarget=require("../utils/RenderTarget"),CONST=require("../../../const"),Quad=require("../utils/Quad"),math=require("../../../math");function FilterManager(renderer){WebGLManager.call(this,renderer);this.filterStack=[];this.filterStack.push({renderTarget:renderer.currentRenderTarget,filter:[],bounds:null});this.texturePool=[];this.textureSize=new math.Rectangle(0,0,renderer.width,renderer.height);this.currentFrame=null}FilterManager.prototype=Object.create(WebGLManager.prototype);FilterManager.prototype.constructor=FilterManager;module.exports=FilterManager;FilterManager.prototype.onContextChange=function(){this.texturePool.length=0;var gl=this.renderer.gl;this.quad=new Quad(gl)};FilterManager.prototype.setFilterStack=function(filterStack){this.filterStack=filterStack};FilterManager.prototype.pushFilter=function(target,filters){var bounds=target.filterArea?target.filterArea.clone():target.getBounds();bounds.x=bounds.x|0;bounds.y=bounds.y|0;bounds.width=bounds.width|0;bounds.height=bounds.height|0;var padding=filters[0].padding|0;bounds.x-=padding;bounds.y-=padding;bounds.width+=padding*2;bounds.height+=padding*2;if(this.renderer.currentRenderTarget.transform){var transform=this.renderer.currentRenderTarget.transform;bounds.x+=transform.tx;bounds.y+=transform.ty;this.capFilterArea(bounds);bounds.x-=transform.tx;bounds.y-=transform.ty}else{this.capFilterArea(bounds)}if(bounds.width>0&&bounds.height>0){this.currentFrame=bounds;var texture=this.getRenderTarget();this.renderer.setRenderTarget(texture);texture.clear();this.filterStack.push({renderTarget:texture,filter:filters})}else{this.filterStack.push({renderTarget:null,filter:filters})}};FilterManager.prototype.popFilter=function(){var filterData=this.filterStack.pop();var previousFilterData=this.filterStack[this.filterStack.length-1];var input=filterData.renderTarget;if(!filterData.renderTarget){return}var output=previousFilterData.renderTarget;var gl=this.renderer.gl;this.currentFrame=input.frame;this.quad.map(this.textureSize,input.frame);gl.bindBuffer(gl.ARRAY_BUFFER,this.quad.vertexBuffer);gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,this.quad.indexBuffer);var filters=filterData.filter;gl.vertexAttribPointer(this.renderer.shaderManager.defaultShader.attributes.aVertexPosition,2,gl.FLOAT,false,0,0);gl.vertexAttribPointer(this.renderer.shaderManager.defaultShader.attributes.aTextureCoord,2,gl.FLOAT,false,0,2*4*4);gl.vertexAttribPointer(this.renderer.shaderManager.defaultShader.attributes.aColor,4,gl.FLOAT,false,0,4*4*4);this.renderer.blendModeManager.setBlendMode(CONST.BLEND_MODES.NORMAL);if(filters.length===1){if(filters[0].uniforms.dimensions){filters[0].uniforms.dimensions.value[0]=this.renderer.width;filters[0].uniforms.dimensions.value[1]=this.renderer.height;filters[0].uniforms.dimensions.value[2]=this.quad.vertices[0];filters[0].uniforms.dimensions.value[3]=this.quad.vertices[5]}filters[0].applyFilter(this.renderer,input,output);this.returnRenderTarget(input)}else{var flipTexture=input;var flopTexture=this.getRenderTarget(true);for(var i=0;i<filters.length-1;i++){var filter=filters[i];if(filter.uniforms.dimensions){filter.uniforms.dimensions.value[0]=this.renderer.width;filter.uniforms.dimensions.value[1]=this.renderer.height;filter.uniforms.dimensions.value[2]=this.quad.vertices[0];filter.uniforms.dimensions.value[3]=this.quad.vertices[5]}filter.applyFilter(this.renderer,flipTexture,flopTexture);var temp=flipTexture;flipTexture=flopTexture;flopTexture=temp}filters[filters.length-1].applyFilter(this.renderer,flipTexture,output);this.returnRenderTarget(flipTexture);this.returnRenderTarget(flopTexture)}return filterData.filter};FilterManager.prototype.getRenderTarget=function(clear){var renderTarget=this.texturePool.pop()||new RenderTarget(this.renderer.gl,this.textureSize.width,this.textureSize.height,CONST.SCALE_MODES.LINEAR,this.renderer.resolution*CONST.FILTER_RESOLUTION);renderTarget.frame=this.currentFrame;if(clear){renderTarget.clear(true)}return renderTarget};FilterManager.prototype.returnRenderTarget=function(renderTarget){this.texturePool.push(renderTarget)};FilterManager.prototype.applyFilter=function(shader,inputTarget,outputTarget,clear){var gl=this.renderer.gl;this.renderer.setRenderTarget(outputTarget);if(clear){outputTarget.clear()}this.renderer.shaderManager.setShader(shader);shader.uniforms.projectionMatrix.value=this.renderer.currentRenderTarget.projectionMatrix.toArray(true);shader.syncUniforms();gl.activeTexture(gl.TEXTURE0);gl.bindTexture(gl.TEXTURE_2D,inputTarget.texture);gl.drawElements(gl.TRIANGLES,6,gl.UNSIGNED_SHORT,0);this.renderer.drawCount++};FilterManager.prototype.calculateMappedMatrix=function(filterArea,sprite,outputMatrix){var worldTransform=sprite.worldTransform.copy(math.Matrix.TEMP_MATRIX),texture=sprite._texture.baseTexture;var mappedMatrix=outputMatrix.identity();var ratio=this.textureSize.height/this.textureSize.width;mappedMatrix.translate(filterArea.x/this.textureSize.width,filterArea.y/this.textureSize.height);mappedMatrix.scale(1,ratio);var translateScaleX=this.textureSize.width/texture.width;var translateScaleY=this.textureSize.height/texture.height;worldTransform.tx/=texture.width*translateScaleX;worldTransform.ty/=texture.width*translateScaleX;worldTransform.invert();mappedMatrix.prepend(worldTransform);mappedMatrix.scale(1,1/ratio);mappedMatrix.scale(translateScaleX,translateScaleY);mappedMatrix.translate(sprite.anchor.x,sprite.anchor.y);return mappedMatrix};FilterManager.prototype.capFilterArea=function(filterArea){if(filterArea.x<0){filterArea.width+=filterArea.x;filterArea.x=0}if(filterArea.y<0){filterArea.height+=filterArea.y;filterArea.y=0}if(filterArea.x+filterArea.width>this.textureSize.width){filterArea.width=this.textureSize.width-filterArea.x}if(filterArea.y+filterArea.height>this.textureSize.height){filterArea.height=this.textureSize.height-filterArea.y}};FilterManager.prototype.resize=function(width,height){this.textureSize.width=width;this.textureSize.height=height;for(var i=0;i<this.texturePool.length;i++){this.texturePool[i].resize(width,height)}};FilterManager.prototype.destroy=function(){this.quad.destroy();WebGLManager.prototype.destroy.call(this);this.filterStack=null;this.offsetY=0;for(var i=0;i<this.texturePool.length;i++){this.texturePool[i].destroy()}this.texturePool=null}},{"../../../const":22,"../../../math":33,"../utils/Quad":64,"../utils/RenderTarget":65,"./WebGLManager":58}],55:[function(require,module,exports){var WebGLManager=require("./WebGLManager"),AlphaMaskFilter=require("../filters/SpriteMaskFilter");function MaskManager(renderer){WebGLManager.call(this,renderer);this.stencilStack=[];this.reverse=true;this.count=0;this.alphaMaskPool=[]}MaskManager.prototype=Object.create(WebGLManager.prototype);MaskManager.prototype.constructor=MaskManager;module.exports=MaskManager;MaskManager.prototype.pushMask=function(target,maskData){if(maskData.texture){this.pushSpriteMask(target,maskData)}else{this.pushStencilMask(target,maskData)}};MaskManager.prototype.popMask=function(target,maskData){if(maskData.texture){this.popSpriteMask(target,maskData)}else{this.popStencilMask(target,maskData)}};MaskManager.prototype.pushSpriteMask=function(target,maskData){var alphaMaskFilter=this.alphaMaskPool.pop();if(!alphaMaskFilter){alphaMaskFilter=[new AlphaMaskFilter(maskData)]}alphaMaskFilter[0].maskSprite=maskData;this.renderer.filterManager.pushFilter(target,alphaMaskFilter)};MaskManager.prototype.popSpriteMask=function(){var filters=this.renderer.filterManager.popFilter();this.alphaMaskPool.push(filters)};MaskManager.prototype.pushStencilMask=function(target,maskData){this.renderer.stencilManager.pushMask(maskData)};MaskManager.prototype.popStencilMask=function(target,maskData){this.renderer.stencilManager.popMask(maskData)}},{"../filters/SpriteMaskFilter":52,"./WebGLManager":58}],56:[function(require,module,exports){var WebGLManager=require("./WebGLManager"),TextureShader=require("../shaders/TextureShader"),ComplexPrimitiveShader=require("../shaders/ComplexPrimitiveShader"),PrimitiveShader=require("../shaders/PrimitiveShader"),utils=require("../../../utils");function ShaderManager(renderer){WebGLManager.call(this,renderer);this.maxAttibs=10;this.attribState=[];this.tempAttribState=[];for(var i=0;i<this.maxAttibs;i++){this.attribState[i]=false}this.stack=[];this._currentId=-1;this.currentShader=null}ShaderManager.prototype=Object.create(WebGLManager.prototype);ShaderManager.prototype.constructor=ShaderManager;utils.pluginTarget.mixin(ShaderManager);module.exports=ShaderManager;ShaderManager.prototype.onContextChange=function(){this.initPlugins();var gl=this.renderer.gl;this.maxAttibs=gl.getParameter(gl.MAX_VERTEX_ATTRIBS);this.attribState=[];for(var i=0;i<this.maxAttibs;i++){this.attribState[i]=false}this.defaultShader=new TextureShader(this);this.primitiveShader=new PrimitiveShader(this);this.complexPrimitiveShader=new ComplexPrimitiveShader(this)};ShaderManager.prototype.setAttribs=function(attribs){var i;for(i=0;i<this.tempAttribState.length;i++){this.tempAttribState[i]=false}for(var a in attribs){this.tempAttribState[attribs[a]]=true}var gl=this.renderer.gl;for(i=0;i<this.attribState.length;i++){if(this.attribState[i]!==this.tempAttribState[i]){this.attribState[i]=this.tempAttribState[i];if(this.attribState[i]){gl.enableVertexAttribArray(i)}else{gl.disableVertexAttribArray(i)}}}};ShaderManager.prototype.setShader=function(shader){if(this._currentId===shader.uid){return false}this._currentId=shader.uid;this.currentShader=shader;this.renderer.gl.useProgram(shader.program);this.setAttribs(shader.attributes);return true};ShaderManager.prototype.destroy=function(){this.primitiveShader.destroy();this.complexPrimitiveShader.destroy();WebGLManager.prototype.destroy.call(this);this.destroyPlugins();this.attribState=null;this.tempAttribState=null}},{"../../../utils":77,"../shaders/ComplexPrimitiveShader":59,"../shaders/PrimitiveShader":60,"../shaders/TextureShader":62,"./WebGLManager":58}],57:[function(require,module,exports){var WebGLManager=require("./WebGLManager"),utils=require("../../../utils");function WebGLMaskManager(renderer){WebGLManager.call(this,renderer);this.stencilMaskStack=null}WebGLMaskManager.prototype=Object.create(WebGLManager.prototype);WebGLMaskManager.prototype.constructor=WebGLMaskManager;module.exports=WebGLMaskManager;WebGLMaskManager.prototype.setMaskStack=function(stencilMaskStack){this.stencilMaskStack=stencilMaskStack;var gl=this.renderer.gl;if(stencilMaskStack.stencilStack.length===0){gl.disable(gl.STENCIL_TEST)}else{gl.enable(gl.STENCIL_TEST)}};WebGLMaskManager.prototype.pushStencil=function(graphics,webGLData){this.renderer.currentRenderTarget.attachStencilBuffer();var gl=this.renderer.gl,sms=this.stencilMaskStack;this.bindGraphics(graphics,webGLData);if(sms.stencilStack.length===0){gl.enable(gl.STENCIL_TEST);gl.clear(gl.STENCIL_BUFFER_BIT);sms.reverse=true;sms.count=0}sms.stencilStack.push(webGLData);var level=sms.count;gl.colorMask(false,false,false,false);gl.stencilFunc(gl.ALWAYS,0,255);gl.stencilOp(gl.KEEP,gl.KEEP,gl.INVERT);if(webGLData.mode===1){gl.drawElements(gl.TRIANGLE_FAN,webGLData.indices.length-4,gl.UNSIGNED_SHORT,0);if(sms.reverse){gl.stencilFunc(gl.EQUAL,255-level,255);gl.stencilOp(gl.KEEP,gl.KEEP,gl.DECR)}else{gl.stencilFunc(gl.EQUAL,level,255);gl.stencilOp(gl.KEEP,gl.KEEP,gl.INCR)}gl.drawElements(gl.TRIANGLE_FAN,4,gl.UNSIGNED_SHORT,(webGLData.indices.length-4)*2);if(sms.reverse){gl.stencilFunc(gl.EQUAL,255-(level+1),255)}else{gl.stencilFunc(gl.EQUAL,level+1,255)}sms.reverse=!sms.reverse}else{if(!sms.reverse){gl.stencilFunc(gl.EQUAL,255-level,255);gl.stencilOp(gl.KEEP,gl.KEEP,gl.DECR)}else{gl.stencilFunc(gl.EQUAL,level,255);gl.stencilOp(gl.KEEP,gl.KEEP,gl.INCR)}gl.drawElements(gl.TRIANGLE_STRIP,webGLData.indices.length,gl.UNSIGNED_SHORT,0);if(!sms.reverse){gl.stencilFunc(gl.EQUAL,255-(level+1),255)}else{gl.stencilFunc(gl.EQUAL,level+1,255)}}gl.colorMask(true,true,true,true);gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP);sms.count++};WebGLMaskManager.prototype.bindGraphics=function(graphics,webGLData){var gl=this.renderer.gl;var shader;if(webGLData.mode===1){shader=this.renderer.shaderManager.complexPrimitiveShader;this.renderer.shaderManager.setShader(shader);gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location,false,graphics.worldTransform.toArray(true));gl.uniformMatrix3fv(shader.uniforms.projectionMatrix._location,false,this.renderer.currentRenderTarget.projectionMatrix.toArray(true));gl.uniform3fv(shader.uniforms.tint._location,utils.hex2rgb(graphics.tint));gl.uniform3fv(shader.uniforms.color._location,webGLData.color);gl.uniform1f(shader.uniforms.alpha._location,graphics.worldAlpha);gl.bindBuffer(gl.ARRAY_BUFFER,webGLData.buffer);gl.vertexAttribPointer(shader.attributes.aVertexPosition,2,gl.FLOAT,false,4*2,0);gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,webGLData.indexBuffer)}else{shader=this.renderer.shaderManager.primitiveShader;this.renderer.shaderManager.setShader(shader);gl.uniformMatrix3fv(shader.uniforms.translationMatrix._location,false,graphics.worldTransform.toArray(true));gl.uniformMatrix3fv(shader.uniforms.projectionMatrix._location,false,this.renderer.currentRenderTarget.projectionMatrix.toArray(true));gl.uniform3fv(shader.uniforms.tint._location,utils.hex2rgb(graphics.tint));gl.uniform1f(shader.uniforms.alpha._location,graphics.worldAlpha);gl.bindBuffer(gl.ARRAY_BUFFER,webGLData.buffer);gl.vertexAttribPointer(shader.attributes.aVertexPosition,2,gl.FLOAT,false,4*6,0);gl.vertexAttribPointer(shader.attributes.aColor,4,gl.FLOAT,false,4*6,2*4);gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,webGLData.indexBuffer)}};WebGLMaskManager.prototype.popStencil=function(graphics,webGLData){var gl=this.renderer.gl,sms=this.stencilMaskStack;sms.stencilStack.pop();sms.count--;if(sms.stencilStack.length===0){gl.disable(gl.STENCIL_TEST)}else{var level=sms.count;this.bindGraphics(graphics,webGLData);gl.colorMask(false,false,false,false);if(webGLData.mode===1){sms.reverse=!sms.reverse;if(sms.reverse){gl.stencilFunc(gl.EQUAL,255-(level+1),255);gl.stencilOp(gl.KEEP,gl.KEEP,gl.INCR)}else{gl.stencilFunc(gl.EQUAL,level+1,255);gl.stencilOp(gl.KEEP,gl.KEEP,gl.DECR)}gl.drawElements(gl.TRIANGLE_FAN,4,gl.UNSIGNED_SHORT,(webGLData.indices.length-4)*2);gl.stencilFunc(gl.ALWAYS,0,255);gl.stencilOp(gl.KEEP,gl.KEEP,gl.INVERT);gl.drawElements(gl.TRIANGLE_FAN,webGLData.indices.length-4,gl.UNSIGNED_SHORT,0);this.renderer.drawCount+=2;if(!sms.reverse){gl.stencilFunc(gl.EQUAL,255-level,255)}else{gl.stencilFunc(gl.EQUAL,level,255)}}else{if(!sms.reverse){gl.stencilFunc(gl.EQUAL,255-(level+1),255);gl.stencilOp(gl.KEEP,gl.KEEP,gl.INCR)}else{gl.stencilFunc(gl.EQUAL,level+1,255);gl.stencilOp(gl.KEEP,gl.KEEP,gl.DECR)}gl.drawElements(gl.TRIANGLE_STRIP,webGLData.indices.length,gl.UNSIGNED_SHORT,0);this.renderer.drawCount++;if(!sms.reverse){gl.stencilFunc(gl.EQUAL,255-level,255)}else{gl.stencilFunc(gl.EQUAL,level,255)}}gl.colorMask(true,true,true,true);gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP)}};WebGLMaskManager.prototype.destroy=function(){WebGLManager.prototype.destroy.call(this);this.stencilMaskStack.stencilStack=null};WebGLMaskManager.prototype.pushMask=function(maskData){this.renderer.setObjectRenderer(this.renderer.plugins.graphics);if(maskData.dirty){this.renderer.plugins.graphics.updateGraphics(maskData,this.renderer.gl)}if(!maskData._webGL[this.renderer.gl.id].data.length){return}this.pushStencil(maskData,maskData._webGL[this.renderer.gl.id].data[0])};WebGLMaskManager.prototype.popMask=function(maskData){this.renderer.setObjectRenderer(this.renderer.plugins.graphics);this.popStencil(maskData,maskData._webGL[this.renderer.gl.id].data[0])}},{"../../../utils":77,"./WebGLManager":58}],58:[function(require,module,exports){function WebGLManager(renderer){this.renderer=renderer;this.renderer.on("context",this.onContextChange,this)}WebGLManager.prototype.constructor=WebGLManager;module.exports=WebGLManager;WebGLManager.prototype.onContextChange=function(){};WebGLManager.prototype.destroy=function(){this.renderer.off("context",this.onContextChange,this);this.renderer=null}},{}],59:[function(require,module,exports){var Shader=require("./Shader");function ComplexPrimitiveShader(shaderManager){Shader.call(this,shaderManager,["attribute vec2 aVertexPosition;","uniform mat3 translationMatrix;","uniform mat3 projectionMatrix;","uniform vec3 tint;","uniform float alpha;","uniform vec3 color;","varying vec4 vColor;","void main(void){"," gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vColor = vec4(color * alpha * tint, alpha);","}"].join("\n"),["precision mediump float;","varying vec4 vColor;","void main(void){"," gl_FragColor = vColor;","}"].join("\n"),{tint:{type:"3f",value:[0,0,0]},alpha:{type:"1f",value:0},color:{type:"3f",value:[0,0,0]},translationMatrix:{type:"mat3",value:new Float32Array(9)},projectionMatrix:{type:"mat3",value:new Float32Array(9)}},{aVertexPosition:0})}ComplexPrimitiveShader.prototype=Object.create(Shader.prototype);ComplexPrimitiveShader.prototype.constructor=ComplexPrimitiveShader;module.exports=ComplexPrimitiveShader},{"./Shader":61}],60:[function(require,module,exports){var Shader=require("./Shader");function PrimitiveShader(shaderManager){Shader.call(this,shaderManager,["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform mat3 projectionMatrix;","uniform float alpha;","uniform float flipY;","uniform vec3 tint;","varying vec4 vColor;","void main(void){"," gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vColor = aColor * vec4(tint * alpha, alpha);","}"].join("\n"),["precision mediump float;","varying vec4 vColor;","void main(void){"," gl_FragColor = vColor;","}"].join("\n"),{tint:{type:"3f",value:[0,0,0]},alpha:{type:"1f",value:0},translationMatrix:{type:"mat3",value:new Float32Array(9)},projectionMatrix:{type:"mat3",value:new Float32Array(9)}},{aVertexPosition:0,aColor:0})}PrimitiveShader.prototype=Object.create(Shader.prototype);PrimitiveShader.prototype.constructor=PrimitiveShader;module.exports=PrimitiveShader},{"./Shader":61}],61:[function(require,module,exports){var utils=require("../../../utils");function Shader(shaderManager,vertexSrc,fragmentSrc,uniforms,attributes){if(!vertexSrc||!fragmentSrc){throw new Error("Pixi.js Error. Shader requires vertexSrc and fragmentSrc")}this.uid=utils.uid();this.gl=shaderManager.renderer.gl;this.shaderManager=shaderManager;this.program=null;this.uniforms=uniforms||{};this.attributes=attributes||{};this.textureCount=1;this.vertexSrc=vertexSrc;this.fragmentSrc=fragmentSrc;this.init()}Shader.prototype.constructor=Shader;module.exports=Shader;Shader.prototype.init=function(){this.compile();this.gl.useProgram(this.program);this.cacheUniformLocations(Object.keys(this.uniforms));this.cacheAttributeLocations(Object.keys(this.attributes))};Shader.prototype.cacheUniformLocations=function(keys){for(var i=0;i<keys.length;++i){this.uniforms[keys[i]]._location=this.gl.getUniformLocation(this.program,keys[i])}};Shader.prototype.cacheAttributeLocations=function(keys){for(var i=0;i<keys.length;++i){this.attributes[keys[i]]=this.gl.getAttribLocation(this.program,keys[i])}};Shader.prototype.compile=function(){var gl=this.gl;var glVertShader=this._glCompile(gl.VERTEX_SHADER,this.vertexSrc);var glFragShader=this._glCompile(gl.FRAGMENT_SHADER,this.fragmentSrc);var program=gl.createProgram();gl.attachShader(program,glVertShader);gl.attachShader(program,glFragShader);gl.linkProgram(program);if(!gl.getProgramParameter(program,gl.LINK_STATUS)){console.error("Pixi.js Error: Could not initialize shader.");console.error("gl.VALIDATE_STATUS",gl.getProgramParameter(program,gl.VALIDATE_STATUS));console.error("gl.getError()",gl.getError());if(gl.getProgramInfoLog(program)!==""){console.warn("Pixi.js Warning: gl.getProgramInfoLog()",gl.getProgramInfoLog(program))}gl.deleteProgram(program);program=null}gl.deleteShader(glVertShader);gl.deleteShader(glFragShader);return this.program=program};Shader.prototype.syncUniform=function(uniform){var location=uniform._location,value=uniform.value,gl=this.gl,i,il;switch(uniform.type){case"b":case"bool":case"boolean":gl.uniform1i(location,value?1:0);break;case"i":case"1i":gl.uniform1i(location,value);break;case"f":case"1f":gl.uniform1f(location,value);break;case"2f":gl.uniform2f(location,value[0],value[1]);
  8. break;case"3f":gl.uniform3f(location,value[0],value[1],value[2]);break;case"4f":gl.uniform4f(location,value[0],value[1],value[2],value[3]);break;case"v2":gl.uniform2f(location,value.x,value.y);break;case"v3":gl.uniform3f(location,value.x,value.y,value.z);break;case"v4":gl.uniform4f(location,value.x,value.y,value.z,value.w);break;case"1iv":gl.uniform1iv(location,value);break;case"2iv":gl.uniform2iv(location,value);break;case"3iv":gl.uniform3iv(location,value);break;case"4iv":gl.uniform4iv(location,value);break;case"1fv":gl.uniform1fv(location,value);break;case"2fv":gl.uniform2fv(location,value);break;case"3fv":gl.uniform3fv(location,value);break;case"4fv":gl.uniform4fv(location,value);break;case"m2":case"mat2":case"Matrix2fv":gl.uniformMatrix2fv(location,uniform.transpose,value);break;case"m3":case"mat3":case"Matrix3fv":gl.uniformMatrix3fv(location,uniform.transpose,value);break;case"m4":case"mat4":case"Matrix4fv":gl.uniformMatrix4fv(location,uniform.transpose,value);break;case"c":if(typeof value==="number"){value=utils.hex2rgb(value)}gl.uniform3f(location,value[0],value[1],value[2]);break;case"iv1":gl.uniform1iv(location,value);break;case"iv":gl.uniform3iv(location,value);break;case"fv1":gl.uniform1fv(location,value);break;case"fv":gl.uniform3fv(location,value);break;case"v2v":if(!uniform._array){uniform._array=new Float32Array(2*value.length)}for(i=0,il=value.length;i<il;++i){uniform._array[i*2]=value[i].x;uniform._array[i*2+1]=value[i].y}gl.uniform2fv(location,uniform._array);break;case"v3v":if(!uniform._array){uniform._array=new Float32Array(3*value.length)}for(i=0,il=value.length;i<il;++i){uniform._array[i*3]=value[i].x;uniform._array[i*3+1]=value[i].y;uniform._array[i*3+2]=value[i].z}gl.uniform3fv(location,uniform._array);break;case"v4v":if(!uniform._array){uniform._array=new Float32Array(4*value.length)}for(i=0,il=value.length;i<il;++i){uniform._array[i*4]=value[i].x;uniform._array[i*4+1]=value[i].y;uniform._array[i*4+2]=value[i].z;uniform._array[i*4+3]=value[i].w}gl.uniform4fv(location,uniform._array);break;case"t":case"sampler2D":if(!uniform.value||!uniform.value.baseTexture.hasLoaded){break}gl.activeTexture(gl["TEXTURE"+this.textureCount]);var texture=uniform.value.baseTexture._glTextures[gl.id];if(!texture){this.initSampler2D(uniform);texture=uniform.value.baseTexture._glTextures[gl.id]}gl.bindTexture(gl.TEXTURE_2D,texture);gl.uniform1i(uniform._location,this.textureCount);this.textureCount++;break;default:console.warn("Pixi.js Shader Warning: Unknown uniform type: "+uniform.type)}};Shader.prototype.syncUniforms=function(){this.textureCount=1;for(var key in this.uniforms){this.syncUniform(this.uniforms[key])}};Shader.prototype.initSampler2D=function(uniform){var gl=this.gl;var texture=uniform.value.baseTexture;if(!texture.hasLoaded){return}if(uniform.textureData){var data=uniform.textureData;texture._glTextures[gl.id]=gl.createTexture();gl.bindTexture(gl.TEXTURE_2D,texture._glTextures[gl.id]);gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,texture.premultipliedAlpha);gl.texImage2D(gl.TEXTURE_2D,0,data.luminance?gl.LUMINANCE:gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,texture.source);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,data.magFilter?data.magFilter:gl.LINEAR);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,data.wrapS?data.wrapS:gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,data.wrapS?data.wrapS:gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,data.wrapT?data.wrapT:gl.CLAMP_TO_EDGE)}else{this.shaderManager.renderer.updateTexture(texture)}};Shader.prototype.destroy=function(){this.gl.deleteProgram(this.program);this.gl=null;this.uniforms=null;this.attributes=null;this.vertexSrc=null;this.fragmentSrc=null};Shader.prototype._glCompile=function(type,src){var shader=this.gl.createShader(type);this.gl.shaderSource(shader,src);this.gl.compileShader(shader);if(!this.gl.getShaderParameter(shader,this.gl.COMPILE_STATUS)){console.log(this.gl.getShaderInfoLog(shader));return null}return shader}},{"../../../utils":77}],62:[function(require,module,exports){var Shader=require("./Shader");function TextureShader(shaderManager,vertexSrc,fragmentSrc,customUniforms,customAttributes){var uniforms={uSampler:{type:"sampler2D",value:0},projectionMatrix:{type:"mat3",value:new Float32Array([1,0,0,0,1,0,0,0,1])}};if(customUniforms){for(var u in customUniforms){uniforms[u]=customUniforms[u]}}var attributes={aVertexPosition:0,aTextureCoord:0,aColor:0};if(customAttributes){for(var a in customAttributes){attributes[a]=customAttributes[a]}}vertexSrc=vertexSrc||TextureShader.defaultVertexSrc;fragmentSrc=fragmentSrc||TextureShader.defaultFragmentSrc;Shader.call(this,shaderManager,vertexSrc,fragmentSrc,uniforms,attributes)}TextureShader.prototype=Object.create(Shader.prototype);TextureShader.prototype.constructor=TextureShader;module.exports=TextureShader;TextureShader.defaultVertexSrc=["precision lowp float;","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","uniform mat3 projectionMatrix;","varying vec2 vTextureCoord;","varying vec4 vColor;","void main(void){"," gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);","}"].join("\n");TextureShader.defaultFragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void){"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"].join("\n")},{"./Shader":61}],63:[function(require,module,exports){var WebGLManager=require("../managers/WebGLManager");function ObjectRenderer(renderer){WebGLManager.call(this,renderer)}ObjectRenderer.prototype=Object.create(WebGLManager.prototype);ObjectRenderer.prototype.constructor=ObjectRenderer;module.exports=ObjectRenderer;ObjectRenderer.prototype.start=function(){};ObjectRenderer.prototype.stop=function(){this.flush()};ObjectRenderer.prototype.flush=function(){};ObjectRenderer.prototype.render=function(object){}},{"../managers/WebGLManager":58}],64:[function(require,module,exports){function Quad(gl){this.gl=gl;this.vertices=new Float32Array([0,0,200,0,200,200,0,200]);this.uvs=new Float32Array([0,0,1,0,1,1,0,1]);this.colors=new Float32Array([1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]);this.indices=new Uint16Array([0,1,2,0,3,2]);this.vertexBuffer=gl.createBuffer();this.indexBuffer=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,this.vertexBuffer);gl.bufferData(gl.ARRAY_BUFFER,(8+8+16)*4,gl.DYNAMIC_DRAW);gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,this.indexBuffer);gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,this.indices,gl.STATIC_DRAW);this.upload()}Quad.prototype.constructor=Quad;Quad.prototype.map=function(rect,rect2){var x=0;var y=0;this.uvs[0]=x;this.uvs[1]=y;this.uvs[2]=x+rect2.width/rect.width;this.uvs[3]=y;this.uvs[4]=x+rect2.width/rect.width;this.uvs[5]=y+rect2.height/rect.height;this.uvs[6]=x;this.uvs[7]=y+rect2.height/rect.height;x=rect2.x;y=rect2.y;this.vertices[0]=x;this.vertices[1]=y;this.vertices[2]=x+rect2.width;this.vertices[3]=y;this.vertices[4]=x+rect2.width;this.vertices[5]=y+rect2.height;this.vertices[6]=x;this.vertices[7]=y+rect2.height;this.upload()};Quad.prototype.upload=function(){var gl=this.gl;gl.bindBuffer(gl.ARRAY_BUFFER,this.vertexBuffer);gl.bufferSubData(gl.ARRAY_BUFFER,0,this.vertices);gl.bufferSubData(gl.ARRAY_BUFFER,8*4,this.uvs);gl.bufferSubData(gl.ARRAY_BUFFER,(8+8)*4,this.colors)};Quad.prototype.destroy=function(){var gl=this.gl;gl.deleteBuffer(this.vertexBuffer);gl.deleteBuffer(this.indexBuffer)};module.exports=Quad},{}],65:[function(require,module,exports){var math=require("../../../math"),utils=require("../../../utils"),CONST=require("../../../const"),StencilMaskStack=require("./StencilMaskStack");var RenderTarget=function(gl,width,height,scaleMode,resolution,root){this.gl=gl;this.frameBuffer=null;this.texture=null;this.size=new math.Rectangle(0,0,1,1);this.resolution=resolution||CONST.RESOLUTION;this.projectionMatrix=new math.Matrix;this.transform=null;this.frame=null;this.stencilBuffer=null;this.stencilMaskStack=new StencilMaskStack;this.filterStack=[{renderTarget:this,filter:[],bounds:this.size}];this.scaleMode=scaleMode||CONST.SCALE_MODES.DEFAULT;this.root=root;if(!this.root){this.frameBuffer=gl.createFramebuffer();this.texture=gl.createTexture();gl.bindTexture(gl.TEXTURE_2D,this.texture);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,scaleMode===CONST.SCALE_MODES.LINEAR?gl.LINEAR:gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,scaleMode===CONST.SCALE_MODES.LINEAR?gl.LINEAR:gl.NEAREST);var isPowerOfTwo=utils.isPowerOfTwo(width,height);if(!isPowerOfTwo){gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE)}else{gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.REPEAT);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.REPEAT)}gl.bindFramebuffer(gl.FRAMEBUFFER,this.frameBuffer);gl.framebufferTexture2D(gl.FRAMEBUFFER,gl.COLOR_ATTACHMENT0,gl.TEXTURE_2D,this.texture,0)}this.resize(width,height)};RenderTarget.prototype.constructor=RenderTarget;module.exports=RenderTarget;RenderTarget.prototype.clear=function(bind){var gl=this.gl;if(bind){gl.bindFramebuffer(gl.FRAMEBUFFER,this.frameBuffer)}gl.clearColor(0,0,0,0);gl.clear(gl.COLOR_BUFFER_BIT)};RenderTarget.prototype.attachStencilBuffer=function(){if(this.stencilBuffer){return}if(!this.root){var gl=this.gl;this.stencilBuffer=gl.createRenderbuffer();gl.bindRenderbuffer(gl.RENDERBUFFER,this.stencilBuffer);gl.framebufferRenderbuffer(gl.FRAMEBUFFER,gl.DEPTH_STENCIL_ATTACHMENT,gl.RENDERBUFFER,this.stencilBuffer);gl.renderbufferStorage(gl.RENDERBUFFER,gl.DEPTH_STENCIL,this.size.width*this.resolution,this.size.height*this.resolution)}};RenderTarget.prototype.activate=function(){var gl=this.gl;gl.bindFramebuffer(gl.FRAMEBUFFER,this.frameBuffer);var projectionFrame=this.frame||this.size;this.calculateProjection(projectionFrame);if(this.transform){this.projectionMatrix.append(this.transform)}gl.viewport(0,0,projectionFrame.width*this.resolution,projectionFrame.height*this.resolution)};RenderTarget.prototype.calculateProjection=function(projectionFrame){var pm=this.projectionMatrix;pm.identity();if(!this.root){pm.a=1/projectionFrame.width*2;pm.d=1/projectionFrame.height*2;pm.tx=-1-projectionFrame.x*pm.a;pm.ty=-1-projectionFrame.y*pm.d}else{pm.a=1/projectionFrame.width*2;pm.d=-1/projectionFrame.height*2;pm.tx=-1-projectionFrame.x*pm.a;pm.ty=1-projectionFrame.y*pm.d}};RenderTarget.prototype.resize=function(width,height){width=width|0;height=height|0;if(this.size.width===width&&this.size.height===height){return}this.size.width=width;this.size.height=height;if(!this.root){var gl=this.gl;gl.bindTexture(gl.TEXTURE_2D,this.texture);gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,width*this.resolution,height*this.resolution,0,gl.RGBA,gl.UNSIGNED_BYTE,null);if(this.stencilBuffer){gl.bindRenderbuffer(gl.RENDERBUFFER,this.stencilBuffer);gl.renderbufferStorage(gl.RENDERBUFFER,gl.DEPTH_STENCIL,width*this.resolution,height*this.resolution)}}var projectionFrame=this.frame||this.size;this.calculateProjection(projectionFrame)};RenderTarget.prototype.destroy=function(){var gl=this.gl;gl.deleteRenderbuffer(this.stencilBuffer);gl.deleteFramebuffer(this.frameBuffer);gl.deleteTexture(this.texture);this.frameBuffer=null;this.texture=null}},{"../../../const":22,"../../../math":33,"../../../utils":77,"./StencilMaskStack":66}],66:[function(require,module,exports){function StencilMaskStack(){this.stencilStack=[];this.reverse=true;this.count=0}StencilMaskStack.prototype.constructor=StencilMaskStack;module.exports=StencilMaskStack},{}],67:[function(require,module,exports){var math=require("../math"),Texture=require("../textures/Texture"),Container=require("../display/Container"),CanvasTinter=require("../renderers/canvas/utils/CanvasTinter"),utils=require("../utils"),CONST=require("../const"),tempPoint=new math.Point,GroupD8=math.GroupD8,canvasRenderWorldTransform=new math.Matrix;function Sprite(texture){Container.call(this);this.anchor=new math.Point;this._texture=null;this._width=0;this._height=0;this.tint=16777215;this.blendMode=CONST.BLEND_MODES.NORMAL;this.shader=null;this.cachedTint=16777215;this.texture=texture||Texture.EMPTY}Sprite.prototype=Object.create(Container.prototype);Sprite.prototype.constructor=Sprite;module.exports=Sprite;Object.defineProperties(Sprite.prototype,{width:{get:function(){return Math.abs(this.scale.x)*this.texture._frame.width},set:function(value){var sign=utils.sign(this.scale.x)||1;this.scale.x=sign*value/this.texture._frame.width;this._width=value}},height:{get:function(){return Math.abs(this.scale.y)*this.texture._frame.height},set:function(value){var sign=utils.sign(this.scale.y)||1;this.scale.y=sign*value/this.texture._frame.height;this._height=value}},texture:{get:function(){return this._texture},set:function(value){if(this._texture===value){return}this._texture=value;this.cachedTint=16777215;if(value){if(value.baseTexture.hasLoaded){this._onTextureUpdate()}else{value.once("update",this._onTextureUpdate,this)}}}}});Sprite.prototype._onTextureUpdate=function(){if(this._width){this.scale.x=utils.sign(this.scale.x)*this._width/this.texture.frame.width}if(this._height){this.scale.y=utils.sign(this.scale.y)*this._height/this.texture.frame.height}};Sprite.prototype._renderWebGL=function(renderer){renderer.setObjectRenderer(renderer.plugins.sprite);renderer.plugins.sprite.render(this)};Sprite.prototype.getBounds=function(matrix){if(!this._currentBounds){var width=this._texture._frame.width;var height=this._texture._frame.height;var w0=width*(1-this.anchor.x);var w1=width*-this.anchor.x;var h0=height*(1-this.anchor.y);var h1=height*-this.anchor.y;var worldTransform=matrix||this.worldTransform;var a=worldTransform.a;var b=worldTransform.b;var c=worldTransform.c;var d=worldTransform.d;var tx=worldTransform.tx;var ty=worldTransform.ty;var minX,maxX,minY,maxY;var x1=a*w1+c*h1+tx;var y1=d*h1+b*w1+ty;var x2=a*w0+c*h1+tx;var y2=d*h1+b*w0+ty;var x3=a*w0+c*h0+tx;var y3=d*h0+b*w0+ty;var x4=a*w1+c*h0+tx;var y4=d*h0+b*w1+ty;minX=x1;minX=x2<minX?x2:minX;minX=x3<minX?x3:minX;minX=x4<minX?x4:minX;minY=y1;minY=y2<minY?y2:minY;minY=y3<minY?y3:minY;minY=y4<minY?y4:minY;maxX=x1;maxX=x2>maxX?x2:maxX;maxX=x3>maxX?x3:maxX;maxX=x4>maxX?x4:maxX;maxY=y1;maxY=y2>maxY?y2:maxY;maxY=y3>maxY?y3:maxY;maxY=y4>maxY?y4:maxY;if(this.children.length){var childBounds=this.containerGetBounds();w0=childBounds.x;w1=childBounds.x+childBounds.width;h0=childBounds.y;h1=childBounds.y+childBounds.height;minX=minX<w0?minX:w0;minY=minY<h0?minY:h0;maxX=maxX>w1?maxX:w1;maxY=maxY>h1?maxY:h1}var bounds=this._bounds;bounds.x=minX;bounds.width=maxX-minX;bounds.y=minY;bounds.height=maxY-minY;this._currentBounds=bounds}return this._currentBounds};Sprite.prototype.getLocalBounds=function(){this._bounds.x=-this._texture._frame.width*this.anchor.x;this._bounds.y=-this._texture._frame.height*this.anchor.y;this._bounds.width=this._texture._frame.width;this._bounds.height=this._texture._frame.height;return this._bounds};Sprite.prototype.containsPoint=function(point){this.worldTransform.applyInverse(point,tempPoint);var width=this._texture._frame.width;var height=this._texture._frame.height;var x1=-width*this.anchor.x;var y1;if(tempPoint.x>x1&&tempPoint.x<x1+width){y1=-height*this.anchor.y;if(tempPoint.y>y1&&tempPoint.y<y1+height){return true}}return false};Sprite.prototype._renderCanvas=function(renderer){if(this.texture.crop.width<=0||this.texture.crop.height<=0){return}var compositeOperation=renderer.blendModes[this.blendMode];if(compositeOperation!==renderer.context.globalCompositeOperation){renderer.context.globalCompositeOperation=compositeOperation}if(this.texture.valid){var texture=this._texture,wt=this.worldTransform,dx,dy,width=texture.crop.width,height=texture.crop.height;renderer.context.globalAlpha=this.worldAlpha;var smoothingEnabled=texture.baseTexture.scaleMode===CONST.SCALE_MODES.LINEAR;if(renderer.smoothProperty&&renderer.context[renderer.smoothProperty]!==smoothingEnabled){renderer.context[renderer.smoothProperty]=smoothingEnabled}if((texture.rotate&3)===2){width=texture.crop.height;height=texture.crop.width}if(texture.trim){dx=texture.crop.width/2+texture.trim.x-this.anchor.x*texture.trim.width;dy=texture.crop.height/2+texture.trim.y-this.anchor.y*texture.trim.height}else{dx=(.5-this.anchor.x)*texture._frame.width;dy=(.5-this.anchor.y)*texture._frame.height}if(texture.rotate){wt.copy(canvasRenderWorldTransform);wt=canvasRenderWorldTransform;GroupD8.matrixAppendRotationInv(wt,texture.rotate,dx,dy);dx=0;dy=0}dx-=width/2;dy-=height/2;if(renderer.roundPixels){renderer.context.setTransform(wt.a,wt.b,wt.c,wt.d,wt.tx*renderer.resolution|0,wt.ty*renderer.resolution|0);dx=dx|0;dy=dy|0}else{renderer.context.setTransform(wt.a,wt.b,wt.c,wt.d,wt.tx*renderer.resolution,wt.ty*renderer.resolution)}var resolution=texture.baseTexture.resolution;if(this.tint!==16777215){if(this.cachedTint!==this.tint){this.cachedTint=this.tint;this.tintedTexture=CanvasTinter.getTintedTexture(this,this.tint)}renderer.context.drawImage(this.tintedTexture,0,0,width*resolution,height*resolution,dx*renderer.resolution,dy*renderer.resolution,width*renderer.resolution,height*renderer.resolution)}else{renderer.context.drawImage(texture.baseTexture.source,texture.crop.x*resolution,texture.crop.y*resolution,width*resolution,height*resolution,dx*renderer.resolution,dy*renderer.resolution,width*renderer.resolution,height*renderer.resolution)}}};Sprite.prototype.destroy=function(destroyTexture,destroyBaseTexture){Container.prototype.destroy.call(this);this.anchor=null;if(destroyTexture){this._texture.destroy(destroyBaseTexture)}this._texture=null;this.shader=null};Sprite.fromFrame=function(frameId){var texture=utils.TextureCache[frameId];if(!texture){throw new Error('The frameId "'+frameId+'" does not exist in the texture cache')}return new Sprite(texture)};Sprite.fromImage=function(imageId,crossorigin,scaleMode){return new Sprite(Texture.fromImage(imageId,crossorigin,scaleMode))}},{"../const":22,"../display/Container":23,"../math":33,"../renderers/canvas/utils/CanvasTinter":48,"../textures/Texture":72,"../utils":77}],68:[function(require,module,exports){var ObjectRenderer=require("../../renderers/webgl/utils/ObjectRenderer"),WebGLRenderer=require("../../renderers/webgl/WebGLRenderer"),CONST=require("../../const");function SpriteRenderer(renderer){ObjectRenderer.call(this,renderer);this.vertSize=5;this.vertByteSize=this.vertSize*4;this.size=CONST.SPRITE_BATCH_SIZE;var numVerts=this.size*4*this.vertByteSize;var numIndices=this.size*6;this.vertices=new ArrayBuffer(numVerts);this.positions=new Float32Array(this.vertices);this.colors=new Uint32Array(this.vertices);this.indices=new Uint16Array(numIndices);for(var i=0,j=0;i<numIndices;i+=6,j+=4){this.indices[i+0]=j+0;this.indices[i+1]=j+1;this.indices[i+2]=j+2;this.indices[i+3]=j+0;this.indices[i+4]=j+2;this.indices[i+5]=j+3}this.currentBatchSize=0;this.sprites=[];this.shader=null}SpriteRenderer.prototype=Object.create(ObjectRenderer.prototype);SpriteRenderer.prototype.constructor=SpriteRenderer;module.exports=SpriteRenderer;WebGLRenderer.registerPlugin("sprite",SpriteRenderer);SpriteRenderer.prototype.onContextChange=function(){var gl=this.renderer.gl;this.shader=this.renderer.shaderManager.defaultShader;this.vertexBuffer=gl.createBuffer();this.indexBuffer=gl.createBuffer();gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,this.indexBuffer);gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,this.indices,gl.STATIC_DRAW);gl.bindBuffer(gl.ARRAY_BUFFER,this.vertexBuffer);gl.bufferData(gl.ARRAY_BUFFER,this.vertices,gl.DYNAMIC_DRAW);this.currentBlendMode=99999};SpriteRenderer.prototype.render=function(sprite){var texture=sprite._texture;if(this.currentBatchSize>=this.size){this.flush()}var uvs=texture._uvs;if(!uvs){return}var aX=sprite.anchor.x;var aY=sprite.anchor.y;var w0,w1,h0,h1;if(texture.trim&&sprite.tileScale===undefined){var trim=texture.trim;w1=trim.x-aX*trim.width;w0=w1+texture.crop.width;h1=trim.y-aY*trim.height;h0=h1+texture.crop.height}else{w0=texture._frame.width*(1-aX);w1=texture._frame.width*-aX;h0=texture._frame.height*(1-aY);h1=texture._frame.height*-aY}var index=this.currentBatchSize*this.vertByteSize;var worldTransform=sprite.worldTransform;var a=worldTransform.a;var b=worldTransform.b;var c=worldTransform.c;var d=worldTransform.d;var tx=worldTransform.tx;var ty=worldTransform.ty;var colors=this.colors;var positions=this.positions;if(this.renderer.roundPixels){var resolution=this.renderer.resolution;positions[index]=((a*w1+c*h1+tx)*resolution|0)/resolution;positions[index+1]=((d*h1+b*w1+ty)*resolution|0)/resolution;positions[index+5]=((a*w0+c*h1+tx)*resolution|0)/resolution;positions[index+6]=((d*h1+b*w0+ty)*resolution|0)/resolution;positions[index+10]=((a*w0+c*h0+tx)*resolution|0)/resolution;positions[index+11]=((d*h0+b*w0+ty)*resolution|0)/resolution;positions[index+15]=((a*w1+c*h0+tx)*resolution|0)/resolution;positions[index+16]=((d*h0+b*w1+ty)*resolution|0)/resolution}else{positions[index]=a*w1+c*h1+tx;positions[index+1]=d*h1+b*w1+ty;positions[index+5]=a*w0+c*h1+tx;positions[index+6]=d*h1+b*w0+ty;positions[index+10]=a*w0+c*h0+tx;positions[index+11]=d*h0+b*w0+ty;positions[index+15]=a*w1+c*h0+tx;positions[index+16]=d*h0+b*w1+ty}positions[index+2]=uvs.x0;positions[index+3]=uvs.y0;positions[index+7]=uvs.x1;positions[index+8]=uvs.y1;positions[index+12]=uvs.x2;positions[index+13]=uvs.y2;positions[index+17]=uvs.x3;positions[index+18]=uvs.y3;var tint=sprite.tint;colors[index+4]=colors[index+9]=colors[index+14]=colors[index+19]=(tint>>16)+(tint&65280)+((tint&255)<<16)+(sprite.worldAlpha*255<<24);this.sprites[this.currentBatchSize++]=sprite};SpriteRenderer.prototype.flush=function(){if(this.currentBatchSize===0){return}var gl=this.renderer.gl;var shader;if(this.currentBatchSize>this.size*.5){gl.bufferSubData(gl.ARRAY_BUFFER,0,this.vertices)}else{var view=this.positions.subarray(0,this.currentBatchSize*this.vertByteSize);gl.bufferSubData(gl.ARRAY_BUFFER,0,view)}var nextTexture,nextBlendMode,nextShader;var batchSize=0;var start=0;var currentBaseTexture=null;var currentBlendMode=this.renderer.blendModeManager.currentBlendMode;var currentShader=null;var blendSwap=false;var shaderSwap=false;var sprite;for(var i=0,j=this.currentBatchSize;i<j;i++){sprite=this.sprites[i];nextTexture=sprite._texture.baseTexture;nextBlendMode=sprite.blendMode;nextShader=sprite.shader||this.shader;blendSwap=currentBlendMode!==nextBlendMode;shaderSwap=currentShader!==nextShader;if(currentBaseTexture!==nextTexture||blendSwap||shaderSwap){this.renderBatch(currentBaseTexture,batchSize,start);start=i;batchSize=0;currentBaseTexture=nextTexture;if(blendSwap){currentBlendMode=nextBlendMode;this.renderer.blendModeManager.setBlendMode(currentBlendMode)}if(shaderSwap){currentShader=nextShader;shader=currentShader.shaders?currentShader.shaders[gl.id]:currentShader;if(!shader){shader=currentShader.getShader(this.renderer)}this.renderer.shaderManager.setShader(shader);shader.uniforms.projectionMatrix.value=this.renderer.currentRenderTarget.projectionMatrix.toArray(true);shader.syncUniforms();gl.activeTexture(gl.TEXTURE0)}}batchSize++}this.renderBatch(currentBaseTexture,batchSize,start);this.currentBatchSize=0};SpriteRenderer.prototype.renderBatch=function(texture,size,startIndex){if(size===0){return}var gl=this.renderer.gl;if(!texture._glTextures[gl.id]){this.renderer.updateTexture(texture)}else{gl.bindTexture(gl.TEXTURE_2D,texture._glTextures[gl.id])}gl.drawElements(gl.TRIANGLES,size*6,gl.UNSIGNED_SHORT,startIndex*6*2);this.renderer.drawCount++};SpriteRenderer.prototype.start=function(){var gl=this.renderer.gl;gl.bindBuffer(gl.ARRAY_BUFFER,this.vertexBuffer);gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var stride=this.vertByteSize;gl.vertexAttribPointer(this.shader.attributes.aVertexPosition,2,gl.FLOAT,false,stride,0);gl.vertexAttribPointer(this.shader.attributes.aTextureCoord,2,gl.FLOAT,false,stride,2*4);gl.vertexAttribPointer(this.shader.attributes.aColor,4,gl.UNSIGNED_BYTE,true,stride,4*4)};SpriteRenderer.prototype.destroy=function(){this.renderer.gl.deleteBuffer(this.vertexBuffer);this.renderer.gl.deleteBuffer(this.indexBuffer);ObjectRenderer.prototype.destroy.call(this);this.shader.destroy();this.renderer=null;this.vertices=null;this.positions=null;this.colors=null;this.indices=null;this.vertexBuffer=null;this.indexBuffer=null;this.sprites=null;this.shader=null}},{"../../const":22,"../../renderers/webgl/WebGLRenderer":49,"../../renderers/webgl/utils/ObjectRenderer":63}],69:[function(require,module,exports){var Sprite=require("../sprites/Sprite"),Texture=require("../textures/Texture"),math=require("../math"),utils=require("../utils"),CONST=require("../const");function Text(text,style,resolution){this.canvas=document.createElement("canvas");this.context=this.canvas.getContext("2d");this.resolution=resolution||CONST.RESOLUTION;this._text=null;this._style=null;var texture=Texture.fromCanvas(this.canvas);texture.trim=new math.Rectangle;Sprite.call(this,texture);this.text=text;this.style=style}Text.prototype=Object.create(Sprite.prototype);Text.prototype.constructor=Text;module.exports=Text;Text.fontPropertiesCache={};Text.fontPropertiesCanvas=document.createElement("canvas");Text.fontPropertiesContext=Text.fontPropertiesCanvas.getContext("2d");Object.defineProperties(Text.prototype,{width:{get:function(){if(this.dirty){this.updateText()}return this.scale.x*this._texture._frame.width},set:function(value){this.scale.x=value/this._texture._frame.width;this._width=value}},height:{get:function(){if(this.dirty){this.updateText()}return this.scale.y*this._texture._frame.height},set:function(value){this.scale.y=value/this._texture._frame.height;this._height=value}},style:{get:function(){return this._style},set:function(style){style=style||{};if(typeof style.fill==="number"){style.fill=utils.hex2string(style.fill)}if(typeof style.stroke==="number"){style.stroke=utils.hex2string(style.stroke)}if(typeof style.dropShadowColor==="number"){style.dropShadowColor=utils.hex2string(style.dropShadowColor)}style.font=style.font||"bold 20pt Arial";style.fill=style.fill||"black";style.align=style.align||"left";style.stroke=style.stroke||"black";style.strokeThickness=style.strokeThickness||0;style.wordWrap=style.wordWrap||false;style.wordWrapWidth=style.wordWrapWidth||100;style.breakWords=style.breakWords||false;style.letterSpacing=style.letterSpacing||0;style.dropShadow=style.dropShadow||false;style.dropShadowColor=style.dropShadowColor||"#000000";style.dropShadowAngle=style.dropShadowAngle!==undefined?style.dropShadowAngle:Math.PI/6;style.dropShadowDistance=style.dropShadowDistance!==undefined?style.dropShadowDistance:5;style.dropShadowBlur=style.dropShadowBlur!==undefined?style.dropShadowBlur:0;style.padding=style.padding||0;style.textBaseline=style.textBaseline||"alphabetic";style.lineJoin=style.lineJoin||"miter";style.miterLimit=style.miterLimit||10;this._style=style;this.dirty=true}},text:{get:function(){return this._text},set:function(text){text=text.toString()||" ";if(this._text===text){return}this._text=text;this.dirty=true}}});Text.prototype.updateText=function(){var style=this._style;this.context.font=style.font;var outputText=style.wordWrap?this.wordWrap(this._text):this._text;var lines=outputText.split(/(?:\r\n|\r|\n)/);var lineWidths=new Array(lines.length);var maxLineWidth=0;var fontProperties=this.determineFontProperties(style.font);for(var i=0;i<lines.length;i++){var lineWidth=this.context.measureText(lines[i]).width+(lines[i].length-1)*style.letterSpacing;lineWidths[i]=lineWidth;maxLineWidth=Math.max(maxLineWidth,lineWidth)}var width=maxLineWidth+style.strokeThickness;if(style.dropShadow){width+=style.dropShadowDistance}this.canvas.width=Math.ceil((width+this.context.lineWidth)*this.resolution);var lineHeight=this.style.lineHeight||fontProperties.fontSize+style.strokeThickness;var height=lineHeight*lines.length;if(style.dropShadow){height+=style.dropShadowDistance}this.canvas.height=Math.ceil((height+this._style.padding*2)*this.resolution);this.context.scale(this.resolution,this.resolution);if(navigator.isCocoonJS){this.context.clearRect(0,0,this.canvas.width,this.canvas.height)}this.context.font=style.font;this.context.strokeStyle=style.stroke;this.context.lineWidth=style.strokeThickness;this.context.textBaseline=style.textBaseline;this.context.lineJoin=style.lineJoin;this.context.miterLimit=style.miterLimit;var linePositionX;var linePositionY;if(style.dropShadow){if(style.dropShadowBlur>0){this.context.shadowColor=style.dropShadowColor;this.context.shadowBlur=style.dropShadowBlur}else{this.context.fillStyle=style.dropShadowColor}var xShadowOffset=Math.cos(style.dropShadowAngle)*style.dropShadowDistance;var yShadowOffset=Math.sin(style.dropShadowAngle)*style.dropShadowDistance;for(i=0;i<lines.length;i++){linePositionX=style.strokeThickness/2;linePositionY=style.strokeThickness/2+i*lineHeight+fontProperties.ascent;if(style.align==="right"){linePositionX+=maxLineWidth-lineWidths[i]}else if(style.align==="center"){linePositionX+=(maxLineWidth-lineWidths[i])/2}if(style.fill){this.drawLetterSpacing(lines[i],linePositionX+xShadowOffset,linePositionY+yShadowOffset+style.padding)}}}this.context.fillStyle=style.fill;for(i=0;i<lines.length;i++){linePositionX=style.strokeThickness/2;linePositionY=style.strokeThickness/2+i*lineHeight+fontProperties.ascent;if(style.align==="right"){linePositionX+=maxLineWidth-lineWidths[i]}else if(style.align==="center"){linePositionX+=(maxLineWidth-lineWidths[i])/2}if(style.stroke&&style.strokeThickness){this.drawLetterSpacing(lines[i],linePositionX,linePositionY+style.padding,true)}if(style.fill){this.drawLetterSpacing(lines[i],linePositionX,linePositionY+style.padding)}}this.updateTexture()};Text.prototype.drawLetterSpacing=function(text,x,y,isStroke){var style=this._style;var letterSpacing=style.letterSpacing;if(letterSpacing===0){if(isStroke){this.context.strokeText(text,x,y)}else{this.context.fillText(text,x,y)}return}var characters=String.prototype.split.call(text,""),index=0,current,currentPosition=x;while(index<text.length){current=characters[index++];if(isStroke){this.context.strokeText(current,currentPosition,y)}else{this.context.fillText(current,currentPosition,y)}currentPosition+=this.context.measureText(current).width+letterSpacing}};Text.prototype.updateTexture=function(){var texture=this._texture;var style=this._style;texture.baseTexture.hasLoaded=true;texture.baseTexture.resolution=this.resolution;texture.baseTexture.width=this.canvas.width/this.resolution;texture.baseTexture.height=this.canvas.height/this.resolution;texture.crop.width=texture._frame.width=this.canvas.width/this.resolution;texture.crop.height=texture._frame.height=this.canvas.height/this.resolution;texture.trim.x=0;texture.trim.y=-style.padding;texture.trim.width=texture._frame.width;texture.trim.height=texture._frame.height-style.padding*2;this._width=this.canvas.width/this.resolution;this._height=this.canvas.height/this.resolution;texture.baseTexture.emit("update",texture.baseTexture);this.dirty=false};Text.prototype.renderWebGL=function(renderer){if(this.dirty){this.updateText()}Sprite.prototype.renderWebGL.call(this,renderer)};Text.prototype._renderCanvas=function(renderer){if(this.dirty){this.updateText()}Sprite.prototype._renderCanvas.call(this,renderer)};Text.prototype.determineFontProperties=function(fontStyle){var properties=Text.fontPropertiesCache[fontStyle];if(!properties){properties={};var canvas=Text.fontPropertiesCanvas;var context=Text.fontPropertiesContext;context.font=fontStyle;var width=Math.ceil(context.measureText("|MÉq").width);var baseline=Math.ceil(context.measureText("M").width);var height=2*baseline;baseline=baseline*1.4|0;canvas.width=width;canvas.height=height;context.fillStyle="#f00";context.fillRect(0,0,width,height);context.font=fontStyle;context.textBaseline="alphabetic";
  9. context.fillStyle="#000";context.fillText("|MÉq",0,baseline);var imagedata=context.getImageData(0,0,width,height).data;var pixels=imagedata.length;var line=width*4;var i,j;var idx=0;var stop=false;for(i=0;i<baseline;i++){for(j=0;j<line;j+=4){if(imagedata[idx+j]!==255){stop=true;break}}if(!stop){idx+=line}else{break}}properties.ascent=baseline-i;idx=pixels-line;stop=false;for(i=height;i>baseline;i--){for(j=0;j<line;j+=4){if(imagedata[idx+j]!==255){stop=true;break}}if(!stop){idx-=line}else{break}}properties.descent=i-baseline;properties.fontSize=properties.ascent+properties.descent;Text.fontPropertiesCache[fontStyle]=properties}return properties};Text.prototype.wordWrap=function(text){var result="";var lines=text.split("\n");var wordWrapWidth=this._style.wordWrapWidth;for(var i=0;i<lines.length;i++){var spaceLeft=wordWrapWidth;var words=lines[i].split(" ");for(var j=0;j<words.length;j++){var wordWidth=this.context.measureText(words[j]).width;if(this._style.breakWords&&wordWidth>wordWrapWidth){var characters=words[j].split("");for(var c=0;c<characters.length;c++){var characterWidth=this.context.measureText(characters[c]).width;if(characterWidth>spaceLeft){result+="\n"+characters[c];spaceLeft=wordWrapWidth-characterWidth}else{if(c===0){result+=" "}result+=characters[c];spaceLeft-=characterWidth}}}else{var wordWidthWithSpace=wordWidth+this.context.measureText(" ").width;if(j===0||wordWidthWithSpace>spaceLeft){if(j>0){result+="\n"}result+=words[j];spaceLeft=wordWrapWidth-wordWidth}else{spaceLeft-=wordWidthWithSpace;result+=" "+words[j]}}}if(i<lines.length-1){result+="\n"}}return result};Text.prototype.getBounds=function(matrix){if(this.dirty){this.updateText()}return Sprite.prototype.getBounds.call(this,matrix)};Text.prototype.destroy=function(destroyBaseTexture){this.context=null;this.canvas=null;this._style=null;this._texture.destroy(destroyBaseTexture===undefined?true:destroyBaseTexture)}},{"../const":22,"../math":33,"../sprites/Sprite":67,"../textures/Texture":72,"../utils":77}],70:[function(require,module,exports){var utils=require("../utils"),CONST=require("../const"),EventEmitter=require("eventemitter3");function BaseTexture(source,scaleMode,resolution){EventEmitter.call(this);this.uid=utils.uid();this.resolution=resolution||1;this.width=100;this.height=100;this.realWidth=100;this.realHeight=100;this.scaleMode=scaleMode||CONST.SCALE_MODES.DEFAULT;this.hasLoaded=false;this.isLoading=false;this.source=null;this.premultipliedAlpha=true;this.imageUrl=null;this.isPowerOfTwo=false;this.mipmap=false;this._glTextures={};if(source){this.loadSource(source)}}BaseTexture.prototype=Object.create(EventEmitter.prototype);BaseTexture.prototype.constructor=BaseTexture;module.exports=BaseTexture;BaseTexture.prototype.update=function(){this.realWidth=this.source.naturalWidth||this.source.width;this.realHeight=this.source.naturalHeight||this.source.height;this.width=this.realWidth/this.resolution;this.height=this.realHeight/this.resolution;this.isPowerOfTwo=utils.isPowerOfTwo(this.realWidth,this.realHeight);this.emit("update",this)};BaseTexture.prototype.loadSource=function(source){var wasLoading=this.isLoading;this.hasLoaded=false;this.isLoading=false;if(wasLoading&&this.source){this.source.onload=null;this.source.onerror=null}this.source=source;if((this.source.complete||this.source.getContext)&&this.source.width&&this.source.height){this._sourceLoaded()}else if(!source.getContext){this.isLoading=true;var scope=this;source.onload=function(){source.onload=null;source.onerror=null;if(!scope.isLoading){return}scope.isLoading=false;scope._sourceLoaded();scope.emit("loaded",scope)};source.onerror=function(){source.onload=null;source.onerror=null;if(!scope.isLoading){return}scope.isLoading=false;scope.emit("error",scope)};if(source.complete&&source.src){this.isLoading=false;source.onload=null;source.onerror=null;if(source.width&&source.height){this._sourceLoaded();if(wasLoading){this.emit("loaded",this)}}else{if(wasLoading){this.emit("error",this)}}}}};BaseTexture.prototype._sourceLoaded=function(){this.hasLoaded=true;this.update()};BaseTexture.prototype.destroy=function(){if(this.imageUrl){delete utils.BaseTextureCache[this.imageUrl];delete utils.TextureCache[this.imageUrl];this.imageUrl=null;if(!navigator.isCocoonJS){this.source.src=""}}else if(this.source&&this.source._pixiId){delete utils.BaseTextureCache[this.source._pixiId]}this.source=null;this.dispose()};BaseTexture.prototype.dispose=function(){this.emit("dispose",this)};BaseTexture.prototype.updateSourceImage=function(newSrc){this.source.src=newSrc;this.loadSource(this.source)};BaseTexture.fromImage=function(imageUrl,crossorigin,scaleMode){var baseTexture=utils.BaseTextureCache[imageUrl];if(crossorigin===undefined&&imageUrl.indexOf("data:")!==0){crossorigin=true}if(!baseTexture){var image=new Image;if(crossorigin){image.crossOrigin=""}baseTexture=new BaseTexture(image,scaleMode);baseTexture.imageUrl=imageUrl;image.src=imageUrl;utils.BaseTextureCache[imageUrl]=baseTexture;baseTexture.resolution=utils.getResolutionOfUrl(imageUrl)}return baseTexture};BaseTexture.fromCanvas=function(canvas,scaleMode){if(!canvas._pixiId){canvas._pixiId="canvas_"+utils.uid()}var baseTexture=utils.BaseTextureCache[canvas._pixiId];if(!baseTexture){baseTexture=new BaseTexture(canvas,scaleMode);utils.BaseTextureCache[canvas._pixiId]=baseTexture}return baseTexture}},{"../const":22,"../utils":77,eventemitter3:10}],71:[function(require,module,exports){var BaseTexture=require("./BaseTexture"),Texture=require("./Texture"),RenderTarget=require("../renderers/webgl/utils/RenderTarget"),FilterManager=require("../renderers/webgl/managers/FilterManager"),CanvasBuffer=require("../renderers/canvas/utils/CanvasBuffer"),math=require("../math"),CONST=require("../const"),tempMatrix=new math.Matrix;function RenderTexture(renderer,width,height,scaleMode,resolution){if(!renderer){throw new Error("Unable to create RenderTexture, you must pass a renderer into the constructor.")}width=width||100;height=height||100;resolution=resolution||CONST.RESOLUTION;var baseTexture=new BaseTexture;baseTexture.width=width;baseTexture.height=height;baseTexture.resolution=resolution;baseTexture.scaleMode=scaleMode||CONST.SCALE_MODES.DEFAULT;baseTexture.hasLoaded=true;Texture.call(this,baseTexture,new math.Rectangle(0,0,width,height));this.width=width;this.height=height;this.resolution=resolution;this.render=null;this.renderer=renderer;if(this.renderer.type===CONST.RENDERER_TYPE.WEBGL){var gl=this.renderer.gl;this.textureBuffer=new RenderTarget(gl,this.width,this.height,baseTexture.scaleMode,this.resolution);this.baseTexture._glTextures[gl.id]=this.textureBuffer.texture;this.filterManager=new FilterManager(this.renderer);this.filterManager.onContextChange();this.filterManager.resize(width,height);this.render=this.renderWebGL;this.renderer.currentRenderer.start();this.renderer.currentRenderTarget.activate()}else{this.render=this.renderCanvas;this.textureBuffer=new CanvasBuffer(this.width*this.resolution,this.height*this.resolution);this.baseTexture.source=this.textureBuffer.canvas}this.valid=true;this._updateUvs()}RenderTexture.prototype=Object.create(Texture.prototype);RenderTexture.prototype.constructor=RenderTexture;module.exports=RenderTexture;RenderTexture.prototype.resize=function(width,height,updateBase){if(width===this.width&&height===this.height){return}this.valid=width>0&&height>0;this.width=this._frame.width=this.crop.width=width;this.height=this._frame.height=this.crop.height=height;if(updateBase){this.baseTexture.width=this.width;this.baseTexture.height=this.height}if(!this.valid){return}this.textureBuffer.resize(this.width,this.height);if(this.filterManager){this.filterManager.resize(this.width,this.height)}};RenderTexture.prototype.clear=function(){if(!this.valid){return}if(this.renderer.type===CONST.RENDERER_TYPE.WEBGL){this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer)}this.textureBuffer.clear()};RenderTexture.prototype.renderWebGL=function(displayObject,matrix,clear,updateTransform){if(!this.valid){return}updateTransform=updateTransform!==undefined?updateTransform:true;this.textureBuffer.transform=matrix;this.textureBuffer.activate();displayObject.worldAlpha=1;if(updateTransform){displayObject.worldTransform.identity();displayObject.currentBounds=null;var children=displayObject.children;var i,j;for(i=0,j=children.length;i<j;++i){children[i].updateTransform()}}var temp=this.renderer.filterManager;this.renderer.filterManager=this.filterManager;this.renderer.renderDisplayObject(displayObject,this.textureBuffer,clear);this.renderer.filterManager=temp};RenderTexture.prototype.renderCanvas=function(displayObject,matrix,clear,updateTransform){if(!this.valid){return}updateTransform=!!updateTransform;var wt=tempMatrix;wt.identity();if(matrix){wt.append(matrix)}var cachedWt=displayObject.worldTransform;displayObject.worldTransform=wt;displayObject.worldAlpha=1;var children=displayObject.children;var i,j;for(i=0,j=children.length;i<j;++i){children[i].updateTransform()}if(clear){this.textureBuffer.clear()}var context=this.textureBuffer.context;var realResolution=this.renderer.resolution;this.renderer.resolution=this.resolution;this.renderer.renderDisplayObject(displayObject,context);this.renderer.resolution=realResolution;if(displayObject.worldTransform===wt){displayObject.worldTransform=cachedWt}};RenderTexture.prototype.destroy=function(){Texture.prototype.destroy.call(this,true);this.textureBuffer.destroy();if(this.filterManager){this.filterManager.destroy()}this.renderer=null};RenderTexture.prototype.getImage=function(){var image=new Image;image.src=this.getBase64();return image};RenderTexture.prototype.getBase64=function(){return this.getCanvas().toDataURL()};RenderTexture.prototype.getCanvas=function(){if(this.renderer.type===CONST.RENDERER_TYPE.WEBGL){var gl=this.renderer.gl;var width=this.textureBuffer.size.width;var height=this.textureBuffer.size.height;var webGLPixels=new Uint8Array(4*width*height);gl.bindFramebuffer(gl.FRAMEBUFFER,this.textureBuffer.frameBuffer);gl.readPixels(0,0,width,height,gl.RGBA,gl.UNSIGNED_BYTE,webGLPixels);gl.bindFramebuffer(gl.FRAMEBUFFER,null);var tempCanvas=new CanvasBuffer(width,height);var canvasData=tempCanvas.context.getImageData(0,0,width,height);canvasData.data.set(webGLPixels);tempCanvas.context.putImageData(canvasData,0,0);return tempCanvas.canvas}else{return this.textureBuffer.canvas}};RenderTexture.prototype.getPixels=function(){var width,height;if(this.renderer.type===CONST.RENDERER_TYPE.WEBGL){var gl=this.renderer.gl;width=this.textureBuffer.size.width;height=this.textureBuffer.size.height;var webGLPixels=new Uint8Array(4*width*height);gl.bindFramebuffer(gl.FRAMEBUFFER,this.textureBuffer.frameBuffer);gl.readPixels(0,0,width,height,gl.RGBA,gl.UNSIGNED_BYTE,webGLPixels);gl.bindFramebuffer(gl.FRAMEBUFFER,null);return webGLPixels}else{width=this.textureBuffer.canvas.width;height=this.textureBuffer.canvas.height;return this.textureBuffer.canvas.getContext("2d").getImageData(0,0,width,height).data}};RenderTexture.prototype.getPixel=function(x,y){if(this.renderer.type===CONST.RENDERER_TYPE.WEBGL){var gl=this.renderer.gl;var webGLPixels=new Uint8Array(4);gl.bindFramebuffer(gl.FRAMEBUFFER,this.textureBuffer.frameBuffer);gl.readPixels(x,y,1,1,gl.RGBA,gl.UNSIGNED_BYTE,webGLPixels);gl.bindFramebuffer(gl.FRAMEBUFFER,null);return webGLPixels}else{return this.textureBuffer.canvas.getContext("2d").getImageData(x,y,1,1).data}}},{"../const":22,"../math":33,"../renderers/canvas/utils/CanvasBuffer":45,"../renderers/webgl/managers/FilterManager":54,"../renderers/webgl/utils/RenderTarget":65,"./BaseTexture":70,"./Texture":72}],72:[function(require,module,exports){var BaseTexture=require("./BaseTexture"),VideoBaseTexture=require("./VideoBaseTexture"),TextureUvs=require("./TextureUvs"),EventEmitter=require("eventemitter3"),math=require("../math"),utils=require("../utils");function Texture(baseTexture,frame,crop,trim,rotate){EventEmitter.call(this);this.noFrame=false;if(!frame){this.noFrame=true;frame=new math.Rectangle(0,0,1,1)}if(baseTexture instanceof Texture){baseTexture=baseTexture.baseTexture}this.baseTexture=baseTexture;this._frame=frame;this.trim=trim;this.valid=false;this.requiresUpdate=false;this._uvs=null;this.width=0;this.height=0;this.crop=crop||frame;this._rotate=+(rotate||0);if(rotate===true){this._rotate=2}else{if(this._rotate%2!==0){throw"attempt to use diamond-shaped UVs. If you are sure, set rotation manually"}}if(baseTexture.hasLoaded){if(this.noFrame){frame=new math.Rectangle(0,0,baseTexture.width,baseTexture.height);baseTexture.on("update",this.onBaseTextureUpdated,this)}this.frame=frame}else{baseTexture.once("loaded",this.onBaseTextureLoaded,this)}}Texture.prototype=Object.create(EventEmitter.prototype);Texture.prototype.constructor=Texture;module.exports=Texture;Object.defineProperties(Texture.prototype,{frame:{get:function(){return this._frame},set:function(frame){this._frame=frame;this.noFrame=false;this.width=frame.width;this.height=frame.height;if(!this.trim&&!this.rotate&&(frame.x+frame.width>this.baseTexture.width||frame.y+frame.height>this.baseTexture.height)){throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this)}this.valid=frame&&frame.width&&frame.height&&this.baseTexture.hasLoaded;if(this.trim){this.width=this.trim.width;this.height=this.trim.height;this._frame.width=this.trim.width;this._frame.height=this.trim.height}else{this.crop=frame}if(this.valid){this._updateUvs()}}},rotate:{get:function(){return this._rotate},set:function(rotate){this._rotate=rotate;if(this.valid){this._updateUvs()}}}});Texture.prototype.update=function(){this.baseTexture.update()};Texture.prototype.onBaseTextureLoaded=function(baseTexture){if(this.noFrame){this.frame=new math.Rectangle(0,0,baseTexture.width,baseTexture.height)}else{this.frame=this._frame}this.emit("update",this)};Texture.prototype.onBaseTextureUpdated=function(baseTexture){this._frame.width=baseTexture.width;this._frame.height=baseTexture.height;this.emit("update",this)};Texture.prototype.destroy=function(destroyBase){if(this.baseTexture){if(destroyBase){this.baseTexture.destroy()}this.baseTexture.off("update",this.onBaseTextureUpdated,this);this.baseTexture.off("loaded",this.onBaseTextureLoaded,this);this.baseTexture=null}this._frame=null;this._uvs=null;this.trim=null;this.crop=null;this.valid=false;this.off("dispose",this.dispose,this);this.off("update",this.update,this)};Texture.prototype.clone=function(){return new Texture(this.baseTexture,this.frame,this.crop,this.trim,this.rotate)};Texture.prototype._updateUvs=function(){if(!this._uvs){this._uvs=new TextureUvs}this._uvs.set(this.crop,this.baseTexture,this.rotate)};Texture.fromImage=function(imageUrl,crossorigin,scaleMode){var texture=utils.TextureCache[imageUrl];if(!texture){texture=new Texture(BaseTexture.fromImage(imageUrl,crossorigin,scaleMode));utils.TextureCache[imageUrl]=texture}return texture};Texture.fromFrame=function(frameId){var texture=utils.TextureCache[frameId];if(!texture){throw new Error('The frameId "'+frameId+'" does not exist in the texture cache')}return texture};Texture.fromCanvas=function(canvas,scaleMode){return new Texture(BaseTexture.fromCanvas(canvas,scaleMode))};Texture.fromVideo=function(video,scaleMode){if(typeof video==="string"){return Texture.fromVideoUrl(video,scaleMode)}else{return new Texture(VideoBaseTexture.fromVideo(video,scaleMode))}};Texture.fromVideoUrl=function(videoUrl,scaleMode){return new Texture(VideoBaseTexture.fromUrl(videoUrl,scaleMode))};Texture.addTextureToCache=function(texture,id){utils.TextureCache[id]=texture};Texture.removeTextureFromCache=function(id){var texture=utils.TextureCache[id];delete utils.TextureCache[id];delete utils.BaseTextureCache[id];return texture};Texture.EMPTY=new Texture(new BaseTexture)},{"../math":33,"../utils":77,"./BaseTexture":70,"./TextureUvs":73,"./VideoBaseTexture":74,eventemitter3:10}],73:[function(require,module,exports){function TextureUvs(){this.x0=0;this.y0=0;this.x1=1;this.y1=0;this.x2=1;this.y2=1;this.x3=0;this.y3=1}module.exports=TextureUvs;var GroupD8=require("../math/GroupD8");TextureUvs.prototype.set=function(frame,baseFrame,rotate){var tw=baseFrame.width;var th=baseFrame.height;if(rotate){var swapWidthHeight=GroupD8.isSwapWidthHeight(rotate);var w2=(swapWidthHeight?frame.height:frame.width)/2/tw;var h2=(swapWidthHeight?frame.width:frame.height)/2/th;var cX=frame.x/tw+w2;var cY=frame.y/th+h2;rotate=GroupD8.add(rotate,GroupD8.NW);this.x0=cX+w2*GroupD8.uX(rotate);this.y0=cY+h2*GroupD8.uY(rotate);rotate=GroupD8.add(rotate,2);this.x1=cX+w2*GroupD8.uX(rotate);this.y1=cY+h2*GroupD8.uY(rotate);rotate=GroupD8.add(rotate,2);this.x2=cX+w2*GroupD8.uX(rotate);this.y2=cY+h2*GroupD8.uY(rotate);rotate=GroupD8.add(rotate,2);this.x3=cX+w2*GroupD8.uX(rotate);this.y3=cY+h2*GroupD8.uY(rotate)}else{this.x0=frame.x/tw;this.y0=frame.y/th;this.x1=(frame.x+frame.width)/tw;this.y1=frame.y/th;this.x2=(frame.x+frame.width)/tw;this.y2=(frame.y+frame.height)/th;this.x3=frame.x/tw;this.y3=(frame.y+frame.height)/th}}},{"../math/GroupD8":30}],74:[function(require,module,exports){var BaseTexture=require("./BaseTexture"),utils=require("../utils");function VideoBaseTexture(source,scaleMode){if(!source){throw new Error("No video source element specified.")}if((source.readyState===source.HAVE_ENOUGH_DATA||source.readyState===source.HAVE_FUTURE_DATA)&&source.width&&source.height){source.complete=true}BaseTexture.call(this,source,scaleMode);this.autoUpdate=false;this._onUpdate=this._onUpdate.bind(this);this._onCanPlay=this._onCanPlay.bind(this);if(!source.complete){source.addEventListener("canplay",this._onCanPlay);source.addEventListener("canplaythrough",this._onCanPlay);source.addEventListener("play",this._onPlayStart.bind(this));source.addEventListener("pause",this._onPlayStop.bind(this))}this.__loaded=false}VideoBaseTexture.prototype=Object.create(BaseTexture.prototype);VideoBaseTexture.prototype.constructor=VideoBaseTexture;module.exports=VideoBaseTexture;VideoBaseTexture.prototype._onUpdate=function(){if(this.autoUpdate){window.requestAnimationFrame(this._onUpdate);this.update()}};VideoBaseTexture.prototype._onPlayStart=function(){if(!this.autoUpdate){window.requestAnimationFrame(this._onUpdate);this.autoUpdate=true}};VideoBaseTexture.prototype._onPlayStop=function(){this.autoUpdate=false};VideoBaseTexture.prototype._onCanPlay=function(){this.hasLoaded=true;if(this.source){this.source.removeEventListener("canplay",this._onCanPlay);this.source.removeEventListener("canplaythrough",this._onCanPlay);this.width=this.source.videoWidth;this.height=this.source.videoHeight;this.source.play();if(!this.__loaded){this.__loaded=true;this.emit("loaded",this)}}};VideoBaseTexture.prototype.destroy=function(){if(this.source&&this.source._pixiId){delete utils.BaseTextureCache[this.source._pixiId];delete this.source._pixiId}BaseTexture.prototype.destroy.call(this)};VideoBaseTexture.fromVideo=function(video,scaleMode){if(!video._pixiId){video._pixiId="video_"+utils.uid()}var baseTexture=utils.BaseTextureCache[video._pixiId];if(!baseTexture){baseTexture=new VideoBaseTexture(video,scaleMode);utils.BaseTextureCache[video._pixiId]=baseTexture}return baseTexture};VideoBaseTexture.fromUrl=function(videoSrc,scaleMode){var video=document.createElement("video");if(Array.isArray(videoSrc)){for(var i=0;i<videoSrc.length;++i){video.appendChild(createSource(videoSrc[i].src||videoSrc[i],videoSrc[i].mime))}}else{video.appendChild(createSource(videoSrc.src||videoSrc,videoSrc.mime))}video.load();video.play();return VideoBaseTexture.fromVideo(video,scaleMode)};VideoBaseTexture.fromUrls=VideoBaseTexture.fromUrl;function createSource(path,type){if(!type){type="video/"+path.substr(path.lastIndexOf(".")+1)}var source=document.createElement("source");source.src=path;source.type=type;return source}},{"../utils":77,"./BaseTexture":70}],75:[function(require,module,exports){var CONST=require("../const"),EventEmitter=require("eventemitter3"),TICK="tick";function Ticker(){var _this=this;this._tick=function _tick(time){_this._requestId=null;if(_this.started){_this.update(time);if(_this.started&&_this._requestId===null&&_this._emitter.listeners(TICK,true)){_this._requestId=requestAnimationFrame(_this._tick)}}};this._emitter=new EventEmitter;this._requestId=null;this._maxElapsedMS=100;this.autoStart=false;this.deltaTime=1;this.elapsedMS=1/CONST.TARGET_FPMS;this.lastTime=0;this.speed=1;this.started=false}Object.defineProperties(Ticker.prototype,{FPS:{get:function(){return 1e3/this.elapsedMS}},minFPS:{get:function(){return 1e3/this._maxElapsedMS},set:function(fps){var minFPMS=Math.min(Math.max(0,fps)/1e3,CONST.TARGET_FPMS);this._maxElapsedMS=1/minFPMS}}});Ticker.prototype._requestIfNeeded=function _requestIfNeeded(){if(this._requestId===null&&this._emitter.listeners(TICK,true)){this.lastTime=performance.now();this._requestId=requestAnimationFrame(this._tick)}};Ticker.prototype._cancelIfNeeded=function _cancelIfNeeded(){if(this._requestId!==null){cancelAnimationFrame(this._requestId);this._requestId=null}};Ticker.prototype._startIfPossible=function _startIfPossible(){if(this.started){this._requestIfNeeded()}else if(this.autoStart){this.start()}};Ticker.prototype.add=function add(fn,context){this._emitter.on(TICK,fn,context);this._startIfPossible();return this};Ticker.prototype.addOnce=function addOnce(fn,context){this._emitter.once(TICK,fn,context);this._startIfPossible();return this};Ticker.prototype.remove=function remove(fn,context){this._emitter.off(TICK,fn,context);if(!this._emitter.listeners(TICK,true)){this._cancelIfNeeded()}return this};Ticker.prototype.start=function start(){if(!this.started){this.started=true;this._requestIfNeeded()}};Ticker.prototype.stop=function stop(){if(this.started){this.started=false;this._cancelIfNeeded()}};Ticker.prototype.update=function update(currentTime){var elapsedMS;currentTime=currentTime||performance.now();elapsedMS=this.elapsedMS=currentTime-this.lastTime;if(elapsedMS>this._maxElapsedMS){elapsedMS=this._maxElapsedMS}this.deltaTime=elapsedMS*CONST.TARGET_FPMS*this.speed;this._emitter.emit(TICK,this.deltaTime);this.lastTime=currentTime};module.exports=Ticker},{"../const":22,eventemitter3:10}],76:[function(require,module,exports){var Ticker=require("./Ticker");var shared=new Ticker;shared.autoStart=true;module.exports={shared:shared,Ticker:Ticker}},{"./Ticker":75}],77:[function(require,module,exports){var CONST=require("../const");var utils=module.exports={_uid:0,_saidHello:false,EventEmitter:require("eventemitter3"),pluginTarget:require("./pluginTarget"),async:require("async"),uid:function(){return++utils._uid},hex2rgb:function(hex,out){out=out||[];out[0]=(hex>>16&255)/255;out[1]=(hex>>8&255)/255;out[2]=(hex&255)/255;return out},hex2string:function(hex){hex=hex.toString(16);hex="000000".substr(0,6-hex.length)+hex;return"#"+hex},rgb2hex:function(rgb){return(rgb[0]*255<<16)+(rgb[1]*255<<8)+rgb[2]*255},canUseNewCanvasBlendModes:function(){if(typeof document==="undefined"){return false}var pngHead="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/";var pngEnd="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==";var magenta=new Image;magenta.src=pngHead+"AP804Oa6"+pngEnd;var yellow=new Image;yellow.src=pngHead+"/wCKxvRF"+pngEnd;var canvas=document.createElement("canvas");canvas.width=6;canvas.height=1;var context=canvas.getContext("2d");context.globalCompositeOperation="multiply";context.drawImage(magenta,0,0);context.drawImage(yellow,2,0);var data=context.getImageData(2,0,1,1).data;return data[0]===255&&data[1]===0&&data[2]===0},getNextPowerOfTwo:function(number){if(number>0&&(number&number-1)===0){return number}else{var result=1;while(result<number){result<<=1}return result}},isPowerOfTwo:function(width,height){return width>0&&(width&width-1)===0&&height>0&&(height&height-1)===0},getResolutionOfUrl:function(url){var resolution=CONST.RETINA_PREFIX.exec(url);if(resolution){return parseFloat(resolution[1])}return 1},sayHello:function(type){if(utils._saidHello){return}if(navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var args=["\n %c %c %c Pixi.js "+CONST.VERSION+" - ✰ "+type+" ✰ %c "+" %c "+" http://www.pixijs.com/ %c %c ♥%c♥%c♥ \n\n","background: #ff66a5; padding:5px 0;","background: #ff66a5; padding:5px 0;","color: #ff66a5; background: #030307; padding:5px 0;","background: #ff66a5; padding:5px 0;","background: #ffc3dc; padding:5px 0;","background: #ff66a5; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;"];window.console.log.apply(console,args)}else if(window.console){window.console.log("Pixi.js "+CONST.VERSION+" - "+type+" - http://www.pixijs.com/")}utils._saidHello=true},isWebGLSupported:function(){var contextOptions={stencil:true};try{if(!window.WebGLRenderingContext){return false}var canvas=document.createElement("canvas"),gl=canvas.getContext("webgl",contextOptions)||canvas.getContext("experimental-webgl",contextOptions);return!!(gl&&gl.getContextAttributes().stencil)}catch(e){return false}},sign:function(n){return n?n<0?-1:1:0},removeItems:function(arr,startIdx,removeCount){var length=arr.length;if(startIdx>=length||removeCount===0){return}removeCount=startIdx+removeCount>length?length-startIdx:removeCount;for(var i=startIdx,len=length-removeCount;i<len;++i){arr[i]=arr[i+removeCount]}arr.length=len},TextureCache:{},BaseTextureCache:{}}},{"../const":22,"./pluginTarget":78,async:1,eventemitter3:10}],78:[function(require,module,exports){function pluginTarget(obj){obj.__plugins={};obj.registerPlugin=function(pluginName,ctor){obj.__plugins[pluginName]=ctor};obj.prototype.initPlugins=function(){this.plugins=this.plugins||{};for(var o in obj.__plugins){this.plugins[o]=new obj.__plugins[o](this)}};obj.prototype.destroyPlugins=function(){for(var o in this.plugins){this.plugins[o].destroy();this.plugins[o]=null}this.plugins=null}}module.exports={mixin:function mixin(obj){pluginTarget(obj)}}},{}],79:[function(require,module,exports){var core=require("./core"),mesh=require("./mesh"),extras=require("./extras"),filters=require("./filters");core.SpriteBatch=function(){throw new ReferenceError("SpriteBatch does not exist any more, please use the new ParticleContainer instead.")};core.AssetLoader=function(){throw new ReferenceError("The loader system was overhauled in pixi v3, please see the new PIXI.loaders.Loader class.")};Object.defineProperties(core,{Stage:{get:function(){console.warn("You do not need to use a PIXI Stage any more, you can simply render any container.");return core.Container}},DisplayObjectContainer:{get:function(){console.warn("DisplayObjectContainer has been shortened to Container, please use Container from now on.");return core.Container}},Strip:{get:function(){console.warn("The Strip class has been renamed to Mesh and moved to mesh.Mesh, please use mesh.Mesh from now on.");return mesh.Mesh}},Rope:{get:function(){console.warn("The Rope class has been moved to mesh.Rope, please use mesh.Rope from now on.");return mesh.Rope}},MovieClip:{get:function(){console.warn("The MovieClip class has been moved to extras.MovieClip, please use extras.MovieClip from now on.");return extras.MovieClip}},TilingSprite:{get:function(){console.warn("The TilingSprite class has been moved to extras.TilingSprite, please use extras.TilingSprite from now on.");return extras.TilingSprite}},BitmapText:{get:function(){console.warn("The BitmapText class has been moved to extras.BitmapText, please use extras.BitmapText from now on.");return extras.BitmapText}},blendModes:{get:function(){console.warn("The blendModes has been moved to BLEND_MODES, please use BLEND_MODES from now on.");return core.BLEND_MODES}},scaleModes:{get:function(){console.warn("The scaleModes has been moved to SCALE_MODES, please use SCALE_MODES from now on.");return core.SCALE_MODES}},BaseTextureCache:{get:function(){console.warn("The BaseTextureCache class has been moved to utils.BaseTextureCache, please use utils.BaseTextureCache from now on.");return core.utils.BaseTextureCache}},TextureCache:{get:function(){console.warn("The TextureCache class has been moved to utils.TextureCache, please use utils.TextureCache from now on.");return core.utils.TextureCache}},math:{get:function(){console.warn("The math namespace is deprecated, please access members already accessible on PIXI.");return core}}});core.Sprite.prototype.setTexture=function(texture){this.texture=texture;console.warn("setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture;")};extras.BitmapText.prototype.setText=function(text){this.text=text;console.warn("setText is now deprecated, please use the text property, e.g : myBitmapText.text = 'my text';")};core.Text.prototype.setText=function(text){this.text=text;console.warn("setText is now deprecated, please use the text property, e.g : myText.text = 'my text';")};core.Text.prototype.setStyle=function(style){this.style=style;console.warn("setStyle is now deprecated, please use the style property, e.g : myText.style = style;")};core.Texture.prototype.setFrame=function(frame){this.frame=frame;console.warn("setFrame is now deprecated, please use the frame property, e.g : myTexture.frame = frame;")};Object.defineProperties(filters,{AbstractFilter:{get:function(){console.warn("filters.AbstractFilter is an undocumented alias, please use AbstractFilter from now on.");return core.AbstractFilter}},FXAAFilter:{get:function(){console.warn("filters.FXAAFilter is an undocumented alias, please use FXAAFilter from now on.");return core.FXAAFilter}},SpriteMaskFilter:{get:function(){console.warn("filters.SpriteMaskFilter is an undocumented alias, please use SpriteMaskFilter from now on.");return core.SpriteMaskFilter}}});core.utils.uuid=function(){console.warn("utils.uuid() is deprecated, please use utils.uid() from now on.");return core.utils.uid()}},{"./core":29,"./extras":86,"./filters":103,"./mesh":128}],80:[function(require,module,exports){var core=require("../core");function BitmapText(text,style){core.Container.call(this);style=style||{};this.textWidth=0;this.textHeight=0;this._glyphs=[];this._font={tint:style.tint!==undefined?style.tint:16777215,align:style.align||"left",name:null,size:0};this.font=style.font;this._text=text;this.maxWidth=0;this.maxLineHeight=0;this.dirty=false;this.updateText()}BitmapText.prototype=Object.create(core.Container.prototype);BitmapText.prototype.constructor=BitmapText;module.exports=BitmapText;Object.defineProperties(BitmapText.prototype,{tint:{get:function(){return this._font.tint},set:function(value){this._font.tint=typeof value==="number"&&value>=0?value:16777215;this.dirty=true}},align:{get:function(){return this._font.align},set:function(value){this._font.align=value||"left";this.dirty=true}},font:{get:function(){return this._font},set:function(value){if(!value){return}if(typeof value==="string"){value=value.split(" ");this._font.name=value.length===1?value[0]:value.slice(1).join(" ");this._font.size=value.length>=2?parseInt(value[0],10):BitmapText.fonts[this._font.name].size}else{this._font.name=value.name;this._font.size=typeof value.size==="number"?value.size:parseInt(value.size,10)}this.dirty=true}},text:{get:function(){return this._text},set:function(value){value=value.toString()||" ";if(this._text===value){return}this._text=value;this.dirty=true}}});BitmapText.prototype.updateText=function(){var data=BitmapText.fonts[this._font.name];var pos=new core.Point;var prevCharCode=null;var chars=[];var lastLineWidth=0;var maxLineWidth=0;var lineWidths=[];var line=0;var scale=this._font.size/data.size;var lastSpace=-1;var maxLineHeight=0;for(var i=0;i<this.text.length;i++){var charCode=this.text.charCodeAt(i);lastSpace=/(\s)/.test(this.text.charAt(i))?i:lastSpace;if(/(?:\r\n|\r|\n)/.test(this.text.charAt(i))){lineWidths.push(lastLineWidth);maxLineWidth=Math.max(maxLineWidth,lastLineWidth);
  10. line++;pos.x=0;pos.y+=data.lineHeight;prevCharCode=null;continue}if(lastSpace!==-1&&this.maxWidth>0&&pos.x*scale>this.maxWidth){core.utils.removeItems(chars,lastSpace,i-lastSpace);i=lastSpace;lastSpace=-1;lineWidths.push(lastLineWidth);maxLineWidth=Math.max(maxLineWidth,lastLineWidth);line++;pos.x=0;pos.y+=data.lineHeight;prevCharCode=null;continue}var charData=data.chars[charCode];if(!charData){continue}if(prevCharCode&&charData.kerning[prevCharCode]){pos.x+=charData.kerning[prevCharCode]}chars.push({texture:charData.texture,line:line,charCode:charCode,position:new core.Point(pos.x+charData.xOffset,pos.y+charData.yOffset)});lastLineWidth=pos.x+(charData.texture.width+charData.xOffset);pos.x+=charData.xAdvance;maxLineHeight=Math.max(maxLineHeight,charData.yOffset+charData.texture.height);prevCharCode=charCode}lineWidths.push(lastLineWidth);maxLineWidth=Math.max(maxLineWidth,lastLineWidth);var lineAlignOffsets=[];for(i=0;i<=line;i++){var alignOffset=0;if(this._font.align==="right"){alignOffset=maxLineWidth-lineWidths[i]}else if(this._font.align==="center"){alignOffset=(maxLineWidth-lineWidths[i])/2}lineAlignOffsets.push(alignOffset)}var lenChars=chars.length;var tint=this.tint;for(i=0;i<lenChars;i++){var c=this._glyphs[i];if(c){c.texture=chars[i].texture}else{c=new core.Sprite(chars[i].texture);this._glyphs.push(c)}c.position.x=(chars[i].position.x+lineAlignOffsets[chars[i].line])*scale;c.position.y=chars[i].position.y*scale;c.scale.x=c.scale.y=scale;c.tint=tint;if(!c.parent){this.addChild(c)}}for(i=lenChars;i<this._glyphs.length;++i){this.removeChild(this._glyphs[i])}this.textWidth=maxLineWidth*scale;this.textHeight=(pos.y+data.lineHeight)*scale;this.maxLineHeight=maxLineHeight*scale};BitmapText.prototype.updateTransform=function(){this.validate();this.containerUpdateTransform()};BitmapText.prototype.getLocalBounds=function(){this.validate();return core.Container.prototype.getLocalBounds.call(this)};BitmapText.prototype.validate=function(){if(this.dirty){this.updateText();this.dirty=false}};BitmapText.fonts={}},{"../core":29}],81:[function(require,module,exports){var core=require("../core");function MovieClip(textures){core.Sprite.call(this,textures[0]instanceof core.Texture?textures[0]:textures[0].texture);this._textures=null;this._durations=null;this.textures=textures;this.animationSpeed=1;this.loop=true;this.onComplete=null;this._currentTime=0;this.playing=false}MovieClip.prototype=Object.create(core.Sprite.prototype);MovieClip.prototype.constructor=MovieClip;module.exports=MovieClip;Object.defineProperties(MovieClip.prototype,{totalFrames:{get:function(){return this._textures.length}},textures:{get:function(){return this._textures},set:function(value){if(value[0]instanceof core.Texture){this._textures=value;this._durations=null}else{this._textures=[];this._durations=[];for(var i=0;i<value.length;i++){this._textures.push(value[i].texture);this._durations.push(value[i].time)}}}},currentFrame:{get:function(){var currentFrame=Math.floor(this._currentTime)%this._textures.length;if(currentFrame<0){currentFrame+=this._textures.length}return currentFrame}}});MovieClip.prototype.stop=function(){if(!this.playing){return}this.playing=false;core.ticker.shared.remove(this.update,this)};MovieClip.prototype.play=function(){if(this.playing){return}this.playing=true;core.ticker.shared.add(this.update,this)};MovieClip.prototype.gotoAndStop=function(frameNumber){this.stop();this._currentTime=frameNumber;this._texture=this._textures[this.currentFrame]};MovieClip.prototype.gotoAndPlay=function(frameNumber){this._currentTime=frameNumber;this.play()};MovieClip.prototype.update=function(deltaTime){var elapsed=this.animationSpeed*deltaTime;if(this._durations!==null){var lag=this._currentTime%1*this._durations[this.currentFrame];lag+=elapsed/60*1e3;while(lag<0){this._currentTime--;lag+=this._durations[this.currentFrame]}var sign=Math.sign(this.animationSpeed*deltaTime);this._currentTime=Math.floor(this._currentTime);while(lag>=this._durations[this.currentFrame]){lag-=this._durations[this.currentFrame]*sign;this._currentTime+=sign}this._currentTime+=lag/this._durations[this.currentFrame]}else{this._currentTime+=elapsed}if(this._currentTime<0&&!this.loop){this.gotoAndStop(0);if(this.onComplete){this.onComplete()}}else if(this._currentTime>=this._textures.length&&!this.loop){this.gotoAndStop(this._textures.length-1);if(this.onComplete){this.onComplete()}}else{this._texture=this._textures[this.currentFrame]}};MovieClip.prototype.destroy=function(){this.stop();core.Sprite.prototype.destroy.call(this)};MovieClip.fromFrames=function(frames){var textures=[];for(var i=0;i<frames.length;++i){textures.push(new core.Texture.fromFrame(frames[i]))}return new MovieClip(textures)};MovieClip.fromImages=function(images){var textures=[];for(var i=0;i<images.length;++i){textures.push(new core.Texture.fromImage(images[i]))}return new MovieClip(textures)}},{"../core":29}],82:[function(require,module,exports){var core=require("../core"),tempPoint=new core.Point,CanvasTinter=require("../core/renderers/canvas/utils/CanvasTinter");function TilingSprite(texture,width,height){core.Sprite.call(this,texture);this.tileScale=new core.Point(1,1);this.tilePosition=new core.Point(0,0);this._width=width||100;this._height=height||100;this._uvs=new core.TextureUvs;this._canvasPattern=null;this.shader=new core.AbstractFilter(["precision lowp float;","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","uniform mat3 projectionMatrix;","uniform vec4 uFrame;","uniform vec4 uTransform;","varying vec2 vTextureCoord;","varying vec4 vColor;","void main(void){"," gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vec2 coord = aTextureCoord;"," coord -= uTransform.xy;"," coord /= uTransform.zw;"," vTextureCoord = coord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);","}"].join("\n"),["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","uniform vec4 uFrame;","uniform vec2 uPixelSize;","void main(void){"," vec2 coord = mod(vTextureCoord, uFrame.zw);"," coord = clamp(coord, uPixelSize, uFrame.zw - uPixelSize);"," coord += uFrame.xy;"," gl_FragColor = texture2D(uSampler, coord) * vColor ;","}"].join("\n"),{uFrame:{type:"4fv",value:[0,0,1,1]},uTransform:{type:"4fv",value:[0,0,1,1]},uPixelSize:{type:"2fv",value:[1,1]}})}TilingSprite.prototype=Object.create(core.Sprite.prototype);TilingSprite.prototype.constructor=TilingSprite;module.exports=TilingSprite;Object.defineProperties(TilingSprite.prototype,{width:{get:function(){return this._width},set:function(value){this._width=value}},height:{get:function(){return this._height},set:function(value){this._height=value}}});TilingSprite.prototype._onTextureUpdate=function(){return};TilingSprite.prototype._renderWebGL=function(renderer){var texture=this._texture;if(!texture||!texture._uvs){return}var tempUvs=texture._uvs,tempWidth=texture._frame.width,tempHeight=texture._frame.height,tw=texture.baseTexture.width,th=texture.baseTexture.height;texture._uvs=this._uvs;texture._frame.width=this.width;texture._frame.height=this.height;this.shader.uniforms.uPixelSize.value[0]=1/tw;this.shader.uniforms.uPixelSize.value[1]=1/th;this.shader.uniforms.uFrame.value[0]=tempUvs.x0;this.shader.uniforms.uFrame.value[1]=tempUvs.y0;this.shader.uniforms.uFrame.value[2]=tempUvs.x1-tempUvs.x0;this.shader.uniforms.uFrame.value[3]=tempUvs.y2-tempUvs.y0;this.shader.uniforms.uTransform.value[0]=this.tilePosition.x%(tempWidth*this.tileScale.x)/this._width;this.shader.uniforms.uTransform.value[1]=this.tilePosition.y%(tempHeight*this.tileScale.y)/this._height;this.shader.uniforms.uTransform.value[2]=tw/this._width*this.tileScale.x;this.shader.uniforms.uTransform.value[3]=th/this._height*this.tileScale.y;renderer.setObjectRenderer(renderer.plugins.sprite);renderer.plugins.sprite.render(this);texture._uvs=tempUvs;texture._frame.width=tempWidth;texture._frame.height=tempHeight};TilingSprite.prototype._renderCanvas=function(renderer){var texture=this._texture;if(!texture.baseTexture.hasLoaded){return}var context=renderer.context,transform=this.worldTransform,resolution=renderer.resolution,baseTexture=texture.baseTexture,modX=this.tilePosition.x/this.tileScale.x%texture._frame.width,modY=this.tilePosition.y/this.tileScale.y%texture._frame.height;if(!this._canvasPattern){var tempCanvas=new core.CanvasBuffer(texture._frame.width*resolution,texture._frame.height*resolution);if(this.tint!==16777215){if(this.cachedTint!==this.tint){this.cachedTint=this.tint;this.tintedTexture=CanvasTinter.getTintedTexture(this,this.tint)}tempCanvas.context.drawImage(this.tintedTexture,0,0)}else{tempCanvas.context.drawImage(baseTexture.source,-texture._frame.x*resolution,-texture._frame.y*resolution)}this._canvasPattern=tempCanvas.context.createPattern(tempCanvas.canvas,"repeat")}context.globalAlpha=this.worldAlpha;context.setTransform(transform.a*resolution,transform.b*resolution,transform.c*resolution,transform.d*resolution,transform.tx*resolution,transform.ty*resolution);context.scale(this.tileScale.x/resolution,this.tileScale.y/resolution);context.translate(modX+this.anchor.x*-this._width,modY+this.anchor.y*-this._height);var compositeOperation=renderer.blendModes[this.blendMode];if(compositeOperation!==renderer.context.globalCompositeOperation){context.globalCompositeOperation=compositeOperation}context.fillStyle=this._canvasPattern;context.fillRect(-modX,-modY,this._width*resolution/this.tileScale.x,this._height*resolution/this.tileScale.y)};TilingSprite.prototype.getBounds=function(){var width=this._width;var height=this._height;var w0=width*(1-this.anchor.x);var w1=width*-this.anchor.x;var h0=height*(1-this.anchor.y);var h1=height*-this.anchor.y;var worldTransform=this.worldTransform;var a=worldTransform.a;var b=worldTransform.b;var c=worldTransform.c;var d=worldTransform.d;var tx=worldTransform.tx;var ty=worldTransform.ty;var x1=a*w1+c*h1+tx;var y1=d*h1+b*w1+ty;var x2=a*w0+c*h1+tx;var y2=d*h1+b*w0+ty;var x3=a*w0+c*h0+tx;var y3=d*h0+b*w0+ty;var x4=a*w1+c*h0+tx;var y4=d*h0+b*w1+ty;var minX,maxX,minY,maxY;minX=x1;minX=x2<minX?x2:minX;minX=x3<minX?x3:minX;minX=x4<minX?x4:minX;minY=y1;minY=y2<minY?y2:minY;minY=y3<minY?y3:minY;minY=y4<minY?y4:minY;maxX=x1;maxX=x2>maxX?x2:maxX;maxX=x3>maxX?x3:maxX;maxX=x4>maxX?x4:maxX;maxY=y1;maxY=y2>maxY?y2:maxY;maxY=y3>maxY?y3:maxY;maxY=y4>maxY?y4:maxY;var bounds=this._bounds;bounds.x=minX;bounds.width=maxX-minX;bounds.y=minY;bounds.height=maxY-minY;this._currentBounds=bounds;return bounds};TilingSprite.prototype.containsPoint=function(point){this.worldTransform.applyInverse(point,tempPoint);var width=this._width;var height=this._height;var x1=-width*this.anchor.x;var y1;if(tempPoint.x>x1&&tempPoint.x<x1+width){y1=-height*this.anchor.y;if(tempPoint.y>y1&&tempPoint.y<y1+height){return true}}return false};TilingSprite.prototype.destroy=function(){core.Sprite.prototype.destroy.call(this);this.tileScale=null;this._tileScaleOffset=null;this.tilePosition=null;this._uvs=null};TilingSprite.fromFrame=function(frameId,width,height){var texture=core.utils.TextureCache[frameId];if(!texture){throw new Error('The frameId "'+frameId+'" does not exist in the texture cache '+this)}return new TilingSprite(texture,width,height)};TilingSprite.fromImage=function(imageId,width,height,crossorigin,scaleMode){return new TilingSprite(core.Texture.fromImage(imageId,crossorigin,scaleMode),width,height)}},{"../core":29,"../core/renderers/canvas/utils/CanvasTinter":48}],83:[function(require,module,exports){var core=require("../core"),DisplayObject=core.DisplayObject,_tempMatrix=new core.Matrix;DisplayObject.prototype._cacheAsBitmap=false;DisplayObject.prototype._originalRenderWebGL=null;DisplayObject.prototype._originalRenderCanvas=null;DisplayObject.prototype._originalUpdateTransform=null;DisplayObject.prototype._originalHitTest=null;DisplayObject.prototype._originalDestroy=null;DisplayObject.prototype._cachedSprite=null;Object.defineProperties(DisplayObject.prototype,{cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(value){if(this._cacheAsBitmap===value){return}this._cacheAsBitmap=value;if(value){this._originalRenderWebGL=this.renderWebGL;this._originalRenderCanvas=this.renderCanvas;this._originalUpdateTransform=this.updateTransform;this._originalGetBounds=this.getBounds;this._originalDestroy=this.destroy;this._originalContainsPoint=this.containsPoint;this.renderWebGL=this._renderCachedWebGL;this.renderCanvas=this._renderCachedCanvas;this.destroy=this._cacheAsBitmapDestroy}else{if(this._cachedSprite){this._destroyCachedDisplayObject()}this.renderWebGL=this._originalRenderWebGL;this.renderCanvas=this._originalRenderCanvas;this.getBounds=this._originalGetBounds;this.destroy=this._originalDestroy;this.updateTransform=this._originalUpdateTransform;this.containsPoint=this._originalContainsPoint}}}});DisplayObject.prototype._renderCachedWebGL=function(renderer){if(!this.visible||this.worldAlpha<=0||!this.renderable){return}this._initCachedDisplayObject(renderer);this._cachedSprite.worldAlpha=this.worldAlpha;renderer.setObjectRenderer(renderer.plugins.sprite);renderer.plugins.sprite.render(this._cachedSprite)};DisplayObject.prototype._initCachedDisplayObject=function(renderer){if(this._cachedSprite){return}renderer.currentRenderer.flush();var bounds=this.getLocalBounds().clone();if(this._filters){var padding=this._filters[0].padding;bounds.x-=padding;bounds.y-=padding;bounds.width+=padding*2;bounds.height+=padding*2}var cachedRenderTarget=renderer.currentRenderTarget;var stack=renderer.filterManager.filterStack;var renderTexture=new core.RenderTexture(renderer,bounds.width|0,bounds.height|0);var m=_tempMatrix;m.tx=-bounds.x;m.ty=-bounds.y;this.renderWebGL=this._originalRenderWebGL;renderTexture.render(this,m,true,true);renderer.setRenderTarget(cachedRenderTarget);renderer.filterManager.filterStack=stack;this.renderWebGL=this._renderCachedWebGL;this.updateTransform=this.displayObjectUpdateTransform;this.getBounds=this._getCachedBounds;this._cachedSprite=new core.Sprite(renderTexture);this._cachedSprite.worldTransform=this.worldTransform;this._cachedSprite.anchor.x=-(bounds.x/bounds.width);this._cachedSprite.anchor.y=-(bounds.y/bounds.height);this.updateTransform();this.containsPoint=this._cachedSprite.containsPoint.bind(this._cachedSprite)};DisplayObject.prototype._renderCachedCanvas=function(renderer){if(!this.visible||this.worldAlpha<=0||!this.renderable){return}this._initCachedDisplayObjectCanvas(renderer);this._cachedSprite.worldAlpha=this.worldAlpha;this._cachedSprite.renderCanvas(renderer)};DisplayObject.prototype._initCachedDisplayObjectCanvas=function(renderer){if(this._cachedSprite){return}var bounds=this.getLocalBounds();var cachedRenderTarget=renderer.context;var renderTexture=new core.RenderTexture(renderer,bounds.width|0,bounds.height|0);var m=_tempMatrix;m.tx=-bounds.x;m.ty=-bounds.y;this.renderCanvas=this._originalRenderCanvas;renderTexture.render(this,m,true);renderer.context=cachedRenderTarget;this.renderCanvas=this._renderCachedCanvas;this.updateTransform=this.displayObjectUpdateTransform;this.getBounds=this._getCachedBounds;this._cachedSprite=new core.Sprite(renderTexture);this._cachedSprite.worldTransform=this.worldTransform;this._cachedSprite.anchor.x=-(bounds.x/bounds.width);this._cachedSprite.anchor.y=-(bounds.y/bounds.height);this.updateTransform();this.containsPoint=this._cachedSprite.containsPoint.bind(this._cachedSprite)};DisplayObject.prototype._getCachedBounds=function(){this._cachedSprite._currentBounds=null;return this._cachedSprite.getBounds()};DisplayObject.prototype._destroyCachedDisplayObject=function(){this._cachedSprite._texture.destroy();this._cachedSprite=null};DisplayObject.prototype._cacheAsBitmapDestroy=function(){this.cacheAsBitmap=false;this._originalDestroy()}},{"../core":29}],84:[function(require,module,exports){var core=require("../core");core.DisplayObject.prototype.name=null;core.Container.prototype.getChildByName=function(name){for(var i=0;i<this.children.length;i++){if(this.children[i].name===name){return this.children[i]}}return null}},{"../core":29}],85:[function(require,module,exports){var core=require("../core");core.DisplayObject.prototype.getGlobalPosition=function(point){point=point||new core.Point;if(this.parent){this.displayObjectUpdateTransform();point.x=this.worldTransform.tx;point.y=this.worldTransform.ty}else{point.x=this.position.x;point.y=this.position.y}return point}},{"../core":29}],86:[function(require,module,exports){require("./cacheAsBitmap");require("./getChildByName");require("./getGlobalPosition");module.exports={MovieClip:require("./MovieClip"),TilingSprite:require("./TilingSprite"),BitmapText:require("./BitmapText")}},{"./BitmapText":80,"./MovieClip":81,"./TilingSprite":82,"./cacheAsBitmap":83,"./getChildByName":84,"./getGlobalPosition":85}],87:[function(require,module,exports){var core=require("../../core");function AsciiFilter(){core.AbstractFilter.call(this,null,"precision mediump float;\n\nuniform vec4 dimensions;\nuniform float pixelSize;\nuniform sampler2D uSampler;\n\nfloat character(float n, vec2 p)\n{\n p = floor(p*vec2(4.0, -4.0) + 2.5);\n if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y)\n {\n if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0;\n }\n return 0.0;\n}\n\nvoid main()\n{\n vec2 uv = gl_FragCoord.xy;\n\n vec3 col = texture2D(uSampler, floor( uv / pixelSize ) * pixelSize / dimensions.xy).rgb;\n\n float gray = (col.r + col.g + col.b) / 3.0;\n\n float n = 65536.0; // .\n if (gray > 0.2) n = 65600.0; // :\n if (gray > 0.3) n = 332772.0; // *\n if (gray > 0.4) n = 15255086.0; // o\n if (gray > 0.5) n = 23385164.0; // &\n if (gray > 0.6) n = 15252014.0; // 8\n if (gray > 0.7) n = 13199452.0; // @\n if (gray > 0.8) n = 11512810.0; // #\n\n vec2 p = mod( uv / ( pixelSize * 0.5 ), 2.0) - vec2(1.0);\n col = col * character(n, p);\n\n gl_FragColor = vec4(col, 1.0);\n}\n",{dimensions:{type:"4fv",value:new Float32Array([0,0,0,0])},pixelSize:{type:"1f",value:8}})}AsciiFilter.prototype=Object.create(core.AbstractFilter.prototype);AsciiFilter.prototype.constructor=AsciiFilter;module.exports=AsciiFilter;Object.defineProperties(AsciiFilter.prototype,{size:{get:function(){return this.uniforms.pixelSize.value},set:function(value){this.uniforms.pixelSize.value=value}}})},{"../../core":29}],88:[function(require,module,exports){var core=require("../../core"),BlurXFilter=require("../blur/BlurXFilter"),BlurYFilter=require("../blur/BlurYFilter");function BloomFilter(){core.AbstractFilter.call(this);this.blurXFilter=new BlurXFilter;this.blurYFilter=new BlurYFilter;this.defaultFilter=new core.AbstractFilter}BloomFilter.prototype=Object.create(core.AbstractFilter.prototype);BloomFilter.prototype.constructor=BloomFilter;module.exports=BloomFilter;BloomFilter.prototype.applyFilter=function(renderer,input,output){var renderTarget=renderer.filterManager.getRenderTarget(true);this.defaultFilter.applyFilter(renderer,input,output);this.blurXFilter.applyFilter(renderer,input,renderTarget);renderer.blendModeManager.setBlendMode(core.BLEND_MODES.SCREEN);this.blurYFilter.applyFilter(renderer,renderTarget,output);renderer.blendModeManager.setBlendMode(core.BLEND_MODES.NORMAL);renderer.filterManager.returnRenderTarget(renderTarget)};Object.defineProperties(BloomFilter.prototype,{blur:{get:function(){return this.blurXFilter.blur},set:function(value){this.blurXFilter.blur=this.blurYFilter.blur=value}},blurX:{get:function(){return this.blurXFilter.blur},set:function(value){this.blurXFilter.blur=value}},blurY:{get:function(){return this.blurYFilter.blur},set:function(value){this.blurYFilter.blur=value}}})},{"../../core":29,"../blur/BlurXFilter":91,"../blur/BlurYFilter":92}],89:[function(require,module,exports){var core=require("../../core");function BlurDirFilter(dirX,dirY){core.AbstractFilter.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform float strength;\nuniform float dirX;\nuniform float dirY;\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying vec2 vBlurTexCoords[3];\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3((aVertexPosition), 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n\n vBlurTexCoords[0] = aTextureCoord + vec2( (0.004 * strength) * dirX, (0.004 * strength) * dirY );\n vBlurTexCoords[1] = aTextureCoord + vec2( (0.008 * strength) * dirX, (0.008 * strength) * dirY );\n vBlurTexCoords[2] = aTextureCoord + vec2( (0.012 * strength) * dirX, (0.012 * strength) * dirY );\n\n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}\n","precision lowp float;\n\nvarying vec2 vTextureCoord;\nvarying vec2 vBlurTexCoords[3];\nvarying vec4 vColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n gl_FragColor = vec4(0.0);\n\n gl_FragColor += texture2D(uSampler, vTextureCoord ) * 0.3989422804014327;\n gl_FragColor += texture2D(uSampler, vBlurTexCoords[ 0]) * 0.2419707245191454;\n gl_FragColor += texture2D(uSampler, vBlurTexCoords[ 1]) * 0.05399096651318985;\n gl_FragColor += texture2D(uSampler, vBlurTexCoords[ 2]) * 0.004431848411938341;\n}\n",{strength:{type:"1f",value:1},dirX:{type:"1f",value:dirX||0},dirY:{type:"1f",value:dirY||0}});this.defaultFilter=new core.AbstractFilter;this.passes=1;this.dirX=dirX||0;this.dirY=dirY||0;this.strength=4}BlurDirFilter.prototype=Object.create(core.AbstractFilter.prototype);BlurDirFilter.prototype.constructor=BlurDirFilter;module.exports=BlurDirFilter;BlurDirFilter.prototype.applyFilter=function(renderer,input,output,clear){var shader=this.getShader(renderer);this.uniforms.strength.value=this.strength/4/this.passes*(input.frame.width/input.size.width);if(this.passes===1){renderer.filterManager.applyFilter(shader,input,output,clear)}else{var renderTarget=renderer.filterManager.getRenderTarget(true);renderer.filterManager.applyFilter(shader,input,renderTarget,clear);for(var i=0;i<this.passes-2;i++){renderer.filterManager.applyFilter(shader,renderTarget,renderTarget,clear)}renderer.filterManager.applyFilter(shader,renderTarget,output,clear);renderer.filterManager.returnRenderTarget(renderTarget)}};Object.defineProperties(BlurDirFilter.prototype,{blur:{get:function(){return this.strength},set:function(value){this.padding=value*.5;this.strength=value}},dirX:{get:function(){return this.dirX},set:function(value){this.uniforms.dirX.value=value}},dirY:{get:function(){return this.dirY},set:function(value){this.uniforms.dirY.value=value}}})},{"../../core":29}],90:[function(require,module,exports){var core=require("../../core"),BlurXFilter=require("./BlurXFilter"),BlurYFilter=require("./BlurYFilter");function BlurFilter(){core.AbstractFilter.call(this);this.blurXFilter=new BlurXFilter;this.blurYFilter=new BlurYFilter}BlurFilter.prototype=Object.create(core.AbstractFilter.prototype);BlurFilter.prototype.constructor=BlurFilter;module.exports=BlurFilter;BlurFilter.prototype.applyFilter=function(renderer,input,output){var renderTarget=renderer.filterManager.getRenderTarget(true);this.blurXFilter.applyFilter(renderer,input,renderTarget);this.blurYFilter.applyFilter(renderer,renderTarget,output);renderer.filterManager.returnRenderTarget(renderTarget)};Object.defineProperties(BlurFilter.prototype,{blur:{get:function(){return this.blurXFilter.blur},set:function(value){this.padding=Math.abs(value)*.5;this.blurXFilter.blur=this.blurYFilter.blur=value}},passes:{get:function(){return this.blurXFilter.passes},set:function(value){this.blurXFilter.passes=this.blurYFilter.passes=value}},blurX:{get:function(){return this.blurXFilter.blur},set:function(value){this.blurXFilter.blur=value}},blurY:{get:function(){return this.blurYFilter.blur},set:function(value){this.blurYFilter.blur=value}}})},{"../../core":29,"./BlurXFilter":91,"./BlurYFilter":92}],91:[function(require,module,exports){var core=require("../../core");function BlurXFilter(){core.AbstractFilter.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform float strength;\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying vec2 vBlurTexCoords[6];\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3((aVertexPosition), 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n\n vBlurTexCoords[ 0] = aTextureCoord + vec2(-0.012 * strength, 0.0);\n vBlurTexCoords[ 1] = aTextureCoord + vec2(-0.008 * strength, 0.0);\n vBlurTexCoords[ 2] = aTextureCoord + vec2(-0.004 * strength, 0.0);\n vBlurTexCoords[ 3] = aTextureCoord + vec2( 0.004 * strength, 0.0);\n vBlurTexCoords[ 4] = aTextureCoord + vec2( 0.008 * strength, 0.0);\n vBlurTexCoords[ 5] = aTextureCoord + vec2( 0.012 * strength, 0.0);\n\n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}\n","precision lowp float;\n\nvarying vec2 vTextureCoord;\nvarying vec2 vBlurTexCoords[6];\nvarying vec4 vColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n gl_FragColor = vec4(0.0);\n\n gl_FragColor += texture2D(uSampler, vBlurTexCoords[ 0])*0.004431848411938341;\n gl_FragColor += texture2D(uSampler, vBlurTexCoords[ 1])*0.05399096651318985;\n gl_FragColor += texture2D(uSampler, vBlurTexCoords[ 2])*0.2419707245191454;\n gl_FragColor += texture2D(uSampler, vTextureCoord )*0.3989422804014327;\n gl_FragColor += texture2D(uSampler, vBlurTexCoords[ 3])*0.2419707245191454;\n gl_FragColor += texture2D(uSampler, vBlurTexCoords[ 4])*0.05399096651318985;\n gl_FragColor += texture2D(uSampler, vBlurTexCoords[ 5])*0.004431848411938341;\n}\n",{strength:{type:"1f",value:1}});this.passes=1;this.strength=4}BlurXFilter.prototype=Object.create(core.AbstractFilter.prototype);BlurXFilter.prototype.constructor=BlurXFilter;module.exports=BlurXFilter;BlurXFilter.prototype.applyFilter=function(renderer,input,output,clear){var shader=this.getShader(renderer);this.uniforms.strength.value=this.strength/4/this.passes*(input.frame.width/input.size.width);if(this.passes===1){renderer.filterManager.applyFilter(shader,input,output,clear)}else{var renderTarget=renderer.filterManager.getRenderTarget(true);var flip=input;var flop=renderTarget;for(var i=0;i<this.passes-1;i++){renderer.filterManager.applyFilter(shader,flip,flop,true);var temp=flop;flop=flip;flip=temp}renderer.filterManager.applyFilter(shader,flip,output,clear);renderer.filterManager.returnRenderTarget(renderTarget)}};Object.defineProperties(BlurXFilter.prototype,{blur:{get:function(){return this.strength},set:function(value){this.padding=Math.abs(value)*.5;this.strength=value}}})},{"../../core":29}],92:[function(require,module,exports){var core=require("../../core");function BlurYFilter(){core.AbstractFilter.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform float strength;\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying vec2 vBlurTexCoords[6];\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3((aVertexPosition), 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n\n vBlurTexCoords[ 0] = aTextureCoord + vec2(0.0, -0.012 * strength);\n vBlurTexCoords[ 1] = aTextureCoord + vec2(0.0, -0.008 * strength);\n vBlurTexCoords[ 2] = aTextureCoord + vec2(0.0, -0.004 * strength);\n vBlurTexCoords[ 3] = aTextureCoord + vec2(0.0, 0.004 * strength);\n vBlurTexCoords[ 4] = aTextureCoord + vec2(0.0, 0.008 * strength);\n vBlurTexCoords[ 5] = aTextureCoord + vec2(0.0, 0.012 * strength);\n\n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}\n","precision lowp float;\n\nvarying vec2 vTextureCoord;\nvarying vec2 vBlurTexCoords[6];\nvarying vec4 vColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n gl_FragColor = vec4(0.0);\n\n gl_FragColor += texture2D(uSampler, vBlurTexCoords[ 0])*0.004431848411938341;\n gl_FragColor += texture2D(uSampler, vBlurTexCoords[ 1])*0.05399096651318985;\n gl_FragColor += texture2D(uSampler, vBlurTexCoords[ 2])*0.2419707245191454;\n gl_FragColor += texture2D(uSampler, vTextureCoord )*0.3989422804014327;\n gl_FragColor += texture2D(uSampler, vBlurTexCoords[ 3])*0.2419707245191454;\n gl_FragColor += texture2D(uSampler, vBlurTexCoords[ 4])*0.05399096651318985;\n gl_FragColor += texture2D(uSampler, vBlurTexCoords[ 5])*0.004431848411938341;\n}\n",{strength:{type:"1f",value:1}});this.passes=1;this.strength=4}BlurYFilter.prototype=Object.create(core.AbstractFilter.prototype);BlurYFilter.prototype.constructor=BlurYFilter;module.exports=BlurYFilter;BlurYFilter.prototype.applyFilter=function(renderer,input,output,clear){var shader=this.getShader(renderer);this.uniforms.strength.value=Math.abs(this.strength)/4/this.passes*(input.frame.height/input.size.height);if(this.passes===1){renderer.filterManager.applyFilter(shader,input,output,clear)}else{var renderTarget=renderer.filterManager.getRenderTarget(true);var flip=input;var flop=renderTarget;for(var i=0;i<this.passes-1;i++){renderer.filterManager.applyFilter(shader,flip,flop,true);var temp=flop;flop=flip;flip=temp}renderer.filterManager.applyFilter(shader,flip,output,clear);renderer.filterManager.returnRenderTarget(renderTarget)}};Object.defineProperties(BlurYFilter.prototype,{blur:{get:function(){return this.strength},set:function(value){this.padding=Math.abs(value)*.5;this.strength=value}}})},{"../../core":29}],93:[function(require,module,exports){var core=require("../../core");function SmartBlurFilter(){core.AbstractFilter.call(this,null,"precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec2 delta;\n\nfloat random(vec3 scale, float seed)\n{\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n\n for (float t = -30.0; t <= 30.0; t++)\n {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 sample = texture2D(uSampler, vTextureCoord + delta * percent);\n sample.rgb *= sample.a;\n color += sample * weight;\n total += weight;\n }\n\n gl_FragColor = color / total;\n gl_FragColor.rgb /= gl_FragColor.a + 0.00001;\n}\n",{delta:{type:"v2",value:{x:.1,y:0}}})}SmartBlurFilter.prototype=Object.create(core.AbstractFilter.prototype);SmartBlurFilter.prototype.constructor=SmartBlurFilter;module.exports=SmartBlurFilter},{"../../core":29}],94:[function(require,module,exports){var core=require("../../core");function ColorMatrixFilter(){core.AbstractFilter.call(this,null,"precision mediump float;\n\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float m[25];\n\nvoid main(void)\n{\n\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n gl_FragColor.r = (m[0] * c.r);\n gl_FragColor.r += (m[1] * c.g);\n gl_FragColor.r += (m[2] * c.b);\n gl_FragColor.r += (m[3] * c.a);\n gl_FragColor.r += m[4] * c.a;\n\n gl_FragColor.g = (m[5] * c.r);\n gl_FragColor.g += (m[6] * c.g);\n gl_FragColor.g += (m[7] * c.b);\n gl_FragColor.g += (m[8] * c.a);\n gl_FragColor.g += m[9] * c.a;\n\n gl_FragColor.b = (m[10] * c.r);\n gl_FragColor.b += (m[11] * c.g);\n gl_FragColor.b += (m[12] * c.b);\n gl_FragColor.b += (m[13] * c.a);\n gl_FragColor.b += m[14] * c.a;\n\n gl_FragColor.a = (m[15] * c.r);\n gl_FragColor.a += (m[16] * c.g);\n gl_FragColor.a += (m[17] * c.b);\n gl_FragColor.a += (m[18] * c.a);\n gl_FragColor.a += m[19] * c.a;\n\n}\n",{m:{type:"1fv",value:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]}})}ColorMatrixFilter.prototype=Object.create(core.AbstractFilter.prototype);
  11. ColorMatrixFilter.prototype.constructor=ColorMatrixFilter;module.exports=ColorMatrixFilter;ColorMatrixFilter.prototype._loadMatrix=function(matrix,multiply){multiply=!!multiply;var newMatrix=matrix;if(multiply){this._multiply(newMatrix,this.uniforms.m.value,matrix);newMatrix=this._colorMatrix(newMatrix)}this.uniforms.m.value=newMatrix};ColorMatrixFilter.prototype._multiply=function(out,a,b){out[0]=a[0]*b[0]+a[1]*b[5]+a[2]*b[10]+a[3]*b[15];out[1]=a[0]*b[1]+a[1]*b[6]+a[2]*b[11]+a[3]*b[16];out[2]=a[0]*b[2]+a[1]*b[7]+a[2]*b[12]+a[3]*b[17];out[3]=a[0]*b[3]+a[1]*b[8]+a[2]*b[13]+a[3]*b[18];out[4]=a[0]*b[4]+a[1]*b[9]+a[2]*b[14]+a[3]*b[19];out[5]=a[5]*b[0]+a[6]*b[5]+a[7]*b[10]+a[8]*b[15];out[6]=a[5]*b[1]+a[6]*b[6]+a[7]*b[11]+a[8]*b[16];out[7]=a[5]*b[2]+a[6]*b[7]+a[7]*b[12]+a[8]*b[17];out[8]=a[5]*b[3]+a[6]*b[8]+a[7]*b[13]+a[8]*b[18];out[9]=a[5]*b[4]+a[6]*b[9]+a[7]*b[14]+a[8]*b[19];out[10]=a[10]*b[0]+a[11]*b[5]+a[12]*b[10]+a[13]*b[15];out[11]=a[10]*b[1]+a[11]*b[6]+a[12]*b[11]+a[13]*b[16];out[12]=a[10]*b[2]+a[11]*b[7]+a[12]*b[12]+a[13]*b[17];out[13]=a[10]*b[3]+a[11]*b[8]+a[12]*b[13]+a[13]*b[18];out[14]=a[10]*b[4]+a[11]*b[9]+a[12]*b[14]+a[13]*b[19];out[15]=a[15]*b[0]+a[16]*b[5]+a[17]*b[10]+a[18]*b[15];out[16]=a[15]*b[1]+a[16]*b[6]+a[17]*b[11]+a[18]*b[16];out[17]=a[15]*b[2]+a[16]*b[7]+a[17]*b[12]+a[18]*b[17];out[18]=a[15]*b[3]+a[16]*b[8]+a[17]*b[13]+a[18]*b[18];out[19]=a[15]*b[4]+a[16]*b[9]+a[17]*b[14]+a[18]*b[19];return out};ColorMatrixFilter.prototype._colorMatrix=function(matrix){var m=new Float32Array(matrix);m[4]/=255;m[9]/=255;m[14]/=255;m[19]/=255;return m};ColorMatrixFilter.prototype.brightness=function(b,multiply){var matrix=[b,0,0,0,0,0,b,0,0,0,0,0,b,0,0,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.greyscale=function(scale,multiply){var matrix=[scale,scale,scale,0,0,scale,scale,scale,0,0,scale,scale,scale,0,0,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.grayscale=ColorMatrixFilter.prototype.greyscale;ColorMatrixFilter.prototype.blackAndWhite=function(multiply){var matrix=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.hue=function(rotation,multiply){rotation=(rotation||0)/180*Math.PI;var cos=Math.cos(rotation),sin=Math.sin(rotation);var lumR=.213,lumG=.715,lumB=.072;var matrix=[lumR+cos*(1-lumR)+sin*-lumR,lumG+cos*-lumG+sin*-lumG,lumB+cos*-lumB+sin*(1-lumB),0,0,lumR+cos*-lumR+sin*.143,lumG+cos*(1-lumG)+sin*.14,lumB+cos*-lumB+sin*-.283,0,0,lumR+cos*-lumR+sin*-(1-lumR),lumG+cos*-lumG+sin*lumG,lumB+cos*(1-lumB)+sin*lumB,0,0,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.contrast=function(amount,multiply){var v=(amount||0)+1;var o=-128*(v-1);var matrix=[v,0,0,0,o,0,v,0,0,o,0,0,v,0,o,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.saturate=function(amount,multiply){var x=(amount||0)*2/3+1;var y=(x-1)*-.5;var matrix=[x,y,y,0,0,y,x,y,0,0,y,y,x,0,0,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.desaturate=function(multiply){this.saturate(-1)};ColorMatrixFilter.prototype.negative=function(multiply){var matrix=[0,1,1,0,0,1,0,1,0,0,1,1,0,0,0,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.sepia=function(multiply){var matrix=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.technicolor=function(multiply){var matrix=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.polaroid=function(multiply){var matrix=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.toBGR=function(multiply){var matrix=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.kodachrome=function(multiply){var matrix=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.browni=function(multiply){var matrix=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.vintage=function(multiply){var matrix=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.colorTone=function(desaturation,toned,lightColor,darkColor,multiply){desaturation=desaturation||.2;toned=toned||.15;lightColor=lightColor||16770432;darkColor=darkColor||3375104;var lR=(lightColor>>16&255)/255;var lG=(lightColor>>8&255)/255;var lB=(lightColor&255)/255;var dR=(darkColor>>16&255)/255;var dG=(darkColor>>8&255)/255;var dB=(darkColor&255)/255;var matrix=[.3,.59,.11,0,0,lR,lG,lB,desaturation,0,dR,dG,dB,toned,0,lR-dR,lG-dG,lB-dB,0,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.night=function(intensity,multiply){intensity=intensity||.1;var matrix=[intensity*-2,-intensity,0,0,0,-intensity,0,intensity,0,0,0,intensity,intensity*2,0,0,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.predator=function(amount,multiply){var matrix=[11.224130630493164*amount,-4.794486999511719*amount,-2.8746118545532227*amount,0*amount,.40342438220977783*amount,-3.6330697536468506*amount,9.193157196044922*amount,-2.951810836791992*amount,0*amount,-1.316135048866272*amount,-3.2184197902679443*amount,-4.2375030517578125*amount,7.476448059082031*amount,0*amount,.8044459223747253*amount,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.lsd=function(multiply){var matrix=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(matrix,multiply)};ColorMatrixFilter.prototype.reset=function(){var matrix=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(matrix,false)};Object.defineProperties(ColorMatrixFilter.prototype,{matrix:{get:function(){return this.uniforms.m.value},set:function(value){this.uniforms.m.value=value}}})},{"../../core":29}],95:[function(require,module,exports){var core=require("../../core");function ColorStepFilter(){core.AbstractFilter.call(this,null,"precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float step;\n\nvoid main(void)\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n\n color = floor(color * step) / step;\n\n gl_FragColor = color;\n}\n",{step:{type:"1f",value:5}})}ColorStepFilter.prototype=Object.create(core.AbstractFilter.prototype);ColorStepFilter.prototype.constructor=ColorStepFilter;module.exports=ColorStepFilter;Object.defineProperties(ColorStepFilter.prototype,{step:{get:function(){return this.uniforms.step.value},set:function(value){this.uniforms.step.value=value}}})},{"../../core":29}],96:[function(require,module,exports){var core=require("../../core");function ConvolutionFilter(matrix,width,height){core.AbstractFilter.call(this,null,"precision mediump float;\n\nvarying mediump vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec2 texelSize;\nuniform float matrix[9];\n\nvoid main(void)\n{\n vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left\n vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center\n vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right\n\n vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left\n vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center\n vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right\n\n vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left\n vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center\n vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right\n\n gl_FragColor =\n c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] +\n c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] +\n c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8];\n\n gl_FragColor.a = c22.a;\n}\n",{matrix:{type:"1fv",value:new Float32Array(matrix)},texelSize:{type:"v2",value:{x:1/width,y:1/height}}})}ConvolutionFilter.prototype=Object.create(core.AbstractFilter.prototype);ConvolutionFilter.prototype.constructor=ConvolutionFilter;module.exports=ConvolutionFilter;Object.defineProperties(ConvolutionFilter.prototype,{matrix:{get:function(){return this.uniforms.matrix.value},set:function(value){this.uniforms.matrix.value=new Float32Array(value)}},width:{get:function(){return 1/this.uniforms.texelSize.value.x},set:function(value){this.uniforms.texelSize.value.x=1/value}},height:{get:function(){return 1/this.uniforms.texelSize.value.y},set:function(value){this.uniforms.texelSize.value.y=1/value}}})},{"../../core":29}],97:[function(require,module,exports){var core=require("../../core");function CrossHatchFilter(){core.AbstractFilter.call(this,null,"precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb);\n\n gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\n\n if (lum < 1.00)\n {\n if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0)\n {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n if (lum < 0.75)\n {\n if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0)\n {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n if (lum < 0.50)\n {\n if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0)\n {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n\n if (lum < 0.3)\n {\n if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0)\n {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n }\n }\n}\n")}CrossHatchFilter.prototype=Object.create(core.AbstractFilter.prototype);CrossHatchFilter.prototype.constructor=CrossHatchFilter;module.exports=CrossHatchFilter},{"../../core":29}],98:[function(require,module,exports){var core=require("../../core");function DisplacementFilter(sprite,scale){var maskMatrix=new core.Matrix;sprite.renderable=false;core.AbstractFilter.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec2 vMapCoord;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n vMapCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;\n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}\n","precision mediump float;\n\nvarying vec2 vMapCoord;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform vec2 scale;\n\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vMapCoord);\n\n map -= 0.5;\n map.xy *= scale;\n\n gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y));\n}\n",{mapSampler:{type:"sampler2D",value:sprite.texture},otherMatrix:{type:"mat3",value:maskMatrix.toArray(true)},scale:{type:"v2",value:{x:1,y:1}}});this.maskSprite=sprite;this.maskMatrix=maskMatrix;if(scale===null||scale===undefined){scale=20}this.scale=new core.Point(scale,scale)}DisplacementFilter.prototype=Object.create(core.AbstractFilter.prototype);DisplacementFilter.prototype.constructor=DisplacementFilter;module.exports=DisplacementFilter;DisplacementFilter.prototype.applyFilter=function(renderer,input,output){var filterManager=renderer.filterManager;filterManager.calculateMappedMatrix(input.frame,this.maskSprite,this.maskMatrix);this.uniforms.otherMatrix.value=this.maskMatrix.toArray(true);this.uniforms.scale.value.x=this.scale.x*(1/input.frame.width);this.uniforms.scale.value.y=this.scale.y*(1/input.frame.height);var shader=this.getShader(renderer);filterManager.applyFilter(shader,input,output)};Object.defineProperties(DisplacementFilter.prototype,{map:{get:function(){return this.uniforms.mapSampler.value},set:function(value){this.uniforms.mapSampler.value=value}}})},{"../../core":29}],99:[function(require,module,exports){var core=require("../../core");function DotScreenFilter(){core.AbstractFilter.call(this,null,"precision mediump float;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform vec4 dimensions;\nuniform sampler2D uSampler;\n\nuniform float angle;\nuniform float scale;\n\nfloat pattern()\n{\n float s = sin(angle), c = cos(angle);\n vec2 tex = vTextureCoord * dimensions.xy;\n vec2 point = vec2(\n c * tex.x - s * tex.y,\n s * tex.x + c * tex.y\n ) * scale;\n return (sin(point.x) * sin(point.y)) * 4.0;\n}\n\nvoid main()\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n float average = (color.r + color.g + color.b) / 3.0;\n gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a);\n}\n",{scale:{type:"1f",value:1},angle:{type:"1f",value:5},dimensions:{type:"4fv",value:[0,0,0,0]}})}DotScreenFilter.prototype=Object.create(core.AbstractFilter.prototype);DotScreenFilter.prototype.constructor=DotScreenFilter;module.exports=DotScreenFilter;Object.defineProperties(DotScreenFilter.prototype,{scale:{get:function(){return this.uniforms.scale.value},set:function(value){this.uniforms.scale.value=value}},angle:{get:function(){return this.uniforms.angle.value},set:function(value){this.uniforms.angle.value=value}}})},{"../../core":29}],100:[function(require,module,exports){var core=require("../../core");function BlurYTintFilter(){core.AbstractFilter.call(this,"attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform float strength;\nuniform vec2 offset;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying vec2 vBlurTexCoords[6];\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3((aVertexPosition+offset), 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n\n vBlurTexCoords[ 0] = aTextureCoord + vec2(0.0, -0.012 * strength);\n vBlurTexCoords[ 1] = aTextureCoord + vec2(0.0, -0.008 * strength);\n vBlurTexCoords[ 2] = aTextureCoord + vec2(0.0, -0.004 * strength);\n vBlurTexCoords[ 3] = aTextureCoord + vec2(0.0, 0.004 * strength);\n vBlurTexCoords[ 4] = aTextureCoord + vec2(0.0, 0.008 * strength);\n vBlurTexCoords[ 5] = aTextureCoord + vec2(0.0, 0.012 * strength);\n\n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}\n","precision lowp float;\n\nvarying vec2 vTextureCoord;\nvarying vec2 vBlurTexCoords[6];\nvarying vec4 vColor;\n\nuniform vec3 color;\nuniform float alpha;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n vec4 sum = vec4(0.0);\n\n sum += texture2D(uSampler, vBlurTexCoords[ 0])*0.004431848411938341;\n sum += texture2D(uSampler, vBlurTexCoords[ 1])*0.05399096651318985;\n sum += texture2D(uSampler, vBlurTexCoords[ 2])*0.2419707245191454;\n sum += texture2D(uSampler, vTextureCoord )*0.3989422804014327;\n sum += texture2D(uSampler, vBlurTexCoords[ 3])*0.2419707245191454;\n sum += texture2D(uSampler, vBlurTexCoords[ 4])*0.05399096651318985;\n sum += texture2D(uSampler, vBlurTexCoords[ 5])*0.004431848411938341;\n\n gl_FragColor = vec4( color.rgb * sum.a * alpha, sum.a * alpha );\n}\n",{blur:{type:"1f",value:1/512},color:{type:"c",value:[0,0,0]},alpha:{type:"1f",value:.7},offset:{type:"2f",value:[5,5]},strength:{type:"1f",value:1}});this.passes=1;this.strength=4}BlurYTintFilter.prototype=Object.create(core.AbstractFilter.prototype);BlurYTintFilter.prototype.constructor=BlurYTintFilter;module.exports=BlurYTintFilter;BlurYTintFilter.prototype.applyFilter=function(renderer,input,output,clear){var shader=this.getShader(renderer);this.uniforms.strength.value=this.strength/4/this.passes*(input.frame.height/input.size.height);if(this.passes===1){renderer.filterManager.applyFilter(shader,input,output,clear)}else{var renderTarget=renderer.filterManager.getRenderTarget(true);var flip=input;var flop=renderTarget;for(var i=0;i<this.passes-1;i++){renderer.filterManager.applyFilter(shader,flip,flop,clear);var temp=flop;flop=flip;flip=temp}renderer.filterManager.applyFilter(shader,flip,output,clear);renderer.filterManager.returnRenderTarget(renderTarget)}};Object.defineProperties(BlurYTintFilter.prototype,{blur:{get:function(){return this.strength},set:function(value){this.padding=value*.5;this.strength=value}}})},{"../../core":29}],101:[function(require,module,exports){var core=require("../../core"),BlurXFilter=require("../blur/BlurXFilter"),BlurYTintFilter=require("./BlurYTintFilter");function DropShadowFilter(){core.AbstractFilter.call(this);this.blurXFilter=new BlurXFilter;this.blurYTintFilter=new BlurYTintFilter;this.defaultFilter=new core.AbstractFilter;this.padding=30;this._dirtyPosition=true;this._angle=45*Math.PI/180;this._distance=10;this.alpha=.75;this.hideObject=false;this.blendMode=core.BLEND_MODES.MULTIPLY}DropShadowFilter.prototype=Object.create(core.AbstractFilter.prototype);DropShadowFilter.prototype.constructor=DropShadowFilter;module.exports=DropShadowFilter;DropShadowFilter.prototype.applyFilter=function(renderer,input,output){var renderTarget=renderer.filterManager.getRenderTarget(true);if(this._dirtyPosition){this._dirtyPosition=false;this.blurYTintFilter.uniforms.offset.value[0]=Math.sin(this._angle)*this._distance;this.blurYTintFilter.uniforms.offset.value[1]=Math.cos(this._angle)*this._distance}this.blurXFilter.applyFilter(renderer,input,renderTarget);renderer.blendModeManager.setBlendMode(this.blendMode);this.blurYTintFilter.applyFilter(renderer,renderTarget,output);renderer.blendModeManager.setBlendMode(core.BLEND_MODES.NORMAL);if(!this.hideObject){this.defaultFilter.applyFilter(renderer,input,output)}renderer.filterManager.returnRenderTarget(renderTarget)};Object.defineProperties(DropShadowFilter.prototype,{blur:{get:function(){return this.blurXFilter.blur},set:function(value){this.blurXFilter.blur=this.blurYTintFilter.blur=value}},blurX:{get:function(){return this.blurXFilter.blur},set:function(value){this.blurXFilter.blur=value}},blurY:{get:function(){return this.blurYTintFilter.blur},set:function(value){this.blurYTintFilter.blur=value}},color:{get:function(){return core.utils.rgb2hex(this.blurYTintFilter.uniforms.color.value)},set:function(value){this.blurYTintFilter.uniforms.color.value=core.utils.hex2rgb(value)}},alpha:{get:function(){return this.blurYTintFilter.uniforms.alpha.value},set:function(value){this.blurYTintFilter.uniforms.alpha.value=value}},distance:{get:function(){return this._distance},set:function(value){this._dirtyPosition=true;this._distance=value}},angle:{get:function(){return this._angle},set:function(value){this._dirtyPosition=true;this._angle=value}}})},{"../../core":29,"../blur/BlurXFilter":91,"./BlurYTintFilter":100}],102:[function(require,module,exports){var core=require("../../core");function GrayFilter(){core.AbstractFilter.call(this,null,"precision mediump float;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform sampler2D uSampler;\nuniform float gray;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), gray);\n}\n",{gray:{type:"1f",value:1}})}GrayFilter.prototype=Object.create(core.AbstractFilter.prototype);GrayFilter.prototype.constructor=GrayFilter;module.exports=GrayFilter;Object.defineProperties(GrayFilter.prototype,{gray:{get:function(){return this.uniforms.gray.value},set:function(value){this.uniforms.gray.value=value}}})},{"../../core":29}],103:[function(require,module,exports){module.exports={AsciiFilter:require("./ascii/AsciiFilter"),BloomFilter:require("./bloom/BloomFilter"),BlurFilter:require("./blur/BlurFilter"),BlurXFilter:require("./blur/BlurXFilter"),BlurYFilter:require("./blur/BlurYFilter"),BlurDirFilter:require("./blur/BlurDirFilter"),ColorMatrixFilter:require("./color/ColorMatrixFilter"),ColorStepFilter:require("./color/ColorStepFilter"),ConvolutionFilter:require("./convolution/ConvolutionFilter"),CrossHatchFilter:require("./crosshatch/CrossHatchFilter"),DisplacementFilter:require("./displacement/DisplacementFilter"),DotScreenFilter:require("./dot/DotScreenFilter"),GrayFilter:require("./gray/GrayFilter"),DropShadowFilter:require("./dropshadow/DropShadowFilter"),InvertFilter:require("./invert/InvertFilter"),NoiseFilter:require("./noise/NoiseFilter"),PixelateFilter:require("./pixelate/PixelateFilter"),RGBSplitFilter:require("./rgb/RGBSplitFilter"),ShockwaveFilter:require("./shockwave/ShockwaveFilter"),SepiaFilter:require("./sepia/SepiaFilter"),SmartBlurFilter:require("./blur/SmartBlurFilter"),TiltShiftFilter:require("./tiltshift/TiltShiftFilter"),TiltShiftXFilter:require("./tiltshift/TiltShiftXFilter"),TiltShiftYFilter:require("./tiltshift/TiltShiftYFilter"),TwistFilter:require("./twist/TwistFilter")}},{"./ascii/AsciiFilter":87,"./bloom/BloomFilter":88,"./blur/BlurDirFilter":89,"./blur/BlurFilter":90,"./blur/BlurXFilter":91,"./blur/BlurYFilter":92,"./blur/SmartBlurFilter":93,"./color/ColorMatrixFilter":94,"./color/ColorStepFilter":95,"./convolution/ConvolutionFilter":96,"./crosshatch/CrossHatchFilter":97,"./displacement/DisplacementFilter":98,"./dot/DotScreenFilter":99,"./dropshadow/DropShadowFilter":101,"./gray/GrayFilter":102,"./invert/InvertFilter":104,"./noise/NoiseFilter":105,"./pixelate/PixelateFilter":106,"./rgb/RGBSplitFilter":107,"./sepia/SepiaFilter":108,"./shockwave/ShockwaveFilter":109,"./tiltshift/TiltShiftFilter":111,"./tiltshift/TiltShiftXFilter":112,"./tiltshift/TiltShiftYFilter":113,"./twist/TwistFilter":114}],104:[function(require,module,exports){var core=require("../../core");function InvertFilter(){core.AbstractFilter.call(this,null,"precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform float invert;\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n\n gl_FragColor.rgb = mix( (vec3(1)-gl_FragColor.rgb) * gl_FragColor.a, gl_FragColor.rgb, 1.0 - invert);\n}\n",{invert:{type:"1f",value:1}})}InvertFilter.prototype=Object.create(core.AbstractFilter.prototype);InvertFilter.prototype.constructor=InvertFilter;module.exports=InvertFilter;Object.defineProperties(InvertFilter.prototype,{invert:{get:function(){return this.uniforms.invert.value},set:function(value){this.uniforms.invert.value=value}}})},{"../../core":29}],105:[function(require,module,exports){var core=require("../../core");function NoiseFilter(){core.AbstractFilter.call(this,null,"precision highp float;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform float noise;\nuniform sampler2D uSampler;\n\nfloat rand(vec2 co)\n{\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main()\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n\n float diff = (rand(vTextureCoord) - 0.5) * noise;\n\n color.r += diff;\n color.g += diff;\n color.b += diff;\n\n gl_FragColor = color;\n}\n",{noise:{type:"1f",value:.5}})}NoiseFilter.prototype=Object.create(core.AbstractFilter.prototype);NoiseFilter.prototype.constructor=NoiseFilter;module.exports=NoiseFilter;Object.defineProperties(NoiseFilter.prototype,{noise:{get:function(){return this.uniforms.noise.value},set:function(value){this.uniforms.noise.value=value}}})},{"../../core":29}],106:[function(require,module,exports){var core=require("../../core");function PixelateFilter(){core.AbstractFilter.call(this,null,"precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform vec4 dimensions;\nuniform vec2 pixelSize;\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n vec2 coord = vTextureCoord;\n\n vec2 size = dimensions.xy / pixelSize;\n\n vec2 color = floor( ( vTextureCoord * size ) ) / size + pixelSize/dimensions.xy * 0.5;\n\n gl_FragColor = texture2D(uSampler, color);\n}\n",{dimensions:{type:"4fv",value:new Float32Array([0,0,0,0])},pixelSize:{type:"v2",value:{x:10,y:10}}})}PixelateFilter.prototype=Object.create(core.AbstractFilter.prototype);PixelateFilter.prototype.constructor=PixelateFilter;module.exports=PixelateFilter;Object.defineProperties(PixelateFilter.prototype,{size:{get:function(){return this.uniforms.pixelSize.value},set:function(value){this.uniforms.pixelSize.value=value}}})},{"../../core":29}],107:[function(require,module,exports){var core=require("../../core");function RGBSplitFilter(){core.AbstractFilter.call(this,null,"precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 dimensions;\nuniform vec2 red;\nuniform vec2 green;\nuniform vec2 blue;\n\nvoid main(void)\n{\n gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/dimensions.xy).r;\n gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/dimensions.xy).g;\n gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/dimensions.xy).b;\n gl_FragColor.a = texture2D(uSampler, vTextureCoord).a;\n}\n",{red:{type:"v2",value:{x:20,y:20}},green:{type:"v2",value:{x:-20,y:20}},blue:{type:"v2",value:{x:20,y:-20}},dimensions:{type:"4fv",value:[0,0,0,0]}})}RGBSplitFilter.prototype=Object.create(core.AbstractFilter.prototype);RGBSplitFilter.prototype.constructor=RGBSplitFilter;module.exports=RGBSplitFilter;Object.defineProperties(RGBSplitFilter.prototype,{red:{get:function(){return this.uniforms.red.value},set:function(value){this.uniforms.red.value=value}},green:{get:function(){return this.uniforms.green.value},set:function(value){this.uniforms.green.value=value}},blue:{get:function(){return this.uniforms.blue.value},set:function(value){this.uniforms.blue.value=value}}})},{"../../core":29}],108:[function(require,module,exports){var core=require("../../core");function SepiaFilter(){core.AbstractFilter.call(this,null,"precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float sepia;\n\nconst mat3 sepiaMatrix = mat3(0.3588, 0.7044, 0.1368, 0.2990, 0.5870, 0.1140, 0.2392, 0.4696, 0.0912);\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb * sepiaMatrix, sepia);\n}\n",{sepia:{type:"1f",value:1}})}SepiaFilter.prototype=Object.create(core.AbstractFilter.prototype);SepiaFilter.prototype.constructor=SepiaFilter;module.exports=SepiaFilter;Object.defineProperties(SepiaFilter.prototype,{sepia:{get:function(){return this.uniforms.sepia.value},set:function(value){this.uniforms.sepia.value=value}}})},{"../../core":29}],109:[function(require,module,exports){var core=require("../../core");function ShockwaveFilter(){core.AbstractFilter.call(this,null,"precision lowp float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nuniform vec2 center;\nuniform vec3 params; // 10.0, 0.8, 0.1\nuniform float time;\n\nvoid main()\n{\n vec2 uv = vTextureCoord;\n vec2 texCoord = uv;\n\n float dist = distance(uv, center);\n\n if ( (dist <= (time + params.z)) && (dist >= (time - params.z)) )\n {\n float diff = (dist - time);\n float powDiff = 1.0 - pow(abs(diff*params.x), params.y);\n\n float diffTime = diff * powDiff;\n vec2 diffUV = normalize(uv - center);\n texCoord = uv + (diffUV * diffTime);\n }\n\n gl_FragColor = texture2D(uSampler, texCoord);\n}\n",{center:{type:"v2",value:{x:.5,y:.5}},params:{type:"v3",value:{x:10,y:.8,z:.1}},time:{type:"1f",value:0}})}ShockwaveFilter.prototype=Object.create(core.AbstractFilter.prototype);ShockwaveFilter.prototype.constructor=ShockwaveFilter;module.exports=ShockwaveFilter;Object.defineProperties(ShockwaveFilter.prototype,{center:{get:function(){return this.uniforms.center.value},set:function(value){this.uniforms.center.value=value}},params:{get:function(){return this.uniforms.params.value},set:function(value){this.uniforms.params.value=value}},time:{get:function(){return this.uniforms.time.value},set:function(value){this.uniforms.time.value=value}}})},{"../../core":29}],110:[function(require,module,exports){var core=require("../../core");function TiltShiftAxisFilter(){core.AbstractFilter.call(this,null,"precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float blur;\nuniform float gradientBlur;\nuniform vec2 start;\nuniform vec2 end;\nuniform vec2 delta;\nuniform vec2 texSize;\n\nfloat random(vec3 scale, float seed)\n{\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n}\n\nvoid main(void)\n{\n vec4 color = vec4(0.0);\n float total = 0.0;\n\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n vec2 normal = normalize(vec2(start.y - end.y, end.x - start.x));\n float radius = smoothstep(0.0, 1.0, abs(dot(vTextureCoord * texSize - start, normal)) / gradientBlur) * blur;\n\n for (float t = -30.0; t <= 30.0; t++)\n {\n float percent = (t + offset - 0.5) / 30.0;\n float weight = 1.0 - abs(percent);\n vec4 sample = texture2D(uSampler, vTextureCoord + delta / texSize * percent * radius);\n sample.rgb *= sample.a;\n color += sample * weight;\n total += weight;\n }\n\n gl_FragColor = color / total;\n gl_FragColor.rgb /= gl_FragColor.a + 0.00001;\n}\n",{blur:{type:"1f",value:100},gradientBlur:{type:"1f",value:600},start:{type:"v2",value:{x:0,y:window.innerHeight/2}},end:{type:"v2",value:{x:600,y:window.innerHeight/2}},delta:{type:"v2",value:{x:30,y:30}},texSize:{type:"v2",value:{x:window.innerWidth,y:window.innerHeight}}});this.updateDelta()}TiltShiftAxisFilter.prototype=Object.create(core.AbstractFilter.prototype);TiltShiftAxisFilter.prototype.constructor=TiltShiftAxisFilter;module.exports=TiltShiftAxisFilter;TiltShiftAxisFilter.prototype.updateDelta=function(){this.uniforms.delta.value.x=0;this.uniforms.delta.value.y=0};Object.defineProperties(TiltShiftAxisFilter.prototype,{blur:{get:function(){return this.uniforms.blur.value},set:function(value){this.uniforms.blur.value=value}},gradientBlur:{get:function(){return this.uniforms.gradientBlur.value},set:function(value){this.uniforms.gradientBlur.value=value}},start:{get:function(){return this.uniforms.start.value},set:function(value){this.uniforms.start.value=value;this.updateDelta()}},end:{get:function(){return this.uniforms.end.value},set:function(value){this.uniforms.end.value=value;this.updateDelta()}}})},{"../../core":29}],111:[function(require,module,exports){var core=require("../../core"),TiltShiftXFilter=require("./TiltShiftXFilter"),TiltShiftYFilter=require("./TiltShiftYFilter");function TiltShiftFilter(){core.AbstractFilter.call(this);this.tiltShiftXFilter=new TiltShiftXFilter;this.tiltShiftYFilter=new TiltShiftYFilter}TiltShiftFilter.prototype=Object.create(core.AbstractFilter.prototype);TiltShiftFilter.prototype.constructor=TiltShiftFilter;module.exports=TiltShiftFilter;TiltShiftFilter.prototype.applyFilter=function(renderer,input,output){
  12. var renderTarget=renderer.filterManager.getRenderTarget(true);this.tiltShiftXFilter.applyFilter(renderer,input,renderTarget);this.tiltShiftYFilter.applyFilter(renderer,renderTarget,output);renderer.filterManager.returnRenderTarget(renderTarget)};Object.defineProperties(TiltShiftFilter.prototype,{blur:{get:function(){return this.tiltShiftXFilter.blur},set:function(value){this.tiltShiftXFilter.blur=this.tiltShiftYFilter.blur=value}},gradientBlur:{get:function(){return this.tiltShiftXFilter.gradientBlur},set:function(value){this.tiltShiftXFilter.gradientBlur=this.tiltShiftYFilter.gradientBlur=value}},start:{get:function(){return this.tiltShiftXFilter.start},set:function(value){this.tiltShiftXFilter.start=this.tiltShiftYFilter.start=value}},end:{get:function(){return this.tiltShiftXFilter.end},set:function(value){this.tiltShiftXFilter.end=this.tiltShiftYFilter.end=value}}})},{"../../core":29,"./TiltShiftXFilter":112,"./TiltShiftYFilter":113}],112:[function(require,module,exports){var TiltShiftAxisFilter=require("./TiltShiftAxisFilter");function TiltShiftXFilter(){TiltShiftAxisFilter.call(this)}TiltShiftXFilter.prototype=Object.create(TiltShiftAxisFilter.prototype);TiltShiftXFilter.prototype.constructor=TiltShiftXFilter;module.exports=TiltShiftXFilter;TiltShiftXFilter.prototype.updateDelta=function(){var dx=this.uniforms.end.value.x-this.uniforms.start.value.x;var dy=this.uniforms.end.value.y-this.uniforms.start.value.y;var d=Math.sqrt(dx*dx+dy*dy);this.uniforms.delta.value.x=dx/d;this.uniforms.delta.value.y=dy/d}},{"./TiltShiftAxisFilter":110}],113:[function(require,module,exports){var TiltShiftAxisFilter=require("./TiltShiftAxisFilter");function TiltShiftYFilter(){TiltShiftAxisFilter.call(this)}TiltShiftYFilter.prototype=Object.create(TiltShiftAxisFilter.prototype);TiltShiftYFilter.prototype.constructor=TiltShiftYFilter;module.exports=TiltShiftYFilter;TiltShiftYFilter.prototype.updateDelta=function(){var dx=this.uniforms.end.value.x-this.uniforms.start.value.x;var dy=this.uniforms.end.value.y-this.uniforms.start.value.y;var d=Math.sqrt(dx*dx+dy*dy);this.uniforms.delta.value.x=-dy/d;this.uniforms.delta.value.y=dx/d}},{"./TiltShiftAxisFilter":110}],114:[function(require,module,exports){var core=require("../../core");function TwistFilter(){core.AbstractFilter.call(this,null,"precision mediump float;\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float radius;\nuniform float angle;\nuniform vec2 offset;\n\nvoid main(void)\n{\n vec2 coord = vTextureCoord - offset;\n float dist = length(coord);\n\n if (dist < radius)\n {\n float ratio = (radius - dist) / radius;\n float angleMod = ratio * ratio * angle;\n float s = sin(angleMod);\n float c = cos(angleMod);\n coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);\n }\n\n gl_FragColor = texture2D(uSampler, coord+offset);\n}\n",{radius:{type:"1f",value:.5},angle:{type:"1f",value:5},offset:{type:"v2",value:{x:.5,y:.5}}})}TwistFilter.prototype=Object.create(core.AbstractFilter.prototype);TwistFilter.prototype.constructor=TwistFilter;module.exports=TwistFilter;Object.defineProperties(TwistFilter.prototype,{offset:{get:function(){return this.uniforms.offset.value},set:function(value){this.uniforms.offset.value=value}},radius:{get:function(){return this.uniforms.radius.value},set:function(value){this.uniforms.radius.value=value}},angle:{get:function(){return this.uniforms.angle.value},set:function(value){this.uniforms.angle.value=value}}})},{"../../core":29}],115:[function(require,module,exports){(function(global){require("./polyfill");var core=module.exports=require("./core");core.extras=require("./extras");core.filters=require("./filters");core.interaction=require("./interaction");core.loaders=require("./loaders");core.mesh=require("./mesh");core.accessibility=require("./accessibility");core.loader=new core.loaders.Loader;Object.assign(core,require("./deprecation"));global.PIXI=core}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./accessibility":21,"./core":29,"./deprecation":79,"./extras":86,"./filters":103,"./interaction":118,"./loaders":121,"./mesh":128,"./polyfill":133}],116:[function(require,module,exports){var core=require("../core");function InteractionData(){this.global=new core.Point;this.target=null;this.originalEvent=null}InteractionData.prototype.constructor=InteractionData;module.exports=InteractionData;InteractionData.prototype.getLocalPosition=function(displayObject,point,globalPos){return displayObject.worldTransform.applyInverse(globalPos||this.global,point)}},{"../core":29}],117:[function(require,module,exports){var core=require("../core"),InteractionData=require("./InteractionData");Object.assign(core.DisplayObject.prototype,require("./interactiveTarget"));function InteractionManager(renderer,options){options=options||{};this.renderer=renderer;this.autoPreventDefault=options.autoPreventDefault!==undefined?options.autoPreventDefault:true;this.interactionFrequency=options.interactionFrequency||10;this.mouse=new InteractionData;this.eventData={stopped:false,target:null,type:null,data:this.mouse,stopPropagation:function(){this.stopped=true}};this.interactiveDataPool=[];this.interactionDOMElement=null;this.moveWhenInside=false;this.eventsAdded=false;this.onMouseUp=this.onMouseUp.bind(this);this.processMouseUp=this.processMouseUp.bind(this);this.onMouseDown=this.onMouseDown.bind(this);this.processMouseDown=this.processMouseDown.bind(this);this.onMouseMove=this.onMouseMove.bind(this);this.processMouseMove=this.processMouseMove.bind(this);this.onMouseOut=this.onMouseOut.bind(this);this.processMouseOverOut=this.processMouseOverOut.bind(this);this.onTouchStart=this.onTouchStart.bind(this);this.processTouchStart=this.processTouchStart.bind(this);this.onTouchEnd=this.onTouchEnd.bind(this);this.processTouchEnd=this.processTouchEnd.bind(this);this.onTouchMove=this.onTouchMove.bind(this);this.processTouchMove=this.processTouchMove.bind(this);this.last=0;this.currentCursorStyle="inherit";this._tempPoint=new core.Point;this.resolution=1;this.setTargetElement(this.renderer.view,this.renderer.resolution)}InteractionManager.prototype.constructor=InteractionManager;module.exports=InteractionManager;InteractionManager.prototype.setTargetElement=function(element,resolution){this.removeEvents();this.interactionDOMElement=element;this.resolution=resolution||1;this.addEvents()};InteractionManager.prototype.addEvents=function(){if(!this.interactionDOMElement){return}core.ticker.shared.add(this.update,this);if(window.navigator.msPointerEnabled){this.interactionDOMElement.style["-ms-content-zooming"]="none";this.interactionDOMElement.style["-ms-touch-action"]="none"}window.document.addEventListener("mousemove",this.onMouseMove,true);this.interactionDOMElement.addEventListener("mousedown",this.onMouseDown,true);this.interactionDOMElement.addEventListener("mouseout",this.onMouseOut,true);this.interactionDOMElement.addEventListener("touchstart",this.onTouchStart,true);this.interactionDOMElement.addEventListener("touchend",this.onTouchEnd,true);this.interactionDOMElement.addEventListener("touchmove",this.onTouchMove,true);window.addEventListener("mouseup",this.onMouseUp,true);this.eventsAdded=true};InteractionManager.prototype.removeEvents=function(){if(!this.interactionDOMElement){return}core.ticker.shared.remove(this.update);if(window.navigator.msPointerEnabled){this.interactionDOMElement.style["-ms-content-zooming"]="";this.interactionDOMElement.style["-ms-touch-action"]=""}window.document.removeEventListener("mousemove",this.onMouseMove,true);this.interactionDOMElement.removeEventListener("mousedown",this.onMouseDown,true);this.interactionDOMElement.removeEventListener("mouseout",this.onMouseOut,true);this.interactionDOMElement.removeEventListener("touchstart",this.onTouchStart,true);this.interactionDOMElement.removeEventListener("touchend",this.onTouchEnd,true);this.interactionDOMElement.removeEventListener("touchmove",this.onTouchMove,true);this.interactionDOMElement=null;window.removeEventListener("mouseup",this.onMouseUp,true);this.eventsAdded=false};InteractionManager.prototype.update=function(deltaTime){this._deltaTime+=deltaTime;if(this._deltaTime<this.interactionFrequency){return}this._deltaTime=0;if(!this.interactionDOMElement){return}if(this.didMove){this.didMove=false;return}this.cursor="inherit";this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseOverOut,true);if(this.currentCursorStyle!==this.cursor){this.currentCursorStyle=this.cursor;this.interactionDOMElement.style.cursor=this.cursor}};InteractionManager.prototype.dispatchEvent=function(displayObject,eventString,eventData){if(!eventData.stopped){eventData.target=displayObject;eventData.type=eventString;displayObject.emit(eventString,eventData);if(displayObject[eventString]){displayObject[eventString](eventData)}}};InteractionManager.prototype.mapPositionToPoint=function(point,x,y){var rect=this.interactionDOMElement.getBoundingClientRect();point.x=(x-rect.left)*(this.interactionDOMElement.width/rect.width)/this.resolution;point.y=(y-rect.top)*(this.interactionDOMElement.height/rect.height)/this.resolution};InteractionManager.prototype.processInteractive=function(point,displayObject,func,hitTest,interactive){if(!displayObject||!displayObject.visible){return false}var hit=false,interactiveParent=interactive=displayObject.interactive||interactive;if(displayObject.hitArea){interactiveParent=false}if(displayObject.interactiveChildren){var children=displayObject.children;for(var i=children.length-1;i>=0;i--){var child=children[i];if(this.processInteractive(point,child,func,hitTest,interactiveParent)){if(!child.parent){continue}hit=true;interactiveParent=false;hitTest=false}}}if(interactive){if(hitTest&&!hit){if(displayObject.hitArea){displayObject.worldTransform.applyInverse(point,this._tempPoint);hit=displayObject.hitArea.contains(this._tempPoint.x,this._tempPoint.y)}else if(displayObject.containsPoint){hit=displayObject.containsPoint(point)}}if(displayObject.interactive){func(displayObject,hit)}}return hit};InteractionManager.prototype.onMouseDown=function(event){this.mouse.originalEvent=event;this.eventData.data=this.mouse;this.eventData.stopped=false;this.mapPositionToPoint(this.mouse.global,event.clientX,event.clientY);if(this.autoPreventDefault){this.mouse.originalEvent.preventDefault()}this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseDown,true)};InteractionManager.prototype.processMouseDown=function(displayObject,hit){var e=this.mouse.originalEvent;var isRightButton=e.button===2||e.which===3;if(hit){displayObject[isRightButton?"_isRightDown":"_isLeftDown"]=true;this.dispatchEvent(displayObject,isRightButton?"rightdown":"mousedown",this.eventData)}};InteractionManager.prototype.onMouseUp=function(event){this.mouse.originalEvent=event;this.eventData.data=this.mouse;this.eventData.stopped=false;this.mapPositionToPoint(this.mouse.global,event.clientX,event.clientY);this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseUp,true)};InteractionManager.prototype.processMouseUp=function(displayObject,hit){var e=this.mouse.originalEvent;var isRightButton=e.button===2||e.which===3;var isDown=isRightButton?"_isRightDown":"_isLeftDown";if(hit){this.dispatchEvent(displayObject,isRightButton?"rightup":"mouseup",this.eventData);if(displayObject[isDown]){displayObject[isDown]=false;this.dispatchEvent(displayObject,isRightButton?"rightclick":"click",this.eventData)}}else{if(displayObject[isDown]){displayObject[isDown]=false;this.dispatchEvent(displayObject,isRightButton?"rightupoutside":"mouseupoutside",this.eventData)}}};InteractionManager.prototype.onMouseMove=function(event){this.mouse.originalEvent=event;this.eventData.data=this.mouse;this.eventData.stopped=false;this.mapPositionToPoint(this.mouse.global,event.clientX,event.clientY);this.didMove=true;this.cursor="inherit";this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseMove,true);if(this.currentCursorStyle!==this.cursor){this.currentCursorStyle=this.cursor;this.interactionDOMElement.style.cursor=this.cursor}};InteractionManager.prototype.processMouseMove=function(displayObject,hit){this.processMouseOverOut(displayObject,hit);if(!this.moveWhenInside||hit){this.dispatchEvent(displayObject,"mousemove",this.eventData)}};InteractionManager.prototype.onMouseOut=function(event){this.mouse.originalEvent=event;this.eventData.stopped=false;this.mapPositionToPoint(this.mouse.global,event.clientX,event.clientY);this.interactionDOMElement.style.cursor="inherit";this.mapPositionToPoint(this.mouse.global,event.clientX,event.clientY);this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseOverOut,false)};InteractionManager.prototype.processMouseOverOut=function(displayObject,hit){if(hit){if(!displayObject._over){displayObject._over=true;this.dispatchEvent(displayObject,"mouseover",this.eventData)}if(displayObject.buttonMode){this.cursor=displayObject.defaultCursor}}else{if(displayObject._over){displayObject._over=false;this.dispatchEvent(displayObject,"mouseout",this.eventData)}}};InteractionManager.prototype.onTouchStart=function(event){if(this.autoPreventDefault){event.preventDefault()}var changedTouches=event.changedTouches;var cLength=changedTouches.length;for(var i=0;i<cLength;i++){var touchEvent=changedTouches[i];var touchData=this.getTouchData(touchEvent);touchData.originalEvent=event;this.eventData.data=touchData;this.eventData.stopped=false;this.processInteractive(touchData.global,this.renderer._lastObjectRendered,this.processTouchStart,true);this.returnTouchData(touchData)}};InteractionManager.prototype.processTouchStart=function(displayObject,hit){if(hit){displayObject._touchDown=true;this.dispatchEvent(displayObject,"touchstart",this.eventData)}};InteractionManager.prototype.onTouchEnd=function(event){if(this.autoPreventDefault){event.preventDefault()}var changedTouches=event.changedTouches;var cLength=changedTouches.length;for(var i=0;i<cLength;i++){var touchEvent=changedTouches[i];var touchData=this.getTouchData(touchEvent);touchData.originalEvent=event;this.eventData.data=touchData;this.eventData.stopped=false;this.processInteractive(touchData.global,this.renderer._lastObjectRendered,this.processTouchEnd,true);this.returnTouchData(touchData)}};InteractionManager.prototype.processTouchEnd=function(displayObject,hit){if(hit){this.dispatchEvent(displayObject,"touchend",this.eventData);if(displayObject._touchDown){displayObject._touchDown=false;this.dispatchEvent(displayObject,"tap",this.eventData)}}else{if(displayObject._touchDown){displayObject._touchDown=false;this.dispatchEvent(displayObject,"touchendoutside",this.eventData)}}};InteractionManager.prototype.onTouchMove=function(event){if(this.autoPreventDefault){event.preventDefault()}var changedTouches=event.changedTouches;var cLength=changedTouches.length;for(var i=0;i<cLength;i++){var touchEvent=changedTouches[i];var touchData=this.getTouchData(touchEvent);touchData.originalEvent=event;this.eventData.data=touchData;this.eventData.stopped=false;this.processInteractive(touchData.global,this.renderer._lastObjectRendered,this.processTouchMove,this.moveWhenInside);this.returnTouchData(touchData)}};InteractionManager.prototype.processTouchMove=function(displayObject,hit){if(!this.moveWhenInside||hit){this.dispatchEvent(displayObject,"touchmove",this.eventData)}};InteractionManager.prototype.getTouchData=function(touchEvent){var touchData=this.interactiveDataPool.pop();if(!touchData){touchData=new InteractionData}touchData.identifier=touchEvent.identifier;this.mapPositionToPoint(touchData.global,touchEvent.clientX,touchEvent.clientY);if(navigator.isCocoonJS){touchData.global.x=touchData.global.x/this.resolution;touchData.global.y=touchData.global.y/this.resolution}touchEvent.globalX=touchData.global.x;touchEvent.globalY=touchData.global.y;return touchData};InteractionManager.prototype.returnTouchData=function(touchData){this.interactiveDataPool.push(touchData)};InteractionManager.prototype.destroy=function(){this.removeEvents();this.renderer=null;this.mouse=null;this.eventData=null;this.interactiveDataPool=null;this.interactionDOMElement=null;this.onMouseUp=null;this.processMouseUp=null;this.onMouseDown=null;this.processMouseDown=null;this.onMouseMove=null;this.processMouseMove=null;this.onMouseOut=null;this.processMouseOverOut=null;this.onTouchStart=null;this.processTouchStart=null;this.onTouchEnd=null;this.processTouchEnd=null;this.onTouchMove=null;this.processTouchMove=null;this._tempPoint=null};core.WebGLRenderer.registerPlugin("interaction",InteractionManager);core.CanvasRenderer.registerPlugin("interaction",InteractionManager)},{"../core":29,"./InteractionData":116,"./interactiveTarget":119}],118:[function(require,module,exports){module.exports={InteractionData:require("./InteractionData"),InteractionManager:require("./InteractionManager"),interactiveTarget:require("./interactiveTarget")}},{"./InteractionData":116,"./InteractionManager":117,"./interactiveTarget":119}],119:[function(require,module,exports){var interactiveTarget={interactive:false,buttonMode:false,interactiveChildren:true,defaultCursor:"pointer",_over:false,_touchDown:false};module.exports=interactiveTarget},{}],120:[function(require,module,exports){var Resource=require("resource-loader").Resource,core=require("../core"),extras=require("../extras"),path=require("path");function parse(resource,texture){var data={};var info=resource.data.getElementsByTagName("info")[0];var common=resource.data.getElementsByTagName("common")[0];data.font=info.getAttribute("face");data.size=parseInt(info.getAttribute("size"),10);data.lineHeight=parseInt(common.getAttribute("lineHeight"),10);data.chars={};var letters=resource.data.getElementsByTagName("char");for(var i=0;i<letters.length;i++){var charCode=parseInt(letters[i].getAttribute("id"),10);var textureRect=new core.Rectangle(parseInt(letters[i].getAttribute("x"),10)+texture.frame.x,parseInt(letters[i].getAttribute("y"),10)+texture.frame.y,parseInt(letters[i].getAttribute("width"),10),parseInt(letters[i].getAttribute("height"),10));data.chars[charCode]={xOffset:parseInt(letters[i].getAttribute("xoffset"),10),yOffset:parseInt(letters[i].getAttribute("yoffset"),10),xAdvance:parseInt(letters[i].getAttribute("xadvance"),10),kerning:{},texture:new core.Texture(texture.baseTexture,textureRect)}}var kernings=resource.data.getElementsByTagName("kerning");for(i=0;i<kernings.length;i++){var first=parseInt(kernings[i].getAttribute("first"),10);var second=parseInt(kernings[i].getAttribute("second"),10);var amount=parseInt(kernings[i].getAttribute("amount"),10);if(data.chars[second]){data.chars[second].kerning[first]=amount}}resource.bitmapFont=data;extras.BitmapText.fonts[data.font]=data}module.exports=function(){return function(resource,next){if(!resource.data||!resource.isXml){return next()}if(resource.data.getElementsByTagName("page").length===0||resource.data.getElementsByTagName("info").length===0||resource.data.getElementsByTagName("info")[0].getAttribute("face")===null){return next()}var xmlUrl=path.dirname(resource.url);if(xmlUrl==="."){xmlUrl=""}if(this.baseUrl&&xmlUrl){if(this.baseUrl.charAt(this.baseUrl.length-1)==="/"){xmlUrl+="/"}xmlUrl=xmlUrl.replace(this.baseUrl,"")}if(xmlUrl&&xmlUrl.charAt(xmlUrl.length-1)!=="/"){xmlUrl+="/"}var textureUrl=xmlUrl+resource.data.getElementsByTagName("page")[0].getAttribute("file");if(core.utils.TextureCache[textureUrl]){parse(resource,core.utils.TextureCache[textureUrl]);next()}else{var loadOptions={crossOrigin:resource.crossOrigin,loadType:Resource.LOAD_TYPE.IMAGE,metadata:resource.metadata.imageMetadata};this.add(resource.name+"_image",textureUrl,loadOptions,function(res){parse(resource,res.texture);next()})}}}},{"../core":29,"../extras":86,path:2,"resource-loader":16}],121:[function(require,module,exports){module.exports={Loader:require("./loader"),bitmapFontParser:require("./bitmapFontParser"),spritesheetParser:require("./spritesheetParser"),textureParser:require("./textureParser"),Resource:require("resource-loader").Resource}},{"./bitmapFontParser":120,"./loader":122,"./spritesheetParser":123,"./textureParser":124,"resource-loader":16}],122:[function(require,module,exports){var ResourceLoader=require("resource-loader"),textureParser=require("./textureParser"),spritesheetParser=require("./spritesheetParser"),bitmapFontParser=require("./bitmapFontParser");function Loader(baseUrl,concurrency){ResourceLoader.call(this,baseUrl,concurrency);for(var i=0;i<Loader._pixiMiddleware.length;++i){this.use(Loader._pixiMiddleware[i]())}}Loader.prototype=Object.create(ResourceLoader.prototype);Loader.prototype.constructor=Loader;module.exports=Loader;Loader._pixiMiddleware=[ResourceLoader.middleware.parsing.blob,textureParser,spritesheetParser,bitmapFontParser];Loader.addPixiMiddleware=function(fn){Loader._pixiMiddleware.push(fn)};var Resource=ResourceLoader.Resource;Resource.setExtensionXhrType("fnt",Resource.XHR_RESPONSE_TYPE.DOCUMENT)},{"./bitmapFontParser":120,"./spritesheetParser":123,"./textureParser":124,"resource-loader":16}],123:[function(require,module,exports){var Resource=require("resource-loader").Resource,path=require("path"),core=require("../core"),async=require("async");var BATCH_SIZE=1e3;module.exports=function(){return function(resource,next){var imageResourceName=resource.name+"_image";if(!resource.data||!resource.isJson||!resource.data.frames||this.resources[imageResourceName]){return next()}var loadOptions={crossOrigin:resource.crossOrigin,loadType:Resource.LOAD_TYPE.IMAGE,metadata:resource.metadata.imageMetadata};var route=path.dirname(resource.url.replace(this.baseUrl,""));this.add(imageResourceName,route+"/"+resource.data.meta.image,loadOptions,function(res){resource.textures={};var frames=resource.data.frames;var frameKeys=Object.keys(frames);var resolution=core.utils.getResolutionOfUrl(resource.url);var batchIndex=0;function processFrames(initialFrameIndex,maxFrames){var frameIndex=initialFrameIndex;while(frameIndex-initialFrameIndex<maxFrames&&frameIndex<frameKeys.length){var frame=frames[frameKeys[frameIndex]];var rect=frame.frame;if(rect){var size=null;var trim=null;if(frame.rotated){size=new core.Rectangle(rect.x,rect.y,rect.h,rect.w)}else{size=new core.Rectangle(rect.x,rect.y,rect.w,rect.h)}if(frame.trimmed){trim=new core.Rectangle(frame.spriteSourceSize.x/resolution,frame.spriteSourceSize.y/resolution,frame.sourceSize.w/resolution,frame.sourceSize.h/resolution)}if(frame.rotated){var temp=size.width;size.width=size.height;size.height=temp}size.x/=resolution;size.y/=resolution;size.width/=resolution;size.height/=resolution;resource.textures[frameKeys[frameIndex]]=new core.Texture(res.texture.baseTexture,size,size.clone(),trim,frame.rotated);core.utils.TextureCache[frameKeys[frameIndex]]=resource.textures[frameKeys[frameIndex]]}frameIndex++}}function shouldProcessNextBatch(){return batchIndex*BATCH_SIZE<frameKeys.length}function processNextBatch(done){processFrames(batchIndex*BATCH_SIZE,BATCH_SIZE);batchIndex++;setTimeout(done,0)}if(frameKeys.length<=BATCH_SIZE){processFrames(0,BATCH_SIZE);next()}else{async.whilst(shouldProcessNextBatch,processNextBatch,next)}})}}},{"../core":29,async:1,path:2,"resource-loader":16}],124:[function(require,module,exports){var core=require("../core");module.exports=function(){return function(resource,next){if(resource.data&&resource.isImage){var baseTexture=new core.BaseTexture(resource.data,null,core.utils.getResolutionOfUrl(resource.url));baseTexture.imageUrl=resource.url;resource.texture=new core.Texture(baseTexture);core.utils.BaseTextureCache[resource.url]=baseTexture;core.utils.TextureCache[resource.url]=resource.texture}next()}}},{"../core":29}],125:[function(require,module,exports){var core=require("../core"),tempPoint=new core.Point,tempPolygon=new core.Polygon;function Mesh(texture,vertices,uvs,indices,drawMode){core.Container.call(this);this._texture=null;this.uvs=uvs||new Float32Array([0,0,1,0,1,1,0,1]);this.vertices=vertices||new Float32Array([0,0,100,0,100,100,0,100]);this.indices=indices||new Uint16Array([0,1,3,2]);this.dirty=true;this.blendMode=core.BLEND_MODES.NORMAL;this.canvasPadding=0;this.drawMode=drawMode||Mesh.DRAW_MODES.TRIANGLE_MESH;this.texture=texture;this.shader=null}Mesh.prototype=Object.create(core.Container.prototype);Mesh.prototype.constructor=Mesh;module.exports=Mesh;Object.defineProperties(Mesh.prototype,{texture:{get:function(){return this._texture},set:function(value){if(this._texture===value){return}this._texture=value;if(value){if(value.baseTexture.hasLoaded){this._onTextureUpdate()}else{value.once("update",this._onTextureUpdate,this)}}}}});Mesh.prototype._renderWebGL=function(renderer){renderer.setObjectRenderer(renderer.plugins.mesh);renderer.plugins.mesh.render(this)};Mesh.prototype._renderCanvas=function(renderer){var context=renderer.context;var transform=this.worldTransform;var res=renderer.resolution;if(renderer.roundPixels){context.setTransform(transform.a*res,transform.b*res,transform.c*res,transform.d*res,transform.tx*res|0,transform.ty*res|0)}else{context.setTransform(transform.a*res,transform.b*res,transform.c*res,transform.d*res,transform.tx*res,transform.ty*res)}if(this.drawMode===Mesh.DRAW_MODES.TRIANGLE_MESH){this._renderCanvasTriangleMesh(context)}else{this._renderCanvasTriangles(context)}};Mesh.prototype._renderCanvasTriangleMesh=function(context){var vertices=this.vertices;var uvs=this.uvs;var length=vertices.length/2;for(var i=0;i<length-2;i++){var index=i*2;this._renderCanvasDrawTriangle(context,vertices,uvs,index,index+2,index+4)}};Mesh.prototype._renderCanvasTriangles=function(context){var vertices=this.vertices;var uvs=this.uvs;var indices=this.indices;var length=indices.length;for(var i=0;i<length;i+=3){var index0=indices[i]*2,index1=indices[i+1]*2,index2=indices[i+2]*2;this._renderCanvasDrawTriangle(context,vertices,uvs,index0,index1,index2)}};Mesh.prototype._renderCanvasDrawTriangle=function(context,vertices,uvs,index0,index1,index2){var base=this._texture.baseTexture;var textureSource=base.source;var textureWidth=base.width;var textureHeight=base.height;var x0=vertices[index0],x1=vertices[index1],x2=vertices[index2];var y0=vertices[index0+1],y1=vertices[index1+1],y2=vertices[index2+1];var u0=uvs[index0]*base.width,u1=uvs[index1]*base.width,u2=uvs[index2]*base.width;var v0=uvs[index0+1]*base.height,v1=uvs[index1+1]*base.height,v2=uvs[index2+1]*base.height;if(this.canvasPadding>0){var paddingX=this.canvasPadding/this.worldTransform.a;var paddingY=this.canvasPadding/this.worldTransform.d;var centerX=(x0+x1+x2)/3;var centerY=(y0+y1+y2)/3;var normX=x0-centerX;var normY=y0-centerY;var dist=Math.sqrt(normX*normX+normY*normY);x0=centerX+normX/dist*(dist+paddingX);y0=centerY+normY/dist*(dist+paddingY);normX=x1-centerX;normY=y1-centerY;dist=Math.sqrt(normX*normX+normY*normY);x1=centerX+normX/dist*(dist+paddingX);y1=centerY+normY/dist*(dist+paddingY);normX=x2-centerX;normY=y2-centerY;dist=Math.sqrt(normX*normX+normY*normY);x2=centerX+normX/dist*(dist+paddingX);y2=centerY+normY/dist*(dist+paddingY)}context.save();context.beginPath();context.moveTo(x0,y0);context.lineTo(x1,y1);context.lineTo(x2,y2);context.closePath();context.clip();var delta=u0*v1+v0*u2+u1*v2-v1*u2-v0*u1-u0*v2;var deltaA=x0*v1+v0*x2+x1*v2-v1*x2-v0*x1-x0*v2;var deltaB=u0*x1+x0*u2+u1*x2-x1*u2-x0*u1-u0*x2;var deltaC=u0*v1*x2+v0*x1*u2+x0*u1*v2-x0*v1*u2-v0*u1*x2-u0*x1*v2;var deltaD=y0*v1+v0*y2+y1*v2-v1*y2-v0*y1-y0*v2;var deltaE=u0*y1+y0*u2+u1*y2-y1*u2-y0*u1-u0*y2;var deltaF=u0*v1*y2+v0*y1*u2+y0*u1*v2-y0*v1*u2-v0*u1*y2-u0*y1*v2;context.transform(deltaA/delta,deltaD/delta,deltaB/delta,deltaE/delta,deltaC/delta,deltaF/delta);context.drawImage(textureSource,0,0,textureWidth*base.resolution,textureHeight*base.resolution,0,0,textureWidth,textureHeight);context.restore()};Mesh.prototype.renderMeshFlat=function(Mesh){var context=this.context;var vertices=Mesh.vertices;var length=vertices.length/2;context.beginPath();for(var i=1;i<length-2;i++){var index=i*2;var x0=vertices[index],x1=vertices[index+2],x2=vertices[index+4];var y0=vertices[index+1],y1=vertices[index+3],y2=vertices[index+5];context.moveTo(x0,y0);context.lineTo(x1,y1);context.lineTo(x2,y2)}context.fillStyle="#FF0000";context.fill();context.closePath()};Mesh.prototype._onTextureUpdate=function(){this.updateFrame=true};Mesh.prototype.getBounds=function(matrix){if(!this._currentBounds){var worldTransform=matrix||this.worldTransform;var a=worldTransform.a;var b=worldTransform.b;var c=worldTransform.c;var d=worldTransform.d;var tx=worldTransform.tx;var ty=worldTransform.ty;var maxX=-Infinity;var maxY=-Infinity;var minX=Infinity;var minY=Infinity;var vertices=this.vertices;for(var i=0,n=vertices.length;i<n;i+=2){var rawX=vertices[i],rawY=vertices[i+1];var x=a*rawX+c*rawY+tx;var y=d*rawY+b*rawX+ty;minX=x<minX?x:minX;minY=y<minY?y:minY;maxX=x>maxX?x:maxX;maxY=y>maxY?y:maxY}if(minX===-Infinity||maxY===Infinity){return core.Rectangle.EMPTY}var bounds=this._bounds;bounds.x=minX;bounds.width=maxX-minX;bounds.y=minY;bounds.height=maxY-minY;this._currentBounds=bounds}return this._currentBounds};Mesh.prototype.containsPoint=function(point){if(!this.getBounds().contains(point.x,point.y)){return false}this.worldTransform.applyInverse(point,tempPoint);var vertices=this.vertices;var points=tempPolygon.points;var i,len;if(this.drawMode===Mesh.DRAW_MODES.TRIANGLES){var indices=this.indices;len=this.indices.length;for(i=0;i<len;i+=3){var ind0=indices[i]*2,ind1=indices[i+1]*2,ind2=indices[i+2]*2;points[0]=vertices[ind0];points[1]=vertices[ind0+1];points[2]=vertices[ind1];points[3]=vertices[ind1+1];points[4]=vertices[ind2];points[5]=vertices[ind2+1];if(tempPolygon.contains(tempPoint.x,tempPoint.y)){return true}}}else{len=vertices.length;for(i=0;i<len;i+=6){points[0]=vertices[i];points[1]=vertices[i+1];points[2]=vertices[i+2];points[3]=vertices[i+3];points[4]=vertices[i+4];points[5]=vertices[i+5];if(tempPolygon.contains(tempPoint.x,tempPoint.y)){return true}}}return false};Mesh.DRAW_MODES={TRIANGLE_MESH:0,TRIANGLES:1}},{"../core":29}],126:[function(require,module,exports){var Mesh=require("./Mesh");function Plane(texture,segmentsX,segmentsY){Mesh.call(this,texture);this._ready=true;this.segmentsX=segmentsX||10;this.segmentsY=segmentsY||10;this.drawMode=Mesh.DRAW_MODES.TRIANGLES;this.refresh()}Plane.prototype=Object.create(Mesh.prototype);Plane.prototype.constructor=Plane;module.exports=Plane;Plane.prototype.refresh=function(){var total=this.segmentsX*this.segmentsY;var verts=[];var colors=[];var uvs=[];var indices=[];var texture=this.texture;var segmentsXSub=this.segmentsX-1;var segmentsYSub=this.segmentsY-1;var i=0;var sizeX=texture.width/segmentsXSub;var sizeY=texture.height/segmentsYSub;for(i=0;i<total;i++){var x=i%this.segmentsX;var y=i/this.segmentsX|0;verts.push(x*sizeX,y*sizeY);uvs.push(texture._uvs.x0+(texture._uvs.x1-texture._uvs.x0)*(x/(this.segmentsX-1)),texture._uvs.y0+(texture._uvs.y3-texture._uvs.y0)*(y/(this.segmentsY-1)))}var totalSub=segmentsXSub*segmentsYSub;for(i=0;i<totalSub;i++){var xpos=i%segmentsXSub;var ypos=i/segmentsXSub|0;var value=ypos*this.segmentsX+xpos;var value2=ypos*this.segmentsX+xpos+1;var value3=(ypos+1)*this.segmentsX+xpos;var value4=(ypos+1)*this.segmentsX+xpos+1;indices.push(value,value2,value3);indices.push(value2,value4,value3)}this.vertices=new Float32Array(verts);this.uvs=new Float32Array(uvs);this.colors=new Float32Array(colors);this.indices=new Uint16Array(indices)};Plane.prototype._onTextureUpdate=function(){Mesh.prototype._onTextureUpdate.call(this);if(this._ready){this.refresh()}}},{"./Mesh":125}],127:[function(require,module,exports){var Mesh=require("./Mesh");var core=require("../core");function Rope(texture,points){Mesh.call(this,texture);this.points=points;this.vertices=new Float32Array(points.length*4);
  13. this.uvs=new Float32Array(points.length*4);this.colors=new Float32Array(points.length*2);this.indices=new Uint16Array(points.length*2);this._ready=true;this.refresh()}Rope.prototype=Object.create(Mesh.prototype);Rope.prototype.constructor=Rope;module.exports=Rope;Rope.prototype.refresh=function(){var points=this.points;if(points.length<1||!this._texture._uvs){return}var uvs=this.uvs;var indices=this.indices;var colors=this.colors;var textureUvs=this._texture._uvs;var offset=new core.Point(textureUvs.x0,textureUvs.y0);var factor=new core.Point(textureUvs.x2-textureUvs.x0,textureUvs.y2-textureUvs.y0);uvs[0]=0+offset.x;uvs[1]=0+offset.y;uvs[2]=0+offset.x;uvs[3]=1*factor.y+offset.y;colors[0]=1;colors[1]=1;indices[0]=0;indices[1]=1;var total=points.length,point,index,amount;for(var i=1;i<total;i++){point=points[i];index=i*4;amount=i/(total-1);uvs[index]=amount*factor.x+offset.x;uvs[index+1]=0+offset.y;uvs[index+2]=amount*factor.x+offset.x;uvs[index+3]=1*factor.y+offset.y;index=i*2;colors[index]=1;colors[index+1]=1;index=i*2;indices[index]=index;indices[index+1]=index+1}this.dirty=true};Rope.prototype._onTextureUpdate=function(){Mesh.prototype._onTextureUpdate.call(this);if(this._ready){this.refresh()}};Rope.prototype.updateTransform=function(){var points=this.points;if(points.length<1){return}var lastPoint=points[0];var nextPoint;var perpX=0;var perpY=0;var vertices=this.vertices;var total=points.length,point,index,ratio,perpLength,num;for(var i=0;i<total;i++){point=points[i];index=i*4;if(i<points.length-1){nextPoint=points[i+1]}else{nextPoint=point}perpY=-(nextPoint.x-lastPoint.x);perpX=nextPoint.y-lastPoint.y;ratio=(1-i/(total-1))*10;if(ratio>1){ratio=1}perpLength=Math.sqrt(perpX*perpX+perpY*perpY);num=this._texture.height/2;perpX/=perpLength;perpY/=perpLength;perpX*=num;perpY*=num;vertices[index]=point.x+perpX;vertices[index+1]=point.y+perpY;vertices[index+2]=point.x-perpX;vertices[index+3]=point.y-perpY;lastPoint=point}this.containerUpdateTransform()}},{"../core":29,"./Mesh":125}],128:[function(require,module,exports){module.exports={Mesh:require("./Mesh"),Plane:require("./Plane"),Rope:require("./Rope"),MeshRenderer:require("./webgl/MeshRenderer"),MeshShader:require("./webgl/MeshShader")}},{"./Mesh":125,"./Plane":126,"./Rope":127,"./webgl/MeshRenderer":129,"./webgl/MeshShader":130}],129:[function(require,module,exports){var core=require("../../core"),Mesh=require("../Mesh");function MeshRenderer(renderer){core.ObjectRenderer.call(this,renderer);this.indices=new Uint16Array(15e3);for(var i=0,j=0;i<15e3;i+=6,j+=4){this.indices[i+0]=j+0;this.indices[i+1]=j+1;this.indices[i+2]=j+2;this.indices[i+3]=j+0;this.indices[i+4]=j+2;this.indices[i+5]=j+3}this.currentShader=null}MeshRenderer.prototype=Object.create(core.ObjectRenderer.prototype);MeshRenderer.prototype.constructor=MeshRenderer;module.exports=MeshRenderer;core.WebGLRenderer.registerPlugin("mesh",MeshRenderer);MeshRenderer.prototype.onContextChange=function(){};MeshRenderer.prototype.render=function(mesh){if(!mesh._vertexBuffer){this._initWebGL(mesh)}var renderer=this.renderer,gl=renderer.gl,texture=mesh._texture.baseTexture,shader=mesh.shader;var drawMode=mesh.drawMode===Mesh.DRAW_MODES.TRIANGLE_MESH?gl.TRIANGLE_STRIP:gl.TRIANGLES;renderer.blendModeManager.setBlendMode(mesh.blendMode);if(!shader){shader=renderer.shaderManager.plugins.meshShader}else{shader=shader.shaders[gl.id]||shader.getShader(renderer)}this.renderer.shaderManager.setShader(shader);shader.uniforms.translationMatrix.value=mesh.worldTransform.toArray(true);shader.uniforms.projectionMatrix.value=renderer.currentRenderTarget.projectionMatrix.toArray(true);shader.uniforms.alpha.value=mesh.worldAlpha;shader.syncUniforms();if(!mesh.dirty){gl.bindBuffer(gl.ARRAY_BUFFER,mesh._vertexBuffer);gl.bufferSubData(gl.ARRAY_BUFFER,0,mesh.vertices);gl.vertexAttribPointer(shader.attributes.aVertexPosition,2,gl.FLOAT,false,0,0);gl.bindBuffer(gl.ARRAY_BUFFER,mesh._uvBuffer);gl.vertexAttribPointer(shader.attributes.aTextureCoord,2,gl.FLOAT,false,0,0);gl.activeTexture(gl.TEXTURE0);if(!texture._glTextures[gl.id]){this.renderer.updateTexture(texture)}else{gl.bindTexture(gl.TEXTURE_2D,texture._glTextures[gl.id])}gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,mesh._indexBuffer);gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER,0,mesh.indices)}else{mesh.dirty=false;gl.bindBuffer(gl.ARRAY_BUFFER,mesh._vertexBuffer);gl.bufferData(gl.ARRAY_BUFFER,mesh.vertices,gl.STATIC_DRAW);gl.vertexAttribPointer(shader.attributes.aVertexPosition,2,gl.FLOAT,false,0,0);gl.bindBuffer(gl.ARRAY_BUFFER,mesh._uvBuffer);gl.bufferData(gl.ARRAY_BUFFER,mesh.uvs,gl.STATIC_DRAW);gl.vertexAttribPointer(shader.attributes.aTextureCoord,2,gl.FLOAT,false,0,0);gl.activeTexture(gl.TEXTURE0);if(!texture._glTextures[gl.id]){this.renderer.updateTexture(texture)}else{gl.bindTexture(gl.TEXTURE_2D,texture._glTextures[gl.id])}gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,mesh._indexBuffer);gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,mesh.indices,gl.STATIC_DRAW)}gl.drawElements(drawMode,mesh.indices.length,gl.UNSIGNED_SHORT,0)};MeshRenderer.prototype._initWebGL=function(mesh){var gl=this.renderer.gl;mesh._vertexBuffer=gl.createBuffer();mesh._indexBuffer=gl.createBuffer();mesh._uvBuffer=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,mesh._vertexBuffer);gl.bufferData(gl.ARRAY_BUFFER,mesh.vertices,gl.DYNAMIC_DRAW);gl.bindBuffer(gl.ARRAY_BUFFER,mesh._uvBuffer);gl.bufferData(gl.ARRAY_BUFFER,mesh.uvs,gl.STATIC_DRAW);if(mesh.colors){mesh._colorBuffer=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,mesh._colorBuffer);gl.bufferData(gl.ARRAY_BUFFER,mesh.colors,gl.STATIC_DRAW)}gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,mesh._indexBuffer);gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,mesh.indices,gl.STATIC_DRAW)};MeshRenderer.prototype.flush=function(){};MeshRenderer.prototype.start=function(){this.currentShader=null};MeshRenderer.prototype.destroy=function(){core.ObjectRenderer.prototype.destroy.call(this)}},{"../../core":29,"../Mesh":125}],130:[function(require,module,exports){var core=require("../../core");function MeshShader(shaderManager){core.Shader.call(this,shaderManager,["precision lowp float;","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","uniform mat3 translationMatrix;","uniform mat3 projectionMatrix;","varying vec2 vTextureCoord;","void main(void){"," gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vTextureCoord = aTextureCoord;","}"].join("\n"),["precision lowp float;","varying vec2 vTextureCoord;","uniform float alpha;","uniform sampler2D uSampler;","void main(void){"," gl_FragColor = texture2D(uSampler, vTextureCoord) * alpha ;","}"].join("\n"),{alpha:{type:"1f",value:0},translationMatrix:{type:"mat3",value:new Float32Array(9)},projectionMatrix:{type:"mat3",value:new Float32Array(9)}},{aVertexPosition:0,aTextureCoord:0})}MeshShader.prototype=Object.create(core.Shader.prototype);MeshShader.prototype.constructor=MeshShader;module.exports=MeshShader;core.ShaderManager.registerPlugin("meshShader",MeshShader)},{"../../core":29}],131:[function(require,module,exports){if(!Math.sign){Math.sign=function(x){x=+x;if(x===0||isNaN(x)){return x}return x>0?1:-1}}},{}],132:[function(require,module,exports){if(!Object.assign){Object.assign=require("object-assign")}},{"object-assign":11}],133:[function(require,module,exports){require("./Object.assign");require("./requestAnimationFrame");require("./Math.sign")},{"./Math.sign":131,"./Object.assign":132,"./requestAnimationFrame":134}],134:[function(require,module,exports){(function(global){if(!(Date.now&&Date.prototype.getTime)){Date.now=function now(){return(new Date).getTime()}}if(!(global.performance&&global.performance.now)){var startTime=Date.now();if(!global.performance){global.performance={}}global.performance.now=function(){return Date.now()-startTime}}var lastTime=Date.now();var vendors=["ms","moz","webkit","o"];for(var x=0;x<vendors.length&&!global.requestAnimationFrame;++x){global.requestAnimationFrame=global[vendors[x]+"RequestAnimationFrame"];global.cancelAnimationFrame=global[vendors[x]+"CancelAnimationFrame"]||global[vendors[x]+"CancelRequestAnimationFrame"]}if(!global.requestAnimationFrame){global.requestAnimationFrame=function(callback){if(typeof callback!=="function"){throw new TypeError(callback+"is not a function")}var currentTime=Date.now(),delay=16+lastTime-currentTime;if(delay<0){delay=0}lastTime=currentTime;return setTimeout(function(){lastTime=Date.now();callback(performance.now())},delay)}}if(!global.cancelAnimationFrame){global.cancelAnimationFrame=function(id){clearTimeout(id)}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}]},{},[115])(115)});(function(global,exports,perf){"use strict";function fixSetTarget(param){if(!param)return;if(!param.setTargetAtTime)param.setTargetAtTime=param.setTargetValueAtTime}if(window.hasOwnProperty("webkitAudioContext")&&!window.hasOwnProperty("AudioContext")){window.AudioContext=webkitAudioContext;if(!AudioContext.prototype.hasOwnProperty("createGain"))AudioContext.prototype.createGain=AudioContext.prototype.createGainNode;if(!AudioContext.prototype.hasOwnProperty("createDelay"))AudioContext.prototype.createDelay=AudioContext.prototype.createDelayNode;if(!AudioContext.prototype.hasOwnProperty("createScriptProcessor"))AudioContext.prototype.createScriptProcessor=AudioContext.prototype.createJavaScriptNode;if(!AudioContext.prototype.hasOwnProperty("createPeriodicWave"))AudioContext.prototype.createPeriodicWave=AudioContext.prototype.createWaveTable;AudioContext.prototype.internal_createGain=AudioContext.prototype.createGain;AudioContext.prototype.createGain=function(){var node=this.internal_createGain();fixSetTarget(node.gain);return node};AudioContext.prototype.internal_createDelay=AudioContext.prototype.createDelay;AudioContext.prototype.createDelay=function(maxDelayTime){var node=maxDelayTime?this.internal_createDelay(maxDelayTime):this.internal_createDelay();fixSetTarget(node.delayTime);return node};AudioContext.prototype.internal_createBufferSource=AudioContext.prototype.createBufferSource;AudioContext.prototype.createBufferSource=function(){var node=this.internal_createBufferSource();if(!node.start){node.start=function(when,offset,duration){if(offset||duration)this.noteGrainOn(when||0,offset,duration);else this.noteOn(when||0)}}else{node.internal_start=node.start;node.start=function(when,offset,duration){if(typeof duration!=="undefined")node.internal_start(when||0,offset,duration);else node.internal_start(when||0,offset||0)}}if(!node.stop){node.stop=function(when){this.noteOff(when||0)}}else{node.internal_stop=node.stop;node.stop=function(when){node.internal_stop(when||0)}}fixSetTarget(node.playbackRate);return node};AudioContext.prototype.internal_createDynamicsCompressor=AudioContext.prototype.createDynamicsCompressor;AudioContext.prototype.createDynamicsCompressor=function(){var node=this.internal_createDynamicsCompressor();fixSetTarget(node.threshold);fixSetTarget(node.knee);fixSetTarget(node.ratio);fixSetTarget(node.reduction);fixSetTarget(node.attack);fixSetTarget(node.release);return node};AudioContext.prototype.internal_createBiquadFilter=AudioContext.prototype.createBiquadFilter;AudioContext.prototype.createBiquadFilter=function(){var node=this.internal_createBiquadFilter();fixSetTarget(node.frequency);fixSetTarget(node.detune);fixSetTarget(node.Q);fixSetTarget(node.gain);return node};if(AudioContext.prototype.hasOwnProperty("createOscillator")){AudioContext.prototype.internal_createOscillator=AudioContext.prototype.createOscillator;AudioContext.prototype.createOscillator=function(){var node=this.internal_createOscillator();if(!node.start){node.start=function(when){this.noteOn(when||0)}}else{node.internal_start=node.start;node.start=function(when){node.internal_start(when||0)}}if(!node.stop){node.stop=function(when){this.noteOff(when||0)}}else{node.internal_stop=node.stop;node.stop=function(when){node.internal_stop(when||0)}}if(!node.setPeriodicWave)node.setPeriodicWave=node.setWaveTable;fixSetTarget(node.frequency);fixSetTarget(node.detune);return node}}}if(window.hasOwnProperty("webkitOfflineAudioContext")&&!window.hasOwnProperty("OfflineAudioContext")){window.OfflineAudioContext=webkitOfflineAudioContext}})(window);var actx=new AudioContext;var sounds={toLoad:0,loaded:0,audioExtensions:["mp3","ogg","wav","webm"],whenLoaded:undefined,onProgress:undefined,onFailed:function(source,error){throw new Error("Audio could not be loaded: "+source)},load:function(sources){console.log("Loading sounds..");var self=this;self.toLoad=sources.length;sources.forEach(function(source){var extension=source.split(".").pop();if(self.audioExtensions.indexOf(extension)!==-1){var soundSprite=makeSound(source,self.loadHandler.bind(self),true,false,self.onFailed);soundSprite.name=source;self[soundSprite.name]=soundSprite}else{console.log("File type not recognized: "+source)}})},loadHandler:function(){var self=this;self.loaded+=1;if(self.onProgress){self.onProgress(100*self.loaded/self.toLoad)}if(self.toLoad===self.loaded){console.log("Sounds finished loading");self.toLoad=0;self.loaded=0;self.whenLoaded()}}};function makeSound(source,loadHandler,loadSound,xhr,failHandler){var o={};o.volumeNode=actx.createGain();if(!actx.createStereoPanner){o.panNode=actx.createPanner()}else{o.panNode=actx.createStereoPanner()}o.delayNode=actx.createDelay();o.feedbackNode=actx.createGain();o.filterNode=actx.createBiquadFilter();o.convolverNode=actx.createConvolver();o.soundNode=null;o.buffer=null;o.source=source;o.loop=false;o.playing=false;o.loadHandler=undefined;o.panValue=0;o.volumeValue=1;o.startTime=0;o.startOffset=0;o.playbackRate=1;o.echo=false;o.delayValue=.3;o.feebackValue=.3;o.filterValue=0;o.reverb=false;o.reverbImpulse=null;o.play=function(){o.startTime=actx.currentTime;o.soundNode=actx.createBufferSource();o.soundNode.buffer=o.buffer;o.soundNode.playbackRate.value=this.playbackRate;o.soundNode.connect(o.volumeNode);if(o.reverb===false){o.volumeNode.connect(o.panNode)}else{o.volumeNode.connect(o.convolverNode);o.convolverNode.connect(o.panNode);o.convolverNode.buffer=o.reverbImpulse}o.panNode.connect(actx.destination);if(o.echo){o.feedbackNode.gain.value=o.feebackValue;o.delayNode.delayTime.value=o.delayValue;o.filterNode.frequency.value=o.filterValue;o.delayNode.connect(o.feedbackNode);if(o.filterValue>0){o.feedbackNode.connect(o.filterNode);o.filterNode.connect(o.delayNode)}else{o.feedbackNode.connect(o.delayNode)}o.volumeNode.connect(o.delayNode);o.delayNode.connect(o.panNode)}o.soundNode.loop=o.loop;o.soundNode.start(0,o.startOffset%o.buffer.duration);o.playing=true};o.pause=function(){if(o.playing){o.soundNode.stop(0);o.startOffset+=actx.currentTime-o.startTime;o.playing=false}};o.restart=function(){if(o.playing){o.soundNode.stop(0)}o.startOffset=0;o.play()};o.playFrom=function(value){if(o.playing){o.soundNode.stop(0)}o.startOffset=value;o.play()};o.setEcho=function(delayValue,feedbackValue,filterValue){if(delayValue===undefined)delayValue=.3;if(feedbackValue===undefined)feedbackValue=.3;if(filterValue===undefined)filterValue=0;o.delayValue=delayValue;o.feebackValue=feedbackValue;o.filterValue=filterValue;o.echo=true};o.setReverb=function(duration,decay,reverse){if(duration===undefined)duration=2;if(decay===undefined)decay=2;if(reverse===undefined)reverse=false;o.reverbImpulse=impulseResponse(duration,decay,reverse,actx);o.reverb=true};o.fade=function(endValue,durationInSeconds){if(o.playing){o.volumeNode.gain.linearRampToValueAtTime(o.volumeNode.gain.value,actx.currentTime);o.volumeNode.gain.linearRampToValueAtTime(endValue,actx.currentTime+durationInSeconds)}};o.fadeIn=function(durationInSeconds){o.volumeNode.gain.value=0;o.fade(1,durationInSeconds)};o.fadeOut=function(durationInSeconds){o.fade(0,durationInSeconds)};Object.defineProperties(o,{volume:{get:function(){return o.volumeValue},set:function(value){o.volumeNode.gain.value=value;o.volumeValue=value},enumerable:true,configurable:true},pan:{get:function(){if(!actx.createStereoPanner){return o.panValue}else{return o.panNode.pan.value}},set:function(value){if(!actx.createStereoPanner){var x=value,y=0,z=1-Math.abs(x);o.panNode.setPosition(x,y,z);o.panValue=value}else{o.panNode.pan.value=value}},enumerable:true,configurable:true}});if(loadSound){this.loadSound(o,source,loadHandler,failHandler)}if(xhr){this.decodeAudio(o,xhr,loadHandler,failHandler)}return o}function loadSound(o,source,loadHandler,failHandler){var xhr=new XMLHttpRequest;xhr.open("GET",source,true);xhr.responseType="arraybuffer";xhr.addEventListener("load",decodeAudio.bind(this,o,xhr,loadHandler,failHandler));xhr.send()}function decodeAudio(o,xhr,loadHandler,failHandler){actx.decodeAudioData(xhr.response,function(buffer){o.buffer=buffer;o.hasLoaded=true;if(loadHandler){loadHandler()}},function(error){if(failHandler)failHandler(o.source,error)})}function soundEffect(frequencyValue,attack,decay,type,volumeValue,panValue,wait,pitchBendAmount,reverse,randomValue,dissonance,echo,reverb,timeout){if(frequencyValue===undefined)frequencyValue=200;if(attack===undefined)attack=0;if(decay===undefined)decay=1;if(type===undefined)type="sine";if(volumeValue===undefined)volumeValue=1;if(panValue===undefined)panValue=0;if(wait===undefined)wait=0;if(pitchBendAmount===undefined)pitchBendAmount=0;if(reverse===undefined)reverse=false;if(randomValue===undefined)randomValue=0;if(dissonance===undefined)dissonance=0;if(echo===undefined)echo=undefined;if(reverb===undefined)reverb=undefined;if(timeout===undefined)timeout=undefined;var oscillator,volume,pan;oscillator=actx.createOscillator();volume=actx.createGain();if(!actx.createStereoPanner){pan=actx.createPanner()}else{pan=actx.createStereoPanner()}oscillator.connect(volume);volume.connect(pan);pan.connect(actx.destination);volume.gain.value=volumeValue;if(!actx.createStereoPanner){pan.setPosition(panValue,0,1-Math.abs(panValue))}else{pan.pan.value=panValue}oscillator.type=type;var frequency;var randomInt=function(min,max){return Math.floor(Math.random()*(max-min+1))+min};if(randomValue>0){frequency=randomInt(frequencyValue-randomValue/2,frequencyValue+randomValue/2)}else{frequency=frequencyValue}oscillator.frequency.value=frequency;if(attack>0)fadeIn(volume);fadeOut(volume);if(pitchBendAmount>0)pitchBend(oscillator);if(echo)addEcho(volume);if(reverb)addReverb(volume);if(dissonance>0)addDissonance();play(oscillator);function addReverb(volumeNode){var convolver=actx.createConvolver();convolver.buffer=impulseResponse(reverb[0],reverb[1],reverb[2],actx);volumeNode.connect(convolver);convolver.connect(pan)}function addEcho(volumeNode){var feedback=actx.createGain(),delay=actx.createDelay(),filter=actx.createBiquadFilter();delay.delayTime.value=echo[0];feedback.gain.value=echo[1];if(echo[2])filter.frequency.value=echo[2];delay.connect(feedback);if(echo[2]){feedback.connect(filter);filter.connect(delay)}else{feedback.connect(delay)}volumeNode.connect(delay);delay.connect(pan)}function fadeIn(volumeNode){volumeNode.gain.value=0;volumeNode.gain.linearRampToValueAtTime(0,actx.currentTime+wait);volumeNode.gain.linearRampToValueAtTime(volumeValue,actx.currentTime+wait+attack)}function fadeOut(volumeNode){volumeNode.gain.linearRampToValueAtTime(volumeValue,actx.currentTime+attack+wait);volumeNode.gain.linearRampToValueAtTime(0,actx.currentTime+wait+attack+decay)}function pitchBend(oscillatorNode){var frequency=oscillatorNode.frequency.value;if(!reverse){oscillatorNode.frequency.linearRampToValueAtTime(frequency,actx.currentTime+wait);oscillatorNode.frequency.linearRampToValueAtTime(frequency-pitchBendAmount,actx.currentTime+wait+attack+decay)}else{oscillatorNode.frequency.linearRampToValueAtTime(frequency,actx.currentTime+wait);oscillatorNode.frequency.linearRampToValueAtTime(frequency+pitchBendAmount,actx.currentTime+wait+attack+decay)}}function addDissonance(){var d1=actx.createOscillator(),d2=actx.createOscillator(),d1Volume=actx.createGain(),d2Volume=actx.createGain();d1Volume.gain.value=volumeValue;d2Volume.gain.value=volumeValue;d1.connect(d1Volume);d1Volume.connect(actx.destination);d2.connect(d2Volume);d2Volume.connect(actx.destination);d1.type="sawtooth";d2.type="sawtooth";d1.frequency.value=frequency+dissonance;d2.frequency.value=frequency-dissonance;if(attack>0){fadeIn(d1Volume);fadeIn(d2Volume)}if(decay>0){fadeOut(d1Volume);fadeOut(d2Volume)}if(pitchBendAmount>0){pitchBend(d1);pitchBend(d2)}if(echo){addEcho(d1Volume);addEcho(d2Volume)}if(reverb){addReverb(d1Volume);addReverb(d2Volume)}play(d1);play(d2)}function play(node){node.start(actx.currentTime+wait);node.stop(actx.currentTime+wait+2)}}function impulseResponse(duration,decay,reverse,actx){var length=actx.sampleRate*duration;var impulse=actx.createBuffer(2,length,actx.sampleRate);var left=impulse.getChannelData(0),right=impulse.getChannelData(1);for(var i=0;i<length;i++){var n;if(reverse){n=length-i}else{n=i}left[i]=(Math.random()*2-1)*Math.pow(1-n/length,decay);right[i]=(Math.random()*2-1)*Math.pow(1-n/length,decay)}return impulse}function keyboard(keyCode){var key={};key.code=keyCode;key.isDown=false;key.isUp=true;key.press=undefined;key.release=undefined;key.downHandler=function(event){if(event.keyCode===key.code){if(key.isUp&&key.press)key.press();key.isDown=true;key.isUp=false}event.preventDefault()};key.upHandler=function(event){if(event.keyCode===key.code){if(key.isDown&&key.release)key.release();key.isDown=false;key.isUp=true}event.preventDefault()};window.addEventListener("keydown",key.downHandler.bind(key),false);window.addEventListener("keyup",key.upHandler.bind(key),false);return key}function scaleToWindow(canvas,backgroundColor){var scaleX,scaleY,scale,center;scaleX=window.innerWidth/canvas.offsetWidth;scaleY=window.innerHeight/canvas.offsetHeight;scale=Math.min(scaleX,scaleY);canvas.style.transformOrigin="0 0";canvas.style.transform="scale("+scale+")";if(canvas.offsetWidth>canvas.offsetHeight){if(canvas.offsetWidth*scale<window.innerWidth){center="horizontally"}else{center="vertically"}}else{if(canvas.offsetHeight*scale<window.innerHeight){center="vertically"}else{center="horizontally"}}var margin;if(center==="horizontally"){margin=(window.innerWidth-canvas.offsetWidth*scale)/2;canvas.style.marginTop=0+"px";canvas.style.marginBottom=0+"px";canvas.style.marginLeft=margin+"px";canvas.style.marginRight=margin+"px"}if(center==="vertically"){margin=(window.innerHeight-canvas.offsetHeight*scale)/2;canvas.style.marginTop=margin+"px";canvas.style.marginBottom=margin+"px";canvas.style.marginLeft=0+"px";canvas.style.marginRight=0+"px"}canvas.style.paddingLeft=0+"px";canvas.style.paddingRight=0+"px";canvas.style.paddingTop=0+"px";canvas.style.paddingBottom=0+"px";canvas.style.display="block";document.body.style.backgroundColor=backgroundColor;var ua=navigator.userAgent.toLowerCase();if(ua.indexOf("safari")!=-1){if(ua.indexOf("chrome")>-1){}else{}}return scale}"use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var Bump=function(){function Bump(){var renderingEngine=arguments.length<=0||arguments[0]===undefined?PIXI:arguments[0];_classCallCheck(this,Bump);if(renderingEngine===undefined)throw new Error("Please assign a rendering engine in the constructor before using bump.js");this.renderer="pixi"}_createClass(Bump,[{key:"addCollisionProperties",value:function addCollisionProperties(sprite){if(this.renderer==="pixi"){if(sprite.gx===undefined){Object.defineProperty(sprite,"gx",{get:function get(){return sprite.getGlobalPosition().x},enumerable:true,configurable:true})}if(sprite.gy===undefined){Object.defineProperty(sprite,"gy",{get:function get(){return sprite.getGlobalPosition().y},enumerable:true,configurable:true})}if(sprite.centerX===undefined){Object.defineProperty(sprite,"centerX",{get:function get(){return sprite.x+sprite.width/2},enumerable:true,configurable:true})}if(sprite.centerY===undefined){Object.defineProperty(sprite,"centerY",{get:function get(){return sprite.y+sprite.height/2},enumerable:true,configurable:true})}if(sprite.halfWidth===undefined){Object.defineProperty(sprite,"halfWidth",{get:function get(){return sprite.width/2},enumerable:true,configurable:true})}if(sprite.halfHeight===undefined){Object.defineProperty(sprite,"halfHeight",{get:function get(){return sprite.height/2},enumerable:true,configurable:true})}if(sprite.xAnchorOffset===undefined){Object.defineProperty(sprite,"xAnchorOffset",{get:function get(){if(sprite.anchor!==undefined){return sprite.width*sprite.anchor.x}else{return 0}},enumerable:true,configurable:true})}if(sprite.yAnchorOffset===undefined){Object.defineProperty(sprite,"yAnchorOffset",{get:function get(){if(sprite.anchor!==undefined){return sprite.height*sprite.anchor.y}else{return 0}},enumerable:true,configurable:true})}if(sprite.circular&&sprite.radius===undefined){Object.defineProperty(sprite,"radius",{get:function get(){return sprite.width/2},enumerable:true,configurable:true})}}sprite._bumpPropertiesAdded=true}},{key:"hitTestPoint",value:function hitTestPoint(point,sprite){if(!sprite._bumpPropertiesAdded)this.addCollisionProperties(sprite);var shape=undefined,left=undefined,right=undefined,top=undefined,bottom=undefined,vx=undefined,vy=undefined,magnitude=undefined,hit=undefined;if(sprite.radius){shape="circle"}else{shape="rectangle"}if(shape==="rectangle"){left=sprite.x-sprite.xAnchorOffset;right=sprite.x+sprite.width-sprite.xAnchorOffset;top=sprite.y-sprite.yAnchorOffset;bottom=sprite.y+sprite.height-sprite.yAnchorOffset;hit=point.x>left&&point.x<right&&point.y>top&&point.y<bottom}if(shape==="circle"){var _vx=point.x-sprite.x-sprite.width/2+sprite.xAnchorOffset,_vy=point.y-sprite.y-sprite.height/2+sprite.yAnchorOffset,_magnitude=Math.sqrt(_vx*_vx+_vy*_vy);hit=_magnitude<sprite.radius}return hit}},{key:"hitTestCircle",value:function hitTestCircle(c1,c2){var global=arguments.length<=2||arguments[2]===undefined?false:arguments[2];if(!c1._bumpPropertiesAdded)this.addCollisionProperties(c1);if(!c2._bumpPropertiesAdded)this.addCollisionProperties(c2);var vx=undefined,vy=undefined,magnitude=undefined,combinedRadii=undefined,hit=undefined;if(global){vx=c2.gx+c2.width/2-c2.xAnchorOffset-(c1.gx+c1.width/2-c1.xAnchorOffset);vy=c2.gy+c2.width/2-c2.yAnchorOffset-(c1.gy+c1.width/2-c1.yAnchorOffset)}else{vx=c2.x+c2.width/2-c2.xAnchorOffset-(c1.x+c1.width/2-c1.xAnchorOffset);vy=c2.y+c2.width/2-c2.yAnchorOffset-(c1.y+c1.width/2-c1.yAnchorOffset)}magnitude=Math.sqrt(vx*vx+vy*vy);combinedRadii=c1.radius+c2.radius;hit=magnitude<combinedRadii;return hit}},{key:"circleCollision",value:function circleCollision(c1,c2){var bounce=arguments.length<=2||arguments[2]===undefined?false:arguments[2];var global=arguments.length<=3||arguments[3]===undefined?false:arguments[3];if(!c1._bumpPropertiesAdded)this.addCollisionProperties(c1);if(!c2._bumpPropertiesAdded)this.addCollisionProperties(c2);var magnitude=undefined,combinedRadii=undefined,overlap=undefined,vx=undefined,vy=undefined,dx=undefined,dy=undefined,s={},hit=false;if(global){vx=c2.gx+c2.width/2-c2.xAnchorOffset-(c1.gx+c1.width/2-c1.xAnchorOffset);vy=c2.gy+c2.width/2-c2.yAnchorOffset-(c1.gy+c1.width/2-c1.yAnchorOffset)}else{vx=c2.x+c2.width/2-c2.xAnchorOffset-(c1.x+c1.width/2-c1.xAnchorOffset);vy=c2.y+c2.width/2-c2.yAnchorOffset-(c1.y+c1.width/2-c1.yAnchorOffset)}magnitude=Math.sqrt(vx*vx+vy*vy);combinedRadii=c1.radius+c2.radius;if(magnitude<combinedRadii){hit=true;overlap=combinedRadii-magnitude;var quantumPadding=.3;overlap+=quantumPadding;dx=vx/magnitude;dy=vy/magnitude;c1.x-=overlap*dx;c1.y-=overlap*dy;if(bounce){s.x=vy;s.y=-vx;this.bounceOffSurface(c1,s)}}return hit}},{key:"movingCircleCollision",value:function movingCircleCollision(c1,c2){var global=arguments.length<=2||arguments[2]===undefined?false:arguments[2];if(!c1._bumpPropertiesAdded)this.addCollisionProperties(c1);if(!c2._bumpPropertiesAdded)this.addCollisionProperties(c2);var combinedRadii=undefined,overlap=undefined,xSide=undefined,ySide=undefined,s={},p1A={},p1B={},p2A={},p2B={},hit=false;c1.mass=c1.mass||1;c2.mass=c2.mass||1;if(global){s.vx=c2.gx+c2.radius-c2.xAnchorOffset-(c1.gx+c1.radius-c1.xAnchorOffset);s.vy=c2.gy+c2.radius-c2.yAnchorOffset-(c1.gy+c1.radius-c1.yAnchorOffset)}else{s.vx=c2.x+c2.radius-c2.xAnchorOffset-(c1.x+c1.radius-c1.xAnchorOffset);s.vy=c2.y+c2.radius-c2.yAnchorOffset-(c1.y+c1.radius-c1.yAnchorOffset)}s.magnitude=Math.sqrt(s.vx*s.vx+s.vy*s.vy);combinedRadii=c1.radius+c2.radius;if(s.magnitude<combinedRadii){hit=true;overlap=combinedRadii-s.magnitude;overlap+=.3;s.dx=s.vx/s.magnitude;s.dy=s.vy/s.magnitude;s.vxHalf=Math.abs(s.dx*overlap/2);s.vyHalf=Math.abs(s.dy*overlap/2);c1.x>c2.x?xSide=1:xSide=-1;c1.y>c2.y?ySide=1:ySide=-1;c1.x=c1.x+s.vxHalf*xSide;c1.y=c1.y+s.vyHalf*ySide;c2.x=c2.x+s.vxHalf*-xSide;c2.y=c2.y+s.vyHalf*-ySide;s.lx=s.vy;s.ly=-s.vx;var dp1=c1.vx*s.dx+c1.vy*s.dy;p1A.x=dp1*s.dx;p1A.y=dp1*s.dy;var dp2=c1.vx*(s.lx/s.magnitude)+c1.vy*(s.ly/s.magnitude);p1B.x=dp2*(s.lx/s.magnitude);p1B.y=dp2*(s.ly/s.magnitude);var dp3=c2.vx*s.dx+c2.vy*s.dy;p2A.x=dp3*s.dx;p2A.y=dp3*s.dy;var dp4=c2.vx*(s.lx/s.magnitude)+c2.vy*(s.ly/s.magnitude);p2B.x=dp4*(s.lx/s.magnitude);p2B.y=dp4*(s.ly/s.magnitude);c1.bounce={};c1.bounce.x=p1B.x+p2A.x;c1.bounce.y=p1B.y+p2A.y;c2.bounce={};c2.bounce.x=p1A.x+p2B.x;c2.bounce.y=p1A.y+p2B.y;c1.vx=c1.bounce.x/c1.mass;c1.vy=c1.bounce.y/c1.mass;c2.vx=c2.bounce.x/c2.mass;c2.vy=c2.bounce.y/c2.mass}return hit}},{key:"multipleCircleCollision",value:function multipleCircleCollision(arrayOfCircles){var global=arguments.length<=1||arguments[1]===undefined?false:arguments[1];for(var i=0;i<arrayOfCircles.length;i++){var c1=arrayOfCircles[i];for(var j=i+1;j<arrayOfCircles.length;j++){var c2=arrayOfCircles[j];this.movingCircleCollision(c1,c2,global)}}}},{key:"rectangleCollision",value:function rectangleCollision(r1,r2){var bounce=arguments.length<=2||arguments[2]===undefined?false:arguments[2];var global=arguments.length<=3||arguments[3]===undefined?true:arguments[3];if(!r1._bumpPropertiesAdded)this.addCollisionProperties(r1);if(!r2._bumpPropertiesAdded)this.addCollisionProperties(r2);var collision=undefined,combinedHalfWidths=undefined,combinedHalfHeights=undefined,overlapX=undefined,overlapY=undefined,vx=undefined,vy=undefined;if(global){vx=r1.gx+Math.abs(r1.halfWidth)-r1.xAnchorOffset-(r2.gx+Math.abs(r2.halfWidth)-r2.xAnchorOffset);vy=r1.gy+Math.abs(r1.halfHeight)-r1.yAnchorOffset-(r2.gy+Math.abs(r2.halfHeight)-r2.yAnchorOffset)}else{vx=r1.x+Math.abs(r1.halfWidth)-r1.xAnchorOffset-(r2.x+Math.abs(r2.halfWidth)-r2.xAnchorOffset);vy=r1.y+Math.abs(r1.halfHeight)-r1.yAnchorOffset-(r2.y+Math.abs(r2.halfHeight)-r2.yAnchorOffset)}combinedHalfWidths=Math.abs(r1.halfWidth)+Math.abs(r2.halfWidth);combinedHalfHeights=Math.abs(r1.halfHeight)+Math.abs(r2.halfHeight);if(Math.abs(vx)<combinedHalfWidths){if(Math.abs(vy)<combinedHalfHeights){overlapX=combinedHalfWidths-Math.abs(vx);overlapY=combinedHalfHeights-Math.abs(vy);if(overlapX>=overlapY){if(vy>0){collision="top";r1.y=r1.y+overlapY}else{collision="bottom";r1.y=r1.y-overlapY}if(bounce){r1.vy*=-1}}else{if(vx>0){collision="left";r1.x=r1.x+overlapX}else{collision="right";r1.x=r1.x-overlapX}if(bounce){r1.vx*=-1}}}else{}}else{}return collision}},{key:"hitTestRectangle",value:function hitTestRectangle(r1,r2){var global=arguments.length<=2||arguments[2]===undefined?false:arguments[2];if(!r1._bumpPropertiesAdded)this.addCollisionProperties(r1);
  14. if(!r2._bumpPropertiesAdded)this.addCollisionProperties(r2);var hit=undefined,combinedHalfWidths=undefined,combinedHalfHeights=undefined,vx=undefined,vy=undefined;hit=false;if(global){vx=r1.gx+Math.abs(r1.halfWidth)-r1.xAnchorOffset-(r2.gx+Math.abs(r2.halfWidth)-r2.xAnchorOffset);vy=r1.gy+Math.abs(r1.halfHeight)-r1.yAnchorOffset-(r2.gy+Math.abs(r2.halfHeight)-r2.yAnchorOffset)}else{vx=r1.x+Math.abs(r1.halfWidth)-r1.xAnchorOffset-(r2.x+Math.abs(r2.halfWidth)-r2.xAnchorOffset);vy=r1.y+Math.abs(r1.halfHeight)-r1.yAnchorOffset-(r2.y+Math.abs(r2.halfHeight)-r2.yAnchorOffset)}combinedHalfWidths=Math.abs(r1.halfWidth)+Math.abs(r2.halfWidth);combinedHalfHeights=Math.abs(r1.halfHeight)+Math.abs(r2.halfHeight);if(Math.abs(vx)<combinedHalfWidths){if(Math.abs(vy)<combinedHalfHeights){hit=true}else{hit=false}}else{hit=false}return hit}},{key:"hitTestCircleRectangle",value:function hitTestCircleRectangle(c1,r1){var global=arguments.length<=2||arguments[2]===undefined?false:arguments[2];if(!r1._bumpPropertiesAdded)this.addCollisionProperties(r1);if(!c1._bumpPropertiesAdded)this.addCollisionProperties(c1);var region=undefined,collision=undefined,c1x=undefined,c1y=undefined,r1x=undefined,r1y=undefined;if(global){c1x=c1.gx;c1y=c1.gy;r1x=r1.gx;r1y=r1.gy}else{c1x=c1.x;c1y=c1.y;r1x=r1.x;r1y=r1.y}if(c1y-c1.yAnchorOffset<r1y-Math.abs(r1.halfHeight)-r1.yAnchorOffset){if(c1x-c1.xAnchorOffset<r1x-1-Math.abs(r1.halfWidth)-r1.xAnchorOffset){region="topLeft"}else if(c1x-c1.xAnchorOffset>r1x+1+Math.abs(r1.halfWidth)-r1.xAnchorOffset){region="topRight"}else{region="topMiddle"}}else if(c1y-c1.yAnchorOffset>r1y+Math.abs(r1.halfHeight)-r1.yAnchorOffset){if(c1x-c1.xAnchorOffset<r1x-1-Math.abs(r1.halfWidth)-r1.xAnchorOffset){region="bottomLeft"}else if(c1x-c1.xAnchorOffset>r1x+1+Math.abs(r1.halfWidth)-r1.xAnchorOffset){region="bottomRight"}else{region="bottomMiddle"}}else{if(c1x-c1.xAnchorOffset<r1x-Math.abs(r1.halfWidth)-r1.xAnchorOffset){region="leftMiddle"}else{region="rightMiddle"}}if(region==="topMiddle"||region==="bottomMiddle"||region==="leftMiddle"||region==="rightMiddle"){collision=this.hitTestRectangle(c1,r1,global)}else{var point={};switch(region){case"topLeft":point.x=r1x-r1.xAnchorOffset;point.y=r1y-r1.yAnchorOffset;break;case"topRight":point.x=r1x+r1.width-r1.xAnchorOffset;point.y=r1y-r1.yAnchorOffset;break;case"bottomLeft":point.x=r1x-r1.xAnchorOffset;point.y=r1y+r1.height-r1.yAnchorOffset;break;case"bottomRight":point.x=r1x+r1.width-r1.xAnchorOffset;point.y=r1y+r1.height-r1.yAnchorOffset}collision=this.hitTestCirclePoint(c1,point,global)}if(collision){return region}else{return collision}}},{key:"hitTestCirclePoint",value:function hitTestCirclePoint(c1,point){var global=arguments.length<=2||arguments[2]===undefined?false:arguments[2];if(!c1._bumpPropertiesAdded)this.addCollisionProperties(c1);point.diameter=1;point.width=point.diameter;point.radius=.5;point.centerX=point.x;point.centerY=point.y;point.gx=point.x;point.gy=point.y;point.xAnchorOffset=0;point.yAnchorOffset=0;point._bumpPropertiesAdded=true;return this.hitTestCircle(c1,point,global)}},{key:"circleRectangleCollision",value:function circleRectangleCollision(c1,r1){var bounce=arguments.length<=2||arguments[2]===undefined?false:arguments[2];var global=arguments.length<=3||arguments[3]===undefined?false:arguments[3];if(!r1._bumpPropertiesAdded)this.addCollisionProperties(r1);if(!c1._bumpPropertiesAdded)this.addCollisionProperties(c1);var region=undefined,collision=undefined,c1x=undefined,c1y=undefined,r1x=undefined,r1y=undefined;if(global){c1x=c1.gx;c1y=c1.gy;r1x=r1.gx;r1y=r1.gy}else{c1x=c1.x;c1y=c1.y;r1x=r1.x;r1y=r1.y}if(c1y-c1.yAnchorOffset<r1y-Math.abs(r1.halfHeight)-r1.yAnchorOffset){if(c1x-c1.xAnchorOffset<r1x-1-Math.abs(r1.halfWidth)-r1.xAnchorOffset){region="topLeft"}else if(c1x-c1.xAnchorOffset>r1x+1+Math.abs(r1.halfWidth)-r1.xAnchorOffset){region="topRight"}else{region="topMiddle"}}else if(c1y-c1.yAnchorOffset>r1y+Math.abs(r1.halfHeight)-r1.yAnchorOffset){if(c1x-c1.xAnchorOffset<r1x-1-Math.abs(r1.halfWidth)-r1.xAnchorOffset){region="bottomLeft"}else if(c1x-c1.xAnchorOffset>r1x+1+Math.abs(r1.halfWidth)-r1.xAnchorOffset){region="bottomRight"}else{region="bottomMiddle"}}else{if(c1x-c1.xAnchorOffset<r1x-Math.abs(r1.halfWidth)-r1.xAnchorOffset){region="leftMiddle"}else{region="rightMiddle"}}if(region==="topMiddle"||region==="bottomMiddle"||region==="leftMiddle"||region==="rightMiddle"){collision=this.rectangleCollision(c1,r1,bounce,global)}else{var point={};switch(region){case"topLeft":point.x=r1x-r1.xAnchorOffset;point.y=r1y-r1.yAnchorOffset;break;case"topRight":point.x=r1x+r1.width-r1.xAnchorOffset;point.y=r1y-r1.yAnchorOffset;break;case"bottomLeft":point.x=r1x-r1.xAnchorOffset;point.y=r1y+r1.height-r1.yAnchorOffset;break;case"bottomRight":point.x=r1x+r1.width-r1.xAnchorOffset;point.y=r1y+r1.height-r1.yAnchorOffset}collision=this.circlePointCollision(c1,point,bounce,global)}if(collision){return region}else{return collision}}},{key:"circlePointCollision",value:function circlePointCollision(c1,point){var bounce=arguments.length<=2||arguments[2]===undefined?false:arguments[2];var global=arguments.length<=3||arguments[3]===undefined?false:arguments[3];if(!c1._bumpPropertiesAdded)this.addCollisionProperties(c1);point.diameter=1;point.width=point.diameter;point.radius=.5;point.centerX=point.x;point.centerY=point.y;point.gx=point.x;point.gy=point.y;point.xAnchorOffset=0;point.yAnchorOffset=0;point._bumpPropertiesAdded=true;return this.circleCollision(c1,point,bounce,global)}},{key:"bounceOffSurface",value:function bounceOffSurface(o,s){if(!o._bumpPropertiesAdded)this.addCollisionProperties(o);var dp1=undefined,dp2=undefined,p1={},p2={},bounce={},mass=o.mass||1;s.lx=s.y;s.ly=-s.x;s.magnitude=Math.sqrt(s.x*s.x+s.y*s.y);s.dx=s.x/s.magnitude;s.dy=s.y/s.magnitude;dp1=o.vx*s.dx+o.vy*s.dy;p1.vx=dp1*s.dx;p1.vy=dp1*s.dy;dp2=o.vx*(s.lx/s.magnitude)+o.vy*(s.ly/s.magnitude);p2.vx=dp2*(s.lx/s.magnitude);p2.vy=dp2*(s.ly/s.magnitude);p2.vx*=-1;p2.vy*=-1;bounce.x=p1.vx+p2.vx;bounce.y=p1.vy+p2.vy;o.vx=bounce.x/mass;o.vy=bounce.y/mass}},{key:"contain",value:function contain(sprite,container){var bounce=arguments.length<=2||arguments[2]===undefined?false:arguments[2];var extra=arguments.length<=3||arguments[3]===undefined?undefined:arguments[3];if(!sprite._bumpPropertiesAdded)this.addCollisionProperties(sprite);if(container.xAnchorOffset===undefined)container.xAnchorOffset=0;if(container.yAnchorOffset===undefined)container.yAnchorOffset=0;if(sprite.parent.gx===undefined)sprite.parent.gx=0;if(sprite.parent.gy===undefined)sprite.parent.gy=0;var collision=new Set;if(sprite.x-sprite.xAnchorOffset<container.x-sprite.parent.gx-container.xAnchorOffset){if(bounce)sprite.vx*=-1;if(sprite.mass)sprite.vx/=sprite.mass;sprite.x=container.x-sprite.parent.gx-container.xAnchorOffset+sprite.xAnchorOffset;collision.add("left")}if(sprite.y-sprite.yAnchorOffset<container.y-sprite.parent.gy-container.yAnchorOffset){if(bounce)sprite.vy*=-1;if(sprite.mass)sprite.vy/=sprite.mass;sprite.y=container.y-sprite.parent.gy-container.yAnchorOffset+sprite.yAnchorOffset;collision.add("top")}if(sprite.x-sprite.xAnchorOffset+sprite.width>container.width-container.xAnchorOffset){if(bounce)sprite.vx*=-1;if(sprite.mass)sprite.vx/=sprite.mass;sprite.x=container.width-sprite.width-container.xAnchorOffset+sprite.xAnchorOffset;collision.add("right")}if(sprite.y-sprite.yAnchorOffset+sprite.height>container.height-container.yAnchorOffset){if(bounce)sprite.vy*=-1;if(sprite.mass)sprite.vy/=sprite.mass;sprite.y=container.height-sprite.height-container.yAnchorOffset+sprite.yAnchorOffset;collision.add("bottom")}if(collision.size===0)collision=undefined;if(collision&&extra)extra(collision);return collision}},{key:"outsideBounds",value:function outsideBounds(s,bounds,extra){var x=bounds.x,y=bounds.y,width=bounds.width,height=bounds.height;var collision=new Set;if(s.x<x-s.width){collision.add("left")}if(s.y<y-s.height){collision.add("top")}if(s.x>width+s.width){collision.add("right")}if(s.y>height+s.height){collision.add("bottom")}if(collision.size===0)collision=undefined;if(collision&&extra)extra(collision);return collision}},{key:"_getCenter",value:function _getCenter(o,dimension,axis){if(o.anchor!==undefined){if(o.anchor[axis]!==0){return 0}else{return dimension/2}}else{return dimension}}},{key:"hit",value:function hit(a,b){var react=arguments.length<=2||arguments[2]===undefined?false:arguments[2];var bounce=arguments.length<=3||arguments[3]===undefined?false:arguments[3];var global=arguments[4];var extra=arguments.length<=5||arguments[5]===undefined?undefined:arguments[5];var hitTestPoint=this.hitTestPoint.bind(this),hitTestRectangle=this.hitTestRectangle.bind(this),hitTestCircle=this.hitTestCircle.bind(this),movingCircleCollision=this.movingCircleCollision.bind(this),circleCollision=this.circleCollision.bind(this),hitTestCircleRectangle=this.hitTestCircleRectangle.bind(this),rectangleCollision=this.rectangleCollision.bind(this),circleRectangleCollision=this.circleRectangleCollision.bind(this);var collision=undefined,aIsASprite=a.parent!==undefined,bIsASprite=b.parent!==undefined;if(aIsASprite&&b instanceof Array||bIsASprite&&a instanceof Array){spriteVsArray()}else{collision=findCollisionType(a,b);if(collision&&extra)extra(collision)}return collision;function findCollisionType(a,b){var aIsASprite=a.parent!==undefined;var bIsASprite=b.parent!==undefined;if(aIsASprite&&bIsASprite){if(a.diameter&&b.diameter){return circleVsCircle(a,b)}else if(a.diameter&&!b.diameter){return circleVsRectangle(a,b)}else{return rectangleVsRectangle(a,b)}}else if(bIsASprite&&!(a.x===undefined)&&!(a.y===undefined)){return hitTestPoint(a,b)}else{throw new Error("I'm sorry, "+a+" and "+b+" cannot be use together in a collision test.'")}}function spriteVsArray(){if(a instanceof Array){var _ref=[_b,_a];var _a=_ref[0];var _b=_ref[1]}for(var i=b.length-1;i>=0;i--){var sprite=b[i];collision=findCollisionType(a,sprite);if(collision&&extra)extra(collision,sprite)}}function circleVsCircle(a,b){if(!react){return hitTestCircle(a,b)}else{if(a.vx+a.vy!==0&&b.vx+b.vy!==0){return movingCircleCollision(a,b,global)}else{return circleCollision(a,b,bounce,global)}}}function rectangleVsRectangle(a,b){if(!react){return hitTestRectangle(a,b,global)}else{return rectangleCollision(a,b,bounce,global)}}function circleVsRectangle(a,b){if(!react){return hitTestCircleRectangle(a,b,global)}else{return circleRectangleCollision(a,b,bounce,global)}}}}]);return Bump}();var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i]}return arr2}else{return Array.from(arr)}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var Charm=function(){function Charm(){var _this=this;var renderingEngine=arguments.length<=0||arguments[0]===undefined?PIXI:arguments[0];_classCallCheck(this,Charm);if(renderingEngine===undefined)throw new Error("Please assign a rendering engine in the constructor before using charm.js");this.renderer="";if(renderingEngine.ParticleContainer&&renderingEngine.Sprite){this.renderer="pixi"}this.globalTweens=[];this.easingFormulas={linear:function linear(x){return x},smoothstep:function smoothstep(x){return x*x*(3-2*x)},smoothstepSquared:function smoothstepSquared(x){return Math.pow(x*x*(3-2*x),2)},smoothstepCubed:function smoothstepCubed(x){return Math.pow(x*x*(3-2*x),3)},acceleration:function acceleration(x){return x*x},accelerationCubed:function accelerationCubed(x){return Math.pow(x*x,3)},deceleration:function deceleration(x){return 1-Math.pow(1-x,2)},decelerationCubed:function decelerationCubed(x){return 1-Math.pow(1-x,3)},sine:function sine(x){return Math.sin(x*Math.PI/2)},sineSquared:function sineSquared(x){return Math.pow(Math.sin(x*Math.PI/2),2)},sineCubed:function sineCubed(x){return Math.pow(Math.sin(x*Math.PI/2),2)},inverseSine:function inverseSine(x){return 1-Math.sin((1-x)*Math.PI/2)},inverseSineSquared:function inverseSineSquared(x){return 1-Math.pow(Math.sin((1-x)*Math.PI/2),2)},inverseSineCubed:function inverseSineCubed(x){return 1-Math.pow(Math.sin((1-x)*Math.PI/2),3)},spline:function spline(t,p0,p1,p2,p3){return.5*(2*p1+(-p0+p2)*t+(2*p0-5*p1+4*p2-p3)*t*t+(-p0+3*p1-3*p2+p3)*t*t*t)},cubicBezier:function cubicBezier(t,a,b,c,d){var t2=t*t;var t3=t2*t;return a+(-a*3+t*(3*a-a*t))*t+(3*b+t*(-6*b+b*3*t))*t+(c*3-c*3*t)*t2+d*t3}};this._addScaleProperties=function(sprite){if(_this.renderer==="pixi"){if(!("scaleX"in sprite)&&"scale"in sprite&&"x"in sprite.scale){Object.defineProperty(sprite,"scaleX",{get:function get(){return sprite.scale.x},set:function set(value){sprite.scale.x=value}})}if(!("scaleY"in sprite)&&"scale"in sprite&&"y"in sprite.scale){Object.defineProperty(sprite,"scaleY",{get:function get(){return sprite.scale.y},set:function set(value){sprite.scale.y=value}})}}}}_createClass(Charm,[{key:"tweenProperty",value:function tweenProperty(sprite,property,startValue,endValue,totalFrames){var type=arguments.length<=5||arguments[5]===undefined?"smoothstep":arguments[5];var _this2=this;var yoyo=arguments.length<=6||arguments[6]===undefined?false:arguments[6];var delayBeforeRepeat=arguments.length<=7||arguments[7]===undefined?0:arguments[7];var o={};var typeArray=type.split(" ");if(typeArray[0]==="bounce"){o.startMagnitude=parseInt(typeArray[1]);o.endMagnitude=parseInt(typeArray[2])}o.start=function(startValue,endValue){o.startValue=JSON.parse(JSON.stringify(startValue));o.endValue=JSON.parse(JSON.stringify(endValue));o.playing=true;o.totalFrames=totalFrames;o.frameCounter=0;_this2.globalTweens.push(o)};o.start(startValue,endValue);o.update=function(){var time=undefined,curvedTime=undefined;if(o.playing){if(o.frameCounter<o.totalFrames){var normalizedTime=o.frameCounter/o.totalFrames;if(typeArray[0]!=="bounce"){curvedTime=_this2.easingFormulas[type](normalizedTime)}else{curvedTime=_this2.easingFormulas.spline(normalizedTime,o.startMagnitude,0,1,o.endMagnitude)}sprite[property]=o.endValue*curvedTime+o.startValue*(1-curvedTime);o.frameCounter+=1}else{sprite[property]=o.endValue;o.end()}}};o.end=function(){o.playing=false;if(o.onComplete)o.onComplete();_this2.globalTweens.splice(_this2.globalTweens.indexOf(o),1);if(yoyo){_this2.wait(delayBeforeRepeat).then(function(){o.start(o.endValue,o.startValue)})}};o.play=function(){return o.playing=true};o.pause=function(){return o.playing=false};return o}},{key:"makeTween",value:function makeTween(tweensToAdd){var _this3=this;var o={};o.tweens=[];tweensToAdd.forEach(function(tweenPropertyArguments){var newTween=_this3.tweenProperty.apply(_this3,_toConsumableArray(tweenPropertyArguments));o.tweens.push(newTween)});var completionCounter=0;o.completed=function(){completionCounter+=1;if(completionCounter===o.tweens.length){if(o.onComplete)o.onComplete();completionCounter=0}};o.tweens.forEach(function(tween){tween.onComplete=function(){return o.completed()}});o.pause=function(){o.tweens.forEach(function(tween){tween.playing=false})};o.play=function(){o.tweens.forEach(function(tween){tween.playing=true})};return o}},{key:"fadeOut",value:function fadeOut(sprite){var frames=arguments.length<=1||arguments[1]===undefined?60:arguments[1];return this.tweenProperty(sprite,"alpha",sprite.alpha,0,frames,"sine")}},{key:"fadeIn",value:function fadeIn(sprite){var frames=arguments.length<=1||arguments[1]===undefined?60:arguments[1];return this.tweenProperty(sprite,"alpha",sprite.alpha,1,frames,"sine")}},{key:"pulse",value:function pulse(sprite){var frames=arguments.length<=1||arguments[1]===undefined?60:arguments[1];var minAlpha=arguments.length<=2||arguments[2]===undefined?0:arguments[2];return this.tweenProperty(sprite,"alpha",sprite.alpha,minAlpha,frames,"smoothstep",true)}},{key:"slide",value:function slide(sprite,endX,endY){var frames=arguments.length<=3||arguments[3]===undefined?60:arguments[3];var type=arguments.length<=4||arguments[4]===undefined?"smoothstep":arguments[4];var yoyo=arguments.length<=5||arguments[5]===undefined?false:arguments[5];var delayBeforeRepeat=arguments.length<=6||arguments[6]===undefined?0:arguments[6];return this.makeTween([[sprite,"x",sprite.x,endX,frames,type,yoyo,delayBeforeRepeat],[sprite,"y",sprite.y,endY,frames,type,yoyo,delayBeforeRepeat]])}},{key:"breathe",value:function breathe(sprite){var endScaleX=arguments.length<=1||arguments[1]===undefined?.8:arguments[1];var endScaleY=arguments.length<=2||arguments[2]===undefined?.8:arguments[2];var frames=arguments.length<=3||arguments[3]===undefined?60:arguments[3];var yoyo=arguments.length<=4||arguments[4]===undefined?true:arguments[4];var delayBeforeRepeat=arguments.length<=5||arguments[5]===undefined?0:arguments[5];this._addScaleProperties(sprite);return this.makeTween([[sprite,"scaleX",sprite.scaleX,endScaleX,frames,"smoothstepSquared",yoyo,delayBeforeRepeat],[sprite,"scaleY",sprite.scaleY,endScaleY,frames,"smoothstepSquared",yoyo,delayBeforeRepeat]])}},{key:"scale",value:function scale(sprite){var endScaleX=arguments.length<=1||arguments[1]===undefined?.5:arguments[1];var endScaleY=arguments.length<=2||arguments[2]===undefined?.5:arguments[2];var frames=arguments.length<=3||arguments[3]===undefined?60:arguments[3];this._addScaleProperties(sprite);return this.makeTween([[sprite,"scaleX",sprite.scaleX,endScaleX,frames,"smoothstep",false],[sprite,"scaleY",sprite.scaleY,endScaleY,frames,"smoothstep",false]])}},{key:"strobe",value:function strobe(sprite){var scaleFactor=arguments.length<=1||arguments[1]===undefined?1.3:arguments[1];var startMagnitude=arguments.length<=2||arguments[2]===undefined?10:arguments[2];var endMagnitude=arguments.length<=3||arguments[3]===undefined?20:arguments[3];var frames=arguments.length<=4||arguments[4]===undefined?10:arguments[4];var yoyo=arguments.length<=5||arguments[5]===undefined?true:arguments[5];var delayBeforeRepeat=arguments.length<=6||arguments[6]===undefined?0:arguments[6];var bounce="bounce "+startMagnitude+" "+endMagnitude;this._addScaleProperties(sprite);return this.makeTween([[sprite,"scaleX",sprite.scaleX,scaleFactor,frames,bounce,yoyo,delayBeforeRepeat],[sprite,"scaleY",sprite.scaleY,scaleFactor,frames,bounce,yoyo,delayBeforeRepeat]])}},{key:"wobble",value:function wobble(sprite){var scaleFactorX=arguments.length<=1||arguments[1]===undefined?1.2:arguments[1];var scaleFactorY=arguments.length<=2||arguments[2]===undefined?1.2:arguments[2];var frames=arguments.length<=3||arguments[3]===undefined?10:arguments[3];var xStartMagnitude=arguments.length<=4||arguments[4]===undefined?10:arguments[4];var xEndMagnitude=arguments.length<=5||arguments[5]===undefined?10:arguments[5];var yStartMagnitude=arguments.length<=6||arguments[6]===undefined?-10:arguments[6];var yEndMagnitude=arguments.length<=7||arguments[7]===undefined?-10:arguments[7];var friction=arguments.length<=8||arguments[8]===undefined?.98:arguments[8];var _this4=this;var yoyo=arguments.length<=9||arguments[9]===undefined?true:arguments[9];var delayBeforeRepeat=arguments.length<=10||arguments[10]===undefined?0:arguments[10];var bounceX="bounce "+xStartMagnitude+" "+xEndMagnitude;var bounceY="bounce "+yStartMagnitude+" "+yEndMagnitude;this._addScaleProperties(sprite);var o=this.makeTween([[sprite,"scaleX",sprite.scaleX,scaleFactorX,frames,bounceX,yoyo,delayBeforeRepeat],[sprite,"scaleY",sprite.scaleY,scaleFactorY,frames,bounceY,yoyo,delayBeforeRepeat]]);o.tweens.forEach(function(tween){tween.onComplete=function(){if(tween.endValue>1){tween.endValue*=friction;if(tween.endValue<=1){tween.endValue=1;_this4.removeTween(tween)}}}});return o}},{key:"followCurve",value:function followCurve(sprite,pointsArray,totalFrames){var type=arguments.length<=3||arguments[3]===undefined?"smoothstep":arguments[3];var _this5=this;var yoyo=arguments.length<=4||arguments[4]===undefined?false:arguments[4];var delayBeforeRepeat=arguments.length<=5||arguments[5]===undefined?0:arguments[5];var o={};var typeArray=type.split(" ");if(typeArray[0]==="bounce"){o.startMagnitude=parseInt(typeArray[1]);o.endMagnitude=parseInt(typeArray[2])}o.start=function(pointsArray){o.playing=true;o.totalFrames=totalFrames;o.frameCounter=0;o.pointsArray=JSON.parse(JSON.stringify(pointsArray));_this5.globalTweens.push(o)};o.start(pointsArray);o.update=function(){var normalizedTime=undefined,curvedTime=undefined,p=o.pointsArray;if(o.playing){if(o.frameCounter<o.totalFrames){normalizedTime=o.frameCounter/o.totalFrames;if(typeArray[0]!=="bounce"){curvedTime=_this5.easingFormulas[type](normalizedTime)}else{curvedTime=_this5.easingFormulas.spline(normalizedTime,o.startMagnitude,0,1,o.endMagnitude)}sprite.x=_this5.easingFormulas.cubicBezier(curvedTime,p[0][0],p[1][0],p[2][0],p[3][0]);sprite.y=_this5.easingFormulas.cubicBezier(curvedTime,p[0][1],p[1][1],p[2][1],p[3][1]);o.frameCounter+=1}else{o.end()}}};o.end=function(){o.playing=false;if(o.onComplete)o.onComplete();_this5.globalTweens.splice(_this5.globalTweens.indexOf(o),1);if(yoyo){_this5.wait(delayBeforeRepeat).then(function(){o.pointsArray=o.pointsArray.reverse();o.start(o.pointsArray)})}};o.pause=function(){o.playing=false};o.play=function(){o.playing=true};return o}},{key:"walkPath",value:function walkPath(sprite,originalPathArray){var totalFrames=arguments.length<=2||arguments[2]===undefined?300:arguments[2];var type=arguments.length<=3||arguments[3]===undefined?"smoothstep":arguments[3];var loop=arguments.length<=4||arguments[4]===undefined?false:arguments[4];var _this6=this;var yoyo=arguments.length<=5||arguments[5]===undefined?false:arguments[5];var delayBetweenSections=arguments.length<=6||arguments[6]===undefined?0:arguments[6];var pathArray=JSON.parse(JSON.stringify(originalPathArray));var frames=totalFrames/pathArray.length;var currentPoint=0;var makePath=function makePath(currentPoint){var tween=_this6.makeTween([[sprite,"x",pathArray[currentPoint][0],pathArray[currentPoint+1][0],frames,type],[sprite,"y",pathArray[currentPoint][1],pathArray[currentPoint+1][1],frames,type]]);tween.onComplete=function(){currentPoint+=1;if(currentPoint<pathArray.length-1){_this6.wait(delayBetweenSections).then(function(){tween=makePath(currentPoint)})}else{if(loop){if(yoyo)pathArray.reverse();_this6.wait(delayBetweenSections).then(function(){currentPoint=0;sprite.x=pathArray[0][0];sprite.y=pathArray[0][1];tween=makePath(currentPoint)})}}};return tween};var tween=makePath(currentPoint);return tween}},{key:"walkCurve",value:function walkCurve(sprite,pathArray){var totalFrames=arguments.length<=2||arguments[2]===undefined?300:arguments[2];var type=arguments.length<=3||arguments[3]===undefined?"smoothstep":arguments[3];var loop=arguments.length<=4||arguments[4]===undefined?false:arguments[4];var _this7=this;var yoyo=arguments.length<=5||arguments[5]===undefined?false:arguments[5];var delayBeforeContinue=arguments.length<=6||arguments[6]===undefined?0:arguments[6];var frames=totalFrames/pathArray.length;var currentCurve=0;var makePath=function makePath(currentCurve){var tween=_this7.followCurve(sprite,pathArray[currentCurve],frames,type);tween.onComplete=function(){currentCurve+=1;if(currentCurve<pathArray.length){_this7.wait(delayBeforeContinue).then(function(){tween=makePath(currentCurve)})}else{if(loop){if(yoyo){pathArray.reverse();pathArray.forEach(function(curveArray){return curveArray.reverse()})}_this7.wait(delayBeforeContinue).then(function(){currentCurve=0;sprite.x=pathArray[0][0];sprite.y=pathArray[0][1];tween=makePath(currentCurve)})}}};return tween};var tween=makePath(currentCurve);return tween}},{key:"wait",value:function wait(){var duration=arguments.length<=0||arguments[0]===undefined?0:arguments[0];return new Promise(function(resolve,reject){setTimeout(resolve,duration)})}},{key:"removeTween",value:function removeTween(tweenObject){var _this8=this;if(!tweenObject.tweens){tweenObject.pause();if(this.globalTweens.indexOf(tweenObject)!=-1){this.globalTweens.splice(this.globalTweens.indexOf(tweenObject),1)}}else{tweenObject.pause();tweenObject.tweens.forEach(function(element){_this8.globalTweens.splice(_this8.globalTweens.indexOf(element),1)})}}},{key:"update",value:function update(){if(this.globalTweens.length>0){for(var i=this.globalTweens.length-1;i>=0;i--){var tween=this.globalTweens[i];if(tween)tween.update()}}}}]);return Charm}();var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var Tink=function(){function Tink(PIXI,element){var scale=arguments.length<=2||arguments[2]===undefined?1:arguments[2];_classCallCheck(this,Tink);this.element=element;this._scale=scale;this.draggableSprites=[];this.pointers=[];this.buttons=[];this.PIXI=PIXI;this.TextureCache=this.PIXI.utils.TextureCache;this.AnimatedSprite=this.PIXI.extras.MovieClip;this.Texture=this.PIXI.Texture}_createClass(Tink,[{key:"makeDraggable",value:function makeDraggable(){var _this=this;for(var _len=arguments.length,sprites=Array(_len),_key=0;_key<_len;_key++){sprites[_key]=arguments[_key]}if(!(sprites[0]instanceof Array)){sprites.forEach(function(sprite){_this.draggableSprites.push(sprite);if(sprite.draggable===undefined){sprite.draggable=true;sprite._localDraggableAllocation=true}})}else{var spritesArray=sprites[0];if(spritesArray.length>0){for(var i=spritesArray.length-1;i>=0;i--){var sprite=spritesArray[i];this.draggableSprites.push(sprite);if(sprite.draggable===undefined){sprite.draggable=true;sprite._localDraggableAllocation=true}}}}}},{key:"makeUndraggable",value:function makeUndraggable(){var _this2=this;for(var _len2=arguments.length,sprites=Array(_len2),_key2=0;_key2<_len2;_key2++){sprites[_key2]=arguments[_key2]}if(!(sprites[0]instanceof Array)){sprites.forEach(function(sprite){_this2.draggableSprites.splice(_this2.draggableSprites.indexOf(sprite),1);if(sprite._localDraggableAllocation===true)sprite.draggable=false})}else{var spritesArray=sprites[0];if(spritesArray.length>0){for(var i=spritesArray.length-1;i>=0;i--){var sprite=spritesArray[i];this.draggableSprites.splice(this.draggableSprites.indexOf(sprite),1);if(sprite._localDraggableAllocation===true)sprite.draggable=false}}}}},{key:"makePointer",value:function makePointer(){var element=arguments.length<=0||arguments[0]===undefined?this.element:arguments[0];var scale=arguments.length<=1||arguments[1]===undefined?this.scale:arguments[1];var draggableSprites=this.draggableSprites;var addGlobalPositionProperties=this.addGlobalPositionProperties;var pointer={element:element,_scale:scale,_x:0,_y:0,width:1,height:1,get x(){return this._x/this.scale},get y(){return this._y/this.scale},get centerX(){return this.x},get centerY(){return this.y},get position(){return{x:this.x,y:this.y}},get scale(){return this._scale},set scale(value){this._scale=value},get cursor(){return this.element.style.cursor},set cursor(value){this.element.style.cursor=value},isDown:false,isUp:true,tapped:false,downTime:0,elapsedTime:0,press:undefined,release:undefined,tap:undefined,dragSprite:null,dragOffsetX:0,dragOffsetY:0,_visible:true,get visible(){return this._visible},set visible(value){if(value===true){this.cursor="auto"}else{this.cursor="none"}this._visible=value},moveHandler:function moveHandler(event){var element=event.target;this._x=event.pageX-element.offsetLeft;this._y=event.pageY-element.offsetTop;event.preventDefault()},touchmoveHandler:function touchmoveHandler(event){var element=event.target;this._x=event.targetTouches[0].pageX-element.offsetLeft;this._y=event.targetTouches[0].pageY-element.offsetTop;event.preventDefault()},downHandler:function downHandler(event){this.isDown=true;this.isUp=false;this.tapped=false;this.downTime=Date.now();if(this.press)this.press();event.preventDefault()},touchstartHandler:function touchstartHandler(event){var element=event.target;this._x=event.targetTouches[0].pageX-element.offsetLeft;this._y=event.targetTouches[0].pageY-element.offsetTop;this.isDown=true;this.isUp=false;this.tapped=false;this.downTime=Date.now();if(this.press)this.press();event.preventDefault()},upHandler:function upHandler(event){this.elapsedTime=Math.abs(this.downTime-Date.now());if(this.elapsedTime<=200&&this.tapped===false){this.tapped=true;if(this.tap)this.tap()}this.isUp=true;this.isDown=false;if(this.release)this.release()},touchendHandler:function touchendHandler(event){this.elapsedTime=Math.abs(this.downTime-Date.now());if(this.elapsedTime<=200&&this.tapped===false){this.tapped=true;if(this.tap)this.tap()}this.isUp=true;this.isDown=false;if(this.release)this.release()},hitTestSprite:function hitTestSprite(sprite){addGlobalPositionProperties(sprite);var hit=false;var xAnchorOffset=undefined,yAnchorOffset=undefined;if(sprite.anchor!==undefined){xAnchorOffset=sprite.width*sprite.anchor.x;yAnchorOffset=sprite.height*sprite.anchor.y}else{xAnchorOffset=0;yAnchorOffset=0}if(!sprite.circular){var left=sprite.gx-xAnchorOffset,right=sprite.gx+sprite.width-xAnchorOffset,top=sprite.gy-yAnchorOffset,bottom=sprite.gy+sprite.height-yAnchorOffset;hit=this.x>left&&this.x<right&&this.y>top&&this.y<bottom}else{var vx=this.x-(sprite.gx+sprite.width/2-xAnchorOffset),vy=this.y-(sprite.gy+sprite.width/2-yAnchorOffset),distance=Math.sqrt(vx*vx+vy*vy);hit=distance<sprite.width/2}return hit}};element.addEventListener("mousemove",pointer.moveHandler.bind(pointer),false);element.addEventListener("mousedown",pointer.downHandler.bind(pointer),false);window.addEventListener("mouseup",pointer.upHandler.bind(pointer),false);element.addEventListener("touchmove",pointer.touchmoveHandler.bind(pointer),false);element.addEventListener("touchstart",pointer.touchstartHandler.bind(pointer),false);window.addEventListener("touchend",pointer.touchendHandler.bind(pointer),false);element.style.touchAction="none";this.pointers.push(pointer);return pointer}},{key:"addGlobalPositionProperties",value:function addGlobalPositionProperties(sprite){if(sprite.gx===undefined){Object.defineProperty(sprite,"gx",{get:function get(){return sprite.getGlobalPosition().x}})}if(sprite.gy===undefined){Object.defineProperty(sprite,"gy",{get:function get(){return sprite.getGlobalPosition().y}})}}},{key:"updateDragAndDrop",value:function updateDragAndDrop(draggableSprites){if(this.pointers.length===0){this.makePointer(this.element,this.scale)}this.pointers.forEach(function(pointer){if(pointer.isDown){if(pointer.dragSprite===null){for(var i=draggableSprites.length-1;i>-1;i--){var sprite=draggableSprites[i];if(pointer.hitTestSprite(sprite)&&sprite.draggable){pointer.dragOffsetX=pointer.x-sprite.gx;pointer.dragOffsetY=pointer.y-sprite.gy;pointer.dragSprite=sprite;var children=sprite.parent.children;children.splice(children.indexOf(sprite),1);children.push(sprite);draggableSprites.splice(draggableSprites.indexOf(sprite),1);draggableSprites.push(sprite);break}}}else{pointer.dragSprite.x=pointer.x-pointer.dragOffsetX;pointer.dragSprite.y=pointer.y-pointer.dragOffsetY}}if(pointer.isUp){pointer.dragSprite=null}draggableSprites.some(function(sprite){if(pointer.hitTestSprite(sprite)&&sprite.draggable){
  15. if(pointer.visible)pointer.cursor="pointer";return true}else{if(pointer.visible)pointer.cursor="auto";return false}})})}},{key:"makeInteractive",value:function makeInteractive(o){o.press=o.press||undefined;o.release=o.release||undefined;o.over=o.over||undefined;o.out=o.out||undefined;o.tap=o.tap||undefined;o.state="up";o.action="";o.pressed=false;o.hoverOver=false;o.tinkType="";o.enabled=true;this.buttons.push(o)}},{key:"updateButtons",value:function updateButtons(){var _this3=this;if(this.pointers.length===0){this.makePointer(this.element,this.scale)}this.pointers.forEach(function(pointer){pointer.shouldBeHand=false;_this3.buttons.forEach(function(o){if(o.enabled){var hit=pointer.hitTestSprite(o);if(pointer.isUp){o.state="up";if(o.tinkType==="button")o.gotoAndStop(0)}if(hit){o.state="over";if(o.totalFrames&&o.totalFrames===3&&o.tinkType==="button"){o.gotoAndStop(1)}if(pointer.isDown){o.state="down";if(o.tinkType==="button"){if(o.totalFrames===3){o.gotoAndStop(2)}else{o.gotoAndStop(1)}}}pointer.shouldBeHand=true;if(pointer.visible)pointer.cursor="pointer"}else{if(pointer.visible)pointer.cursor="auto"}if(o.state==="down"){if(!o.pressed){if(o.press)o.press();o.pressed=true;o.action="pressed"}}if(o.state==="over"){if(o.pressed){if(o.release)o.release();o.pressed=false;o.action="released";if(pointer.tapped&&o.tap)o.tap()}if(!o.hoverOver){if(o.over)o.over();o.hoverOver=true}}if(o.state==="up"){if(o.pressed){if(o.release)o.release();o.pressed=false;o.action="released"}if(o.hoverOver){if(o.out)o.out();o.hoverOver=false}}}});if(pointer.shouldBeHand){pointer.cursor="pointer"}else{pointer.cursor="auto"}})}},{key:"button",value:function button(source){var x=arguments.length<=1||arguments[1]===undefined?0:arguments[1];var y=arguments.length<=2||arguments[2]===undefined?0:arguments[2];var o=undefined;if(typeof source[0]==="string"){if(this.TextureCache[source[0]]){o=this.AnimatedSprite.fromFrames(source)}else{o=this.AnimatedSprite.fromImages(source)}}else if(source[0]instanceof this.Texture){o=new this.AnimatedSprite(source)}this.makeInteractive(o);o.tinkType="button";o.x=x;o.y=y;return o}},{key:"update",value:function update(){if(this.draggableSprites.length!==0)this.updateDragAndDrop(this.draggableSprites);if(this.buttons.length!==0)this.updateButtons()}},{key:"keyboard",value:function keyboard(keyCode){var key={};key.code=keyCode;key.isDown=false;key.isUp=true;key.press=undefined;key.release=undefined;key.downHandler=function(event){if(event.keyCode===key.code){if(key.isUp&&key.press)key.press();key.isDown=true;key.isUp=false}event.preventDefault()};key.upHandler=function(event){if(event.keyCode===key.code){if(key.isDown&&key.release)key.release();key.isDown=false;key.isUp=true}event.preventDefault()};window.addEventListener("keydown",key.downHandler.bind(key),false);window.addEventListener("keyup",key.upHandler.bind(key),false);return key}},{key:"arrowControl",value:function arrowControl(sprite,speed){if(speed===undefined){throw new Error("Please supply the arrowControl method with the speed at which you want the sprite to move")}var upArrow=this.keyboard(38),rightArrow=this.keyboard(39),downArrow=this.keyboard(40),leftArrow=this.keyboard(37);leftArrow.press=function(){sprite.vx=-speed;sprite.vy=0};leftArrow.release=function(){if(!rightArrow.isDown&&sprite.vy===0){sprite.vx=0}};upArrow.press=function(){sprite.vy=-speed;sprite.vx=0};upArrow.release=function(){if(!downArrow.isDown&&sprite.vx===0){sprite.vy=0}};rightArrow.press=function(){sprite.vx=speed;sprite.vy=0};rightArrow.release=function(){if(!leftArrow.isDown&&sprite.vy===0){sprite.vx=0}};downArrow.press=function(){sprite.vy=speed;sprite.vx=0};downArrow.release=function(){if(!upArrow.isDown&&sprite.vx===0){sprite.vy=0}}}},{key:"scale",get:function get(){return this._scale},set:function set(value){this._scale=value;this.pointers.forEach(function(pointer){return pointer.scale=value})}}]);return Tink}();var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var Dust=function(){function Dust(){var renderingEngine=arguments.length<=0||arguments[0]===undefined?PIXI:arguments[0];_classCallCheck(this,Dust);if(renderingEngine===undefined)throw new Error("Please assign a rendering engine in the constructor before using pixiDust.js");this.renderer="";if(renderingEngine.ParticleContainer){this.Container=renderingEngine.Container;this.renderer="pixi"}this.globalParticles=[]}_createClass(Dust,[{key:"randomFloat",value:function randomFloat(min,max){return min+Math.random()*(max-min)}},{key:"randomInt",value:function randomInt(min,max){return Math.floor(Math.random()*(max-min+1))+min}},{key:"create",value:function create(){var x=arguments.length<=0||arguments[0]===undefined?0:arguments[0];var y=arguments.length<=1||arguments[1]===undefined?0:arguments[1];var spriteFunction=arguments.length<=2||arguments[2]===undefined?function(){return console.log("Sprite creation function")}:arguments[2];var container=arguments.length<=3||arguments[3]===undefined?function(){return new _this.Container}:arguments[3];var numberOfParticles=arguments.length<=4||arguments[4]===undefined?20:arguments[4];var gravity=arguments.length<=5||arguments[5]===undefined?0:arguments[5];var randomSpacing=arguments.length<=6||arguments[6]===undefined?true:arguments[6];var minAngle=arguments.length<=7||arguments[7]===undefined?0:arguments[7];var maxAngle=arguments.length<=8||arguments[8]===undefined?6.28:arguments[8];var minSize=arguments.length<=9||arguments[9]===undefined?4:arguments[9];var maxSize=arguments.length<=10||arguments[10]===undefined?16:arguments[10];var minSpeed=arguments.length<=11||arguments[11]===undefined?.3:arguments[11];var maxSpeed=arguments.length<=12||arguments[12]===undefined?3:arguments[12];var minScaleSpeed=arguments.length<=13||arguments[13]===undefined?.01:arguments[13];var maxScaleSpeed=arguments.length<=14||arguments[14]===undefined?.05:arguments[14];var minAlphaSpeed=arguments.length<=15||arguments[15]===undefined?.02:arguments[15];var maxAlphaSpeed=arguments.length<=16||arguments[16]===undefined?.02:arguments[16];var _this=this;var minRotationSpeed=arguments.length<=17||arguments[17]===undefined?.01:arguments[17];var maxRotationSpeed=arguments.length<=18||arguments[18]===undefined?.03:arguments[18];var particles=[];this.globalParticles.push(particles);var angles=[];var angle=undefined;var spacing=(maxAngle-minAngle)/(numberOfParticles-1);for(var i=0;i<numberOfParticles;i++){if(randomSpacing){angle=this.randomFloat(minAngle,maxAngle);angles.push(angle)}else{if(angle===undefined)angle=minAngle;angles.push(angle);angle+=spacing}}var makeParticle=function makeParticle(angle){var particle=spriteFunction();if(particle.totalFrames>0){particle.gotoAndStop(_this.randomInt(0,particle.totalFrames-1))}var size=_this.randomInt(minSize,maxSize);particle.width=size;particle.height=size;particle.anchor.set(.5,.5);particle.x=x;particle.y=y;particle.scaleSpeed=_this.randomFloat(minScaleSpeed,maxScaleSpeed);particle.alphaSpeed=_this.randomFloat(minAlphaSpeed,maxAlphaSpeed);particle.rotationSpeed=_this.randomFloat(minRotationSpeed,maxRotationSpeed);var speed=_this.randomFloat(minSpeed,maxSpeed);particle.vx=speed*Math.cos(angle);particle.vy=speed*Math.sin(angle);particles.push(particle);container.addChild(particle);particle.updateParticle=function(){particle.vy+=gravity;particle.x+=particle.vx;particle.y+=particle.vy;if(particle.scale.x-particle.scaleSpeed>0){particle.scale.x-=particle.scaleSpeed}if(particle.scale.y-particle.scaleSpeed>0){particle.scale.y-=particle.scaleSpeed}particle.rotation+=particle.rotationSpeed;particle.alpha-=particle.alphaSpeed;if(particle.alpha<=0){container.removeChild(particle);particles.splice(particles.indexOf(particle),1)}}};angles.forEach(function(angle){return makeParticle(angle)});return particles}},{key:"emitter",value:function emitter(interval,particleFunction){var emitterObject={},timerInterval=undefined;emitterObject.playing=false;function play(){if(!emitterObject.playing){particleFunction();timerInterval=setInterval(emitParticle.bind(this),interval);emitterObject.playing=true}}function stop(){if(emitterObject.playing){clearInterval(timerInterval);emitterObject.playing=false}}function emitParticle(){particleFunction()}emitterObject.play=play;emitterObject.stop=stop;return emitterObject}},{key:"update",value:function update(){if(this.globalParticles.length>0){for(var i=this.globalParticles.length-1;i>=0;i--){var particles=this.globalParticles[i];if(particles.length>0){for(var j=particles.length-1;j>=0;j--){var particle=particles[j];particle.updateParticle()}}else{this.globalParticles.splice(this.globalParticles.indexOf(particles),1)}}}}}]);return Dust}();var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var SpriteUtilities=function(){function SpriteUtilities(){var renderingEngine=arguments.length<=0||arguments[0]===undefined?PIXI:arguments[0];_classCallCheck(this,SpriteUtilities);if(renderingEngine===undefined)throw new Error("Please supply a reference to PIXI in the SpriteUtilities constructor before using spriteUtilities.js");this.renderer="";if(renderingEngine.ParticleContainer&&renderingEngine.Sprite){this.renderer="pixi";this.Container=renderingEngine.Container;this.ParticleContainer=renderingEngine.ParticleContainer;this.TextureCache=renderingEngine.utils.TextureCache;this.Texture=renderingEngine.Texture;this.Rectangle=renderingEngine.Rectangle;this.MovieClip=renderingEngine.extras.MovieClip;this.BitmapText=renderingEngine.extras.BitmapText;this.Sprite=renderingEngine.Sprite;this.TilingSprite=renderingEngine.extras.TilingSprite;this.Graphics=renderingEngine.Graphics;this.Text=renderingEngine.Text;this.shakingSprites=[]}}_createClass(SpriteUtilities,[{key:"update",value:function update(){if(this.shakingSprites.length>0){for(var i=this.shakingSprites.length-1;i>=0;i--){var shakingSprite=this.shakingSprites[i];if(shakingSprite.updateShake)shakingSprite.updateShake()}}}},{key:"sprite",value:function sprite(source){var x=arguments.length<=1||arguments[1]===undefined?0:arguments[1];var y=arguments.length<=2||arguments[2]===undefined?0:arguments[2];var tiling=arguments.length<=3||arguments[3]===undefined?false:arguments[3];var width=arguments[4];var height=arguments[5];var o=undefined,texture=undefined;if(typeof source==="string"){if(this.TextureCache[source]){texture=this.TextureCache[source]}else{texture=this.Texture.fromImage(source)}if(texture){if(!tiling){o=new this.Sprite(texture)}else{o=new this.TilingSprite(texture,width,height)}}else{throw new Error(source+" cannot be found")}}else if(source instanceof this.Texture){if(!tiling){o=new this.Sprite(source)}else{o=new this.TilingSprite(source,width,height)}}else if(source instanceof Array){if(typeof source[0]==="string"){if(this.TextureCache[source[0]]){o=this.MovieClip.fromFrames(source)}else{o=this.MovieClip.fromImages(source)}}else if(source[0]instanceof this.Texture){o=new this.MovieClip(source)}}if(o){o.x=x;o.y=y;if(width)o.width=width;if(height)o.height=height;if(o instanceof this.MovieClip)this.addStatePlayer(o);return o}}},{key:"addStatePlayer",value:function addStatePlayer(sprite){var frameCounter=0,numberOfFrames=0,startFrame=0,endFrame=0,timerInterval=undefined;function show(frameNumber){reset();sprite.gotoAndStop(frameNumber)}function stopAnimation(){reset();sprite.gotoAndStop(sprite.currentFrame)}function playAnimation(sequenceArray){reset();if(!sequenceArray){startFrame=0;endFrame=sprite.totalFrames-1}else{startFrame=sequenceArray[0];endFrame=sequenceArray[1]}numberOfFrames=endFrame-startFrame;if(!sprite.fps)sprite.fps=12;var frameRate=1e3/sprite.fps;sprite.gotoAndStop(startFrame);frameCounter=1;if(!sprite.animating){timerInterval=setInterval(advanceFrame.bind(this),frameRate);sprite.animating=true}}function advanceFrame(){if(frameCounter<numberOfFrames+1){sprite.gotoAndStop(sprite.currentFrame+1);frameCounter+=1}else{if(sprite.loop){sprite.gotoAndStop(startFrame);frameCounter=1}}}function reset(){if(timerInterval!==undefined&&sprite.animating===true){sprite.animating=false;frameCounter=0;startFrame=0;endFrame=0;numberOfFrames=0;clearInterval(timerInterval)}}sprite.show=show;sprite.stopAnimation=stopAnimation;sprite.playAnimation=playAnimation}},{key:"tilingSprite",value:function tilingSprite(source,width,height,x,y){if(width===undefined){throw new Error("Please define a width as your second argument for the tiling sprite")}if(height===undefined){throw new Error("Please define a height as your third argument for the tiling sprite")}var o=this.sprite(source,x,y,true,width,height);Object.defineProperties(o,{tileX:{get:function get(){return o.tilePosition.x},set:function set(value){o.tilePosition.x=value},enumerable:true,configurable:true},tileY:{get:function get(){return o.tilePosition.y},set:function set(value){o.tilePosition.y=value},enumerable:true,configurable:true},tileScaleX:{get:function get(){return o.tileScale.x},set:function set(value){o.tileScale.x=value},enumerable:true,configurable:true},tileScaleY:{get:function get(){return o.tileScale.y},set:function set(value){o.tileScale.y=value},enumerable:true,configurable:true}});return o}},{key:"filmstrip",value:function filmstrip(texture,frameWidth,frameHeight){var spacing=arguments.length<=3||arguments[3]===undefined?0:arguments[3];var positions=[];var textureWidth=this.TextureCache[texture].width,textureHeight=this.TextureCache[texture].height;var columns=textureWidth/frameWidth,rows=textureHeight/frameHeight;var numberOfFrames=columns*rows;for(var i=0;i<numberOfFrames;i++){var x=i%columns*frameWidth,y=Math.floor(i/columns)*frameHeight;if(spacing>0){x+=spacing+spacing*i%columns;y+=spacing+spacing*Math.floor(i/columns)}positions.push([x,y])}return this.frames(texture,positions,frameWidth,frameHeight)}},{key:"frame",value:function frame(source,x,y,width,height){var texture=undefined,imageFrame=undefined;if(typeof source==="string"){if(this.TextureCache[source]){texture=new this.Texture(this.TextureCache[source])}}else if(source instanceof this.Texture){texture=new this.Texture(source)}if(!texture){throw new Error("Please load the "+source+" texture into the cache.")}else{imageFrame=new this.Rectangle(x,y,width,height);texture.frame=imageFrame;return texture}}},{key:"frames",value:function frames(source,coordinates,frameWidth,frameHeight){var _this=this;var baseTexture=undefined,textures=undefined;if(typeof source==="string"){if(this.TextureCache[source]){baseTexture=new this.Texture(this.TextureCache[source])}}else if(source instanceof this.Texture){baseTexture=new this.Texture(source)}if(!baseTexture){throw new Error("Please load the "+source+" texture into the cache.")}else{var _textures=coordinates.map(function(position){var x=position[0],y=position[1];var imageFrame=new _this.Rectangle(x,y,frameWidth,frameHeight);var frameTexture=new _this.Texture(baseTexture);frameTexture.frame=imageFrame;return frameTexture});return _textures}}},{key:"frameSeries",value:function frameSeries(){var startNumber=arguments.length<=0||arguments[0]===undefined?0:arguments[0];var endNumber=arguments.length<=1||arguments[1]===undefined?1:arguments[1];var baseName=arguments.length<=2||arguments[2]===undefined?"":arguments[2];var extension=arguments.length<=3||arguments[3]===undefined?"":arguments[3];var frames=[];for(var i=startNumber;i<endNumber+1;i++){var frame=this.TextureCache[""+(baseName+i+extension)];frames.push(frame)}return frames}},{key:"text",value:function text(){var content=arguments.length<=0||arguments[0]===undefined?"message":arguments[0];var font=arguments.length<=1||arguments[1]===undefined?"16px sans":arguments[1];var fillStyle=arguments.length<=2||arguments[2]===undefined?"red":arguments[2];var x=arguments.length<=3||arguments[3]===undefined?0:arguments[3];var y=arguments.length<=4||arguments[4]===undefined?0:arguments[4];var message=new this.Text(content,{font:font,fill:fillStyle});message.x=x;message.y=y;message._content=content;Object.defineProperty(message,"content",{get:function get(){return this._content},set:function set(value){this._content=value;this.text=value},enumerable:true,configurable:true});return message}},{key:"bitmapText",value:function bitmapText(){var content=arguments.length<=0||arguments[0]===undefined?"message":arguments[0];var font=arguments[1];var align=arguments[2];var tint=arguments[3];var x=arguments.length<=4||arguments[4]===undefined?0:arguments[4];var y=arguments.length<=5||arguments[5]===undefined?0:arguments[5];var message=new this.BitmapText(content,{font:font,align:align,tint:tint});message.x=x;message.y=y;message._content=content;Object.defineProperty(message,"content",{get:function get(){return this._content},set:function set(value){this._content=value;this.text=value},enumerable:true,configurable:true});return message}},{key:"rectangle",value:function rectangle(){var width=arguments.length<=0||arguments[0]===undefined?32:arguments[0];var height=arguments.length<=1||arguments[1]===undefined?32:arguments[1];var fillStyle=arguments.length<=2||arguments[2]===undefined?16724736:arguments[2];var strokeStyle=arguments.length<=3||arguments[3]===undefined?13260:arguments[3];var lineWidth=arguments.length<=4||arguments[4]===undefined?0:arguments[4];var x=arguments.length<=5||arguments[5]===undefined?0:arguments[5];var y=arguments.length<=6||arguments[6]===undefined?0:arguments[6];var o=new this.Graphics;o._sprite=undefined;o._width=width;o._height=height;o._fillStyle=this.color(fillStyle);o._strokeStyle=this.color(strokeStyle);o._lineWidth=lineWidth;var draw=function draw(width,height,fillStyle,strokeStyle,lineWidth){o.clear();o.beginFill(fillStyle);if(lineWidth>0){o.lineStyle(lineWidth,strokeStyle,1)}o.drawRect(0,0,width,height);o.endFill()};draw(o._width,o._height,o._fillStyle,o._strokeStyle,o._lineWidth);var texture=o.generateTexture();var sprite=new this.Sprite(texture);sprite.x=x;sprite.y=y;var self=this;Object.defineProperties(sprite,{fillStyle:{get:function get(){return o._fillStyle},set:function set(value){o._fillStyle=self.color(value);draw(o._width,o._height,o._fillStyle,o._strokeStyle,o._lineWidth,o._x,o._y);var texture=o.generateTexture();o._sprite.texture=texture},enumerable:true,configurable:true},strokeStyle:{get:function get(){return o._strokeStyle},set:function set(value){o._strokeStyle=self.color(value);draw(o._width,o._height,o._fillStyle,o._strokeStyle,o._lineWidth,o._x,o._y);var texture=o.generateTexture();o._sprite.texture=texture},enumerable:true,configurable:true},lineWidth:{get:function get(){return o._lineWidth},set:function set(value){o._lineWidth=value;draw(o._width,o._height,o._fillStyle,o._strokeStyle,o._lineWidth,o._x,o._y);var texture=o.generateTexture();o._sprite.texture=texture},enumerable:true,configurable:true}});o._sprite=sprite;return sprite}},{key:"circle",value:function circle(){var diameter=arguments.length<=0||arguments[0]===undefined?32:arguments[0];var fillStyle=arguments.length<=1||arguments[1]===undefined?16724736:arguments[1];var strokeStyle=arguments.length<=2||arguments[2]===undefined?13260:arguments[2];var lineWidth=arguments.length<=3||arguments[3]===undefined?0:arguments[3];var x=arguments.length<=4||arguments[4]===undefined?0:arguments[4];var y=arguments.length<=5||arguments[5]===undefined?0:arguments[5];var o=new this.Graphics;o._diameter=diameter;o._fillStyle=this.color(fillStyle);o._strokeStyle=this.color(strokeStyle);o._lineWidth=lineWidth;var draw=function draw(diameter,fillStyle,strokeStyle,lineWidth){o.clear();o.beginFill(fillStyle);if(lineWidth>0){o.lineStyle(lineWidth,strokeStyle,1)}o.drawCircle(0,0,diameter/2);o.endFill()};draw(o._diameter,o._fillStyle,o._strokeStyle,o._lineWidth);var texture=o.generateTexture();var sprite=new this.Sprite(texture);sprite.x=x;sprite.y=y;var self=this;Object.defineProperties(sprite,{fillStyle:{get:function get(){return o._fillStyle},set:function set(value){o._fillStyle=self.color(value);draw(o._diameter,o._fillStyle,o._strokeStyle,o._lineWidth);var texture=o.generateTexture();o._sprite.texture=texture},enumerable:true,configurable:true},strokeStyle:{get:function get(){return o._strokeStyle},set:function set(value){o._strokeStyle=self.color(value);draw(o._diameter,o._fillStyle,o._strokeStyle,o._lineWidth);var texture=o.generateTexture();o._sprite.texture=texture},enumerable:true,configurable:true},diameter:{get:function get(){return o._diameter},set:function set(value){o._lineWidth=10;draw(o._diameter,o._fillStyle,o._strokeStyle,o._lineWidth);var texture=o.generateTexture();o._sprite.texture=texture},enumerable:true,configurable:true},radius:{get:function get(){return o._diameter/2},set:function set(value){draw(value*2,o._fillStyle,o._strokeStyle,o._lineWidth);var texture=o.generateTexture();o._sprite.texture=texture},enumerable:true,configurable:true}});o._sprite=sprite;return sprite}},{key:"line",value:function line(){var strokeStyle=arguments.length<=0||arguments[0]===undefined?0:arguments[0];var lineWidth=arguments.length<=1||arguments[1]===undefined?1:arguments[1];var ax=arguments.length<=2||arguments[2]===undefined?0:arguments[2];var ay=arguments.length<=3||arguments[3]===undefined?0:arguments[3];var bx=arguments.length<=4||arguments[4]===undefined?32:arguments[4];var by=arguments.length<=5||arguments[5]===undefined?32:arguments[5];var o=new this.Graphics;o._strokeStyle=this.color(strokeStyle);o._width=lineWidth;o._ax=ax;o._ay=ay;o._bx=bx;o._by=by;var draw=function draw(strokeStyle,lineWidth,ax,ay,bx,by){o.clear();o.lineStyle(lineWidth,strokeStyle,1);o.moveTo(ax,ay);o.lineTo(bx,by)};draw(o._strokeStyle,o._width,o._ax,o._ay,o._bx,o._by);var self=this;Object.defineProperties(o,{ax:{get:function get(){return o._ax},set:function set(value){o._ax=value;draw(o._strokeStyle,o._width,o._ax,o._ay,o._bx,o._by)},enumerable:true,configurable:true},ay:{get:function get(){return o._ay},set:function set(value){o._ay=value;draw(o._strokeStyle,o._width,o._ax,o._ay,o._bx,o._by)},enumerable:true,configurable:true},bx:{get:function get(){return o._bx},set:function set(value){o._bx=value;draw(o._strokeStyle,o._width,o._ax,o._ay,o._bx,o._by)},enumerable:true,configurable:true},by:{get:function get(){return o._by},set:function set(value){o._by=value;draw(o._strokeStyle,o._width,o._ax,o._ay,o._bx,o._by)},enumerable:true,configurable:true},strokeStyle:{get:function get(){return o._strokeStyle},set:function set(value){o._strokeStyle=self.color(value);draw(o._strokeStyle,o._width,o._ax,o._ay,o._bx,o._by)},enumerable:true,configurable:true},width:{get:function get(){return o._width},set:function set(value){o._width=value;draw(o._strokeStyle,o._width,o._ax,o._ay,o._bx,o._by)},enumerable:true,configurable:true}});return o}},{key:"grid",value:function grid(){var columns=arguments.length<=0||arguments[0]===undefined?0:arguments[0];var rows=arguments.length<=1||arguments[1]===undefined?0:arguments[1];var cellWidth=arguments.length<=2||arguments[2]===undefined?32:arguments[2];var cellHeight=arguments.length<=3||arguments[3]===undefined?32:arguments[3];var centerCell=arguments.length<=4||arguments[4]===undefined?false:arguments[4];var xOffset=arguments.length<=5||arguments[5]===undefined?0:arguments[5];var yOffset=arguments.length<=6||arguments[6]===undefined?0:arguments[6];var makeSprite=arguments.length<=7||arguments[7]===undefined?undefined:arguments[7];var extra=arguments.length<=8||arguments[8]===undefined?undefined:arguments[8];var container=new this.Container;var createGrid=function createGrid(){var length=columns*rows;for(var i=0;i<length;i++){var x=i%columns*cellWidth,y=Math.floor(i/columns)*cellHeight;var sprite=makeSprite();container.addChild(sprite);if(!centerCell){sprite.x=x+xOffset;sprite.y=y+yOffset}else{sprite.x=x+cellWidth/2-sprite.width/2+xOffset;sprite.y=y+cellHeight/2-sprite.width/2+yOffset}if(extra)extra(sprite)}};createGrid();return container}},{key:"shoot",value:function shoot(shooter,angle,x,y,container,bulletSpeed,bulletArray,bulletSprite){var bullet=bulletSprite();bullet.anchor.set(.5,.5);shooter.addChild(bullet);bullet.x=x;bullet.y=y;var tempGx=bullet.getGlobalPosition().x,tempGy=bullet.getGlobalPosition().y;container.addChild(bullet);bullet.x=tempGx;bullet.y=tempGy;bullet.vx=Math.cos(angle)*bulletSpeed;bullet.vy=Math.sin(angle)*bulletSpeed;bulletArray.push(bullet)}},{key:"grid",value:function grid(){var columns=arguments.length<=0||arguments[0]===undefined?0:arguments[0];var rows=arguments.length<=1||arguments[1]===undefined?0:arguments[1];var cellWidth=arguments.length<=2||arguments[2]===undefined?32:arguments[2];var cellHeight=arguments.length<=3||arguments[3]===undefined?32:arguments[3];var centerCell=arguments.length<=4||arguments[4]===undefined?false:arguments[4];var xOffset=arguments.length<=5||arguments[5]===undefined?0:arguments[5];var yOffset=arguments.length<=6||arguments[6]===undefined?0:arguments[6];var makeSprite=arguments.length<=7||arguments[7]===undefined?undefined:arguments[7];var extra=arguments.length<=8||arguments[8]===undefined?undefined:arguments[8];var container=this.group();var createGrid=function createGrid(){var length=columns*rows;for(var i=0;i<length;i++){var x=i%columns*cellWidth,y=Math.floor(i/columns)*cellHeight;var sprite=makeSprite();container.addChild(sprite);if(!centerCell){sprite.x=x+xOffset;sprite.y=y+yOffset}else{sprite.x=x+cellWidth/2-sprite.halfWidth+xOffset;sprite.y=y+cellHeight/2-sprite.halfHeight+yOffset}if(extra)extra(sprite)}};createGrid();return container}},{key:"shake",value:function shake(sprite){var magnitude=arguments.length<=1||arguments[1]===undefined?16:arguments[1];var angular=arguments.length<=2||arguments[2]===undefined?false:arguments[2];var self=this;var counter=1;var numberOfShakes=10;var startX=sprite.x,startY=sprite.y,startAngle=sprite.rotation;var magnitudeUnit=magnitude/numberOfShakes;var randomInt=function randomInt(min,max){return Math.floor(Math.random()*(max-min+1))+min};if(self.shakingSprites.indexOf(sprite)===-1){self.shakingSprites.push(sprite);sprite.updateShake=function(){if(angular){angularShake()}else{upAndDownShake()}}}function upAndDownShake(){if(counter<numberOfShakes){sprite.x=startX;sprite.y=startY;magnitude-=magnitudeUnit;sprite.x+=randomInt(-magnitude,magnitude);sprite.y+=randomInt(-magnitude,magnitude);counter+=1}if(counter>=numberOfShakes){sprite.x=startX;sprite.y=startY;self.shakingSprites.splice(self.shakingSprites.indexOf(sprite),1)}}var tiltAngle=1;function angularShake(){if(counter<numberOfShakes){sprite.rotation=startAngle;magnitude-=magnitudeUnit;sprite.rotation=magnitude*tiltAngle;counter+=1;tiltAngle*=-1}if(counter>=numberOfShakes){sprite.rotation=startAngle;self.shakingSprites.splice(self.shakingSprites.indexOf(sprite),1)}}}},{key:"_getCenter",value:function _getCenter(o,dimension,axis){if(o.anchor!==undefined){if(o.anchor[axis]!==0){return 0}else{return dimension/2}}else{return dimension}}},{key:"group",value:function group(){var container=new this.Container;for(var _len=arguments.length,sprites=Array(_len),_key=0;_key<_len;_key++){sprites[_key]=arguments[_key]}sprites.forEach(function(sprite){container.addChild(sprite)});return container}},{key:"batch",value:function batch(){var size=arguments.length<=0||arguments[0]===undefined?15e3:arguments[0];var options=arguments.length<=1||arguments[1]===undefined?{rotation:true,alpha:true,scale:true,uvs:true}:arguments[1];var o=new this.ParticleContainer(size,options);return o}},{key:"remove",value:function remove(){for(var _len2=arguments.length,sprites=Array(_len2),_key2=0;_key2<_len2;_key2++){sprites[_key2]=arguments[_key2]}if(!(sprites[0]instanceof Array)){if(sprites.length>1){sprites.forEach(function(sprite){sprite.parent.removeChild(sprite)})}else{sprites[0].parent.removeChild(sprites[0])}}else{var spritesArray=sprites[0];if(spritesArray.length>0){for(var i=spritesArray.length-1;i>=0;i--){var sprite=spritesArray[i];sprite.parent.removeChild(sprite);spritesArray.splice(spritesArray.indexOf(sprite),1)}}}}},{key:"colorToRGBA",value:function colorToRGBA(color){var cvs,ctx;cvs=document.createElement("canvas");cvs.height=1;cvs.width=1;ctx=cvs.getContext("2d");ctx.fillStyle=color;ctx.fillRect(0,0,1,1);var data=ctx.getImageData(0,0,1,1).data;return data}},{key:"byteToHex",value:function byteToHex(num){return("0"+num.toString(16)).slice(-2)}},{key:"colorToHex",value:function colorToHex(color){var _this2=this;var rgba,hex;rgba=this.colorToRGBA(color);hex=[0,1,2].map(function(idx){return _this2.byteToHex(rgba[idx])}).join("");return"0x"+hex}},{key:"color",value:function color(value){if(!isNaN(value)){return value}else{return parseInt(this.colorToHex(value))}}}]);return SpriteUtilities}();var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var GameUtilities=function(){function GameUtilities(){_classCallCheck(this,GameUtilities)}_createClass(GameUtilities,[{key:"distance",value:function distance(s1,s2){var vx=s2.x+this._getCenter(s2,s2.width,"x")-(s1.x+this._getCenter(s1,s1.width,"x")),vy=s2.y+this._getCenter(s2,s2.height,"y")-(s1.y+this._getCenter(s1,s1.height,"y"));return Math.sqrt(vx*vx+vy*vy)}},{key:"followEase",value:function followEase(follower,leader,speed){var vx=leader.x+this._getCenter(leader,leader.width,"x")-(follower.x+this._getCenter(follower,follower.width,"x")),vy=leader.y+this._getCenter(leader,leader.height,"y")-(follower.y+this._getCenter(follower,follower.height,"y")),distance=Math.sqrt(vx*vx+vy*vy);if(distance>=1){follower.x+=vx*speed;follower.y+=vy*speed}}},{key:"followConstant",value:function followConstant(follower,leader,speed){var vx=leader.x+this._getCenter(leader,leader.width,"x")-(follower.x+this._getCenter(follower,follower.width,"x")),vy=leader.y+this._getCenter(leader,leader.height,"y")-(follower.y+this._getCenter(follower,follower.height,"y")),distance=Math.sqrt(vx*vx+vy*vy);if(distance>=speed){follower.x+=vx/distance*speed;follower.y+=vy/distance*speed}}},{key:"angle",value:function angle(s1,s2){return Math.atan2(s2.y+this._getCenter(s2,s2.height,"y")-(s1.y+this._getCenter(s1,s1.height,"y")),s2.x+this._getCenter(s2,s2.width,"x")-(s1.x+this._getCenter(s1,s1.width,"x")))}},{key:"_getCenter",value:function _getCenter(o,dimension,axis){if(o.anchor!==undefined){if(o.anchor[axis]!==0){return 0}else{return dimension/2}}else{return dimension}}},{key:"rotateAroundSprite",value:function rotateAroundSprite(rotatingSprite,centerSprite,distance,angle){
  16. rotatingSprite.x=centerSprite.x+this._getCenter(centerSprite,centerSprite.width,"x")-rotatingSprite.parent.x+distance*Math.cos(angle)-this._getCenter(rotatingSprite,rotatingSprite.width,"x");rotatingSprite.y=centerSprite.y+this._getCenter(centerSprite,centerSprite.height,"y")-rotatingSprite.parent.y+distance*Math.sin(angle)-this._getCenter(rotatingSprite,rotatingSprite.height,"y")}},{key:"rotateAroundPoint",value:function rotateAroundPoint(pointX,pointY,distanceX,distanceY,angle){var point={};point.x=pointX+Math.cos(angle)*distanceX;point.y=pointY+Math.sin(angle)*distanceY;return point}},{key:"randomInt",value:function randomInt(min,max){return Math.floor(Math.random()*(max-min+1))+min}},{key:"randomFloat",value:function randomFloat(min,max){return min+Math.random()*(max-min)}},{key:"wait",value:function wait(duration,callBack){setTimeout(callBack,duration)}},{key:"move",value:function move(){for(var _len=arguments.length,sprites=Array(_len),_key=0;_key<_len;_key++){sprites[_key]=arguments[_key]}if(!(sprites[0]instanceof Array)){if(sprites.length>1){sprites.forEach(function(sprite){sprite.x+=sprite.vx;sprite.y+=sprite.vy})}else{sprites[0].x+=sprites[0].vx;sprites[0].y+=sprites[0].vy}}else{var spritesArray=sprites[0];if(spritesArray.length>0){for(var i=spritesArray.length-1;i>=0;i--){var sprite=spritesArray[i];sprite.x+=sprite.vx;sprite.y+=sprite.vy}}}}},{key:"worldCamera",value:function worldCamera(world,worldWidth,worldHeight,canvas){var camera={width:canvas.width,height:canvas.height,_x:0,_y:0,get x(){return this._x},set x(value){this._x=value;world.x=-this._x},get y(){return this._y},set y(value){this._y=value;world.y=-this._y},get centerX(){return this.x+this.width/2},get centerY(){return this.y+this.height/2},get rightInnerBoundary(){return this.x+this.width/2+this.width/4},get leftInnerBoundary(){return this.x+this.width/2-this.width/4},get topInnerBoundary(){return this.y+this.height/2-this.height/4},get bottomInnerBoundary(){return this.y+this.height/2+this.height/4},follow:function follow(sprite){if(sprite.x<this.leftInnerBoundary){this.x=sprite.x-this.width/4}if(sprite.y<this.topInnerBoundary){this.y=sprite.y-this.height/4}if(sprite.x+sprite.width>this.rightInnerBoundary){this.x=sprite.x+sprite.width-this.width/4*3}if(sprite.y+sprite.height>this.bottomInnerBoundary){this.y=sprite.y+sprite.height-this.height/4*3}if(this.x<0){this.x=0}if(this.y<0){this.y=0}if(this.x+this.width>worldWidth){this.x=worldWidth-this.width}if(this.y+this.height>worldHeight){this.y=worldHeight-this.height}},centerOver:function centerOver(sprite){this.x=sprite.x+sprite.halfWidth-this.width/2;this.y=sprite.y+sprite.halfHeight-this.height/2}};return camera}},{key:"lineOfSight",value:function lineOfSight(s1,s2,obstacles){var segment=arguments.length<=3||arguments[3]===undefined?32:arguments[3];spriteOneCenterX=s1.x+this._getCenter(s1,s1.width,"x");spriteOneCenterY=s1.y+this._getCenter(s1,s1.height,"y");spriteTwoCenterX=s2.x+this._getCenter(s2,s2.width,"x");spriteTwoCenterY=s2.y+this._getCenter(s2,s2.height,"y");var vx=spriteTwoCenterX-spriteOneCenterX,vy=spriteTwoCenterY-spriteOneCenterY;var magnitude=Math.sqrt(vx*vx+vy*vy);var numberOfPoints=magnitude/segment;var points=function points(){var arrayOfPoints=[];for(var i=1;i<=numberOfPoints;i++){var newMagnitude=segment*i;var dx=vx/magnitude,dy=vy/magnitude;var x=spriteOneCenterX+dx*newMagnitude,y=spriteOneCenterY+dy*newMagnitude;arrayOfPoints.push({x:x,y:y})}return arrayOfPoints};var hitTestPoint=function hitTestPoint(point,sprite){var left=point.x>sprite.x,right=point.x<sprite.x+sprite.width,top=point.y>sprite.y,bottom=point.y<sprite.y+sprite.height;return left&&right&&top&&bottom};var noObstacles=points().every(function(point){return obstacles.every(function(obstacle){return!hitTestPoint(point,obstacle)})});return noObstacles}}]);return GameUtilities}();var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var Smoothie=function(){function Smoothie(){var options=arguments.length<=0||arguments[0]===undefined?{engine:PIXI,renderer:undefined,root:undefined,update:undefined,interpolate:true,fps:60,renderFps:undefined,properties:{position:true,rotation:true,size:false,scale:false,alpha:false,tile:false}}:arguments[0];_classCallCheck(this,Smoothie);if(options.engine===undefined)throw new Error("Please assign a rendering engine as Smoothie's engine option");this.engine="";if(options.engine.ParticleContainer&&options.engine.Sprite){this.renderingEngine="pixi";this.Container=options.engine.Container;this.Sprite=options.engine.Sprite;this.MovieClip=options.engine.extras.MovieClip}if(options.renderer===undefined){throw new Error("Please assign a renderer object as Smoothie's renderer option")}else{this.renderer=options.renderer}if(options.root===undefined){throw new Error("Please assign a root container object (the stage) as Smoothie's rootr option")}else{this.stage=options.root}if(options.update===undefined){throw new Error("Please assign a function that you want to update on each frame as Smoothie's update option")}else{this.update=options.update}if(options.properties===undefined){this.properties={position:true,rotation:true}}else{this.properties=options.properties}if(options.fps!==undefined){this._fps=options.fps}else{this._fps=undefined}if(options.renderFps!==undefined){this._renderFps=options.renderFps}else{this._renderFps=undefined}if(options.interpolate===false){this.interpolate=false}else{this.interpolate=true}this.paused=false;this._startTime=Date.now();this._frameDuration=1e3/this._fps;this._lag=0;this._lagOffset=0;this._renderStartTime=0;if(this._renderFps!==undefined){this._renderDuration=1e3/this._renderFps}}_createClass(Smoothie,[{key:"pause",value:function pause(){this.paused=true}},{key:"resume",value:function resume(){this.paused=false}},{key:"start",value:function start(){this.gameLoop()}},{key:"gameLoop",value:function gameLoop(timestamp){var _this=this;requestAnimationFrame(this.gameLoop.bind(this));if(!this.paused){var interpolate=function interpolate(){var current=Date.now(),elapsed=current-_this._startTime;if(elapsed>1e3)elapsed=_this._frameDuration;_this._startTime=current;_this._lag+=elapsed;while(_this._lag>=_this._frameDuration){_this.capturePreviousSpriteProperties();_this.update();_this._lag-=_this._frameDuration}_this._lagOffset=_this._lag/_this._frameDuration;_this.render(_this._lagOffset)};if(this._fps===undefined){this.update();this.render()}else{if(this._renderFps===undefined){interpolate()}else{if(timestamp>=this._renderStartTime){interpolate();this._renderStartTime=timestamp+this._renderDuration}}}}}},{key:"capturePreviousSpriteProperties",value:function capturePreviousSpriteProperties(){var _this2=this;var setProperties=function setProperties(sprite){if(_this2.properties.position){sprite._previousX=sprite.x;sprite._previousY=sprite.y}if(_this2.properties.rotation){sprite._previousRotation=sprite.rotation}if(_this2.properties.size){sprite._previousWidth=sprite.width;sprite._previousHeight=sprite.height}if(_this2.properties.scale){sprite._previousScaleX=sprite.scale.x;sprite._previousScaleY=sprite.scale.y}if(_this2.properties.alpha){sprite._previousAlpha=sprite.alpha}if(_this2.properties.tile){if(sprite.tilePosition!==undefined){sprite._previousTilePositionX=sprite.tilePosition.x;sprite._previousTilePositionY=sprite.tilePosition.y}if(sprite.tileScale!==undefined){sprite._previousTileScaleX=sprite.tileScale.x;sprite._previousTileScaleY=sprite.tileScale.y}}if(sprite.children&&sprite.children.length>0){for(var i=0;i<sprite.children.length;i++){var child=sprite.children[i];setProperties(child)}}};for(var i=0;i<this.stage.children.length;i++){var sprite=this.stage.children[i];setProperties(sprite)}}},{key:"render",value:function render(){var _this3=this;var lagOffset=arguments.length<=0||arguments[0]===undefined?1:arguments[0];if(this.interpolate){(function(){var interpolateSprite=function interpolateSprite(sprite){if(_this3.properties.position){sprite._currentX=sprite.x;sprite._currentY=sprite.y;if(sprite._previousX!==undefined){sprite.x=(sprite.x-sprite._previousX)*lagOffset+sprite._previousX}if(sprite._previousY!==undefined){sprite.y=(sprite.y-sprite._previousY)*lagOffset+sprite._previousY}}if(_this3.properties.rotation){sprite._currentRotation=sprite.rotation;if(sprite._previousRotation!==undefined){sprite.rotation=(sprite.rotation-sprite._previousRotation)*lagOffset+sprite._previousRotation}}if(_this3.properties.size){if(sprite instanceof _this3.Sprite||sprite instanceof _this3.MovieClip){sprite._currentWidth=sprite.width;sprite._currentHeight=sprite.height;if(sprite._previousWidth!==undefined){sprite.width=(sprite.width-sprite._previousWidth)*lagOffset+sprite._previousWidth}if(sprite._previousHeight!==undefined){sprite.height=(sprite.height-sprite._previousHeight)*lagOffset+sprite._previousHeight}}}if(_this3.properties.scale){sprite._currentScaleX=sprite.scale.x;sprite._currentScaleY=sprite.scale.y;if(sprite._previousScaleX!==undefined){sprite.scale.x=(sprite.scale.x-sprite._previousScaleX)*lagOffset+sprite._previousScaleX}if(sprite._previousScaleY!==undefined){sprite.scale.y=(sprite.scale.y-sprite._previousScaleY)*lagOffset+sprite._previousScaleY}}if(_this3.properties.alpha){sprite._currentAlpha=sprite.alpha;if(sprite._previousAlpha!==undefined){sprite.alpha=(sprite.alpha-sprite._previousAlpha)*lagOffset+sprite._previousAlpha}}if(_this3.properties.tile){if(sprite.tilePosition!==undefined){sprite._currentTilePositionX=sprite.tilePosition.x;sprite._currentTilePositionY=sprite.tilePosition.y;if(sprite._previousTilePositionX!==undefined){sprite.tilePosition.x=(sprite.tilePosition.x-sprite._previousTilePositionX)*lagOffset+sprite._previousTilePositionX}if(sprite._previousTilePositionY!==undefined){sprite.tilePosition.y=(sprite.tilePosition.y-sprite._previousTilePositionY)*lagOffset+sprite._previousTilePositionY}}if(sprite.tileScale!==undefined){sprite._currentTileScaleX=sprite.tileScale.x;sprite._currentTileScaleY=sprite.tileScale.y;if(sprite._previousTileScaleX!==undefined){sprite.tileScale.x=(sprite.tileScale.x-sprite._previousTileScaleX)*lagOffset+sprite._previousTileScaleX}if(sprite._previousTileScaleY!==undefined){sprite.tileScale.y=(sprite.tileScale.y-sprite._previousTileScaleY)*lagOffset+sprite._previousTileScaleY}}}if(sprite.children.length!==0){for(var j=0;j<sprite.children.length;j++){var child=sprite.children[j];interpolateSprite(child)}}};for(var i=0;i<_this3.stage.children.length;i++){var sprite=_this3.stage.children[i];interpolateSprite(sprite)}})()}this.renderer.render(this.stage);if(this.interpolate){(function(){var restoreSpriteProperties=function restoreSpriteProperties(sprite){if(_this3.properties.position){sprite.x=sprite._currentX;sprite.y=sprite._currentY}if(_this3.properties.rotation){sprite.rotation=sprite._currentRotation}if(_this3.properties.size){if(sprite instanceof _this3.Sprite||sprite instanceof _this3.MovieClip){sprite.width=sprite._currentWidth;sprite.height=sprite._currentHeight}}if(_this3.properties.scale){sprite.scale.x=sprite._currentScaleX;sprite.scale.y=sprite._currentScaleY}if(_this3.properties.alpha){sprite.alpha=sprite._currentAlpha}if(_this3.properties.tile){if(sprite.tilePosition!==undefined){sprite.tilePosition.x=sprite._currentTilePositionX;sprite.tilePosition.y=sprite._currentTilePositionY}if(sprite.tileScale!==undefined){sprite.tileScale.x=sprite._currentTileScaleX;sprite.tileScale.y=sprite._currentTileScaleY}}if(sprite.children.length!==0){for(var i=0;i<sprite.children.length;i++){var child=sprite.children[i];restoreSpriteProperties(child)}}};for(var i=0;i<_this3.stage.children.length;i++){var sprite=_this3.stage.children[i];restoreSpriteProperties(sprite)}})()}}},{key:"fps",get:function get(){return this._fps},set:function set(value){this._fps=value;this._frameDuration=1e3/this._fps}},{key:"renderFps",get:function get(){return this._renderFps},set:function set(value){this._renderFps=value;this._renderDuration=1e3/this._renderFps}},{key:"dt",get:function get(){return this._lagOffset}}]);return Smoothie}();var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var TileUtilities=function(){function TileUtilities(){var renderingEngine=arguments.length<=0||arguments[0]===undefined?PIXI:arguments[0];_classCallCheck(this,TileUtilities);if(renderingEngine===undefined)throw new Error("Please assign a rendering engine in the constructor before using bump.js");this.renderer="";if(renderingEngine.ParticleContainer&&renderingEngine.Sprite){this.renderingEngine=renderingEngine;this.renderer="pixi";this.Container=this.renderingEngine.Container;this.TextureCache=this.renderingEngine.utils.TextureCache;this.Texture=this.renderingEngine.Texture;this.Sprite=this.renderingEngine.Sprite;this.Rectangle=this.renderingEngine.Rectangle;this.Graphics=this.renderingEngine.Graphics;this.loader=this.renderingEngine.loader;this.resources=this.renderingEngine.loader.resources}}_createClass(TileUtilities,[{key:"frame",value:function frame(source,x,y,width,height){var texture=undefined,imageFrame=undefined;if(typeof source==="string"){if(this.TextureCache[source]){texture=new this.Texture(this.TextureCache[source])}}else if(source instanceof this.Texture){texture=new this.Texture(source)}if(!texture){throw new Error("Please load the "+source+" texture into the cache.")}else{imageFrame=new this.Rectangle(x,y,width,height);texture.frame=imageFrame;return texture}}},{key:"getIndex",value:function getIndex(x,y,tilewidth,tileheight,mapWidthInTiles){var index={};index.x=Math.floor(x/tilewidth);index.y=Math.floor(y/tileheight);return index.x+index.y*mapWidthInTiles}},{key:"getTile",value:function getTile(index,mapArray,world){var tile={};tile.gid=mapArray[index];tile.width=world.tilewidth;tile.height=world.tileheight;tile.halfWidth=world.tilewidth/2;tile.halfHeight=world.tileheight/2;tile.x=index%world.widthInTiles*world.tilewidth+world.x;tile.y=Math.floor(index/world.widthInTiles)*world.tileheight+world.y;tile.gx=tile.x;tile.gy=tile.y;tile.centerX=tile.x+world.tilewidth/2;tile.centery=tile.y+world.tileheight/2;return tile}},{key:"surroundingCells",value:function surroundingCells(index,widthInTiles){return[index-widthInTiles-1,index-widthInTiles,index-widthInTiles+1,index-1,index,index+1,index+widthInTiles-1,index+widthInTiles,index+widthInTiles+1]}},{key:"getPoints",value:function getPoints(s){var ca=s.collisionArea;if(ca!==undefined){return{topLeft:{x:s.x+ca.x,y:s.y+ca.y},topRight:{x:s.x+ca.x+ca.width,y:s.y+ca.y},bottomLeft:{x:s.x+ca.x,y:s.y+ca.y+ca.height},bottomRight:{x:s.x+ca.x+ca.width,y:s.y+ca.y+ca.height}}}else{return{topLeft:{x:s.x,y:s.y},topRight:{x:s.x+s.width-1,y:s.y},bottomLeft:{x:s.x,y:s.y+s.height-1},bottomRight:{x:s.x+s.width-1,y:s.y+s.height-1}}}}},{key:"hitTestTile",value:function hitTestTile(sprite,mapArray,gidToCheck,world,pointsToCheck){var _this=this;var checkPoints=function checkPoints(key){var point=sprite.collisionPoints[key];collision.index=_this.getIndex(point.x,point.y,world.tilewidth,world.tileheight,world.widthInTiles);collision.gid=mapArray[collision.index];if(collision.gid===gidToCheck){return true}else{return false}};pointsToCheck=pointsToCheck||"some";var collision={};switch(pointsToCheck){case"center":var point={center:{x:sprite.centerX,y:sprite.centerY}};sprite.collisionPoints=point;collision.hit=Object.keys(sprite.collisionPoints).some(checkPoints);break;case"every":sprite.collisionPoints=this.getPoints(sprite);collision.hit=Object.keys(sprite.collisionPoints).every(checkPoints);break;case"some":sprite.collisionPoints=this.getPoints(sprite);collision.hit=Object.keys(sprite.collisionPoints).some(checkPoints);break}return collision}},{key:"updateMap",value:function updateMap(mapArray,spritesToUpdate,world){var _this2=this;var newMapArray=mapArray.map(function(gid){gid=0;return gid});if(spritesToUpdate instanceof Array){(function(){var self=_this2;spritesToUpdate.forEach(function(sprite){sprite.index=self.getIndex(sprite.centerX,sprite.centerY,world.tilewidth,world.tileheight,world.widthInTiles);newMapArray[sprite.index]=sprite.gid})})()}else{var sprite=spritesToUpdate;sprite.index=this.getIndex(sprite.centerX,sprite.centerY,world.tilewidth,world.tileheight,world.widthInTiles);newMapArray[sprite.index]=sprite.gid}return newMapArray}},{key:"makeTiledWorld",value:function makeTiledWorld(jsonTiledMap,tileset){var _this3=this;var tiledMap=PIXI.loader.resources[jsonTiledMap].data;var world=new this.Container;world.tileheight=tiledMap.tileheight;world.tilewidth=tiledMap.tilewidth;world.worldWidth=tiledMap.width*tiledMap.tilewidth;world.worldHeight=tiledMap.height*tiledMap.tileheight;world.widthInTiles=tiledMap.width;world.heightInTiles=tiledMap.height;world.objects=[];var spacing=tiledMap.tilesets[0].spacing;var numberOfTilesetColumns=Math.floor(tiledMap.tilesets[0].imagewidth/(tiledMap.tilewidth+spacing));tiledMap.layers.forEach(function(tiledLayer){var layerGroup=new _this3.Container;Object.keys(tiledLayer).forEach(function(key){if(key!=="width"&&key!=="height"){layerGroup[key]=tiledLayer[key]}});layerGroup.alpha=tiledLayer.opacity;world.addChild(layerGroup);world.objects.push(layerGroup);if(tiledLayer.type==="tilelayer"){tiledLayer.data.forEach(function(gid,index){var tileSprite=undefined,texture=undefined,mapX=undefined,mapY=undefined,tilesetX=undefined,tilesetY=undefined,mapColumn=undefined,mapRow=undefined,tilesetColumn=undefined,tilesetRow=undefined;if(gid!==0){(function(){mapColumn=index%world.widthInTiles;mapRow=Math.floor(index/world.widthInTiles);mapX=mapColumn*world.tilewidth;mapY=mapRow*world.tileheight;tilesetColumn=(gid-1)%numberOfTilesetColumns;tilesetRow=Math.floor((gid-1)/numberOfTilesetColumns);tilesetX=tilesetColumn*world.tilewidth;tilesetY=tilesetRow*world.tileheight;if(spacing>0){tilesetX+=spacing+spacing*((gid-1)%numberOfTilesetColumns);tilesetY+=spacing+spacing*Math.floor((gid-1)/numberOfTilesetColumns)}texture=_this3.frame(tileset,tilesetX,tilesetY,world.tilewidth,world.tileheight);var tileproperties=tiledMap.tilesets[0].tileproperties,key=String(gid-1);if(tileproperties[key]&&tileproperties[key].name){tileSprite=new _this3.Sprite(texture);Object.keys(tileproperties[key]).forEach(function(property){tileSprite[property]=tileproperties[key][property]});world.objects.push(tileSprite)}else{tileSprite=new _this3.Sprite(texture)}tileSprite.x=mapX;tileSprite.y=mapY;tileSprite.index=index;tileSprite.gid=gid;layerGroup.addChild(tileSprite)})()}})}if(tiledLayer.type==="objectgroup"){tiledLayer.objects.forEach(function(object){object.group=layerGroup;world.objects.push(object)})}});world.getObject=function(objectName){var searchForObject=function searchForObject(){var foundObject=undefined;world.objects.some(function(object){if(object.name&&object.name===objectName){foundObject=object;return true}});if(foundObject){return foundObject}else{throw new Error("There is no object with the property name: "+objectName)}};return searchForObject()};world.getObjects=function(objectNames){var foundObjects=[];world.objects.forEach(function(object){if(object.name&&objectNames.indexOf(object.name)!==-1){foundObjects.push(object)}});if(foundObjects.length>0){return foundObjects}else{throw new Error("I could not find those objects")}return foundObjects};return world}},{key:"byDepth",value:function byDepth(a,b){a.depth=(a.cartX+a.cartY)*(a.z+1);b.depth=(b.cartX+b.cartY)*(b.z+1);if(a.depth<b.depth){return-1}else if(a.depth>b.depth){return 1}else{return 0}}},{key:"hitTestIsoTile",value:function hitTestIsoTile(sprite,mapArray,gidToCheck,world,pointsToCheck){var _this4=this;var checkPoints=function checkPoints(key){var point=sprite.collisionPoints[key];collision.index=_this4.getIndex(point.x,point.y,world.cartTilewidth,world.cartTileheight,world.widthInTiles);collision.gid=mapArray[collision.index];if(collision.gid===gidToCheck){return true}else{return false}};pointsToCheck=pointsToCheck||"some";var collision={};switch(pointsToCheck){case"center":var point={center:{x:s.cartX+ca.x+ca.width/2,y:s.cartY+ca.y+ca.height/2}};sprite.collisionPoints=point;collision.hit=Object.keys(sprite.collisionPoints).some(checkPoints);break;case"every":sprite.collisionPoints=this.getIsoPoints(sprite);collision.hit=Object.keys(sprite.collisionPoints).every(checkPoints);break;case"some":sprite.collisionPoints=this.getIsoPoints(sprite);collision.hit=Object.keys(sprite.collisionPoints).some(checkPoints);break}return collision}},{key:"getIsoPoints",value:function getIsoPoints(s){var ca=s.collisionArea;if(ca!==undefined){return{topLeft:{x:s.cartX+ca.x,y:s.cartY+ca.y},topRight:{x:s.cartX+ca.x+ca.width,y:s.cartY+ca.y},bottomLeft:{x:s.cartX+ca.x,y:s.cartY+ca.y+ca.height},bottomRight:{x:s.cartX+ca.x+ca.width,y:s.cartY+ca.y+ca.height}}}else{return{topLeft:{x:s.cartX,y:s.cartY},topRight:{x:s.cartX+s.cartWidth-1,y:s.cartY},bottomLeft:{x:s.cartX,y:s.cartY+s.cartHeight-1},bottomRight:{x:s.cartX+s.cartWidth-1,y:s.cartY+s.cartHeight-1}}}}},{key:"makeIsoPointer",value:function makeIsoPointer(pointer,world){Object.defineProperties(pointer,{cartX:{get:function get(){var x=(2*this.y+this.x-(2*world.y+world.x))/2-world.cartTilewidth/2;return x},enumerable:true,configurable:true},cartY:{get:function get(){var y=(2*this.y-this.x-(2*world.y-world.x))/2+world.cartTileheight/2;return y},enumerable:true,configurable:true},column:{get:function get(){return Math.floor(this.cartX/world.cartTilewidth)},enumerable:true,configurable:true},row:{get:function get(){return Math.floor(this.cartY/world.cartTileheight)},enumerable:true,configurable:true},index:{get:function get(){var index={};index.x=Math.floor(this.cartX/world.cartTilewidth);index.y=Math.floor(this.cartY/world.cartTileheight);return index.x+index.y*world.widthInTiles},enumerable:true,configurable:true}})}},{key:"isoRectangle",value:function isoRectangle(width,height,fillStyle){var halfHeight=height/2;var rectangle=new this.Graphics;rectangle.beginFill(fillStyle);rectangle.moveTo(0,0);rectangle.lineTo(width,halfHeight);rectangle.lineTo(0,height);rectangle.lineTo(-width,halfHeight);rectangle.lineTo(0,0);rectangle.endFill();var texture=rectangle.generateTexture();var sprite=new this.Sprite(texture);return sprite}},{key:"addIsoProperties",value:function addIsoProperties(sprite,x,y,width,height){sprite.cartX=x;sprite.cartY=y;sprite.cartWidth=width;sprite.cartHeight=height;Object.defineProperties(sprite,{isoX:{get:function get(){return this.cartX-this.cartY},enumerable:true,configurable:true},isoY:{get:function get(){return(this.cartX+this.cartY)/2},enumerable:true,configurable:true}})}},{key:"makeIsoTiledWorld",value:function makeIsoTiledWorld(jsonTiledMap,tileset){var _this5=this;var tiledMap=PIXI.loader.resources[jsonTiledMap].data;if(!tiledMap.properties.cartTilewidth&&!tiledMap.properties.cartTileheight&&!tiledMao.properties.tileDepth){throw new Error("Set custom cartTilewidth, cartTileheight and tileDepth map properties in Tiled Editor")}var world=new this.Container;world.tileheight=parseInt(tiledMap.properties.tileDepth);world.tilewidth=tiledMap.tilewidth;world.cartTileheight=parseInt(tiledMap.properties.cartTileheight);world.cartTilewidth=parseInt(tiledMap.properties.cartTilewidth);world.worldWidth=tiledMap.width*world.cartTilewidth;world.worldHeight=tiledMap.height*world.cartTileheight;world.widthInTiles=tiledMap.width;world.heightInTiles=tiledMap.height;world.objects=[];var spacing=tiledMap.tilesets[0].spacing;var numberOfTilesetColumns=Math.floor(tiledMap.tilesets[0].imagewidth/(tiledMap.tilewidth+spacing));var z=0;tiledMap.layers.forEach(function(tiledLayer){var layerGroup=new _this5.Container;Object.keys(tiledLayer).forEach(function(key){if(key!=="width"&&key!=="height"){layerGroup[key]=tiledLayer[key]}});layerGroup.alpha=tiledLayer.opacity;world.addChild(layerGroup);world.objects.push(layerGroup);if(tiledLayer.type==="tilelayer"){tiledLayer.data.forEach(function(gid,index){var tileSprite=undefined,texture=undefined,mapX=undefined,mapY=undefined,tilesetX=undefined,tilesetY=undefined,mapColumn=undefined,mapRow=undefined,tilesetColumn=undefined,tilesetRow=undefined;if(gid!==0){(function(){mapColumn=index%world.widthInTiles;mapRow=Math.floor(index/world.widthInTiles);mapX=mapColumn*world.cartTilewidth;mapY=mapRow*world.cartTileheight;tilesetColumn=(gid-1)%numberOfTilesetColumns;tilesetRow=Math.floor((gid-1)/numberOfTilesetColumns);tilesetX=tilesetColumn*world.tilewidth;tilesetY=tilesetRow*world.tileheight;if(spacing>0){tilesetX+=spacing+spacing*((gid-1)%numberOfTilesetColumns);tilesetY+=spacing+spacing*Math.floor((gid-1)/numberOfTilesetColumns)}texture=_this5.frame(tileset,tilesetX,tilesetY,world.tilewidth,world.tileheight);var tileproperties=tiledMap.tilesets[0].tileproperties,key=String(gid-1);if(tileproperties[key]&&tileproperties[key].name){tileSprite=new _this5.Sprite(texture);Object.keys(tileproperties[key]).forEach(function(property){tileSprite[property]=tileproperties[key][property]});world.objects.push(tileSprite)}else{tileSprite=new _this5.Sprite(texture)}_this5.addIsoProperties(tileSprite,mapX,mapY,world.cartTilewidth,world.cartTileheight);tileSprite.x=tileSprite.isoX;tileSprite.y=tileSprite.isoY;tileSprite.z=z;tileSprite.index=index;tileSprite.gid=gid;layerGroup.addChild(tileSprite)})()}})}if(tiledLayer.type==="objectgroup"){tiledLayer.objects.forEach(function(object){object.group=layerGroup;world.objects.push(object)})}z+=1});world.getObject=function(objectName){var searchForObject=function searchForObject(){var foundObject=undefined;world.objects.some(function(object){if(object.name&&object.name===objectName){foundObject=object;return true}});if(foundObject){return foundObject}else{throw new Error("There is no object with the property name: "+objectName)}};return searchForObject()};world.getObjects=function(objectNames){var foundObjects=[];world.objects.forEach(function(object){if(object.name&&objectNames.indexOf(object.name)!==-1){foundObjects.push(object)}});if(foundObjects.length>0){return foundObjects}else{throw new Error("I could not find those objects")}return foundObjects};return world}},{key:"shortestPath",value:function shortestPath(startIndex,destinationIndex,mapArray,mapWidthInTiles){var obstacleGids=arguments.length<=4||arguments[4]===undefined?[]:arguments[4];var heuristic=arguments.length<=5||arguments[5]===undefined?"manhattan":arguments[5];var useDiagonalNodes=arguments.length<=6||arguments[6]===undefined?true:arguments[6];var nodes=function nodes(mapArray,mapWidthInTiles){return mapArray.map(function(cell,index){var column=index%mapWidthInTiles;var row=Math.floor(index/mapWidthInTiles);return node={f:0,g:0,h:0,parent:null,column:column,row:row,index:index}})};var theShortestPath=[];var nodeMap=nodes(mapArray,mapWidthInTiles);var closedList=[];var openList=[];var straightCost=10;var diagonalCost=14;var startNode=nodeMap[startIndex];var centerNode=startNode;openList.push(centerNode);var destinationNode=nodeMap[destinationIndex];var surroundingNodes=function surroundingNodes(index,mapArray,mapWidthInTiles,useDiagonalNodes){var allSurroundingNodes=[nodeMap[index-mapWidthInTiles-1],nodeMap[index-mapWidthInTiles],nodeMap[index-mapWidthInTiles+1],nodeMap[index-1],nodeMap[index+1],nodeMap[index+mapWidthInTiles-1],nodeMap[index+mapWidthInTiles],nodeMap[index+mapWidthInTiles+1]];var crossSurroundingNodes=[nodeMap[index-mapWidthInTiles],nodeMap[index-1],nodeMap[index+1],nodeMap[index+mapWidthInTiles]];var nodesToCheck=undefined;if(useDiagonalNodes){nodesToCheck=allSurroundingNodes}else{nodesToCheck=crossSurroundingNodes}var validSurroundingNodes=nodesToCheck.filter(function(node){var nodeIsWithinTopAndBottomBounds=node!==undefined;if(nodeIsWithinTopAndBottomBounds){var indexIsOnLeftBorder=index%mapWidthInTiles===0;var indexIsOnRightBorder=(index+1)%mapWidthInTiles===0;var nodeIsBeyondLeftBorder=node.column%(mapWidthInTiles-1)===0&&node.column!==0;var nodeIsBeyondRightBorder=node.column%mapWidthInTiles===0;var nodeContainsAnObstacle=obstacleGids.some(function(obstacle){return mapArray[node.index]===obstacle});if(indexIsOnLeftBorder){return!nodeIsBeyondLeftBorder}else if(indexIsOnRightBorder){return!nodeIsBeyondRightBorder}else if(nodeContainsAnObstacle){return false}else{return true}}});return validSurroundingNodes};var manhattan=function manhattan(testNode,destinationNode){var h=Math.abs(testNode.row-destinationNode.row)*straightCost+Math.abs(testNode.column-destinationNode.column)*straightCost;return h};var euclidean=function euclidean(testNode,destinationNode){var vx=destinationNode.column-testNode.column,vy=destinationNode.row-testNode.row,h=Math.floor(Math.sqrt(vx*vx+vy*vy)*straightCost);return h};var diagonal=function diagonal(testNode,destinationNode){var vx=Math.abs(destinationNode.column-testNode.column),vy=Math.abs(destinationNode.row-testNode.row),h=0;if(vx>vy){h=Math.floor(diagonalCost*vy+straightCost*(vx-vy))}else{h=Math.floor(diagonalCost*vx+straightCost*(vy-vx))}return h};while(centerNode!==destinationNode){var surroundingTestNodes=surroundingNodes(centerNode.index,mapArray,mapWidthInTiles,useDiagonalNodes);var _loop=function _loop(i){var testNode=surroundingTestNodes[i];var cost=0;if(centerNode.row===testNode.row||centerNode.column===testNode.column){cost=straightCost}else{cost=diagonalCost}var g=centerNode.g+cost;var h=undefined;switch(heuristic){case"manhattan":h=manhattan(testNode,destinationNode);break;case"euclidean":h=euclidean(testNode,destinationNode);break;case"diagonal":h=diagonal(testNode,destinationNode);break;default:throw new Error("Oops! It looks like you misspelled the name of the heuristic")}var f=g+h;var isOnOpenList=openList.some(function(node){return testNode===node});var isOnClosedList=closedList.some(function(node){return testNode===node});if(isOnOpenList||isOnClosedList){if(testNode.f>f){testNode.f=f;testNode.g=g;testNode.h=h;testNode.parent=centerNode}}else{testNode.f=f;testNode.g=g;testNode.h=h;testNode.parent=centerNode;openList.push(testNode)}};for(var i=0;i<surroundingTestNodes.length;i++){_loop(i)}closedList.push(centerNode);if(openList.length===0){return theShortestPath}openList=openList.sort(function(a,b){return a.f-b.f});centerNode=openList.shift()}if(openList.length!==0){var _testNode=destinationNode;theShortestPath.push(_testNode);while(_testNode!==startNode){_testNode=_testNode.parent;theShortestPath.unshift(_testNode)}}return theShortestPath}},{key:"tileBasedLineOfSight",value:function tileBasedLineOfSight(spriteOne,spriteTwo,mapArray,world){var emptyGid=arguments.length<=4||arguments[4]===undefined?0:arguments[4];var _this6=this;var segment=arguments.length<=5||arguments[5]===undefined?32:arguments[5];var angles=arguments.length<=6||arguments[6]===undefined?[]:arguments[6];var vx=spriteTwo.centerX-spriteOne.centerX,vy=spriteTwo.centerY-spriteOne.centerY;var magnitude=Math.sqrt(vx*vx+vy*vy);var numberOfPoints=magnitude/segment;var points=function points(){
  17. var arrayOfPoints=[];for(var i=1;i<=numberOfPoints;i++){var newMagnitude=segment*i;var dx=vx/magnitude,dy=vy/magnitude;var x=spriteOne.centerX+dx*newMagnitude,y=spriteOne.centerY+dy*newMagnitude;var getIndex=function getIndex(x,y,tilewidth,tileheight,mapWidthInTiles){var index={};index.x=Math.floor(x/tilewidth);index.y=Math.floor(y/tileheight);return index.x+index.y*mapWidthInTiles};var index=_this6.getIndex(x,y,world.tilewidth,world.tileheight,world.widthInTiles);arrayOfPoints.push({x:x,y:y,index:index})}return arrayOfPoints};var noObstacles=points().every(function(point){return mapArray[point.index]===emptyGid});var validAngle=function validAngle(){var angle=Math.atan2(vy,vx)*180/Math.PI;if(angles.length!==0){return angles.some(function(x){return x===angle})}else{return true}};if(noObstacles===true&&validAngle()===true){return true}else{return false}}},{key:"surroundingCrossCells",value:function surroundingCrossCells(index,widthInTiles){return[index-widthInTiles,index-1,index+1,index+widthInTiles]}},{key:"surroundingDiagonalCells",value:function surroundingDiagonalCells(index,widthInTiles){return[index-widthInTiles-1,index-widthInTiles+1,index+widthInTiles-1,index+widthInTiles+1]}},{key:"validDirections",value:function validDirections(sprite,mapArray,validGid,world){var index=g.getIndex(sprite.x,sprite.y,world.tilewidth,world.tileheight,world.widthInTiles);var surroundingCrossCells=function surroundingCrossCells(index,widthInTiles){return[index-widthInTiles,index-1,index+1,index+widthInTiles]};var surroundingIndexNumbers=surroundingCrossCells(index,world.widthInTiles);var surroundingTileGids=surroundingIndexNumbers.map(function(index){return mapArray[index]});var directionList=surroundingTileGids.map(function(gid,i){var possibleDirections=["up","left","right","down"];if(gid===validGid){return possibleDirections[i]}else{return"none"}});var filteredDirectionList=directionList.filter(function(direction){return direction!="none"});return filteredDirectionList}},{key:"canChangeDirection",value:function canChangeDirection(){var validDirections=arguments.length<=0||arguments[0]===undefined?[]:arguments[0];var inCulDeSac=validDirections.length===1;var trapped=validDirections.length===0;var up=validDirections.find(function(x){return x==="up"}),down=validDirections.find(function(x){return x==="down"}),left=validDirections.find(function(x){return x==="left"}),right=validDirections.find(function(x){return x==="right"}),atIntersection=(up||down)&&(left||right);return trapped||atIntersection||inCulDeSac}},{key:"randomDirection",value:function randomDirection(sprite){var validDirections=arguments.length<=1||arguments[1]===undefined?[]:arguments[1];var randomInt=function randomInt(min,max){return Math.floor(Math.random()*(max-min+1))+min};var trapped=validDirections.length===0;if(!trapped){return validDirections[randomInt(0,validDirections.length-1)]}else{return"trapped"}}},{key:"closestDirection",value:function closestDirection(spriteOne,spriteTwo){var validDirections=arguments.length<=2||arguments[2]===undefined?[]:arguments[2];var closest=function closest(){var vx=spriteTwo.centerX-spriteOne.centerX,vy=spriteTwo.centerY-spriteOne.centerY;if(Math.abs(vx)>=Math.abs(vy)){if(vx<=0){return"left"}else{return"right"}}else{if(vy<=0){return"up"}else{return"down"}}}}}]);return TileUtilities}();var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function hexi(width,height,setup){var thingsToLoad=arguments.length<=3||arguments[3]===undefined?undefined:arguments[3];var load=arguments.length<=4||arguments[4]===undefined?undefined:arguments[4];var hexi=new Hexi({width:width,height:height,setup:setup,assets:thingsToLoad,load:load,interpolationProperties:{position:true,rotation:true,size:true,alpha:true},interpolate:true});return hexi}var Hexi=function(){function Hexi(o){_classCallCheck(this,Hexi);this.charm=new Charm(PIXI);this.dust=new Dust(PIXI);this.bump=new Bump(PIXI);this.spriteUtilities=new SpriteUtilities(PIXI);this.tileUtilities=new TileUtilities(PIXI);this.gameUtilities=new GameUtilities;this.modulesToUpdate=[];this.modulesToUpdate.push(this.charm);this.modulesToUpdate.push(this.dust);this.modulesToUpdate.push(this.spriteUtilities);if(o.renderer==="auto"||o.renderer===undefined){this.renderer=PIXI.autoDetectRenderer(o.width,o.height,o,o.noWebGL)}else if(o.renderer==="canvas"){this.renderer=new PIXI.CanvasRenderer(o.width,o.height,o)}else if(o.renderer==="webgl"){this.renderer=new PIXI.WebGLRenderer(o.width,o.height,o)}this.canvas=this.renderer.view;this.tink=new Tink(PIXI,this.canvas);this.modulesToUpdate.push(this.tink);this.createModulePropertyAliases();Object.defineProperties.bind(this,this.canvas,{halfWidth:{get:function get(){return this.canvas.width/2},enumerable:true,configurable:true},halfHeight:{get:function get(){return this.canvas.height/2},enumerable:true,configurable:true}});this.canvas.scaled=false;if(o.backgroundColor){this.renderer.backgroundColor=this.color(o.backgroundColor)}else{this.renderer.backgroundColor=16777215}if(o.border)this.canvas.style.border=o.border;document.body.appendChild(this.canvas);this.stage=new this.Container;this.addProperties(this.stage);this.stage._stage=true;if(o.scaleToWindow){this.scaleToWindow(o.scaleBorderColor)}else{this.scale=1}this.pointer=this.makePointer(this.canvas,this.scale);this.state=undefined;if(o.load!==undefined)this.loadState=o.load;if(!o.setup){throw new Error("Please supply the setup option in the constructor to tell Hexi which function should run first when it starts.")}else{this.setupState=o.setup}this.loadingProgress=0;this.loadingFile="";if(o.assets!==undefined){this.assetsToLoad=o.assets}this._progressBarAdded=false;this.soundObjects={};this.smoothie=new Smoothie({engine:PIXI,renderer:this.renderer,root:this.stage,update:this.update.bind(this),properties:o.interpolationProperties,interpolate:o.interpolate,fps:o.fps,renderFps:o.renderFps,properties:{position:true,scale:true,tile:true}})}_createClass(Hexi,[{key:"start",value:function start(){if(this.assetsToLoad){this.load(this.assetsToLoad,this.validateAssets);if(this.loadState)this.state=this.loadState}else{this.setupState()}this.smoothie.start()}},{key:"load",value:function load(assetsToLoad){var _this=this;var callbackFunction=arguments.length<=1||arguments[1]===undefined?undefined:arguments[1];var findAssets=function findAssets(fileExtensionArray){var fileSourcePaths=assetsToLoad.filter(function(source){var extension=source.split(".").pop();if(fileExtensionArray.indexOf(extension)!==-1){return true}});return fileSourcePaths};var fontExtensions=["ttf","otf","ttc","woff"];var fontFiles=findAssets(fontExtensions);if(fontFiles.length>0){this.spanElements=[];fontFiles.forEach(function(source){var fontFamily=source.split("/").pop().split(".")[0];if(_this.fontFamilies)_this.fontFamilies.push(fontFamily);var newStyle=document.createElement("style");var fontFace="@font-face {font-family: '"+fontFamily+"'; src: url('"+source+"');}";newStyle.appendChild(document.createTextNode(fontFace));document.head.appendChild(newStyle);var span=document.createElement("span");span.style.fontFamily=fontFamily;document.body.appendChild(span);span.innerHTML="?";span.style.display="block";span.style.opacity="0";_this.spanElements.push(span)})}var Resource=PIXI.loaders.Resource;Resource.setExtensionLoadType("wav",Resource.LOAD_TYPE.XHR);Resource.setExtensionLoadType("mp3",Resource.LOAD_TYPE.XHR);Resource.setExtensionLoadType("ogg",Resource.LOAD_TYPE.XHR);Resource.setExtensionLoadType("webm",Resource.LOAD_TYPE.XHR);Resource.setExtensionXhrType("wav",Resource.XHR_RESPONSE_TYPE.BUFFER);Resource.setExtensionXhrType("mp3",Resource.XHR_RESPONSE_TYPE.BUFFER);Resource.setExtensionXhrType("ogg",Resource.XHR_RESPONSE_TYPE.BUFFER);Resource.setExtensionXhrType("webm",Resource.XHR_RESPONSE_TYPE.BUFFER);var loadProgressHandler=function loadProgressHandler(loader,resource){_this.loadingFile=resource.url;_this.loadingProgress=loader.progress};this.loader.reset();this.loadingProgress=0;this.loadingFile="";this.loader.add(assetsToLoad).on("progress",loadProgressHandler).load(callbackFunction.bind(this))}},{key:"validateAssets",value:function validateAssets(){var _this2=this;console.log("All assets loaded");var finishLoadingState=function finishLoadingState(){_this2.assetsToLoad=[];_this2.loadState=undefined;_this2.state=undefined;if(_this2._progressBarAdded){_this2.progressBar.remove()}if(_this2.spanElements){_this2.spanElements.forEach(function(element){element.style.display="none"})}_this2.setupState()};var soundsToDecode=0,soundsDecoded=0;var soundExtensions=["wav","mp3","ogg","webm"];var decodeHandler=function decodeHandler(){soundsDecoded+=1;if(soundsToDecode===soundsDecoded){finishLoadingState()}};Object.keys(this.loader.resources).forEach(function(resource){var extension=resource.split(".").pop();if(soundExtensions.indexOf(extension)!==-1){soundsToDecode+=1;var xhr=_this2.loader.resources[resource].xhr,url=_this2.loader.resources[resource].url;var soundSprite=makeSound(url,decodeHandler.bind(_this2),false,xhr);soundSprite.name=_this2.loader.resources[resource].name;_this2.soundObjects[soundSprite.name]=soundSprite}});if(soundsToDecode===0){finishLoadingState()}}},{key:"update",value:function update(){this.modulesToUpdate.forEach(function(module){return module.update()});if(this.state&&!this.paused){this.state()}}},{key:"pause",value:function pause(){this.paused=true}},{key:"resume",value:function resume(){this.paused=false}},{key:"createModulePropertyAliases",value:function createModulePropertyAliases(){var _this3=this;this.Container=PIXI.Container;this.loader=PIXI.loader;this.TextureCache=PIXI.utils.TextureCache;this.filters=PIXI.filters;this.dropShadowFilter=function(){return new _this3.filters.DropShadowFilter};this.asciiFilter=function(){return new _this3.filters.AsciiFilter};this.alphaMaskFilter=function(){return new _this3.filters.AlphaMaskFilter};this.bloomFilter=function(){return new _this3.filters.BloomFilter};this.blurDirFilter=function(){return new _this3.filters.BlurDirFilter};this.blurFilter=function(){return new _this3.filters.BlurFilter};this.colorMatrixFilter=function(){return new _this3.filters.ColorMatrixFilter};this.colorStepFilter=function(){return new _this3.filters.ColorStepFilter};this.crossHatchFilter=function(){return new _this3.filters.CrossHatchFilter};this.displacementFilter=function(){return new _this3.filters.DisplacementFilter};this.dotScreenFilter=function(){return new _this3.filters.DotScreenFilter};this.grayFilter=function(){return new _this3.filters.GrayFilter};this.invertFilter=function(){return new _this3.filters.InvertFilter};this.pixelateFilter=function(){return new _this3.filters.PixelateFilter};this.sepiaFilter=function(){return new _this3.filters.SepiaFilter};this.shockwaveFilter=function(){return new _this3.filters.ShockwaveFilter};this.twistFilter=function(){return new _this3.filters.TwistFilter};this.rgbSplitFilter=function(){return new _this3.filters.RGBSplitFilter};this.smartBlurFilter=function(){return new _this3.filters.SmartBlurFilter};this.tiltShiftFilter=function(){return new _this3.filters.TiltShiftFilter};this.draggableSprites=this.tink.draggableSprites;this.pointers=this.tink.pointers;this.buttons=this.tink.buttons;this.makePointer=function(canvas,scale){return _this3.tink.makePointer(canvas,scale)};this.makeDraggable=function(){var _tink;return(_tink=_this3.tink).makeDraggable.apply(_tink,arguments)};this.makeUndraggable=function(){var _tink2;return(_tink2=_this3.tink).makeUndraggable.apply(_tink2,arguments)};this.makeInteractive=function(o){return _this3.tink.makeInteractive(o)};this.keyboard=this.tink.keyboard;this.arrowControl=function(sprite,speed){return _this3.tink.arrowControl(sprite,speed)};this.createParticles=function(x,y,spriteFunction,container,numberOfParticles,gravity,randomSpacing,minAngle,maxAngle,minSize,maxSize,minSpeed,maxSpeed,minScaleSpeed,maxScaleSpeed,minAlphaSpeed,maxAlphaSpeed,minRotationSpeed,maxRotationSpeed){return _this3.dust.create(x,y,spriteFunction,container,numberOfParticles,gravity,randomSpacing,minAngle,maxAngle,minSize,maxSize,minSpeed,maxSpeed,minScaleSpeed,maxScaleSpeed,minAlphaSpeed,maxAlphaSpeed,minRotationSpeed,maxRotationSpeed)};this.particleEmitter=function(interval,particleFunction){return _this3.dust.emitter(interval,particleFunction)};this.filmstrip=function(texture,frameWidth,frameHeight,spacing){return _this3.spriteUtilities.filmstrip(texture,frameWidth,frameHeight,spacing)};this.frame=function(source,x,y,width,height){return _this3.spriteUtilities.frame(source,x,y,width,height)};this.frames=function(source,coordinates,frameWidth,frameHeight){return _this3.spriteUtilities.frames(source,coordinates,frameWidth,frameHeight)};this.frameSeries=function(startNumber,endNumber,baseName,extension){return _this3.spriteUtilities.frames(startNumber,endNumber,baseName,extension)};this.colorToRGBA=function(value){return _this3.spriteUtilities.colorToRGBA(value)};this.colorToHex=function(value){return _this3.spriteUtilities.colorToHex(value)};this.byteToHex=function(value){return _this3.spriteUtilities.byteToHex(value)};this.color=function(value){return _this3.spriteUtilities.color(value)};this.shoot=function(shooter,angle,x,y,container,bulletSpeed,bulletArray,bulletSprite){return _this3.spriteUtilities.shoot(shooter,angle,x,y,container,bulletSpeed,bulletArray,bulletSprite)};this.shake=function(sprite){var magnitude=arguments.length<=1||arguments[1]===undefined?16:arguments[1];var angular=arguments.length<=2||arguments[2]===undefined?false:arguments[2];console.log("shake");return _this3.spriteUtilities.shake(sprite,magnitude,angular)};this.fadeOut=function(sprite){var frames=arguments.length<=1||arguments[1]===undefined?60:arguments[1];return _this3.charm.fadeOut(sprite,frames)};this.fadeIn=function(sprite){var frames=arguments.length<=1||arguments[1]===undefined?60:arguments[1];return _this3.charm.fadeIn(sprite,frames)};this.pulse=function(sprite){var frames=arguments.length<=1||arguments[1]===undefined?60:arguments[1];var minAlpha=arguments.length<=2||arguments[2]===undefined?0:arguments[2];return _this3.charm.pulse(sprite,frames,minAlpha)};this.slide=function(sprite,endX,endY){var frames=arguments.length<=3||arguments[3]===undefined?60:arguments[3];var type=arguments.length<=4||arguments[4]===undefined?"smoothstep":arguments[4];var yoyo=arguments.length<=5||arguments[5]===undefined?false:arguments[5];var delayBeforeRepeat=arguments.length<=6||arguments[6]===undefined?0:arguments[6];return _this3.charm.slide(sprite,endX,endY,frames,type,yoyo,delayBeforeRepeat=0)};this.breathe=function(sprite){var endScaleX=arguments.length<=1||arguments[1]===undefined?.8:arguments[1];var endScaleY=arguments.length<=2||arguments[2]===undefined?.8:arguments[2];var frames=arguments.length<=3||arguments[3]===undefined?60:arguments[3];var yoyo=arguments.length<=4||arguments[4]===undefined?true:arguments[4];var delayBeforeRepeat=arguments.length<=5||arguments[5]===undefined?0:arguments[5];return _this3.charm.breathe(sprite,endScaleX,endScaleY,frames,yoyo,delayBeforeRepeat)};this.scale=function(sprite){var endScaleX=arguments.length<=1||arguments[1]===undefined?.5:arguments[1];var endScaleY=arguments.length<=2||arguments[2]===undefined?.5:arguments[2];var frames=arguments.length<=3||arguments[3]===undefined?60:arguments[3];return _this3.charm.scale(sprite,endScaleX,endScaleY,frames)};this.strobe=function(sprite){var scaleFactor=arguments.length<=1||arguments[1]===undefined?1.3:arguments[1];var startMagnitude=arguments.length<=2||arguments[2]===undefined?10:arguments[2];var endMagnitude=arguments.length<=3||arguments[3]===undefined?20:arguments[3];var frames=arguments.length<=4||arguments[4]===undefined?10:arguments[4];var yoyo=arguments.length<=5||arguments[5]===undefined?true:arguments[5];var delayBeforeRepeat=arguments.length<=6||arguments[6]===undefined?0:arguments[6];return _this3.charm.strobe(sprite,scaleFactor,startMagnitude,endMagnitude,frames,yoyo,delayBeforeRepeat)};this.wobble=function(sprite){var scaleFactorX=arguments.length<=1||arguments[1]===undefined?1.2:arguments[1];var scaleFactorY=arguments.length<=2||arguments[2]===undefined?1.2:arguments[2];var frames=arguments.length<=3||arguments[3]===undefined?10:arguments[3];var xStartMagnitude=arguments.length<=4||arguments[4]===undefined?10:arguments[4];var xEndMagnitude=arguments.length<=5||arguments[5]===undefined?10:arguments[5];var yStartMagnitude=arguments.length<=6||arguments[6]===undefined?-10:arguments[6];var yEndMagnitude=arguments.length<=7||arguments[7]===undefined?-10:arguments[7];var friction=arguments.length<=8||arguments[8]===undefined?.98:arguments[8];var yoyo=arguments.length<=9||arguments[9]===undefined?true:arguments[9];var delayBeforeRepeat=arguments.length<=10||arguments[10]===undefined?0:arguments[10];return _this3.charm.wobble(sprite,scaleFactorX=1.2,scaleFactorY=1.2,frames=10,xStartMagnitude=10,xEndMagnitude=10,yStartMagnitude=-10,yEndMagnitude=-10,friction=.98,yoyo=true,delayBeforeRepeat=0)};this.followCurve=function(sprite,pointsArray,totalFrames){var type=arguments.length<=3||arguments[3]===undefined?"smoothstep":arguments[3];var yoyo=arguments.length<=4||arguments[4]===undefined?false:arguments[4];var delayBeforeRepeat=arguments.length<=5||arguments[5]===undefined?0:arguments[5];return _this3.charm.followCurve(sprite,pointsArray,totalFrames,type,yoyo,delayBeforeRepeat)};this.walkPath=function(sprite,originalPathArray){var totalFrames=arguments.length<=2||arguments[2]===undefined?300:arguments[2];var type=arguments.length<=3||arguments[3]===undefined?"smoothstep":arguments[3];var loop=arguments.length<=4||arguments[4]===undefined?false:arguments[4];var yoyo=arguments.length<=5||arguments[5]===undefined?false:arguments[5];var delayBetweenSections=arguments.length<=6||arguments[6]===undefined?0:arguments[6];return _this3.charm.walkPath(sprite,originalPathArray,totalFrames,type,loop,yoyo,delayBetweenSections)};this.walkCurve=function(sprite,pathArray){var totalFrames=arguments.length<=2||arguments[2]===undefined?300:arguments[2];var type=arguments.length<=3||arguments[3]===undefined?"smoothstep":arguments[3];var loop=arguments.length<=4||arguments[4]===undefined?false:arguments[4];var yoyo=arguments.length<=5||arguments[5]===undefined?false:arguments[5];var delayBeforeContinue=arguments.length<=6||arguments[6]===undefined?0:arguments[6];return _this3.charm.walkCurve(sprite,pathArray,totalFrames,type,loop,yoyo,delayBeforeContinue)};this.removeTween=function(tweenObject){return _this3.charm.removeTween(tweenObject)};this.makeTween=function(tweensToAdd){return _this3.charm.makeTween(tweensToAdd)};this.tweenProperty=function(sprite,property,startValue,endValue,totalFrames){var type=arguments.length<=5||arguments[5]===undefined?"smoothstep":arguments[5];var yoyo=arguments.length<=6||arguments[6]===undefined?false:arguments[6];var delayBeforeRepeat=arguments.length<=7||arguments[7]===undefined?0:arguments[7];return _this3.charm.tweenProperty(sprite,property,startValue,endValue,totalFrames,type,yoyo,delayBeforeRepeat)};this.hitTestPoint=function(point,sprite){return _this3.bump.hitTestPoint(point,sprite)};this.hitTestCircle=function(c1,c2){var global=arguments.length<=2||arguments[2]===undefined?false:arguments[2];return _this3.bump.hitTestCircle(c1,c2,global)};this.circleCollision=function(c1,c2){var bounce=arguments.length<=2||arguments[2]===undefined?false:arguments[2];var global=arguments.length<=3||arguments[3]===undefined?false:arguments[3];return _this3.bump.circleCollision(c1,c2,bounce,global)};this.movingCircleCollision=function(c1,c2){var global=arguments.length<=2||arguments[2]===undefined?false:arguments[2];return _this3.bump.movingCircleCollision(c1,c2,global)};this.multipleCircleCollision=function(arrayOfCircles){var global=arguments.length<=1||arguments[1]===undefined?false:arguments[1];return _this3.bump.multipleCircleCollision(arrayOfCircles,global)};this.rectangleCollision=function(r1,r2){var bounce=arguments.length<=2||arguments[2]===undefined?false:arguments[2];var global=arguments.length<=3||arguments[3]===undefined?true:arguments[3];return _this3.bump.rectangleCollision(r1,r2,bounce,global)};this.hitTestRectangle=function(r1,r2){var global=arguments.length<=2||arguments[2]===undefined?false:arguments[2];return _this3.bump.hitTestRectangle(r1,r2,global)};this.hitTestCircleRectangle=function(c1,r1){var global=arguments.length<=2||arguments[2]===undefined?false:arguments[2];return _this3.bump.hitTestCircleRectangle(c1,r1,global)};this.hitTestCirclePoint=function(c1,point){var global=arguments.length<=2||arguments[2]===undefined?false:arguments[2];return _this3.bump.hitTestCirclePoint(c1,point,global)};this.circleRectangleCollision=function(c1,r1){var bounce=arguments.length<=2||arguments[2]===undefined?false:arguments[2];var global=arguments.length<=3||arguments[3]===undefined?false:arguments[3];return _this3.bump.circleRectangleCollision(c1,r1,bounce,global)};this.circlePointCollision=function(c1,point){var bounce=arguments.length<=2||arguments[2]===undefined?false:arguments[2];var global=arguments.length<=3||arguments[3]===undefined?false:arguments[3];return _this3.bump.circlePointCollision(c1,point,bounce,global)};this.bounceOffSurface=function(o,s){return _this3.bump.bounceOffSurface(o,s)};this.hit=function(a,b){var react=arguments.length<=2||arguments[2]===undefined?false:arguments[2];var bounce=arguments.length<=3||arguments[3]===undefined?false:arguments[3];var global=arguments[4];var extra=arguments.length<=5||arguments[5]===undefined?undefined:arguments[5];return _this3.bump.hit(a,b,react,bounce,global,extra)};this.shortestPath=function(startIndex,destinationIndex,mapArray,mapWidthInTiles){var obstacleGids=arguments.length<=4||arguments[4]===undefined?[]:arguments[4];var heuristic=arguments.length<=5||arguments[5]===undefined?"manhattan":arguments[5];var useDiagonalNodes=arguments.length<=6||arguments[6]===undefined?true:arguments[6];return _this3.tileUtilities.shortestPath(startIndex,destinationIndex,mapArray,mapWidthInTiles,obstacleGids,heuristic,useDiagonalNodes)};this.tileBasedLineOfSight=function(spriteOne,spriteTwo,mapArray,world){var emptyGid=arguments.length<=4||arguments[4]===undefined?0:arguments[4];var segment=arguments.length<=5||arguments[5]===undefined?32:arguments[5];var angles=arguments.length<=6||arguments[6]===undefined?[]:arguments[6];return _this3.tileUtilities.tileBasedLineOfSight(spriteOne,spriteTwo,mapArray,world,emptyGid,segment,angles)};this.contain=function(sprite,container){var bounce=arguments.length<=2||arguments[2]===undefined?false:arguments[2];var extra=arguments.length<=3||arguments[3]===undefined?undefined:arguments[3];var o={};if(container._stage){o=_this3.compensateForStageSize(container)}else{o=container}return _this3.bump.contain(sprite,o,bounce,extra)};this.outsideBounds=function(sprite,container){var extra=arguments.length<=2||arguments[2]===undefined?undefined:arguments[2];var o={};if(container._stage){o=_this3.compensateForStageSize(container)}else{o=container}return _this3.bump.outsideBounds(sprite,o,extra)};this.distance=function(s1,s2){return _this3.gameUtilities.distance(s1,s2)};this.followEase=function(follower,leader,speed){return _this3.gameUtilities.followEase(follower,leader,speed)};this.followConstant=function(follower,leader,speed){return _this3.gameUtilities.followConstant(follower,leader,speed)};this.angle=function(s1,s2){return _this3.gameUtilities.angle(s1,s2)};this.rotateAroundSprite=function(rotatingSprite,centerSprite,distance,angle){return _this3.gameUtilities.rotateAroundSprite(rotatingSprite,centerSprite,distance,angle)};this.rotateAroundPoint=this.gameUtilities.rotateAroundPoint;this.randomInt=this.gameUtilities.randomInt;this.randomFloat=this.gameUtilities.randomFloat;this.move=this.gameUtilities.move;this.wait=this.gameUtilities.wait;this.worldCamera=function(world,worldWidth,worldHeight){var canvas=arguments.length<=3||arguments[3]===undefined?_this3.canvas:arguments[3];return _this3.gameUtilities.worldCamera(world,worldWidth,worldHeight,canvas)};this.lineOfSight=function(spriteOne,spriteTwo,obstacles){var segment=arguments.length<=3||arguments[3]===undefined?32:arguments[3];return _this3.gameUtilities.lineOfSight(spriteOne,spriteTwo,obstacles,segment)};this.soundEffect=function(frequencyValue,attack,decay,type,volumeValue,panValue,wait,pitchBendAmount,reverse,randomValue,dissonance,echo,reverb){return soundEffect(frequencyValue,attack,decay,type,volumeValue,panValue,wait,pitchBendAmount,reverse,randomValue,dissonance,echo,reverb)};this.hitTestTile=function(sprite,mapArray,gidToCheck,world,pointsToCheck){return _this3.tileUtilities.hitTestTile(sprite,mapArray,gidToCheck,world,pointsToCheck)};this.getIndex=function(x,y,tilewidth,tileheight,mapWidthInTiles){return _this3.tileUtilities.getIndex(x,y,tilewidth,tileheight,mapWidthInTiles)};this.getTile=this.tileUtilities.getTile;this.surroundingCells=this.tileUtilities.surroundingCells;this.getPoints=this.tileUtilities.getPoints;this.updateMap=function(mapArray,spritesToUpdate,world){return _this3.tileUtilities.updateMap(mapArray,spritesToUpdate,world)};this.byDepth=this.tileUtilities.byDepth;this.hitTestIsoTile=function(sprite,mapArray,gidToCheck,world,pointsToCheck){return _this3.tileUtilities.hitTestIsoTile(sprite,mapArray,gidToCheck,world,pointsToCheck)};this.getIsoPoints=this.tileUtilities.getIsoPoints;this.makeIsoPointer=function(pointer,world){return _this3.tileUtilities.makeIsoPointer(pointer,world)};this.isoRectangle=function(width,height,fillStyle){return _this3.tileUtilities.isoRectangle(width,height,fillStyle)};this.addIsoProperties=function(sprite,x,y,width,height){return _this3.tileUtilities.addIsoProperties(sprite,x,y,width,height)};this.makeIsoTiledWorld=function(jsonTiledMap,tileset){return _this3.tileUtilities.makeIsoTiledWorld(jsonTiledMap,tileset)}}},{key:"sprite",value:function sprite(source){var x=arguments.length<=1||arguments[1]===undefined?0:arguments[1];var y=arguments.length<=2||arguments[2]===undefined?0:arguments[2];var tiling=arguments.length<=3||arguments[3]===undefined?false:arguments[3];var width=arguments[4];var height=arguments[5];var o=this.spriteUtilities.sprite(source,x,y,tiling,width,height);this.addProperties(o);this.stage.addChild(o);return o}},{key:"tilingSprite",value:function tilingSprite(source,width,height){var x=arguments.length<=3||arguments[3]===undefined?0:arguments[3];var y=arguments.length<=4||arguments[4]===undefined?0:arguments[4];var o=this.spriteUtilities.tilingSprite(source,width,height,x,y);this.addProperties(o);this.stage.addChild(o);return o}},{key:"text",value:function text(){var content=arguments.length<=0||arguments[0]===undefined?"message":arguments[0];var font=arguments.length<=1||arguments[1]===undefined?"16px sans":arguments[1];var fillStyle=arguments.length<=2||arguments[2]===undefined?"red":arguments[2];var x=arguments.length<=3||arguments[3]===undefined?0:arguments[3];var y=arguments.length<=4||arguments[4]===undefined?0:arguments[4];var message=this.spriteUtilities.text(content,font,fillStyle,x,y);this.addProperties(message);this.stage.addChild(message);return message}},{key:"bitmapText",value:function bitmapText(){var content=arguments.length<=0||arguments[0]===undefined?"message":arguments[0];var font=arguments[1];var align=arguments[2];var tint=arguments[3];var x=arguments.length<=4||arguments[4]===undefined?0:arguments[4];var y=arguments.length<=5||arguments[5]===undefined?0:arguments[5];var message=this.spriteUtilities.bitmapText(content,font,align,tint,x,y);this.addProperties(message);this.stage.addChild(message);return message}},{key:"rectangle",value:function rectangle(){var width=arguments.length<=0||arguments[0]===undefined?32:arguments[0];var height=arguments.length<=1||arguments[1]===undefined?32:arguments[1];var fillStyle=arguments.length<=2||arguments[2]===undefined?16724736:arguments[2];var strokeStyle=arguments.length<=3||arguments[3]===undefined?13260:arguments[3];var lineWidth=arguments.length<=4||arguments[4]===undefined?0:arguments[4];var x=arguments.length<=5||arguments[5]===undefined?0:arguments[5];var y=arguments.length<=6||arguments[6]===undefined?0:arguments[6];var o=this.spriteUtilities.rectangle(width,height,fillStyle,strokeStyle,lineWidth,x,y);this.addProperties(o);this.stage.addChild(o);return o}},{key:"circle",value:function circle(){var diameter=arguments.length<=0||arguments[0]===undefined?32:arguments[0];var fillStyle=arguments.length<=1||arguments[1]===undefined?16724736:arguments[1];var strokeStyle=arguments.length<=2||arguments[2]===undefined?13260:arguments[2];var lineWidth=arguments.length<=3||arguments[3]===undefined?0:arguments[3];var x=arguments.length<=4||arguments[4]===undefined?0:arguments[4];var y=arguments.length<=5||arguments[5]===undefined?0:arguments[5];var o=this.spriteUtilities.circle(diameter,fillStyle,strokeStyle,lineWidth,x,y);this.addProperties(o);o.circular=true;this.stage.addChild(o);return o}},{key:"line",value:function line(){var strokeStyle=arguments.length<=0||arguments[0]===undefined?0:arguments[0];var lineWidth=arguments.length<=1||arguments[1]===undefined?1:arguments[1];var ax=arguments.length<=2||arguments[2]===undefined?0:arguments[2];var ay=arguments.length<=3||arguments[3]===undefined?0:arguments[3];var bx=arguments.length<=4||arguments[4]===undefined?32:arguments[4];var by=arguments.length<=5||arguments[5]===undefined?32:arguments[5];var o=this.spriteUtilities.line(strokeStyle,lineWidth,ax,ay,bx,by);this.addProperties(o);this.stage.addChild(o);return o}},{key:"button",value:function button(source,x,y){var o=this.tink.button(source,x,y);this.addProperties(o);this.stage.addChild(o);return o}},{key:"group",value:function group(){var _spriteUtilities;var o=(_spriteUtilities=this.spriteUtilities).group.apply(_spriteUtilities,arguments);this.addProperties(o);this.stage.addChild(o);return o}},{key:"batch",value:function batch(size,options){var o=this.spriteUtilities.batch(size,options);this.addProperties(o);this.stage.addChild(o);return o}},{key:"grid",value:function grid(){var columns=arguments.length<=0||arguments[0]===undefined?0:arguments[0];var rows=arguments.length<=1||arguments[1]===undefined?0:arguments[1];var cellWidth=arguments.length<=2||arguments[2]===undefined?32:arguments[2];var cellHeight=arguments.length<=3||arguments[3]===undefined?32:arguments[3];var centerCell=arguments.length<=4||arguments[4]===undefined?false:arguments[4];var xOffset=arguments.length<=5||arguments[5]===undefined?0:arguments[5];var yOffset=arguments.length<=6||arguments[6]===undefined?0:arguments[6];var makeSprite=arguments.length<=7||arguments[7]===undefined?undefined:arguments[7];var extra=arguments.length<=8||arguments[8]===undefined?undefined:arguments[8];var o=this.spriteUtilities.grid(columns,rows,cellWidth,cellHeight,centerCell,xOffset,yOffset,makeSprite,extra);this.addProperties(o);this.stage.addChild(o);return o}},{key:"makeTiledWorld",value:function makeTiledWorld(jsonTiledMap,tileset){var _this4=this;var o=this.tileUtilities.makeTiledWorld(jsonTiledMap,tileset);this.addProperties(o);var addHexiSpriteProperties=function addHexiSpriteProperties(object){_this4.addProperties(object);if(object.children){if(object.children.length>0){object.children.forEach(function(child){addHexiSpriteProperties(child)})}}};if(o.children){if(o.children.length>0){
  18. o.children.forEach(function(child){addHexiSpriteProperties(child)})}}this.stage.addChild(o);return o}},{key:"remove",value:function remove(){var _spriteUtilities2;(_spriteUtilities2=this.spriteUtilities).remove.apply(_spriteUtilities2,arguments)}},{key:"flowRight",value:function flowRight(padding){var flowSprites=function flowSprites(spritesToFlow){if(spritesToFlow.length>0){for(var i=0;i<spritesToFlow.length-1;i++){var sprite=spritesToFlow[i];sprite.putRight(spritesToFlow[i+1],+padding)}}};for(var _len=arguments.length,sprites=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){sprites[_key-1]=arguments[_key]}if(!(sprites[0]instanceof Array)){flowSprites(sprites)}else{var spritesArray=sprites[0];flowSprites(spritesArray)}}},{key:"flowDown",value:function flowDown(padding){var flowSprites=function flowSprites(spritesToFlow){if(spritesToFlow.length>0){for(var i=0;i<spritesToFlow.length-1;i++){var sprite=spritesToFlow[i];sprite.putBottom(spritesToFlow[i+1],0,+padding)}}};for(var _len2=arguments.length,sprites=Array(_len2>1?_len2-1:0),_key2=1;_key2<_len2;_key2++){sprites[_key2-1]=arguments[_key2]}if(!(sprites[0]instanceof Array)){flowSprites(sprites)}else{var spritesArray=sprites[0];flowSprites(spritesArray)}}},{key:"flowLeft",value:function flowLeft(padding){var flowSprites=function flowSprites(spritesToFlow){if(spritesToFlow.length>0){for(var i=0;i<spritesToFlow.length-1;i++){var sprite=spritesToFlow[i];sprite.putLeft(spritesToFlow[i+1],-padding)}}};for(var _len3=arguments.length,sprites=Array(_len3>1?_len3-1:0),_key3=1;_key3<_len3;_key3++){sprites[_key3-1]=arguments[_key3]}if(!(sprites[0]instanceof Array)){flowSprites(sprites)}else{var spritesArray=sprites[0];flowSprites(spritesArray)}}},{key:"flowUp",value:function flowUp(padding){var flowSprites=function flowSprites(spritesToFlow){if(spritesToFlow.length>0){for(var i=0;i<spritesToFlow.length-1;i++){var sprite=spritesToFlow[i];sprite.putTop(spritesToFlow[i+1],0,-padding)}}};for(var _len4=arguments.length,sprites=Array(_len4>1?_len4-1:0),_key4=1;_key4<_len4;_key4++){sprites[_key4-1]=arguments[_key4]}if(!(sprites[0]instanceof Array)){flowSprites(sprites)}else{var spritesArray=sprites[0];flowSprites(spritesArray)}}},{key:"addProperties",value:function addProperties(o){var _this5=this;o.vx=0;o.vy=0;o._layer=0;o._circular=false;o._interact=false;o._draggable=false;o._bumpPropertiesAdded=true;o.swapChildren=function(child1,child2){var index1=o.children.indexOf(child1),index2=o.children.indexOf(child2);if(index1!==-1&&index2!==-1){child1.childIndex=index2;child2.childIndex=index1;o.children[index1]=child2;o.children[index2]=child1}else{throw new Error(child+" Both objects must be a child of the caller "+o)}};o.add=function(){for(var _len5=arguments.length,sprites=Array(_len5),_key5=0;_key5<_len5;_key5++){sprites[_key5]=arguments[_key5]}if(sprites.length>1){sprites.forEach(function(sprite){return o.addChild(sprite)})}else{o.addChild(sprites[0])}};o.remove=function(){for(var _len6=arguments.length,sprites=Array(_len6),_key6=0;_key6<_len6;_key6++){sprites[_key6]=arguments[_key6]}if(sprites.length>1){sprites.forEach(function(sprite){return o.removeChild(sprite)})}else{o.removeChild(sprites[0])}};var a=o;var nudgeAnchor=function nudgeAnchor(o,value,axis){if(o.anchor!==undefined){if(o.anchor[axis]!==0){return value*(1-o.anchor[axis]-o.anchor[axis])}else{return value}}else{return value}};var compensateForAnchor=function compensateForAnchor(o,value,axis){if(o.anchor!==undefined){if(o.anchor[axis]!==0){return value*o.anchor[axis]}else{return 0}}else{return 0}};var compensateForAnchors=function compensateForAnchors(a,b,property1,property2){return compensateForAnchor(a,a[property1],property2)+compensateForAnchor(b,b[property1],property2)};o.putCenter=function(b){var xOffset=arguments.length<=1||arguments[1]===undefined?0:arguments[1];var yOffset=arguments.length<=2||arguments[2]===undefined?0:arguments[2];if(o._stage)a=_this5.compensateForStageSize(o);b.x=a.x+nudgeAnchor(a,a.halfWidth,"x")-nudgeAnchor(b,b.halfWidth,"x")+xOffset;b.y=a.y+nudgeAnchor(a,a.halfHeight,"y")-nudgeAnchor(b,b.halfHeight,"y")+yOffset;if(!o._stage)o.compensateForParentPosition(a,b)};o.putLeft=function(b){var xOffset=arguments.length<=1||arguments[1]===undefined?0:arguments[1];var yOffset=arguments.length<=2||arguments[2]===undefined?0:arguments[2];if(o._stage)a=_this5.compensateForStageSize(o);b.x=a.x-nudgeAnchor(b,b.width,"x")+xOffset-compensateForAnchors(a,b,"width","x");b.y=a.y+nudgeAnchor(a,a.halfHeight,"y")-nudgeAnchor(b,b.halfHeight,"y")+yOffset;if(!o._stage)o.compensateForParentPosition(a,b)};o.putTop=function(b){var xOffset=arguments.length<=1||arguments[1]===undefined?0:arguments[1];var yOffset=arguments.length<=2||arguments[2]===undefined?0:arguments[2];if(o._stage)a=_this5.compensateForStageSize(o);b.x=a.x+nudgeAnchor(a,a.halfWidth,"x")-nudgeAnchor(b,b.halfWidth,"x")+xOffset;b.y=a.y-nudgeAnchor(b,b.height,"y")+yOffset-compensateForAnchors(a,b,"height","y");if(!o._stage)o.compensateForParentPosition(a,b)};o.putRight=function(b){var xOffset=arguments.length<=1||arguments[1]===undefined?0:arguments[1];var yOffset=arguments.length<=2||arguments[2]===undefined?0:arguments[2];if(o._stage)a=_this5.compensateForStageSize(o);b.x=a.x+nudgeAnchor(a,a.width,"x")+xOffset+compensateForAnchors(a,b,"width","x");b.y=a.y+nudgeAnchor(a,a.halfHeight,"y")-nudgeAnchor(b,b.halfHeight,"y")+yOffset;if(!o._stage)o.compensateForParentPosition(a,b)};o.putBottom=function(b){var xOffset=arguments.length<=1||arguments[1]===undefined?0:arguments[1];var yOffset=arguments.length<=2||arguments[2]===undefined?0:arguments[2];if(o._stage)a=_this5.compensateForStageSize(o);b.x=a.x+nudgeAnchor(a,a.halfWidth,"x")-nudgeAnchor(b,b.halfWidth,"x")+xOffset;b.y=a.y+nudgeAnchor(a,a.height,"y")+yOffset+compensateForAnchors(a,b,"height","y");if(!o._stage)o.compensateForParentPosition(a,b)};o.compensateForParentPosition=function(a,b){if(b.parent.gx!==0||b.parent.gy!==0){b.x-=a.gx;b.y-=a.gy}};var self=this;Object.defineProperties(o,{gx:{get:function get(){return o.getGlobalPosition().x},enumerable:true,configurable:true},gy:{get:function get(){return o.getGlobalPosition().y},enumerable:true,configurable:true},centerX:{get:function get(){return o.x+o.width/2-o.xAnchorOffset},enumerable:true,configurable:true},centerY:{get:function get(){return o.y+o.height/2-o.yAnchorOffset},enumerable:true,configurable:true},halfWidth:{get:function get(){return o.width/2},enumerable:true,configurable:true},halfHeight:{get:function get(){return o.height/2},enumerable:true,configurable:true},scaleModeNearest:{set:function set(value){if(o.texture.baseTexture){if(value){o.texture.baseTexture.scaleMode=PIXI.SCALE_MODES.NEAREST}else{o.texture.baseTexture.scaleMode=PIXI.SCALE_MODES.LINEAR}}else{throw new Error("The scale mode of "+o+" cannot be modified")}},enumerable:true,configurable:true},pivotX:{get:function get(){return o.anchor.x},set:function set(value){if(o.anchor===undefined){throw new Error(o+" does not have a PivotX value")}o.anchor.x=value;if(!o._previousPivotX){o.x+=value*o.width}else{o.x+=(value-o._previousPivotX)*o.width}o._previousPivotX=value},enumerable:true,configurable:true},pivotY:{get:function get(){return o.anchor.y},set:function set(value){if(o.anchor===undefined){throw new Error(o+" does not have a PivotY value")}o.anchor.y=value;if(!o._previousPivotY){o.y+=value*o.height}else{o.y+=(value-o._previousPivotY)*o.height}o._previousPivotY=value},enumerable:true,configurable:true},xAnchorOffset:{get:function get(){if(o.anchor!==undefined){return o.height*o.anchor.x}else{return 0}},enumerable:true,configurable:true},yAnchorOffset:{get:function get(){if(o.anchor!==undefined){return o.width*o.anchor.y}else{return 0}},enumerable:true,configurable:true},scaleX:{get:function get(){return o.scale.x},set:function set(value){o.scale.x=value},enumerable:true,configurable:true},scaleY:{get:function get(){return o.scale.y},set:function set(value){o.scale.y=value},enumerable:true,configurable:true},layer:{get:function get(){return o._layer},set:function set(value){o._layer=value;if(o.parent){o.parent.children.sort(function(a,b){return a.layer-b.layer})}},enumerable:true,configurable:true},interact:{get:function get(){return o._interact},set:function set(value){if(value===true){if(!o._interact){self.makeInteractive(o);o._interact=true}}else{if(self.tink.buttons.indexOf(o)!==-1){self.tink.buttons.splice(self.tink.buttons.indexOf(o),1);o._interact=false}}},enumerable:true,configurable:true},draggable:{get:function get(){return o._draggable},set:function set(value){if(value===true){if(!o._draggable){self.makeDraggable(o);o._draggable=true}}else{self.makeUndraggable(o);o._draggable=false}},enumerable:true,configurable:true},localBounds:{get:function get(){return{x:0,y:0,width:o.width,height:o.height}},enumerable:true,configurable:true},globalBounds:{get:function get(){return{x:o.gx,y:o.gy,width:o.gx+o.width,height:o.gy+o.height}},enumerable:true,configurable:true},empty:{get:function get(){if(o.children.length===0){return true}else{return false}},enumerable:true,configurable:true},circular:{get:function get(){return o._circular},set:function set(value){if(value===true&&o._circular===false){Object.defineProperties(o,{diameter:{get:function get(){return o.width},set:function set(value){o.width=value;o.height=value},enumerable:true,configurable:true},radius:{get:function get(){return o.halfWidth},set:function set(value){o.width=value*2;o.height=value*2},enumerable:true,configurable:true}});o._circular=true}if(value===false&&o._circular===true){delete o.diameter;delete o.radius;o._circular=false}},enumerable:true,configurable:true}});o.setPosition=function(x,y){o.x=x;o.y=y};o.setScale=function(xScale,yScale){o.scale.x=xScale;o.scale.y=yScale};o.setPivot=function(xPivot,yPivot){o.pivotX=xPivot;o.pivotY=yPivot};if(o.circular){Object.defineProperty(o,"radius",{get:function get(){return o.width/2},enumerable:true,configurable:true})}}},{key:"scaleToWindow",value:function(_scaleToWindow){function scaleToWindow(){return _scaleToWindow.apply(this,arguments)}scaleToWindow.toString=function(){return _scaleToWindow.toString()};return scaleToWindow}(function(){var _this6=this;var scaleBorderColor=arguments.length<=0||arguments[0]===undefined?"#2C3539":arguments[0];var newStyle=document.createElement("style");var style="* {padding: 0; margin: 0}";newStyle.appendChild(document.createTextNode(style));document.head.appendChild(newStyle);this.scale=scaleToWindow(this.canvas,scaleBorderColor);this.pointer.scale=this.scale;console.log(this.pointer);window.addEventListener("resize",function(event){_this6.scale=scaleToWindow(_this6.canvas,scaleBorderColor);_this6.pointer.scale=_this6.scale});this.canvas.scaled=true})},{key:"log",value:function log(value){return console.log(value)}},{key:"makeProgressBar",value:function makeProgressBar(hexiObject){var hexi=hexiObject;hexi.progressBar={maxWidth:0,height:0,backgroundColor:"0x808080",foregroundColor:"0x00FFFF",backBar:null,frontBar:null,percentage:null,assets:null,initialized:false,create:function create(){this.maxWidth=hexi.canvas.width/2;this.backBar=hexi.rectangle(this.maxWidth,32,this.backgroundColor);this.backBar.x=hexi.canvas.width/2-this.maxWidth/2;this.backBar.y=hexi.canvas.height/2-16;this.frontBar=hexi.rectangle(this.maxWidth,32,this.foregroundColor);this.frontBar.x=hexi.canvas.width/2-this.maxWidth/2;this.frontBar.y=hexi.canvas.height/2-16;this.percentage=hexi.text("0%","28px sans-serif","black");this.percentage.x=hexi.canvas.width/2-this.maxWidth/2+12;this.percentage.y=hexi.canvas.height/2-17},update:function update(){var ratio=hexi.loadingProgress/100;this.frontBar.width=this.maxWidth*ratio;this.percentage.content=Math.round(hexi.loadingProgress)+" %"},remove:function remove(){hexi.stage.removeChild(this.frontBar);hexi.stage.removeChild(this.backBar);hexi.stage.removeChild(this.percentage)}}}},{key:"loadingBar",value:function loadingBar(){if(!this._progressBarAdded){this.makeProgressBar(this);this.progressBar.create();this._progressBarAdded=true}else{this.progressBar.update()}}},{key:"compensateForStageSize",value:function compensateForStageSize(o){if(o._stage===true){var a={};a.x=0;a.y=0;a.width=this.canvas.width;a.height=this.canvas.height;a.halfWidth=this.canvas.width/2;a.halfHeight=this.canvas.height/2;a.xAnchorOffset=0;a.yAnchorOffset=0;return a}}},{key:"image",value:function image(imageFileName){if(this.TextureCache[imageFileName]){return this.TextureCache[imageFileName]}else{throw new Error(imageFileName+" does not appear to be an image")}}},{key:"id",value:function id(textureAtlasFrameId){if(this.TextureCache[textureAtlasFrameId]){return this.TextureCache[textureAtlasFrameId]}else{throw new Error(textureAtlasFrameId+" does not appear to be a texture atlas frame id")}}},{key:"json",value:function json(jsonFileName){if(this.loader.resources[jsonFileName].data){return this.resources[jsonFileName].data}else{throw new Error(jsonFileName+" does not appear to be a JSON data file")}}},{key:"xml",value:function xml(xmlFileName){if(this.loader.resources[xmlFileName].data){return this.resources[xmlFileName].data}else{throw new Error(xmlFileName+" does not appear to be a XML data file")}}},{key:"sound",value:function sound(soundFileName){if(this.soundObjects[soundFileName]){return this.soundObjects[soundFileName]}else{throw new Error(soundFileName+" does not appear to be a sound object")}}},{key:"resources",get:function get(){return this.loader.resources}},{key:"fps",get:function get(){return this.smoothie.fps},set:function set(value){this.smoothie.fps=value}},{key:"renderFps",get:function get(){return this.smoothie.renderFps},set:function set(value){this.smoothie.renderFps=value}},{key:"interpolate",get:function get(){return this.smoothie.interpolate},set:function set(value){this.smoothie.interpolate=value}},{key:"interpolationProperties",get:function get(){return this.smoothie.properties},set:function set(value){this.smoothie.properties=value}},{key:"border",set:function set(value){this.canvas.style.border=value}},{key:"backgroundColor",set:function set(value){this.renderer.backgroundColor=this.color(value)}}]);return Hexi}();