diff --git a/all.js b/all.js deleted file mode 100644 index 7050da9..0000000 --- a/all.js +++ /dev/null @@ -1,70 +0,0 @@ -/*1295489895,169565300,JIT Construction: v334085,en_US*/ - -if(!window.FB)window.FB={_apiKey:null,_session:null,_userStatus:'unknown',_logging:true,_inCanvas:((window.location.search.indexOf('fb_sig_in_iframe=1')>-1)||(window.location.search.indexOf('session=')>-1)||(window.location.search.indexOf('signed_request=')>-1)),_https:(window.name.indexOf('_fb_https')>-1),_domain:{api:'https://api.facebook.com/',api_read:'https://api-read.facebook.com/',cdn:'http://static.ak.fbcdn.net/',https_cdn:'https://s-static.ak.fbcdn.net/',graph:'https://graph.facebook.com/',staticfb:'http://static.ak.facebook.com/',https_staticfb:'https://s-static.ak.facebook.com/',www:window.location.protocol+'//www.facebook.com/',https_www:'https://www.facebook.com/'},_locale:null,_localeIsRtl:false,getDomain:function(a){switch(a){case 'api':return FB._domain.api;case 'api_read':return FB._domain.api_read;case 'cdn':return (window.location.protocol=='https:'||FB._https)?FB._domain.https_cdn:FB._domain.cdn;case 'graph':return FB._domain.graph;case 'staticfb':return FB._https?FB._domain.https_staticfb:FB._domain.staticfb;case 'https_staticfb':return FB._domain.https_staticfb;case 'www':return FB._https?FB._domain.https_www:FB._domain.www;case 'https_www':return FB._domain.https_www;}},copy:function(d,c,b,e){for(var a in c)if(b||typeof d[a]==='undefined')d[a]=e?e(c[a]):c[a];return d;},create:function(c,h){var e=window.FB,d=c?c.split('.'):[],a=d.length;for(var b=0;b');e.root.innerHTML='';f=true;window.setTimeout(function(){e.root.innerHTML=b;},0);}else{var c=document.createElement('iframe');c.id=e.id;c.name=e.name;c.onload=FB.Content._callbacks[a];c.scrolling='no';c.style.border='none';c.style.overflow='hidden';if(e.title)c.title=e.title;if(e.className)c.className=e.className;if(e.height)c.style.height=e.height+'px';if(e.width)c.style.width=e.width+'px';e.root.appendChild(c);f=true;c.src=e.url;}},postTarget:function(b){var a=document.createElement('form');a.action=b.url;a.target=b.target;a.method='POST';FB.Content.appendHidden(a);FB.Array.forEach(b.params,function(e,d){if(e!==null&&e!==undefined){var c=document.createElement('input');c.name=d;c.value=e;a.appendChild(c);}});a.submit();a.parentNode.removeChild(a);}}); -FB.provide('Flash',{_minVersions:[[9,0,159,0],[10,0,22,87]],_swfPath:'swf/XdComm.swf',_callbacks:[],init:function(){if(FB.Flash._init)return;FB.Flash._init=true;window.FB_OnFlashXdCommReady=function(){FB.Flash._ready=true;for(var d=0,e=FB.Flash._callbacks.length;d'+''+''+'');FB.Content.appendHidden(b);},hasMinVersion:function(){if(typeof FB.Flash._hasMinVersion==='undefined'){var i,a,b,h=[];try{i=new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');}catch(j){if(navigator.mimeTypes.length>0){var mimeType='application/x-shockwave-flash';if(navigator.mimeTypes[mimeType].enabledPlugin){var name='Shockwave Flash';i=(navigator.plugins[name+' 2.0']||navigator.plugins[name]).description;}}}if(i){var f=i.replace(/\D+/g,',').match(/^,?(.+),?$/)[1].split(',');for(a=0,b=f.length;ag[c])break majorVersion;}};}return FB.Flash._hasMinVersion;},onReady:function(a){FB.Flash.init();if(FB.Flash._ready){window.setTimeout(a,0);}else FB.Flash._callbacks.push(a);}}); -if(!this.JSON)this.JSON={};(function(){function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function')value=value.toJSON(key);if(typeof rep==='function')value=rep.call(holder,key,value);switch(typeof value){case 'string':return quote(value);case 'number':return isFinite(value)?String(value):'null';case 'boolean':case 'null':return String(value);case 'object':if(!value)return 'null';gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i-1?'&':'?')+FB.QS.encode(e));if(h.length>2000)throw new Error('JSONP only support a maximum of 2000 bytes of input.');FB.ApiServer._callbacks[c]=function(i){a&&a(i);delete FB.ApiServer._callbacks[c];g.parentNode.removeChild(g);};g.src=h;document.getElementsByTagName('head')[0].appendChild(g);},flash:function(b,e,c,d,a){if(!window.FB_OnXdHttpResult)window.FB_OnXdHttpResult=function(g,f){FB.ApiServer._callbacks[g](decodeURIComponent(f));};FB.Flash.onReady(function(){var h=FB.getDomain(b)+e,f=FB.QS.encode(d);if(c==='get'){if(h.length+f.length>2000){if(b==='graph')d.method='get';c='post';f=FB.QS.encode(d);}else{h+=(h.indexOf('?')>-1?'&':'?')+f;f='';}}else if(c!=='post'){if(b==='graph')d.method=c;c='post';f=FB.QS.encode(d);}var g=document.XdComm.sendXdHttpRequest(c.toUpperCase(),h,f,null);FB.ApiServer._callbacks[g]=function(i){a&&a(FB.JSON.parse(i));delete FB.ApiServer._callbacks[g];};});}}); -FB.provide('EventProvider',{subscribers:function(){if(!this._subscribersMap)this._subscribersMap={};return this._subscribersMap;},subscribe:function(b,a){var c=this.subscribers();if(!c[b]){c[b]=[a];}else c[b].push(a);},unsubscribe:function(b,a){var c=this.subscribers()[b];FB.Array.forEach(c,function(e,d){if(e==a)c[d]=null;});},monitor:function(d,a){if(!a()){var b=this,c=function(){if(a.apply(a,arguments))b.unsubscribe(d,c);};this.subscribe(d,c);}},clear:function(a){delete this.subscribers()[a];},fire:function(){var a=Array.prototype.slice.call(arguments),b=a.shift();FB.Array.forEach(this.subscribers()[b],function(c){if(c)c.apply(this,a);});}});FB.provide('Event',FB.EventProvider); -FB.provide('Intl',{_punctCharClass:('['+'.!?'+'\u3002'+'\uFF01'+'\uFF1F'+'\u0964'+'\u2026'+'\u0EAF'+'\u1801'+'\u0E2F'+'\uFF0E'+']'),_endsInPunct:function(a){if(typeof a!='string')return false;return a.match(new RegExp(FB.Intl._punctCharClass+'['+')"'+"'"+'\u00BB'+'\u0F3B'+'\u0F3D'+'\u2019'+'\u201D'+'\u203A'+'\u3009'+'\u300B'+'\u300D'+'\u300F'+'\u3011'+'\u3015'+'\u3017'+'\u3019'+'\u301B'+'\u301E'+'\u301F'+'\uFD3F'+'\uFF07'+'\uFF09'+'\uFF3D'+'\s'+']*$'));},_tx:function(d,a){if(a!==undefined)if(typeof a!='object'){FB.log('The second arg to FB.Intl._tx() must be an Object for '+'tx('+d+', ...)');}else{var c;for(var b in a)if(a.hasOwnProperty(b)){if(FB.Intl._endsInPunct(a[b])){c=new RegExp('\{'+b+'\}'+FB.Intl._punctCharClass+'*','g');}else c=new RegExp('\{'+b+'\}','g');d=d.replace(c,a[b]);}}return d;},tx:function(b,a){function c(e,d){void(0);}if(!FB.Intl._stringTable)return null;return FBIntern.Intl._tx(FB.Intl._stringTable[b],a);}}); -FB.provide('String',{trim:function(a){return a.replace(/^\s*|\s*$/g,'');},format:function(a){if(!FB.String.format._formatRE)FB.String.format._formatRE=/(\{[^\}^\{]+\})/g;var b=arguments;return a.replace(FB.String.format._formatRE,function(e,d){var c=parseInt(d.substr(1),10),f=b[c+1];if(f===null||f===undefined)return '';return f.toString();});},escapeHTML:function(b){var a=document.createElement('div');a.appendChild(document.createTextNode(b));return a.innerHTML.replace(/"/g,'"').replace(/'/g,''');},quote:function(c){var a=/["\\\x00-\x1f\x7f-\x9f]/g,b={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};return a.test(c)?'"'+c.replace(a,function(d){var e=b[d];if(e)return e;e=d.charCodeAt();return '\\u00'+Math.floor(e/16).toString(16)+(e%16).toString(16);})+'"':'"'+c+'"';}}); -FB.provide('Dom',{containsCss:function(c,a){var b=' '+c.className+' ';return b.indexOf(' '+a+' ')>=0;},addCss:function(b,a){if(!FB.Dom.containsCss(b,a))b.className=b.className+' '+a;},removeCss:function(b,a){if(FB.Dom.containsCss(b,a)){b.className=b.className.replace(a,'');FB.Dom.removeCss(b,a);}},getStyle:function(a,c){var d=false,b=a.style;if(a.currentStyle){FB.Array.forEach(c.match(/\-([a-z])/g),function(e){c=c.replace(e,e.substr(1,1).toUpperCase());});d=a.currentStyle[c];}else{FB.Array.forEach(c.match(/[A-Z]/g),function(e){c=c.replace(e,'-'+e.toLowerCase());});if(window.getComputedStyle){d=document.defaultView.getComputedStyle(a,null).getPropertyValue(c);if(c=='background-position-y'||c=='background-position-x')if(d=='top'||d=='left')d='0px';}}if(c=='opacity'){if(a.filters&&a.filters.alpha)return d;return d*100;}return d;},setStyle:function(a,c,d){var b=a.style;if(c=='opacity'){if(d>=100)d=99.999;if(d<0)d=0;b.opacity=d/100;b.MozOpacity=d/100;b.KhtmlOpacity=d/100;if(a.filters)if(a.filters.alpha==undefined){a.filter="alpha(opacity="+d+")";}else a.filters.alpha.opacity=d;}else b[c]=d;},addScript:function(b){var a=document.createElement('script');a.type="text/javascript";a.src=b;return document.getElementsByTagName('head')[0].appendChild(a);},addCssRules:function(e,c){if(!FB.Dom._cssRules)FB.Dom._cssRules={};var a=true;FB.Array.forEach(c,function(f){if(!(f in FB.Dom._cssRules)){a=false;FB.Dom._cssRules[f]=true;}});if(a)return;if(FB.Dom.getBrowserType()!='ie'){var d=document.createElement('style');d.type='text/css';d.textContent=e;document.getElementsByTagName('head')[0].appendChild(d);}else try{document.createStyleSheet().cssText=e;}catch(b){if(document.styleSheets[0])document.styleSheets[0].cssText+=e;}},getBrowserType:function(){if(!FB.Dom._browserType){var d=window.navigator.userAgent.toLowerCase(),b=['msie','firefox','safari','gecko'],c=['ie','mozilla','safari','mozilla'];for(var a=0;a=0){FB.Dom._browserType=c[a];break;}}return FB.Dom._browserType;},getViewportInfo:function(){var a=(document.documentElement&&document.compatMode=='CSS1Compat')?document.documentElement:document.body;return {scrollTop:a.scrollTop,scrollLeft:a.scrollLeft,width:self.innerWidth?self.innerWidth:a.clientWidth,height:self.innerHeight?self.innerHeight:a.clientHeight};},ready:function(a){if(FB.Dom._isReady){a();}else FB.Event.subscribe('dom.ready',a);}});(function(){function domReady(){FB.Dom._isReady=true;FB.Event.fire('dom.ready');FB.Event.clear('dom.ready');}if(FB.Dom._isReady||document.readyState=='complete')return domReady();if(document.addEventListener){document.addEventListener('DOMContentLoaded',domReady,false);}else if(document.attachEvent)document.attachEvent('onreadystatechange',domReady);if(FB.Dom.getBrowserType()=='ie'&&window===top)(function(){try{document.documentElement.doScroll('left');}catch(error){setTimeout(arguments.callee,0);return;}domReady();})();var oldonload=window.onload;window.onload=function(){domReady();if(oldonload)if(typeof oldonload=='string'){eval(oldonload);}else oldonload();};})(); -FB.provide('Dialog',{_loaderEl:null,_stack:[],_active:null,_findRoot:function(a){while(a){if(FB.Dom.containsCss(a,'fb_dialog'))return a;a=a.parentNode;}},_showLoader:function(a,c){if(!FB.Dialog._loaderEl){c=parseInt(c,10);c=c?c:460;FB.Dialog._loaderEl=FB.Dialog._findRoot(FB.Dialog.create({content:('
'+' '+'
'+'
'+' Facebook'+'
'+'
'+'
'+''),width:c}));}if(!a)a=function(){};var b=FB.$('fb_dialog_loader_close');FB.Dom.removeCss(b,'fb_hidden');b.onclick=function(){FB.Dialog._hideLoader();a();};FB.Dialog._makeActive(FB.Dialog._loaderEl);},_hideLoader:function(){if(FB.Dialog._loaderEl&&FB.Dialog._loaderEl==FB.Dialog._active)FB.Dialog._loaderEl.style.top='-10000px';},_makeActive:function(b){FB.Dialog._lowerActive();var a={width:parseInt(b.offsetWidth,10),height:parseInt(b.offsetHeight,10)},e=FB.Dom.getViewportInfo(),c=(e.scrollLeft+(e.width-a.width)/2),d=(e.scrollTop+(e.height-a.height)/2.5);b.style.left=(c>0?c:0)+'px';b.style.top=(d>0?d:0)+'px';FB.Dialog._active=b;},_lowerActive:function(){if(!FB.Dialog._active)return;FB.Dialog._active.style.top='-10000px';FB.Dialog._active=null;},_removeStacked:function(a){FB.Dialog._stack=FB.Array.filter(FB.Dialog._stack,function(b){return b!=a;});},create:function(e){e=e||{};if(e.loader)FB.Dialog._showLoader(e.onClose,e.loaderWidth);var d=document.createElement('div'),c=document.createElement('div'),a='fb_dialog';if(e.closeIcon&&e.onClose){var b=document.createElement('a');b.className='fb_dialog_close_icon';b.onclick=e.onClose;d.appendChild(b);}if(FB.Dom.getBrowserType()=='ie'){a+=' fb_dialog_legacy';FB.Array.forEach(['vert_left','vert_right','horiz_top','horiz_bottom','top_left','top_right','bottom_left','bottom_right'],function(g){var h=document.createElement('span');h.className='fb_dialog_'+g;d.appendChild(h);});}else a+=' fb_dialog_advanced';if(e.content)FB.Content.append(e.content,c);d.className=a;var f=parseInt(e.width,10);if(!isNaN(f))d.style.width=f+'px';c.className='fb_dialog_content';d.appendChild(c);FB.Content.append(d);if(e.visible)FB.Dialog.show(d);return c;},show:function(a){a=FB.Dialog._findRoot(a);if(a){FB.Dialog._removeStacked(a);FB.Dialog._hideLoader();FB.Dialog._makeActive(a);FB.Dialog._stack.push(a);}},remove:function(a){a=FB.Dialog._findRoot(a);if(a){var b=FB.Dialog._active==a;FB.Dialog._removeStacked(a);FB.Dialog._hideLoader();if(b)if(FB.Dialog._stack.length>0){FB.Dialog.show(FB.Dialog._stack.pop());}else FB.Dialog._lowerActive();window.setTimeout(function(){a.parentNode.removeChild(a);},3000);}}}); -FB.provide('XD',{_origin:null,_transport:null,_callbacks:{},_forever:{},init:function(a){if(FB.XD._origin)return;if(window.addEventListener&&!window.attachEvent&&window.postMessage){FB.XD._origin=(window.location.protocol+'//'+window.location.host+'/'+FB.guid());FB.XD.PostMessage.init();FB.XD._transport='postmessage';}else if(!a&&FB.Flash.hasMinVersion()){FB.XD._origin=(window.location.protocol+'//'+document.domain+'/'+FB.guid());FB.XD.Flash.init();FB.XD._transport='flash';}else{FB.XD._transport='fragment';FB.XD.Fragment._channelUrl=a||window.location.toString();}},resolveRelation:function(b){var g,d,f=b.split('.'),e=window;for(var a=0,c=f.length;a0)return 'javascript:false;//';var f=FB.getDomain('cdn')+'connect/xd_proxy.php#',c=FB.guid();if(FB.XD._transport=='fragment'){f=FB.XD.Fragment._channelUrl;var d=f.indexOf('#');if(d>0)f=f.substr(0,d);f+=((f.indexOf('?')<0?'?':'&')+FB.XD.Fragment._magic+'#?=&');}if(b)FB.XD._forever[c]=true;FB.XD._callbacks[c]=a;return f+FB.QS.encode({cb:c,origin:FB.XD._origin,relation:e||'opener',transport:FB.XD._transport});},recv:function(b){if(typeof b=='string')b=FB.QS.decode(b);var a=FB.XD._callbacks[b.cb];if(!FB.XD._forever[b.cb])delete FB.XD._callbacks[b.cb];a&&a(b);},PostMessage:{init:function(){var a=FB.XD.PostMessage.onMessage;window.addEventListener?window.addEventListener('message',a,false):window.attachEvent('onmessage',a);},onMessage:function(event){FB.XD.recv(event.data);}},Flash:{init:function(){FB.Flash.onReady(function(){document.XdComm.postMessage_init('FB.XD.Flash.onMessage',FB.XD._origin);});},onMessage:function(a){FB.XD.recv(decodeURIComponent(a));}},Fragment:{_magic:'fb_xd_fragment',checkAndDispatch:function(){var b=window.location.toString(),a=b.substr(b.indexOf('#')+1),c=b.indexOf(FB.XD.Fragment._magic);if(c>0){FB.init=FB.getLoginStatus=FB.api=function(){};document.documentElement.style.display='none';FB.XD.resolveRelation(FB.QS.decode(a).relation).FB.XD.recv(a);}}}});FB.XD.Fragment.checkAndDispatch(); -FB.provide('Arbiter',{inform:function(c,e,f,b){if(window.name.indexOf('app_runner_')===0){var d=FB.JSON.stringify({method:c,params:e});if(window.postMessage){FB.XD.resolveRelation(f||'parent').postMessage(d,'*');return;}else try{window.opener.postMessage(d);return;}catch(a){}}var h=(FB.getDomain((b?'https_':'')+'staticfb')+'connect/canvas_proxy.php#'+FB.QS.encode({method:c,params:FB.JSON.stringify(e||{}),relation:f}));var g=FB.Content.appendHidden('');FB.Content.insertIframe({url:h,root:g,width:1,height:1,onload:function(){setTimeout(function(){g.parentNode.removeChild(g);},10);}});}}); -FB.provide('',{ui:function(e,b){if(!e.method){FB.log('"method" is a required parameter for FB.ui().');return;}var a=FB.UIServer.prepareCall(e,b);if(!a)return;var d=a.params.display;if(d=='dialog')d='iframe';var c=FB.UIServer[d];if(!c){FB.log('"display" must be one of "popup", "iframe" or "hidden".');return;}c(a);}});FB.provide('UIServer',{Methods:{},_active:{},_defaultCb:{},_resultToken:'"xxRESULTTOKENxx"',genericTransform:function(a){if(a.params.display=='dialog'||a.params.display=='iframe'){a.params.display='iframe';a.params.channel=FB.UIServer._xdChannelHandler(a.id,'parent.parent');}return a;},prepareCall:function(h,b){var g=h.method.toLowerCase(),f=FB.UIServer.Methods[g]||{size:{width:575,height:240}},e=FB.guid(),d=FB._https||(g!=='auth.status');FB.copy(h,{api_key:FB._apiKey,app_id:FB._apiKey,locale:FB._locale,sdk:'joey',access_token:d&&FB._session&&FB._session.access_token||undefined});h.display=FB.UIServer.getDisplayMode(f,h);if(!f.url){f.url='dialog/'+g;delete h.method;}var a={cb:b,id:e,size:f.size||{},url:FB.getDomain(d?'https_www':'www')+f.url,params:h};var j=f.transform?f.transform:FB.UIServer.genericTransform;if(j){a=j(a);if(!a)return;}var i=FB.UIServer.getXdRelation(a.params.display);if(!(a.id in FB.UIServer._defaultCb)&&!('next' in a.params))a.params.next=FB.UIServer._xdResult(a.cb,a.id,i,true);if(i==='parent')a.params.channel_url=FB.UIServer._xdChannelHandler(e,'parent.parent');a.params=FB.JSON.flatten(a.params);var c=FB.QS.encode(a.params);if((a.url+c).length>2000){a.post=true;}else if(c)a.url+='?'+c;return a;},getDisplayMode:function(a,b){if(b.display==='hidden')return 'hidden';if(window.name.indexOf('app_runner_')===0)return 'async';if(!FB._session&&b.display=='dialog'&&!a.loggedOutIframe){FB.log('"dialog" mode can only be used when the user is connected.');return 'popup';}return b.display||(FB._session?'dialog':'popup');},getXdRelation:function(a){if(a==='popup')return 'opener';if(a==='dialog'||a==='iframe')return 'parent';if(a==='async')return 'parent.frames['+window.name+']';},popup:function(b){var a=typeof window.screenX!='undefined'?window.screenX:window.screenLeft,i=typeof window.screenY!='undefined'?window.screenY:window.screenTop,g=typeof window.outerWidth!='undefined'?window.outerWidth:document.documentElement.clientWidth,f=typeof window.outerHeight!='undefined'?window.outerHeight:(document.documentElement.clientHeight-22),k=b.size.width,d=b.size.height,h=(a<0)?window.screen.width+a:a,e=parseInt(h+((g-k)/2),10),j=parseInt(i+((f-d)/2.5),10),c=('width='+k+',height='+d+',left='+e+',top='+j+',scrollbars=1');if(b.params.method=='permissions.request')c+=',location=1,toolbar=0';if(b.post){FB.UIServer._active[b.id]=window.open('about:blank',b.id,c);FB.Content.postTarget({url:b.url,target:b.id,params:b.params});}else FB.UIServer._active[b.id]=window.open(b.url,b.id,c);if(b.id in FB.UIServer._defaultCb)FB.UIServer._popupMonitor();},hidden:function(a){a.className='FB_UI_Hidden';a.root=FB.Content.appendHidden('');FB.UIServer._insertIframe(a);},iframe:function(a){a.className='FB_UI_Dialog';a.root=FB.Dialog.create({onClose:function(){FB.UIServer._triggerDefault(a.id);},loader:true,loaderWidth:a.size.width,closeIcon:true});FB.Dom.addCss(a.root,'fb_dialog_iframe');FB.UIServer._insertIframe(a);},async:function(a){a.frame=window.name;delete a.url;delete a.size;FB.Arbiter.inform('showDialog',a);},_insertIframe:function(b){FB.UIServer._active[b.id]=false;var a=function(c){if(b.id in FB.UIServer._active)FB.UIServer._active[b.id]=c;};if(b.post){FB.Content.insertIframe({url:'about:blank',root:b.root,className:b.className,width:b.size.width,height:b.size.height,onload:function(c){a(c);FB.Content.postTarget({url:b.url,target:c.name,params:b.params});}});}else FB.Content.insertIframe({url:b.url,root:b.root,className:b.className,width:b.size.width,height:b.size.height,onload:a});},_triggerDefault:function(a){FB.UIServer._xdRecv({frame:a},FB.UIServer._defaultCb[a]||function(){});},_popupMonitor:function(){var a;for(var b in FB.UIServer._active)if(FB.UIServer._active.hasOwnProperty(b)&&b in FB.UIServer._defaultCb){var c=FB.UIServer._active[b];try{if(c.tagName)continue;}catch(d){}try{if(c.closed){FB.UIServer._triggerDefault(b);}else a=true;}catch(e){}}if(a&&!FB.UIServer._popupInterval){FB.UIServer._popupInterval=window.setInterval(FB.UIServer._popupMonitor,100);}else if(!a&&FB.UIServer._popupInterval){window.clearInterval(FB.UIServer._popupInterval);FB.UIServer._popupInterval=null;}},_xdChannelHandler:function(a,b){return FB.XD.handler(function(c){var d=FB.UIServer._active[a];if(!d)return;if(c.type=='resize'){if(c.height)d.style.height=c.height+'px';if(c.width)d.style.width=c.width+'px';FB.Arbiter.inform('resize.ack',{},'parent.frames['+d.name+']',true);FB.Dialog.show(d);}},b,true);},_xdNextHandler:function(a,b,d,c){if(c)FB.UIServer._defaultCb[b]=a;return FB.XD.handler(function(e){FB.UIServer._xdRecv(e,a);},d)+'&frame='+b;},_xdRecv:function(b,a){var c=FB.UIServer._active[b.frame];try{if(FB.Dom.containsCss(c,'FB_UI_Hidden')){window.setTimeout(function(){c.parentNode.parentNode.removeChild(c.parentNode);},3000);}else if(FB.Dom.containsCss(c,'FB_UI_Dialog'))FB.Dialog.remove(c);}catch(d){}try{if(c.close){c.close();FB.UIServer._popupCount--;}}catch(e){}delete FB.UIServer._active[b.frame];delete FB.UIServer._defaultCb[b.frame];a(b);},_xdResult:function(a,b,d,c){return (FB.UIServer._xdNextHandler(function(e){a&&a(e.result&&e.result!=FB.UIServer._resultToken&&FB.JSON.parse(e.result));},b,d,c)+'&result='+encodeURIComponent(FB.UIServer._resultToken));}}); -FB.provide('',{getLoginStatus:function(a,b){if(!FB._apiKey){FB.log('FB.getLoginStatus() called before calling FB.init().');return;}if(a)if(!b&&FB.Auth._loadState=='loaded'){a({status:FB._userStatus,session:FB._session});return;}else FB.Event.subscribe('FB.loginStatus',a);if(!b&&FB.Auth._loadState=='loading')return;FB.Auth._loadState='loading';var c=function(d){FB.Auth._loadState='loaded';FB.Event.fire('FB.loginStatus',d);FB.Event.clear('FB.loginStatus');};FB.ui({method:'auth.status',display:'hidden'},c);},getSession:function(){return FB._session;},login:function(a,b){FB.ui(FB.copy({method:'permissions.request',display:'popup'},b||{}),a);},logout:function(a){FB.ui({method:'auth.logout',display:'hidden'},a);}});FB.provide('Auth',{_callbacks:[],setSession:function(e,g){var b=!FB._session&&e,c=FB._session&&!e,a=FB._session&&e&&FB._session.uid!=e.uid,f=b||c||(FB._session&&e&&FB._session.access_token!=e.access_token),h=g!=FB._userStatus;var d={session:e,status:g};FB._session=e;FB._userStatus=g;if(f&&FB.Cookie&&FB.Cookie.getEnabled())FB.Cookie.set(e);if(h)FB.Event.fire('auth.statusChange',d);if(c||a)FB.Event.fire('auth.logout',d);if(b||a)FB.Event.fire('auth.login',d);if(f)FB.Event.fire('auth.sessionChange',d);if(FB.Auth._refreshTimer){window.clearTimeout(FB.Auth._refreshTimer);delete FB.Auth._refreshTimer;}if(FB.Auth._loadState&&e&&e.expires)FB.Auth._refreshTimer=window.setTimeout(function(){FB.getLoginStatus(null,true);},1200000);return d;},xdHandler:function(a,b,f,c,e,d){return FB.UIServer._xdNextHandler(FB.Auth.xdResponseWrapper(a,e,d),b,f,c);},xdResponseWrapper:function(a,c,b){return function(d){try{b=FB.JSON.parse(d.session);}catch(f){}if(b)c='connected';if(d.fb_https&&!FB._https)FB._https=true;var e=FB.Auth.setSession(b||null,c);e.perms=d&&d.perms||null;a&&a(e);};}});FB.provide('UIServer.Methods',{'permissions.request':{size:{width:627,height:326},transform:function(a){if(!FB._apiKey){FB.log('FB.login() called before calling FB.init().');return;}if(FB._session&&!a.params.perms){FB.log('FB.login() called when user is already connected.');a.cb&&a.cb({status:FB._userStatus,session:FB._session});return;}a=FB.UIServer.genericTransform(a);a.cb=FB.Auth.xdResponseWrapper(a.cb,FB._userStatus,FB._session);a.params.method='permissions.request';FB.copy(a.params,{fbconnect:FB._inCanvas?0:1,return_session:1,session_version:3});return a;}},'auth.logout':{url:'logout.php',transform:function(a){if(!FB._apiKey){FB.log('FB.logout() called before calling FB.init().');}else if(!FB._session){FB.log('FB.logout() called without a session.');}else{a.params.next=FB.Auth.xdHandler(a.cb,a.id,'parent',false,'unknown');return a;}}},'auth.status':{url:'extern/login_status.php',transform:function(a){var b=a.cb,c=a.id,d=FB.Auth.xdHandler;delete a.cb;FB.copy(a.params,{no_session:d(b,c,'parent',false,'notConnected'),no_user:d(b,c,'parent',false,'unknown'),ok_session:d(b,c,'parent',false,'connected'),session_version:3,extern:FB._inCanvas?0:2});return a;}}}); -FB.provide('Canvas',{_timer:null,_lastSize:{},setSize:function(b){if(typeof b!="object")b={};b=FB.copy(b||{},FB.Canvas._computeContentSize());b=FB.copy(b,{frame:window.name||'iframe_canvas'});if(FB.Canvas._lastSize[b.frame]){var a=FB.Canvas._lastSize[b.frame].height;if(FB.Canvas._lastSize[b.frame].width==b.width&&(b.height<=a&&(a-b.height<=16)))return false;}FB.Canvas._lastSize[b.frame]=b;FB.Arbiter.inform('setSize',b);return true;},setAutoResize:function(b,a){if(a===undefined&&typeof b=="number"){a=b;b=true;}if(b===undefined||b){if(FB.Canvas._timer===null)FB.Canvas._timer=window.setInterval(FB.Canvas.setSize,a||100);FB.Canvas.setSize();}else if(FB.Canvas._timer!==null){window.clearInterval(FB.Canvas._timer);FB.Canvas._timer=null;}},_computeContentSize:function(){var a=document.body,c=document.documentElement,d=0,b=Math.max(Math.max(a.offsetHeight,a.scrollHeight)+a.offsetTop,Math.max(c.offsetHeight,c.scrollHeight)+c.offsetTop);if(a.offsetWidthd)d=f;});if(c.clientLeft>0)d+=(c.clientLeft*2);if(c.clientTop>0)b+=(c.clientTop*2);return {height:b,width:d};}}); -FB.provide('UIServer.Methods',{'stream.share':{size:{width:575,height:380},url:'sharer.php',transform:function(a){if(!a.params.u)a.params.u=window.location.toString();return a;}},'fbml.dialog':{size:{width:575,height:300},url:'render_fbml.php',loggedOutIframe:true,transform:function(a){return a;}},'auth.logintofacebook':{size:{width:530,height:287},url:'login.php',transform:function(a){a.params.skip_api_login=1;var c=FB.UIServer.getXdRelation(a.params.display);var b=FB.UIServer._xdResult(a.cb,a.id,c,true);a.params.next=FB.getDomain(FB._https?'https_www':'www')+"login.php?"+FB.QS.encode({api_key:FB._apiKey,next:b,skip_api_login:1});return a;}}}); -FB.provide('',{share:function(a){FB.log('FB.share() has been deprecated. Please use FB.ui() instead.');FB.ui({display:'popup',method:'stream.share',u:a});},publish:function(b,a){FB.log('FB.publish() has been deprecated. Please use FB.ui() instead.');b=b||{};FB.ui(FB.copy({display:'popup',method:'stream.publish',preview:1},b||{}),a);},addFriend:function(b,a){FB.log('FB.addFriend() has been deprecated. Please use FB.ui() instead.');FB.ui({display:'popup',id:b,method:'friend.add'},a);}});FB.UIServer.Methods['auth.login']=FB.UIServer.Methods['permissions.request']; -FB.provide('XFBML',{_renderTimeout:30000,parse:function(c,a){c=c||document.body;var b=1,d=function(){b--;if(b===0){a&&a();FB.Event.fire('xfbml.render');}};FB.Array.forEach(FB.XFBML._tagInfos,function(f){if(!f.xmlns)f.xmlns='fb';var g=FB.XFBML._getDomElements(c,f.xmlns,f.localName);for(var e=0;e0)FB.log(b+' XFBML tags failed to render in '+FB.XFBML._renderTimeout+'ms.');},FB.XFBML._renderTimeout);d();},registerTag:function(a){FB.XFBML._tagInfos.push(a);},_processElement:function(dom,tagInfo,cb){var element=dom._element;if(element){element.subscribe('render',cb);element.process();}else{var processor=function(){var fn=eval(tagInfo.className);var getBoolAttr=function(attr){var attr=dom.getAttribute(attr);return (attr&&FB.Array.indexOf(['true','1','yes','on'],attr.toLowerCase())>-1);};var isLogin=false;var showFaces=true;var renderInIframe=false;if(tagInfo.className==='FB.XFBML.LoginButton'){renderInIframe=getBoolAttr('render-in-iframe');showFaces=getBoolAttr('show-faces')||getBoolAttr('show_faces');isLogin=renderInIframe||showFaces;if(isLogin)fn=FB.XFBML.Login;}element=dom._element=new fn(dom);if(isLogin){var extraParams={show_faces:showFaces};var perms=dom.getAttribute('perms');if(perms)extraParams.perms=perms;element.setExtraParams(extraParams);}element.subscribe('render',cb);element.process();};if(FB.CLASSES[tagInfo.className.substr(3)]){processor();}else FB.log('Tag '+tagInfo.className+' was not found.');}},_getDomElements:function(a,e,d){var c=e+':'+d;switch(FB.Dom.getBrowserType()){case 'mozilla':return a.getElementsByTagNameNS(document.body.namespaceURI,c);case 'ie':try{var docNamespaces=document.namespaces;if(docNamespaces&&docNamespaces[e]){var nodes=a.getElementsByTagName(d);if(!document.addEventListener||nodes.length>0)return nodes;}}catch(b){}return a.getElementsByTagName(c);default:return a.getElementsByTagName(c);}},_tagInfos:[{localName:'activity',className:'FB.XFBML.Activity'},{localName:'add-profile-tab',className:'FB.XFBML.AddProfileTab'},{localName:'bookmark',className:'FB.XFBML.Bookmark'},{localName:'comments',className:'FB.XFBML.Comments'},{localName:'connect-bar',className:'FB.XFBML.ConnectBar'},{localName:'fan',className:'FB.XFBML.Fan'},{localName:'like',className:'FB.XFBML.Like'},{localName:'like-box',className:'FB.XFBML.LikeBox'},{localName:'live-stream',className:'FB.XFBML.LiveStream'},{localName:'login',className:'FB.XFBML.Login'},{localName:'login-button',className:'FB.XFBML.LoginButton'},{localName:'facepile',className:'FB.XFBML.Facepile'},{localName:'friendpile',className:'FB.XFBML.Friendpile'},{localName:'name',className:'FB.XFBML.Name'},{localName:'profile-pic',className:'FB.XFBML.ProfilePic'},{localName:'recommendations',className:'FB.XFBML.Recommendations'},{localName:'registration',className:'FB.XFBML.Registration'},{localName:'send',className:'FB.XFBML.Send'},{localName:'serverfbml',className:'FB.XFBML.ServerFbml'},{localName:'share-button',className:'FB.XFBML.ShareButton'},{localName:'social-bar',className:'FB.XFBML.SocialBar'}]});(function(){try{if(document.namespaces&&!document.namespaces.item.fb)document.namespaces.add('fb');}catch(a){}}()); -FB.provide('XFBML',{set:function(b,c,a){FB.log('FB.XFBML.set() has been deprecated.');b.innerHTML=c;FB.XFBML.parse(b,a);}}); -FB.provide('',{bind:function(){var a=Array.prototype.slice.call(arguments),c=a.shift(),b=a.shift();return function(){return c.apply(b,a.concat(Array.prototype.slice.call(arguments)));};},Class:function(b,a,d){if(FB.CLASSES[b])return FB.CLASSES[b];var c=a||function(){};c.prototype=d;c.prototype.bind=function(e){return FB.bind(e,this);};c.prototype.constructor=c;FB.create(b,c);FB.CLASSES[b]=c;return c;},subclass:function(d,b,c,e){if(FB.CLASSES[d])return FB.CLASSES[d];var a=FB.create(b);FB.copy(e,a.prototype);e._base=a;e._callBase=function(g){var f=Array.prototype.slice.call(arguments,1);return a.prototype[g].apply(this,f);};return FB.Class(d,c?c:function(){if(a.apply)a.apply(this,arguments);},e);},CLASSES:{}});FB.provide('Type',{isType:function(a,b){while(a)if(a.constructor===b||a===b){return true;}else a=a._base;return false;}}); -FB.Class('Obj',null,FB.copy({setProperty:function(a,b){if(FB.JSON.stringify(b)!=FB.JSON.stringify(this[a])){this[a]=b;this.fire(a,b);}}},FB.EventProvider)); -FB.subclass('Waitable','Obj',function(){},{set:function(a){this.setProperty('value',a);},error:function(a){this.fire("error",a);},wait:function(a,b){if(b)this.subscribe('error',b);this.monitor('value',this.bind(function(){if(this.value!==undefined){a(this.value);return true;}}));}}); -FB.subclass('Data.Query','Waitable',function(){if(!FB.Data.Query._c)FB.Data.Query._c=1;this.name='v_'+FB.Data.Query._c++;},{parse:function(a){var b=FB.String.format.apply(null,a),d=(/^select (.*?) from (\w+)\s+where (.*)$/i).exec(b);this.fields=this._toFields(d[1]);this.table=d[2];this.where=this._parseWhere(d[3]);for(var c=1;c-1){return d;}else return b;});},isValid:function(){for(var a=this.dom;a;a=a.parentNode)if(a==document.body)return true;},clear:function(){this.dom.innerHTML='';}},FB.EventProvider)); -FB.subclass('XFBML.IframeWidget','XFBML.Element',null,{_showLoader:true,_refreshOnAuthChange:false,_allowReProcess:false,_fetchPreCachedLoader:false,_visibleAfter:'load',getUrlBits:function(){throw new Error('Inheriting class needs to implement getUrlBits().');},setupAndValidate:function(){return true;},oneTimeSetup:function(){},getSize:function(){},getIframeName:function(){},getIframeTitle:function(){},getChannelUrl:function(){if(!this._channelUrl){var a=this;this._channelUrl=FB.XD.handler(function(b){a.fire('xd.'+b.type,b);},'parent.parent',true);}return this._channelUrl;},getIframeNode:function(){return this.dom.getElementsByTagName('iframe')[0];},process:function(a){if(this._done){if(!this._allowReProcess&&!a)return;this.clear();}else this._oneTimeSetup();this._done=true;if(!this.setupAndValidate()){this.fire('render');return;}if(this._showLoader)this._addLoader();FB.Dom.addCss(this.dom,'fb_iframe_widget');if(this._visibleAfter!='immediate'){FB.Dom.addCss(this.dom,'fb_hide_iframes');}else this.subscribe('iframe.onload',FB.bind(this.fire,this,'render'));var c=this.getSize()||{};var d=this._getURL();if(!this._fetchPreCachedLoader)d+='?'+FB.QS.encode(this._getQS());if(d.length>2000){d='about:blank';var b=FB.bind(function(){this._postRequest();this.unsubscribe('iframe.onload',b);},this);this.subscribe('iframe.onload',b);}FB.Content.insertIframe({url:d,root:this.dom.appendChild(document.createElement('span')),name:this.getIframeName(),title:this.getIframeTitle(),className:FB._localeIsRtl?'fb_rtl':'fb_ltr',height:c.height,width:c.width,onload:FB.bind(this.fire,this,'iframe.onload')});},_oneTimeSetup:function(){this.subscribe('xd.resize',FB.bind(this._handleResizeMsg,this));if(FB.getLoginStatus){this.subscribe('xd.refreshLoginStatus',FB.bind(FB.getLoginStatus,FB,function(){},true));this.subscribe('xd.logout',FB.bind(FB.logout,FB,function(){}));}if(this._refreshOnAuthChange)this._setupAuthRefresh();if(this._visibleAfter=='load')this.subscribe('iframe.onload',FB.bind(this._makeVisible,this));this.oneTimeSetup();},_makeVisible:function(){this._removeLoader();FB.Dom.removeCss(this.dom,'fb_hide_iframes');this.fire('render');},_setupAuthRefresh:function(){FB.getLoginStatus(FB.bind(function(b){var a=b.status;FB.Event.subscribe('auth.statusChange',FB.bind(function(c){if(!this.isValid())return;if(a=='unknown'||c.status=='unknown')this.process(true);a=c.status;},this));},this));},_handleResizeMsg:function(b){if(!this.isValid())return;var a=this.getIframeNode();a.style.height=b.height+'px';if(b.width)a.style.width=b.width+'px';a.style.border='none';this._makeVisible();},_addLoader:function(){if(!this._loaderDiv){FB.Dom.addCss(this.dom,'fb_iframe_widget_loader');this._loaderDiv=document.createElement('div');this._loaderDiv.className='FB_Loader';this.dom.appendChild(this._loaderDiv);}},_removeLoader:function(){if(this._loaderDiv){FB.Dom.removeCss(this.dom,'fb_iframe_widget_loader');if(this._loaderDiv.parentNode)this._loaderDiv.parentNode.removeChild(this._loaderDiv);this._loaderDiv=null;}},_getQS:function(){return FB.copy({api_key:FB._apiKey,locale:FB._locale,sdk:'joey',session_key:FB._session&&FB._session.session_key,ref:this.getAttribute('ref')},this.getUrlBits().params);},_getURL:function(){var a='www',b='';if(this._fetchPreCachedLoader){a='cdn';b='static/';}return FB.getDomain(a)+'plugins/'+b+this.getUrlBits().name+'.php';},_postRequest:function(){FB.Content.postTarget({url:this._getURL(),target:this.getIframeNode().name,params:this._getQS()});}}); -FB.subclass('XFBML.Activity','XFBML.IframeWidget',null,{_visibleAfter:'load',_refreshOnAuthChange:true,setupAndValidate:function(){this._attr={border_color:this.getAttribute('border-color'),colorscheme:this.getAttribute('color-scheme'),filter:this.getAttribute('filter'),font:this.getAttribute('font'),header:this._getBoolAttribute('header'),height:this._getPxAttribute('height',300),recommendations:this._getBoolAttribute('recommendations'),site:this.getAttribute('site',location.hostname),width:this._getPxAttribute('width',300)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'activity',params:this._attr};}}); -FB.subclass('XFBML.ButtonElement','XFBML.Element',null,{_allowedSizes:['icon','small','medium','large','xlarge'],onClick:function(){throw new Error('Inheriting class needs to implement onClick().');},setupAndValidate:function(){return true;},getButtonMarkup:function(){return this.getOriginalHTML();},getOriginalHTML:function(){return this._originalHTML;},process:function(){if(!('_originalHTML' in this))this._originalHTML=FB.String.trim(this.dom.innerHTML);if(!this.setupAndValidate()){this.fire('render');return;}var d=this._getAttributeFromList('size','medium',this._allowedSizes),a='',b='';if(d=='icon'){a='fb_button_simple';}else{var c=FB._localeIsRtl?'_rtl':'';b=this.getButtonMarkup();a='fb_button'+c+' fb_button_'+d+c;}this.dom.innerHTML=(''+''+b+''+'');this.dom.firstChild.onclick=FB.bind(this.onClick,this);this.fire('render');}}); -FB.provide('Helper',{isUser:function(a){return a<2.2e+09||(a>=1e+14&&a<=100099999989999);},getLoggedInUser:function(){return FB._session?FB._session.uid:null;},upperCaseFirstChar:function(a){if(a.length>0){return a.substr(0,1).toUpperCase()+a.substr(1);}else return a;},getProfileLink:function(c,b,a){a=a||(c?FB.getDomain('www')+'profile.php?id='+c.uid:null);if(a)b=''+b+'';return b;},invokeHandler:function(handler,scope,args){if(handler)if(typeof handler==='string'){eval(handler);}else if(handler.apply)handler.apply(scope,args||[]);},fireEvent:function(a,b){var c=b._attr.href;b.fire(a,c);FB.Event.fire(a,c,b);},executeFunctionByName:function(d){var a=Array.prototype.slice.call(arguments,1);var f=d.split(".");var c=f.pop();var b=window;for(var e=0;e0){a.xid=encodeURIComponent(document.URL.substring(0,b));}else a.xid=encodeURIComponent(document.URL);}if(a.migrated&&!a.href)a.href='http://www.facebook.com/plugins/comments_v1.php?'+'app_id='+FB._apiKey+'&xid='+encodeURIComponent(a.xid)+'&url='+encodeURIComponent(a.url);this._attr=a;return true;},oneTimeSetup:function(){this.subscribe('xd.addComment',FB.bind(this._handleCommentMsg,this));},getSize:function(){return {width:this._attr.width,height:200};},getUrlBits:function(){return {name:'comments',params:this._attr};},_handleCommentMsg:function(a){if(!this.isValid())return;FB.Event.fire('comments.add',{post:a.post,user:a.user,widget:this});}}); -FB.provide('Anim',{ate:function(c,g,d,b){d=!isNaN(parseFloat(d))&&d>=0?d:750;var e=40,f={},j={},a=null,h=c.style,i=setInterval(FB.bind(function(){if(!a)a=new Date().getTime();var k=1;if(d!=0)k=Math.min((new Date().getTime()-a)/d,1);FB.Array.forEach(g,FB.bind(function(o,m){if(!f[m]){var n=FB.Dom.getStyle(c,m);if(n===false)return;f[m]=this._parseCSS(n+'');}if(!j[m])j[m]=this._parseCSS(o.toString());var l='';FB.Array.forEach(f[m],function(q,p){if(isNaN(j[m][p].numPart)&&j[m][p].textPart=='?'){l=q.numPart+q.textPart;}else if(isNaN(q.numPart)){l=q.textPart;}else l+=(q.numPart+Math.ceil((j[m][p].numPart-q.numPart)*Math.sin(Math.PI/2*k)))+j[m][p].textPart+' ';});FB.Dom.setStyle(c,m,l);},this));if(k==1){clearInterval(i);if(b)b(c);}},this),e);},_parseCSS:function(a){var b=[];FB.Array.forEach(a.split(' '),function(d){var c=parseInt(d,10);b.push({numPart:c,textPart:d.replace(c,'')});});return b;}}); -FB.provide('Insights',{impression:function(e,a){var b=FB.guid(),g="//ah8.facebook.com/impression.php/"+b+"/",c=new Image(1,1),f=[];if(!e.api_key&&FB._apiKey)e.api_key=FB._apiKey;for(var d in e)f.push(encodeURIComponent(d)+'='+encodeURIComponent(e[d]));g+='?'+f.join('&');if(a)c.onload=a;c.src=g;}}); -FB.subclass('XFBML.ConnectBar','XFBML.Element',null,{_initialHeight:null,_initTopMargin:0,_picFieldName:'pic_square',_page:null,_displayed:false,_notDisplayed:false,_container:null,_animationSpeed:0,process:function(){FB.getLoginStatus(this.bind(function(a){FB.Event.monitor('auth.statusChange',this.bind(function(){if(this.isValid()&&FB._userStatus=='connected'){this._uid=FB.Helper.getLoggedInUser();FB.api({method:'Connect.shouldShowConnectBar'},this.bind(function(b){if(b!=2){this._animationSpeed=(b==0)?750:0;this._showBar();}else this._noRender();}));}else this._noRender();return false;}));}));},_showBar:function(){var a=FB.Data._selectByIndex(['first_name','profile_url',this._picFieldName],'user','uid',this._uid);var b=FB.Data._selectByIndex(['display_name'],'application','api_key',FB._apiKey);FB.Data.waitOn([a,b],FB.bind(function(c){c[0][0].site_name=c[1][0].display_name;if(!this._displayed){this._displayed=true;this._notDisplayed=false;this._renderConnectBar(c[0][0]);this.fire('render');FB.Insights.impression({lid:104,name:'widget_load'});this.fire('connectbar.ondisplay');FB.Event.fire('connectbar.ondisplay',this);FB.Helper.invokeHandler(this.getAttribute('on-display'),this);}},this));},_noRender:function(){if(this._displayed){this._displayed=false;this._closeConnectBar();}if(!this._notDisplayed){this._notDisplayed=true;this.fire('render');this.fire('connectbar.onnotdisplay');FB.Event.fire('connectbar.onnotdisplay',this);FB.Helper.invokeHandler(this.getAttribute('on-not-display'),this);}},_renderConnectBar:function(d){var b=document.createElement('div'),c=document.createElement('div');b.className='fb_connect_bar';c.className='fb_reset fb_connect_bar_container';c.appendChild(b);document.body.appendChild(c);this._container=c;this._initialHeight=Math.round(parseFloat(FB.Dom.getStyle(c,'height'))+parseFloat(FB.Dom.getStyle(c,'borderBottomWidth')));b.innerHTML=FB.String.format('
'+''+'{2}'+''+'
'+''+'{4}'+''+'{5}'+' '+'{6} – '+'{0}'+'',FB.Intl._tx("No Thanks"),FB.getDomain('cdn')+FB.XFBML.ConnectBar.imgs.buttonUrl,FB.Intl._tx("Close"),d[this._picFieldName]||FB.getDomain('cdn')+FB.XFBML.ConnectBar.imgs.missingProfileUrl,FB.String.escapeHTML(d.first_name),FB.Intl._tx("Hi {firstName}. \u003cstrong>{siteName}\u003c\/strong> is using Facebook to personalize your experience.",{firstName:FB.String.escapeHTML(d.first_name),siteName:FB.String.escapeHTML(d.site_name)}),FB.Intl._tx("Learn More"),d.profile_url,FB.getDomain('www')+'sitetour/connect.php');var a=this;FB.Array.forEach(b.getElementsByTagName('a'),function(g){g.onclick=FB.bind(a._clickHandler,a);});this._page=document.body;var f=0;if(this._page.parentNode){f=Math.round((parseFloat(FB.Dom.getStyle(this._page.parentNode,'height'))-parseFloat(FB.Dom.getStyle(this._page,'height')))/2);}else f=parseInt(FB.Dom.getStyle(this._page,'marginTop'),10);f=isNaN(f)?0:f;this._initTopMargin=f;if(!window.XMLHttpRequest){c.className+=" fb_connect_bar_container_ie6";}else{c.style.top=(-1*this._initialHeight)+'px';FB.Anim.ate(c,{top:'0px'},this._animationSpeed);}var e={marginTop:this._initTopMargin+this._initialHeight+'px'};if(FB.Dom.getBrowserType()=='ie'){e.backgroundPositionY=this._initialHeight+'px';}else e.backgroundPosition='? '+this._initialHeight+'px';FB.Anim.ate(this._page,e,this._animationSpeed);},_clickHandler:function(a){a=a||window.event;var b=a.target||a.srcElement;while(b.nodeName!='A')b=b.parentNode;switch(b.className){case 'fb_bar_close':FB.api({method:'Connect.connectBarMarkAcknowledged'});FB.Insights.impression({lid:104,name:'widget_user_closed'});this._closeConnectBar();break;case 'fb_learn_more':case 'fb_profile':window.open(b.href);break;case 'fb_no_thanks':this._closeConnectBar();FB.api({method:'Connect.connectBarMarkAcknowledged'});FB.Insights.impression({lid:104,name:'widget_user_no_thanks'});FB.api({method:'auth.revokeAuthorization',block:true},this.bind(function(){this.fire('connectbar.ondeauth');FB.Event.fire('connectbar.ondeauth',this);FB.Helper.invokeHandler(this.getAttribute('on-deauth'),this);if(this._getBoolAttribute('auto-refresh',true))window.location.reload();}));break;}return false;},_closeConnectBar:function(){this._notDisplayed=true;var a={marginTop:this._initTopMargin+'px'};if(FB.Dom.getBrowserType()=='ie'){a.backgroundPositionY='0px';}else a.backgroundPosition='? 0px';var b=(this._animationSpeed==0)?0:300;FB.Anim.ate(this._page,a,b);FB.Anim.ate(this._container,{top:(-1*this._initialHeight)+'px'},b,function(c){c.parentNode.removeChild(c);});this.fire('connectbar.onclose');FB.Event.fire('connectbar.onclose',this);FB.Helper.invokeHandler(this.getAttribute('on-close'),this);}});FB.provide('XFBML.ConnectBar',{imgs:{buttonUrl:'images/facebook-widgets/close_btn.png',missingProfileUrl:'pics/q_silhouette.gif'}}); -FB.subclass('XFBML.Facepile','XFBML.IframeWidget',null,{_visibleAfter:'load',_extraParams:{},setupAndValidate:function(){this._attr={href:this.getAttribute('href'),channel:this.getChannelUrl(),max_rows:this.getAttribute('max-rows'),width:this._getPxAttribute('width',200),ref:this.getAttribute('ref')};for(var a in this._extraParams)this._attr[a]=this._extraParams[a];return true;},setExtraParams:function(a){this._extraParams=a;},oneTimeSetup:function(){var a=FB._userStatus;FB.Event.subscribe('auth.statusChange',FB.bind(function(b){if(a=='connected'||b.status=='connected')this.process(true);a=b.status;},this));},getSize:function(){return {width:this._attr.width,height:70};},getUrlBits:function(){return {name:'facepile',params:this._attr};}}); -FB.subclass('XFBML.Fan','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={api_key:FB._apiKey,connections:this.getAttribute('connections','10'),css:this.getAttribute('css'),height:this._getPxAttribute('height'),id:this.getAttribute('profile-id'),logobar:this._getBoolAttribute('logo-bar'),name:this.getAttribute('name'),stream:this._getBoolAttribute('stream',true),width:this._getPxAttribute('width',300)};if(!this._attr.id&&!this._attr.name){FB.log(' requires one of the "id" or "name" attributes.');return false;}var a=this._attr.height;if(!a)if((!this._attr.connections||this._attr.connections==='0')&&!this._attr.stream){a=65;}else if(!this._attr.connections||this._attr.connections==='0'){a=375;}else if(!this._attr.stream){a=250;}else a=550;if(this._attr.logobar)a+=25;this._attr.height=a;return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'fan',params:this._attr};}}); -FB.subclass('XFBML.Friendpile','XFBML.Facepile',null,{}); -FB.subclass('XFBML.EdgeCommentWidget','XFBML.IframeWidget',function(a){this._iframeWidth=a.width;this._iframeHeight=a.height;this._attr={master_frame_name:a.masterFrameName};this.dom=a.commentNode;this.dom.style.top=a.relativeHeightOffset;if(a.relativeWidthOffset)if(FB._localeIsRtl){this.dom.style.right=a.relativeWidthOffset;}else this.dom.style.left=a.relativeWidthOffset;this.dom.style.zIndex=FB.XFBML.EdgeCommentWidget.NextZIndex++;FB.Dom.addCss(this.dom,'fb_edge_comment_widget');},{_visibleAfter:'load',_showLoader:false,getSize:function(){return {width:this._iframeWidth,height:this._iframeHeight};},getUrlBits:function(){return {name:'comment_widget_shell',params:this._attr};}});FB.provide('XFBML.EdgeCommentWidget',{NextZIndex:10000}); -FB.subclass('XFBML.EdgeWidget','XFBML.IframeWidget',null,{_visibleAfter:'immediate',_showLoader:false,setupAndValidate:function(){FB.Dom.addCss(this.dom,'fb_edge_widget_with_comment');this._attr={channel_url:this.getChannelUrl(),debug:this._getBoolAttribute('debug'),href:this.getAttribute('href',window.location.href),is_permalink:this._getBoolAttribute('is-permalink'),node_type:this.getAttribute('node-type','link'),width:this._getWidgetWidth(),font:this.getAttribute('font'),layout:this._getLayout(),colorscheme:this.getAttribute('color-scheme'),action:this.getAttribute('action'),ref:this.getAttribute('ref'),show_faces:this._shouldShowFaces(),no_resize:this._getBoolAttribute('no_resize')};return true;},oneTimeSetup:function(){this.subscribe('xd.edgeCreated',FB.bind(this._onEdgeCreate,this));this.subscribe('xd.edgeRemoved',FB.bind(this._onEdgeRemove,this));this.subscribe('xd.presentEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogPresentation,this));this.subscribe('xd.dismissEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogDismissal,this));this.subscribe('xd.hideEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogHide,this));this.subscribe('xd.showEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogShow,this));},getSize:function(){return {width:this._getWidgetWidth(),height:this._getWidgetHeight()};},_getWidgetHeight:function(){var a=this._getLayout();var c=this._shouldShowFaces()?'show':'hide';var b={standard:{show:80,hide:35},box_count:{show:65,hide:65},button_count:{show:21,hide:21}};return b[a][c];},_getWidgetWidth:function(){var e=this._getLayout();var g=this._shouldShowFaces()?'show':'hide';var c=this.getAttribute('action')==='recommend'?130:90;var b=this.getAttribute('action')==='recommend'?100:55;var f={standard:{show:450,hide:450},box_count:{show:b,hide:b},button_count:{show:c,hide:c}};var d=f[e][g];var h=this._getPxAttribute('width',d);var a={standard:{min:225,max:900},box_count:{min:b,max:900},button_count:{min:c,max:900}};if(ha[e].max)h=a[e].max;return h;},_getLayout:function(){return this._getAttributeFromList('layout','standard',['standard','button_count','box_count']);},_shouldShowFaces:function(){return this._getLayout()==='standard'&&this._getBoolAttribute('show-faces',true);},_handleEdgeCommentDialogPresentation:function(b){if(!this.isValid())return;var a=document.createElement('span');this._commentSlave=this._createEdgeCommentWidget(b,a);this.dom.appendChild(a);this._commentSlave.process();this._commentWidgetNode=a;},_createEdgeCommentWidget:function(b,a){var c={commentNode:a,externalUrl:b.externalURL,width:330,height:200,masterFrameName:b.masterFrameName,layout:this._getLayout(),relativeHeightOffset:this._getHeightOffset(),relativeWidthOffset:this._getWidthOffset(b)};return new FB.XFBML.EdgeCommentWidget(c);},_getHeightOffset:function(){var a=this._getLayout();var b={standard:'20px',button_count:'17px',box_count:'-5px'};return b[a];},_getWidthOffset:function(c){if(c.preComputedWidthOffset)return parseInt(c.preComputedWidthOffset,10)+'px';var a=this._getLayout();var b={standard:'17px',box_count:'0px',button_count:'0px'};return b[a];},_handleEdgeCommentDialogDismissal:function(a){if(this._commentWidgetNode){this.dom.removeChild(this._commentWidgetNode);delete this._commentWidgetNode;}},_handleEdgeCommentDialogHide:function(){if(this._commentWidgetNode)this._commentWidgetNode.style.display="none";},_handleEdgeCommentDialogShow:function(){if(this._commentWidgetNode)this._commentWidgetNode.style.display="block";},_fireEventAndInvokeHandler:function(b,a){FB.Helper.fireEvent(b,this);FB.Helper.invokeHandler(this.getAttribute(a),this,[this._attr.href]);},_onEdgeCreate:function(){this._fireEventAndInvokeHandler('edge.create','on-create');},_onEdgeRemove:function(){this._fireEventAndInvokeHandler('edge.remove','on-remove');}}); -FB.subclass('XFBML.Like','XFBML.EdgeWidget',null,{getUrlBits:function(){return {name:'like',params:this._attr};},getIframeTitle:function(){return 'Like this content on Facebook.';}}); -FB.subclass('XFBML.LikeBox','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={channel:this.getChannelUrl(),api_key:FB._apiKey,connections:this.getAttribute('connections'),css:this.getAttribute('css'),height:this.getAttribute('height'),id:this.getAttribute('profile-id'),header:this._getBoolAttribute('header',true),name:this.getAttribute('name'),show_faces:this._getBoolAttribute('show-faces',true),stream:this._getBoolAttribute('stream',true),width:this._getPxAttribute('width',300),href:this.getAttribute('href'),colorscheme:this.getAttribute('colorscheme','light')};if(this._attr.connections==='0'){this._attr.show_faces=false;}else if(this._attr.connections)this._attr.show_faces=true;if(!this._attr.id&&!this._attr.name&&!this._attr.href){FB.log(' requires one of the "id" or "name" attributes.');return false;}var a=this._attr.height;if(!a)if(!this._attr.show_faces&&!this._attr.stream){a=62;}else{a=95;if(this._attr.show_faces)a+=163;if(this._attr.stream)a+=300;if(this._attr.header&&this._attr.header!=='0')a+=32;}this._attr.height=a;this.subscribe('xd.likeboxLiked',FB.bind(this._onLiked,this));this.subscribe('xd.likeboxUnliked',FB.bind(this._onUnliked,this));return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'likebox',params:this._attr};},_onLiked:function(){FB.Helper.fireEvent('edge.create',this);},_onUnliked:function(){FB.Helper.fireEvent('edge.remove',this);}}); -FB.subclass('XFBML.LiveStream','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={height:this._getPxAttribute('height',500),hideFriendsTab:this.getAttribute('hide-friends-tab'),redesigned:this._getBoolAttribute('redesigned-stream'),width:this._getPxAttribute('width',400),xid:this.getAttribute('xid','default'),always_post_to_friends:this._getBoolAttribute('always-post-to-friends',false)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){var a=this._attr.redesigned?'live_stream_box':'livefeed';return {name:a,params:this._attr};}}); -FB.subclass('XFBML.Login','XFBML.Facepile',null,{_visibleAfter:'load',getSize:function(){return {width:this._attr.width,height:94};},getUrlBits:function(){return {name:'login',params:this._attr};}}); -FB.subclass('XFBML.LoginButton','XFBML.ButtonElement',null,{setupAndValidate:function(){if(this._alreadySetup)return true;this._alreadySetup=true;this._attr={autologoutlink:this._getBoolAttribute('auto-logout-link'),length:this._getAttributeFromList('length','short',['long','short']),onlogin:this.getAttribute('on-login'),perms:this.getAttribute('perms'),registration_url:this.getAttribute('registration-url'),status:'unknown'};if(this._attr.autologoutlink)FB.Event.subscribe('auth.statusChange',FB.bind(this.process,this));if(this._attr.registration_url){FB.Event.subscribe('auth.statusChange',this._saveStatus(this.process));FB.getLoginStatus(this._saveStatus(this.process));}return true;},getButtonMarkup:function(){var a=this.getOriginalHTML();if(a)return a;if(!this._attr.registration_url){if(FB.getSession()&&this._attr.autologoutlink){return FB.Intl._tx("Facebook Logout");}else return this._getLoginText();}else switch(this._attr.status){case 'unknown':return this._getLoginText();case 'notConnected':return FB.Intl._tx("Register");case 'connected':if(FB.getSession()&&this._attr.autologoutlink)return FB.Intl._tx("Facebook Logout");return this._getLoginText();default:FB.log('Unknown status: '+this.status);return FB.Intl._tx("Login");}},_getLoginText:function(){return this._attr.length=='short'?FB.Intl._tx("Login"):FB.Intl._tx("Login with Facebook");},onClick:function(){if(!this._attr.registration_url){if(!FB.getSession()||!this._attr.autologoutlink){FB.login(FB.bind(this._authCallback,this),{perms:this._attr.perms});}else FB.logout(FB.bind(this._authCallback,this));}else switch(this._attr.status){case 'unknown':FB.ui({method:'auth.loginToFacebook'},FB.bind(function(a){FB.getLoginStatus(this._saveStatus(this._authCallback),true);},this));break;case 'notConnected':window.top.location=this._attr.registration_url;break;case 'connected':if(!FB.getSession()||!this._attr.autologoutlink){this._authCallback();}else FB.logout(FB.bind(this._authCallback,this));break;default:FB.log('Unknown status: '+this.status);}},_authCallback:function(a){FB.Helper.invokeHandler(this._attr.onlogin,this,[a]);},_saveStatus:function(a){return FB.bind(function(b){this._attr.status=b.status;if(a){a=this.bind(a,this);return a(b);}},this);}}); -FB.subclass('XFBML.Name','XFBML.Element',null,{process:function(){FB.copy(this,{_uid:this.getAttribute('uid'),_firstnameonly:this._getBoolAttribute('first-name-only'),_lastnameonly:this._getBoolAttribute('last-name-only'),_possessive:this._getBoolAttribute('possessive'),_reflexive:this._getBoolAttribute('reflexive'),_objective:this._getBoolAttribute('objective'),_linked:this._getBoolAttribute('linked',true),_subjectId:this.getAttribute('subject-id')});if(!this._uid){FB.log('"uid" is a required attribute for ');this.fire('render');return;}var b=[];if(this._firstnameonly){b.push('first_name');}else if(this._lastnameonly){b.push('last_name');}else b.push('name');if(this._subjectId){b.push('sex');if(this._subjectId==FB.Helper.getLoggedInUser())this._reflexive=true;}var a;FB.Event.monitor('auth.statusChange',this.bind(function(){if(!this.isValid()){this.fire('render');return true;}if(!this._uid||this._uid=='loggedinuser')this._uid=FB.Helper.getLoggedInUser();if(!this._uid)return;if(FB.Helper.isUser(this._uid)){a=FB.Data._selectByIndex(b,'user','uid',this._uid);}else a=FB.Data._selectByIndex(['name','id'],'profile','id',this._uid);a.wait(this.bind(function(c){if(this._subjectId==this._uid){this._renderPronoun(c[0]);}else this._renderOther(c[0]);this.fire('render');}));}));},_renderPronoun:function(b){var c='',a=this._objective;if(this._subjectId){a=true;if(this._subjectId===this._uid)this._reflexive=true;}if(this._uid==FB.Connect.get_loggedInUser()&&this._getBoolAttribute('use-you',true)){if(this._possessive){if(this._reflexive){c='your own';}else c='your';}else if(this._reflexive){c='yourself';}else c='you';}else switch(b.sex){case 'male':if(this._possessive){c=this._reflexive?'his own':'his';}else if(this._reflexive){c='himself';}else if(a){c='him';}else c='he';break;case 'female':if(this._possessive){c=this._reflexive?'her own':'her';}else if(this._reflexive){c='herself';}else if(a){c='her';}else c='she';break;default:if(this._getBoolAttribute('use-they',true)){if(this._possessive){if(this._reflexive){c='their own';}else c='their';}else if(this._reflexive){c='themselves';}else if(a){c='them';}else c='they';}else if(this._possessive){if(this._reflexive){c='his/her own';}else c='his/her';}else if(this._reflexive){c='himself/herself';}else if(a){c='him/her';}else c='he/she';break;}if(this._getBoolAttribute('capitalize',false))c=FB.Helper.upperCaseFirstChar(c);this.dom.innerHTML=c;},_renderOther:function(c){if(!c)return;var b='',a='';if(this._uid==FB.Helper.getLoggedInUser()&&this._getBoolAttribute('use-you',true)){if(this._reflexive){if(this._possessive){b='your own';}else b='yourself';}else if(this._possessive){b='your';}else b='you';}else{if(null===c.first_name)c.first_name='';if(null===c.last_name)c.last_name='';if(this._firstnameonly){b=FB.String.escapeHTML(c.first_name);}else if(this._lastnameonly)b=FB.String.escapeHTML(c.last_name);if(!b)b=FB.String.escapeHTML(c.name);if(b!==''&&this._possessive)b+='\'s';}if(!b)b=FB.String.escapeHTML(this.getAttribute('if-cant-see','Facebook User'));if(b){if(this._getBoolAttribute('capitalize',false))b=FB.Helper.upperCaseFirstChar(b);if(this._linked){a=FB.Helper.getProfileLink(c,b,this.getAttribute('href',null));}else a=b;}this.dom.innerHTML=a;}}); -FB.subclass('XFBML.ProfilePic','XFBML.Element',null,{process:function(){var d=this.getAttribute('size','thumb'),b=FB.XFBML.ProfilePic._sizeToPicFieldMap[d],g=this._getPxAttribute('width'),a=this._getPxAttribute('height'),e=this.dom.style,f=this.getAttribute('uid');if(this._getBoolAttribute('facebook-logo'))b+='_with_logo';if(g){g=g+'px';e.width=g;}if(a){a=a+'px';e.height=a;}var c=this.bind(function(j){var l=j?j[0]:null,i=l?l[b]:null;if(!i)i=FB.getDomain('cdn')+FB.XFBML.ProfilePic._defPicMap[b];var k=((g?'width:'+g+';':'')+(a?'height:'+g+';':'')),h=FB.String.format('{1}',i,l?FB.String.escapeHTML(l.name):'',k,this.dom.className);if(this._getBoolAttribute('linked',true))h=FB.Helper.getProfileLink(l,h,this.getAttribute('href',null));this.dom.innerHTML=h;FB.Dom.addCss(this.dom,'fb_profile_pic_rendered');this.fire('render');});FB.Event.monitor('auth.statusChange',this.bind(function(){if(!this.isValid()){this.fire('render');return true;}if(this.getAttribute('uid',null)=='loggedinuser')f=FB.Helper.getLoggedInUser();if(FB._userStatus&&f){FB.Data._selectByIndex(['name',b],FB.Helper.isUser(f)?'user':'profile',FB.Helper.isUser(f)?'uid':'id',f).wait(c);}else c();}));}});FB.provide('XFBML.ProfilePic',{_defPicMap:{pic:'pics/s_silhouette.jpg',pic_big:'pics/d_silhouette.gif',pic_big_with_logo:'pics/d_silhouette_logo.gif',pic_small:'pics/t_silhouette.jpg',pic_small_with_logo:'pics/t_silhouette_logo.gif',pic_square:'pics/q_silhouette.gif',pic_square_with_logo:'pics/q_silhouette_logo.gif',pic_with_logo:'pics/s_silhouette_logo.gif'},_sizeToPicFieldMap:{n:'pic_big',normal:'pic_big',q:'pic_square',s:'pic',small:'pic',square:'pic_square',t:'pic_small',thumb:'pic_small'}}); -FB.subclass('XFBML.Recommendations','XFBML.IframeWidget',null,{_visibleAfter:'load',_refreshOnAuthChange:true,setupAndValidate:function(){this._attr={border_color:this.getAttribute('border-color'),colorscheme:this.getAttribute('color-scheme'),filter:this.getAttribute('filter'),font:this.getAttribute('font'),header:this._getBoolAttribute('header'),height:this._getPxAttribute('height',300),site:this.getAttribute('site',location.hostname),width:this._getPxAttribute('width',300)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'recommendations',params:this._attr};}}); -FB.subclass('XFBML.Registration','XFBML.IframeWidget',null,{_visibleAfter:'immediate',_baseHeight:167,_fieldHeight:28,_skinnyWidth:520,_skinnyBaseHeight:173,_skinnyFieldHeight:52,setupAndValidate:function(){this._attr={channel_url:this.getChannelUrl(),client_id:FB._apiKey,fb_only:this._getBoolAttribute('fb-only',false),fields:this.getAttribute('fields'),height:this._getPxAttribute('height'),redirect_uri:this.getAttribute('redirect-uri',window.location.href),onvalidate:this.getAttribute('onvalidate'),width:this._getPxAttribute('width',600)};if(this._attr.onvalidate)this.subscribe('xd.validate',this.bind(function(b){var d=FB.JSON.parse(b.value);var a=this.bind(function(e){FB.Arbiter.inform('Registration.Validation',{errors:e,id:b.id},'parent.frames["'+this.getIframeNode().name+'"]');});var c=FB.Helper.executeFunctionByName(this._attr.onvalidate,d,a);if(c)a(c);}));return true;},getSize:function(){return {width:this._attr.width,height:this._getHeight()};},_getHeight:function(){if(this._attr.height)return this._attr.height;var b;if(!this._attr.fields){b=['name'];}else try{b=FB.JSON.parse(this._attr.fields);}catch(a){b=this._attr.fields.split(/,/);}if(this._attr.width requires the "fbml" attribute.');return false;}return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'serverfbml',params:this._attr};}}); -FB.subclass('XFBML.ShareButton','XFBML.Element',null,{process:function(){this._href=this.getAttribute('href',window.location.href);this._type=this.getAttribute('type','icon_link');FB.Dom.addCss(this.dom,'fb_share_count_hidden');this._renderButton(true);},_renderButton:function(f){if(!this.isValid()){this.fire('render');return;}var b='',c='',d='',a='',e=FB.Intl._tx("Share"),g='';switch(this._type){case 'icon':case 'icon_link':a='fb_button_simple';b=(''+(this._type=='icon_link'?e:' ')+'');f=false;break;case 'link':b=FB.Intl._tx("Share on Facebook");f=false;break;case 'button':b=''+e+'';a='fb_button fb_button_small';f=false;break;case 'button_count':b=''+e+'';c=(' '+''+this._getCounterMarkup()+'');a='fb_button fb_button_small';break;default:b=''+e+'';d=(' '+''+this._getCounterMarkup()+'');a='fb_button fb_button_small';g='fb_share_count_wrapper';}this.dom.innerHTML=FB.String.format('{4}{3}{5}',g,this._href,a,b,d,c,FB.JSON.stringify({method:'stream.share',u:this._href}));if(!f)this.fire('render');},_getCounterMarkup:function(){if(!this._count)this._count=FB.Data._selectByIndex(['total_count'],'link_stat','url',this._href);var b='0';if(this._count.value!==undefined){if(this._count.value.length>0){var a=this._count.value[0].total_count;if(a>3){FB.Dom.removeCss(this.dom,'fb_share_count_hidden');b=a>=1e+07?Math.round(a/1e+06)+'M':(a>=10000?Math.round(a/1000)+'K':a);}}}else this._count.wait(FB.bind(this._renderButton,this,false));return ''+b+'';}}); -void(0); - - -FB.provide("", {"_domain":{"api":"https:\/\/api.facebook.com\/","api_read":"https:\/\/api-read.facebook.com\/","cdn":"http:\/\/static.ak.fbcdn.net\/","graph":"https:\/\/graph.facebook.com\/","https_cdn":"https:\/\/s-static.ak.fbcdn.net\/","https_staticfb":"https:\/\/s-static.ak.facebook.com\/","https_www":"https:\/\/www.facebook.com\/","staticfb":"http:\/\/static.ak.facebook.com\/","www":"http:\/\/www.facebook.com\/"},"_locale":"en_US","_localeIsRtl":false}, true); -FB.provide("Flash", {"_minVersions":[[10,0,22,87]],"_swfPath":"rsrc.php\/v1\/yF\/r\/Y7YCBKX-HZn.swf"}, true); -FB.provide("XFBML.ConnectBar", {"imgs":{"buttonUrl":"rsrc.php\/yY\/r\/h_Y6u1wrZPW.png","missingProfileUrl":"rsrc.php\/yo\/r\/UlIqmHJn-SK.gif"}}, true); -FB.provide("XFBML.ProfilePic", {"_defPicMap":{"pic":"rsrc.php\/yh\/r\/C5yt7Cqf3zU.jpg","pic_big":"rsrc.php\/yL\/r\/HsTZSDw4avx.gif","pic_big_with_logo":"rsrc.php\/y5\/r\/SRDCaeCL7hM.gif","pic_small":"rsrc.php\/yi\/r\/odA9sNLrE86.jpg","pic_small_with_logo":"rsrc.php\/yD\/r\/k1xiRXKnlGd.gif","pic_square":"rsrc.php\/yo\/r\/UlIqmHJn-SK.gif","pic_square_with_logo":"rsrc.php\/yX\/r\/9dYJBPDHXwZ.gif","pic_with_logo":"rsrc.php\/yu\/r\/fPPR9f2FJ3t.gif"}}, true); -if (FB.Dom && FB.Dom.addCssRules) { FB.Dom.addCssRules(".fb_hidden{position:absolute;top:-10000px;z-index:10001}\n.fb_reset{background:none;border-spacing:0;border:0;color:#000;cursor:auto;direction:ltr;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;font-size:11px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal}\n.fb_link img{border:none}\n.fb_dialog{position:absolute;top:-10000px;z-index:10001}\n.fb_dialog_advanced{background:rgba(82, 82, 82, .7);padding:10px;-moz-border-radius:8px;-webkit-border-radius:8px}\n.fb_dialog_content{background:#fff;color:#333}\n.fb_dialog_close_icon{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 0 transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif);cursor:pointer;display:block;height:15px;position:absolute;right:18px;top:17px;width:15px;top:8px\\9;right:7px\\9}\n.fb_dialog_close_icon:hover{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -15px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif)}\n.fb_dialog_close_icon:active{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -30px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif)}\n.fb_dialog_loader{background-color:#f2f2f2;border:1px solid #606060;font-size:24px;padding:20px}\n.fb_dialog_top_left,\n.fb_dialog_top_right,\n.fb_dialog_bottom_left,\n.fb_dialog_bottom_right{height:10px;width:10px;overflow:hidden;position:absolute}\n.fb_dialog_top_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 0;left:-10px;top:-10px}\n.fb_dialog_top_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -10px;right:-10px;top:-10px}\n.fb_dialog_bottom_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -20px;bottom:-10px;left:-10px}\n.fb_dialog_bottom_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -30px;right:-10px;bottom:-10px}\n.fb_dialog_vert_left,\n.fb_dialog_vert_right,\n.fb_dialog_horiz_top,\n.fb_dialog_horiz_bottom{position:absolute;background:#525252;filter:alpha(opacity=70);opacity:.7}\n.fb_dialog_vert_left,\n.fb_dialog_vert_right{width:10px;height:100\u0025}\n.fb_dialog_vert_left{margin-left:-10px}\n.fb_dialog_vert_right{right:0;margin-right:-10px}\n.fb_dialog_horiz_top,\n.fb_dialog_horiz_bottom{width:100\u0025;height:10px}\n.fb_dialog_horiz_top{margin-top:-10px}\n.fb_dialog_horiz_bottom{bottom:0;margin-bottom:-10px}\n.fb_dialog_iframe{line-height:0}\n.fb_dialog_content .dialog_title{background:#6d84b4;border:1px solid #3b5998;color:#fff;font-size:14px;font-weight:bold;margin:0}\n.fb_dialog_content .dialog_title > span{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zd\/r\/Cou7n-nqK52.gif) no-repeat 5px 50\u0025;float:left;padding:5px 0 7px 26px}\n.fb_dialog_content .dialog_content{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/z9\/r\/jKEcVPZFk-2.gif) no-repeat 50\u0025 50\u0025;border:1px solid #555;border-bottom:0;border-top:0;height:150px}\n.fb_dialog_content .dialog_footer{background:#f2f2f2;border:1px solid #555;border-top-color:#ccc;height:40px}\n#fb_dialog_loader_close{float:right}\n.fb_iframe_widget{position:relative;display:-moz-inline-block;display:inline-block}\n.fb_iframe_widget iframe{position:relative;vertical-align:text-bottom}\n.fb_iframe_widget span{position:relative}\n.fb_hide_iframes iframe{position:relative;left:-10000px}\n.fb_iframe_widget_loader{position:relative;display:inline-block}\n.fb_iframe_widget_loader iframe{min-height:32px;z-index:2;zoom:1}\n.fb_iframe_widget_loader .FB_Loader{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/z9\/r\/jKEcVPZFk-2.gif) no-repeat;height:32px;width:32px;margin-left:-16px;position:absolute;left:50\u0025;z-index:4}\n.fb_button_simple,\n.fb_button_simple_rtl{background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zH\/r\/eIpbnVKI9lR.png);background-repeat:no-repeat;cursor:pointer;outline:none;text-decoration:none}\n.fb_button_simple_rtl{background-position:right 0}\n.fb_button_simple .fb_button_text{margin:0 0 0 20px;padding-bottom:1px}\n.fb_button_simple_rtl .fb_button_text{margin:0 10px 0 0}\na.fb_button_simple:hover .fb_button_text,\na.fb_button_simple_rtl:hover .fb_button_text,\n.fb_button_simple:hover .fb_button_text,\n.fb_button_simple_rtl:hover .fb_button_text{text-decoration:underline}\n.fb_button,\n.fb_button_rtl{background:#29447e url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/FGFbc80dUKj.png);background-repeat:no-repeat;cursor:pointer;display:inline-block;padding:0 0 0 1px;text-decoration:none;outline:none}\n.fb_button .fb_button_text,\n.fb_button_rtl .fb_button_text{background:#5f78ab url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/FGFbc80dUKj.png);border-top:solid 1px #879ac0;border-bottom:solid 1px #1a356e;color:#fff;display:block;font-family:\"lucida grande\",tahoma,verdana,arial,sans-serif;font-weight:bold;padding:2px 6px 3px 6px;margin:1px 1px 0 21px;text-shadow:none}\na.fb_button,\na.fb_button_rtl,\n.fb_button,\n.fb_button_rtl{text-decoration:none}\na.fb_button:active .fb_button_text,\na.fb_button_rtl:active .fb_button_text,\n.fb_button:active .fb_button_text,\n.fb_button_rtl:active .fb_button_text{border-bottom:solid 1px #29447e;border-top:solid 1px #45619d;background:#4f6aa3;text-shadow:none}\n.fb_button_xlarge,\n.fb_button_xlarge_rtl{background-position:left -60px;font-size:24px;line-height:30px}\n.fb_button_xlarge .fb_button_text{padding:3px 8px 3px 12px;margin-left:38px}\na.fb_button_xlarge:active{background-position:left -99px}\n.fb_button_xlarge_rtl{background-position:right -268px}\n.fb_button_xlarge_rtl .fb_button_text{padding:3px 8px 3px 12px;margin-right:39px}\na.fb_button_xlarge_rtl:active{background-position:right -307px}\n.fb_button_large,\n.fb_button_large_rtl{background-position:left -138px;font-size:13px;line-height:16px}\n.fb_button_large .fb_button_text{margin-left:24px;padding:2px 6px 4px 6px}\na.fb_button_large:active{background-position:left -163px}\n.fb_button_large_rtl{background-position:right -346px}\n.fb_button_large_rtl .fb_button_text{margin-right:25px}\na.fb_button_large_rtl:active{background-position:right -371px}\n.fb_button_medium,\n.fb_button_medium_rtl{background-position:left -188px;font-size:11px;line-height:14px}\na.fb_button_medium:active{background-position:left -210px}\n.fb_button_medium_rtl{background-position:right -396px}\n.fb_button_text_rtl,\n.fb_button_medium_rtl .fb_button_text{padding:2px 6px 3px 6px;margin-right:22px}\na.fb_button_medium_rtl:active{background-position:right -418px}\n.fb_button_small,\n.fb_button_small_rtl{background-position:left -232px;font-size:10px;line-height:10px}\n.fb_button_small .fb_button_text{padding:2px 6px 3px;margin-left:17px}\na.fb_button_small:active,\n.fb_button_small:active{background-position:left -250px}\n.fb_button_small_rtl{background-position:right -440px}\n.fb_button_small_rtl .fb_button_text{padding:2px 6px;margin-right:18px}\na.fb_button_small_rtl:active{background-position:right -458px}\n.fb_connect_bar_container div,\n.fb_connect_bar_container span,\n.fb_connect_bar_container a,\n.fb_connect_bar_container img,\n.fb_connect_bar_container strong{background:none;border-spacing:0;border:0;direction:ltr;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal;vertical-align:baseline}\n.fb_connect_bar_container{position:fixed;left:0 !important;right:0 !important;height:42px !important;padding:0 25px !important;margin:0 !important;vertical-align:middle !important;border-bottom:1px solid #333 !important;background:#3b5998 !important;z-index:99999999 !important;overflow:hidden !important}\n.fb_connect_bar_container_ie6{position:absolute;top:expression(document.compatMode==\"CSS1Compat\"? document.documentElement.scrollTop+\"px\":body.scrollTop+\"px\")}\n.fb_connect_bar{position:relative;margin:auto;height:100\u0025;width:100\u0025;padding:6px 0 0 0 !important;background:none;color:#fff !important;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif !important;font-size:13px !important;font-style:normal !important;font-variant:normal !important;font-weight:normal !important;letter-spacing:normal !important;line-height:1 !important;text-decoration:none !important;text-indent:0 !important;text-shadow:none !important;text-transform:none !important;white-space:normal !important;word-spacing:normal !important}\n.fb_connect_bar a:hover{color:#fff}\n.fb_connect_bar .fb_profile img{height:30px;width:30px;vertical-align:middle;margin:0 6px 5px 0}\n.fb_connect_bar div a,\n.fb_connect_bar span,\n.fb_connect_bar span a{color:#bac6da;font-size:11px;text-decoration:none}\n.fb_connect_bar .fb_buttons{float:right;margin-top:7px}\n.fb_edge_widget_with_comment{position:relative;*z-index:1000}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget{position:absolute}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_ltr{left:-4px}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_rtl{left:2px}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget{left:0}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget .FB_Loader{left:10\u0025}\n.fb_share_count_wrapper{position:relative;float:left}\n.fb_share_count{background:#b0b9ec none repeat scroll 0 0;color:#333;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;text-align:center}\n.fb_share_count_inner{background:#e8ebf2;display:block}\n.fb_share_count_right{margin-left:-1px;display:inline-block}\n.fb_share_count_right .fb_share_count_inner{border-top:solid 1px #e8ebf2;border-bottom:solid 1px #b0b9ec;margin:1px 1px 0 1px;font-size:10px;line-height:10px;padding:2px 6px 3px;font-weight:bold}\n.fb_share_count_top{display:block;letter-spacing:-1px;line-height:34px;margin-bottom:7px;font-size:22px;border:solid 1px #b0b9ec}\n.fb_share_count_nub_top{border:none;display:block;position:absolute;left:7px;top:35px;margin:0;padding:0;width:6px;height:7px;background-repeat:no-repeat;background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zU\/r\/bSOHtKbCGYI.png)}\n.fb_share_count_nub_right{border:none;display:inline-block;padding:0;width:5px;height:10px;background-repeat:no-repeat;background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zX\/r\/i_oIVTKMYsL.png);vertical-align:top;background-position:right 5px;z-index:10;left:2px;margin:0 2px 0 0;position:relative}\n.fb_share_no_count{display:none}\n.fb_share_size_Small .fb_share_count_right .fb_share_count_inner{font-size:10px}\n.fb_share_size_Medium .fb_share_count_right .fb_share_count_inner{font-size:11px;padding:2px 6px 3px;letter-spacing:-1px;line-height:14px}\n.fb_share_size_Large .fb_share_count_right .fb_share_count_inner{font-size:13px;line-height:16px;padding:2px 6px 4px;font-weight:normal;letter-spacing:-1px}\n.fb_share_count_hidden .fb_share_count_nub_top,\n.fb_share_count_hidden .fb_share_count_top,\n.fb_share_count_hidden .fb_share_count_nub_right,\n.fb_share_count_hidden .fb_share_count_right{visibility:hidden}\n", ["fb.css.base","fb.css.dialog","fb.css.iframewidget","fb.css.button","fb.css.connectbarwidget","fb.css.edgecommentwidget","fb.css.sendbuttonformwidget","fb.css.sharebutton"]); } \ No newline at end of file diff --git a/animated_image.js b/animated_image.js deleted file mode 100644 index fbec113..0000000 --- a/animated_image.js +++ /dev/null @@ -1,93 +0,0 @@ -// Manages an animated image. Assumes that while it is active, -// get_image is called once per game loop -// Defaults to starting immediately -// Unless you call loop, will only run through the images once -// spec: -// All optional -// anim_rate : the number of frames to display each image -// reverse : whether to go backwards in the images when you reach the end or not - -var animated_image = function(image_name, spec) { - - // obj to return - var obj = []; - - // private vars - - var all_images = image_manager.get_images(image_name); - all_images.sort( - function(i1, i2) { - //return i1.path < i2.path; - return i1.path < i2.path ? -1 : (i1.path > i2.path ? 1 : 0); - } - ); - //for_each(all_images, function(i) { console.log(i.path); }); - var curr_index = 0; - var active = true; - var loop = false; - var rate_counter = 0; // Goes from 0 to anim_rate - 1 - var anim_rate = spec.anim_rate || 3; - - // If we are reversing, add all the images in the opposite - // order to all_images - if (spec.reverse || false) { - for (var i = (all_images.length - 1); i >=0; i--) { - all_images.push(all_images[i]); - } - } - - //public methods - - obj.start = function() { - active = true; - }; - - obj.pause = function() { - active = false; - }; - - obj.loop = function() { - loop = true; - }; - - obj.is_finished = function() { - // changed to && cuz it should be not looping - // and at the end to be finished - return (!loop && curr_index === (all_images.length - 1)); - }; - - // Returns the current image - obj.get_frame = function() { - var curr_image = all_images[curr_index].image; - update(); - return curr_image; - }; - - obj.set_rate = function(r) { - anim_rate = r; - }; - - // private methods - - var update = function() { - if (active) { - if (rate_counter >= (anim_rate - 1)) { - next_frame(); - rate_counter = 0; - } - else { - rate_counter++; - } - } - }; - - var next_frame = function() { - // If not 'at the end and not looping', - // increment curr_index, restarting if we reach the end - if (!(curr_index === all_images.length && !loop)) { - curr_index = (curr_index + 1) % all_images.length; - } - } - - return obj; -} diff --git a/antibody.js b/antibody.js deleted file mode 100644 index 4537cf0..0000000 --- a/antibody.js +++ /dev/null @@ -1,86 +0,0 @@ -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards - -var antibody = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 11; - spec.height = spec.height || 7; - spec.speed = (spec.speed || 4) * g_speed_factor; - spec.no_target_speed = (spec.no_target_speed || 2) * g_speed_factor; - - //spec.vel = random_vel(); - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "antibody"; - }; - - // --- private variables --- - - // flag denoting whether the antibody is attached to a cell - var attached = false; - - // --- public methods --- - - // should be called when an antibody attaches to a cell - // tar will be the cell that it is attaching to (may not be its target) - obj.attach = function(tar) { - attached = true; - obj.face_target(tar); - // scoot it out just a bit - obj.get_vel().mult(-1); - obj.move(); - - //obj.set_target(null); - }; - - // implementing game_object interface - - obj.my_update = function() { - if (!attached) { - obj.set_speed(obj.get_level() / 4 + 1) - obj.move(); - // don't want two antibodies attacking one cell - var tar = obj.get_target(); - if (tar && (tar.has_antibody() - // also don't want them to keep target - // if the target changes level - || tar.get_level() !== obj.get_level() - // or if it starts to die - || tar.get_state() === "dying")) { - obj.set_target(null); - } - } - }; - - // should point towards target - // Y-shaped (top of Y is front) - obj.draw = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.stroke(obj.get_color()); - p.strokeWeight(2); - - p.line(-w, 0, w/3, 0); - p.line(w/3, 0, w, h/2); - p.line(w/3, 0, w, -h/2); - - p.popMatrix(); - }; - - return obj; -} diff --git a/b_cell.js b/b_cell.js deleted file mode 100644 index a40c5e0..0000000 --- a/b_cell.js +++ /dev/null @@ -1,254 +0,0 @@ -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards -// state = just leave to be default (alive) - -var b_cell = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 30; - spec.height = spec.height || 30; - spec.speed = (spec.speed || 5) * g_speed_factor; - - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "b_cell"; - }; - - // --- private variables --- - - var b_anim = animated_image("bcell", {reverse : true}); - // for illustration - var b_image = image_manager.get_image("bcell_normal.png"); - // where to go and shoot from - var slot = null; - - // state can be "alive", "active", "shooting", "outdated" - - // Antibodies are created in update, and returned in get_antibodies() - var new_antibodies = null; - - // --- private methods - - // Makes one antibody and adds it to new_antibodies - var make_antibody = function() { - if (!new_antibodies) { - new_antibodies = []; - } - var obj_pos = obj.get_pos(); - var new_antibody = antibody(p, { - pos : new p.PVector(obj_pos.x, obj_pos.y + (obj.get_height() / 2)), - mutation_info: obj.get_mutation_info() - }); - new_antibodies.push(new_antibody); - return new_antibody; - }; - - - // --- public methods --- - - // Makes this target stop and begin producing antibodies - obj.make_antibodies = function() { - obj.set_state("shooting"); - obj.set_target(null); - // production will happen in update - }; - - // to be called on collision with floater - // takes a slot pos - obj.activate = function(aslot) { - obj.set_state("active"); - slot = aslot; - // send the bcell to the top - obj.set_target(game_object(p, { - pos: slot.pos //new p.PVector(p.width - (obj.get_width() / 2), 0) - })); - }; - - obj.get_slot = function() { - return slot; - }; - - // Returns any newly created antibodies - obj.get_antibodies = function() { - if (new_antibodies) { - var to_return = new_antibodies; - new_antibodies = null; - return to_return; - } - else { - return []; - } - }; - - obj.is_activated = function() { - return obj.get_state() === "active"; - }; - - obj.is_alive = function() { - return obj.get_state() === "alive"; - }; - - obj.is_shooting = function() { - return obj.get_state() === "shooting"; - }; - - obj.get_scroll_dist = function() { - var state = obj.get_state(); - if (state === "shooting" - //|| state === "alive" - || state === "active" ) { - return 0; - } - else if (state === "outdated") { - return obj.DEFAULT_SCROLL_DIST;// * 2; - } - else { - return obj.DEFAULT_SCROLL_DIST; - } - }; - - // implementing game_object interface - - obj.my_update = function() { - if (obj.get_state() === "shooting") { - //obj.stop(); - // make it face downwards - var angle = p.PI/2 - // switch if at bottom - if (!slot.is_top) { - angle = -p.PI/2; - } - obj.set_target_angle(angle); - if (Math.random() < .03) { - var new_anti = make_antibody(); - new_anti.set_target_angle(p.random(0, 2*angle)); - } - } - else { - obj.move(); - } - }; - - var draw_antibody = function() { - // private vars - var counter = 0; - var c_max = 30; - var ascending = true; - - // for illustrations - obj.set_anti_count = function(c) { - counter = c; - }; - - return function(){ - - p.pushMatrix(); - - var pos = obj.get_pos(); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - // Copied from antibody.js to avoid overhead of - // creating new antibody every time - p.stroke(obj.get_color()); - p.strokeWeight(1 + (counter / 6)); - - var w = 11; - var h = 7; - p.line(-w, 0, w / 3, 0); - p.line(w / 3, 0, w, h / 2); - p.line(w / 3, 0, w, -h / 2); - - p.popMatrix(); - - if (!anim_paused) { - if (ascending === true) { - counter++; - } - else if (ascending === false) { - counter--; - } - } - if (counter === c_max) { - ascending = false; - } - else if (counter === 0) { - ascending = true; - } - }; - }(); - - // should point towards target - // (triangle for now) - obj.draw = function() { - /* - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.fill(obj.get_color()); - // If outdated, draw differently? - if (obj.get_state() === "outdated") { - p.fill(0); - } - p.noStroke(); - - // rightward triangle - p.triangle(-w/2, -h/2, -w/2, h/2, w/2, 0); - - p.fill(255); - p.ellipse(-w/4, 0, 10, 10); - - p.popMatrix(); - */ - - p.pushMatrix(); - - var pos = obj.get_pos(); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle() + p.PI / 2); - p.fill(obj.get_color()); - p.noStroke(); - //p.rect(rectx_offset, recty_offset, rect_width, rect_height); - p.imageMode(obj.get_mode()); - - if (!obj.is_illustration()) { - b_image = b_anim.get_frame(); - } - p.image(b_image, 0, 0, obj.get_width(), obj.get_height()); - - p.popMatrix(); - - var state = obj.get_state(); - if (state === "active" || state === "shooting") { - draw_antibody(); - } - }; - - var anim_paused = false; - obj.stop_animation = function() { - b_anim.pause(); - anim_paused = true; - }; - - obj.resume_animation = function() { - b_anim.start(); - anim_paused = false; - }; - - return obj; -} diff --git a/background_edge.js b/background_edge.js deleted file mode 100644 index 6d8bb09..0000000 --- a/background_edge.js +++ /dev/null @@ -1,54 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec -// boolean is_top = true if its a top edge, otherwise false -// - -var background_edge = function(p, spec) { - - //var background_image = p.loadImage("images/background.jpg"); - //var background_image = p.loadImage("images/background1.png"); - var edge = spec.is_top ? - image_manager.get_image("background_topside.png") : - image_manager.get_image("background_bottomside.png"); - - // --- defaults --- - - spec.mode = p.CORNERS; - spec.width = spec.width || edge.width; - spec.height = spec.height || edge.height; - - // if bottom, height should have been set to bottom of screen - // so we need to shift it up - if (!spec.is_top) { - spec.pos.add(new p.PVector(0, -spec.height)); - } - - // obj to return - var obj = background_object(p, spec); - - obj.get_type = function() { - return "background_edge"; - }; - - - // --- private variables --- - - - // --- public methods --- - - // override draw method only - obj.draw = function() { - p.imageMode(obj.get_mode()); - p.image(edge, obj.get_pos().x, obj.get_pos().y); - }; - - // override offscreen check cuz we draw from the corners - obj.is_offscreen = function() { - // only need to check left edge of screen - return obj.get_pos().x + obj.get_width() < 0; - }; - - return obj; -}; - diff --git a/background_object.js b/background_object.js deleted file mode 100644 index 0f96f4e..0000000 --- a/background_object.js +++ /dev/null @@ -1,76 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec -// - -var background_object = function(p, spec) { - - var obj_image = random_from( - image_manager.get_images("background")).image; - - - // --- defaults --- - - spec.mode = spec.mode || p.CENTER; - spec.width = spec.width || obj_image.width; - spec.height = spec.height || obj_image.height; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "background_object"; - }; - - // --- private variables --- - - - // --- public methods --- - - // implementing game_object interface - - // update is default (move) - - // (flat rect for now) - obj.draw = function() { - //var x_pos = obj.get_pos().x; - - //p.fill(p.color(49, 0, 0)); - //p.rect(x_pos, 0, obj.get_width() - x_pos, obj.get_height()); - //background_image.resize(p.width, p.height); - //p.image(background_image, 0, 0); - //console.log(obj.get_pos().x); - p.imageMode(obj.get_mode()); - p.image(obj_image, obj.get_pos().x, obj.get_pos().y); - //p.set(obj.get_pos().x, 0, background_image); - //p.fill(255, 70); - //p.noStroke(); - //p.rect(obj.get_pos().x, 0, obj.get_width(), obj.get_height()); - }; - - // background can't go off screen or die - obj.is_dead = function() { - return false; - }; - /* - obj.is_offscreen = function() { - return false; - }; - */ - //var count = 0; - - obj.scroll = function(scroll_factor) { - // count += 1; - //if (count === 1) { - // count = 0; - obj.get_pos().add(new p.PVector(obj.get_scroll_dist(), 0)); - // } - }; - - obj.get_scroll_dist = function() { - return -1; - }; - - return obj; -}; - diff --git a/button.js b/button.js deleted file mode 100644 index 995dde5..0000000 --- a/button.js +++ /dev/null @@ -1,122 +0,0 @@ -// Have a rectangle representing their position and a state to go to when clicked -// spec: -// state : function that returns a new state to go to when clicked -// (think of it like a thunk) -// rect : spec for a rectangle representing the button - -var button = function(p, spec) { - - // --- defaults --- - //spec.rect.width = spec.rect.width || 100; - //spec.rect.height = spec.rect.height || 35; - - // obj to return - var obj = {}; - - // --- private variables --- - - var next_state_fun = spec.state; - var active = spec.active || true; - - var image = spec.rect.image ? - image_manager.get_image(spec.rect.image) : null; - var over_image = spec.rect.over_image ? - image_manager.get_image(spec.rect.over_image) : null; - - // if no width is given but an image is - // use the image width - if (!spec.rect.width && image) { - spec.rect.width = image.width; - } - // and for height - if (!spec.rect.height && image) { - spec.rect.height = image.height; - } - - var rect = rectangle(p, spec.rect); - - // --- public methods --- - - obj.draw = function() { - if (!active) { - rect.set_tint(100); - /* - var r = spec.rect; - p.noStroke(); - p.fill(0, 150); - p.rectMode(p.CENTER); - p.rect(r.pos.x, r.pos.y, r.width, r.height); - */ - } - else { - //rect.set_tint(255); - } - rect.draw(); - }; - - // makes a button not active - obj.deactivate = function() { - // hack to make sure button tint updates - obj.mouse_moved(-1, -1); - active = false; - }; - - // makes a button active - obj.activate = function() { - // hack to make sure button tint updates - obj.mouse_moved(-1, -1); - active = true; - }; - - // Returns the state to go to if clicked, or - // null if not clicked - obj.is_clicked = function(x, y) { - if (active && rect.is_in(x, y)) { - // after click go back to normal image - if (over_image) { - rect.set_image(image); - } - return obj.get_state(); - } - else { - return null; - } - }; - - // special case for track buttons - obj.click = obj.is_clicked; - - obj.mouse_moved = function(x, y) { - if (active && rect.is_in(x, y)) { - if (over_image) { - rect.set_image(over_image); - } - else { - //rect.set_tint(0); - rect.set_tint(255, 255); - //rect.draw_twice(); - //console.log("tinting"); - } - } - else { - if (!over_image) { - rect.set_tint(200, 255); - } - //rect.draw_once(); - rect.set_image(image); - } - }; - // call once to init button tints - obj.mouse_moved(-1, -1); - - // Returns the state to go to - obj.get_state = function() { - return next_state_fun(); - }; - - obj.get_rect = function() { - return spec.rect; - }; - - return obj; -}; diff --git a/cache.manifest-old b/cache.manifest-old deleted file mode 100644 index 1fbb9e6..0000000 --- a/cache.manifest-old +++ /dev/null @@ -1,9 +0,0 @@ -CACHE MANIFEST -#v .012 -CACHE: -sounds/cell_infect.wav -sounds/cell_fire.wav -#sounds/heart_loop1.mp3 -php_functions.php -NETWORK: -* diff --git a/cell.js b/cell.js deleted file mode 100644 index ebdcaaa..0000000 --- a/cell.js +++ /dev/null @@ -1,345 +0,0 @@ -// *** cell *** -// --- inherits from game_object -// spec: -// game_object spec + -// String state = "alive" or "dead" or "infected" or "active" -// mutation : Mutation_obj so cell can get current mutation color - -var cell = function(p, spec) { - - // --- defaults --- - - // was 40 - spec.width = spec.width || 25; - spec.height = spec.height || 25; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "cell"; - }; - - // --- private variables --- - - // images - var cell_image = random_from( - image_manager.get_images("infectable_cell")).image; - var burst_anim = animated_image("burst", {}); - var infect_anim = animated_image("cell_infect", {}); - - // state can be "alive", "infected", "active", or "dead" - var state = spec.state || "alive"; - // random initial angle - var arrow_angle = p.random(-p.PI/2, p.PI/2); - // random dir (1 or -1) - var arrow_dir = p.random() >= 0.5 ? 1 : -1; - - // indicates whether has been hit by an arrow and is being targeted - //var is_targeted = false; - - // holds an antibody that is attached to the cell, or null - var anti = null; - - // --- public methods --- - - // implementing game_object interface - - // update is different depending on state - obj.update = function() { - obj.move(); - if (state === "alive") { - // just chill - } - else if (state === "infected") { - // still chill - } - else if (state === "active") { - // spin the arrow - rotateArrow(); - } - else if (state === "dying") { - if (burst_anim.is_finished()) { - obj.set_state("dead"); - } - } - /* - else if (state === "dead") { - } - */ - }; - - // draw makes a cell with a different color depending on state - // (circle for now) - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.get_mode()); - - p.noStroke(); - - if (state === "dying") { - // draw frame and advance anim - p.image(burst_anim.get_frame(), pos.x, pos.y, - obj.get_width(), obj.get_height()); - // skip the rest of the method - return; - } - - - if (state === "alive") { - p.fill(p.color(200, 50, 50)); - } - else { - if (state === "infected") { - p.fill(obj.get_color()); - // draw after drawing the image - } - else if (state === "active") { - drawArrow(); - - // Draw a separate circle for the red outline - // so that we can more accurately fill in the cell - // red outline for now - p.stroke(255, 0, 0); - p.strokeWeight(4); - p.ellipse(pos.x, pos.y, obj.get_width(), obj.get_height()); - - p.noStroke(); - p.fill(obj.get_color()); - } - //if (infect_anim.is_finished() || obj.is_illustration()) { - p.ellipse(pos.x, pos.y, obj.get_width() * 4/5, obj.get_height() * 4/5); - //} - } - - p.imageMode(obj.get_mode()); - p.image(cell_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - - if (state === "infected" || state === "active") { - // draw after the image - if (!infect_anim.is_finished() && !obj.is_illustration()) { - // draw frame and advance anim - p.image(infect_anim.get_frame(), pos.x, pos.y, - obj.get_width(), obj.get_height()); - //p.fill(obj.get_color()); - } - } - - /* - else if (state === "dead") { - p.fill(0); - p.ellipse(pos.x, pos.y, - obj.get_width(), obj.get_height()); - } - */ - - }; - - // to be used in illustration only - obj.set_image = function(i) { - cell_image = i; - }; - - obj.get_image = function() { - return cell_image; - }; - - obj.is_dead = function() { - //console.log(burst_anim.is_finished()); - return state === "dead"; - }; - - obj.stop_animation = function() { - burst_anim.pause(); - infect_anim.pause(); - }; - - obj.resume_animation = function() { - burst_anim.start(); - infect_anim.start(); - }; - - obj.set_state = function(s) { - if (s === "infected") { - infect_anim.start(); - } - state = s; - }; - - obj.set_antibody = function(a) { - anti = a; - anti.attach(obj); - }; - - obj.has_antibody = function() { - return (anti !== null); - }; - - obj.get_state = function() { - return state; - }; - - obj.die = function() { - if (anti) { - anti.die(); - } - obj.set_state("dying"); - burst_anim.start(); - }; - - // explodes this cell if it is active - obj.fire = function() { - if (state === "active") { - // Make sounds - sounds.play_sound("cell_fire"); - - obj.die(); - - var pos = obj.get_pos(); - var ang = arrow_angle; - // use width cuz it's a circle - var r = obj.get_width()/2; - - // gen particles at edge of cell for now - var x = r*p.cos(ang) + pos.x; - var y = r*p.sin(ang) + pos.y; - - var num_particles = get_num_particles(); - // angle between all the shots - var range = p.PI/6; - var incr = range/num_particles; - - var particles = []; - - ang = arrow_angle - range/2; - // special case - if (num_particles === 1) { - ang = arrow_angle; - } - while (num_particles > 0) { - var new_vel = new p.PVector(p.cos(ang), p.sin(ang)); - // mult by speed scalar - new_vel.mult(7); - // if we want to add velocity of cell - new_vel.add(obj.get_vel()); - - particles.push(particle(p, { - pos: new p.PVector(x, y), - vel: new_vel, - mutation_info: obj.get_mutation_info() - })); - - num_particles--; - ang += incr; - } - - return particles; - } - throw "Can't fire on "+state+" cell!"; - }; - - // override for circular object - obj.calc_radius = function() { - return obj.get_width()/2; - }; - obj.set_radius(obj.calc_radius()); - - // --- private functions --- - - // rotates according to arrow_dir - // switches direction at certain angles - var rotateArrow = function() { - if (arrow_angle > p.PI/2 - || arrow_angle < -p.PI/2) { - arrow_dir = (2-arrow_dir)-2; - } - arrow_angle += p.radians(5+obj.get_level()/2)*arrow_dir * g_speed_factor; - }; - - var drawArrow = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - - // move to center of circle - p.translate(pos.x, pos.y); - // rotate first - p.rotate(arrow_angle); - // move out to right edge of circle - p.translate(w/2, 0); - - // red outline for now - p.stroke(255, 0, 0); - p.strokeWeight(2); - p.fill(obj.get_color()); - - var x1 = w/2; - // draw facing out to right - p.beginShape(); - p.vertex(0, -5); - p.vertex(x1, -5); - p.vertex(x1, -10); - p.vertex(x1+15, 0); - p.vertex(x1, 10); - p.vertex(x1, 5); - p.vertex(0, 5); - p.endShape(); - - p.popMatrix(); - - // Draw Dots if easy - if (GLOBAL_is_easy) { - var pos = obj.get_pos(); - var ang = arrow_angle; - // use width cuz it's a circle - var r = obj.get_width()/2; - - // gen particles at edge of cell for now - var x = r*p.cos(ang) + pos.x; - var y = r*p.sin(ang) + pos.y; - - var num_particles = get_num_particles(); - // angle between all the shots - var range = p.PI/6; - var incr = range/num_particles; - - ang = arrow_angle - range/2; - // special case - if (num_particles === 1) { - ang = arrow_angle; - } - var num_dots = 5; - while (num_particles > 0) { - var offset = 4; - p.fill(153); - p.noStroke(); - for (var i = 0; i < num_dots; i++) { - x = r*p.cos(ang)*offset + pos.x ; - y = r*p.sin(ang)*offset + pos.y ; - p.ellipse(x, y, 2, 2); - offset += 2; - } - - num_particles--; - ang += incr; - } - } - }; - - var get_num_particles = function() { - - var extra_particles = 0; - var mut_info = obj.get_mutation_info(); - /* - for_each(mut_info.abilities, function(a) { - if (a === "extra_particle") { - extra_particles++; - } - }); - */ - return mut_info.particles + extra_particles; - }; - - return obj; -}; diff --git a/credits_state.js b/credits_state.js deleted file mode 100644 index 9d79008..0000000 --- a/credits_state.js +++ /dev/null @@ -1,59 +0,0 @@ -var credits_state = function(p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var credits_back = image_manager.get_image("creditsscreen.png"); - - // Buttons - - var back_button = button(p, { - state : function() { return prev_state; }, - rect : { - pos : new p.PVector(p.width * (3/4), 500), - width: 120, - height: 50, - image: "back.png", - } - }); - - - //Not ordered - var all_buttons = [ back_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "credits"; - }; - - obj.update = function() { - //do nothing - }; - - obj.render = function() { - // fill the background - p.noStroke(); - p.fill(g.background_color); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.imageMode(p.CENTER); - p.image(credits_back, p.width/2, p.height/2); - }; - - obj.key_pressed = function(k) { - if (p.keyCode === 13 || p.keyCode === 27) { // enter, esc - obj.exit_state(); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/css/styles.css b/css/styles.css deleted file mode 100644 index 44efae4..0000000 --- a/css/styles.css +++ /dev/null @@ -1,60 +0,0 @@ -canvas { - border: 3px solid gray; - z-index: 1; - width: 700; - height: 600; - position: relative; -} -#scores-wrap { - z-index: 2; - /*background: white;*/ - /*color: black;*/ - width: 500; - height: 400; - /* use top/left to center manually */ - /* add in border width */ - left: 103px; - top: 83px; - position: absolute; - /* start hidden */ - display: none; -} -#scores { - height: 430; -} -table.score-table { - border-collapse: collapse; - width: 100%; - background: black; - color: white; - /*padding: 0.2em;*/ -} -.score-table, .score-table tr, .score-table td { - /*color: black;*/ - border: 2px solid #666; - font-size: 14; - text-align: right; -} -.score-table th { - font-size: 16; - text-align: center; - color: #000; - background: #fff; - border: 2px solid #666; - border-top: 5px solid #666; -} -.score-table th, .score-table tr, .score-table td { - padding: 0.2em 0.4em; -} -.Score-header { - width: 120; -} -.Name-header { - width: 140; -} -.Level-header { - width: 50; -} -.Date-header { - width: 100; -} diff --git a/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png b/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png deleted file mode 100755 index 5473aff..0000000 Binary files a/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png and /dev/null differ diff --git a/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png b/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png deleted file mode 100755 index 5950a8d..0000000 Binary files a/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png and /dev/null differ diff --git a/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png b/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png deleted file mode 100755 index 1ad224a..0000000 Binary files a/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png and /dev/null differ diff --git a/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png b/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png deleted file mode 100755 index 1cf1cac..0000000 Binary files a/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png and /dev/null differ diff --git a/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png b/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png deleted file mode 100755 index 35ec0d9..0000000 Binary files a/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png and /dev/null differ diff --git a/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png b/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png deleted file mode 100755 index b1b03b6..0000000 Binary files a/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png and /dev/null differ diff --git a/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png b/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png deleted file mode 100755 index e56eefd..0000000 Binary files a/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png and /dev/null differ diff --git a/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png b/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png deleted file mode 100755 index 3525eb9..0000000 Binary files a/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png and /dev/null differ diff --git a/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png b/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png deleted file mode 100755 index 2b6a9f9..0000000 Binary files a/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png and /dev/null differ diff --git a/css/ui-darkness/images/ui-icons_222222_256x240.png b/css/ui-darkness/images/ui-icons_222222_256x240.png deleted file mode 100755 index b273ff1..0000000 Binary files a/css/ui-darkness/images/ui-icons_222222_256x240.png and /dev/null differ diff --git a/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png b/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png deleted file mode 100755 index c5d93b6..0000000 Binary files a/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png and /dev/null differ diff --git a/css/ui-darkness/images/ui-icons_a83300_256x240.png b/css/ui-darkness/images/ui-icons_a83300_256x240.png deleted file mode 100755 index 95993ea..0000000 Binary files a/css/ui-darkness/images/ui-icons_a83300_256x240.png and /dev/null differ diff --git a/css/ui-darkness/images/ui-icons_cccccc_256x240.png b/css/ui-darkness/images/ui-icons_cccccc_256x240.png deleted file mode 100755 index 9254e05..0000000 Binary files a/css/ui-darkness/images/ui-icons_cccccc_256x240.png and /dev/null differ diff --git a/css/ui-darkness/images/ui-icons_ffffff_256x240.png b/css/ui-darkness/images/ui-icons_ffffff_256x240.png deleted file mode 100755 index 42f8f99..0000000 Binary files a/css/ui-darkness/images/ui-icons_ffffff_256x240.png and /dev/null differ diff --git a/css/ui-darkness/jquery-ui-1.8.9.custom.css b/css/ui-darkness/jquery-ui-1.8.9.custom.css deleted file mode 100755 index 164af9f..0000000 --- a/css/ui-darkness/jquery-ui-1.8.9.custom.css +++ /dev/null @@ -1,312 +0,0 @@ -/* - * jQuery UI CSS Framework 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - */ - -/* Layout helpers -----------------------------------*/ -.ui-helper-hidden { display: none; } -.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } -.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } -.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } -.ui-helper-clearfix { display: inline-block; } -/* required comment for clearfix to work in Opera \*/ -* html .ui-helper-clearfix { height:1%; } -.ui-helper-clearfix { display:block; } -/* end clearfix */ -.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } - - -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { cursor: default !important; } - - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } - - -/* - * jQuery UI CSS Framework 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - * - * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Segoe%20UI,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=6px&bgColorHeader=333333&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=25&borderColorHeader=333333&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=000000&bgTextureContent=05_inset_soft.png&bgImgOpacityContent=25&borderColorContent=666666&fcContent=ffffff&iconColorContent=cccccc&bgColorDefault=555555&bgTextureDefault=02_glass.png&bgImgOpacityDefault=20&borderColorDefault=666666&fcDefault=eeeeee&iconColorDefault=cccccc&bgColorHover=0078a3&bgTextureHover=02_glass.png&bgImgOpacityHover=40&borderColorHover=59b4d4&fcHover=ffffff&iconColorHover=ffffff&bgColorActive=f58400&bgTextureActive=05_inset_soft.png&bgImgOpacityActive=30&borderColorActive=ffaf0f&fcActive=ffffff&iconColorActive=222222&bgColorHighlight=eeeeee&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=80&borderColorHighlight=cccccc&fcHighlight=2e7db2&iconColorHighlight=4b8e0b&bgColorError=ffc73d&bgTextureError=02_glass.png&bgImgOpacityError=40&borderColorError=ffb73d&fcError=111111&iconColorError=a83300&bgColorOverlay=5c5c5c&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=50&opacityOverlay=80&bgColorShadow=cccccc&bgTextureShadow=01_flat.png&bgImgOpacityShadow=30&opacityShadow=60&thicknessShadow=7px&offsetTopShadow=-7px&offsetLeftShadow=-7px&cornerRadiusShadow=8px - */ - - -/* Component containers -----------------------------------*/ -.ui-widget { font-family: Segoe UI, Arial, sans-serif; font-size: 1.1em; } -.ui-widget .ui-widget { font-size: 1em; } -.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Segoe UI, Arial, sans-serif; font-size: 1em; } -.ui-widget-content { border: 1px solid #666666; background: #000000 url(images/ui-bg_inset-soft_25_000000_1x100.png) 50% bottom repeat-x; color: #ffffff; } -.ui-widget-content a { color: #ffffff; } -.ui-widget-header { border: 1px solid #333333; background: #333333 url(images/ui-bg_gloss-wave_25_333333_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; } -.ui-widget-header a { color: #ffffff; } - -/* Interaction states -----------------------------------*/ -.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #666666; background: #555555 url(images/ui-bg_glass_20_555555_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #eeeeee; } -.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #eeeeee; text-decoration: none; } -.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #59b4d4; background: #0078a3 url(images/ui-bg_glass_40_0078a3_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #ffffff; } -.ui-state-hover a, .ui-state-hover a:hover { color: #ffffff; text-decoration: none; } -.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #ffaf0f; background: #f58400 url(images/ui-bg_inset-soft_30_f58400_1x100.png) 50% 50% repeat-x; font-weight: bold; color: #ffffff; } -.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #ffffff; text-decoration: none; } -.ui-widget :active { outline: none; } - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #cccccc; background: #eeeeee url(images/ui-bg_highlight-soft_80_eeeeee_1x100.png) 50% top repeat-x; color: #2e7db2; } -.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #2e7db2; } -.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #ffb73d; background: #ffc73d url(images/ui-bg_glass_40_ffc73d_1x400.png) 50% 50% repeat-x; color: #111111; } -.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #111111; } -.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #111111; } -.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } -.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } -.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_cccccc_256x240.png); } -.ui-widget-content .ui-icon {background-image: url(images/ui-icons_cccccc_256x240.png); } -.ui-widget-header .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); } -.ui-state-default .ui-icon { background-image: url(images/ui-icons_cccccc_256x240.png); } -.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); } -.ui-state-active .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); } -.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_4b8e0b_256x240.png); } -.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_a83300_256x240.png); } - -/* positioning */ -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-off { background-position: -96px -144px; } -.ui-icon-radio-on { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-start { background-position: -80px -160px; } -/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-tl { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px; } -.ui-corner-tr { -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px; } -.ui-corner-bl { -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; } -.ui-corner-br { -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } -.ui-corner-top { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px; -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px; } -.ui-corner-bottom { -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } -.ui-corner-right { -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px; -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } -.ui-corner-left { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px; -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; } -.ui-corner-all { -moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px; } - -/* Overlays */ -.ui-widget-overlay { background: #5c5c5c url(images/ui-bg_flat_50_5c5c5c_40x100.png) 50% 50% repeat-x; opacity: .80;filter:Alpha(Opacity=80); } -.ui-widget-shadow { margin: -7px 0 0 -7px; padding: 7px; background: #cccccc url(images/ui-bg_flat_30_cccccc_40x100.png) 50% 50% repeat-x; opacity: .60;filter:Alpha(Opacity=60); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/* - * jQuery UI Tabs 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Tabs#theming - */ -.ui-tabs { position: relative; /*padding: .2em;*/ zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ -.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; } -.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; } -.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; } -.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */ -.ui-tabs .ui-tabs-panel { display: block; border-width: 0;/* padding: 1em 1.4em;*/ background: none; } -.ui-tabs .ui-tabs-hide { display: none !important; } diff --git a/date.format.js b/date.format.js deleted file mode 100644 index 3992c50..0000000 --- a/date.format.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Date Format 1.2.3 - * (c) 2007-2009 Steven Levithan - * MIT license - * - * Includes enhancements by Scott Trenda - * and Kris Kowal - * - * Accepts a date, a mask, or a date and a mask. - * Returns a formatted version of the given date. - * The date defaults to the current date/time. - * The mask defaults to dateFormat.masks.default. - */ - -var dateFormat = function () { - var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, - timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, - timezoneClip = /[^-+\dA-Z]/g, - pad = function (val, len) { - val = String(val); - len = len || 2; - while (val.length < len) val = "0" + val; - return val; - }; - - // Regexes and supporting functions are cached through closure - return function (date, mask, utc) { - var dF = dateFormat; - - // You can't provide utc if you skip other args (use the "UTC:" mask prefix) - if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { - mask = date; - date = undefined; - } - - // Passing date through Date applies Date.parse, if necessary - date = date ? new Date(date) : new Date; - if (isNaN(date)) throw SyntaxError("invalid date"); - - mask = String(dF.masks[mask] || mask || dF.masks["default"]); - - // Allow setting the utc argument via the mask - if (mask.slice(0, 4) == "UTC:") { - mask = mask.slice(4); - utc = true; - } - - var _ = utc ? "getUTC" : "get", - d = date[_ + "Date"](), - D = date[_ + "Day"](), - m = date[_ + "Month"](), - y = date[_ + "FullYear"](), - H = date[_ + "Hours"](), - M = date[_ + "Minutes"](), - s = date[_ + "Seconds"](), - L = date[_ + "Milliseconds"](), - o = utc ? 0 : date.getTimezoneOffset(), - flags = { - d: d, - dd: pad(d), - ddd: dF.i18n.dayNames[D], - dddd: dF.i18n.dayNames[D + 7], - m: m + 1, - mm: pad(m + 1), - mmm: dF.i18n.monthNames[m], - mmmm: dF.i18n.monthNames[m + 12], - yy: String(y).slice(2), - yyyy: y, - h: H % 12 || 12, - hh: pad(H % 12 || 12), - H: H, - HH: pad(H), - M: M, - MM: pad(M), - s: s, - ss: pad(s), - l: pad(L, 3), - L: pad(L > 99 ? Math.round(L / 10) : L), - t: H < 12 ? "a" : "p", - tt: H < 12 ? "am" : "pm", - T: H < 12 ? "A" : "P", - TT: H < 12 ? "AM" : "PM", - Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""), - o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), - S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10] - }; - - return mask.replace(token, function ($0) { - return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); - }); - }; -}(); - -// Some common format strings -dateFormat.masks = { - "default": "ddd mmm dd yyyy HH:MM:ss", - shortDate: "m/d/yy", - mediumDate: "mmm d, yyyy", - longDate: "mmmm d, yyyy", - fullDate: "dddd, mmmm d, yyyy", - shortTime: "h:MM TT", - mediumTime: "h:MM:ss TT", - longTime: "h:MM:ss TT Z", - isoDate: "yyyy-mm-dd", - isoTime: "HH:MM:ss", - isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", - isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" -}; - -// Internationalization strings -dateFormat.i18n = { - dayNames: [ - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" - ], - monthNames: [ - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", - "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" - ] -}; - -// For convenience... -Date.prototype.format = function (mask, utc) { - return dateFormat(this, mask, utc); -}; - diff --git a/empty_cell.js b/empty_cell.js deleted file mode 100644 index 76e58c9..0000000 --- a/empty_cell.js +++ /dev/null @@ -1,91 +0,0 @@ -// *** empty_cell *** -// --- inherits from cell -// spec: -// cell spec - -var empty_cell = function(p, spec) { - - // --- defaults --- - // inherited from cell - - // obj to return - var obj = cell(p, spec); - - obj.get_type = function() { - return "empty_cell"; - }; - - // --- private variables --- - - // state can be "alive", "infected", or "dead" - //var state = spec.state || "alive"; - - //var empty_image = p.loadImage("images/noninfectable1.png"); - /* - var images = random_image_selector(); - var empty_image = null; - if (on_server) { // so itwill work locally - for_each(g_empty_cell_images, function(i){ - images.add(p.loadImage(i)); - }); - empty_image = images.get_image(); - } - else { - empty_image = p.loadImage("images/new/noninfectable.png"); - } - */ - var empty_image = random_from( - image_manager.get_images("empty_cell")).image; - - // --- public methods --- - - // implementing game_object interface - - // update is different depending on state - obj.update = function() { - obj.move(); - if (obj.get_state() === "alive") { - // just chill - } - else if (obj.get_state() === "infected") { - // prepare to die - } - else if (obj.get_state() === "dead") { - // explode!! - } - }; - - // draw makes a cell with a different color depending on state - // just an outline for empty cell - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.mode); - - p.strokeWeight(2); - p.stroke(0); - p.noFill(); - - if (obj.get_state() === "alive") { - p.stroke(0); - } - else if (obj.get_state() === "infected") { - p.stroke(150); - } - else if (obj.get_state() === "dead") { - p.fill(0); - } - - p.imageMode(obj.get_mode()); - p.image(empty_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - }; - - obj.is_dead = function() { - return obj.get_state() === "dead"; - }; - - obj.die = function() { - obj.set_state("dead") = "dead"; - }; - - return obj; -} diff --git a/facebook.php b/facebook.php deleted file mode 100644 index 6d4fa72..0000000 --- a/facebook.php +++ /dev/null @@ -1,1845 +0,0 @@ - - - - - - - - - - - - src/facebook.php at master from facebook's php-sdk - GitHub - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
-

Your current locale selection: English. Choose another?

- - - - - - - - - - - - -
- -
-
-
- - - - - - - - - - - - - - - - diff --git a/fb/index.html.BASE.17064.html b/fb/index.html.BASE.17064.html deleted file mode 100644 index b4ee629..0000000 --- a/fb/index.html.BASE.17064.html +++ /dev/null @@ -1,104 +0,0 @@ - -Virion - - - - - - -
- - - - - - diff --git a/fb/index.html.LOCAL.17064.html b/fb/index.html.LOCAL.17064.html deleted file mode 100644 index 160b267..0000000 --- a/fb/index.html.LOCAL.17064.html +++ /dev/null @@ -1,104 +0,0 @@ - -Virion - - - - - - -
- - - - - - diff --git a/fb/index.html.REMOTE.17064.html b/fb/index.html.REMOTE.17064.html deleted file mode 100644 index 0d44769..0000000 --- a/fb/index.html.REMOTE.17064.html +++ /dev/null @@ -1,104 +0,0 @@ - -Virion - - - - - - -
- - - - - - diff --git a/fisforformat.min.js b/fisforformat.min.js deleted file mode 100644 index d890718..0000000 --- a/fisforformat.min.js +++ /dev/null @@ -1,11 +0,0 @@ -/* - * "f" is for Format & WHAT THE diff?? v0.5.0 - * - * Copyright (c) 2009 Joshua Faulkenberry - * Dual licensed under the MIT and GPL licenses. - * http://docs.jquery.com/License - * - * Date: 2009-03-20 22:15:23 -0700 (Fri, 20 Mar 2009) - * Revision: 6 - */ -window.Date.prototype.f=function(format){if(format=="@"){return this.getTime()}else{if(format=="REL"){var diff=(((new Date()).getTime()-this.getTime())/1000),day_diff=Math.floor(diff/86400);return day_diff==0&&(diff>-60&&"right now"||diff>-120&&"1 minute from now"||diff>-3600&&-(Math.floor(diff/60))+" minutes from now"||diff>-7200&&"1 hour ago"||diff>-86400&&-(Math.floor(diff/3600))+" hours from now"||diff<60&&"just now"||diff<120&&"1 minute ago"||diff<3600&&Math.floor(diff/60)+" minutes ago"||diff<7200&&"1 hour ago"||diff<86400&&Math.floor(diff/3600)+" hours ago")||day_diff==0&&"Tomorrow"||day_diff>-7&&-(day_diff)+" days from now"||-(Math.ceil(day_diff/7))==1&&"1 week from now"||day_diff>-78&&-(Math.ceil(day_diff/7))+" weeks from now"||day_diff>-730&&-(Math.ceil(day_diff/30))+" months from now"||day_diff<=-730&&-(Math.ceil(day_diff/365))+" years from now"||day_diff==1&&"Yesterday"||day_diff<7&&day_diff+" days ago"||(Math.ceil(day_diff/7))==1&&"1 week ago"||day_diff<78&&Math.ceil(day_diff/7)+" weeks ago"||day_diff<730&&Math.ceil(day_diff/30)+" months ago"||Math.ceil(day_diff/365)+" years ago"}}var MONTH_NAMES=["January","February","March","April","May","June","July","August","September","October","November","December"],DAY_NAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],LZ=function(x){return(x<0||x>9?"":"0")+x},date=this,format=format+"",result="",i_format=0,c="",token="",y=date.getYear()+"",M=date.getMonth()+1,d=date.getDate(),E=date.getDay(),H=date.getHours(),m=date.getMinutes(),s=date.getSeconds(),yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k,value=new Object();if(y.length<4){y=""+(y-0+1900)}value.y=""+y;value.yyyy=y;value.yy=y.substr(2,4);value.M=M;value.MM=LZ(M);value.MMM=MONTH_NAMES[M-1];value.NNN=MONTH_NAMES[M-1].substr(0,3);value.N=MONTH_NAMES[M-1].substr(0,1);value.d=d;value.dd=LZ(d);value.e=DAY_NAMES[E].substr(0,1);value.ee=DAY_NAMES[E].substr(0,2);value.E=DAY_NAMES[E].substr(0,3);value.EE=DAY_NAMES[E];value.H=H;value.HH=LZ(H);if(H==0){value.h=12}else{if(H>12){value.h=H-12}else{value.h=H}}value.hh=LZ(value.h);if(H>11){value.K=H-12}else{value.K=H}value.k=H+1;value.KK=LZ(value.K);value.kk=LZ(value.k);if(H>11){value.a="PM"}else{value.a="AM"}value.m=m;value.mm=LZ(m);value.s=s;value.ss=LZ(s);while(i_format=tl[trg]){if(trg=="Y"||trg=="D"||trg=="C"||trg=="T"){for(var yr=(min);yr.getFullYear()<=max.getFullYear();yr.setYear(yr.getFullYear()+1)){if(yr.isLeapYear()){diff-=tl.d}}}if(diff>=tl[trg]){result=Math.floor(diff/tl[trg])+" "+(Math.floor(diff/tl[trg])==1&&names[trg][0]||names[trg][1]);diff=diff%tl[trg]}}eval("breakdown = breakdown.replace(/"+trg+'/g, "")');return result}var min=date<=this&&date||date>this&&this,max=date>this&&date||date<=this&&this,diff=(max.getTime()-min.getTime()),tl={T:1000*60*60*24*365*100*10,C:1000*60*60*24*365*100,D:1000*60*60*24*365*10,Y:1000*60*60*24*365,M:1000*60*60*24*28,W:1000*60*60*24*7,d:1000*60*60*24,H:1000*60*60,m:1000*60,S:1000,N:1},names={T:options.labels.T||["Mellinium","Mellinia"],C:options.labels.C||["Century","Centuries"],D:options.labels.D||["Decade","Decades"],Y:options.labels.Y||["Year","Years"],M:options.labels.M||["Month","Months"],W:options.labels.W||["Week","Weeks"],d:options.labels.d||["Day","Days"],H:options.labels.H||["Hour","Hours"],m:options.labels.m||["Minute","Minutes"],S:options.labels.S||["Second","Seconds"],N:options.labels.N||["Millisecond","Milliseconds"]};if(options.len){for(var x in names){names[x]=names[x].substr(0,options.len)}}var testDt=new Date(min.toString());if(max.getFullYear()-testDt.getFullYear()>1){testDt.setYear(max.getFullYear()-1)}while(testDtmin.getDayLightSavingsDays()[1].getDate())||min.getMonth()0){if(breakdown=="*"){breakdown="TCDYMWdHmSN"}else{if(breakdown.indexOf("T")>-1){if(out=processTime("T")){result[result.length]=out}}else{if(breakdown.indexOf("C")>-1){if(out=processTime("C")){result[result.length]=out}}else{if(breakdown.indexOf("D")>-1){if(out=processTime("D")){result[result.length]=out}}else{if(breakdown.indexOf("Y")>-1){if(out=processTime("Y")){result[result.length]=out}}else{if(breakdown.indexOf("M")>-1){if(diff>=tl.M){var cur=(new Date(max.getTime()-diff));var monthCount=0;var lastVal=0;for(var yr=cur.getFullYear();yr<=max.getFullYear();yr++){while(cur.getFullYear()==yr){lastVal=cur.getTime();cur.setMonth(cur.getMonth()+1);if(diff-(cur.getTime()-lastVal)>=0){monthCount++;diff-=(cur.getTime()-lastVal)}if(yr==max.getFullYear()&&cur.getMonth()==max.getMonth()){break}}}if(monthCount){result[result.length]=monthCount+" "+(monthCount==1&&names.M[0]||names.M[1])}}breakdown=breakdown.replace(/M/g,"")}else{if(breakdown.indexOf("W")>-1){if(out=processTime("W")){result[result.length]=out}}else{if(breakdown.indexOf("d")>-1){if(out=processTime("d")){result[result.length]=out}}else{if(breakdown.indexOf("H")>-1){if(out=processTime("H")){result[result.length]=out}}else{if(breakdown.indexOf("m")>-1){if(out=processTime("m")){result[result.length]=out}}else{if(breakdown.indexOf("S")>-1){if(out=processTime("S")){result[result.length]=out}}else{if(breakdown.indexOf("N")>-1){if(out=processTime("N")){result[result.length]=out}}else{diff=0}}}}}}}}}}}}}options.divider=options.divider||", ";if(options.divider==", "&&result.length>1&&!options.hideAnd){result[result.length-1]="and "+result[result.length-1]}diff=result.join(options.divider)}if(diff==""){diff="Same"}if(options.lc){diff=diff.toLowerCase()}return diff};window.Date.prototype.getDaysInMonth=function(){return[31,28,31,30,31,30,31,31,30,31,30,31][this.getMonth()]};window.Date.prototype.isLeapYear=function(){return(new Date(this.getFullYear(),2-1,29)).getDate()==29};window.Date.prototype.getDayLightSavingsDays=function(){var result=[];var day1=new Date("03/07/"+this.getFullYear());var day2=new Date("03/06/"+this.getFullYear());while(day1.getMonth()<3||(day1.getMonth()==3&&day1.getDate()<16)){if((day1.getTime()-day2.getTime())/1000/60/60!=24){result[result.length]=new Date(day2.getTime())}day1.setDate(day1.getDate()+1);day2.setDate(day2.getDate()+1)}var day1=new Date("10/31/"+this.getFullYear());var day2=new Date("10/30/"+this.getFullYear());while(day1.getMonth()<11||(day1.getMonth()==10&&day1.getDate()<9)){if((day1.getTime()-day2.getTime())/1000/60/60!=24){result[result.length]=new Date(day2.getTime())}day1.setDate(day1.getDate()+1);day2.setDate(day2.getDate()+1)}return result};window.Date.prototype.isDayLightSavingsDay=function(){var comp=new Date(this.getTime());comp.setDate(comp.getDate()+1);return(comp.getTime()-this.getTime())/1000/60/60!=24}; \ No newline at end of file diff --git a/floater.js b/floater.js deleted file mode 100644 index 86ff5a5..0000000 --- a/floater.js +++ /dev/null @@ -1,122 +0,0 @@ -// *** floater *** -// --- inherits from game_object -// spec: -// game_object spec -// state = leave to be default "alive" - -var floater = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 43; - spec.height = spec.height || 50; - spec.vel = new p.PVector(0, 0.3); - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "floater"; - }; - - // --- private variables --- - - var macrophage_alive = animated_image("macrophage", {reverse : true}); - var macrophage_active = animated_image("macrophage_active", {reverse : true}); - // for illustration - var macro_active_img = image_manager.get_image("macrophage_1_active.png"); - var macro_alive_img = image_manager.get_image("macrophage_1.png"); - - // how far up or down it can move - var range = 50; - var btm_lim = obj.get_pos().y + range; - var top_lim = obj.get_pos().y - range; - // state can be "alive", "activated", or "dead" - var state = spec.state || "alive"; - - // --- public methods --- - - // implementing game_object interface - - obj.update = function() { - // if we reach a limit - var y = obj.get_pos().y; - if (y <= top_lim || y >= btm_lim) { - // turn around - var v = obj.get_vel(); - obj.set_vel(new p.PVector(v.x, -v.y)); - } - obj.move(); - }; - - // (rectangle for now) - obj.draw = function() { - /* - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.fill(obj.get_color()); - - p.stroke(0); - p.strokeWeight(1); - - // had to hack to center rect - // might need to change - p.rect(pos.x-w/2, pos.y-h/2, w, h); - */ - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.imageMode(obj.get_mode()); - if (state === "active") { - p.shapeMode(obj.mode); - p.fill(obj.get_color()); - p.noStroke(); - p.ellipse(pos.x + w / 8, pos.y - w / 8 + 1, w/2, w/2); - if (!obj.is_illustration()) { - macro_active_img = macrophage_active.get_frame(); - } - p.image(macro_active_img, pos.x, pos.y, w, h); - } - else { - if (!obj.is_illustration()) { - macro_alive_img = macrophage_alive.get_frame(); - } - p.image(macro_alive_img, pos.x, pos.y, w, h); - } - }; - - obj.stop_animation = function() { - macrophage_alive.pause(); - macrophage_active.pause(); - }; - - obj.resume_animation = function() { - macrophage_alive.start(); - macrophage_active.start(); - }; - - obj.is_dead = function() { - return state === "dead"; - }; - - obj.is_alive = function() { - return state === "alive"; - }; - - obj.is_activated = function() { - return state === "active"; - }; - - obj.get_state = function() { - return state; - }; - - obj.activate = function() { - state = "active"; - }; - - return obj; -} diff --git a/game/README b/game/README deleted file mode 100644 index e69de29..0000000 diff --git a/game/dev/all.js b/game/dev/all.js deleted file mode 100644 index 7050da9..0000000 --- a/game/dev/all.js +++ /dev/null @@ -1,70 +0,0 @@ -/*1295489895,169565300,JIT Construction: v334085,en_US*/ - -if(!window.FB)window.FB={_apiKey:null,_session:null,_userStatus:'unknown',_logging:true,_inCanvas:((window.location.search.indexOf('fb_sig_in_iframe=1')>-1)||(window.location.search.indexOf('session=')>-1)||(window.location.search.indexOf('signed_request=')>-1)),_https:(window.name.indexOf('_fb_https')>-1),_domain:{api:'https://api.facebook.com/',api_read:'https://api-read.facebook.com/',cdn:'http://static.ak.fbcdn.net/',https_cdn:'https://s-static.ak.fbcdn.net/',graph:'https://graph.facebook.com/',staticfb:'http://static.ak.facebook.com/',https_staticfb:'https://s-static.ak.facebook.com/',www:window.location.protocol+'//www.facebook.com/',https_www:'https://www.facebook.com/'},_locale:null,_localeIsRtl:false,getDomain:function(a){switch(a){case 'api':return FB._domain.api;case 'api_read':return FB._domain.api_read;case 'cdn':return (window.location.protocol=='https:'||FB._https)?FB._domain.https_cdn:FB._domain.cdn;case 'graph':return FB._domain.graph;case 'staticfb':return FB._https?FB._domain.https_staticfb:FB._domain.staticfb;case 'https_staticfb':return FB._domain.https_staticfb;case 'www':return FB._https?FB._domain.https_www:FB._domain.www;case 'https_www':return FB._domain.https_www;}},copy:function(d,c,b,e){for(var a in c)if(b||typeof d[a]==='undefined')d[a]=e?e(c[a]):c[a];return d;},create:function(c,h){var e=window.FB,d=c?c.split('.'):[],a=d.length;for(var b=0;b');e.root.innerHTML='';f=true;window.setTimeout(function(){e.root.innerHTML=b;},0);}else{var c=document.createElement('iframe');c.id=e.id;c.name=e.name;c.onload=FB.Content._callbacks[a];c.scrolling='no';c.style.border='none';c.style.overflow='hidden';if(e.title)c.title=e.title;if(e.className)c.className=e.className;if(e.height)c.style.height=e.height+'px';if(e.width)c.style.width=e.width+'px';e.root.appendChild(c);f=true;c.src=e.url;}},postTarget:function(b){var a=document.createElement('form');a.action=b.url;a.target=b.target;a.method='POST';FB.Content.appendHidden(a);FB.Array.forEach(b.params,function(e,d){if(e!==null&&e!==undefined){var c=document.createElement('input');c.name=d;c.value=e;a.appendChild(c);}});a.submit();a.parentNode.removeChild(a);}}); -FB.provide('Flash',{_minVersions:[[9,0,159,0],[10,0,22,87]],_swfPath:'swf/XdComm.swf',_callbacks:[],init:function(){if(FB.Flash._init)return;FB.Flash._init=true;window.FB_OnFlashXdCommReady=function(){FB.Flash._ready=true;for(var d=0,e=FB.Flash._callbacks.length;d'+''+''+'');FB.Content.appendHidden(b);},hasMinVersion:function(){if(typeof FB.Flash._hasMinVersion==='undefined'){var i,a,b,h=[];try{i=new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');}catch(j){if(navigator.mimeTypes.length>0){var mimeType='application/x-shockwave-flash';if(navigator.mimeTypes[mimeType].enabledPlugin){var name='Shockwave Flash';i=(navigator.plugins[name+' 2.0']||navigator.plugins[name]).description;}}}if(i){var f=i.replace(/\D+/g,',').match(/^,?(.+),?$/)[1].split(',');for(a=0,b=f.length;ag[c])break majorVersion;}};}return FB.Flash._hasMinVersion;},onReady:function(a){FB.Flash.init();if(FB.Flash._ready){window.setTimeout(a,0);}else FB.Flash._callbacks.push(a);}}); -if(!this.JSON)this.JSON={};(function(){function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function')value=value.toJSON(key);if(typeof rep==='function')value=rep.call(holder,key,value);switch(typeof value){case 'string':return quote(value);case 'number':return isFinite(value)?String(value):'null';case 'boolean':case 'null':return String(value);case 'object':if(!value)return 'null';gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i-1?'&':'?')+FB.QS.encode(e));if(h.length>2000)throw new Error('JSONP only support a maximum of 2000 bytes of input.');FB.ApiServer._callbacks[c]=function(i){a&&a(i);delete FB.ApiServer._callbacks[c];g.parentNode.removeChild(g);};g.src=h;document.getElementsByTagName('head')[0].appendChild(g);},flash:function(b,e,c,d,a){if(!window.FB_OnXdHttpResult)window.FB_OnXdHttpResult=function(g,f){FB.ApiServer._callbacks[g](decodeURIComponent(f));};FB.Flash.onReady(function(){var h=FB.getDomain(b)+e,f=FB.QS.encode(d);if(c==='get'){if(h.length+f.length>2000){if(b==='graph')d.method='get';c='post';f=FB.QS.encode(d);}else{h+=(h.indexOf('?')>-1?'&':'?')+f;f='';}}else if(c!=='post'){if(b==='graph')d.method=c;c='post';f=FB.QS.encode(d);}var g=document.XdComm.sendXdHttpRequest(c.toUpperCase(),h,f,null);FB.ApiServer._callbacks[g]=function(i){a&&a(FB.JSON.parse(i));delete FB.ApiServer._callbacks[g];};});}}); -FB.provide('EventProvider',{subscribers:function(){if(!this._subscribersMap)this._subscribersMap={};return this._subscribersMap;},subscribe:function(b,a){var c=this.subscribers();if(!c[b]){c[b]=[a];}else c[b].push(a);},unsubscribe:function(b,a){var c=this.subscribers()[b];FB.Array.forEach(c,function(e,d){if(e==a)c[d]=null;});},monitor:function(d,a){if(!a()){var b=this,c=function(){if(a.apply(a,arguments))b.unsubscribe(d,c);};this.subscribe(d,c);}},clear:function(a){delete this.subscribers()[a];},fire:function(){var a=Array.prototype.slice.call(arguments),b=a.shift();FB.Array.forEach(this.subscribers()[b],function(c){if(c)c.apply(this,a);});}});FB.provide('Event',FB.EventProvider); -FB.provide('Intl',{_punctCharClass:('['+'.!?'+'\u3002'+'\uFF01'+'\uFF1F'+'\u0964'+'\u2026'+'\u0EAF'+'\u1801'+'\u0E2F'+'\uFF0E'+']'),_endsInPunct:function(a){if(typeof a!='string')return false;return a.match(new RegExp(FB.Intl._punctCharClass+'['+')"'+"'"+'\u00BB'+'\u0F3B'+'\u0F3D'+'\u2019'+'\u201D'+'\u203A'+'\u3009'+'\u300B'+'\u300D'+'\u300F'+'\u3011'+'\u3015'+'\u3017'+'\u3019'+'\u301B'+'\u301E'+'\u301F'+'\uFD3F'+'\uFF07'+'\uFF09'+'\uFF3D'+'\s'+']*$'));},_tx:function(d,a){if(a!==undefined)if(typeof a!='object'){FB.log('The second arg to FB.Intl._tx() must be an Object for '+'tx('+d+', ...)');}else{var c;for(var b in a)if(a.hasOwnProperty(b)){if(FB.Intl._endsInPunct(a[b])){c=new RegExp('\{'+b+'\}'+FB.Intl._punctCharClass+'*','g');}else c=new RegExp('\{'+b+'\}','g');d=d.replace(c,a[b]);}}return d;},tx:function(b,a){function c(e,d){void(0);}if(!FB.Intl._stringTable)return null;return FBIntern.Intl._tx(FB.Intl._stringTable[b],a);}}); -FB.provide('String',{trim:function(a){return a.replace(/^\s*|\s*$/g,'');},format:function(a){if(!FB.String.format._formatRE)FB.String.format._formatRE=/(\{[^\}^\{]+\})/g;var b=arguments;return a.replace(FB.String.format._formatRE,function(e,d){var c=parseInt(d.substr(1),10),f=b[c+1];if(f===null||f===undefined)return '';return f.toString();});},escapeHTML:function(b){var a=document.createElement('div');a.appendChild(document.createTextNode(b));return a.innerHTML.replace(/"/g,'"').replace(/'/g,''');},quote:function(c){var a=/["\\\x00-\x1f\x7f-\x9f]/g,b={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};return a.test(c)?'"'+c.replace(a,function(d){var e=b[d];if(e)return e;e=d.charCodeAt();return '\\u00'+Math.floor(e/16).toString(16)+(e%16).toString(16);})+'"':'"'+c+'"';}}); -FB.provide('Dom',{containsCss:function(c,a){var b=' '+c.className+' ';return b.indexOf(' '+a+' ')>=0;},addCss:function(b,a){if(!FB.Dom.containsCss(b,a))b.className=b.className+' '+a;},removeCss:function(b,a){if(FB.Dom.containsCss(b,a)){b.className=b.className.replace(a,'');FB.Dom.removeCss(b,a);}},getStyle:function(a,c){var d=false,b=a.style;if(a.currentStyle){FB.Array.forEach(c.match(/\-([a-z])/g),function(e){c=c.replace(e,e.substr(1,1).toUpperCase());});d=a.currentStyle[c];}else{FB.Array.forEach(c.match(/[A-Z]/g),function(e){c=c.replace(e,'-'+e.toLowerCase());});if(window.getComputedStyle){d=document.defaultView.getComputedStyle(a,null).getPropertyValue(c);if(c=='background-position-y'||c=='background-position-x')if(d=='top'||d=='left')d='0px';}}if(c=='opacity'){if(a.filters&&a.filters.alpha)return d;return d*100;}return d;},setStyle:function(a,c,d){var b=a.style;if(c=='opacity'){if(d>=100)d=99.999;if(d<0)d=0;b.opacity=d/100;b.MozOpacity=d/100;b.KhtmlOpacity=d/100;if(a.filters)if(a.filters.alpha==undefined){a.filter="alpha(opacity="+d+")";}else a.filters.alpha.opacity=d;}else b[c]=d;},addScript:function(b){var a=document.createElement('script');a.type="text/javascript";a.src=b;return document.getElementsByTagName('head')[0].appendChild(a);},addCssRules:function(e,c){if(!FB.Dom._cssRules)FB.Dom._cssRules={};var a=true;FB.Array.forEach(c,function(f){if(!(f in FB.Dom._cssRules)){a=false;FB.Dom._cssRules[f]=true;}});if(a)return;if(FB.Dom.getBrowserType()!='ie'){var d=document.createElement('style');d.type='text/css';d.textContent=e;document.getElementsByTagName('head')[0].appendChild(d);}else try{document.createStyleSheet().cssText=e;}catch(b){if(document.styleSheets[0])document.styleSheets[0].cssText+=e;}},getBrowserType:function(){if(!FB.Dom._browserType){var d=window.navigator.userAgent.toLowerCase(),b=['msie','firefox','safari','gecko'],c=['ie','mozilla','safari','mozilla'];for(var a=0;a=0){FB.Dom._browserType=c[a];break;}}return FB.Dom._browserType;},getViewportInfo:function(){var a=(document.documentElement&&document.compatMode=='CSS1Compat')?document.documentElement:document.body;return {scrollTop:a.scrollTop,scrollLeft:a.scrollLeft,width:self.innerWidth?self.innerWidth:a.clientWidth,height:self.innerHeight?self.innerHeight:a.clientHeight};},ready:function(a){if(FB.Dom._isReady){a();}else FB.Event.subscribe('dom.ready',a);}});(function(){function domReady(){FB.Dom._isReady=true;FB.Event.fire('dom.ready');FB.Event.clear('dom.ready');}if(FB.Dom._isReady||document.readyState=='complete')return domReady();if(document.addEventListener){document.addEventListener('DOMContentLoaded',domReady,false);}else if(document.attachEvent)document.attachEvent('onreadystatechange',domReady);if(FB.Dom.getBrowserType()=='ie'&&window===top)(function(){try{document.documentElement.doScroll('left');}catch(error){setTimeout(arguments.callee,0);return;}domReady();})();var oldonload=window.onload;window.onload=function(){domReady();if(oldonload)if(typeof oldonload=='string'){eval(oldonload);}else oldonload();};})(); -FB.provide('Dialog',{_loaderEl:null,_stack:[],_active:null,_findRoot:function(a){while(a){if(FB.Dom.containsCss(a,'fb_dialog'))return a;a=a.parentNode;}},_showLoader:function(a,c){if(!FB.Dialog._loaderEl){c=parseInt(c,10);c=c?c:460;FB.Dialog._loaderEl=FB.Dialog._findRoot(FB.Dialog.create({content:('
'+' '+'
'+'
'+' Facebook'+'
'+'
'+'
'+''),width:c}));}if(!a)a=function(){};var b=FB.$('fb_dialog_loader_close');FB.Dom.removeCss(b,'fb_hidden');b.onclick=function(){FB.Dialog._hideLoader();a();};FB.Dialog._makeActive(FB.Dialog._loaderEl);},_hideLoader:function(){if(FB.Dialog._loaderEl&&FB.Dialog._loaderEl==FB.Dialog._active)FB.Dialog._loaderEl.style.top='-10000px';},_makeActive:function(b){FB.Dialog._lowerActive();var a={width:parseInt(b.offsetWidth,10),height:parseInt(b.offsetHeight,10)},e=FB.Dom.getViewportInfo(),c=(e.scrollLeft+(e.width-a.width)/2),d=(e.scrollTop+(e.height-a.height)/2.5);b.style.left=(c>0?c:0)+'px';b.style.top=(d>0?d:0)+'px';FB.Dialog._active=b;},_lowerActive:function(){if(!FB.Dialog._active)return;FB.Dialog._active.style.top='-10000px';FB.Dialog._active=null;},_removeStacked:function(a){FB.Dialog._stack=FB.Array.filter(FB.Dialog._stack,function(b){return b!=a;});},create:function(e){e=e||{};if(e.loader)FB.Dialog._showLoader(e.onClose,e.loaderWidth);var d=document.createElement('div'),c=document.createElement('div'),a='fb_dialog';if(e.closeIcon&&e.onClose){var b=document.createElement('a');b.className='fb_dialog_close_icon';b.onclick=e.onClose;d.appendChild(b);}if(FB.Dom.getBrowserType()=='ie'){a+=' fb_dialog_legacy';FB.Array.forEach(['vert_left','vert_right','horiz_top','horiz_bottom','top_left','top_right','bottom_left','bottom_right'],function(g){var h=document.createElement('span');h.className='fb_dialog_'+g;d.appendChild(h);});}else a+=' fb_dialog_advanced';if(e.content)FB.Content.append(e.content,c);d.className=a;var f=parseInt(e.width,10);if(!isNaN(f))d.style.width=f+'px';c.className='fb_dialog_content';d.appendChild(c);FB.Content.append(d);if(e.visible)FB.Dialog.show(d);return c;},show:function(a){a=FB.Dialog._findRoot(a);if(a){FB.Dialog._removeStacked(a);FB.Dialog._hideLoader();FB.Dialog._makeActive(a);FB.Dialog._stack.push(a);}},remove:function(a){a=FB.Dialog._findRoot(a);if(a){var b=FB.Dialog._active==a;FB.Dialog._removeStacked(a);FB.Dialog._hideLoader();if(b)if(FB.Dialog._stack.length>0){FB.Dialog.show(FB.Dialog._stack.pop());}else FB.Dialog._lowerActive();window.setTimeout(function(){a.parentNode.removeChild(a);},3000);}}}); -FB.provide('XD',{_origin:null,_transport:null,_callbacks:{},_forever:{},init:function(a){if(FB.XD._origin)return;if(window.addEventListener&&!window.attachEvent&&window.postMessage){FB.XD._origin=(window.location.protocol+'//'+window.location.host+'/'+FB.guid());FB.XD.PostMessage.init();FB.XD._transport='postmessage';}else if(!a&&FB.Flash.hasMinVersion()){FB.XD._origin=(window.location.protocol+'//'+document.domain+'/'+FB.guid());FB.XD.Flash.init();FB.XD._transport='flash';}else{FB.XD._transport='fragment';FB.XD.Fragment._channelUrl=a||window.location.toString();}},resolveRelation:function(b){var g,d,f=b.split('.'),e=window;for(var a=0,c=f.length;a0)return 'javascript:false;//';var f=FB.getDomain('cdn')+'connect/xd_proxy.php#',c=FB.guid();if(FB.XD._transport=='fragment'){f=FB.XD.Fragment._channelUrl;var d=f.indexOf('#');if(d>0)f=f.substr(0,d);f+=((f.indexOf('?')<0?'?':'&')+FB.XD.Fragment._magic+'#?=&');}if(b)FB.XD._forever[c]=true;FB.XD._callbacks[c]=a;return f+FB.QS.encode({cb:c,origin:FB.XD._origin,relation:e||'opener',transport:FB.XD._transport});},recv:function(b){if(typeof b=='string')b=FB.QS.decode(b);var a=FB.XD._callbacks[b.cb];if(!FB.XD._forever[b.cb])delete FB.XD._callbacks[b.cb];a&&a(b);},PostMessage:{init:function(){var a=FB.XD.PostMessage.onMessage;window.addEventListener?window.addEventListener('message',a,false):window.attachEvent('onmessage',a);},onMessage:function(event){FB.XD.recv(event.data);}},Flash:{init:function(){FB.Flash.onReady(function(){document.XdComm.postMessage_init('FB.XD.Flash.onMessage',FB.XD._origin);});},onMessage:function(a){FB.XD.recv(decodeURIComponent(a));}},Fragment:{_magic:'fb_xd_fragment',checkAndDispatch:function(){var b=window.location.toString(),a=b.substr(b.indexOf('#')+1),c=b.indexOf(FB.XD.Fragment._magic);if(c>0){FB.init=FB.getLoginStatus=FB.api=function(){};document.documentElement.style.display='none';FB.XD.resolveRelation(FB.QS.decode(a).relation).FB.XD.recv(a);}}}});FB.XD.Fragment.checkAndDispatch(); -FB.provide('Arbiter',{inform:function(c,e,f,b){if(window.name.indexOf('app_runner_')===0){var d=FB.JSON.stringify({method:c,params:e});if(window.postMessage){FB.XD.resolveRelation(f||'parent').postMessage(d,'*');return;}else try{window.opener.postMessage(d);return;}catch(a){}}var h=(FB.getDomain((b?'https_':'')+'staticfb')+'connect/canvas_proxy.php#'+FB.QS.encode({method:c,params:FB.JSON.stringify(e||{}),relation:f}));var g=FB.Content.appendHidden('');FB.Content.insertIframe({url:h,root:g,width:1,height:1,onload:function(){setTimeout(function(){g.parentNode.removeChild(g);},10);}});}}); -FB.provide('',{ui:function(e,b){if(!e.method){FB.log('"method" is a required parameter for FB.ui().');return;}var a=FB.UIServer.prepareCall(e,b);if(!a)return;var d=a.params.display;if(d=='dialog')d='iframe';var c=FB.UIServer[d];if(!c){FB.log('"display" must be one of "popup", "iframe" or "hidden".');return;}c(a);}});FB.provide('UIServer',{Methods:{},_active:{},_defaultCb:{},_resultToken:'"xxRESULTTOKENxx"',genericTransform:function(a){if(a.params.display=='dialog'||a.params.display=='iframe'){a.params.display='iframe';a.params.channel=FB.UIServer._xdChannelHandler(a.id,'parent.parent');}return a;},prepareCall:function(h,b){var g=h.method.toLowerCase(),f=FB.UIServer.Methods[g]||{size:{width:575,height:240}},e=FB.guid(),d=FB._https||(g!=='auth.status');FB.copy(h,{api_key:FB._apiKey,app_id:FB._apiKey,locale:FB._locale,sdk:'joey',access_token:d&&FB._session&&FB._session.access_token||undefined});h.display=FB.UIServer.getDisplayMode(f,h);if(!f.url){f.url='dialog/'+g;delete h.method;}var a={cb:b,id:e,size:f.size||{},url:FB.getDomain(d?'https_www':'www')+f.url,params:h};var j=f.transform?f.transform:FB.UIServer.genericTransform;if(j){a=j(a);if(!a)return;}var i=FB.UIServer.getXdRelation(a.params.display);if(!(a.id in FB.UIServer._defaultCb)&&!('next' in a.params))a.params.next=FB.UIServer._xdResult(a.cb,a.id,i,true);if(i==='parent')a.params.channel_url=FB.UIServer._xdChannelHandler(e,'parent.parent');a.params=FB.JSON.flatten(a.params);var c=FB.QS.encode(a.params);if((a.url+c).length>2000){a.post=true;}else if(c)a.url+='?'+c;return a;},getDisplayMode:function(a,b){if(b.display==='hidden')return 'hidden';if(window.name.indexOf('app_runner_')===0)return 'async';if(!FB._session&&b.display=='dialog'&&!a.loggedOutIframe){FB.log('"dialog" mode can only be used when the user is connected.');return 'popup';}return b.display||(FB._session?'dialog':'popup');},getXdRelation:function(a){if(a==='popup')return 'opener';if(a==='dialog'||a==='iframe')return 'parent';if(a==='async')return 'parent.frames['+window.name+']';},popup:function(b){var a=typeof window.screenX!='undefined'?window.screenX:window.screenLeft,i=typeof window.screenY!='undefined'?window.screenY:window.screenTop,g=typeof window.outerWidth!='undefined'?window.outerWidth:document.documentElement.clientWidth,f=typeof window.outerHeight!='undefined'?window.outerHeight:(document.documentElement.clientHeight-22),k=b.size.width,d=b.size.height,h=(a<0)?window.screen.width+a:a,e=parseInt(h+((g-k)/2),10),j=parseInt(i+((f-d)/2.5),10),c=('width='+k+',height='+d+',left='+e+',top='+j+',scrollbars=1');if(b.params.method=='permissions.request')c+=',location=1,toolbar=0';if(b.post){FB.UIServer._active[b.id]=window.open('about:blank',b.id,c);FB.Content.postTarget({url:b.url,target:b.id,params:b.params});}else FB.UIServer._active[b.id]=window.open(b.url,b.id,c);if(b.id in FB.UIServer._defaultCb)FB.UIServer._popupMonitor();},hidden:function(a){a.className='FB_UI_Hidden';a.root=FB.Content.appendHidden('');FB.UIServer._insertIframe(a);},iframe:function(a){a.className='FB_UI_Dialog';a.root=FB.Dialog.create({onClose:function(){FB.UIServer._triggerDefault(a.id);},loader:true,loaderWidth:a.size.width,closeIcon:true});FB.Dom.addCss(a.root,'fb_dialog_iframe');FB.UIServer._insertIframe(a);},async:function(a){a.frame=window.name;delete a.url;delete a.size;FB.Arbiter.inform('showDialog',a);},_insertIframe:function(b){FB.UIServer._active[b.id]=false;var a=function(c){if(b.id in FB.UIServer._active)FB.UIServer._active[b.id]=c;};if(b.post){FB.Content.insertIframe({url:'about:blank',root:b.root,className:b.className,width:b.size.width,height:b.size.height,onload:function(c){a(c);FB.Content.postTarget({url:b.url,target:c.name,params:b.params});}});}else FB.Content.insertIframe({url:b.url,root:b.root,className:b.className,width:b.size.width,height:b.size.height,onload:a});},_triggerDefault:function(a){FB.UIServer._xdRecv({frame:a},FB.UIServer._defaultCb[a]||function(){});},_popupMonitor:function(){var a;for(var b in FB.UIServer._active)if(FB.UIServer._active.hasOwnProperty(b)&&b in FB.UIServer._defaultCb){var c=FB.UIServer._active[b];try{if(c.tagName)continue;}catch(d){}try{if(c.closed){FB.UIServer._triggerDefault(b);}else a=true;}catch(e){}}if(a&&!FB.UIServer._popupInterval){FB.UIServer._popupInterval=window.setInterval(FB.UIServer._popupMonitor,100);}else if(!a&&FB.UIServer._popupInterval){window.clearInterval(FB.UIServer._popupInterval);FB.UIServer._popupInterval=null;}},_xdChannelHandler:function(a,b){return FB.XD.handler(function(c){var d=FB.UIServer._active[a];if(!d)return;if(c.type=='resize'){if(c.height)d.style.height=c.height+'px';if(c.width)d.style.width=c.width+'px';FB.Arbiter.inform('resize.ack',{},'parent.frames['+d.name+']',true);FB.Dialog.show(d);}},b,true);},_xdNextHandler:function(a,b,d,c){if(c)FB.UIServer._defaultCb[b]=a;return FB.XD.handler(function(e){FB.UIServer._xdRecv(e,a);},d)+'&frame='+b;},_xdRecv:function(b,a){var c=FB.UIServer._active[b.frame];try{if(FB.Dom.containsCss(c,'FB_UI_Hidden')){window.setTimeout(function(){c.parentNode.parentNode.removeChild(c.parentNode);},3000);}else if(FB.Dom.containsCss(c,'FB_UI_Dialog'))FB.Dialog.remove(c);}catch(d){}try{if(c.close){c.close();FB.UIServer._popupCount--;}}catch(e){}delete FB.UIServer._active[b.frame];delete FB.UIServer._defaultCb[b.frame];a(b);},_xdResult:function(a,b,d,c){return (FB.UIServer._xdNextHandler(function(e){a&&a(e.result&&e.result!=FB.UIServer._resultToken&&FB.JSON.parse(e.result));},b,d,c)+'&result='+encodeURIComponent(FB.UIServer._resultToken));}}); -FB.provide('',{getLoginStatus:function(a,b){if(!FB._apiKey){FB.log('FB.getLoginStatus() called before calling FB.init().');return;}if(a)if(!b&&FB.Auth._loadState=='loaded'){a({status:FB._userStatus,session:FB._session});return;}else FB.Event.subscribe('FB.loginStatus',a);if(!b&&FB.Auth._loadState=='loading')return;FB.Auth._loadState='loading';var c=function(d){FB.Auth._loadState='loaded';FB.Event.fire('FB.loginStatus',d);FB.Event.clear('FB.loginStatus');};FB.ui({method:'auth.status',display:'hidden'},c);},getSession:function(){return FB._session;},login:function(a,b){FB.ui(FB.copy({method:'permissions.request',display:'popup'},b||{}),a);},logout:function(a){FB.ui({method:'auth.logout',display:'hidden'},a);}});FB.provide('Auth',{_callbacks:[],setSession:function(e,g){var b=!FB._session&&e,c=FB._session&&!e,a=FB._session&&e&&FB._session.uid!=e.uid,f=b||c||(FB._session&&e&&FB._session.access_token!=e.access_token),h=g!=FB._userStatus;var d={session:e,status:g};FB._session=e;FB._userStatus=g;if(f&&FB.Cookie&&FB.Cookie.getEnabled())FB.Cookie.set(e);if(h)FB.Event.fire('auth.statusChange',d);if(c||a)FB.Event.fire('auth.logout',d);if(b||a)FB.Event.fire('auth.login',d);if(f)FB.Event.fire('auth.sessionChange',d);if(FB.Auth._refreshTimer){window.clearTimeout(FB.Auth._refreshTimer);delete FB.Auth._refreshTimer;}if(FB.Auth._loadState&&e&&e.expires)FB.Auth._refreshTimer=window.setTimeout(function(){FB.getLoginStatus(null,true);},1200000);return d;},xdHandler:function(a,b,f,c,e,d){return FB.UIServer._xdNextHandler(FB.Auth.xdResponseWrapper(a,e,d),b,f,c);},xdResponseWrapper:function(a,c,b){return function(d){try{b=FB.JSON.parse(d.session);}catch(f){}if(b)c='connected';if(d.fb_https&&!FB._https)FB._https=true;var e=FB.Auth.setSession(b||null,c);e.perms=d&&d.perms||null;a&&a(e);};}});FB.provide('UIServer.Methods',{'permissions.request':{size:{width:627,height:326},transform:function(a){if(!FB._apiKey){FB.log('FB.login() called before calling FB.init().');return;}if(FB._session&&!a.params.perms){FB.log('FB.login() called when user is already connected.');a.cb&&a.cb({status:FB._userStatus,session:FB._session});return;}a=FB.UIServer.genericTransform(a);a.cb=FB.Auth.xdResponseWrapper(a.cb,FB._userStatus,FB._session);a.params.method='permissions.request';FB.copy(a.params,{fbconnect:FB._inCanvas?0:1,return_session:1,session_version:3});return a;}},'auth.logout':{url:'logout.php',transform:function(a){if(!FB._apiKey){FB.log('FB.logout() called before calling FB.init().');}else if(!FB._session){FB.log('FB.logout() called without a session.');}else{a.params.next=FB.Auth.xdHandler(a.cb,a.id,'parent',false,'unknown');return a;}}},'auth.status':{url:'extern/login_status.php',transform:function(a){var b=a.cb,c=a.id,d=FB.Auth.xdHandler;delete a.cb;FB.copy(a.params,{no_session:d(b,c,'parent',false,'notConnected'),no_user:d(b,c,'parent',false,'unknown'),ok_session:d(b,c,'parent',false,'connected'),session_version:3,extern:FB._inCanvas?0:2});return a;}}}); -FB.provide('Canvas',{_timer:null,_lastSize:{},setSize:function(b){if(typeof b!="object")b={};b=FB.copy(b||{},FB.Canvas._computeContentSize());b=FB.copy(b,{frame:window.name||'iframe_canvas'});if(FB.Canvas._lastSize[b.frame]){var a=FB.Canvas._lastSize[b.frame].height;if(FB.Canvas._lastSize[b.frame].width==b.width&&(b.height<=a&&(a-b.height<=16)))return false;}FB.Canvas._lastSize[b.frame]=b;FB.Arbiter.inform('setSize',b);return true;},setAutoResize:function(b,a){if(a===undefined&&typeof b=="number"){a=b;b=true;}if(b===undefined||b){if(FB.Canvas._timer===null)FB.Canvas._timer=window.setInterval(FB.Canvas.setSize,a||100);FB.Canvas.setSize();}else if(FB.Canvas._timer!==null){window.clearInterval(FB.Canvas._timer);FB.Canvas._timer=null;}},_computeContentSize:function(){var a=document.body,c=document.documentElement,d=0,b=Math.max(Math.max(a.offsetHeight,a.scrollHeight)+a.offsetTop,Math.max(c.offsetHeight,c.scrollHeight)+c.offsetTop);if(a.offsetWidthd)d=f;});if(c.clientLeft>0)d+=(c.clientLeft*2);if(c.clientTop>0)b+=(c.clientTop*2);return {height:b,width:d};}}); -FB.provide('UIServer.Methods',{'stream.share':{size:{width:575,height:380},url:'sharer.php',transform:function(a){if(!a.params.u)a.params.u=window.location.toString();return a;}},'fbml.dialog':{size:{width:575,height:300},url:'render_fbml.php',loggedOutIframe:true,transform:function(a){return a;}},'auth.logintofacebook':{size:{width:530,height:287},url:'login.php',transform:function(a){a.params.skip_api_login=1;var c=FB.UIServer.getXdRelation(a.params.display);var b=FB.UIServer._xdResult(a.cb,a.id,c,true);a.params.next=FB.getDomain(FB._https?'https_www':'www')+"login.php?"+FB.QS.encode({api_key:FB._apiKey,next:b,skip_api_login:1});return a;}}}); -FB.provide('',{share:function(a){FB.log('FB.share() has been deprecated. Please use FB.ui() instead.');FB.ui({display:'popup',method:'stream.share',u:a});},publish:function(b,a){FB.log('FB.publish() has been deprecated. Please use FB.ui() instead.');b=b||{};FB.ui(FB.copy({display:'popup',method:'stream.publish',preview:1},b||{}),a);},addFriend:function(b,a){FB.log('FB.addFriend() has been deprecated. Please use FB.ui() instead.');FB.ui({display:'popup',id:b,method:'friend.add'},a);}});FB.UIServer.Methods['auth.login']=FB.UIServer.Methods['permissions.request']; -FB.provide('XFBML',{_renderTimeout:30000,parse:function(c,a){c=c||document.body;var b=1,d=function(){b--;if(b===0){a&&a();FB.Event.fire('xfbml.render');}};FB.Array.forEach(FB.XFBML._tagInfos,function(f){if(!f.xmlns)f.xmlns='fb';var g=FB.XFBML._getDomElements(c,f.xmlns,f.localName);for(var e=0;e0)FB.log(b+' XFBML tags failed to render in '+FB.XFBML._renderTimeout+'ms.');},FB.XFBML._renderTimeout);d();},registerTag:function(a){FB.XFBML._tagInfos.push(a);},_processElement:function(dom,tagInfo,cb){var element=dom._element;if(element){element.subscribe('render',cb);element.process();}else{var processor=function(){var fn=eval(tagInfo.className);var getBoolAttr=function(attr){var attr=dom.getAttribute(attr);return (attr&&FB.Array.indexOf(['true','1','yes','on'],attr.toLowerCase())>-1);};var isLogin=false;var showFaces=true;var renderInIframe=false;if(tagInfo.className==='FB.XFBML.LoginButton'){renderInIframe=getBoolAttr('render-in-iframe');showFaces=getBoolAttr('show-faces')||getBoolAttr('show_faces');isLogin=renderInIframe||showFaces;if(isLogin)fn=FB.XFBML.Login;}element=dom._element=new fn(dom);if(isLogin){var extraParams={show_faces:showFaces};var perms=dom.getAttribute('perms');if(perms)extraParams.perms=perms;element.setExtraParams(extraParams);}element.subscribe('render',cb);element.process();};if(FB.CLASSES[tagInfo.className.substr(3)]){processor();}else FB.log('Tag '+tagInfo.className+' was not found.');}},_getDomElements:function(a,e,d){var c=e+':'+d;switch(FB.Dom.getBrowserType()){case 'mozilla':return a.getElementsByTagNameNS(document.body.namespaceURI,c);case 'ie':try{var docNamespaces=document.namespaces;if(docNamespaces&&docNamespaces[e]){var nodes=a.getElementsByTagName(d);if(!document.addEventListener||nodes.length>0)return nodes;}}catch(b){}return a.getElementsByTagName(c);default:return a.getElementsByTagName(c);}},_tagInfos:[{localName:'activity',className:'FB.XFBML.Activity'},{localName:'add-profile-tab',className:'FB.XFBML.AddProfileTab'},{localName:'bookmark',className:'FB.XFBML.Bookmark'},{localName:'comments',className:'FB.XFBML.Comments'},{localName:'connect-bar',className:'FB.XFBML.ConnectBar'},{localName:'fan',className:'FB.XFBML.Fan'},{localName:'like',className:'FB.XFBML.Like'},{localName:'like-box',className:'FB.XFBML.LikeBox'},{localName:'live-stream',className:'FB.XFBML.LiveStream'},{localName:'login',className:'FB.XFBML.Login'},{localName:'login-button',className:'FB.XFBML.LoginButton'},{localName:'facepile',className:'FB.XFBML.Facepile'},{localName:'friendpile',className:'FB.XFBML.Friendpile'},{localName:'name',className:'FB.XFBML.Name'},{localName:'profile-pic',className:'FB.XFBML.ProfilePic'},{localName:'recommendations',className:'FB.XFBML.Recommendations'},{localName:'registration',className:'FB.XFBML.Registration'},{localName:'send',className:'FB.XFBML.Send'},{localName:'serverfbml',className:'FB.XFBML.ServerFbml'},{localName:'share-button',className:'FB.XFBML.ShareButton'},{localName:'social-bar',className:'FB.XFBML.SocialBar'}]});(function(){try{if(document.namespaces&&!document.namespaces.item.fb)document.namespaces.add('fb');}catch(a){}}()); -FB.provide('XFBML',{set:function(b,c,a){FB.log('FB.XFBML.set() has been deprecated.');b.innerHTML=c;FB.XFBML.parse(b,a);}}); -FB.provide('',{bind:function(){var a=Array.prototype.slice.call(arguments),c=a.shift(),b=a.shift();return function(){return c.apply(b,a.concat(Array.prototype.slice.call(arguments)));};},Class:function(b,a,d){if(FB.CLASSES[b])return FB.CLASSES[b];var c=a||function(){};c.prototype=d;c.prototype.bind=function(e){return FB.bind(e,this);};c.prototype.constructor=c;FB.create(b,c);FB.CLASSES[b]=c;return c;},subclass:function(d,b,c,e){if(FB.CLASSES[d])return FB.CLASSES[d];var a=FB.create(b);FB.copy(e,a.prototype);e._base=a;e._callBase=function(g){var f=Array.prototype.slice.call(arguments,1);return a.prototype[g].apply(this,f);};return FB.Class(d,c?c:function(){if(a.apply)a.apply(this,arguments);},e);},CLASSES:{}});FB.provide('Type',{isType:function(a,b){while(a)if(a.constructor===b||a===b){return true;}else a=a._base;return false;}}); -FB.Class('Obj',null,FB.copy({setProperty:function(a,b){if(FB.JSON.stringify(b)!=FB.JSON.stringify(this[a])){this[a]=b;this.fire(a,b);}}},FB.EventProvider)); -FB.subclass('Waitable','Obj',function(){},{set:function(a){this.setProperty('value',a);},error:function(a){this.fire("error",a);},wait:function(a,b){if(b)this.subscribe('error',b);this.monitor('value',this.bind(function(){if(this.value!==undefined){a(this.value);return true;}}));}}); -FB.subclass('Data.Query','Waitable',function(){if(!FB.Data.Query._c)FB.Data.Query._c=1;this.name='v_'+FB.Data.Query._c++;},{parse:function(a){var b=FB.String.format.apply(null,a),d=(/^select (.*?) from (\w+)\s+where (.*)$/i).exec(b);this.fields=this._toFields(d[1]);this.table=d[2];this.where=this._parseWhere(d[3]);for(var c=1;c-1){return d;}else return b;});},isValid:function(){for(var a=this.dom;a;a=a.parentNode)if(a==document.body)return true;},clear:function(){this.dom.innerHTML='';}},FB.EventProvider)); -FB.subclass('XFBML.IframeWidget','XFBML.Element',null,{_showLoader:true,_refreshOnAuthChange:false,_allowReProcess:false,_fetchPreCachedLoader:false,_visibleAfter:'load',getUrlBits:function(){throw new Error('Inheriting class needs to implement getUrlBits().');},setupAndValidate:function(){return true;},oneTimeSetup:function(){},getSize:function(){},getIframeName:function(){},getIframeTitle:function(){},getChannelUrl:function(){if(!this._channelUrl){var a=this;this._channelUrl=FB.XD.handler(function(b){a.fire('xd.'+b.type,b);},'parent.parent',true);}return this._channelUrl;},getIframeNode:function(){return this.dom.getElementsByTagName('iframe')[0];},process:function(a){if(this._done){if(!this._allowReProcess&&!a)return;this.clear();}else this._oneTimeSetup();this._done=true;if(!this.setupAndValidate()){this.fire('render');return;}if(this._showLoader)this._addLoader();FB.Dom.addCss(this.dom,'fb_iframe_widget');if(this._visibleAfter!='immediate'){FB.Dom.addCss(this.dom,'fb_hide_iframes');}else this.subscribe('iframe.onload',FB.bind(this.fire,this,'render'));var c=this.getSize()||{};var d=this._getURL();if(!this._fetchPreCachedLoader)d+='?'+FB.QS.encode(this._getQS());if(d.length>2000){d='about:blank';var b=FB.bind(function(){this._postRequest();this.unsubscribe('iframe.onload',b);},this);this.subscribe('iframe.onload',b);}FB.Content.insertIframe({url:d,root:this.dom.appendChild(document.createElement('span')),name:this.getIframeName(),title:this.getIframeTitle(),className:FB._localeIsRtl?'fb_rtl':'fb_ltr',height:c.height,width:c.width,onload:FB.bind(this.fire,this,'iframe.onload')});},_oneTimeSetup:function(){this.subscribe('xd.resize',FB.bind(this._handleResizeMsg,this));if(FB.getLoginStatus){this.subscribe('xd.refreshLoginStatus',FB.bind(FB.getLoginStatus,FB,function(){},true));this.subscribe('xd.logout',FB.bind(FB.logout,FB,function(){}));}if(this._refreshOnAuthChange)this._setupAuthRefresh();if(this._visibleAfter=='load')this.subscribe('iframe.onload',FB.bind(this._makeVisible,this));this.oneTimeSetup();},_makeVisible:function(){this._removeLoader();FB.Dom.removeCss(this.dom,'fb_hide_iframes');this.fire('render');},_setupAuthRefresh:function(){FB.getLoginStatus(FB.bind(function(b){var a=b.status;FB.Event.subscribe('auth.statusChange',FB.bind(function(c){if(!this.isValid())return;if(a=='unknown'||c.status=='unknown')this.process(true);a=c.status;},this));},this));},_handleResizeMsg:function(b){if(!this.isValid())return;var a=this.getIframeNode();a.style.height=b.height+'px';if(b.width)a.style.width=b.width+'px';a.style.border='none';this._makeVisible();},_addLoader:function(){if(!this._loaderDiv){FB.Dom.addCss(this.dom,'fb_iframe_widget_loader');this._loaderDiv=document.createElement('div');this._loaderDiv.className='FB_Loader';this.dom.appendChild(this._loaderDiv);}},_removeLoader:function(){if(this._loaderDiv){FB.Dom.removeCss(this.dom,'fb_iframe_widget_loader');if(this._loaderDiv.parentNode)this._loaderDiv.parentNode.removeChild(this._loaderDiv);this._loaderDiv=null;}},_getQS:function(){return FB.copy({api_key:FB._apiKey,locale:FB._locale,sdk:'joey',session_key:FB._session&&FB._session.session_key,ref:this.getAttribute('ref')},this.getUrlBits().params);},_getURL:function(){var a='www',b='';if(this._fetchPreCachedLoader){a='cdn';b='static/';}return FB.getDomain(a)+'plugins/'+b+this.getUrlBits().name+'.php';},_postRequest:function(){FB.Content.postTarget({url:this._getURL(),target:this.getIframeNode().name,params:this._getQS()});}}); -FB.subclass('XFBML.Activity','XFBML.IframeWidget',null,{_visibleAfter:'load',_refreshOnAuthChange:true,setupAndValidate:function(){this._attr={border_color:this.getAttribute('border-color'),colorscheme:this.getAttribute('color-scheme'),filter:this.getAttribute('filter'),font:this.getAttribute('font'),header:this._getBoolAttribute('header'),height:this._getPxAttribute('height',300),recommendations:this._getBoolAttribute('recommendations'),site:this.getAttribute('site',location.hostname),width:this._getPxAttribute('width',300)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'activity',params:this._attr};}}); -FB.subclass('XFBML.ButtonElement','XFBML.Element',null,{_allowedSizes:['icon','small','medium','large','xlarge'],onClick:function(){throw new Error('Inheriting class needs to implement onClick().');},setupAndValidate:function(){return true;},getButtonMarkup:function(){return this.getOriginalHTML();},getOriginalHTML:function(){return this._originalHTML;},process:function(){if(!('_originalHTML' in this))this._originalHTML=FB.String.trim(this.dom.innerHTML);if(!this.setupAndValidate()){this.fire('render');return;}var d=this._getAttributeFromList('size','medium',this._allowedSizes),a='',b='';if(d=='icon'){a='fb_button_simple';}else{var c=FB._localeIsRtl?'_rtl':'';b=this.getButtonMarkup();a='fb_button'+c+' fb_button_'+d+c;}this.dom.innerHTML=(''+''+b+''+'');this.dom.firstChild.onclick=FB.bind(this.onClick,this);this.fire('render');}}); -FB.provide('Helper',{isUser:function(a){return a<2.2e+09||(a>=1e+14&&a<=100099999989999);},getLoggedInUser:function(){return FB._session?FB._session.uid:null;},upperCaseFirstChar:function(a){if(a.length>0){return a.substr(0,1).toUpperCase()+a.substr(1);}else return a;},getProfileLink:function(c,b,a){a=a||(c?FB.getDomain('www')+'profile.php?id='+c.uid:null);if(a)b=''+b+'';return b;},invokeHandler:function(handler,scope,args){if(handler)if(typeof handler==='string'){eval(handler);}else if(handler.apply)handler.apply(scope,args||[]);},fireEvent:function(a,b){var c=b._attr.href;b.fire(a,c);FB.Event.fire(a,c,b);},executeFunctionByName:function(d){var a=Array.prototype.slice.call(arguments,1);var f=d.split(".");var c=f.pop();var b=window;for(var e=0;e0){a.xid=encodeURIComponent(document.URL.substring(0,b));}else a.xid=encodeURIComponent(document.URL);}if(a.migrated&&!a.href)a.href='http://www.facebook.com/plugins/comments_v1.php?'+'app_id='+FB._apiKey+'&xid='+encodeURIComponent(a.xid)+'&url='+encodeURIComponent(a.url);this._attr=a;return true;},oneTimeSetup:function(){this.subscribe('xd.addComment',FB.bind(this._handleCommentMsg,this));},getSize:function(){return {width:this._attr.width,height:200};},getUrlBits:function(){return {name:'comments',params:this._attr};},_handleCommentMsg:function(a){if(!this.isValid())return;FB.Event.fire('comments.add',{post:a.post,user:a.user,widget:this});}}); -FB.provide('Anim',{ate:function(c,g,d,b){d=!isNaN(parseFloat(d))&&d>=0?d:750;var e=40,f={},j={},a=null,h=c.style,i=setInterval(FB.bind(function(){if(!a)a=new Date().getTime();var k=1;if(d!=0)k=Math.min((new Date().getTime()-a)/d,1);FB.Array.forEach(g,FB.bind(function(o,m){if(!f[m]){var n=FB.Dom.getStyle(c,m);if(n===false)return;f[m]=this._parseCSS(n+'');}if(!j[m])j[m]=this._parseCSS(o.toString());var l='';FB.Array.forEach(f[m],function(q,p){if(isNaN(j[m][p].numPart)&&j[m][p].textPart=='?'){l=q.numPart+q.textPart;}else if(isNaN(q.numPart)){l=q.textPart;}else l+=(q.numPart+Math.ceil((j[m][p].numPart-q.numPart)*Math.sin(Math.PI/2*k)))+j[m][p].textPart+' ';});FB.Dom.setStyle(c,m,l);},this));if(k==1){clearInterval(i);if(b)b(c);}},this),e);},_parseCSS:function(a){var b=[];FB.Array.forEach(a.split(' '),function(d){var c=parseInt(d,10);b.push({numPart:c,textPart:d.replace(c,'')});});return b;}}); -FB.provide('Insights',{impression:function(e,a){var b=FB.guid(),g="//ah8.facebook.com/impression.php/"+b+"/",c=new Image(1,1),f=[];if(!e.api_key&&FB._apiKey)e.api_key=FB._apiKey;for(var d in e)f.push(encodeURIComponent(d)+'='+encodeURIComponent(e[d]));g+='?'+f.join('&');if(a)c.onload=a;c.src=g;}}); -FB.subclass('XFBML.ConnectBar','XFBML.Element',null,{_initialHeight:null,_initTopMargin:0,_picFieldName:'pic_square',_page:null,_displayed:false,_notDisplayed:false,_container:null,_animationSpeed:0,process:function(){FB.getLoginStatus(this.bind(function(a){FB.Event.monitor('auth.statusChange',this.bind(function(){if(this.isValid()&&FB._userStatus=='connected'){this._uid=FB.Helper.getLoggedInUser();FB.api({method:'Connect.shouldShowConnectBar'},this.bind(function(b){if(b!=2){this._animationSpeed=(b==0)?750:0;this._showBar();}else this._noRender();}));}else this._noRender();return false;}));}));},_showBar:function(){var a=FB.Data._selectByIndex(['first_name','profile_url',this._picFieldName],'user','uid',this._uid);var b=FB.Data._selectByIndex(['display_name'],'application','api_key',FB._apiKey);FB.Data.waitOn([a,b],FB.bind(function(c){c[0][0].site_name=c[1][0].display_name;if(!this._displayed){this._displayed=true;this._notDisplayed=false;this._renderConnectBar(c[0][0]);this.fire('render');FB.Insights.impression({lid:104,name:'widget_load'});this.fire('connectbar.ondisplay');FB.Event.fire('connectbar.ondisplay',this);FB.Helper.invokeHandler(this.getAttribute('on-display'),this);}},this));},_noRender:function(){if(this._displayed){this._displayed=false;this._closeConnectBar();}if(!this._notDisplayed){this._notDisplayed=true;this.fire('render');this.fire('connectbar.onnotdisplay');FB.Event.fire('connectbar.onnotdisplay',this);FB.Helper.invokeHandler(this.getAttribute('on-not-display'),this);}},_renderConnectBar:function(d){var b=document.createElement('div'),c=document.createElement('div');b.className='fb_connect_bar';c.className='fb_reset fb_connect_bar_container';c.appendChild(b);document.body.appendChild(c);this._container=c;this._initialHeight=Math.round(parseFloat(FB.Dom.getStyle(c,'height'))+parseFloat(FB.Dom.getStyle(c,'borderBottomWidth')));b.innerHTML=FB.String.format('
'+''+'{2}'+''+'
'+''+'{4}'+''+'{5}'+' '+'{6} – '+'{0}'+'',FB.Intl._tx("No Thanks"),FB.getDomain('cdn')+FB.XFBML.ConnectBar.imgs.buttonUrl,FB.Intl._tx("Close"),d[this._picFieldName]||FB.getDomain('cdn')+FB.XFBML.ConnectBar.imgs.missingProfileUrl,FB.String.escapeHTML(d.first_name),FB.Intl._tx("Hi {firstName}. \u003cstrong>{siteName}\u003c\/strong> is using Facebook to personalize your experience.",{firstName:FB.String.escapeHTML(d.first_name),siteName:FB.String.escapeHTML(d.site_name)}),FB.Intl._tx("Learn More"),d.profile_url,FB.getDomain('www')+'sitetour/connect.php');var a=this;FB.Array.forEach(b.getElementsByTagName('a'),function(g){g.onclick=FB.bind(a._clickHandler,a);});this._page=document.body;var f=0;if(this._page.parentNode){f=Math.round((parseFloat(FB.Dom.getStyle(this._page.parentNode,'height'))-parseFloat(FB.Dom.getStyle(this._page,'height')))/2);}else f=parseInt(FB.Dom.getStyle(this._page,'marginTop'),10);f=isNaN(f)?0:f;this._initTopMargin=f;if(!window.XMLHttpRequest){c.className+=" fb_connect_bar_container_ie6";}else{c.style.top=(-1*this._initialHeight)+'px';FB.Anim.ate(c,{top:'0px'},this._animationSpeed);}var e={marginTop:this._initTopMargin+this._initialHeight+'px'};if(FB.Dom.getBrowserType()=='ie'){e.backgroundPositionY=this._initialHeight+'px';}else e.backgroundPosition='? '+this._initialHeight+'px';FB.Anim.ate(this._page,e,this._animationSpeed);},_clickHandler:function(a){a=a||window.event;var b=a.target||a.srcElement;while(b.nodeName!='A')b=b.parentNode;switch(b.className){case 'fb_bar_close':FB.api({method:'Connect.connectBarMarkAcknowledged'});FB.Insights.impression({lid:104,name:'widget_user_closed'});this._closeConnectBar();break;case 'fb_learn_more':case 'fb_profile':window.open(b.href);break;case 'fb_no_thanks':this._closeConnectBar();FB.api({method:'Connect.connectBarMarkAcknowledged'});FB.Insights.impression({lid:104,name:'widget_user_no_thanks'});FB.api({method:'auth.revokeAuthorization',block:true},this.bind(function(){this.fire('connectbar.ondeauth');FB.Event.fire('connectbar.ondeauth',this);FB.Helper.invokeHandler(this.getAttribute('on-deauth'),this);if(this._getBoolAttribute('auto-refresh',true))window.location.reload();}));break;}return false;},_closeConnectBar:function(){this._notDisplayed=true;var a={marginTop:this._initTopMargin+'px'};if(FB.Dom.getBrowserType()=='ie'){a.backgroundPositionY='0px';}else a.backgroundPosition='? 0px';var b=(this._animationSpeed==0)?0:300;FB.Anim.ate(this._page,a,b);FB.Anim.ate(this._container,{top:(-1*this._initialHeight)+'px'},b,function(c){c.parentNode.removeChild(c);});this.fire('connectbar.onclose');FB.Event.fire('connectbar.onclose',this);FB.Helper.invokeHandler(this.getAttribute('on-close'),this);}});FB.provide('XFBML.ConnectBar',{imgs:{buttonUrl:'images/facebook-widgets/close_btn.png',missingProfileUrl:'pics/q_silhouette.gif'}}); -FB.subclass('XFBML.Facepile','XFBML.IframeWidget',null,{_visibleAfter:'load',_extraParams:{},setupAndValidate:function(){this._attr={href:this.getAttribute('href'),channel:this.getChannelUrl(),max_rows:this.getAttribute('max-rows'),width:this._getPxAttribute('width',200),ref:this.getAttribute('ref')};for(var a in this._extraParams)this._attr[a]=this._extraParams[a];return true;},setExtraParams:function(a){this._extraParams=a;},oneTimeSetup:function(){var a=FB._userStatus;FB.Event.subscribe('auth.statusChange',FB.bind(function(b){if(a=='connected'||b.status=='connected')this.process(true);a=b.status;},this));},getSize:function(){return {width:this._attr.width,height:70};},getUrlBits:function(){return {name:'facepile',params:this._attr};}}); -FB.subclass('XFBML.Fan','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={api_key:FB._apiKey,connections:this.getAttribute('connections','10'),css:this.getAttribute('css'),height:this._getPxAttribute('height'),id:this.getAttribute('profile-id'),logobar:this._getBoolAttribute('logo-bar'),name:this.getAttribute('name'),stream:this._getBoolAttribute('stream',true),width:this._getPxAttribute('width',300)};if(!this._attr.id&&!this._attr.name){FB.log(' requires one of the "id" or "name" attributes.');return false;}var a=this._attr.height;if(!a)if((!this._attr.connections||this._attr.connections==='0')&&!this._attr.stream){a=65;}else if(!this._attr.connections||this._attr.connections==='0'){a=375;}else if(!this._attr.stream){a=250;}else a=550;if(this._attr.logobar)a+=25;this._attr.height=a;return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'fan',params:this._attr};}}); -FB.subclass('XFBML.Friendpile','XFBML.Facepile',null,{}); -FB.subclass('XFBML.EdgeCommentWidget','XFBML.IframeWidget',function(a){this._iframeWidth=a.width;this._iframeHeight=a.height;this._attr={master_frame_name:a.masterFrameName};this.dom=a.commentNode;this.dom.style.top=a.relativeHeightOffset;if(a.relativeWidthOffset)if(FB._localeIsRtl){this.dom.style.right=a.relativeWidthOffset;}else this.dom.style.left=a.relativeWidthOffset;this.dom.style.zIndex=FB.XFBML.EdgeCommentWidget.NextZIndex++;FB.Dom.addCss(this.dom,'fb_edge_comment_widget');},{_visibleAfter:'load',_showLoader:false,getSize:function(){return {width:this._iframeWidth,height:this._iframeHeight};},getUrlBits:function(){return {name:'comment_widget_shell',params:this._attr};}});FB.provide('XFBML.EdgeCommentWidget',{NextZIndex:10000}); -FB.subclass('XFBML.EdgeWidget','XFBML.IframeWidget',null,{_visibleAfter:'immediate',_showLoader:false,setupAndValidate:function(){FB.Dom.addCss(this.dom,'fb_edge_widget_with_comment');this._attr={channel_url:this.getChannelUrl(),debug:this._getBoolAttribute('debug'),href:this.getAttribute('href',window.location.href),is_permalink:this._getBoolAttribute('is-permalink'),node_type:this.getAttribute('node-type','link'),width:this._getWidgetWidth(),font:this.getAttribute('font'),layout:this._getLayout(),colorscheme:this.getAttribute('color-scheme'),action:this.getAttribute('action'),ref:this.getAttribute('ref'),show_faces:this._shouldShowFaces(),no_resize:this._getBoolAttribute('no_resize')};return true;},oneTimeSetup:function(){this.subscribe('xd.edgeCreated',FB.bind(this._onEdgeCreate,this));this.subscribe('xd.edgeRemoved',FB.bind(this._onEdgeRemove,this));this.subscribe('xd.presentEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogPresentation,this));this.subscribe('xd.dismissEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogDismissal,this));this.subscribe('xd.hideEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogHide,this));this.subscribe('xd.showEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogShow,this));},getSize:function(){return {width:this._getWidgetWidth(),height:this._getWidgetHeight()};},_getWidgetHeight:function(){var a=this._getLayout();var c=this._shouldShowFaces()?'show':'hide';var b={standard:{show:80,hide:35},box_count:{show:65,hide:65},button_count:{show:21,hide:21}};return b[a][c];},_getWidgetWidth:function(){var e=this._getLayout();var g=this._shouldShowFaces()?'show':'hide';var c=this.getAttribute('action')==='recommend'?130:90;var b=this.getAttribute('action')==='recommend'?100:55;var f={standard:{show:450,hide:450},box_count:{show:b,hide:b},button_count:{show:c,hide:c}};var d=f[e][g];var h=this._getPxAttribute('width',d);var a={standard:{min:225,max:900},box_count:{min:b,max:900},button_count:{min:c,max:900}};if(ha[e].max)h=a[e].max;return h;},_getLayout:function(){return this._getAttributeFromList('layout','standard',['standard','button_count','box_count']);},_shouldShowFaces:function(){return this._getLayout()==='standard'&&this._getBoolAttribute('show-faces',true);},_handleEdgeCommentDialogPresentation:function(b){if(!this.isValid())return;var a=document.createElement('span');this._commentSlave=this._createEdgeCommentWidget(b,a);this.dom.appendChild(a);this._commentSlave.process();this._commentWidgetNode=a;},_createEdgeCommentWidget:function(b,a){var c={commentNode:a,externalUrl:b.externalURL,width:330,height:200,masterFrameName:b.masterFrameName,layout:this._getLayout(),relativeHeightOffset:this._getHeightOffset(),relativeWidthOffset:this._getWidthOffset(b)};return new FB.XFBML.EdgeCommentWidget(c);},_getHeightOffset:function(){var a=this._getLayout();var b={standard:'20px',button_count:'17px',box_count:'-5px'};return b[a];},_getWidthOffset:function(c){if(c.preComputedWidthOffset)return parseInt(c.preComputedWidthOffset,10)+'px';var a=this._getLayout();var b={standard:'17px',box_count:'0px',button_count:'0px'};return b[a];},_handleEdgeCommentDialogDismissal:function(a){if(this._commentWidgetNode){this.dom.removeChild(this._commentWidgetNode);delete this._commentWidgetNode;}},_handleEdgeCommentDialogHide:function(){if(this._commentWidgetNode)this._commentWidgetNode.style.display="none";},_handleEdgeCommentDialogShow:function(){if(this._commentWidgetNode)this._commentWidgetNode.style.display="block";},_fireEventAndInvokeHandler:function(b,a){FB.Helper.fireEvent(b,this);FB.Helper.invokeHandler(this.getAttribute(a),this,[this._attr.href]);},_onEdgeCreate:function(){this._fireEventAndInvokeHandler('edge.create','on-create');},_onEdgeRemove:function(){this._fireEventAndInvokeHandler('edge.remove','on-remove');}}); -FB.subclass('XFBML.Like','XFBML.EdgeWidget',null,{getUrlBits:function(){return {name:'like',params:this._attr};},getIframeTitle:function(){return 'Like this content on Facebook.';}}); -FB.subclass('XFBML.LikeBox','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={channel:this.getChannelUrl(),api_key:FB._apiKey,connections:this.getAttribute('connections'),css:this.getAttribute('css'),height:this.getAttribute('height'),id:this.getAttribute('profile-id'),header:this._getBoolAttribute('header',true),name:this.getAttribute('name'),show_faces:this._getBoolAttribute('show-faces',true),stream:this._getBoolAttribute('stream',true),width:this._getPxAttribute('width',300),href:this.getAttribute('href'),colorscheme:this.getAttribute('colorscheme','light')};if(this._attr.connections==='0'){this._attr.show_faces=false;}else if(this._attr.connections)this._attr.show_faces=true;if(!this._attr.id&&!this._attr.name&&!this._attr.href){FB.log(' requires one of the "id" or "name" attributes.');return false;}var a=this._attr.height;if(!a)if(!this._attr.show_faces&&!this._attr.stream){a=62;}else{a=95;if(this._attr.show_faces)a+=163;if(this._attr.stream)a+=300;if(this._attr.header&&this._attr.header!=='0')a+=32;}this._attr.height=a;this.subscribe('xd.likeboxLiked',FB.bind(this._onLiked,this));this.subscribe('xd.likeboxUnliked',FB.bind(this._onUnliked,this));return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'likebox',params:this._attr};},_onLiked:function(){FB.Helper.fireEvent('edge.create',this);},_onUnliked:function(){FB.Helper.fireEvent('edge.remove',this);}}); -FB.subclass('XFBML.LiveStream','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={height:this._getPxAttribute('height',500),hideFriendsTab:this.getAttribute('hide-friends-tab'),redesigned:this._getBoolAttribute('redesigned-stream'),width:this._getPxAttribute('width',400),xid:this.getAttribute('xid','default'),always_post_to_friends:this._getBoolAttribute('always-post-to-friends',false)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){var a=this._attr.redesigned?'live_stream_box':'livefeed';return {name:a,params:this._attr};}}); -FB.subclass('XFBML.Login','XFBML.Facepile',null,{_visibleAfter:'load',getSize:function(){return {width:this._attr.width,height:94};},getUrlBits:function(){return {name:'login',params:this._attr};}}); -FB.subclass('XFBML.LoginButton','XFBML.ButtonElement',null,{setupAndValidate:function(){if(this._alreadySetup)return true;this._alreadySetup=true;this._attr={autologoutlink:this._getBoolAttribute('auto-logout-link'),length:this._getAttributeFromList('length','short',['long','short']),onlogin:this.getAttribute('on-login'),perms:this.getAttribute('perms'),registration_url:this.getAttribute('registration-url'),status:'unknown'};if(this._attr.autologoutlink)FB.Event.subscribe('auth.statusChange',FB.bind(this.process,this));if(this._attr.registration_url){FB.Event.subscribe('auth.statusChange',this._saveStatus(this.process));FB.getLoginStatus(this._saveStatus(this.process));}return true;},getButtonMarkup:function(){var a=this.getOriginalHTML();if(a)return a;if(!this._attr.registration_url){if(FB.getSession()&&this._attr.autologoutlink){return FB.Intl._tx("Facebook Logout");}else return this._getLoginText();}else switch(this._attr.status){case 'unknown':return this._getLoginText();case 'notConnected':return FB.Intl._tx("Register");case 'connected':if(FB.getSession()&&this._attr.autologoutlink)return FB.Intl._tx("Facebook Logout");return this._getLoginText();default:FB.log('Unknown status: '+this.status);return FB.Intl._tx("Login");}},_getLoginText:function(){return this._attr.length=='short'?FB.Intl._tx("Login"):FB.Intl._tx("Login with Facebook");},onClick:function(){if(!this._attr.registration_url){if(!FB.getSession()||!this._attr.autologoutlink){FB.login(FB.bind(this._authCallback,this),{perms:this._attr.perms});}else FB.logout(FB.bind(this._authCallback,this));}else switch(this._attr.status){case 'unknown':FB.ui({method:'auth.loginToFacebook'},FB.bind(function(a){FB.getLoginStatus(this._saveStatus(this._authCallback),true);},this));break;case 'notConnected':window.top.location=this._attr.registration_url;break;case 'connected':if(!FB.getSession()||!this._attr.autologoutlink){this._authCallback();}else FB.logout(FB.bind(this._authCallback,this));break;default:FB.log('Unknown status: '+this.status);}},_authCallback:function(a){FB.Helper.invokeHandler(this._attr.onlogin,this,[a]);},_saveStatus:function(a){return FB.bind(function(b){this._attr.status=b.status;if(a){a=this.bind(a,this);return a(b);}},this);}}); -FB.subclass('XFBML.Name','XFBML.Element',null,{process:function(){FB.copy(this,{_uid:this.getAttribute('uid'),_firstnameonly:this._getBoolAttribute('first-name-only'),_lastnameonly:this._getBoolAttribute('last-name-only'),_possessive:this._getBoolAttribute('possessive'),_reflexive:this._getBoolAttribute('reflexive'),_objective:this._getBoolAttribute('objective'),_linked:this._getBoolAttribute('linked',true),_subjectId:this.getAttribute('subject-id')});if(!this._uid){FB.log('"uid" is a required attribute for ');this.fire('render');return;}var b=[];if(this._firstnameonly){b.push('first_name');}else if(this._lastnameonly){b.push('last_name');}else b.push('name');if(this._subjectId){b.push('sex');if(this._subjectId==FB.Helper.getLoggedInUser())this._reflexive=true;}var a;FB.Event.monitor('auth.statusChange',this.bind(function(){if(!this.isValid()){this.fire('render');return true;}if(!this._uid||this._uid=='loggedinuser')this._uid=FB.Helper.getLoggedInUser();if(!this._uid)return;if(FB.Helper.isUser(this._uid)){a=FB.Data._selectByIndex(b,'user','uid',this._uid);}else a=FB.Data._selectByIndex(['name','id'],'profile','id',this._uid);a.wait(this.bind(function(c){if(this._subjectId==this._uid){this._renderPronoun(c[0]);}else this._renderOther(c[0]);this.fire('render');}));}));},_renderPronoun:function(b){var c='',a=this._objective;if(this._subjectId){a=true;if(this._subjectId===this._uid)this._reflexive=true;}if(this._uid==FB.Connect.get_loggedInUser()&&this._getBoolAttribute('use-you',true)){if(this._possessive){if(this._reflexive){c='your own';}else c='your';}else if(this._reflexive){c='yourself';}else c='you';}else switch(b.sex){case 'male':if(this._possessive){c=this._reflexive?'his own':'his';}else if(this._reflexive){c='himself';}else if(a){c='him';}else c='he';break;case 'female':if(this._possessive){c=this._reflexive?'her own':'her';}else if(this._reflexive){c='herself';}else if(a){c='her';}else c='she';break;default:if(this._getBoolAttribute('use-they',true)){if(this._possessive){if(this._reflexive){c='their own';}else c='their';}else if(this._reflexive){c='themselves';}else if(a){c='them';}else c='they';}else if(this._possessive){if(this._reflexive){c='his/her own';}else c='his/her';}else if(this._reflexive){c='himself/herself';}else if(a){c='him/her';}else c='he/she';break;}if(this._getBoolAttribute('capitalize',false))c=FB.Helper.upperCaseFirstChar(c);this.dom.innerHTML=c;},_renderOther:function(c){if(!c)return;var b='',a='';if(this._uid==FB.Helper.getLoggedInUser()&&this._getBoolAttribute('use-you',true)){if(this._reflexive){if(this._possessive){b='your own';}else b='yourself';}else if(this._possessive){b='your';}else b='you';}else{if(null===c.first_name)c.first_name='';if(null===c.last_name)c.last_name='';if(this._firstnameonly){b=FB.String.escapeHTML(c.first_name);}else if(this._lastnameonly)b=FB.String.escapeHTML(c.last_name);if(!b)b=FB.String.escapeHTML(c.name);if(b!==''&&this._possessive)b+='\'s';}if(!b)b=FB.String.escapeHTML(this.getAttribute('if-cant-see','Facebook User'));if(b){if(this._getBoolAttribute('capitalize',false))b=FB.Helper.upperCaseFirstChar(b);if(this._linked){a=FB.Helper.getProfileLink(c,b,this.getAttribute('href',null));}else a=b;}this.dom.innerHTML=a;}}); -FB.subclass('XFBML.ProfilePic','XFBML.Element',null,{process:function(){var d=this.getAttribute('size','thumb'),b=FB.XFBML.ProfilePic._sizeToPicFieldMap[d],g=this._getPxAttribute('width'),a=this._getPxAttribute('height'),e=this.dom.style,f=this.getAttribute('uid');if(this._getBoolAttribute('facebook-logo'))b+='_with_logo';if(g){g=g+'px';e.width=g;}if(a){a=a+'px';e.height=a;}var c=this.bind(function(j){var l=j?j[0]:null,i=l?l[b]:null;if(!i)i=FB.getDomain('cdn')+FB.XFBML.ProfilePic._defPicMap[b];var k=((g?'width:'+g+';':'')+(a?'height:'+g+';':'')),h=FB.String.format('{1}',i,l?FB.String.escapeHTML(l.name):'',k,this.dom.className);if(this._getBoolAttribute('linked',true))h=FB.Helper.getProfileLink(l,h,this.getAttribute('href',null));this.dom.innerHTML=h;FB.Dom.addCss(this.dom,'fb_profile_pic_rendered');this.fire('render');});FB.Event.monitor('auth.statusChange',this.bind(function(){if(!this.isValid()){this.fire('render');return true;}if(this.getAttribute('uid',null)=='loggedinuser')f=FB.Helper.getLoggedInUser();if(FB._userStatus&&f){FB.Data._selectByIndex(['name',b],FB.Helper.isUser(f)?'user':'profile',FB.Helper.isUser(f)?'uid':'id',f).wait(c);}else c();}));}});FB.provide('XFBML.ProfilePic',{_defPicMap:{pic:'pics/s_silhouette.jpg',pic_big:'pics/d_silhouette.gif',pic_big_with_logo:'pics/d_silhouette_logo.gif',pic_small:'pics/t_silhouette.jpg',pic_small_with_logo:'pics/t_silhouette_logo.gif',pic_square:'pics/q_silhouette.gif',pic_square_with_logo:'pics/q_silhouette_logo.gif',pic_with_logo:'pics/s_silhouette_logo.gif'},_sizeToPicFieldMap:{n:'pic_big',normal:'pic_big',q:'pic_square',s:'pic',small:'pic',square:'pic_square',t:'pic_small',thumb:'pic_small'}}); -FB.subclass('XFBML.Recommendations','XFBML.IframeWidget',null,{_visibleAfter:'load',_refreshOnAuthChange:true,setupAndValidate:function(){this._attr={border_color:this.getAttribute('border-color'),colorscheme:this.getAttribute('color-scheme'),filter:this.getAttribute('filter'),font:this.getAttribute('font'),header:this._getBoolAttribute('header'),height:this._getPxAttribute('height',300),site:this.getAttribute('site',location.hostname),width:this._getPxAttribute('width',300)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'recommendations',params:this._attr};}}); -FB.subclass('XFBML.Registration','XFBML.IframeWidget',null,{_visibleAfter:'immediate',_baseHeight:167,_fieldHeight:28,_skinnyWidth:520,_skinnyBaseHeight:173,_skinnyFieldHeight:52,setupAndValidate:function(){this._attr={channel_url:this.getChannelUrl(),client_id:FB._apiKey,fb_only:this._getBoolAttribute('fb-only',false),fields:this.getAttribute('fields'),height:this._getPxAttribute('height'),redirect_uri:this.getAttribute('redirect-uri',window.location.href),onvalidate:this.getAttribute('onvalidate'),width:this._getPxAttribute('width',600)};if(this._attr.onvalidate)this.subscribe('xd.validate',this.bind(function(b){var d=FB.JSON.parse(b.value);var a=this.bind(function(e){FB.Arbiter.inform('Registration.Validation',{errors:e,id:b.id},'parent.frames["'+this.getIframeNode().name+'"]');});var c=FB.Helper.executeFunctionByName(this._attr.onvalidate,d,a);if(c)a(c);}));return true;},getSize:function(){return {width:this._attr.width,height:this._getHeight()};},_getHeight:function(){if(this._attr.height)return this._attr.height;var b;if(!this._attr.fields){b=['name'];}else try{b=FB.JSON.parse(this._attr.fields);}catch(a){b=this._attr.fields.split(/,/);}if(this._attr.width requires the "fbml" attribute.');return false;}return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'serverfbml',params:this._attr};}}); -FB.subclass('XFBML.ShareButton','XFBML.Element',null,{process:function(){this._href=this.getAttribute('href',window.location.href);this._type=this.getAttribute('type','icon_link');FB.Dom.addCss(this.dom,'fb_share_count_hidden');this._renderButton(true);},_renderButton:function(f){if(!this.isValid()){this.fire('render');return;}var b='',c='',d='',a='',e=FB.Intl._tx("Share"),g='';switch(this._type){case 'icon':case 'icon_link':a='fb_button_simple';b=(''+(this._type=='icon_link'?e:' ')+'');f=false;break;case 'link':b=FB.Intl._tx("Share on Facebook");f=false;break;case 'button':b=''+e+'';a='fb_button fb_button_small';f=false;break;case 'button_count':b=''+e+'';c=(' '+''+this._getCounterMarkup()+'');a='fb_button fb_button_small';break;default:b=''+e+'';d=(' '+''+this._getCounterMarkup()+'');a='fb_button fb_button_small';g='fb_share_count_wrapper';}this.dom.innerHTML=FB.String.format('{4}{3}{5}',g,this._href,a,b,d,c,FB.JSON.stringify({method:'stream.share',u:this._href}));if(!f)this.fire('render');},_getCounterMarkup:function(){if(!this._count)this._count=FB.Data._selectByIndex(['total_count'],'link_stat','url',this._href);var b='0';if(this._count.value!==undefined){if(this._count.value.length>0){var a=this._count.value[0].total_count;if(a>3){FB.Dom.removeCss(this.dom,'fb_share_count_hidden');b=a>=1e+07?Math.round(a/1e+06)+'M':(a>=10000?Math.round(a/1000)+'K':a);}}}else this._count.wait(FB.bind(this._renderButton,this,false));return ''+b+'';}}); -void(0); - - -FB.provide("", {"_domain":{"api":"https:\/\/api.facebook.com\/","api_read":"https:\/\/api-read.facebook.com\/","cdn":"http:\/\/static.ak.fbcdn.net\/","graph":"https:\/\/graph.facebook.com\/","https_cdn":"https:\/\/s-static.ak.fbcdn.net\/","https_staticfb":"https:\/\/s-static.ak.facebook.com\/","https_www":"https:\/\/www.facebook.com\/","staticfb":"http:\/\/static.ak.facebook.com\/","www":"http:\/\/www.facebook.com\/"},"_locale":"en_US","_localeIsRtl":false}, true); -FB.provide("Flash", {"_minVersions":[[10,0,22,87]],"_swfPath":"rsrc.php\/v1\/yF\/r\/Y7YCBKX-HZn.swf"}, true); -FB.provide("XFBML.ConnectBar", {"imgs":{"buttonUrl":"rsrc.php\/yY\/r\/h_Y6u1wrZPW.png","missingProfileUrl":"rsrc.php\/yo\/r\/UlIqmHJn-SK.gif"}}, true); -FB.provide("XFBML.ProfilePic", {"_defPicMap":{"pic":"rsrc.php\/yh\/r\/C5yt7Cqf3zU.jpg","pic_big":"rsrc.php\/yL\/r\/HsTZSDw4avx.gif","pic_big_with_logo":"rsrc.php\/y5\/r\/SRDCaeCL7hM.gif","pic_small":"rsrc.php\/yi\/r\/odA9sNLrE86.jpg","pic_small_with_logo":"rsrc.php\/yD\/r\/k1xiRXKnlGd.gif","pic_square":"rsrc.php\/yo\/r\/UlIqmHJn-SK.gif","pic_square_with_logo":"rsrc.php\/yX\/r\/9dYJBPDHXwZ.gif","pic_with_logo":"rsrc.php\/yu\/r\/fPPR9f2FJ3t.gif"}}, true); -if (FB.Dom && FB.Dom.addCssRules) { FB.Dom.addCssRules(".fb_hidden{position:absolute;top:-10000px;z-index:10001}\n.fb_reset{background:none;border-spacing:0;border:0;color:#000;cursor:auto;direction:ltr;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;font-size:11px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal}\n.fb_link img{border:none}\n.fb_dialog{position:absolute;top:-10000px;z-index:10001}\n.fb_dialog_advanced{background:rgba(82, 82, 82, .7);padding:10px;-moz-border-radius:8px;-webkit-border-radius:8px}\n.fb_dialog_content{background:#fff;color:#333}\n.fb_dialog_close_icon{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 0 transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif);cursor:pointer;display:block;height:15px;position:absolute;right:18px;top:17px;width:15px;top:8px\\9;right:7px\\9}\n.fb_dialog_close_icon:hover{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -15px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif)}\n.fb_dialog_close_icon:active{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -30px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif)}\n.fb_dialog_loader{background-color:#f2f2f2;border:1px solid #606060;font-size:24px;padding:20px}\n.fb_dialog_top_left,\n.fb_dialog_top_right,\n.fb_dialog_bottom_left,\n.fb_dialog_bottom_right{height:10px;width:10px;overflow:hidden;position:absolute}\n.fb_dialog_top_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 0;left:-10px;top:-10px}\n.fb_dialog_top_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -10px;right:-10px;top:-10px}\n.fb_dialog_bottom_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -20px;bottom:-10px;left:-10px}\n.fb_dialog_bottom_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -30px;right:-10px;bottom:-10px}\n.fb_dialog_vert_left,\n.fb_dialog_vert_right,\n.fb_dialog_horiz_top,\n.fb_dialog_horiz_bottom{position:absolute;background:#525252;filter:alpha(opacity=70);opacity:.7}\n.fb_dialog_vert_left,\n.fb_dialog_vert_right{width:10px;height:100\u0025}\n.fb_dialog_vert_left{margin-left:-10px}\n.fb_dialog_vert_right{right:0;margin-right:-10px}\n.fb_dialog_horiz_top,\n.fb_dialog_horiz_bottom{width:100\u0025;height:10px}\n.fb_dialog_horiz_top{margin-top:-10px}\n.fb_dialog_horiz_bottom{bottom:0;margin-bottom:-10px}\n.fb_dialog_iframe{line-height:0}\n.fb_dialog_content .dialog_title{background:#6d84b4;border:1px solid #3b5998;color:#fff;font-size:14px;font-weight:bold;margin:0}\n.fb_dialog_content .dialog_title > span{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zd\/r\/Cou7n-nqK52.gif) no-repeat 5px 50\u0025;float:left;padding:5px 0 7px 26px}\n.fb_dialog_content .dialog_content{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/z9\/r\/jKEcVPZFk-2.gif) no-repeat 50\u0025 50\u0025;border:1px solid #555;border-bottom:0;border-top:0;height:150px}\n.fb_dialog_content .dialog_footer{background:#f2f2f2;border:1px solid #555;border-top-color:#ccc;height:40px}\n#fb_dialog_loader_close{float:right}\n.fb_iframe_widget{position:relative;display:-moz-inline-block;display:inline-block}\n.fb_iframe_widget iframe{position:relative;vertical-align:text-bottom}\n.fb_iframe_widget span{position:relative}\n.fb_hide_iframes iframe{position:relative;left:-10000px}\n.fb_iframe_widget_loader{position:relative;display:inline-block}\n.fb_iframe_widget_loader iframe{min-height:32px;z-index:2;zoom:1}\n.fb_iframe_widget_loader .FB_Loader{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/z9\/r\/jKEcVPZFk-2.gif) no-repeat;height:32px;width:32px;margin-left:-16px;position:absolute;left:50\u0025;z-index:4}\n.fb_button_simple,\n.fb_button_simple_rtl{background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zH\/r\/eIpbnVKI9lR.png);background-repeat:no-repeat;cursor:pointer;outline:none;text-decoration:none}\n.fb_button_simple_rtl{background-position:right 0}\n.fb_button_simple .fb_button_text{margin:0 0 0 20px;padding-bottom:1px}\n.fb_button_simple_rtl .fb_button_text{margin:0 10px 0 0}\na.fb_button_simple:hover .fb_button_text,\na.fb_button_simple_rtl:hover .fb_button_text,\n.fb_button_simple:hover .fb_button_text,\n.fb_button_simple_rtl:hover .fb_button_text{text-decoration:underline}\n.fb_button,\n.fb_button_rtl{background:#29447e url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/FGFbc80dUKj.png);background-repeat:no-repeat;cursor:pointer;display:inline-block;padding:0 0 0 1px;text-decoration:none;outline:none}\n.fb_button .fb_button_text,\n.fb_button_rtl .fb_button_text{background:#5f78ab url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/FGFbc80dUKj.png);border-top:solid 1px #879ac0;border-bottom:solid 1px #1a356e;color:#fff;display:block;font-family:\"lucida grande\",tahoma,verdana,arial,sans-serif;font-weight:bold;padding:2px 6px 3px 6px;margin:1px 1px 0 21px;text-shadow:none}\na.fb_button,\na.fb_button_rtl,\n.fb_button,\n.fb_button_rtl{text-decoration:none}\na.fb_button:active .fb_button_text,\na.fb_button_rtl:active .fb_button_text,\n.fb_button:active .fb_button_text,\n.fb_button_rtl:active .fb_button_text{border-bottom:solid 1px #29447e;border-top:solid 1px #45619d;background:#4f6aa3;text-shadow:none}\n.fb_button_xlarge,\n.fb_button_xlarge_rtl{background-position:left -60px;font-size:24px;line-height:30px}\n.fb_button_xlarge .fb_button_text{padding:3px 8px 3px 12px;margin-left:38px}\na.fb_button_xlarge:active{background-position:left -99px}\n.fb_button_xlarge_rtl{background-position:right -268px}\n.fb_button_xlarge_rtl .fb_button_text{padding:3px 8px 3px 12px;margin-right:39px}\na.fb_button_xlarge_rtl:active{background-position:right -307px}\n.fb_button_large,\n.fb_button_large_rtl{background-position:left -138px;font-size:13px;line-height:16px}\n.fb_button_large .fb_button_text{margin-left:24px;padding:2px 6px 4px 6px}\na.fb_button_large:active{background-position:left -163px}\n.fb_button_large_rtl{background-position:right -346px}\n.fb_button_large_rtl .fb_button_text{margin-right:25px}\na.fb_button_large_rtl:active{background-position:right -371px}\n.fb_button_medium,\n.fb_button_medium_rtl{background-position:left -188px;font-size:11px;line-height:14px}\na.fb_button_medium:active{background-position:left -210px}\n.fb_button_medium_rtl{background-position:right -396px}\n.fb_button_text_rtl,\n.fb_button_medium_rtl .fb_button_text{padding:2px 6px 3px 6px;margin-right:22px}\na.fb_button_medium_rtl:active{background-position:right -418px}\n.fb_button_small,\n.fb_button_small_rtl{background-position:left -232px;font-size:10px;line-height:10px}\n.fb_button_small .fb_button_text{padding:2px 6px 3px;margin-left:17px}\na.fb_button_small:active,\n.fb_button_small:active{background-position:left -250px}\n.fb_button_small_rtl{background-position:right -440px}\n.fb_button_small_rtl .fb_button_text{padding:2px 6px;margin-right:18px}\na.fb_button_small_rtl:active{background-position:right -458px}\n.fb_connect_bar_container div,\n.fb_connect_bar_container span,\n.fb_connect_bar_container a,\n.fb_connect_bar_container img,\n.fb_connect_bar_container strong{background:none;border-spacing:0;border:0;direction:ltr;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal;vertical-align:baseline}\n.fb_connect_bar_container{position:fixed;left:0 !important;right:0 !important;height:42px !important;padding:0 25px !important;margin:0 !important;vertical-align:middle !important;border-bottom:1px solid #333 !important;background:#3b5998 !important;z-index:99999999 !important;overflow:hidden !important}\n.fb_connect_bar_container_ie6{position:absolute;top:expression(document.compatMode==\"CSS1Compat\"? document.documentElement.scrollTop+\"px\":body.scrollTop+\"px\")}\n.fb_connect_bar{position:relative;margin:auto;height:100\u0025;width:100\u0025;padding:6px 0 0 0 !important;background:none;color:#fff !important;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif !important;font-size:13px !important;font-style:normal !important;font-variant:normal !important;font-weight:normal !important;letter-spacing:normal !important;line-height:1 !important;text-decoration:none !important;text-indent:0 !important;text-shadow:none !important;text-transform:none !important;white-space:normal !important;word-spacing:normal !important}\n.fb_connect_bar a:hover{color:#fff}\n.fb_connect_bar .fb_profile img{height:30px;width:30px;vertical-align:middle;margin:0 6px 5px 0}\n.fb_connect_bar div a,\n.fb_connect_bar span,\n.fb_connect_bar span a{color:#bac6da;font-size:11px;text-decoration:none}\n.fb_connect_bar .fb_buttons{float:right;margin-top:7px}\n.fb_edge_widget_with_comment{position:relative;*z-index:1000}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget{position:absolute}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_ltr{left:-4px}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_rtl{left:2px}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget{left:0}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget .FB_Loader{left:10\u0025}\n.fb_share_count_wrapper{position:relative;float:left}\n.fb_share_count{background:#b0b9ec none repeat scroll 0 0;color:#333;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;text-align:center}\n.fb_share_count_inner{background:#e8ebf2;display:block}\n.fb_share_count_right{margin-left:-1px;display:inline-block}\n.fb_share_count_right .fb_share_count_inner{border-top:solid 1px #e8ebf2;border-bottom:solid 1px #b0b9ec;margin:1px 1px 0 1px;font-size:10px;line-height:10px;padding:2px 6px 3px;font-weight:bold}\n.fb_share_count_top{display:block;letter-spacing:-1px;line-height:34px;margin-bottom:7px;font-size:22px;border:solid 1px #b0b9ec}\n.fb_share_count_nub_top{border:none;display:block;position:absolute;left:7px;top:35px;margin:0;padding:0;width:6px;height:7px;background-repeat:no-repeat;background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zU\/r\/bSOHtKbCGYI.png)}\n.fb_share_count_nub_right{border:none;display:inline-block;padding:0;width:5px;height:10px;background-repeat:no-repeat;background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zX\/r\/i_oIVTKMYsL.png);vertical-align:top;background-position:right 5px;z-index:10;left:2px;margin:0 2px 0 0;position:relative}\n.fb_share_no_count{display:none}\n.fb_share_size_Small .fb_share_count_right .fb_share_count_inner{font-size:10px}\n.fb_share_size_Medium .fb_share_count_right .fb_share_count_inner{font-size:11px;padding:2px 6px 3px;letter-spacing:-1px;line-height:14px}\n.fb_share_size_Large .fb_share_count_right .fb_share_count_inner{font-size:13px;line-height:16px;padding:2px 6px 4px;font-weight:normal;letter-spacing:-1px}\n.fb_share_count_hidden .fb_share_count_nub_top,\n.fb_share_count_hidden .fb_share_count_top,\n.fb_share_count_hidden .fb_share_count_nub_right,\n.fb_share_count_hidden .fb_share_count_right{visibility:hidden}\n", ["fb.css.base","fb.css.dialog","fb.css.iframewidget","fb.css.button","fb.css.connectbarwidget","fb.css.edgecommentwidget","fb.css.sendbuttonformwidget","fb.css.sharebutton"]); } \ No newline at end of file diff --git a/game/dev/animated_image.js b/game/dev/animated_image.js deleted file mode 100644 index fbec113..0000000 --- a/game/dev/animated_image.js +++ /dev/null @@ -1,93 +0,0 @@ -// Manages an animated image. Assumes that while it is active, -// get_image is called once per game loop -// Defaults to starting immediately -// Unless you call loop, will only run through the images once -// spec: -// All optional -// anim_rate : the number of frames to display each image -// reverse : whether to go backwards in the images when you reach the end or not - -var animated_image = function(image_name, spec) { - - // obj to return - var obj = []; - - // private vars - - var all_images = image_manager.get_images(image_name); - all_images.sort( - function(i1, i2) { - //return i1.path < i2.path; - return i1.path < i2.path ? -1 : (i1.path > i2.path ? 1 : 0); - } - ); - //for_each(all_images, function(i) { console.log(i.path); }); - var curr_index = 0; - var active = true; - var loop = false; - var rate_counter = 0; // Goes from 0 to anim_rate - 1 - var anim_rate = spec.anim_rate || 3; - - // If we are reversing, add all the images in the opposite - // order to all_images - if (spec.reverse || false) { - for (var i = (all_images.length - 1); i >=0; i--) { - all_images.push(all_images[i]); - } - } - - //public methods - - obj.start = function() { - active = true; - }; - - obj.pause = function() { - active = false; - }; - - obj.loop = function() { - loop = true; - }; - - obj.is_finished = function() { - // changed to && cuz it should be not looping - // and at the end to be finished - return (!loop && curr_index === (all_images.length - 1)); - }; - - // Returns the current image - obj.get_frame = function() { - var curr_image = all_images[curr_index].image; - update(); - return curr_image; - }; - - obj.set_rate = function(r) { - anim_rate = r; - }; - - // private methods - - var update = function() { - if (active) { - if (rate_counter >= (anim_rate - 1)) { - next_frame(); - rate_counter = 0; - } - else { - rate_counter++; - } - } - }; - - var next_frame = function() { - // If not 'at the end and not looping', - // increment curr_index, restarting if we reach the end - if (!(curr_index === all_images.length && !loop)) { - curr_index = (curr_index + 1) % all_images.length; - } - } - - return obj; -} diff --git a/game/dev/antibody.js b/game/dev/antibody.js deleted file mode 100644 index 4537cf0..0000000 --- a/game/dev/antibody.js +++ /dev/null @@ -1,86 +0,0 @@ -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards - -var antibody = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 11; - spec.height = spec.height || 7; - spec.speed = (spec.speed || 4) * g_speed_factor; - spec.no_target_speed = (spec.no_target_speed || 2) * g_speed_factor; - - //spec.vel = random_vel(); - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "antibody"; - }; - - // --- private variables --- - - // flag denoting whether the antibody is attached to a cell - var attached = false; - - // --- public methods --- - - // should be called when an antibody attaches to a cell - // tar will be the cell that it is attaching to (may not be its target) - obj.attach = function(tar) { - attached = true; - obj.face_target(tar); - // scoot it out just a bit - obj.get_vel().mult(-1); - obj.move(); - - //obj.set_target(null); - }; - - // implementing game_object interface - - obj.my_update = function() { - if (!attached) { - obj.set_speed(obj.get_level() / 4 + 1) - obj.move(); - // don't want two antibodies attacking one cell - var tar = obj.get_target(); - if (tar && (tar.has_antibody() - // also don't want them to keep target - // if the target changes level - || tar.get_level() !== obj.get_level() - // or if it starts to die - || tar.get_state() === "dying")) { - obj.set_target(null); - } - } - }; - - // should point towards target - // Y-shaped (top of Y is front) - obj.draw = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.stroke(obj.get_color()); - p.strokeWeight(2); - - p.line(-w, 0, w/3, 0); - p.line(w/3, 0, w, h/2); - p.line(w/3, 0, w, -h/2); - - p.popMatrix(); - }; - - return obj; -} diff --git a/game/dev/b_cell.js b/game/dev/b_cell.js deleted file mode 100644 index a40c5e0..0000000 --- a/game/dev/b_cell.js +++ /dev/null @@ -1,254 +0,0 @@ -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards -// state = just leave to be default (alive) - -var b_cell = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 30; - spec.height = spec.height || 30; - spec.speed = (spec.speed || 5) * g_speed_factor; - - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "b_cell"; - }; - - // --- private variables --- - - var b_anim = animated_image("bcell", {reverse : true}); - // for illustration - var b_image = image_manager.get_image("bcell_normal.png"); - // where to go and shoot from - var slot = null; - - // state can be "alive", "active", "shooting", "outdated" - - // Antibodies are created in update, and returned in get_antibodies() - var new_antibodies = null; - - // --- private methods - - // Makes one antibody and adds it to new_antibodies - var make_antibody = function() { - if (!new_antibodies) { - new_antibodies = []; - } - var obj_pos = obj.get_pos(); - var new_antibody = antibody(p, { - pos : new p.PVector(obj_pos.x, obj_pos.y + (obj.get_height() / 2)), - mutation_info: obj.get_mutation_info() - }); - new_antibodies.push(new_antibody); - return new_antibody; - }; - - - // --- public methods --- - - // Makes this target stop and begin producing antibodies - obj.make_antibodies = function() { - obj.set_state("shooting"); - obj.set_target(null); - // production will happen in update - }; - - // to be called on collision with floater - // takes a slot pos - obj.activate = function(aslot) { - obj.set_state("active"); - slot = aslot; - // send the bcell to the top - obj.set_target(game_object(p, { - pos: slot.pos //new p.PVector(p.width - (obj.get_width() / 2), 0) - })); - }; - - obj.get_slot = function() { - return slot; - }; - - // Returns any newly created antibodies - obj.get_antibodies = function() { - if (new_antibodies) { - var to_return = new_antibodies; - new_antibodies = null; - return to_return; - } - else { - return []; - } - }; - - obj.is_activated = function() { - return obj.get_state() === "active"; - }; - - obj.is_alive = function() { - return obj.get_state() === "alive"; - }; - - obj.is_shooting = function() { - return obj.get_state() === "shooting"; - }; - - obj.get_scroll_dist = function() { - var state = obj.get_state(); - if (state === "shooting" - //|| state === "alive" - || state === "active" ) { - return 0; - } - else if (state === "outdated") { - return obj.DEFAULT_SCROLL_DIST;// * 2; - } - else { - return obj.DEFAULT_SCROLL_DIST; - } - }; - - // implementing game_object interface - - obj.my_update = function() { - if (obj.get_state() === "shooting") { - //obj.stop(); - // make it face downwards - var angle = p.PI/2 - // switch if at bottom - if (!slot.is_top) { - angle = -p.PI/2; - } - obj.set_target_angle(angle); - if (Math.random() < .03) { - var new_anti = make_antibody(); - new_anti.set_target_angle(p.random(0, 2*angle)); - } - } - else { - obj.move(); - } - }; - - var draw_antibody = function() { - // private vars - var counter = 0; - var c_max = 30; - var ascending = true; - - // for illustrations - obj.set_anti_count = function(c) { - counter = c; - }; - - return function(){ - - p.pushMatrix(); - - var pos = obj.get_pos(); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - // Copied from antibody.js to avoid overhead of - // creating new antibody every time - p.stroke(obj.get_color()); - p.strokeWeight(1 + (counter / 6)); - - var w = 11; - var h = 7; - p.line(-w, 0, w / 3, 0); - p.line(w / 3, 0, w, h / 2); - p.line(w / 3, 0, w, -h / 2); - - p.popMatrix(); - - if (!anim_paused) { - if (ascending === true) { - counter++; - } - else if (ascending === false) { - counter--; - } - } - if (counter === c_max) { - ascending = false; - } - else if (counter === 0) { - ascending = true; - } - }; - }(); - - // should point towards target - // (triangle for now) - obj.draw = function() { - /* - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.fill(obj.get_color()); - // If outdated, draw differently? - if (obj.get_state() === "outdated") { - p.fill(0); - } - p.noStroke(); - - // rightward triangle - p.triangle(-w/2, -h/2, -w/2, h/2, w/2, 0); - - p.fill(255); - p.ellipse(-w/4, 0, 10, 10); - - p.popMatrix(); - */ - - p.pushMatrix(); - - var pos = obj.get_pos(); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle() + p.PI / 2); - p.fill(obj.get_color()); - p.noStroke(); - //p.rect(rectx_offset, recty_offset, rect_width, rect_height); - p.imageMode(obj.get_mode()); - - if (!obj.is_illustration()) { - b_image = b_anim.get_frame(); - } - p.image(b_image, 0, 0, obj.get_width(), obj.get_height()); - - p.popMatrix(); - - var state = obj.get_state(); - if (state === "active" || state === "shooting") { - draw_antibody(); - } - }; - - var anim_paused = false; - obj.stop_animation = function() { - b_anim.pause(); - anim_paused = true; - }; - - obj.resume_animation = function() { - b_anim.start(); - anim_paused = false; - }; - - return obj; -} diff --git a/game/dev/background_edge.js b/game/dev/background_edge.js deleted file mode 100644 index 6d8bb09..0000000 --- a/game/dev/background_edge.js +++ /dev/null @@ -1,54 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec -// boolean is_top = true if its a top edge, otherwise false -// - -var background_edge = function(p, spec) { - - //var background_image = p.loadImage("images/background.jpg"); - //var background_image = p.loadImage("images/background1.png"); - var edge = spec.is_top ? - image_manager.get_image("background_topside.png") : - image_manager.get_image("background_bottomside.png"); - - // --- defaults --- - - spec.mode = p.CORNERS; - spec.width = spec.width || edge.width; - spec.height = spec.height || edge.height; - - // if bottom, height should have been set to bottom of screen - // so we need to shift it up - if (!spec.is_top) { - spec.pos.add(new p.PVector(0, -spec.height)); - } - - // obj to return - var obj = background_object(p, spec); - - obj.get_type = function() { - return "background_edge"; - }; - - - // --- private variables --- - - - // --- public methods --- - - // override draw method only - obj.draw = function() { - p.imageMode(obj.get_mode()); - p.image(edge, obj.get_pos().x, obj.get_pos().y); - }; - - // override offscreen check cuz we draw from the corners - obj.is_offscreen = function() { - // only need to check left edge of screen - return obj.get_pos().x + obj.get_width() < 0; - }; - - return obj; -}; - diff --git a/game/dev/background_object.js b/game/dev/background_object.js deleted file mode 100644 index 0f96f4e..0000000 --- a/game/dev/background_object.js +++ /dev/null @@ -1,76 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec -// - -var background_object = function(p, spec) { - - var obj_image = random_from( - image_manager.get_images("background")).image; - - - // --- defaults --- - - spec.mode = spec.mode || p.CENTER; - spec.width = spec.width || obj_image.width; - spec.height = spec.height || obj_image.height; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "background_object"; - }; - - // --- private variables --- - - - // --- public methods --- - - // implementing game_object interface - - // update is default (move) - - // (flat rect for now) - obj.draw = function() { - //var x_pos = obj.get_pos().x; - - //p.fill(p.color(49, 0, 0)); - //p.rect(x_pos, 0, obj.get_width() - x_pos, obj.get_height()); - //background_image.resize(p.width, p.height); - //p.image(background_image, 0, 0); - //console.log(obj.get_pos().x); - p.imageMode(obj.get_mode()); - p.image(obj_image, obj.get_pos().x, obj.get_pos().y); - //p.set(obj.get_pos().x, 0, background_image); - //p.fill(255, 70); - //p.noStroke(); - //p.rect(obj.get_pos().x, 0, obj.get_width(), obj.get_height()); - }; - - // background can't go off screen or die - obj.is_dead = function() { - return false; - }; - /* - obj.is_offscreen = function() { - return false; - }; - */ - //var count = 0; - - obj.scroll = function(scroll_factor) { - // count += 1; - //if (count === 1) { - // count = 0; - obj.get_pos().add(new p.PVector(obj.get_scroll_dist(), 0)); - // } - }; - - obj.get_scroll_dist = function() { - return -1; - }; - - return obj; -}; - diff --git a/game/dev/button.js b/game/dev/button.js deleted file mode 100644 index 995dde5..0000000 --- a/game/dev/button.js +++ /dev/null @@ -1,122 +0,0 @@ -// Have a rectangle representing their position and a state to go to when clicked -// spec: -// state : function that returns a new state to go to when clicked -// (think of it like a thunk) -// rect : spec for a rectangle representing the button - -var button = function(p, spec) { - - // --- defaults --- - //spec.rect.width = spec.rect.width || 100; - //spec.rect.height = spec.rect.height || 35; - - // obj to return - var obj = {}; - - // --- private variables --- - - var next_state_fun = spec.state; - var active = spec.active || true; - - var image = spec.rect.image ? - image_manager.get_image(spec.rect.image) : null; - var over_image = spec.rect.over_image ? - image_manager.get_image(spec.rect.over_image) : null; - - // if no width is given but an image is - // use the image width - if (!spec.rect.width && image) { - spec.rect.width = image.width; - } - // and for height - if (!spec.rect.height && image) { - spec.rect.height = image.height; - } - - var rect = rectangle(p, spec.rect); - - // --- public methods --- - - obj.draw = function() { - if (!active) { - rect.set_tint(100); - /* - var r = spec.rect; - p.noStroke(); - p.fill(0, 150); - p.rectMode(p.CENTER); - p.rect(r.pos.x, r.pos.y, r.width, r.height); - */ - } - else { - //rect.set_tint(255); - } - rect.draw(); - }; - - // makes a button not active - obj.deactivate = function() { - // hack to make sure button tint updates - obj.mouse_moved(-1, -1); - active = false; - }; - - // makes a button active - obj.activate = function() { - // hack to make sure button tint updates - obj.mouse_moved(-1, -1); - active = true; - }; - - // Returns the state to go to if clicked, or - // null if not clicked - obj.is_clicked = function(x, y) { - if (active && rect.is_in(x, y)) { - // after click go back to normal image - if (over_image) { - rect.set_image(image); - } - return obj.get_state(); - } - else { - return null; - } - }; - - // special case for track buttons - obj.click = obj.is_clicked; - - obj.mouse_moved = function(x, y) { - if (active && rect.is_in(x, y)) { - if (over_image) { - rect.set_image(over_image); - } - else { - //rect.set_tint(0); - rect.set_tint(255, 255); - //rect.draw_twice(); - //console.log("tinting"); - } - } - else { - if (!over_image) { - rect.set_tint(200, 255); - } - //rect.draw_once(); - rect.set_image(image); - } - }; - // call once to init button tints - obj.mouse_moved(-1, -1); - - // Returns the state to go to - obj.get_state = function() { - return next_state_fun(); - }; - - obj.get_rect = function() { - return spec.rect; - }; - - return obj; -}; diff --git a/game/dev/cache.manifest-old b/game/dev/cache.manifest-old deleted file mode 100644 index 1fbb9e6..0000000 --- a/game/dev/cache.manifest-old +++ /dev/null @@ -1,9 +0,0 @@ -CACHE MANIFEST -#v .012 -CACHE: -sounds/cell_infect.wav -sounds/cell_fire.wav -#sounds/heart_loop1.mp3 -php_functions.php -NETWORK: -* diff --git a/game/dev/cell.js b/game/dev/cell.js deleted file mode 100644 index ebdcaaa..0000000 --- a/game/dev/cell.js +++ /dev/null @@ -1,345 +0,0 @@ -// *** cell *** -// --- inherits from game_object -// spec: -// game_object spec + -// String state = "alive" or "dead" or "infected" or "active" -// mutation : Mutation_obj so cell can get current mutation color - -var cell = function(p, spec) { - - // --- defaults --- - - // was 40 - spec.width = spec.width || 25; - spec.height = spec.height || 25; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "cell"; - }; - - // --- private variables --- - - // images - var cell_image = random_from( - image_manager.get_images("infectable_cell")).image; - var burst_anim = animated_image("burst", {}); - var infect_anim = animated_image("cell_infect", {}); - - // state can be "alive", "infected", "active", or "dead" - var state = spec.state || "alive"; - // random initial angle - var arrow_angle = p.random(-p.PI/2, p.PI/2); - // random dir (1 or -1) - var arrow_dir = p.random() >= 0.5 ? 1 : -1; - - // indicates whether has been hit by an arrow and is being targeted - //var is_targeted = false; - - // holds an antibody that is attached to the cell, or null - var anti = null; - - // --- public methods --- - - // implementing game_object interface - - // update is different depending on state - obj.update = function() { - obj.move(); - if (state === "alive") { - // just chill - } - else if (state === "infected") { - // still chill - } - else if (state === "active") { - // spin the arrow - rotateArrow(); - } - else if (state === "dying") { - if (burst_anim.is_finished()) { - obj.set_state("dead"); - } - } - /* - else if (state === "dead") { - } - */ - }; - - // draw makes a cell with a different color depending on state - // (circle for now) - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.get_mode()); - - p.noStroke(); - - if (state === "dying") { - // draw frame and advance anim - p.image(burst_anim.get_frame(), pos.x, pos.y, - obj.get_width(), obj.get_height()); - // skip the rest of the method - return; - } - - - if (state === "alive") { - p.fill(p.color(200, 50, 50)); - } - else { - if (state === "infected") { - p.fill(obj.get_color()); - // draw after drawing the image - } - else if (state === "active") { - drawArrow(); - - // Draw a separate circle for the red outline - // so that we can more accurately fill in the cell - // red outline for now - p.stroke(255, 0, 0); - p.strokeWeight(4); - p.ellipse(pos.x, pos.y, obj.get_width(), obj.get_height()); - - p.noStroke(); - p.fill(obj.get_color()); - } - //if (infect_anim.is_finished() || obj.is_illustration()) { - p.ellipse(pos.x, pos.y, obj.get_width() * 4/5, obj.get_height() * 4/5); - //} - } - - p.imageMode(obj.get_mode()); - p.image(cell_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - - if (state === "infected" || state === "active") { - // draw after the image - if (!infect_anim.is_finished() && !obj.is_illustration()) { - // draw frame and advance anim - p.image(infect_anim.get_frame(), pos.x, pos.y, - obj.get_width(), obj.get_height()); - //p.fill(obj.get_color()); - } - } - - /* - else if (state === "dead") { - p.fill(0); - p.ellipse(pos.x, pos.y, - obj.get_width(), obj.get_height()); - } - */ - - }; - - // to be used in illustration only - obj.set_image = function(i) { - cell_image = i; - }; - - obj.get_image = function() { - return cell_image; - }; - - obj.is_dead = function() { - //console.log(burst_anim.is_finished()); - return state === "dead"; - }; - - obj.stop_animation = function() { - burst_anim.pause(); - infect_anim.pause(); - }; - - obj.resume_animation = function() { - burst_anim.start(); - infect_anim.start(); - }; - - obj.set_state = function(s) { - if (s === "infected") { - infect_anim.start(); - } - state = s; - }; - - obj.set_antibody = function(a) { - anti = a; - anti.attach(obj); - }; - - obj.has_antibody = function() { - return (anti !== null); - }; - - obj.get_state = function() { - return state; - }; - - obj.die = function() { - if (anti) { - anti.die(); - } - obj.set_state("dying"); - burst_anim.start(); - }; - - // explodes this cell if it is active - obj.fire = function() { - if (state === "active") { - // Make sounds - sounds.play_sound("cell_fire"); - - obj.die(); - - var pos = obj.get_pos(); - var ang = arrow_angle; - // use width cuz it's a circle - var r = obj.get_width()/2; - - // gen particles at edge of cell for now - var x = r*p.cos(ang) + pos.x; - var y = r*p.sin(ang) + pos.y; - - var num_particles = get_num_particles(); - // angle between all the shots - var range = p.PI/6; - var incr = range/num_particles; - - var particles = []; - - ang = arrow_angle - range/2; - // special case - if (num_particles === 1) { - ang = arrow_angle; - } - while (num_particles > 0) { - var new_vel = new p.PVector(p.cos(ang), p.sin(ang)); - // mult by speed scalar - new_vel.mult(7); - // if we want to add velocity of cell - new_vel.add(obj.get_vel()); - - particles.push(particle(p, { - pos: new p.PVector(x, y), - vel: new_vel, - mutation_info: obj.get_mutation_info() - })); - - num_particles--; - ang += incr; - } - - return particles; - } - throw "Can't fire on "+state+" cell!"; - }; - - // override for circular object - obj.calc_radius = function() { - return obj.get_width()/2; - }; - obj.set_radius(obj.calc_radius()); - - // --- private functions --- - - // rotates according to arrow_dir - // switches direction at certain angles - var rotateArrow = function() { - if (arrow_angle > p.PI/2 - || arrow_angle < -p.PI/2) { - arrow_dir = (2-arrow_dir)-2; - } - arrow_angle += p.radians(5+obj.get_level()/2)*arrow_dir * g_speed_factor; - }; - - var drawArrow = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - - // move to center of circle - p.translate(pos.x, pos.y); - // rotate first - p.rotate(arrow_angle); - // move out to right edge of circle - p.translate(w/2, 0); - - // red outline for now - p.stroke(255, 0, 0); - p.strokeWeight(2); - p.fill(obj.get_color()); - - var x1 = w/2; - // draw facing out to right - p.beginShape(); - p.vertex(0, -5); - p.vertex(x1, -5); - p.vertex(x1, -10); - p.vertex(x1+15, 0); - p.vertex(x1, 10); - p.vertex(x1, 5); - p.vertex(0, 5); - p.endShape(); - - p.popMatrix(); - - // Draw Dots if easy - if (GLOBAL_is_easy) { - var pos = obj.get_pos(); - var ang = arrow_angle; - // use width cuz it's a circle - var r = obj.get_width()/2; - - // gen particles at edge of cell for now - var x = r*p.cos(ang) + pos.x; - var y = r*p.sin(ang) + pos.y; - - var num_particles = get_num_particles(); - // angle between all the shots - var range = p.PI/6; - var incr = range/num_particles; - - ang = arrow_angle - range/2; - // special case - if (num_particles === 1) { - ang = arrow_angle; - } - var num_dots = 5; - while (num_particles > 0) { - var offset = 4; - p.fill(153); - p.noStroke(); - for (var i = 0; i < num_dots; i++) { - x = r*p.cos(ang)*offset + pos.x ; - y = r*p.sin(ang)*offset + pos.y ; - p.ellipse(x, y, 2, 2); - offset += 2; - } - - num_particles--; - ang += incr; - } - } - }; - - var get_num_particles = function() { - - var extra_particles = 0; - var mut_info = obj.get_mutation_info(); - /* - for_each(mut_info.abilities, function(a) { - if (a === "extra_particle") { - extra_particles++; - } - }); - */ - return mut_info.particles + extra_particles; - }; - - return obj; -}; diff --git a/game/dev/credits_state.js b/game/dev/credits_state.js deleted file mode 100644 index 9d79008..0000000 --- a/game/dev/credits_state.js +++ /dev/null @@ -1,59 +0,0 @@ -var credits_state = function(p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var credits_back = image_manager.get_image("creditsscreen.png"); - - // Buttons - - var back_button = button(p, { - state : function() { return prev_state; }, - rect : { - pos : new p.PVector(p.width * (3/4), 500), - width: 120, - height: 50, - image: "back.png", - } - }); - - - //Not ordered - var all_buttons = [ back_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "credits"; - }; - - obj.update = function() { - //do nothing - }; - - obj.render = function() { - // fill the background - p.noStroke(); - p.fill(g.background_color); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.imageMode(p.CENTER); - p.image(credits_back, p.width/2, p.height/2); - }; - - obj.key_pressed = function(k) { - if (p.keyCode === 13 || p.keyCode === 27) { // enter, esc - obj.exit_state(); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/game/dev/css/styles.css b/game/dev/css/styles.css deleted file mode 100644 index 44efae4..0000000 --- a/game/dev/css/styles.css +++ /dev/null @@ -1,60 +0,0 @@ -canvas { - border: 3px solid gray; - z-index: 1; - width: 700; - height: 600; - position: relative; -} -#scores-wrap { - z-index: 2; - /*background: white;*/ - /*color: black;*/ - width: 500; - height: 400; - /* use top/left to center manually */ - /* add in border width */ - left: 103px; - top: 83px; - position: absolute; - /* start hidden */ - display: none; -} -#scores { - height: 430; -} -table.score-table { - border-collapse: collapse; - width: 100%; - background: black; - color: white; - /*padding: 0.2em;*/ -} -.score-table, .score-table tr, .score-table td { - /*color: black;*/ - border: 2px solid #666; - font-size: 14; - text-align: right; -} -.score-table th { - font-size: 16; - text-align: center; - color: #000; - background: #fff; - border: 2px solid #666; - border-top: 5px solid #666; -} -.score-table th, .score-table tr, .score-table td { - padding: 0.2em 0.4em; -} -.Score-header { - width: 120; -} -.Name-header { - width: 140; -} -.Level-header { - width: 50; -} -.Date-header { - width: 100; -} diff --git a/game/dev/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png b/game/dev/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png deleted file mode 100755 index 5473aff..0000000 Binary files a/game/dev/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png and /dev/null differ diff --git a/game/dev/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png b/game/dev/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png deleted file mode 100755 index 5950a8d..0000000 Binary files a/game/dev/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png and /dev/null differ diff --git a/game/dev/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png b/game/dev/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png deleted file mode 100755 index 1ad224a..0000000 Binary files a/game/dev/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png and /dev/null differ diff --git a/game/dev/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png b/game/dev/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png deleted file mode 100755 index 1cf1cac..0000000 Binary files a/game/dev/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png and /dev/null differ diff --git a/game/dev/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png b/game/dev/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png deleted file mode 100755 index 35ec0d9..0000000 Binary files a/game/dev/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png and /dev/null differ diff --git a/game/dev/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png b/game/dev/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png deleted file mode 100755 index b1b03b6..0000000 Binary files a/game/dev/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png and /dev/null differ diff --git a/game/dev/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png b/game/dev/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png deleted file mode 100755 index e56eefd..0000000 Binary files a/game/dev/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png and /dev/null differ diff --git a/game/dev/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png b/game/dev/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png deleted file mode 100755 index 3525eb9..0000000 Binary files a/game/dev/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png and /dev/null differ diff --git a/game/dev/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png b/game/dev/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png deleted file mode 100755 index 2b6a9f9..0000000 Binary files a/game/dev/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png and /dev/null differ diff --git a/game/dev/css/ui-darkness/images/ui-icons_222222_256x240.png b/game/dev/css/ui-darkness/images/ui-icons_222222_256x240.png deleted file mode 100755 index b273ff1..0000000 Binary files a/game/dev/css/ui-darkness/images/ui-icons_222222_256x240.png and /dev/null differ diff --git a/game/dev/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png b/game/dev/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png deleted file mode 100755 index c5d93b6..0000000 Binary files a/game/dev/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png and /dev/null differ diff --git a/game/dev/css/ui-darkness/images/ui-icons_a83300_256x240.png b/game/dev/css/ui-darkness/images/ui-icons_a83300_256x240.png deleted file mode 100755 index 95993ea..0000000 Binary files a/game/dev/css/ui-darkness/images/ui-icons_a83300_256x240.png and /dev/null differ diff --git a/game/dev/css/ui-darkness/images/ui-icons_cccccc_256x240.png b/game/dev/css/ui-darkness/images/ui-icons_cccccc_256x240.png deleted file mode 100755 index 9254e05..0000000 Binary files a/game/dev/css/ui-darkness/images/ui-icons_cccccc_256x240.png and /dev/null differ diff --git a/game/dev/css/ui-darkness/images/ui-icons_ffffff_256x240.png b/game/dev/css/ui-darkness/images/ui-icons_ffffff_256x240.png deleted file mode 100755 index 42f8f99..0000000 Binary files a/game/dev/css/ui-darkness/images/ui-icons_ffffff_256x240.png and /dev/null differ diff --git a/game/dev/css/ui-darkness/jquery-ui-1.8.9.custom.css b/game/dev/css/ui-darkness/jquery-ui-1.8.9.custom.css deleted file mode 100755 index 164af9f..0000000 --- a/game/dev/css/ui-darkness/jquery-ui-1.8.9.custom.css +++ /dev/null @@ -1,312 +0,0 @@ -/* - * jQuery UI CSS Framework 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - */ - -/* Layout helpers -----------------------------------*/ -.ui-helper-hidden { display: none; } -.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } -.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } -.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } -.ui-helper-clearfix { display: inline-block; } -/* required comment for clearfix to work in Opera \*/ -* html .ui-helper-clearfix { height:1%; } -.ui-helper-clearfix { display:block; } -/* end clearfix */ -.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } - - -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { cursor: default !important; } - - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } - - -/* - * jQuery UI CSS Framework 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - * - * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Segoe%20UI,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=6px&bgColorHeader=333333&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=25&borderColorHeader=333333&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=000000&bgTextureContent=05_inset_soft.png&bgImgOpacityContent=25&borderColorContent=666666&fcContent=ffffff&iconColorContent=cccccc&bgColorDefault=555555&bgTextureDefault=02_glass.png&bgImgOpacityDefault=20&borderColorDefault=666666&fcDefault=eeeeee&iconColorDefault=cccccc&bgColorHover=0078a3&bgTextureHover=02_glass.png&bgImgOpacityHover=40&borderColorHover=59b4d4&fcHover=ffffff&iconColorHover=ffffff&bgColorActive=f58400&bgTextureActive=05_inset_soft.png&bgImgOpacityActive=30&borderColorActive=ffaf0f&fcActive=ffffff&iconColorActive=222222&bgColorHighlight=eeeeee&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=80&borderColorHighlight=cccccc&fcHighlight=2e7db2&iconColorHighlight=4b8e0b&bgColorError=ffc73d&bgTextureError=02_glass.png&bgImgOpacityError=40&borderColorError=ffb73d&fcError=111111&iconColorError=a83300&bgColorOverlay=5c5c5c&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=50&opacityOverlay=80&bgColorShadow=cccccc&bgTextureShadow=01_flat.png&bgImgOpacityShadow=30&opacityShadow=60&thicknessShadow=7px&offsetTopShadow=-7px&offsetLeftShadow=-7px&cornerRadiusShadow=8px - */ - - -/* Component containers -----------------------------------*/ -.ui-widget { font-family: Segoe UI, Arial, sans-serif; font-size: 1.1em; } -.ui-widget .ui-widget { font-size: 1em; } -.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Segoe UI, Arial, sans-serif; font-size: 1em; } -.ui-widget-content { border: 1px solid #666666; background: #000000 url(images/ui-bg_inset-soft_25_000000_1x100.png) 50% bottom repeat-x; color: #ffffff; } -.ui-widget-content a { color: #ffffff; } -.ui-widget-header { border: 1px solid #333333; background: #333333 url(images/ui-bg_gloss-wave_25_333333_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; } -.ui-widget-header a { color: #ffffff; } - -/* Interaction states -----------------------------------*/ -.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #666666; background: #555555 url(images/ui-bg_glass_20_555555_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #eeeeee; } -.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #eeeeee; text-decoration: none; } -.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #59b4d4; background: #0078a3 url(images/ui-bg_glass_40_0078a3_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #ffffff; } -.ui-state-hover a, .ui-state-hover a:hover { color: #ffffff; text-decoration: none; } -.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #ffaf0f; background: #f58400 url(images/ui-bg_inset-soft_30_f58400_1x100.png) 50% 50% repeat-x; font-weight: bold; color: #ffffff; } -.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #ffffff; text-decoration: none; } -.ui-widget :active { outline: none; } - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #cccccc; background: #eeeeee url(images/ui-bg_highlight-soft_80_eeeeee_1x100.png) 50% top repeat-x; color: #2e7db2; } -.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #2e7db2; } -.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #ffb73d; background: #ffc73d url(images/ui-bg_glass_40_ffc73d_1x400.png) 50% 50% repeat-x; color: #111111; } -.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #111111; } -.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #111111; } -.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } -.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } -.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_cccccc_256x240.png); } -.ui-widget-content .ui-icon {background-image: url(images/ui-icons_cccccc_256x240.png); } -.ui-widget-header .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); } -.ui-state-default .ui-icon { background-image: url(images/ui-icons_cccccc_256x240.png); } -.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); } -.ui-state-active .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); } -.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_4b8e0b_256x240.png); } -.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_a83300_256x240.png); } - -/* positioning */ -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-off { background-position: -96px -144px; } -.ui-icon-radio-on { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-start { background-position: -80px -160px; } -/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-tl { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px; } -.ui-corner-tr { -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px; } -.ui-corner-bl { -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; } -.ui-corner-br { -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } -.ui-corner-top { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px; -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px; } -.ui-corner-bottom { -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } -.ui-corner-right { -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px; -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } -.ui-corner-left { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px; -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; } -.ui-corner-all { -moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px; } - -/* Overlays */ -.ui-widget-overlay { background: #5c5c5c url(images/ui-bg_flat_50_5c5c5c_40x100.png) 50% 50% repeat-x; opacity: .80;filter:Alpha(Opacity=80); } -.ui-widget-shadow { margin: -7px 0 0 -7px; padding: 7px; background: #cccccc url(images/ui-bg_flat_30_cccccc_40x100.png) 50% 50% repeat-x; opacity: .60;filter:Alpha(Opacity=60); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/* - * jQuery UI Tabs 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Tabs#theming - */ -.ui-tabs { position: relative; /*padding: .2em;*/ zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ -.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; } -.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; } -.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; } -.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */ -.ui-tabs .ui-tabs-panel { display: block; border-width: 0;/* padding: 1em 1.4em;*/ background: none; } -.ui-tabs .ui-tabs-hide { display: none !important; } diff --git a/game/dev/date.format.js b/game/dev/date.format.js deleted file mode 100644 index 3992c50..0000000 --- a/game/dev/date.format.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Date Format 1.2.3 - * (c) 2007-2009 Steven Levithan - * MIT license - * - * Includes enhancements by Scott Trenda - * and Kris Kowal - * - * Accepts a date, a mask, or a date and a mask. - * Returns a formatted version of the given date. - * The date defaults to the current date/time. - * The mask defaults to dateFormat.masks.default. - */ - -var dateFormat = function () { - var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, - timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, - timezoneClip = /[^-+\dA-Z]/g, - pad = function (val, len) { - val = String(val); - len = len || 2; - while (val.length < len) val = "0" + val; - return val; - }; - - // Regexes and supporting functions are cached through closure - return function (date, mask, utc) { - var dF = dateFormat; - - // You can't provide utc if you skip other args (use the "UTC:" mask prefix) - if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { - mask = date; - date = undefined; - } - - // Passing date through Date applies Date.parse, if necessary - date = date ? new Date(date) : new Date; - if (isNaN(date)) throw SyntaxError("invalid date"); - - mask = String(dF.masks[mask] || mask || dF.masks["default"]); - - // Allow setting the utc argument via the mask - if (mask.slice(0, 4) == "UTC:") { - mask = mask.slice(4); - utc = true; - } - - var _ = utc ? "getUTC" : "get", - d = date[_ + "Date"](), - D = date[_ + "Day"](), - m = date[_ + "Month"](), - y = date[_ + "FullYear"](), - H = date[_ + "Hours"](), - M = date[_ + "Minutes"](), - s = date[_ + "Seconds"](), - L = date[_ + "Milliseconds"](), - o = utc ? 0 : date.getTimezoneOffset(), - flags = { - d: d, - dd: pad(d), - ddd: dF.i18n.dayNames[D], - dddd: dF.i18n.dayNames[D + 7], - m: m + 1, - mm: pad(m + 1), - mmm: dF.i18n.monthNames[m], - mmmm: dF.i18n.monthNames[m + 12], - yy: String(y).slice(2), - yyyy: y, - h: H % 12 || 12, - hh: pad(H % 12 || 12), - H: H, - HH: pad(H), - M: M, - MM: pad(M), - s: s, - ss: pad(s), - l: pad(L, 3), - L: pad(L > 99 ? Math.round(L / 10) : L), - t: H < 12 ? "a" : "p", - tt: H < 12 ? "am" : "pm", - T: H < 12 ? "A" : "P", - TT: H < 12 ? "AM" : "PM", - Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""), - o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), - S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10] - }; - - return mask.replace(token, function ($0) { - return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); - }); - }; -}(); - -// Some common format strings -dateFormat.masks = { - "default": "ddd mmm dd yyyy HH:MM:ss", - shortDate: "m/d/yy", - mediumDate: "mmm d, yyyy", - longDate: "mmmm d, yyyy", - fullDate: "dddd, mmmm d, yyyy", - shortTime: "h:MM TT", - mediumTime: "h:MM:ss TT", - longTime: "h:MM:ss TT Z", - isoDate: "yyyy-mm-dd", - isoTime: "HH:MM:ss", - isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", - isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" -}; - -// Internationalization strings -dateFormat.i18n = { - dayNames: [ - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" - ], - monthNames: [ - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", - "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" - ] -}; - -// For convenience... -Date.prototype.format = function (mask, utc) { - return dateFormat(this, mask, utc); -}; - diff --git a/game/dev/empty_cell.js b/game/dev/empty_cell.js deleted file mode 100644 index 76e58c9..0000000 --- a/game/dev/empty_cell.js +++ /dev/null @@ -1,91 +0,0 @@ -// *** empty_cell *** -// --- inherits from cell -// spec: -// cell spec - -var empty_cell = function(p, spec) { - - // --- defaults --- - // inherited from cell - - // obj to return - var obj = cell(p, spec); - - obj.get_type = function() { - return "empty_cell"; - }; - - // --- private variables --- - - // state can be "alive", "infected", or "dead" - //var state = spec.state || "alive"; - - //var empty_image = p.loadImage("images/noninfectable1.png"); - /* - var images = random_image_selector(); - var empty_image = null; - if (on_server) { // so itwill work locally - for_each(g_empty_cell_images, function(i){ - images.add(p.loadImage(i)); - }); - empty_image = images.get_image(); - } - else { - empty_image = p.loadImage("images/new/noninfectable.png"); - } - */ - var empty_image = random_from( - image_manager.get_images("empty_cell")).image; - - // --- public methods --- - - // implementing game_object interface - - // update is different depending on state - obj.update = function() { - obj.move(); - if (obj.get_state() === "alive") { - // just chill - } - else if (obj.get_state() === "infected") { - // prepare to die - } - else if (obj.get_state() === "dead") { - // explode!! - } - }; - - // draw makes a cell with a different color depending on state - // just an outline for empty cell - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.mode); - - p.strokeWeight(2); - p.stroke(0); - p.noFill(); - - if (obj.get_state() === "alive") { - p.stroke(0); - } - else if (obj.get_state() === "infected") { - p.stroke(150); - } - else if (obj.get_state() === "dead") { - p.fill(0); - } - - p.imageMode(obj.get_mode()); - p.image(empty_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - }; - - obj.is_dead = function() { - return obj.get_state() === "dead"; - }; - - obj.die = function() { - obj.set_state("dead") = "dead"; - }; - - return obj; -} diff --git a/game/dev/facebook.php b/game/dev/facebook.php deleted file mode 100644 index 6d4fa72..0000000 --- a/game/dev/facebook.php +++ /dev/null @@ -1,1845 +0,0 @@ - - - - - - - - - - - - src/facebook.php at master from facebook's php-sdk - GitHub - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
-

Your current locale selection: English. Choose another?

- - - - - - - - - - - - -
- -
-
-
- - - - - - - - - - - - - - - - diff --git a/game/dev/fisforformat.min.js b/game/dev/fisforformat.min.js deleted file mode 100644 index d890718..0000000 --- a/game/dev/fisforformat.min.js +++ /dev/null @@ -1,11 +0,0 @@ -/* - * "f" is for Format & WHAT THE diff?? v0.5.0 - * - * Copyright (c) 2009 Joshua Faulkenberry - * Dual licensed under the MIT and GPL licenses. - * http://docs.jquery.com/License - * - * Date: 2009-03-20 22:15:23 -0700 (Fri, 20 Mar 2009) - * Revision: 6 - */ -window.Date.prototype.f=function(format){if(format=="@"){return this.getTime()}else{if(format=="REL"){var diff=(((new Date()).getTime()-this.getTime())/1000),day_diff=Math.floor(diff/86400);return day_diff==0&&(diff>-60&&"right now"||diff>-120&&"1 minute from now"||diff>-3600&&-(Math.floor(diff/60))+" minutes from now"||diff>-7200&&"1 hour ago"||diff>-86400&&-(Math.floor(diff/3600))+" hours from now"||diff<60&&"just now"||diff<120&&"1 minute ago"||diff<3600&&Math.floor(diff/60)+" minutes ago"||diff<7200&&"1 hour ago"||diff<86400&&Math.floor(diff/3600)+" hours ago")||day_diff==0&&"Tomorrow"||day_diff>-7&&-(day_diff)+" days from now"||-(Math.ceil(day_diff/7))==1&&"1 week from now"||day_diff>-78&&-(Math.ceil(day_diff/7))+" weeks from now"||day_diff>-730&&-(Math.ceil(day_diff/30))+" months from now"||day_diff<=-730&&-(Math.ceil(day_diff/365))+" years from now"||day_diff==1&&"Yesterday"||day_diff<7&&day_diff+" days ago"||(Math.ceil(day_diff/7))==1&&"1 week ago"||day_diff<78&&Math.ceil(day_diff/7)+" weeks ago"||day_diff<730&&Math.ceil(day_diff/30)+" months ago"||Math.ceil(day_diff/365)+" years ago"}}var MONTH_NAMES=["January","February","March","April","May","June","July","August","September","October","November","December"],DAY_NAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],LZ=function(x){return(x<0||x>9?"":"0")+x},date=this,format=format+"",result="",i_format=0,c="",token="",y=date.getYear()+"",M=date.getMonth()+1,d=date.getDate(),E=date.getDay(),H=date.getHours(),m=date.getMinutes(),s=date.getSeconds(),yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k,value=new Object();if(y.length<4){y=""+(y-0+1900)}value.y=""+y;value.yyyy=y;value.yy=y.substr(2,4);value.M=M;value.MM=LZ(M);value.MMM=MONTH_NAMES[M-1];value.NNN=MONTH_NAMES[M-1].substr(0,3);value.N=MONTH_NAMES[M-1].substr(0,1);value.d=d;value.dd=LZ(d);value.e=DAY_NAMES[E].substr(0,1);value.ee=DAY_NAMES[E].substr(0,2);value.E=DAY_NAMES[E].substr(0,3);value.EE=DAY_NAMES[E];value.H=H;value.HH=LZ(H);if(H==0){value.h=12}else{if(H>12){value.h=H-12}else{value.h=H}}value.hh=LZ(value.h);if(H>11){value.K=H-12}else{value.K=H}value.k=H+1;value.KK=LZ(value.K);value.kk=LZ(value.k);if(H>11){value.a="PM"}else{value.a="AM"}value.m=m;value.mm=LZ(m);value.s=s;value.ss=LZ(s);while(i_format=tl[trg]){if(trg=="Y"||trg=="D"||trg=="C"||trg=="T"){for(var yr=(min);yr.getFullYear()<=max.getFullYear();yr.setYear(yr.getFullYear()+1)){if(yr.isLeapYear()){diff-=tl.d}}}if(diff>=tl[trg]){result=Math.floor(diff/tl[trg])+" "+(Math.floor(diff/tl[trg])==1&&names[trg][0]||names[trg][1]);diff=diff%tl[trg]}}eval("breakdown = breakdown.replace(/"+trg+'/g, "")');return result}var min=date<=this&&date||date>this&&this,max=date>this&&date||date<=this&&this,diff=(max.getTime()-min.getTime()),tl={T:1000*60*60*24*365*100*10,C:1000*60*60*24*365*100,D:1000*60*60*24*365*10,Y:1000*60*60*24*365,M:1000*60*60*24*28,W:1000*60*60*24*7,d:1000*60*60*24,H:1000*60*60,m:1000*60,S:1000,N:1},names={T:options.labels.T||["Mellinium","Mellinia"],C:options.labels.C||["Century","Centuries"],D:options.labels.D||["Decade","Decades"],Y:options.labels.Y||["Year","Years"],M:options.labels.M||["Month","Months"],W:options.labels.W||["Week","Weeks"],d:options.labels.d||["Day","Days"],H:options.labels.H||["Hour","Hours"],m:options.labels.m||["Minute","Minutes"],S:options.labels.S||["Second","Seconds"],N:options.labels.N||["Millisecond","Milliseconds"]};if(options.len){for(var x in names){names[x]=names[x].substr(0,options.len)}}var testDt=new Date(min.toString());if(max.getFullYear()-testDt.getFullYear()>1){testDt.setYear(max.getFullYear()-1)}while(testDtmin.getDayLightSavingsDays()[1].getDate())||min.getMonth()0){if(breakdown=="*"){breakdown="TCDYMWdHmSN"}else{if(breakdown.indexOf("T")>-1){if(out=processTime("T")){result[result.length]=out}}else{if(breakdown.indexOf("C")>-1){if(out=processTime("C")){result[result.length]=out}}else{if(breakdown.indexOf("D")>-1){if(out=processTime("D")){result[result.length]=out}}else{if(breakdown.indexOf("Y")>-1){if(out=processTime("Y")){result[result.length]=out}}else{if(breakdown.indexOf("M")>-1){if(diff>=tl.M){var cur=(new Date(max.getTime()-diff));var monthCount=0;var lastVal=0;for(var yr=cur.getFullYear();yr<=max.getFullYear();yr++){while(cur.getFullYear()==yr){lastVal=cur.getTime();cur.setMonth(cur.getMonth()+1);if(diff-(cur.getTime()-lastVal)>=0){monthCount++;diff-=(cur.getTime()-lastVal)}if(yr==max.getFullYear()&&cur.getMonth()==max.getMonth()){break}}}if(monthCount){result[result.length]=monthCount+" "+(monthCount==1&&names.M[0]||names.M[1])}}breakdown=breakdown.replace(/M/g,"")}else{if(breakdown.indexOf("W")>-1){if(out=processTime("W")){result[result.length]=out}}else{if(breakdown.indexOf("d")>-1){if(out=processTime("d")){result[result.length]=out}}else{if(breakdown.indexOf("H")>-1){if(out=processTime("H")){result[result.length]=out}}else{if(breakdown.indexOf("m")>-1){if(out=processTime("m")){result[result.length]=out}}else{if(breakdown.indexOf("S")>-1){if(out=processTime("S")){result[result.length]=out}}else{if(breakdown.indexOf("N")>-1){if(out=processTime("N")){result[result.length]=out}}else{diff=0}}}}}}}}}}}}}options.divider=options.divider||", ";if(options.divider==", "&&result.length>1&&!options.hideAnd){result[result.length-1]="and "+result[result.length-1]}diff=result.join(options.divider)}if(diff==""){diff="Same"}if(options.lc){diff=diff.toLowerCase()}return diff};window.Date.prototype.getDaysInMonth=function(){return[31,28,31,30,31,30,31,31,30,31,30,31][this.getMonth()]};window.Date.prototype.isLeapYear=function(){return(new Date(this.getFullYear(),2-1,29)).getDate()==29};window.Date.prototype.getDayLightSavingsDays=function(){var result=[];var day1=new Date("03/07/"+this.getFullYear());var day2=new Date("03/06/"+this.getFullYear());while(day1.getMonth()<3||(day1.getMonth()==3&&day1.getDate()<16)){if((day1.getTime()-day2.getTime())/1000/60/60!=24){result[result.length]=new Date(day2.getTime())}day1.setDate(day1.getDate()+1);day2.setDate(day2.getDate()+1)}var day1=new Date("10/31/"+this.getFullYear());var day2=new Date("10/30/"+this.getFullYear());while(day1.getMonth()<11||(day1.getMonth()==10&&day1.getDate()<9)){if((day1.getTime()-day2.getTime())/1000/60/60!=24){result[result.length]=new Date(day2.getTime())}day1.setDate(day1.getDate()+1);day2.setDate(day2.getDate()+1)}return result};window.Date.prototype.isDayLightSavingsDay=function(){var comp=new Date(this.getTime());comp.setDate(comp.getDate()+1);return(comp.getTime()-this.getTime())/1000/60/60!=24}; \ No newline at end of file diff --git a/game/dev/floater.js b/game/dev/floater.js deleted file mode 100644 index 86ff5a5..0000000 --- a/game/dev/floater.js +++ /dev/null @@ -1,122 +0,0 @@ -// *** floater *** -// --- inherits from game_object -// spec: -// game_object spec -// state = leave to be default "alive" - -var floater = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 43; - spec.height = spec.height || 50; - spec.vel = new p.PVector(0, 0.3); - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "floater"; - }; - - // --- private variables --- - - var macrophage_alive = animated_image("macrophage", {reverse : true}); - var macrophage_active = animated_image("macrophage_active", {reverse : true}); - // for illustration - var macro_active_img = image_manager.get_image("macrophage_1_active.png"); - var macro_alive_img = image_manager.get_image("macrophage_1.png"); - - // how far up or down it can move - var range = 50; - var btm_lim = obj.get_pos().y + range; - var top_lim = obj.get_pos().y - range; - // state can be "alive", "activated", or "dead" - var state = spec.state || "alive"; - - // --- public methods --- - - // implementing game_object interface - - obj.update = function() { - // if we reach a limit - var y = obj.get_pos().y; - if (y <= top_lim || y >= btm_lim) { - // turn around - var v = obj.get_vel(); - obj.set_vel(new p.PVector(v.x, -v.y)); - } - obj.move(); - }; - - // (rectangle for now) - obj.draw = function() { - /* - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.fill(obj.get_color()); - - p.stroke(0); - p.strokeWeight(1); - - // had to hack to center rect - // might need to change - p.rect(pos.x-w/2, pos.y-h/2, w, h); - */ - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.imageMode(obj.get_mode()); - if (state === "active") { - p.shapeMode(obj.mode); - p.fill(obj.get_color()); - p.noStroke(); - p.ellipse(pos.x + w / 8, pos.y - w / 8 + 1, w/2, w/2); - if (!obj.is_illustration()) { - macro_active_img = macrophage_active.get_frame(); - } - p.image(macro_active_img, pos.x, pos.y, w, h); - } - else { - if (!obj.is_illustration()) { - macro_alive_img = macrophage_alive.get_frame(); - } - p.image(macro_alive_img, pos.x, pos.y, w, h); - } - }; - - obj.stop_animation = function() { - macrophage_alive.pause(); - macrophage_active.pause(); - }; - - obj.resume_animation = function() { - macrophage_alive.start(); - macrophage_active.start(); - }; - - obj.is_dead = function() { - return state === "dead"; - }; - - obj.is_alive = function() { - return state === "alive"; - }; - - obj.is_activated = function() { - return state === "active"; - }; - - obj.get_state = function() { - return state; - }; - - obj.activate = function() { - state = "active"; - }; - - return obj; -} diff --git a/game/dev/game_object.js b/game/dev/game_object.js deleted file mode 100644 index 71d409d..0000000 --- a/game/dev/game_object.js +++ /dev/null @@ -1,276 +0,0 @@ -// *** game_object *** -// spec: -// mode = p.CENTER or p.CORNERS (constants from processing) -// - describes how the coords work, set by p.shapeMode() -// p.PVector pos = initial position (x,y) -// float width = width of the entire object -// float height = height of the entire object -// float radius = circle collision radius (will be auto-calced) -// p.PVector vel = initial velocity -// p.PVector accel = initial acceleration -// mutation_info = object with level, num_particles and color props -// illustration = boolean that says whether or not to draw animations - -var game_object = function (p, spec) { - - - // object to return - var obj = {}; - - // should be overridden by subtypes - obj.get_type = function() { - return "game_object"; - }; - - obj.DEFAULT_SCROLL_DIST = -1.2; - - // --- private variables --- - - var mode = spec.mode || p.CENTER; - var pos = spec.pos || new p.PVector(0, 0); - var width = spec.width || 0; - var height = spec.height || 0; - var vel = spec.vel || new p.PVector(0, 0); - var accel = spec.accel || new p.PVector(0, 0); - // used for circle collision testing - var radius = spec.radius // default set at bottom of file - // used for mutation - var mutation_info = spec.mutation_info || - { level: -1, color: p.color(0, 0, 0), particles: 0 }; - var illustration = spec.illustration || false; - - var alive = true; - - // --- public methods --- - - // all game_objects must implement this interface: - // void update() - called each frame to move/update objects - // void draw() - called each frame to display the object - // void scroll() - moves the object left by a certain amount - - // update moves obj by default - obj.update = function() { obj.move(); }; - - // draw does nothing by default - obj.draw = function() {}; - - // by default returns the negated alive variable - obj.is_dead = function() { return !alive; }; - - // Generic methods for all game_objects: - // returns true if the object is completely offscreen - // i.e. checks pos + dimensions - obj.is_offscreen = function() { - var left_edge = pos.x - width/2; - var right_edge = pos.x + width/2; - var top_edge = pos.y - height/2; - var btm_edge = pos.y + height/2; - return (left_edge > p.width - || right_edge < 0 - || top_edge > p.height - || btm_edge < 0); - }; - - // Returns if the obj is off the right of the screen - obj.is_off_right = function() { - var left_edge = pos.x - width/2; - return left_edge > p.width; - }; - - - // Bounces the object off a wall, if it is at one - obj.bounce = function() { - var left_edge = pos.x - width; - var right_edge = pos.x + width; - var top_edge = pos.y - height; - var btm_edge = pos.y + height; - if (top_edge <= 0 && vel.y < 0) { - vel.y = -vel.y; - } - if (btm_edge >= p.height && vel.y > 0) { - vel.y = -vel.y; - } - if (left_edge <= 0 && vel.x < 0) { - vel.x = -vel.x; - } - if (right_edge >= p.width && vel.x > 0) { - vel.x = -vel.x; - } - }; - - // reverses the y velocity - // used for bouncing vertically - obj.reverse_y = function() { - var vel = obj.get_vel(); - obj.set_vel(new p.PVector(vel.x, -vel.y)); - }; - - // reverses the x velocity - // used for bouncing horizontally - obj.reverse_x = function() { - var vel = obj.get_vel(); - obj.set_vel(new p.PVector(- vel.x, vel.y)); - }; - - // updates the position according to accel and vel - // Bounces off walls - obj.move = function() { - vel.add(accel); - pos.add(vel); - }; - - // stops the object in its tracks by zeroing out vel - obj.stop = function() { - vel = new p.PVector(0, 0); - }; - - // Scrolls the obj a specified distance left or right (positive is right) - obj.scroll = function(scroll_factor) { - var scroll_x = obj.get_scroll_dist(); - if (scroll_x === null) { - scroll_x = obj.DEFAULT_SCROLL_DIST; - } - pos.add(new p.PVector(scroll_x*scroll_factor, 0)); - }; - - obj.die = function() { - alive = false; - }; - - obj.is_illustration = function() { - return illustration; - }; - - // --- setters --- - - obj.set_illustration = function(i) { - illustration = i; - }; - - obj.set_pos = function(new_pos) { - pos = new_pos; - }; - - obj.set_accel = function(new_accel) { - accel = new_accel; - }; - - obj.set_vel = function(new_vel) { - vel = new_vel; - }; - - // should only be used once, just for circular objects - obj.set_radius = function(new_radius) { - radius = new_radius; - }; - - // Should only be used for collisions - obj.set_pos = function(posn) { - pos = posn; - }; - - obj.set_mutation_info = function(m) { - mutation_info = m; - }; - - // --- getters --- - - // Override to set different scroll dist - // or leave as null to use default - obj.get_scroll_dist = function() { - return null; - }; - - obj.get_pos = function() { - return pos; - }; - - obj.get_left = function() { - return pos.x - (width / 2); - }; - - obj.get_top = function() { - return pos.y - (height / 2); - }; - - obj.get_right = function() { - return pos.x + (width / 2); - }; - - obj.get_bottom = function() { - return pos.y + (height / 2); - }; - - // returns the x offset for rectangle collisions - // should be overridden for rectangular objects - obj.get_x_offset = function() { - return 0; - }; - // returns the y offset for rectangle collisions - // should be overridden for rectangular objects - obj.get_y_offset = function() { - return 0; - }; - - obj.get_width = function() { - return width; - }; - - obj.get_height = function() { - return height; - }; - - obj.get_mode = function() { - return mode; - }; - - obj.get_vel = function() { - return vel; - }; - - obj.get_accel = function() { - return accel; - }; - - obj.get_radius = function() { - return radius; - }; - - obj.get_mutation_info = function() { - return mutation_info; - }; - - obj.get_color = function() { - return mutation_info.color; - }; - - obj.get_level = function() { - return mutation_info.level; - }; - - obj.is = function(type) { - return obj.get_type() === type; - }; - - obj.to_string = function() { - return obj.get_type()+" ("+pos.x+", "+pos.y+")"; - }; - - // draws the collision circle as an overlay - obj.draw_circle = function() { - p.fill(255, 50); - p.noStroke(); - p.shapeMode(p.CENTER); - p.ellipse(pos.x, pos.y, 2*radius, 2*radius); - }; - - // uses pythagorean theorem to calc radius of bounding circle - obj.calc_radius = function() { - return 0.5*p.sqrt(width*width+height*height); - }; - - // calc radius if not already set - radius = radius || obj.calc_radius(); - - return obj; -} diff --git a/game/dev/game_over_state.js b/game/dev/game_over_state.js deleted file mode 100644 index 6190456..0000000 --- a/game/dev/game_over_state.js +++ /dev/null @@ -1,175 +0,0 @@ -// spec: -// score : num representing score of game -// mutation_level : num representing mutation level at end of game - -var game_over_state = function (p, prev_state, spec, game_type) { - //right now, prev_state is not used - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var topy = 100; - // Score display - var score_rect = rectangle(p, { - pos : new p.PVector(p.width / 2, topy+80),// 230), - width : 0, - height : 0, - text : "Score: " + add_commas(spec.score), - text_size : 30, - text_color : 255 - }); - - var mutation_rect = rectangle(p, { - pos : new p.PVector(p.width / 2, topy+130),//280), - width : 0, - height : 0, - text : "Mutation Level: " + spec.mutation_level, - text_size : 30, - text_color : 255 - }); - - var b_top = topy+180; - var b_spc = 60; - var button_style = { - width: 120, height: 50, - text_align: p.LEFT, - }; - // Buttons - var restart_button = button(p, { - state : function() { - sounds.play_button_click(); - return in_game_state(p, prev_state, game_type); - }, - rect : { - pos : new p.PVector(p.width / 2, b_top),//330), - //text : "Restart", - //text_x_offset: 40, - image: "restart.png", - //style: button_style - } - }); - var post_button = button(p, { - state : function() { - // only post if they are logged in - if (g_user_id) { - sounds.play_button_click(); - FB.ui({ - method: 'feed', - name: "Play Virion!", - picture: "http://virus-game.cs.brown.edu/images/logo/vlogolarge.png", - link: "http://apps.facebook.com/viriongame", - caption: "I just scored "+add_commas(spec.score)+ - " playing Virion!", - }); - } - return obj; - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+b_spc),//390), - //text : "Post Score to Wall", - //text_x_offset: 35, - image: "postscore.png", - //style: button_style - } - }); - var invite_button = button(p, { - state : function() { - // only post if they are logged in - if (g_user_id) { - sounds.play_button_click(); - FB.ui({ - method: 'apprequests', - title: "Infect Your Friends", - message: 'Check out this awesome game!', - }); - } - return obj; - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+2*b_spc),//450), - //text : "Infect Your Friends", - //text_x_offset: 35, - image: "infectfriends.png", - //style: button_style - } - }); - - // only allow posts/invites if logged in - if (!g_user_id) { - post_button.deactivate(); - invite_button.deactivate(); - } - - var scores_button = button(p, { - state : function() { - sounds.play_button_click(); - return high_scores_state(p, obj); - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+3*b_spc),//510), - //text : "High Scores", - //text_x_offset: 35, - image: "highscores.png", - //style: button_style - } - }); - var splash_button = button(p, { - state : function() { - sounds.play_button_click(); - return splash_state(p); - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+4*b_spc),//570), - //text : "Main Menu", - //text_x_offset: 35, - image: "mainmenu.png", - //style: button_style - } - }); - - //Not ordered - var all_buttons = [restart_button, post_button, - invite_button, splash_button, scores_button]; - var all_rectangles = [score_rect, mutation_rect]; - - // --- public methods --- - - obj.get_type = function() { - return "game_over"; - }; - - obj.update = function() { - //do nothing - }; - - obj.key_pressed = function(k) { - if (k === 114 || p.keyCode === 13) { //r, enter - obj.set_next_state(restart_button.get_state()); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - obj.render = function() { - p.fill(0, 150); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.fill(255); - p.textAlign(p.CENTER); - - p.textSize(50); - p.text("Game Over", p.width/2, topy); - p.textSize(20); - p.text("Your virus was wiped out!", p.width/2, topy+30); - - for_each(all_rectangles, function(r) {r.draw();}); - }; - - return obj; -}; diff --git a/game/dev/game_state.js b/game/dev/game_state.js deleted file mode 100644 index 775f8f9..0000000 --- a/game/dev/game_state.js +++ /dev/null @@ -1,124 +0,0 @@ -// *** game_state *** -// Interface for all game states - -// NOTE ALL OF THE FOLLOWING WHEN CREATING A GAME STATE: -// All game states must take a previous_state in their constructor, and then call set_previous_state() -// The exception to this is splash, which is the base state and should never be exited -// If a state change happens in: -// update() - return the new state -// mouse_click/key_pressed: Call set_next_state(new_state) with the state to go to -// Buttons: -// Drawing and clicking of buttons is taken care of -// You must take care of key strokes - -var game_state = function (p) { - - // object to return - var obj = {}; - - // --- private variables --- - var next_state = null; - var previous_state = null; - var all_buttons = []; //TODO: This is static but is updated every update() - - - // --- public methods --- - - //Wrapper for every states render function - //First draws all the buttons, then calls render - obj.render_wrapper = function() { - obj.render(); - for_each(all_buttons, function(b) { b.draw(); }); - }; - - //Do not over-ride these methods - obj.set_next_state = function(ns) { - next_state = ns; - }; - obj.set_previous_state = function(ps) { - previous_state = ps; - }; - obj.exit_state = function() { - if (previous_state === null) { - throw "error previous state not set in game_state"; - } - assert(previous_state !== null, "Previous state was null in game_state.exit_state"); - next_state = previous_state; - }; - - // Wrapper for every states update function - // Goes to the next state (by returning it) if next_state has been set - obj.update_wrapper = function() { - all_buttons = obj.get_all_buttons(); - if (next_state !== null) { - var to_return = next_state; - //in case we return to this state (CURRENTLY, SHOULDN'T EVER HAPPEN I THINK) - next_state = null; - return to_return; - } - //else - obj.update(); - obj.render_wrapper(); - }; - - // Wrapper for mouse clicks - // First checks if any of the buttons are clicked, then calls mouse_click - obj.mouse_click_wrapper = function(x, y) { - var click_function = function(b) { - var next_state = b.is_clicked(x, y); - if (next_state !== null) { - obj.set_next_state(next_state); - } - } - for_each(all_buttons, click_function); - obj.mouse_click(x, y); - }; - - obj.mouse_moved_wrapper = function(x, y) { - for_each( - all_buttons, - function(b) { - b.mouse_moved(x, y); - } - ); - obj.mouse_moved(x, y); - }; - - - // all game_states must implement the following functions: - - //Returns the type of the state - obj.get_type = function() { - return "get_type not overwritten"; - }; - - //Takes in the key pressed and handles a key press - obj.key_pressed = function(k) {throw "key_pressed not overwritten"}; - - // Do nothing unless overwritten - obj.mouse_moved = function(x, y) {}; - - //Updates the current state, and returns the next state to go to - //next state can be: - // null, if no state change - // a state representing a state to go to (either previous state or newly created next state - obj.update = function() {throw "update not overwritten"}; - - // Returns all of the buttons on the screen - obj.get_all_buttons = function() {throw "get_all_buttons not overwritten"}; - - // --- Optionally implement these, they default to nothing --- - - //Renders the current state - obj.render = function(){ }; //throw "render not overwritten"}; - - //Takes in the x and y coordinates of the mouse, and handles a mouse click - obj.mouse_click = function(x, y){}; //throw "mouse_click not overwritten"}; - - //Called when returning to this state - obj.resume = function() {}; - - - - return obj; -}; diff --git a/game/dev/generator.js b/game/dev/generator.js deleted file mode 100644 index acad075..0000000 --- a/game/dev/generator.js +++ /dev/null @@ -1,393 +0,0 @@ -// *** generator *** -// generates random enemies -// spec: -// game : an in_game_state -// Is going to access: (through getters since we're so safe) -// game_objects - array -// distance - a num -// type_to_level - hash from type to level -// active_cell -// mutation : a mutation obj, so it can get current mutation color - -var make_generator = function(p, spec) { - // --- defaults --- - - // obj to return - var obj = {}; - - // --- private variables --- - - //These will be updated at every call of update() - var game_objects = null; - var distance = null; - var mutation = spec.mutation; - var game = spec.game; - var last_obj = null; // The last object generated - - var default_gen_speed = 10; - // structure that stores the generation settings - // for each type of object - // - start = distance after which to start generating - // - num = how many total on screen - // - cap = upper limit on num - // - rate = determines when to increment num - // when dist % rate = 0, num increments - // - gen_speed = speed with which to generate the object - // 1 (1/100 frames) to 100 (100/100 frames) - // If not specified, defaults to DEFAULT_GEN_SPEED - // - spacing = diagonal space to put b/w objects of this type (optional) - // - gen_x = how far offscreen to gen this type (optional) - // - gen_y = function that returns random y pos for this object (optional) - // - make_new = function that takes a pos and returns a new enemy - // - diminish = Include to make enemy's num decrease over time instead of increasing (optional) - var gen_info = { - "cell": { - // was 8 - start: 0, num: 30, cap: 10, rate: 2000, gen_speed: 55, diminish : true, - spacing: 50, - make_new: function(en_pos) { - return cell(p, { - pos: en_pos, - state: "alive", - }); - } - }, - "wall_cell": { - start: 0, num: 3, cap: 7, rate: 3000, //non testing value: 1000 - spacing: "dynamic",//100, - make_new: function(en_pos) { - return wall_cell(p, { pos: en_pos }); - } - }, - "empty_cell": { - start: 5000, num: 1, cap: 10, rate: 5000, - make_new: function(en_pos) { - return empty_cell(p, { pos: en_pos }); - } - }, - "floater": { - start: 1000, num: 3, cap: 7, rate: 7000, - spacing: "dynamic",//100, - make_new: function(en_pos) { - return floater(p, { pos: en_pos }); - } - }, - /* - "tkiller": { - start: 1000, num: 1, cap: 5, rate: 20000, - make_new: function(en_pos) { - // target will get set later - return tkiller(p, { - pos: en_pos, - mutation_info: game.get_mutation_info() - }); - } - }, - */ - "multiplier": { - start:0, num: 10, cap: 20, rate: 20000, - make_new: function(en_pos) { - return multiplier(p, { pos : en_pos }); - } - }, - /* - "b_cell": { - start:0, num: 1, cap: 1, rate: 999999, - make_new: function(en_pos) { - return b_cell(p, { pos : en_pos }); - } - }, - */ - "background_object": { - start:0, num: 8, cap: 8, rate: 999999, - spacing: p.width/5, gen_x: 500, - gen_y: function() { - return p.random(200, p.height - 180); - }, - make_new: function(en_pos) { - return background_object(p, { pos: en_pos }); - } - }, - }; - - // list of types of enemies - var enemy_types = keys(gen_info); - /*var random_type = function() { - return random_from(enemy_types);//[p.floor(p.random( - //enemy_types.length))]; - }; - */ - - // just some wrappers - var start = function(type) { - return gen_info[type].start; - }; - var num = function(type) { - return gen_info[type].num; - }; - var cap = function(type) { - return gen_info[type].cap; - }; - var rate = function(type) { - return gen_info[type].rate; - }; - var spacing = function(type) { - // dynamic spacing - if(gen_info[type].spacing === "dynamic") { - return p.width/num(type); - } - return gen_info[type].spacing; - }; - var gen_x_pos = function(type) { - return p.width + (gen_info[type].gen_x || 50); - }; - var gen_y_pos = function(type) { - if (gen_info[type].gen_y) { - return gen_info[type].gen_y(); - } - return p.floor(p.random(90, p.height-50)); - }; - var gen_speed = function(type) { - return gen_info[type].gen_speed; - }; - var make_new = function(type) { - return gen_info[type].make_new; - }; - var diminish = function(type) { - return gen_info[type].diminish || false; - } - var gen_more = function(type) { - if (diminish(type)) { - if (num(type) > cap(type)) { - gen_info[type].num = num(type)-1; - } - } - else { - if (num(type) < cap(type)) { - gen_info[type].num = num(type)+1; - } - } - }; - - // Returns whether it is not too soon to generate another - // object, based on last_obj - var ok_to_generate = function() { - if (last_obj) { - if (last_obj.get_type() === "cell") { - // 2 times width spacing - return last_obj.get_pos().x < - (gen_x_pos(last_obj.get_type()) - last_obj.get_width() * 2); - } - } - // else - return true; - }; - - // --- public methods --- - - //Should be called every time the game updates - obj.update = function() { - //game_objects = game.get_game_objects(); - distance = p.floor(game.get_distance()); - - update_types(); - - var enemy_type = random_from(enemy_types);//random_type(); - var num_enemies = count_enemy(enemy_type); - - // if there aren't enough of that enemy on the board - if (num_enemies < num(enemy_type) - // and some random factor - && p.random(100) < (gen_speed(enemy_type) || default_gen_speed ) - // and we are ready to start making this enemy - && distance >= start(enemy_type)) { - //&& ok_to_generate()) { - - var enemy_y = gen_y_pos(enemy_type); - var enemy_pos = new p.PVector(gen_x_pos(enemy_type), enemy_y); - - var new_enemy = make_new(enemy_type)(enemy_pos); - assert(new_enemy, "Error in generator.update()"); - - // make sure it's far enough away from the last object - // of its type - if (!spaced_out_enough(new_enemy)) { - return; - } - - // make sure it's not overlapping anything else - if (is_overlapping(new_enemy) - && !new_enemy.is("background_object")) { - //console.log("overlapped"); - return; - } - - //Add the new enemy to game_objects - game.add_object(new_enemy); - - // If b cell, must update b cells targets - if (new_enemy.get_type() === "b_cell") { - console.log("made new b_cell"); - game.set_b_cell_target(new_enemy); - } - - last_obj = new_enemy; - } - - }; - - // --- private methods --- - - var update_types = function() { - /* - if (distance % 100 <= 0.5) { - console.log(distance); - } - */ - // update nums for types based on rate - for_each( - enemy_types, - function(type) { - if (distance % rate(type) <= 0.1 - && distance >= 10) { - gen_more(type); - console.log("increased num of "+type+ - "s to "+num(type)); - } - } - ); - }; - - // returns how many of given enemy there are - var count_enemy = function(enemy_type) { - var n = 0; - game.do_to_type(function(o) { n++; }, - enemy_type, true); - return n; - } - - // returns true if the enemy overlaps any game objects - var is_overlapping = function(enemy) { - var overlap = false; - var check_overlap = function(obj) { - if (game.check_circle_collision(enemy, obj)) { - overlap = true; - } - }; - game.do_to_type(check_overlap, "particle", false); - game.do_to_type(check_overlap, "cell", false); - game.do_to_type(check_overlap, "enemy", false); - game.do_to_type(check_overlap, "wall_segment", false); - return overlap; - }; - - // returns true if the new enemy if far enough away (in x coord) - // from the rightmost of its type - // or if there is no spacing requirement for that type - var spaced_out_enough = function(new_enemy) { - var to_return = true; - // if there is spacing defined for this type - if (spacing(new_enemy.get_type())) { - var min_dist = 99999; - // find the closest object of the type - game.do_to_type( - function(o) { - var dist = new_enemy.get_pos().dist(o.get_pos()); - if (dist < min_dist) { - min_dist = dist; - // check if it is too close - if (dist < spacing(new_enemy.get_type())) { - to_return = false; - } - } - }, - new_enemy.get_type(), true - ); - } - return to_return; - }; - - - - /* - // return true if it is far enough apart from rightmost of its type - return new_enemy.get_pos().dist( - rightmost(new_enemy.get_type()).get_pos()) - > spacing(new_enemy.get_type()); - } - return true; - }; - - /* - var rightmost = function(type) { - var rightmost_x = 0; - var rightmost; - game.do_to_type( - function(o) { - if (o.get_pos().x > rightmost_x) { - rightmost = o; - rightmost_x = o.get_pos().x; - } - }, - type, true - ); - return rightmost; - }; - */ - - // returns an object: - // cell: number of cells on the screen - // wall_cell: number of wall_cells - // empty_cell: number of empty_cells - // tkiller: number of tkillers - // floater: number of floaters - var get_enemies = (function() { - var total = 0; - - // These are the types to check - //var types = ["cell", "wall_cell", "empty_cell", - // "floater", "tkiller"]; - - //Checks if an element is in an array - var member = function(arr, elem) { - return (arr.indexOf(elem) != -1); - }; - - var get_em = function() { - var enemies = { "cell":0, "wall_cell":0, - "empty_cell":0, "floater":0, "tkiller":0, - "multiplier":0, "b_cell":0}; - - // increment counter for each object - var incr = function(o) { - enemies[o.get_type()] += 1; - }; - game.do_to_type(incr, "cell", false); - game.do_to_type(incr, "enemy", false); - }; - /*for (var type in enemies) { - if (enemies.hasOwnProperty(type)) { - game.do_to_type( - function(o) { - enemies[type] += 1; - }, - type, true); - } - } - /*for (var i = 0; i < game_objects.length; i++) { - var lst = game_objects[i]; - for (var j = 0; j < lst.length; j++) { - var obj = lst[j]; - if (member(types, obj.get_type())) { - total++; - } - } - } - return total; - */ - - return get_em; - }()); - - return obj; -}; diff --git a/game/dev/global_functions.js b/game/dev/global_functions.js deleted file mode 100644 index d6c3167..0000000 --- a/game/dev/global_functions.js +++ /dev/null @@ -1,90 +0,0 @@ -// ** Global Constants -//DEFAULT_SCROLL_DIST = -0.8; - -// *** global_functions *** -// Holds functions used in the whole project - -//Have to catch it so fuck it -/* -function AssertException(message) { this.message = message}; -function assert(exp, message) { - if (!exp) { - throw new AssertException(message); - } -} -*/ - -var assert = function(exp, message) { - if (!exp) { - console.error("Assert error!: " + message); - } -}; - -//Does something to every element of an arr -var for_each = function(arr, fun) { - for (var i = 0; i < arr.length; i++) { - fun(arr[i]); - } -}; - -// returns the index+1 of an element in a list, -// otherwise false -// can't return just the index because 0 is false in js -var member = function(arr, elt) { - for (var i=0; i 1 ? '.' + x[1] : ''; - var rgx = /(\d+)(\d{3})/; - while (rgx.test(x1)) { - x1 = x1.replace(rgx, '$1' + ',' + '$2'); - } - return prefix + x1 + x2; -}; - diff --git a/game/dev/help.txt b/game/dev/help.txt deleted file mode 100644 index 7bdf35b..0000000 --- a/game/dev/help.txt +++ /dev/null @@ -1,9 +0,0 @@ -You've managed to infiltrate the human body's defenses and get your virus particle into the bloodstream! Now you must infect cells and use them to make more copies of your virus before the immune system wipes you out. - -After a particle infects a cell, the virus will use the cell's machinery to start making copies of itself. Once the cell is full of new virus particles, press the SPACEBAR or click the MOUSE to kill the cell, causing virus particles to burst through the cell wall towards other cells in the direction the arrow is pointing. You can pick which cell to burst using the LEFT and RIGHT arrow keys. - -Aim carefully though, because the immune system has sent out macrophages to absorb your particles. If a particle hits a macrophage, it will signal a B-cell, which will start producing antibodies. If an antibody attaches to an infected cell, a T-cell will attack it. If you don't burst the cell in time, the T-cell will kill it, destroying all the particles inside! - -Luckily, your virus can mutate and temporarily escape the immune system. Every time the virus replicates, there are errors when copying the virus's genetic material. These errors may cause mutations in the virus. Each time you infect a cell, the virus becomes more and more likely to mutate. Once you mutate, the immune system will not be able to attack you until a macrophage absorbs a virus particle from the new strain. - -How long will your virus be able to survive? diff --git a/game/dev/help_state.js b/game/dev/help_state.js deleted file mode 100644 index 27addf4..0000000 --- a/game/dev/help_state.js +++ /dev/null @@ -1,626 +0,0 @@ -var help_state = function (p, prev_state) { - - var help_image = image_manager.get_image("helpsplash.png"); - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var screens = []; - var screen_w = help_image.width - 180; - var screen_h = help_image.height - 200; - var screen_pos = new p.PVector(p.width/2, p.height/2-15); - - var screen_index = 0; - var cur_screen = function() { - return screens[screen_index]; - }; - var next_screen = function() { - if (screen_index <= screens.length-1) { - screen_index += 1; - if (screen_index === screens.length-1) { - next_button.deactivate(); - } - previous_button.activate(); - return true; - } - return false; - }; - var previous_screen = function() { - if (screen_index >= 0) { - screen_index -= 1; - if (screen_index === 0) { - previous_button.deactivate(); - } - next_button.activate(); - return true; - } - return false; - }; - - // a screen is a panel that goes in the screens array - // it displays one or more item - // spec: - // - pos: PVector representing the center of the screen - // - width - // - height - var screen = function(spec) { - var obj = {}; - var items = []; - obj.add_item = function(item) { - items.push(item); - }; - - obj.render = function() { - p.pushMatrix(); - - p.translate(spec.pos.x-spec.width/2, spec.pos.y-spec.height/2); - - // debugging - /* - p.noFill(); - p.stroke(255); - p.rect(0, 0, spec.width, spec.height); - */ - - // translate and render each item - var padding = 15; - for_each( - items, - function(item) { - item.render(); - p.translate(0, item.height()+padding); - } - ); - - p.popMatrix(); - }; - - return obj; - }; - - var new_screen = function() { - return screen({ - pos: screen_pos, - width: screen_w, - height: screen_h - }); - }; - - // item displays text and an image as part of a screen - // spec: - // - width - // - height - // - text - the text to display - // - title - the name of this item (optional) - // - image - image to display - // - illustration (obj) - // - width, height - dimensions for the illustration - // - draw - function that draws some illustration - // (origin at top left corner) - // - img_left - boolean, true if the image/ill should go on the left, - // false for the right - // (should only have image or illustration) - // - var item = function(spec) { - var obj = {}; - - // auto height - spec.height = spec.height - // the 0 here just takes us to the next cond - || (spec.image ? spec.image.height : 0) - // the actual default is at the end of this - || (spec.illustration ? spec.illustration.height : 80); - spec.width = spec.width || screen_w; - spec.padding = spec.padding || 10; - - obj.height = function() { return spec.height; }; - - obj.render = function() { - var text_x = 0; - var text_y = 0; - var text_w = spec.width; - - if (spec.image || spec.illustration) { - // make adjustments based on either one - var i = spec.image || spec.illustration; - text_w -= i.width + spec.padding; - var img_x = spec.width - i.width; - if (spec.img_left) { - img_x = 0; - text_x = i.width + spec.padding; - } - // draw either - if (spec.image) { - p.imageMode(p.CORNER); - p.image(spec.image, img_x, 0); - } - else { - p.pushMatrix(); - p.translate(img_x, 0); - spec.illustration.draw(); - p.popMatrix(); - } - } - - p.textLeading(14); - if (spec.title) { - p.textSize(18); - p.textAlign(p.LEFT, p.TOP); - p.fill(255); - p.text(spec.title, text_x, 0); - text_y += p.textAscent(); - } - p.textSize(14); - p.textAlign(p.LEFT, p.TOP); - p.fill(255); - p.text(spec.text, text_x, text_y, text_w, spec.height-text_y); - }; - - return obj; - }; - - // init the help screens - // eval'd immediately - var init_screens = (function() { - var color1 = 0xffffff00; - var color2 = 0xff7f2aff; - var cimg = image_manager.get_image("infectable_cell_2n.png"); - - var s1 = new_screen(); - screens.push(s1); - s1.add_item(item({ - text: "You've infiltrated the human body's defenses and gotten your virus particle (or virion) into the bloodstream! Here are the cells you may encounter:", - height: 45, - padding: 1, - illustration: { - width: 30, height: 30, - draw: function() { - var img = image_manager.get_image("tinyvirus_trans.png"); - var w = 15; - var h = 15; - p.fill(color1); - p.noStroke(); - p.ellipse(w, h, w*.75, h*.75); - p.imageMode(p.CENTER); - p.image(img, w, h, w, h); - } - }, - img_left: false - })); - s1.add_item(item({ - title: "Infectable (Permissive) Cells", - text: "Hit an infectable cell with a virion to infect it. After penetrating the cell wall, the virion will use the cell's machinery to make copies of itself.", - //image: cimg, - illustration: { - width: 50, height: 60, - draw: (function() { - var c = cell(p, { - pos: new p.PVector(30, 30), - width: 30, height: 30, - illustration: true - }); - c.set_image(cimg); - //c.set_state("active"); - return function() { - c.draw(); - }; - }()), - }, - img_left: true - })); - s1.add_item(item({ - text: "Press SPACEBAR or click the MOUSE to burst an infected cell and shoot the new virions in the direction of the arrow. Pick which cell to burst using the LEFT and RIGHT arrow keys.", - //image: image_manager.get_image("infectable_cell_2n.png"), - illustration: { - width: 30, height: 60, - draw: (function() { - var c = cell(p, { - pos: new p.PVector(20, 30), - width: 30, height: 30, - mutation_info: { color: color1 }, - illustration: true - }); - c.set_image(cimg); - c.set_state("active"); - return function() { - c.draw(); - }; - }()), - }, - img_left: false - })); - s1.add_item(item({ - title: "Non-permissive Cells", - text: "Some cells can be infected, but will not let your virion replicate. A virion that infects a non-permissive cell is as good as dead.", - illustration: { - width: 50, height: 60, - draw: (function() { - var c = empty_cell(p, { - pos: new p.PVector(30, 30), - width: 30, height: 30, - }); - return function() { - c.draw(); - }; - }()), - }, - img_left: true - })); - s1.add_item(item({ - title: "Resistant Cells", - text: "Virions can't break through the cell wall of resistant cells - they will just bounce off in the other direction.", - height: 60, - illustration: { - width: 30, height: 60, - draw: (function() { - var c = wall_cell(p, { - pos: new p.PVector(20, 30), - //width: 30, height: 30, - }); - return function() { - c.draw(); - }; - }()), - }, - img_left: false - })); - - var s2 = new_screen(); - screens.push(s2); - s2.add_item(item({ - text: "Be careful! The immune system will try to destroy your virus. Here are the enemies you should look out for:", - height: 30 - })); - s2.add_item(item({ - title: "Macrophages", - text: "The immune system's first line of defense. They will absorb any virion that hits them and then signal a B cell to give it information about your virus.", - height: 80, - //image: image_manager.get_image("macrophage_1.png"), - illustration: { - width: 50, height: 70, - draw: (function() { - var m = floater(p, { - pos: new p.PVector(25, 35), - width: 50, height: 70, - mutation_info: { color: color1 }, - illustration: true - }); - m.activate(); - return function() { - m.draw(); - }; - }()) - }, - img_left: true - })); - s2.add_item(item({ - title: "B Cells", - text: "Once a B cell knows about your virus, it will produce Y-shaped antibodies that will attach to infected cells, marking them for destruction.", - height: 70, - //image: image_manager.get_image("bcell_normal.png"), - illustration: { - width: 60, height: 60, - draw: (function() { - var b = b_cell(p, { - pos: new p.PVector(30, 55), - width: 40, height: 40, - mutation_info: { color: color1 }, - illustration: true - }); - b.set_state("active"); - b.set_target_angle(-p.PI/2); - - var a1 = antibody(p, { - pos: new p.PVector(40, 17), - mutation_info: { color: color1 }, - }); - a1.set_target_angle(-p.PI/4); - - var a2 = antibody(p, { - pos: new p.PVector(18, 23), - mutation_info: { color: color1 }, - }); - a2.set_target_angle(-3*p.PI/4+.2); - - return function() { - // make a thicker antibody - b.set_anti_count(10); - b.draw(); - a1.draw(); - a2.draw(); - }; - }()) - }, - img_left: false - })); - s2.add_item(item({ - title: "Granulocytes", - text: "If an infected cell is marked with an antibody, the granulocyte will hunt it down and destroy it, along with all the virions inside!", - //image: image_manager.get_image("tcell_2.png"), - illustration: { - width: 60, height: 60, - draw: (function() { - var tk = tkiller(p, { - pos: new p.PVector(30, 30), - width: 60, height: 60, - mutation_info: { color: color1 }, - illustration: true - }); - //tk.set_state("alive"); - - return function() { - tk.draw(); - }; - }()) - }, - img_left: true - })); - - var s3 = new_screen(); - screens.push(s3); - s3.add_item(item({ - title: "Mutation", - text: "Luckily, in the process of replicating a virus's genetic material, mistakes are often made, causing the virus to mutate! If a mutation occurs, a new strain of the virus will be created. Every time you infect a cell, the chance of a mutation occurring increases.", - height: 120, - padding: 15, - illustration: { - width: 90, height: 90, - draw: (function() { - var c1 = cell(p, { - pos: new p.PVector(10, 20), - width: 30, height: 30, - mutation_info: { color: color1 }, - illustration: true - }); - c1.set_image(cimg); - c1.set_state("infected"); - - var c2 = cell(p, { - pos: new p.PVector(70, 80), - width: 30, height: 30, - mutation_info: { color: color2 }, - illustration: true - }); - c2.set_image(cimg); - c2.set_state("infected"); - - return function() { - c1.draw(); - c2.draw(); - p.stroke(255); - p.strokeWeight(3); - p.line(30, 40, 50, 60); - p.line(50, 60, 50, 50); - p.line(50, 60, 40, 60); - }; - }()), - }, - img_left: false - })); - s3.add_item(item({ - text: "Macrophages, B cells, granulocytes, and antibodies are created to attack a specific strain of a virus. So when your virus mutates, the new strain will be safe from the old enemies.", - //image: image_manager.get_image("macrophage_1.png"), - padding: 15, - illustration: { - width: 60, height: 60, - draw: (function() { - var tk = tkiller(p, { - pos: new p.PVector(50, 10), - mutation_info: { color: color1 }, - illustration: true - }); - tk.set_target_angle(-p.PI/4); - //tk.set_state("illustration"); - - var c = cell(p, { - pos: new p.PVector(10, 40), - width: 30, height: 30, - mutation_info: { color: color2 }, - illustration: true - }); - c.set_image(cimg); - c.set_state("infected"); - - var a = antibody(p, { - pos: new p.PVector(20, 15), - mutation_info: { color: color2 } - }); - a.set_target(c); - a.update(); - - return function() { - tk.draw(); - c.draw(); - a.draw(); - }; - }()), - }, - img_left: true - })); - s3.add_item(item({ - text: "Each new strain will be represented by a different color. Therefore, an infected cell can only be attacked by enemies of the same color.", - //image: image_manager.get_image("tcell_2.png"), - //padding: 15, - illustration: { - width: 60, height: 50, - draw: (function() { - var tk = tkiller(p, { - pos: new p.PVector(50, 12), - mutation_info: { color: color2 }, - illustration: true - }); - //tk.set_target_angle(p.PI/4); - //tk.set_state("illustration"); - - var c = cell(p, { - pos: new p.PVector(15, 40), - width: 30, height: 30, - mutation_info: { color: color2 }, - illustration: true - }); - c.set_image(cimg); - c.set_state("infected"); - - tk.set_target(c); - tk.update(); - - var a = antibody(p, { - pos: new p.PVector(5, 15), - mutation_info: { color: color2 } - }); - a.set_target(c); - a.update(); - - return function() { - tk.draw(); - c.draw(); - a.draw(); - }; - }()), - }, - img_left: false - })); - s3.add_item(item({ - title: "Multiplier Particles", - text: "Higher mutation levels will give you more points, as will collecting multiplier particles. When you infect a cell, the amount of points you get is multiplied by your multiplier and level.", - illustration: { - width: 50, height: 90, - draw: (function() { - var poss = [ - new p.PVector(10, 10), - new p.PVector(27, 25), - new p.PVector(20, 45), - new p.PVector(35, 50), - //new p.PVector(23, 30), - new p.PVector(40, 12) - ]; - var ms = []; - for_each(poss, - function(pos) { - ms.push(multiplier(p, { pos: pos })); - } - ); - - return function() { - for_each(ms, function(m) { m.draw(); }); - }; - }()), - }, - img_left: true - })); - - - }()); - - - /* - var box_w = 370; - var box_h = 500; - var box_x = p.width/2 - box_w/2; - var box_y = p.height/2 - box_h/2; - */ - - // Buttons - var button_y = p.height/2 + 190; - var button_style = { - width: 120, - height: 50, - }; - - var back_button = button(p, { - state : function() { sounds.play_button_back(); return prev_state; }, - rect : { - pos : new p.PVector(p.width/2, button_y), //box_x+box_w-80, box_y+box_h-30), - //text: "Back", - //text_x_offset: 5, - //text_y_offset: -8, - image: "back.png", - } - }); - - var next_button = button(p, { - state: function() { - sounds.play_button_click(); - next_screen(); - return obj; - }, - rect: { - pos: new p.PVector(p.width/2+120, button_y), - //text: "Next", - image: "next.png", - //style: button_style - } - }); - - var previous_button = button(p, { - state: function() { - sounds.play_button_back(); - previous_screen(); - return obj; - }, - rect: { - pos: new p.PVector(p.width/2-120, button_y), - //text: "Previous", - image: "previous.png", - //style: button_style - } - }); - previous_button.deactivate(); - - //Not ordered - var all_buttons = [ previous_button, back_button, next_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "help"; - }; - - obj.update = function() { - //do nothing - }; - - - obj.render = function() { - //p.pushMatrix(); - - p.imageMode(p.CENTER); - p.image(help_image, p.width/2, p.height/2); - - cur_screen().render(); - - //p.translate(box_x, box_y); - - //p.fill(0); - //p.rect(0, 0, box_w, box_h); - - //p.noStroke(); - //p.fill(255); - - //p.textAlign(p.CENTER, p.CENTER); - //p.textSize(24); - //p.text("Instructions", box_w/2, 30); - - //p.textAlign(p.LEFT, p.CENTER); - //p.textSize(13); - //p.text(instruction_text, - //5, 20, box_w, box_h-50); - - //p.popMatrix(); - }; - - obj.key_pressed = function(k) { - if (k === 104) { //h - obj.set_next_state(help_button.get_state()); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/game/dev/high_scores_state.js b/game/dev/high_scores_state.js deleted file mode 100644 index 4f3583f..0000000 --- a/game/dev/high_scores_state.js +++ /dev/null @@ -1,83 +0,0 @@ -var high_scores_state = function (p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - // Buttons - - var button_style = { - text_size: 14, - text_align: p.LEFT, - text_x_offset: 25, - width: 120, - height: 50, - }; - - var back_button = button(p, { - state : function() { - sounds.play_button_back(); - - // hide the div - $("#scores-wrap").hide(); - $("#scores").tabs("destroy"); - return prev_state;//splash_state(p); - }, - rect : { - pos : new p.PVector(540, 550), - //text: "Main Menu", - //text_x_offset: -5, - image: "back.png", - //image_x_offset: -5, - //style: button_style - } - }); - - //Not ordered - var all_buttons = [ back_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "high_scores"; - }; - - obj.update = function() { - }; - - obj.render = function() { - p.noStroke(); - p.fill(0, 150); - p.rect(0, 0, p.width, p.height); - }; - - obj.key_pressed = function(k) { - /* - if (k === 112 || p.keyCode == 13) { //p, enter - obj.exit_state(); - } - */ - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - // init the scores immediately - var init = (function() { - // add a loading message to be removed on load - $("#scores-wrap").prepend( - "
Loading high score data...
" - ); - - // show the div - $("#scores-wrap").show(); - // update and render scores - // TODO what if it fails? - scores.do_scores(); - }()); - - return obj; -}; diff --git a/game/dev/image_manager.js b/game/dev/image_manager.js deleted file mode 100644 index 0b7192e..0000000 --- a/game/dev/image_manager.js +++ /dev/null @@ -1,171 +0,0 @@ -// image_manager preloads and holds all the images used in the game - -var make_image_manager = function() { - - // obj to return - var obj = []; - - // --- private variables --- - - // this will be counted in preloading - var num_images = 0; - - // object to hold all arrays of image paths - // and the dir name that they come from - // dir should be name after "images/" and must end in '/' - var all_images = { - infectable_cell : { dir : "infectable_cell/" }, - empty_cell : { dir : "noninfectable_cell/" }, - background : { dir : "background_objects/" }, - screens : { dir : "screens/" }, - wall_segments : { dir : "wall_segments/" }, - macrophage : {dir : "macrophage_animation/"}, - macrophage_active : {dir : "holemacrophage_animation/"}, - bcell : {dir : "b_animation/"}, - burst : { dir : "burstingcell_animation/"}, - cell_infect : { dir : "cellinfect_animation/"}, - t_animation : { dir : "t_animation/"}, - buttons : { dir : "buttons/"}, - // catches all images in images/ - other : { dir : "" }, - }; - - // add "arr" property to each image - for_each( - keys(all_images), - function(key) { - all_images[key].images = []; - } - ); - - // filter out non-images from global image file list - var image_types = ["png", "jpg", "gif"]; - for_each( - keys(all_image_files), - function(key) { - all_image_files[key] = all_image_files[key].filter( - function(name) { - return member(image_types, - name.substring(name.lastIndexOf('.')+1)); - } - ); - } - ); - - // --- public methods --- - - // returns all the image objects of a given type - // if preloading and initing is done - // NOTE: returns a copy of the array of pointers, but the pointers - // will all point to the same objects so don't change the objects - obj.get_images = function(type) { - if (!all_images[type]) { - console.error("Invalid image type: "+type); - } - //for_each(all_images[type], console.log() - return all_images[type].images.slice(); - }; - - // finds and returns the first image with the given name - // (no path necessary) - obj.get_image = function(name) { - var to_return; - for_each( - keys(all_images), - function(key) { - for_each( - all_images[key].images, - function(img_obj) { - if (name === img_obj.path.substring( - img_obj.path.lastIndexOf('/')+1)) { - to_return = img_obj.image; - } - } - ); - } - ); - if (!to_return) { - console.error("Invalid image name: "+name); - } - return to_return; - }; - - // preloads all the images - obj.preload_images = function() { - console.log("preloading images"); - for_each_image( - function(path) { - // let processing load it in the cache - sketch.imageCache.add(path); - // count it - num_images += 1; - console.log("loading "+path); - } - ); - }; - - // DO NOT CALL BEFORE CALLING PRELOAD - obj.num_loaded = function() { - return num_images - sketch.imageCache.pending; - }; - - // DO NOT CALL BEFORE CALLING PRELOAD - obj.num_images = function() { - return num_images; - }; - - // DO NOT CALL BEFORE CALLING PRELOAD - obj.is_done_preloading = function() { - return !sketch.imageCache.pending; - }; - - // DO NOT CALL BEFORE PRELOADING IS DONE - // should be called after preloading is done - // to make the image objects - // note: must be passed a processing instance p - obj.init_images = function(p) { - console.log("initing images"); - for_each_image( - function(img_path, type) { - // make an actual image object for each preloaded image - all_images[type].images.push({ - path: img_path, - image: p.loadImage(img_path), - }); - } - ); - }; - - // --- private methods --- - - // gets array of paths from the object populated by the php function - var files_in_dir = function(dir_path) { - if (!all_image_files[dir_path]) { - console.error("Invalid dir: "+dir_path); - } - return all_image_files[dir_path]; - }; - - // applies f to each image path - // f takes a path and an image type (key) - var for_each_image = function(f) { - // for each type of image - for_each( - keys(all_images), - function(key) { - // for each image in the dir - for_each( - files_in_dir("images/"+all_images[key].dir), - function(path) { - f(path, key); - } - ); - } - ); - }; - - return obj; -}; - -// make a global instance -var image_manager = make_image_manager(); diff --git a/game/dev/images/b_animation/bcell_a01.png b/game/dev/images/b_animation/bcell_a01.png deleted file mode 100644 index a11fd65..0000000 Binary files a/game/dev/images/b_animation/bcell_a01.png and /dev/null differ diff --git a/game/dev/images/b_animation/bcell_a02.png b/game/dev/images/b_animation/bcell_a02.png deleted file mode 100644 index 2cdf59d..0000000 Binary files a/game/dev/images/b_animation/bcell_a02.png and /dev/null differ diff --git a/game/dev/images/b_animation/bcell_a03.png b/game/dev/images/b_animation/bcell_a03.png deleted file mode 100644 index 0751bbe..0000000 Binary files a/game/dev/images/b_animation/bcell_a03.png and /dev/null differ diff --git a/game/dev/images/b_animation/bcell_a04.png b/game/dev/images/b_animation/bcell_a04.png deleted file mode 100644 index e1ff517..0000000 Binary files a/game/dev/images/b_animation/bcell_a04.png and /dev/null differ diff --git a/game/dev/images/b_animation/bcell_a05.png b/game/dev/images/b_animation/bcell_a05.png deleted file mode 100644 index d95d849..0000000 Binary files a/game/dev/images/b_animation/bcell_a05.png and /dev/null differ diff --git a/game/dev/images/b_animation/bcell_a06.png b/game/dev/images/b_animation/bcell_a06.png deleted file mode 100644 index 4d11066..0000000 Binary files a/game/dev/images/b_animation/bcell_a06.png and /dev/null differ diff --git a/game/dev/images/b_animation/bcell_a07.png b/game/dev/images/b_animation/bcell_a07.png deleted file mode 100644 index 1f2efb1..0000000 Binary files a/game/dev/images/b_animation/bcell_a07.png and /dev/null differ diff --git a/game/dev/images/background1.png b/game/dev/images/background1.png deleted file mode 100644 index 0232c24..0000000 Binary files a/game/dev/images/background1.png and /dev/null differ diff --git a/game/dev/images/background_bottomside.png b/game/dev/images/background_bottomside.png deleted file mode 100644 index 039dd50..0000000 Binary files a/game/dev/images/background_bottomside.png and /dev/null differ diff --git a/game/dev/images/background_objects/.DS_Store b/game/dev/images/background_objects/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/dev/images/background_objects/.DS_Store and /dev/null differ diff --git a/game/dev/images/background_objects/background_bcells1.png b/game/dev/images/background_objects/background_bcells1.png deleted file mode 100644 index 6de753b..0000000 Binary files a/game/dev/images/background_objects/background_bcells1.png and /dev/null differ diff --git a/game/dev/images/background_objects/background_bcells2.png b/game/dev/images/background_objects/background_bcells2.png deleted file mode 100644 index 3a523d9..0000000 Binary files a/game/dev/images/background_objects/background_bcells2.png and /dev/null differ diff --git a/game/dev/images/background_objects/background_bcells3.png b/game/dev/images/background_objects/background_bcells3.png deleted file mode 100644 index ef718b9..0000000 Binary files a/game/dev/images/background_objects/background_bcells3.png and /dev/null differ diff --git a/game/dev/images/background_objects/background_bcells4.png b/game/dev/images/background_objects/background_bcells4.png deleted file mode 100644 index 6295cbd..0000000 Binary files a/game/dev/images/background_objects/background_bcells4.png and /dev/null differ diff --git a/game/dev/images/background_objects/background_dstreaks1.png b/game/dev/images/background_objects/background_dstreaks1.png deleted file mode 100644 index 825f60f..0000000 Binary files a/game/dev/images/background_objects/background_dstreaks1.png and /dev/null differ diff --git a/game/dev/images/background_objects/background_dstreaks2.png b/game/dev/images/background_objects/background_dstreaks2.png deleted file mode 100644 index a6f0582..0000000 Binary files a/game/dev/images/background_objects/background_dstreaks2.png and /dev/null differ diff --git a/game/dev/images/background_objects/background_dstreaks3.png b/game/dev/images/background_objects/background_dstreaks3.png deleted file mode 100644 index c65a2f8..0000000 Binary files a/game/dev/images/background_objects/background_dstreaks3.png and /dev/null differ diff --git a/game/dev/images/background_objects/background_lstreaks1.png b/game/dev/images/background_objects/background_lstreaks1.png deleted file mode 100644 index 74595f5..0000000 Binary files a/game/dev/images/background_objects/background_lstreaks1.png and /dev/null differ diff --git a/game/dev/images/background_objects/background_lstreaks2.png b/game/dev/images/background_objects/background_lstreaks2.png deleted file mode 100644 index 62d1f4e..0000000 Binary files a/game/dev/images/background_objects/background_lstreaks2.png and /dev/null differ diff --git a/game/dev/images/background_topside.png b/game/dev/images/background_topside.png deleted file mode 100644 index 613f9ac..0000000 Binary files a/game/dev/images/background_topside.png and /dev/null differ diff --git a/game/dev/images/bcell_normal.png b/game/dev/images/bcell_normal.png deleted file mode 100644 index 60b8545..0000000 Binary files a/game/dev/images/bcell_normal.png and /dev/null differ diff --git a/game/dev/images/bullet_listcell.png b/game/dev/images/bullet_listcell.png deleted file mode 100644 index b778d5c..0000000 Binary files a/game/dev/images/bullet_listcell.png and /dev/null differ diff --git a/game/dev/images/burstingcell_animation/burst_a01.png b/game/dev/images/burstingcell_animation/burst_a01.png deleted file mode 100644 index 464828e..0000000 Binary files a/game/dev/images/burstingcell_animation/burst_a01.png and /dev/null differ diff --git a/game/dev/images/burstingcell_animation/burst_a02.png b/game/dev/images/burstingcell_animation/burst_a02.png deleted file mode 100644 index 87f6492..0000000 Binary files a/game/dev/images/burstingcell_animation/burst_a02.png and /dev/null differ diff --git a/game/dev/images/burstingcell_animation/burst_a03.png b/game/dev/images/burstingcell_animation/burst_a03.png deleted file mode 100644 index bb6d224..0000000 Binary files a/game/dev/images/burstingcell_animation/burst_a03.png and /dev/null differ diff --git a/game/dev/images/burstingcell_animation/burst_a04.png b/game/dev/images/burstingcell_animation/burst_a04.png deleted file mode 100644 index 174dd4a..0000000 Binary files a/game/dev/images/burstingcell_animation/burst_a04.png and /dev/null differ diff --git a/game/dev/images/burstingcell_animation/burst_a05.png b/game/dev/images/burstingcell_animation/burst_a05.png deleted file mode 100644 index 50fa69f..0000000 Binary files a/game/dev/images/burstingcell_animation/burst_a05.png and /dev/null differ diff --git a/game/dev/images/burstingcell_animation/burst_a06.png b/game/dev/images/burstingcell_animation/burst_a06.png deleted file mode 100644 index 414accb..0000000 Binary files a/game/dev/images/burstingcell_animation/burst_a06.png and /dev/null differ diff --git a/game/dev/images/burstingcell_animation/burst_a07.png b/game/dev/images/burstingcell_animation/burst_a07.png deleted file mode 100644 index 0aa533b..0000000 Binary files a/game/dev/images/burstingcell_animation/burst_a07.png and /dev/null differ diff --git a/game/dev/images/burstingcell_animation/burst_a08.png b/game/dev/images/burstingcell_animation/burst_a08.png deleted file mode 100644 index 735a858..0000000 Binary files a/game/dev/images/burstingcell_animation/burst_a08.png and /dev/null differ diff --git a/game/dev/images/burstingcell_animation/burst_a09.png b/game/dev/images/burstingcell_animation/burst_a09.png deleted file mode 100644 index 74f67d9..0000000 Binary files a/game/dev/images/burstingcell_animation/burst_a09.png and /dev/null differ diff --git a/game/dev/images/burstingcell_animation/burst_a10.png b/game/dev/images/burstingcell_animation/burst_a10.png deleted file mode 100644 index 5182129..0000000 Binary files a/game/dev/images/burstingcell_animation/burst_a10.png and /dev/null differ diff --git a/game/dev/images/burstingcell_animation/burst_a11.png b/game/dev/images/burstingcell_animation/burst_a11.png deleted file mode 100644 index cb79f9a..0000000 Binary files a/game/dev/images/burstingcell_animation/burst_a11.png and /dev/null differ diff --git a/game/dev/images/burstingcell_animation/burst_a12.png b/game/dev/images/burstingcell_animation/burst_a12.png deleted file mode 100644 index 7a75730..0000000 Binary files a/game/dev/images/burstingcell_animation/burst_a12.png and /dev/null differ diff --git a/game/dev/images/burstingcell_animation/burst_a13.png b/game/dev/images/burstingcell_animation/burst_a13.png deleted file mode 100644 index d1054f6..0000000 Binary files a/game/dev/images/burstingcell_animation/burst_a13.png and /dev/null differ diff --git a/game/dev/images/buttons/back.png b/game/dev/images/buttons/back.png deleted file mode 100644 index a6e28a9..0000000 Binary files a/game/dev/images/buttons/back.png and /dev/null differ diff --git a/game/dev/images/buttons/check0.png b/game/dev/images/buttons/check0.png deleted file mode 100644 index 993c88a..0000000 Binary files a/game/dev/images/buttons/check0.png and /dev/null differ diff --git a/game/dev/images/buttons/check1.png b/game/dev/images/buttons/check1.png deleted file mode 100644 index 0207b44..0000000 Binary files a/game/dev/images/buttons/check1.png and /dev/null differ diff --git a/game/dev/images/buttons/continue.png b/game/dev/images/buttons/continue.png deleted file mode 100644 index f5f4bed..0000000 Binary files a/game/dev/images/buttons/continue.png and /dev/null differ diff --git a/game/dev/images/buttons/credits.png b/game/dev/images/buttons/credits.png deleted file mode 100644 index 567677e..0000000 Binary files a/game/dev/images/buttons/credits.png and /dev/null differ diff --git a/game/dev/images/buttons/highscores.png b/game/dev/images/buttons/highscores.png deleted file mode 100644 index e59ce26..0000000 Binary files a/game/dev/images/buttons/highscores.png and /dev/null differ diff --git a/game/dev/images/buttons/infectfriends.png b/game/dev/images/buttons/infectfriends.png deleted file mode 100644 index 6bd07d4..0000000 Binary files a/game/dev/images/buttons/infectfriends.png and /dev/null differ diff --git a/game/dev/images/buttons/instructions.png b/game/dev/images/buttons/instructions.png deleted file mode 100644 index ab6ee9b..0000000 Binary files a/game/dev/images/buttons/instructions.png and /dev/null differ diff --git a/game/dev/images/buttons/mainmenu.png b/game/dev/images/buttons/mainmenu.png deleted file mode 100644 index 3778426..0000000 Binary files a/game/dev/images/buttons/mainmenu.png and /dev/null differ diff --git a/game/dev/images/buttons/mainscreenmockup.jpg b/game/dev/images/buttons/mainscreenmockup.jpg deleted file mode 100755 index 859bae9..0000000 Binary files a/game/dev/images/buttons/mainscreenmockup.jpg and /dev/null differ diff --git a/game/dev/images/buttons/mbeginner.png b/game/dev/images/buttons/mbeginner.png deleted file mode 100755 index e8a99e9..0000000 Binary files a/game/dev/images/buttons/mbeginner.png and /dev/null differ diff --git a/game/dev/images/buttons/mbeginner_r.png b/game/dev/images/buttons/mbeginner_r.png deleted file mode 100755 index 5eeee23..0000000 Binary files a/game/dev/images/buttons/mbeginner_r.png and /dev/null differ diff --git a/game/dev/images/buttons/mhighscores.png b/game/dev/images/buttons/mhighscores.png deleted file mode 100755 index 7065e7b..0000000 Binary files a/game/dev/images/buttons/mhighscores.png and /dev/null differ diff --git a/game/dev/images/buttons/mhighscores_r.png b/game/dev/images/buttons/mhighscores_r.png deleted file mode 100644 index 78ff539..0000000 Binary files a/game/dev/images/buttons/mhighscores_r.png and /dev/null differ diff --git a/game/dev/images/buttons/mhowtoplay.png b/game/dev/images/buttons/mhowtoplay.png deleted file mode 100755 index 229ff4d..0000000 Binary files a/game/dev/images/buttons/mhowtoplay.png and /dev/null differ diff --git a/game/dev/images/buttons/mhowtoplay_r.png b/game/dev/images/buttons/mhowtoplay_r.png deleted file mode 100755 index a21644f..0000000 Binary files a/game/dev/images/buttons/mhowtoplay_r.png and /dev/null differ diff --git a/game/dev/images/buttons/mnewgame.png b/game/dev/images/buttons/mnewgame.png deleted file mode 100644 index 37ae877..0000000 Binary files a/game/dev/images/buttons/mnewgame.png and /dev/null differ diff --git a/game/dev/images/buttons/mnewgame_r.png b/game/dev/images/buttons/mnewgame_r.png deleted file mode 100644 index b8359c5..0000000 Binary files a/game/dev/images/buttons/mnewgame_r.png and /dev/null differ diff --git a/game/dev/images/buttons/mnormal.png b/game/dev/images/buttons/mnormal.png deleted file mode 100755 index a8cd0ce..0000000 Binary files a/game/dev/images/buttons/mnormal.png and /dev/null differ diff --git a/game/dev/images/buttons/mnormal_r.png b/game/dev/images/buttons/mnormal_r.png deleted file mode 100755 index ee2139d..0000000 Binary files a/game/dev/images/buttons/mnormal_r.png and /dev/null differ diff --git a/game/dev/images/buttons/msettings.png b/game/dev/images/buttons/msettings.png deleted file mode 100644 index e1fc244..0000000 Binary files a/game/dev/images/buttons/msettings.png and /dev/null differ diff --git a/game/dev/images/buttons/msettings_r.png b/game/dev/images/buttons/msettings_r.png deleted file mode 100644 index 27fd0d1..0000000 Binary files a/game/dev/images/buttons/msettings_r.png and /dev/null differ diff --git a/game/dev/images/buttons/mtutorial.png b/game/dev/images/buttons/mtutorial.png deleted file mode 100755 index 9de8ca9..0000000 Binary files a/game/dev/images/buttons/mtutorial.png and /dev/null differ diff --git a/game/dev/images/buttons/mtutorial_r.png b/game/dev/images/buttons/mtutorial_r.png deleted file mode 100755 index 804366f..0000000 Binary files a/game/dev/images/buttons/mtutorial_r.png and /dev/null differ diff --git a/game/dev/images/buttons/next.png b/game/dev/images/buttons/next.png deleted file mode 100644 index ee4b257..0000000 Binary files a/game/dev/images/buttons/next.png and /dev/null differ diff --git a/game/dev/images/buttons/postscore.png b/game/dev/images/buttons/postscore.png deleted file mode 100644 index bd6a40d..0000000 Binary files a/game/dev/images/buttons/postscore.png and /dev/null differ diff --git a/game/dev/images/buttons/previous.png b/game/dev/images/buttons/previous.png deleted file mode 100644 index 1d1d0cb..0000000 Binary files a/game/dev/images/buttons/previous.png and /dev/null differ diff --git a/game/dev/images/buttons/quit.png b/game/dev/images/buttons/quit.png deleted file mode 100644 index ca30b7e..0000000 Binary files a/game/dev/images/buttons/quit.png and /dev/null differ diff --git a/game/dev/images/buttons/restart.png b/game/dev/images/buttons/restart.png deleted file mode 100644 index 0a986b5..0000000 Binary files a/game/dev/images/buttons/restart.png and /dev/null differ diff --git a/game/dev/images/buttons/return.png b/game/dev/images/buttons/return.png deleted file mode 100644 index a3f4981..0000000 Binary files a/game/dev/images/buttons/return.png and /dev/null differ diff --git a/game/dev/images/buttons/set_click.png b/game/dev/images/buttons/set_click.png deleted file mode 100644 index f7dbec3..0000000 Binary files a/game/dev/images/buttons/set_click.png and /dev/null differ diff --git a/game/dev/images/buttons/set_mouseselect.png b/game/dev/images/buttons/set_mouseselect.png deleted file mode 100644 index a29db1e..0000000 Binary files a/game/dev/images/buttons/set_mouseselect.png and /dev/null differ diff --git a/game/dev/images/buttons/set_music.png b/game/dev/images/buttons/set_music.png deleted file mode 100644 index 70146ec..0000000 Binary files a/game/dev/images/buttons/set_music.png and /dev/null differ diff --git a/game/dev/images/buttons/set_sound.png b/game/dev/images/buttons/set_sound.png deleted file mode 100644 index 5f0d487..0000000 Binary files a/game/dev/images/buttons/set_sound.png and /dev/null differ diff --git a/game/dev/images/buttons/set_spacebar.png b/game/dev/images/buttons/set_spacebar.png deleted file mode 100644 index 153275c..0000000 Binary files a/game/dev/images/buttons/set_spacebar.png and /dev/null differ diff --git a/game/dev/images/buttons/set_track.png b/game/dev/images/buttons/set_track.png deleted file mode 100644 index c2489cb..0000000 Binary files a/game/dev/images/buttons/set_track.png and /dev/null differ diff --git a/game/dev/images/buttons/settings.png b/game/dev/images/buttons/settings.png deleted file mode 100644 index cb52726..0000000 Binary files a/game/dev/images/buttons/settings.png and /dev/null differ diff --git a/game/dev/images/buttons/track_left.png b/game/dev/images/buttons/track_left.png deleted file mode 100644 index 0ad83cd..0000000 Binary files a/game/dev/images/buttons/track_left.png and /dev/null differ diff --git a/game/dev/images/buttons/track_right.png b/game/dev/images/buttons/track_right.png deleted file mode 100644 index 0890c6e..0000000 Binary files a/game/dev/images/buttons/track_right.png and /dev/null differ diff --git a/game/dev/images/buttons/tut_ok.png b/game/dev/images/buttons/tut_ok.png deleted file mode 100755 index b047b7b..0000000 Binary files a/game/dev/images/buttons/tut_ok.png and /dev/null differ diff --git a/game/dev/images/buttons/tutorialbox.png b/game/dev/images/buttons/tutorialbox.png deleted file mode 100755 index cff6abf..0000000 Binary files a/game/dev/images/buttons/tutorialbox.png and /dev/null differ diff --git a/game/dev/images/cellinfect_animation/infect_a01.png b/game/dev/images/cellinfect_animation/infect_a01.png deleted file mode 100644 index 7d02b1a..0000000 Binary files a/game/dev/images/cellinfect_animation/infect_a01.png and /dev/null differ diff --git a/game/dev/images/cellinfect_animation/infect_a02.png b/game/dev/images/cellinfect_animation/infect_a02.png deleted file mode 100644 index cd5d557..0000000 Binary files a/game/dev/images/cellinfect_animation/infect_a02.png and /dev/null differ diff --git a/game/dev/images/cellinfect_animation/infect_a03.png b/game/dev/images/cellinfect_animation/infect_a03.png deleted file mode 100644 index 070d4d9..0000000 Binary files a/game/dev/images/cellinfect_animation/infect_a03.png and /dev/null differ diff --git a/game/dev/images/cellinfect_animation/infect_a04.png b/game/dev/images/cellinfect_animation/infect_a04.png deleted file mode 100644 index 45c2d2c..0000000 Binary files a/game/dev/images/cellinfect_animation/infect_a04.png and /dev/null differ diff --git a/game/dev/images/cellinfect_animation/infect_a05.png b/game/dev/images/cellinfect_animation/infect_a05.png deleted file mode 100644 index 6b0cf04..0000000 Binary files a/game/dev/images/cellinfect_animation/infect_a05.png and /dev/null differ diff --git a/game/dev/images/cellinfect_animation/infect_a06.png b/game/dev/images/cellinfect_animation/infect_a06.png deleted file mode 100644 index caf6ac5..0000000 Binary files a/game/dev/images/cellinfect_animation/infect_a06.png and /dev/null differ diff --git a/game/dev/images/cellinfect_animation/infect_a07.png b/game/dev/images/cellinfect_animation/infect_a07.png deleted file mode 100644 index fedb457..0000000 Binary files a/game/dev/images/cellinfect_animation/infect_a07.png and /dev/null differ diff --git a/game/dev/images/cellinfect_animation/infect_a08.png b/game/dev/images/cellinfect_animation/infect_a08.png deleted file mode 100644 index 1e0ca69..0000000 Binary files a/game/dev/images/cellinfect_animation/infect_a08.png and /dev/null differ diff --git a/game/dev/images/cellinfect_animation/infect_a09.png b/game/dev/images/cellinfect_animation/infect_a09.png deleted file mode 100644 index 43d1b04..0000000 Binary files a/game/dev/images/cellinfect_animation/infect_a09.png and /dev/null differ diff --git a/game/dev/images/cellinfect_animation/infect_a10.png b/game/dev/images/cellinfect_animation/infect_a10.png deleted file mode 100644 index 0aee860..0000000 Binary files a/game/dev/images/cellinfect_animation/infect_a10.png and /dev/null differ diff --git a/game/dev/images/cellinfect_animation/infect_a11.png b/game/dev/images/cellinfect_animation/infect_a11.png deleted file mode 100644 index 542e505..0000000 Binary files a/game/dev/images/cellinfect_animation/infect_a11.png and /dev/null differ diff --git a/game/dev/images/cellinfect_animation/infect_a12.png b/game/dev/images/cellinfect_animation/infect_a12.png deleted file mode 100644 index 1bcc3ab..0000000 Binary files a/game/dev/images/cellinfect_animation/infect_a12.png and /dev/null differ diff --git a/game/dev/images/halogo.jpg b/game/dev/images/halogo.jpg deleted file mode 100644 index e6e43c0..0000000 Binary files a/game/dev/images/halogo.jpg and /dev/null differ diff --git a/game/dev/images/holemacrophage_animation/hmacrophage_a01.png b/game/dev/images/holemacrophage_animation/hmacrophage_a01.png deleted file mode 100644 index 739eea8..0000000 Binary files a/game/dev/images/holemacrophage_animation/hmacrophage_a01.png and /dev/null differ diff --git a/game/dev/images/holemacrophage_animation/hmacrophage_a02.png b/game/dev/images/holemacrophage_animation/hmacrophage_a02.png deleted file mode 100644 index 189ed3d..0000000 Binary files a/game/dev/images/holemacrophage_animation/hmacrophage_a02.png and /dev/null differ diff --git a/game/dev/images/holemacrophage_animation/hmacrophage_a03.png b/game/dev/images/holemacrophage_animation/hmacrophage_a03.png deleted file mode 100644 index b9011c3..0000000 Binary files a/game/dev/images/holemacrophage_animation/hmacrophage_a03.png and /dev/null differ diff --git a/game/dev/images/holemacrophage_animation/hmacrophage_a04.png b/game/dev/images/holemacrophage_animation/hmacrophage_a04.png deleted file mode 100644 index 315daee..0000000 Binary files a/game/dev/images/holemacrophage_animation/hmacrophage_a04.png and /dev/null differ diff --git a/game/dev/images/holemacrophage_animation/hmacrophage_a05.png b/game/dev/images/holemacrophage_animation/hmacrophage_a05.png deleted file mode 100644 index 6510538..0000000 Binary files a/game/dev/images/holemacrophage_animation/hmacrophage_a05.png and /dev/null differ diff --git a/game/dev/images/holemacrophage_animation/hmacrophage_a06.png b/game/dev/images/holemacrophage_animation/hmacrophage_a06.png deleted file mode 100644 index e4387c2..0000000 Binary files a/game/dev/images/holemacrophage_animation/hmacrophage_a06.png and /dev/null differ diff --git a/game/dev/images/holemacrophage_animation/hmacrophage_a07.png b/game/dev/images/holemacrophage_animation/hmacrophage_a07.png deleted file mode 100644 index 4aefeb5..0000000 Binary files a/game/dev/images/holemacrophage_animation/hmacrophage_a07.png and /dev/null differ diff --git a/game/dev/images/holemacrophage_animation/hmacrophage_a08.png b/game/dev/images/holemacrophage_animation/hmacrophage_a08.png deleted file mode 100644 index f1c0e9c..0000000 Binary files a/game/dev/images/holemacrophage_animation/hmacrophage_a08.png and /dev/null differ diff --git a/game/dev/images/holemacrophage_animation/hmacrophage_a09.png b/game/dev/images/holemacrophage_animation/hmacrophage_a09.png deleted file mode 100644 index aad7670..0000000 Binary files a/game/dev/images/holemacrophage_animation/hmacrophage_a09.png and /dev/null differ diff --git a/game/dev/images/holemacrophage_animation/hmacrophage_a10.png b/game/dev/images/holemacrophage_animation/hmacrophage_a10.png deleted file mode 100644 index 84499ec..0000000 Binary files a/game/dev/images/holemacrophage_animation/hmacrophage_a10.png and /dev/null differ diff --git a/game/dev/images/holemacrophage_animation/hmacrophage_a11.png b/game/dev/images/holemacrophage_animation/hmacrophage_a11.png deleted file mode 100644 index cf9c8e4..0000000 Binary files a/game/dev/images/holemacrophage_animation/hmacrophage_a11.png and /dev/null differ diff --git a/game/dev/images/holemacrophage_animation/hmacrophage_a12.png b/game/dev/images/holemacrophage_animation/hmacrophage_a12.png deleted file mode 100644 index d7d1da2..0000000 Binary files a/game/dev/images/holemacrophage_animation/hmacrophage_a12.png and /dev/null differ diff --git a/game/dev/images/holemacrophage_animation/hmacrophage_a13.png b/game/dev/images/holemacrophage_animation/hmacrophage_a13.png deleted file mode 100644 index 7c7161b..0000000 Binary files a/game/dev/images/holemacrophage_animation/hmacrophage_a13.png and /dev/null differ diff --git a/game/dev/images/holemacrophage_animation/hmacrophage_a14.png b/game/dev/images/holemacrophage_animation/hmacrophage_a14.png deleted file mode 100644 index 3d54eba..0000000 Binary files a/game/dev/images/holemacrophage_animation/hmacrophage_a14.png and /dev/null differ diff --git a/game/dev/images/infectable_cell/infectable_cell_2n.png b/game/dev/images/infectable_cell/infectable_cell_2n.png deleted file mode 100644 index ac98c48..0000000 Binary files a/game/dev/images/infectable_cell/infectable_cell_2n.png and /dev/null differ diff --git a/game/dev/images/infectable_cell/infectable_cell_3n.png b/game/dev/images/infectable_cell/infectable_cell_3n.png deleted file mode 100644 index 5cb97e8..0000000 Binary files a/game/dev/images/infectable_cell/infectable_cell_3n.png and /dev/null differ diff --git a/game/dev/images/infectable_cell/infectable_cell_4n.png b/game/dev/images/infectable_cell/infectable_cell_4n.png deleted file mode 100644 index 8027852..0000000 Binary files a/game/dev/images/infectable_cell/infectable_cell_4n.png and /dev/null differ diff --git a/game/dev/images/infectable_cell/infectable_cell_5n.png b/game/dev/images/infectable_cell/infectable_cell_5n.png deleted file mode 100644 index 6503050..0000000 Binary files a/game/dev/images/infectable_cell/infectable_cell_5n.png and /dev/null differ diff --git a/game/dev/images/infectable_cell/infectable_cell_6n.png b/game/dev/images/infectable_cell/infectable_cell_6n.png deleted file mode 100644 index 41e450e..0000000 Binary files a/game/dev/images/infectable_cell/infectable_cell_6n.png and /dev/null differ diff --git a/game/dev/images/infectable_cell/infectable_cell_7n.png b/game/dev/images/infectable_cell/infectable_cell_7n.png deleted file mode 100644 index f9cbc94..0000000 Binary files a/game/dev/images/infectable_cell/infectable_cell_7n.png and /dev/null differ diff --git a/game/dev/images/listcell.png b/game/dev/images/listcell.png deleted file mode 100644 index 27af90c..0000000 Binary files a/game/dev/images/listcell.png and /dev/null differ diff --git a/game/dev/images/logo/logo128.png b/game/dev/images/logo/logo128.png deleted file mode 100644 index d370aed..0000000 Binary files a/game/dev/images/logo/logo128.png and /dev/null differ diff --git a/game/dev/images/logo/logo32.png b/game/dev/images/logo/logo32.png deleted file mode 100644 index b076f80..0000000 Binary files a/game/dev/images/logo/logo32.png and /dev/null differ diff --git a/game/dev/images/logo/logo64.png b/game/dev/images/logo/logo64.png deleted file mode 100644 index ca134e5..0000000 Binary files a/game/dev/images/logo/logo64.png and /dev/null differ diff --git a/game/dev/images/logo/vlogolarge.png b/game/dev/images/logo/vlogolarge.png deleted file mode 100644 index 274bab9..0000000 Binary files a/game/dev/images/logo/vlogolarge.png and /dev/null differ diff --git a/game/dev/images/logo/vlogolargetext.png b/game/dev/images/logo/vlogolargetext.png deleted file mode 100644 index 6004b8e..0000000 Binary files a/game/dev/images/logo/vlogolargetext.png and /dev/null differ diff --git a/game/dev/images/macrophage_1.png b/game/dev/images/macrophage_1.png deleted file mode 100644 index b03e4cd..0000000 Binary files a/game/dev/images/macrophage_1.png and /dev/null differ diff --git a/game/dev/images/macrophage_1_active.png b/game/dev/images/macrophage_1_active.png deleted file mode 100644 index 4b858d4..0000000 Binary files a/game/dev/images/macrophage_1_active.png and /dev/null differ diff --git a/game/dev/images/macrophage_animation/macrophage_a01.png b/game/dev/images/macrophage_animation/macrophage_a01.png deleted file mode 100644 index 34e9035..0000000 Binary files a/game/dev/images/macrophage_animation/macrophage_a01.png and /dev/null differ diff --git a/game/dev/images/macrophage_animation/macrophage_a02.png b/game/dev/images/macrophage_animation/macrophage_a02.png deleted file mode 100644 index 0cb1089..0000000 Binary files a/game/dev/images/macrophage_animation/macrophage_a02.png and /dev/null differ diff --git a/game/dev/images/macrophage_animation/macrophage_a03.png b/game/dev/images/macrophage_animation/macrophage_a03.png deleted file mode 100644 index 12f9af3..0000000 Binary files a/game/dev/images/macrophage_animation/macrophage_a03.png and /dev/null differ diff --git a/game/dev/images/macrophage_animation/macrophage_a04.png b/game/dev/images/macrophage_animation/macrophage_a04.png deleted file mode 100644 index 3ccaca9..0000000 Binary files a/game/dev/images/macrophage_animation/macrophage_a04.png and /dev/null differ diff --git a/game/dev/images/macrophage_animation/macrophage_a05.png b/game/dev/images/macrophage_animation/macrophage_a05.png deleted file mode 100644 index b5e97c1..0000000 Binary files a/game/dev/images/macrophage_animation/macrophage_a05.png and /dev/null differ diff --git a/game/dev/images/macrophage_animation/macrophage_a06.png b/game/dev/images/macrophage_animation/macrophage_a06.png deleted file mode 100644 index e8a1b97..0000000 Binary files a/game/dev/images/macrophage_animation/macrophage_a06.png and /dev/null differ diff --git a/game/dev/images/macrophage_animation/macrophage_a07.png b/game/dev/images/macrophage_animation/macrophage_a07.png deleted file mode 100644 index 13ab22f..0000000 Binary files a/game/dev/images/macrophage_animation/macrophage_a07.png and /dev/null differ diff --git a/game/dev/images/macrophage_animation/macrophage_a08.png b/game/dev/images/macrophage_animation/macrophage_a08.png deleted file mode 100644 index 7ac4102..0000000 Binary files a/game/dev/images/macrophage_animation/macrophage_a08.png and /dev/null differ diff --git a/game/dev/images/macrophage_animation/macrophage_a09.png b/game/dev/images/macrophage_animation/macrophage_a09.png deleted file mode 100644 index 32f7c20..0000000 Binary files a/game/dev/images/macrophage_animation/macrophage_a09.png and /dev/null differ diff --git a/game/dev/images/macrophage_animation/macrophage_a10.png b/game/dev/images/macrophage_animation/macrophage_a10.png deleted file mode 100644 index 4f64246..0000000 Binary files a/game/dev/images/macrophage_animation/macrophage_a10.png and /dev/null differ diff --git a/game/dev/images/macrophage_animation/macrophage_a11.png b/game/dev/images/macrophage_animation/macrophage_a11.png deleted file mode 100644 index bb1870f..0000000 Binary files a/game/dev/images/macrophage_animation/macrophage_a11.png and /dev/null differ diff --git a/game/dev/images/macrophage_animation/macrophage_a12.png b/game/dev/images/macrophage_animation/macrophage_a12.png deleted file mode 100644 index 506e48b..0000000 Binary files a/game/dev/images/macrophage_animation/macrophage_a12.png and /dev/null differ diff --git a/game/dev/images/macrophage_animation/macrophage_a13.png b/game/dev/images/macrophage_animation/macrophage_a13.png deleted file mode 100644 index 7b14bd9..0000000 Binary files a/game/dev/images/macrophage_animation/macrophage_a13.png and /dev/null differ diff --git a/game/dev/images/macrophage_animation/macrophage_a14.png b/game/dev/images/macrophage_animation/macrophage_a14.png deleted file mode 100644 index f78597b..0000000 Binary files a/game/dev/images/macrophage_animation/macrophage_a14.png and /dev/null differ diff --git a/game/dev/images/noninfectable_cell/noninfectable_cell_1n.png b/game/dev/images/noninfectable_cell/noninfectable_cell_1n.png deleted file mode 100644 index 9768618..0000000 Binary files a/game/dev/images/noninfectable_cell/noninfectable_cell_1n.png and /dev/null differ diff --git a/game/dev/images/noninfectable_cell/noninfectable_cell_2n.png b/game/dev/images/noninfectable_cell/noninfectable_cell_2n.png deleted file mode 100644 index c6b582c..0000000 Binary files a/game/dev/images/noninfectable_cell/noninfectable_cell_2n.png and /dev/null differ diff --git a/game/dev/images/noninfectable_cell/noninfectable_cell_3n.png b/game/dev/images/noninfectable_cell/noninfectable_cell_3n.png deleted file mode 100644 index a387eb0..0000000 Binary files a/game/dev/images/noninfectable_cell/noninfectable_cell_3n.png and /dev/null differ diff --git a/game/dev/images/noninfectable_cell/noninfectable_cell_4n.png b/game/dev/images/noninfectable_cell/noninfectable_cell_4n.png deleted file mode 100644 index 1bf02a8..0000000 Binary files a/game/dev/images/noninfectable_cell/noninfectable_cell_4n.png and /dev/null differ diff --git a/game/dev/images/noninfectable_cell/noninfectable_cell_5n.png b/game/dev/images/noninfectable_cell/noninfectable_cell_5n.png deleted file mode 100644 index 841dd45..0000000 Binary files a/game/dev/images/noninfectable_cell/noninfectable_cell_5n.png and /dev/null differ diff --git a/game/dev/images/old/.DS_Store b/game/dev/images/old/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/dev/images/old/.DS_Store and /dev/null differ diff --git a/game/dev/images/old/b/.DS_Store b/game/dev/images/old/b/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/dev/images/old/b/.DS_Store and /dev/null differ diff --git a/game/dev/images/old/b/macrophage_a1.gif b/game/dev/images/old/b/macrophage_a1.gif deleted file mode 100755 index ea1ba06..0000000 Binary files a/game/dev/images/old/b/macrophage_a1.gif and /dev/null differ diff --git a/game/dev/images/old/background/background_bcells1.png b/game/dev/images/old/background/background_bcells1.png deleted file mode 100755 index f809f50..0000000 Binary files a/game/dev/images/old/background/background_bcells1.png and /dev/null differ diff --git a/game/dev/images/old/background/background_bcells2.png b/game/dev/images/old/background/background_bcells2.png deleted file mode 100755 index d99ee15..0000000 Binary files a/game/dev/images/old/background/background_bcells2.png and /dev/null differ diff --git a/game/dev/images/old/background/background_bcells3.png b/game/dev/images/old/background/background_bcells3.png deleted file mode 100755 index 099a0f7..0000000 Binary files a/game/dev/images/old/background/background_bcells3.png and /dev/null differ diff --git a/game/dev/images/old/background/background_bcells4.png b/game/dev/images/old/background/background_bcells4.png deleted file mode 100755 index 9ed69c7..0000000 Binary files a/game/dev/images/old/background/background_bcells4.png and /dev/null differ diff --git a/game/dev/images/old/background/background_bottomside.png b/game/dev/images/old/background/background_bottomside.png deleted file mode 100755 index 90bda8d..0000000 Binary files a/game/dev/images/old/background/background_bottomside.png and /dev/null differ diff --git a/game/dev/images/old/background/background_dstreaks1.png b/game/dev/images/old/background/background_dstreaks1.png deleted file mode 100755 index 9f553e6..0000000 Binary files a/game/dev/images/old/background/background_dstreaks1.png and /dev/null differ diff --git a/game/dev/images/old/background/background_dstreaks2.png b/game/dev/images/old/background/background_dstreaks2.png deleted file mode 100755 index 258b8c6..0000000 Binary files a/game/dev/images/old/background/background_dstreaks2.png and /dev/null differ diff --git a/game/dev/images/old/background/background_dstreaks3.png b/game/dev/images/old/background/background_dstreaks3.png deleted file mode 100755 index fcbcbb7..0000000 Binary files a/game/dev/images/old/background/background_dstreaks3.png and /dev/null differ diff --git a/game/dev/images/old/background/background_lstreaks1.png b/game/dev/images/old/background/background_lstreaks1.png deleted file mode 100755 index 3f313ce..0000000 Binary files a/game/dev/images/old/background/background_lstreaks1.png and /dev/null differ diff --git a/game/dev/images/old/background/background_lstreaks2.png b/game/dev/images/old/background/background_lstreaks2.png deleted file mode 100755 index 6d9e38e..0000000 Binary files a/game/dev/images/old/background/background_lstreaks2.png and /dev/null differ diff --git a/game/dev/images/old/background/background_topside.png b/game/dev/images/old/background/background_topside.png deleted file mode 100755 index 70573ac..0000000 Binary files a/game/dev/images/old/background/background_topside.png and /dev/null differ diff --git a/game/dev/images/old/bcell1.png b/game/dev/images/old/bcell1.png deleted file mode 100644 index f383cdd..0000000 Binary files a/game/dev/images/old/bcell1.png and /dev/null differ diff --git a/game/dev/images/old/cellwall1.png b/game/dev/images/old/cellwall1.png deleted file mode 100644 index ac5e3c1..0000000 Binary files a/game/dev/images/old/cellwall1.png and /dev/null differ diff --git a/game/dev/images/old/cellwall1draft.svg b/game/dev/images/old/cellwall1draft.svg deleted file mode 100644 index 0c2ae5a..0000000 --- a/game/dev/images/old/cellwall1draft.svg +++ /dev/null @@ -1,1120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/dev/images/old/infectable1.png b/game/dev/images/old/infectable1.png deleted file mode 100644 index 29f9eb1..0000000 Binary files a/game/dev/images/old/infectable1.png and /dev/null differ diff --git a/game/dev/images/old/infectable2.png b/game/dev/images/old/infectable2.png deleted file mode 100644 index 40d0d7d..0000000 Binary files a/game/dev/images/old/infectable2.png and /dev/null differ diff --git a/game/dev/images/old/infectable3.png b/game/dev/images/old/infectable3.png deleted file mode 100644 index 69567be..0000000 Binary files a/game/dev/images/old/infectable3.png and /dev/null differ diff --git a/game/dev/images/old/infectable_cell/infectable_cell_2n.png b/game/dev/images/old/infectable_cell/infectable_cell_2n.png deleted file mode 100755 index 29f9eb1..0000000 Binary files a/game/dev/images/old/infectable_cell/infectable_cell_2n.png and /dev/null differ diff --git a/game/dev/images/old/infectable_cell/infectable_cell_3n.png b/game/dev/images/old/infectable_cell/infectable_cell_3n.png deleted file mode 100755 index 40d0d7d..0000000 Binary files a/game/dev/images/old/infectable_cell/infectable_cell_3n.png and /dev/null differ diff --git a/game/dev/images/old/infectable_cell/infectable_cell_4n.png b/game/dev/images/old/infectable_cell/infectable_cell_4n.png deleted file mode 100755 index 69567be..0000000 Binary files a/game/dev/images/old/infectable_cell/infectable_cell_4n.png and /dev/null differ diff --git a/game/dev/images/old/infectable_cell/infectable_cell_5n.png b/game/dev/images/old/infectable_cell/infectable_cell_5n.png deleted file mode 100755 index 620adbb..0000000 Binary files a/game/dev/images/old/infectable_cell/infectable_cell_5n.png and /dev/null differ diff --git a/game/dev/images/old/infectable_cell/infectable_cell_6n.png b/game/dev/images/old/infectable_cell/infectable_cell_6n.png deleted file mode 100755 index aa65877..0000000 Binary files a/game/dev/images/old/infectable_cell/infectable_cell_6n.png and /dev/null differ diff --git a/game/dev/images/old/infectable_cell/infectable_cell_7n.png b/game/dev/images/old/infectable_cell/infectable_cell_7n.png deleted file mode 100755 index 2951a73..0000000 Binary files a/game/dev/images/old/infectable_cell/infectable_cell_7n.png and /dev/null differ diff --git a/game/dev/images/old/macrophage1.png b/game/dev/images/old/macrophage1.png deleted file mode 100644 index 4dc0f6b..0000000 Binary files a/game/dev/images/old/macrophage1.png and /dev/null differ diff --git a/game/dev/images/old/macrophage_active.png b/game/dev/images/old/macrophage_active.png deleted file mode 100644 index ed7d1ee..0000000 Binary files a/game/dev/images/old/macrophage_active.png and /dev/null differ diff --git a/game/dev/images/old/new/.DS_Store b/game/dev/images/old/new/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/dev/images/old/new/.DS_Store and /dev/null differ diff --git a/game/dev/images/old/new/infectable1.png b/game/dev/images/old/new/infectable1.png deleted file mode 100755 index 298f24c..0000000 Binary files a/game/dev/images/old/new/infectable1.png and /dev/null differ diff --git a/game/dev/images/old/new/infectable2.png b/game/dev/images/old/new/infectable2.png deleted file mode 100755 index 01100dd..0000000 Binary files a/game/dev/images/old/new/infectable2.png and /dev/null differ diff --git a/game/dev/images/old/new/infectable3.png b/game/dev/images/old/new/infectable3.png deleted file mode 100755 index 9bc043f..0000000 Binary files a/game/dev/images/old/new/infectable3.png and /dev/null differ diff --git a/game/dev/images/old/new/noninfectable.png b/game/dev/images/old/new/noninfectable.png deleted file mode 100755 index bbe312b..0000000 Binary files a/game/dev/images/old/new/noninfectable.png and /dev/null differ diff --git a/game/dev/images/old/noninfectable1.png b/game/dev/images/old/noninfectable1.png deleted file mode 100644 index dde08a7..0000000 Binary files a/game/dev/images/old/noninfectable1.png and /dev/null differ diff --git a/game/dev/images/old/noninfectable_cell/noninfectable_cell_2n.png b/game/dev/images/old/noninfectable_cell/noninfectable_cell_2n.png deleted file mode 100755 index e586a95..0000000 Binary files a/game/dev/images/old/noninfectable_cell/noninfectable_cell_2n.png and /dev/null differ diff --git a/game/dev/images/old/noninfectable_cell/noninfectable_cell_3.png b/game/dev/images/old/noninfectable_cell/noninfectable_cell_3.png deleted file mode 100755 index a04f17c..0000000 Binary files a/game/dev/images/old/noninfectable_cell/noninfectable_cell_3.png and /dev/null differ diff --git a/game/dev/images/old/noninfectable_cell/noninfectable_cell_4.png b/game/dev/images/old/noninfectable_cell/noninfectable_cell_4.png deleted file mode 100755 index 5114e1d..0000000 Binary files a/game/dev/images/old/noninfectable_cell/noninfectable_cell_4.png and /dev/null differ diff --git a/game/dev/images/old/noninfectable_cell/noninfectable_cell_5.png b/game/dev/images/old/noninfectable_cell/noninfectable_cell_5.png deleted file mode 100755 index 86a67e3..0000000 Binary files a/game/dev/images/old/noninfectable_cell/noninfectable_cell_5.png and /dev/null differ diff --git a/game/dev/images/old/particle.png b/game/dev/images/old/particle.png deleted file mode 100644 index e2c8a15..0000000 Binary files a/game/dev/images/old/particle.png and /dev/null differ diff --git a/game/dev/images/old/screens/.DS_Store b/game/dev/images/old/screens/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/dev/images/old/screens/.DS_Store and /dev/null differ diff --git a/game/dev/images/old/screens/bullet_listcell.png b/game/dev/images/old/screens/bullet_listcell.png deleted file mode 100755 index 7525958..0000000 Binary files a/game/dev/images/old/screens/bullet_listcell.png and /dev/null differ diff --git a/game/dev/images/old/screens/header.png b/game/dev/images/old/screens/header.png deleted file mode 100755 index 8b83ea6..0000000 Binary files a/game/dev/images/old/screens/header.png and /dev/null differ diff --git a/game/dev/images/old/screens/listcell.png b/game/dev/images/old/screens/listcell.png deleted file mode 100755 index ef2eba2..0000000 Binary files a/game/dev/images/old/screens/listcell.png and /dev/null differ diff --git a/game/dev/images/old/screens/loading.png b/game/dev/images/old/screens/loading.png deleted file mode 100755 index a20886e..0000000 Binary files a/game/dev/images/old/screens/loading.png and /dev/null differ diff --git a/game/dev/images/old/screens/loadingsplash.png b/game/dev/images/old/screens/loadingsplash.png deleted file mode 100755 index 9c3d6bc..0000000 Binary files a/game/dev/images/old/screens/loadingsplash.png and /dev/null differ diff --git a/game/dev/images/old/screens/mainscreenbase.png b/game/dev/images/old/screens/mainscreenbase.png deleted file mode 100755 index 2287e53..0000000 Binary files a/game/dev/images/old/screens/mainscreenbase.png and /dev/null differ diff --git a/game/dev/images/old/screens/newgame_listcell.png b/game/dev/images/old/screens/newgame_listcell.png deleted file mode 100755 index 3360fb7..0000000 Binary files a/game/dev/images/old/screens/newgame_listcell.png and /dev/null differ diff --git a/game/dev/images/old/screens/settings.png b/game/dev/images/old/screens/settings.png deleted file mode 100755 index 3041eea..0000000 Binary files a/game/dev/images/old/screens/settings.png and /dev/null differ diff --git a/game/dev/images/old/screens/settingssplash.png b/game/dev/images/old/screens/settingssplash.png deleted file mode 100755 index ac1891a..0000000 Binary files a/game/dev/images/old/screens/settingssplash.png and /dev/null differ diff --git a/game/dev/images/old/tcells/tcell1.png b/game/dev/images/old/tcells/tcell1.png deleted file mode 100755 index a49799f..0000000 Binary files a/game/dev/images/old/tcells/tcell1.png and /dev/null differ diff --git a/game/dev/images/old/tcells/tcell2.png b/game/dev/images/old/tcells/tcell2.png deleted file mode 100755 index 24b6ac2..0000000 Binary files a/game/dev/images/old/tcells/tcell2.png and /dev/null differ diff --git a/game/dev/images/old/tcells/tcell3.png b/game/dev/images/old/tcells/tcell3.png deleted file mode 100755 index 98dbc44..0000000 Binary files a/game/dev/images/old/tcells/tcell3.png and /dev/null differ diff --git a/game/dev/images/old/tcells/tcell4.png b/game/dev/images/old/tcells/tcell4.png deleted file mode 100755 index 891c32b..0000000 Binary files a/game/dev/images/old/tcells/tcell4.png and /dev/null differ diff --git a/game/dev/images/old/virus1.png b/game/dev/images/old/virus1.png deleted file mode 100644 index d9db175..0000000 Binary files a/game/dev/images/old/virus1.png and /dev/null differ diff --git a/game/dev/images/old/virusfinal.svg b/game/dev/images/old/virusfinal.svg deleted file mode 100644 index 3b61a61..0000000 --- a/game/dev/images/old/virusfinal.svg +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/dev/images/old/wall_segments/cellwall1.png b/game/dev/images/old/wall_segments/cellwall1.png deleted file mode 100755 index 0d71d6e..0000000 Binary files a/game/dev/images/old/wall_segments/cellwall1.png and /dev/null differ diff --git a/game/dev/images/old/wall_segments/cellwall2.png b/game/dev/images/old/wall_segments/cellwall2.png deleted file mode 100755 index f06bf92..0000000 Binary files a/game/dev/images/old/wall_segments/cellwall2.png and /dev/null differ diff --git a/game/dev/images/old/wall_segments/cellwall3.png b/game/dev/images/old/wall_segments/cellwall3.png deleted file mode 100755 index 2b7f3c7..0000000 Binary files a/game/dev/images/old/wall_segments/cellwall3.png and /dev/null differ diff --git a/game/dev/images/old/wall_segments/cellwall4.png b/game/dev/images/old/wall_segments/cellwall4.png deleted file mode 100755 index d33f471..0000000 Binary files a/game/dev/images/old/wall_segments/cellwall4.png and /dev/null differ diff --git a/game/dev/images/old/wall_segments/cellwall5.png b/game/dev/images/old/wall_segments/cellwall5.png deleted file mode 100755 index c0bbabd..0000000 Binary files a/game/dev/images/old/wall_segments/cellwall5.png and /dev/null differ diff --git a/game/dev/images/old/wall_segments/cellwall6.png b/game/dev/images/old/wall_segments/cellwall6.png deleted file mode 100755 index 203950f..0000000 Binary files a/game/dev/images/old/wall_segments/cellwall6.png and /dev/null differ diff --git a/game/dev/images/old/wall_segments/cellwall7.png b/game/dev/images/old/wall_segments/cellwall7.png deleted file mode 100755 index 262a9b3..0000000 Binary files a/game/dev/images/old/wall_segments/cellwall7.png and /dev/null differ diff --git a/game/dev/images/old/wallcell1.png b/game/dev/images/old/wallcell1.png deleted file mode 100644 index 30c4535..0000000 Binary files a/game/dev/images/old/wallcell1.png and /dev/null differ diff --git a/game/dev/images/screens/creditsscreen.png b/game/dev/images/screens/creditsscreen.png deleted file mode 100644 index 40ff9db..0000000 Binary files a/game/dev/images/screens/creditsscreen.png and /dev/null differ diff --git a/game/dev/images/screens/helpsplash.png b/game/dev/images/screens/helpsplash.png deleted file mode 100644 index f92663b..0000000 Binary files a/game/dev/images/screens/helpsplash.png and /dev/null differ diff --git a/game/dev/images/screens/loadingsplash.png b/game/dev/images/screens/loadingsplash.png deleted file mode 100644 index 7825408..0000000 Binary files a/game/dev/images/screens/loadingsplash.png and /dev/null differ diff --git a/game/dev/images/screens/mainscreenbase.png b/game/dev/images/screens/mainscreenbase.png deleted file mode 100644 index dd63a98..0000000 Binary files a/game/dev/images/screens/mainscreenbase.png and /dev/null differ diff --git a/game/dev/images/screens/settingssplash.png b/game/dev/images/screens/settingssplash.png deleted file mode 100644 index 7cd9b4e..0000000 Binary files a/game/dev/images/screens/settingssplash.png and /dev/null differ diff --git a/game/dev/images/t_animation/tcell_a01.png b/game/dev/images/t_animation/tcell_a01.png deleted file mode 100644 index 22b4364..0000000 Binary files a/game/dev/images/t_animation/tcell_a01.png and /dev/null differ diff --git a/game/dev/images/t_animation/tcell_a02.png b/game/dev/images/t_animation/tcell_a02.png deleted file mode 100644 index 6743fbc..0000000 Binary files a/game/dev/images/t_animation/tcell_a02.png and /dev/null differ diff --git a/game/dev/images/t_animation/tcell_a03.png b/game/dev/images/t_animation/tcell_a03.png deleted file mode 100644 index d6b30c9..0000000 Binary files a/game/dev/images/t_animation/tcell_a03.png and /dev/null differ diff --git a/game/dev/images/t_animation/tcell_a04.png b/game/dev/images/t_animation/tcell_a04.png deleted file mode 100644 index 17e9836..0000000 Binary files a/game/dev/images/t_animation/tcell_a04.png and /dev/null differ diff --git a/game/dev/images/t_animation/tcell_a05.png b/game/dev/images/t_animation/tcell_a05.png deleted file mode 100644 index a909794..0000000 Binary files a/game/dev/images/t_animation/tcell_a05.png and /dev/null differ diff --git a/game/dev/images/t_animation/tcell_a06.png b/game/dev/images/t_animation/tcell_a06.png deleted file mode 100644 index af2bf7f..0000000 Binary files a/game/dev/images/t_animation/tcell_a06.png and /dev/null differ diff --git a/game/dev/images/t_animation/tcell_a07.png b/game/dev/images/t_animation/tcell_a07.png deleted file mode 100644 index e6a1f7c..0000000 Binary files a/game/dev/images/t_animation/tcell_a07.png and /dev/null differ diff --git a/game/dev/images/tcell_2.png b/game/dev/images/tcell_2.png deleted file mode 100644 index bcdfd37..0000000 Binary files a/game/dev/images/tcell_2.png and /dev/null differ diff --git a/game/dev/images/tinyvirus_shadowtrans.png b/game/dev/images/tinyvirus_shadowtrans.png deleted file mode 100644 index 06f8178..0000000 Binary files a/game/dev/images/tinyvirus_shadowtrans.png and /dev/null differ diff --git a/game/dev/images/tinyvirus_trans.png b/game/dev/images/tinyvirus_trans.png deleted file mode 100644 index ffad22b..0000000 Binary files a/game/dev/images/tinyvirus_trans.png and /dev/null differ diff --git a/game/dev/images/wall_segments/cellwall1.png b/game/dev/images/wall_segments/cellwall1.png deleted file mode 100644 index 0e4aa10..0000000 Binary files a/game/dev/images/wall_segments/cellwall1.png and /dev/null differ diff --git a/game/dev/images/wall_segments/cellwall2.png b/game/dev/images/wall_segments/cellwall2.png deleted file mode 100644 index 8b07659..0000000 Binary files a/game/dev/images/wall_segments/cellwall2.png and /dev/null differ diff --git a/game/dev/images/wall_segments/cellwall3.png b/game/dev/images/wall_segments/cellwall3.png deleted file mode 100644 index d91f9ac..0000000 Binary files a/game/dev/images/wall_segments/cellwall3.png and /dev/null differ diff --git a/game/dev/images/wall_segments/cellwall4.png b/game/dev/images/wall_segments/cellwall4.png deleted file mode 100644 index aaf96ad..0000000 Binary files a/game/dev/images/wall_segments/cellwall4.png and /dev/null differ diff --git a/game/dev/images/wall_segments/cellwall5.png b/game/dev/images/wall_segments/cellwall5.png deleted file mode 100644 index edb9fa1..0000000 Binary files a/game/dev/images/wall_segments/cellwall5.png and /dev/null differ diff --git a/game/dev/images/wall_segments/cellwall6.png b/game/dev/images/wall_segments/cellwall6.png deleted file mode 100644 index 175ed0f..0000000 Binary files a/game/dev/images/wall_segments/cellwall6.png and /dev/null differ diff --git a/game/dev/images/wall_segments/cellwall7.png b/game/dev/images/wall_segments/cellwall7.png deleted file mode 100644 index e1d20e5..0000000 Binary files a/game/dev/images/wall_segments/cellwall7.png and /dev/null differ diff --git a/game/dev/images/wallcell_1.png b/game/dev/images/wallcell_1.png deleted file mode 100644 index 9f5f197..0000000 Binary files a/game/dev/images/wallcell_1.png and /dev/null differ diff --git a/game/dev/in_game_state.js b/game/dev/in_game_state.js deleted file mode 100644 index a3e5604..0000000 --- a/game/dev/in_game_state.js +++ /dev/null @@ -1,1937 +0,0 @@ -// *** game *** -// NOTE: get_type() returns "game" not "in_game" - -// defined up here cuz instructions need them -// and a game might not be init'd before reading instr -g_speed_factor = 1; // multiply all speed constants in the game by this, for easy mode - -// Global Variable so cell arrows can draw dots -GLOBAL_is_easy = false; - -// flag for whether the tutorial has been played through -// if false, easy mode will include the tutorial -g_tut_done = false; - -// game_type is: -// 0 - easy -// 1 - tutorial -// 2 - hard -var in_game_state = function (p, previous_state, game_type) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - - // whether or not we are testing - // use it wherever - var testing = false; - obj.testing = function() { return testing; }; - - // --- constants --- - //var num_of_render_levels = 5; Now auto-calculating in init so don't have to change - - // --- private variables --- - - - var GOOD_NOTIFICATION_COLOR = p.color(0, 255, 0); - var BAD_NOTIFICATION_COLOR = p.color(255, 0, 0); - - var prev_state = previous_state; - // distance is the x-coordinate of the total distance traveled - // increments with scroll - var distance = 0; - //var score = 0; - var active_cell = null; - var last_active_cell = null; - // multiply each object's scroll amount by this - // factor, which increases throughout the game - var scroll_factor = 1; - if (game_type < 2) { - g_speed_factor = 0.75; - } - scroll_factor *= g_speed_factor; - - var game_objects = []; - var paused = false; - - var status_bar_height = 40; - var status_height = 20; - - var score = num_status_obj(p, { - pos : new p.PVector(p.width - 100, status_height), - text : "Score:", - num : 0, - format : add_commas - }); - var mult = num_status_obj(p, { - pos : new p.PVector(p.width - 200, status_height), - text : "Multiplier:", - num : 1, - format : function(num) { - return num+"x"; - } - }); - var time_elapsed = 0; // Time elapsed in seconds - var set_time = false; //bool that says if we've started counting time - var time_status = num_status_obj(p, { - pos : new p.PVector(85, status_height), - text : "Time:", - num : time_elapsed, - // formats time to mins:secs - format : function(num) { - var secs = num%60; - if (secs < 10) { secs = "0" + secs; } - return p.floor(num/60) + ":" + secs; - } - }); - var mutation = mutation_obj(p, { status_height : status_height }); - - var pause_button = button(p, { - state: function() { - do_pause(); - console.log("pause button"); - return pause_state(p, obj); - }, - rect: { - pos: new p.PVector(25, status_height), - width: 25, height: 25, - } - }); - // draw two vertical rects - pause_button.draw = function() { - p.pushMatrix(); - // get the rect spec back - var r = pause_button.get_rect(); - var w = r.width; - var h = r.height; - p.translate(r.pos.x-w/2, r.pos.y-h/2); - p.strokeWeight(2); - p.stroke(255); - p.noFill(); - p.ellipse(w/2, h/2, w, h); - p.noStroke(); - p.fill(255); - p.rectMode(p.CORNER); - p.rect(w/4, h/5, w/5, 3*h/5); - p.rect(w-w/4-w/5, h/5, w/5, 3*h/5); - p.popMatrix(); - }; - - // Used to draw all of the statuses (must implement draw) - var all_status_objs = [score, mult, time_status, mutation]; - var all_buttons = [pause_button]; - - - var is_tutorial = false; - if (game_type === 1 - // if the tutorial hasn't been done, do on easy mode - || (game_type === 0 && !g_tut_done) ){ - is_tutorial = true; - } - if (game_type < 2) { - GLOBAL_is_easy = true; - } - - - // the popup to draw at a given time - // null if there is none - var tut_window = null; - // flag for unpausing - // when false mouse clicks wont fire - var ok_to_fire = true; - // Call tut_manager.popup(type) when you want to signal a tutorial message - // All the types are in tut_flags - var tut_manager = (function() { - - // object to store all the msgs - var tut_msgs = { - spacebar: "Press SPACEBAR or CLICK the mouse to shoot virions out of an infected cell in the direction of the arrow. The dotted lines will help you aim.", - arrows: "Use the LEFT and RIGHT arrow keys to switch between infected cells.", - macrophage: "Watch out for macrophages! They will kill your virion and alert a B cell.", - antibodies: "Oh no! The B cell is producing antibodies! If an antibody attaches to an infected cell, the cell will be marked for destruction by a granulocyte.", - killer: "A granulocyte just destroyed one of your infected cells marked with an antibody and all the virions inside it! Your virus won't be safe from the granulocyte until it mutates, creating a new strain.", - mutation: "Your virus just mutated to a new strain! Each virion can only be attacked by immune cells that know about its strain. Immune cells that know about a certain strain will be filled with the same color as virions of that strain.", strain: "Uh oh! The last virion of the new strain died, so your current highest mutation level went back down. You should try to keep alive the virions of the newest strain - they will earn you the most points!" }; // These flags are set to false when they've already occured - // built based on tut_msgs - var tut_flags = {}; - for_each( - keys(tut_msgs), - function(type) { - tut_flags[type] = true; - } - ); - - var tut_popup = function(txt) { - var obj = {}; - - var x = p.width/2; - var y = p.height/2; - var w = 400; - var h = 200; - var tw = w-50; - var tut_box = image_manager.get_image("tutorialbox.png"); - obj.draw = function() { - /* - p.noStroke(); - p.fill(100); - p.rectMode(p.CENTER); - p.rect(x, y, w, h); - */ - p.imageMode(p.CENTER); - p.image(tut_box, x, y); - p.fill(255); - p.textLeading(17); - p.textSize(16); - p.textAlign(p.CENTER, p.CENTER); - p.text(txt, x-tw/2, y-h/2, tw, h-50); - }; - - return obj; - }; - - var show_popup = function(text) { - var close_button = button(p, { - state: function() { - tut_window = null; - obj.resume(); - all_buttons.pop() // DANGEROUS... Hope we're not adding any other buttons anytime soon - return obj; // the current state - }, - rect: { - pos: new p.PVector(p.width/2, p.height/2+60), - //width: 50, height: 50, - //text: "OK" - image: "tut_ok.png" - } - }); - all_buttons.push(close_button); - - tut_window = tut_popup(text); - }; - - var tut_obj = { - popup : function(type) { - if (is_tutorial && tut_flags[type]) { - tut_pause(); - ok_to_fire = false; - text = tut_msgs[type]; - show_popup(text); - tut_flags[type] = false; - } - allFinished = true; - for_each( - keys(tut_msgs), - function(type) { - if (tut_flags[type]) { - allFinished = false; - } - } - ); - // the tutorial will have been completely finished by now - if (allFinished) { - g_tut_done = true; - } - } - }; - return tut_obj; - })() - - var all_notifications = []; - var last_notification_time = -1 - // takes a string and adds a new notification - var notify = function(note, color) { - var the_pos = null; - if (active_cell) { - console.log("Setting to active cell"); - a_pos = active_cell.get_pos(); - the_pos = new p.PVector(a_pos.x, a_pos.y - 30); - } - else { - console.log("Setting to default"); - the_pos = new p.PVector(p.width * (5/8), p.height * (5/8)); - } - if (new Date().getTime() > (last_notification_time + 2000)) { // two seconds - all_notifications.push(notification(p, { "text": note, "color": color, - "pos" : the_pos})); - last_notification_time = new Date().getTime(); - } - }; - - var generator = make_generator(p, { - game : obj, - mutation : mutation - }); - - // temporary flag TODO - //var game_over = false; - - //A mapping from game_object types to their rendering levels - var type_to_level = { - "background_object":0, - "background_edge":0, - "wall":1, - "wall_segment":1, - "particle":2, // general name for level - "cell":3, // general name for level - "wall_cell": 3, - "empty_cell": 3, - "enemy":4, // general name for level - "floater":4, - "tkiller":4, - "antibody":4, - "b_cell": 5, - "multiplier":6, - "info":7 - }; - - // given a type returns the array of objects - // corresponding to that type's level - var level = function(type) { - var lvl = game_objects[type_to_level[type]]; - assert (lvl, type+" not a valid type!"); - return lvl; - }; - - -/* - // Buttons - // Have a rectangle representing their position and - // a state to go to when pressed - var pause_button = { - state : pause_state(), - rectangle : rectangle(p, { - pos : new p.PVector(p.width - 20, 20), - width : 20, - height : 20 - }) - }; - var help_button = { - state : help_state(), - rectangle : rectangle(p, { - pos : new p.PVector(p.width - 80, 20), - width : 20, - height : 20 - }) - }; - var exit_button = { - state : exit_state(), - rectangle : rectangle(p, { - pos : new p.PVector(20, 20), - width : 20, - height : 20 - }) - }; -*/ - //Not ordered - - - // --- private methods --- - - // initialization code goes here - // gets called at the bottom - var init = function() { - // Start playing the game music - if (g.music) { - sounds.play_background_music(); - } - - //Initialize game_objects to be a list of num_of_render_levels empty lists - var num_of_render_levels = 0; - for (var key in type_to_level){ - if (type_to_level.hasOwnProperty(key)) { - var new_level = type_to_level[key]; - if (new_level > num_of_render_levels) { - num_of_render_levels = new_level; - } - } - } - for (var i = 0; i < num_of_render_levels; i++) { - game_objects[i] = []; - } - - var startx = p.width-150; - if (testing) { - var startx = 150; - } - - var initial_cells = [ - cell(p, { - pos: new p.PVector(startx, p.height/2), - vel: new p.PVector(0, 0), - state: "alive", - }), - cell(p, { - pos: new p.PVector(startx+170, p.height/2-40), - vel: new p.PVector(0, 0), - state: "alive", - }), - cell(p, { - pos: new p.PVector(startx+170, p.height/2), - vel: new p.PVector(0, 0), - state: "alive", - }), - cell(p, { - pos: new p.PVector(startx+170, p.height/2+40), - vel: new p.PVector(0, 0), - state: "alive", - }) - ]; - //var cell_level = type_to_level["cell"]; - //game_objects[cell_level].push(initial_cell); - obj.add_objects(initial_cells); - - var initial_par = particle(p, { - pos: new p.PVector(0, p.height/2), - vel: new p.PVector(8, 0), - // start with some gray - mutation_info: mutation.get_info()//p.color(250, 250, 250) - //mutation : mutation - }); - - obj.add_object(initial_par); - - init_walls(); - init_back(); - - //active_cell = initial_cell; - - // Add background - //var bg = background(p, { pos : new p.PVector(0, 0)}); - //obj.add_object(bg); - //console.log(level("background")[0]); - }; - - // creates, adds, and returns a new b_cell with no target - var make_b_cell = function() { - var new_b_cell = b_cell(p, { - pos: new p.PVector(p.width+50, p.random(p.height/4, 3*p.height/4)), - }); - obj.add_object(new_b_cell); - return new_b_cell; - }; - - // creates, adds, and returns a new tkiller with no target - var make_tkiller = function() { - var new_tkiller = tkiller(p, { - pos: new p.PVector(p.width+50, p.random(p.height/4, 3*p.height/4)), - }); - obj.add_object(new_tkiller); - return new_tkiller; - }; - - // Returns the current b cell on the screen, if there is one - var get_b_cell = function(level) { - var the_b_cell = null; - do_to_type( - function(b) { - if (b.get_level() === level) { - the_b_cell = b; - } - }, - "b_cell", true - ); - return the_b_cell; - }; - - var alert_b_cell = function(flo) { - // gets b_cell of the flo's level - var b = get_b_cell(flo.get_level()); - // if there isn't one - if (!b) { - // make one - b = make_b_cell(); - b.set_mutation_info(flo.get_mutation_info()); - b.set_target(flo); - } - // if there is one - else { - // it should be either active, shooting, or outdated - // so do nothing - } - }; - - // Alerts the b cell (only one on screen at a time?) to a newly mutated - // obj. - // If o.mutation_level >= b cells current target.mutation_level and o is - // closer than the b cells curr target (or if b cells curr - // target is null), updates b_cells curr target to be o - /* - var alert_b_cell = function(o) { - //var cell_objs = level("b_cell"); - //var cell_obj = null; - /*for (var i = 0; i < cell_objs.length; i++) { - cell_obj = cell_objs[i]; - if (cell_obj.get_type() === "b_cell") { - the_b_cell = cell_obj; - } - } - / - - var the_b_cell = get_b_cell(); - - if (the_b_cell && the_b_cell.is_alive()) { - var old_target = the_b_cell.get_target(); - - if (old_target) { - // if new macro has higher or equal level - if (//o.get_level() >= old_target.get_level() - // if new macro has current mutation level - o.get_level() === mutation.get_level() - // and it is closer - && old_target.get_pos().dist(the_b_cell.get_pos()) > - o.get_pos().dist(the_b_cell.get_pos())) { - the_b_cell.set_target(o); - } - } - else { - the_b_cell.set_target(o); - } - } - }; - */ - - // sets active_cell to the leftmost infected cell - // if there is one - var next_active_cell = function() { - var sort_fun = function(active_c) { // don't care about active - if (last_active_cell) { - // let's try the nearest cell to the one that died - return function(c1, c2) { - return dist_less_than(last_active_cell, c1, c2) ? -1 : 1; - }; - } - // otherwise leftmost - return function(c1, c2) { - return c1.get_pos().x - c2.get_pos().x; - }; - } - choose_cell(sort_fun); - }; - - // Set the next-left or next-right cell to be active, and - // if appropriate sets current active to be not active - - // Chooses the closest cell to a_pos - var choose_closest_cell = function(a_pos) { - if (active_cell) { // for the beginning - var old_active = active_cell; - var sort_fun = function(active_cell){ - return function(c1, c2){ - return c1.get_pos().dist(a_pos) - - c2.get_pos().dist(a_pos); - } - }; - choose_cell(sort_fun); - - // In case it doesn't change (choose_cell assumes - // that the cell is diff from the curr active) - if (old_active.get_pos().dist(a_pos) < - active_cell.get_pos().dist(a_pos)) { - active_cell.set_state("infected"); - active_cell = old_active; - active_cell.set_state("active"); - } - } - } - - // Chooses the closest cell to the active cell in the direction of comp, - // i.e. such that comp(c1.x, active.x) is true - var choose_cell_helper = function(comp) { - var sort_fun = function(active_c) { //don't rename to active_cell - return function(c1, c2) { - c1x = c1.get_pos().x; - c2x = c2.get_pos().x; - actx = active_c.get_pos().x; - // If one is in the right dir and the other isnt, - // return the one that is - if (comp(c1x, actx) && !(comp(c2x, actx))) { - return -1; - } - else if (!(comp(c1x, actx)) && comp(c2x, actx)) { - return 1; - } - // If they are on the same side, return opposite of comp - else { - if (comp(c1x, c2x)) { - return 1; - } - else { - return -1; - } - } - } - }; - choose_cell(sort_fun); - }; - - // Chooses the next left cell to be active - var choose_left_cell = function() { - choose_cell_helper(function (x, y) {return x < y;}); - }; - - // Same in the right dir - var choose_right_cell = function() { - choose_cell_helper(function (x, y) {return x > y;}); - }; - - // Sets a cell to be active based on sort_fun, and if this is diff - // from curr cell, sets curr cell to not be active - // sort_fun must take the currently active cell, and return a function - // that takes 2 cells, ad returns true if the first is 'better' than - // the second - var choose_cell = function(sort_fun) { - var cells = level("cell");//game_objects[type_to_level["cell"]]; - var infecteds = cells.filter( - function(cell) { - // don't want empty_cells - return cell.get_type() === "cell" - && cell.get_state() === "infected"; - }); - var sort_f = sort_fun(active_cell); - infecteds.sort(sort_f); - - var curr_active = active_cell; - if (infecteds.length > 0) { - - // tutorial msg about switching cells - if (infecteds.length > 1) { - tut_manager.popup("arrows"); - } - - active_cell = infecteds[0]; - //If same as current - if (curr_active) { // for the beginning - curr_active.set_state("infected"); //if same, about to change - } - active_cell.set_state("active"); - //console.log("got next "+active_cell.to_string()); - } - }; - - // Returns true if source is closer to target1 than target2 - // All 3 args are game_objs - var dist_less_than = function(source, target1, target2) { - var source_pos = source.get_pos(); - return source_pos.dist(target1.get_pos()) < - source_pos.dist(target2.get_pos()); - }; - - // Updates all tkillers targets - // Tkillers target the closest infected and targeted cell - var update_tkillers_targets = function(){ - var all_infected_cells = get_all_infected_cells(); - do_to_type(function(tkill){ - // remove bad targets - if (tkill.get_target() - // if it's dead - && (tkill.get_target().is_dead() - // or dying - || tkill.get_target().get_state() === "dying" - // or offscreen - || tkill.get_target().is_offscreen() - // or the target mutated - || !same_mutation_level(tkill, tkill.get_target()))) { - tkill.set_target(null); - } - // set a new target - for_each( - all_infected_cells, - function(infected_cell) { - if (infected_cell.has_antibody() - && same_mutation_level(infected_cell, tkill) - && (!tkill.get_target() || - dist_less_than(tkill, - infected_cell, tkill.get_target()))) { - tkill.set_target(infected_cell); - } - } - ); - }, "tkiller", true); - }; - - // adds new tkillers if need be - var add_tkillers = function() { - var tks = get_all_of_type("tkiller"); - do_to_type( - // for each b_cell - function(b) { - // if it needs a tkiller - if (b.is_shooting()) { - // check if one exists - var has_tkiller = false; - for_each(tks, function(tk) { - if (same_mutation_level(b, tk)) { - has_tkiller = true; - } - }); - // if one doesn't - if (!has_tkiller) { - console.log("made tkiller for lvl "+b.get_level()); - // make one - var tk = make_tkiller(); - tk.set_mutation_info(b.get_mutation_info()); - } - } - }, - "b_cell", true - ); - }; - - - // kills the active cell and updates the targets - // of all the tkillers - var kill_active_cell = function() { - active_cell.die(); - last_active_cell = active_cell; - active_cell = null; - update_tkillers_targets(); - }; - - //Checks whether any 2 objs are colliding, and if so calls handle_collision on them - var check_collisions = (function() { - // rendering levels to check collisions for: - var to_check = [ - //["particle", "particle"], - ["particle", "cell"], - ["particle", "enemy"], - ["particle", "multiplier"], - //["cell", "cell"], - ["cell", "enemy"], - //["enemy", "enemy"], - ["enemy", "b_cell"], - ["b_cell", "wall"], - ["particle", "wall"], - ["multiplier", "wall"], - ["enemy", "wall"] - ]; - - // hey this looks like combinations! - var do_comb = function(arr1, start1, end1, - arr2, start2, end2, fun) { - var i = start1, j = start2; - while (i <= end1) { - while (j <= end2) { - fun(arr1[i], arr2[j]); - j++; - } - i++; - // when arrays are the same - // don't do repeats - if (arr1 === arr2) { - j = i; - } - else { - j = 0; - } - } - }; - - var collision_fun = function() { - // double combinations! - // for each pair of rendering groups - // do_comb(game_objects, 1, 3, - // game_objects, 1, 3, - for_each(to_check, function(pair) { - var lvl1 = level(pair[0]); - var lvl2 = level(pair[1]); - // for each pair of objects in the groups - do_comb(lvl1, 0, lvl1.length-1, - lvl2, 0, lvl2.length-1, check); - }); - //); - }; - - - var check = function(obj1, obj2) { - //console.log("checking "+obj1.to_string() - // +", "+obj2.to_string()); - // check the collisions - // don't check collisions with self - if (obj1 !== obj2 - && check_collision(obj1, obj2)) { - handle_collision(obj1, obj2); - //console.log("collision! " +obj1.to_string() - // +", "+obj2.to_string()); - } - } - - return collision_fun; - }()); - - // Returns whether 2 objects are colliding - var check_collision = function(obj1, obj2) { - var type1 = obj1.get_type(); - var type2 = obj2.get_type(); - - if (!obj1.is_off_right() && - !obj2.is_off_right() && - check_circle_collision(obj1, obj2)) { - var check_again = retrieve(extra_check, type1, type2); - if (check_again !== undefined) { - return check_again(obj1, obj2); - } - else { - check_again = retrieve(extra_check, type2, type1); - if (check_again !== undefined) { - return check_again(obj2, obj1); - } - else { - return true; - } - } - } - else { - return false; - } - }; - - // Checks for a collision between circle (obj2) and rectangle (obj1) - var check_rectangle_collision = function(rect, circ) { - return overlapping_vertically(circ, rect, rect.get_y_offset()) && - overlapping_horizontally(circ, rect, rect.get_x_offset()); - }; - - // Rectangle and circle collision helper functions - // Returns whether the circle is overlapping the rectangle, horizontally, - // by offset num of pixels - var overlapping_horizontally = function(circ, rect, offset) { - var circlel = circ.get_left(), circler = circ.get_right(); - var rectl = rect.get_left(), rectr = rect.get_right(); - return ((circler <= rectr && circler >= (rectl + offset)) || - (circlel >= rectl && circlel <= (rectr - offset))); - }; - // Returns whether the circle is overlapping the rectangle, vertically, - // by offset num of pixels - var overlapping_vertically = function(circ, rect, offset) { - var circlet = circ.get_top(), circleb = circ.get_bottom(); - var rectt = rect.get_top(), rectb = rect.get_bottom(); - - return (circleb <= rectb && circleb >= (rectt + offset) || - (circlet >= rectt && circlet <= (rectb - offset))); - }; - - // holds extra collision checking functions for certain - // pairs of types - var extra_check = { - "wall_segment": { - "particle": check_rectangle_collision, - "b_cell": check_rectangle_collision, - "multiplier": //check_rectangle_collision - // had to do manually cuz offset was messed up - function(rect, circ) { - return overlapping_vertically(circ, rect, 0) && - overlapping_horizontally(circ, rect, 0); - } - }, - "floater": { - "b_cell": check_rectangle_collision - }, - "wall_cell": { - "particle": check_rectangle_collision - } - }; - - // checks for collisions between two objects by - // checking if their bounding circles are overlapping - // returns true if they are colliding - var check_circle_collision = function(obj1, obj2) { - // if the distance between their center points - // is <= the sum of their radii then they are colliding - // ONLY WORKS FOR CENTERED SHAPES - return (obj1.get_pos().dist(obj2.get_pos()) - <= obj1.get_radius() + obj2.get_radius()); - }; - // make it public - obj.check_circle_collision = check_circle_collision; - - /* - // Reverses 2 objs appropriate velocities - var bounce_collided = (function() { - // A list containing 2 element lists - // Inner lists represent object type pairs to not bounce off each other - var to_exclude = [ ["particle", "multiplier"], - ["particle", "particle"], - ["wall_segment", "b_cell"], - ["particle", "antibody"]]; - - var is_excluded = function(o1, o2) { - var is_excluded = false; - var type1 = o1.get_type(), type2 = o2.get_type(); - var objs_in_list = function(list) { - return ((list[0] === type1 && list[1] === type2) || - (list[0] === type2 && list[1] === type1)); - } - for_each(to_exclude, function(l) { - if (objs_in_list(l)) { - is_excluded = true; - } - }); - return is_excluded; - } - return function(obj1, obj2) { - if (!is_excluded(obj1, obj2)) { - bounce(obj1, obj2); - } - } - }()); - */ - - var bounce = function(obj1, obj2) { - //offset adjusts how closely we check, since we can't check exactly when they collide every time - var offset = 5; - var onel = obj1.get_left(), oner = obj1.get_right(); - var onet = obj1.get_top(), oneb = obj1.get_bottom(); - var twol = obj2.get_left() + offset, twor = obj2.get_right() - offset; - var twot = obj2.get_top() + offset, twob = obj2.get_bottom() - offset; - - //When bouncing, check velocity to make sure they are 'incoming' to each other - //This avoids them getting stuck (makes sure they didn't just collide) - //bounce vertically - var y_vel = obj1.get_vel().y; - var x_vel = obj1.get_vel().x; - if ((onet >= twob && y_vel <= 0) || (oneb <= twot && y_vel >= 0)) { - obj1.reverse_y(); - obj2.reverse_y(); - } - if ((oner <= twol && x_vel >= 0) - || (onel > twor && x_vel <= 0)) { //bounce horizontally - obj1.reverse_x(); - obj2.reverse_x(); - } - }; - - // handles collisions between different object types - var handle_collision = function(obj1, obj2) { - var ot1 = obj1.get_type(); - var ot2 = obj2.get_type(); - - // try first with one order - var handler = retrieve(collision_handlers, ot1, ot2); - if (handler) { - handler(obj1, obj2); - } - // if it didn't work - else { - // try the other order - handler = retrieve(collision_handlers, ot2, ot1); - if (handler) { - handler(obj2, obj1); - } - else { - //Not an error now? - //throw "Unsupported collision type!"; - } - - } - - // Bounce if appropriate - //bounce_collided(obj1, obj2); - }; - - // object to store all the handlers - // created once with a closure - // dont manage bouncing/changing direction here - var collision_handlers = (function() { - var nothing = function(obj1, obj2) {}; - - // infects the cell, kills the particle - var infect = function(par, cell) { - // only if cell is "alive" - // (ie only one particle per cell) - assert(cell, "Not a cell in infect!"); - if (cell.get_state() !== "dead" - && cell.get_state() !== "dying") { - par.die(); - } - if (cell.get_state() === "alive") { - tut_manager.popup("spacebar"); - //Play sound - sounds.play_sound("cell_infect"); - - // increase mutation percentage if level is highest on screen - // must be done before setting state of infected cell - // only happens if infected by particle of cur level - if (par.get_level() === mutation.get_level()) { - mutation.infected_cell(); - } - - cell.set_state("infected"); - cell.set_mutation_info(par.get_mutation_info()); - - // Add 10 to score - score.incr(10 * par.get_level() * mult.get_num()); - } - else { - // otherwise deflect - //bounce(par, cell); - } - }; - - - var handlers = { - "particle": { - // particle vs. particle - // do nothing? - "particle": nothing, - - // particle vs. cell - // infect the cell, kill the particle - "cell": infect, - - // particle vs. wall_cell - // bounce particle off cell - // cell doesn't move - "wall_cell": bounce, - - // particle vs. empty_cell - // // infect the cell, kill the particle - // kill the particle - "empty_cell": function(par, cell) { - // TODO diff sound? - sounds.play_sound("cell_infect"); - par.die(); - }, - - // particle vs. floater - // kill the particle - // floater takes on color of particle - "floater": function(par, flo) { - par.die(); - if (flo.is_alive()) { - // update flo if not activated || level < - // par.level - if (!flo.is_activated() || - flo.get_level() < - par.get_level()) { - flo.set_mutation_info(par.get_mutation_info()); - flo.activate(); - alert_b_cell(flo); - sounds.play_sound("macrophage_infect"); - tut_manager.popup("macrophage"); - } - notify("Macrophage activated!", BAD_NOTIFICATION_COLOR); - } - }, - - // particle vs. tkiller - // nothing? - "tkiller": nothing, - - // particle vs. multiplier - // get rid of the mult and incr mult - "multiplier": function(par, mul) { - //par.die(); - mul.die(); - mult.incr(1); - }, - - // particle vs wall - // Kill particle - "wall_segment": function(par, wall) { - par.die(); - } - }, - - // cell vs. cell - // cell vs. wall_cell - // cell vs. empty_cell - // wall_cell vs. wall_cell - // wall_cell vs. empty_cell - // empty_cell vs. empty_cell - // don't let them overlap (is bouncing necessary?) - "cell": { - "cell": nothing, - "wall_cell": nothing, - "empty_cell": nothing - }, - "wall_cell": { - "wall_cell": nothing, - "empty_cell": nothing - }, - "empty_cell": { - "empty_cell": nothing - }, - - // floater vs. cell - // floater vs. wall_cell - // floater vs. empty_cell - // floater vs. floater - // no overlap? - "floater": { - "cell": bounce, - "wall_cell": bounce, - "empty_cell": bounce, - "floater": bounce - }, - - "tkiller": { - // tkiller vs. cell - "cell": function(tk, cell) { - if ((cell.get_state() === "infected" || - cell.get_state() === "active") - && cell.has_antibody() - && same_mutation_level(tk, cell)) { - tut_manager.popup("killer"); - cell.die(); - sounds.play_sound("kill"); - tk.set_target(null); - if (active_cell === cell) { - //last_active_cell = active_cell; - //active_cell = null; - kill_active_cell(); - } - } - }, - - // tkiller vs. wall_cell - // tkiller vs. empty_cell - // tkiller vs. floater - // tkiller vs. tkiller - // nothing? TODO bounce? - "wall_cell": nothing, - "empty_cell": nothing, - "floater": nothing, - "tkiller": nothing - }, - - "antibody": { - "cell": function(a, c) { - if (same_mutation_level(a, c)) { - if (!c.has_antibody() && - (c.get_state() === "infected" || - c.get_state() === "active")) { - c.set_antibody(a); - } - } - } - }, - - "multiplier": { - // multiplier vs wall - // do nothing - "wall_segment": bounce - }, - - "b_cell": { - "floater": function(b, flo) { - if (b.is_alive() && flo.is_activated()) { - b.set_mutation_info(flo.get_mutation_info()); - b.activate(get_bcell_slot()); - bounce(b, flo); - notify("B cell activated!", BAD_NOTIFICATION_COLOR); - } - // trying to avoid getting stuck - if (b.is_outdated()) { - bounce(b, flo); - b.set_target(null); - } - }, - "wall_segment": function(b, wall) { - //console.log("collision"); - if (b.is_activated()) { - tut_manager.popup("antibodies"); - // start making antibodies - b.make_antibodies(); - // make a tkiller - var tk = make_tkiller(); - tk.set_mutation_info(b.get_mutation_info()); - - notify("Incoming antibodies!", BAD_NOTIFICATION_COLOR); - } - else if (b.is_alive()) { - bounce(b, wall); - } - else if (b.is_outdated()) { - } - } - } - }; - return handlers; - }()); - - //Removes all objs which are either off screen or dead - var remove_objs = function() { - var filter_fun = function(x) { - //Check offscreen, but don't remove newly generated - var offscreen = false; - if (x.is_offscreen()) { - //Only remove particles that are off the right - if (x.is_off_right()) { - if (x.get_type() === "particle") { - offscreen = true; - } - //else false - } - else { - //console.log("removing "+x.to_string()); - offscreen = true; - } - } - return (! (offscreen || x.is_dead())); - }; - for (var i = 0; i < game_objects.length; i++) { - game_objects[i] = game_objects[i].filter(filter_fun); - } - - // check offscreen for active cell - if (active_cell && active_cell.is_offscreen()) { - //active_cell = null; - kill_active_cell(); - } - }; - - // Returns whether the 2 objects have the same mutation level - var same_mutation_level = function(o1, o2) { - var o1level = o1.get_mutation_info().level; - var o2level = o2.get_mutation_info().level; - return (o1level === o2level); - }; - - - // adds a new background tile if the rightmost is onscreen - // ASSUMES ALL WALL TILES ARE SAME SIZE - var back_top = null; - var back_btm = null; - var add_back = (function() { - - var add_one = function(edge_tile) { - if (!goes_off_right(edge_tile)) { - //console.log("adding edge"); - - var new_spec = {}; - var x = edge_tile.get_pos().x - + edge_tile.get_width(); - - var y = status_bar_height; - new_spec.is_top = true; - // switch if it's a bottom edge - if (edge_tile === back_btm) { - // this will be changed in the edge object - y = p.height; - new_spec.is_top = false; - } - - new_spec.pos = new p.PVector(x, y); - - var new_tile = background_edge(p, new_spec); - obj.add_object(new_tile); - - if (edge_tile === back_top) { - back_top = new_tile; - } - else { - back_btm = new_tile; - } - //console.log("added tile "+new_tile.to_string()); - } - }; - - var add_both = function() { - add_one(back_top); - add_one(back_btm); - }; - - return add_both; - }()); - - // initialized the background - var init_back = function() { - // initial edges - back_top = background_edge(p, { - pos: new p.PVector(-100, status_bar_height), - is_top: true - }); - obj.add_object(back_top); - - back_btm = background_edge(p, { - pos: new p.PVector(-10, p.height), - is_top: false - }); - obj.add_object(back_btm); - - // add one more tile to fill screen - add_back(); - }; - - // tells if a background tile goes off the right of the screen - var goes_off_right = function(tile) { - return tile.get_pos().x + tile.get_width() > p.width; - }; - - // adds a new wall segment if the rightmost wall - // segment is onscreen - var rightmost_top = null; - var rightmost_btm = null; - var add_wall = (function() { - - // adds either a top or bottom wall - var add_one = function(rightmost) { - // if the rightmost has entered the screen - if (!rightmost.is_off_right()) { - var new_spec = {}; - - // note that new wall coords should be at - // bottom left corner of seg - // should be next to last seg - var x = rightmost.get_pos().x - + rightmost.get_width()/2 - 5; - - // set y for top wall - var y = 95; - new_spec.is_top = true; - // switch if it's a bottom wall - if (rightmost === rightmost_top) { - y = p.height+5; - new_spec.is_top = false; - } - - new_spec.pos = new p.PVector(x, y); - - // add the new segment - var new_seg = wall_segment(p, new_spec); - obj.add_object(new_seg); - - // update the corresponding rightmost - if (rightmost === rightmost_top) { - rightmost_top = new_seg; - } - else { - rightmost_btm = new_seg; - } - } - }; - - var add_both = function() { - add_one(rightmost_top); - add_one(rightmost_btm); - }; - - return add_both; - }()); - - var init_walls = function() { - // add first empty segments - // the values used here are important so don't change them - rightmost_top = wall_segment(p, { - pos: new p.PVector(-10, 0), - width: 5 - }); - - rightmost_btm = wall_segment(p, { - pos: new p.PVector(-10, p.height), - width: 5 - }); - - // while both walls don't span the screen - while(!(rightmost_top.is_off_right() - && rightmost_btm.is_off_right())) { - // add new walls - add_wall(); - } - }; - - //Does a function to every object - //Pass in a function that takes an object - var do_to_all_objs = function(f) { - for (var i=0; i= 0) ) { - do_to_all_objs(function(o) { o.get_pos().add( - new p.PVector(-dist/10, 0)); }); - //["particle", "cell", "enemy"], false); - } - } - }; - - - // --- public methods --- - - obj.get_type = function() { - return "game"; - }; - - //Calls update() on every obj - //after updating, calls remove_objs - obj.update = (function() { - var game_types = ["background", "wall", "particle", - "cell", "enemy", "multiplier", "antibody"]; - - var update_fun = function() { - // Can't be set when object is initialized - // Takes time every update though to check - if (!set_time) { - //Set interval to update time elapsed - var update_time = function() { - if (!paused) { - time_elapsed += 1; - time_status.set_num(time_elapsed); - } - } - setInterval(update_time, 1000); - set_time = true; - } - if (!paused) { - // if we don't have an active cell - if (active_cell === null) { - // try to find the next one - next_active_cell(); - } - // THIS MUST COME BEFORE GAME OVER CHECK - - // check for game over - // (if no particles are left and no active cell) - //console.log("num of particles: " + level("particle").length); - if (active_cell === null && - level("particle").length === 0) { - var go_state = game_over_state(p, previous_state, { - score : score.get_num(), - mutation_level : mutation.get_level() - }, game_type); - sounds.pause_background_music(); - obj.set_next_state(go_state); - - // stop the animations - do_to_all_objs( - function(o) { - if (o.stop_animation) { - o.stop_animation(); - } - } - ); - - // stop notifications - all_notifications = []; - - // stop the time and stuff - paused = true; - - // Add to the high score table - // If fb user name and id are set - if (g_user_name && g_user_id) { - scores.submit_score(score.get_num(), - mutation.get_level(), g_user_name, g_user_id); - // Update the high score table - // (not necessary now) - //scores.do_scores(); - } - - // simply don't do the rest of update - return; - } - - //Add any newly generated objs - generator.update(); - - // Make antibodies seek any infected cells they are near - make_antibodies_seek(); - - // Add antibodies generated from b cells - do_to_type( - function(b) { - obj.add_objects(b.get_antibodies()); - }, - "b_cell", true - ); - - // adds a new segment of wall if necessary - add_wall(); - // adds a new background tile if necessary - add_back(); - - add_tkillers(); - update_tkillers_targets(); - - // set outdated t/b cells - set_all_outdated(); - - // scroll all objects - - do_to_all_objs(function(o){ - o.scroll(scroll_factor); - }); - - //dynamic_scroll(); - - // update distance travelled - distance += scroll_factor; - - // update all objects - do_to_all_objs(function(o){ - o.update(); - }); - - check_collisions(); - - remove_objs(); - - update_mutation(); - - /* - // for debugging - var count = 0; - do_to_all_objs(function() { count += 1; }); - console.log(count); - console.log("fr "+p.__frameRate); - */ - } - }; - - var update_mutation = function() { - // check for a new mutation - // if mutation occurred - if (mutation.has_new_mutation() && active_cell) { - // pick infected cell closest to active cell with the current - // mutation level - var choices = get_all_of_type("cell").filter( - function(c) { - return ((c.get_state() === "infected" - || c.get_state() === "active") - && c.get_level() === mutation.get_level()); - } - ); - choices.sort( - function(c1, c2) { - return dist_less_than(active_cell, c1, c2) ? -1 : 1; - } - ); - var cell_to_mutate = choices[0]; - - // do the actual mutation and hold onto new ability - //var new_ability = - mutation.do_mutation(); - // mutate the active cell - cell_to_mutate.set_mutation_info(mutation.get_info()); - // update the scroll factor - scroll_factor += 0.15; - - //if (new_ability) { - // notify("New Ability: " + new_ability); - //} - //else { - notify("Mutation occurred!", GOOD_NOTIFICATION_COLOR); - //} - - - tut_manager.popup("mutation"); - - console.log("mutation occurred!"); - } - // otherwise check for downgrades - else { - // check for the highest mutation level on screen - var max_level = 0; - var find_max = function(o) { - if (o.get_level() > max_level) { - max_level = o.get_level(); - } - }; - do_to_type(find_max, "cell", false); - do_to_type(find_max, "particle", false); - - // if max level lower than mutation level - if (max_level > 0 && max_level < mutation.get_level()) { - // downgrade to that level - mutation.set_level(max_level); - // reset the counters - mutation.reset_mutation(); - - notify("Lost new strain!", BAD_NOTIFICATION_COLOR); - tut_manager.popup("strain"); - console.log("downgraded to mutation level "+max_level); - - scroll_factor -= 0.15; - - // TODO do enemies become not outdated? - } - } - }; - - return update_fun; - }()); - - //Calls draw() on every obj - obj.render = function(){ - - // put the active cell at the end of the list - // so it is drawn on top - if (active_cell) { - var cells = level("cell"); - remove_elt(cells, active_cell); - cells.push(active_cell); - } - - p.background(g.background_color); - - for (var i=0; i -Virion - - - - - - -
- - - - - - - diff --git a/game/dev/index1.html b/game/dev/index1.html deleted file mode 100644 index 5555d94..0000000 --- a/game/dev/index1.html +++ /dev/null @@ -1,299 +0,0 @@ - - - -Virion - - - - - - - - - - -
- - - - - - - -
- - -
- -
-
- Could not load high scores! You may want to check your internet connection. -
-
- - - Your browser does not support the HTML5 canvas element. Upgrade to Chrome, Firefox 4, Safari, or Opera to play this game. - -
-
Virion was created as an entry in the Hidden Agenda contest.
If you like the game, leave some feedback on the Hidden Agenda page to help Virion win!
- -
-
- -
-
- Note: Virion was built entirely using the new open HTML5 standard and the Processing.js JavaScript library. This means that you will never have to install a proprietary plugin to play our game, and in the near future will be able to play our game on any browser on any platform. Currently, however, some browsers do not yet have full support for the HTML5 standard, so please note the following browser compatibility issues:

- Google Chrome has no problems, and is highly recommended for the best overall performance
- If you are using Firefox 3 and the game is not loading or running slowly, try updating to Firefox 4
- If you are using Safari and seeing performance issues, try turning off the sound effects
- If you are using Internet Explorer, please switch to any of the above browsers immediately! -

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/dev/indexTest.html b/game/dev/indexTest.html deleted file mode 100644 index 15c3b4d..0000000 --- a/game/dev/indexTest.html +++ /dev/null @@ -1,105 +0,0 @@ - -Virion - - - - - - - -
- - - - - - diff --git a/game/dev/jplayer/Jplayer.swf b/game/dev/jplayer/Jplayer.swf deleted file mode 100755 index 9487f49..0000000 Binary files a/game/dev/jplayer/Jplayer.swf and /dev/null differ diff --git a/game/dev/jplayer/jquery.jplayer.min.js b/game/dev/jplayer/jquery.jplayer.min.js deleted file mode 100755 index b9b7007..0000000 --- a/game/dev/jplayer/jquery.jplayer.min.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - * jPlayer Plugin for jQuery JavaScript Library - * http://www.happyworm.com/jquery/jplayer - * - * Copyright (c) 2009 - 2010 Happyworm Ltd - * Dual licensed under the MIT and GPL licenses. - * - http://www.opensource.org/licenses/mit-license.php - * - http://www.gnu.org/copyleft/gpl.html - * - * Author: Mark J Panaghiston - * Version: 2.0.0 - * Date: 20th December 2010 - */ - -(function(c,h){c.fn.jPlayer=function(a){var b=typeof a==="string",d=Array.prototype.slice.call(arguments,1),f=this;a=!b&&d.length?c.extend.apply(null,[true,a].concat(d)):a;if(b&&a.charAt(0)==="_")return f;b?this.each(function(){var e=c.data(this,"jPlayer"),g=e&&c.isFunction(e[a])?e[a].apply(e,d):e;if(g!==e&&g!==h){f=g;return false}}):this.each(function(){var e=c.data(this,"jPlayer");if(e){e.option(a||{})._init();e.option(a||{})}else c.data(this,"jPlayer",new c.jPlayer(a,this))});return f};c.jPlayer= -function(a,b){if(arguments.length){this.element=c(b);this.options=c.extend(true,{},this.options,a);var d=this;this.element.bind("remove.jPlayer",function(){d.destroy()});this._init()}};c.jPlayer.event={ready:"jPlayer_ready",resize:"jPlayer_resize",error:"jPlayer_error",warning:"jPlayer_warning",loadstart:"jPlayer_loadstart",progress:"jPlayer_progress",suspend:"jPlayer_suspend",abort:"jPlayer_abort",emptied:"jPlayer_emptied",stalled:"jPlayer_stalled",play:"jPlayer_play",pause:"jPlayer_pause",loadedmetadata:"jPlayer_loadedmetadata", -loadeddata:"jPlayer_loadeddata",waiting:"jPlayer_waiting",playing:"jPlayer_playing",canplay:"jPlayer_canplay",canplaythrough:"jPlayer_canplaythrough",seeking:"jPlayer_seeking",seeked:"jPlayer_seeked",timeupdate:"jPlayer_timeupdate",ended:"jPlayer_ended",ratechange:"jPlayer_ratechange",durationchange:"jPlayer_durationchange",volumechange:"jPlayer_volumechange"};c.jPlayer.htmlEvent=["loadstart","abort","emptied","stalled","loadedmetadata","loadeddata","canplaythrough","ratechange"];c.jPlayer.pause= -function(){c.each(c.jPlayer.prototype.instances,function(a,b){b.data("jPlayer").status.srcSet&&b.jPlayer("pause")})};c.jPlayer.timeFormat={showHour:false,showMin:true,showSec:true,padHour:false,padMin:true,padSec:true,sepHour:":",sepMin:":",sepSec:""};c.jPlayer.convertTime=function(a){a=new Date(a*1E3);var b=a.getUTCHours(),d=a.getUTCMinutes();a=a.getUTCSeconds();b=c.jPlayer.timeFormat.padHour&&b<10?"0"+b:b;d=c.jPlayer.timeFormat.padMin&&d<10?"0"+d:d;a=c.jPlayer.timeFormat.padSec&&a<10?"0"+a:a;return(c.jPlayer.timeFormat.showHour? -b+c.jPlayer.timeFormat.sepHour:"")+(c.jPlayer.timeFormat.showMin?d+c.jPlayer.timeFormat.sepMin:"")+(c.jPlayer.timeFormat.showSec?a+c.jPlayer.timeFormat.sepSec:"")};c.jPlayer.uaMatch=function(a){a=a.toLowerCase();var b=/(opera)(?:.*version)?[ \/]([\w.]+)/,d=/(msie) ([\w.]+)/,f=/(mozilla)(?:.*? rv:([\w.]+))?/;a=/(webkit)[ \/]([\w.]+)/.exec(a)||b.exec(a)||d.exec(a)||a.indexOf("compatible")<0&&f.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}};c.jPlayer.browser={};var m=c.jPlayer.uaMatch(navigator.userAgent); -if(m.browser){c.jPlayer.browser[m.browser]=true;c.jPlayer.browser.version=m.version}c.jPlayer.prototype={count:0,version:{script:"2.0.0",needFlash:"2.0.0",flash:"unknown"},options:{swfPath:"./",solution:"html, flash",supplied:"mp3",preload:"metadata",volume:0.8,muted:false,backgroundColor:"#000000",cssSelectorAncestor:"#jp_interface_1",cssSelector:{videoPlay:".jp-video-play",play:".jp-play",pause:".jp-pause",stop:".jp-stop",seekBar:".jp-seek-bar",playBar:".jp-play-bar",mute:".jp-mute",unmute:".jp-unmute", -volumeBar:".jp-volume-bar",volumeBarValue:".jp-volume-bar-value",currentTime:".jp-current-time",duration:".jp-duration"},idPrefix:"jp",errorAlerts:false,warningAlerts:false},instances:{},status:{src:"",media:{},paused:true,format:{},formatType:"",waitForPlay:true,waitForLoad:true,srcSet:false,video:false,seekPercent:0,currentPercentRelative:0,currentPercentAbsolute:0,currentTime:0,duration:0},_status:{volume:h,muted:false,width:0,height:0},internal:{ready:false,instance:h,htmlDlyCmdId:h},solution:{html:true, -flash:true},format:{mp3:{codec:'audio/mpeg; codecs="mp3"',flashCanPlay:true,media:"audio"},m4a:{codec:'audio/mp4; codecs="mp4a.40.2"',flashCanPlay:true,media:"audio"},oga:{codec:'audio/ogg; codecs="vorbis"',flashCanPlay:false,media:"audio"},wav:{codec:'audio/wav; codecs="1"',flashCanPlay:false,media:"audio"},webma:{codec:'audio/webm; codecs="vorbis"',flashCanPlay:false,media:"audio"},m4v:{codec:'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',flashCanPlay:true,media:"video"},ogv:{codec:'video/ogg; codecs="theora, vorbis"', -flashCanPlay:false,media:"video"},webmv:{codec:'video/webm; codecs="vorbis, vp8"',flashCanPlay:false,media:"video"}},_init:function(){var a=this;this.element.empty();this.status=c.extend({},this.status,this._status);this.internal=c.extend({},this.internal);this.formats=[];this.solutions=[];this.require={};this.htmlElement={};this.html={};this.html.audio={};this.html.video={};this.flash={};this.css={};this.css.cs={};this.css.jq={};this.status.volume=this._limitValue(this.options.volume,0,1);this.status.muted= -this.options.muted;this.status.width=this.element.css("width");this.status.height=this.element.css("height");this.element.css({"background-color":this.options.backgroundColor});c.each(this.options.supplied.toLowerCase().split(","),function(e,g){var i=g.replace(/^\s+|\s+$/g,"");if(a.format[i]){var j=false;c.each(a.formats,function(n,k){if(i===k){j=true;return false}});j||a.formats.push(i)}});c.each(this.options.solution.toLowerCase().split(","),function(e,g){var i=g.replace(/^\s+|\s+$/g,"");if(a.solution[i]){var j= -false;c.each(a.solutions,function(n,k){if(i===k){j=true;return false}});j||a.solutions.push(i)}});this.internal.instance="jp_"+this.count;this.instances[this.internal.instance]=this.element;this.element.attr("id")===""&&this.element.attr("id",this.options.idPrefix+"_jplayer_"+this.count);this.internal.self=c.extend({},{id:this.element.attr("id"),jq:this.element});this.internal.audio=c.extend({},{id:this.options.idPrefix+"_audio_"+this.count,jq:h});this.internal.video=c.extend({},{id:this.options.idPrefix+ -"_video_"+this.count,jq:h});this.internal.flash=c.extend({},{id:this.options.idPrefix+"_flash_"+this.count,jq:h,swf:this.options.swfPath+(this.options.swfPath!==""&&this.options.swfPath.slice(-1)!=="/"?"/":"")+"Jplayer.swf"});this.internal.poster=c.extend({},{id:this.options.idPrefix+"_poster_"+this.count,jq:h});c.each(c.jPlayer.event,function(e,g){if(a.options[e]!==h){a.element.bind(g+".jPlayer",a.options[e]);a.options[e]=h}});this.htmlElement.poster=document.createElement("img");this.htmlElement.poster.id= -this.internal.poster.id;this.htmlElement.poster.onload=function(){if(!a.status.video||a.status.waitForPlay)a.internal.poster.jq.show()};this.element.append(this.htmlElement.poster);this.internal.poster.jq=c("#"+this.internal.poster.id);this.internal.poster.jq.css({width:this.status.width,height:this.status.height});this.internal.poster.jq.hide();this.require.audio=false;this.require.video=false;c.each(this.formats,function(e,g){a.require[a.format[g].media]=true});this.html.audio.available=false;if(this.require.audio){this.htmlElement.audio= -document.createElement("audio");this.htmlElement.audio.id=this.internal.audio.id;this.html.audio.available=!!this.htmlElement.audio.canPlayType}this.html.video.available=false;if(this.require.video){this.htmlElement.video=document.createElement("video");this.htmlElement.video.id=this.internal.video.id;this.html.video.available=!!this.htmlElement.video.canPlayType}this.flash.available=this._checkForFlash(10);this.html.canPlay={};this.flash.canPlay={};c.each(this.formats,function(e,g){a.html.canPlay[g]= -a.html[a.format[g].media].available&&""!==a.htmlElement[a.format[g].media].canPlayType(a.format[g].codec);a.flash.canPlay[g]=a.format[g].flashCanPlay&&a.flash.available});this.html.desired=false;this.flash.desired=false;c.each(this.solutions,function(e,g){if(e===0)a[g].desired=true;else{var i=false,j=false;c.each(a.formats,function(n,k){if(a[a.solutions[0]].canPlay[k])if(a.format[k].media==="video")j=true;else i=true});a[g].desired=a.require.audio&&!i||a.require.video&&!j}});this.html.support={}; -this.flash.support={};c.each(this.formats,function(e,g){a.html.support[g]=a.html.canPlay[g]&&a.html.desired;a.flash.support[g]=a.flash.canPlay[g]&&a.flash.desired});this.html.used=false;this.flash.used=false;c.each(this.solutions,function(e,g){c.each(a.formats,function(i,j){if(a[g].support[j]){a[g].used=true;return false}})});this.html.used||this.flash.used||this._error({type:c.jPlayer.error.NO_SOLUTION,context:"{solution:'"+this.options.solution+"', supplied:'"+this.options.supplied+"'}",message:c.jPlayer.errorMsg.NO_SOLUTION, -hint:c.jPlayer.errorHint.NO_SOLUTION});this.html.active=false;this.html.audio.gate=false;this.html.video.gate=false;this.flash.active=false;this.flash.gate=false;if(this.flash.used){var b="id="+escape(this.internal.self.id)+"&vol="+this.status.volume+"&muted="+this.status.muted;if(c.browser.msie&&Number(c.browser.version)<=8){var d='';f[1]='';f[2]='';f[3]='';f[4]='';b=document.createElement(d);for(d=0;d0?100*d/this.status.duration:0;if(typeof a.seekable==="object"&&a.seekable.length>0){e=this.status.duration>0?100*a.seekable.end(a.seekable.length-1)/this.status.duration:100;g=100*a.currentTime/a.seekable.end(a.seekable.length-1)}else{e=100;g=f}if(b)f=g=d=0;this.status.seekPercent=e;this.status.currentPercentRelative=g;this.status.currentPercentAbsolute=f;this.status.currentTime=d},_resetStatus:function(){this.status=c.extend({},this.status,c.jPlayer.prototype.status)}, -_trigger:function(a,b,d){a=c.Event(a);a.jPlayer={};a.jPlayer.version=c.extend({},this.version);a.jPlayer.status=c.extend(true,{},this.status);a.jPlayer.html=c.extend(true,{},this.html);a.jPlayer.flash=c.extend(true,{},this.flash);if(b)a.jPlayer.error=c.extend({},b);if(d)a.jPlayer.warning=c.extend({},d);this.element.trigger(a)},jPlayerFlashEvent:function(a,b){if(a===c.jPlayer.event.ready&&!this.internal.ready){this.internal.ready=true;this.version.flash=b.version;this.version.needFlash!==this.version.flash&& -this._error({type:c.jPlayer.error.VERSION,context:this.version.flash,message:c.jPlayer.errorMsg.VERSION+this.version.flash,hint:c.jPlayer.errorHint.VERSION});this._trigger(a)}if(this.flash.gate)switch(a){case c.jPlayer.event.progress:this._getFlashStatus(b);this._updateInterface();this._trigger(a);break;case c.jPlayer.event.timeupdate:this._getFlashStatus(b);this._updateInterface();this._trigger(a);break;case c.jPlayer.event.play:this._seeked();this._updateButtons(true);this._trigger(a);break;case c.jPlayer.event.pause:this._updateButtons(false); -this._trigger(a);break;case c.jPlayer.event.ended:this._updateButtons(false);this._trigger(a);break;case c.jPlayer.event.error:this.status.waitForLoad=true;this.status.waitForPlay=true;this.status.video&&this.internal.flash.jq.css({width:"0px",height:"0px"});this._validString(this.status.media.poster)&&this.internal.poster.jq.show();this.css.jq.videoPlay.length&&this.css.jq.videoPlay.show();this.status.video?this._flash_setVideo(this.status.media):this._flash_setAudio(this.status.media);this._error({type:c.jPlayer.error.URL, -context:b.src,message:c.jPlayer.errorMsg.URL,hint:c.jPlayer.errorHint.URL});break;case c.jPlayer.event.seeking:this._seeking();this._trigger(a);break;case c.jPlayer.event.seeked:this._seeked();this._trigger(a);break;default:this._trigger(a)}return false},_getFlashStatus:function(a){this.status.seekPercent=a.seekPercent;this.status.currentPercentRelative=a.currentPercentRelative;this.status.currentPercentAbsolute=a.currentPercentAbsolute;this.status.currentTime=a.currentTime;this.status.duration=a.duration}, -_updateButtons:function(a){this.status.paused=!a;if(this.css.jq.play.length&&this.css.jq.pause.length)if(a){this.css.jq.play.hide();this.css.jq.pause.show()}else{this.css.jq.play.show();this.css.jq.pause.hide()}},_updateInterface:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.width(this.status.seekPercent+"%");this.css.jq.playBar.length&&this.css.jq.playBar.width(this.status.currentPercentRelative+"%");this.css.jq.currentTime.length&&this.css.jq.currentTime.text(c.jPlayer.convertTime(this.status.currentTime)); -this.css.jq.duration.length&&this.css.jq.duration.text(c.jPlayer.convertTime(this.status.duration))},_seeking:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.addClass("jp-seeking-bg")},_seeked:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.removeClass("jp-seeking-bg")},setMedia:function(a){var b=this;this._seeked();clearTimeout(this.internal.htmlDlyCmdId);var d=this.html.audio.gate,f=this.html.video.gate,e=false;c.each(this.formats,function(g,i){var j=b.format[i].media==="video"; -c.each(b.solutions,function(n,k){if(b[k].support[i]&&b._validString(a[i])){var l=k==="html";if(j)if(l){b.html.audio.gate=false;b.html.video.gate=true;b.flash.gate=false}else{b.html.audio.gate=false;b.html.video.gate=false;b.flash.gate=true}else if(l){b.html.audio.gate=true;b.html.video.gate=false;b.flash.gate=false}else{b.html.audio.gate=false;b.html.video.gate=false;b.flash.gate=true}if(b.flash.active||b.html.active&&b.flash.gate||d===b.html.audio.gate&&f===b.html.video.gate)b.clearMedia();else if(d!== -b.html.audio.gate&&f!==b.html.video.gate){b._html_pause();b.status.video&&b.internal.video.jq.css({width:"0px",height:"0px"});b._resetStatus()}if(j){if(l){b._html_setVideo(a);b.html.active=true;b.flash.active=false}else{b._flash_setVideo(a);b.html.active=false;b.flash.active=true}b.css.jq.videoPlay.length&&b.css.jq.videoPlay.show();b.status.video=true}else{if(l){b._html_setAudio(a);b.html.active=true;b.flash.active=false}else{b._flash_setAudio(a);b.html.active=false;b.flash.active=true}b.css.jq.videoPlay.length&& -b.css.jq.videoPlay.hide();b.status.video=false}e=true;return false}});if(e)return false});if(e){if(this._validString(a.poster))if(this.htmlElement.poster.src!==a.poster)this.htmlElement.poster.src=a.poster;else this.internal.poster.jq.show();else this.internal.poster.jq.hide();this.status.srcSet=true;this.status.media=c.extend({},a);this._updateButtons(false);this._updateInterface()}else{this.status.srcSet&&!this.status.waitForPlay&&this.pause();this.html.audio.gate=false;this.html.video.gate=false; -this.flash.gate=false;this.html.active=false;this.flash.active=false;this._resetStatus();this._updateInterface();this._updateButtons(false);this.internal.poster.jq.hide();this.html.used&&this.require.video&&this.internal.video.jq.css({width:"0px",height:"0px"});this.flash.used&&this.internal.flash.jq.css({width:"0px",height:"0px"});this._error({type:c.jPlayer.error.NO_SUPPORT,context:"{supplied:'"+this.options.supplied+"'}",message:c.jPlayer.errorMsg.NO_SUPPORT,hint:c.jPlayer.errorHint.NO_SUPPORT})}}, -clearMedia:function(){this._resetStatus();this._updateButtons(false);this.internal.poster.jq.hide();clearTimeout(this.internal.htmlDlyCmdId);if(this.html.active)this._html_clearMedia();else this.flash.active&&this._flash_clearMedia()},load:function(){if(this.status.srcSet)if(this.html.active)this._html_load();else this.flash.active&&this._flash_load();else this._urlNotSetError("load")},play:function(a){a=typeof a==="number"?a:NaN;if(this.status.srcSet)if(this.html.active)this._html_play(a);else this.flash.active&& -this._flash_play(a);else this._urlNotSetError("play")},videoPlay:function(){this.play()},pause:function(a){a=typeof a==="number"?a:NaN;if(this.status.srcSet)if(this.html.active)this._html_pause(a);else this.flash.active&&this._flash_pause(a);else this._urlNotSetError("pause")},pauseOthers:function(){var a=this;c.each(this.instances,function(b,d){a.element!==d&&d.data("jPlayer").status.srcSet&&d.jPlayer("pause")})},stop:function(){if(this.status.srcSet)if(this.html.active)this._html_pause(0);else this.flash.active&& -this._flash_pause(0);else this._urlNotSetError("stop")},playHead:function(a){a=this._limitValue(a,0,100);if(this.status.srcSet)if(this.html.active)this._html_playHead(a);else this.flash.active&&this._flash_playHead(a);else this._urlNotSetError("playHead")},mute:function(){this.status.muted=true;this.html.used&&this._html_mute(true);this.flash.used&&this._flash_mute(true);this._updateMute(true);this._updateVolume(0);this._trigger(c.jPlayer.event.volumechange)},unmute:function(){this.status.muted=false; -this.html.used&&this._html_mute(false);this.flash.used&&this._flash_mute(false);this._updateMute(false);this._updateVolume(this.status.volume);this._trigger(c.jPlayer.event.volumechange)},_updateMute:function(a){if(this.css.jq.mute.length&&this.css.jq.unmute.length)if(a){this.css.jq.mute.hide();this.css.jq.unmute.show()}else{this.css.jq.mute.show();this.css.jq.unmute.hide()}},volume:function(a){a=this._limitValue(a,0,1);this.status.volume=a;this.html.used&&this._html_volume(a);this.flash.used&&this._flash_volume(a); -this.status.muted||this._updateVolume(a);this._trigger(c.jPlayer.event.volumechange)},volumeBar:function(a){if(!this.status.muted&&this.css.jq.volumeBar){var b=this.css.jq.volumeBar.offset();a=a.pageX-b.left;b=this.css.jq.volumeBar.width();this.volume(a/b)}},volumeBarValue:function(a){this.volumeBar(a)},_updateVolume:function(a){this.css.jq.volumeBarValue.length&&this.css.jq.volumeBarValue.width(a*100+"%")},_volumeFix:function(a){var b=0.0010*Math.random();return a+(a<0.5?b:-b)},_cssSelectorAncestor:function(a, -b){this.options.cssSelectorAncestor=a;b&&c.each(this.options.cssSelector,function(d,f){self._cssSelector(d,f)})},_cssSelector:function(a,b){var d=this;if(typeof b==="string")if(c.jPlayer.prototype.options.cssSelector[a]){this.css.jq[a]&&this.css.jq[a].length&&this.css.jq[a].unbind(".jPlayer");this.options.cssSelector[a]=b;this.css.cs[a]=this.options.cssSelectorAncestor+" "+b;this.css.jq[a]=b?c(this.css.cs[a]):[];this.css.jq[a].length&&this.css.jq[a].bind("click.jPlayer",function(f){d[a](f);c(this).blur(); -return false});b&&this.css.jq[a].length!==1&&this._warning({type:c.jPlayer.warning.CSS_SELECTOR_COUNT,context:this.css.cs[a],message:c.jPlayer.warningMsg.CSS_SELECTOR_COUNT+this.css.jq[a].length+" found for "+a+" method.",hint:c.jPlayer.warningHint.CSS_SELECTOR_COUNT})}else this._warning({type:c.jPlayer.warning.CSS_SELECTOR_METHOD,context:a,message:c.jPlayer.warningMsg.CSS_SELECTOR_METHOD,hint:c.jPlayer.warningHint.CSS_SELECTOR_METHOD});else this._warning({type:c.jPlayer.warning.CSS_SELECTOR_STRING, -context:b,message:c.jPlayer.warningMsg.CSS_SELECTOR_STRING,hint:c.jPlayer.warningHint.CSS_SELECTOR_STRING})},seekBar:function(a){if(this.css.jq.seekBar){var b=this.css.jq.seekBar.offset();a=a.pageX-b.left;b=this.css.jq.seekBar.width();this.playHead(100*a/b)}},playBar:function(a){this.seekBar(a)},currentTime:function(){},duration:function(){},option:function(a,b){var d=a;if(arguments.length===0)return c.extend(true,{},this.options);if(typeof a==="string"){var f=a.split(".");if(b===h){for(var e=c.extend(true, -{},this.options),g=0;g=9||this.htmlElement.media.load()}},_html_load:function(){if(this.status.waitForLoad){this.status.waitForLoad=false;this.htmlElement.media.src=this.status.src; -try{this.htmlElement.media.load()}catch(a){}}clearTimeout(this.internal.htmlDlyCmdId)},_html_play:function(a){var b=this;this._html_load();this.htmlElement.media.play();if(!isNaN(a))try{this.htmlElement.media.currentTime=a}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.play(a)},100);return}this._html_checkWaitForPlay()},_html_pause:function(a){var b=this;a>0?this._html_load():clearTimeout(this.internal.htmlDlyCmdId);this.htmlElement.media.pause();if(!isNaN(a))try{this.htmlElement.media.currentTime= -a}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.pause(a)},100);return}a>0&&this._html_checkWaitForPlay()},_html_playHead:function(a){var b=this;this._html_load();try{if(typeof this.htmlElement.media.seekable==="object"&&this.htmlElement.media.seekable.length>0)this.htmlElement.media.currentTime=a*this.htmlElement.media.seekable.end(this.htmlElement.media.seekable.length-1)/100;else if(this.htmlElement.media.duration>0&&!isNaN(this.htmlElement.media.duration))this.htmlElement.media.currentTime= -a*this.htmlElement.media.duration/100;else throw"e";}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.playHead(a)},100);return}this.status.waitForLoad||this._html_checkWaitForPlay()},_html_checkWaitForPlay:function(){if(this.status.waitForPlay){this.status.waitForPlay=false;this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide();if(this.status.video){this.internal.poster.jq.hide();this.internal.video.jq.css({width:this.status.width,height:this.status.height})}}},_html_volume:function(a){if(this.html.audio.available)this.htmlElement.audio.volume= -a;if(this.html.video.available)this.htmlElement.video.volume=a},_html_mute:function(a){if(this.html.audio.available)this.htmlElement.audio.muted=a;if(this.html.video.available)this.htmlElement.video.muted=a},_flash_setAudio:function(a){var b=this;try{c.each(this.formats,function(f,e){if(b.flash.support[e]&&a[e]){switch(e){case "m4a":b._getMovie().fl_setAudio_m4a(a[e]);break;case "mp3":b._getMovie().fl_setAudio_mp3(a[e])}b.status.src=a[e];b.status.format[e]=true;b.status.formatType=e;return false}}); -if(this.options.preload==="auto"){this._flash_load();this.status.waitForLoad=false}}catch(d){this._flashError(d)}},_flash_setVideo:function(a){var b=this;try{c.each(this.formats,function(f,e){if(b.flash.support[e]&&a[e]){switch(e){case "m4v":b._getMovie().fl_setVideo_m4v(a[e])}b.status.src=a[e];b.status.format[e]=true;b.status.formatType=e;return false}});if(this.options.preload==="auto"){this._flash_load();this.status.waitForLoad=false}}catch(d){this._flashError(d)}},_flash_clearMedia:function(){this.internal.flash.jq.css({width:"0px", -height:"0px"});try{this._getMovie().fl_clearMedia()}catch(a){this._flashError(a)}},_flash_load:function(){try{this._getMovie().fl_load()}catch(a){this._flashError(a)}this.status.waitForLoad=false},_flash_play:function(a){try{this._getMovie().fl_play(a)}catch(b){this._flashError(b)}this.status.waitForLoad=false;this._flash_checkWaitForPlay()},_flash_pause:function(a){try{this._getMovie().fl_pause(a)}catch(b){this._flashError(b)}if(a>0){this.status.waitForLoad=false;this._flash_checkWaitForPlay()}}, -_flash_playHead:function(a){try{this._getMovie().fl_play_head(a)}catch(b){this._flashError(b)}this.status.waitForLoad||this._flash_checkWaitForPlay()},_flash_checkWaitForPlay:function(){if(this.status.waitForPlay){this.status.waitForPlay=false;this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide();if(this.status.video){this.internal.poster.jq.hide();this.internal.flash.jq.css({width:this.status.width,height:this.status.height})}}},_flash_volume:function(a){try{this._getMovie().fl_volume(a)}catch(b){this._flashError(b)}}, -_flash_mute:function(a){try{this._getMovie().fl_mute(a)}catch(b){this._flashError(b)}},_getMovie:function(){return document[this.internal.flash.id]},_checkForFlash:function(a){var b=false,d;if(window.ActiveXObject)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+a);b=true}catch(f){}else if(navigator.plugins&&navigator.mimeTypes.length>0)if(d=navigator.plugins["Shockwave Flash"])if(navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/,"$1")>=a)b=true;return c.browser.msie&& -Number(c.browser.version)>=9?false:b},_validString:function(a){return a&&typeof a==="string"},_limitValue:function(a,b,d){return ad?d:a},_urlNotSetError:function(a){this._error({type:c.jPlayer.error.URL_NOT_SET,context:a,message:c.jPlayer.errorMsg.URL_NOT_SET,hint:c.jPlayer.errorHint.URL_NOT_SET})},_flashError:function(a){this._error({type:c.jPlayer.error.FLASH,context:this.internal.flash.swf,message:c.jPlayer.errorMsg.FLASH+a.message,hint:c.jPlayer.errorHint.FLASH})},_error:function(a){this._trigger(c.jPlayer.event.error, -a);if(this.options.errorAlerts)this._alert("Error!"+(a.message?"\n\n"+a.message:"")+(a.hint?"\n\n"+a.hint:"")+"\n\nContext: "+a.context)},_warning:function(a){this._trigger(c.jPlayer.event.warning,h,a);if(this.options.errorAlerts)this._alert("Warning!"+(a.message?"\n\n"+a.message:"")+(a.hint?"\n\n"+a.hint:"")+"\n\nContext: "+a.context)},_alert:function(a){alert("jPlayer "+this.version.script+" : id='"+this.internal.self.id+"' : "+a)}};c.jPlayer.error={FLASH:"e_flash",NO_SOLUTION:"e_no_solution",NO_SUPPORT:"e_no_support", -URL:"e_url",URL_NOT_SET:"e_url_not_set",VERSION:"e_version"};c.jPlayer.errorMsg={FLASH:"jPlayer's Flash fallback is not configured correctly, or a command was issued before the jPlayer Ready event. Details: ",NO_SOLUTION:"No solution can be found by jPlayer in this browser. Neither HTML nor Flash can be used.",NO_SUPPORT:"It is not possible to play any media format provided in setMedia() on this browser using your current options.",URL:"Media URL could not be loaded.",URL_NOT_SET:"Attempt to issue media playback commands, while no media url is set.", -VERSION:"jPlayer "+c.jPlayer.prototype.version.script+" needs Jplayer.swf version "+c.jPlayer.prototype.version.needFlash+" but found "};c.jPlayer.errorHint={FLASH:"Check your swfPath option and that Jplayer.swf is there.",NO_SOLUTION:"Review the jPlayer options: support and supplied.",NO_SUPPORT:"Video or audio formats defined in the supplied option are missing.",URL:"Check media URL is valid.",URL_NOT_SET:"Use setMedia() to set the media URL.",VERSION:"Update jPlayer files."};c.jPlayer.warning= -{CSS_SELECTOR_COUNT:"e_css_selector_count",CSS_SELECTOR_METHOD:"e_css_selector_method",CSS_SELECTOR_STRING:"e_css_selector_string",OPTION_KEY:"e_option_key"};c.jPlayer.warningMsg={CSS_SELECTOR_COUNT:"The number of methodCssSelectors found did not equal one: ",CSS_SELECTOR_METHOD:"The methodName given in jPlayer('cssSelector') is not a valid jPlayer method.",CSS_SELECTOR_STRING:"The methodCssSelector given in jPlayer('cssSelector') is not a String or is empty.",OPTION_KEY:"The option requested in jPlayer('option') is undefined."}; -c.jPlayer.warningHint={CSS_SELECTOR_COUNT:"Check your css selector and the ancestor.",CSS_SELECTOR_METHOD:"Check your method name.",CSS_SELECTOR_STRING:"Check your css selector is a string.",OPTION_KEY:"Check your option name."}})(jQuery); diff --git a/game/dev/jquery-1.4.4.min.js b/game/dev/jquery-1.4.4.min.js deleted file mode 100644 index 8f3ca2e..0000000 --- a/game/dev/jquery-1.4.4.min.js +++ /dev/null @@ -1,167 +0,0 @@ -/*! - * jQuery JavaScript Library v1.4.4 - * http://jquery.com/ - * - * Copyright 2010, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * Copyright 2010, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * - * Date: Thu Nov 11 19:04:53 2010 -0500 - */ -(function(E,B){function ka(a,b,d){if(d===B&&a.nodeType===1){d=a.getAttribute("data-"+b);if(typeof d==="string"){try{d=d==="true"?true:d==="false"?false:d==="null"?null:!c.isNaN(d)?parseFloat(d):Ja.test(d)?c.parseJSON(d):d}catch(e){}c.data(a,b,d)}else d=B}return d}function U(){return false}function ca(){return true}function la(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function Ka(a){var b,d,e,f,h,l,k,o,x,r,A,C=[];f=[];h=c.data(this,this.nodeType?"events":"__events__");if(typeof h==="function")h= -h.events;if(!(a.liveFired===this||!h||!h.live||a.button&&a.type==="click")){if(a.namespace)A=RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)");a.liveFired=this;var J=h.live.slice(0);for(k=0;kd)break;a.currentTarget=f.elem;a.data=f.handleObj.data;a.handleObj=f.handleObj;A=f.handleObj.origHandler.apply(f.elem,arguments);if(A===false||a.isPropagationStopped()){d=f.level;if(A===false)b=false;if(a.isImmediatePropagationStopped())break}}return b}}function Y(a,b){return(a&&a!=="*"?a+".":"")+b.replace(La, -"`").replace(Ma,"&")}function ma(a,b,d){if(c.isFunction(b))return c.grep(a,function(f,h){return!!b.call(f,h,f)===d});else if(b.nodeType)return c.grep(a,function(f){return f===b===d});else if(typeof b==="string"){var e=c.grep(a,function(f){return f.nodeType===1});if(Na.test(b))return c.filter(b,e,!d);else b=c.filter(b,e)}return c.grep(a,function(f){return c.inArray(f,b)>=0===d})}function na(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var e=c.data(a[d++]),f=c.data(this, -e);if(e=e&&e.events){delete f.handle;f.events={};for(var h in e)for(var l in e[h])c.event.add(this,h,e[h][l],e[h][l].data)}}})}function Oa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function oa(a,b,d){var e=b==="width"?a.offsetWidth:a.offsetHeight;if(d==="border")return e;c.each(b==="width"?Pa:Qa,function(){d||(e-=parseFloat(c.css(a,"padding"+this))||0);if(d==="margin")e+=parseFloat(c.css(a, -"margin"+this))||0;else e-=parseFloat(c.css(a,"border"+this+"Width"))||0});return e}function da(a,b,d,e){if(c.isArray(b)&&b.length)c.each(b,function(f,h){d||Ra.test(a)?e(a,h):da(a+"["+(typeof h==="object"||c.isArray(h)?f:"")+"]",h,d,e)});else if(!d&&b!=null&&typeof b==="object")c.isEmptyObject(b)?e(a,""):c.each(b,function(f,h){da(a+"["+f+"]",h,d,e)});else e(a,b)}function S(a,b){var d={};c.each(pa.concat.apply([],pa.slice(0,b)),function(){d[this]=a});return d}function qa(a){if(!ea[a]){var b=c("<"+ -a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d==="")d="block";ea[a]=d}return ea[a]}function fa(a){return c.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var t=E.document,c=function(){function a(){if(!b.isReady){try{t.documentElement.doScroll("left")}catch(j){setTimeout(a,1);return}b.ready()}}var b=function(j,s){return new b.fn.init(j,s)},d=E.jQuery,e=E.$,f,h=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,l=/\S/,k=/^\s+/,o=/\s+$/,x=/\W/,r=/\d/,A=/^<(\w+)\s*\/?>(?:<\/\1>)?$/, -C=/^[\],:{}\s]*$/,J=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,w=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,I=/(?:^|:|,)(?:\s*\[)+/g,L=/(webkit)[ \/]([\w.]+)/,g=/(opera)(?:.*version)?[ \/]([\w.]+)/,i=/(msie) ([\w.]+)/,n=/(mozilla)(?:.*? rv:([\w.]+))?/,m=navigator.userAgent,p=false,q=[],u,y=Object.prototype.toString,F=Object.prototype.hasOwnProperty,M=Array.prototype.push,N=Array.prototype.slice,O=String.prototype.trim,D=Array.prototype.indexOf,R={};b.fn=b.prototype={init:function(j, -s){var v,z,H;if(!j)return this;if(j.nodeType){this.context=this[0]=j;this.length=1;return this}if(j==="body"&&!s&&t.body){this.context=t;this[0]=t.body;this.selector="body";this.length=1;return this}if(typeof j==="string")if((v=h.exec(j))&&(v[1]||!s))if(v[1]){H=s?s.ownerDocument||s:t;if(z=A.exec(j))if(b.isPlainObject(s)){j=[t.createElement(z[1])];b.fn.attr.call(j,s,true)}else j=[H.createElement(z[1])];else{z=b.buildFragment([v[1]],[H]);j=(z.cacheable?z.fragment.cloneNode(true):z.fragment).childNodes}return b.merge(this, -j)}else{if((z=t.getElementById(v[2]))&&z.parentNode){if(z.id!==v[2])return f.find(j);this.length=1;this[0]=z}this.context=t;this.selector=j;return this}else if(!s&&!x.test(j)){this.selector=j;this.context=t;j=t.getElementsByTagName(j);return b.merge(this,j)}else return!s||s.jquery?(s||f).find(j):b(s).find(j);else if(b.isFunction(j))return f.ready(j);if(j.selector!==B){this.selector=j.selector;this.context=j.context}return b.makeArray(j,this)},selector:"",jquery:"1.4.4",length:0,size:function(){return this.length}, -toArray:function(){return N.call(this,0)},get:function(j){return j==null?this.toArray():j<0?this.slice(j)[0]:this[j]},pushStack:function(j,s,v){var z=b();b.isArray(j)?M.apply(z,j):b.merge(z,j);z.prevObject=this;z.context=this.context;if(s==="find")z.selector=this.selector+(this.selector?" ":"")+v;else if(s)z.selector=this.selector+"."+s+"("+v+")";return z},each:function(j,s){return b.each(this,j,s)},ready:function(j){b.bindReady();if(b.isReady)j.call(t,b);else q&&q.push(j);return this},eq:function(j){return j=== --1?this.slice(j):this.slice(j,+j+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(N.apply(this,arguments),"slice",N.call(arguments).join(","))},map:function(j){return this.pushStack(b.map(this,function(s,v){return j.call(s,v,s)}))},end:function(){return this.prevObject||b(null)},push:M,sort:[].sort,splice:[].splice};b.fn.init.prototype=b.fn;b.extend=b.fn.extend=function(){var j,s,v,z,H,G=arguments[0]||{},K=1,Q=arguments.length,ga=false; -if(typeof G==="boolean"){ga=G;G=arguments[1]||{};K=2}if(typeof G!=="object"&&!b.isFunction(G))G={};if(Q===K){G=this;--K}for(;K0))if(q){var s=0,v=q;for(q=null;j=v[s++];)j.call(t,b);b.fn.trigger&&b(t).trigger("ready").unbind("ready")}}},bindReady:function(){if(!p){p=true;if(t.readyState==="complete")return setTimeout(b.ready,1);if(t.addEventListener){t.addEventListener("DOMContentLoaded",u,false);E.addEventListener("load",b.ready,false)}else if(t.attachEvent){t.attachEvent("onreadystatechange",u);E.attachEvent("onload", -b.ready);var j=false;try{j=E.frameElement==null}catch(s){}t.documentElement.doScroll&&j&&a()}}},isFunction:function(j){return b.type(j)==="function"},isArray:Array.isArray||function(j){return b.type(j)==="array"},isWindow:function(j){return j&&typeof j==="object"&&"setInterval"in j},isNaN:function(j){return j==null||!r.test(j)||isNaN(j)},type:function(j){return j==null?String(j):R[y.call(j)]||"object"},isPlainObject:function(j){if(!j||b.type(j)!=="object"||j.nodeType||b.isWindow(j))return false;if(j.constructor&& -!F.call(j,"constructor")&&!F.call(j.constructor.prototype,"isPrototypeOf"))return false;for(var s in j);return s===B||F.call(j,s)},isEmptyObject:function(j){for(var s in j)return false;return true},error:function(j){throw j;},parseJSON:function(j){if(typeof j!=="string"||!j)return null;j=b.trim(j);if(C.test(j.replace(J,"@").replace(w,"]").replace(I,"")))return E.JSON&&E.JSON.parse?E.JSON.parse(j):(new Function("return "+j))();else b.error("Invalid JSON: "+j)},noop:function(){},globalEval:function(j){if(j&& -l.test(j)){var s=t.getElementsByTagName("head")[0]||t.documentElement,v=t.createElement("script");v.type="text/javascript";if(b.support.scriptEval)v.appendChild(t.createTextNode(j));else v.text=j;s.insertBefore(v,s.firstChild);s.removeChild(v)}},nodeName:function(j,s){return j.nodeName&&j.nodeName.toUpperCase()===s.toUpperCase()},each:function(j,s,v){var z,H=0,G=j.length,K=G===B||b.isFunction(j);if(v)if(K)for(z in j){if(s.apply(j[z],v)===false)break}else for(;H
a";var f=d.getElementsByTagName("*"),h=d.getElementsByTagName("a")[0],l=t.createElement("select"), -k=l.appendChild(t.createElement("option"));if(!(!f||!f.length||!h)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(h.getAttribute("style")),hrefNormalized:h.getAttribute("href")==="/a",opacity:/^0.55$/.test(h.style.opacity),cssFloat:!!h.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:k.selected,deleteExpando:true,optDisabled:false,checkClone:false, -scriptEval:false,noCloneEvent:true,boxModel:null,inlineBlockNeedsLayout:false,shrinkWrapBlocks:false,reliableHiddenOffsets:true};l.disabled=true;c.support.optDisabled=!k.disabled;b.type="text/javascript";try{b.appendChild(t.createTextNode("window."+e+"=1;"))}catch(o){}a.insertBefore(b,a.firstChild);if(E[e]){c.support.scriptEval=true;delete E[e]}try{delete b.test}catch(x){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function r(){c.support.noCloneEvent= -false;d.detachEvent("onclick",r)});d.cloneNode(true).fireEvent("onclick")}d=t.createElement("div");d.innerHTML="";a=t.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var r=t.createElement("div");r.style.width=r.style.paddingLeft="1px";t.body.appendChild(r);c.boxModel=c.support.boxModel=r.offsetWidth===2;if("zoom"in r.style){r.style.display="inline";r.style.zoom= -1;c.support.inlineBlockNeedsLayout=r.offsetWidth===2;r.style.display="";r.innerHTML="
";c.support.shrinkWrapBlocks=r.offsetWidth!==2}r.innerHTML="
t
";var A=r.getElementsByTagName("td");c.support.reliableHiddenOffsets=A[0].offsetHeight===0;A[0].style.display="";A[1].style.display="none";c.support.reliableHiddenOffsets=c.support.reliableHiddenOffsets&&A[0].offsetHeight===0;r.innerHTML="";t.body.removeChild(r).style.display= -"none"});a=function(r){var A=t.createElement("div");r="on"+r;var C=r in A;if(!C){A.setAttribute(r,"return;");C=typeof A[r]==="function"}return C};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=f=h=null}})();var ra={},Ja=/^(?:\{.*\}|\[.*\])$/;c.extend({cache:{},uuid:0,expando:"jQuery"+c.now(),noData:{embed:true,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:true},data:function(a,b,d){if(c.acceptData(a)){a=a==E?ra:a;var e=a.nodeType,f=e?a[c.expando]:null,h= -c.cache;if(!(e&&!f&&typeof b==="string"&&d===B)){if(e)f||(a[c.expando]=f=++c.uuid);else h=a;if(typeof b==="object")if(e)h[f]=c.extend(h[f],b);else c.extend(h,b);else if(e&&!h[f])h[f]={};a=e?h[f]:h;if(d!==B)a[b]=d;return typeof b==="string"?a[b]:a}}},removeData:function(a,b){if(c.acceptData(a)){a=a==E?ra:a;var d=a.nodeType,e=d?a[c.expando]:a,f=c.cache,h=d?f[e]:e;if(b){if(h){delete h[b];d&&c.isEmptyObject(h)&&c.removeData(a)}}else if(d&&c.support.deleteExpando)delete a[c.expando];else if(a.removeAttribute)a.removeAttribute(c.expando); -else if(d)delete f[e];else for(var l in a)delete a[l]}},acceptData:function(a){if(a.nodeName){var b=c.noData[a.nodeName.toLowerCase()];if(b)return!(b===true||a.getAttribute("classid")!==b)}return true}});c.fn.extend({data:function(a,b){var d=null;if(typeof a==="undefined"){if(this.length){var e=this[0].attributes,f;d=c.data(this[0]);for(var h=0,l=e.length;h-1)return true;return false},val:function(a){if(!arguments.length){var b=this[0];if(b){if(c.nodeName(b,"option")){var d=b.attributes.value;return!d||d.specified?b.value:b.text}if(c.nodeName(b,"select")){var e=b.selectedIndex;d=[];var f=b.options;b=b.type==="select-one"; -if(e<0)return null;var h=b?e:0;for(e=b?e+1:f.length;h=0;else if(c.nodeName(this,"select")){var A=c.makeArray(r);c("option",this).each(function(){this.selected=c.inArray(c(this).val(),A)>=0});if(!A.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true}, -attr:function(a,b,d,e){if(!a||a.nodeType===3||a.nodeType===8)return B;if(e&&b in c.attrFn)return c(a)[b](d);e=a.nodeType!==1||!c.isXMLDoc(a);var f=d!==B;b=e&&c.props[b]||b;var h=Ta.test(b);if((b in a||a[b]!==B)&&e&&!h){if(f){b==="type"&&Ua.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");if(d===null)a.nodeType===1&&a.removeAttribute(b);else a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&& -b.specified?b.value:Va.test(a.nodeName)||Wa.test(a.nodeName)&&a.href?0:B;return a[b]}if(!c.support.style&&e&&b==="style"){if(f)a.style.cssText=""+d;return a.style.cssText}f&&a.setAttribute(b,""+d);if(!a.attributes[b]&&a.hasAttribute&&!a.hasAttribute(b))return B;a=!c.support.hrefNormalized&&e&&h?a.getAttribute(b,2):a.getAttribute(b);return a===null?B:a}});var X=/\.(.*)$/,ia=/^(?:textarea|input|select)$/i,La=/\./g,Ma=/ /g,Xa=/[^\w\s.|`]/g,Ya=function(a){return a.replace(Xa,"\\$&")},ua={focusin:0,focusout:0}; -c.event={add:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(c.isWindow(a)&&a!==E&&!a.frameElement)a=E;if(d===false)d=U;else if(!d)return;var f,h;if(d.handler){f=d;d=f.handler}if(!d.guid)d.guid=c.guid++;if(h=c.data(a)){var l=a.nodeType?"events":"__events__",k=h[l],o=h.handle;if(typeof k==="function"){o=k.handle;k=k.events}else if(!k){a.nodeType||(h[l]=h=function(){});h.events=k={}}if(!o)h.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem, -arguments):B};o.elem=a;b=b.split(" ");for(var x=0,r;l=b[x++];){h=f?c.extend({},f):{handler:d,data:e};if(l.indexOf(".")>-1){r=l.split(".");l=r.shift();h.namespace=r.slice(0).sort().join(".")}else{r=[];h.namespace=""}h.type=l;if(!h.guid)h.guid=d.guid;var A=k[l],C=c.event.special[l]||{};if(!A){A=k[l]=[];if(!C.setup||C.setup.call(a,e,r,o)===false)if(a.addEventListener)a.addEventListener(l,o,false);else a.attachEvent&&a.attachEvent("on"+l,o)}if(C.add){C.add.call(a,h);if(!h.handler.guid)h.handler.guid= -d.guid}A.push(h);c.event.global[l]=true}a=null}}},global:{},remove:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(d===false)d=U;var f,h,l=0,k,o,x,r,A,C,J=a.nodeType?"events":"__events__",w=c.data(a),I=w&&w[J];if(w&&I){if(typeof I==="function"){w=I;I=I.events}if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(f in I)c.event.remove(a,f+b)}else{for(b=b.split(" ");f=b[l++];){r=f;k=f.indexOf(".")<0;o=[];if(!k){o=f.split(".");f=o.shift();x=RegExp("(^|\\.)"+ -c.map(o.slice(0).sort(),Ya).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(A=I[f])if(d){r=c.event.special[f]||{};for(h=e||0;h=0){a.type=f=f.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[f]&&c.each(c.cache,function(){this.events&&this.events[f]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType=== -8)return B;a.result=B;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(e=d.nodeType?c.data(d,"handle"):(c.data(d,"__events__")||{}).handle)&&e.apply(d,b);e=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+f]&&d["on"+f].apply(d,b)===false){a.result=false;a.preventDefault()}}catch(h){}if(!a.isPropagationStopped()&&e)c.event.trigger(a,b,e,true);else if(!a.isDefaultPrevented()){var l;e=a.target;var k=f.replace(X,""),o=c.nodeName(e,"a")&&k=== -"click",x=c.event.special[k]||{};if((!x._default||x._default.call(d,a)===false)&&!o&&!(e&&e.nodeName&&c.noData[e.nodeName.toLowerCase()])){try{if(e[k]){if(l=e["on"+k])e["on"+k]=null;c.event.triggered=true;e[k]()}}catch(r){}if(l)e["on"+k]=l;c.event.triggered=false}}},handle:function(a){var b,d,e,f;d=[];var h=c.makeArray(arguments);a=h[0]=c.event.fix(a||E.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;if(!b){e=a.type.split(".");a.type=e.shift();d=e.slice(0).sort();e=RegExp("(^|\\.)"+ -d.join("\\.(?:.*\\.)?")+"(\\.|$)")}a.namespace=a.namespace||d.join(".");f=c.data(this,this.nodeType?"events":"__events__");if(typeof f==="function")f=f.events;d=(f||{})[a.type];if(f&&d){d=d.slice(0);f=0;for(var l=d.length;f-1?c.map(a.options,function(e){return e.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},Z=function(a,b){var d=a.target,e,f;if(!(!ia.test(d.nodeName)||d.readOnly)){e=c.data(d,"_change_data");f=xa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",f);if(!(e===B||f===e))if(e!=null||f){a.type="change";a.liveFired= -B;return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:Z,beforedeactivate:Z,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return Z.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return Z.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,"_change_data",xa(a))}},setup:function(){if(this.type=== -"file")return false;for(var a in V)c.event.add(this,a+".specialChange",V[a]);return ia.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return ia.test(this.nodeName)}};V=c.event.special.change.filters;V.focus=V.beforeactivate}t.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.trigger(e,null,e.target)}c.event.special[b]={setup:function(){ua[b]++===0&&t.addEventListener(a,d,true)},teardown:function(){--ua[b]=== -0&&t.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,e,f){if(typeof d==="object"){for(var h in d)this[b](h,e,d[h],f);return this}if(c.isFunction(e)||e===false){f=e;e=B}var l=b==="one"?c.proxy(f,function(o){c(this).unbind(o,l);return f.apply(this,arguments)}):f;if(d==="unload"&&b!=="one")this.one(d,e,f);else{h=0;for(var k=this.length;h0?this.bind(b,d,e):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});E.attachEvent&&!E.addEventListener&&c(E).bind("unload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}}); -(function(){function a(g,i,n,m,p,q){p=0;for(var u=m.length;p0){F=y;break}}y=y[g]}m[p]=F}}}var d=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,f=Object.prototype.toString,h=false,l=true;[0,0].sort(function(){l=false;return 0});var k=function(g,i,n,m){n=n||[];var p=i=i||t;if(i.nodeType!==1&&i.nodeType!==9)return[];if(!g||typeof g!=="string")return n;var q,u,y,F,M,N=true,O=k.isXML(i),D=[],R=g;do{d.exec("");if(q=d.exec(R)){R=q[3];D.push(q[1]);if(q[2]){F=q[3]; -break}}}while(q);if(D.length>1&&x.exec(g))if(D.length===2&&o.relative[D[0]])u=L(D[0]+D[1],i);else for(u=o.relative[D[0]]?[i]:k(D.shift(),i);D.length;){g=D.shift();if(o.relative[g])g+=D.shift();u=L(g,u)}else{if(!m&&D.length>1&&i.nodeType===9&&!O&&o.match.ID.test(D[0])&&!o.match.ID.test(D[D.length-1])){q=k.find(D.shift(),i,O);i=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]}if(i){q=m?{expr:D.pop(),set:C(m)}:k.find(D.pop(),D.length===1&&(D[0]==="~"||D[0]==="+")&&i.parentNode?i.parentNode:i,O);u=q.expr?k.filter(q.expr, -q.set):q.set;if(D.length>0)y=C(u);else N=false;for(;D.length;){q=M=D.pop();if(o.relative[M])q=D.pop();else M="";if(q==null)q=i;o.relative[M](y,q,O)}}else y=[]}y||(y=u);y||k.error(M||g);if(f.call(y)==="[object Array]")if(N)if(i&&i.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&k.contains(i,y[g])))n.push(u[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&n.push(u[g]);else n.push.apply(n,y);else C(y,n);if(F){k(F,p,n,m);k.uniqueSort(n)}return n};k.uniqueSort=function(g){if(w){h= -l;g.sort(w);if(h)for(var i=1;i0};k.find=function(g,i,n){var m;if(!g)return[];for(var p=0,q=o.order.length;p":function(g,i){var n,m=typeof i==="string",p=0,q=g.length;if(m&&!/\W/.test(i))for(i=i.toLowerCase();p=0))n||m.push(u);else if(n)i[q]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var i=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=i[1]+(i[2]||1)-0;g[3]=i[3]-0}g[0]=e++;return g},ATTR:function(g,i,n, -m,p,q){i=g[1].replace(/\\/g,"");if(!q&&o.attrMap[i])g[1]=o.attrMap[i];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,i,n,m,p){if(g[1]==="not")if((d.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,i);else{g=k.filter(g[3],i,n,true^p);n||m.push.apply(m,g);return false}else if(o.match.POS.test(g[0])||o.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled=== -true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,i,n){return!!k(n[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"=== -g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,i){return i===0},last:function(g,i,n,m){return i===m.length-1},even:function(g,i){return i%2===0},odd:function(g,i){return i%2===1},lt:function(g,i,n){return in[3]-0},nth:function(g,i,n){return n[3]- -0===i},eq:function(g,i,n){return n[3]-0===i}},filter:{PSEUDO:function(g,i,n,m){var p=i[1],q=o.filters[p];if(q)return q(g,n,i,m);else if(p==="contains")return(g.textContent||g.innerText||k.getText([g])||"").indexOf(i[3])>=0;else if(p==="not"){i=i[3];n=0;for(m=i.length;n=0}},ID:function(g,i){return g.nodeType===1&&g.getAttribute("id")===i},TAG:function(g,i){return i==="*"&&g.nodeType===1||g.nodeName.toLowerCase()=== -i},CLASS:function(g,i){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(i)>-1},ATTR:function(g,i){var n=i[1];n=o.attrHandle[n]?o.attrHandle[n](g):g[n]!=null?g[n]:g.getAttribute(n);var m=n+"",p=i[2],q=i[4];return n==null?p==="!=":p==="="?m===q:p==="*="?m.indexOf(q)>=0:p==="~="?(" "+m+" ").indexOf(q)>=0:!q?m&&n!==false:p==="!="?m!==q:p==="^="?m.indexOf(q)===0:p==="$="?m.substr(m.length-q.length)===q:p==="|="?m===q||m.substr(0,q.length+1)===q+"-":false},POS:function(g,i,n,m){var p=o.setFilters[i[2]]; -if(p)return p(g,n,i,m)}}},x=o.match.POS,r=function(g,i){return"\\"+(i-0+1)},A;for(A in o.match){o.match[A]=RegExp(o.match[A].source+/(?![^\[]*\])(?![^\(]*\))/.source);o.leftMatch[A]=RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[A].source.replace(/\\(\d+)/g,r))}var C=function(g,i){g=Array.prototype.slice.call(g,0);if(i){i.push.apply(i,g);return i}return g};try{Array.prototype.slice.call(t.documentElement.childNodes,0)}catch(J){C=function(g,i){var n=0,m=i||[];if(f.call(g)==="[object Array]")Array.prototype.push.apply(m, -g);else if(typeof g.length==="number")for(var p=g.length;n";n.insertBefore(g,n.firstChild);if(t.getElementById(i)){o.find.ID=function(m,p,q){if(typeof p.getElementById!=="undefined"&&!q)return(p=p.getElementById(m[1]))?p.id===m[1]||typeof p.getAttributeNode!=="undefined"&&p.getAttributeNode("id").nodeValue===m[1]?[p]:B:[]};o.filter.ID=function(m,p){var q=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&q&&q.nodeValue===p}}n.removeChild(g); -n=g=null})();(function(){var g=t.createElement("div");g.appendChild(t.createComment(""));if(g.getElementsByTagName("*").length>0)o.find.TAG=function(i,n){var m=n.getElementsByTagName(i[1]);if(i[1]==="*"){for(var p=[],q=0;m[q];q++)m[q].nodeType===1&&p.push(m[q]);m=p}return m};g.innerHTML="";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")o.attrHandle.href=function(i){return i.getAttribute("href",2)};g=null})();t.querySelectorAll&& -function(){var g=k,i=t.createElement("div");i.innerHTML="

";if(!(i.querySelectorAll&&i.querySelectorAll(".TEST").length===0)){k=function(m,p,q,u){p=p||t;m=m.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!u&&!k.isXML(p))if(p.nodeType===9)try{return C(p.querySelectorAll(m),q)}catch(y){}else if(p.nodeType===1&&p.nodeName.toLowerCase()!=="object"){var F=p.getAttribute("id"),M=F||"__sizzle__";F||p.setAttribute("id",M);try{return C(p.querySelectorAll("#"+M+" "+m),q)}catch(N){}finally{F|| -p.removeAttribute("id")}}return g(m,p,q,u)};for(var n in g)k[n]=g[n];i=null}}();(function(){var g=t.documentElement,i=g.matchesSelector||g.mozMatchesSelector||g.webkitMatchesSelector||g.msMatchesSelector,n=false;try{i.call(t.documentElement,"[test!='']:sizzle")}catch(m){n=true}if(i)k.matchesSelector=function(p,q){q=q.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(p))try{if(n||!o.match.PSEUDO.test(q)&&!/!=/.test(q))return i.call(p,q)}catch(u){}return k(q,null,null,[p]).length>0}})();(function(){var g= -t.createElement("div");g.innerHTML="
";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){o.order.splice(1,0,"CLASS");o.find.CLASS=function(i,n,m){if(typeof n.getElementsByClassName!=="undefined"&&!m)return n.getElementsByClassName(i[1])};g=null}}})();k.contains=t.documentElement.contains?function(g,i){return g!==i&&(g.contains?g.contains(i):true)}:t.documentElement.compareDocumentPosition? -function(g,i){return!!(g.compareDocumentPosition(i)&16)}:function(){return false};k.isXML=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false};var L=function(g,i){for(var n,m=[],p="",q=i.nodeType?[i]:i;n=o.match.PSEUDO.exec(g);){p+=n[0];g=g.replace(o.match.PSEUDO,"")}g=o.relative[g]?g+"*":g;n=0;for(var u=q.length;n0)for(var h=d;h0},closest:function(a,b){var d=[],e,f,h=this[0];if(c.isArray(a)){var l,k={},o=1;if(h&&a.length){e=0;for(f=a.length;e-1:c(h).is(e))d.push({selector:l,elem:h,level:o})}h= -h.parentNode;o++}}return d}l=cb.test(a)?c(a,b||this.context):null;e=0;for(f=this.length;e-1:c.find.matchesSelector(h,a)){d.push(h);break}else{h=h.parentNode;if(!h||!h.ownerDocument||h===b)break}d=d.length>1?c.unique(d):d;return this.pushStack(d,"closest",a)},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var d=typeof a==="string"?c(a,b||this.context): -c.makeArray(a),e=c.merge(this.get(),d);return this.pushStack(!d[0]||!d[0].parentNode||d[0].parentNode.nodeType===11||!e[0]||!e[0].parentNode||e[0].parentNode.nodeType===11?e:c.unique(e))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a, -2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a, -b){c.fn[a]=function(d,e){var f=c.map(this,b,d);Za.test(a)||(e=d);if(e&&typeof e==="string")f=c.filter(e,f);f=this.length>1?c.unique(f):f;if((this.length>1||ab.test(e))&&$a.test(a))f=f.reverse();return this.pushStack(f,a,bb.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return b.length===1?c.find.matchesSelector(b[0],a)?[b[0]]:[]:c.find.matches(a,b)},dir:function(a,b,d){var e=[];for(a=a[b];a&&a.nodeType!==9&&(d===B||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&& -e.push(a);a=a[b]}return e},nth:function(a,b,d){b=b||1;for(var e=0;a;a=a[d])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var za=/ jQuery\d+="(?:\d+|null)"/g,$=/^\s+/,Aa=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Ba=/<([\w:]+)/,db=/\s]+\/)>/g,P={option:[1, -""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};P.optgroup=P.option;P.tbody=P.tfoot=P.colgroup=P.caption=P.thead;P.th=P.td;if(!c.support.htmlSerialize)P._default=[1,"div
","
"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d= -c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==B)return this.empty().append((this[0]&&this[0].ownerDocument||t).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this}, -wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})}, -prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b, -this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,e;(e=this[d])!=null;d++)if(!a||c.filter(a,[e]).length){if(!b&&e.nodeType===1){c.cleanData(e.getElementsByTagName("*"));c.cleanData([e])}e.parentNode&&e.parentNode.removeChild(e)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild); -return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,e=this.ownerDocument;if(!d){d=e.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(za,"").replace(fb,'="$1">').replace($,"")],e)[0]}else return this.cloneNode(true)});if(a===true){na(this,b);na(this.find("*"),b.find("*"))}return b},html:function(a){if(a===B)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(za,""):null; -else if(typeof a==="string"&&!Ca.test(a)&&(c.support.leadingWhitespace||!$.test(a))&&!P[(Ba.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Aa,"<$1>");try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?h.cloneNode(true):h)}k.length&&c.each(k,Oa)}return this}});c.buildFragment=function(a,b,d){var e,f,h;b=b&&b[0]?b[0].ownerDocument||b[0]:t;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===t&&!Ca.test(a[0])&&(c.support.checkClone||!Da.test(a[0]))){f=true;if(h=c.fragments[a[0]])if(h!==1)e=h}if(!e){e=b.createDocumentFragment();c.clean(a,b,e,d)}if(f)c.fragments[a[0]]=h?e:1;return{fragment:e,cacheable:f}};c.fragments={};c.each({appendTo:"append", -prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var e=[];d=c(d);var f=this.length===1&&this[0].parentNode;if(f&&f.nodeType===11&&f.childNodes.length===1&&d.length===1){d[b](this[0]);return this}else{f=0;for(var h=d.length;f0?this.clone(true):this).get();c(d[f])[b](l);e=e.concat(l)}return this.pushStack(e,a,d.selector)}}});c.extend({clean:function(a,b,d,e){b=b||t;if(typeof b.createElement==="undefined")b=b.ownerDocument|| -b[0]&&b[0].ownerDocument||t;for(var f=[],h=0,l;(l=a[h])!=null;h++){if(typeof l==="number")l+="";if(l){if(typeof l==="string"&&!eb.test(l))l=b.createTextNode(l);else if(typeof l==="string"){l=l.replace(Aa,"<$1>");var k=(Ba.exec(l)||["",""])[1].toLowerCase(),o=P[k]||P._default,x=o[0],r=b.createElement("div");for(r.innerHTML=o[1]+l+o[2];x--;)r=r.lastChild;if(!c.support.tbody){x=db.test(l);k=k==="table"&&!x?r.firstChild&&r.firstChild.childNodes:o[1]===""&&!x?r.childNodes:[];for(o=k.length- -1;o>=0;--o)c.nodeName(k[o],"tbody")&&!k[o].childNodes.length&&k[o].parentNode.removeChild(k[o])}!c.support.leadingWhitespace&&$.test(l)&&r.insertBefore(b.createTextNode($.exec(l)[0]),r.firstChild);l=r.childNodes}if(l.nodeType)f.push(l);else f=c.merge(f,l)}}if(d)for(h=0;f[h];h++)if(e&&c.nodeName(f[h],"script")&&(!f[h].type||f[h].type.toLowerCase()==="text/javascript"))e.push(f[h].parentNode?f[h].parentNode.removeChild(f[h]):f[h]);else{f[h].nodeType===1&&f.splice.apply(f,[h+1,0].concat(c.makeArray(f[h].getElementsByTagName("script")))); -d.appendChild(f[h])}return f},cleanData:function(a){for(var b,d,e=c.cache,f=c.event.special,h=c.support.deleteExpando,l=0,k;(k=a[l])!=null;l++)if(!(k.nodeName&&c.noData[k.nodeName.toLowerCase()]))if(d=k[c.expando]){if((b=e[d])&&b.events)for(var o in b.events)f[o]?c.event.remove(k,o):c.removeEvent(k,o,b.handle);if(h)delete k[c.expando];else k.removeAttribute&&k.removeAttribute(c.expando);delete e[d]}}});var Ea=/alpha\([^)]*\)/i,gb=/opacity=([^)]*)/,hb=/-([a-z])/ig,ib=/([A-Z])/g,Fa=/^-?\d+(?:px)?$/i, -jb=/^-?\d/,kb={position:"absolute",visibility:"hidden",display:"block"},Pa=["Left","Right"],Qa=["Top","Bottom"],W,Ga,aa,lb=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){if(arguments.length===2&&b===B)return this;return c.access(this,a,b,true,function(d,e,f){return f!==B?c.style(d,e,f):c.css(d,e)})};c.extend({cssHooks:{opacity:{get:function(a,b){if(b){var d=W(a,"opacity","opacity");return d===""?"1":d}else return a.style.opacity}}},cssNumber:{zIndex:true,fontWeight:true,opacity:true, -zoom:true,lineHeight:true},cssProps:{"float":c.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,d,e){if(!(!a||a.nodeType===3||a.nodeType===8||!a.style)){var f,h=c.camelCase(b),l=a.style,k=c.cssHooks[h];b=c.cssProps[h]||h;if(d!==B){if(!(typeof d==="number"&&isNaN(d)||d==null)){if(typeof d==="number"&&!c.cssNumber[h])d+="px";if(!k||!("set"in k)||(d=k.set(a,d))!==B)try{l[b]=d}catch(o){}}}else{if(k&&"get"in k&&(f=k.get(a,false,e))!==B)return f;return l[b]}}},css:function(a,b,d){var e,f=c.camelCase(b), -h=c.cssHooks[f];b=c.cssProps[f]||f;if(h&&"get"in h&&(e=h.get(a,true,d))!==B)return e;else if(W)return W(a,b,f)},swap:function(a,b,d){var e={},f;for(f in b){e[f]=a.style[f];a.style[f]=b[f]}d.call(a);for(f in b)a.style[f]=e[f]},camelCase:function(a){return a.replace(hb,lb)}});c.curCSS=c.css;c.each(["height","width"],function(a,b){c.cssHooks[b]={get:function(d,e,f){var h;if(e){if(d.offsetWidth!==0)h=oa(d,b,f);else c.swap(d,kb,function(){h=oa(d,b,f)});if(h<=0){h=W(d,b,b);if(h==="0px"&&aa)h=aa(d,b,b); -if(h!=null)return h===""||h==="auto"?"0px":h}if(h<0||h==null){h=d.style[b];return h===""||h==="auto"?"0px":h}return typeof h==="string"?h:h+"px"}},set:function(d,e){if(Fa.test(e)){e=parseFloat(e);if(e>=0)return e+"px"}else return e}}});if(!c.support.opacity)c.cssHooks.opacity={get:function(a,b){return gb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var d=a.style;d.zoom=1;var e=c.isNaN(b)?"":"alpha(opacity="+b*100+")",f= -d.filter||"";d.filter=Ea.test(f)?f.replace(Ea,e):d.filter+" "+e}};if(t.defaultView&&t.defaultView.getComputedStyle)Ga=function(a,b,d){var e;d=d.replace(ib,"-$1").toLowerCase();if(!(b=a.ownerDocument.defaultView))return B;if(b=b.getComputedStyle(a,null)){e=b.getPropertyValue(d);if(e===""&&!c.contains(a.ownerDocument.documentElement,a))e=c.style(a,d)}return e};if(t.documentElement.currentStyle)aa=function(a,b){var d,e,f=a.currentStyle&&a.currentStyle[b],h=a.style;if(!Fa.test(f)&&jb.test(f)){d=h.left; -e=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;h.left=b==="fontSize"?"1em":f||0;f=h.pixelLeft+"px";h.left=d;a.runtimeStyle.left=e}return f===""?"auto":f};W=Ga||aa;if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetHeight;return a.offsetWidth===0&&b===0||!c.support.reliableHiddenOffsets&&(a.style.display||c.css(a,"display"))==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var mb=c.now(),nb=/)<[^<]*)*<\/script>/gi, -ob=/^(?:select|textarea)/i,pb=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,qb=/^(?:GET|HEAD)$/,Ra=/\[\]$/,T=/\=\?(&|$)/,ja=/\?/,rb=/([?&])_=[^&]*/,sb=/^(\w+:)?\/\/([^\/?#]+)/,tb=/%20/g,ub=/#.*$/,Ha=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!=="string"&&Ha)return Ha.apply(this,arguments);else if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var f=a.slice(e,a.length);a=a.slice(0,e)}e="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b=== -"object"){b=c.param(b,c.ajaxSettings.traditional);e="POST"}var h=this;c.ajax({url:a,type:e,dataType:"html",data:b,complete:function(l,k){if(k==="success"||k==="notmodified")h.html(f?c("
").append(l.responseText.replace(nb,"")).find(f):l.responseText);d&&h.each(d,[l.responseText,k,l])}});return this},serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&& -!this.disabled&&(this.checked||ob.test(this.nodeName)||pb.test(this.type))}).map(function(a,b){var d=c(this).val();return d==null?null:c.isArray(d)?c.map(d,function(e){return{name:b.name,value:e}}):{name:b.name,value:d}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:e})}, -getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:e})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return new E.XMLHttpRequest},accepts:{xml:"application/xml, text/xml",html:"text/html", -script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},ajax:function(a){var b=c.extend(true,{},c.ajaxSettings,a),d,e,f,h=b.type.toUpperCase(),l=qb.test(h);b.url=b.url.replace(ub,"");b.context=a&&a.context!=null?a.context:b;if(b.data&&b.processData&&typeof b.data!=="string")b.data=c.param(b.data,b.traditional);if(b.dataType==="jsonp"){if(h==="GET")T.test(b.url)||(b.url+=(ja.test(b.url)?"&":"?")+(b.jsonp||"callback")+"=?");else if(!b.data|| -!T.test(b.data))b.data=(b.data?b.data+"&":"")+(b.jsonp||"callback")+"=?";b.dataType="json"}if(b.dataType==="json"&&(b.data&&T.test(b.data)||T.test(b.url))){d=b.jsonpCallback||"jsonp"+mb++;if(b.data)b.data=(b.data+"").replace(T,"="+d+"$1");b.url=b.url.replace(T,"="+d+"$1");b.dataType="script";var k=E[d];E[d]=function(m){if(c.isFunction(k))k(m);else{E[d]=B;try{delete E[d]}catch(p){}}f=m;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);r&&r.removeChild(A)}}if(b.dataType==="script"&&b.cache===null)b.cache= -false;if(b.cache===false&&l){var o=c.now(),x=b.url.replace(rb,"$1_="+o);b.url=x+(x===b.url?(ja.test(b.url)?"&":"?")+"_="+o:"")}if(b.data&&l)b.url+=(ja.test(b.url)?"&":"?")+b.data;b.global&&c.active++===0&&c.event.trigger("ajaxStart");o=(o=sb.exec(b.url))&&(o[1]&&o[1].toLowerCase()!==location.protocol||o[2].toLowerCase()!==location.host);if(b.dataType==="script"&&h==="GET"&&o){var r=t.getElementsByTagName("head")[0]||t.documentElement,A=t.createElement("script");if(b.scriptCharset)A.charset=b.scriptCharset; -A.src=b.url;if(!d){var C=false;A.onload=A.onreadystatechange=function(){if(!C&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){C=true;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);A.onload=A.onreadystatechange=null;r&&A.parentNode&&r.removeChild(A)}}}r.insertBefore(A,r.firstChild);return B}var J=false,w=b.xhr();if(w){b.username?w.open(h,b.url,b.async,b.username,b.password):w.open(h,b.url,b.async);try{if(b.data!=null&&!l||a&&a.contentType)w.setRequestHeader("Content-Type", -b.contentType);if(b.ifModified){c.lastModified[b.url]&&w.setRequestHeader("If-Modified-Since",c.lastModified[b.url]);c.etag[b.url]&&w.setRequestHeader("If-None-Match",c.etag[b.url])}o||w.setRequestHeader("X-Requested-With","XMLHttpRequest");w.setRequestHeader("Accept",b.dataType&&b.accepts[b.dataType]?b.accepts[b.dataType]+", */*; q=0.01":b.accepts._default)}catch(I){}if(b.beforeSend&&b.beforeSend.call(b.context,w,b)===false){b.global&&c.active--===1&&c.event.trigger("ajaxStop");w.abort();return false}b.global&& -c.triggerGlobal(b,"ajaxSend",[w,b]);var L=w.onreadystatechange=function(m){if(!w||w.readyState===0||m==="abort"){J||c.handleComplete(b,w,e,f);J=true;if(w)w.onreadystatechange=c.noop}else if(!J&&w&&(w.readyState===4||m==="timeout")){J=true;w.onreadystatechange=c.noop;e=m==="timeout"?"timeout":!c.httpSuccess(w)?"error":b.ifModified&&c.httpNotModified(w,b.url)?"notmodified":"success";var p;if(e==="success")try{f=c.httpData(w,b.dataType,b)}catch(q){e="parsererror";p=q}if(e==="success"||e==="notmodified")d|| -c.handleSuccess(b,w,e,f);else c.handleError(b,w,e,p);d||c.handleComplete(b,w,e,f);m==="timeout"&&w.abort();if(b.async)w=null}};try{var g=w.abort;w.abort=function(){w&&Function.prototype.call.call(g,w);L("abort")}}catch(i){}b.async&&b.timeout>0&&setTimeout(function(){w&&!J&&L("timeout")},b.timeout);try{w.send(l||b.data==null?null:b.data)}catch(n){c.handleError(b,w,null,n);c.handleComplete(b,w,e,f)}b.async||L();return w}},param:function(a,b){var d=[],e=function(h,l){l=c.isFunction(l)?l():l;d[d.length]= -encodeURIComponent(h)+"="+encodeURIComponent(l)};if(b===B)b=c.ajaxSettings.traditional;if(c.isArray(a)||a.jquery)c.each(a,function(){e(this.name,this.value)});else for(var f in a)da(f,a[f],b,e);return d.join("&").replace(tb,"+")}});c.extend({active:0,lastModified:{},etag:{},handleError:function(a,b,d,e){a.error&&a.error.call(a.context,b,d,e);a.global&&c.triggerGlobal(a,"ajaxError",[b,a,e])},handleSuccess:function(a,b,d,e){a.success&&a.success.call(a.context,e,d,b);a.global&&c.triggerGlobal(a,"ajaxSuccess", -[b,a])},handleComplete:function(a,b,d){a.complete&&a.complete.call(a.context,b,d);a.global&&c.triggerGlobal(a,"ajaxComplete",[b,a]);a.global&&c.active--===1&&c.event.trigger("ajaxStop")},triggerGlobal:function(a,b,d){(a.context&&a.context.url==null?c(a.context):c.event).trigger(b,d)},httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"), -e=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(e)c.etag[b]=e;return a.status===304},httpData:function(a,b,d){var e=a.getResponseHeader("content-type")||"",f=b==="xml"||!b&&e.indexOf("xml")>=0;a=f?a.responseXML:a.responseText;f&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b==="json"||!b&&e.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&e.indexOf("javascript")>=0)c.globalEval(a);return a}}); -if(E.ActiveXObject)c.ajaxSettings.xhr=function(){if(E.location.protocol!=="file:")try{return new E.XMLHttpRequest}catch(a){}try{return new E.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}};c.support.ajax=!!c.ajaxSettings.xhr();var ea={},vb=/^(?:toggle|show|hide)$/,wb=/^([+\-]=)?([\d+.\-]+)(.*)$/,ba,pa=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b,d){if(a||a===0)return this.animate(S("show", -3),a,b,d);else{d=0;for(var e=this.length;d=0;e--)if(d[e].elem===this){b&&d[e](true);d.splice(e,1)}});b||this.dequeue();return this}});c.each({slideDown:S("show",1),slideUp:S("hide",1),slideToggle:S("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){c.fn[a]=function(d,e,f){return this.animate(b, -d,e,f)}});c.extend({speed:function(a,b,d){var e=a&&typeof a==="object"?c.extend({},a):{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};e.duration=c.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in c.fx.speeds?c.fx.speeds[e.duration]:c.fx.speeds._default;e.old=e.complete;e.complete=function(){e.queue!==false&&c(this).dequeue();c.isFunction(e.old)&&e.old.call(this)};return e},easing:{linear:function(a,b,d,e){return d+e*a},swing:function(a,b,d,e){return(-Math.cos(a* -Math.PI)/2+0.5)*e+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||c.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a=parseFloat(c.css(this.elem,this.prop));return a&&a>-1E4?a:0},custom:function(a,b,d){function e(l){return f.step(l)} -var f=this,h=c.fx;this.startTime=c.now();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;this.pos=this.state=0;e.elem=this.elem;if(e()&&c.timers.push(e)&&!ba)ba=setInterval(h.tick,h.interval)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true; -this.custom(this.cur(),0)},step:function(a){var b=c.now(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var e in this.options.curAnim)if(this.options.curAnim[e]!==true)d=false;if(d){if(this.options.overflow!=null&&!c.support.shrinkWrapBlocks){var f=this.elem,h=this.options;c.each(["","X","Y"],function(k,o){f.style["overflow"+o]=h.overflow[k]})}this.options.hide&&c(this.elem).hide();if(this.options.hide|| -this.options.show)for(var l in this.options.curAnim)c.style(this.elem,l,this.options.orig[l]);this.options.complete.call(this.elem)}return false}else{a=b-this.startTime;this.state=a/this.options.duration;b=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||b](this.state,a,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a= -c.timers,b=0;b-1;e={};var x={};if(o)x=f.position();l=o?x.top:parseInt(l,10)||0;k=o?x.left:parseInt(k,10)||0;if(c.isFunction(b))b=b.call(a,d,h);if(b.top!=null)e.top=b.top-h.top+l;if(b.left!=null)e.left=b.left-h.left+k;"using"in b?b.using.call(a, -e):f.css(e)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),e=Ia.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.css(a,"marginTop"))||0;d.left-=parseFloat(c.css(a,"marginLeft"))||0;e.top+=parseFloat(c.css(b[0],"borderTopWidth"))||0;e.left+=parseFloat(c.css(b[0],"borderLeftWidth"))||0;return{top:d.top-e.top,left:d.left-e.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||t.body;a&&!Ia.test(a.nodeName)&& -c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(e){var f=this[0],h;if(!f)return null;if(e!==B)return this.each(function(){if(h=fa(this))h.scrollTo(!a?e:c(h).scrollLeft(),a?e:c(h).scrollTop());else this[d]=e});else return(h=fa(f))?"pageXOffset"in h?h[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&h.document.documentElement[d]||h.document.body[d]:f[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase(); -c.fn["inner"+b]=function(){return this[0]?parseFloat(c.css(this[0],d,"padding")):null};c.fn["outer"+b]=function(e){return this[0]?parseFloat(c.css(this[0],d,e?"margin":"border")):null};c.fn[d]=function(e){var f=this[0];if(!f)return e==null?null:this;if(c.isFunction(e))return this.each(function(l){var k=c(this);k[d](e.call(this,l,k[d]()))});if(c.isWindow(f))return f.document.compatMode==="CSS1Compat"&&f.document.documentElement["client"+b]||f.document.body["client"+b];else if(f.nodeType===9)return Math.max(f.documentElement["client"+ -b],f.body["scroll"+b],f.documentElement["scroll"+b],f.body["offset"+b],f.documentElement["offset"+b]);else if(e===B){f=c.css(f,d);var h=parseFloat(f);return c.isNaN(h)?f:h}else return this.css(d,typeof e==="string"?e:e+"px")}})})(window); diff --git a/game/dev/jquery-ui-1.8.9.custom.min.js b/game/dev/jquery-ui-1.8.9.custom.min.js deleted file mode 100755 index 044d307..0000000 --- a/game/dev/jquery-ui-1.8.9.custom.min.js +++ /dev/null @@ -1,68 +0,0 @@ -/*! - * jQuery UI 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI - */ -(function(c,j){function k(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.9",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106, -NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this, -"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position"); -if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,l,m){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(l)g-=parseFloat(c.curCSS(f, -"border"+this+"Width",true))||0;if(m)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h, -d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){var b=a.nodeName.toLowerCase(),d=c.attr(a,"tabindex");if("area"===b){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&k(a)}return(/input|select|textarea|button|object/.test(b)?!a.disabled:"a"==b?a.href||!isNaN(d):!isNaN(d))&&k(a)},tabbable:function(a){var b=c.attr(a,"tabindex");return(isNaN(b)||b>=0)&&c(a).is(":focusable")}}); -c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a
",remove:null,select:null,show:null,spinner:"Loading…",tabTemplate:"
  • #{label}
  • "},_create:function(){this._tabify(true)},_setOption:function(b,e){if(b=="selected")this.options.collapsible&& -e==this.options.selected||this.select(e);else{this.options[b]=e;this._tabify()}},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+u()},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+w());return d.cookie.apply(null,[b].concat(d.makeArray(arguments)))},_ui:function(b,e){return{tab:b,panel:e,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b= -d(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(b){function e(g,f){g.css("display","");!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}var a=this,c=this.options,h=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=d(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);this.anchors.each(function(g,f){var i=d(f).attr("href"),l=i.split("#")[0],q;if(l&&(l===location.toString().split("#")[0]|| -(q=d("base")[0])&&l===q.href)){i=f.hash;f.href=i}if(h.test(i))a.panels=a.panels.add(a.element.find(a._sanitizeSelector(i)));else if(i&&i!=="#"){d.data(f,"href.tabs",i);d.data(f,"load.tabs",i.replace(/#.*$/,""));i=a._tabId(f);f.href="#"+i;f=a.element.find("#"+i);if(!f.length){f=d(c.panelTemplate).attr("id",i).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else c.disabled.push(g)});if(b){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"); -this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(c.selected===p){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){c.selected=g;return false}});if(typeof c.selected!=="number"&&c.cookie)c.selected=parseInt(a._cookie(),10);if(typeof c.selected!=="number"&&this.lis.filter(".ui-tabs-selected").length)c.selected= -this.lis.index(this.lis.filter(".ui-tabs-selected"));c.selected=c.selected||(this.lis.length?0:-1)}else if(c.selected===null)c.selected=-1;c.selected=c.selected>=0&&this.anchors[c.selected]||c.selected<0?c.selected:0;c.disabled=d.unique(c.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(c.selected,c.disabled)!=-1&&c.disabled.splice(d.inArray(c.selected,c.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active"); -if(c.selected>=0&&this.anchors.length){a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash)).removeClass("ui-tabs-hide");this.lis.eq(c.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[c.selected],a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash))[0]))});this.load(c.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else c.selected=this.lis.index(this.lis.filter(".ui-tabs-selected")); -this.element[c.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");c.cookie&&this._cookie(c.selected,c.cookie);b=0;for(var j;j=this.lis[b];b++)d(j)[d.inArray(b,c.disabled)!=-1&&!d(j).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");c.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(c.event!=="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+ -g)};this.lis.bind("mouseover.tabs",function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(c.fx)if(d.isArray(c.fx)){m=c.fx[0];o=c.fx[1]}else m=o=c.fx;var r=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal", -function(){e(f,o);a._trigger("show",null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},s=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")}; -this.anchors.bind(c.event+".tabs",function(){var g=this,f=d(g).closest("li"),i=a.panels.filter(":not(.ui-tabs-hide)"),l=a.element.find(a._sanitizeSelector(g.hash));if(f.hasClass("ui-tabs-selected")&&!c.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a.panels.filter(":animated").length||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}c.selected=a.anchors.index(this);a.abort();if(c.collapsible)if(f.hasClass("ui-tabs-selected")){c.selected= --1;c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){s(g,i)}).dequeue("tabs");this.blur();return false}else if(!i.length){c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this));this.blur();return false}c.cookie&&a._cookie(c.selected,c.cookie);if(l.length){i.length&&a.element.queue("tabs",function(){s(g,i)});a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier."; -d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(b){if(typeof b=="string")b=this.anchors.index(this.anchors.filter("[href$="+b+"]"));return b},destroy:function(){var b=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e= -d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(c,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});b.cookie&&this._cookie(null,b.cookie);return this},add:function(b, -e,a){if(a===p)a=this.anchors.length;var c=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,b).replace(/#\{label\}/g,e));b=!b.indexOf("#")?b.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var j=c.element.find("#"+b);j.length||(j=d(h.panelTemplate).attr("id",b).data("destroy.tabs",true));j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);j.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]); -j.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");j.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){c._trigger("show",null,c._ui(c.anchors[0],c.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(b){b=this._getIndex(b);var e=this.options,a=this.lis.eq(b).remove(),c=this.panels.eq(b).remove(); -if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(b+(b+1=b?--h:h});this._tabify();this._trigger("remove",null,this._ui(a.find("a")[0],c[0]));return this},enable:function(b){b=this._getIndex(b);var e=this.options;if(d.inArray(b,e.disabled)!=-1){this.lis.eq(b).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=b});this._trigger("enable",null, -this._ui(this.anchors[b],this.panels[b]));return this}},disable:function(b){b=this._getIndex(b);var e=this.options;if(b!=e.selected){this.lis.eq(b).addClass("ui-state-disabled");e.disabled.push(b);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[b],this.panels[b]))}return this},select:function(b){b=this._getIndex(b);if(b==-1)if(this.options.collapsible&&this.options.selected!=-1)b=this.options.selected;else return this;this.anchors.eq(b).trigger(this.options.event+".tabs");return this}, -load:function(b){b=this._getIndex(b);var e=this,a=this.options,c=this.anchors.eq(b)[0],h=d.data(c,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(c,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(b).addClass("ui-state-processing");if(a.spinner){var j=d("span",c);j.data("label.tabs",j.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){e.element.find(e._sanitizeSelector(c.hash)).html(k);e._cleanup();a.cache&&d.data(c, -"cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.error(k,n,b,c)}catch(m){}}}));e.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this}, -url:function(b,e){this.anchors.eq(b).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.9"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(b,e){var a=this,c=this.options,h=a._rotate||(a._rotate=function(j){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=c.selected;a.select(++k= load_max && - image_manager.is_done_preloading() && - sounds.sounds_loaded()){ - // init all image objects - image_manager.init_images(p); - loading_finished(); - } - }; - - - obj.get_all_buttons = function() { - return []; - }; - - obj.key_pressed = function() {}; - - return obj; -}; diff --git a/game/dev/multiplier.js b/game/dev/multiplier.js deleted file mode 100644 index 4fb7830..0000000 --- a/game/dev/multiplier.js +++ /dev/null @@ -1,56 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec - -var multiplier = function(p, spec) { - // --- defaults --- - - spec.width = spec.width || 5; - spec.height = spec.height || 5; - // make sure it goes left - spec.vel = new p.PVector(p.random(0, -1)* g_speed_factor, p.random()* g_speed_factor); - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "multiplier"; - }; - - // --- private variables --- - - var alive = true; - - // --- public methods --- - - // implementing game_object interface - - obj.update = function() { - obj.bounce(); - obj.move(); - }; - - // (rectangle for now) - obj.draw = function() { - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.fill(0, 255, 0); - p.noStroke(); - - p.ellipse(pos.x, pos.y, - obj.get_width(), obj.get_height()); - }; - - obj.die = function() { - alive = false; - } - - obj.is_dead = function() { - return (!alive); - }; - - return obj; -}; diff --git a/game/dev/mutation_obj.js b/game/dev/mutation_obj.js deleted file mode 100644 index 9403397..0000000 --- a/game/dev/mutation_obj.js +++ /dev/null @@ -1,328 +0,0 @@ -// Manages all information about the current state of mutation -// in the game -// Provides a num_status_obj, which is used for rendering -// spec: -// status_height = y value for status objects - -var mutation_obj = function(p, spec) { - - // obj to return - var obj = {}; - - // --- private variables --- - - var level = 1; - var cells_infected = 0; - var cells_needed; // init'd below - var new_mutation = false; - // Color array for all the mutation levels - var color_array = [ - /* - p.color(250, 250, 40), - p.color(60, 240, 240), - p.color(167, 17, 161), - p.color(100, 250, 110), - p.color(13, 28, 171), - p.color(118, 12, 25) - */ - 0xffff2a7f, - 0xffffff00, - 0xff7f2aff, - 0xff37c871, - 0xffd42aff, - 0xffff7f2a, - 0xff2ad4ff, - 0xffff2a2a, - 0xff7fff2a, - 0xffc8b7b7 - ]; - -/* - // Keeps track of all the abilities earned in the game so far - // If you lose a mutation level, must pop abilities off this array - var abilities = []; - - // All the possible abilities, sorted by level - // An ability can be earned at level x if it is in poss_abilities[0-x] - // TODO: add all abilities and change their levels - // TODO: Change these to be ready to be displayed to the user (or create a formatting mechanism) - var poss_abilities = [ - ["extra_particle"], - ["faster_particles", "bigger_particles"] - ]; -*/ - - // Flashing - var flash_color = null; - var is_flashing = false; - - // Shows the probability of getting a mutation - var bar_status_obj = num_status_obj(p, { - pos : new p.PVector(170, spec.status_height || 20), - text : "Mutation:", - num : 0, - bar : true, - max : 0 // init'd below - }); - - //Shows the curent mutation level - var level_spec = { - pos : new p.PVector(350, spec.status_height || 20), - text : "Strain ", - num : 1, - text_color : p.color(0) - }; - var level_status_obj = num_status_obj(p, level_spec); - - // --- private methods - -/* - // Returns a random ability, taking into account the current level - // Every possibile ability has an equal chance - var get_random_ability = function() { - var all_possible = []; - for(var i = 0; i < level; i++) { - for_each(poss_abilities[i], function(a) {all_possible.push(a);}); - } - assert(all_possible.length != 0); - return all_possible[Math.floor(Math.random() * all_possible.length)]; - } -*/ - - // Returns bool saying if a mutation should occur - // takes into account level, cells_infected, and a random probability - var mutation_occured = function() { - //return Math.random() + ( (cells_infected / 50) / (level + 1)) > .95; - //return (Math.random() * (cells_infected / 50)) > .3; - //return (Math.random() + (cells_infected / 100) - (level / 50)) > .98; - return (Math.random()*0.5 + (cells_infected / cells_needed)) > .98; - }; - - // returns the max number of cells the player needs to infect to have - // a 100% probability of mutating - var calc_cells_needed = function() { - return 30 + 20*level; - }; - cells_needed = calc_cells_needed(); - bar_status_obj.set_max(cells_needed); - - // Flashes the mutation bar red and white - var flash_bar = function() { - is_flashing = true; - - // Flash red and white every half second - flash_red(); - setTimeout(flash_white, 500); - setTimeout(flash_red, 1000); - setTimeout(flash_white, 1500); - setTimeout(flash_red, 2000); - setTimeout(flash_white, 2500); - // End flashing in 3 seconds - setTimeout(end_flash, 3000); - } - - // updates the flash color - var flash_red = function() { - flash_color = [255, 0, 0]; - } - var flash_white = function() { - flash_color = [255, 255, 255]; - } - - // Draws the bar with the appropriate flashing color - var draw_flashing_bar = function() { - bar_status_obj.draw_color(flash_color); - } - // Ends the flashing - var end_flash = function() { - is_flashing = false; - } - - // Gives us a rainbow gradient - // Taken from : http://snipplr.com/view.php?codeview&id=14590 - /** - * HSV to RGB color conversion - * - * H runs from 0 to 360 degrees - * S and V run from 0 to 100 - * - * Ported from the excellent java algorithm by Eugene Vishnevsky at: - * http://www.cs.rit.edu/~ncs/color/t_convert.html - */ - var hsvToRgb = function(h, s, v) { - var r, g, b; - var i; - var f, p, q, t; - - // Make sure our arguments stay in-range - h = Math.max(0, Math.min(360, h)); - s = Math.max(0, Math.min(100, s)); - v = Math.max(0, Math.min(100, v)); - - // We accept saturation and value arguments from 0 to 100 because that's - // how Photoshop represents those values. Internally, however, the - // saturation and value are calculated from a range of 0 to 1. We make - // That conversion here. - s /= 100; - v /= 100; - - if(s == 0) { - // Achromatic (grey) - r = g = b = v; - return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; - } - - h /= 60; // sector 0 to 5 - i = Math.floor(h); - f = h - i; // factorial part of h - p = v * (1 - s); - q = v * (1 - s * f); - t = v * (1 - s * (1 - f)); - - switch(i) { - case 0: - r = v; - g = t; - b = p; - break; - - case 1: - r = q; - g = v; - b = p; - break; - - case 2: - r = p; - g = v; - b = t; - break; - - case 3: - r = p; - g = q; - b = v; - break; - - case 4: - r = t; - g = p; - b = v; - break; - - default: // case 5: - r = v; - g = p; - b = q; - } - - return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; - } - - // --- public methods --- - - obj.draw = function() { - bar_status_obj.draw(); - if (is_flashing) { - draw_flashing_bar(); - } - - // draw mutation colored box under level num - p.fill(get_color()); - p.noStroke(); - var lpos = level_spec.pos; - p.rectMode(p.CORNER); - p.rect(lpos.x-30, lpos.y-10, 70, 20); - - level_status_obj.draw(); - }; - - // increments the mutation percentage - obj.infected_cell = function() { - cells_infected += 1; - bar_status_obj.incr(1); - // if a mutation occurs - if (mutation_occured()) { - // set the flag - new_mutation = true; - flash_bar(); - - // Play sounds - sounds.play_sound("level_up"); - } - }; - - // returns true if a new mutation is ready - obj.has_new_mutation = function() { - return new_mutation; - }; - - // to be called when in_game_state decides to enact the new mutation - // as signalled by the flag - // Returns a new ability if one was added - obj.do_mutation = function() { - flash_bar(); - // Add new ability before incrementing level - //var new_ability = get_random_ability(); - //abilities.push(new_ability); - level += 1; - level_status_obj.incr(1); - // update num cells needed - cells_needed = calc_cells_needed(); - bar_status_obj.set_max(cells_needed); - // reset counters - obj.reset_mutation(); - - //return new_ability; - }; - - - // resets the counters and the flag - // to be called after a mutation is enacted in the game - obj.reset_mutation = function() { - cells_infected = 0; - bar_status_obj.set_num(0); - // reset flag - new_mutation = false; - }; - - var get_color = function() { - return color_array[(level - 1) % color_array.length]; - }; - - // Returns the current mutation level and color - obj.get_info = function() { - // color level goes from 0 to 360 - //var new_color_level = (360 - (360 - level * 30)); - //var hue = new_color_level / 360; - //var rgb_arr = hsvToRgb(new_color_level, 75, 75); - return { - level: level, - //color: p.color(rgb_arr[0], rgb_arr[1], rgb_arr[2]), - // level starts at 1, so have to subtract 1 - color : get_color(), //% color_array.size], - // get one new particle every 10 levels - particles: 3+p.floor(level/3), - //abilities: abilities - }; - }; - - obj.get_level = function() { - return level; - }; - - obj.set_level = function(l) { - // decrement by the difference in levels - level_status_obj.incr(l-level); - // Pop off abilities - /* - for (var i = 0; i < (level - l); i++) { - abilities.pop(); - } - */ - // set the new level - level = l; - }; - - return obj; -}; diff --git a/game/dev/notification.js b/game/dev/notification.js deleted file mode 100644 index dfee58e..0000000 --- a/game/dev/notification.js +++ /dev/null @@ -1,64 +0,0 @@ -// Used to alert the user of new information -// draw() returns false if the status update is finished -// spec: -// text : text to display -// color : color of text (defaults to black) -// pos : pos of notification - -var notification = function(p, spec) { - - // object to return - var obj = {}; - - // --- private variables --- - - var time_counter = 0; // used to draw the object at various times - var total_time = 60; // ~ 2 seconds. If changed must be changed in notify in in_game_state to prevent overlap //200; // ~6 secs? - - var text_size = 20; - var box_color = spec.color || p.color(255, 255, 255); - - // --- public methods --- - - - obj.draw = function() { - var time_percent = time_counter / total_time; - //var text_size = 25 - 25*(time_percent); - var text_alpha = 255 - 200*time_percent; - - //var x_pos = (p.width * (5/8)); //+ (p.width / 2) *time_percent; - //var y_pos = (p.height * (5/8)) - (p.height / 2) *time_percent; - - var x_pos = spec.pos.x; - var y_pos = spec.pos.y; - - // I don't like the moving from the center - // so I'm trying it stationary - //var x_pos = p.width / 2; - //var y_pos = 70; - - // this needs to come before textWidth - p.textAlign(p.CENTER, p.CENTER); - p.textSize(text_size); - - var w = p.textWidth(spec.text); - - // draw a box behind it - //p.fill(box_color, text_alpha); - //p.rectMode(p.CORNER) - //p.rect(x_pos-w/2-5, y_pos-p.textAscent(), w+10, p.textAscent()*2); - - //p.fill(p.color(0, 0, 0), text_alpha); - //p.fill(p.color(255, 255, 255), text_alpha); - p.fill(box_color, text_alpha); - p.text(spec.text, x_pos, y_pos); - - if (time_counter > total_time) { // Finished - return false; - } - time_counter++; - return true; - } - - return obj; -}; diff --git a/game/dev/num_status_obj.js b/game/dev/num_status_obj.js deleted file mode 100644 index fc05e28..0000000 --- a/game/dev/num_status_obj.js +++ /dev/null @@ -1,115 +0,0 @@ -// Generic wrapper for a status that includes text and a num -// Can be drawn as a number or a bar -// Provides draw, incr, set_num, and get_num -// spec: -// pos : center pos of text -// text : Will display " " -// num : num to start at -// bar : bool (optional) -// max : num (required if bar) - -var num_status_obj = function(p, spec) { - - // obj to return - var obj = {}; - - // --- private variables --- - - var pos = spec.pos; - var number = spec.num; - var txt = spec.text; - var bar = spec.bar || false; - var max = spec.max; - var height = 20; - var max_width = 100; //for the bar, might need to be passed in - - var get_obj_text = function() { - if (bar) { - return txt; - } - else { - var num_txt = ""+number; - if (spec.format) { - num_txt = spec.format(number); - } - return txt + " " + num_txt; - } - } - - var rect = rectangle(p, { // Really just a text obj - pos : pos, - width : 0, - height : 0, - text : get_obj_text(), - text_size : 14, - text_color: spec.text_color || 255, - }); - - // --- private methods - - var update = function(n) { - - number = n; - - rect.update_text(get_obj_text()); - }; - var draw_full_rect = function(color) { - p.fill(color[0], color[1], color[2]); - //p.strokeWeight(1); - //p.stroke(0); - var topy = pos.y - (height / 2); - var leftx = pos.x + (txt.length * 4); - p.rect(leftx, topy, max_width, height); - }; - - // --- public methods --- - - obj.draw = function() { - rect.draw(); - // Draw the bar separately, if appropriate - if (bar) { - p.noStroke(); - // Draw empty rectangle first - draw_full_rect([255, 255, 255]); - - // Then draw mutation status bar - p.fill(150); - - var topy = pos.y - (height / 2); - var leftx = pos.x + (txt.length * 4); - var rect_width = (number / max) * max_width; - rect_width = rect_width > max_width ? max_width : rect_width; - p.rectMode(p.CORNER); - p.rect(leftx, topy, rect_width, height); - - p.fill(255) - } - }; - - // SHOULD ONLY BE CALLED IF bar IS TRUE - // Draws a full bar of the specified color - // color : 3 element rgb array - obj.draw_color = function(color) { - draw_full_rect(color); - }; - - obj.incr = function(n) { - update(number + n); - }; - - // Set and get - - obj.set_max = function(m) { - max = m; - }; - - obj.set_num = function(n) { - update(n); - }; - - obj.get_num = function() { - return number; - }; - - return obj; -}; diff --git a/game/dev/object_with_states.js b/game/dev/object_with_states.js deleted file mode 100644 index a18e993..0000000 --- a/game/dev/object_with_states.js +++ /dev/null @@ -1,26 +0,0 @@ -// Gives an object the capability to set and get states -// inherits from game_object -// spec: -// spec.state -- current state, default to 'alive' - -var object_with_states = function(p, spec) { - - var obj = game_object(p, spec); - - var state = spec.state || "alive"; - - // --- public methods --- - - obj.set_state = function(s) { - // If outdated, don't update state - if (state != "outdated") { - state = s; - } - }; - - obj.get_state = function() { - return state; - }; - - return obj; -} diff --git a/game/dev/old-index.html b/game/dev/old-index.html deleted file mode 100644 index 3f3eb4d..0000000 --- a/game/dev/old-index.html +++ /dev/null @@ -1,223 +0,0 @@ - - - -Virion - - - - - - - - - -
    - - -
    Login with Facebook to track your high scores!
    - - - - Login with Facebook - - - -

    - -
    You are not Logged In
    - - - - -
    -
    Welcome to Virion beta testing!  Give the game a try and then scroll down to give us your feedback.
    -
    - -
    -
    - Could not load high scores! You may want to check your internet connection. -
    -
    - - - Your browser does not support the HTML5 canvas element. Upgrade to Chrome, Firefox 4, Safari, or Opera to play this game. - -
    -
    -

    Virion Beta Testing Feedback

    -
    - Tell us what you thought of the game by filling out the survey below. You can also email us at viriongame at gmail dot com. Thanks! We appreciate your help.  — The Virion Team -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/dev/option_button.js b/game/dev/option_button.js deleted file mode 100644 index 5154998..0000000 --- a/game/dev/option_button.js +++ /dev/null @@ -1,63 +0,0 @@ -// Have a rectangle representing their position and a state to go to when clicked -// spec: -// rect : spec for a rectangle representing the button -// click_fun : what to do when clicked -// global_var : var that determines whether this option is enabled or not - -var option_button = function(p, spec) { - - // --- defaults --- - //spec.rect.width = spec.width || 200; - //spec.rect.height = spec.height || 60; - - // obj to return - var obj = {}; - - // --- private variables --- - - var but = button(p, spec); - var rect = rectangle(p, spec.rect); - // Left-edge x and top-edge y coordinates of 'checkbox' indicating whether - // option is enabled - var status_x = rect.get_left_x() + 28//50; - var status_y = rect.get_top_y() + 30//37; - var tick_size = 30; - var tick_yes_image = image_manager.get_image("check1.png"); - var tick_no_image = image_manager.get_image("check0.png"); - - // --- public methods --- - - obj.draw = function() { - //rect.draw(); - but.draw(); - - p.imageMode(p.CENTER); - if (g[spec.global_var]) { - //p.fill(255, 255, 255); - //p.ellipse(status_x, status_y, 10, 10); - p.image(tick_yes_image, status_x, status_y, tick_size, tick_size); - } - else { - p.image(tick_no_image, status_x, status_y, tick_size, tick_size); - } - }; - - // Returns the state to go to if clicked, or - // null if not clicked - obj.click = function(x, y) { - //but.is_clicked(); - if (rect.is_in(x, y)) { - spec.click_fun(); - } - // Redraw in case anything changes - obj.draw(); - }; - - obj.is_clicked = function() { return null; }; - - obj.mouse_moved = function(x, y) { - but.mouse_moved(x, y); - }; - - return obj; -}; diff --git a/game/dev/options_state.js b/game/dev/options_state.js deleted file mode 100644 index 8333f7b..0000000 --- a/game/dev/options_state.js +++ /dev/null @@ -1,209 +0,0 @@ -var options_state = function (p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // Used to determine whether to play menu music when 'music' button is toggled - var prev_was_splash = false; - if (prev_state.get_type() === "splash") { - prev_was_splash = true; - } - - - // --- private variables --- - - var background_image = image_manager.get_image("settingssplash.png"); - - var button_style = { - text_x_offset : 60, - text_y_offset: -3, - text_align: p.LEFT - }; - - // Buttons - - var col1_x = p.width/2 - 120; - var col2_x = p.width/2 + 120; - - var back_button = button(p, { - state : function() { - sounds.play_button_back(); - return prev_state; - }, - rect : { - pos : new p.PVector(p.width / 2, p.height - 80), - //width : 120, - //height : 50, - //text: "Back", - //text_x_offset: 5, - //text_y_offset: -8, - image: "back.png", - } - }); - - // Options - //var option_image = "bullet_listcell.png"; - var sound_fx_button = option_button(p, { - click_fun : function() {sounds.play_button_click(); g.toggle_sound_fx();}, - global_var : "sound_fx", - rect : { - pos : new p.PVector(col1_x, p.height/2 - 70), - //text: "Sound Effects", - //text_x_offset: 60, - image : "set_sound.png",//option_image, - //over_image : "set_sound_a.png", - //style: button_style - } - }); - var music_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - // toggle the flag - g.toggle_music(); - - if (g.music) { - if (prev_was_splash) { - sounds.play_menu_music(); - } - } - else { - sounds.pause_menu_music(); - } - }, - global_var : "music", - rect : { - pos : new p.PVector(col1_x, p.height/2 + 40), - //text: "Music", - //text_x_offset: 60, - image : "set_music.png",//option_image, - //over_image : "set_music_a.png", - //style: button_style - } - }); - var spacebar_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - g.toggle_spacebar_to_fire(); - }, - global_var : "spacebar_to_fire", - rect : { - pos : new p.PVector(col2_x, p.height/2 - 70), - //text: "Spacebar to Fire", - //text_x_offset : 60, - image : "set_spacebar.png",//option_image, - //over_image : "set_spacebar_a.png", - //style: button_style - } - }); - var mouse_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - g.toggle_click_to_fire(); - }, - global_var : "click_to_fire", - rect : { - pos : new p.PVector(col2_x, p.height/2 + 40), - //text: "Mouse Click to Fire", - //text_x_offset : 60, - image : "set_click.png",//option_image, - //over_image : "set_click_a.png", - //style: button_style - } - }); - var mouse_to_select_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - g.toggle_mouse_to_select(); - }, - global_var : "mouse_to_select", - rect : { - pos : new p.PVector(col2_x, p.height/2 + 140), - //text: "Mouse to Select Cells\nInstead of Left/Right", - image : "set_mouseselect.png",//option_image, - //over_image : "set_mouseselect_a.png", - //text_x_offset : 60, - //style: button_style - } - }); - var track_left_button = button(p, { - state : function() { - sounds.play_button_click(); - g.prev_track(); - return obj; - }, - rect : { - pos : new p.PVector(col1_x - 50, p.height/2 + 145), - image : "track_left.png", - } - }); - var track_right_button = button(p, { - state : function() { - sounds.play_button_click(); - g.next_track(); - return obj; - }, - rect : { - pos : new p.PVector(col1_x + 50, p.height/2 + 145), - image : "track_right.png", - } - }); - - - - //Not ordered - var all_option_buttons = [sound_fx_button, music_button, - spacebar_button, mouse_button, mouse_to_select_button]; - var all_buttons = [back_button, track_left_button, track_right_button] - .concat(all_option_buttons); - - - // --- public methods --- - - obj.get_type = function() { - return "options"; - }; - - obj.update = function() { - //do nothing - }; - - obj.key_pressed = function(k) { - if (k === 115 || p.keyCode === 13 || k === 32) { //s, enter, space - } - else if (k === 104) { //h - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - obj.render = function() { - //p.background(g.background_color); - //p.fill(g.background_color); - //p.rect(100, 100, 500, 500); - p.imageMode(p.CORNERS); - p.image(background_image, 0, 0);//, p.width, p.height); - - // draw the track button background manually - var track_x = col1_x; - var track_y = p.height/2 + 140; - var track_image = image_manager.get_image("set_track.png"); - p.imageMode(p.CENTER); - p.image(track_image, track_x, track_y); - // draw current track - p.fill(0); - p.textAlign(p.CENTER); - p.textSize(14); - p.text(g.track, track_x, track_y+5); - - for_each(all_option_buttons, function(b) { b.draw(); }); - }; - - obj.mouse_click = function(x, y) { - for_each(all_option_buttons, function(b) { b.click(x, y); }); - }; - - return obj; -}; diff --git a/game/dev/particle.js b/game/dev/particle.js deleted file mode 100644 index 630645b..0000000 --- a/game/dev/particle.js +++ /dev/null @@ -1,437 +0,0 @@ -// *** particle *** -// --- inherits from game_object -// spec: -// game_object spec - -var particle = function(p, spec) { - - // --- defaults --- - - // was 15 - spec.width = spec.width || 10; - spec.height = spec.height || 10; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "particle"; - }; - - // --- private variables --- - - //var par_shape = p.loadShape("images/virusfinal.svg"); - //var par_image = p.loadImage("images/virus1.png"); - var par_image = image_manager.get_image("tinyvirus_trans.png"); - //var mutation = spec.mutation; - - // --- public methods --- - - // implementing game_object interface - - // update is default (move) - - // draw makes a small virus particle - // (circle for now) - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.get_mode()); - //var color = mutation.get_color(); - p.fill(obj.get_color()); - p.noStroke(); - p.ellipse(pos.x, pos.y, - obj.get_width() * .75, obj.get_height() * .75); - p.imageMode(obj.get_mode()); - p.image(par_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - //var d = new Date(); - //console.log(d.getMilliseconds()); - //p.shape(par_shape, pos.x, pos.y, - //obj.get_width() + 20, obj.get_height() + 20); - //draw(canvas.getContext('2d')); - //canvas.getContext('2d').drawSvg("images/virusFinal.svg", 300, 10, 20, 20); - //console.log("a " + d.getMilliseconds()); - - }; - - // override for circular object - obj.calc_radius = function() { - return obj.get_width()/2; - }; - obj.set_radius(obj.calc_radius()); - - return obj; -} - -// SVG -> Javascript code to draw the particle -/* -var draw = function(ctx) { -ctx.save(); -ctx.strokeStyle = 'rgba(0,0,0,0)'; -ctx.lineCap = 'butt'; -ctx.lineJoin = 'miter'; -ctx.miterLimit = 4; -ctx.save(); -ctx.restore(); -ctx.save(); -ctx.restore(); -ctx.save(); -ctx.scale(0.02,0.02); -ctx.save(); -ctx.fillStyle = "#fff1d0"; -ctx.strokeStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.lineWidth = 5; -ctx.miterLimit = 4; -ctx.beginPath(); -ctx.moveTo(411.42857,373.36218); -ctx.bezierCurveTo(378.29148999999995,373.36218,351.42857,400.2251,351.42857,433.36218); -ctx.bezierCurveTo(351.42857,435.74656000000004,351.59556999999995,438.08169000000004,351.86607,440.39343); -ctx.bezierCurveTo(333.68726999999996,446.05755000000005,316.62739,454.24753000000004,301.08482,464.54968); -ctx.bezierCurveTo(293.76497,456.45166,283.20419999999996,451.36218,271.42857,451.36218); -ctx.bezierCurveTo(249.33718,451.36218,231.42856999999998,469.27079000000003,231.42856999999998,491.36218); -ctx.bezierCurveTo(231.42856999999998,503.13781,236.51805,513.69858,244.61606999999998,521.0184300000001); -ctx.bezierCurveTo(234.27291999999997,536.6228600000001,226.0638,553.7583900000001,220.39731999999998,572.0184300000001); -ctx.bezierCurveTo(217.46769999999998,571.5787200000001,214.48073999999997,571.3621800000001,211.42856999999998,571.3621800000001); -ctx.bezierCurveTo(178.29148999999998,571.3621800000001,151.42856999999998,598.2251000000001,151.42856999999998,631.3621800000001); -ctx.bezierCurveTo(151.42856999999998,664.49926,178.29148999999998,691.3621800000001,211.42856999999998,691.3621800000001); -ctx.bezierCurveTo(214.48073999999997,691.3621800000001,217.46769999999998,691.1456400000001,220.39731999999998,690.7059300000001); -ctx.bezierCurveTo(226.0638,708.9659700000001,234.27291999999997,726.1015000000001,244.61606999999998,741.7059300000001); -ctx.bezierCurveTo(236.51805,749.02578,231.42856999999998,759.5865500000001,231.42856999999998,771.3621800000001); -ctx.bezierCurveTo(231.42856999999998,793.4535700000001,249.33718,811.3621800000001,271.42857,811.3621800000001); -ctx.bezierCurveTo(283.20419999999996,811.3621800000001,293.76497,806.2727000000001,301.08482,798.1746800000001); -ctx.bezierCurveTo(316.68924999999996,808.5178300000001,333.82478,816.7269500000001,352.08482,822.3934300000001); -ctx.bezierCurveTo(351.64511,825.3230500000001,351.42857,828.31001,351.42857,831.3621800000001); -ctx.bezierCurveTo(351.42857,864.49926,378.29148999999995,891.3621800000001,411.42857,891.3621800000001); -ctx.bezierCurveTo(444.56565,891.3621800000001,471.42857,864.49926,471.42857,831.3621800000001); -ctx.bezierCurveTo(471.42857,828.31001,471.21202999999997,825.3230500000001,470.77232,822.3934300000001); -ctx.bezierCurveTo(489.03236,816.7269500000001,506.16789,808.5178300000001,521.77232,798.1746800000001); -ctx.bezierCurveTo(529.09217,806.2727000000001,539.6529400000001,811.3621800000001,551.42857,811.3621800000001); -ctx.bezierCurveTo(573.5199600000001,811.3621800000001,591.42857,793.4535700000001,591.42857,771.3621800000001); -ctx.bezierCurveTo(591.42857,759.5865500000001,586.33909,749.02578,578.24107,741.7059300000001); -ctx.bezierCurveTo(588.5842200000001,726.1015000000001,596.7933400000001,708.9659700000001,602.45982,690.7059300000001); -ctx.bezierCurveTo(605.38944,691.1456400000001,608.3764,691.3621800000001,611.42857,691.3621800000001); -ctx.bezierCurveTo(644.56565,691.3621800000001,671.42857,664.49926,671.42857,631.3621800000001); -ctx.bezierCurveTo(671.42857,598.2251000000001,644.56565,571.3621800000001,611.42857,571.3621800000001); -ctx.bezierCurveTo(608.3764,571.3621800000001,605.38944,571.5787200000001,602.45982,572.0184300000001); -ctx.bezierCurveTo(596.7933400000001,553.7583900000001,588.5842200000001,536.6228600000001,578.24107,521.0184300000001); -ctx.bezierCurveTo(586.33909,513.6985800000001,591.42857,503.13781000000006,591.42857,491.3621800000001); -ctx.bezierCurveTo(591.42857,469.2707900000001,573.5199600000001,451.3621800000001,551.42857,451.3621800000001); -ctx.bezierCurveTo(539.6529400000001,451.3621800000001,529.09217,456.45166000000006,521.77232,464.5496800000001); -ctx.bezierCurveTo(506.22975,454.2475300000001,489.16987000000006,446.0575500000001,470.99107000000004,440.3934300000001); -ctx.bezierCurveTo(471.26157000000006,438.0816900000001,471.42857000000004,435.7465600000001,471.42857000000004,433.3621800000001); -ctx.bezierCurveTo(471.42857000000004,400.2251000000001,444.56565000000006,373.3621800000001,411.42857000000004,373.3621800000001); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "#d4d4d4"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.globalAlpha = 0.2752293646335602; -ctx.beginPath(); -ctx.moveTo(530.99107,472.99893); -ctx.bezierCurveTo(556.1068300000001,506.42843999999997,570.99107,547.96659,570.99107,592.99893); -ctx.bezierCurveTo(570.99107,640.61609,554.33443,684.34142,526.55357,718.68643); -ctx.bezierCurveTo(529.38723,724.17581,530.99107,730.39551,530.99107,736.99893); -ctx.bezierCurveTo(530.99107,759.09032,513.0824600000001,776.99893,490.99107000000004,776.99893); -ctx.bezierCurveTo(481.81567,776.99893,473.36493,773.91293,466.61607000000004,768.71768); -ctx.bezierCurveTo(459.44539000000003,772.62788,452.0033,776.1000799999999,444.33482000000004,779.12393); -ctx.bezierCurveTo(459.07273000000004,788.9998499999999,469.20043000000004,805.23816,470.77232000000004,823.90518); -ctx.bezierCurveTo(552.02543,798.48635,610.99107,722.63081,610.99107,632.99893); -ctx.bezierCurveTo(610.99107,567.57432,579.55868,509.48801,530.99107,472.99893); -ctx.closePath(); -ctx.moveTo(250.99107000000004,752.99893); -ctx.bezierCurveTo(275.86402000000004,786.1052599999999,310.78272000000004,811.21984,351.20982000000004,823.87393); -ctx.bezierCurveTo(352.19252000000006,812.2756499999999,356.47693000000004,801.61852,363.11607000000004,792.84268); -ctx.bezierCurveTo(321.11956000000004,791.21726,282.46387000000004,776.64461,250.99107000000004,752.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(330.99107,780.39343); -ctx.bezierCurveTo(353.16121999999996,780.39343,371.13367,763.9635099999999,371.13367,743.6961799999999); -ctx.bezierCurveTo(371.13367,742.58201,371.07697,741.48232,370.97059,740.39343); -ctx.bezierCurveTo(369.14252,759.1119,351.94243,773.78793,330.99107000000004,773.78793); -ctx.bezierCurveTo(310.03970000000004,773.78793,292.83962,759.1119,291.01155000000006,740.39343); -ctx.bezierCurveTo(290.90521000000007,741.48232,290.8484700000001,742.58201,290.8484700000001,743.6961799999999); -ctx.bezierCurveTo(290.8484700000001,763.9635099999999,308.82092000000006,780.3934299999999,330.9910700000001,780.3934299999999); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(530.99107,606.99893); -ctx.bezierCurveTo(553.1612200000001,606.99893,571.13367,590.5690099999999,571.13367,570.30168); -ctx.bezierCurveTo(571.13367,569.1875100000001,571.0769700000001,568.0878200000001,570.97059,566.9989300000001); -ctx.bezierCurveTo(569.14252,585.7174000000001,551.9424300000001,600.3934300000001,530.99107,600.3934300000001); -ctx.bezierCurveTo(510.03970000000004,600.3934300000001,492.83962,585.7174000000001,491.01155000000006,566.9989300000001); -ctx.bezierCurveTo(490.90521000000007,568.0878200000001,490.8484700000001,569.1875100000001,490.8484700000001,570.30168); -ctx.bezierCurveTo(490.8484700000001,590.56901,508.82092000000006,606.99893,530.99107,606.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(290.99107,606.99893); -ctx.bezierCurveTo(313.16121999999996,606.99893,331.13367,590.5690099999999,331.13367,570.30168); -ctx.bezierCurveTo(331.13367,569.1875100000001,331.07697,568.0878200000001,330.97059,566.9989300000001); -ctx.bezierCurveTo(329.14252,585.7174000000001,311.94243,600.3934300000001,290.99107000000004,600.3934300000001); -ctx.bezierCurveTo(270.03970000000004,600.3934300000001,252.83962000000002,585.7174000000001,251.01155000000003,566.9989300000001); -ctx.bezierCurveTo(250.90521000000004,568.0878200000001,250.84847000000002,569.1875100000001,250.84847000000002,570.30168); -ctx.bezierCurveTo(250.84847000000002,590.56901,268.82092,606.99893,290.99107000000004,606.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(410.99107,700.39343); -ctx.bezierCurveTo(444.23506999999995,700.39343,471.18464,675.74855,471.18464,645.34755); -ctx.bezierCurveTo(471.18464,643.6763,471.09964,642.02676,470.94010000000003,640.39343); -ctx.bezierCurveTo(468.19892000000004,668.47114,442.4075,690.48518,410.99107000000004,690.48518); -ctx.bezierCurveTo(379.57463,690.48518,353.78322000000003,668.47114,351.04204000000004,640.39343); -ctx.bezierCurveTo(350.88258,642.02676,350.79750000000007,643.6763,350.79750000000007,645.34755); -ctx.bezierCurveTo(350.79750000000007,675.7485499999999,377.74707000000006,700.39343,410.9910700000001,700.39343); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(379.52232,680.31143); -ctx.bezierCurveTo(369.29332,669.55083,362.99107,655.01762,362.99107,638.99893); -ctx.bezierCurveTo(362.99107,605.86185,389.85398999999995,578.99893,422.99107,578.99893); -ctx.bezierCurveTo(432.90058,578.99893,442.2231,581.43242,450.45982,585.68643); -ctx.bezierCurveTo(439.5286,574.18711,424.10945999999996,566.99893,406.99107,566.99893); -ctx.bezierCurveTo(373.85398999999995,566.99893,346.99107,593.86185,346.99107,626.99893); -ctx.bezierCurveTo(346.99107,650.22651,360.21569999999997,670.34016,379.52232,680.31143); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(385.52232,490.31143); -ctx.bezierCurveTo(375.29332,479.55082999999996,368.99107,465.01761999999997,368.99107,448.99893); -ctx.bezierCurveTo(368.99107,415.86185,395.85398999999995,388.99893,428.99107,388.99893); -ctx.bezierCurveTo(438.90058,388.99893,448.2231,391.43242,456.45982,395.68643); -ctx.bezierCurveTo(445.5286,384.18710999999996,430.10945999999996,376.99893,412.99107,376.99893); -ctx.bezierCurveTo(379.85398999999995,376.99893,352.99107,403.86184999999995,352.99107,436.99893); -ctx.bezierCurveTo(352.99107,460.22650999999996,366.21569999999997,480.34015999999997,385.52232,490.31143); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(410.99107,496.90718); -ctx.bezierCurveTo(444.23506999999995,496.90718,471.18464,472.2623,471.18464,441.86129999999997); -ctx.bezierCurveTo(471.18464,440.19005,471.09964,438.54051,470.94010000000003,436.90718); -ctx.bezierCurveTo(468.19892000000004,464.98489,442.4075,486.99893,410.99107000000004,486.99893); -ctx.bezierCurveTo(379.57463,486.99893,353.78322000000003,464.98488999999995,351.04204000000004,436.90718); -ctx.bezierCurveTo(350.88258,438.54051,350.79750000000007,440.19005,350.79750000000007,441.86129999999997); -ctx.bezierCurveTo(350.79750000000007,472.2623,377.74707000000006,496.90718,410.9910700000001,496.90718); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(385.52232,880.31143); -ctx.bezierCurveTo(375.29332,869.55083,368.99107,855.01762,368.99107,838.99893); -ctx.bezierCurveTo(368.99107,805.86185,395.85398999999995,778.99893,428.99107,778.99893); -ctx.bezierCurveTo(438.90058,778.99893,448.2231,781.43242,456.45982,785.68643); -ctx.bezierCurveTo(445.5286,774.18711,430.10945999999996,766.99893,412.99107,766.99893); -ctx.bezierCurveTo(379.85398999999995,766.99893,352.99107,793.86185,352.99107,826.99893); -ctx.bezierCurveTo(352.99107,850.22651,366.21569999999997,870.34016,385.52232,880.31143); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(214.99107,572.99893); -ctx.bezierCurveTo(181.85399,572.99893,154.99107,599.86185,154.99107,632.99893); -ctx.bezierCurveTo(154.99107,656.22651,168.2157,676.34016,187.52232,686.31143); -ctx.bezierCurveTo(177.29332,675.55083,170.99107,661.01762,170.99107,644.99893); -ctx.bezierCurveTo(170.99107,616.5388399999999,190.81059000000002,592.72182,217.39732,586.56143); -ctx.bezierCurveTo(218.55700000000002,582.09924,219.88045,577.67801,221.33482,573.34268); -ctx.bezierCurveTo(219.25357,573.12367,217.13087000000002,572.99893,214.99107,572.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(610.99107,572.99893); -ctx.bezierCurveTo(608.53101,572.99893,606.12354,573.18,603.74107,573.46768); -ctx.bezierCurveTo(605.0957900000001,578.3556199999999,606.25589,583.31197,607.24107,588.34268); -ctx.bezierCurveTo(613.4279,586.18599,620.06901,584.99893,626.99107,584.99893); -ctx.bezierCurveTo(636.90058,584.99893,646.2231,587.43242,654.45982,591.68643); -ctx.bezierCurveTo(643.5286,580.18711,628.10946,572.99893,610.99107,572.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(270.40757,590.02506); -ctx.bezierCurveTo(263.48731000000004,583.2801400000001,259.22363,574.1704900000001,259.22363,564.12971); -ctx.bezierCurveTo(259.22363,543.3588500000001,277.39728,526.5207300000001,299.81559000000004,526.5207300000001); -ctx.bezierCurveTo(306.51970000000006,526.5207300000001,312.82669000000004,528.0460800000001,318.39911000000006,530.71256); -ctx.bezierCurveTo(311.0037700000001,523.5046000000001,300.5722200000001,518.9989300000001,288.99107000000004,518.9989300000001); -ctx.bezierCurveTo(266.57276,518.9989300000001,248.39911000000004,535.8370500000001,248.39911000000004,556.6079100000001); -ctx.bezierCurveTo(248.39911000000004,571.1673400000001,257.34600000000006,583.7749000000001,270.40757,590.02506); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(509.82696,588.84012); -ctx.bezierCurveTo(503.02601999999996,582.03508,498.83585,572.84422,498.83585,562.71395); -ctx.bezierCurveTo(498.83585,541.75794,516.69616,524.76973,538.7279599999999,524.76973); -ctx.bezierCurveTo(545.31648,524.76973,551.51473,526.30868,556.9910699999999,528.99893); -ctx.bezierCurveTo(549.7232399999999,521.72672,539.4715399999999,517.18089,528.0900599999999,517.18089); -ctx.bezierCurveTo(506.0582699999999,517.18089,488.19795999999985,534.1691,488.19795999999985,555.1251); -ctx.bezierCurveTo(488.19795999999985,569.81431,496.9905899999998,582.5342499999999,509.8269599999999,588.84012); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(249.11607,744.46768); -ctx.bezierCurveTo(239.42177,750.46789,232.99107,761.00366,232.99107,772.99893); -ctx.bezierCurveTo(232.99107,786.0855399999999,240.67045000000002,797.41228,251.86607,803.03018); -ctx.bezierCurveTo(245.93443000000002,796.96757,242.27232,788.77399,242.27232,779.74893); -ctx.bezierCurveTo(242.27232,768.88478,247.54392,759.24582,255.74107,753.06143); -ctx.bezierCurveTo(253.45899,750.25464,251.24597,747.3976,249.11607,744.46768); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(572.05357,748.21768); -ctx.bezierCurveTo(571.2613600000001,749.2555,570.45924,750.28971,569.64732,751.31143); -ctx.bezierCurveTo(573.66413,751.8387799999999,577.4639400000001,753.04166,580.92857,754.78018); -ctx.bezierCurveTo(578.36622,752.16126,575.3596,749.93576,572.05357,748.21768); -ctx.closePath(); -ctx.moveTo(530.45982,788.87393); -ctx.bezierCurveTo(528.51967,790.28432,526.54551,791.65748,524.55357,792.99893); -ctx.bezierCurveTo(527.85458,799.46132,533.17976,804.78457,539.77232,808.09268); -ctx.bezierCurveTo(534.7460100000001,802.9553999999999,531.37795,796.27958,530.45982,788.87393); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(490.99107,780.99893); -ctx.bezierCurveTo(513.16122,780.99893,531.1336699999999,764.5690099999999,531.1336699999999,744.30168); -ctx.bezierCurveTo(531.1336699999999,743.1875100000001,531.07697,742.0878200000001,530.9705899999999,740.9989300000001); -ctx.bezierCurveTo(529.1425199999999,759.7174000000001,511.9424299999999,774.3934300000001,490.9910699999999,774.3934300000001); -ctx.bezierCurveTo(470.0396999999999,774.3934300000001,452.8396199999999,759.7174000000001,451.01154999999994,740.9989300000001); -ctx.bezierCurveTo(450.90520999999995,742.0878200000001,450.84846999999996,743.1875100000001,450.84846999999996,744.30168); -ctx.bezierCurveTo(450.84846999999996,764.56901,468.82091999999994,780.99893,490.99107,780.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(252.5773,518.27473); -ctx.bezierCurveTo(246.64565000000002,512.21212,242.99107,504.02398999999997,242.99107,494.99893); -ctx.bezierCurveTo(242.99107,476.32923,258.56848,461.19444,277.78418,461.19444); -ctx.bezierCurveTo(283.53056,461.19444,288.93655,462.56549,293.71290999999997,464.96223); -ctx.bezierCurveTo(287.37404999999995,458.48341999999997,278.43271999999996,454.43354,268.50602,454.43354); -ctx.bezierCurveTo(249.29031999999998,454.43354,233.71290999999997,469.56833,233.71290999999997,488.23803); -ctx.bezierCurveTo(233.71290999999997,501.32464,241.38166999999996,512.65684,252.57729999999998,518.27473); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(550.99107,456.99893); -ctx.bezierCurveTo(541.15601,456.99893,532.2878900000001,460.96844,525.95982,467.34268); -ctx.bezierCurveTo(529.09436,469.54866,532.14881,471.83973999999995,535.14732,474.21768); -ctx.bezierCurveTo(541.4817800000001,467.78294999999997,550.38418,463.74893,560.27232,463.74893); -ctx.bezierCurveTo(566.0187000000001,463.74893,571.43347,465.13343999999995,576.20982,467.53018); -ctx.bezierCurveTo(569.87097,461.05136999999996,560.91777,456.99893,550.99107,456.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(310.12323,762.27473); -ctx.bezierCurveTo(303.07660999999996,756.21629,298.73508,748.0337999999999,298.73508,739.01495); -ctx.bezierCurveTo(298.73508,720.35811,317.24055999999996,705.23373,340.06822999999997,705.23373); -ctx.bezierCurveTo(346.89475,705.23373,353.3169,706.60384,358.99107,708.9989300000001); -ctx.bezierCurveTo(351.4607,702.5245800000001,340.83867,698.4774900000001,329.04605999999995,698.4774900000001); -ctx.bezierCurveTo(306.2184,698.4774900000001,287.71290999999997,713.6018600000001,287.71290999999997,732.2587100000001); -ctx.bezierCurveTo(287.71290999999997,745.33631,296.82316,756.6607,310.12323,762.2747300000001); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(470.75204,762.27473); -ctx.bezierCurveTo(463.5077,756.21629,459.04435,748.0337999999999,459.04435,739.01495); -ctx.bezierCurveTo(459.04435,720.35811,478.06908,705.23373,501.53727000000003,705.23373); -ctx.bezierCurveTo(508.55534000000006,705.23373,515.15769,706.60384,520.99107,708.9989300000001); -ctx.bezierCurveTo(513.2494,702.5245800000001,502.32933,698.4774900000001,490.20583000000005,698.4774900000001); -ctx.bezierCurveTo(466.73764000000006,698.4774900000001,447.7129100000001,713.6018600000001,447.7129100000001,732.2587100000001); -ctx.bezierCurveTo(447.7129100000001,745.33631,457.0787900000001,756.6607,470.7520400000001,762.2747300000001); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.restore(); -ctx.restore(); -}; -*/ diff --git a/game/dev/pause_state.js b/game/dev/pause_state.js deleted file mode 100644 index 30e7767..0000000 --- a/game/dev/pause_state.js +++ /dev/null @@ -1,121 +0,0 @@ -var pause_state = function (p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - // Buttons - // Have a rectangle representing their position and - // a state to go to when pressed - var button_x = p.width / 2; - var button_top = 200; - var button_sep = 60; - - var button_style = { - text_size: 14, - text_align: p.LEFT, - text_x_offset: 25, - width: 120, - height: 50, - }; - - - var continue_button = button(p, { - state : function() { - sounds.play_button_click(); - return prev_state; - }, - rect : { - pos : new p.PVector(button_x, button_top), - //text: "Continue", - image: "continue.png", - width: 120, - height: 50 - //image_x_offset: 5, - //style: button_style - } - }); - - var options_button = button(p, { - state : function() { - sounds.play_button_click(); - return options_state(p, obj); - }, - rect : { - pos : new p.PVector(button_x, button_top+button_sep), - //text: "Settings", - image: "settings.png", - //style: button_style - } - }); - - var help_button = button(p, { - state : function() { - sounds.play_button_click(); - return help_state(p, obj); - }, - rect : { - pos : new p.PVector(button_x, button_top+2*button_sep), - //text: "Instructions", - //text_x_offset: 10, - image: "instructions.png", - //image_x_offset: 3, - //style: button_style - } - }); - - var quit_button = button(p, { - state : function() { - sounds.play_button_click(); - return splash_state(p); - }, - rect : { - pos : new p.PVector(button_x, button_top+3*button_sep), - //text: "Quit", - //text_x_offset: -5, - image: "quit.png", - //image_x_offset: -5, - //style: button_style - } - }); - - //Not ordered - var all_buttons = [ continue_button, options_button, - help_button, quit_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "pause"; - }; - - obj.update = function() { - //do nothing - }; - - obj.render = function() { - p.noStroke(); - p.fill(0, 150); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.fill(255); - p.textSize(40); - p.textAlign(p.CENTER); - p.text("Game Paused", p.width/2, 150); - }; - - obj.key_pressed = function(k) { - if (k === 112 || p.keyCode === 13 || p.keyCode === 27) { //p, enter, esc - obj.exit_state();; - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/game/dev/php_functions.php b/game/dev/php_functions.php deleted file mode 100644 index fc47660..0000000 --- a/game/dev/php_functions.php +++ /dev/null @@ -1,102 +0,0 @@ - - -var g_soundDataMap = -{ - "cell_fire" : "", - "cell_infect" : "", - "macrophage_infect" : "", - "level_up" : "", - "kill" : "", - "buttonmain" : "", - "buttonback" : "", - "cell_firemp3" : "", - "cell_infectmp3" : "", - "macrophage_infectmp3" : "", - "level_upmp3" : "", - "killmp3" : "", - "buttonmainmp3" : "", - "buttonbackmp3" : "", -}; - -/* -Not working -var dynamic_div_tag = null; -// Jplayer instances - -*/ - -//IMAGES - - -//var image_list = []; -//var g_infected_cell_images = []; -//var g_empty_cell_images = []; - -// to be used in image_manager -all_image_files = {}; - - - diff --git a/game/dev/processing-1.0.0.js b/game/dev/processing-1.0.0.js deleted file mode 100644 index 605223f..0000000 --- a/game/dev/processing-1.0.0.js +++ /dev/null @@ -1,18013 +0,0 @@ -/* - - P R O C E S S I N G . J S - 1.0.0 - a port of the Processing visualization language - - License : MIT - Developer : John Resig: http://ejohn.org - Web Site : http://processingjs.org - Java Version : http://processing.org - Github Repo. : http://github.com/jeresig/processing-js - Bug Tracking : http://processing-js.lighthouseapp.com - Mozilla POW! : http://wiki.Mozilla.org/Education/Projects/ProcessingForTheWeb - Maintained by : Seneca: http://zenit.senecac.on.ca/wiki/index.php/Processing.js - Hyper-Metrix: http://hyper-metrix.com/#Processing - BuildingSky: http://weare.buildingsky.net/pages/processing-js - - */ - -(function() { - - var undef; // intentionally left undefined - - var ajax = function ajax(url) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", url, false); - xhr.setRequestHeader("If-Modified-Since", "Fri, 01 Jan 1960 00:00:00 GMT"); - xhr.send(null); - // failed request? - if (xhr.status !== 200 && xhr.status !== 0) { throw ("XMLHttpRequest failed, status code " + xhr.status); } - return xhr.responseText; - }; - - /* Browsers fixes start */ - function fixReplaceByRegExp() { - var re = /t/g; - if ("t".replace(re,"") !== null && re.exec("t")) { - return; // it is not necessary - } - var _ie_replace = String.prototype.replace; - String.prototype.replace = function(searchValue, repaceValue) { - var result = _ie_replace.apply(this, arguments); - if (searchValue instanceof RegExp && searchValue.global) { - searchValue.lastIndex = 0; - } - return result; - }; - } - - function fixMatchByRegExp() { - var re = /t/g; - if ("t".match(re) !== null && re.exec("t")) { - return; // it is not necessary - } - var _ie_match = String.prototype.match; - String.prototype.match = function(searchValue) { - var result = _ie_match.apply(this, arguments); - if(searchValue instanceof RegExp && searchValue.global) { - searchValue.lastIndex = 0; - } - return result; - }; - } - fixReplaceByRegExp(); - fixMatchByRegExp(); - - (function fixOperaCreateImageData() { - try { - if (!("createImageData" in CanvasRenderingContext2D.prototype)) { - CanvasRenderingContext2D.prototype.createImageData = function (sw, sh) { - return new ImageData(sw, sh); - }; - } - } catch(e) {} - }()); - /* Browsers fixes end */ - - var PConstants = { - X: 0, - Y: 1, - Z: 2, - - R: 3, - G: 4, - B: 5, - A: 6, - - U: 7, - V: 8, - - NX: 9, - NY: 10, - NZ: 11, - - EDGE: 12, - - // Stroke - SR: 13, - SG: 14, - SB: 15, - SA: 16, - - SW: 17, - - // Transformations (2D and 3D) - TX: 18, - TY: 19, - TZ: 20, - - VX: 21, - VY: 22, - VZ: 23, - VW: 24, - - // Material properties - AR: 25, - AG: 26, - AB: 27, - - DR: 3, - DG: 4, - DB: 5, - DA: 6, - - SPR: 28, - SPG: 29, - SPB: 30, - - SHINE: 31, - - ER: 32, - EG: 33, - EB: 34, - - BEEN_LIT: 35, - - VERTEX_FIELD_COUNT: 36, - - // Renderers - P2D: 1, - JAVA2D: 1, - WEBGL: 2, - P3D: 2, - OPENGL: 2, - PDF: 0, - DXF: 0, - - // Platform IDs - OTHER: 0, - WINDOWS: 1, - MAXOSX: 2, - LINUX: 3, - - EPSILON: 0.0001, - - MAX_FLOAT: 3.4028235e+38, - MIN_FLOAT: -3.4028235e+38, - MAX_INT: 2147483647, - MIN_INT: -2147483648, - - PI: Math.PI, - TWO_PI: 2 * Math.PI, - HALF_PI: Math.PI / 2, - THIRD_PI: Math.PI / 3, - QUARTER_PI: Math.PI / 4, - - DEG_TO_RAD: Math.PI / 180, - RAD_TO_DEG: 180 / Math.PI, - - WHITESPACE: " \t\n\r\f\u00A0", - - // Color modes - RGB: 1, - ARGB: 2, - HSB: 3, - ALPHA: 4, - CMYK: 5, - - // Image file types - TIFF: 0, - TARGA: 1, - JPEG: 2, - GIF: 3, - - // Filter/convert types - BLUR: 11, - GRAY: 12, - INVERT: 13, - OPAQUE: 14, - POSTERIZE: 15, - THRESHOLD: 16, - ERODE: 17, - DILATE: 18, - - // Blend modes - REPLACE: 0, - BLEND: 1 << 0, - ADD: 1 << 1, - SUBTRACT: 1 << 2, - LIGHTEST: 1 << 3, - DARKEST: 1 << 4, - DIFFERENCE: 1 << 5, - EXCLUSION: 1 << 6, - MULTIPLY: 1 << 7, - SCREEN: 1 << 8, - OVERLAY: 1 << 9, - HARD_LIGHT: 1 << 10, - SOFT_LIGHT: 1 << 11, - DODGE: 1 << 12, - BURN: 1 << 13, - - // Color component bit masks - ALPHA_MASK: 0xff000000, - RED_MASK: 0x00ff0000, - GREEN_MASK: 0x0000ff00, - BLUE_MASK: 0x000000ff, - - // Projection matrices - CUSTOM: 0, - ORTHOGRAPHIC: 2, - PERSPECTIVE: 3, - - // Shapes - POINT: 2, - POINTS: 2, - LINE: 4, - LINES: 4, - TRIANGLE: 8, - TRIANGLES: 9, - TRIANGLE_STRIP: 10, - TRIANGLE_FAN: 11, - QUAD: 16, - QUADS: 16, - QUAD_STRIP: 17, - POLYGON: 20, - PATH: 21, - RECT: 30, - ELLIPSE: 31, - ARC: 32, - SPHERE: 40, - BOX: 41, - - GROUP: 0, - PRIMITIVE: 1, - //PATH: 21, // shared with Shape PATH - GEOMETRY: 3, - - // Shape Vertex - VERTEX: 0, - BEZIER_VERTEX: 1, - CURVE_VERTEX: 2, - BREAK: 3, - CLOSESHAPE: 4, - - // Shape closing modes - OPEN: 1, - CLOSE: 2, - - // Shape drawing modes - CORNER: 0, // Draw mode convention to use (x, y) to (width, height) - CORNERS: 1, // Draw mode convention to use (x1, y1) to (x2, y2) coordinates - RADIUS: 2, // Draw mode from the center, and using the radius - CENTER_RADIUS: 2, // Deprecated! Use RADIUS instead - CENTER: 3, // Draw from the center, using second pair of values as the diameter - DIAMETER: 3, // Synonym for the CENTER constant. Draw from the center - CENTER_DIAMETER: 3, // Deprecated! Use DIAMETER instead - - // Text vertical alignment modes - BASELINE: 0, // Default vertical alignment for text placement - TOP: 101, // Align text to the top - BOTTOM: 102, // Align text from the bottom, using the baseline - - // UV Texture coordinate modes - NORMAL: 1, - NORMALIZED: 1, - IMAGE: 2, - - // Text placement modes - MODEL: 4, - SHAPE: 5, - - // Stroke modes - SQUARE: 'butt', - ROUND: 'round', - PROJECT: 'square', - MITER: 'miter', - BEVEL: 'bevel', - - // Lighting modes - AMBIENT: 0, - DIRECTIONAL: 1, - //POINT: 2, Shared with Shape constant - SPOT: 3, - - // Key constants - - // Both key and keyCode will be equal to these values - BACKSPACE: 8, - TAB: 9, - ENTER: 10, - RETURN: 13, - ESC: 27, - DELETE: 127, - CODED: 0xffff, - - // p.key will be CODED and p.keyCode will be this value - SHIFT: 16, - CONTROL: 17, - ALT: 18, - CAPSLK: 20, - PGUP: 33, - PGDN: 34, - END: 35, - HOME: 36, - LEFT: 37, - UP: 38, - RIGHT: 39, - DOWN: 40, - INS: 45, - DEL: 46, - F1: 112, - F2: 113, - F3: 114, - F4: 115, - F5: 116, - F6: 117, - F7: 118, - F8: 119, - F9: 120, - F10: 121, - F11: 122, - F12: 123, - NUMLK: 144, - - // Cursor types - ARROW: 'default', - CROSS: 'crosshair', - HAND: 'pointer', - MOVE: 'move', - TEXT: 'text', - WAIT: 'wait', - NOCURSOR: "url('data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), auto", - - // Hints - DISABLE_OPENGL_2X_SMOOTH: 1, - ENABLE_OPENGL_2X_SMOOTH: -1, - ENABLE_OPENGL_4X_SMOOTH: 2, - ENABLE_NATIVE_FONTS: 3, - DISABLE_DEPTH_TEST: 4, - ENABLE_DEPTH_TEST: -4, - ENABLE_DEPTH_SORT: 5, - DISABLE_DEPTH_SORT: -5, - DISABLE_OPENGL_ERROR_REPORT: 6, - ENABLE_OPENGL_ERROR_REPORT: -6, - ENABLE_ACCURATE_TEXTURES: 7, - DISABLE_ACCURATE_TEXTURES: -7, - HINT_COUNT: 10, - - // PJS defined constants - SINCOS_LENGTH: parseInt(360 / 0.5, 10), - PRECISIONB: 15, // fixed point precision is limited to 15 bits!! - PRECISIONF: 1 << 15, - PREC_MAXVAL: (1 << 15) - 1, - PREC_ALPHA_SHIFT: 24 - 15, - PREC_RED_SHIFT: 16 - 15, - NORMAL_MODE_AUTO: 0, - NORMAL_MODE_SHAPE: 1, - NORMAL_MODE_VERTEX: 2, - MAX_LIGHTS: 8 - }; - - // Typed Arrays: fallback to WebGL arrays or Native JS arrays if unavailable - function setupTypedArray(name, fallback) { - // check if TypedArray exists - // typeof on Minefield and Chrome return function, typeof on Webkit returns object. - if (typeof this[name] !== "function" && typeof this[name] !== "object") { - // nope.. check if WebGLArray exists - if (typeof this[fallback] === "function") { - this[name] = this[fallback]; - } else { - // nope.. set as Native JS array - this[name] = function(obj) { - if (obj instanceof Array) { - return obj; - } else if (typeof obj === "number") { - return new Array(obj); - } - }; - } - } - } - - setupTypedArray("Float32Array", "WebGLFloatArray"); - setupTypedArray("Int32Array", "WebGLIntArray"); - setupTypedArray("Uint16Array", "WebGLUnsignedShortArray"); - setupTypedArray("Uint8Array", "WebGLUnsignedByteArray"); - - /** - * An ArrayList stores a variable number of objects. - * - * @param {int} initialCapacity optional defines the initial capacity of the list, it's empty by default - * - * @returns {ArrayList} new ArrayList object - */ - var ArrayList = (function() { - function Iterator(array) { - var index = 0; - this.hasNext = function() { - return index < array.length; - }; - - this.next = function() { - return array[index++]; - }; - - this.remove = function() { - array.splice(index, 1); - }; - } - - function ArrayList() { - var array = arguments.length === 0 ? [] : - typeof arguments[0] === 'number' ? new Array(0 | arguments[0]) : - arguments[0]; - - /** - * @member ArrayList - * ArrayList.get() Returns the element at the specified position in this list. - * - * @param {int} i index of element to return - * - * @returns {Object} the element at the specified position in this list. - */ - this.get = function(i) { - return array[i]; - }; - /** - * @member ArrayList - * ArrayList.contains() Returns true if this list contains the specified element. - * - * @param {Object} item element whose presence in this List is to be tested. - * - * @returns {boolean} true if the specified element is present; false otherwise. - */ - this.contains = function(item) { - return array.indexOf(item) !== -1; - }; - /** - * @member ArrayList - * ArrayList.add() Adds the specified element to this list. - * - * @param {int} index optional index at which the specified element is to be inserted - * @param {Object} object element to be added to the list - */ - this.add = function() { - if (arguments.length === 1) { - array.push(arguments[0]); // for add(Object) - } else if (arguments.length === 2) { - var arg0 = arguments[0]; - if (typeof arg0 === 'number') { - if (arg0 >= 0 && arg0 <= array.length) { - array.splice(arg0, 0, arguments[1]); // for add(i, Object) - } else { - throw(arg0 + " is not a valid index"); - } - } else { - throw(typeof arg0 + " is not a number"); - } - } else { - throw("Please use the proper number of parameters."); - } - }; - - /** - * @member ArrayList - * ArrayList.set() Replaces the element at the specified position in this list with the specified element. - * - * @param {int} index index of element to replace - * @param {Object} object element to be stored at the specified position - */ - this.set = function() { - if (arguments.length === 2) { - var arg0 = arguments[0]; - if (typeof arg0 === 'number') { - if (arg0 >= 0 && arg0 < array.length) { - array.splice(arg0, 1, arguments[1]); - } else { - throw(arg0 + " is not a valid index."); - } - } else { - throw(typeof arg0 + " is not a number"); - } - } else { - throw("Please use the proper number of parameters."); - } - }; - - /** - * @member ArrayList - * ArrayList.size() Returns the number of elements in this list. - * - * @returns {int} the number of elements in this list - */ - this.size = function() { - return array.length; - }; - - /** - * @member ArrayList - * ArrayList.clear() Removes all of the elements from this list. The list will be empty after this call returns. - */ - this.clear = function() { - array.length = 0; - }; - - /** - * @member ArrayList - * ArrayList.remove() Removes the element at the specified position in this list. - * Shifts any subsequent elements to the left (subtracts one from their indices). - * - * @param {int} index the index of the element to removed. - * - * @returns {Object} the element that was removed from the list - */ - this.remove = function(i) { - return array.splice(i, 1)[0]; - }; - - /** - * @member ArrayList - * ArrayList.isEmpty() Tests if this list has no elements. - * - * @returns {boolean} true if this list has no elements; false otherwise - */ - this.isEmpty = function() { - return !array.length; - }; - - /** - * @member ArrayList - * ArrayList.clone() Returns a shallow copy of this ArrayList instance. (The elements themselves are not copied.) - * - * @returns {ArrayList} a clone of this ArrayList instance - */ - this.clone = function() { - return new ArrayList(array.slice(0)); - }; - - /** - * @member ArrayList - * ArrayList.toArray() Returns an array containing all of the elements in this list in the correct order. - * - * @returns {Object[]} Returns an array containing all of the elements in this list in the correct order - */ - this.toArray = function() { - return array.slice(0); - }; - - this.iterator = function() { - return new Iterator(array); - }; - } - - return ArrayList; - }()); - - /** - * A HashMap stores a collection of objects, each referenced by a key. This is similar to an Array, only - * instead of accessing elements with a numeric index, a String is used. (If you are familiar with - * associative arrays from other languages, this is the same idea.) - * - * @param {int} initialCapacity defines the initial capacity of the map, it's 16 by default - * @param {float} loadFactor the load factor for the map, the default is 0.75 - * @param {Map} m gives the new HashMap the same mappings as this Map - */ - var HashMap = (function() { - function virtHashCode(obj) { - if (obj.constructor === String) { - var hash = 0; - for (var i = 0; i < obj.length; ++i) { - hash = (hash * 31 + obj.charCodeAt(i)) & 0xFFFFFFFF; - } - return hash; - } else if (typeof(obj) !== "object") { - return obj & 0xFFFFFFFF; - } else if ("hashCode" in obj) { - return obj.hashCode.call(obj); - } else { - if (obj.$id === undef) { - obj.$id = ((Math.floor(Math.random() * 0x10000) - 0x8000) << 16) | Math.floor(Math.random() * 0x10000); - } - return obj.$id; - } - } - - function virtEquals(obj, other) { - if (obj === null || other === null) { - return (obj === null) && (other === null); - } else if (obj.constructor === String) { - return obj === other; - } else if (typeof(obj) !== "object") { - return obj === other; - } else if ("equals" in obj) { - return obj.equals.call(obj, other); - } else { - return obj === other; - } - } - - /** - * @member HashMap - * A HashMap stores a collection of objects, each referenced by a key. This is similar to an Array, only - * instead of accessing elements with a numeric index, a String is used. (If you are familiar with - * associative arrays from other languages, this is the same idea.) - * - * @param {int} initialCapacity defines the initial capacity of the map, it's 16 by default - * @param {float} loadFactor the load factor for the map, the default is 0.75 - * @param {Map} m gives the new HashMap the same mappings as this Map - */ - function HashMap() { - if (arguments.length === 1 && arguments[0].constructor === HashMap) { - return arguments[0].clone(); - } - - var initialCapacity = arguments.length > 0 ? arguments[0] : 16; - var loadFactor = arguments.length > 1 ? arguments[1] : 0.75; - var buckets = new Array(initialCapacity); - var count = 0; - var hashMap = this; - - function ensureLoad() { - if (count <= loadFactor * buckets.length) { - return; - } - var allEntries = []; - for (var i = 0; i < buckets.length; ++i) { - if (buckets[i] !== undef) { - allEntries = allEntries.concat(buckets[i]); - } - } - buckets = new Array(buckets.length * 2); - for (var j = 0; j < allEntries.length; ++j) { - var index = virtHashCode(allEntries[j].key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - buckets[index] = bucket = []; - } - bucket.push(allEntries[j]); - } - } - - function Iterator(conversion, removeItem) { - var bucketIndex = 0; - var itemIndex = -1; - var endOfBuckets = false; - - function findNext() { - while (!endOfBuckets) { - ++itemIndex; - if (bucketIndex >= buckets.length) { - endOfBuckets = true; - } else if (buckets[bucketIndex] === undef || itemIndex >= buckets[bucketIndex].length) { - itemIndex = -1; - ++bucketIndex; - } else { - return; - } - } - } - - /* - * @member Iterator - * Checks if the Iterator has more items - */ - this.hasNext = function() { - return !endOfBuckets; - }; - - /* - * @member Iterator - * Return the next Item - */ - this.next = function() { - var result = conversion(buckets[bucketIndex][itemIndex]); - findNext(); - return result; - }; - - /* - * @member Iterator - * Remove the current item - */ - this.remove = function() { - removeItem(this.next()); - --itemIndex; - }; - - findNext(); - } - - function Set(conversion, isIn, removeItem) { - this.clear = function() { - hashMap.clear(); - }; - - this.contains = function(o) { - return isIn(o); - }; - - this.containsAll = function(o) { - var it = o.iterator(); - while (it.hasNext()) { - if (!this.contains(it.next())) { - return false; - } - } - return true; - }; - - this.isEmpty = function() { - return hashMap.isEmpty(); - }; - - this.iterator = function() { - return new Iterator(conversion, removeItem); - }; - - this.remove = function(o) { - if (this.contains(o)) { - removeItem(o); - return true; - } - return false; - }; - - this.removeAll = function(c) { - var it = c.iterator(); - var changed = false; - while (it.hasNext()) { - var item = it.next(); - if (this.contains(item)) { - removeItem(item); - changed = true; - } - } - return true; - }; - - this.retainAll = function(c) { - var it = this.iterator(); - var toRemove = []; - while (it.hasNext()) { - var entry = it.next(); - if (!c.contains(entry)) { - toRemove.push(entry); - } - } - for (var i = 0; i < toRemove.length; ++i) { - removeItem(toRemove[i]); - } - return toRemove.length > 0; - }; - - this.size = function() { - return hashMap.size(); - }; - - this.toArray = function() { - var result = new ArrayList(0); - var it = this.iterator(); - while (it.hasNext()) { - result.push(it.next()); - } - return result; - }; - } - - function Entry(pair) { - this._isIn = function(map) { - return map === hashMap && (pair.removed === undef); - }; - - this.equals = function(o) { - return virtEquals(pair.key, o.getKey()); - }; - - this.getKey = function() { - return pair.key; - }; - - this.getValue = function() { - return pair.value; - }; - - this.hashCode = function(o) { - return virtHashCode(pair.key); - }; - - this.setValue = function(value) { - var old = pair.value; - pair.value = value; - return old; - }; - } - - this.clear = function() { - count = 0; - buckets = new Array(initialCapacity); - }; - - this.clone = function() { - var map = new HashMap(); - map.putAll(this); - return map; - }; - - this.containsKey = function(key) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - return false; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - return true; - } - } - return false; - }; - - this.containsValue = function(value) { - for (var i = 0; i < buckets.length; ++i) { - var bucket = buckets[i]; - if (bucket === undef) { - continue; - } - for (var j = 0; j < bucket.length; ++j) { - if (virtEquals(bucket[j].value, value)) { - return true; - } - } - } - return false; - }; - - this.entrySet = function() { - return new Set( - - function(pair) { - return new Entry(pair); - }, - - function(pair) { - return pair.constructor === Entry && pair._isIn(hashMap); - }, - - function(pair) { - return hashMap.remove(pair.getKey()); - }); - }; - - this.get = function(key) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - return null; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - return bucket[i].value; - } - } - return null; - }; - - this.isEmpty = function() { - return count === 0; - }; - - this.keySet = function() { - return new Set( - - function(pair) { - return pair.key; - }, - - function(key) { - return hashMap.containsKey(key); - }, - - function(key) { - return hashMap.remove(key); - }); - }; - - this.put = function(key, value) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - ++count; - buckets[index] = [{ - key: key, - value: value - }]; - ensureLoad(); - return null; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - var previous = bucket[i].value; - bucket[i].value = value; - return previous; - } - } - ++count; - bucket.push({ - key: key, - value: value - }); - ensureLoad(); - return null; - }; - - this.putAll = function(m) { - var it = m.entrySet().iterator(); - while (it.hasNext()) { - var entry = it.next(); - this.put(entry.getKey(), entry.getValue()); - } - }; - - this.remove = function(key) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - return null; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - --count; - var previous = bucket[i].value; - bucket[i].removed = true; - if (bucket.length > 1) { - bucket.splice(i, 1); - } else { - buckets[index] = undef; - } - return previous; - } - } - return null; - }; - - this.size = function() { - return count; - }; - - this.values = function() { - var result = new ArrayList(0); - var it = this.entrySet().iterator(); - while (it.hasNext()) { - var entry = it.next(); - result.push(entry.getValue()); - } - return result; - }; - } - - return HashMap; - }()); - - var PVector = (function() { - function PVector(x, y, z) { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - } - - function createPVectorMethod(method) { - return function(v1, v2) { - var v = v1.get(); - v[method](v2); - return v; - }; - } - - function createSimplePVectorMethod(method) { - return function(v1, v2) { - return v1[method](v2); - }; - } - - var simplePVMethods = "dist dot cross".split(" "); - var method = simplePVMethods.length; - - PVector.angleBetween = function(v1, v2) { - return Math.acos(v1.dot(v2) / (v1.mag() * v2.mag())); - }; - - // Common vector operations for PVector - PVector.prototype = { - set: function(v, y, z) { - if (arguments.length === 1) { - this.set(v.x || v[0], v.y || v[1], v.z || v[2]); - } else { - this.x = v; - this.y = y; - this.z = z; - } - }, - get: function() { - return new PVector(this.x, this.y, this.z); - }, - mag: function() { - return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); - }, - add: function(v, y, z) { - if (arguments.length === 3) { - this.x += v; - this.y += y; - this.z += z; - } else if (arguments.length === 1) { - this.x += v.x; - this.y += v.y; - this.z += v.z; - } - }, - sub: function(v, y, z) { - if (arguments.length === 3) { - this.x -= v; - this.y -= y; - this.z -= z; - } else if (arguments.length === 1) { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z; - } - }, - mult: function(v) { - if (typeof v === 'number') { - this.x *= v; - this.y *= v; - this.z *= v; - } else if (typeof v === 'object') { - this.x *= v.x; - this.y *= v.y; - this.z *= v.z; - } - }, - div: function(v) { - if (typeof v === 'number') { - this.x /= v; - this.y /= v; - this.z /= v; - } else if (typeof v === 'object') { - this.x /= v.x; - this.y /= v.y; - this.z /= v.z; - } - }, - dist: function(v) { - var dx = this.x - v.x, - dy = this.y - v.y, - dz = this.z - v.z; - return Math.sqrt(dx * dx + dy * dy + dz * dz); - }, - dot: function(v, y, z) { - if (arguments.length === 3) { - return (this.x * v + this.y * y + this.z * z); - } else if (arguments.length === 1) { - return (this.x * v.x + this.y * v.y + this.z * v.z); - } - }, - cross: function(v) { - return new PVector(this.y * v.z - v.y * this.z, - this.z * v.x - v.z * this.x, - this.x * v.y - v.x * this.y); - }, - normalize: function() { - var m = this.mag(); - if (m > 0) { - this.div(m); - } - }, - limit: function(high) { - if (this.mag() > high) { - this.normalize(); - this.mult(high); - } - }, - heading2D: function() { - return (-Math.atan2(-this.y, this.x)); - }, - toString: function() { - return "[" + this.x + ", " + this.y + ", " + this.z + "]"; - }, - array: function() { - return [this.x, this.y, this.z]; - } - }; - - while (method--) { - PVector[simplePVMethods[method]] = createSimplePVectorMethod(simplePVMethods[method]); - } - - for (method in PVector.prototype) { - if (PVector.prototype.hasOwnProperty(method) && !PVector.hasOwnProperty(method)) { - PVector[method] = createPVectorMethod(method); - } - } - - return PVector; - }()); - - // Building defaultScope. Changing of the prototype protects - // internal Processing code from the changes in defaultScope - function DefaultScope() {} - DefaultScope.prototype = PConstants; - - var defaultScope = new DefaultScope(); - defaultScope.ArrayList = ArrayList; - defaultScope.HashMap = HashMap; - defaultScope.PVector = PVector; - //defaultScope.PImage = PImage; // TODO - //defaultScope.PShape = PShape; // TODO - //defaultScope.PShapeSVG = PShapeSVG; // TODO - - var Processing = this.Processing = function Processing(curElement, aCode) { - // Previously we allowed calling Processing as a func instead of ctor, but no longer. - if (!(this instanceof Processing)) { - throw("called Processing constructor as if it were a function: missing 'new'."); - } - - // When something new is added to "p." it must also be added to the "names" array. - // The names array contains the names of everything that is inside "p." - var p = this; - - // PJS specific (non-p5) methods and properties to externalize - p.externals = { - canvas: curElement, - context: undef, - sketch: undef, - onblur: function() {}, - onfocus: function() {} - }; - - p.name = 'Processing.js Instance'; // Set Processing defaults / environment variables - p.use3DContext = false; // default '2d' canvas context - - /** - * Confirms if a Processing program is "focused", meaning that it is - * active and will accept input from mouse or keyboard. This variable - * is "true" if it is focused and "false" if not. This variable is - * often used when you want to warn people they need to click on the - * browser before it will work. - */ - p.focused = true; - p.breakShape = false; - - // Glyph path storage for textFonts - p.glyphTable = {}; - - // Global vars for tracking mouse position - p.pmouseX = 0; - p.pmouseY = 0; - p.mouseX = 0; - p.mouseY = 0; - p.mouseButton = 0; - p.mouseScroll = 0; - - // Undefined event handlers to be replaced by user when needed - p.mouseClicked = undef; - p.mouseDragged = undef; - p.mouseMoved = undef; - p.mousePressed = undef; - p.mouseReleased = undef; - p.mouseScrolled = undef; - p.key = undef; - p.keyCode = undef; - p.keyPressed = function(){}; // needed to remove function checks - p.keyReleased = function(){}; - p.keyTyped = function(){}; - p.draw = undef; - p.setup = undef; - - // Remapped vars - p.__mousePressed = false; - p.__keyPressed = false; - p.__frameRate = 0; - - // The current animation frame - p.frameCount = 0; - - // The height/width of the canvas - p.width = curElement.width - 0; - p.height = curElement.height - 0; - - p.defineProperty = function(obj, name, desc) { - if("defineProperty" in Object) { - Object.defineProperty(obj, name, desc); - } else { - if (desc.hasOwnProperty("get")) { - obj.__defineGetter__(name, desc.get); - } - if (desc.hasOwnProperty("set")) { - obj.__defineSetter__(name, desc.set); - } - } - }; - - // "Private" variables used to maintain state - var curContext, - curSketch, - online = true, - doFill = true, - fillStyle = [1.0, 1.0, 1.0, 1.0], - currentFillColor = 0xFFFFFFFF, - isFillDirty = true, - doStroke = true, - strokeStyle = [0.8, 0.8, 0.8, 1.0], - currentStrokeColor = 0xFFFDFDFD, - isStrokeDirty = true, - lineWidth = 1, - loopStarted = false, - doLoop = true, - looping = 0, - curRectMode = PConstants.CORNER, - curEllipseMode = PConstants.CENTER, - normalX = 0, - normalY = 0, - normalZ = 0, - normalMode = PConstants.NORMAL_MODE_AUTO, - inDraw = false, - curFrameRate = 60, - curCursor = PConstants.ARROW, - oldCursor = curElement.style.cursor, - curMsPerFrame = 1, - curShape = PConstants.POLYGON, - curShapeCount = 0, - curvePoints = [], - curTightness = 0, - curveDet = 20, - curveInited = false, - bezDetail = 20, - colorModeA = 255, - colorModeX = 255, - colorModeY = 255, - colorModeZ = 255, - pathOpen = false, - mouseDragging = false, - curColorMode = PConstants.RGB, - curTint = null, - curTextSize = 12, - curTextFont = "Arial", - curTextLeading = 14, - getLoaded = false, - start = new Date().getTime(), - timeSinceLastFPS = start, - framesSinceLastFPS = 0, - textcanvas, - curveBasisMatrix, - curveToBezierMatrix, - curveDrawMatrix, - bezierDrawMatrix, - bezierBasisInverse, - bezierBasisMatrix, - // Keys and Keystrokes - firstCodedDown = true, // first coded key stroke - firstEDGKeyDown = true, // first Enter - Delete Google key stroke - firstEDMKeyDown = true, // first Enter - Delete Mozilla key stroke - firstMKeyDown = true, // first Mozilla key stroke - firstGKeyDown = true, // first Google key stroke - gRefire = false, // Google refire - curContextCache = { attributes: {}, locations: {} }, - // Shaders - programObject3D, - programObject2D, - programObjectUnlitShape, - boxBuffer, - boxNormBuffer, - boxOutlineBuffer, - rectBuffer, - rectNormBuffer, - sphereBuffer, - lineBuffer, - fillBuffer, - fillColorBuffer, - strokeColorBuffer, - pointBuffer, - shapeTexVBO, - canTex, // texture for createGraphics - textTex, // texture for 3d tex - curTexture = {width:0,height:0}, - curTextureMode = PConstants.IMAGE, - usingTexture = false, - textBuffer, - textureBuffer, - indexBuffer, - // Text alignment - horizontalTextAlignment = PConstants.LEFT, - verticalTextAlignment = PConstants.BASELINE, - baselineOffset = 0.2, // percent - tMode = PConstants.MODEL, - // Pixels cache - originalContext, - proxyContext = null, - isContextReplaced = false, - setPixelsCached, - maxPixelsCached = 1000, - codedKeys = [ PConstants.SHIFT, PConstants.CONTROL, PConstants.ALT, PConstants.CAPSLK, PConstants.PGUP, PConstants.PGDN, - PConstants.END, PConstants.HOME, PConstants.LEFT, PConstants.UP, PConstants.RIGHT, PConstants.DOWN, PConstants.NUMLK, - PConstants.INS, PConstants.F1, PConstants.F2, PConstants.F3, PConstants.F4, PConstants.F5, PConstants.F6, PConstants.F7, - PConstants.F8, PConstants.F9, PConstants.F10, PConstants.F11, PConstants.F12 ]; - - // Get padding and border style widths for mouse offsets - var stylePaddingLeft, stylePaddingTop, styleBorderLeft, styleBorderTop; - - if (document.defaultView && document.defaultView.getComputedStyle) { - stylePaddingLeft = parseInt(document.defaultView.getComputedStyle(curElement, null)['paddingLeft'], 10) || 0; - stylePaddingTop = parseInt(document.defaultView.getComputedStyle(curElement, null)['paddingTop'], 10) || 0; - styleBorderLeft = parseInt(document.defaultView.getComputedStyle(curElement, null)['borderLeftWidth'], 10) || 0; - styleBorderTop = parseInt(document.defaultView.getComputedStyle(curElement, null)['borderTopWidth'], 10) || 0; - } - - // User can only have MAX_LIGHTS lights - var lightCount = 0; - - //sphere stuff - var sphereDetailV = 0, - sphereDetailU = 0, - sphereX = [], - sphereY = [], - sphereZ = [], - sinLUT = new Array(PConstants.SINCOS_LENGTH), - cosLUT = new Array(PConstants.SINCOS_LENGTH), - sphereVerts, - sphereNorms; - - // Camera defaults and settings - var cam, - cameraInv, - forwardTransform, - reverseTransform, - modelView, - modelViewInv, - userMatrixStack, - inverseCopy, - projection, - manipulatingCamera = false, - frustumMode = false, - cameraFOV = 60 * (Math.PI / 180), - cameraX = curElement.width / 2, - cameraY = curElement.height / 2, - cameraZ = cameraY / Math.tan(cameraFOV / 2), - cameraNear = cameraZ / 10, - cameraFar = cameraZ * 10, - cameraAspect = curElement.width / curElement.height; - - var vertArray = [], - curveVertArray = [], - curveVertCount = 0, - isCurve = false, - isBezier = false, - firstVert = true; - - //PShape stuff - var curShapeMode = PConstants.CORNER; - - var colors = { - aliceblue: "#f0f8ff", - antiquewhite: "#faebd7", - aqua: "#00ffff", - aquamarine: "#7fffd4", - azure: "#f0ffff", - beige: "#f5f5dc", - bisque: "#ffe4c4", - black: "#000000", - blanchedalmond: "#ffebcd", - blue: "#0000ff", - blueviolet: "#8a2be2", - brown: "#a52a2a", - burlywood: "#deb887", - cadetblue: "#5f9ea0", - chartreuse: "#7fff00", - chocolate: "#d2691e", - coral: "#ff7f50", - cornflowerblue: "#6495ed", - cornsilk: "#fff8dc", - crimson: "#dc143c", - cyan: "#00ffff", - darkblue: "#00008b", - darkcyan: "#008b8b", - darkgoldenrod: "#b8860b", - darkgray: "#a9a9a9", - darkgreen: "#006400", - darkkhaki: "#bdb76b", - darkmagenta: "#8b008b", - darkolivegreen: "#556b2f", - darkorange: "#ff8c00", - darkorchid: "#9932cc", - darkred: "#8b0000", - darksalmon: "#e9967a", - darkseagreen: "#8fbc8f", - darkslateblue: "#483d8b", - darkslategray: "#2f4f4f", - darkturquoise: "#00ced1", - darkviolet: "#9400d3", - deeppink: "#ff1493", - deepskyblue: "#00bfff", - dimgray: "#696969", - dodgerblue: "#1e90ff", - firebrick: "#b22222", - floralwhite: "#fffaf0", - forestgreen: "#228b22", - fuchsia: "#ff00ff", - gainsboro: "#dcdcdc", - ghostwhite: "#f8f8ff", - gold: "#ffd700", - goldenrod: "#daa520", - gray: "#808080", - green: "#008000", - greenyellow: "#adff2f", - honeydew: "#f0fff0", - hotpink: "#ff69b4", - indianred: "#cd5c5c", - indigo: "#4b0082", - ivory: "#fffff0", - khaki: "#f0e68c", - lavender: "#e6e6fa", - lavenderblush: "#fff0f5", - lawngreen: "#7cfc00", - lemonchiffon: "#fffacd", - lightblue: "#add8e6", - lightcoral: "#f08080", - lightcyan: "#e0ffff", - lightgoldenrodyellow: "#fafad2", - lightgrey: "#d3d3d3", - lightgreen: "#90ee90", - lightpink: "#ffb6c1", - lightsalmon: "#ffa07a", - lightseagreen: "#20b2aa", - lightskyblue: "#87cefa", - lightslategray: "#778899", - lightsteelblue: "#b0c4de", - lightyellow: "#ffffe0", - lime: "#00ff00", - limegreen: "#32cd32", - linen: "#faf0e6", - magenta: "#ff00ff", - maroon: "#800000", - mediumaquamarine: "#66cdaa", - mediumblue: "#0000cd", - mediumorchid: "#ba55d3", - mediumpurple: "#9370d8", - mediumseagreen: "#3cb371", - mediumslateblue: "#7b68ee", - mediumspringgreen: "#00fa9a", - mediumturquoise: "#48d1cc", - mediumvioletred: "#c71585", - midnightblue: "#191970", - mintcream: "#f5fffa", - mistyrose: "#ffe4e1", - moccasin: "#ffe4b5", - navajowhite: "#ffdead", - navy: "#000080", - oldlace: "#fdf5e6", - olive: "#808000", - olivedrab: "#6b8e23", - orange: "#ffa500", - orangered: "#ff4500", - orchid: "#da70d6", - palegoldenrod: "#eee8aa", - palegreen: "#98fb98", - paleturquoise: "#afeeee", - palevioletred: "#d87093", - papayawhip: "#ffefd5", - peachpuff: "#ffdab9", - peru: "#cd853f", - pink: "#ffc0cb", - plum: "#dda0dd", - powderblue: "#b0e0e6", - purple: "#800080", - red: "#ff0000", - rosybrown: "#bc8f8f", - royalblue: "#4169e1", - saddlebrown: "#8b4513", - salmon: "#fa8072", - sandybrown: "#f4a460", - seagreen: "#2e8b57", - seashell: "#fff5ee", - sienna: "#a0522d", - silver: "#c0c0c0", - skyblue: "#87ceeb", - slateblue: "#6a5acd", - slategray: "#708090", - snow: "#fffafa", - springgreen: "#00ff7f", - steelblue: "#4682b4", - tan: "#d2b48c", - teal: "#008080", - thistle: "#d8bfd8", - tomato: "#ff6347", - turquoise: "#40e0d0", - violet: "#ee82ee", - wheat: "#f5deb3", - white: "#ffffff", - whitesmoke: "#f5f5f5", - yellow: "#ffff00", - yellowgreen: "#9acd32" - }; - - // Stores states for pushStyle() and popStyle(). - var styleArray = new Array(0); - - // Vertices are specified in a counter-clockwise order - // triangles are in this order: back, front, right, bottom, left, top - var boxVerts = new Float32Array([ - 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, - -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, - -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, - 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, - 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, - -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, - -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, - -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, - -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5]); - - var boxOutlineVerts = new Float32Array([ - 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, - -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, - 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, - -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, - 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, - -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5]); - - var boxNorms = new Float32Array([ - 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, - 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, - 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, - -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, - 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]); - - // These verts are used for the fill and stroke using TRIANGLE_FAN and LINE_LOOP - var rectVerts = new Float32Array([0,0,0, 0,1,0, 1,1,0, 1,0,0]); - - var rectNorms = new Float32Array([0,0,-1, 0,0,-1, 0,0,-1, 0,0,-1]); - - // Vertex shader for points and lines - var vShaderSrcUnlitShape = - "varying vec4 frontColor;" + - - "attribute vec3 aVertex;" + - "attribute vec4 aColor;" + - - "uniform mat4 uView;" + - "uniform mat4 uProjection;" + - - "void main(void) {" + - " frontColor = aColor;" + - " gl_Position = uProjection * uView * vec4(aVertex, 1.0);" + - "}"; - - var fShaderSrcUnlitShape = - "#ifdef GL_ES\n" + - "precision highp float;\n" + - "#endif\n" + - - "varying vec4 frontColor;" + - - "void main(void){" + - " gl_FragColor = frontColor;" + - "}"; - - // Vertex shader for points and lines - var vertexShaderSource2D = - "varying vec4 frontColor;" + - - "attribute vec3 Vertex;" + - "attribute vec2 aTextureCoord;" + - "uniform vec4 color;" + - - "uniform mat4 model;" + - "uniform mat4 view;" + - "uniform mat4 projection;" + - "uniform float pointSize;" + - "varying vec2 vTextureCoord;"+ - - "void main(void) {" + - " gl_PointSize = pointSize;" + - " frontColor = color;" + - " gl_Position = projection * view * model * vec4(Vertex, 1.0);" + - " vTextureCoord = aTextureCoord;" + - "}"; - - var fragmentShaderSource2D = - "#ifdef GL_ES\n" + - "precision highp float;\n" + - "#endif\n" + - - "varying vec4 frontColor;" + - "varying vec2 vTextureCoord;"+ - - "uniform sampler2D uSampler;"+ - "uniform int picktype;"+ - - "void main(void){" + - " if(picktype == 0){"+ - " gl_FragColor = frontColor;" + - " }" + - " else if(picktype == 1){"+ - " float alpha = texture2D(uSampler, vTextureCoord).a;"+ - " gl_FragColor = vec4(frontColor.rgb*alpha, alpha);\n"+ - " }"+ - "}"; - - // Vertex shader for boxes and spheres - var vertexShaderSource3D = - "varying vec4 frontColor;" + - - "attribute vec3 Vertex;" + - "attribute vec3 Normal;" + - "attribute vec4 aColor;" + - "attribute vec2 aTexture;" + - "varying vec2 vTexture;" + - - "uniform vec4 color;" + - - "uniform bool usingMat;" + - "uniform vec3 specular;" + - "uniform vec3 mat_emissive;" + - "uniform vec3 mat_ambient;" + - "uniform vec3 mat_specular;" + - "uniform float shininess;" + - - "uniform mat4 model;" + - "uniform mat4 view;" + - "uniform mat4 projection;" + - "uniform mat4 normalTransform;" + - - "uniform int lightCount;" + - "uniform vec3 falloff;" + - - "struct Light {" + - " bool dummy;" + - " int type;" + - " vec3 color;" + - " vec3 position;" + - " vec3 direction;" + - " float angle;" + - " vec3 halfVector;" + - " float concentration;" + - "};" + - "uniform Light lights[8];" + - - "void AmbientLight( inout vec3 totalAmbient, in vec3 ecPos, in Light light ) {" + - // Get the vector from the light to the vertex - // Get the distance from the current vector to the light position - " float d = length( light.position - ecPos );" + - " float attenuation = 1.0 / ( falloff[0] + ( falloff[1] * d ) + ( falloff[2] * d * d ));" + " totalAmbient += light.color * attenuation;" + - "}" + - - "void DirectionalLight( inout vec3 col, in vec3 ecPos, inout vec3 spec, in vec3 vertNormal, in Light light ) {" + - " float powerfactor = 0.0;" + - " float nDotVP = max(0.0, dot( vertNormal, light.position ));" + - " float nDotVH = max(0.0, dot( vertNormal, normalize( light.position-ecPos )));" + - - " if( nDotVP != 0.0 ){" + - " powerfactor = pow( nDotVH, shininess );" + - " }" + - - " col += light.color * nDotVP;" + - " spec += specular * powerfactor;" + - "}" + - - "void PointLight( inout vec3 col, inout vec3 spec, in vec3 vertNormal, in vec3 ecPos, in vec3 eye, in Light light ) {" + - " float powerfactor;" + - - // Get the vector from the light to the vertex - " vec3 VP = light.position - ecPos;" + - - // Get the distance from the current vector to the light position - " float d = length( VP ); " + - - // Normalize the light ray so it can be used in the dot product operation. - " VP = normalize( VP );" + - - " float attenuation = 1.0 / ( falloff[0] + ( falloff[1] * d ) + ( falloff[2] * d * d ));" + - - " float nDotVP = max( 0.0, dot( vertNormal, VP ));" + - " vec3 halfVector = normalize( VP + eye );" + - " float nDotHV = max( 0.0, dot( vertNormal, halfVector ));" + - - " if( nDotVP == 0.0) {" + - " powerfactor = 0.0;" + - " }" + - " else{" + - " powerfactor = pow( nDotHV, shininess );" + - " }" + - - " spec += specular * powerfactor * attenuation;" + - " col += light.color * nDotVP * attenuation;" + - "}" + - - /* - */ - "void SpotLight( inout vec3 col, inout vec3 spec, in vec3 vertNormal, in vec3 ecPos, in vec3 eye, in Light light ) {" + - " float spotAttenuation;" + - " float powerfactor;" + - - // calculate the vector from the current vertex to the light. - " vec3 VP = light.position - ecPos; " + - " vec3 ldir = normalize( light.direction );" + - - // get the distance from the spotlight and the vertex - " float d = length( VP );" + - " VP = normalize( VP );" + - - " float attenuation = 1.0 / ( falloff[0] + ( falloff[1] * d ) + ( falloff[2] * d * d ) );" + - - // dot product of the vector from vertex to light and light direction. - " float spotDot = dot( VP, ldir );" + - - // if the vertex falls inside the cone - " if( spotDot < cos( light.angle ) ) {" + - " spotAttenuation = pow( spotDot, light.concentration );" + - " }" + - " else{" + - " spotAttenuation = 1.0;" + - " }" + - " attenuation *= spotAttenuation;" + - - " float nDotVP = max( 0.0, dot( vertNormal, VP ));" + - " vec3 halfVector = normalize( VP + eye );" + - " float nDotHV = max( 0.0, dot( vertNormal, halfVector ));" + - - " if( nDotVP == 0.0 ) {" + - " powerfactor = 0.0;" + - " }" + - " else {" + - " powerfactor = pow( nDotHV, shininess );" + - " }" + - - " spec += specular * powerfactor * attenuation;" + - " col += light.color * nDotVP * attenuation;" + - "}" + - - "void main(void) {" + - " vec3 finalAmbient = vec3( 0.0, 0.0, 0.0 );" + - " vec3 finalDiffuse = vec3( 0.0, 0.0, 0.0 );" + - " vec3 finalSpecular = vec3( 0.0, 0.0, 0.0 );" + - - " vec4 col = color;" + - " if(color[0] == -1.0){" + - " col = aColor;" + - " }" + - - " vec3 norm = vec3( normalTransform * vec4( Normal, 0.0 ) );" + - - " vec4 ecPos4 = view * model * vec4(Vertex,1.0);" + - " vec3 ecPos = (vec3(ecPos4))/ecPos4.w;" + - " vec3 eye = vec3( 0.0, 0.0, 1.0 );" + - - // If there were no lights this draw call, just use the - // assigned fill color of the shape and the specular value - " if( lightCount == 0 ) {" + - " frontColor = col + vec4(mat_specular,1.0);" + - " }" + - " else {" + - " for( int i = 0; i < lightCount; i++ ) {" + - " if( lights[i].type == 0 ) {" + - " AmbientLight( finalAmbient, ecPos, lights[i] );" + - " }" + - " else if( lights[i].type == 1 ) {" + - " DirectionalLight( finalDiffuse,ecPos, finalSpecular, norm, lights[i] );" + - " }" + - " else if( lights[i].type == 2 ) {" + - " PointLight( finalDiffuse, finalSpecular, norm, ecPos, eye, lights[i] );" + - " }" + - " else if( lights[i].type == 3 ) {" + - " SpotLight( finalDiffuse, finalSpecular, norm, ecPos, eye, lights[i] );" + - " }" + - " }" + - - " if( usingMat == false ) {" + - " frontColor = vec4( " + - " vec3(col) * finalAmbient +" + - " vec3(col) * finalDiffuse +" + - " vec3(col) * finalSpecular," + - " col[3] );" + - " }" + - " else{" + - " frontColor = vec4( " + - " mat_emissive + " + - " (vec3(col) * mat_ambient * finalAmbient) + " + - " (vec3(col) * finalDiffuse) + " + - " (mat_specular * finalSpecular), " + - " col[3] );" + - " }" + - " }" + - " vTexture.xy = aTexture.xy;" + - " gl_Position = projection * view * model * vec4( Vertex, 1.0 );" + - "}"; - - var fragmentShaderSource3D = - "#ifdef GL_ES\n" + - "precision highp float;\n" + - "#endif\n" + - - "varying vec4 frontColor;" + - - "uniform sampler2D sampler;" + - "uniform bool usingTexture;" + - "varying vec2 vTexture;" + - - // In Processing, when a texture is used, the fill color is ignored - "void main(void){" + - " if(usingTexture){" + - " gl_FragColor = vec4(texture2D(sampler, vTexture.xy));" + - " }"+ - " else{" + - " gl_FragColor = frontColor;" + - " }" + - "}"; - - //////////////////////////////////////////////////////////////////////////// - // 3D Functions - //////////////////////////////////////////////////////////////////////////// - - /* - * Sets a uniform variable in a program object to a particular - * value. Before calling this function, ensure the correct - * program object has been installed as part of the current - * rendering state by calling useProgram. - * - * On some systems, if the variable exists in the shader but isn't used, - * the compiler will optimize it out and this function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {float | Array} varValue either a scalar value or an Array - * - * @returns none - * - * @see uniformi - * @see uniformMatrix - */ - function uniformf(cacheId, programObj, varName, varValue) { - var varLocation = curContextCache.locations[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getUniformLocation(programObj, varName); - curContextCache.locations[cacheId] = varLocation; - } - // the variable won't be found if it was optimized out. - if (varLocation !== -1) { - if (varValue.length === 4) { - curContext.uniform4fv(varLocation, varValue); - } else if (varValue.length === 3) { - curContext.uniform3fv(varLocation, varValue); - } else if (varValue.length === 2) { - curContext.uniform2fv(varLocation, varValue); - } else { - curContext.uniform1f(varLocation, varValue); - } - } - } - - /** - * Sets a uniform int or int array in a program object to a particular - * value. Before calling this function, ensure the correct - * program object has been installed as part of the current - * rendering state. - * - * On some systems, if the variable exists in the shader but isn't used, - * the compiler will optimize it out and this function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {int | Array} varValue either a scalar value or an Array - * - * @returns none - * - * @see uniformf - * @see uniformMatrix - */ - function uniformi(cacheId, programObj, varName, varValue) { - var varLocation = curContextCache.locations[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getUniformLocation(programObj, varName); - curContextCache.locations[cacheId] = varLocation; - } - // the variable won't be found if it was optimized out. - if (varLocation !== -1) { - if (varValue.length === 4) { - curContext.uniform4iv(varLocation, varValue); - } else if (varValue.length === 3) { - curContext.uniform3iv(varLocation, varValue); - } else if (varValue.length === 2) { - curContext.uniform2iv(varLocation, varValue); - } else { - curContext.uniform1i(varLocation, varValue); - } - } - } - - /** - * Binds the VBO, sets the vertex attribute data for the program - * object and enables the attribute. - * - * On some systems, if the attribute exists in the shader but - * isn't used, the compiler will optimize it out and this - * function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {int} size the number of components per vertex attribute - * @param {WebGLBuffer} VBO Vertex Buffer Object - * - * @returns none - * - * @see disableVertexAttribPointer - */ - function vertexAttribPointer(cacheId, programObj, varName, size, VBO) { - var varLocation = curContextCache.attributes[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getAttribLocation(programObj, varName); - curContextCache.attributes[cacheId] = varLocation; - } - if (varLocation !== -1) { - curContext.bindBuffer(curContext.ARRAY_BUFFER, VBO); - curContext.vertexAttribPointer(varLocation, size, curContext.FLOAT, false, 0, 0); - curContext.enableVertexAttribArray(varLocation); - } - } - - /** - * Disables a program object attribute from being sent to WebGL. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName name of the attribute - * - * @returns none - * - * @see vertexAttribPointer - */ - function disableVertexAttribPointer(cacheId, programObj, varName){ - var varLocation = curContextCache.attributes[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getAttribLocation(programObj, varName); - curContextCache.attributes[cacheId] = varLocation; - } - if (varLocation !== -1) { - curContext.disableVertexAttribArray(varLocation); - } - } - - /** - * Sets the value of a uniform matrix variable in a program - * object. Before calling this function, ensure the correct - * program object has been installed as part of the current - * rendering state. - * - * On some systems, if the variable exists in the shader but - * isn't used, the compiler will optimize it out and this - * function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {boolean} transpose must be false - * @param {Array} matrix an array of 4, 9 or 16 values - * - * @returns none - * - * @see uniformi - * @see uniformf - */ - function uniformMatrix(cacheId, programObj, varName, transpose, matrix) { - var varLocation = curContextCache.locations[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getUniformLocation(programObj, varName); - curContextCache.locations[cacheId] = varLocation; - } - // the variable won't be found if it was optimized out. - if (varLocation !== -1) { - if (matrix.length === 16) { - curContext.uniformMatrix4fv(varLocation, transpose, matrix); - } else if (matrix.length === 9) { - curContext.uniformMatrix3fv(varLocation, transpose, matrix); - } else { - curContext.uniformMatrix2fv(varLocation, transpose, matrix); - } - } - } - - var imageModeCorner = function imageModeCorner(x, y, w, h, whAreSizes) { - return { - x: x, - y: y, - w: w, - h: h - }; - }; - var imageModeConvert = imageModeCorner; - - var imageModeCorners = function imageModeCorners(x, y, w, h, whAreSizes) { - return { - x: x, - y: y, - w: whAreSizes ? w : w - x, - h: whAreSizes ? h : h - y - }; - }; - - var imageModeCenter = function imageModeCenter(x, y, w, h, whAreSizes) { - return { - x: x - w / 2, - y: y - h / 2, - w: w, - h: h - }; - }; - - /** - * Creates a WebGL program object. - * - * @param {String} vetexShaderSource - * @param {String} fragmentShaderSource - * - * @returns {WebGLProgram} A program object - */ - var createProgramObject = function(curContext, vetexShaderSource, fragmentShaderSource) { - var vertexShaderObject = curContext.createShader(curContext.VERTEX_SHADER); - curContext.shaderSource(vertexShaderObject, vetexShaderSource); - curContext.compileShader(vertexShaderObject); - if (!curContext.getShaderParameter(vertexShaderObject, curContext.COMPILE_STATUS)) { - throw curContext.getShaderInfoLog(vertexShaderObject); - } - - var fragmentShaderObject = curContext.createShader(curContext.FRAGMENT_SHADER); - curContext.shaderSource(fragmentShaderObject, fragmentShaderSource); - curContext.compileShader(fragmentShaderObject); - if (!curContext.getShaderParameter(fragmentShaderObject, curContext.COMPILE_STATUS)) { - throw curContext.getShaderInfoLog(fragmentShaderObject); - } - - var programObject = curContext.createProgram(); - curContext.attachShader(programObject, vertexShaderObject); - curContext.attachShader(programObject, fragmentShaderObject); - curContext.linkProgram(programObject); - if (!curContext.getProgramParameter(programObject, curContext.LINK_STATUS)) { - throw "Error linking shaders."; - } - - return programObject; - }; - - //////////////////////////////////////////////////////////////////////////// - // Char handling - //////////////////////////////////////////////////////////////////////////// - var charMap = {}; - - var Char = p.Character = function Char(chr) { - if (typeof chr === 'string' && chr.length === 1) { - this.code = chr.charCodeAt(0); - } else { - this.code = NaN; - } - - return (charMap[this.code] === undef) ? charMap[this.code] = this : charMap[this.code]; - }; - - Char.prototype.toString = function() { - return String.fromCharCode(this.code); - }; - - Char.prototype.valueOf = function() { - return this.code; - }; - - /** - * Datatype for storing shapes. Processing can currently load and display SVG (Scalable Vector Graphics) shapes. - * Before a shape is used, it must be loaded with the loadShape() function. The shape() function is used to draw the shape to the display window. - * The PShape object contain a group of methods, linked below, that can operate on the shape data. - *

    The loadShape() method supports SVG files created with Inkscape and Adobe Illustrator. - * It is not a full SVG implementation, but offers some straightforward support for handling vector data. - * - * @param {int} family the shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY - * - * @see #shape() - * @see #loadShape() - * @see #shapeMode() - */ - var PShape = p.PShape = function(family) { - this.family = family || PConstants.GROUP; - this.visible = true; - this.style = true; - this.children = []; - this.nameTable = []; - this.params = []; - this.name = ""; - this.image = null; //type PImage - this.matrix = null; - this.kind = null; - this.close = null; - this.width = null; - this.height = null; - this.parent = null; - - /** - * PShape methods - * missing: findChild(), apply(), contains(), findChild(), getPrimitive(), getParams(), getVertex() , getVertexCount(), - * getVertexCode() , getVertexCodes() , getVertexCodeCount(), getVertexX(), getVertexY(), getVertexZ() - */ - - /** - * @member PShape - * The isVisible() function returns a boolean value "true" if the image is set to be visible, "false" if not. This is modified with the setVisible() parameter. - *

    The visibility of a shape is usually controlled by whatever program created the SVG file. - * For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator. - * - * @return {boolean} returns "true" if the image is set to be visible, "false" if not - */ - this.isVisible = function(){ - return this.visible; - }; - /** - * @member PShape - * The setVisible() function sets the shape to be visible or invisible. This is determined by the value of the visible parameter. - *

    The visibility of a shape is usually controlled by whatever program created the SVG file. - * For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator. - * - * @param {boolean} visible "false" makes the shape invisible and "true" makes it visible - */ - this.setVisible = function (visible){ - this.visible = visible; - }; - /** - * @member PShape - * The disableStyle() function disables the shape's style data and uses Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints. - * Overrides this shape's style information and uses PGraphics styles and colors. Identical to ignoreStyles(true). Also disables styles for all child shapes. - */ - this.disableStyle = function(){ - this.style = false; - for(var i = 0; i < this.children.length; i++) - { - this.children[i].disableStyle(); - } - }; - /** - * @member PShape - * The enableStyle() function enables the shape's style data and ignores Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints. - */ - this.enableStyle = function(){ - this.style = true; - for(var i = 0; i < this.children.length; i++) - { - this.children[i].enableStyle(); - } - }; - /** - * @member PShape - * The getFamily function returns the shape type - * - * @return {int} the shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY - */ - this.getFamily = function(){ - return this.family; - }; - /** - * @member PShape - * The getWidth() function gets the width of the drawing area (not necessarily the shape boundary). - */ - this.getWidth = function(){ - return this.width; - }; - /** - * @member PShape - * The getHeight() function gets the height of the drawing area (not necessarily the shape boundary). - */ - this.getHeight = function(){ - return this.height; - }; - /** - * @member PShape - * The setName() function sets the name of the shape - * - * @param {String} name the name of the shape - */ - this.setName = function(name){ - this.name = name; - }; - /** - * @member PShape - * The getName() function returns the name of the shape - * - * @return {String} the name of the shape - */ - this.getName = function(){ - return this.name; - }; - /** - * @member PShape - * Called by the following (the shape() command adds the g) - * PShape s = loadShapes("blah.svg"); - * shape(s); - */ - this.draw = function(){ - if (this.visible) { - this.pre(); - this.drawImpl(); - this.post(); - } - }; - /** - * @member PShape - * the drawImpl() function draws the SVG document. - */ - this.drawImpl = function(){ - if (this.family === PConstants.GROUP) { - this.drawGroup(); - } else if (this.family === PConstants.PRIMITIVE) { - this.drawPrimitive(); - } else if (this.family === PConstants.GEOMETRY) { - this.drawGeometry(); - } else if (this.family === PConstants.PATH) { - this.drawPath(); - } - }; - /** - * @member PShape - * The drawPath() function draws the part of the SVG document. - */ - this.drawPath = function(){ - if (this.vertices.length === 0) { return; } - - p.beginShape(); - var i; - if (this.vertexCodes.length === 0) { // each point is a simple vertex - if (this.vertices[0].length === 2) { // drawing 2D vertices - for (i = 0; i < this.vertices.length; i++) { - p.vertex(this.vertices[i][0], this.vertices[i][1]); - } - } else { // drawing 3D vertices - for (i = 0; i < this.vertices.length; i++) { - p.vertex(this.vertices[i][0], this.vertices[i][1], this.vertices[i][2]); - } - } - } else { // coded set of vertices - var index = 0; - var j; - if (this.vertices[0].length === 2) { // drawing a 2D path - for (j = 0; j < this.vertexCodes.length; j++) { - switch (this.vertexCodes[j]) { - case PConstants.VERTEX: - p.vertex(this.vertices[index][0], this.vertices[index][1]); - if ( this.vertices[index]["moveTo"] === true) { - vertArray[vertArray.length-1]["moveTo"] = true; - } else if ( this.vertices[index]["moveTo"] === false) { - vertArray[vertArray.length-1]["moveTo"] = false; - } - p.breakShape = false; - index++; - break; - case PConstants.BEZIER_VERTEX: - p.bezierVertex(this.vertices[index+0][0], this.vertices[index+0][1], - this.vertices[index+1][0], this.vertices[index+1][1], - this.vertices[index+2][0], this.vertices[index+2][1]); - index += 3; - break; - case PConstants.CURVE_VERTEX: - p.curveVertex(this.vertices[index][0], this.vertices[index][1]); - index++; - break; - case PConstants.BREAK: - p.breakShape = true; - break; - } - } - } else { // drawing a 3D path - for (j = 0; j < this.vertexCodes.length; j++) { - switch (this.vertexCodes[j]) { - case PConstants.VERTEX: - p.vertex(this.vertices[index][0], this.vertices[index][1], this.vertices[index][2]); - if (this.vertices[index]["moveTo"] === true) { - vertArray[vertArray.length-1]["moveTo"] = true; - } else if (this.vertices[index]["moveTo"] === false) { - vertArray[vertArray.length-1]["moveTo"] = false; - } - p.breakShape = false; - break; - case PConstants.BEZIER_VERTEX: - p.bezierVertex(this.vertices[index+0][0], this.vertices[index+0][1], this.vertices[index+0][2], - this.vertices[index+1][0], this.vertices[index+1][1], this.vertices[index+1][2], - this.vertices[index+2][0], this.vertices[index+2][1], this.vertices[index+2][2]); - index += 3; - break; - case PConstants.CURVE_VERTEX: - p.curveVertex(this.vertices[index][0], this.vertices[index][1], this.vertices[index][2]); - index++; - break; - case PConstants.BREAK: - p.breakShape = true; - break; - } - } - } - } - p.endShape(this.close ? PConstants.CLOSE : PConstants.OPEN); - }; - /** - * @member PShape - * The drawGeometry() function draws the geometry part of the SVG document. - */ - this.drawGeometry = function() { - p.beginShape(this.kind); - var i; - if (this.style) { - for (i = 0; i < this.vertices.length; i++) { - p.vertex(this.vertices[i]); - } - } else { - for (i = 0; i < this.vertices.length; i++) { - var vert = this.vertices[i]; - if (vert[2] === 0) { - p.vertex(vert[0], vert[1]); - } else { - p.vertex(vert[0], vert[1], vert[2]); - } - } - } - p.endShape(); - }; - /** - * @member PShape - * The drawGroup() function draws the part of the SVG document. - */ - this.drawGroup = function() { - for (var i = 0; i < this.children.length; i++) { - this.children[i].draw(); - } - }; - /** - * @member PShape - * The drawPrimitive() function draws SVG document shape elements. These can be point, line, triangle, quad, rect, ellipse, arc, box, or sphere. - */ - this.drawPrimitive = function() { - switch (this.kind) { - case PConstants.POINT: - p.point(this.params[0], this.params[1]); - break; - case PConstants.LINE: - if (this.params.length === 4) { // 2D - p.line(this.params[0], this.params[1], - this.params[2], this.params[3]); - } else { // 3D - p.line(this.params[0], this.params[1], this.params[2], - this.params[3], this.params[4], this.params[5]); - } - break; - case PConstants.TRIANGLE: - p.triangle(this.params[0], this.params[1], - this.params[2], this.params[3], - this.params[4], this.params[5]); - break; - case PConstants.QUAD: - p.quad(this.params[0], this.params[1], - this.params[2], this.params[3], - this.params[4], this.params[5], - this.params[6], this.params[7]); - break; - case PConstants.RECT: - if (this.image !== null) { - p.imageMode(PConstants.CORNER); - p.image(this.image, this.params[0], this.params[1], this.params[2], this.params[3]); - } else { - p.rectMode(PConstants.CORNER); - p.rect(this.params[0], this.params[1], this.params[2], this.params[3]); - } - break; - case PConstants.ELLIPSE: - p.ellipseMode(PConstants.CORNER); - p.ellipse(this.params[0], this.params[1], this.params[2], this.params[3]); - break; - case PConstants.ARC: - p.ellipseMode(PConstants.CORNER); - p.arc(this.params[0], this.params[1], this.params[2], this.params[3], this.params[4], this.params[5]); - break; - case PConstants.BOX: - if (this.params.length === 1) { - p.box(this.params[0]); - } else { - p.box(this.params[0], this.params[1], this.params[2]); - } - break; - case PConstants.SPHERE: - p.sphere(this.params[0]); - break; - } - }; - /** - * @member PShape - * The pre() function performs the preparations before the SVG is drawn. This includes doing transformations and storing previous styles. - */ - this.pre = function() { - if (this.matrix) { - p.pushMatrix(); - curContext.transform(this.matrix.elements[0], this.matrix.elements[3], this.matrix.elements[1], this.matrix.elements[4], this.matrix.elements[2], this.matrix.elements[5]); - //p.applyMatrix(this.matrix.elements[0],this.matrix.elements[0]); - } - if (this.style) { - p.pushStyle(); - this.styles(); - } - }; - /** - * @member PShape - * The post() function performs the necessary actions after the SVG is drawn. This includes removing transformations and removing added styles. - */ - this.post = function() { - if (this.matrix) { - p.popMatrix(); - } - if (this.style) { - p.popStyle(); - } - }; - /** - * @member PShape - * The styles() function changes the Processing's current styles - */ - this.styles = function() { - if (this.stroke) { - p.stroke(this.strokeColor); - p.strokeWeight(this.strokeWeight); - p.strokeCap(this.strokeCap); - p.strokeJoin(this.strokeJoin); - } else { - p.noStroke(); - } - - if (this.fill) { - p.fill(this.fillColor); - - } else { - p.noFill(); - } - }; - /** - * @member PShape - * The getChild() function extracts a child shape from a parent shape. Specify the name of the shape with the target parameter or the - * layer position of the shape to get with the index parameter. - * The shape is returned as a PShape object, or null is returned if there is an error. - * - * @param {String} target the name of the shape to get - * @param {int} index the layer position of the shape to get - * - * @return {PShape} returns a child element of a shape as a PShape object or null if there is an error - */ - this.getChild = function() { - if (typeof arguments[0] === 'number') { - return this.children[arguments[0]]; - } else { - var found, - i; - if(arguments[0] === "" || this.name === arguments[0]){ - return this; - } else { - if(this.nameTable.length > 0) - { - for(i = 0; i < this.nameTable.length || found; i++) - { - if(this.nameTable[i].getName === arguments[0]) { - found = this.nameTable[i]; - } - } - if (found) { return found; } - } - for(i = 0; i < this.children.lenth; i++) - { - found = this.children[i].getChild(arguments[0]); - if(found) { return found; } - } - } - return null; - } - }; - /** - * @member PShape - * The getChildCount() returns the number of children - * - * @return {int} returns a count of children - */ - this.getChildCount = function () { - return this.children.length; - }; - /** - * @member PShape - * The addChild() adds a child to the PShape. - * - * @param {PShape} child the child to add - */ - this.addChild = function( child ) { - this.children.push(child); - child.parent = this; - if (child.getName() !== null) { - this.addName(child.getName(), child); - } - }; - /** - * @member PShape - * The addName() functions adds a shape to the name lookup table. - * - * @param {String} name the name to be added - * @param {PShape} shape the shape - */ - this.addName = function(name, shape) { - if (this.parent !== null) { - this.parent.addName( name, shape ); - } else { - this.nameTable.push( [name, shape] ); - } - }; - /** - * @member PShape - * The translate() function specifies an amount to displace the shape. The x parameter specifies left/right translation, the y parameter specifies up/down translation, and the z parameter specifies translations toward/away from the screen. - * Subsequent calls to the method accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

    Using this method with the z parameter requires using the P3D or OPENGL parameter in combination with size. - * - * @param {int|float} x left/right translation - * @param {int|float} y up/down translation - * @param {int|float} z forward/back translation - * - * @see PMatrix2D#translate - * @see PMatrix3D#translate - */ - this.translate = function() { - if(arguments.length === 2) - { - this.checkMatrix(2); - this.matrix.translate(arguments[0], arguments[1]); - } else { - this.checkMatrix(3); - this.matrix.translate(arguments[0], arguments[1], 0); - } - }; - /** - * @member PShape - * The checkMatrix() function makes sure that the shape's matrix is 1) not null, and 2) has a matrix - * that can handle at least the specified number of dimensions. - * - * @param {int} dimensions the specified number of dimensions - */ - this.checkMatrix = function(dimensions) { - if(this.matrix === null) { - if(dimensions === 2) { - this.matrix = new p.PMatrix2D(); - } else { - this.matrix = new p.PMatrix3D(); - } - }else if(dimensions === 3 && this.matrix instanceof p.PMatrix2D) { - this.matrix = new p.PMatrix3D(); - } - }; - /** - * @member PShape - * The rotateX() function rotates a shape around the x-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

    Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Subsequent calls to the method accumulates the effect. For example, calling rotateX(HALF_PI) and then rotateX(HALF_PI) is the same as rotateX(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

    This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above. - * - * @param {float}angle angle of rotation specified in radians - * - * @see PMatrix3D#rotateX - */ - this.rotateX = function(angle) { - this.rotate(angle, 1, 0, 0); - }; - /** - * @member PShape - * The rotateY() function rotates a shape around the y-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

    Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Subsequent calls to the method accumulates the effect. For example, calling rotateY(HALF_PI) and then rotateY(HALF_PI) is the same as rotateY(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

    This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above. - * - * @param {float}angle angle of rotation specified in radians - * - * @see PMatrix3D#rotateY - */ - this.rotateY = function(angle) { - this.rotate(angle, 0, 1, 0); - }; - /** - * @member PShape - * The rotateZ() function rotates a shape around the z-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

    Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Subsequent calls to the method accumulates the effect. For example, calling rotateZ(HALF_PI) and then rotateZ(HALF_PI) is the same as rotateZ(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

    This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above. - * - * @param {float}angle angle of rotation specified in radians - * - * @see PMatrix3D#rotateZ - */ - this.rotateZ = function(angle) { - this.rotate(angle, 0, 0, 1); - }; - /** - * @member PShape - * The rotate() function rotates a shape the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

    Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Transformations apply to everything that happens after and subsequent calls to the method accumulates the effect. - * For example, calling rotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - * If optional parameters x,y,z are supplied, the rotate is about the point (x, y, z). - * - * @param {float}angle angle of rotation specified in radians - * @param {float}x x-coordinate of the point - * @param {float}y y-coordinate of the point - * @param {float}z z-coordinate of the point - * @see PMatrix2D#rotate - * @see PMatrix3D#rotate - */ - this.rotate = function() { - if(arguments.length === 1){ - this.checkMatrix(2); - this.matrix.rotate(arguments[0]); - } else { - this.checkMatrix(3); - this.matrix.rotate(arguments[0], arguments[1], arguments[2] ,arguments[3]); - } - }; - /** - * @member PShape - * The scale() function increases or decreases the size of a shape by expanding and contracting vertices. Shapes always scale from the relative origin of their bounding box. - * Scale values are specified as decimal percentages. For example, the method call scale(2.0) increases the dimension of a shape by 200%. - * Subsequent calls to the method multiply the effect. For example, calling scale(2.0) and then scale(1.5) is the same as scale(3.0). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

    Using this fuction with the z parameter requires passing P3D or OPENGL into the size() parameter. - * - * @param {float}s percentage to scale the object - * @param {float}x percentage to scale the object in the x-axis - * @param {float}y percentage to scale the object in the y-axis - * @param {float}z percentage to scale the object in the z-axis - * - * @see PMatrix2D#scale - * @see PMatrix3D#scale - */ - this.scale = function() { - if(arguments.length === 2) { - this.checkMatrix(2); - this.matrix.scale(arguments[0], arguments[1]); - } else if (arguments.length === 3) { - this.checkMatrix(2); - this.matrix.scale(arguments[0], arguments[1], arguments[2]); - } else { - this.checkMatrix(2); - this.matrix.scale(arguments[0]); - } - }; - /** - * @member PShape - * The resetMatrix() function resets the matrix - * - * @see PMatrix2D#reset - * @see PMatrix3D#reset - */ - this.resetMatrix = function() { - this.checkMatrix(2); - this.matrix.reset(); - }; - /** - * @member PShape - * The applyMatrix() function multiplies this matrix by another matrix of type PMatrix3D or PMatrix2D. - * Individual elements can also be provided - * - * @param {PMatrix3D|PMatrix2D} matrix the matrix to multiply by - * - * @see PMatrix2D#apply - * @see PMatrix3D#apply - */ - this.applyMatrix = function(matrix) { - if (arguments.length === 1) { - this.applyMatrix(matrix.elements[0], matrix.elements[1], 0, matrix.elements[2], - matrix.elements[3], matrix.elements[4], 0, matrix.elements[5], - 0, 0, 1, 0, - 0, 0, 0, 1); - } else if (arguments.length === 6) { - this.checkMatrix(2); - this.matrix.apply(arguments[0], arguments[1], arguments[2], 0, - arguments[3], arguments[4], arguments[5], 0, - 0, 0, 1, 0, - 0, 0, 0, 1); - - } else if (arguments.length === 16) { - this.checkMatrix(3); - this.matrix.apply(arguments[0], arguments[1], arguments[2], arguments[3], - arguments[4], arguments[5], arguments[6], arguments[7], - arguments[8], arguments[9], arguments[10], arguments[11], - arguments[12], arguments[13], arguments[14], arguments[15]); - } - }; - }; - - /** - * SVG stands for Scalable Vector Graphics, a portable graphics format. It is - * a vector format so it allows for infinite resolution and relatively small - * file sizes. Most modern media software can view SVG files, including Adobe - * products, Firefox, etc. Illustrator and Inkscape can edit SVG files. - * - * @param {PApplet} parent typically use "this" - * @param {String} filename name of the SVG file to load - * @param {XMLElement} xml an XMLElement element - * @param {PShapeSVG} parent the parent PShapeSVG - * - * @see PShape - */ - var PShapeSVG = p.PShapeSVG = function() { - p.PShape.call( this ); // PShape is the base class. - if (arguments.length === 1) { //xml element coming in - this.element = arguments[0] ;//new p.XMLElement(null, arguments[0]); - // set values to their defaults according to the SVG spec - this.vertexCodes = []; - this.vertices = []; - this.opacity = 1; - - this.stroke = false; - this.strokeColor = PConstants.ALPHA_MASK; - this.strokeWeight = 1; - this.strokeCap = PConstants.SQUARE; // equivalent to BUTT in svg spec - this.strokeJoin = PConstants.MITER; - this.strokeGradient = null; - this.strokeGradientPaint = null; - this.strokeName = null; - this.strokeOpacity = 1; - - this.fill = true; - this.fillColor = PConstants.ALPHA_MASK; - this.fillGradient = null; - this.fillGradientPaint = null; - this.fillName = null; - this.fillOpacity = 1; - - if (this.element.getName() !== "svg") { - throw("root is not , it's <" + this.element.getName() + ">"); - } - } - else if (arguments.length === 2) { - if (typeof arguments[1] === 'string') { - if (arguments[1].indexOf(".svg") > -1) { //its a filename - this.element = new p.XMLElement(null, arguments[1]); - // set values to their defaults according to the SVG spec - this.vertexCodes = []; - this.vertices = []; - this.opacity = 1; - - this.stroke = false; - this.strokeColor = PConstants.ALPHA_MASK; - this.strokeWeight = 1; - this.strokeCap = PConstants.SQUARE; // equivalent to BUTT in svg spec - this.strokeJoin = PConstants.MITER; - this.strokeGradient = ""; - this.strokeGradientPaint = ""; - this.strokeName = ""; - this.strokeOpacity = 1; - - this.fill = true; - this.fillColor = PConstants.ALPHA_MASK; - this.fillGradient = null; - this.fillGradientPaint = null; - this.fillOpacity = 1; - - } - } else { // XMLElement - if (arguments[0]) { // PShapeSVG - this.element = arguments[1]; - this.vertexCodes = arguments[0].vertexCodes.slice(); - this.vertices = arguments[0].vertices.slice(); - - this.stroke = arguments[0].stroke; - this.strokeColor = arguments[0].strokeColor; - this.strokeWeight = arguments[0].strokeWeight; - this.strokeCap = arguments[0].strokeCap; - this.strokeJoin = arguments[0].strokeJoin; - this.strokeGradient = arguments[0].strokeGradient; - this.strokeGradientPaint = arguments[0].strokeGradientPaint; - this.strokeName = arguments[0].strokeName; - - this.fill = arguments[0].fill; - this.fillColor = arguments[0].fillColor; - this.fillGradient = arguments[0].fillGradient; - this.fillGradientPaint = arguments[0].fillGradientPaint; - this.fillName = arguments[0].fillName; - this.strokeOpacity = arguments[0].strokeOpacity; - this.fillOpacity = arguments[0].fillOpacity; - this.opacity = arguments[0].opacity; - } - } - } - - this.name = this.element.getStringAttribute("id"); - var displayStr = this.element.getStringAttribute("display", "inline"); - this.visible = displayStr !== "none"; - var str = this.element.getAttribute("transform"); - if (str) { - this.matrix = this.parseMatrix(str); - } - // not proper parsing of the viewBox, but will cover us for cases where - // the width and height of the object is not specified - var viewBoxStr = this.element.getStringAttribute("viewBox"); - if ( viewBoxStr !== null ) { - var viewBox = viewBoxStr.split(" "); - this.width = viewBox[2]; - this.height = viewBox[3]; - } - - // TODO if viewbox is not same as width/height, then use it to scale - // the original objects. for now, viewbox only used when width/height - // are empty values (which by the spec means w/h of "100%" - var unitWidth = this.element.getStringAttribute("width"); - var unitHeight = this.element.getStringAttribute("height"); - if (unitWidth !== null) { - this.width = this.parseUnitSize(unitWidth); - this.height = this.parseUnitSize(unitHeight); - } else { - if ((this.width === 0) || (this.height === 0)) { - // For the spec, the default is 100% and 100%. For purposes - // here, insert a dummy value because this is prolly just a - // font or something for which the w/h doesn't matter. - this.width = 1; - this.height = 1; - - //show warning - throw("The width and/or height is not " + - "readable in the tag of this file."); - } - } - this.parseColors(this.element); - this.parseChildren(this.element); - - }; - /** - * PShapeSVG methods - * missing: getChild(), print(), parseStyleAttributes(), styles() - deals with strokeGradient and fillGradient - */ - PShapeSVG.prototype = { - /** - * @member PShapeSVG - * The parseMatrix() function parses the specified SVG matrix into a PMatrix2D. Note that PMatrix2D - * is rotated relative to the SVG definition, so parameters are rearranged - * here. More about the transformation matrices in - * this section - * of the SVG documentation. - * - * @param {String} str text of the matrix param. - * - * @return {PMatrix2D} a PMatrix2D - */ - parseMatrix: function(str) { - this.checkMatrix(2); - var pieces = []; - str.replace(/\s*(\w+)\((.*?)\)/g, function(all) { - // get a list of transform definitions - pieces.push(p.trim(all)); - }); - if (pieces.length === 0) { - p.println("Transformation:" + str + " is empty"); - return null; - } - for (var i =0; i< pieces.length; i++) { - var m = []; - pieces[i].replace(/\((.*?)\)/, (function() { - return function(all, params) { - // get the coordinates that can be separated by spaces or a comma - m = params.replace(/,+/g, " ").split(/\s+/); - }; - }())); - - if (pieces[i].indexOf("matrix") !== -1) { - this.matrix.set(m[0], m[2], m[4], m[1], m[3], m[5]); - } else if (pieces[i].indexOf("translate") !== -1) { - var tx = m[0]; - var ty = (m.length === 2) ? m[1] : 0; - this.matrix.translate(tx,ty); - } else if (pieces[i].indexOf("scale") !== -1) { - var sx = m[0]; - var sy = (m.length === 2) ? m[1] : m[0]; - this.matrix.scale(sx,sy); - } else if (pieces[i].indexOf("rotate") !== -1) { - var angle = m[0]; - if (m.length === 1) { - this.matrix.rotate(p.radians(angle)); - } else if (m.length === 3) { - this.matrix.translate(m[1], m[2]); - this.matrix.rotate(p.radians(m[0])); - this.matrix.translate(-m[1], -m[2]); - } - } else if (pieces[i].indexOf("skewX") !== -1) { - this.matrix.skewX(parseFloat(m[0])); - } else if (pieces[i].indexOf("skewY") !== -1) { - this.matrix.skewY(m[0]); - } - } - return this.matrix; - }, - /** - * @member PShapeSVG - * The parseChildren() function parses the specified XMLElement - * - * @param {XMLElement}element the XMLElement to parse - */ - parseChildren:function(element) { - var newelement = element.getChildren(); - var children = new p.PShape(); - for (var i = 0; i < newelement.length; i++) { - var kid = this.parseChild(newelement[i]); - if (kid) { - children.addChild(kid); - } - } - this.children.push(children); - }, - /** - * @member PShapeSVG - * The getName() function returns the name - * - * @return {String} the name - */ - getName: function() { - return this.name; - }, - /** - * @member PShapeSVG - * The parseChild() function parses a child XML element. - * - * @param {XMLElement} elem the element to parse - * - * @return {PShape} the newly created PShape - */ - parseChild: function( elem ) { - var name = elem.getName(); - var shape; - switch (name) { - case "g": - shape = new PShapeSVG(this, elem); - break; - case "defs": - // generally this will contain gradient info, so may - // as well just throw it into a group element for parsing - shape = new PShapeSVG(this, elem); - break; - case "line": - shape = new PShapeSVG(this, elem); - shape.parseLine(); - break; - case "circle": - shape = new PShapeSVG(this, elem); - shape.parseEllipse(true); - break; - case "ellipse": - shape = new PShapeSVG(this, elem); - shape.parseEllipse(false); - break; - case "rect": - shape = new PShapeSVG(this, elem); - shape.parseRect(); - break; - case "polygon": - shape = new PShapeSVG(this, elem); - shape.parsePoly(true); - break; - case "polyline": - shape = new PShapeSVG(this, elem); - shape.parsePoly(false); - break; - case "path": - shape = new PShapeSVG(this, elem); - shape.parsePath(); - break; - case "radialGradient": - //return new RadialGradient(this, elem); - break; - case "linearGradient": - //return new LinearGradient(this, elem); - break; - case "text": - p.println("Text in SVG files is not currently supported, convert text to outlines instead." ); - break; - case "filter": - p.println("Filters are not supported."); - break; - case "mask": - p.println("Masks are not supported."); - break; - default: - p.println("Ignoring <" + name + "> tag."); - break; - } - return shape; - }, - /** - * @member PShapeSVG - * The parsePath() function parses the element of the svg file - * A path is defined by including a path element which contains a d="(path data)" attribute, where the d attribute contains - * the moveto, line, curve (both cubic and quadratic Beziers), arc and closepath instructions. - **/ - parsePath: function() { - this.family = PConstants.PATH; - this.kind = 0; - var pathDataChars = []; - var c; - var pathData = p.trim(this.element.getStringAttribute("d").replace(/[\s,]+/g,' ')); //change multiple spaces and commas to single space - if (pathData === null) { return; } - pathData = pathData.toCharArray(); - var cx = 0, - cy = 0, - ctrlX = 0, - ctrlY = 0, - ctrlX1 = 0, - ctrlX2 = 0, - ctrlY1 = 0, - ctrlY2 = 0, - endX = 0, - endY = 0, - ppx = 0, - ppy = 0, - px = 0, - py = 0, - i = 0, - j = 0, - valOf = 0; - var str = ""; - var tmpArray =[]; - var flag = false; - var lastInstruction; - var command; - while (i< pathData.length) { - valOf = pathData[i].valueOf(); - if ((valOf >= 65 && valOf <= 90) || (valOf >= 97 && valOf <= 122)) { // if its a letter - // populate the tmpArray with coordinates - j = i; - i++; - if (i < pathData.length) { // dont go over boundary of array - tmpArray = []; - valOf = pathData[i].valueOf(); - while (!((valOf >= 65 && valOf <= 90) || (valOf >= 97 && valOf <= 100) || (valOf >= 102 && valOf <= 122)) && flag === false) { // if its NOT a letter - if (valOf === 32) { //if its a space and the str isn't empty - // somethimes you get a space after the letter - if (str !== "") { - tmpArray.push(parseFloat(str)); - str = ""; - } - i++; - } else if (valOf === 45) { //if its a - - // allow for 'e' notation in numbers, e.g. 2.10e-9 - if (pathData[i-1].valueOf() === 101) { - str += pathData[i].toString(); - i++; - } else { - // sometimes no space separator after (ex: 104.535-16.322) - if (str !== "") { - tmpArray.push(parseFloat(str)); - } - str = pathData[i].toString(); - i++; - } - } else { - str += pathData[i].toString(); - i++; - } - if (i === pathData.length) { // dont go over boundary of array - flag = true; - } else { - valOf = pathData[i].valueOf(); - } - } - } - if (str !== "") { - tmpArray.push(parseFloat(str)); - str = ""; - } - command = pathData[j]; - switch (command.valueOf()) { - case 77: // M - move to (absolute) - if (tmpArray.length >= 2 && tmpArray.length % 2 ===0) { // need one+ pairs of co-ordinates - cx = tmpArray[0]; - cy = tmpArray[1]; - this.parsePathMoveto(cx, cy); - if (tmpArray.length > 2) { - for (j = 2; j < tmpArray.length; j+=2) { - // absolute line to - cx = tmpArray[j]; - cy = tmpArray[j+1]; - this.parsePathLineto(cx,cy); - } - } - } - break; - case 109: // m - move to (relative) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - cx += tmpArray[0]; - cy += tmpArray[1]; - this.parsePathMoveto(cx,cy); - if (tmpArray.length > 2) { - for (j = 2; j < tmpArray.length; j+=2) { - // relative line to - cx += tmpArray[j]; - cy += tmpArray[j + 1]; - this.parsePathLineto(cx,cy); - } - } - } - break; - case 76: // L - lineto (absolute) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - cx = tmpArray[j]; - cy = tmpArray[j + 1]; - this.parsePathLineto(cx,cy); - } - } - break; - - case 108: // l - lineto (relative) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - cx += tmpArray[j]; - cy += tmpArray[j+1]; - this.parsePathLineto(cx,cy); - } - } - break; - - case 72: // H - horizontal lineto (absolute) - for (j = 0; j < tmpArray.length; j++) { // multiple x co-ordinates can be provided - cx = tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 104: // h - horizontal lineto (relative) - for (j = 0; j < tmpArray.length; j++) { // multiple x co-ordinates can be provided - cx += tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 86: // V - vertical lineto (absolute) - for (j = 0; j < tmpArray.length; j++) { // multiple y co-ordinates can be provided - cy = tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 118: // v - vertical lineto (relative) - for (j = 0; j < tmpArray.length; j++) { // multiple y co-ordinates can be provided - cy += tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 67: // C - curve to (absolute) - if (tmpArray.length >= 6 && tmpArray.length % 6 === 0) { // need one+ multiples of 6 co-ordinates - for (j = 0; j < tmpArray.length; j+=6) { - ctrlX1 = tmpArray[j]; - ctrlY1 = tmpArray[j + 1]; - ctrlX2 = tmpArray[j + 2]; - ctrlY2 = tmpArray[j + 3]; - endX = tmpArray[j + 4]; - endY = tmpArray[j + 5]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 99: // c - curve to (relative) - if (tmpArray.length >= 6 && tmpArray.length % 6 === 0) { // need one+ multiples of 6 co-ordinates - for (j = 0; j < tmpArray.length; j+=6) { - ctrlX1 = cx + tmpArray[j]; - ctrlY1 = cy + tmpArray[j + 1]; - ctrlX2 = cx + tmpArray[j + 2]; - ctrlY2 = cy + tmpArray[j + 3]; - endX = cx + tmpArray[j + 4]; - endY = cy + tmpArray[j + 5]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 83: // S - curve to shorthand (absolute) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - if (lastInstruction.toLowerCase() === "c" || lastInstruction.toLowerCase() === "s") { - ppx = this.vertices[ this.vertices.length-2 ][0]; - ppy = this.vertices[ this.vertices.length-2 ][1]; - px = this.vertices[ this.vertices.length-1 ][0]; - py = this.vertices[ this.vertices.length-1 ][1]; - ctrlX1 = px + (px - ppx); - ctrlY1 = py + (py - ppy); - } else { - //If there is no previous curve, the current point will be used as the first control point. - ctrlX1 = this.vertices[this.vertices.length-1][0]; - ctrlY1 = this.vertices[this.vertices.length-1][1]; - } - ctrlX2 = tmpArray[j]; - ctrlY2 = tmpArray[j + 1]; - endX = tmpArray[j + 2]; - endY = tmpArray[j + 3]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 115: // s - curve to shorthand (relative) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - if (lastInstruction.toLowerCase() === "c" || lastInstruction.toLowerCase() === "s") { - ppx = this.vertices[this.vertices.length-2][0]; - ppy = this.vertices[this.vertices.length-2][1]; - px = this.vertices[this.vertices.length-1][0]; - py = this.vertices[this.vertices.length-1][1]; - ctrlX1 = px + (px - ppx); - ctrlY1 = py + (py - ppy); - } else { - //If there is no previous curve, the current point will be used as the first control point. - ctrlX1 = this.vertices[this.vertices.length-1][0]; - ctrlY1 = this.vertices[this.vertices.length-1][1]; - } - ctrlX2 = cx + tmpArray[j]; - ctrlY2 = cy + tmpArray[j + 1]; - endX = cx + tmpArray[j + 2]; - endY = cy + tmpArray[j + 3]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 81: // Q - quadratic curve to (absolute) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - ctrlX = tmpArray[j]; - ctrlY = tmpArray[j + 1]; - endX = tmpArray[j + 2]; - endY = tmpArray[j + 3]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 113: // q - quadratic curve to (relative) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - ctrlX = cx + tmpArray[j]; - ctrlY = cy + tmpArray[j + 1]; - endX = cx + tmpArray[j + 2]; - endY = cy + tmpArray[j + 3]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 84: // T - quadratic curve to shorthand (absolute) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - if (lastInstruction.toLowerCase() === "q" || lastInstruction.toLowerCase() === "t") { - ppx = this.vertices[this.vertices.length-2][0]; - ppy = this.vertices[this.vertices.length-2][1]; - px = this.vertices[this.vertices.length-1][0]; - py = this.vertices[this.vertices.length-1][1]; - ctrlX = px + (px - ppx); - ctrlY = py + (py - ppy); - } else { - // If there is no previous command or if the previous command was not a Q, q, T or t, - // assume the control point is coincident with the current point. - ctrlX = cx; - ctrlY = cy; - } - endX = tmpArray[j]; - endY = tmpArray[j + 1]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 116: // t - quadratic curve to shorthand (relative) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - if (lastInstruction.toLowerCase() === "q" || lastInstruction.toLowerCase() === "t") { - ppx = this.vertices[this.vertices.length-2][0]; - ppy = this.vertices[this.vertices.length-2][1]; - px = this.vertices[this.vertices.length-1][0]; - py = this.vertices[this.vertices.length-1][1]; - ctrlX = px + (px - ppx); - ctrlY = py + (py - ppy); - } else { - // If there is no previous command or if the previous command was not a Q, q, T or t, - // assume the control point is coincident with the current point. - ctrlX = cx; - ctrlY = cy; - } - endX = cx + tmpArray[j]; - endY = cy + tmpArray[j + 1]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 90: //Z - case 122: //z - this.close = true; - break; - } - lastInstruction = command.toString(); - } else { i++;} - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathQuadto: function(x1, y1, cx, cy, x2, y2) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.BEZIER_VERTEX); - // x1/y1 already covered by last moveto, lineto, or curveto - this.parsePathVertex(x1 + ((cx-x1)*2/3), y1 + ((cy-y1)*2/3)); - this.parsePathVertex(x2 + ((cx-x2)*2/3), y2 + ((cy-y2)*2/3)); - this.parsePathVertex(x2, y2); - } else { - throw ("Path must start with M/m"); - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathCurveto : function(x1, y1, x2, y2, x3, y3) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.BEZIER_VERTEX ); - this.parsePathVertex(x1, y1); - this.parsePathVertex(x2, y2); - this.parsePathVertex(x3, y3); - } else { - throw ("Path must start with M/m"); - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathLineto: function(px, py) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.VERTEX); - this.parsePathVertex(px, py); - // add property to distinguish between curContext.moveTo or curContext.lineTo - this.vertices[this.vertices.length-1]["moveTo"] = false; - } else { - throw ("Path must start with M/m"); - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathMoveto: function(px, py) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.BREAK); - } - this.parsePathCode(PConstants.VERTEX); - this.parsePathVertex(px, py); - // add property to distinguish between curContext.moveTo or curContext.lineTo - this.vertices[this.vertices.length-1]["moveTo"] = true; - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathVertex: function(x, y) { - var verts = []; - verts[0] = x; - verts[1] = y; - this.vertices.push(verts); - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathCode: function(what) { - this.vertexCodes.push(what); - }, - /** - * @member PShapeSVG - * The parsePoly() function parses a polyline or polygon from an SVG file. - * - * @param {boolean}val true if shape is closed (polygon), false if not (polyline) - */ - parsePoly: function(val) { - this.family = PConstants.PATH; - this.close = val; - var pointsAttr = p.trim(this.element.getStringAttribute("points").replace(/[,\s]+/g,' ')); - if (pointsAttr !== null) { - //split into array - var pointsBuffer = pointsAttr.split(" "); - if (pointsBuffer.length % 2 === 0) { - for (var i = 0; i < pointsBuffer.length; i++) { - var verts = []; - verts[0] = pointsBuffer[i]; - verts[1] = pointsBuffer[++i]; - this.vertices.push(verts); - } - } else { - p.println("Error parsing polygon points: odd number of coordinates provided"); - } - } - }, - /** - * @member PShapeSVG - * The parseRect() function parses a rect from an SVG file. - */ - parseRect: function() { - this.kind = PConstants.RECT; - this.family = PConstants.PRIMITIVE; - this.params = []; - this.params[0] = this.element.getFloatAttribute("x"); - this.params[1] = this.element.getFloatAttribute("y"); - this.params[2] = this.element.getFloatAttribute("width"); - this.params[3] = this.element.getFloatAttribute("height"); - if (this.params[2] < 0 || this.params[3] < 0) { - throw("svg error: negative width or height found while parsing "); - } - - }, - /** - * @member PShapeSVG - * The parseEllipse() function handles parsing ellipse and circle tags. - * - * @param {boolean}val true if this is a circle and not an ellipse - */ - parseEllipse: function(val) { - this.kind = PConstants.ELLIPSE; - this.family = PConstants.PRIMITIVE; - this.params = []; - - this.params[0] = this.element.getFloatAttribute("cx") | 0; - this.params[1] = this.element.getFloatAttribute("cy") | 0; - - var rx, ry; - if (val) { //this is a circle - rx = ry = this.element.getFloatAttribute("r"); - if (rx < 0) { - throw("svg error: negative radius found while parsing "); - } - } else { - rx = this.element.getFloatAttribute("rx"); - ry = this.element.getFloatAttribute("ry"); - if (rx < 0 || ry < 0) { - throw("svg error: negative x-axis radius or y-axis radius found while parsing "); - } - } - this.params[0] -= rx; - this.params[1] -= ry; - - this.params[2] = rx*2; - this.params[3] = ry*2; - }, - /** - * @member PShapeSVG - * The parseLine() function handles parsing line tags. - * - * @param {boolean}val true if this is a circle and not an ellipse - */ - parseLine: function() { - this.kind = PConstants.LINE; - this.family = PConstants.PRIMITIVE; - this.params = []; - this.params[0] = this.element.getFloatAttribute("x1"); - this.params[1] = this.element.getFloatAttribute("y1"); - this.params[2] = this.element.getFloatAttribute("x2"); - this.params[3] = this.element.getFloatAttribute("y2"); - }, - /** - * @member PShapeSVG - * The parseColors() function handles parsing the opacity, strijem stroke-width, stroke-linejoin,stroke-linecap, fill, and style attributes - * - * @param {XMLElement}element the element of which attributes to parse - */ - parseColors: function(element) { - if (element.hasAttribute("opacity")) { - this.setOpacity(element.getAttribute("opacity")); - } - if (element.hasAttribute("stroke")) { - this.setStroke(element.getAttribute("stroke")); - } - if (element.hasAttribute("stroke-width")) { - // if NaN (i.e. if it's 'inherit') then default back to the inherit setting - this.setStrokeWeight(element.getAttribute("stroke-width")); - } - if (element.hasAttribute("stroke-linejoin") ) { - this.setStrokeJoin(element.getAttribute("stroke-linejoin")); - } - if (element.hasAttribute("stroke-linecap")) { - this.setStrokeCap(element.getStringAttribute("stroke-linecap")); - } - // fill defaults to black (though stroke defaults to "none") - // http://www.w3.org/TR/SVG/painting.html#FillProperties - if (element.hasAttribute("fill")) { - this.setFill(element.getStringAttribute("fill")); - } - if (element.hasAttribute("style")) { - var styleText = element.getStringAttribute("style"); - var styleTokens = styleText.toString().split( ";" ); - - for (var i = 0; i < styleTokens.length; i++) { - var tokens = p.trim(styleTokens[i].split( ":" )); - switch(tokens[0]){ - case "fill": - this.setFill(tokens[1]); - break; - case "fill-opacity": - this.setFillOpacity(tokens[1]); - break; - case "stroke": - this.setStroke(tokens[1]); - break; - case "stroke-width": - this.setStrokeWeight(tokens[1]); - break; - case "stroke-linecap": - this.setStrokeCap(tokens[1]); - break; - case "stroke-linejoin": - this.setStrokeJoin(tokens[1]); - break; - case "stroke-opacity": - this.setStrokeOpacity(tokens[1]); - break; - case "opacity": - this.setOpacity(tokens[1]); - break; - // Other attributes are not yet implemented - } - } - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} opacityText the value of fillOpacity - * - * @see PShapeSVG#parseColors - */ - setFillOpacity: function(opacityText) { - this.fillOpacity = parseFloat(opacityText); - this.fillColor = this.fillOpacity * 255 << 24 | this.fillColor & 0xFFFFFF; - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} fillText the value of fill - * - * @see PShapeSVG#parseColors - */ - setFill: function (fillText) { - var opacityMask = this.fillColor & 0xFF000000; - if (fillText === "none") { - this.fill = false; - } else if (fillText.indexOf("#") === 0) { - this.fill = true; - if (fillText.length === 4) { - // convert #00F to #0000FF - fillText = fillText.replace(/#(.)(.)(.)/,"#$1$1$2$2$3$3"); - } - this.fillColor = opacityMask | (parseInt(fillText.substring(1), 16)) & 0xFFFFFF; - } else if (fillText.indexOf("rgb") === 0) { - this.fill = true; - this.fillColor = opacityMask | this.parseRGB(fillText); - } else if (fillText.indexOf("url(#") === 0) { - this.fillName = fillText.substring(5, fillText.length - 1 ); - /*Object fillObject = findChild(fillName); - if (fillObject instanceof Gradient) { - fill = true; - fillGradient = (Gradient) fillObject; - fillGradientPaint = calcGradientPaint(fillGradient); //, opacity); - } else { - System.err.println("url " + fillName + " refers to unexpected data"); - }*/ - } else { - if (colors[fillText]) { - this.fill = true; - this.fillColor = opacityMask | (parseInt(colors[fillText].substring(1), 16)) & 0xFFFFFF; - } - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} opacity the value of opacity - * - * @see PShapeSVG#parseColors - */ - setOpacity: function(opacity) { - this.strokeColor = parseFloat(opacity) * 255 << 24 | this.strokeColor & 0xFFFFFF; - this.fillColor = parseFloat(opacity) * 255 << 24 | this.fillColor & 0xFFFFFF; - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} strokeText the value to set stroke to - * - * @see PShapeSVG#parseColors - */ - setStroke: function(strokeText) { - var opacityMask = this.strokeColor & 0xFF000000; - if (strokeText === "none") { - this.stroke = false; - } else if (strokeText.charAt( 0 ) === "#") { - this.stroke = true; - if (strokeText.length === 4) { - // convert #00F to #0000FF - strokeText = strokeText.replace(/#(.)(.)(.)/,"#$1$1$2$2$3$3"); - } - this.strokeColor = opacityMask | (parseInt( strokeText.substring(1), 16)) & 0xFFFFFF; - } else if (strokeText.indexOf( "rgb" ) === 0 ) { - this.stroke = true; - this.strokeColor = opacityMask | this.parseRGB(strokeText); - } else if (strokeText.indexOf( "url(#" ) === 0) { - this.strokeName = strokeText.substring(5, strokeText.length - 1); - //this.strokeObject = findChild(strokeName); - /*if (strokeObject instanceof Gradient) { - strokeGradient = (Gradient) strokeObject; - strokeGradientPaint = calcGradientPaint(strokeGradient); //, opacity); - } else { - System.err.println("url " + strokeName + " refers to unexpected data"); - }*/ - } else { - if (colors[strokeText]){ - this.stroke = true; - this.strokeColor = opacityMask | (parseInt(colors[strokeText].substring(1), 16)) & 0xFFFFFF; - } - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} weight the value to set strokeWeight to - * - * @see PShapeSVG#parseColors - */ - setStrokeWeight: function(weight) { - this.strokeWeight = this.parseUnitSize(weight); - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} linejoin the value to set strokeJoin to - * - * @see PShapeSVG#parseColors - */ - setStrokeJoin: function(linejoin) { - if (linejoin === "miter") { - this.strokeJoin = PConstants.MITER; - - } else if (linejoin === "round") { - this.strokeJoin = PConstants.ROUND; - - } else if (linejoin === "bevel") { - this.strokeJoin = PConstants.BEVEL; - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} linecap the value to set strokeCap to - * - * @see PShapeSVG#parseColors - */ - setStrokeCap: function (linecap) { - if (linecap === "butt") { - this.strokeCap = PConstants.SQUARE; - - } else if (linecap === "round") { - this.strokeCap = PConstants.ROUND; - - } else if (linecap === "square") { - this.strokeCap = PConstants.PROJECT; - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} opacityText the value to set stroke opacity to - * - * @see PShapeSVG#parseColors - */ - setStrokeOpacity: function (opacityText) { - this.strokeOpacity = parseFloat(opacityText); - this.strokeColor = this.strokeOpacity * 255 << 24 | this.strokeColor & 0xFFFFFF; - }, - /** - * @member PShapeSVG - * The parseRGB() function parses an rbg() color string and returns a color int - * - * @param {String} color the color to parse in rbg() format - * - * @return {int} the equivalent color int - */ - parseRGB: function(color) { - var sub = color.substring(color.indexOf('(') + 1, color.indexOf(')')); - var values = sub.split(", "); - return (values[0] << 16) | (values[1] << 8) | (values[2]); - }, - /** - * @member PShapeSVG - * The parseUnitSize() function parse a size that may have a suffix for its units. - * Ignoring cases where this could also be a percentage. - * The units spec: - *
      - *
    • "1pt" equals "1.25px" (and therefore 1.25 user units) - *
    • "1pc" equals "15px" (and therefore 15 user units) - *
    • "1mm" would be "3.543307px" (3.543307 user units) - *
    • "1cm" equals "35.43307px" (and therefore 35.43307 user units) - *
    • "1in" equals "90px" (and therefore 90 user units) - *
    - */ - parseUnitSize: function (text) { - var len = text.length - 2; - if (len < 0) { return text; } - if (text.indexOf("pt") === len) { - return parseFloat(text.substring(0, len)) * 1.25; - } else if (text.indexOf("pc") === len) { - return parseFloat( text.substring( 0, len)) * 15; - } else if (text.indexOf("mm") === len) { - return parseFloat( text.substring(0, len)) * 3.543307; - } else if (text.indexOf("cm") === len) { - return parseFloat(text.substring(0, len)) * 35.43307; - } else if (text.indexOf("in") === len) { - return parseFloat(text.substring(0, len)) * 90; - } else if (text.indexOf("px") === len) { - return parseFloat(text.substring(0, len)); - } else { - return parseFloat(text); - } - } - }; - /** - * The shape() function displays shapes to the screen. - * Processing currently works with SVG shapes only. - * The shape parameter specifies the shape to display and the x - * and y parameters define the location of the shape from its - * upper-left corner. - * The shape is displayed at its original size unless the width - * and height parameters specify a different size. - * The shapeMode() function changes the way the parameters work. - * A call to shapeMode(CORNERS), for example, will change the width - * and height parameters to define the x and y values of the opposite corner - * of the shape. - *

    - * Note complex shapes may draw awkwardly with P2D, P3D, and OPENGL. Those - * renderers do not yet support shapes that have holes or complicated breaks. - * - * @param {PShape} shape the shape to display - * @param {int|float} x x-coordinate of the shape - * @param {int|float} y y-coordinate of the shape - * @param {int|float} width width to display the shape - * @param {int|float} height height to display the shape - * - * @see PShape - * @see loadShape() - * @see shapeMode() - */ - p.shape = function(shape, x, y, width, height) { - if (arguments.length >= 1 && arguments[0] !== null) { - if (shape.isVisible()) { - p.pushMatrix(); - if (curShapeMode === PConstants.CENTER) { - if (arguments.length === 5) { - p.translate(x - width/2, y - height/2); - p.scale(width / shape.getWidth(), height / shape.getHeight()); - } else if (arguments.length === 3) { - p.translate(x - shape.getWidth()/2, - shape.getHeight()/2); - } else { - p.translate(-shape.getWidth()/2, -shape.getHeight()/2); - } - } else if (curShapeMode === PConstants.CORNER) { - if (arguments.length === 5) { - p.translate(x, y); - p.scale(width / shape.getWidth(), height / shape.getHeight()); - } else if (arguments.length === 3) { - p.translate(x, y); - } - } else if (curShapeMode === PConstants.CORNERS) { - if (arguments.length === 5) { - width -= x; - height -= y; - p.translate(x, y); - p.scale(width / shape.getWidth(), height / shape.getHeight()); - } else if (arguments.length === 3) { - p.translate(x, y); - } - } - shape.draw(); - if ((arguments.length === 1 && curShapeMode === PConstants.CENTER ) || arguments.length > 1) { - p.popMatrix(); - } - } - } - }; - - /** - * The shapeMode() function modifies the location from which shapes draw. - * The default mode is shapeMode(CORNER), which specifies the - * location to be the upper left corner of the shape and uses the third - * and fourth parameters of shape() to specify the width and height. - * The syntax shapeMode(CORNERS) uses the first and second parameters - * of shape() to set the location of one corner and uses the third - * and fourth parameters to set the opposite corner. - * The syntax shapeMode(CENTER) draws the shape from its center point - * and uses the third and forth parameters of shape() to specify the - * width and height. - * The parameter must be written in "ALL CAPS" because Processing syntax - * is case sensitive. - * - * @param {int} mode One of CORNER, CORNERS, CENTER - * - * @see shape() - * @see rectMode() - */ - p.shapeMode = function (mode) { - curShapeMode = mode; - }; - - /** - * The loadShape() function loads vector shapes into a variable of type PShape. Currently, only SVG files may be loaded. - * In most cases, loadShape() should be used inside setup() because loading shapes inside draw() will reduce the speed of a sketch. - * - * @param {String} filename an SVG file - * - * @return {PShape} a object of type PShape or null - * @see PShape - * @see PApplet#shape() - * @see PApplet#shapeMode() - */ - p.loadShape = function (filename) { - if (arguments.length === 1) { - if (filename.indexOf(".svg") > -1) { - return new PShapeSVG(null, filename); - } - } - return null; - }; - - /** - * XMLAttribute is an attribute of a XML element. This is an internal class - * - * @param {String} fname the full name of the attribute - * @param {String} n the short name of the attribute - * @param {String} namespace the namespace URI of the attribute - * @param {String} v the value of the attribute - * @param {String }t the type of the attribute - * - * @see XMLElement - */ - var XMLAttribute = function(fname, n, nameSpace, v, t){ - this.fullName = fname || ""; - this.name = n || ""; - this.namespace = nameSpace || ""; - this.value = v; - this.type = t; - }; - /** - * XMLAttribute methods - */ - XMLAttribute.prototype = { - /** - * @member XMLAttribute - * The getName() function returns the short name of the attribute - * - * @return {String} the short name of the attribute - */ - getName: function() { - return this.name; - }, - /** - * @member XMLAttribute - * The getFullName() function returns the full name of the attribute - * - * @return {String} the full name of the attribute - */ - getFullName: function() { - return this.fullName; - }, - /** - * @member XMLAttribute - * The getNamespace() function returns the namespace of the attribute - * - * @return {String} the namespace of the attribute - */ - getNamespace: function() { - return this.namespace; - }, - /** - * @member XMLAttribute - * The getValue() function returns the value of the attribute - * - * @return {String} the value of the attribute - */ - getValue: function() { - return this.value; - }, - /** - * @member XMLAttribute - * The getValue() function returns the type of the attribute - * - * @return {String} the type of the attribute - */ - getType: function() { - return this.type; - }, - /** - * @member XMLAttribute - * The setValue() function sets the value of the attribute - * - * @param {String} newval the new value - */ - setValue: function(newval) { - this.value = newval; - } - }; - - /** - * XMLElement is a representation of an XML object. The object is able to parse XML code - * - * @param {PApplet} parent typically use "this" - * @param {String} filename name of the XML/SVG file to load - * @param {String} xml the xml/svg string - * @param {String} fullname the full name of the element - * @param {String} namespace the namespace of the URI - * @param {String} systemID the system ID of the XML data where the element starts - * @param {Integer }lineNr the line in the XML data where the element starts - */ - var XMLElement = p.XMLElement = function() { - if (arguments.length === 4) { - this.attributes = []; - this.children = []; - this.fullName = arguments[0] || ""; - if (arguments[1]) { - this.name = arguments[1]; - } else { - var index = this.fullName.indexOf(':'); - if (index >= 0) { - this.name = this.fullName.substring(index + 1); - } else { - this.name = this.fullName; - } - } - this.namespace = arguments[1]; - this.content = ""; - this.lineNr = arguments[3]; - this.systemID = arguments[2]; - this.parent = null; - } - else if ((arguments.length === 2 && arguments[1].indexOf(".") > -1) ) { // filename or svg xml element - this.attributes = []; - this.children = []; - this.fullName = ""; - this.name = ""; - this.namespace = ""; - this.content = ""; - this.systemID = ""; - this.lineNr = ""; - this.parent = null; - this.parse(arguments[arguments.length -1]); - } else if (arguments.length === 1 && typeof arguments[0] === "string"){ - //xml string - this.attributes = []; - this.children = []; - this.fullName = ""; - this.name = ""; - this.namespace = ""; - this.content = ""; - this.systemID = ""; - this.lineNr = ""; - this.parent = null; - this.parse(arguments[0]); - } - else { //empty ctor - this.attributes = []; - this.children = []; - this.fullName = ""; - this.name = ""; - this.namespace = ""; - this.content = ""; - this.systemID = ""; - this.lineNr = ""; - this.parent = null; - - } - return this; - }; - /** - * XMLElement methods - * missing: enumerateAttributeNames(), enumerateChildren(), - * NOTE: parse does not work when a url is passed in - */ - XMLElement.prototype = { - /** - * @member XMLElement - * The parse() function retrieves the file via ajax() and uses DOMParser() parseFromString method to make an XML document - * @addon - * - * @param {String} filename name of the XML/SVG file to load - * - * @throws ExceptionType Error loading document - * - * @see XMLElement#parseChildrenRecursive - */ - parse: function(filename) { - var xmlDoc; - try { - if (filename.indexOf(".xml") > -1 || filename.indexOf(".svg") > -1) { - filename = ajax(filename); - } - xmlDoc = new DOMParser().parseFromString(filename, "text/xml"); - var elements = xmlDoc.documentElement; - if (elements) { - this.parseChildrenRecursive(null, elements); - } else { - throw ("Error loading document"); - } - return this; - } catch(e) { - throw(e); - } - }, - /** - * @member XMLElement - * The createElement() function Creates an empty element - * - * @param {String} fullName the full name of the element - * @param {String} namespace the namespace URI - * @param {String} systemID the system ID of the XML data where the element starts - * @param {int} lineNr the line in the XML data where the element starts - */ - createElement: function () { - if (arguments.length === 2) { - return new XMLElement(arguments[0], arguments[1], null, null); - } else { - return new XMLElement(arguments[0], arguments[1], arguments[2], arguments[3]); - } - }, - /** - * @member XMLElement - * The hasAttribute() function returns whether an attribute exists - * - * @param {String} name name of the attribute - * @param {String} namespace the namespace URI of the attribute - * - * @return {boolean} true if the attribute exists - */ - hasAttribute: function () { - if (arguments.length === 1) { - return this.getAttribute(arguments[0]) !== null; - } else if (arguments.length === 2) { - return this.getAttribute(arguments[0],arguments[1]) !== null; - } - }, - /** - * @member XMLElement - * The createPCDataElement() function creates an element to be used for #PCDATA content - * - * @return {XMLElement} new XMLElement element - */ - createPCDataElement: function () { - return new XMLElement(); - }, - /** - * @member XMLElement - * The equals() function checks to see if the element being passed in equals another element - * - * @param {Object} rawElement the element to compare to - * - * @return {boolean} true if the element equals another element - */ - equals: function(object){ - if (typeof object === "Object") { - return this.equalsXMLElement(object); - } - }, - /** - * @member XMLElement - * The equalsXMLElement() function checks to see if the XMLElement being passed in equals another XMLElement - * - * @param {XMLElement} rawElement the element to compare to - * - * @return {boolean} true if the element equals another element - */ - equalsXMLElement: function (object) { - if (object instanceof XMLElement) { - if (this.name !== object.getLocalName()) { return false; } - if (this.attributes.length !== object.getAttributeCount()) { return false; } - for (var i = 0; i < this.attributes.length; i++){ - if (! object.hasAttribute(this.attributes[i].getName(), this.attributes[i].getNamespace())) { return false; } - if (this.attributes[i].getValue() !== object.attributes[i].getValue()) { return false; } - if (this.attributes[i].getType() !== object.attributes[i].getType()) { return false; } - } - if (this.children.length !== object.getChildCount()) { return false; } - var child1, child2; - for (i = 0; i < this.children.length; i++) { - child1 = this.getChildAtIndex(i); - child2 = object.getChildAtIndex(i); - if (! child1.equalsXMLElement(child2)) { return false; } - } - return true; - } - }, - /** - * @member XMLElement - * The getContent() function returns the content of an element. If there is no such content, null is returned - * - * @return {String} the (possibly null) content - */ - getContent: function(){ - return this.content; - }, - /** - * @member XMLElement - * The getAttribute() function returns the value of an attribute - * - * @param {String} name the non-null full name of the attribute - * @param {String} namespace the namespace URI, which may be null - * @param {String} defaultValue the default value of the attribute - * - * @return {String} the value, or defaultValue if the attribute does not exist - */ - getAttribute: function (){ - var attribute; - if( arguments.length === 2 ){ - attribute = this.findAttribute(arguments[0]); - if (attribute) { - return attribute.getValue(); - } else { - return arguments[1]; - } - } else if (arguments.length === 1) { - attribute = this.findAttribute(arguments[0]); - if (attribute) { - return attribute.getValue(); - } else { - return null; - } - } else if (arguments.length === 3) { - attribute = this.findAttribute(arguments[0],arguments[1]); - if (attribute) { - return attribute.getValue(); - } else { - return arguments[2]; - } - } - }, - /** - * @member XMLElement - * The getStringAttribute() function returns the string attribute of the element - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue value is returned. - * When calling the function without the defaultValue parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return {String} the value, or defaultValue if the attribute does not exist - */ - getStringAttribute: function() { - if (arguments.length === 1) { - return this.getAttribute(arguments[0]); - } else if (arguments.length === 2){ - return this.getAttribute(arguments[0], arguments[1]); - } else { - return this.getAttribute(arguments[0], arguments[1],arguments[2]); - } - }, - /** - * @member XMLElement - * The getFloatAttribute() function returns the float attribute of the element. - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue value is returned. - * When calling the function without the defaultValue parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return {float} the value, or defaultValue if the attribute does not exist - */ - getFloatAttribute: function() { - if (arguments.length === 1 ) { - return parseFloat(this.getAttribute(arguments[0], 0)); - } else if (arguments.length === 2 ){ - return this.getAttribute(arguments[0], arguments[1]); - } else { - return this.getAttribute(arguments[0], arguments[1],arguments[2]); - } - }, - /** - * @member XMLElement - * The getIntAttribute() function returns the integer attribute of the element. - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue value is returned. - * When calling the function without the defaultValue parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return {int} the value, or defaultValue if the attribute does not exist - */ - getIntAttribute: function () { - if (arguments.length === 1) { - return this.getAttribute( arguments[0], 0 ); - } else if (arguments.length === 2) { - return this.getAttribute(arguments[0], arguments[1]); - } else { - return this.getAttribute(arguments[0], arguments[1],arguments[2]); - } - }, - /** - * @member XMLElement - * The hasChildren() function returns whether the element has children. - * - * @return {boolean} true if the element has children. - */ - hasChildren: function () { - return this.children.length > 0 ; - }, - /** - * @member XMLElement - * The addChild() function adds a child element - * - * @param {XMLElement} child the non-null child to add. - */ - addChild: function (child) { - if (child !== null) { - child.parent = this; - this.children.push(child); - } - }, - /** - * @member XMLElement - * The insertChild() function inserts a child element at the index provided - * - * @param {XMLElement} child the non-null child to add. - * @param {int} index where to put the child. - */ - insertChild: function (child, index) { - if (child) { - if ((child.getLocalName() === null) && (! this.hasChildren())) { - var lastChild = this.children[this.children.length -1]; - if (lastChild.getLocalName() === null) { - lastChild.setContent(lastChild.getContent() + child.getContent()); - return; - } - } - child.parent = this; - this.children.splice(index,0,child); - } - }, - /** - * @member XMLElement - * The getChild() returns the child XMLElement as specified by the index parameter. - * The value of the index parameter must be less than the total number of children to avoid going out of the array storing the child elements. - * When the path parameter is specified, then it will return all children that match that path. The path is a series of elements and sub-elements, separated by slashes. - * - * @param {int} index where to put the child. - * @param {String} path path to a particular element - * - * @return {XMLElement} the element - */ - getChild: function (){ - if (typeof arguments[0] === "number") { - return this.children[arguments[0]]; - } - else if (arguments[0].indexOf('/') !== -1) { // path was given - this.getChildRecursive(arguments[0].split("/"), 0); - } else { - var kid, kidName; - for (var i = 0; i < this.getChildCount(); i++) { - kid = this.getChild(i); - kidName = kid.getName(); - if (kidName !== null && kidName === arguments[0]) { - return kid; - } - } - return null; - } - }, - /** - * @member XMLElement - * The getChildren() returns all of the children as an XMLElement array. - * When the path parameter is specified, then it will return all children that match that path. - * The path is a series of elements and sub-elements, separated by slashes. - * - * @param {String} path element name or path/to/element - * - * @return {XMLElement} array of child elements that match - * - * @see XMLElement#getChildCount() - * @see XMLElement#getChild() - */ - getChildren: function(){ - if (arguments.length === 1) { - if (typeof arguments[0] === "number") { - return this.getChild( arguments[0]); - } else if (arguments[0].indexOf('/') !== -1) { // path was given - return this.getChildrenRecursive( arguments[0].split("/"), 0); - } else { - var matches = []; - var kid, kidName; - for (var i = 0; i < this.getChildCount(); i++) { - kid = this.getChild(i); - kidName = kid.getName(); - if (kidName !== null && kidName === arguments[0]) { - matches.push(kid); - } - } - return matches; - } - }else { - return this.children; - } - }, - /** - * @member XMLElement - * The getChildCount() returns the number of children for the element. - * - * @return {int} the count - * - * @see XMLElement#getChild() - * @see XMLElement#getChildren() - */ - getChildCount: function(){ - return this.children.length; - }, - /** - * @member XMLElement - * Internal helper function for getChild(). - * - * @param {String[]} items result of splitting the query on slashes - * @param {int} offset where in the items[] array we're currently looking - * - * @return {XMLElement} matching element or null if no match - */ - getChildRecursive: function (items, offset) { - var kid, kidName; - for(var i = 0; i < this.getChildCount(); i++) { - kid = this.getChild(i); - kidName = kid.getName(); - if (kidName !== null && kidName === items[offset]) { - if (offset === items.length-1) { - return kid; - } else { - offset += 1; - return kid.getChildRecursive(items, offset); - } - } - } - return null; - }, - /** - * @member XMLElement - * Internal helper function for getChildren(). - * - * @param {String[]} items result of splitting the query on slashes - * @param {int} offset where in the items[] array we're currently looking - * - * @return {XMLElement[]} matching elements or empty array if no match - */ - getChildrenRecursive: function (items, offset) { - if (offset === items.length-1) { - return this.getChildren(items[offset]); - } - var matches = this.getChildren(items[offset]); - var kidMatches; - for (var i = 0; i < matches.length; i++) { - kidMatches = matches[i].getChildrenRecursive(items, offset+1); - } - return kidMatches; - }, - /** - * @member XMLElement - * Internal helper function for parse(). - * Loops through the - * @addon - * - * @param {XMLElement} parent the parent node - * @param {XML document childNodes} elementpath the remaining nodes that need parsing - * - * @return {XMLElement} the new element and its children elements - */ - parseChildrenRecursive: function (parent , elementpath){ - var xmlelement, - xmlattribute, - tmpattrib; - if (!parent) { - this.fullName = elementpath.localName; - this.name = elementpath.nodeName; - this.content = elementpath.textContent || ""; - xmlelement = this; - } else { // a parent - xmlelement = new XMLElement(elementpath.localName, elementpath.nodeName, "", ""); - xmlelement.content = elementpath.textContent || ""; - xmlelement.parent = parent; - } - - for (var l = 0; l < elementpath.attributes.length; l++) { - tmpattrib = elementpath.attributes[l]; - xmlattribute = new XMLAttribute(tmpattrib.getname , tmpattrib.nodeName, tmpattrib.namespaceURI , tmpattrib.nodeValue , tmpattrib.nodeType); - xmlelement.attributes.push(xmlattribute); - } - - for (var node in elementpath.childNodes){ - if(elementpath.childNodes[node].nodeType === 1) { //ELEMENT_NODE type - xmlelement.children.push( xmlelement.parseChildrenRecursive(xmlelement, elementpath.childNodes[node])); - } - } - return xmlelement; - }, - /** - * @member XMLElement - * The isLeaf() function returns whether the element is a leaf element. - * - * @return {boolean} true if the element has no children. - */ - isLeaf: function(){ - return !this.hasChildren(); - }, - /** - * @member XMLElement - * The listChildren() function put the names of all children into an array. Same as looping through - * each child and calling getName() on each XMLElement. - * - * @return {String[]} a list of element names. - */ - listChildren: function() { - var arr = []; - for (var i = 0; i < this.children.length; i++) { - arr.push( this.getChild(i).getName()); - } - return arr; - }, - /** - * @member XMLElement - * The removeAttribute() function removes an attribute - * - * @param {String} name the non-null name of the attribute. - * @param {String} namespace the namespace URI of the attribute, which may be null. - */ - removeAttribute: function (name , namespace) { - this.namespace = namespace || ""; - for (var i = 0; i < this.attributes.length; i++){ - if (this.attributes[i].getName() === name && this.attributes[i].getNamespace() === this.namespace) { - this.attributes.splice(i, 1); - } - } - }, - /** - * @member XMLElement - * The removeChild() removes a child element. - * - * @param {XMLElement} child the the non-null child to be renoved - */ - removeChild: function(child) { - if (child) { - for (var i = 0; i < this.children.length; i++) { - if (this.children[i].equalsXMLElement(child)) { - this.children.splice(i, 1); - } - } - } - }, - /** - * @member XMLElement - * The removeChildAtIndex() removes the child located at a certain index - * - * @param {int} index the index of the child, where the first child has index 0 - */ - removeChildAtIndex: function(index) { - if (this.children.length > index) { //make sure its not outofbounds - this.children.splice(index, 1); - } - }, - /** - * @member XMLElement - * The findAttribute() function searches an attribute - * - * @param {String} name fullName the non-null full name of the attribute - * @param {String} namespace the name space, which may be null - * - * @return {XMLAttribute} the attribute, or null if the attribute does not exist. - */ - findAttribute: function (name, namespace) { - this.namespace = namespace || ""; - for (var i = 0; i < this.attributes.length; i++ ) { - if (this.attributes[i].getName() === name && this.attributes[i].getNamespace() === this.namespace) { - return this.attributes[i]; - } - } - }, - /** - * @member XMLElement - * The setAttribute() function sets an attribute. - * - * @param {String} name the non-null full name of the attribute - * @param {String} namespace the non-null value of the attribute - */ - setAttribute: function() { - var attr; - if (arguments.length === 3) { - var index = arguments[0].indexOf(':'); - var name = arguments[0].substring(index + 1); - attr = this.findAttribute( name, arguments[1] ); - if (attr) { - attr.setValue(arguments[2]); - } else { - attr = new XMLAttribute(arguments[0], name, arguments[1], arguments[2], "CDATA"); - this.attributes.push(attr); - } - } else { - attr = this.findAttribute(arguments[0]); - if (attr) { - attr.setValue(arguments[1]); - } else { - attr = new XMLAttribute(arguments[0], arguments[0], null, arguments[1], "CDATA"); - this.attributes.push(attr); - } - } - }, - /** - * @member XMLElement - * The setContent() function sets the #PCDATA content. It is an error to call this method with a - * non-null value if there are child objects. - * - * @param {String} content the (possibly null) content - */ - setContent: function(content) { - this.content = content; - }, - /** - * @member XMLElement - * The setName() function sets the full name. This method also sets the short name and clears the - * namespace URI. - * - * @param {String} name the non-null name - * @param {String} namespace the namespace URI, which may be null. - */ - setName: function() { - if (arguments.length === 1) { - this.name = arguments[0]; - this.fullName = arguments[0]; - this.namespace = null; - } else { - var index = arguments[0].indexOf(':'); - if ((arguments[1] === null) || (index < 0)) { - this.name = arguments[0]; - } else { - this.name = arguments[0].substring(index + 1); - } - this.fullName = arguments[0]; - this.namespace = arguments[1]; - } - }, - /** - * @member XMLElement - * The getName() function returns the full name (i.e. the name including an eventual namespace - * prefix) of the element. - * - * @return {String} the name, or null if the element only contains #PCDATA. - */ - getName: function() { - return this.fullName; - }, - getLocalName: function() { - return this.name; - }, - getAttributeCount: function() { - return this.attributes.length; - } - }; - - - //////////////////////////////////////////////////////////////////////////// - // 2D Matrix - //////////////////////////////////////////////////////////////////////////// - /** - * Helper function for printMatrix(). Finds the largest scalar - * in the matrix, then number of digits left of the decimal. - * Call from PMatrix2D and PMatrix3D's print() function. - */ - var printMatrixHelper = function printMatrixHelper(elements) { - var big = 0; - for (var i = 0; i < elements.length; i++) { - if (i !== 0) { - big = Math.max(big, Math.abs(elements[i])); - } else { - big = Math.abs(elements[i]); - } - } - - var digits = (big + "").indexOf("."); - if (digits === 0) { - digits = 1; - } else if (digits === -1) { - digits = (big + "").length; - } - - return digits; - }; - /** - * PMatrix2D is a 3x2 affine matrix implementation. The constructor accepts another PMatrix2D or a list of six float elements. - * If no parameters are provided the matrix is set to the identity matrix. - * - * @param {PMatrix2D} matrix the initial matrix to set to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fifth element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - var PMatrix2D = p.PMatrix2D = function() { - if (arguments.length === 0) { - this.reset(); - } else if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - this.set(arguments[0].array()); - } else if (arguments.length === 6) { - this.set(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); - } - }; - /** - * PMatrix2D methods - */ - PMatrix2D.prototype = { - /** - * @member PMatrix2D - * The set() function sets the matrix elements. The function accepts either another PMatrix2D, an array of elements, or a list of six floats. - * - * @param {PMatrix2D} matrix the matrix to set this matrix to - * @param {float[]} elements an array of elements to set this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fith element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - set: function() { - if (arguments.length === 6) { - var a = arguments; - this.set([a[0], a[1], a[2], - a[3], a[4], a[5]]); - } else if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - this.elements = arguments[0].array(); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - this.elements = arguments[0].slice(); - } - }, - /** - * @member PMatrix2D - * The get() function returns a copy of this PMatrix2D. - * - * @return {PMatrix2D} a copy of this PMatrix2D - */ - get: function() { - var outgoing = new PMatrix2D(); - outgoing.set(this.elements); - return outgoing; - }, - /** - * @member PMatrix2D - * The reset() function sets this PMatrix2D to the identity matrix. - */ - reset: function() { - this.set([1, 0, 0, 0, 1, 0]); - }, - /** - * @member PMatrix2D - * The array() function returns a copy of the element values. - * @addon - * - * @return {float[]} returns a copy of the element values - */ - array: function array() { - return this.elements.slice(); - }, - /** - * @member PMatrix2D - * The translate() function translates this matrix by moving the current coordinates to the location specified by tx and ty. - * - * @param {float} tx the x-axis coordinate to move to - * @param {float} ty the y-axis coordinate to move to - */ - translate: function(tx, ty) { - this.elements[2] = tx * this.elements[0] + ty * this.elements[1] + this.elements[2]; - this.elements[5] = tx * this.elements[3] + ty * this.elements[4] + this.elements[5]; - }, - /** - * @member PMatrix2D - * The transpose() function is not used in processingjs. - */ - transpose: function() { - // Does nothing in Processing. - }, - /** - * @member PMatrix2D - * The mult() function multiplied this matrix. - * If two array elements are passed in the function will multiply a two element vector against this matrix. - * If target is null or not length four, a new float array will be returned. - * The values for vec and target can be the same (though that's less efficient). - * If two PVectors are passed in the function multiply the x and y coordinates of a PVector against this matrix. - * - * @param {PVector} source, target the PVectors used to multiply this matrix - * @param {float[]} source, target the arrays used to multiply this matrix - * - * @return {PVector|float[]} returns a PVector or an array representing the new matrix - */ - mult: function(source, target) { - var x, y; - if (source instanceof PVector) { - x = source.x; - y = source.y; - if (!target) { - target = new PVector(); - } - } else if (source instanceof Array) { - x = source[0]; - y = source[1]; - if (!target) { - target = []; - } - } - if (target instanceof Array) { - target[0] = this.elements[0] * x + this.elements[1] * y + this.elements[2]; - target[1] = this.elements[3] * x + this.elements[4] * y + this.elements[5]; - } else if (target instanceof PVector) { - target.x = this.elements[0] * x + this.elements[1] * y + this.elements[2]; - target.y = this.elements[3] * x + this.elements[4] * y + this.elements[5]; - target.z = 0; - } - return target; - }, - /** - * @member PMatrix2D - * The multX() function calculates the x component of a vector from a transformation. - * - * @param {float} x the x component of the vector being transformed - * @param {float} y the y component of the vector being transformed - * - * @return {float} returnes the result of the calculation - */ - multX: function(x, y) { - return (x * this.elements[0] + y * this.elements[1] + this.elements[2]); - }, - /** - * @member PMatrix2D - * The multY() function calculates the y component of a vector from a transformation. - * - * @param {float} x the x component of the vector being transformed - * @param {float} y the y component of the vector being transformed - * - * @return {float} returnes the result of the calculation - */ - multY: function(x, y) { - return (x * this.elements[3] + y * this.elements[4] + this.elements[5]); - }, - /** - * @member PMatrix2D - * The skewX() function skews the matrix along the x-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewX: function(angle) { - this.apply(1, 0, 1, angle, 0, 0); - }, - /** - * @member PMatrix2D - * The skewY() function skews the matrix along the y-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewY: function(angle) { - this.apply(1, 0, 1, 0, angle, 0); - }, - /** - * @member PMatrix2D - * The determinant() function calvculates the determinant of this matrix. - * - * @return {float} the determinant of the matrix - */ - determinant: function() { - return (this.elements[0] * this.elements[4] - this.elements[1] * this.elements[3]); - }, - /** - * @member PMatrix2D - * The invert() function inverts this matrix - * - * @return {boolean} true if successful - */ - invert: function() { - var d = this.determinant(); - if (Math.abs( d ) > PConstants.MIN_INT) { - var old00 = this.elements[0]; - var old01 = this.elements[1]; - var old02 = this.elements[2]; - var old10 = this.elements[3]; - var old11 = this.elements[4]; - var old12 = this.elements[5]; - this.elements[0] = old11 / d; - this.elements[3] = -old10 / d; - this.elements[1] = -old01 / d; - this.elements[4] = old00 / d; - this.elements[2] = (old01 * old12 - old11 * old02) / d; - this.elements[5] = (old10 * old02 - old00 * old12) / d; - return true; - } - return false; - }, - /** - * @member PMatrix2D - * The scale() function increases or decreases the size of a shape by expanding and contracting vertices. When only one parameter is specified scale will occur in all dimensions. - * This is equivalent to a two parameter call. - * - * @param {float} sx the amount to scale on the x-axis - * @param {float} sy the amount to scale on the y-axis - */ - scale: function(sx, sy) { - if (sx && !sy) { - sy = sx; - } - if (sx && sy) { - this.elements[0] *= sx; - this.elements[1] *= sy; - this.elements[3] *= sx; - this.elements[4] *= sy; - } - }, - /** - * @member PMatrix2D - * The apply() function multiplies the current matrix by the one specified through the parameters. Note that either a PMatrix2D or a list of floats can be passed in. - * - * @param {PMatrix2D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fith element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - apply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - source = arguments[0].array(); - } else if (arguments.length === 6) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - - var result = [0, 0, this.elements[2], - 0, 0, this.elements[5]]; - var e = 0; - for (var row = 0; row < 2; row++) { - for (var col = 0; col < 3; col++, e++) { - result[e] += this.elements[row * 3 + 0] * source[col + 0] + - this.elements[row * 3 + 1] * source[col + 3]; - } - } - this.elements = result.slice(); - }, - /** - * @member PMatrix2D - * The preApply() function applies another matrix to the left of this one. Note that either a PMatrix2D or elements of a matrix can be passed in. - * - * @param {PMatrix2D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fith element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - preApply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - source = arguments[0].array(); - } else if (arguments.length === 6) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - var result = [0, 0, source[2], - 0, 0, source[5]]; - result[2] = source[2] + this.elements[2] * source[0] + this.elements[5] * source[1]; - result[5] = source[5] + this.elements[2] * source[3] + this.elements[5] * source[4]; - result[0] = this.elements[0] * source[0] + this.elements[3] * source[1]; - result[3] = this.elements[0] * source[3] + this.elements[3] * source[4]; - result[1] = this.elements[1] * source[0] + this.elements[4] * source[1]; - result[4] = this.elements[1] * source[3] + this.elements[4] * source[4]; - this.elements = result.slice(); - }, - /** - * @member PMatrix2D - * The rotate() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotate: function(angle) { - var c = Math.cos(angle); - var s = Math.sin(angle); - var temp1 = this.elements[0]; - var temp2 = this.elements[1]; - this.elements[0] = c * temp1 + s * temp2; - this.elements[1] = -s * temp1 + c * temp2; - temp1 = this.elements[3]; - temp2 = this.elements[4]; - this.elements[3] = c * temp1 + s * temp2; - this.elements[4] = -s * temp1 + c * temp2; - }, - /** - * @member PMatrix2D - * The rotateZ() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateZ: function(angle) { - this.rotate(angle); - }, - /** - * @member PMatrix2D - * The print() function prints out the elements of this matrix - */ - print: function() { - var digits = printMatrixHelper(this.elements); - var output = "" + p.nfs(this.elements[0], digits, 4) + " " + - p.nfs(this.elements[1], digits, 4) + " " + - p.nfs(this.elements[2], digits, 4) + "\n" + - p.nfs(this.elements[3], digits, 4) + " " + - p.nfs(this.elements[4], digits, 4) + " " + - p.nfs(this.elements[5], digits, 4) + "\n\n"; - p.println(output); - } - }; - - /** - * PMatrix3D is a 4x4 matrix implementation. The constructor accepts another PMatrix3D or a list of six or sixteen float elements. - * If no parameters are provided the matrix is set to the identity matrix. - */ - var PMatrix3D = p.PMatrix3D = function PMatrix3D() { - // When a matrix is created, it is set to an identity matrix - this.reset(); - }; - /** - * PMatrix3D methods - */ - PMatrix3D.prototype = { - /** - * @member PMatrix2D - * The set() function sets the matrix elements. The function accepts either another PMatrix3D, an array of elements, or a list of six or sixteen floats. - * - * @param {PMatrix3D} matrix the initial matrix to set to - * @param {float[]} elements an array of elements to set this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - */ - set: function() { - if (arguments.length === 16) { - this.elements = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof PMatrix3D) { - this.elements = arguments[0].array(); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - this.elements = arguments[0].slice(); - } - }, - /** - * @member PMatrix3D - * The get() function returns a copy of this PMatrix3D. - * - * @return {PMatrix3D} a copy of this PMatrix3D - */ - get: function() { - var outgoing = new PMatrix3D(); - outgoing.set(this.elements); - return outgoing; - }, - /** - * @member PMatrix3D - * The reset() function sets this PMatrix3D to the identity matrix. - */ - reset: function() { - this.set([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The array() function returns a copy of the element values. - * @addon - * - * @return {float[]} returns a copy of the element values - */ - array: function array() { - return this.elements.slice(); - }, - /** - * @member PMatrix3D - * The translate() function translates this matrix by moving the current coordinates to the location specified by tx, ty, and tz. - * - * @param {float} tx the x-axis coordinate to move to - * @param {float} ty the y-axis coordinate to move to - * @param {float} tz the z-axis coordinate to move to - */ - translate: function(tx, ty, tz) { - if (tz === undef) { - tz = 0; - } - - this.elements[3] += tx * this.elements[0] + ty * this.elements[1] + tz * this.elements[2]; - this.elements[7] += tx * this.elements[4] + ty * this.elements[5] + tz * this.elements[6]; - this.elements[11] += tx * this.elements[8] + ty * this.elements[9] + tz * this.elements[10]; - this.elements[15] += tx * this.elements[12] + ty * this.elements[13] + tz * this.elements[14]; - }, - /** - * @member PMatrix2D - * The transpose() function transpose this matrix. - */ - transpose: function() { - var temp = this.elements.slice(); - this.elements[0] = temp[0]; - this.elements[1] = temp[4]; - this.elements[2] = temp[8]; - this.elements[3] = temp[12]; - this.elements[4] = temp[1]; - this.elements[5] = temp[5]; - this.elements[6] = temp[9]; - this.elements[7] = temp[13]; - this.elements[8] = temp[2]; - this.elements[9] = temp[6]; - this.elements[10] = temp[10]; - this.elements[11] = temp[14]; - this.elements[12] = temp[3]; - this.elements[13] = temp[7]; - this.elements[14] = temp[11]; - this.elements[15] = temp[15]; - }, - /** - * @member PMatrix3D - * The mult() function multiplied this matrix. - * If two array elements are passed in the function will multiply a two element vector against this matrix. - * If target is null or not length four, a new float array will be returned. - * The values for vec and target can be the same (though that's less efficient). - * If two PVectors are passed in the function multiply the x and y coordinates of a PVector against this matrix. - * - * @param {PVector} source, target the PVectors used to multiply this matrix - * @param {float[]} source, target the arrays used to multiply this matrix - * - * @return {PVector|float[]} returns a PVector or an array representing the new matrix - */ - mult: function(source, target) { - var x, y, z, w; - if (source instanceof PVector) { - x = source.x; - y = source.y; - z = source.z; - w = 1; - if (!target) { - target = new PVector(); - } - } else if (source instanceof Array) { - x = source[0]; - y = source[1]; - z = source[2]; - w = source[3] || 1; - - if (!target || target.length !== 3 && target.length !== 4) { - target = [0, 0, 0]; - } - } - - if (target instanceof Array) { - if (target.length === 3) { - target[0] = this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3]; - target[1] = this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7]; - target[2] = this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11]; - } else if (target.length === 4) { - target[0] = this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3] * w; - target[1] = this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7] * w; - target[2] = this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11] * w; - target[3] = this.elements[12] * x + this.elements[13] * y + this.elements[14] * z + this.elements[15] * w; - } - } - if (target instanceof PVector) { - target.x = this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3]; - target.y = this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7]; - target.z = this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11]; - } - return target; - }, - /** - * @member PMatrix3D - * The preApply() function applies another matrix to the left of this one. Note that either a PMatrix3D or elements of a matrix can be passed in. - * - * @param {PMatrix3D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - */ - preApply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix3D) { - source = arguments[0].array(); - } else if (arguments.length === 16) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - - var result = [0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0]; - var e = 0; - for (var row = 0; row < 4; row++) { - for (var col = 0; col < 4; col++, e++) { - result[e] += this.elements[col + 0] * source[row * 4 + 0] + this.elements[col + 4] * - source[row * 4 + 1] + this.elements[col + 8] * source[row * 4 + 2] + - this.elements[col + 12] * source[row * 4 + 3]; - } - } - this.elements = result.slice(); - }, - /** - * @member PMatrix3D - * The apply() function multiplies the current matrix by the one specified through the parameters. Note that either a PMatrix3D or a list of floats can be passed in. - * - * @param {PMatrix3D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - */ - apply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix3D) { - source = arguments[0].array(); - } else if (arguments.length === 16) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - - var result = [0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0]; - var e = 0; - for (var row = 0; row < 4; row++) { - for (var col = 0; col < 4; col++, e++) { - result[e] += this.elements[row * 4 + 0] * source[col + 0] + this.elements[row * 4 + 1] * - source[col + 4] + this.elements[row * 4 + 2] * source[col + 8] + - this.elements[row * 4 + 3] * source[col + 12]; - } - } - this.elements = result.slice(); - }, - /** - * @member PMatrix3D - * The rotate() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotate: function(angle, v0, v1, v2) { - if (!v1) { - this.rotateZ(angle); - } else { - // TODO should make sure this vector is normalized - var c = p.cos(angle); - var s = p.sin(angle); - var t = 1.0 - c; - - this.apply((t * v0 * v0) + c, - (t * v0 * v1) - (s * v2), - (t * v0 * v2) + (s * v1), - 0, - (t * v0 * v1) + (s * v2), - (t * v1 * v1) + c, - (t * v1 * v2) - (s * v0), - 0, - (t * v0 * v2) - (s * v1), - (t * v1 * v2) + (s * v0), - (t * v2 * v2) + c, - 0, 0, 0, 0, 1); - } - }, - /** - * @member PMatrix2D - * The invApply() function applies the inverted matrix to this matrix. - * - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - * - * @return {boolean} returns true if the operation was successful. - */ - invApply: function() { - if (inverseCopy === undef) { - inverseCopy = new PMatrix3D(); - } - var a = arguments; - inverseCopy.set(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], - a[9], a[10], a[11], a[12], a[13], a[14], a[15]); - - if (!inverseCopy.invert()) { - return false; - } - this.preApply(inverseCopy); - return true; - }, - /** - * @member PMatrix3D - * The rotateZ() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateX: function(angle) { - var c = p.cos(angle); - var s = p.sin(angle); - this.apply([1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The rotateY() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateY: function(angle) { - var c = p.cos(angle); - var s = p.sin(angle); - this.apply([c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The rotateZ() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateZ: function(angle) { - var c = Math.cos(angle); - var s = Math.sin(angle); - this.apply([c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The scale() function increases or decreases the size of a matrix by expanding and contracting vertices. When only one parameter is specified scale will occur in all dimensions. - * This is equivalent to a three parameter call. - * - * @param {float} sx the amount to scale on the x-axis - * @param {float} sy the amount to scale on the y-axis - * @param {float} sz the amount to scale on the z-axis - */ - scale: function(sx, sy, sz) { - if (sx && !sy && !sz) { - sy = sz = sx; - } else if (sx && sy && !sz) { - sz = 1; - } - - if (sx && sy && sz) { - this.elements[0] *= sx; - this.elements[1] *= sy; - this.elements[2] *= sz; - this.elements[4] *= sx; - this.elements[5] *= sy; - this.elements[6] *= sz; - this.elements[8] *= sx; - this.elements[9] *= sy; - this.elements[10] *= sz; - this.elements[12] *= sx; - this.elements[13] *= sy; - this.elements[14] *= sz; - } - }, - /** - * @member PMatrix3D - * The skewX() function skews the matrix along the x-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewX: function(angle) { - var t = Math.tan(angle); - this.apply(1, t, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); - }, - /** - * @member PMatrix3D - * The skewY() function skews the matrix along the y-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewY: function(angle) { - var t = Math.tan(angle); - this.apply(1, 0, 0, 0, t, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); - }, - multX: function(x, y, z, w) { - if (!z) { - return this.elements[0] * x + this.elements[1] * y + this.elements[3]; - } else if (!w) { - return this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3]; - } else { - return this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3] * w; - } - }, - multY: function(x, y, z, w) { - if (!z) { - return this.elements[4] * x + this.elements[5] * y + this.elements[7]; - } else if (!w) { - return this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7]; - } else { - return this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7] * w; - } - }, - multZ: function(x, y, z, w) { - if (!w) { - return this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11]; - } else { - return this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11] * w; - } - }, - multW: function(x, y, z, w) { - if (!w) { - return this.elements[12] * x + this.elements[13] * y + this.elements[14] * z + this.elements[15]; - } else { - return this.elements[12] * x + this.elements[13] * y + this.elements[14] * z + this.elements[15] * w; - } - }, - /** - * @member PMatrix3D - * The invert() function inverts this matrix - * - * @return {boolean} true if successful - */ - invert: function() { - var fA0 = this.elements[0] * this.elements[5] - this.elements[1] * this.elements[4]; - var fA1 = this.elements[0] * this.elements[6] - this.elements[2] * this.elements[4]; - var fA2 = this.elements[0] * this.elements[7] - this.elements[3] * this.elements[4]; - var fA3 = this.elements[1] * this.elements[6] - this.elements[2] * this.elements[5]; - var fA4 = this.elements[1] * this.elements[7] - this.elements[3] * this.elements[5]; - var fA5 = this.elements[2] * this.elements[7] - this.elements[3] * this.elements[6]; - var fB0 = this.elements[8] * this.elements[13] - this.elements[9] * this.elements[12]; - var fB1 = this.elements[8] * this.elements[14] - this.elements[10] * this.elements[12]; - var fB2 = this.elements[8] * this.elements[15] - this.elements[11] * this.elements[12]; - var fB3 = this.elements[9] * this.elements[14] - this.elements[10] * this.elements[13]; - var fB4 = this.elements[9] * this.elements[15] - this.elements[11] * this.elements[13]; - var fB5 = this.elements[10] * this.elements[15] - this.elements[11] * this.elements[14]; - - // Determinant - var fDet = fA0 * fB5 - fA1 * fB4 + fA2 * fB3 + fA3 * fB2 - fA4 * fB1 + fA5 * fB0; - - // Account for a very small value - // return false if not successful. - if (Math.abs(fDet) <= 1e-9) { - return false; - } - - var kInv = []; - kInv[0] = +this.elements[5] * fB5 - this.elements[6] * fB4 + this.elements[7] * fB3; - kInv[4] = -this.elements[4] * fB5 + this.elements[6] * fB2 - this.elements[7] * fB1; - kInv[8] = +this.elements[4] * fB4 - this.elements[5] * fB2 + this.elements[7] * fB0; - kInv[12] = -this.elements[4] * fB3 + this.elements[5] * fB1 - this.elements[6] * fB0; - kInv[1] = -this.elements[1] * fB5 + this.elements[2] * fB4 - this.elements[3] * fB3; - kInv[5] = +this.elements[0] * fB5 - this.elements[2] * fB2 + this.elements[3] * fB1; - kInv[9] = -this.elements[0] * fB4 + this.elements[1] * fB2 - this.elements[3] * fB0; - kInv[13] = +this.elements[0] * fB3 - this.elements[1] * fB1 + this.elements[2] * fB0; - kInv[2] = +this.elements[13] * fA5 - this.elements[14] * fA4 + this.elements[15] * fA3; - kInv[6] = -this.elements[12] * fA5 + this.elements[14] * fA2 - this.elements[15] * fA1; - kInv[10] = +this.elements[12] * fA4 - this.elements[13] * fA2 + this.elements[15] * fA0; - kInv[14] = -this.elements[12] * fA3 + this.elements[13] * fA1 - this.elements[14] * fA0; - kInv[3] = -this.elements[9] * fA5 + this.elements[10] * fA4 - this.elements[11] * fA3; - kInv[7] = +this.elements[8] * fA5 - this.elements[10] * fA2 + this.elements[11] * fA1; - kInv[11] = -this.elements[8] * fA4 + this.elements[9] * fA2 - this.elements[11] * fA0; - kInv[15] = +this.elements[8] * fA3 - this.elements[9] * fA1 + this.elements[10] * fA0; - - // Inverse using Determinant - var fInvDet = 1.0 / fDet; - kInv[0] *= fInvDet; - kInv[1] *= fInvDet; - kInv[2] *= fInvDet; - kInv[3] *= fInvDet; - kInv[4] *= fInvDet; - kInv[5] *= fInvDet; - kInv[6] *= fInvDet; - kInv[7] *= fInvDet; - kInv[8] *= fInvDet; - kInv[9] *= fInvDet; - kInv[10] *= fInvDet; - kInv[11] *= fInvDet; - kInv[12] *= fInvDet; - kInv[13] *= fInvDet; - kInv[14] *= fInvDet; - kInv[15] *= fInvDet; - - this.elements = kInv.slice(); - return true; - }, - toString: function() { - var str = ""; - for (var i = 0; i < 15; i++) { - str += this.elements[i] + ", "; - } - str += this.elements[15]; - return str; - }, - /** - * @member PMatrix3D - * The print() function prints out the elements of this matrix - */ - print: function() { - var digits = printMatrixHelper(this.elements); - - var output = "" + p.nfs(this.elements[0], digits, 4) + " " + p.nfs(this.elements[1], digits, 4) + - " " + p.nfs(this.elements[2], digits, 4) + " " + p.nfs(this.elements[3], digits, 4) + - "\n" + p.nfs(this.elements[4], digits, 4) + " " + p.nfs(this.elements[5], digits, 4) + - " " + p.nfs(this.elements[6], digits, 4) + " " + p.nfs(this.elements[7], digits, 4) + - "\n" + p.nfs(this.elements[8], digits, 4) + " " + p.nfs(this.elements[9], digits, 4) + - " " + p.nfs(this.elements[10], digits, 4) + " " + p.nfs(this.elements[11], digits, 4) + - "\n" + p.nfs(this.elements[12], digits, 4) + " " + p.nfs(this.elements[13], digits, 4) + - " " + p.nfs(this.elements[14], digits, 4) + " " + p.nfs(this.elements[15], digits, 4) + "\n\n"; - p.println(output); - }, - invTranslate: function(tx, ty, tz) { - this.preApply(1, 0, 0, -tx, 0, 1, 0, -ty, 0, 0, 1, -tz, 0, 0, 0, 1); - }, - invRotateX: function(angle) { - var c = Math.cos(-angle); - var s = Math.sin(-angle); - this.preApply([1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1]); - }, - invRotateY: function(angle) { - var c = Math.cos(-angle); - var s = Math.sin(-angle); - this.preApply([c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1]); - }, - invRotateZ: function(angle) { - var c = Math.cos(-angle); - var s = Math.sin(-angle); - this.preApply([c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }, - invScale: function(x, y, z) { - this.preApply([1 / x, 0, 0, 0, 0, 1 / y, 0, 0, 0, 0, 1 / z, 0, 0, 0, 0, 1]); - } - }; - - /** - * @private - * The matrix stack stores the transformations and translations that occur within the space. - */ - var PMatrixStack = p.PMatrixStack = function PMatrixStack() { - this.matrixStack = []; - }; - - /** - * @member PMatrixStack - * load pushes the matrix given in the function into the stack - * - * @param {Object | Array} matrix the matrix to be pushed into the stack - */ - PMatrixStack.prototype.load = function load() { - var tmpMatrix; - if (p.use3DContext) { - tmpMatrix = new PMatrix3D(); - } else { - tmpMatrix = new PMatrix2D(); - } - - if (arguments.length === 1) { - tmpMatrix.set(arguments[0]); - } else { - tmpMatrix.set(arguments); - } - this.matrixStack.push(tmpMatrix); - }; - - /** - * @member PMatrixStack - * push adds a duplicate of the top of the stack onto the stack - uses the peek function - */ - PMatrixStack.prototype.push = function push() { - this.matrixStack.push(this.peek()); - }; - - /** - * @member PMatrixStack - * pop removes returns the matrix at the top of the stack - * - * @returns {Object} the matrix at the top of the stack - */ - PMatrixStack.prototype.pop = function pop() { - return this.matrixStack.pop(); - }; - - /** - * @member PMatrixStack - * peek returns but doesn't remove the matrix at the top of the stack - * - * @returns {Object} the matrix at the top of the stack - */ - PMatrixStack.prototype.peek = function peek() { - var tmpMatrix; - if (p.use3DContext) { - tmpMatrix = new PMatrix3D(); - } else { - tmpMatrix = new PMatrix2D(); - } - - tmpMatrix.set(this.matrixStack[this.matrixStack.length - 1]); - return tmpMatrix; - }; - - /** - * @member PMatrixStack - * this function multiplies the matrix at the top of the stack with the matrix given as a parameter - * - * @param {Object | Array} matrix the matrix to be multiplied into the stack - */ - PMatrixStack.prototype.mult = function mult(matrix) { - this.matrixStack[this.matrixStack.length - 1].apply(matrix); - }; - - //////////////////////////////////////////////////////////////////////////// - // Array handling - //////////////////////////////////////////////////////////////////////////// - - /** - * The split() function breaks a string into pieces using a character or string - * as the divider. The delim parameter specifies the character or characters that - * mark the boundaries between each piece. A String[] array is returned that contains - * each of the pieces. - * If the result is a set of numbers, you can convert the String[] array to to a float[] - * or int[] array using the datatype conversion functions int() and float() (see example above). - * The splitTokens() function works in a similar fashion, except that it splits using a range - * of characters instead of a specific character or sequence. - * - * @param {String} str the String to be split - * @param {String} delim the character or String used to separate the data - * - * @returns {string[]} The new string array - * - * @see splitTokens - * @see join - * @see trim - */ - p.split = function(str, delim) { - return str.split(delim); - }; - - /** - * The splitTokens() function splits a String at one or many character "tokens." The tokens - * parameter specifies the character or characters to be used as a boundary. - * If no tokens character is specified, any whitespace character is used to split. - * Whitespace characters include tab (\t), line feed (\n), carriage return (\r), form - * feed (\f), and space. To convert a String to an array of integers or floats, use the - * datatype conversion functions int() and float() to convert the array of Strings. - * - * @param {String} str the String to be split - * @param {Char[]} tokens list of individual characters that will be used as separators - * - * @returns {string[]} The new string array - * - * @see split - * @see join - * @see trim - */ - p.splitTokens = function(str, tokens) { - if (arguments.length === 1) { - tokens = "\n\t\r\f "; - } - - tokens = "[" + tokens + "]"; - - var ary = []; - var index = 0; - var pos = str.search(tokens); - - while (pos >= 0) { - if (pos === 0) { - str = str.substring(1); - } else { - ary[index] = str.substring(0, pos); - index++; - str = str.substring(pos); - } - pos = str.search(tokens); - } - - if (str.length > 0) { - ary[index] = str; - } - - if (ary.length === 0) { - ary = undef; - } - - return ary; - }; - - /** - * Expands an array by one element and adds data to the new position. The datatype of - * the element parameter must be the same as the datatype of the array. - * When using an array of objects, the data returned from the function must be cast to - * the object array's data type. For example: SomeClass[] items = (SomeClass[]) - * append(originalArray, element). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array boolean[], - * byte[], char[], int[], float[], or String[], or an array of objects - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} element new data for the array - * - * @returns Array (the same datatype as the input) - * - * @see shorten - * @see expand - */ - p.append = function(array, element) { - array[array.length] = element; - return array; - }; - - /** - * Concatenates two arrays. For example, concatenating the array { 1, 2, 3 } and the - * array { 4, 5, 6 } yields { 1, 2, 3, 4, 5, 6 }. Both parameters must be arrays of the - * same datatype. - * When using an array of objects, the data returned from the function must be cast to the - * object array's data type. For example: SomeClass[] items = (SomeClass[]) concat(array1, array2). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array1 boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array2 boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * - * @returns Array (the same datatype as the input) - * - * @see splice - */ - p.concat = function(array1, array2) { - return array1.concat(array2); - }; - - /** - * Sorts an array of numbers from smallest to largest and puts an array of - * words in alphabetical order. The original array is not modified, a - * re-ordered array is returned. The count parameter states the number of - * elements to sort. For example if there are 12 elements in an array and - * if count is the value 5, only the first five elements on the array will - * be sorted. Alphabetical ordering is case insensitive. - * - * @param {String[] | int[] | float[]} array Array of elements to sort - * @param {int} numElem Number of elements to sort - * - * @returns {String[] | int[] | float[]} Array (same datatype as the input) - * - * @see reverse - */ - p.sort = function(array, numElem) { - var ret = []; - - // depending on the type used (int, float) or string - // we'll need to use a different compare function - if (array.length > 0) { - // copy since we need to return another array - var elemsToCopy = numElem > 0 ? numElem : array.length; - for (var i = 0; i < elemsToCopy; i++) { - ret.push(array[i]); - } - if (typeof array[0] === "string") { - ret.sort(); - } - // int or float - else { - ret.sort(function(a, b) { - return a - b; - }); - } - - // copy on the rest of the elements that were not sorted in case the user - // only wanted a subset of an array to be sorted. - if (numElem > 0) { - for (var j = ret.length; j < array.length; j++) { - ret.push(array[j]); - } - } - } - return ret; - }; - - /** - * Inserts a value or array of values into an existing array. The first two parameters must - * be of the same datatype. The array parameter defines the array which will be modified - * and the second parameter defines the data which will be inserted. When using an array - * of objects, the data returned from the function must be cast to the object array's data - * type. For example: SomeClass[] items = (SomeClass[]) splice(array1, array2, index). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * @param {boolean|byte|char|int|float|String|boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} - * value boolean, byte, char, int, float, String, boolean[], byte[], char[], int[], - * float[], String[], or other Object: value or an array of objects to be spliced in - * @param {int} index position in the array from which to insert data - * - * @returns Array (the same datatype as the input) - * - * @see contract - * @see subset - */ - p.splice = function(array, value, index) { - - // Trying to splice an empty array into "array" in P5 won't do - // anything, just return the original. - if(value.length === 0) - { - return array; - } - - // If the second argument was an array, we'll need to iterate over all - // the "value" elements and add one by one because - // array.splice(index, 0, value); - // would create a multi-dimensional array which isn't what we want. - if(value instanceof Array) { - for(var i = 0, j = index; i < value.length; j++,i++) { - array.splice(j, 0, value[i]); - } - } else { - array.splice(index, 0, value); - } - - return array; - }; - - /** - * Extracts an array of elements from an existing array. The array parameter defines the - * array from which the elements will be copied and the offset and length parameters determine - * which elements to extract. If no length is given, elements will be extracted from the offset - * to the end of the array. When specifying the offset remember the first array element is 0. - * This function does not change the source array. - * When using an array of objects, the data returned from the function must be cast to the - * object array's data type. - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * @param {int} offset position to begin - * @param {int} length number of values to extract - * - * @returns Array (the same datatype as the input) - * - * @see splice - */ - p.subset = function(array, offset, length) { - if (arguments.length === 2) { - return array.slice(offset, array.length - offset); - } else if (arguments.length === 3) { - return array.slice(offset, offset + length); - } - }; - - /** - * Combines an array of Strings into one String, each separated by the character(s) used for - * the separator parameter. To join arrays of ints or floats, it's necessary to first convert - * them to strings using nf() or nfs(). - * - * @param {Array} array array of Strings - * @param {char|String} separator char or String to be placed between each item - * - * @returns {String} The combined string - * - * @see split - * @see trim - * @see nf - * @see nfs - */ - p.join = function(array, seperator) { - return array.join(seperator); - }; - - /** - * Decreases an array by one element and returns the shortened array. When using an - * array of objects, the data returned from the function must be cast to the object array's - * data type. For example: SomeClass[] items = (SomeClass[]) shorten(originalArray). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array - * boolean[], byte[], char[], int[], float[], or String[], or an array of objects - * - * @returns Array (the same datatype as the input) - * - * @see append - * @see expand - */ - p.shorten = function(ary) { - var newary = []; - - // copy array into new array - var len = ary.length; - for (var i = 0; i < len; i++) { - newary[i] = ary[i]; - } - newary.pop(); - - return newary; - }; - - /** - * Increases the size of an array. By default, this function doubles the size of the array, - * but the optional newSize parameter provides precise control over the increase in size. - * When using an array of objects, the data returned from the function must be cast to the - * object array's data type. For example: SomeClass[] items = (SomeClass[]) expand(originalArray). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} ary - * boolean[], byte[], char[], int[], float[], String[], or an array of objects - * @param {int} newSize positive int: new size for the array - * - * @returns Array (the same datatype as the input) - * - * @see contract - */ - p.expand = function(ary, newSize) { - var temp = ary.slice(0); - if (arguments.length === 1) { - // double size of array - temp.length = ary.length * 2; - return temp; - } else if (arguments.length === 2) { - // size is newSize - temp.length = newSize; - return temp; - } - }; - - /** - * Copies an array (or part of an array) to another array. The src array is copied to the - * dst array, beginning at the position specified by srcPos and into the position specified - * by dstPos. The number of elements to copy is determined by length. The simplified version - * with two arguments copies an entire array to another of the same size. It is equivalent - * to "arrayCopy(src, 0, dst, 0, src.length)". This function is far more efficient for copying - * array data than iterating through a for and copying each element. - * - * @param {Array} src an array of any data type: the source array - * @param {Array} dest an array of any data type (as long as it's the same as src): the destination array - * @param {int} srcPos starting position in the source array - * @param {int} destPos starting position in the destination array - * @param {int} length number of array elements to be copied - * - * @returns none - */ - p.arrayCopy = function() { // src, srcPos, dest, destPos, length) { - var src, srcPos = 0, dest, destPos = 0, length; - - if (arguments.length === 2) { - // recall itself and copy src to dest from start index 0 to 0 of src.length - src = arguments[0]; - dest = arguments[1]; - length = src.length; - } else if (arguments.length === 3) { - // recall itself and copy src to dest from start index 0 to 0 of length - src = arguments[0]; - dest = arguments[1]; - length = arguments[2]; - } else if (arguments.length === 5) { - src = arguments[0]; - srcPos = arguments[1]; - dest = arguments[2]; - destPos = arguments[3]; - length = arguments[4]; - } - - // copy src to dest from index srcPos to index destPos of length recursivly on objects - for (var i = srcPos, j = destPos; i < length + srcPos; i++, j++) { - if (dest[j] !== undef) { - dest[j] = src[i]; - } else { - throw "array index out of bounds exception"; - } - } - }; - - /** - * Reverses the order of an array. - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]} array - * boolean[], byte[], char[], int[], float[], or String[] - * - * @returns Array (the same datatype as the input) - * - * @see sort - */ - p.reverse = function(array) { - return array.reverse(); - }; - - - //////////////////////////////////////////////////////////////////////////// - // Color functions - //////////////////////////////////////////////////////////////////////////// - - // helper functions for internal blending modes - p.mix = function(a, b, f) { - return a + (((b - a) * f) >> 8); - }; - - p.peg = function(n) { - return (n < 0) ? 0 : ((n > 255) ? 255 : n); - }; - - // blending modes - /** - * These are internal blending modes used for BlendColor() - * - * @param {Color} c1 First Color to blend - * @param {Color} c2 Second Color to blend - * - * @returns {Color} The blended Color - * - * @see BlendColor - * @see Blend - */ - p.modes = { - replace: function(c1, c2) { - return c2; - }, - blend: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - p.mix(c1 & PConstants.RED_MASK, c2 & PConstants.RED_MASK, f) & PConstants.RED_MASK | - p.mix(c1 & PConstants.GREEN_MASK, c2 & PConstants.GREEN_MASK, f) & PConstants.GREEN_MASK | - p.mix(c1 & PConstants.BLUE_MASK, c2 & PConstants.BLUE_MASK, f)); - }, - add: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - Math.min(((c1 & PConstants.RED_MASK) + ((c2 & PConstants.RED_MASK) >> 8) * f), PConstants.RED_MASK) & PConstants.RED_MASK | - Math.min(((c1 & PConstants.GREEN_MASK) + ((c2 & PConstants.GREEN_MASK) >> 8) * f), PConstants.GREEN_MASK) & PConstants.GREEN_MASK | - Math.min((c1 & PConstants.BLUE_MASK) + (((c2 & PConstants.BLUE_MASK) * f) >> 8), PConstants.BLUE_MASK)); - }, - subtract: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - Math.max(((c1 & PConstants.RED_MASK) - ((c2 & PConstants.RED_MASK) >> 8) * f), PConstants.GREEN_MASK) & PConstants.RED_MASK | - Math.max(((c1 & PConstants.GREEN_MASK) - ((c2 & PConstants.GREEN_MASK) >> 8) * f), PConstants.BLUE_MASK) & PConstants.GREEN_MASK | - Math.max((c1 & PConstants.BLUE_MASK) - (((c2 & PConstants.BLUE_MASK) * f) >> 8), 0)); - }, - lightest: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - Math.max(c1 & PConstants.RED_MASK, ((c2 & PConstants.RED_MASK) >> 8) * f) & PConstants.RED_MASK | - Math.max(c1 & PConstants.GREEN_MASK, ((c2 & PConstants.GREEN_MASK) >> 8) * f) & PConstants.GREEN_MASK | - Math.max(c1 & PConstants.BLUE_MASK, ((c2 & PConstants.BLUE_MASK) * f) >> 8)); - }, - darkest: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - p.mix(c1 & PConstants.RED_MASK, Math.min(c1 & PConstants.RED_MASK, ((c2 & PConstants.RED_MASK) >> 8) * f), f) & PConstants.RED_MASK | - p.mix(c1 & PConstants.GREEN_MASK, Math.min(c1 & PConstants.GREEN_MASK, ((c2 & PConstants.GREEN_MASK) >> 8) * f), f) & PConstants.GREEN_MASK | - p.mix(c1 & PConstants.BLUE_MASK, Math.min(c1 & PConstants.BLUE_MASK, ((c2 & PConstants.BLUE_MASK) * f) >> 8), f)); - }, - difference: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (ar > br) ? (ar - br) : (br - ar); - var cg = (ag > bg) ? (ag - bg) : (bg - ag); - var cb = (ab > bb) ? (ab - bb) : (bb - ab); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - exclusion: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = ar + br - ((ar * br) >> 7); - var cg = ag + bg - ((ag * bg) >> 7); - var cb = ab + bb - ((ab * bb) >> 7); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - multiply: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (ar * br) >> 8; - var cg = (ag * bg) >> 8; - var cb = (ab * bb) >> 8; - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - screen: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = 255 - (((255 - ar) * (255 - br)) >> 8); - var cg = 255 - (((255 - ag) * (255 - bg)) >> 8); - var cb = 255 - (((255 - ab) * (255 - bb)) >> 8); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - hard_light: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (br < 128) ? ((ar * br) >> 7) : (255 - (((255 - ar) * (255 - br)) >> 7)); - var cg = (bg < 128) ? ((ag * bg) >> 7) : (255 - (((255 - ag) * (255 - bg)) >> 7)); - var cb = (bb < 128) ? ((ab * bb) >> 7) : (255 - (((255 - ab) * (255 - bb)) >> 7)); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - soft_light: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = ((ar * br) >> 7) + ((ar * ar) >> 8) - ((ar * ar * br) >> 15); - var cg = ((ag * bg) >> 7) + ((ag * ag) >> 8) - ((ag * ag * bg) >> 15); - var cb = ((ab * bb) >> 7) + ((ab * ab) >> 8) - ((ab * ab * bb) >> 15); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - overlay: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (ar < 128) ? ((ar * br) >> 7) : (255 - (((255 - ar) * (255 - br)) >> 7)); - var cg = (ag < 128) ? ((ag * bg) >> 7) : (255 - (((255 - ag) * (255 - bg)) >> 7)); - var cb = (ab < 128) ? ((ab * bb) >> 7) : (255 - (((255 - ab) * (255 - bb)) >> 7)); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - dodge: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (br === 255) ? 255 : p.peg((ar << 8) / (255 - br)); // division requires pre-peg()-ing - var cg = (bg === 255) ? 255 : p.peg((ag << 8) / (255 - bg)); // " - var cb = (bb === 255) ? 255 : p.peg((ab << 8) / (255 - bb)); // " - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - burn: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (br === 0) ? 0 : 255 - p.peg(((255 - ar) << 8) / br); // division requires pre-peg()-ing - var cg = (bg === 0) ? 0 : 255 - p.peg(((255 - ag) << 8) / bg); // " - var cb = (bb === 0) ? 0 : 255 - p.peg(((255 - ab) << 8) / bb); // " - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - } - }; - - function color$4(aValue1, aValue2, aValue3, aValue4) { - var r, g, b, a; - - if (curColorMode === PConstants.HSB) { - var rgb = p.color.toRGB(aValue1, aValue2, aValue3); - r = rgb[0]; - g = rgb[1]; - b = rgb[2]; - } else { - r = Math.round(255 * (aValue1 / colorModeX)); - g = Math.round(255 * (aValue2 / colorModeY)); - b = Math.round(255 * (aValue3 / colorModeZ)); - } - - a = Math.round(255 * (aValue4 / colorModeA)); - - // Limit values greater than 255 - r = (r > 255) ? 255 : r; - g = (g > 255) ? 255 : g; - b = (b > 255) ? 255 : b; - a = (a > 255) ? 255 : a; - - // Create color int - return (a << 24) & PConstants.ALPHA_MASK | (r << 16) & PConstants.RED_MASK | (g << 8) & PConstants.GREEN_MASK | b & PConstants.BLUE_MASK; - } - - function color$2(aValue1, aValue2) { - var a; - - // Color int and alpha - if (aValue1 & PConstants.ALPHA_MASK) { - a = Math.round(255 * (aValue2 / colorModeA)); - a = (a > 255) ? 255 : a; - - return aValue1 - (aValue1 & PConstants.ALPHA_MASK) + ((a << 24) & PConstants.ALPHA_MASK); - } - // Grayscale and alpha - else { - if (curColorMode === PConstants.RGB) { - return color$4(aValue1, aValue1, aValue1, aValue2); - } else if (curColorMode === PConstants.HSB) { - return color$4(0, 0, (aValue1 / colorModeX) * colorModeZ, aValue2); - } - } - } - - function color$1(aValue1) { - // Grayscale - if (aValue1 <= colorModeX && aValue1 >= 0) { - if (curColorMode === PConstants.RGB) { - return color$4(aValue1, aValue1, aValue1, colorModeA); - } else if (curColorMode === PConstants.HSB) { - return color$4(0, 0, (aValue1 / colorModeX) * colorModeZ, colorModeA); - } - } - // Color int - else if (aValue1) { - return aValue1; - } - } - - /** - * Creates colors for storing in variables of the color datatype. The parameters are - * interpreted as RGB or HSB values depending on the current colorMode(). The default - * mode is RGB values from 0 to 255 and therefore, the function call color(255, 204, 0) - * will return a bright yellow color. More about how colors are stored can be found in - * the reference for the color datatype. - * - * @param {int|float} aValue1 red or hue or grey values relative to the current color range. - * Also can be color value in hexadecimal notation (i.e. #FFCC00 or 0xFFFFCC00) - * @param {int|float} aValue2 green or saturation values relative to the current color range - * @param {int|float} aValue3 blue or brightness values relative to the current color range - * @param {int|float} aValue4 relative to current color range. Represents alpha - * - * @returns {color} the color - * - * @see colorMode - */ - p.color = function color(aValue1, aValue2, aValue3, aValue4) { - // 4 arguments: (R, G, B, A) or (H, S, B, A) - if (aValue1 !== undef && aValue2 !== undef && aValue3 !== undef && aValue4 !== undef) { - return color$4(aValue1, aValue2, aValue3, aValue4); - } - - // 3 arguments: (R, G, B) or (H, S, B) - else if (aValue1 !== undef && aValue2 !== undef && aValue3 !== undef) { - return color$4(aValue1, aValue2, aValue3, colorModeA); - } - - // 2 arguments: (Color, A) or (Grayscale, A) - else if (aValue1 !== undef && aValue2 !== undef) { - return color$2(aValue1, aValue2); - } - - // 1 argument: (Grayscale) or (Color) - else if (typeof aValue1 === "number") { - return color$1(aValue1); - } - - // Default - else { - return color$4(colorModeX, colorModeY, colorModeZ, colorModeA); - } - }; - - // Ease of use function to extract the colour bits into a string - p.color.toString = function(colorInt) { - return "rgba(" + ((colorInt & PConstants.RED_MASK) >>> 16) + "," + ((colorInt & PConstants.GREEN_MASK) >>> 8) + - "," + ((colorInt & PConstants.BLUE_MASK)) + "," + ((colorInt & PConstants.ALPHA_MASK) >>> 24) / 255 + ")"; - }; - - // Easy of use function to pack rgba values into a single bit-shifted color int. - p.color.toInt = function(r, g, b, a) { - return (a << 24) & PConstants.ALPHA_MASK | (r << 16) & PConstants.RED_MASK | (g << 8) & PConstants.GREEN_MASK | b & PConstants.BLUE_MASK; - }; - - // Creates a simple array in [R, G, B, A] format, [255, 255, 255, 255] - p.color.toArray = function(colorInt) { - return [(colorInt & PConstants.RED_MASK) >>> 16, (colorInt & PConstants.GREEN_MASK) >>> 8, - colorInt & PConstants.BLUE_MASK, (colorInt & PConstants.ALPHA_MASK) >>> 24]; - }; - - // Creates a WebGL color array in [R, G, B, A] format. WebGL wants the color ranges between 0 and 1, [1, 1, 1, 1] - p.color.toGLArray = function(colorInt) { - return [((colorInt & PConstants.RED_MASK) >>> 16) / 255, ((colorInt & PConstants.GREEN_MASK) >>> 8) / 255, - (colorInt & PConstants.BLUE_MASK) / 255, ((colorInt & PConstants.ALPHA_MASK) >>> 24) / 255]; - }; - - // HSB conversion function from Mootools, MIT Licensed - p.color.toRGB = function(h, s, b) { - // Limit values greater than range - h = (h > colorModeX) ? colorModeX : h; - s = (s > colorModeY) ? colorModeY : s; - b = (b > colorModeZ) ? colorModeZ : b; - - h = (h / colorModeX) * 360; - s = (s / colorModeY) * 100; - b = (b / colorModeZ) * 100; - - var br = Math.round(b / 100 * 255); - - if (s === 0) { // Grayscale - return [br, br, br]; - } else { - var hue = h % 360; - var f = hue % 60; - var p = Math.round((b * (100 - s)) / 10000 * 255); - var q = Math.round((b * (6000 - s * f)) / 600000 * 255); - var t = Math.round((b * (6000 - s * (60 - f))) / 600000 * 255); - switch (Math.floor(hue / 60)) { - case 0: - return [br, t, p]; - case 1: - return [q, br, p]; - case 2: - return [p, br, t]; - case 3: - return [p, q, br]; - case 4: - return [t, p, br]; - case 5: - return [br, p, q]; - } - } - }; - - p.color.toHSB = function( colorInt ) { - var red, green, blue; - - red = ((colorInt & PConstants.RED_MASK) >>> 16) / 255; - green = ((colorInt & PConstants.GREEN_MASK) >>> 8) / 255; - blue = (colorInt & PConstants.BLUE_MASK) / 255; - - var max = p.max(p.max(red,green), blue), - min = p.min(p.min(red,green), blue), - hue, saturation; - - if (min === max) { - return [0, 0, max]; - } else { - saturation = (max - min) / max; - - if (red === max) { - hue = (green - blue) / (max - min); - } else if (green === max) { - hue = 2 + ((blue - red) / (max - min)); - } else { - hue = 4 + ((red - green) / (max - min)); - } - - hue /= 6; - - if (hue < 0) { - hue += 1; - } else if (hue > 1) { - hue -= 1; - } - } - return [hue*colorModeX, saturation*colorModeY, max*colorModeZ]; - }; - - /** - * Extracts the brightness value from a color. - * - * @param {color} colInt any value of the color datatype - * - * @returns {float} The brightness color value. - * - * @see red - * @see green - * @see blue - * @see hue - * @see saturation - */ - p.brightness = function(colInt){ - return p.color.toHSB(colInt)[2]; - }; - - /** - * Extracts the saturation value from a color. - * - * @param {color} colInt any value of the color datatype - * - * @returns {float} The saturation color value. - * - * @see red - * @see green - * @see blue - * @see hue - * @see brightness - */ - p.saturation = function(colInt){ - return p.color.toHSB(colInt)[1]; - }; - - /** - * Extracts the hue value from a color. - * - * @param {color} colInt any value of the color datatype - * - * @returns {float} The hue color value. - * - * @see red - * @see green - * @see blue - * @see saturation - * @see brightness - */ - p.hue = function(colInt){ - return p.color.toHSB(colInt)[0]; - }; - - var verifyChannel = function verifyChannel(aColor) { - if (aColor.constructor === Array) { - return aColor; - } else { - return p.color(aColor); - } - }; - - /** - * Extracts the red value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The red color value. - * - * @see green - * @see blue - * @see alpha - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.red = function(aColor) { - return ((aColor & PConstants.RED_MASK) >>> 16) / 255 * colorModeX; - }; - - /** - * Extracts the green value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The green color value. - * - * @see red - * @see blue - * @see alpha - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.green = function(aColor) { - return ((aColor & PConstants.GREEN_MASK) >>> 8) / 255 * colorModeY; - }; - - /** - * Extracts the blue value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The blue color value. - * - * @see red - * @see green - * @see alpha - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.blue = function(aColor) { - return (aColor & PConstants.BLUE_MASK) / 255 * colorModeZ; - }; - - /** - * Extracts the alpha value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The alpha color value. - * - * @see red - * @see green - * @see blue - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.alpha = function(aColor) { - return ((aColor & PConstants.ALPHA_MASK) >>> 24) / 255 * colorModeA; - }; - - /** - * Calculates a color or colors between two colors at a specific increment. - * The amt parameter is the amount to interpolate between the two values where 0.0 - * equal to the first point, 0.1 is very near the first point, 0.5 is half-way in between, etc. - * - * @param {color} c1 interpolate from this color - * @param {color} c2 interpolate to this color - * @param {float} amt between 0.0 and 1.0 - * - * @returns {float} The blended color. - * - * @see blendColor - * @see color - */ - p.lerpColor = function lerpColor(c1, c2, amt) { - // Get RGBA values for Color 1 to floats - var colorBits1 = p.color(c1); - var r1 = (colorBits1 & PConstants.RED_MASK) >>> 16; - var g1 = (colorBits1 & PConstants.GREEN_MASK) >>> 8; - var b1 = (colorBits1 & PConstants.BLUE_MASK); - var a1 = ((colorBits1 & PConstants.ALPHA_MASK) >>> 24) / colorModeA; - - // Get RGBA values for Color 2 to floats - var colorBits2 = p.color(c2); - var r2 = (colorBits2 & PConstants.RED_MASK) >>> 16; - var g2 = (colorBits2 & PConstants.GREEN_MASK) >>> 8; - var b2 = (colorBits2 & PConstants.BLUE_MASK); - var a2 = ((colorBits2 & PConstants.ALPHA_MASK) >>> 24) / colorModeA; - - // Return lerp value for each channel, INT for color, Float for Alpha-range - var r = parseInt(p.lerp(r1, r2, amt), 10); - var g = parseInt(p.lerp(g1, g2, amt), 10); - var b = parseInt(p.lerp(b1, b2, amt), 10); - var a = parseFloat(p.lerp(a1, a2, amt) * colorModeA); - - return p.color.toInt(r, g, b, a); - }; - - // Forced default color mode for #aaaaaa style - /** - * Convert 3 int values to a color in the default color mode RGB even if curColorMode is not set to RGB - * - * @param {int} aValue1 range for the red color - * @param {int} aValue2 range for the green color - * @param {int} aValue3 range for the blue color - * - * @returns {Color} - * - * @see color - */ - p.defaultColor = function(aValue1, aValue2, aValue3) { - var tmpColorMode = curColorMode; - curColorMode = PConstants.RGB; - var c = p.color(aValue1 / 255 * colorModeX, aValue2 / 255 * colorModeY, aValue3 / 255 * colorModeZ); - curColorMode = tmpColorMode; - return c; - }; - - /** - * Changes the way Processing interprets color data. By default, fill(), stroke(), and background() - * colors are set by values between 0 and 255 using the RGB color model. It is possible to change the - * numerical range used for specifying colors and to switch color systems. For example, calling colorMode(RGB, 1.0) - * will specify that values are specified between 0 and 1. The limits for defining colors are altered by setting the - * parameters range1, range2, range3, and range 4. - * - * @param {MODE} mode Either RGB or HSB, corresponding to Red/Green/Blue and Hue/Saturation/Brightness - * @param {int|float} range range for all color elements - * @param {int|float} range1 range for the red or hue depending on the current color mode - * @param {int|float} range2 range for the green or saturation depending on the current color mode - * @param {int|float} range3 range for the blue or brightness depending on the current color mode - * @param {int|float} range4 range for the alpha - * - * @returns none - * - * @see background - * @see fill - * @see stroke - */ - p.colorMode = function colorMode() { // mode, range1, range2, range3, range4 - curColorMode = arguments[0]; - if (arguments.length > 1) { - colorModeX = arguments[1]; - colorModeY = arguments[2] || arguments[1]; - colorModeZ = arguments[3] || arguments[1]; - colorModeA = arguments[4] || arguments[1]; - } - }; - - /** - * Blends two color values together based on the blending mode given as the MODE parameter. - * The possible modes are described in the reference for the blend() function. - * - * @param {color} c1 color: the first color to blend - * @param {color} c2 color: the second color to blend - * @param {MODE} MODE Either BLEND, ADD, SUBTRACT, DARKEST, LIGHTEST, DIFFERENCE, EXCLUSION, MULTIPLY, - * SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, or BURN - * - * @returns {float} The blended color. - * - * @see blend - * @see color - */ - p.blendColor = function(c1, c2, mode) { - var color = 0; - switch (mode) { - case PConstants.REPLACE: - color = p.modes.replace(c1, c2); - break; - case PConstants.BLEND: - color = p.modes.blend(c1, c2); - break; - case PConstants.ADD: - color = p.modes.add(c1, c2); - break; - case PConstants.SUBTRACT: - color = p.modes.subtract(c1, c2); - break; - case PConstants.LIGHTEST: - color = p.modes.lightest(c1, c2); - break; - case PConstants.DARKEST: - color = p.modes.darkest(c1, c2); - break; - case PConstants.DIFFERENCE: - color = p.modes.difference(c1, c2); - break; - case PConstants.EXCLUSION: - color = p.modes.exclusion(c1, c2); - break; - case PConstants.MULTIPLY: - color = p.modes.multiply(c1, c2); - break; - case PConstants.SCREEN: - color = p.modes.screen(c1, c2); - break; - case PConstants.HARD_LIGHT: - color = p.modes.hard_light(c1, c2); - break; - case PConstants.SOFT_LIGHT: - color = p.modes.soft_light(c1, c2); - break; - case PConstants.OVERLAY: - color = p.modes.overlay(c1, c2); - break; - case PConstants.DODGE: - color = p.modes.dodge(c1, c2); - break; - case PConstants.BURN: - color = p.modes.burn(c1, c2); - break; - } - return color; - }; - - //////////////////////////////////////////////////////////////////////////// - // Canvas-Matrix manipulation - //////////////////////////////////////////////////////////////////////////// - - function saveContext() { - curContext.save(); - } - - function restoreContext() { - curContext.restore(); - isStrokeDirty = true; - isFillDirty = true; - } - - /** - * Prints the current matrix to the text window. - * - * @returns none - * - * @see pushMatrix - * @see popMatrix - * @see resetMatrix - * @see applyMatrix - */ - p.printMatrix = function printMatrix() { - modelView.print(); - }; - - /** - * Specifies an amount to displace objects within the display window. The x parameter specifies left/right translation, - * the y parameter specifies up/down translation, and the z parameter specifies translations toward/away from the screen. - * Using this function with the z parameter requires using the P3D or OPENGL parameter in combination with size as shown - * in the above example. Transformations apply to everything that happens after and subsequent calls to the function - * accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). - * If translate() is called within draw(), the transformation is reset when the loop begins again. - * This function can be further controlled by the pushMatrix() and popMatrix(). - * - * @param {int|float} x left/right translation - * @param {int|float} y up/down translation - * @param {int|float} z forward/back translation - * - * @returns none - * - * @see pushMatrix - * @see popMatrix - * @see scale - * @see rotate - * @see rotateX - * @see rotateY - * @see rotateZ - */ - p.translate = function translate(x, y, z) { - if (p.use3DContext) { - forwardTransform.translate(x, y, z); - reverseTransform.invTranslate(x, y, z); - } else { - curContext.translate(x, y); - } - }; - - /** - * Increases or decreases the size of a shape by expanding and contracting vertices. Objects always scale from their - * relative origin to the coordinate system. Scale values are specified as decimal percentages. For example, the - * function call scale(2.0) increases the dimension of a shape by 200%. Transformations apply to everything that - * happens after and subsequent calls to the function multiply the effect. For example, calling scale(2.0) and - * then scale(1.5) is the same as scale(3.0). If scale() is called within draw(), the transformation is reset when - * the loop begins again. Using this fuction with the z parameter requires passing P3D or OPENGL into the size() - * parameter as shown in the example above. This function can be further controlled by pushMatrix() and popMatrix(). - * - * @param {int|float} size percentage to scale the object - * @param {int|float} x percentage to scale the object in the x-axis - * @param {int|float} y percentage to scale the object in the y-axis - * @param {int|float} z percentage to scale the object in the z-axis - * - * @returns none - * - * @see pushMatrix - * @see popMatrix - * @see translate - * @see rotate - * @see rotateX - * @see rotateY - * @see rotateZ - */ - p.scale = function scale(x, y, z) { - if (p.use3DContext) { - forwardTransform.scale(x, y, z); - reverseTransform.invScale(x, y, z); - } else { - curContext.scale(x, y || x); - } - }; - - /** - * Pushes the current transformation matrix onto the matrix stack. Understanding pushMatrix() and popMatrix() - * requires understanding the concept of a matrix stack. The pushMatrix() function saves the current coordinate - * system to the stack and popMatrix() restores the prior coordinate system. pushMatrix() and popMatrix() are - * used in conjuction with the other transformation methods and may be embedded to control the scope of - * the transformations. - * - * @returns none - * - * @see popMatrix - * @see translate - * @see rotate - * @see rotateX - * @see rotateY - * @see rotateZ - */ - p.pushMatrix = function pushMatrix() { - if (p.use3DContext) { - userMatrixStack.load(modelView); - } else { - saveContext(); - } - }; - - /** - * Pops the current transformation matrix off the matrix stack. Understanding pushing and popping requires - * understanding the concept of a matrix stack. The pushMatrix() function saves the current coordinate system to - * the stack and popMatrix() restores the prior coordinate system. pushMatrix() and popMatrix() are used in - * conjuction with the other transformation methods and may be embedded to control the scope of the transformations. - * - * @returns none - * - * @see popMatrix - * @see pushMatrix - */ - p.popMatrix = function popMatrix() { - if (p.use3DContext) { - modelView.set(userMatrixStack.pop()); - } else { - restoreContext(); - } - }; - - /** - * Replaces the current matrix with the identity matrix. The equivalent function in OpenGL is glLoadIdentity(). - * - * @returns none - * - * @see popMatrix - * @see pushMatrix - * @see applyMatrix - * @see printMatrix - */ - p.resetMatrix = function resetMatrix() { - if (p.use3DContext) { - forwardTransform.reset(); - reverseTransform.reset(); - } else { - curContext.setTransform(1,0,0,1,0,0); - } - }; - - /** - * Multiplies the current matrix by the one specified through the parameters. This is very slow because it will - * try to calculate the inverse of the transform, so avoid it whenever possible. The equivalent function - * in OpenGL is glMultMatrix(). - * - * @param {int|float} n00-n15 numbers which define the 4x4 matrix to be multiplied - * - * @returns none - * - * @see popMatrix - * @see pushMatrix - * @see resetMatrix - * @see printMatrix - */ - p.applyMatrix = function applyMatrix() { - var a = arguments; - if (!p.use3DContext) { - for (var cnt = a.length; cnt < 16; cnt++) { - a[cnt] = 0; - } - a[10] = a[15] = 1; - } - - forwardTransform.apply(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]); - reverseTransform.invApply(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]); - }; - - /** - * Rotates a shape around the x-axis the amount specified by the angle parameter. Angles should be - * specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * Objects are always rotated around their relative position to the origin and positive numbers - * rotate objects in a counterclockwise direction. Transformations apply to everything that happens - * after and subsequent calls to the function accumulates the effect. For example, calling rotateX(PI/2) - * and then rotateX(PI/2) is the same as rotateX(PI). If rotateX() is called within the draw(), the - * transformation is reset when the loop begins again. This function requires passing P3D or OPENGL - * into the size() parameter as shown in the example above. - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateY - * @see rotateZ - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotateX = function(angleInRadians) { - forwardTransform.rotateX(angleInRadians); - reverseTransform.invRotateX(angleInRadians); - }; - - /** - * Rotates a shape around the z-axis the amount specified by the angle parameter. Angles should be - * specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * Objects are always rotated around their relative position to the origin and positive numbers - * rotate objects in a counterclockwise direction. Transformations apply to everything that happens - * after and subsequent calls to the function accumulates the effect. For example, calling rotateZ(PI/2) - * and then rotateZ(PI/2) is the same as rotateZ(PI). If rotateZ() is called within the draw(), the - * transformation is reset when the loop begins again. This function requires passing P3D or OPENGL - * into the size() parameter as shown in the example above. - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateX - * @see rotateY - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotateZ = function(angleInRadians) { - forwardTransform.rotateZ(angleInRadians); - reverseTransform.invRotateZ(angleInRadians); - }; - - /** - * Rotates a shape around the y-axis the amount specified by the angle parameter. Angles should be - * specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * Objects are always rotated around their relative position to the origin and positive numbers - * rotate objects in a counterclockwise direction. Transformations apply to everything that happens - * after and subsequent calls to the function accumulates the effect. For example, calling rotateY(PI/2) - * and then rotateY(PI/2) is the same as rotateY(PI). If rotateY() is called within the draw(), the - * transformation is reset when the loop begins again. This function requires passing P3D or OPENGL - * into the size() parameter as shown in the example above. - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateX - * @see rotateZ - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotateY = function(angleInRadians) { - forwardTransform.rotateY(angleInRadians); - reverseTransform.invRotateY(angleInRadians); - }; - - /** - * Rotates a shape the amount specified by the angle parameter. Angles should be specified in radians - * (values from 0 to TWO_PI) or converted to radians with the radians() function. Objects are always - * rotated around their relative position to the origin and positive numbers rotate objects in a - * clockwise direction. Transformations apply to everything that happens after and subsequent calls - * to the function accumulates the effect. For example, calling rotate(HALF_PI) and then rotate(HALF_PI) - * is the same as rotate(PI). All tranformations are reset when draw() begins again. Technically, - * rotate() multiplies the current transformation matrix by a rotation matrix. This function can be - * further controlled by the pushMatrix() and popMatrix(). - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateX - * @see rotateY - * @see rotateZ - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotate = function rotate(angleInRadians) { - if (p.use3DContext) { - forwardTransform.rotateZ(angleInRadians); - reverseTransform.invRotateZ(angleInRadians); - } else { - curContext.rotate(angleInRadians); - } - }; - - /** - * The pushStyle() function saves the current style settings and popStyle() restores the prior settings. - * Note that these functions are always used together. They allow you to change the style settings and later - * return to what you had. When a new style is started with pushStyle(), it builds on the current style information. - * The pushStyle() and popStyle() functions can be embedded to provide more control (see the second example - * above for a demonstration.) - * The style information controlled by the following functions are included in the style: fill(), stroke(), tint(), - * strokeWeight(), strokeCap(), strokeJoin(), imageMode(), rectMode(), ellipseMode(), shapeMode(), colorMode(), - * textAlign(), textFont(), textMode(), textSize(), textLeading(), emissive(), specular(), shininess(), ambient() - * - * @returns none - * - * @see popStyle - */ - p.pushStyle = function pushStyle() { - // Save the canvas state. - saveContext(); - - p.pushMatrix(); - - var newState = { - 'doFill': doFill, - 'currentFillColor': currentFillColor, - 'doStroke': doStroke, - 'currentStrokeColor': currentStrokeColor, - 'curTint': curTint, - 'curRectMode': curRectMode, - 'curColorMode': curColorMode, - 'colorModeX': colorModeX, - 'colorModeZ': colorModeZ, - 'colorModeY': colorModeY, - 'colorModeA': colorModeA, - 'curTextFont': curTextFont, - 'curTextSize': curTextSize - }; - - styleArray.push(newState); - }; - - /** - * The pushStyle() function saves the current style settings and popStyle() restores the prior settings; these - * functions are always used together. They allow you to change the style settings and later return to what you had. - * When a new style is started with pushStyle(), it builds on the current style information. The pushStyle() and - * popStyle() functions can be embedded to provide more control (see the second example above for a demonstration.) - * - * @returns none - * - * @see pushStyle - */ - p.popStyle = function popStyle() { - var oldState = styleArray.pop(); - - if (oldState) { - restoreContext(); - - p.popMatrix(); - - doFill = oldState.doFill; - currentFillColor = oldState.currentFillColor; - doStroke = oldState.doStroke; - currentStrokeColor = oldState.currentStrokeColor; - curTint = oldState.curTint; - curRectMode = oldState.curRectmode; - curColorMode = oldState.curColorMode; - colorModeX = oldState.colorModeX; - colorModeZ = oldState.colorModeZ; - colorModeY = oldState.colorModeY; - colorModeA = oldState.colorModeA; - curTextFont = oldState.curTextFont; - curTextSize = oldState.curTextSize; - } else { - throw "Too many popStyle() without enough pushStyle()"; - } - }; - - //////////////////////////////////////////////////////////////////////////// - // Time based functions - //////////////////////////////////////////////////////////////////////////// - - /** - * Processing communicates with the clock on your computer. - * The year() function returns the current year as an integer (2003, 2004, 2005, etc). - * - * @returns {float} The current year. - * - * @see millis - * @see second - * @see minute - * @see hour - * @see day - * @see month - */ - p.year = function year() { - return new Date().getFullYear(); - }; - /** - * Processing communicates with the clock on your computer. - * The month() function returns the current month as a value from 1 - 12. - * - * @returns {float} The current month. - * - * @see millis - * @see second - * @see minute - * @see hour - * @see day - * @see year - */ - p.month = function month() { - return new Date().getMonth() + 1; - }; - /** - * Processing communicates with the clock on your computer. - * The day() function returns the current day as a value from 1 - 31. - * - * @returns {float} The current day. - * - * @see millis - * @see second - * @see minute - * @see hour - * @see month - * @see year - */ - p.day = function day() { - return new Date().getDate(); - }; - /** - * Processing communicates with the clock on your computer. - * The hour() function returns the current hour as a value from 0 - 23. - * - * @returns {float} The current hour. - * - * @see millis - * @see second - * @see minute - * @see month - * @see day - * @see year - */ - p.hour = function hour() { - return new Date().getHours(); - }; - /** - * Processing communicates with the clock on your computer. - * The minute() function returns the current minute as a value from 0 - 59. - * - * @returns {float} The current minute. - * - * @see millis - * @see second - * @see month - * @see hour - * @see day - * @see year - */ - p.minute = function minute() { - return new Date().getMinutes(); - }; - /** - * Processing communicates with the clock on your computer. - * The second() function returns the current second as a value from 0 - 59. - * - * @returns {float} The current minute. - * - * @see millis - * @see month - * @see minute - * @see hour - * @see day - * @see year - */ - p.second = function second() { - return new Date().getSeconds(); - }; - /** - * Returns the number of milliseconds (thousandths of a second) since starting a sketch. - * This information is often used for timing animation sequences. - * - * @returns {long} The number of milliseconds since starting the sketch. - * - * @see month - * @see second - * @see minute - * @see hour - * @see day - * @see year - */ - p.millis = function millis() { - return new Date().getTime() - start; - }; - - /** - * Executes the code within draw() one time. This functions allows the program to update - * the display window only when necessary, for example when an event registered by - * mousePressed() or keyPressed() occurs. - * In structuring a program, it only makes sense to call redraw() within events such as - * mousePressed(). This is because redraw() does not run draw() immediately (it only sets - * a flag that indicates an update is needed). - * Calling redraw() within draw() has no effect because draw() is continuously called anyway. - * - * @returns none - * - * @see noLoop - * @see loop - */ - p.redraw = function redraw() { - var sec = (new Date().getTime() - timeSinceLastFPS) / 1000; - framesSinceLastFPS++; - var fps = framesSinceLastFPS / sec; - - // recalculate FPS every half second for better accuracy. - if (sec > 0.5) { - timeSinceLastFPS = new Date().getTime(); - framesSinceLastFPS = 0; - p.__frameRate = fps; - } - - p.frameCount++; - - inDraw = true; - - if (p.use3DContext) { - // even if the color buffer isn't cleared with background(), - // the depth buffer needs to be cleared regardless. - curContext.clear(curContext.DEPTH_BUFFER_BIT); - curContextCache = { attributes: {}, locations: {} }; - // Delete all the lighting states and the materials the - // user set in the last draw() call. - p.noLights(); - p.lightFalloff(1, 0, 0); - p.shininess(1); - p.ambient(255, 255, 255); - p.specular(0, 0, 0); - p.camera(); - p.draw(); - } else { - saveContext(); - p.draw(); - restoreContext(); - } - - inDraw = false; - }; - - /** - * Stops Processing from continuously executing the code within draw(). If loop() is - * called, the code in draw() begin to run continuously again. If using noLoop() in - * setup(), it should be the last line inside the block. - * When noLoop() is used, it's not possible to manipulate or access the screen inside event - * handling functions such as mousePressed() or keyPressed(). Instead, use those functions - * to call redraw() or loop(), which will run draw(), which can update the screen properly. - * This means that when noLoop() has been called, no drawing can happen, and functions like - * saveFrame() or loadPixels() may not be used. - * Note that if the sketch is resized, redraw() will be called to update the sketch, even - * after noLoop() has been specified. Otherwise, the sketch would enter an odd state until - * loop() was called. - * - * @returns none - * - * @see redraw - * @see draw - * @see loop - */ - p.noLoop = function noLoop() { - doLoop = false; - loopStarted = false; - clearInterval(looping); - }; - - /** - * Causes Processing to continuously execute the code within draw(). If noLoop() is called, - * the code in draw() stops executing. - * - * @returns none - * - * @see noLoop - */ - p.loop = function loop() { - if (loopStarted) { - return; - } - - looping = window.setInterval(function() { - //try { - if (document.hasFocus instanceof Function) { - p.focused = document.hasFocus(); - } - p.redraw(); - //} catch(e_loop) { - //window.clearInterval(looping); - //throw e_loop; - //} - }, curMsPerFrame); - doLoop = true; - loopStarted = true; - }; - - /** - * Specifies the number of frames to be displayed every second. If the processor is not - * fast enough to maintain the specified rate, it will not be achieved. For example, the - * function call frameRate(30) will attempt to refresh 30 times a second. It is recommended - * to set the frame rate within setup(). The default rate is 60 frames per second. - * - * @param {int} aRate number of frames per second. - * - * @returns none - * - * @see delay - */ - p.frameRate = function frameRate(aRate) { - curFrameRate = aRate; - curMsPerFrame = 1000 / curFrameRate; - - // clear and reset interval - if (doLoop) { - p.noLoop(); - p.loop(); - } - }; - - var eventHandlers = []; - - /** - * Quits/stops/exits the program. Programs without a draw() function exit automatically - * after the last line has run, but programs with draw() run continuously until the - * program is manually stopped or exit() is run. - * Rather than terminating immediately, exit() will cause the sketch to exit after draw() - * has completed (or after setup() completes if called during the setup() method). - * - * @returns none - */ - p.exit = function exit() { - window.clearInterval(looping); - - Processing.removeInstance(p.externals.canvas.id); - - // Step through the libraries to detach them - for (var lib in Processing.lib) { - if (Processing.lib.hasOwnProperty(lib)) { - if (Processing.lib[lib].hasOwnProperty("detach")) { - Processing.lib[lib].detach(p); - } - } - } - - for (var i=0, ehl=eventHandlers.length; i 1 || (arguments.length === 1 && arguments[0] instanceof p.PImage)) { - var image = arguments[0], - x, y; - if (arguments.length >= 3) { - x = arguments[1]; - y = arguments[2]; - if (x < 0 || y < 0 || y >= image.height || x >= image.width) { - throw "x and y must be non-negative and less than the dimensions of the image"; - } - } else { - x = image.width >>> 1; - y = image.height >>> 1; - } - - // see https://developer.mozilla.org/en/Using_URL_values_for_the_cursor_property - var imageDataURL = image.toDataURL(); - var style = "url(\"" + imageDataURL + "\") " + x + " " + y + ", default"; - curCursor = curElement.style.cursor = style; - } else if (arguments.length === 1) { - var mode = arguments[0]; - curCursor = curElement.style.cursor = mode; - } else { - curCursor = curElement.style.cursor = oldCursor; - } - }; - - /** - * Hides the cursor from view. - * - * @returns none - * - * @see cursor - */ - p.noCursor = function noCursor() { - curCursor = curElement.style.cursor = PConstants.NOCURSOR; - }; - - /** - * Links to a webpage either in the same window or in a new window. The complete URL - * must be specified. - * - * @param {String} href complete url as a String in quotes - * @param {String} target name of the window to load the URL as a string in quotes - * - * @returns none - */ - p.link = function(href, target) { - if (target !== undef) { - window.open(href, target); - } else { - window.location = href; - } - }; - - // PGraphics methods - // TODO: These functions are suppose to be called before any operations are called on the - // PGraphics object. They currently do nothing. - p.beginDraw = function beginDraw() {}; - p.endDraw = function endDraw() {}; - - // Imports an external Processing.js library - p.Import = function Import(lib) { - // Replace evil-eval method with a DOM - - - - - - - - -
    - - -
    -
    - diff --git a/game/dev/scores/scores.js b/game/dev/scores/scores.js deleted file mode 100644 index d6403b2..0000000 --- a/game/dev/scores/scores.js +++ /dev/null @@ -1,221 +0,0 @@ -var make_scores = function(){ - var obj = {}; - - var num_rows = 15; - - // async gets scores and feeds to callback - var get_scores = function(callback){ - // ajax request to get scores - - // want to do them sequentially so we - // chain the callbacks - - // this comes third via callback - var do_global = function() { - // Global High Scores - $.post("scores/get_scores.php", { - num: num_rows, - }, callback("Global Scores", - // at the end of last callback we need to - // make the tabs - function() { - console.log("making tabs"); - $("#scores").tabs(); - - // remove the loading message - console.log("removing loading msg"); - $("#scores-loading").remove(); - - $("#scores").show(); - } - )); - }; - - // this comes second via callback - var do_friends = function() { - var friends = g_get_friends(); - if (friends.length !== 0) { - // Global High Scores - $.post("scores/get_scores.php", { - num: num_rows, - uid: g_user_id, - friends: friends - }, callback("Friends' Scores", do_global)); - console.log("got friends scores"); - } - else { - do_global(); - console.log("skipped friends scores"); - } - }; - - // this comes first - // Personal high scores - if (g_user_id) { - $.post("scores/get_scores.php", { - num: num_rows, - uid : g_user_id - }, callback("Your Scores", do_friends)); - console.log("getting user high scores"); - } - else { - do_global(); - } - }; - - var get_user_scores = function(callback) { - $.post("scores/get_scores.php", { - num : num_rows - }, callback); - }; - - // interprets json and displays it - // Passing it a header returns the actual function - // Must use this style so long as get_scores is async - // Passing a function as do_more does it at the end of the callback - var tab_count = 1; - var display_scores = function(header, do_more) { - var headers = [ "Rank", "Score", "Level", "Name", "Date" ]; - var formatters = { - "score": add_commas, - "date": function(date_str) { - //var d = new Date(date_str); - var d = new Date(); - // date_str must be of format yyyy-mm-dd - var year = parseInt(date_str.substring(0, 4)); - var month = parseInt(date_str.substring(5, 7))-1; - var day = parseInt(date_str.substring(8)); - d.setFullYear(year, month, day); - //return d.f("NNN d, yyyy"); - return d.format("mmm d, yyyy"); - }, - }; - return function(data){ - //console.log(data); - - var link = "
  • " - + header + "
  • "; - $("#tab-list").append(link); - - // con is the content to put in the score tab - var con = "
    "; - - try { - var scores = jQuery.parseJSON(data); - if (!scores) { - throw "No scores loaded"; - } - } - catch (e) { - con += "
    Error loading scores." - +" Please check your internet connection."; - } - if (scores) { - - con += "
    "; - - // -- start header row -- - con += ""; - for_each(headers, function(header) { - con += ""; - }); - con += ""; - // -- end header row -- - - //console.log(scores); - // scores is an array of row objects - var row_count = 1; - for_each(scores, function(row){ - con += ""; - con += ""; - for_each(keys(row), function(key){ - var f = formatters[key] || function(x) { return x; }; - // dont show uid - if (key !== "userid") { - con += ""; - } - }); - con += ""; - row_count += 1; - }); - // fill up rest of table for beauty's sake - while (row_count <= num_rows) { - con += ""; - for_each(headers, function(header){ - con += ""; - }); - con += ""; - row_count += 1; - } - - con += "
    " + header + "
    " + row_count + "." + f(row[key]) + "
     
    "; - con += ""; - - } - - // add it to page - $("#scores").append(con); - // update tab num - tab_count += 1; - - // do some more stuff if necessary - if (do_more) { - do_more(); - } - }; - }; - - // gets and displays scores - obj.do_scores = function(){ - console.log("trying to load scores"); - $("#scores").empty(); - $("#scores").hide(); - $("#scores").append("
      "); - // reset tab count - tab_count = 1; - get_scores(display_scores); - }; - - // inserts a score into the db - // score_obj: - // - score: int score - // - level: mutation level - // - userid: unique id for the user (from fb?) - var post_score = function(score_obj, callback){ - $.post("scores/post_score.php", score_obj, callback); - }; - - // testing function to use with form - obj.submit_score = function(score, level, name, uid){ - /* - var form = document.forms[0]; - var score = form.elements[0].value; - var level = form.elements[1].value; - var userid = form.elements[2].value; - */ - var date_str = (new Date()).format("yyyy-mm-dd"); - - var score_obj = { - /* - score: parseInt(score), - level: parseInt(level), - */ - score: score, - level: level, - name: name, - userid: uid, - //date: new Date().f('yyyy-MM-dd') - date: date_str - }; - console.log(score_obj); - - post_score(score_obj, function(data){ - console.log(data); - //obj.do_scores(); - }); - }; - - return obj; -} - -var scores = make_scores(); diff --git a/game/dev/seeker.js b/game/dev/seeker.js deleted file mode 100644 index ba3c879..0000000 --- a/game/dev/seeker.js +++ /dev/null @@ -1,127 +0,0 @@ -// ABSTRACT class for game objects that seek other game objects -// Classes that implement must override "my_update" instead of "update" -// --- inherits from object_with_states -// spec: -// game_object spec + -// speed = how fast the seeker approaches the target -// no_target_speed = how fast the object moves when there is no target -// target = object to move towards - -var seeker = function(p, spec) { - - // --- defaults --- - - // obj to return - var obj = object_with_states(p, spec); - - // --- private variables --- - - var speed = spec.speed || 0.2; - var no_target_speed = spec.no_target_speed || 0.2; - var alive = true; - var target = spec.target || null; - // initialized to random val at bottom - var target_angle = 0; - - // --- public methods --- - - // implementing game_object interface - - // update makes tkiller chase target cell - obj.update = function() { - var pos = obj.get_pos(); - var speed_to_use = speed; - - if (target && target.is_dead()) { - target = null; - } - - // if no target - if (target === null) { - // meander - if (parseInt(p.random(150)) === 0) { - target_angle += p.random(-p.PI/16, p.PI/16); - } - // laze - speed_to_use = no_target_speed; - } - else { - obj.face_target(); - } - - // change velocity to point towards target - var new_vel = new p.PVector( - p.cos(target_angle), p.sin(target_angle)); - new_vel.mult(speed_to_use); - obj.set_vel(new_vel); - - obj.my_update(); - }; - - // MUST BE OVERWRITTEN - obj.my_update = function() { - console.log("my_update (in seeker) not overwritten!"); - }; - - // Indicates that a mutation has occured and this object - // should float off the screen - // Makes this object stop and float off screen - obj.outdated = function() { - obj.set_state("outdated"); - obj.set_vel(new p.PVector(0,0)); - obj.set_target(null); - }; - - obj.is_outdated = function() { - return obj.get_state() === "outdated"; - }; - - // faces tar, or if tar not supplied, the object's - // target - obj.face_target = function(tar) { - var pos = obj.get_pos(); - if (target) { - var tpos = target.get_pos(); - } - if (tar) { - var tpos = tar.get_pos(); - } - if (tpos) { - // update target_angle - target_angle = p.atan2(tpos.y-pos.y, tpos.x-pos.x); // y first! - } - }; - - - obj.set_target = function(new_target) { - if (obj.get_state() !== "outdated") { - target = new_target; - } - }; - - obj.set_speed = function(new_speed) { - speed = new_speed; - }; - - obj.set_target_angle = function(new_target_angle) { - target_angle = new_target_angle; - }; - - obj.get_target = function() { - return target; - }; - - obj.get_target_angle = function() { - return target_angle; - }; - - // creates a random angle for init'ing - obj.random_target_angle = function() { - return p.random(-p.PI, p.PI); - //Math.random() * (p.PI * 2) - p.PI; //random angle - }; - target_angle = obj.random_target_angle(); - - - return obj; -} diff --git a/game/dev/settings.js b/game/dev/settings.js deleted file mode 100644 index ef1251b..0000000 --- a/game/dev/settings.js +++ /dev/null @@ -1,61 +0,0 @@ -// Global settings -// Have to be wrapped in an object since primitives are pass-by-value -var game_settings = function() { - var settings = { - sound_fx : true, - music : true, - track: "no track", - click_to_fire : true, - mouse_to_select : false, - spacebar_to_fire : true, - background_color : 0xFF3a0101 - // 0xFF371010 - }; - - var toggle = function(name) { - settings[name] = !settings[name]; - }; - - settings.toggle_sound_fx = function() { toggle("sound_fx"); }; - settings.toggle_click_to_fire = function() { toggle("click_to_fire"); }; - settings.toggle_spacebar_to_fire = function() { toggle("spacebar_to_fire"); }; - settings.toggle_mouse_to_select = function() { toggle("mouse_to_select"); }; - // note that this only toggles the flag, not the actual music - // that should be done with a sound manager method - settings.toggle_music = function() { - toggle("music"); - //console.log(settings.music); - }; - - settings.next_track = function() { - var t = sounds.next_track(); - settings.track = t; - }; - - settings.prev_track = function() { - var t = sounds.prev_track(); - settings.track = t; - }; - - settings.set_track = function(t) { - settings.track = t; - }; - - return settings; -}; -// abbreviate it -var g = game_settings(); - - -//getters -/* -var g_sound_fx_on = function() { - return g_game_settings.sound_fx; -} -var g_music_on = function() { - return g_game_settings.music; -} -var g_click_to_fire = function() { - return g_game_settings.click_to_fire; -} -*/ diff --git a/game/dev/sound.js b/game/dev/sound.js deleted file mode 100644 index 6de2aa9..0000000 --- a/game/dev/sound.js +++ /dev/null @@ -1,345 +0,0 @@ -// sound_manager -// utility object to play or not play sounds -// settings for sound still stored in settings object -var sound_manager = function() { - var obj = {}; - - var the_swf_path = "./jplayer/"; - // Taken from http://www.storiesinflight.com/html5/audio.html - - //g_divs_loaded_init_sounds = function() { - //console.log("AAAAA initing sounds"); - obj.play_sound = (function() { - var channel_max = 10; // number of channels - audiochannels = new Array(); - for (var a=0;a= all_bg_music.length) { - track_index = 0; - } - // pause the old one - obj.pause_background_music(); - // set the new one - set_background_music(); - //obj.play_background_music(); - return all_bg_music[track_index].name; - }; - - obj.prev_track = function() { - track_index -= 1; - if (track_index < 0) { - track_index = all_bg_music.length-1; - } - // pause the old one - obj.pause_background_music(); - // set the new one - set_background_music(); - return all_bg_music[track_index].name; - }; - - // sets the background music to the current track index - var set_background_music = function() { - // note that random must be the LAST track - var music = all_bg_music[track_index].music; - if (!music) { - music = all_bg_music - [Math.floor(Math.random()*(track_index-1))] - .music; - } - assert(music, "Random wasn't the last track index or a music div was undefined."); - background_music = music; - }; - - obj.resume_background_music = function() { - if (background_music) - background_music.jPlayer("play"); - } - - obj.pause_background_music = function() { - console.log("Pausing bg music"); - if (background_music) - background_music.jPlayer("pause"); - }; - - var menu_music = null; - var button_sounds = null; - - // Really resume menu music, menu music never restarts - obj.play_menu_music = function() { - if (g.music) - menu_music.jPlayer("play"); - } - obj.resume_menu_music = function() { - if (g.music) - menu_music.jPlayer("play"); - } - obj.pause_menu_music = function() { - menu_music.jPlayer("pause"); - } - obj.play_button_click = function() { - if (g.sound_fx) - play_a_sound(button_sounds, "buttonmain"); - } - obj.play_button_back = function() { - if (g.sound_fx) - play_a_sound(button_sounds, "buttonback"); - } - - var play_a_sound = function(jplayer_instance, sound_name) { - jplayer_instance.jPlayer("setMedia", { - //mp3 : g_soundDataMap[sound_name + "mp3"], - mp3 : "sounds/" + sound_name + ".mp3", - oga : g_soundDataMap[sound_name] - }); - //jplayer_instance.jPlayer.event.ready = function() {console.log("read");}; - jplayer_instance.jPlayer("play"); - } - - obj.load_sounds = function() { - // init all bg music - var all_supplied = "oga, mp3"; - var init_jplayer = function(name, mp3name, oggname, should_loop) { - $(name).jPlayer( { - swfPath : the_swf_path, - ready: function () { - $(this).jPlayer("setMedia", { - mp3 : "sounds/"+mp3name, - oga : "sounds/"+oggname - }); - //console.log(name + " is ready"); - bg_music_loaded(); - $(this).bind($.jPlayer.event.progress, - function(event) { - //console.log(event.jPlayer.status.seekPercent); - if (event.jPlayer.status.seekPercent === 100) { - //console.log("percent = 100, name: " + mp3name); - //bg_music_loaded(); - } - }); - $(this).bind($.jPlayer.error.NO_SOLUTION, - function(event) { - //bg_music_loaded(); - console.log("No audio solutions"); - }); - }, - ended : function() { // loop - if (should_loop) { - $(this).jPlayer("play"); - } - }, - supplied : all_supplied, - preload : "auto", - oggSupport: true - //errorAlerts : true - }); - } - - var init_bg_jplayer = function(num, file_name, oggfn) { - init_jplayer("#jquery_jplayer_bg_"+num, file_name, oggfn, true) - } - /* - console.log("loading heart loop"); - init_bg_jplayer(0, "heart_loop1.mp3"); - console.log("loaded heart loop"); - */ - console.log("loading sinister"); - init_bg_jplayer(0, "sinister.mp3", "sinister.ogg", true); - console.log("loaded sinister"); - - init_bg_jplayer(1, "gameloop2.mp3", "gameloop2.ogg", true); - init_bg_jplayer(2, "Infiltration.mp3", "Infiltration.ogg", true); - init_bg_jplayer(3, "Incubation.mp3", "Incubation.ogg", true); - - for (var i = 0; i < num_bg_music; i++) { - all_bg_music.push({ - music: $("#jquery_jplayer_bg_"+i), - name: track_names[i] - }); - } - - init_jplayer("#jquery_jplayer_menu", "menu_loop.mp3", "menu_loop.ogg", true); - menu_music = $("#jquery_jplayer_menu"); - - init_jplayer("#jquery_jplayer_buttons", "buttonmain.mp3", "buttonmain.ogg", false); - button_sounds = $("#jquery_jplayer_buttons"); - - // add random option - // THIS MUST BE THE LAST OBJ IN THE ARRAY - all_bg_music.push({ - name: "Random", - // don't try to access this music! - music: null - }); - track_names.push("Random"); - num_bg_music += 1; - track_index = num_bg_music-1; - // set initial track (random) - g.set_track(track_names[track_index]); - }; - - var num_loaded = 0; - var max_loaded = num_bg_music + 2 // + 1 for menu music, + 1 for button - var bg_music_loaded = function() { - num_loaded++; - console.log("Loaded " + num_loaded + " out of " + max_loaded); - }; - - obj.sounds_loaded = function() { - //console.log(num_loaded); - return num_loaded >= max_loaded; - } - return obj; -}; - -// make a global object -var sounds = sound_manager(); - -// to debug without sounds, use this object -/* -var sounds = { - sounds_loaded: function() { return true; }, - play_sound: function() {}, - play_background_music: function() {}, - pause_background_music: function() {}, - resume_background_music: function() {}, - load_sounds: function() {}, -}; -*/ - - - -/* -var jplayer = $("#jquery_jplayer_1").jPlayer( { - ready: function () { - $(this).jPlayer("setMedia", { - oga :g_soundDataMap["kill"] // "/sounds/kill.ogg" - //mp3 : "sounds/heart_loop1.mp3" - }); - $(this).jPlayer("play"); - //asdf_play(); - console.log("ready"); - }, - supplied : "oga" -}); -//$("#jquery_jplayer_1").jPlayer("setMedia", {mp3 : "sounds/heart_loop1.mp3"}); -var asdf_play = function(){ - $("#jquery_jplayer_1").jPlayer("play"); -}; - -*/ diff --git a/game/dev/sounds/Incubation.mp3 b/game/dev/sounds/Incubation.mp3 deleted file mode 100755 index aecc196..0000000 Binary files a/game/dev/sounds/Incubation.mp3 and /dev/null differ diff --git a/game/dev/sounds/Incubation.ogg b/game/dev/sounds/Incubation.ogg deleted file mode 100755 index f15e5eb..0000000 Binary files a/game/dev/sounds/Incubation.ogg and /dev/null differ diff --git a/game/dev/sounds/Infiltration.mp3 b/game/dev/sounds/Infiltration.mp3 deleted file mode 100755 index eb48089..0000000 Binary files a/game/dev/sounds/Infiltration.mp3 and /dev/null differ diff --git a/game/dev/sounds/Infiltration.ogg b/game/dev/sounds/Infiltration.ogg deleted file mode 100755 index 5cce4b5..0000000 Binary files a/game/dev/sounds/Infiltration.ogg and /dev/null differ diff --git a/game/dev/sounds/buttonback.mp3 b/game/dev/sounds/buttonback.mp3 deleted file mode 100755 index 730c75f..0000000 Binary files a/game/dev/sounds/buttonback.mp3 and /dev/null differ diff --git a/game/dev/sounds/buttonback.ogg b/game/dev/sounds/buttonback.ogg deleted file mode 100755 index 109a1e9..0000000 Binary files a/game/dev/sounds/buttonback.ogg and /dev/null differ diff --git a/game/dev/sounds/buttonmain.mp3 b/game/dev/sounds/buttonmain.mp3 deleted file mode 100755 index aea705c..0000000 Binary files a/game/dev/sounds/buttonmain.mp3 and /dev/null differ diff --git a/game/dev/sounds/buttonmain.ogg b/game/dev/sounds/buttonmain.ogg deleted file mode 100755 index 81c13d7..0000000 Binary files a/game/dev/sounds/buttonmain.ogg and /dev/null differ diff --git a/game/dev/sounds/cell_fire.mp3 b/game/dev/sounds/cell_fire.mp3 deleted file mode 100755 index 0e3ebf3..0000000 Binary files a/game/dev/sounds/cell_fire.mp3 and /dev/null differ diff --git a/game/dev/sounds/cell_fire.ogg b/game/dev/sounds/cell_fire.ogg deleted file mode 100755 index 7e91316..0000000 Binary files a/game/dev/sounds/cell_fire.ogg and /dev/null differ diff --git a/game/dev/sounds/cell_infect.mp3 b/game/dev/sounds/cell_infect.mp3 deleted file mode 100755 index 5bc1007..0000000 Binary files a/game/dev/sounds/cell_infect.mp3 and /dev/null differ diff --git a/game/dev/sounds/cell_infect.ogg b/game/dev/sounds/cell_infect.ogg deleted file mode 100755 index 57aaaea..0000000 Binary files a/game/dev/sounds/cell_infect.ogg and /dev/null differ diff --git a/game/dev/sounds/gameloop2.mp3 b/game/dev/sounds/gameloop2.mp3 deleted file mode 100755 index 5c8f4c3..0000000 Binary files a/game/dev/sounds/gameloop2.mp3 and /dev/null differ diff --git a/game/dev/sounds/gameloop2.ogg b/game/dev/sounds/gameloop2.ogg deleted file mode 100755 index 1c94d25..0000000 Binary files a/game/dev/sounds/gameloop2.ogg and /dev/null differ diff --git a/game/dev/sounds/kill.mp3 b/game/dev/sounds/kill.mp3 deleted file mode 100755 index 6bdfebe..0000000 Binary files a/game/dev/sounds/kill.mp3 and /dev/null differ diff --git a/game/dev/sounds/kill.ogg b/game/dev/sounds/kill.ogg deleted file mode 100755 index deed4fc..0000000 Binary files a/game/dev/sounds/kill.ogg and /dev/null differ diff --git a/game/dev/sounds/level_up.mp3 b/game/dev/sounds/level_up.mp3 deleted file mode 100755 index 55e3fcf..0000000 Binary files a/game/dev/sounds/level_up.mp3 and /dev/null differ diff --git a/game/dev/sounds/level_up.ogg b/game/dev/sounds/level_up.ogg deleted file mode 100755 index 468cae0..0000000 Binary files a/game/dev/sounds/level_up.ogg and /dev/null differ diff --git a/game/dev/sounds/macrophage_infect.mp3 b/game/dev/sounds/macrophage_infect.mp3 deleted file mode 100755 index 472498e..0000000 Binary files a/game/dev/sounds/macrophage_infect.mp3 and /dev/null differ diff --git a/game/dev/sounds/macrophage_infect.ogg b/game/dev/sounds/macrophage_infect.ogg deleted file mode 100755 index 0a49c6f..0000000 Binary files a/game/dev/sounds/macrophage_infect.ogg and /dev/null differ diff --git a/game/dev/sounds/menu_loop.mp3 b/game/dev/sounds/menu_loop.mp3 deleted file mode 100755 index 10f3c1d..0000000 Binary files a/game/dev/sounds/menu_loop.mp3 and /dev/null differ diff --git a/game/dev/sounds/menu_loop.ogg b/game/dev/sounds/menu_loop.ogg deleted file mode 100755 index 2008e2f..0000000 Binary files a/game/dev/sounds/menu_loop.ogg and /dev/null differ diff --git a/game/dev/sounds/old/Level Up!2 Trimmed.ogg b/game/dev/sounds/old/Level Up!2 Trimmed.ogg deleted file mode 100755 index ee8fa82..0000000 Binary files a/game/dev/sounds/old/Level Up!2 Trimmed.ogg and /dev/null differ diff --git a/game/dev/sounds/old/cell_fire.ogg b/game/dev/sounds/old/cell_fire.ogg deleted file mode 100644 index bbec785..0000000 Binary files a/game/dev/sounds/old/cell_fire.ogg and /dev/null differ diff --git a/game/dev/sounds/old/cell_fire.wav b/game/dev/sounds/old/cell_fire.wav deleted file mode 100644 index 77f1ba9..0000000 Binary files a/game/dev/sounds/old/cell_fire.wav and /dev/null differ diff --git a/game/dev/sounds/old/cell_infect.ogg b/game/dev/sounds/old/cell_infect.ogg deleted file mode 100644 index a3d5cf8..0000000 Binary files a/game/dev/sounds/old/cell_infect.ogg and /dev/null differ diff --git a/game/dev/sounds/old/cell_infect.wav b/game/dev/sounds/old/cell_infect.wav deleted file mode 100644 index 8cb4011..0000000 Binary files a/game/dev/sounds/old/cell_infect.wav and /dev/null differ diff --git a/game/dev/sounds/old/kill.ogg b/game/dev/sounds/old/kill.ogg deleted file mode 100755 index c127f02..0000000 Binary files a/game/dev/sounds/old/kill.ogg and /dev/null differ diff --git a/game/dev/sounds/old/level_up.ogg b/game/dev/sounds/old/level_up.ogg deleted file mode 100755 index d1b818c..0000000 Binary files a/game/dev/sounds/old/level_up.ogg and /dev/null differ diff --git a/game/dev/sounds/old/macrophage_infect.ogg b/game/dev/sounds/old/macrophage_infect.ogg deleted file mode 100644 index 684fc34..0000000 Binary files a/game/dev/sounds/old/macrophage_infect.ogg and /dev/null differ diff --git a/game/dev/sounds/sinister.mp3 b/game/dev/sounds/sinister.mp3 deleted file mode 100755 index 95905df..0000000 Binary files a/game/dev/sounds/sinister.mp3 and /dev/null differ diff --git a/game/dev/sounds/sinister.ogg b/game/dev/sounds/sinister.ogg deleted file mode 100755 index e5e2d94..0000000 Binary files a/game/dev/sounds/sinister.ogg and /dev/null differ diff --git a/game/dev/splash_state.js b/game/dev/splash_state.js deleted file mode 100644 index 2ebe87a..0000000 --- a/game/dev/splash_state.js +++ /dev/null @@ -1,238 +0,0 @@ -var splash_state = function (p) { - - // object to return - var obj = game_state(p); - - // --- private variables --- - - //var header_image = p.loadImage("images/screens/header.png"); - var back_image = image_manager.get_image("mainscreenbase.png"); - var back_color = g.background_color; - - // Buttons - // Have a rectangle representing their position and - // a state to go to when pressed - - var top_row_y = 150; - var btm_row_y = 420; - var left_x_top = 465; - var left_x_btm = 500; - var incr_x = 40; - var incr_y = 60; - var button_style = { - //height: 160, - rect_color: back_color - }; - - // Play menu music - sounds.play_menu_music(); - - var pause_menu_music = function() { - sounds.pause_menu_music(); - }; - - var normal_button = button(p, { - state : function() { - pause_menu_music(); - sounds.play_button_click(); - return in_game_state(p, obj, 2); - }, - rect: { - pos: new p.PVector(left_x_top+2*incr_x, top_row_y), - image: "mnormal.png", - over_image: "mnormal_r.png", - //width: 80, - style: button_style, - } - }); - - var easy_button = button(p, { - state : function() { - pause_menu_music(); - sounds.play_button_click(); - return in_game_state(p, obj, 0); - }, - rect: { - pos: new p.PVector(left_x_top+incr_x, top_row_y+incr_y), - //text : "Easy", - image: "mbeginner.png", - over_image: "mbeginner_r.png", - //width: 80, - style: button_style, - } - }); - - var tut_button = button(p, { - state : function() { - pause_menu_music(); - sounds.play_button_click(); - return in_game_state(p, obj, 1); - }, - rect: { - pos: new p.PVector(left_x_top, top_row_y+2*incr_y), - //text : "Tutorial", - image: "mtutorial.png", - over_image: "mtutorial_r.png", - //width: 80, - style: button_style, - } - }); - - - var help_button = button(p, { - state : function() { - sounds.play_button_click(); - return help_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x_btm, btm_row_y), - image: "mhowtoplay.png", - over_image: "mhowtoplay_r.png", - //width: 100, - style: button_style, - } - }); - - var scores_button = button(p, { - state : function() { - sounds.play_button_click(); - return high_scores_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x_btm+incr_x, btm_row_y+incr_y), - image: "mhighscores.png", - over_image: "mhighscores_r.png", - //text: "High Scores", - //width: 100, - style: button_style, - } - }); - - var options_button = button(p, { - state : function() { - sounds.play_button_click(); - return options_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x_btm+2*incr_x-10, btm_row_y+2*incr_y), - image: "msettings.png", - over_image: "msettings_r.png", - //width: 120, - style: button_style, - } - }); - - var credits_button = button(p, { - state : function() { - sounds.play_button_click(); - return credits_state(p, obj); - }, - rect: { - pos: new p.PVector(p.width-100, 30), - image: "credits.png", - width: 200, - height: 50, - } - }); - - /* - var splash_style = { - width : 170, - height : 40, - text_color: 0xFFEE0000, - rect_color: back_color, - text_size: 30, - text_align: p.LEFT - }; - - var button_x = 500; - var button_top = 150; - var button_sep = 60; - - var start_button = button(p, { - state : function() { return in_game_state(p, obj); }, - rect : { - pos : new p.PVector(button_x, button_top), - style : splash_style, - text : "New Game" - //image : "images/screens/newgame_listcell.png" - } - }); - - var options_button = button(p, { - state : function() { return options_state(p, obj); }, - rect : { - pos : new p.PVector(button_x, button_top+button_sep), - style : splash_style, - text : "Settings" - } - }); - - var help_button = button(p, { - state : function() { return help_state(p, obj); }, - rect : { - pos : new p.PVector(button_x, button_top+2*button_sep), - style : splash_style, - text : "How To Play" - } - }); - /* - var high_scores_button = { - state : high_scores_state(), - rectangle : rectangle(p, { - pos : new p.PVector(20, 20), - width : 20, - height : 20 - }) - }; - */ - - //Not ordered - var all_buttons = [easy_button, tut_button, normal_button, options_button, - help_button, scores_button, credits_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "splash"; - }; - - obj.update = function() { - //do nothing - }; - - obj.key_pressed = function(k) { - if (k === 115 || p.keyCode === 13 || k === 32) { //s, enter, space - obj.set_next_state(start_button.get_state()); - pause_menu_music(); - } - else if (k === 104) { //h - obj.set_next_state(help_button.get_state()); - } - }; - - /* - obj.mouse_moved = function(x, y) { - - for_each( - all_buttons, - function(b) { - b.mouse_moved(x, y); - } - ); - }; - */ - - obj.get_all_buttons = function() { - return all_buttons; - }; - - obj.render = function() { - p.background(back_color); - p.imageMode(p.CENTER); - //p.image(header_image, p.width / 2, 100, p.width * 3/4, 100); - p.image(back_image, p.width/2, p.height/2); - }; - - return obj; -}; diff --git a/game/dev/state_manager.js b/game/dev/state_manager.js deleted file mode 100644 index 811716b..0000000 --- a/game/dev/state_manager.js +++ /dev/null @@ -1,187 +0,0 @@ -// *** state_manager *** -// The game engine; manages all of the games states -// Provides update(), mouse_click(x, y), and key_pressed(k) -// The next state to go to, if applicable, is returned by state.update() - -var state_manager = function (p) { - - // object to return - var obj = {}; - - // --- private variables --- - - var curr_state = loading_state(p); //The currently active state - //p.noLoop(); - var displayed_states = [curr_state]; //THIS MUST ALWAYS BE SORTED BY RENDERING LEVEL - - //A mapping from game states to their rendering levels - var type_to_level = { - "splash": 0, - "loading" : 0, - "game": 1, - "game_over": 2, - "pause": 2, - "credits": 2, - "help": 2, - "options" : 2 - }; - - // --- private methods --- - - //Removes a state from the displayed_states - //The state must be in displayed_states, or will throw an error - function remove_from_displayed(s) { - var index = displayed_states.indexOf(s); - if (index === -1) { - throw "error in remove_from_displayed in state_manager"; - } - displayed_states.splice(index, 1); //remove the element - } - - //Adds a state to displayed_states - //Ensures that displayed_states is sorted by ascending rendering level - var add_to_displayed_states = function(s) { - var render_level = type_to_level[s.get_type()]; - //Insert in the array right before a render level that is higher than it, or - //at the end if none - var inserted = false; - for (var i = 0; i < displayed_states.length; i++) { - var old_render_level = type_to_level[displayed_states[i].get_type()]; - if (old_render_level > render_level) { - displayed_states.splice(i, 0, s); - inserted = true; - } - } - if (inserted === false) { //add to end - displayed_states.push(s); - } - } - - - // --- public methods --- - - //Updates the current state and renders all appropriate states - obj.update = function() { - // Update all the states, and get next_state from curr_state.update_wrapper(); - var next_state = null; - var update_function = function(s) { - if (s === curr_state) { - next_state = s.update_wrapper(); - } - else { - // i see no reason to update not current states - //s.update_wrapper(); - } - }; - for_each(displayed_states, update_function); - - //If we have a new state to go to - if (next_state && next_state !== curr_state) { - //console.log("next is "+next_state.get_type()); - //Figure out if next state is an overlay - var state_type = next_state.get_type(); - var is_overlay = -1; - switch (state_type) { - case "splash": - is_overlay = false; - p.noLoop(); - break; - case "game": - is_overlay = false; - p.loop(); - break; - case "pause": - is_overlay = true; - p.noLoop(); - break; - case "help": - is_overlay = true; - p.noLoop(); - break; - case "game_over": - is_overlay = true; - p.noLoop(); - break; - case "options": - is_overlay = true; - p.noLoop(); - break; - case "loading": - is_overlay = false; - p.loop(); - break; - case "high_scores": - is_overlay = true; - p.noLoop(); - break; - case "credits": - is_overlay = true; - p.noLoop(); - break; - } - - //Error checking - if (is_overlay === -1) { - throw "error in update in state_manager"; - } - - //If overlay, add to displayed, otherwise reset displayed - if (is_overlay) { - // account for multiple overlays - // so we can go back to an overlay - if (member(displayed_states, next_state)) { - remove_from_displayed(curr_state); - } - else { - add_to_displayed_states(next_state); - } - } - else { - displayed_states = [next_state]; - } - curr_state = next_state; - //Potentially a problem, we do this even if not returning to a state - curr_state.resume(); - // updating its buttons - curr_state.update_wrapper(); - } - - for (var i = 0; i < displayed_states.length; i++) { - displayed_states[i].render_wrapper(); - } - - /* - if (curr_state.get_type() !== "game") { - p.noLoop(); - } - else { - p.loop(); - } - */ - }; - - //Passes clicks on to curr_state - obj.mouse_click = function (x, y) { - curr_state.mouse_click_wrapper(x, y); - if (curr_state.get_type() !== "game") { - obj.update(); - } - }; - - obj.key_pressed = function(k) { - curr_state.key_pressed(k); - if (curr_state.get_type() !== "game") { - obj.update(); - } - }; - - obj.mouse_moved = function(x,y) { - curr_state.mouse_moved_wrapper(x, y); - if (curr_state.get_type() !== "game") { - obj.update(); - } - //obj.update(); - } - - return obj; -}; diff --git a/game/dev/test.js b/game/dev/test.js deleted file mode 100644 index cc645eb..0000000 --- a/game/dev/test.js +++ /dev/null @@ -1,92 +0,0 @@ -// all the processing code goes in the function -// which gets passed in a processing instance p -var p_code = function(p) { - - var sm, t1, c1, c2; - - p.setup = function() { - p.size(700, 600); - - // deal with console issues - // TODO move this code - if (!window.console) { - console = { log: function() {} }; - } - Processing.logger = console; - - var f = new p.loadFont("_sans"); - p.textFont(f, 14); - - sm = state_manager(p); - - p.frameRate(30); - }; - - update_counter = 0; - // draw is called repeatedly - p.draw = function() { - update_counter += 1; - if (update_counter === 30) { - //console.log("frame "+p.millis()); - //console.log(p.__frameRate); - update_counter = 0; - } - sm.update(); // Also renders - }; - - //Mouse and Keyboard input - p.keyPressed = function() { - sm.key_pressed(p.key); - }; - p.mousePressed = function() { - sm.mouse_click(p.mouseX, p.mouseY); - }; - p.mouseMoved = function() { - sm.mouse_moved(p.mouseX, p.mouseY); - }; -}; - - -// want this to be global -var sketch; - -var start_game = function() { - // attaches the processing code to the canvas - // note that we need to do this AFTER the canvas element is created - var canvas = document.getElementById("test_canvas"); - sketch = new Processing.Sketch(p_code); - //sketch.options.isTransparent = true; - var pInstance = new Processing(canvas, sketch); -}; -window.onload = start_game; - -/* -var back_code = function(p) { - var tiles = []; - p.setup = function() { - p.size(700, 600); - p.frameRate(30); - tiles.push(background(p, { - pos: new p.PVector(0, 0) - })); - tiles.push(background(p, { - pos: new p.PVector(700, 0) - })); - }; - p.draw = function() { - p.background(200); - for_each(tiles, function(tile) { - tile.update(); - tile.scroll(1); - tile.draw(); - }); - }; -}; -*/ -//var back_canvas = document.getElementById("back_canvas"); -//var backInstance = new Processing(back_canvas, back_code); - -// Make spacebar not move the window down -window.onkeydown = function(e) { - return !(e.keyCode == 32); -}; diff --git a/game/dev/tkiller.js b/game/dev/tkiller.js deleted file mode 100644 index db7d2c0..0000000 --- a/game/dev/tkiller.js +++ /dev/null @@ -1,121 +0,0 @@ -// *** tkiller *** -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards - -var tkiller = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 35; - spec.height = spec.height || 35; - spec.speed = (spec.speed || 1.5) * g_speed_factor; - - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "tkiller"; - }; - - // --- private variables --- - - var alive = true; - /* @pjs preload="images/tcell2.png"; */ - var t_image = image_manager.get_image("tcell_2.png"); - - // Rect to fill in - var rectx_offset = -(8/30)*obj.get_width(); - var recty_offset = -(7/30) * obj.get_height(); - var rect_width = (13 / 30) * obj.get_width(); - var rect_height = (17 / 30) * obj.get_height(); - - - var t_anim = animated_image("t_animation", {anim_rate : 6}); - var t_image; - t_anim.start(); - t_anim.loop(); - - // --- public methods --- - - // implementing game_object interface - - // update makes tkiller chase target cell - obj.my_update = function() { - obj.move(); - obj.set_speed(obj.get_level()/2 + 1); - }; - - // should point towards target - // (triangle for now) - obj.draw = function() { - var pos = obj.get_pos(); - /* - p.pushMatrix(); - - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.fill(50); - p.noStroke(); - - // rightward triangle - p.triangle(-w/2, -h/2, -w/2, h/2, w/2, 0); - - p.popMatrix(); - */ - p.pushMatrix(); - p.imageMode(obj.get_mode()); - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle() + p.PI / 2); - p.fill(obj.get_color()); - p.noStroke(); - p.rectMode(p.CORNER); - p.rect(rectx_offset, recty_offset, rect_width, rect_height); - //p.image(t_image, 0, 0, obj.get_width(), obj.get_height()); - if (obj.get_target() === null) { - t_anim.set_rate(6); - } - else { - t_anim.set_rate(3); - } - t_image = t_anim.get_frame(); - - if (obj.is_illustration()) { - t_image = image_manager.get_image("tcell_2.png"); - // to make it less transparent draw twice - p.image(t_image, 0, 0, - obj.get_width(), obj.get_height()); - } - - p.image(t_image, 0, 0, - obj.get_width(), obj.get_height()); - p.popMatrix(); - }; - - // is_dead just returns whether it isn't alive - obj.is_dead = function() { - return !alive; - }; - - // which means we need a way to die - obj.die = function() { - alive = false; - }; - - obj.stop_animation = function() { - t_anim.pause(); - }; - - obj.resume_animation = function() { - t_anim.start(); - }; - - return obj; -} diff --git a/game/dev/wall_cell.js b/game/dev/wall_cell.js deleted file mode 100644 index 62be000..0000000 --- a/game/dev/wall_cell.js +++ /dev/null @@ -1,63 +0,0 @@ -// *** wall_cell *** -// --- inherits from game_object -// spec: -// game_object spec - -var wall_cell = function(p, spec) { - - var wall_image = image_manager.get_image("wallcell_1.png"); - - // --- defaults --- - - // temporarily dividing by 2 cuz image is too big - spec.width = spec.width || wall_image.width;///2 || 40; - spec.height = spec.height || wall_image.height;///2 || 20; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "wall_cell"; - }; - - // --- private variables --- - - var alive = true; - - // --- public methods --- - - // implementing game_object interface - - // update is back to the default - obj.update = function() { - obj.move(); - }; - - // (rect for now) - obj.draw = function() { - var pos = obj.get_pos(); - /* - p.shapeMode(obj.mode); - - p.fill(100); - p.noStroke(); - - var w = obj.get_width(); - var h = obj.get_height(); - p.rect(pos.x-w/2, pos.y-h/2, w, h); - */ - p.imageMode(obj.get_mode()); - p.image(wall_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - }; - - obj.is_dead = function() { - return !alive; - }; - - obj.die = function() { - alive = false; - }; - - - return obj; -} diff --git a/game/dev/wall_segment.js b/game/dev/wall_segment.js deleted file mode 100644 index db886ac..0000000 --- a/game/dev/wall_segment.js +++ /dev/null @@ -1,114 +0,0 @@ -// list of specs for wall segments to use in the game -// later can include which image/shape to use -// MUST HAVE WIDTH AND HEIGHT SPECIFIED -/* -var wall_specs = [ - { width: 100, height: 51 } - //{ width: 100, height: 30, fill: 0 }, - //{ width: 200, height: 30, fill: 50 }, - //{ width: 50, height: 30, fill: 100 }, - //{ width: 150, height: 30, fill: 150 } -]; -*/ - -// *** wall_segment *** -// --- inherits from game_object -// spec: -// game_object spec -// boolean is_top = true if it is on the top of the screen -// pos should be at bottom left corner -// -// Each wall segment must match up with the other -// wall segments at each end -// Segment images should be formatted for the bottom wall - -var wall_segment = function(p, spec) { - - //var wall_shape = p.loadShape("images/cellwall1draft.svg"); - var wall_image = random_from( - image_manager.get_images("wall_segments")).image; - - // --- defaults --- - - // temporarily dividing by 3 because the images are 3x too big - spec.width = spec.width || wall_image.width;///3;// || 60; - spec.height = spec.height || wall_image.height;///3;// || 60; - spec.fill = spec.fill || 150; - spec.mode = p.CENTER; - // adjust to center coords - spec.pos.add(new p.PVector(spec.width/2, -spec.height/2)); - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "wall_segment"; - }; - - // --- private variables --- - - // --- public methods --- - - obj.get_y_offset = function() { - return obj.get_height()/2; - }; - - // implementing game_object interface - - // update is default (move) - - // (flat rect for now) - obj.draw = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - p.shapeMode(obj.mode); - // all diff colors for testing - p.fill(0);//spec.fill); - p.noStroke(); - - var w = obj.get_width(); - var h = obj.get_height(); - - p.translate(pos.x, pos.y); - - if (spec.is_top) { - p.rotate(p.PI); - } - - //p.rect(-w/2, -h/2, w, h); - p.imageMode(obj.get_mode()); - p.image(wall_image, 0, 0, w, h); - //p.set(0, 0, wall_shape); - //draw(canvas.getContext('2d')); - //var d = new Date(); - //console.log(d.getMilliseconds()); - //canvas.getContext('2d').drawSvg("images/virusFinal.svg", 300, 10, 20, 20); - //console.log(d.getMilliseconds()); - - p.popMatrix(); - }; - - obj.draw_circle = function() {}; - - // walls can't die - obj.is_dead = function() { - return false; - }; - - //var count = 0; - obj.scroll = function(scroll_factor) { - //count += 1; - //if (count === 1) { - //count = 0; - obj.get_pos().add(new p.PVector(obj.get_scroll_dist(), 0)); - //} - }; - - obj.get_scroll_dist = function() { - return -1; - }; - - return obj; -}; - diff --git a/game/fb/README b/game/fb/README deleted file mode 100644 index e69de29..0000000 diff --git a/game/fb/all.js b/game/fb/all.js deleted file mode 100644 index 7050da9..0000000 --- a/game/fb/all.js +++ /dev/null @@ -1,70 +0,0 @@ -/*1295489895,169565300,JIT Construction: v334085,en_US*/ - -if(!window.FB)window.FB={_apiKey:null,_session:null,_userStatus:'unknown',_logging:true,_inCanvas:((window.location.search.indexOf('fb_sig_in_iframe=1')>-1)||(window.location.search.indexOf('session=')>-1)||(window.location.search.indexOf('signed_request=')>-1)),_https:(window.name.indexOf('_fb_https')>-1),_domain:{api:'https://api.facebook.com/',api_read:'https://api-read.facebook.com/',cdn:'http://static.ak.fbcdn.net/',https_cdn:'https://s-static.ak.fbcdn.net/',graph:'https://graph.facebook.com/',staticfb:'http://static.ak.facebook.com/',https_staticfb:'https://s-static.ak.facebook.com/',www:window.location.protocol+'//www.facebook.com/',https_www:'https://www.facebook.com/'},_locale:null,_localeIsRtl:false,getDomain:function(a){switch(a){case 'api':return FB._domain.api;case 'api_read':return FB._domain.api_read;case 'cdn':return (window.location.protocol=='https:'||FB._https)?FB._domain.https_cdn:FB._domain.cdn;case 'graph':return FB._domain.graph;case 'staticfb':return FB._https?FB._domain.https_staticfb:FB._domain.staticfb;case 'https_staticfb':return FB._domain.https_staticfb;case 'www':return FB._https?FB._domain.https_www:FB._domain.www;case 'https_www':return FB._domain.https_www;}},copy:function(d,c,b,e){for(var a in c)if(b||typeof d[a]==='undefined')d[a]=e?e(c[a]):c[a];return d;},create:function(c,h){var e=window.FB,d=c?c.split('.'):[],a=d.length;for(var b=0;b');e.root.innerHTML='';f=true;window.setTimeout(function(){e.root.innerHTML=b;},0);}else{var c=document.createElement('iframe');c.id=e.id;c.name=e.name;c.onload=FB.Content._callbacks[a];c.scrolling='no';c.style.border='none';c.style.overflow='hidden';if(e.title)c.title=e.title;if(e.className)c.className=e.className;if(e.height)c.style.height=e.height+'px';if(e.width)c.style.width=e.width+'px';e.root.appendChild(c);f=true;c.src=e.url;}},postTarget:function(b){var a=document.createElement('form');a.action=b.url;a.target=b.target;a.method='POST';FB.Content.appendHidden(a);FB.Array.forEach(b.params,function(e,d){if(e!==null&&e!==undefined){var c=document.createElement('input');c.name=d;c.value=e;a.appendChild(c);}});a.submit();a.parentNode.removeChild(a);}}); -FB.provide('Flash',{_minVersions:[[9,0,159,0],[10,0,22,87]],_swfPath:'swf/XdComm.swf',_callbacks:[],init:function(){if(FB.Flash._init)return;FB.Flash._init=true;window.FB_OnFlashXdCommReady=function(){FB.Flash._ready=true;for(var d=0,e=FB.Flash._callbacks.length;d'+''+''+'
      ');FB.Content.appendHidden(b);},hasMinVersion:function(){if(typeof FB.Flash._hasMinVersion==='undefined'){var i,a,b,h=[];try{i=new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');}catch(j){if(navigator.mimeTypes.length>0){var mimeType='application/x-shockwave-flash';if(navigator.mimeTypes[mimeType].enabledPlugin){var name='Shockwave Flash';i=(navigator.plugins[name+' 2.0']||navigator.plugins[name]).description;}}}if(i){var f=i.replace(/\D+/g,',').match(/^,?(.+),?$/)[1].split(',');for(a=0,b=f.length;ag[c])break majorVersion;}};}return FB.Flash._hasMinVersion;},onReady:function(a){FB.Flash.init();if(FB.Flash._ready){window.setTimeout(a,0);}else FB.Flash._callbacks.push(a);}}); -if(!this.JSON)this.JSON={};(function(){function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function')value=value.toJSON(key);if(typeof rep==='function')value=rep.call(holder,key,value);switch(typeof value){case 'string':return quote(value);case 'number':return isFinite(value)?String(value):'null';case 'boolean':case 'null':return String(value);case 'object':if(!value)return 'null';gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i-1?'&':'?')+FB.QS.encode(e));if(h.length>2000)throw new Error('JSONP only support a maximum of 2000 bytes of input.');FB.ApiServer._callbacks[c]=function(i){a&&a(i);delete FB.ApiServer._callbacks[c];g.parentNode.removeChild(g);};g.src=h;document.getElementsByTagName('head')[0].appendChild(g);},flash:function(b,e,c,d,a){if(!window.FB_OnXdHttpResult)window.FB_OnXdHttpResult=function(g,f){FB.ApiServer._callbacks[g](decodeURIComponent(f));};FB.Flash.onReady(function(){var h=FB.getDomain(b)+e,f=FB.QS.encode(d);if(c==='get'){if(h.length+f.length>2000){if(b==='graph')d.method='get';c='post';f=FB.QS.encode(d);}else{h+=(h.indexOf('?')>-1?'&':'?')+f;f='';}}else if(c!=='post'){if(b==='graph')d.method=c;c='post';f=FB.QS.encode(d);}var g=document.XdComm.sendXdHttpRequest(c.toUpperCase(),h,f,null);FB.ApiServer._callbacks[g]=function(i){a&&a(FB.JSON.parse(i));delete FB.ApiServer._callbacks[g];};});}}); -FB.provide('EventProvider',{subscribers:function(){if(!this._subscribersMap)this._subscribersMap={};return this._subscribersMap;},subscribe:function(b,a){var c=this.subscribers();if(!c[b]){c[b]=[a];}else c[b].push(a);},unsubscribe:function(b,a){var c=this.subscribers()[b];FB.Array.forEach(c,function(e,d){if(e==a)c[d]=null;});},monitor:function(d,a){if(!a()){var b=this,c=function(){if(a.apply(a,arguments))b.unsubscribe(d,c);};this.subscribe(d,c);}},clear:function(a){delete this.subscribers()[a];},fire:function(){var a=Array.prototype.slice.call(arguments),b=a.shift();FB.Array.forEach(this.subscribers()[b],function(c){if(c)c.apply(this,a);});}});FB.provide('Event',FB.EventProvider); -FB.provide('Intl',{_punctCharClass:('['+'.!?'+'\u3002'+'\uFF01'+'\uFF1F'+'\u0964'+'\u2026'+'\u0EAF'+'\u1801'+'\u0E2F'+'\uFF0E'+']'),_endsInPunct:function(a){if(typeof a!='string')return false;return a.match(new RegExp(FB.Intl._punctCharClass+'['+')"'+"'"+'\u00BB'+'\u0F3B'+'\u0F3D'+'\u2019'+'\u201D'+'\u203A'+'\u3009'+'\u300B'+'\u300D'+'\u300F'+'\u3011'+'\u3015'+'\u3017'+'\u3019'+'\u301B'+'\u301E'+'\u301F'+'\uFD3F'+'\uFF07'+'\uFF09'+'\uFF3D'+'\s'+']*$'));},_tx:function(d,a){if(a!==undefined)if(typeof a!='object'){FB.log('The second arg to FB.Intl._tx() must be an Object for '+'tx('+d+', ...)');}else{var c;for(var b in a)if(a.hasOwnProperty(b)){if(FB.Intl._endsInPunct(a[b])){c=new RegExp('\{'+b+'\}'+FB.Intl._punctCharClass+'*','g');}else c=new RegExp('\{'+b+'\}','g');d=d.replace(c,a[b]);}}return d;},tx:function(b,a){function c(e,d){void(0);}if(!FB.Intl._stringTable)return null;return FBIntern.Intl._tx(FB.Intl._stringTable[b],a);}}); -FB.provide('String',{trim:function(a){return a.replace(/^\s*|\s*$/g,'');},format:function(a){if(!FB.String.format._formatRE)FB.String.format._formatRE=/(\{[^\}^\{]+\})/g;var b=arguments;return a.replace(FB.String.format._formatRE,function(e,d){var c=parseInt(d.substr(1),10),f=b[c+1];if(f===null||f===undefined)return '';return f.toString();});},escapeHTML:function(b){var a=document.createElement('div');a.appendChild(document.createTextNode(b));return a.innerHTML.replace(/"/g,'"').replace(/'/g,''');},quote:function(c){var a=/["\\\x00-\x1f\x7f-\x9f]/g,b={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};return a.test(c)?'"'+c.replace(a,function(d){var e=b[d];if(e)return e;e=d.charCodeAt();return '\\u00'+Math.floor(e/16).toString(16)+(e%16).toString(16);})+'"':'"'+c+'"';}}); -FB.provide('Dom',{containsCss:function(c,a){var b=' '+c.className+' ';return b.indexOf(' '+a+' ')>=0;},addCss:function(b,a){if(!FB.Dom.containsCss(b,a))b.className=b.className+' '+a;},removeCss:function(b,a){if(FB.Dom.containsCss(b,a)){b.className=b.className.replace(a,'');FB.Dom.removeCss(b,a);}},getStyle:function(a,c){var d=false,b=a.style;if(a.currentStyle){FB.Array.forEach(c.match(/\-([a-z])/g),function(e){c=c.replace(e,e.substr(1,1).toUpperCase());});d=a.currentStyle[c];}else{FB.Array.forEach(c.match(/[A-Z]/g),function(e){c=c.replace(e,'-'+e.toLowerCase());});if(window.getComputedStyle){d=document.defaultView.getComputedStyle(a,null).getPropertyValue(c);if(c=='background-position-y'||c=='background-position-x')if(d=='top'||d=='left')d='0px';}}if(c=='opacity'){if(a.filters&&a.filters.alpha)return d;return d*100;}return d;},setStyle:function(a,c,d){var b=a.style;if(c=='opacity'){if(d>=100)d=99.999;if(d<0)d=0;b.opacity=d/100;b.MozOpacity=d/100;b.KhtmlOpacity=d/100;if(a.filters)if(a.filters.alpha==undefined){a.filter="alpha(opacity="+d+")";}else a.filters.alpha.opacity=d;}else b[c]=d;},addScript:function(b){var a=document.createElement('script');a.type="text/javascript";a.src=b;return document.getElementsByTagName('head')[0].appendChild(a);},addCssRules:function(e,c){if(!FB.Dom._cssRules)FB.Dom._cssRules={};var a=true;FB.Array.forEach(c,function(f){if(!(f in FB.Dom._cssRules)){a=false;FB.Dom._cssRules[f]=true;}});if(a)return;if(FB.Dom.getBrowserType()!='ie'){var d=document.createElement('style');d.type='text/css';d.textContent=e;document.getElementsByTagName('head')[0].appendChild(d);}else try{document.createStyleSheet().cssText=e;}catch(b){if(document.styleSheets[0])document.styleSheets[0].cssText+=e;}},getBrowserType:function(){if(!FB.Dom._browserType){var d=window.navigator.userAgent.toLowerCase(),b=['msie','firefox','safari','gecko'],c=['ie','mozilla','safari','mozilla'];for(var a=0;a=0){FB.Dom._browserType=c[a];break;}}return FB.Dom._browserType;},getViewportInfo:function(){var a=(document.documentElement&&document.compatMode=='CSS1Compat')?document.documentElement:document.body;return {scrollTop:a.scrollTop,scrollLeft:a.scrollLeft,width:self.innerWidth?self.innerWidth:a.clientWidth,height:self.innerHeight?self.innerHeight:a.clientHeight};},ready:function(a){if(FB.Dom._isReady){a();}else FB.Event.subscribe('dom.ready',a);}});(function(){function domReady(){FB.Dom._isReady=true;FB.Event.fire('dom.ready');FB.Event.clear('dom.ready');}if(FB.Dom._isReady||document.readyState=='complete')return domReady();if(document.addEventListener){document.addEventListener('DOMContentLoaded',domReady,false);}else if(document.attachEvent)document.attachEvent('onreadystatechange',domReady);if(FB.Dom.getBrowserType()=='ie'&&window===top)(function(){try{document.documentElement.doScroll('left');}catch(error){setTimeout(arguments.callee,0);return;}domReady();})();var oldonload=window.onload;window.onload=function(){domReady();if(oldonload)if(typeof oldonload=='string'){eval(oldonload);}else oldonload();};})(); -FB.provide('Dialog',{_loaderEl:null,_stack:[],_active:null,_findRoot:function(a){while(a){if(FB.Dom.containsCss(a,'fb_dialog'))return a;a=a.parentNode;}},_showLoader:function(a,c){if(!FB.Dialog._loaderEl){c=parseInt(c,10);c=c?c:460;FB.Dialog._loaderEl=FB.Dialog._findRoot(FB.Dialog.create({content:('
      '+' '+'
      '+'
      '+' Facebook'+'
      '+'
      '+'
      '+''),width:c}));}if(!a)a=function(){};var b=FB.$('fb_dialog_loader_close');FB.Dom.removeCss(b,'fb_hidden');b.onclick=function(){FB.Dialog._hideLoader();a();};FB.Dialog._makeActive(FB.Dialog._loaderEl);},_hideLoader:function(){if(FB.Dialog._loaderEl&&FB.Dialog._loaderEl==FB.Dialog._active)FB.Dialog._loaderEl.style.top='-10000px';},_makeActive:function(b){FB.Dialog._lowerActive();var a={width:parseInt(b.offsetWidth,10),height:parseInt(b.offsetHeight,10)},e=FB.Dom.getViewportInfo(),c=(e.scrollLeft+(e.width-a.width)/2),d=(e.scrollTop+(e.height-a.height)/2.5);b.style.left=(c>0?c:0)+'px';b.style.top=(d>0?d:0)+'px';FB.Dialog._active=b;},_lowerActive:function(){if(!FB.Dialog._active)return;FB.Dialog._active.style.top='-10000px';FB.Dialog._active=null;},_removeStacked:function(a){FB.Dialog._stack=FB.Array.filter(FB.Dialog._stack,function(b){return b!=a;});},create:function(e){e=e||{};if(e.loader)FB.Dialog._showLoader(e.onClose,e.loaderWidth);var d=document.createElement('div'),c=document.createElement('div'),a='fb_dialog';if(e.closeIcon&&e.onClose){var b=document.createElement('a');b.className='fb_dialog_close_icon';b.onclick=e.onClose;d.appendChild(b);}if(FB.Dom.getBrowserType()=='ie'){a+=' fb_dialog_legacy';FB.Array.forEach(['vert_left','vert_right','horiz_top','horiz_bottom','top_left','top_right','bottom_left','bottom_right'],function(g){var h=document.createElement('span');h.className='fb_dialog_'+g;d.appendChild(h);});}else a+=' fb_dialog_advanced';if(e.content)FB.Content.append(e.content,c);d.className=a;var f=parseInt(e.width,10);if(!isNaN(f))d.style.width=f+'px';c.className='fb_dialog_content';d.appendChild(c);FB.Content.append(d);if(e.visible)FB.Dialog.show(d);return c;},show:function(a){a=FB.Dialog._findRoot(a);if(a){FB.Dialog._removeStacked(a);FB.Dialog._hideLoader();FB.Dialog._makeActive(a);FB.Dialog._stack.push(a);}},remove:function(a){a=FB.Dialog._findRoot(a);if(a){var b=FB.Dialog._active==a;FB.Dialog._removeStacked(a);FB.Dialog._hideLoader();if(b)if(FB.Dialog._stack.length>0){FB.Dialog.show(FB.Dialog._stack.pop());}else FB.Dialog._lowerActive();window.setTimeout(function(){a.parentNode.removeChild(a);},3000);}}}); -FB.provide('XD',{_origin:null,_transport:null,_callbacks:{},_forever:{},init:function(a){if(FB.XD._origin)return;if(window.addEventListener&&!window.attachEvent&&window.postMessage){FB.XD._origin=(window.location.protocol+'//'+window.location.host+'/'+FB.guid());FB.XD.PostMessage.init();FB.XD._transport='postmessage';}else if(!a&&FB.Flash.hasMinVersion()){FB.XD._origin=(window.location.protocol+'//'+document.domain+'/'+FB.guid());FB.XD.Flash.init();FB.XD._transport='flash';}else{FB.XD._transport='fragment';FB.XD.Fragment._channelUrl=a||window.location.toString();}},resolveRelation:function(b){var g,d,f=b.split('.'),e=window;for(var a=0,c=f.length;a0)return 'javascript:false;//';var f=FB.getDomain('cdn')+'connect/xd_proxy.php#',c=FB.guid();if(FB.XD._transport=='fragment'){f=FB.XD.Fragment._channelUrl;var d=f.indexOf('#');if(d>0)f=f.substr(0,d);f+=((f.indexOf('?')<0?'?':'&')+FB.XD.Fragment._magic+'#?=&');}if(b)FB.XD._forever[c]=true;FB.XD._callbacks[c]=a;return f+FB.QS.encode({cb:c,origin:FB.XD._origin,relation:e||'opener',transport:FB.XD._transport});},recv:function(b){if(typeof b=='string')b=FB.QS.decode(b);var a=FB.XD._callbacks[b.cb];if(!FB.XD._forever[b.cb])delete FB.XD._callbacks[b.cb];a&&a(b);},PostMessage:{init:function(){var a=FB.XD.PostMessage.onMessage;window.addEventListener?window.addEventListener('message',a,false):window.attachEvent('onmessage',a);},onMessage:function(event){FB.XD.recv(event.data);}},Flash:{init:function(){FB.Flash.onReady(function(){document.XdComm.postMessage_init('FB.XD.Flash.onMessage',FB.XD._origin);});},onMessage:function(a){FB.XD.recv(decodeURIComponent(a));}},Fragment:{_magic:'fb_xd_fragment',checkAndDispatch:function(){var b=window.location.toString(),a=b.substr(b.indexOf('#')+1),c=b.indexOf(FB.XD.Fragment._magic);if(c>0){FB.init=FB.getLoginStatus=FB.api=function(){};document.documentElement.style.display='none';FB.XD.resolveRelation(FB.QS.decode(a).relation).FB.XD.recv(a);}}}});FB.XD.Fragment.checkAndDispatch(); -FB.provide('Arbiter',{inform:function(c,e,f,b){if(window.name.indexOf('app_runner_')===0){var d=FB.JSON.stringify({method:c,params:e});if(window.postMessage){FB.XD.resolveRelation(f||'parent').postMessage(d,'*');return;}else try{window.opener.postMessage(d);return;}catch(a){}}var h=(FB.getDomain((b?'https_':'')+'staticfb')+'connect/canvas_proxy.php#'+FB.QS.encode({method:c,params:FB.JSON.stringify(e||{}),relation:f}));var g=FB.Content.appendHidden('');FB.Content.insertIframe({url:h,root:g,width:1,height:1,onload:function(){setTimeout(function(){g.parentNode.removeChild(g);},10);}});}}); -FB.provide('',{ui:function(e,b){if(!e.method){FB.log('"method" is a required parameter for FB.ui().');return;}var a=FB.UIServer.prepareCall(e,b);if(!a)return;var d=a.params.display;if(d=='dialog')d='iframe';var c=FB.UIServer[d];if(!c){FB.log('"display" must be one of "popup", "iframe" or "hidden".');return;}c(a);}});FB.provide('UIServer',{Methods:{},_active:{},_defaultCb:{},_resultToken:'"xxRESULTTOKENxx"',genericTransform:function(a){if(a.params.display=='dialog'||a.params.display=='iframe'){a.params.display='iframe';a.params.channel=FB.UIServer._xdChannelHandler(a.id,'parent.parent');}return a;},prepareCall:function(h,b){var g=h.method.toLowerCase(),f=FB.UIServer.Methods[g]||{size:{width:575,height:240}},e=FB.guid(),d=FB._https||(g!=='auth.status');FB.copy(h,{api_key:FB._apiKey,app_id:FB._apiKey,locale:FB._locale,sdk:'joey',access_token:d&&FB._session&&FB._session.access_token||undefined});h.display=FB.UIServer.getDisplayMode(f,h);if(!f.url){f.url='dialog/'+g;delete h.method;}var a={cb:b,id:e,size:f.size||{},url:FB.getDomain(d?'https_www':'www')+f.url,params:h};var j=f.transform?f.transform:FB.UIServer.genericTransform;if(j){a=j(a);if(!a)return;}var i=FB.UIServer.getXdRelation(a.params.display);if(!(a.id in FB.UIServer._defaultCb)&&!('next' in a.params))a.params.next=FB.UIServer._xdResult(a.cb,a.id,i,true);if(i==='parent')a.params.channel_url=FB.UIServer._xdChannelHandler(e,'parent.parent');a.params=FB.JSON.flatten(a.params);var c=FB.QS.encode(a.params);if((a.url+c).length>2000){a.post=true;}else if(c)a.url+='?'+c;return a;},getDisplayMode:function(a,b){if(b.display==='hidden')return 'hidden';if(window.name.indexOf('app_runner_')===0)return 'async';if(!FB._session&&b.display=='dialog'&&!a.loggedOutIframe){FB.log('"dialog" mode can only be used when the user is connected.');return 'popup';}return b.display||(FB._session?'dialog':'popup');},getXdRelation:function(a){if(a==='popup')return 'opener';if(a==='dialog'||a==='iframe')return 'parent';if(a==='async')return 'parent.frames['+window.name+']';},popup:function(b){var a=typeof window.screenX!='undefined'?window.screenX:window.screenLeft,i=typeof window.screenY!='undefined'?window.screenY:window.screenTop,g=typeof window.outerWidth!='undefined'?window.outerWidth:document.documentElement.clientWidth,f=typeof window.outerHeight!='undefined'?window.outerHeight:(document.documentElement.clientHeight-22),k=b.size.width,d=b.size.height,h=(a<0)?window.screen.width+a:a,e=parseInt(h+((g-k)/2),10),j=parseInt(i+((f-d)/2.5),10),c=('width='+k+',height='+d+',left='+e+',top='+j+',scrollbars=1');if(b.params.method=='permissions.request')c+=',location=1,toolbar=0';if(b.post){FB.UIServer._active[b.id]=window.open('about:blank',b.id,c);FB.Content.postTarget({url:b.url,target:b.id,params:b.params});}else FB.UIServer._active[b.id]=window.open(b.url,b.id,c);if(b.id in FB.UIServer._defaultCb)FB.UIServer._popupMonitor();},hidden:function(a){a.className='FB_UI_Hidden';a.root=FB.Content.appendHidden('');FB.UIServer._insertIframe(a);},iframe:function(a){a.className='FB_UI_Dialog';a.root=FB.Dialog.create({onClose:function(){FB.UIServer._triggerDefault(a.id);},loader:true,loaderWidth:a.size.width,closeIcon:true});FB.Dom.addCss(a.root,'fb_dialog_iframe');FB.UIServer._insertIframe(a);},async:function(a){a.frame=window.name;delete a.url;delete a.size;FB.Arbiter.inform('showDialog',a);},_insertIframe:function(b){FB.UIServer._active[b.id]=false;var a=function(c){if(b.id in FB.UIServer._active)FB.UIServer._active[b.id]=c;};if(b.post){FB.Content.insertIframe({url:'about:blank',root:b.root,className:b.className,width:b.size.width,height:b.size.height,onload:function(c){a(c);FB.Content.postTarget({url:b.url,target:c.name,params:b.params});}});}else FB.Content.insertIframe({url:b.url,root:b.root,className:b.className,width:b.size.width,height:b.size.height,onload:a});},_triggerDefault:function(a){FB.UIServer._xdRecv({frame:a},FB.UIServer._defaultCb[a]||function(){});},_popupMonitor:function(){var a;for(var b in FB.UIServer._active)if(FB.UIServer._active.hasOwnProperty(b)&&b in FB.UIServer._defaultCb){var c=FB.UIServer._active[b];try{if(c.tagName)continue;}catch(d){}try{if(c.closed){FB.UIServer._triggerDefault(b);}else a=true;}catch(e){}}if(a&&!FB.UIServer._popupInterval){FB.UIServer._popupInterval=window.setInterval(FB.UIServer._popupMonitor,100);}else if(!a&&FB.UIServer._popupInterval){window.clearInterval(FB.UIServer._popupInterval);FB.UIServer._popupInterval=null;}},_xdChannelHandler:function(a,b){return FB.XD.handler(function(c){var d=FB.UIServer._active[a];if(!d)return;if(c.type=='resize'){if(c.height)d.style.height=c.height+'px';if(c.width)d.style.width=c.width+'px';FB.Arbiter.inform('resize.ack',{},'parent.frames['+d.name+']',true);FB.Dialog.show(d);}},b,true);},_xdNextHandler:function(a,b,d,c){if(c)FB.UIServer._defaultCb[b]=a;return FB.XD.handler(function(e){FB.UIServer._xdRecv(e,a);},d)+'&frame='+b;},_xdRecv:function(b,a){var c=FB.UIServer._active[b.frame];try{if(FB.Dom.containsCss(c,'FB_UI_Hidden')){window.setTimeout(function(){c.parentNode.parentNode.removeChild(c.parentNode);},3000);}else if(FB.Dom.containsCss(c,'FB_UI_Dialog'))FB.Dialog.remove(c);}catch(d){}try{if(c.close){c.close();FB.UIServer._popupCount--;}}catch(e){}delete FB.UIServer._active[b.frame];delete FB.UIServer._defaultCb[b.frame];a(b);},_xdResult:function(a,b,d,c){return (FB.UIServer._xdNextHandler(function(e){a&&a(e.result&&e.result!=FB.UIServer._resultToken&&FB.JSON.parse(e.result));},b,d,c)+'&result='+encodeURIComponent(FB.UIServer._resultToken));}}); -FB.provide('',{getLoginStatus:function(a,b){if(!FB._apiKey){FB.log('FB.getLoginStatus() called before calling FB.init().');return;}if(a)if(!b&&FB.Auth._loadState=='loaded'){a({status:FB._userStatus,session:FB._session});return;}else FB.Event.subscribe('FB.loginStatus',a);if(!b&&FB.Auth._loadState=='loading')return;FB.Auth._loadState='loading';var c=function(d){FB.Auth._loadState='loaded';FB.Event.fire('FB.loginStatus',d);FB.Event.clear('FB.loginStatus');};FB.ui({method:'auth.status',display:'hidden'},c);},getSession:function(){return FB._session;},login:function(a,b){FB.ui(FB.copy({method:'permissions.request',display:'popup'},b||{}),a);},logout:function(a){FB.ui({method:'auth.logout',display:'hidden'},a);}});FB.provide('Auth',{_callbacks:[],setSession:function(e,g){var b=!FB._session&&e,c=FB._session&&!e,a=FB._session&&e&&FB._session.uid!=e.uid,f=b||c||(FB._session&&e&&FB._session.access_token!=e.access_token),h=g!=FB._userStatus;var d={session:e,status:g};FB._session=e;FB._userStatus=g;if(f&&FB.Cookie&&FB.Cookie.getEnabled())FB.Cookie.set(e);if(h)FB.Event.fire('auth.statusChange',d);if(c||a)FB.Event.fire('auth.logout',d);if(b||a)FB.Event.fire('auth.login',d);if(f)FB.Event.fire('auth.sessionChange',d);if(FB.Auth._refreshTimer){window.clearTimeout(FB.Auth._refreshTimer);delete FB.Auth._refreshTimer;}if(FB.Auth._loadState&&e&&e.expires)FB.Auth._refreshTimer=window.setTimeout(function(){FB.getLoginStatus(null,true);},1200000);return d;},xdHandler:function(a,b,f,c,e,d){return FB.UIServer._xdNextHandler(FB.Auth.xdResponseWrapper(a,e,d),b,f,c);},xdResponseWrapper:function(a,c,b){return function(d){try{b=FB.JSON.parse(d.session);}catch(f){}if(b)c='connected';if(d.fb_https&&!FB._https)FB._https=true;var e=FB.Auth.setSession(b||null,c);e.perms=d&&d.perms||null;a&&a(e);};}});FB.provide('UIServer.Methods',{'permissions.request':{size:{width:627,height:326},transform:function(a){if(!FB._apiKey){FB.log('FB.login() called before calling FB.init().');return;}if(FB._session&&!a.params.perms){FB.log('FB.login() called when user is already connected.');a.cb&&a.cb({status:FB._userStatus,session:FB._session});return;}a=FB.UIServer.genericTransform(a);a.cb=FB.Auth.xdResponseWrapper(a.cb,FB._userStatus,FB._session);a.params.method='permissions.request';FB.copy(a.params,{fbconnect:FB._inCanvas?0:1,return_session:1,session_version:3});return a;}},'auth.logout':{url:'logout.php',transform:function(a){if(!FB._apiKey){FB.log('FB.logout() called before calling FB.init().');}else if(!FB._session){FB.log('FB.logout() called without a session.');}else{a.params.next=FB.Auth.xdHandler(a.cb,a.id,'parent',false,'unknown');return a;}}},'auth.status':{url:'extern/login_status.php',transform:function(a){var b=a.cb,c=a.id,d=FB.Auth.xdHandler;delete a.cb;FB.copy(a.params,{no_session:d(b,c,'parent',false,'notConnected'),no_user:d(b,c,'parent',false,'unknown'),ok_session:d(b,c,'parent',false,'connected'),session_version:3,extern:FB._inCanvas?0:2});return a;}}}); -FB.provide('Canvas',{_timer:null,_lastSize:{},setSize:function(b){if(typeof b!="object")b={};b=FB.copy(b||{},FB.Canvas._computeContentSize());b=FB.copy(b,{frame:window.name||'iframe_canvas'});if(FB.Canvas._lastSize[b.frame]){var a=FB.Canvas._lastSize[b.frame].height;if(FB.Canvas._lastSize[b.frame].width==b.width&&(b.height<=a&&(a-b.height<=16)))return false;}FB.Canvas._lastSize[b.frame]=b;FB.Arbiter.inform('setSize',b);return true;},setAutoResize:function(b,a){if(a===undefined&&typeof b=="number"){a=b;b=true;}if(b===undefined||b){if(FB.Canvas._timer===null)FB.Canvas._timer=window.setInterval(FB.Canvas.setSize,a||100);FB.Canvas.setSize();}else if(FB.Canvas._timer!==null){window.clearInterval(FB.Canvas._timer);FB.Canvas._timer=null;}},_computeContentSize:function(){var a=document.body,c=document.documentElement,d=0,b=Math.max(Math.max(a.offsetHeight,a.scrollHeight)+a.offsetTop,Math.max(c.offsetHeight,c.scrollHeight)+c.offsetTop);if(a.offsetWidthd)d=f;});if(c.clientLeft>0)d+=(c.clientLeft*2);if(c.clientTop>0)b+=(c.clientTop*2);return {height:b,width:d};}}); -FB.provide('UIServer.Methods',{'stream.share':{size:{width:575,height:380},url:'sharer.php',transform:function(a){if(!a.params.u)a.params.u=window.location.toString();return a;}},'fbml.dialog':{size:{width:575,height:300},url:'render_fbml.php',loggedOutIframe:true,transform:function(a){return a;}},'auth.logintofacebook':{size:{width:530,height:287},url:'login.php',transform:function(a){a.params.skip_api_login=1;var c=FB.UIServer.getXdRelation(a.params.display);var b=FB.UIServer._xdResult(a.cb,a.id,c,true);a.params.next=FB.getDomain(FB._https?'https_www':'www')+"login.php?"+FB.QS.encode({api_key:FB._apiKey,next:b,skip_api_login:1});return a;}}}); -FB.provide('',{share:function(a){FB.log('FB.share() has been deprecated. Please use FB.ui() instead.');FB.ui({display:'popup',method:'stream.share',u:a});},publish:function(b,a){FB.log('FB.publish() has been deprecated. Please use FB.ui() instead.');b=b||{};FB.ui(FB.copy({display:'popup',method:'stream.publish',preview:1},b||{}),a);},addFriend:function(b,a){FB.log('FB.addFriend() has been deprecated. Please use FB.ui() instead.');FB.ui({display:'popup',id:b,method:'friend.add'},a);}});FB.UIServer.Methods['auth.login']=FB.UIServer.Methods['permissions.request']; -FB.provide('XFBML',{_renderTimeout:30000,parse:function(c,a){c=c||document.body;var b=1,d=function(){b--;if(b===0){a&&a();FB.Event.fire('xfbml.render');}};FB.Array.forEach(FB.XFBML._tagInfos,function(f){if(!f.xmlns)f.xmlns='fb';var g=FB.XFBML._getDomElements(c,f.xmlns,f.localName);for(var e=0;e0)FB.log(b+' XFBML tags failed to render in '+FB.XFBML._renderTimeout+'ms.');},FB.XFBML._renderTimeout);d();},registerTag:function(a){FB.XFBML._tagInfos.push(a);},_processElement:function(dom,tagInfo,cb){var element=dom._element;if(element){element.subscribe('render',cb);element.process();}else{var processor=function(){var fn=eval(tagInfo.className);var getBoolAttr=function(attr){var attr=dom.getAttribute(attr);return (attr&&FB.Array.indexOf(['true','1','yes','on'],attr.toLowerCase())>-1);};var isLogin=false;var showFaces=true;var renderInIframe=false;if(tagInfo.className==='FB.XFBML.LoginButton'){renderInIframe=getBoolAttr('render-in-iframe');showFaces=getBoolAttr('show-faces')||getBoolAttr('show_faces');isLogin=renderInIframe||showFaces;if(isLogin)fn=FB.XFBML.Login;}element=dom._element=new fn(dom);if(isLogin){var extraParams={show_faces:showFaces};var perms=dom.getAttribute('perms');if(perms)extraParams.perms=perms;element.setExtraParams(extraParams);}element.subscribe('render',cb);element.process();};if(FB.CLASSES[tagInfo.className.substr(3)]){processor();}else FB.log('Tag '+tagInfo.className+' was not found.');}},_getDomElements:function(a,e,d){var c=e+':'+d;switch(FB.Dom.getBrowserType()){case 'mozilla':return a.getElementsByTagNameNS(document.body.namespaceURI,c);case 'ie':try{var docNamespaces=document.namespaces;if(docNamespaces&&docNamespaces[e]){var nodes=a.getElementsByTagName(d);if(!document.addEventListener||nodes.length>0)return nodes;}}catch(b){}return a.getElementsByTagName(c);default:return a.getElementsByTagName(c);}},_tagInfos:[{localName:'activity',className:'FB.XFBML.Activity'},{localName:'add-profile-tab',className:'FB.XFBML.AddProfileTab'},{localName:'bookmark',className:'FB.XFBML.Bookmark'},{localName:'comments',className:'FB.XFBML.Comments'},{localName:'connect-bar',className:'FB.XFBML.ConnectBar'},{localName:'fan',className:'FB.XFBML.Fan'},{localName:'like',className:'FB.XFBML.Like'},{localName:'like-box',className:'FB.XFBML.LikeBox'},{localName:'live-stream',className:'FB.XFBML.LiveStream'},{localName:'login',className:'FB.XFBML.Login'},{localName:'login-button',className:'FB.XFBML.LoginButton'},{localName:'facepile',className:'FB.XFBML.Facepile'},{localName:'friendpile',className:'FB.XFBML.Friendpile'},{localName:'name',className:'FB.XFBML.Name'},{localName:'profile-pic',className:'FB.XFBML.ProfilePic'},{localName:'recommendations',className:'FB.XFBML.Recommendations'},{localName:'registration',className:'FB.XFBML.Registration'},{localName:'send',className:'FB.XFBML.Send'},{localName:'serverfbml',className:'FB.XFBML.ServerFbml'},{localName:'share-button',className:'FB.XFBML.ShareButton'},{localName:'social-bar',className:'FB.XFBML.SocialBar'}]});(function(){try{if(document.namespaces&&!document.namespaces.item.fb)document.namespaces.add('fb');}catch(a){}}()); -FB.provide('XFBML',{set:function(b,c,a){FB.log('FB.XFBML.set() has been deprecated.');b.innerHTML=c;FB.XFBML.parse(b,a);}}); -FB.provide('',{bind:function(){var a=Array.prototype.slice.call(arguments),c=a.shift(),b=a.shift();return function(){return c.apply(b,a.concat(Array.prototype.slice.call(arguments)));};},Class:function(b,a,d){if(FB.CLASSES[b])return FB.CLASSES[b];var c=a||function(){};c.prototype=d;c.prototype.bind=function(e){return FB.bind(e,this);};c.prototype.constructor=c;FB.create(b,c);FB.CLASSES[b]=c;return c;},subclass:function(d,b,c,e){if(FB.CLASSES[d])return FB.CLASSES[d];var a=FB.create(b);FB.copy(e,a.prototype);e._base=a;e._callBase=function(g){var f=Array.prototype.slice.call(arguments,1);return a.prototype[g].apply(this,f);};return FB.Class(d,c?c:function(){if(a.apply)a.apply(this,arguments);},e);},CLASSES:{}});FB.provide('Type',{isType:function(a,b){while(a)if(a.constructor===b||a===b){return true;}else a=a._base;return false;}}); -FB.Class('Obj',null,FB.copy({setProperty:function(a,b){if(FB.JSON.stringify(b)!=FB.JSON.stringify(this[a])){this[a]=b;this.fire(a,b);}}},FB.EventProvider)); -FB.subclass('Waitable','Obj',function(){},{set:function(a){this.setProperty('value',a);},error:function(a){this.fire("error",a);},wait:function(a,b){if(b)this.subscribe('error',b);this.monitor('value',this.bind(function(){if(this.value!==undefined){a(this.value);return true;}}));}}); -FB.subclass('Data.Query','Waitable',function(){if(!FB.Data.Query._c)FB.Data.Query._c=1;this.name='v_'+FB.Data.Query._c++;},{parse:function(a){var b=FB.String.format.apply(null,a),d=(/^select (.*?) from (\w+)\s+where (.*)$/i).exec(b);this.fields=this._toFields(d[1]);this.table=d[2];this.where=this._parseWhere(d[3]);for(var c=1;c-1){return d;}else return b;});},isValid:function(){for(var a=this.dom;a;a=a.parentNode)if(a==document.body)return true;},clear:function(){this.dom.innerHTML='';}},FB.EventProvider)); -FB.subclass('XFBML.IframeWidget','XFBML.Element',null,{_showLoader:true,_refreshOnAuthChange:false,_allowReProcess:false,_fetchPreCachedLoader:false,_visibleAfter:'load',getUrlBits:function(){throw new Error('Inheriting class needs to implement getUrlBits().');},setupAndValidate:function(){return true;},oneTimeSetup:function(){},getSize:function(){},getIframeName:function(){},getIframeTitle:function(){},getChannelUrl:function(){if(!this._channelUrl){var a=this;this._channelUrl=FB.XD.handler(function(b){a.fire('xd.'+b.type,b);},'parent.parent',true);}return this._channelUrl;},getIframeNode:function(){return this.dom.getElementsByTagName('iframe')[0];},process:function(a){if(this._done){if(!this._allowReProcess&&!a)return;this.clear();}else this._oneTimeSetup();this._done=true;if(!this.setupAndValidate()){this.fire('render');return;}if(this._showLoader)this._addLoader();FB.Dom.addCss(this.dom,'fb_iframe_widget');if(this._visibleAfter!='immediate'){FB.Dom.addCss(this.dom,'fb_hide_iframes');}else this.subscribe('iframe.onload',FB.bind(this.fire,this,'render'));var c=this.getSize()||{};var d=this._getURL();if(!this._fetchPreCachedLoader)d+='?'+FB.QS.encode(this._getQS());if(d.length>2000){d='about:blank';var b=FB.bind(function(){this._postRequest();this.unsubscribe('iframe.onload',b);},this);this.subscribe('iframe.onload',b);}FB.Content.insertIframe({url:d,root:this.dom.appendChild(document.createElement('span')),name:this.getIframeName(),title:this.getIframeTitle(),className:FB._localeIsRtl?'fb_rtl':'fb_ltr',height:c.height,width:c.width,onload:FB.bind(this.fire,this,'iframe.onload')});},_oneTimeSetup:function(){this.subscribe('xd.resize',FB.bind(this._handleResizeMsg,this));if(FB.getLoginStatus){this.subscribe('xd.refreshLoginStatus',FB.bind(FB.getLoginStatus,FB,function(){},true));this.subscribe('xd.logout',FB.bind(FB.logout,FB,function(){}));}if(this._refreshOnAuthChange)this._setupAuthRefresh();if(this._visibleAfter=='load')this.subscribe('iframe.onload',FB.bind(this._makeVisible,this));this.oneTimeSetup();},_makeVisible:function(){this._removeLoader();FB.Dom.removeCss(this.dom,'fb_hide_iframes');this.fire('render');},_setupAuthRefresh:function(){FB.getLoginStatus(FB.bind(function(b){var a=b.status;FB.Event.subscribe('auth.statusChange',FB.bind(function(c){if(!this.isValid())return;if(a=='unknown'||c.status=='unknown')this.process(true);a=c.status;},this));},this));},_handleResizeMsg:function(b){if(!this.isValid())return;var a=this.getIframeNode();a.style.height=b.height+'px';if(b.width)a.style.width=b.width+'px';a.style.border='none';this._makeVisible();},_addLoader:function(){if(!this._loaderDiv){FB.Dom.addCss(this.dom,'fb_iframe_widget_loader');this._loaderDiv=document.createElement('div');this._loaderDiv.className='FB_Loader';this.dom.appendChild(this._loaderDiv);}},_removeLoader:function(){if(this._loaderDiv){FB.Dom.removeCss(this.dom,'fb_iframe_widget_loader');if(this._loaderDiv.parentNode)this._loaderDiv.parentNode.removeChild(this._loaderDiv);this._loaderDiv=null;}},_getQS:function(){return FB.copy({api_key:FB._apiKey,locale:FB._locale,sdk:'joey',session_key:FB._session&&FB._session.session_key,ref:this.getAttribute('ref')},this.getUrlBits().params);},_getURL:function(){var a='www',b='';if(this._fetchPreCachedLoader){a='cdn';b='static/';}return FB.getDomain(a)+'plugins/'+b+this.getUrlBits().name+'.php';},_postRequest:function(){FB.Content.postTarget({url:this._getURL(),target:this.getIframeNode().name,params:this._getQS()});}}); -FB.subclass('XFBML.Activity','XFBML.IframeWidget',null,{_visibleAfter:'load',_refreshOnAuthChange:true,setupAndValidate:function(){this._attr={border_color:this.getAttribute('border-color'),colorscheme:this.getAttribute('color-scheme'),filter:this.getAttribute('filter'),font:this.getAttribute('font'),header:this._getBoolAttribute('header'),height:this._getPxAttribute('height',300),recommendations:this._getBoolAttribute('recommendations'),site:this.getAttribute('site',location.hostname),width:this._getPxAttribute('width',300)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'activity',params:this._attr};}}); -FB.subclass('XFBML.ButtonElement','XFBML.Element',null,{_allowedSizes:['icon','small','medium','large','xlarge'],onClick:function(){throw new Error('Inheriting class needs to implement onClick().');},setupAndValidate:function(){return true;},getButtonMarkup:function(){return this.getOriginalHTML();},getOriginalHTML:function(){return this._originalHTML;},process:function(){if(!('_originalHTML' in this))this._originalHTML=FB.String.trim(this.dom.innerHTML);if(!this.setupAndValidate()){this.fire('render');return;}var d=this._getAttributeFromList('size','medium',this._allowedSizes),a='',b='';if(d=='icon'){a='fb_button_simple';}else{var c=FB._localeIsRtl?'_rtl':'';b=this.getButtonMarkup();a='fb_button'+c+' fb_button_'+d+c;}this.dom.innerHTML=(''+''+b+''+'');this.dom.firstChild.onclick=FB.bind(this.onClick,this);this.fire('render');}}); -FB.provide('Helper',{isUser:function(a){return a<2.2e+09||(a>=1e+14&&a<=100099999989999);},getLoggedInUser:function(){return FB._session?FB._session.uid:null;},upperCaseFirstChar:function(a){if(a.length>0){return a.substr(0,1).toUpperCase()+a.substr(1);}else return a;},getProfileLink:function(c,b,a){a=a||(c?FB.getDomain('www')+'profile.php?id='+c.uid:null);if(a)b=''+b+'';return b;},invokeHandler:function(handler,scope,args){if(handler)if(typeof handler==='string'){eval(handler);}else if(handler.apply)handler.apply(scope,args||[]);},fireEvent:function(a,b){var c=b._attr.href;b.fire(a,c);FB.Event.fire(a,c,b);},executeFunctionByName:function(d){var a=Array.prototype.slice.call(arguments,1);var f=d.split(".");var c=f.pop();var b=window;for(var e=0;e0){a.xid=encodeURIComponent(document.URL.substring(0,b));}else a.xid=encodeURIComponent(document.URL);}if(a.migrated&&!a.href)a.href='http://www.facebook.com/plugins/comments_v1.php?'+'app_id='+FB._apiKey+'&xid='+encodeURIComponent(a.xid)+'&url='+encodeURIComponent(a.url);this._attr=a;return true;},oneTimeSetup:function(){this.subscribe('xd.addComment',FB.bind(this._handleCommentMsg,this));},getSize:function(){return {width:this._attr.width,height:200};},getUrlBits:function(){return {name:'comments',params:this._attr};},_handleCommentMsg:function(a){if(!this.isValid())return;FB.Event.fire('comments.add',{post:a.post,user:a.user,widget:this});}}); -FB.provide('Anim',{ate:function(c,g,d,b){d=!isNaN(parseFloat(d))&&d>=0?d:750;var e=40,f={},j={},a=null,h=c.style,i=setInterval(FB.bind(function(){if(!a)a=new Date().getTime();var k=1;if(d!=0)k=Math.min((new Date().getTime()-a)/d,1);FB.Array.forEach(g,FB.bind(function(o,m){if(!f[m]){var n=FB.Dom.getStyle(c,m);if(n===false)return;f[m]=this._parseCSS(n+'');}if(!j[m])j[m]=this._parseCSS(o.toString());var l='';FB.Array.forEach(f[m],function(q,p){if(isNaN(j[m][p].numPart)&&j[m][p].textPart=='?'){l=q.numPart+q.textPart;}else if(isNaN(q.numPart)){l=q.textPart;}else l+=(q.numPart+Math.ceil((j[m][p].numPart-q.numPart)*Math.sin(Math.PI/2*k)))+j[m][p].textPart+' ';});FB.Dom.setStyle(c,m,l);},this));if(k==1){clearInterval(i);if(b)b(c);}},this),e);},_parseCSS:function(a){var b=[];FB.Array.forEach(a.split(' '),function(d){var c=parseInt(d,10);b.push({numPart:c,textPart:d.replace(c,'')});});return b;}}); -FB.provide('Insights',{impression:function(e,a){var b=FB.guid(),g="//ah8.facebook.com/impression.php/"+b+"/",c=new Image(1,1),f=[];if(!e.api_key&&FB._apiKey)e.api_key=FB._apiKey;for(var d in e)f.push(encodeURIComponent(d)+'='+encodeURIComponent(e[d]));g+='?'+f.join('&');if(a)c.onload=a;c.src=g;}}); -FB.subclass('XFBML.ConnectBar','XFBML.Element',null,{_initialHeight:null,_initTopMargin:0,_picFieldName:'pic_square',_page:null,_displayed:false,_notDisplayed:false,_container:null,_animationSpeed:0,process:function(){FB.getLoginStatus(this.bind(function(a){FB.Event.monitor('auth.statusChange',this.bind(function(){if(this.isValid()&&FB._userStatus=='connected'){this._uid=FB.Helper.getLoggedInUser();FB.api({method:'Connect.shouldShowConnectBar'},this.bind(function(b){if(b!=2){this._animationSpeed=(b==0)?750:0;this._showBar();}else this._noRender();}));}else this._noRender();return false;}));}));},_showBar:function(){var a=FB.Data._selectByIndex(['first_name','profile_url',this._picFieldName],'user','uid',this._uid);var b=FB.Data._selectByIndex(['display_name'],'application','api_key',FB._apiKey);FB.Data.waitOn([a,b],FB.bind(function(c){c[0][0].site_name=c[1][0].display_name;if(!this._displayed){this._displayed=true;this._notDisplayed=false;this._renderConnectBar(c[0][0]);this.fire('render');FB.Insights.impression({lid:104,name:'widget_load'});this.fire('connectbar.ondisplay');FB.Event.fire('connectbar.ondisplay',this);FB.Helper.invokeHandler(this.getAttribute('on-display'),this);}},this));},_noRender:function(){if(this._displayed){this._displayed=false;this._closeConnectBar();}if(!this._notDisplayed){this._notDisplayed=true;this.fire('render');this.fire('connectbar.onnotdisplay');FB.Event.fire('connectbar.onnotdisplay',this);FB.Helper.invokeHandler(this.getAttribute('on-not-display'),this);}},_renderConnectBar:function(d){var b=document.createElement('div'),c=document.createElement('div');b.className='fb_connect_bar';c.className='fb_reset fb_connect_bar_container';c.appendChild(b);document.body.appendChild(c);this._container=c;this._initialHeight=Math.round(parseFloat(FB.Dom.getStyle(c,'height'))+parseFloat(FB.Dom.getStyle(c,'borderBottomWidth')));b.innerHTML=FB.String.format('
      '+''+'{2}'+''+'
      '+''+'{4}'+''+'{5}'+' '+'{6} – '+'{0}'+'',FB.Intl._tx("No Thanks"),FB.getDomain('cdn')+FB.XFBML.ConnectBar.imgs.buttonUrl,FB.Intl._tx("Close"),d[this._picFieldName]||FB.getDomain('cdn')+FB.XFBML.ConnectBar.imgs.missingProfileUrl,FB.String.escapeHTML(d.first_name),FB.Intl._tx("Hi {firstName}. \u003cstrong>{siteName}\u003c\/strong> is using Facebook to personalize your experience.",{firstName:FB.String.escapeHTML(d.first_name),siteName:FB.String.escapeHTML(d.site_name)}),FB.Intl._tx("Learn More"),d.profile_url,FB.getDomain('www')+'sitetour/connect.php');var a=this;FB.Array.forEach(b.getElementsByTagName('a'),function(g){g.onclick=FB.bind(a._clickHandler,a);});this._page=document.body;var f=0;if(this._page.parentNode){f=Math.round((parseFloat(FB.Dom.getStyle(this._page.parentNode,'height'))-parseFloat(FB.Dom.getStyle(this._page,'height')))/2);}else f=parseInt(FB.Dom.getStyle(this._page,'marginTop'),10);f=isNaN(f)?0:f;this._initTopMargin=f;if(!window.XMLHttpRequest){c.className+=" fb_connect_bar_container_ie6";}else{c.style.top=(-1*this._initialHeight)+'px';FB.Anim.ate(c,{top:'0px'},this._animationSpeed);}var e={marginTop:this._initTopMargin+this._initialHeight+'px'};if(FB.Dom.getBrowserType()=='ie'){e.backgroundPositionY=this._initialHeight+'px';}else e.backgroundPosition='? '+this._initialHeight+'px';FB.Anim.ate(this._page,e,this._animationSpeed);},_clickHandler:function(a){a=a||window.event;var b=a.target||a.srcElement;while(b.nodeName!='A')b=b.parentNode;switch(b.className){case 'fb_bar_close':FB.api({method:'Connect.connectBarMarkAcknowledged'});FB.Insights.impression({lid:104,name:'widget_user_closed'});this._closeConnectBar();break;case 'fb_learn_more':case 'fb_profile':window.open(b.href);break;case 'fb_no_thanks':this._closeConnectBar();FB.api({method:'Connect.connectBarMarkAcknowledged'});FB.Insights.impression({lid:104,name:'widget_user_no_thanks'});FB.api({method:'auth.revokeAuthorization',block:true},this.bind(function(){this.fire('connectbar.ondeauth');FB.Event.fire('connectbar.ondeauth',this);FB.Helper.invokeHandler(this.getAttribute('on-deauth'),this);if(this._getBoolAttribute('auto-refresh',true))window.location.reload();}));break;}return false;},_closeConnectBar:function(){this._notDisplayed=true;var a={marginTop:this._initTopMargin+'px'};if(FB.Dom.getBrowserType()=='ie'){a.backgroundPositionY='0px';}else a.backgroundPosition='? 0px';var b=(this._animationSpeed==0)?0:300;FB.Anim.ate(this._page,a,b);FB.Anim.ate(this._container,{top:(-1*this._initialHeight)+'px'},b,function(c){c.parentNode.removeChild(c);});this.fire('connectbar.onclose');FB.Event.fire('connectbar.onclose',this);FB.Helper.invokeHandler(this.getAttribute('on-close'),this);}});FB.provide('XFBML.ConnectBar',{imgs:{buttonUrl:'images/facebook-widgets/close_btn.png',missingProfileUrl:'pics/q_silhouette.gif'}}); -FB.subclass('XFBML.Facepile','XFBML.IframeWidget',null,{_visibleAfter:'load',_extraParams:{},setupAndValidate:function(){this._attr={href:this.getAttribute('href'),channel:this.getChannelUrl(),max_rows:this.getAttribute('max-rows'),width:this._getPxAttribute('width',200),ref:this.getAttribute('ref')};for(var a in this._extraParams)this._attr[a]=this._extraParams[a];return true;},setExtraParams:function(a){this._extraParams=a;},oneTimeSetup:function(){var a=FB._userStatus;FB.Event.subscribe('auth.statusChange',FB.bind(function(b){if(a=='connected'||b.status=='connected')this.process(true);a=b.status;},this));},getSize:function(){return {width:this._attr.width,height:70};},getUrlBits:function(){return {name:'facepile',params:this._attr};}}); -FB.subclass('XFBML.Fan','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={api_key:FB._apiKey,connections:this.getAttribute('connections','10'),css:this.getAttribute('css'),height:this._getPxAttribute('height'),id:this.getAttribute('profile-id'),logobar:this._getBoolAttribute('logo-bar'),name:this.getAttribute('name'),stream:this._getBoolAttribute('stream',true),width:this._getPxAttribute('width',300)};if(!this._attr.id&&!this._attr.name){FB.log(' requires one of the "id" or "name" attributes.');return false;}var a=this._attr.height;if(!a)if((!this._attr.connections||this._attr.connections==='0')&&!this._attr.stream){a=65;}else if(!this._attr.connections||this._attr.connections==='0'){a=375;}else if(!this._attr.stream){a=250;}else a=550;if(this._attr.logobar)a+=25;this._attr.height=a;return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'fan',params:this._attr};}}); -FB.subclass('XFBML.Friendpile','XFBML.Facepile',null,{}); -FB.subclass('XFBML.EdgeCommentWidget','XFBML.IframeWidget',function(a){this._iframeWidth=a.width;this._iframeHeight=a.height;this._attr={master_frame_name:a.masterFrameName};this.dom=a.commentNode;this.dom.style.top=a.relativeHeightOffset;if(a.relativeWidthOffset)if(FB._localeIsRtl){this.dom.style.right=a.relativeWidthOffset;}else this.dom.style.left=a.relativeWidthOffset;this.dom.style.zIndex=FB.XFBML.EdgeCommentWidget.NextZIndex++;FB.Dom.addCss(this.dom,'fb_edge_comment_widget');},{_visibleAfter:'load',_showLoader:false,getSize:function(){return {width:this._iframeWidth,height:this._iframeHeight};},getUrlBits:function(){return {name:'comment_widget_shell',params:this._attr};}});FB.provide('XFBML.EdgeCommentWidget',{NextZIndex:10000}); -FB.subclass('XFBML.EdgeWidget','XFBML.IframeWidget',null,{_visibleAfter:'immediate',_showLoader:false,setupAndValidate:function(){FB.Dom.addCss(this.dom,'fb_edge_widget_with_comment');this._attr={channel_url:this.getChannelUrl(),debug:this._getBoolAttribute('debug'),href:this.getAttribute('href',window.location.href),is_permalink:this._getBoolAttribute('is-permalink'),node_type:this.getAttribute('node-type','link'),width:this._getWidgetWidth(),font:this.getAttribute('font'),layout:this._getLayout(),colorscheme:this.getAttribute('color-scheme'),action:this.getAttribute('action'),ref:this.getAttribute('ref'),show_faces:this._shouldShowFaces(),no_resize:this._getBoolAttribute('no_resize')};return true;},oneTimeSetup:function(){this.subscribe('xd.edgeCreated',FB.bind(this._onEdgeCreate,this));this.subscribe('xd.edgeRemoved',FB.bind(this._onEdgeRemove,this));this.subscribe('xd.presentEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogPresentation,this));this.subscribe('xd.dismissEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogDismissal,this));this.subscribe('xd.hideEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogHide,this));this.subscribe('xd.showEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogShow,this));},getSize:function(){return {width:this._getWidgetWidth(),height:this._getWidgetHeight()};},_getWidgetHeight:function(){var a=this._getLayout();var c=this._shouldShowFaces()?'show':'hide';var b={standard:{show:80,hide:35},box_count:{show:65,hide:65},button_count:{show:21,hide:21}};return b[a][c];},_getWidgetWidth:function(){var e=this._getLayout();var g=this._shouldShowFaces()?'show':'hide';var c=this.getAttribute('action')==='recommend'?130:90;var b=this.getAttribute('action')==='recommend'?100:55;var f={standard:{show:450,hide:450},box_count:{show:b,hide:b},button_count:{show:c,hide:c}};var d=f[e][g];var h=this._getPxAttribute('width',d);var a={standard:{min:225,max:900},box_count:{min:b,max:900},button_count:{min:c,max:900}};if(ha[e].max)h=a[e].max;return h;},_getLayout:function(){return this._getAttributeFromList('layout','standard',['standard','button_count','box_count']);},_shouldShowFaces:function(){return this._getLayout()==='standard'&&this._getBoolAttribute('show-faces',true);},_handleEdgeCommentDialogPresentation:function(b){if(!this.isValid())return;var a=document.createElement('span');this._commentSlave=this._createEdgeCommentWidget(b,a);this.dom.appendChild(a);this._commentSlave.process();this._commentWidgetNode=a;},_createEdgeCommentWidget:function(b,a){var c={commentNode:a,externalUrl:b.externalURL,width:330,height:200,masterFrameName:b.masterFrameName,layout:this._getLayout(),relativeHeightOffset:this._getHeightOffset(),relativeWidthOffset:this._getWidthOffset(b)};return new FB.XFBML.EdgeCommentWidget(c);},_getHeightOffset:function(){var a=this._getLayout();var b={standard:'20px',button_count:'17px',box_count:'-5px'};return b[a];},_getWidthOffset:function(c){if(c.preComputedWidthOffset)return parseInt(c.preComputedWidthOffset,10)+'px';var a=this._getLayout();var b={standard:'17px',box_count:'0px',button_count:'0px'};return b[a];},_handleEdgeCommentDialogDismissal:function(a){if(this._commentWidgetNode){this.dom.removeChild(this._commentWidgetNode);delete this._commentWidgetNode;}},_handleEdgeCommentDialogHide:function(){if(this._commentWidgetNode)this._commentWidgetNode.style.display="none";},_handleEdgeCommentDialogShow:function(){if(this._commentWidgetNode)this._commentWidgetNode.style.display="block";},_fireEventAndInvokeHandler:function(b,a){FB.Helper.fireEvent(b,this);FB.Helper.invokeHandler(this.getAttribute(a),this,[this._attr.href]);},_onEdgeCreate:function(){this._fireEventAndInvokeHandler('edge.create','on-create');},_onEdgeRemove:function(){this._fireEventAndInvokeHandler('edge.remove','on-remove');}}); -FB.subclass('XFBML.Like','XFBML.EdgeWidget',null,{getUrlBits:function(){return {name:'like',params:this._attr};},getIframeTitle:function(){return 'Like this content on Facebook.';}}); -FB.subclass('XFBML.LikeBox','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={channel:this.getChannelUrl(),api_key:FB._apiKey,connections:this.getAttribute('connections'),css:this.getAttribute('css'),height:this.getAttribute('height'),id:this.getAttribute('profile-id'),header:this._getBoolAttribute('header',true),name:this.getAttribute('name'),show_faces:this._getBoolAttribute('show-faces',true),stream:this._getBoolAttribute('stream',true),width:this._getPxAttribute('width',300),href:this.getAttribute('href'),colorscheme:this.getAttribute('colorscheme','light')};if(this._attr.connections==='0'){this._attr.show_faces=false;}else if(this._attr.connections)this._attr.show_faces=true;if(!this._attr.id&&!this._attr.name&&!this._attr.href){FB.log(' requires one of the "id" or "name" attributes.');return false;}var a=this._attr.height;if(!a)if(!this._attr.show_faces&&!this._attr.stream){a=62;}else{a=95;if(this._attr.show_faces)a+=163;if(this._attr.stream)a+=300;if(this._attr.header&&this._attr.header!=='0')a+=32;}this._attr.height=a;this.subscribe('xd.likeboxLiked',FB.bind(this._onLiked,this));this.subscribe('xd.likeboxUnliked',FB.bind(this._onUnliked,this));return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'likebox',params:this._attr};},_onLiked:function(){FB.Helper.fireEvent('edge.create',this);},_onUnliked:function(){FB.Helper.fireEvent('edge.remove',this);}}); -FB.subclass('XFBML.LiveStream','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={height:this._getPxAttribute('height',500),hideFriendsTab:this.getAttribute('hide-friends-tab'),redesigned:this._getBoolAttribute('redesigned-stream'),width:this._getPxAttribute('width',400),xid:this.getAttribute('xid','default'),always_post_to_friends:this._getBoolAttribute('always-post-to-friends',false)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){var a=this._attr.redesigned?'live_stream_box':'livefeed';return {name:a,params:this._attr};}}); -FB.subclass('XFBML.Login','XFBML.Facepile',null,{_visibleAfter:'load',getSize:function(){return {width:this._attr.width,height:94};},getUrlBits:function(){return {name:'login',params:this._attr};}}); -FB.subclass('XFBML.LoginButton','XFBML.ButtonElement',null,{setupAndValidate:function(){if(this._alreadySetup)return true;this._alreadySetup=true;this._attr={autologoutlink:this._getBoolAttribute('auto-logout-link'),length:this._getAttributeFromList('length','short',['long','short']),onlogin:this.getAttribute('on-login'),perms:this.getAttribute('perms'),registration_url:this.getAttribute('registration-url'),status:'unknown'};if(this._attr.autologoutlink)FB.Event.subscribe('auth.statusChange',FB.bind(this.process,this));if(this._attr.registration_url){FB.Event.subscribe('auth.statusChange',this._saveStatus(this.process));FB.getLoginStatus(this._saveStatus(this.process));}return true;},getButtonMarkup:function(){var a=this.getOriginalHTML();if(a)return a;if(!this._attr.registration_url){if(FB.getSession()&&this._attr.autologoutlink){return FB.Intl._tx("Facebook Logout");}else return this._getLoginText();}else switch(this._attr.status){case 'unknown':return this._getLoginText();case 'notConnected':return FB.Intl._tx("Register");case 'connected':if(FB.getSession()&&this._attr.autologoutlink)return FB.Intl._tx("Facebook Logout");return this._getLoginText();default:FB.log('Unknown status: '+this.status);return FB.Intl._tx("Login");}},_getLoginText:function(){return this._attr.length=='short'?FB.Intl._tx("Login"):FB.Intl._tx("Login with Facebook");},onClick:function(){if(!this._attr.registration_url){if(!FB.getSession()||!this._attr.autologoutlink){FB.login(FB.bind(this._authCallback,this),{perms:this._attr.perms});}else FB.logout(FB.bind(this._authCallback,this));}else switch(this._attr.status){case 'unknown':FB.ui({method:'auth.loginToFacebook'},FB.bind(function(a){FB.getLoginStatus(this._saveStatus(this._authCallback),true);},this));break;case 'notConnected':window.top.location=this._attr.registration_url;break;case 'connected':if(!FB.getSession()||!this._attr.autologoutlink){this._authCallback();}else FB.logout(FB.bind(this._authCallback,this));break;default:FB.log('Unknown status: '+this.status);}},_authCallback:function(a){FB.Helper.invokeHandler(this._attr.onlogin,this,[a]);},_saveStatus:function(a){return FB.bind(function(b){this._attr.status=b.status;if(a){a=this.bind(a,this);return a(b);}},this);}}); -FB.subclass('XFBML.Name','XFBML.Element',null,{process:function(){FB.copy(this,{_uid:this.getAttribute('uid'),_firstnameonly:this._getBoolAttribute('first-name-only'),_lastnameonly:this._getBoolAttribute('last-name-only'),_possessive:this._getBoolAttribute('possessive'),_reflexive:this._getBoolAttribute('reflexive'),_objective:this._getBoolAttribute('objective'),_linked:this._getBoolAttribute('linked',true),_subjectId:this.getAttribute('subject-id')});if(!this._uid){FB.log('"uid" is a required attribute for ');this.fire('render');return;}var b=[];if(this._firstnameonly){b.push('first_name');}else if(this._lastnameonly){b.push('last_name');}else b.push('name');if(this._subjectId){b.push('sex');if(this._subjectId==FB.Helper.getLoggedInUser())this._reflexive=true;}var a;FB.Event.monitor('auth.statusChange',this.bind(function(){if(!this.isValid()){this.fire('render');return true;}if(!this._uid||this._uid=='loggedinuser')this._uid=FB.Helper.getLoggedInUser();if(!this._uid)return;if(FB.Helper.isUser(this._uid)){a=FB.Data._selectByIndex(b,'user','uid',this._uid);}else a=FB.Data._selectByIndex(['name','id'],'profile','id',this._uid);a.wait(this.bind(function(c){if(this._subjectId==this._uid){this._renderPronoun(c[0]);}else this._renderOther(c[0]);this.fire('render');}));}));},_renderPronoun:function(b){var c='',a=this._objective;if(this._subjectId){a=true;if(this._subjectId===this._uid)this._reflexive=true;}if(this._uid==FB.Connect.get_loggedInUser()&&this._getBoolAttribute('use-you',true)){if(this._possessive){if(this._reflexive){c='your own';}else c='your';}else if(this._reflexive){c='yourself';}else c='you';}else switch(b.sex){case 'male':if(this._possessive){c=this._reflexive?'his own':'his';}else if(this._reflexive){c='himself';}else if(a){c='him';}else c='he';break;case 'female':if(this._possessive){c=this._reflexive?'her own':'her';}else if(this._reflexive){c='herself';}else if(a){c='her';}else c='she';break;default:if(this._getBoolAttribute('use-they',true)){if(this._possessive){if(this._reflexive){c='their own';}else c='their';}else if(this._reflexive){c='themselves';}else if(a){c='them';}else c='they';}else if(this._possessive){if(this._reflexive){c='his/her own';}else c='his/her';}else if(this._reflexive){c='himself/herself';}else if(a){c='him/her';}else c='he/she';break;}if(this._getBoolAttribute('capitalize',false))c=FB.Helper.upperCaseFirstChar(c);this.dom.innerHTML=c;},_renderOther:function(c){if(!c)return;var b='',a='';if(this._uid==FB.Helper.getLoggedInUser()&&this._getBoolAttribute('use-you',true)){if(this._reflexive){if(this._possessive){b='your own';}else b='yourself';}else if(this._possessive){b='your';}else b='you';}else{if(null===c.first_name)c.first_name='';if(null===c.last_name)c.last_name='';if(this._firstnameonly){b=FB.String.escapeHTML(c.first_name);}else if(this._lastnameonly)b=FB.String.escapeHTML(c.last_name);if(!b)b=FB.String.escapeHTML(c.name);if(b!==''&&this._possessive)b+='\'s';}if(!b)b=FB.String.escapeHTML(this.getAttribute('if-cant-see','Facebook User'));if(b){if(this._getBoolAttribute('capitalize',false))b=FB.Helper.upperCaseFirstChar(b);if(this._linked){a=FB.Helper.getProfileLink(c,b,this.getAttribute('href',null));}else a=b;}this.dom.innerHTML=a;}}); -FB.subclass('XFBML.ProfilePic','XFBML.Element',null,{process:function(){var d=this.getAttribute('size','thumb'),b=FB.XFBML.ProfilePic._sizeToPicFieldMap[d],g=this._getPxAttribute('width'),a=this._getPxAttribute('height'),e=this.dom.style,f=this.getAttribute('uid');if(this._getBoolAttribute('facebook-logo'))b+='_with_logo';if(g){g=g+'px';e.width=g;}if(a){a=a+'px';e.height=a;}var c=this.bind(function(j){var l=j?j[0]:null,i=l?l[b]:null;if(!i)i=FB.getDomain('cdn')+FB.XFBML.ProfilePic._defPicMap[b];var k=((g?'width:'+g+';':'')+(a?'height:'+g+';':'')),h=FB.String.format('{1}',i,l?FB.String.escapeHTML(l.name):'',k,this.dom.className);if(this._getBoolAttribute('linked',true))h=FB.Helper.getProfileLink(l,h,this.getAttribute('href',null));this.dom.innerHTML=h;FB.Dom.addCss(this.dom,'fb_profile_pic_rendered');this.fire('render');});FB.Event.monitor('auth.statusChange',this.bind(function(){if(!this.isValid()){this.fire('render');return true;}if(this.getAttribute('uid',null)=='loggedinuser')f=FB.Helper.getLoggedInUser();if(FB._userStatus&&f){FB.Data._selectByIndex(['name',b],FB.Helper.isUser(f)?'user':'profile',FB.Helper.isUser(f)?'uid':'id',f).wait(c);}else c();}));}});FB.provide('XFBML.ProfilePic',{_defPicMap:{pic:'pics/s_silhouette.jpg',pic_big:'pics/d_silhouette.gif',pic_big_with_logo:'pics/d_silhouette_logo.gif',pic_small:'pics/t_silhouette.jpg',pic_small_with_logo:'pics/t_silhouette_logo.gif',pic_square:'pics/q_silhouette.gif',pic_square_with_logo:'pics/q_silhouette_logo.gif',pic_with_logo:'pics/s_silhouette_logo.gif'},_sizeToPicFieldMap:{n:'pic_big',normal:'pic_big',q:'pic_square',s:'pic',small:'pic',square:'pic_square',t:'pic_small',thumb:'pic_small'}}); -FB.subclass('XFBML.Recommendations','XFBML.IframeWidget',null,{_visibleAfter:'load',_refreshOnAuthChange:true,setupAndValidate:function(){this._attr={border_color:this.getAttribute('border-color'),colorscheme:this.getAttribute('color-scheme'),filter:this.getAttribute('filter'),font:this.getAttribute('font'),header:this._getBoolAttribute('header'),height:this._getPxAttribute('height',300),site:this.getAttribute('site',location.hostname),width:this._getPxAttribute('width',300)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'recommendations',params:this._attr};}}); -FB.subclass('XFBML.Registration','XFBML.IframeWidget',null,{_visibleAfter:'immediate',_baseHeight:167,_fieldHeight:28,_skinnyWidth:520,_skinnyBaseHeight:173,_skinnyFieldHeight:52,setupAndValidate:function(){this._attr={channel_url:this.getChannelUrl(),client_id:FB._apiKey,fb_only:this._getBoolAttribute('fb-only',false),fields:this.getAttribute('fields'),height:this._getPxAttribute('height'),redirect_uri:this.getAttribute('redirect-uri',window.location.href),onvalidate:this.getAttribute('onvalidate'),width:this._getPxAttribute('width',600)};if(this._attr.onvalidate)this.subscribe('xd.validate',this.bind(function(b){var d=FB.JSON.parse(b.value);var a=this.bind(function(e){FB.Arbiter.inform('Registration.Validation',{errors:e,id:b.id},'parent.frames["'+this.getIframeNode().name+'"]');});var c=FB.Helper.executeFunctionByName(this._attr.onvalidate,d,a);if(c)a(c);}));return true;},getSize:function(){return {width:this._attr.width,height:this._getHeight()};},_getHeight:function(){if(this._attr.height)return this._attr.height;var b;if(!this._attr.fields){b=['name'];}else try{b=FB.JSON.parse(this._attr.fields);}catch(a){b=this._attr.fields.split(/,/);}if(this._attr.width requires the "fbml" attribute.');return false;}return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'serverfbml',params:this._attr};}}); -FB.subclass('XFBML.ShareButton','XFBML.Element',null,{process:function(){this._href=this.getAttribute('href',window.location.href);this._type=this.getAttribute('type','icon_link');FB.Dom.addCss(this.dom,'fb_share_count_hidden');this._renderButton(true);},_renderButton:function(f){if(!this.isValid()){this.fire('render');return;}var b='',c='',d='',a='',e=FB.Intl._tx("Share"),g='';switch(this._type){case 'icon':case 'icon_link':a='fb_button_simple';b=(''+(this._type=='icon_link'?e:' ')+'');f=false;break;case 'link':b=FB.Intl._tx("Share on Facebook");f=false;break;case 'button':b=''+e+'';a='fb_button fb_button_small';f=false;break;case 'button_count':b=''+e+'';c=(' '+''+this._getCounterMarkup()+'');a='fb_button fb_button_small';break;default:b=''+e+'';d=(' '+''+this._getCounterMarkup()+'');a='fb_button fb_button_small';g='fb_share_count_wrapper';}this.dom.innerHTML=FB.String.format('{4}{3}{5}',g,this._href,a,b,d,c,FB.JSON.stringify({method:'stream.share',u:this._href}));if(!f)this.fire('render');},_getCounterMarkup:function(){if(!this._count)this._count=FB.Data._selectByIndex(['total_count'],'link_stat','url',this._href);var b='0';if(this._count.value!==undefined){if(this._count.value.length>0){var a=this._count.value[0].total_count;if(a>3){FB.Dom.removeCss(this.dom,'fb_share_count_hidden');b=a>=1e+07?Math.round(a/1e+06)+'M':(a>=10000?Math.round(a/1000)+'K':a);}}}else this._count.wait(FB.bind(this._renderButton,this,false));return ''+b+'';}}); -void(0); - - -FB.provide("", {"_domain":{"api":"https:\/\/api.facebook.com\/","api_read":"https:\/\/api-read.facebook.com\/","cdn":"http:\/\/static.ak.fbcdn.net\/","graph":"https:\/\/graph.facebook.com\/","https_cdn":"https:\/\/s-static.ak.fbcdn.net\/","https_staticfb":"https:\/\/s-static.ak.facebook.com\/","https_www":"https:\/\/www.facebook.com\/","staticfb":"http:\/\/static.ak.facebook.com\/","www":"http:\/\/www.facebook.com\/"},"_locale":"en_US","_localeIsRtl":false}, true); -FB.provide("Flash", {"_minVersions":[[10,0,22,87]],"_swfPath":"rsrc.php\/v1\/yF\/r\/Y7YCBKX-HZn.swf"}, true); -FB.provide("XFBML.ConnectBar", {"imgs":{"buttonUrl":"rsrc.php\/yY\/r\/h_Y6u1wrZPW.png","missingProfileUrl":"rsrc.php\/yo\/r\/UlIqmHJn-SK.gif"}}, true); -FB.provide("XFBML.ProfilePic", {"_defPicMap":{"pic":"rsrc.php\/yh\/r\/C5yt7Cqf3zU.jpg","pic_big":"rsrc.php\/yL\/r\/HsTZSDw4avx.gif","pic_big_with_logo":"rsrc.php\/y5\/r\/SRDCaeCL7hM.gif","pic_small":"rsrc.php\/yi\/r\/odA9sNLrE86.jpg","pic_small_with_logo":"rsrc.php\/yD\/r\/k1xiRXKnlGd.gif","pic_square":"rsrc.php\/yo\/r\/UlIqmHJn-SK.gif","pic_square_with_logo":"rsrc.php\/yX\/r\/9dYJBPDHXwZ.gif","pic_with_logo":"rsrc.php\/yu\/r\/fPPR9f2FJ3t.gif"}}, true); -if (FB.Dom && FB.Dom.addCssRules) { FB.Dom.addCssRules(".fb_hidden{position:absolute;top:-10000px;z-index:10001}\n.fb_reset{background:none;border-spacing:0;border:0;color:#000;cursor:auto;direction:ltr;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;font-size:11px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal}\n.fb_link img{border:none}\n.fb_dialog{position:absolute;top:-10000px;z-index:10001}\n.fb_dialog_advanced{background:rgba(82, 82, 82, .7);padding:10px;-moz-border-radius:8px;-webkit-border-radius:8px}\n.fb_dialog_content{background:#fff;color:#333}\n.fb_dialog_close_icon{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 0 transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif);cursor:pointer;display:block;height:15px;position:absolute;right:18px;top:17px;width:15px;top:8px\\9;right:7px\\9}\n.fb_dialog_close_icon:hover{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -15px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif)}\n.fb_dialog_close_icon:active{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -30px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif)}\n.fb_dialog_loader{background-color:#f2f2f2;border:1px solid #606060;font-size:24px;padding:20px}\n.fb_dialog_top_left,\n.fb_dialog_top_right,\n.fb_dialog_bottom_left,\n.fb_dialog_bottom_right{height:10px;width:10px;overflow:hidden;position:absolute}\n.fb_dialog_top_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 0;left:-10px;top:-10px}\n.fb_dialog_top_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -10px;right:-10px;top:-10px}\n.fb_dialog_bottom_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -20px;bottom:-10px;left:-10px}\n.fb_dialog_bottom_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -30px;right:-10px;bottom:-10px}\n.fb_dialog_vert_left,\n.fb_dialog_vert_right,\n.fb_dialog_horiz_top,\n.fb_dialog_horiz_bottom{position:absolute;background:#525252;filter:alpha(opacity=70);opacity:.7}\n.fb_dialog_vert_left,\n.fb_dialog_vert_right{width:10px;height:100\u0025}\n.fb_dialog_vert_left{margin-left:-10px}\n.fb_dialog_vert_right{right:0;margin-right:-10px}\n.fb_dialog_horiz_top,\n.fb_dialog_horiz_bottom{width:100\u0025;height:10px}\n.fb_dialog_horiz_top{margin-top:-10px}\n.fb_dialog_horiz_bottom{bottom:0;margin-bottom:-10px}\n.fb_dialog_iframe{line-height:0}\n.fb_dialog_content .dialog_title{background:#6d84b4;border:1px solid #3b5998;color:#fff;font-size:14px;font-weight:bold;margin:0}\n.fb_dialog_content .dialog_title > span{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zd\/r\/Cou7n-nqK52.gif) no-repeat 5px 50\u0025;float:left;padding:5px 0 7px 26px}\n.fb_dialog_content .dialog_content{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/z9\/r\/jKEcVPZFk-2.gif) no-repeat 50\u0025 50\u0025;border:1px solid #555;border-bottom:0;border-top:0;height:150px}\n.fb_dialog_content .dialog_footer{background:#f2f2f2;border:1px solid #555;border-top-color:#ccc;height:40px}\n#fb_dialog_loader_close{float:right}\n.fb_iframe_widget{position:relative;display:-moz-inline-block;display:inline-block}\n.fb_iframe_widget iframe{position:relative;vertical-align:text-bottom}\n.fb_iframe_widget span{position:relative}\n.fb_hide_iframes iframe{position:relative;left:-10000px}\n.fb_iframe_widget_loader{position:relative;display:inline-block}\n.fb_iframe_widget_loader iframe{min-height:32px;z-index:2;zoom:1}\n.fb_iframe_widget_loader .FB_Loader{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/z9\/r\/jKEcVPZFk-2.gif) no-repeat;height:32px;width:32px;margin-left:-16px;position:absolute;left:50\u0025;z-index:4}\n.fb_button_simple,\n.fb_button_simple_rtl{background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zH\/r\/eIpbnVKI9lR.png);background-repeat:no-repeat;cursor:pointer;outline:none;text-decoration:none}\n.fb_button_simple_rtl{background-position:right 0}\n.fb_button_simple .fb_button_text{margin:0 0 0 20px;padding-bottom:1px}\n.fb_button_simple_rtl .fb_button_text{margin:0 10px 0 0}\na.fb_button_simple:hover .fb_button_text,\na.fb_button_simple_rtl:hover .fb_button_text,\n.fb_button_simple:hover .fb_button_text,\n.fb_button_simple_rtl:hover .fb_button_text{text-decoration:underline}\n.fb_button,\n.fb_button_rtl{background:#29447e url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/FGFbc80dUKj.png);background-repeat:no-repeat;cursor:pointer;display:inline-block;padding:0 0 0 1px;text-decoration:none;outline:none}\n.fb_button .fb_button_text,\n.fb_button_rtl .fb_button_text{background:#5f78ab url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/FGFbc80dUKj.png);border-top:solid 1px #879ac0;border-bottom:solid 1px #1a356e;color:#fff;display:block;font-family:\"lucida grande\",tahoma,verdana,arial,sans-serif;font-weight:bold;padding:2px 6px 3px 6px;margin:1px 1px 0 21px;text-shadow:none}\na.fb_button,\na.fb_button_rtl,\n.fb_button,\n.fb_button_rtl{text-decoration:none}\na.fb_button:active .fb_button_text,\na.fb_button_rtl:active .fb_button_text,\n.fb_button:active .fb_button_text,\n.fb_button_rtl:active .fb_button_text{border-bottom:solid 1px #29447e;border-top:solid 1px #45619d;background:#4f6aa3;text-shadow:none}\n.fb_button_xlarge,\n.fb_button_xlarge_rtl{background-position:left -60px;font-size:24px;line-height:30px}\n.fb_button_xlarge .fb_button_text{padding:3px 8px 3px 12px;margin-left:38px}\na.fb_button_xlarge:active{background-position:left -99px}\n.fb_button_xlarge_rtl{background-position:right -268px}\n.fb_button_xlarge_rtl .fb_button_text{padding:3px 8px 3px 12px;margin-right:39px}\na.fb_button_xlarge_rtl:active{background-position:right -307px}\n.fb_button_large,\n.fb_button_large_rtl{background-position:left -138px;font-size:13px;line-height:16px}\n.fb_button_large .fb_button_text{margin-left:24px;padding:2px 6px 4px 6px}\na.fb_button_large:active{background-position:left -163px}\n.fb_button_large_rtl{background-position:right -346px}\n.fb_button_large_rtl .fb_button_text{margin-right:25px}\na.fb_button_large_rtl:active{background-position:right -371px}\n.fb_button_medium,\n.fb_button_medium_rtl{background-position:left -188px;font-size:11px;line-height:14px}\na.fb_button_medium:active{background-position:left -210px}\n.fb_button_medium_rtl{background-position:right -396px}\n.fb_button_text_rtl,\n.fb_button_medium_rtl .fb_button_text{padding:2px 6px 3px 6px;margin-right:22px}\na.fb_button_medium_rtl:active{background-position:right -418px}\n.fb_button_small,\n.fb_button_small_rtl{background-position:left -232px;font-size:10px;line-height:10px}\n.fb_button_small .fb_button_text{padding:2px 6px 3px;margin-left:17px}\na.fb_button_small:active,\n.fb_button_small:active{background-position:left -250px}\n.fb_button_small_rtl{background-position:right -440px}\n.fb_button_small_rtl .fb_button_text{padding:2px 6px;margin-right:18px}\na.fb_button_small_rtl:active{background-position:right -458px}\n.fb_connect_bar_container div,\n.fb_connect_bar_container span,\n.fb_connect_bar_container a,\n.fb_connect_bar_container img,\n.fb_connect_bar_container strong{background:none;border-spacing:0;border:0;direction:ltr;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal;vertical-align:baseline}\n.fb_connect_bar_container{position:fixed;left:0 !important;right:0 !important;height:42px !important;padding:0 25px !important;margin:0 !important;vertical-align:middle !important;border-bottom:1px solid #333 !important;background:#3b5998 !important;z-index:99999999 !important;overflow:hidden !important}\n.fb_connect_bar_container_ie6{position:absolute;top:expression(document.compatMode==\"CSS1Compat\"? document.documentElement.scrollTop+\"px\":body.scrollTop+\"px\")}\n.fb_connect_bar{position:relative;margin:auto;height:100\u0025;width:100\u0025;padding:6px 0 0 0 !important;background:none;color:#fff !important;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif !important;font-size:13px !important;font-style:normal !important;font-variant:normal !important;font-weight:normal !important;letter-spacing:normal !important;line-height:1 !important;text-decoration:none !important;text-indent:0 !important;text-shadow:none !important;text-transform:none !important;white-space:normal !important;word-spacing:normal !important}\n.fb_connect_bar a:hover{color:#fff}\n.fb_connect_bar .fb_profile img{height:30px;width:30px;vertical-align:middle;margin:0 6px 5px 0}\n.fb_connect_bar div a,\n.fb_connect_bar span,\n.fb_connect_bar span a{color:#bac6da;font-size:11px;text-decoration:none}\n.fb_connect_bar .fb_buttons{float:right;margin-top:7px}\n.fb_edge_widget_with_comment{position:relative;*z-index:1000}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget{position:absolute}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_ltr{left:-4px}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_rtl{left:2px}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget{left:0}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget .FB_Loader{left:10\u0025}\n.fb_share_count_wrapper{position:relative;float:left}\n.fb_share_count{background:#b0b9ec none repeat scroll 0 0;color:#333;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;text-align:center}\n.fb_share_count_inner{background:#e8ebf2;display:block}\n.fb_share_count_right{margin-left:-1px;display:inline-block}\n.fb_share_count_right .fb_share_count_inner{border-top:solid 1px #e8ebf2;border-bottom:solid 1px #b0b9ec;margin:1px 1px 0 1px;font-size:10px;line-height:10px;padding:2px 6px 3px;font-weight:bold}\n.fb_share_count_top{display:block;letter-spacing:-1px;line-height:34px;margin-bottom:7px;font-size:22px;border:solid 1px #b0b9ec}\n.fb_share_count_nub_top{border:none;display:block;position:absolute;left:7px;top:35px;margin:0;padding:0;width:6px;height:7px;background-repeat:no-repeat;background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zU\/r\/bSOHtKbCGYI.png)}\n.fb_share_count_nub_right{border:none;display:inline-block;padding:0;width:5px;height:10px;background-repeat:no-repeat;background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zX\/r\/i_oIVTKMYsL.png);vertical-align:top;background-position:right 5px;z-index:10;left:2px;margin:0 2px 0 0;position:relative}\n.fb_share_no_count{display:none}\n.fb_share_size_Small .fb_share_count_right .fb_share_count_inner{font-size:10px}\n.fb_share_size_Medium .fb_share_count_right .fb_share_count_inner{font-size:11px;padding:2px 6px 3px;letter-spacing:-1px;line-height:14px}\n.fb_share_size_Large .fb_share_count_right .fb_share_count_inner{font-size:13px;line-height:16px;padding:2px 6px 4px;font-weight:normal;letter-spacing:-1px}\n.fb_share_count_hidden .fb_share_count_nub_top,\n.fb_share_count_hidden .fb_share_count_top,\n.fb_share_count_hidden .fb_share_count_nub_right,\n.fb_share_count_hidden .fb_share_count_right{visibility:hidden}\n", ["fb.css.base","fb.css.dialog","fb.css.iframewidget","fb.css.button","fb.css.connectbarwidget","fb.css.edgecommentwidget","fb.css.sendbuttonformwidget","fb.css.sharebutton"]); } \ No newline at end of file diff --git a/game/fb/animated_image.js b/game/fb/animated_image.js deleted file mode 100644 index fbec113..0000000 --- a/game/fb/animated_image.js +++ /dev/null @@ -1,93 +0,0 @@ -// Manages an animated image. Assumes that while it is active, -// get_image is called once per game loop -// Defaults to starting immediately -// Unless you call loop, will only run through the images once -// spec: -// All optional -// anim_rate : the number of frames to display each image -// reverse : whether to go backwards in the images when you reach the end or not - -var animated_image = function(image_name, spec) { - - // obj to return - var obj = []; - - // private vars - - var all_images = image_manager.get_images(image_name); - all_images.sort( - function(i1, i2) { - //return i1.path < i2.path; - return i1.path < i2.path ? -1 : (i1.path > i2.path ? 1 : 0); - } - ); - //for_each(all_images, function(i) { console.log(i.path); }); - var curr_index = 0; - var active = true; - var loop = false; - var rate_counter = 0; // Goes from 0 to anim_rate - 1 - var anim_rate = spec.anim_rate || 3; - - // If we are reversing, add all the images in the opposite - // order to all_images - if (spec.reverse || false) { - for (var i = (all_images.length - 1); i >=0; i--) { - all_images.push(all_images[i]); - } - } - - //public methods - - obj.start = function() { - active = true; - }; - - obj.pause = function() { - active = false; - }; - - obj.loop = function() { - loop = true; - }; - - obj.is_finished = function() { - // changed to && cuz it should be not looping - // and at the end to be finished - return (!loop && curr_index === (all_images.length - 1)); - }; - - // Returns the current image - obj.get_frame = function() { - var curr_image = all_images[curr_index].image; - update(); - return curr_image; - }; - - obj.set_rate = function(r) { - anim_rate = r; - }; - - // private methods - - var update = function() { - if (active) { - if (rate_counter >= (anim_rate - 1)) { - next_frame(); - rate_counter = 0; - } - else { - rate_counter++; - } - } - }; - - var next_frame = function() { - // If not 'at the end and not looping', - // increment curr_index, restarting if we reach the end - if (!(curr_index === all_images.length && !loop)) { - curr_index = (curr_index + 1) % all_images.length; - } - } - - return obj; -} diff --git a/game/fb/antibody.js b/game/fb/antibody.js deleted file mode 100644 index 4537cf0..0000000 --- a/game/fb/antibody.js +++ /dev/null @@ -1,86 +0,0 @@ -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards - -var antibody = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 11; - spec.height = spec.height || 7; - spec.speed = (spec.speed || 4) * g_speed_factor; - spec.no_target_speed = (spec.no_target_speed || 2) * g_speed_factor; - - //spec.vel = random_vel(); - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "antibody"; - }; - - // --- private variables --- - - // flag denoting whether the antibody is attached to a cell - var attached = false; - - // --- public methods --- - - // should be called when an antibody attaches to a cell - // tar will be the cell that it is attaching to (may not be its target) - obj.attach = function(tar) { - attached = true; - obj.face_target(tar); - // scoot it out just a bit - obj.get_vel().mult(-1); - obj.move(); - - //obj.set_target(null); - }; - - // implementing game_object interface - - obj.my_update = function() { - if (!attached) { - obj.set_speed(obj.get_level() / 4 + 1) - obj.move(); - // don't want two antibodies attacking one cell - var tar = obj.get_target(); - if (tar && (tar.has_antibody() - // also don't want them to keep target - // if the target changes level - || tar.get_level() !== obj.get_level() - // or if it starts to die - || tar.get_state() === "dying")) { - obj.set_target(null); - } - } - }; - - // should point towards target - // Y-shaped (top of Y is front) - obj.draw = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.stroke(obj.get_color()); - p.strokeWeight(2); - - p.line(-w, 0, w/3, 0); - p.line(w/3, 0, w, h/2); - p.line(w/3, 0, w, -h/2); - - p.popMatrix(); - }; - - return obj; -} diff --git a/game/fb/b_cell.js b/game/fb/b_cell.js deleted file mode 100644 index a40c5e0..0000000 --- a/game/fb/b_cell.js +++ /dev/null @@ -1,254 +0,0 @@ -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards -// state = just leave to be default (alive) - -var b_cell = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 30; - spec.height = spec.height || 30; - spec.speed = (spec.speed || 5) * g_speed_factor; - - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "b_cell"; - }; - - // --- private variables --- - - var b_anim = animated_image("bcell", {reverse : true}); - // for illustration - var b_image = image_manager.get_image("bcell_normal.png"); - // where to go and shoot from - var slot = null; - - // state can be "alive", "active", "shooting", "outdated" - - // Antibodies are created in update, and returned in get_antibodies() - var new_antibodies = null; - - // --- private methods - - // Makes one antibody and adds it to new_antibodies - var make_antibody = function() { - if (!new_antibodies) { - new_antibodies = []; - } - var obj_pos = obj.get_pos(); - var new_antibody = antibody(p, { - pos : new p.PVector(obj_pos.x, obj_pos.y + (obj.get_height() / 2)), - mutation_info: obj.get_mutation_info() - }); - new_antibodies.push(new_antibody); - return new_antibody; - }; - - - // --- public methods --- - - // Makes this target stop and begin producing antibodies - obj.make_antibodies = function() { - obj.set_state("shooting"); - obj.set_target(null); - // production will happen in update - }; - - // to be called on collision with floater - // takes a slot pos - obj.activate = function(aslot) { - obj.set_state("active"); - slot = aslot; - // send the bcell to the top - obj.set_target(game_object(p, { - pos: slot.pos //new p.PVector(p.width - (obj.get_width() / 2), 0) - })); - }; - - obj.get_slot = function() { - return slot; - }; - - // Returns any newly created antibodies - obj.get_antibodies = function() { - if (new_antibodies) { - var to_return = new_antibodies; - new_antibodies = null; - return to_return; - } - else { - return []; - } - }; - - obj.is_activated = function() { - return obj.get_state() === "active"; - }; - - obj.is_alive = function() { - return obj.get_state() === "alive"; - }; - - obj.is_shooting = function() { - return obj.get_state() === "shooting"; - }; - - obj.get_scroll_dist = function() { - var state = obj.get_state(); - if (state === "shooting" - //|| state === "alive" - || state === "active" ) { - return 0; - } - else if (state === "outdated") { - return obj.DEFAULT_SCROLL_DIST;// * 2; - } - else { - return obj.DEFAULT_SCROLL_DIST; - } - }; - - // implementing game_object interface - - obj.my_update = function() { - if (obj.get_state() === "shooting") { - //obj.stop(); - // make it face downwards - var angle = p.PI/2 - // switch if at bottom - if (!slot.is_top) { - angle = -p.PI/2; - } - obj.set_target_angle(angle); - if (Math.random() < .03) { - var new_anti = make_antibody(); - new_anti.set_target_angle(p.random(0, 2*angle)); - } - } - else { - obj.move(); - } - }; - - var draw_antibody = function() { - // private vars - var counter = 0; - var c_max = 30; - var ascending = true; - - // for illustrations - obj.set_anti_count = function(c) { - counter = c; - }; - - return function(){ - - p.pushMatrix(); - - var pos = obj.get_pos(); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - // Copied from antibody.js to avoid overhead of - // creating new antibody every time - p.stroke(obj.get_color()); - p.strokeWeight(1 + (counter / 6)); - - var w = 11; - var h = 7; - p.line(-w, 0, w / 3, 0); - p.line(w / 3, 0, w, h / 2); - p.line(w / 3, 0, w, -h / 2); - - p.popMatrix(); - - if (!anim_paused) { - if (ascending === true) { - counter++; - } - else if (ascending === false) { - counter--; - } - } - if (counter === c_max) { - ascending = false; - } - else if (counter === 0) { - ascending = true; - } - }; - }(); - - // should point towards target - // (triangle for now) - obj.draw = function() { - /* - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.fill(obj.get_color()); - // If outdated, draw differently? - if (obj.get_state() === "outdated") { - p.fill(0); - } - p.noStroke(); - - // rightward triangle - p.triangle(-w/2, -h/2, -w/2, h/2, w/2, 0); - - p.fill(255); - p.ellipse(-w/4, 0, 10, 10); - - p.popMatrix(); - */ - - p.pushMatrix(); - - var pos = obj.get_pos(); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle() + p.PI / 2); - p.fill(obj.get_color()); - p.noStroke(); - //p.rect(rectx_offset, recty_offset, rect_width, rect_height); - p.imageMode(obj.get_mode()); - - if (!obj.is_illustration()) { - b_image = b_anim.get_frame(); - } - p.image(b_image, 0, 0, obj.get_width(), obj.get_height()); - - p.popMatrix(); - - var state = obj.get_state(); - if (state === "active" || state === "shooting") { - draw_antibody(); - } - }; - - var anim_paused = false; - obj.stop_animation = function() { - b_anim.pause(); - anim_paused = true; - }; - - obj.resume_animation = function() { - b_anim.start(); - anim_paused = false; - }; - - return obj; -} diff --git a/game/fb/background_edge.js b/game/fb/background_edge.js deleted file mode 100644 index 6d8bb09..0000000 --- a/game/fb/background_edge.js +++ /dev/null @@ -1,54 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec -// boolean is_top = true if its a top edge, otherwise false -// - -var background_edge = function(p, spec) { - - //var background_image = p.loadImage("images/background.jpg"); - //var background_image = p.loadImage("images/background1.png"); - var edge = spec.is_top ? - image_manager.get_image("background_topside.png") : - image_manager.get_image("background_bottomside.png"); - - // --- defaults --- - - spec.mode = p.CORNERS; - spec.width = spec.width || edge.width; - spec.height = spec.height || edge.height; - - // if bottom, height should have been set to bottom of screen - // so we need to shift it up - if (!spec.is_top) { - spec.pos.add(new p.PVector(0, -spec.height)); - } - - // obj to return - var obj = background_object(p, spec); - - obj.get_type = function() { - return "background_edge"; - }; - - - // --- private variables --- - - - // --- public methods --- - - // override draw method only - obj.draw = function() { - p.imageMode(obj.get_mode()); - p.image(edge, obj.get_pos().x, obj.get_pos().y); - }; - - // override offscreen check cuz we draw from the corners - obj.is_offscreen = function() { - // only need to check left edge of screen - return obj.get_pos().x + obj.get_width() < 0; - }; - - return obj; -}; - diff --git a/game/fb/background_object.js b/game/fb/background_object.js deleted file mode 100644 index 0f96f4e..0000000 --- a/game/fb/background_object.js +++ /dev/null @@ -1,76 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec -// - -var background_object = function(p, spec) { - - var obj_image = random_from( - image_manager.get_images("background")).image; - - - // --- defaults --- - - spec.mode = spec.mode || p.CENTER; - spec.width = spec.width || obj_image.width; - spec.height = spec.height || obj_image.height; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "background_object"; - }; - - // --- private variables --- - - - // --- public methods --- - - // implementing game_object interface - - // update is default (move) - - // (flat rect for now) - obj.draw = function() { - //var x_pos = obj.get_pos().x; - - //p.fill(p.color(49, 0, 0)); - //p.rect(x_pos, 0, obj.get_width() - x_pos, obj.get_height()); - //background_image.resize(p.width, p.height); - //p.image(background_image, 0, 0); - //console.log(obj.get_pos().x); - p.imageMode(obj.get_mode()); - p.image(obj_image, obj.get_pos().x, obj.get_pos().y); - //p.set(obj.get_pos().x, 0, background_image); - //p.fill(255, 70); - //p.noStroke(); - //p.rect(obj.get_pos().x, 0, obj.get_width(), obj.get_height()); - }; - - // background can't go off screen or die - obj.is_dead = function() { - return false; - }; - /* - obj.is_offscreen = function() { - return false; - }; - */ - //var count = 0; - - obj.scroll = function(scroll_factor) { - // count += 1; - //if (count === 1) { - // count = 0; - obj.get_pos().add(new p.PVector(obj.get_scroll_dist(), 0)); - // } - }; - - obj.get_scroll_dist = function() { - return -1; - }; - - return obj; -}; - diff --git a/game/fb/button.js b/game/fb/button.js deleted file mode 100644 index 995dde5..0000000 --- a/game/fb/button.js +++ /dev/null @@ -1,122 +0,0 @@ -// Have a rectangle representing their position and a state to go to when clicked -// spec: -// state : function that returns a new state to go to when clicked -// (think of it like a thunk) -// rect : spec for a rectangle representing the button - -var button = function(p, spec) { - - // --- defaults --- - //spec.rect.width = spec.rect.width || 100; - //spec.rect.height = spec.rect.height || 35; - - // obj to return - var obj = {}; - - // --- private variables --- - - var next_state_fun = spec.state; - var active = spec.active || true; - - var image = spec.rect.image ? - image_manager.get_image(spec.rect.image) : null; - var over_image = spec.rect.over_image ? - image_manager.get_image(spec.rect.over_image) : null; - - // if no width is given but an image is - // use the image width - if (!spec.rect.width && image) { - spec.rect.width = image.width; - } - // and for height - if (!spec.rect.height && image) { - spec.rect.height = image.height; - } - - var rect = rectangle(p, spec.rect); - - // --- public methods --- - - obj.draw = function() { - if (!active) { - rect.set_tint(100); - /* - var r = spec.rect; - p.noStroke(); - p.fill(0, 150); - p.rectMode(p.CENTER); - p.rect(r.pos.x, r.pos.y, r.width, r.height); - */ - } - else { - //rect.set_tint(255); - } - rect.draw(); - }; - - // makes a button not active - obj.deactivate = function() { - // hack to make sure button tint updates - obj.mouse_moved(-1, -1); - active = false; - }; - - // makes a button active - obj.activate = function() { - // hack to make sure button tint updates - obj.mouse_moved(-1, -1); - active = true; - }; - - // Returns the state to go to if clicked, or - // null if not clicked - obj.is_clicked = function(x, y) { - if (active && rect.is_in(x, y)) { - // after click go back to normal image - if (over_image) { - rect.set_image(image); - } - return obj.get_state(); - } - else { - return null; - } - }; - - // special case for track buttons - obj.click = obj.is_clicked; - - obj.mouse_moved = function(x, y) { - if (active && rect.is_in(x, y)) { - if (over_image) { - rect.set_image(over_image); - } - else { - //rect.set_tint(0); - rect.set_tint(255, 255); - //rect.draw_twice(); - //console.log("tinting"); - } - } - else { - if (!over_image) { - rect.set_tint(200, 255); - } - //rect.draw_once(); - rect.set_image(image); - } - }; - // call once to init button tints - obj.mouse_moved(-1, -1); - - // Returns the state to go to - obj.get_state = function() { - return next_state_fun(); - }; - - obj.get_rect = function() { - return spec.rect; - }; - - return obj; -}; diff --git a/game/fb/cache.manifest-old b/game/fb/cache.manifest-old deleted file mode 100644 index 1fbb9e6..0000000 --- a/game/fb/cache.manifest-old +++ /dev/null @@ -1,9 +0,0 @@ -CACHE MANIFEST -#v .012 -CACHE: -sounds/cell_infect.wav -sounds/cell_fire.wav -#sounds/heart_loop1.mp3 -php_functions.php -NETWORK: -* diff --git a/game/fb/cell.js b/game/fb/cell.js deleted file mode 100644 index ebdcaaa..0000000 --- a/game/fb/cell.js +++ /dev/null @@ -1,345 +0,0 @@ -// *** cell *** -// --- inherits from game_object -// spec: -// game_object spec + -// String state = "alive" or "dead" or "infected" or "active" -// mutation : Mutation_obj so cell can get current mutation color - -var cell = function(p, spec) { - - // --- defaults --- - - // was 40 - spec.width = spec.width || 25; - spec.height = spec.height || 25; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "cell"; - }; - - // --- private variables --- - - // images - var cell_image = random_from( - image_manager.get_images("infectable_cell")).image; - var burst_anim = animated_image("burst", {}); - var infect_anim = animated_image("cell_infect", {}); - - // state can be "alive", "infected", "active", or "dead" - var state = spec.state || "alive"; - // random initial angle - var arrow_angle = p.random(-p.PI/2, p.PI/2); - // random dir (1 or -1) - var arrow_dir = p.random() >= 0.5 ? 1 : -1; - - // indicates whether has been hit by an arrow and is being targeted - //var is_targeted = false; - - // holds an antibody that is attached to the cell, or null - var anti = null; - - // --- public methods --- - - // implementing game_object interface - - // update is different depending on state - obj.update = function() { - obj.move(); - if (state === "alive") { - // just chill - } - else if (state === "infected") { - // still chill - } - else if (state === "active") { - // spin the arrow - rotateArrow(); - } - else if (state === "dying") { - if (burst_anim.is_finished()) { - obj.set_state("dead"); - } - } - /* - else if (state === "dead") { - } - */ - }; - - // draw makes a cell with a different color depending on state - // (circle for now) - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.get_mode()); - - p.noStroke(); - - if (state === "dying") { - // draw frame and advance anim - p.image(burst_anim.get_frame(), pos.x, pos.y, - obj.get_width(), obj.get_height()); - // skip the rest of the method - return; - } - - - if (state === "alive") { - p.fill(p.color(200, 50, 50)); - } - else { - if (state === "infected") { - p.fill(obj.get_color()); - // draw after drawing the image - } - else if (state === "active") { - drawArrow(); - - // Draw a separate circle for the red outline - // so that we can more accurately fill in the cell - // red outline for now - p.stroke(255, 0, 0); - p.strokeWeight(4); - p.ellipse(pos.x, pos.y, obj.get_width(), obj.get_height()); - - p.noStroke(); - p.fill(obj.get_color()); - } - //if (infect_anim.is_finished() || obj.is_illustration()) { - p.ellipse(pos.x, pos.y, obj.get_width() * 4/5, obj.get_height() * 4/5); - //} - } - - p.imageMode(obj.get_mode()); - p.image(cell_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - - if (state === "infected" || state === "active") { - // draw after the image - if (!infect_anim.is_finished() && !obj.is_illustration()) { - // draw frame and advance anim - p.image(infect_anim.get_frame(), pos.x, pos.y, - obj.get_width(), obj.get_height()); - //p.fill(obj.get_color()); - } - } - - /* - else if (state === "dead") { - p.fill(0); - p.ellipse(pos.x, pos.y, - obj.get_width(), obj.get_height()); - } - */ - - }; - - // to be used in illustration only - obj.set_image = function(i) { - cell_image = i; - }; - - obj.get_image = function() { - return cell_image; - }; - - obj.is_dead = function() { - //console.log(burst_anim.is_finished()); - return state === "dead"; - }; - - obj.stop_animation = function() { - burst_anim.pause(); - infect_anim.pause(); - }; - - obj.resume_animation = function() { - burst_anim.start(); - infect_anim.start(); - }; - - obj.set_state = function(s) { - if (s === "infected") { - infect_anim.start(); - } - state = s; - }; - - obj.set_antibody = function(a) { - anti = a; - anti.attach(obj); - }; - - obj.has_antibody = function() { - return (anti !== null); - }; - - obj.get_state = function() { - return state; - }; - - obj.die = function() { - if (anti) { - anti.die(); - } - obj.set_state("dying"); - burst_anim.start(); - }; - - // explodes this cell if it is active - obj.fire = function() { - if (state === "active") { - // Make sounds - sounds.play_sound("cell_fire"); - - obj.die(); - - var pos = obj.get_pos(); - var ang = arrow_angle; - // use width cuz it's a circle - var r = obj.get_width()/2; - - // gen particles at edge of cell for now - var x = r*p.cos(ang) + pos.x; - var y = r*p.sin(ang) + pos.y; - - var num_particles = get_num_particles(); - // angle between all the shots - var range = p.PI/6; - var incr = range/num_particles; - - var particles = []; - - ang = arrow_angle - range/2; - // special case - if (num_particles === 1) { - ang = arrow_angle; - } - while (num_particles > 0) { - var new_vel = new p.PVector(p.cos(ang), p.sin(ang)); - // mult by speed scalar - new_vel.mult(7); - // if we want to add velocity of cell - new_vel.add(obj.get_vel()); - - particles.push(particle(p, { - pos: new p.PVector(x, y), - vel: new_vel, - mutation_info: obj.get_mutation_info() - })); - - num_particles--; - ang += incr; - } - - return particles; - } - throw "Can't fire on "+state+" cell!"; - }; - - // override for circular object - obj.calc_radius = function() { - return obj.get_width()/2; - }; - obj.set_radius(obj.calc_radius()); - - // --- private functions --- - - // rotates according to arrow_dir - // switches direction at certain angles - var rotateArrow = function() { - if (arrow_angle > p.PI/2 - || arrow_angle < -p.PI/2) { - arrow_dir = (2-arrow_dir)-2; - } - arrow_angle += p.radians(5+obj.get_level()/2)*arrow_dir * g_speed_factor; - }; - - var drawArrow = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - - // move to center of circle - p.translate(pos.x, pos.y); - // rotate first - p.rotate(arrow_angle); - // move out to right edge of circle - p.translate(w/2, 0); - - // red outline for now - p.stroke(255, 0, 0); - p.strokeWeight(2); - p.fill(obj.get_color()); - - var x1 = w/2; - // draw facing out to right - p.beginShape(); - p.vertex(0, -5); - p.vertex(x1, -5); - p.vertex(x1, -10); - p.vertex(x1+15, 0); - p.vertex(x1, 10); - p.vertex(x1, 5); - p.vertex(0, 5); - p.endShape(); - - p.popMatrix(); - - // Draw Dots if easy - if (GLOBAL_is_easy) { - var pos = obj.get_pos(); - var ang = arrow_angle; - // use width cuz it's a circle - var r = obj.get_width()/2; - - // gen particles at edge of cell for now - var x = r*p.cos(ang) + pos.x; - var y = r*p.sin(ang) + pos.y; - - var num_particles = get_num_particles(); - // angle between all the shots - var range = p.PI/6; - var incr = range/num_particles; - - ang = arrow_angle - range/2; - // special case - if (num_particles === 1) { - ang = arrow_angle; - } - var num_dots = 5; - while (num_particles > 0) { - var offset = 4; - p.fill(153); - p.noStroke(); - for (var i = 0; i < num_dots; i++) { - x = r*p.cos(ang)*offset + pos.x ; - y = r*p.sin(ang)*offset + pos.y ; - p.ellipse(x, y, 2, 2); - offset += 2; - } - - num_particles--; - ang += incr; - } - } - }; - - var get_num_particles = function() { - - var extra_particles = 0; - var mut_info = obj.get_mutation_info(); - /* - for_each(mut_info.abilities, function(a) { - if (a === "extra_particle") { - extra_particles++; - } - }); - */ - return mut_info.particles + extra_particles; - }; - - return obj; -}; diff --git a/game/fb/credits_state.js b/game/fb/credits_state.js deleted file mode 100644 index 9d79008..0000000 --- a/game/fb/credits_state.js +++ /dev/null @@ -1,59 +0,0 @@ -var credits_state = function(p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var credits_back = image_manager.get_image("creditsscreen.png"); - - // Buttons - - var back_button = button(p, { - state : function() { return prev_state; }, - rect : { - pos : new p.PVector(p.width * (3/4), 500), - width: 120, - height: 50, - image: "back.png", - } - }); - - - //Not ordered - var all_buttons = [ back_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "credits"; - }; - - obj.update = function() { - //do nothing - }; - - obj.render = function() { - // fill the background - p.noStroke(); - p.fill(g.background_color); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.imageMode(p.CENTER); - p.image(credits_back, p.width/2, p.height/2); - }; - - obj.key_pressed = function(k) { - if (p.keyCode === 13 || p.keyCode === 27) { // enter, esc - obj.exit_state(); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/game/fb/css/styles.css b/game/fb/css/styles.css deleted file mode 100644 index 44efae4..0000000 --- a/game/fb/css/styles.css +++ /dev/null @@ -1,60 +0,0 @@ -canvas { - border: 3px solid gray; - z-index: 1; - width: 700; - height: 600; - position: relative; -} -#scores-wrap { - z-index: 2; - /*background: white;*/ - /*color: black;*/ - width: 500; - height: 400; - /* use top/left to center manually */ - /* add in border width */ - left: 103px; - top: 83px; - position: absolute; - /* start hidden */ - display: none; -} -#scores { - height: 430; -} -table.score-table { - border-collapse: collapse; - width: 100%; - background: black; - color: white; - /*padding: 0.2em;*/ -} -.score-table, .score-table tr, .score-table td { - /*color: black;*/ - border: 2px solid #666; - font-size: 14; - text-align: right; -} -.score-table th { - font-size: 16; - text-align: center; - color: #000; - background: #fff; - border: 2px solid #666; - border-top: 5px solid #666; -} -.score-table th, .score-table tr, .score-table td { - padding: 0.2em 0.4em; -} -.Score-header { - width: 120; -} -.Name-header { - width: 140; -} -.Level-header { - width: 50; -} -.Date-header { - width: 100; -} diff --git a/game/fb/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png b/game/fb/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png deleted file mode 100755 index 5473aff..0000000 Binary files a/game/fb/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png and /dev/null differ diff --git a/game/fb/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png b/game/fb/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png deleted file mode 100755 index 5950a8d..0000000 Binary files a/game/fb/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png and /dev/null differ diff --git a/game/fb/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png b/game/fb/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png deleted file mode 100755 index 1ad224a..0000000 Binary files a/game/fb/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png and /dev/null differ diff --git a/game/fb/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png b/game/fb/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png deleted file mode 100755 index 1cf1cac..0000000 Binary files a/game/fb/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png and /dev/null differ diff --git a/game/fb/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png b/game/fb/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png deleted file mode 100755 index 35ec0d9..0000000 Binary files a/game/fb/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png and /dev/null differ diff --git a/game/fb/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png b/game/fb/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png deleted file mode 100755 index b1b03b6..0000000 Binary files a/game/fb/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png and /dev/null differ diff --git a/game/fb/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png b/game/fb/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png deleted file mode 100755 index e56eefd..0000000 Binary files a/game/fb/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png and /dev/null differ diff --git a/game/fb/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png b/game/fb/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png deleted file mode 100755 index 3525eb9..0000000 Binary files a/game/fb/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png and /dev/null differ diff --git a/game/fb/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png b/game/fb/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png deleted file mode 100755 index 2b6a9f9..0000000 Binary files a/game/fb/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png and /dev/null differ diff --git a/game/fb/css/ui-darkness/images/ui-icons_222222_256x240.png b/game/fb/css/ui-darkness/images/ui-icons_222222_256x240.png deleted file mode 100755 index b273ff1..0000000 Binary files a/game/fb/css/ui-darkness/images/ui-icons_222222_256x240.png and /dev/null differ diff --git a/game/fb/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png b/game/fb/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png deleted file mode 100755 index c5d93b6..0000000 Binary files a/game/fb/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png and /dev/null differ diff --git a/game/fb/css/ui-darkness/images/ui-icons_a83300_256x240.png b/game/fb/css/ui-darkness/images/ui-icons_a83300_256x240.png deleted file mode 100755 index 95993ea..0000000 Binary files a/game/fb/css/ui-darkness/images/ui-icons_a83300_256x240.png and /dev/null differ diff --git a/game/fb/css/ui-darkness/images/ui-icons_cccccc_256x240.png b/game/fb/css/ui-darkness/images/ui-icons_cccccc_256x240.png deleted file mode 100755 index 9254e05..0000000 Binary files a/game/fb/css/ui-darkness/images/ui-icons_cccccc_256x240.png and /dev/null differ diff --git a/game/fb/css/ui-darkness/images/ui-icons_ffffff_256x240.png b/game/fb/css/ui-darkness/images/ui-icons_ffffff_256x240.png deleted file mode 100755 index 42f8f99..0000000 Binary files a/game/fb/css/ui-darkness/images/ui-icons_ffffff_256x240.png and /dev/null differ diff --git a/game/fb/css/ui-darkness/jquery-ui-1.8.9.custom.css b/game/fb/css/ui-darkness/jquery-ui-1.8.9.custom.css deleted file mode 100755 index 164af9f..0000000 --- a/game/fb/css/ui-darkness/jquery-ui-1.8.9.custom.css +++ /dev/null @@ -1,312 +0,0 @@ -/* - * jQuery UI CSS Framework 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - */ - -/* Layout helpers -----------------------------------*/ -.ui-helper-hidden { display: none; } -.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } -.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } -.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } -.ui-helper-clearfix { display: inline-block; } -/* required comment for clearfix to work in Opera \*/ -* html .ui-helper-clearfix { height:1%; } -.ui-helper-clearfix { display:block; } -/* end clearfix */ -.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } - - -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { cursor: default !important; } - - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } - - -/* - * jQuery UI CSS Framework 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - * - * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Segoe%20UI,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=6px&bgColorHeader=333333&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=25&borderColorHeader=333333&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=000000&bgTextureContent=05_inset_soft.png&bgImgOpacityContent=25&borderColorContent=666666&fcContent=ffffff&iconColorContent=cccccc&bgColorDefault=555555&bgTextureDefault=02_glass.png&bgImgOpacityDefault=20&borderColorDefault=666666&fcDefault=eeeeee&iconColorDefault=cccccc&bgColorHover=0078a3&bgTextureHover=02_glass.png&bgImgOpacityHover=40&borderColorHover=59b4d4&fcHover=ffffff&iconColorHover=ffffff&bgColorActive=f58400&bgTextureActive=05_inset_soft.png&bgImgOpacityActive=30&borderColorActive=ffaf0f&fcActive=ffffff&iconColorActive=222222&bgColorHighlight=eeeeee&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=80&borderColorHighlight=cccccc&fcHighlight=2e7db2&iconColorHighlight=4b8e0b&bgColorError=ffc73d&bgTextureError=02_glass.png&bgImgOpacityError=40&borderColorError=ffb73d&fcError=111111&iconColorError=a83300&bgColorOverlay=5c5c5c&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=50&opacityOverlay=80&bgColorShadow=cccccc&bgTextureShadow=01_flat.png&bgImgOpacityShadow=30&opacityShadow=60&thicknessShadow=7px&offsetTopShadow=-7px&offsetLeftShadow=-7px&cornerRadiusShadow=8px - */ - - -/* Component containers -----------------------------------*/ -.ui-widget { font-family: Segoe UI, Arial, sans-serif; font-size: 1.1em; } -.ui-widget .ui-widget { font-size: 1em; } -.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Segoe UI, Arial, sans-serif; font-size: 1em; } -.ui-widget-content { border: 1px solid #666666; background: #000000 url(images/ui-bg_inset-soft_25_000000_1x100.png) 50% bottom repeat-x; color: #ffffff; } -.ui-widget-content a { color: #ffffff; } -.ui-widget-header { border: 1px solid #333333; background: #333333 url(images/ui-bg_gloss-wave_25_333333_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; } -.ui-widget-header a { color: #ffffff; } - -/* Interaction states -----------------------------------*/ -.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #666666; background: #555555 url(images/ui-bg_glass_20_555555_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #eeeeee; } -.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #eeeeee; text-decoration: none; } -.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #59b4d4; background: #0078a3 url(images/ui-bg_glass_40_0078a3_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #ffffff; } -.ui-state-hover a, .ui-state-hover a:hover { color: #ffffff; text-decoration: none; } -.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #ffaf0f; background: #f58400 url(images/ui-bg_inset-soft_30_f58400_1x100.png) 50% 50% repeat-x; font-weight: bold; color: #ffffff; } -.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #ffffff; text-decoration: none; } -.ui-widget :active { outline: none; } - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #cccccc; background: #eeeeee url(images/ui-bg_highlight-soft_80_eeeeee_1x100.png) 50% top repeat-x; color: #2e7db2; } -.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #2e7db2; } -.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #ffb73d; background: #ffc73d url(images/ui-bg_glass_40_ffc73d_1x400.png) 50% 50% repeat-x; color: #111111; } -.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #111111; } -.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #111111; } -.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } -.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } -.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_cccccc_256x240.png); } -.ui-widget-content .ui-icon {background-image: url(images/ui-icons_cccccc_256x240.png); } -.ui-widget-header .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); } -.ui-state-default .ui-icon { background-image: url(images/ui-icons_cccccc_256x240.png); } -.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); } -.ui-state-active .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); } -.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_4b8e0b_256x240.png); } -.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_a83300_256x240.png); } - -/* positioning */ -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-off { background-position: -96px -144px; } -.ui-icon-radio-on { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-start { background-position: -80px -160px; } -/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-tl { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px; } -.ui-corner-tr { -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px; } -.ui-corner-bl { -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; } -.ui-corner-br { -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } -.ui-corner-top { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px; -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px; } -.ui-corner-bottom { -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } -.ui-corner-right { -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px; -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } -.ui-corner-left { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px; -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; } -.ui-corner-all { -moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px; } - -/* Overlays */ -.ui-widget-overlay { background: #5c5c5c url(images/ui-bg_flat_50_5c5c5c_40x100.png) 50% 50% repeat-x; opacity: .80;filter:Alpha(Opacity=80); } -.ui-widget-shadow { margin: -7px 0 0 -7px; padding: 7px; background: #cccccc url(images/ui-bg_flat_30_cccccc_40x100.png) 50% 50% repeat-x; opacity: .60;filter:Alpha(Opacity=60); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/* - * jQuery UI Tabs 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Tabs#theming - */ -.ui-tabs { position: relative; /*padding: .2em;*/ zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ -.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; } -.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; } -.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; } -.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */ -.ui-tabs .ui-tabs-panel { display: block; border-width: 0;/* padding: 1em 1.4em;*/ background: none; } -.ui-tabs .ui-tabs-hide { display: none !important; } diff --git a/game/fb/date.format.js b/game/fb/date.format.js deleted file mode 100644 index 3992c50..0000000 --- a/game/fb/date.format.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Date Format 1.2.3 - * (c) 2007-2009 Steven Levithan - * MIT license - * - * Includes enhancements by Scott Trenda - * and Kris Kowal - * - * Accepts a date, a mask, or a date and a mask. - * Returns a formatted version of the given date. - * The date defaults to the current date/time. - * The mask defaults to dateFormat.masks.default. - */ - -var dateFormat = function () { - var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, - timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, - timezoneClip = /[^-+\dA-Z]/g, - pad = function (val, len) { - val = String(val); - len = len || 2; - while (val.length < len) val = "0" + val; - return val; - }; - - // Regexes and supporting functions are cached through closure - return function (date, mask, utc) { - var dF = dateFormat; - - // You can't provide utc if you skip other args (use the "UTC:" mask prefix) - if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { - mask = date; - date = undefined; - } - - // Passing date through Date applies Date.parse, if necessary - date = date ? new Date(date) : new Date; - if (isNaN(date)) throw SyntaxError("invalid date"); - - mask = String(dF.masks[mask] || mask || dF.masks["default"]); - - // Allow setting the utc argument via the mask - if (mask.slice(0, 4) == "UTC:") { - mask = mask.slice(4); - utc = true; - } - - var _ = utc ? "getUTC" : "get", - d = date[_ + "Date"](), - D = date[_ + "Day"](), - m = date[_ + "Month"](), - y = date[_ + "FullYear"](), - H = date[_ + "Hours"](), - M = date[_ + "Minutes"](), - s = date[_ + "Seconds"](), - L = date[_ + "Milliseconds"](), - o = utc ? 0 : date.getTimezoneOffset(), - flags = { - d: d, - dd: pad(d), - ddd: dF.i18n.dayNames[D], - dddd: dF.i18n.dayNames[D + 7], - m: m + 1, - mm: pad(m + 1), - mmm: dF.i18n.monthNames[m], - mmmm: dF.i18n.monthNames[m + 12], - yy: String(y).slice(2), - yyyy: y, - h: H % 12 || 12, - hh: pad(H % 12 || 12), - H: H, - HH: pad(H), - M: M, - MM: pad(M), - s: s, - ss: pad(s), - l: pad(L, 3), - L: pad(L > 99 ? Math.round(L / 10) : L), - t: H < 12 ? "a" : "p", - tt: H < 12 ? "am" : "pm", - T: H < 12 ? "A" : "P", - TT: H < 12 ? "AM" : "PM", - Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""), - o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), - S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10] - }; - - return mask.replace(token, function ($0) { - return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); - }); - }; -}(); - -// Some common format strings -dateFormat.masks = { - "default": "ddd mmm dd yyyy HH:MM:ss", - shortDate: "m/d/yy", - mediumDate: "mmm d, yyyy", - longDate: "mmmm d, yyyy", - fullDate: "dddd, mmmm d, yyyy", - shortTime: "h:MM TT", - mediumTime: "h:MM:ss TT", - longTime: "h:MM:ss TT Z", - isoDate: "yyyy-mm-dd", - isoTime: "HH:MM:ss", - isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", - isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" -}; - -// Internationalization strings -dateFormat.i18n = { - dayNames: [ - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" - ], - monthNames: [ - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", - "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" - ] -}; - -// For convenience... -Date.prototype.format = function (mask, utc) { - return dateFormat(this, mask, utc); -}; - diff --git a/game/fb/empty_cell.js b/game/fb/empty_cell.js deleted file mode 100644 index 76e58c9..0000000 --- a/game/fb/empty_cell.js +++ /dev/null @@ -1,91 +0,0 @@ -// *** empty_cell *** -// --- inherits from cell -// spec: -// cell spec - -var empty_cell = function(p, spec) { - - // --- defaults --- - // inherited from cell - - // obj to return - var obj = cell(p, spec); - - obj.get_type = function() { - return "empty_cell"; - }; - - // --- private variables --- - - // state can be "alive", "infected", or "dead" - //var state = spec.state || "alive"; - - //var empty_image = p.loadImage("images/noninfectable1.png"); - /* - var images = random_image_selector(); - var empty_image = null; - if (on_server) { // so itwill work locally - for_each(g_empty_cell_images, function(i){ - images.add(p.loadImage(i)); - }); - empty_image = images.get_image(); - } - else { - empty_image = p.loadImage("images/new/noninfectable.png"); - } - */ - var empty_image = random_from( - image_manager.get_images("empty_cell")).image; - - // --- public methods --- - - // implementing game_object interface - - // update is different depending on state - obj.update = function() { - obj.move(); - if (obj.get_state() === "alive") { - // just chill - } - else if (obj.get_state() === "infected") { - // prepare to die - } - else if (obj.get_state() === "dead") { - // explode!! - } - }; - - // draw makes a cell with a different color depending on state - // just an outline for empty cell - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.mode); - - p.strokeWeight(2); - p.stroke(0); - p.noFill(); - - if (obj.get_state() === "alive") { - p.stroke(0); - } - else if (obj.get_state() === "infected") { - p.stroke(150); - } - else if (obj.get_state() === "dead") { - p.fill(0); - } - - p.imageMode(obj.get_mode()); - p.image(empty_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - }; - - obj.is_dead = function() { - return obj.get_state() === "dead"; - }; - - obj.die = function() { - obj.set_state("dead") = "dead"; - }; - - return obj; -} diff --git a/game/fb/facebook.php b/game/fb/facebook.php deleted file mode 100644 index 6d4fa72..0000000 --- a/game/fb/facebook.php +++ /dev/null @@ -1,1845 +0,0 @@ - - - - - - - - - - - - src/facebook.php at master from facebook's php-sdk - GitHub - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      -
      - - - -
      -

      Your current locale selection: English. Choose another?

      - - - - - - - - - - - - -
      - -
      -
      -
      - - - - - - - - - - - - - - - - diff --git a/game/fb/fisforformat.min.js b/game/fb/fisforformat.min.js deleted file mode 100644 index d890718..0000000 --- a/game/fb/fisforformat.min.js +++ /dev/null @@ -1,11 +0,0 @@ -/* - * "f" is for Format & WHAT THE diff?? v0.5.0 - * - * Copyright (c) 2009 Joshua Faulkenberry - * Dual licensed under the MIT and GPL licenses. - * http://docs.jquery.com/License - * - * Date: 2009-03-20 22:15:23 -0700 (Fri, 20 Mar 2009) - * Revision: 6 - */ -window.Date.prototype.f=function(format){if(format=="@"){return this.getTime()}else{if(format=="REL"){var diff=(((new Date()).getTime()-this.getTime())/1000),day_diff=Math.floor(diff/86400);return day_diff==0&&(diff>-60&&"right now"||diff>-120&&"1 minute from now"||diff>-3600&&-(Math.floor(diff/60))+" minutes from now"||diff>-7200&&"1 hour ago"||diff>-86400&&-(Math.floor(diff/3600))+" hours from now"||diff<60&&"just now"||diff<120&&"1 minute ago"||diff<3600&&Math.floor(diff/60)+" minutes ago"||diff<7200&&"1 hour ago"||diff<86400&&Math.floor(diff/3600)+" hours ago")||day_diff==0&&"Tomorrow"||day_diff>-7&&-(day_diff)+" days from now"||-(Math.ceil(day_diff/7))==1&&"1 week from now"||day_diff>-78&&-(Math.ceil(day_diff/7))+" weeks from now"||day_diff>-730&&-(Math.ceil(day_diff/30))+" months from now"||day_diff<=-730&&-(Math.ceil(day_diff/365))+" years from now"||day_diff==1&&"Yesterday"||day_diff<7&&day_diff+" days ago"||(Math.ceil(day_diff/7))==1&&"1 week ago"||day_diff<78&&Math.ceil(day_diff/7)+" weeks ago"||day_diff<730&&Math.ceil(day_diff/30)+" months ago"||Math.ceil(day_diff/365)+" years ago"}}var MONTH_NAMES=["January","February","March","April","May","June","July","August","September","October","November","December"],DAY_NAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],LZ=function(x){return(x<0||x>9?"":"0")+x},date=this,format=format+"",result="",i_format=0,c="",token="",y=date.getYear()+"",M=date.getMonth()+1,d=date.getDate(),E=date.getDay(),H=date.getHours(),m=date.getMinutes(),s=date.getSeconds(),yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k,value=new Object();if(y.length<4){y=""+(y-0+1900)}value.y=""+y;value.yyyy=y;value.yy=y.substr(2,4);value.M=M;value.MM=LZ(M);value.MMM=MONTH_NAMES[M-1];value.NNN=MONTH_NAMES[M-1].substr(0,3);value.N=MONTH_NAMES[M-1].substr(0,1);value.d=d;value.dd=LZ(d);value.e=DAY_NAMES[E].substr(0,1);value.ee=DAY_NAMES[E].substr(0,2);value.E=DAY_NAMES[E].substr(0,3);value.EE=DAY_NAMES[E];value.H=H;value.HH=LZ(H);if(H==0){value.h=12}else{if(H>12){value.h=H-12}else{value.h=H}}value.hh=LZ(value.h);if(H>11){value.K=H-12}else{value.K=H}value.k=H+1;value.KK=LZ(value.K);value.kk=LZ(value.k);if(H>11){value.a="PM"}else{value.a="AM"}value.m=m;value.mm=LZ(m);value.s=s;value.ss=LZ(s);while(i_format=tl[trg]){if(trg=="Y"||trg=="D"||trg=="C"||trg=="T"){for(var yr=(min);yr.getFullYear()<=max.getFullYear();yr.setYear(yr.getFullYear()+1)){if(yr.isLeapYear()){diff-=tl.d}}}if(diff>=tl[trg]){result=Math.floor(diff/tl[trg])+" "+(Math.floor(diff/tl[trg])==1&&names[trg][0]||names[trg][1]);diff=diff%tl[trg]}}eval("breakdown = breakdown.replace(/"+trg+'/g, "")');return result}var min=date<=this&&date||date>this&&this,max=date>this&&date||date<=this&&this,diff=(max.getTime()-min.getTime()),tl={T:1000*60*60*24*365*100*10,C:1000*60*60*24*365*100,D:1000*60*60*24*365*10,Y:1000*60*60*24*365,M:1000*60*60*24*28,W:1000*60*60*24*7,d:1000*60*60*24,H:1000*60*60,m:1000*60,S:1000,N:1},names={T:options.labels.T||["Mellinium","Mellinia"],C:options.labels.C||["Century","Centuries"],D:options.labels.D||["Decade","Decades"],Y:options.labels.Y||["Year","Years"],M:options.labels.M||["Month","Months"],W:options.labels.W||["Week","Weeks"],d:options.labels.d||["Day","Days"],H:options.labels.H||["Hour","Hours"],m:options.labels.m||["Minute","Minutes"],S:options.labels.S||["Second","Seconds"],N:options.labels.N||["Millisecond","Milliseconds"]};if(options.len){for(var x in names){names[x]=names[x].substr(0,options.len)}}var testDt=new Date(min.toString());if(max.getFullYear()-testDt.getFullYear()>1){testDt.setYear(max.getFullYear()-1)}while(testDtmin.getDayLightSavingsDays()[1].getDate())||min.getMonth()0){if(breakdown=="*"){breakdown="TCDYMWdHmSN"}else{if(breakdown.indexOf("T")>-1){if(out=processTime("T")){result[result.length]=out}}else{if(breakdown.indexOf("C")>-1){if(out=processTime("C")){result[result.length]=out}}else{if(breakdown.indexOf("D")>-1){if(out=processTime("D")){result[result.length]=out}}else{if(breakdown.indexOf("Y")>-1){if(out=processTime("Y")){result[result.length]=out}}else{if(breakdown.indexOf("M")>-1){if(diff>=tl.M){var cur=(new Date(max.getTime()-diff));var monthCount=0;var lastVal=0;for(var yr=cur.getFullYear();yr<=max.getFullYear();yr++){while(cur.getFullYear()==yr){lastVal=cur.getTime();cur.setMonth(cur.getMonth()+1);if(diff-(cur.getTime()-lastVal)>=0){monthCount++;diff-=(cur.getTime()-lastVal)}if(yr==max.getFullYear()&&cur.getMonth()==max.getMonth()){break}}}if(monthCount){result[result.length]=monthCount+" "+(monthCount==1&&names.M[0]||names.M[1])}}breakdown=breakdown.replace(/M/g,"")}else{if(breakdown.indexOf("W")>-1){if(out=processTime("W")){result[result.length]=out}}else{if(breakdown.indexOf("d")>-1){if(out=processTime("d")){result[result.length]=out}}else{if(breakdown.indexOf("H")>-1){if(out=processTime("H")){result[result.length]=out}}else{if(breakdown.indexOf("m")>-1){if(out=processTime("m")){result[result.length]=out}}else{if(breakdown.indexOf("S")>-1){if(out=processTime("S")){result[result.length]=out}}else{if(breakdown.indexOf("N")>-1){if(out=processTime("N")){result[result.length]=out}}else{diff=0}}}}}}}}}}}}}options.divider=options.divider||", ";if(options.divider==", "&&result.length>1&&!options.hideAnd){result[result.length-1]="and "+result[result.length-1]}diff=result.join(options.divider)}if(diff==""){diff="Same"}if(options.lc){diff=diff.toLowerCase()}return diff};window.Date.prototype.getDaysInMonth=function(){return[31,28,31,30,31,30,31,31,30,31,30,31][this.getMonth()]};window.Date.prototype.isLeapYear=function(){return(new Date(this.getFullYear(),2-1,29)).getDate()==29};window.Date.prototype.getDayLightSavingsDays=function(){var result=[];var day1=new Date("03/07/"+this.getFullYear());var day2=new Date("03/06/"+this.getFullYear());while(day1.getMonth()<3||(day1.getMonth()==3&&day1.getDate()<16)){if((day1.getTime()-day2.getTime())/1000/60/60!=24){result[result.length]=new Date(day2.getTime())}day1.setDate(day1.getDate()+1);day2.setDate(day2.getDate()+1)}var day1=new Date("10/31/"+this.getFullYear());var day2=new Date("10/30/"+this.getFullYear());while(day1.getMonth()<11||(day1.getMonth()==10&&day1.getDate()<9)){if((day1.getTime()-day2.getTime())/1000/60/60!=24){result[result.length]=new Date(day2.getTime())}day1.setDate(day1.getDate()+1);day2.setDate(day2.getDate()+1)}return result};window.Date.prototype.isDayLightSavingsDay=function(){var comp=new Date(this.getTime());comp.setDate(comp.getDate()+1);return(comp.getTime()-this.getTime())/1000/60/60!=24}; \ No newline at end of file diff --git a/game/fb/floater.js b/game/fb/floater.js deleted file mode 100644 index 86ff5a5..0000000 --- a/game/fb/floater.js +++ /dev/null @@ -1,122 +0,0 @@ -// *** floater *** -// --- inherits from game_object -// spec: -// game_object spec -// state = leave to be default "alive" - -var floater = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 43; - spec.height = spec.height || 50; - spec.vel = new p.PVector(0, 0.3); - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "floater"; - }; - - // --- private variables --- - - var macrophage_alive = animated_image("macrophage", {reverse : true}); - var macrophage_active = animated_image("macrophage_active", {reverse : true}); - // for illustration - var macro_active_img = image_manager.get_image("macrophage_1_active.png"); - var macro_alive_img = image_manager.get_image("macrophage_1.png"); - - // how far up or down it can move - var range = 50; - var btm_lim = obj.get_pos().y + range; - var top_lim = obj.get_pos().y - range; - // state can be "alive", "activated", or "dead" - var state = spec.state || "alive"; - - // --- public methods --- - - // implementing game_object interface - - obj.update = function() { - // if we reach a limit - var y = obj.get_pos().y; - if (y <= top_lim || y >= btm_lim) { - // turn around - var v = obj.get_vel(); - obj.set_vel(new p.PVector(v.x, -v.y)); - } - obj.move(); - }; - - // (rectangle for now) - obj.draw = function() { - /* - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.fill(obj.get_color()); - - p.stroke(0); - p.strokeWeight(1); - - // had to hack to center rect - // might need to change - p.rect(pos.x-w/2, pos.y-h/2, w, h); - */ - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.imageMode(obj.get_mode()); - if (state === "active") { - p.shapeMode(obj.mode); - p.fill(obj.get_color()); - p.noStroke(); - p.ellipse(pos.x + w / 8, pos.y - w / 8 + 1, w/2, w/2); - if (!obj.is_illustration()) { - macro_active_img = macrophage_active.get_frame(); - } - p.image(macro_active_img, pos.x, pos.y, w, h); - } - else { - if (!obj.is_illustration()) { - macro_alive_img = macrophage_alive.get_frame(); - } - p.image(macro_alive_img, pos.x, pos.y, w, h); - } - }; - - obj.stop_animation = function() { - macrophage_alive.pause(); - macrophage_active.pause(); - }; - - obj.resume_animation = function() { - macrophage_alive.start(); - macrophage_active.start(); - }; - - obj.is_dead = function() { - return state === "dead"; - }; - - obj.is_alive = function() { - return state === "alive"; - }; - - obj.is_activated = function() { - return state === "active"; - }; - - obj.get_state = function() { - return state; - }; - - obj.activate = function() { - state = "active"; - }; - - return obj; -} diff --git a/game/fb/game_object.js b/game/fb/game_object.js deleted file mode 100644 index 71d409d..0000000 --- a/game/fb/game_object.js +++ /dev/null @@ -1,276 +0,0 @@ -// *** game_object *** -// spec: -// mode = p.CENTER or p.CORNERS (constants from processing) -// - describes how the coords work, set by p.shapeMode() -// p.PVector pos = initial position (x,y) -// float width = width of the entire object -// float height = height of the entire object -// float radius = circle collision radius (will be auto-calced) -// p.PVector vel = initial velocity -// p.PVector accel = initial acceleration -// mutation_info = object with level, num_particles and color props -// illustration = boolean that says whether or not to draw animations - -var game_object = function (p, spec) { - - - // object to return - var obj = {}; - - // should be overridden by subtypes - obj.get_type = function() { - return "game_object"; - }; - - obj.DEFAULT_SCROLL_DIST = -1.2; - - // --- private variables --- - - var mode = spec.mode || p.CENTER; - var pos = spec.pos || new p.PVector(0, 0); - var width = spec.width || 0; - var height = spec.height || 0; - var vel = spec.vel || new p.PVector(0, 0); - var accel = spec.accel || new p.PVector(0, 0); - // used for circle collision testing - var radius = spec.radius // default set at bottom of file - // used for mutation - var mutation_info = spec.mutation_info || - { level: -1, color: p.color(0, 0, 0), particles: 0 }; - var illustration = spec.illustration || false; - - var alive = true; - - // --- public methods --- - - // all game_objects must implement this interface: - // void update() - called each frame to move/update objects - // void draw() - called each frame to display the object - // void scroll() - moves the object left by a certain amount - - // update moves obj by default - obj.update = function() { obj.move(); }; - - // draw does nothing by default - obj.draw = function() {}; - - // by default returns the negated alive variable - obj.is_dead = function() { return !alive; }; - - // Generic methods for all game_objects: - // returns true if the object is completely offscreen - // i.e. checks pos + dimensions - obj.is_offscreen = function() { - var left_edge = pos.x - width/2; - var right_edge = pos.x + width/2; - var top_edge = pos.y - height/2; - var btm_edge = pos.y + height/2; - return (left_edge > p.width - || right_edge < 0 - || top_edge > p.height - || btm_edge < 0); - }; - - // Returns if the obj is off the right of the screen - obj.is_off_right = function() { - var left_edge = pos.x - width/2; - return left_edge > p.width; - }; - - - // Bounces the object off a wall, if it is at one - obj.bounce = function() { - var left_edge = pos.x - width; - var right_edge = pos.x + width; - var top_edge = pos.y - height; - var btm_edge = pos.y + height; - if (top_edge <= 0 && vel.y < 0) { - vel.y = -vel.y; - } - if (btm_edge >= p.height && vel.y > 0) { - vel.y = -vel.y; - } - if (left_edge <= 0 && vel.x < 0) { - vel.x = -vel.x; - } - if (right_edge >= p.width && vel.x > 0) { - vel.x = -vel.x; - } - }; - - // reverses the y velocity - // used for bouncing vertically - obj.reverse_y = function() { - var vel = obj.get_vel(); - obj.set_vel(new p.PVector(vel.x, -vel.y)); - }; - - // reverses the x velocity - // used for bouncing horizontally - obj.reverse_x = function() { - var vel = obj.get_vel(); - obj.set_vel(new p.PVector(- vel.x, vel.y)); - }; - - // updates the position according to accel and vel - // Bounces off walls - obj.move = function() { - vel.add(accel); - pos.add(vel); - }; - - // stops the object in its tracks by zeroing out vel - obj.stop = function() { - vel = new p.PVector(0, 0); - }; - - // Scrolls the obj a specified distance left or right (positive is right) - obj.scroll = function(scroll_factor) { - var scroll_x = obj.get_scroll_dist(); - if (scroll_x === null) { - scroll_x = obj.DEFAULT_SCROLL_DIST; - } - pos.add(new p.PVector(scroll_x*scroll_factor, 0)); - }; - - obj.die = function() { - alive = false; - }; - - obj.is_illustration = function() { - return illustration; - }; - - // --- setters --- - - obj.set_illustration = function(i) { - illustration = i; - }; - - obj.set_pos = function(new_pos) { - pos = new_pos; - }; - - obj.set_accel = function(new_accel) { - accel = new_accel; - }; - - obj.set_vel = function(new_vel) { - vel = new_vel; - }; - - // should only be used once, just for circular objects - obj.set_radius = function(new_radius) { - radius = new_radius; - }; - - // Should only be used for collisions - obj.set_pos = function(posn) { - pos = posn; - }; - - obj.set_mutation_info = function(m) { - mutation_info = m; - }; - - // --- getters --- - - // Override to set different scroll dist - // or leave as null to use default - obj.get_scroll_dist = function() { - return null; - }; - - obj.get_pos = function() { - return pos; - }; - - obj.get_left = function() { - return pos.x - (width / 2); - }; - - obj.get_top = function() { - return pos.y - (height / 2); - }; - - obj.get_right = function() { - return pos.x + (width / 2); - }; - - obj.get_bottom = function() { - return pos.y + (height / 2); - }; - - // returns the x offset for rectangle collisions - // should be overridden for rectangular objects - obj.get_x_offset = function() { - return 0; - }; - // returns the y offset for rectangle collisions - // should be overridden for rectangular objects - obj.get_y_offset = function() { - return 0; - }; - - obj.get_width = function() { - return width; - }; - - obj.get_height = function() { - return height; - }; - - obj.get_mode = function() { - return mode; - }; - - obj.get_vel = function() { - return vel; - }; - - obj.get_accel = function() { - return accel; - }; - - obj.get_radius = function() { - return radius; - }; - - obj.get_mutation_info = function() { - return mutation_info; - }; - - obj.get_color = function() { - return mutation_info.color; - }; - - obj.get_level = function() { - return mutation_info.level; - }; - - obj.is = function(type) { - return obj.get_type() === type; - }; - - obj.to_string = function() { - return obj.get_type()+" ("+pos.x+", "+pos.y+")"; - }; - - // draws the collision circle as an overlay - obj.draw_circle = function() { - p.fill(255, 50); - p.noStroke(); - p.shapeMode(p.CENTER); - p.ellipse(pos.x, pos.y, 2*radius, 2*radius); - }; - - // uses pythagorean theorem to calc radius of bounding circle - obj.calc_radius = function() { - return 0.5*p.sqrt(width*width+height*height); - }; - - // calc radius if not already set - radius = radius || obj.calc_radius(); - - return obj; -} diff --git a/game/fb/game_over_state.js b/game/fb/game_over_state.js deleted file mode 100644 index 6190456..0000000 --- a/game/fb/game_over_state.js +++ /dev/null @@ -1,175 +0,0 @@ -// spec: -// score : num representing score of game -// mutation_level : num representing mutation level at end of game - -var game_over_state = function (p, prev_state, spec, game_type) { - //right now, prev_state is not used - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var topy = 100; - // Score display - var score_rect = rectangle(p, { - pos : new p.PVector(p.width / 2, topy+80),// 230), - width : 0, - height : 0, - text : "Score: " + add_commas(spec.score), - text_size : 30, - text_color : 255 - }); - - var mutation_rect = rectangle(p, { - pos : new p.PVector(p.width / 2, topy+130),//280), - width : 0, - height : 0, - text : "Mutation Level: " + spec.mutation_level, - text_size : 30, - text_color : 255 - }); - - var b_top = topy+180; - var b_spc = 60; - var button_style = { - width: 120, height: 50, - text_align: p.LEFT, - }; - // Buttons - var restart_button = button(p, { - state : function() { - sounds.play_button_click(); - return in_game_state(p, prev_state, game_type); - }, - rect : { - pos : new p.PVector(p.width / 2, b_top),//330), - //text : "Restart", - //text_x_offset: 40, - image: "restart.png", - //style: button_style - } - }); - var post_button = button(p, { - state : function() { - // only post if they are logged in - if (g_user_id) { - sounds.play_button_click(); - FB.ui({ - method: 'feed', - name: "Play Virion!", - picture: "http://virus-game.cs.brown.edu/images/logo/vlogolarge.png", - link: "http://apps.facebook.com/viriongame", - caption: "I just scored "+add_commas(spec.score)+ - " playing Virion!", - }); - } - return obj; - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+b_spc),//390), - //text : "Post Score to Wall", - //text_x_offset: 35, - image: "postscore.png", - //style: button_style - } - }); - var invite_button = button(p, { - state : function() { - // only post if they are logged in - if (g_user_id) { - sounds.play_button_click(); - FB.ui({ - method: 'apprequests', - title: "Infect Your Friends", - message: 'Check out this awesome game!', - }); - } - return obj; - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+2*b_spc),//450), - //text : "Infect Your Friends", - //text_x_offset: 35, - image: "infectfriends.png", - //style: button_style - } - }); - - // only allow posts/invites if logged in - if (!g_user_id) { - post_button.deactivate(); - invite_button.deactivate(); - } - - var scores_button = button(p, { - state : function() { - sounds.play_button_click(); - return high_scores_state(p, obj); - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+3*b_spc),//510), - //text : "High Scores", - //text_x_offset: 35, - image: "highscores.png", - //style: button_style - } - }); - var splash_button = button(p, { - state : function() { - sounds.play_button_click(); - return splash_state(p); - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+4*b_spc),//570), - //text : "Main Menu", - //text_x_offset: 35, - image: "mainmenu.png", - //style: button_style - } - }); - - //Not ordered - var all_buttons = [restart_button, post_button, - invite_button, splash_button, scores_button]; - var all_rectangles = [score_rect, mutation_rect]; - - // --- public methods --- - - obj.get_type = function() { - return "game_over"; - }; - - obj.update = function() { - //do nothing - }; - - obj.key_pressed = function(k) { - if (k === 114 || p.keyCode === 13) { //r, enter - obj.set_next_state(restart_button.get_state()); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - obj.render = function() { - p.fill(0, 150); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.fill(255); - p.textAlign(p.CENTER); - - p.textSize(50); - p.text("Game Over", p.width/2, topy); - p.textSize(20); - p.text("Your virus was wiped out!", p.width/2, topy+30); - - for_each(all_rectangles, function(r) {r.draw();}); - }; - - return obj; -}; diff --git a/game/fb/game_state.js b/game/fb/game_state.js deleted file mode 100644 index 775f8f9..0000000 --- a/game/fb/game_state.js +++ /dev/null @@ -1,124 +0,0 @@ -// *** game_state *** -// Interface for all game states - -// NOTE ALL OF THE FOLLOWING WHEN CREATING A GAME STATE: -// All game states must take a previous_state in their constructor, and then call set_previous_state() -// The exception to this is splash, which is the base state and should never be exited -// If a state change happens in: -// update() - return the new state -// mouse_click/key_pressed: Call set_next_state(new_state) with the state to go to -// Buttons: -// Drawing and clicking of buttons is taken care of -// You must take care of key strokes - -var game_state = function (p) { - - // object to return - var obj = {}; - - // --- private variables --- - var next_state = null; - var previous_state = null; - var all_buttons = []; //TODO: This is static but is updated every update() - - - // --- public methods --- - - //Wrapper for every states render function - //First draws all the buttons, then calls render - obj.render_wrapper = function() { - obj.render(); - for_each(all_buttons, function(b) { b.draw(); }); - }; - - //Do not over-ride these methods - obj.set_next_state = function(ns) { - next_state = ns; - }; - obj.set_previous_state = function(ps) { - previous_state = ps; - }; - obj.exit_state = function() { - if (previous_state === null) { - throw "error previous state not set in game_state"; - } - assert(previous_state !== null, "Previous state was null in game_state.exit_state"); - next_state = previous_state; - }; - - // Wrapper for every states update function - // Goes to the next state (by returning it) if next_state has been set - obj.update_wrapper = function() { - all_buttons = obj.get_all_buttons(); - if (next_state !== null) { - var to_return = next_state; - //in case we return to this state (CURRENTLY, SHOULDN'T EVER HAPPEN I THINK) - next_state = null; - return to_return; - } - //else - obj.update(); - obj.render_wrapper(); - }; - - // Wrapper for mouse clicks - // First checks if any of the buttons are clicked, then calls mouse_click - obj.mouse_click_wrapper = function(x, y) { - var click_function = function(b) { - var next_state = b.is_clicked(x, y); - if (next_state !== null) { - obj.set_next_state(next_state); - } - } - for_each(all_buttons, click_function); - obj.mouse_click(x, y); - }; - - obj.mouse_moved_wrapper = function(x, y) { - for_each( - all_buttons, - function(b) { - b.mouse_moved(x, y); - } - ); - obj.mouse_moved(x, y); - }; - - - // all game_states must implement the following functions: - - //Returns the type of the state - obj.get_type = function() { - return "get_type not overwritten"; - }; - - //Takes in the key pressed and handles a key press - obj.key_pressed = function(k) {throw "key_pressed not overwritten"}; - - // Do nothing unless overwritten - obj.mouse_moved = function(x, y) {}; - - //Updates the current state, and returns the next state to go to - //next state can be: - // null, if no state change - // a state representing a state to go to (either previous state or newly created next state - obj.update = function() {throw "update not overwritten"}; - - // Returns all of the buttons on the screen - obj.get_all_buttons = function() {throw "get_all_buttons not overwritten"}; - - // --- Optionally implement these, they default to nothing --- - - //Renders the current state - obj.render = function(){ }; //throw "render not overwritten"}; - - //Takes in the x and y coordinates of the mouse, and handles a mouse click - obj.mouse_click = function(x, y){}; //throw "mouse_click not overwritten"}; - - //Called when returning to this state - obj.resume = function() {}; - - - - return obj; -}; diff --git a/game/fb/generator.js b/game/fb/generator.js deleted file mode 100644 index acad075..0000000 --- a/game/fb/generator.js +++ /dev/null @@ -1,393 +0,0 @@ -// *** generator *** -// generates random enemies -// spec: -// game : an in_game_state -// Is going to access: (through getters since we're so safe) -// game_objects - array -// distance - a num -// type_to_level - hash from type to level -// active_cell -// mutation : a mutation obj, so it can get current mutation color - -var make_generator = function(p, spec) { - // --- defaults --- - - // obj to return - var obj = {}; - - // --- private variables --- - - //These will be updated at every call of update() - var game_objects = null; - var distance = null; - var mutation = spec.mutation; - var game = spec.game; - var last_obj = null; // The last object generated - - var default_gen_speed = 10; - // structure that stores the generation settings - // for each type of object - // - start = distance after which to start generating - // - num = how many total on screen - // - cap = upper limit on num - // - rate = determines when to increment num - // when dist % rate = 0, num increments - // - gen_speed = speed with which to generate the object - // 1 (1/100 frames) to 100 (100/100 frames) - // If not specified, defaults to DEFAULT_GEN_SPEED - // - spacing = diagonal space to put b/w objects of this type (optional) - // - gen_x = how far offscreen to gen this type (optional) - // - gen_y = function that returns random y pos for this object (optional) - // - make_new = function that takes a pos and returns a new enemy - // - diminish = Include to make enemy's num decrease over time instead of increasing (optional) - var gen_info = { - "cell": { - // was 8 - start: 0, num: 30, cap: 10, rate: 2000, gen_speed: 55, diminish : true, - spacing: 50, - make_new: function(en_pos) { - return cell(p, { - pos: en_pos, - state: "alive", - }); - } - }, - "wall_cell": { - start: 0, num: 3, cap: 7, rate: 3000, //non testing value: 1000 - spacing: "dynamic",//100, - make_new: function(en_pos) { - return wall_cell(p, { pos: en_pos }); - } - }, - "empty_cell": { - start: 5000, num: 1, cap: 10, rate: 5000, - make_new: function(en_pos) { - return empty_cell(p, { pos: en_pos }); - } - }, - "floater": { - start: 1000, num: 3, cap: 7, rate: 7000, - spacing: "dynamic",//100, - make_new: function(en_pos) { - return floater(p, { pos: en_pos }); - } - }, - /* - "tkiller": { - start: 1000, num: 1, cap: 5, rate: 20000, - make_new: function(en_pos) { - // target will get set later - return tkiller(p, { - pos: en_pos, - mutation_info: game.get_mutation_info() - }); - } - }, - */ - "multiplier": { - start:0, num: 10, cap: 20, rate: 20000, - make_new: function(en_pos) { - return multiplier(p, { pos : en_pos }); - } - }, - /* - "b_cell": { - start:0, num: 1, cap: 1, rate: 999999, - make_new: function(en_pos) { - return b_cell(p, { pos : en_pos }); - } - }, - */ - "background_object": { - start:0, num: 8, cap: 8, rate: 999999, - spacing: p.width/5, gen_x: 500, - gen_y: function() { - return p.random(200, p.height - 180); - }, - make_new: function(en_pos) { - return background_object(p, { pos: en_pos }); - } - }, - }; - - // list of types of enemies - var enemy_types = keys(gen_info); - /*var random_type = function() { - return random_from(enemy_types);//[p.floor(p.random( - //enemy_types.length))]; - }; - */ - - // just some wrappers - var start = function(type) { - return gen_info[type].start; - }; - var num = function(type) { - return gen_info[type].num; - }; - var cap = function(type) { - return gen_info[type].cap; - }; - var rate = function(type) { - return gen_info[type].rate; - }; - var spacing = function(type) { - // dynamic spacing - if(gen_info[type].spacing === "dynamic") { - return p.width/num(type); - } - return gen_info[type].spacing; - }; - var gen_x_pos = function(type) { - return p.width + (gen_info[type].gen_x || 50); - }; - var gen_y_pos = function(type) { - if (gen_info[type].gen_y) { - return gen_info[type].gen_y(); - } - return p.floor(p.random(90, p.height-50)); - }; - var gen_speed = function(type) { - return gen_info[type].gen_speed; - }; - var make_new = function(type) { - return gen_info[type].make_new; - }; - var diminish = function(type) { - return gen_info[type].diminish || false; - } - var gen_more = function(type) { - if (diminish(type)) { - if (num(type) > cap(type)) { - gen_info[type].num = num(type)-1; - } - } - else { - if (num(type) < cap(type)) { - gen_info[type].num = num(type)+1; - } - } - }; - - // Returns whether it is not too soon to generate another - // object, based on last_obj - var ok_to_generate = function() { - if (last_obj) { - if (last_obj.get_type() === "cell") { - // 2 times width spacing - return last_obj.get_pos().x < - (gen_x_pos(last_obj.get_type()) - last_obj.get_width() * 2); - } - } - // else - return true; - }; - - // --- public methods --- - - //Should be called every time the game updates - obj.update = function() { - //game_objects = game.get_game_objects(); - distance = p.floor(game.get_distance()); - - update_types(); - - var enemy_type = random_from(enemy_types);//random_type(); - var num_enemies = count_enemy(enemy_type); - - // if there aren't enough of that enemy on the board - if (num_enemies < num(enemy_type) - // and some random factor - && p.random(100) < (gen_speed(enemy_type) || default_gen_speed ) - // and we are ready to start making this enemy - && distance >= start(enemy_type)) { - //&& ok_to_generate()) { - - var enemy_y = gen_y_pos(enemy_type); - var enemy_pos = new p.PVector(gen_x_pos(enemy_type), enemy_y); - - var new_enemy = make_new(enemy_type)(enemy_pos); - assert(new_enemy, "Error in generator.update()"); - - // make sure it's far enough away from the last object - // of its type - if (!spaced_out_enough(new_enemy)) { - return; - } - - // make sure it's not overlapping anything else - if (is_overlapping(new_enemy) - && !new_enemy.is("background_object")) { - //console.log("overlapped"); - return; - } - - //Add the new enemy to game_objects - game.add_object(new_enemy); - - // If b cell, must update b cells targets - if (new_enemy.get_type() === "b_cell") { - console.log("made new b_cell"); - game.set_b_cell_target(new_enemy); - } - - last_obj = new_enemy; - } - - }; - - // --- private methods --- - - var update_types = function() { - /* - if (distance % 100 <= 0.5) { - console.log(distance); - } - */ - // update nums for types based on rate - for_each( - enemy_types, - function(type) { - if (distance % rate(type) <= 0.1 - && distance >= 10) { - gen_more(type); - console.log("increased num of "+type+ - "s to "+num(type)); - } - } - ); - }; - - // returns how many of given enemy there are - var count_enemy = function(enemy_type) { - var n = 0; - game.do_to_type(function(o) { n++; }, - enemy_type, true); - return n; - } - - // returns true if the enemy overlaps any game objects - var is_overlapping = function(enemy) { - var overlap = false; - var check_overlap = function(obj) { - if (game.check_circle_collision(enemy, obj)) { - overlap = true; - } - }; - game.do_to_type(check_overlap, "particle", false); - game.do_to_type(check_overlap, "cell", false); - game.do_to_type(check_overlap, "enemy", false); - game.do_to_type(check_overlap, "wall_segment", false); - return overlap; - }; - - // returns true if the new enemy if far enough away (in x coord) - // from the rightmost of its type - // or if there is no spacing requirement for that type - var spaced_out_enough = function(new_enemy) { - var to_return = true; - // if there is spacing defined for this type - if (spacing(new_enemy.get_type())) { - var min_dist = 99999; - // find the closest object of the type - game.do_to_type( - function(o) { - var dist = new_enemy.get_pos().dist(o.get_pos()); - if (dist < min_dist) { - min_dist = dist; - // check if it is too close - if (dist < spacing(new_enemy.get_type())) { - to_return = false; - } - } - }, - new_enemy.get_type(), true - ); - } - return to_return; - }; - - - - /* - // return true if it is far enough apart from rightmost of its type - return new_enemy.get_pos().dist( - rightmost(new_enemy.get_type()).get_pos()) - > spacing(new_enemy.get_type()); - } - return true; - }; - - /* - var rightmost = function(type) { - var rightmost_x = 0; - var rightmost; - game.do_to_type( - function(o) { - if (o.get_pos().x > rightmost_x) { - rightmost = o; - rightmost_x = o.get_pos().x; - } - }, - type, true - ); - return rightmost; - }; - */ - - // returns an object: - // cell: number of cells on the screen - // wall_cell: number of wall_cells - // empty_cell: number of empty_cells - // tkiller: number of tkillers - // floater: number of floaters - var get_enemies = (function() { - var total = 0; - - // These are the types to check - //var types = ["cell", "wall_cell", "empty_cell", - // "floater", "tkiller"]; - - //Checks if an element is in an array - var member = function(arr, elem) { - return (arr.indexOf(elem) != -1); - }; - - var get_em = function() { - var enemies = { "cell":0, "wall_cell":0, - "empty_cell":0, "floater":0, "tkiller":0, - "multiplier":0, "b_cell":0}; - - // increment counter for each object - var incr = function(o) { - enemies[o.get_type()] += 1; - }; - game.do_to_type(incr, "cell", false); - game.do_to_type(incr, "enemy", false); - }; - /*for (var type in enemies) { - if (enemies.hasOwnProperty(type)) { - game.do_to_type( - function(o) { - enemies[type] += 1; - }, - type, true); - } - } - /*for (var i = 0; i < game_objects.length; i++) { - var lst = game_objects[i]; - for (var j = 0; j < lst.length; j++) { - var obj = lst[j]; - if (member(types, obj.get_type())) { - total++; - } - } - } - return total; - */ - - return get_em; - }()); - - return obj; -}; diff --git a/game/fb/global_functions.js b/game/fb/global_functions.js deleted file mode 100644 index d6c3167..0000000 --- a/game/fb/global_functions.js +++ /dev/null @@ -1,90 +0,0 @@ -// ** Global Constants -//DEFAULT_SCROLL_DIST = -0.8; - -// *** global_functions *** -// Holds functions used in the whole project - -//Have to catch it so fuck it -/* -function AssertException(message) { this.message = message}; -function assert(exp, message) { - if (!exp) { - throw new AssertException(message); - } -} -*/ - -var assert = function(exp, message) { - if (!exp) { - console.error("Assert error!: " + message); - } -}; - -//Does something to every element of an arr -var for_each = function(arr, fun) { - for (var i = 0; i < arr.length; i++) { - fun(arr[i]); - } -}; - -// returns the index+1 of an element in a list, -// otherwise false -// can't return just the index because 0 is false in js -var member = function(arr, elt) { - for (var i=0; i 1 ? '.' + x[1] : ''; - var rgx = /(\d+)(\d{3})/; - while (rgx.test(x1)) { - x1 = x1.replace(rgx, '$1' + ',' + '$2'); - } - return prefix + x1 + x2; -}; - diff --git a/game/fb/help.txt b/game/fb/help.txt deleted file mode 100644 index 7bdf35b..0000000 --- a/game/fb/help.txt +++ /dev/null @@ -1,9 +0,0 @@ -You've managed to infiltrate the human body's defenses and get your virus particle into the bloodstream! Now you must infect cells and use them to make more copies of your virus before the immune system wipes you out. - -After a particle infects a cell, the virus will use the cell's machinery to start making copies of itself. Once the cell is full of new virus particles, press the SPACEBAR or click the MOUSE to kill the cell, causing virus particles to burst through the cell wall towards other cells in the direction the arrow is pointing. You can pick which cell to burst using the LEFT and RIGHT arrow keys. - -Aim carefully though, because the immune system has sent out macrophages to absorb your particles. If a particle hits a macrophage, it will signal a B-cell, which will start producing antibodies. If an antibody attaches to an infected cell, a T-cell will attack it. If you don't burst the cell in time, the T-cell will kill it, destroying all the particles inside! - -Luckily, your virus can mutate and temporarily escape the immune system. Every time the virus replicates, there are errors when copying the virus's genetic material. These errors may cause mutations in the virus. Each time you infect a cell, the virus becomes more and more likely to mutate. Once you mutate, the immune system will not be able to attack you until a macrophage absorbs a virus particle from the new strain. - -How long will your virus be able to survive? diff --git a/game/fb/help_state.js b/game/fb/help_state.js deleted file mode 100644 index 27addf4..0000000 --- a/game/fb/help_state.js +++ /dev/null @@ -1,626 +0,0 @@ -var help_state = function (p, prev_state) { - - var help_image = image_manager.get_image("helpsplash.png"); - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var screens = []; - var screen_w = help_image.width - 180; - var screen_h = help_image.height - 200; - var screen_pos = new p.PVector(p.width/2, p.height/2-15); - - var screen_index = 0; - var cur_screen = function() { - return screens[screen_index]; - }; - var next_screen = function() { - if (screen_index <= screens.length-1) { - screen_index += 1; - if (screen_index === screens.length-1) { - next_button.deactivate(); - } - previous_button.activate(); - return true; - } - return false; - }; - var previous_screen = function() { - if (screen_index >= 0) { - screen_index -= 1; - if (screen_index === 0) { - previous_button.deactivate(); - } - next_button.activate(); - return true; - } - return false; - }; - - // a screen is a panel that goes in the screens array - // it displays one or more item - // spec: - // - pos: PVector representing the center of the screen - // - width - // - height - var screen = function(spec) { - var obj = {}; - var items = []; - obj.add_item = function(item) { - items.push(item); - }; - - obj.render = function() { - p.pushMatrix(); - - p.translate(spec.pos.x-spec.width/2, spec.pos.y-spec.height/2); - - // debugging - /* - p.noFill(); - p.stroke(255); - p.rect(0, 0, spec.width, spec.height); - */ - - // translate and render each item - var padding = 15; - for_each( - items, - function(item) { - item.render(); - p.translate(0, item.height()+padding); - } - ); - - p.popMatrix(); - }; - - return obj; - }; - - var new_screen = function() { - return screen({ - pos: screen_pos, - width: screen_w, - height: screen_h - }); - }; - - // item displays text and an image as part of a screen - // spec: - // - width - // - height - // - text - the text to display - // - title - the name of this item (optional) - // - image - image to display - // - illustration (obj) - // - width, height - dimensions for the illustration - // - draw - function that draws some illustration - // (origin at top left corner) - // - img_left - boolean, true if the image/ill should go on the left, - // false for the right - // (should only have image or illustration) - // - var item = function(spec) { - var obj = {}; - - // auto height - spec.height = spec.height - // the 0 here just takes us to the next cond - || (spec.image ? spec.image.height : 0) - // the actual default is at the end of this - || (spec.illustration ? spec.illustration.height : 80); - spec.width = spec.width || screen_w; - spec.padding = spec.padding || 10; - - obj.height = function() { return spec.height; }; - - obj.render = function() { - var text_x = 0; - var text_y = 0; - var text_w = spec.width; - - if (spec.image || spec.illustration) { - // make adjustments based on either one - var i = spec.image || spec.illustration; - text_w -= i.width + spec.padding; - var img_x = spec.width - i.width; - if (spec.img_left) { - img_x = 0; - text_x = i.width + spec.padding; - } - // draw either - if (spec.image) { - p.imageMode(p.CORNER); - p.image(spec.image, img_x, 0); - } - else { - p.pushMatrix(); - p.translate(img_x, 0); - spec.illustration.draw(); - p.popMatrix(); - } - } - - p.textLeading(14); - if (spec.title) { - p.textSize(18); - p.textAlign(p.LEFT, p.TOP); - p.fill(255); - p.text(spec.title, text_x, 0); - text_y += p.textAscent(); - } - p.textSize(14); - p.textAlign(p.LEFT, p.TOP); - p.fill(255); - p.text(spec.text, text_x, text_y, text_w, spec.height-text_y); - }; - - return obj; - }; - - // init the help screens - // eval'd immediately - var init_screens = (function() { - var color1 = 0xffffff00; - var color2 = 0xff7f2aff; - var cimg = image_manager.get_image("infectable_cell_2n.png"); - - var s1 = new_screen(); - screens.push(s1); - s1.add_item(item({ - text: "You've infiltrated the human body's defenses and gotten your virus particle (or virion) into the bloodstream! Here are the cells you may encounter:", - height: 45, - padding: 1, - illustration: { - width: 30, height: 30, - draw: function() { - var img = image_manager.get_image("tinyvirus_trans.png"); - var w = 15; - var h = 15; - p.fill(color1); - p.noStroke(); - p.ellipse(w, h, w*.75, h*.75); - p.imageMode(p.CENTER); - p.image(img, w, h, w, h); - } - }, - img_left: false - })); - s1.add_item(item({ - title: "Infectable (Permissive) Cells", - text: "Hit an infectable cell with a virion to infect it. After penetrating the cell wall, the virion will use the cell's machinery to make copies of itself.", - //image: cimg, - illustration: { - width: 50, height: 60, - draw: (function() { - var c = cell(p, { - pos: new p.PVector(30, 30), - width: 30, height: 30, - illustration: true - }); - c.set_image(cimg); - //c.set_state("active"); - return function() { - c.draw(); - }; - }()), - }, - img_left: true - })); - s1.add_item(item({ - text: "Press SPACEBAR or click the MOUSE to burst an infected cell and shoot the new virions in the direction of the arrow. Pick which cell to burst using the LEFT and RIGHT arrow keys.", - //image: image_manager.get_image("infectable_cell_2n.png"), - illustration: { - width: 30, height: 60, - draw: (function() { - var c = cell(p, { - pos: new p.PVector(20, 30), - width: 30, height: 30, - mutation_info: { color: color1 }, - illustration: true - }); - c.set_image(cimg); - c.set_state("active"); - return function() { - c.draw(); - }; - }()), - }, - img_left: false - })); - s1.add_item(item({ - title: "Non-permissive Cells", - text: "Some cells can be infected, but will not let your virion replicate. A virion that infects a non-permissive cell is as good as dead.", - illustration: { - width: 50, height: 60, - draw: (function() { - var c = empty_cell(p, { - pos: new p.PVector(30, 30), - width: 30, height: 30, - }); - return function() { - c.draw(); - }; - }()), - }, - img_left: true - })); - s1.add_item(item({ - title: "Resistant Cells", - text: "Virions can't break through the cell wall of resistant cells - they will just bounce off in the other direction.", - height: 60, - illustration: { - width: 30, height: 60, - draw: (function() { - var c = wall_cell(p, { - pos: new p.PVector(20, 30), - //width: 30, height: 30, - }); - return function() { - c.draw(); - }; - }()), - }, - img_left: false - })); - - var s2 = new_screen(); - screens.push(s2); - s2.add_item(item({ - text: "Be careful! The immune system will try to destroy your virus. Here are the enemies you should look out for:", - height: 30 - })); - s2.add_item(item({ - title: "Macrophages", - text: "The immune system's first line of defense. They will absorb any virion that hits them and then signal a B cell to give it information about your virus.", - height: 80, - //image: image_manager.get_image("macrophage_1.png"), - illustration: { - width: 50, height: 70, - draw: (function() { - var m = floater(p, { - pos: new p.PVector(25, 35), - width: 50, height: 70, - mutation_info: { color: color1 }, - illustration: true - }); - m.activate(); - return function() { - m.draw(); - }; - }()) - }, - img_left: true - })); - s2.add_item(item({ - title: "B Cells", - text: "Once a B cell knows about your virus, it will produce Y-shaped antibodies that will attach to infected cells, marking them for destruction.", - height: 70, - //image: image_manager.get_image("bcell_normal.png"), - illustration: { - width: 60, height: 60, - draw: (function() { - var b = b_cell(p, { - pos: new p.PVector(30, 55), - width: 40, height: 40, - mutation_info: { color: color1 }, - illustration: true - }); - b.set_state("active"); - b.set_target_angle(-p.PI/2); - - var a1 = antibody(p, { - pos: new p.PVector(40, 17), - mutation_info: { color: color1 }, - }); - a1.set_target_angle(-p.PI/4); - - var a2 = antibody(p, { - pos: new p.PVector(18, 23), - mutation_info: { color: color1 }, - }); - a2.set_target_angle(-3*p.PI/4+.2); - - return function() { - // make a thicker antibody - b.set_anti_count(10); - b.draw(); - a1.draw(); - a2.draw(); - }; - }()) - }, - img_left: false - })); - s2.add_item(item({ - title: "Granulocytes", - text: "If an infected cell is marked with an antibody, the granulocyte will hunt it down and destroy it, along with all the virions inside!", - //image: image_manager.get_image("tcell_2.png"), - illustration: { - width: 60, height: 60, - draw: (function() { - var tk = tkiller(p, { - pos: new p.PVector(30, 30), - width: 60, height: 60, - mutation_info: { color: color1 }, - illustration: true - }); - //tk.set_state("alive"); - - return function() { - tk.draw(); - }; - }()) - }, - img_left: true - })); - - var s3 = new_screen(); - screens.push(s3); - s3.add_item(item({ - title: "Mutation", - text: "Luckily, in the process of replicating a virus's genetic material, mistakes are often made, causing the virus to mutate! If a mutation occurs, a new strain of the virus will be created. Every time you infect a cell, the chance of a mutation occurring increases.", - height: 120, - padding: 15, - illustration: { - width: 90, height: 90, - draw: (function() { - var c1 = cell(p, { - pos: new p.PVector(10, 20), - width: 30, height: 30, - mutation_info: { color: color1 }, - illustration: true - }); - c1.set_image(cimg); - c1.set_state("infected"); - - var c2 = cell(p, { - pos: new p.PVector(70, 80), - width: 30, height: 30, - mutation_info: { color: color2 }, - illustration: true - }); - c2.set_image(cimg); - c2.set_state("infected"); - - return function() { - c1.draw(); - c2.draw(); - p.stroke(255); - p.strokeWeight(3); - p.line(30, 40, 50, 60); - p.line(50, 60, 50, 50); - p.line(50, 60, 40, 60); - }; - }()), - }, - img_left: false - })); - s3.add_item(item({ - text: "Macrophages, B cells, granulocytes, and antibodies are created to attack a specific strain of a virus. So when your virus mutates, the new strain will be safe from the old enemies.", - //image: image_manager.get_image("macrophage_1.png"), - padding: 15, - illustration: { - width: 60, height: 60, - draw: (function() { - var tk = tkiller(p, { - pos: new p.PVector(50, 10), - mutation_info: { color: color1 }, - illustration: true - }); - tk.set_target_angle(-p.PI/4); - //tk.set_state("illustration"); - - var c = cell(p, { - pos: new p.PVector(10, 40), - width: 30, height: 30, - mutation_info: { color: color2 }, - illustration: true - }); - c.set_image(cimg); - c.set_state("infected"); - - var a = antibody(p, { - pos: new p.PVector(20, 15), - mutation_info: { color: color2 } - }); - a.set_target(c); - a.update(); - - return function() { - tk.draw(); - c.draw(); - a.draw(); - }; - }()), - }, - img_left: true - })); - s3.add_item(item({ - text: "Each new strain will be represented by a different color. Therefore, an infected cell can only be attacked by enemies of the same color.", - //image: image_manager.get_image("tcell_2.png"), - //padding: 15, - illustration: { - width: 60, height: 50, - draw: (function() { - var tk = tkiller(p, { - pos: new p.PVector(50, 12), - mutation_info: { color: color2 }, - illustration: true - }); - //tk.set_target_angle(p.PI/4); - //tk.set_state("illustration"); - - var c = cell(p, { - pos: new p.PVector(15, 40), - width: 30, height: 30, - mutation_info: { color: color2 }, - illustration: true - }); - c.set_image(cimg); - c.set_state("infected"); - - tk.set_target(c); - tk.update(); - - var a = antibody(p, { - pos: new p.PVector(5, 15), - mutation_info: { color: color2 } - }); - a.set_target(c); - a.update(); - - return function() { - tk.draw(); - c.draw(); - a.draw(); - }; - }()), - }, - img_left: false - })); - s3.add_item(item({ - title: "Multiplier Particles", - text: "Higher mutation levels will give you more points, as will collecting multiplier particles. When you infect a cell, the amount of points you get is multiplied by your multiplier and level.", - illustration: { - width: 50, height: 90, - draw: (function() { - var poss = [ - new p.PVector(10, 10), - new p.PVector(27, 25), - new p.PVector(20, 45), - new p.PVector(35, 50), - //new p.PVector(23, 30), - new p.PVector(40, 12) - ]; - var ms = []; - for_each(poss, - function(pos) { - ms.push(multiplier(p, { pos: pos })); - } - ); - - return function() { - for_each(ms, function(m) { m.draw(); }); - }; - }()), - }, - img_left: true - })); - - - }()); - - - /* - var box_w = 370; - var box_h = 500; - var box_x = p.width/2 - box_w/2; - var box_y = p.height/2 - box_h/2; - */ - - // Buttons - var button_y = p.height/2 + 190; - var button_style = { - width: 120, - height: 50, - }; - - var back_button = button(p, { - state : function() { sounds.play_button_back(); return prev_state; }, - rect : { - pos : new p.PVector(p.width/2, button_y), //box_x+box_w-80, box_y+box_h-30), - //text: "Back", - //text_x_offset: 5, - //text_y_offset: -8, - image: "back.png", - } - }); - - var next_button = button(p, { - state: function() { - sounds.play_button_click(); - next_screen(); - return obj; - }, - rect: { - pos: new p.PVector(p.width/2+120, button_y), - //text: "Next", - image: "next.png", - //style: button_style - } - }); - - var previous_button = button(p, { - state: function() { - sounds.play_button_back(); - previous_screen(); - return obj; - }, - rect: { - pos: new p.PVector(p.width/2-120, button_y), - //text: "Previous", - image: "previous.png", - //style: button_style - } - }); - previous_button.deactivate(); - - //Not ordered - var all_buttons = [ previous_button, back_button, next_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "help"; - }; - - obj.update = function() { - //do nothing - }; - - - obj.render = function() { - //p.pushMatrix(); - - p.imageMode(p.CENTER); - p.image(help_image, p.width/2, p.height/2); - - cur_screen().render(); - - //p.translate(box_x, box_y); - - //p.fill(0); - //p.rect(0, 0, box_w, box_h); - - //p.noStroke(); - //p.fill(255); - - //p.textAlign(p.CENTER, p.CENTER); - //p.textSize(24); - //p.text("Instructions", box_w/2, 30); - - //p.textAlign(p.LEFT, p.CENTER); - //p.textSize(13); - //p.text(instruction_text, - //5, 20, box_w, box_h-50); - - //p.popMatrix(); - }; - - obj.key_pressed = function(k) { - if (k === 104) { //h - obj.set_next_state(help_button.get_state()); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/game/fb/high_scores_state.js b/game/fb/high_scores_state.js deleted file mode 100644 index 4f3583f..0000000 --- a/game/fb/high_scores_state.js +++ /dev/null @@ -1,83 +0,0 @@ -var high_scores_state = function (p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - // Buttons - - var button_style = { - text_size: 14, - text_align: p.LEFT, - text_x_offset: 25, - width: 120, - height: 50, - }; - - var back_button = button(p, { - state : function() { - sounds.play_button_back(); - - // hide the div - $("#scores-wrap").hide(); - $("#scores").tabs("destroy"); - return prev_state;//splash_state(p); - }, - rect : { - pos : new p.PVector(540, 550), - //text: "Main Menu", - //text_x_offset: -5, - image: "back.png", - //image_x_offset: -5, - //style: button_style - } - }); - - //Not ordered - var all_buttons = [ back_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "high_scores"; - }; - - obj.update = function() { - }; - - obj.render = function() { - p.noStroke(); - p.fill(0, 150); - p.rect(0, 0, p.width, p.height); - }; - - obj.key_pressed = function(k) { - /* - if (k === 112 || p.keyCode == 13) { //p, enter - obj.exit_state(); - } - */ - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - // init the scores immediately - var init = (function() { - // add a loading message to be removed on load - $("#scores-wrap").prepend( - "
      Loading high score data...
      " - ); - - // show the div - $("#scores-wrap").show(); - // update and render scores - // TODO what if it fails? - scores.do_scores(); - }()); - - return obj; -}; diff --git a/game/fb/image_manager.js b/game/fb/image_manager.js deleted file mode 100644 index 0b7192e..0000000 --- a/game/fb/image_manager.js +++ /dev/null @@ -1,171 +0,0 @@ -// image_manager preloads and holds all the images used in the game - -var make_image_manager = function() { - - // obj to return - var obj = []; - - // --- private variables --- - - // this will be counted in preloading - var num_images = 0; - - // object to hold all arrays of image paths - // and the dir name that they come from - // dir should be name after "images/" and must end in '/' - var all_images = { - infectable_cell : { dir : "infectable_cell/" }, - empty_cell : { dir : "noninfectable_cell/" }, - background : { dir : "background_objects/" }, - screens : { dir : "screens/" }, - wall_segments : { dir : "wall_segments/" }, - macrophage : {dir : "macrophage_animation/"}, - macrophage_active : {dir : "holemacrophage_animation/"}, - bcell : {dir : "b_animation/"}, - burst : { dir : "burstingcell_animation/"}, - cell_infect : { dir : "cellinfect_animation/"}, - t_animation : { dir : "t_animation/"}, - buttons : { dir : "buttons/"}, - // catches all images in images/ - other : { dir : "" }, - }; - - // add "arr" property to each image - for_each( - keys(all_images), - function(key) { - all_images[key].images = []; - } - ); - - // filter out non-images from global image file list - var image_types = ["png", "jpg", "gif"]; - for_each( - keys(all_image_files), - function(key) { - all_image_files[key] = all_image_files[key].filter( - function(name) { - return member(image_types, - name.substring(name.lastIndexOf('.')+1)); - } - ); - } - ); - - // --- public methods --- - - // returns all the image objects of a given type - // if preloading and initing is done - // NOTE: returns a copy of the array of pointers, but the pointers - // will all point to the same objects so don't change the objects - obj.get_images = function(type) { - if (!all_images[type]) { - console.error("Invalid image type: "+type); - } - //for_each(all_images[type], console.log() - return all_images[type].images.slice(); - }; - - // finds and returns the first image with the given name - // (no path necessary) - obj.get_image = function(name) { - var to_return; - for_each( - keys(all_images), - function(key) { - for_each( - all_images[key].images, - function(img_obj) { - if (name === img_obj.path.substring( - img_obj.path.lastIndexOf('/')+1)) { - to_return = img_obj.image; - } - } - ); - } - ); - if (!to_return) { - console.error("Invalid image name: "+name); - } - return to_return; - }; - - // preloads all the images - obj.preload_images = function() { - console.log("preloading images"); - for_each_image( - function(path) { - // let processing load it in the cache - sketch.imageCache.add(path); - // count it - num_images += 1; - console.log("loading "+path); - } - ); - }; - - // DO NOT CALL BEFORE CALLING PRELOAD - obj.num_loaded = function() { - return num_images - sketch.imageCache.pending; - }; - - // DO NOT CALL BEFORE CALLING PRELOAD - obj.num_images = function() { - return num_images; - }; - - // DO NOT CALL BEFORE CALLING PRELOAD - obj.is_done_preloading = function() { - return !sketch.imageCache.pending; - }; - - // DO NOT CALL BEFORE PRELOADING IS DONE - // should be called after preloading is done - // to make the image objects - // note: must be passed a processing instance p - obj.init_images = function(p) { - console.log("initing images"); - for_each_image( - function(img_path, type) { - // make an actual image object for each preloaded image - all_images[type].images.push({ - path: img_path, - image: p.loadImage(img_path), - }); - } - ); - }; - - // --- private methods --- - - // gets array of paths from the object populated by the php function - var files_in_dir = function(dir_path) { - if (!all_image_files[dir_path]) { - console.error("Invalid dir: "+dir_path); - } - return all_image_files[dir_path]; - }; - - // applies f to each image path - // f takes a path and an image type (key) - var for_each_image = function(f) { - // for each type of image - for_each( - keys(all_images), - function(key) { - // for each image in the dir - for_each( - files_in_dir("images/"+all_images[key].dir), - function(path) { - f(path, key); - } - ); - } - ); - }; - - return obj; -}; - -// make a global instance -var image_manager = make_image_manager(); diff --git a/game/fb/images/b_animation/bcell_a01.png b/game/fb/images/b_animation/bcell_a01.png deleted file mode 100644 index a11fd65..0000000 Binary files a/game/fb/images/b_animation/bcell_a01.png and /dev/null differ diff --git a/game/fb/images/b_animation/bcell_a02.png b/game/fb/images/b_animation/bcell_a02.png deleted file mode 100644 index 2cdf59d..0000000 Binary files a/game/fb/images/b_animation/bcell_a02.png and /dev/null differ diff --git a/game/fb/images/b_animation/bcell_a03.png b/game/fb/images/b_animation/bcell_a03.png deleted file mode 100644 index 0751bbe..0000000 Binary files a/game/fb/images/b_animation/bcell_a03.png and /dev/null differ diff --git a/game/fb/images/b_animation/bcell_a04.png b/game/fb/images/b_animation/bcell_a04.png deleted file mode 100644 index e1ff517..0000000 Binary files a/game/fb/images/b_animation/bcell_a04.png and /dev/null differ diff --git a/game/fb/images/b_animation/bcell_a05.png b/game/fb/images/b_animation/bcell_a05.png deleted file mode 100644 index d95d849..0000000 Binary files a/game/fb/images/b_animation/bcell_a05.png and /dev/null differ diff --git a/game/fb/images/b_animation/bcell_a06.png b/game/fb/images/b_animation/bcell_a06.png deleted file mode 100644 index 4d11066..0000000 Binary files a/game/fb/images/b_animation/bcell_a06.png and /dev/null differ diff --git a/game/fb/images/b_animation/bcell_a07.png b/game/fb/images/b_animation/bcell_a07.png deleted file mode 100644 index 1f2efb1..0000000 Binary files a/game/fb/images/b_animation/bcell_a07.png and /dev/null differ diff --git a/game/fb/images/background1.png b/game/fb/images/background1.png deleted file mode 100644 index 0232c24..0000000 Binary files a/game/fb/images/background1.png and /dev/null differ diff --git a/game/fb/images/background_bottomside.png b/game/fb/images/background_bottomside.png deleted file mode 100644 index 039dd50..0000000 Binary files a/game/fb/images/background_bottomside.png and /dev/null differ diff --git a/game/fb/images/background_objects/.DS_Store b/game/fb/images/background_objects/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/fb/images/background_objects/.DS_Store and /dev/null differ diff --git a/game/fb/images/background_objects/background_bcells1.png b/game/fb/images/background_objects/background_bcells1.png deleted file mode 100644 index 6de753b..0000000 Binary files a/game/fb/images/background_objects/background_bcells1.png and /dev/null differ diff --git a/game/fb/images/background_objects/background_bcells2.png b/game/fb/images/background_objects/background_bcells2.png deleted file mode 100644 index 3a523d9..0000000 Binary files a/game/fb/images/background_objects/background_bcells2.png and /dev/null differ diff --git a/game/fb/images/background_objects/background_bcells3.png b/game/fb/images/background_objects/background_bcells3.png deleted file mode 100644 index ef718b9..0000000 Binary files a/game/fb/images/background_objects/background_bcells3.png and /dev/null differ diff --git a/game/fb/images/background_objects/background_bcells4.png b/game/fb/images/background_objects/background_bcells4.png deleted file mode 100644 index 6295cbd..0000000 Binary files a/game/fb/images/background_objects/background_bcells4.png and /dev/null differ diff --git a/game/fb/images/background_objects/background_dstreaks1.png b/game/fb/images/background_objects/background_dstreaks1.png deleted file mode 100644 index 825f60f..0000000 Binary files a/game/fb/images/background_objects/background_dstreaks1.png and /dev/null differ diff --git a/game/fb/images/background_objects/background_dstreaks2.png b/game/fb/images/background_objects/background_dstreaks2.png deleted file mode 100644 index a6f0582..0000000 Binary files a/game/fb/images/background_objects/background_dstreaks2.png and /dev/null differ diff --git a/game/fb/images/background_objects/background_dstreaks3.png b/game/fb/images/background_objects/background_dstreaks3.png deleted file mode 100644 index c65a2f8..0000000 Binary files a/game/fb/images/background_objects/background_dstreaks3.png and /dev/null differ diff --git a/game/fb/images/background_objects/background_lstreaks1.png b/game/fb/images/background_objects/background_lstreaks1.png deleted file mode 100644 index 74595f5..0000000 Binary files a/game/fb/images/background_objects/background_lstreaks1.png and /dev/null differ diff --git a/game/fb/images/background_objects/background_lstreaks2.png b/game/fb/images/background_objects/background_lstreaks2.png deleted file mode 100644 index 62d1f4e..0000000 Binary files a/game/fb/images/background_objects/background_lstreaks2.png and /dev/null differ diff --git a/game/fb/images/background_topside.png b/game/fb/images/background_topside.png deleted file mode 100644 index 613f9ac..0000000 Binary files a/game/fb/images/background_topside.png and /dev/null differ diff --git a/game/fb/images/bcell_normal.png b/game/fb/images/bcell_normal.png deleted file mode 100644 index 60b8545..0000000 Binary files a/game/fb/images/bcell_normal.png and /dev/null differ diff --git a/game/fb/images/bullet_listcell.png b/game/fb/images/bullet_listcell.png deleted file mode 100644 index b778d5c..0000000 Binary files a/game/fb/images/bullet_listcell.png and /dev/null differ diff --git a/game/fb/images/burstingcell_animation/burst_a01.png b/game/fb/images/burstingcell_animation/burst_a01.png deleted file mode 100644 index 464828e..0000000 Binary files a/game/fb/images/burstingcell_animation/burst_a01.png and /dev/null differ diff --git a/game/fb/images/burstingcell_animation/burst_a02.png b/game/fb/images/burstingcell_animation/burst_a02.png deleted file mode 100644 index 87f6492..0000000 Binary files a/game/fb/images/burstingcell_animation/burst_a02.png and /dev/null differ diff --git a/game/fb/images/burstingcell_animation/burst_a03.png b/game/fb/images/burstingcell_animation/burst_a03.png deleted file mode 100644 index bb6d224..0000000 Binary files a/game/fb/images/burstingcell_animation/burst_a03.png and /dev/null differ diff --git a/game/fb/images/burstingcell_animation/burst_a04.png b/game/fb/images/burstingcell_animation/burst_a04.png deleted file mode 100644 index 174dd4a..0000000 Binary files a/game/fb/images/burstingcell_animation/burst_a04.png and /dev/null differ diff --git a/game/fb/images/burstingcell_animation/burst_a05.png b/game/fb/images/burstingcell_animation/burst_a05.png deleted file mode 100644 index 50fa69f..0000000 Binary files a/game/fb/images/burstingcell_animation/burst_a05.png and /dev/null differ diff --git a/game/fb/images/burstingcell_animation/burst_a06.png b/game/fb/images/burstingcell_animation/burst_a06.png deleted file mode 100644 index 414accb..0000000 Binary files a/game/fb/images/burstingcell_animation/burst_a06.png and /dev/null differ diff --git a/game/fb/images/burstingcell_animation/burst_a07.png b/game/fb/images/burstingcell_animation/burst_a07.png deleted file mode 100644 index 0aa533b..0000000 Binary files a/game/fb/images/burstingcell_animation/burst_a07.png and /dev/null differ diff --git a/game/fb/images/burstingcell_animation/burst_a08.png b/game/fb/images/burstingcell_animation/burst_a08.png deleted file mode 100644 index 735a858..0000000 Binary files a/game/fb/images/burstingcell_animation/burst_a08.png and /dev/null differ diff --git a/game/fb/images/burstingcell_animation/burst_a09.png b/game/fb/images/burstingcell_animation/burst_a09.png deleted file mode 100644 index 74f67d9..0000000 Binary files a/game/fb/images/burstingcell_animation/burst_a09.png and /dev/null differ diff --git a/game/fb/images/burstingcell_animation/burst_a10.png b/game/fb/images/burstingcell_animation/burst_a10.png deleted file mode 100644 index 5182129..0000000 Binary files a/game/fb/images/burstingcell_animation/burst_a10.png and /dev/null differ diff --git a/game/fb/images/burstingcell_animation/burst_a11.png b/game/fb/images/burstingcell_animation/burst_a11.png deleted file mode 100644 index cb79f9a..0000000 Binary files a/game/fb/images/burstingcell_animation/burst_a11.png and /dev/null differ diff --git a/game/fb/images/burstingcell_animation/burst_a12.png b/game/fb/images/burstingcell_animation/burst_a12.png deleted file mode 100644 index 7a75730..0000000 Binary files a/game/fb/images/burstingcell_animation/burst_a12.png and /dev/null differ diff --git a/game/fb/images/burstingcell_animation/burst_a13.png b/game/fb/images/burstingcell_animation/burst_a13.png deleted file mode 100644 index d1054f6..0000000 Binary files a/game/fb/images/burstingcell_animation/burst_a13.png and /dev/null differ diff --git a/game/fb/images/buttons/back.png b/game/fb/images/buttons/back.png deleted file mode 100644 index a6e28a9..0000000 Binary files a/game/fb/images/buttons/back.png and /dev/null differ diff --git a/game/fb/images/buttons/check0.png b/game/fb/images/buttons/check0.png deleted file mode 100644 index 993c88a..0000000 Binary files a/game/fb/images/buttons/check0.png and /dev/null differ diff --git a/game/fb/images/buttons/check1.png b/game/fb/images/buttons/check1.png deleted file mode 100644 index 0207b44..0000000 Binary files a/game/fb/images/buttons/check1.png and /dev/null differ diff --git a/game/fb/images/buttons/continue.png b/game/fb/images/buttons/continue.png deleted file mode 100644 index f5f4bed..0000000 Binary files a/game/fb/images/buttons/continue.png and /dev/null differ diff --git a/game/fb/images/buttons/credits.png b/game/fb/images/buttons/credits.png deleted file mode 100644 index 567677e..0000000 Binary files a/game/fb/images/buttons/credits.png and /dev/null differ diff --git a/game/fb/images/buttons/highscores.png b/game/fb/images/buttons/highscores.png deleted file mode 100644 index e59ce26..0000000 Binary files a/game/fb/images/buttons/highscores.png and /dev/null differ diff --git a/game/fb/images/buttons/infectfriends.png b/game/fb/images/buttons/infectfriends.png deleted file mode 100644 index 6bd07d4..0000000 Binary files a/game/fb/images/buttons/infectfriends.png and /dev/null differ diff --git a/game/fb/images/buttons/instructions.png b/game/fb/images/buttons/instructions.png deleted file mode 100644 index ab6ee9b..0000000 Binary files a/game/fb/images/buttons/instructions.png and /dev/null differ diff --git a/game/fb/images/buttons/mainmenu.png b/game/fb/images/buttons/mainmenu.png deleted file mode 100644 index 3778426..0000000 Binary files a/game/fb/images/buttons/mainmenu.png and /dev/null differ diff --git a/game/fb/images/buttons/mainscreenmockup.jpg b/game/fb/images/buttons/mainscreenmockup.jpg deleted file mode 100755 index 859bae9..0000000 Binary files a/game/fb/images/buttons/mainscreenmockup.jpg and /dev/null differ diff --git a/game/fb/images/buttons/mbeginner.png b/game/fb/images/buttons/mbeginner.png deleted file mode 100755 index e8a99e9..0000000 Binary files a/game/fb/images/buttons/mbeginner.png and /dev/null differ diff --git a/game/fb/images/buttons/mbeginner_r.png b/game/fb/images/buttons/mbeginner_r.png deleted file mode 100755 index 5eeee23..0000000 Binary files a/game/fb/images/buttons/mbeginner_r.png and /dev/null differ diff --git a/game/fb/images/buttons/mhighscores.png b/game/fb/images/buttons/mhighscores.png deleted file mode 100755 index 7065e7b..0000000 Binary files a/game/fb/images/buttons/mhighscores.png and /dev/null differ diff --git a/game/fb/images/buttons/mhighscores_r.png b/game/fb/images/buttons/mhighscores_r.png deleted file mode 100644 index 78ff539..0000000 Binary files a/game/fb/images/buttons/mhighscores_r.png and /dev/null differ diff --git a/game/fb/images/buttons/mhowtoplay.png b/game/fb/images/buttons/mhowtoplay.png deleted file mode 100755 index 229ff4d..0000000 Binary files a/game/fb/images/buttons/mhowtoplay.png and /dev/null differ diff --git a/game/fb/images/buttons/mhowtoplay_r.png b/game/fb/images/buttons/mhowtoplay_r.png deleted file mode 100755 index a21644f..0000000 Binary files a/game/fb/images/buttons/mhowtoplay_r.png and /dev/null differ diff --git a/game/fb/images/buttons/mnewgame.png b/game/fb/images/buttons/mnewgame.png deleted file mode 100644 index 37ae877..0000000 Binary files a/game/fb/images/buttons/mnewgame.png and /dev/null differ diff --git a/game/fb/images/buttons/mnewgame_r.png b/game/fb/images/buttons/mnewgame_r.png deleted file mode 100644 index b8359c5..0000000 Binary files a/game/fb/images/buttons/mnewgame_r.png and /dev/null differ diff --git a/game/fb/images/buttons/mnormal.png b/game/fb/images/buttons/mnormal.png deleted file mode 100755 index a8cd0ce..0000000 Binary files a/game/fb/images/buttons/mnormal.png and /dev/null differ diff --git a/game/fb/images/buttons/mnormal_r.png b/game/fb/images/buttons/mnormal_r.png deleted file mode 100755 index ee2139d..0000000 Binary files a/game/fb/images/buttons/mnormal_r.png and /dev/null differ diff --git a/game/fb/images/buttons/msettings.png b/game/fb/images/buttons/msettings.png deleted file mode 100644 index e1fc244..0000000 Binary files a/game/fb/images/buttons/msettings.png and /dev/null differ diff --git a/game/fb/images/buttons/msettings_r.png b/game/fb/images/buttons/msettings_r.png deleted file mode 100644 index 27fd0d1..0000000 Binary files a/game/fb/images/buttons/msettings_r.png and /dev/null differ diff --git a/game/fb/images/buttons/mtutorial.png b/game/fb/images/buttons/mtutorial.png deleted file mode 100755 index 9de8ca9..0000000 Binary files a/game/fb/images/buttons/mtutorial.png and /dev/null differ diff --git a/game/fb/images/buttons/mtutorial_r.png b/game/fb/images/buttons/mtutorial_r.png deleted file mode 100755 index 804366f..0000000 Binary files a/game/fb/images/buttons/mtutorial_r.png and /dev/null differ diff --git a/game/fb/images/buttons/next.png b/game/fb/images/buttons/next.png deleted file mode 100644 index ee4b257..0000000 Binary files a/game/fb/images/buttons/next.png and /dev/null differ diff --git a/game/fb/images/buttons/postscore.png b/game/fb/images/buttons/postscore.png deleted file mode 100644 index bd6a40d..0000000 Binary files a/game/fb/images/buttons/postscore.png and /dev/null differ diff --git a/game/fb/images/buttons/previous.png b/game/fb/images/buttons/previous.png deleted file mode 100644 index 1d1d0cb..0000000 Binary files a/game/fb/images/buttons/previous.png and /dev/null differ diff --git a/game/fb/images/buttons/quit.png b/game/fb/images/buttons/quit.png deleted file mode 100644 index ca30b7e..0000000 Binary files a/game/fb/images/buttons/quit.png and /dev/null differ diff --git a/game/fb/images/buttons/restart.png b/game/fb/images/buttons/restart.png deleted file mode 100644 index 0a986b5..0000000 Binary files a/game/fb/images/buttons/restart.png and /dev/null differ diff --git a/game/fb/images/buttons/return.png b/game/fb/images/buttons/return.png deleted file mode 100644 index a3f4981..0000000 Binary files a/game/fb/images/buttons/return.png and /dev/null differ diff --git a/game/fb/images/buttons/set_click.png b/game/fb/images/buttons/set_click.png deleted file mode 100644 index f7dbec3..0000000 Binary files a/game/fb/images/buttons/set_click.png and /dev/null differ diff --git a/game/fb/images/buttons/set_mouseselect.png b/game/fb/images/buttons/set_mouseselect.png deleted file mode 100644 index a29db1e..0000000 Binary files a/game/fb/images/buttons/set_mouseselect.png and /dev/null differ diff --git a/game/fb/images/buttons/set_music.png b/game/fb/images/buttons/set_music.png deleted file mode 100644 index 70146ec..0000000 Binary files a/game/fb/images/buttons/set_music.png and /dev/null differ diff --git a/game/fb/images/buttons/set_sound.png b/game/fb/images/buttons/set_sound.png deleted file mode 100644 index 5f0d487..0000000 Binary files a/game/fb/images/buttons/set_sound.png and /dev/null differ diff --git a/game/fb/images/buttons/set_spacebar.png b/game/fb/images/buttons/set_spacebar.png deleted file mode 100644 index 153275c..0000000 Binary files a/game/fb/images/buttons/set_spacebar.png and /dev/null differ diff --git a/game/fb/images/buttons/set_track.png b/game/fb/images/buttons/set_track.png deleted file mode 100644 index c2489cb..0000000 Binary files a/game/fb/images/buttons/set_track.png and /dev/null differ diff --git a/game/fb/images/buttons/settings.png b/game/fb/images/buttons/settings.png deleted file mode 100644 index cb52726..0000000 Binary files a/game/fb/images/buttons/settings.png and /dev/null differ diff --git a/game/fb/images/buttons/track_left.png b/game/fb/images/buttons/track_left.png deleted file mode 100644 index 0ad83cd..0000000 Binary files a/game/fb/images/buttons/track_left.png and /dev/null differ diff --git a/game/fb/images/buttons/track_right.png b/game/fb/images/buttons/track_right.png deleted file mode 100644 index 0890c6e..0000000 Binary files a/game/fb/images/buttons/track_right.png and /dev/null differ diff --git a/game/fb/images/buttons/tut_ok.png b/game/fb/images/buttons/tut_ok.png deleted file mode 100755 index b047b7b..0000000 Binary files a/game/fb/images/buttons/tut_ok.png and /dev/null differ diff --git a/game/fb/images/buttons/tutorialbox.png b/game/fb/images/buttons/tutorialbox.png deleted file mode 100755 index cff6abf..0000000 Binary files a/game/fb/images/buttons/tutorialbox.png and /dev/null differ diff --git a/game/fb/images/cellinfect_animation/infect_a01.png b/game/fb/images/cellinfect_animation/infect_a01.png deleted file mode 100644 index 7d02b1a..0000000 Binary files a/game/fb/images/cellinfect_animation/infect_a01.png and /dev/null differ diff --git a/game/fb/images/cellinfect_animation/infect_a02.png b/game/fb/images/cellinfect_animation/infect_a02.png deleted file mode 100644 index cd5d557..0000000 Binary files a/game/fb/images/cellinfect_animation/infect_a02.png and /dev/null differ diff --git a/game/fb/images/cellinfect_animation/infect_a03.png b/game/fb/images/cellinfect_animation/infect_a03.png deleted file mode 100644 index 070d4d9..0000000 Binary files a/game/fb/images/cellinfect_animation/infect_a03.png and /dev/null differ diff --git a/game/fb/images/cellinfect_animation/infect_a04.png b/game/fb/images/cellinfect_animation/infect_a04.png deleted file mode 100644 index 45c2d2c..0000000 Binary files a/game/fb/images/cellinfect_animation/infect_a04.png and /dev/null differ diff --git a/game/fb/images/cellinfect_animation/infect_a05.png b/game/fb/images/cellinfect_animation/infect_a05.png deleted file mode 100644 index 6b0cf04..0000000 Binary files a/game/fb/images/cellinfect_animation/infect_a05.png and /dev/null differ diff --git a/game/fb/images/cellinfect_animation/infect_a06.png b/game/fb/images/cellinfect_animation/infect_a06.png deleted file mode 100644 index caf6ac5..0000000 Binary files a/game/fb/images/cellinfect_animation/infect_a06.png and /dev/null differ diff --git a/game/fb/images/cellinfect_animation/infect_a07.png b/game/fb/images/cellinfect_animation/infect_a07.png deleted file mode 100644 index fedb457..0000000 Binary files a/game/fb/images/cellinfect_animation/infect_a07.png and /dev/null differ diff --git a/game/fb/images/cellinfect_animation/infect_a08.png b/game/fb/images/cellinfect_animation/infect_a08.png deleted file mode 100644 index 1e0ca69..0000000 Binary files a/game/fb/images/cellinfect_animation/infect_a08.png and /dev/null differ diff --git a/game/fb/images/cellinfect_animation/infect_a09.png b/game/fb/images/cellinfect_animation/infect_a09.png deleted file mode 100644 index 43d1b04..0000000 Binary files a/game/fb/images/cellinfect_animation/infect_a09.png and /dev/null differ diff --git a/game/fb/images/cellinfect_animation/infect_a10.png b/game/fb/images/cellinfect_animation/infect_a10.png deleted file mode 100644 index 0aee860..0000000 Binary files a/game/fb/images/cellinfect_animation/infect_a10.png and /dev/null differ diff --git a/game/fb/images/cellinfect_animation/infect_a11.png b/game/fb/images/cellinfect_animation/infect_a11.png deleted file mode 100644 index 542e505..0000000 Binary files a/game/fb/images/cellinfect_animation/infect_a11.png and /dev/null differ diff --git a/game/fb/images/cellinfect_animation/infect_a12.png b/game/fb/images/cellinfect_animation/infect_a12.png deleted file mode 100644 index 1bcc3ab..0000000 Binary files a/game/fb/images/cellinfect_animation/infect_a12.png and /dev/null differ diff --git a/game/fb/images/halogo.jpg b/game/fb/images/halogo.jpg deleted file mode 100644 index e6e43c0..0000000 Binary files a/game/fb/images/halogo.jpg and /dev/null differ diff --git a/game/fb/images/holemacrophage_animation/hmacrophage_a01.png b/game/fb/images/holemacrophage_animation/hmacrophage_a01.png deleted file mode 100644 index 739eea8..0000000 Binary files a/game/fb/images/holemacrophage_animation/hmacrophage_a01.png and /dev/null differ diff --git a/game/fb/images/holemacrophage_animation/hmacrophage_a02.png b/game/fb/images/holemacrophage_animation/hmacrophage_a02.png deleted file mode 100644 index 189ed3d..0000000 Binary files a/game/fb/images/holemacrophage_animation/hmacrophage_a02.png and /dev/null differ diff --git a/game/fb/images/holemacrophage_animation/hmacrophage_a03.png b/game/fb/images/holemacrophage_animation/hmacrophage_a03.png deleted file mode 100644 index b9011c3..0000000 Binary files a/game/fb/images/holemacrophage_animation/hmacrophage_a03.png and /dev/null differ diff --git a/game/fb/images/holemacrophage_animation/hmacrophage_a04.png b/game/fb/images/holemacrophage_animation/hmacrophage_a04.png deleted file mode 100644 index 315daee..0000000 Binary files a/game/fb/images/holemacrophage_animation/hmacrophage_a04.png and /dev/null differ diff --git a/game/fb/images/holemacrophage_animation/hmacrophage_a05.png b/game/fb/images/holemacrophage_animation/hmacrophage_a05.png deleted file mode 100644 index 6510538..0000000 Binary files a/game/fb/images/holemacrophage_animation/hmacrophage_a05.png and /dev/null differ diff --git a/game/fb/images/holemacrophage_animation/hmacrophage_a06.png b/game/fb/images/holemacrophage_animation/hmacrophage_a06.png deleted file mode 100644 index e4387c2..0000000 Binary files a/game/fb/images/holemacrophage_animation/hmacrophage_a06.png and /dev/null differ diff --git a/game/fb/images/holemacrophage_animation/hmacrophage_a07.png b/game/fb/images/holemacrophage_animation/hmacrophage_a07.png deleted file mode 100644 index 4aefeb5..0000000 Binary files a/game/fb/images/holemacrophage_animation/hmacrophage_a07.png and /dev/null differ diff --git a/game/fb/images/holemacrophage_animation/hmacrophage_a08.png b/game/fb/images/holemacrophage_animation/hmacrophage_a08.png deleted file mode 100644 index f1c0e9c..0000000 Binary files a/game/fb/images/holemacrophage_animation/hmacrophage_a08.png and /dev/null differ diff --git a/game/fb/images/holemacrophage_animation/hmacrophage_a09.png b/game/fb/images/holemacrophage_animation/hmacrophage_a09.png deleted file mode 100644 index aad7670..0000000 Binary files a/game/fb/images/holemacrophage_animation/hmacrophage_a09.png and /dev/null differ diff --git a/game/fb/images/holemacrophage_animation/hmacrophage_a10.png b/game/fb/images/holemacrophage_animation/hmacrophage_a10.png deleted file mode 100644 index 84499ec..0000000 Binary files a/game/fb/images/holemacrophage_animation/hmacrophage_a10.png and /dev/null differ diff --git a/game/fb/images/holemacrophage_animation/hmacrophage_a11.png b/game/fb/images/holemacrophage_animation/hmacrophage_a11.png deleted file mode 100644 index cf9c8e4..0000000 Binary files a/game/fb/images/holemacrophage_animation/hmacrophage_a11.png and /dev/null differ diff --git a/game/fb/images/holemacrophage_animation/hmacrophage_a12.png b/game/fb/images/holemacrophage_animation/hmacrophage_a12.png deleted file mode 100644 index d7d1da2..0000000 Binary files a/game/fb/images/holemacrophage_animation/hmacrophage_a12.png and /dev/null differ diff --git a/game/fb/images/holemacrophage_animation/hmacrophage_a13.png b/game/fb/images/holemacrophage_animation/hmacrophage_a13.png deleted file mode 100644 index 7c7161b..0000000 Binary files a/game/fb/images/holemacrophage_animation/hmacrophage_a13.png and /dev/null differ diff --git a/game/fb/images/holemacrophage_animation/hmacrophage_a14.png b/game/fb/images/holemacrophage_animation/hmacrophage_a14.png deleted file mode 100644 index 3d54eba..0000000 Binary files a/game/fb/images/holemacrophage_animation/hmacrophage_a14.png and /dev/null differ diff --git a/game/fb/images/infectable_cell/infectable_cell_2n.png b/game/fb/images/infectable_cell/infectable_cell_2n.png deleted file mode 100644 index ac98c48..0000000 Binary files a/game/fb/images/infectable_cell/infectable_cell_2n.png and /dev/null differ diff --git a/game/fb/images/infectable_cell/infectable_cell_3n.png b/game/fb/images/infectable_cell/infectable_cell_3n.png deleted file mode 100644 index 5cb97e8..0000000 Binary files a/game/fb/images/infectable_cell/infectable_cell_3n.png and /dev/null differ diff --git a/game/fb/images/infectable_cell/infectable_cell_4n.png b/game/fb/images/infectable_cell/infectable_cell_4n.png deleted file mode 100644 index 8027852..0000000 Binary files a/game/fb/images/infectable_cell/infectable_cell_4n.png and /dev/null differ diff --git a/game/fb/images/infectable_cell/infectable_cell_5n.png b/game/fb/images/infectable_cell/infectable_cell_5n.png deleted file mode 100644 index 6503050..0000000 Binary files a/game/fb/images/infectable_cell/infectable_cell_5n.png and /dev/null differ diff --git a/game/fb/images/infectable_cell/infectable_cell_6n.png b/game/fb/images/infectable_cell/infectable_cell_6n.png deleted file mode 100644 index 41e450e..0000000 Binary files a/game/fb/images/infectable_cell/infectable_cell_6n.png and /dev/null differ diff --git a/game/fb/images/infectable_cell/infectable_cell_7n.png b/game/fb/images/infectable_cell/infectable_cell_7n.png deleted file mode 100644 index f9cbc94..0000000 Binary files a/game/fb/images/infectable_cell/infectable_cell_7n.png and /dev/null differ diff --git a/game/fb/images/listcell.png b/game/fb/images/listcell.png deleted file mode 100644 index 27af90c..0000000 Binary files a/game/fb/images/listcell.png and /dev/null differ diff --git a/game/fb/images/logo/logo128.png b/game/fb/images/logo/logo128.png deleted file mode 100644 index d370aed..0000000 Binary files a/game/fb/images/logo/logo128.png and /dev/null differ diff --git a/game/fb/images/logo/logo32.png b/game/fb/images/logo/logo32.png deleted file mode 100644 index b076f80..0000000 Binary files a/game/fb/images/logo/logo32.png and /dev/null differ diff --git a/game/fb/images/logo/logo64.png b/game/fb/images/logo/logo64.png deleted file mode 100644 index ca134e5..0000000 Binary files a/game/fb/images/logo/logo64.png and /dev/null differ diff --git a/game/fb/images/logo/vlogolarge.png b/game/fb/images/logo/vlogolarge.png deleted file mode 100644 index 274bab9..0000000 Binary files a/game/fb/images/logo/vlogolarge.png and /dev/null differ diff --git a/game/fb/images/logo/vlogolargetext.png b/game/fb/images/logo/vlogolargetext.png deleted file mode 100644 index 6004b8e..0000000 Binary files a/game/fb/images/logo/vlogolargetext.png and /dev/null differ diff --git a/game/fb/images/macrophage_1.png b/game/fb/images/macrophage_1.png deleted file mode 100644 index b03e4cd..0000000 Binary files a/game/fb/images/macrophage_1.png and /dev/null differ diff --git a/game/fb/images/macrophage_1_active.png b/game/fb/images/macrophage_1_active.png deleted file mode 100644 index 4b858d4..0000000 Binary files a/game/fb/images/macrophage_1_active.png and /dev/null differ diff --git a/game/fb/images/macrophage_animation/macrophage_a01.png b/game/fb/images/macrophage_animation/macrophage_a01.png deleted file mode 100644 index 34e9035..0000000 Binary files a/game/fb/images/macrophage_animation/macrophage_a01.png and /dev/null differ diff --git a/game/fb/images/macrophage_animation/macrophage_a02.png b/game/fb/images/macrophage_animation/macrophage_a02.png deleted file mode 100644 index 0cb1089..0000000 Binary files a/game/fb/images/macrophage_animation/macrophage_a02.png and /dev/null differ diff --git a/game/fb/images/macrophage_animation/macrophage_a03.png b/game/fb/images/macrophage_animation/macrophage_a03.png deleted file mode 100644 index 12f9af3..0000000 Binary files a/game/fb/images/macrophage_animation/macrophage_a03.png and /dev/null differ diff --git a/game/fb/images/macrophage_animation/macrophage_a04.png b/game/fb/images/macrophage_animation/macrophage_a04.png deleted file mode 100644 index 3ccaca9..0000000 Binary files a/game/fb/images/macrophage_animation/macrophage_a04.png and /dev/null differ diff --git a/game/fb/images/macrophage_animation/macrophage_a05.png b/game/fb/images/macrophage_animation/macrophage_a05.png deleted file mode 100644 index b5e97c1..0000000 Binary files a/game/fb/images/macrophage_animation/macrophage_a05.png and /dev/null differ diff --git a/game/fb/images/macrophage_animation/macrophage_a06.png b/game/fb/images/macrophage_animation/macrophage_a06.png deleted file mode 100644 index e8a1b97..0000000 Binary files a/game/fb/images/macrophage_animation/macrophage_a06.png and /dev/null differ diff --git a/game/fb/images/macrophage_animation/macrophage_a07.png b/game/fb/images/macrophage_animation/macrophage_a07.png deleted file mode 100644 index 13ab22f..0000000 Binary files a/game/fb/images/macrophage_animation/macrophage_a07.png and /dev/null differ diff --git a/game/fb/images/macrophage_animation/macrophage_a08.png b/game/fb/images/macrophage_animation/macrophage_a08.png deleted file mode 100644 index 7ac4102..0000000 Binary files a/game/fb/images/macrophage_animation/macrophage_a08.png and /dev/null differ diff --git a/game/fb/images/macrophage_animation/macrophage_a09.png b/game/fb/images/macrophage_animation/macrophage_a09.png deleted file mode 100644 index 32f7c20..0000000 Binary files a/game/fb/images/macrophage_animation/macrophage_a09.png and /dev/null differ diff --git a/game/fb/images/macrophage_animation/macrophage_a10.png b/game/fb/images/macrophage_animation/macrophage_a10.png deleted file mode 100644 index 4f64246..0000000 Binary files a/game/fb/images/macrophage_animation/macrophage_a10.png and /dev/null differ diff --git a/game/fb/images/macrophage_animation/macrophage_a11.png b/game/fb/images/macrophage_animation/macrophage_a11.png deleted file mode 100644 index bb1870f..0000000 Binary files a/game/fb/images/macrophage_animation/macrophage_a11.png and /dev/null differ diff --git a/game/fb/images/macrophage_animation/macrophage_a12.png b/game/fb/images/macrophage_animation/macrophage_a12.png deleted file mode 100644 index 506e48b..0000000 Binary files a/game/fb/images/macrophage_animation/macrophage_a12.png and /dev/null differ diff --git a/game/fb/images/macrophage_animation/macrophage_a13.png b/game/fb/images/macrophage_animation/macrophage_a13.png deleted file mode 100644 index 7b14bd9..0000000 Binary files a/game/fb/images/macrophage_animation/macrophage_a13.png and /dev/null differ diff --git a/game/fb/images/macrophage_animation/macrophage_a14.png b/game/fb/images/macrophage_animation/macrophage_a14.png deleted file mode 100644 index f78597b..0000000 Binary files a/game/fb/images/macrophage_animation/macrophage_a14.png and /dev/null differ diff --git a/game/fb/images/noninfectable_cell/noninfectable_cell_1n.png b/game/fb/images/noninfectable_cell/noninfectable_cell_1n.png deleted file mode 100644 index 9768618..0000000 Binary files a/game/fb/images/noninfectable_cell/noninfectable_cell_1n.png and /dev/null differ diff --git a/game/fb/images/noninfectable_cell/noninfectable_cell_2n.png b/game/fb/images/noninfectable_cell/noninfectable_cell_2n.png deleted file mode 100644 index c6b582c..0000000 Binary files a/game/fb/images/noninfectable_cell/noninfectable_cell_2n.png and /dev/null differ diff --git a/game/fb/images/noninfectable_cell/noninfectable_cell_3n.png b/game/fb/images/noninfectable_cell/noninfectable_cell_3n.png deleted file mode 100644 index a387eb0..0000000 Binary files a/game/fb/images/noninfectable_cell/noninfectable_cell_3n.png and /dev/null differ diff --git a/game/fb/images/noninfectable_cell/noninfectable_cell_4n.png b/game/fb/images/noninfectable_cell/noninfectable_cell_4n.png deleted file mode 100644 index 1bf02a8..0000000 Binary files a/game/fb/images/noninfectable_cell/noninfectable_cell_4n.png and /dev/null differ diff --git a/game/fb/images/noninfectable_cell/noninfectable_cell_5n.png b/game/fb/images/noninfectable_cell/noninfectable_cell_5n.png deleted file mode 100644 index 841dd45..0000000 Binary files a/game/fb/images/noninfectable_cell/noninfectable_cell_5n.png and /dev/null differ diff --git a/game/fb/images/old/.DS_Store b/game/fb/images/old/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/fb/images/old/.DS_Store and /dev/null differ diff --git a/game/fb/images/old/b/.DS_Store b/game/fb/images/old/b/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/fb/images/old/b/.DS_Store and /dev/null differ diff --git a/game/fb/images/old/b/macrophage_a1.gif b/game/fb/images/old/b/macrophage_a1.gif deleted file mode 100755 index ea1ba06..0000000 Binary files a/game/fb/images/old/b/macrophage_a1.gif and /dev/null differ diff --git a/game/fb/images/old/background/background_bcells1.png b/game/fb/images/old/background/background_bcells1.png deleted file mode 100755 index f809f50..0000000 Binary files a/game/fb/images/old/background/background_bcells1.png and /dev/null differ diff --git a/game/fb/images/old/background/background_bcells2.png b/game/fb/images/old/background/background_bcells2.png deleted file mode 100755 index d99ee15..0000000 Binary files a/game/fb/images/old/background/background_bcells2.png and /dev/null differ diff --git a/game/fb/images/old/background/background_bcells3.png b/game/fb/images/old/background/background_bcells3.png deleted file mode 100755 index 099a0f7..0000000 Binary files a/game/fb/images/old/background/background_bcells3.png and /dev/null differ diff --git a/game/fb/images/old/background/background_bcells4.png b/game/fb/images/old/background/background_bcells4.png deleted file mode 100755 index 9ed69c7..0000000 Binary files a/game/fb/images/old/background/background_bcells4.png and /dev/null differ diff --git a/game/fb/images/old/background/background_bottomside.png b/game/fb/images/old/background/background_bottomside.png deleted file mode 100755 index 90bda8d..0000000 Binary files a/game/fb/images/old/background/background_bottomside.png and /dev/null differ diff --git a/game/fb/images/old/background/background_dstreaks1.png b/game/fb/images/old/background/background_dstreaks1.png deleted file mode 100755 index 9f553e6..0000000 Binary files a/game/fb/images/old/background/background_dstreaks1.png and /dev/null differ diff --git a/game/fb/images/old/background/background_dstreaks2.png b/game/fb/images/old/background/background_dstreaks2.png deleted file mode 100755 index 258b8c6..0000000 Binary files a/game/fb/images/old/background/background_dstreaks2.png and /dev/null differ diff --git a/game/fb/images/old/background/background_dstreaks3.png b/game/fb/images/old/background/background_dstreaks3.png deleted file mode 100755 index fcbcbb7..0000000 Binary files a/game/fb/images/old/background/background_dstreaks3.png and /dev/null differ diff --git a/game/fb/images/old/background/background_lstreaks1.png b/game/fb/images/old/background/background_lstreaks1.png deleted file mode 100755 index 3f313ce..0000000 Binary files a/game/fb/images/old/background/background_lstreaks1.png and /dev/null differ diff --git a/game/fb/images/old/background/background_lstreaks2.png b/game/fb/images/old/background/background_lstreaks2.png deleted file mode 100755 index 6d9e38e..0000000 Binary files a/game/fb/images/old/background/background_lstreaks2.png and /dev/null differ diff --git a/game/fb/images/old/background/background_topside.png b/game/fb/images/old/background/background_topside.png deleted file mode 100755 index 70573ac..0000000 Binary files a/game/fb/images/old/background/background_topside.png and /dev/null differ diff --git a/game/fb/images/old/bcell1.png b/game/fb/images/old/bcell1.png deleted file mode 100644 index f383cdd..0000000 Binary files a/game/fb/images/old/bcell1.png and /dev/null differ diff --git a/game/fb/images/old/cellwall1.png b/game/fb/images/old/cellwall1.png deleted file mode 100644 index ac5e3c1..0000000 Binary files a/game/fb/images/old/cellwall1.png and /dev/null differ diff --git a/game/fb/images/old/cellwall1draft.svg b/game/fb/images/old/cellwall1draft.svg deleted file mode 100644 index 0c2ae5a..0000000 --- a/game/fb/images/old/cellwall1draft.svg +++ /dev/null @@ -1,1120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/fb/images/old/infectable1.png b/game/fb/images/old/infectable1.png deleted file mode 100644 index 29f9eb1..0000000 Binary files a/game/fb/images/old/infectable1.png and /dev/null differ diff --git a/game/fb/images/old/infectable2.png b/game/fb/images/old/infectable2.png deleted file mode 100644 index 40d0d7d..0000000 Binary files a/game/fb/images/old/infectable2.png and /dev/null differ diff --git a/game/fb/images/old/infectable3.png b/game/fb/images/old/infectable3.png deleted file mode 100644 index 69567be..0000000 Binary files a/game/fb/images/old/infectable3.png and /dev/null differ diff --git a/game/fb/images/old/infectable_cell/infectable_cell_2n.png b/game/fb/images/old/infectable_cell/infectable_cell_2n.png deleted file mode 100755 index 29f9eb1..0000000 Binary files a/game/fb/images/old/infectable_cell/infectable_cell_2n.png and /dev/null differ diff --git a/game/fb/images/old/infectable_cell/infectable_cell_3n.png b/game/fb/images/old/infectable_cell/infectable_cell_3n.png deleted file mode 100755 index 40d0d7d..0000000 Binary files a/game/fb/images/old/infectable_cell/infectable_cell_3n.png and /dev/null differ diff --git a/game/fb/images/old/infectable_cell/infectable_cell_4n.png b/game/fb/images/old/infectable_cell/infectable_cell_4n.png deleted file mode 100755 index 69567be..0000000 Binary files a/game/fb/images/old/infectable_cell/infectable_cell_4n.png and /dev/null differ diff --git a/game/fb/images/old/infectable_cell/infectable_cell_5n.png b/game/fb/images/old/infectable_cell/infectable_cell_5n.png deleted file mode 100755 index 620adbb..0000000 Binary files a/game/fb/images/old/infectable_cell/infectable_cell_5n.png and /dev/null differ diff --git a/game/fb/images/old/infectable_cell/infectable_cell_6n.png b/game/fb/images/old/infectable_cell/infectable_cell_6n.png deleted file mode 100755 index aa65877..0000000 Binary files a/game/fb/images/old/infectable_cell/infectable_cell_6n.png and /dev/null differ diff --git a/game/fb/images/old/infectable_cell/infectable_cell_7n.png b/game/fb/images/old/infectable_cell/infectable_cell_7n.png deleted file mode 100755 index 2951a73..0000000 Binary files a/game/fb/images/old/infectable_cell/infectable_cell_7n.png and /dev/null differ diff --git a/game/fb/images/old/macrophage1.png b/game/fb/images/old/macrophage1.png deleted file mode 100644 index 4dc0f6b..0000000 Binary files a/game/fb/images/old/macrophage1.png and /dev/null differ diff --git a/game/fb/images/old/macrophage_active.png b/game/fb/images/old/macrophage_active.png deleted file mode 100644 index ed7d1ee..0000000 Binary files a/game/fb/images/old/macrophage_active.png and /dev/null differ diff --git a/game/fb/images/old/new/.DS_Store b/game/fb/images/old/new/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/fb/images/old/new/.DS_Store and /dev/null differ diff --git a/game/fb/images/old/new/infectable1.png b/game/fb/images/old/new/infectable1.png deleted file mode 100755 index 298f24c..0000000 Binary files a/game/fb/images/old/new/infectable1.png and /dev/null differ diff --git a/game/fb/images/old/new/infectable2.png b/game/fb/images/old/new/infectable2.png deleted file mode 100755 index 01100dd..0000000 Binary files a/game/fb/images/old/new/infectable2.png and /dev/null differ diff --git a/game/fb/images/old/new/infectable3.png b/game/fb/images/old/new/infectable3.png deleted file mode 100755 index 9bc043f..0000000 Binary files a/game/fb/images/old/new/infectable3.png and /dev/null differ diff --git a/game/fb/images/old/new/noninfectable.png b/game/fb/images/old/new/noninfectable.png deleted file mode 100755 index bbe312b..0000000 Binary files a/game/fb/images/old/new/noninfectable.png and /dev/null differ diff --git a/game/fb/images/old/noninfectable1.png b/game/fb/images/old/noninfectable1.png deleted file mode 100644 index dde08a7..0000000 Binary files a/game/fb/images/old/noninfectable1.png and /dev/null differ diff --git a/game/fb/images/old/noninfectable_cell/noninfectable_cell_2n.png b/game/fb/images/old/noninfectable_cell/noninfectable_cell_2n.png deleted file mode 100755 index e586a95..0000000 Binary files a/game/fb/images/old/noninfectable_cell/noninfectable_cell_2n.png and /dev/null differ diff --git a/game/fb/images/old/noninfectable_cell/noninfectable_cell_3.png b/game/fb/images/old/noninfectable_cell/noninfectable_cell_3.png deleted file mode 100755 index a04f17c..0000000 Binary files a/game/fb/images/old/noninfectable_cell/noninfectable_cell_3.png and /dev/null differ diff --git a/game/fb/images/old/noninfectable_cell/noninfectable_cell_4.png b/game/fb/images/old/noninfectable_cell/noninfectable_cell_4.png deleted file mode 100755 index 5114e1d..0000000 Binary files a/game/fb/images/old/noninfectable_cell/noninfectable_cell_4.png and /dev/null differ diff --git a/game/fb/images/old/noninfectable_cell/noninfectable_cell_5.png b/game/fb/images/old/noninfectable_cell/noninfectable_cell_5.png deleted file mode 100755 index 86a67e3..0000000 Binary files a/game/fb/images/old/noninfectable_cell/noninfectable_cell_5.png and /dev/null differ diff --git a/game/fb/images/old/particle.png b/game/fb/images/old/particle.png deleted file mode 100644 index e2c8a15..0000000 Binary files a/game/fb/images/old/particle.png and /dev/null differ diff --git a/game/fb/images/old/screens/.DS_Store b/game/fb/images/old/screens/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/fb/images/old/screens/.DS_Store and /dev/null differ diff --git a/game/fb/images/old/screens/bullet_listcell.png b/game/fb/images/old/screens/bullet_listcell.png deleted file mode 100755 index 7525958..0000000 Binary files a/game/fb/images/old/screens/bullet_listcell.png and /dev/null differ diff --git a/game/fb/images/old/screens/header.png b/game/fb/images/old/screens/header.png deleted file mode 100755 index 8b83ea6..0000000 Binary files a/game/fb/images/old/screens/header.png and /dev/null differ diff --git a/game/fb/images/old/screens/listcell.png b/game/fb/images/old/screens/listcell.png deleted file mode 100755 index ef2eba2..0000000 Binary files a/game/fb/images/old/screens/listcell.png and /dev/null differ diff --git a/game/fb/images/old/screens/loading.png b/game/fb/images/old/screens/loading.png deleted file mode 100755 index a20886e..0000000 Binary files a/game/fb/images/old/screens/loading.png and /dev/null differ diff --git a/game/fb/images/old/screens/loadingsplash.png b/game/fb/images/old/screens/loadingsplash.png deleted file mode 100755 index 9c3d6bc..0000000 Binary files a/game/fb/images/old/screens/loadingsplash.png and /dev/null differ diff --git a/game/fb/images/old/screens/mainscreenbase.png b/game/fb/images/old/screens/mainscreenbase.png deleted file mode 100755 index 2287e53..0000000 Binary files a/game/fb/images/old/screens/mainscreenbase.png and /dev/null differ diff --git a/game/fb/images/old/screens/newgame_listcell.png b/game/fb/images/old/screens/newgame_listcell.png deleted file mode 100755 index 3360fb7..0000000 Binary files a/game/fb/images/old/screens/newgame_listcell.png and /dev/null differ diff --git a/game/fb/images/old/screens/settings.png b/game/fb/images/old/screens/settings.png deleted file mode 100755 index 3041eea..0000000 Binary files a/game/fb/images/old/screens/settings.png and /dev/null differ diff --git a/game/fb/images/old/screens/settingssplash.png b/game/fb/images/old/screens/settingssplash.png deleted file mode 100755 index ac1891a..0000000 Binary files a/game/fb/images/old/screens/settingssplash.png and /dev/null differ diff --git a/game/fb/images/old/tcells/tcell1.png b/game/fb/images/old/tcells/tcell1.png deleted file mode 100755 index a49799f..0000000 Binary files a/game/fb/images/old/tcells/tcell1.png and /dev/null differ diff --git a/game/fb/images/old/tcells/tcell2.png b/game/fb/images/old/tcells/tcell2.png deleted file mode 100755 index 24b6ac2..0000000 Binary files a/game/fb/images/old/tcells/tcell2.png and /dev/null differ diff --git a/game/fb/images/old/tcells/tcell3.png b/game/fb/images/old/tcells/tcell3.png deleted file mode 100755 index 98dbc44..0000000 Binary files a/game/fb/images/old/tcells/tcell3.png and /dev/null differ diff --git a/game/fb/images/old/tcells/tcell4.png b/game/fb/images/old/tcells/tcell4.png deleted file mode 100755 index 891c32b..0000000 Binary files a/game/fb/images/old/tcells/tcell4.png and /dev/null differ diff --git a/game/fb/images/old/virus1.png b/game/fb/images/old/virus1.png deleted file mode 100644 index d9db175..0000000 Binary files a/game/fb/images/old/virus1.png and /dev/null differ diff --git a/game/fb/images/old/virusfinal.svg b/game/fb/images/old/virusfinal.svg deleted file mode 100644 index 3b61a61..0000000 --- a/game/fb/images/old/virusfinal.svg +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/fb/images/old/wall_segments/cellwall1.png b/game/fb/images/old/wall_segments/cellwall1.png deleted file mode 100755 index 0d71d6e..0000000 Binary files a/game/fb/images/old/wall_segments/cellwall1.png and /dev/null differ diff --git a/game/fb/images/old/wall_segments/cellwall2.png b/game/fb/images/old/wall_segments/cellwall2.png deleted file mode 100755 index f06bf92..0000000 Binary files a/game/fb/images/old/wall_segments/cellwall2.png and /dev/null differ diff --git a/game/fb/images/old/wall_segments/cellwall3.png b/game/fb/images/old/wall_segments/cellwall3.png deleted file mode 100755 index 2b7f3c7..0000000 Binary files a/game/fb/images/old/wall_segments/cellwall3.png and /dev/null differ diff --git a/game/fb/images/old/wall_segments/cellwall4.png b/game/fb/images/old/wall_segments/cellwall4.png deleted file mode 100755 index d33f471..0000000 Binary files a/game/fb/images/old/wall_segments/cellwall4.png and /dev/null differ diff --git a/game/fb/images/old/wall_segments/cellwall5.png b/game/fb/images/old/wall_segments/cellwall5.png deleted file mode 100755 index c0bbabd..0000000 Binary files a/game/fb/images/old/wall_segments/cellwall5.png and /dev/null differ diff --git a/game/fb/images/old/wall_segments/cellwall6.png b/game/fb/images/old/wall_segments/cellwall6.png deleted file mode 100755 index 203950f..0000000 Binary files a/game/fb/images/old/wall_segments/cellwall6.png and /dev/null differ diff --git a/game/fb/images/old/wall_segments/cellwall7.png b/game/fb/images/old/wall_segments/cellwall7.png deleted file mode 100755 index 262a9b3..0000000 Binary files a/game/fb/images/old/wall_segments/cellwall7.png and /dev/null differ diff --git a/game/fb/images/old/wallcell1.png b/game/fb/images/old/wallcell1.png deleted file mode 100644 index 30c4535..0000000 Binary files a/game/fb/images/old/wallcell1.png and /dev/null differ diff --git a/game/fb/images/screens/creditsscreen.png b/game/fb/images/screens/creditsscreen.png deleted file mode 100644 index 40ff9db..0000000 Binary files a/game/fb/images/screens/creditsscreen.png and /dev/null differ diff --git a/game/fb/images/screens/helpsplash.png b/game/fb/images/screens/helpsplash.png deleted file mode 100644 index f92663b..0000000 Binary files a/game/fb/images/screens/helpsplash.png and /dev/null differ diff --git a/game/fb/images/screens/loadingsplash.png b/game/fb/images/screens/loadingsplash.png deleted file mode 100644 index 7825408..0000000 Binary files a/game/fb/images/screens/loadingsplash.png and /dev/null differ diff --git a/game/fb/images/screens/mainscreenbase.png b/game/fb/images/screens/mainscreenbase.png deleted file mode 100644 index dd63a98..0000000 Binary files a/game/fb/images/screens/mainscreenbase.png and /dev/null differ diff --git a/game/fb/images/screens/settingssplash.png b/game/fb/images/screens/settingssplash.png deleted file mode 100644 index 7cd9b4e..0000000 Binary files a/game/fb/images/screens/settingssplash.png and /dev/null differ diff --git a/game/fb/images/t_animation/tcell_a01.png b/game/fb/images/t_animation/tcell_a01.png deleted file mode 100644 index 22b4364..0000000 Binary files a/game/fb/images/t_animation/tcell_a01.png and /dev/null differ diff --git a/game/fb/images/t_animation/tcell_a02.png b/game/fb/images/t_animation/tcell_a02.png deleted file mode 100644 index 6743fbc..0000000 Binary files a/game/fb/images/t_animation/tcell_a02.png and /dev/null differ diff --git a/game/fb/images/t_animation/tcell_a03.png b/game/fb/images/t_animation/tcell_a03.png deleted file mode 100644 index d6b30c9..0000000 Binary files a/game/fb/images/t_animation/tcell_a03.png and /dev/null differ diff --git a/game/fb/images/t_animation/tcell_a04.png b/game/fb/images/t_animation/tcell_a04.png deleted file mode 100644 index 17e9836..0000000 Binary files a/game/fb/images/t_animation/tcell_a04.png and /dev/null differ diff --git a/game/fb/images/t_animation/tcell_a05.png b/game/fb/images/t_animation/tcell_a05.png deleted file mode 100644 index a909794..0000000 Binary files a/game/fb/images/t_animation/tcell_a05.png and /dev/null differ diff --git a/game/fb/images/t_animation/tcell_a06.png b/game/fb/images/t_animation/tcell_a06.png deleted file mode 100644 index af2bf7f..0000000 Binary files a/game/fb/images/t_animation/tcell_a06.png and /dev/null differ diff --git a/game/fb/images/t_animation/tcell_a07.png b/game/fb/images/t_animation/tcell_a07.png deleted file mode 100644 index e6a1f7c..0000000 Binary files a/game/fb/images/t_animation/tcell_a07.png and /dev/null differ diff --git a/game/fb/images/tcell_2.png b/game/fb/images/tcell_2.png deleted file mode 100644 index bcdfd37..0000000 Binary files a/game/fb/images/tcell_2.png and /dev/null differ diff --git a/game/fb/images/tinyvirus_shadowtrans.png b/game/fb/images/tinyvirus_shadowtrans.png deleted file mode 100644 index 06f8178..0000000 Binary files a/game/fb/images/tinyvirus_shadowtrans.png and /dev/null differ diff --git a/game/fb/images/tinyvirus_trans.png b/game/fb/images/tinyvirus_trans.png deleted file mode 100644 index ffad22b..0000000 Binary files a/game/fb/images/tinyvirus_trans.png and /dev/null differ diff --git a/game/fb/images/wall_segments/cellwall1.png b/game/fb/images/wall_segments/cellwall1.png deleted file mode 100644 index 0e4aa10..0000000 Binary files a/game/fb/images/wall_segments/cellwall1.png and /dev/null differ diff --git a/game/fb/images/wall_segments/cellwall2.png b/game/fb/images/wall_segments/cellwall2.png deleted file mode 100644 index 8b07659..0000000 Binary files a/game/fb/images/wall_segments/cellwall2.png and /dev/null differ diff --git a/game/fb/images/wall_segments/cellwall3.png b/game/fb/images/wall_segments/cellwall3.png deleted file mode 100644 index d91f9ac..0000000 Binary files a/game/fb/images/wall_segments/cellwall3.png and /dev/null differ diff --git a/game/fb/images/wall_segments/cellwall4.png b/game/fb/images/wall_segments/cellwall4.png deleted file mode 100644 index aaf96ad..0000000 Binary files a/game/fb/images/wall_segments/cellwall4.png and /dev/null differ diff --git a/game/fb/images/wall_segments/cellwall5.png b/game/fb/images/wall_segments/cellwall5.png deleted file mode 100644 index edb9fa1..0000000 Binary files a/game/fb/images/wall_segments/cellwall5.png and /dev/null differ diff --git a/game/fb/images/wall_segments/cellwall6.png b/game/fb/images/wall_segments/cellwall6.png deleted file mode 100644 index 175ed0f..0000000 Binary files a/game/fb/images/wall_segments/cellwall6.png and /dev/null differ diff --git a/game/fb/images/wall_segments/cellwall7.png b/game/fb/images/wall_segments/cellwall7.png deleted file mode 100644 index e1d20e5..0000000 Binary files a/game/fb/images/wall_segments/cellwall7.png and /dev/null differ diff --git a/game/fb/images/wallcell_1.png b/game/fb/images/wallcell_1.png deleted file mode 100644 index 9f5f197..0000000 Binary files a/game/fb/images/wallcell_1.png and /dev/null differ diff --git a/game/fb/in_game_state.js b/game/fb/in_game_state.js deleted file mode 100644 index e377b4e..0000000 --- a/game/fb/in_game_state.js +++ /dev/null @@ -1,1938 +0,0 @@ -// *** game *** -// NOTE: get_type() returns "game" not "in_game" - -// defined up here cuz instructions need them -// and a game might not be init'd before reading instr -g_speed_factor = 1; // multiply all speed constants in the game by this, for easy mode - -// Global Variable so cell arrows can draw dots -GLOBAL_is_easy = false; - -// flag for whether the tutorial has been played through -// if false, easy mode will include the tutorial -g_tut_done = false; - -// game_type is: -// 0 - easy -// 1 - tutorial -// 2 - hard -var in_game_state = function (p, previous_state, game_type) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - - // whether or not we are testing - // use it wherever - var testing = false; - obj.testing = function() { return testing; }; - - // --- constants --- - //var num_of_render_levels = 5; Now auto-calculating in init so don't have to change - - // --- private variables --- - - - var GOOD_NOTIFICATION_COLOR = p.color(0, 255, 0); - var BAD_NOTIFICATION_COLOR = p.color(255, 0, 0); - - var prev_state = previous_state; - // distance is the x-coordinate of the total distance traveled - // increments with scroll - var distance = 0; - //var score = 0; - var active_cell = null; - var last_active_cell = null; - // multiply each object's scroll amount by this - // factor, which increases throughout the game - var scroll_factor = 1; - if (game_type < 2) { - g_speed_factor = 0.75; - } - scroll_factor *= g_speed_factor; - - var game_objects = []; - var paused = false; - - var status_bar_height = 40; - var status_height = 20; - - var score = num_status_obj(p, { - pos : new p.PVector(p.width - 100, status_height), - text : "Score:", - num : 0, - format : add_commas - }); - var mult = num_status_obj(p, { - pos : new p.PVector(p.width - 200, status_height), - text : "Multiplier:", - num : 1, - format : function(num) { - return num+"x"; - } - }); - var time_elapsed = 0; // Time elapsed in seconds - var set_time = false; //bool that says if we've started counting time - var time_status = num_status_obj(p, { - pos : new p.PVector(85, status_height), - text : "Time:", - num : time_elapsed, - // formats time to mins:secs - format : function(num) { - var secs = num%60; - if (secs < 10) { secs = "0" + secs; } - return p.floor(num/60) + ":" + secs; - } - }); - var mutation = mutation_obj(p, { status_height : status_height }); - - var pause_button = button(p, { - state: function() { - do_pause(); - console.log("pause button"); - return pause_state(p, obj); - }, - rect: { - pos: new p.PVector(25, status_height), - width: 25, height: 25, - } - }); - // draw two vertical rects - pause_button.draw = function() { - p.pushMatrix(); - // get the rect spec back - var r = pause_button.get_rect(); - var w = r.width; - var h = r.height; - p.translate(r.pos.x-w/2, r.pos.y-h/2); - p.strokeWeight(2); - p.stroke(255); - p.noFill(); - p.ellipse(w/2, h/2, w, h); - p.noStroke(); - p.fill(255); - p.rectMode(p.CORNER); - p.rect(w/4, h/5, w/5, 3*h/5); - p.rect(w-w/4-w/5, h/5, w/5, 3*h/5); - p.popMatrix(); - }; - - // Used to draw all of the statuses (must implement draw) - var all_status_objs = [score, mult, time_status, mutation]; - var all_buttons = [pause_button]; - - - var is_tutorial = false; - if (game_type === 1 - // if the tutorial hasn't been done, do on easy mode - || (game_type === 0 && !g_tut_done) ){ - is_tutorial = true; - } - if (game_type < 2) { - GLOBAL_is_easy = true; - } - - - // the popup to draw at a given time - // null if there is none - var tut_window = null; - // flag for unpausing - // when false mouse clicks wont fire - var ok_to_fire = true; - // Call tut_manager.popup(type) when you want to signal a tutorial message - // All the types are in tut_flags - var tut_manager = (function() { - - // object to store all the msgs - var tut_msgs = { - spacebar: "Press SPACEBAR or CLICK the mouse to shoot virions out of an infected cell in the direction of the arrow. The dotted lines will help you aim.", - arrows: "Use the LEFT and RIGHT arrow keys to switch between infected cells.", - macrophage: "Watch out for macrophages! They will kill your virion and alert a B cell.", - antibodies: "Oh no! The B cell is producing antibodies! If an antibody attaches to an infected cell, the cell will be marked for destruction by a granulocyte.", - killer: "A granulocyte just destroyed one of your infected cells marked with an antibody and all the virions inside it! Your virus won't be safe from the granulocyte until it mutates, creating a new strain.", - mutation: "Your virus just mutated to a new strain! Each virion can only be attacked by immune cells that know about its strain. Immune cells that know about a certain strain will be filled with the same color as virions of that strain.", strain: "Uh oh! The last virion of the new strain died, so your current highest mutation level went back down. You should try to keep alive the virions of the newest strain - they will earn you the most points!" }; // These flags are set to false when they've already occured - // built based on tut_msgs - var tut_flags = {}; - for_each( - keys(tut_msgs), - function(type) { - tut_flags[type] = true; - } - ); - - var tut_popup = function(txt) { - var obj = {}; - - var x = p.width/2; - var y = p.height/2; - var w = 400; - var h = 200; - var tw = w-50; - var tut_box = image_manager.get_image("tutorialbox.png"); - obj.draw = function() { - /* - p.noStroke(); - p.fill(100); - p.rectMode(p.CENTER); - p.rect(x, y, w, h); - */ - p.imageMode(p.CENTER); - p.image(tut_box, x, y); - p.fill(255); - p.textLeading(17); - p.textSize(16); - p.textAlign(p.CENTER, p.CENTER); - p.text(txt, x-tw/2, y-h/2, tw, h-50); - }; - - return obj; - }; - - var show_popup = function(text) { - var close_button = button(p, { - state: function() { - tut_window = null; - obj.resume(); - all_buttons.pop() // DANGEROUS... Hope we're not adding any other buttons anytime soon - return obj; // the current state - }, - rect: { - pos: new p.PVector(p.width/2, p.height/2+60), - //width: 50, height: 50, - //text: "OK" - image: "tut_ok.png" - } - }); - all_buttons.push(close_button); - - tut_window = tut_popup(text); - sounds.play_sound("TextPopUp"); - }; - - var tut_obj = { - popup : function(type) { - if (is_tutorial && tut_flags[type]) { - tut_pause(); - ok_to_fire = false; - text = tut_msgs[type]; - show_popup(text); - tut_flags[type] = false; - } - allFinished = true; - for_each( - keys(tut_msgs), - function(type) { - if (tut_flags[type]) { - allFinished = false; - } - } - ); - // the tutorial will have been completely finished by now - if (allFinished) { - g_tut_done = true; - } - } - }; - return tut_obj; - })() - - var all_notifications = []; - var last_notification_time = -1 - // takes a string and adds a new notification - var notify = function(note, color) { - var the_pos = null; - if (active_cell) { - console.log("Setting to active cell"); - a_pos = active_cell.get_pos(); - the_pos = new p.PVector(a_pos.x, a_pos.y - 30); - } - else { - console.log("Setting to default"); - the_pos = new p.PVector(p.width * (5/8), p.height * (5/8)); - } - if (new Date().getTime() > (last_notification_time + 2000)) { // two seconds - all_notifications.push(notification(p, { "text": note, "color": color, - "pos" : the_pos})); - last_notification_time = new Date().getTime(); - } - }; - - var generator = make_generator(p, { - game : obj, - mutation : mutation - }); - - // temporary flag TODO - //var game_over = false; - - //A mapping from game_object types to their rendering levels - var type_to_level = { - "background_object":0, - "background_edge":0, - "wall":1, - "wall_segment":1, - "particle":2, // general name for level - "cell":3, // general name for level - "wall_cell": 3, - "empty_cell": 3, - "enemy":4, // general name for level - "floater":4, - "tkiller":4, - "antibody":4, - "b_cell": 5, - "multiplier":6, - "info":7 - }; - - // given a type returns the array of objects - // corresponding to that type's level - var level = function(type) { - var lvl = game_objects[type_to_level[type]]; - assert (lvl, type+" not a valid type!"); - return lvl; - }; - - -/* - // Buttons - // Have a rectangle representing their position and - // a state to go to when pressed - var pause_button = { - state : pause_state(), - rectangle : rectangle(p, { - pos : new p.PVector(p.width - 20, 20), - width : 20, - height : 20 - }) - }; - var help_button = { - state : help_state(), - rectangle : rectangle(p, { - pos : new p.PVector(p.width - 80, 20), - width : 20, - height : 20 - }) - }; - var exit_button = { - state : exit_state(), - rectangle : rectangle(p, { - pos : new p.PVector(20, 20), - width : 20, - height : 20 - }) - }; -*/ - //Not ordered - - - // --- private methods --- - - // initialization code goes here - // gets called at the bottom - var init = function() { - // Start playing the game music - if (g.music) { - sounds.play_background_music(); - } - - //Initialize game_objects to be a list of num_of_render_levels empty lists - var num_of_render_levels = 0; - for (var key in type_to_level){ - if (type_to_level.hasOwnProperty(key)) { - var new_level = type_to_level[key]; - if (new_level > num_of_render_levels) { - num_of_render_levels = new_level; - } - } - } - for (var i = 0; i < num_of_render_levels; i++) { - game_objects[i] = []; - } - - var startx = p.width-150; - if (testing) { - var startx = 150; - } - - var initial_cells = [ - cell(p, { - pos: new p.PVector(startx, p.height/2), - vel: new p.PVector(0, 0), - state: "alive", - }), - cell(p, { - pos: new p.PVector(startx+170, p.height/2-40), - vel: new p.PVector(0, 0), - state: "alive", - }), - cell(p, { - pos: new p.PVector(startx+170, p.height/2), - vel: new p.PVector(0, 0), - state: "alive", - }), - cell(p, { - pos: new p.PVector(startx+170, p.height/2+40), - vel: new p.PVector(0, 0), - state: "alive", - }) - ]; - //var cell_level = type_to_level["cell"]; - //game_objects[cell_level].push(initial_cell); - obj.add_objects(initial_cells); - - var initial_par = particle(p, { - pos: new p.PVector(0, p.height/2), - vel: new p.PVector(8, 0), - // start with some gray - mutation_info: mutation.get_info()//p.color(250, 250, 250) - //mutation : mutation - }); - - obj.add_object(initial_par); - - init_walls(); - init_back(); - - //active_cell = initial_cell; - - // Add background - //var bg = background(p, { pos : new p.PVector(0, 0)}); - //obj.add_object(bg); - //console.log(level("background")[0]); - }; - - // creates, adds, and returns a new b_cell with no target - var make_b_cell = function() { - var new_b_cell = b_cell(p, { - pos: new p.PVector(p.width+50, p.random(p.height/4, 3*p.height/4)), - }); - obj.add_object(new_b_cell); - return new_b_cell; - }; - - // creates, adds, and returns a new tkiller with no target - var make_tkiller = function() { - var new_tkiller = tkiller(p, { - pos: new p.PVector(p.width+50, p.random(p.height/4, 3*p.height/4)), - }); - obj.add_object(new_tkiller); - return new_tkiller; - }; - - // Returns the current b cell on the screen, if there is one - var get_b_cell = function(level) { - var the_b_cell = null; - do_to_type( - function(b) { - if (b.get_level() === level) { - the_b_cell = b; - } - }, - "b_cell", true - ); - return the_b_cell; - }; - - var alert_b_cell = function(flo) { - // gets b_cell of the flo's level - var b = get_b_cell(flo.get_level()); - // if there isn't one - if (!b) { - // make one - b = make_b_cell(); - b.set_mutation_info(flo.get_mutation_info()); - b.set_target(flo); - } - // if there is one - else { - // it should be either active, shooting, or outdated - // so do nothing - } - }; - - // Alerts the b cell (only one on screen at a time?) to a newly mutated - // obj. - // If o.mutation_level >= b cells current target.mutation_level and o is - // closer than the b cells curr target (or if b cells curr - // target is null), updates b_cells curr target to be o - /* - var alert_b_cell = function(o) { - //var cell_objs = level("b_cell"); - //var cell_obj = null; - /*for (var i = 0; i < cell_objs.length; i++) { - cell_obj = cell_objs[i]; - if (cell_obj.get_type() === "b_cell") { - the_b_cell = cell_obj; - } - } - / - - var the_b_cell = get_b_cell(); - - if (the_b_cell && the_b_cell.is_alive()) { - var old_target = the_b_cell.get_target(); - - if (old_target) { - // if new macro has higher or equal level - if (//o.get_level() >= old_target.get_level() - // if new macro has current mutation level - o.get_level() === mutation.get_level() - // and it is closer - && old_target.get_pos().dist(the_b_cell.get_pos()) > - o.get_pos().dist(the_b_cell.get_pos())) { - the_b_cell.set_target(o); - } - } - else { - the_b_cell.set_target(o); - } - } - }; - */ - - // sets active_cell to the leftmost infected cell - // if there is one - var next_active_cell = function() { - var sort_fun = function(active_c) { // don't care about active - if (last_active_cell) { - // let's try the nearest cell to the one that died - return function(c1, c2) { - return dist_less_than(last_active_cell, c1, c2) ? -1 : 1; - }; - } - // otherwise leftmost - return function(c1, c2) { - return c1.get_pos().x - c2.get_pos().x; - }; - } - choose_cell(sort_fun); - }; - - // Set the next-left or next-right cell to be active, and - // if appropriate sets current active to be not active - - // Chooses the closest cell to a_pos - var choose_closest_cell = function(a_pos) { - if (active_cell) { // for the beginning - var old_active = active_cell; - var sort_fun = function(active_cell){ - return function(c1, c2){ - return c1.get_pos().dist(a_pos) - - c2.get_pos().dist(a_pos); - } - }; - choose_cell(sort_fun); - - // In case it doesn't change (choose_cell assumes - // that the cell is diff from the curr active) - if (old_active.get_pos().dist(a_pos) < - active_cell.get_pos().dist(a_pos)) { - active_cell.set_state("infected"); - active_cell = old_active; - active_cell.set_state("active"); - } - } - } - - // Chooses the closest cell to the active cell in the direction of comp, - // i.e. such that comp(c1.x, active.x) is true - var choose_cell_helper = function(comp) { - var sort_fun = function(active_c) { //don't rename to active_cell - return function(c1, c2) { - c1x = c1.get_pos().x; - c2x = c2.get_pos().x; - actx = active_c.get_pos().x; - // If one is in the right dir and the other isnt, - // return the one that is - if (comp(c1x, actx) && !(comp(c2x, actx))) { - return -1; - } - else if (!(comp(c1x, actx)) && comp(c2x, actx)) { - return 1; - } - // If they are on the same side, return opposite of comp - else { - if (comp(c1x, c2x)) { - return 1; - } - else { - return -1; - } - } - } - }; - choose_cell(sort_fun); - }; - - // Chooses the next left cell to be active - var choose_left_cell = function() { - choose_cell_helper(function (x, y) {return x < y;}); - }; - - // Same in the right dir - var choose_right_cell = function() { - choose_cell_helper(function (x, y) {return x > y;}); - }; - - // Sets a cell to be active based on sort_fun, and if this is diff - // from curr cell, sets curr cell to not be active - // sort_fun must take the currently active cell, and return a function - // that takes 2 cells, ad returns true if the first is 'better' than - // the second - var choose_cell = function(sort_fun) { - var cells = level("cell");//game_objects[type_to_level["cell"]]; - var infecteds = cells.filter( - function(cell) { - // don't want empty_cells - return cell.get_type() === "cell" - && cell.get_state() === "infected"; - }); - var sort_f = sort_fun(active_cell); - infecteds.sort(sort_f); - - var curr_active = active_cell; - if (infecteds.length > 0) { - - // tutorial msg about switching cells - if (infecteds.length > 1) { - tut_manager.popup("arrows"); - } - - active_cell = infecteds[0]; - //If same as current - if (curr_active) { // for the beginning - curr_active.set_state("infected"); //if same, about to change - } - active_cell.set_state("active"); - //console.log("got next "+active_cell.to_string()); - } - }; - - // Returns true if source is closer to target1 than target2 - // All 3 args are game_objs - var dist_less_than = function(source, target1, target2) { - var source_pos = source.get_pos(); - return source_pos.dist(target1.get_pos()) < - source_pos.dist(target2.get_pos()); - }; - - // Updates all tkillers targets - // Tkillers target the closest infected and targeted cell - var update_tkillers_targets = function(){ - var all_infected_cells = get_all_infected_cells(); - do_to_type(function(tkill){ - // remove bad targets - if (tkill.get_target() - // if it's dead - && (tkill.get_target().is_dead() - // or dying - || tkill.get_target().get_state() === "dying" - // or offscreen - || tkill.get_target().is_offscreen() - // or the target mutated - || !same_mutation_level(tkill, tkill.get_target()))) { - tkill.set_target(null); - } - // set a new target - for_each( - all_infected_cells, - function(infected_cell) { - if (infected_cell.has_antibody() - && same_mutation_level(infected_cell, tkill) - && (!tkill.get_target() || - dist_less_than(tkill, - infected_cell, tkill.get_target()))) { - tkill.set_target(infected_cell); - } - } - ); - }, "tkiller", true); - }; - - // adds new tkillers if need be - var add_tkillers = function() { - var tks = get_all_of_type("tkiller"); - do_to_type( - // for each b_cell - function(b) { - // if it needs a tkiller - if (b.is_shooting()) { - // check if one exists - var has_tkiller = false; - for_each(tks, function(tk) { - if (same_mutation_level(b, tk)) { - has_tkiller = true; - } - }); - // if one doesn't - if (!has_tkiller) { - console.log("made tkiller for lvl "+b.get_level()); - // make one - var tk = make_tkiller(); - tk.set_mutation_info(b.get_mutation_info()); - } - } - }, - "b_cell", true - ); - }; - - - // kills the active cell and updates the targets - // of all the tkillers - var kill_active_cell = function() { - active_cell.die(); - last_active_cell = active_cell; - active_cell = null; - update_tkillers_targets(); - }; - - //Checks whether any 2 objs are colliding, and if so calls handle_collision on them - var check_collisions = (function() { - // rendering levels to check collisions for: - var to_check = [ - //["particle", "particle"], - ["particle", "cell"], - ["particle", "enemy"], - ["particle", "multiplier"], - //["cell", "cell"], - ["cell", "enemy"], - //["enemy", "enemy"], - ["enemy", "b_cell"], - ["b_cell", "wall"], - ["particle", "wall"], - ["multiplier", "wall"], - ["enemy", "wall"] - ]; - - // hey this looks like combinations! - var do_comb = function(arr1, start1, end1, - arr2, start2, end2, fun) { - var i = start1, j = start2; - while (i <= end1) { - while (j <= end2) { - fun(arr1[i], arr2[j]); - j++; - } - i++; - // when arrays are the same - // don't do repeats - if (arr1 === arr2) { - j = i; - } - else { - j = 0; - } - } - }; - - var collision_fun = function() { - // double combinations! - // for each pair of rendering groups - // do_comb(game_objects, 1, 3, - // game_objects, 1, 3, - for_each(to_check, function(pair) { - var lvl1 = level(pair[0]); - var lvl2 = level(pair[1]); - // for each pair of objects in the groups - do_comb(lvl1, 0, lvl1.length-1, - lvl2, 0, lvl2.length-1, check); - }); - //); - }; - - - var check = function(obj1, obj2) { - //console.log("checking "+obj1.to_string() - // +", "+obj2.to_string()); - // check the collisions - // don't check collisions with self - if (obj1 !== obj2 - && check_collision(obj1, obj2)) { - handle_collision(obj1, obj2); - //console.log("collision! " +obj1.to_string() - // +", "+obj2.to_string()); - } - } - - return collision_fun; - }()); - - // Returns whether 2 objects are colliding - var check_collision = function(obj1, obj2) { - var type1 = obj1.get_type(); - var type2 = obj2.get_type(); - - if (!obj1.is_off_right() && - !obj2.is_off_right() && - check_circle_collision(obj1, obj2)) { - var check_again = retrieve(extra_check, type1, type2); - if (check_again !== undefined) { - return check_again(obj1, obj2); - } - else { - check_again = retrieve(extra_check, type2, type1); - if (check_again !== undefined) { - return check_again(obj2, obj1); - } - else { - return true; - } - } - } - else { - return false; - } - }; - - // Checks for a collision between circle (obj2) and rectangle (obj1) - var check_rectangle_collision = function(rect, circ) { - return overlapping_vertically(circ, rect, rect.get_y_offset()) && - overlapping_horizontally(circ, rect, rect.get_x_offset()); - }; - - // Rectangle and circle collision helper functions - // Returns whether the circle is overlapping the rectangle, horizontally, - // by offset num of pixels - var overlapping_horizontally = function(circ, rect, offset) { - var circlel = circ.get_left(), circler = circ.get_right(); - var rectl = rect.get_left(), rectr = rect.get_right(); - return ((circler <= rectr && circler >= (rectl + offset)) || - (circlel >= rectl && circlel <= (rectr - offset))); - }; - // Returns whether the circle is overlapping the rectangle, vertically, - // by offset num of pixels - var overlapping_vertically = function(circ, rect, offset) { - var circlet = circ.get_top(), circleb = circ.get_bottom(); - var rectt = rect.get_top(), rectb = rect.get_bottom(); - - return (circleb <= rectb && circleb >= (rectt + offset) || - (circlet >= rectt && circlet <= (rectb - offset))); - }; - - // holds extra collision checking functions for certain - // pairs of types - var extra_check = { - "wall_segment": { - "particle": check_rectangle_collision, - "b_cell": check_rectangle_collision, - "multiplier": //check_rectangle_collision - // had to do manually cuz offset was messed up - function(rect, circ) { - return overlapping_vertically(circ, rect, 0) && - overlapping_horizontally(circ, rect, 0); - } - }, - "floater": { - "b_cell": check_rectangle_collision - }, - "wall_cell": { - "particle": check_rectangle_collision - } - }; - - // checks for collisions between two objects by - // checking if their bounding circles are overlapping - // returns true if they are colliding - var check_circle_collision = function(obj1, obj2) { - // if the distance between their center points - // is <= the sum of their radii then they are colliding - // ONLY WORKS FOR CENTERED SHAPES - return (obj1.get_pos().dist(obj2.get_pos()) - <= obj1.get_radius() + obj2.get_radius()); - }; - // make it public - obj.check_circle_collision = check_circle_collision; - - /* - // Reverses 2 objs appropriate velocities - var bounce_collided = (function() { - // A list containing 2 element lists - // Inner lists represent object type pairs to not bounce off each other - var to_exclude = [ ["particle", "multiplier"], - ["particle", "particle"], - ["wall_segment", "b_cell"], - ["particle", "antibody"]]; - - var is_excluded = function(o1, o2) { - var is_excluded = false; - var type1 = o1.get_type(), type2 = o2.get_type(); - var objs_in_list = function(list) { - return ((list[0] === type1 && list[1] === type2) || - (list[0] === type2 && list[1] === type1)); - } - for_each(to_exclude, function(l) { - if (objs_in_list(l)) { - is_excluded = true; - } - }); - return is_excluded; - } - return function(obj1, obj2) { - if (!is_excluded(obj1, obj2)) { - bounce(obj1, obj2); - } - } - }()); - */ - - var bounce = function(obj1, obj2) { - //offset adjusts how closely we check, since we can't check exactly when they collide every time - var offset = 5; - var onel = obj1.get_left(), oner = obj1.get_right(); - var onet = obj1.get_top(), oneb = obj1.get_bottom(); - var twol = obj2.get_left() + offset, twor = obj2.get_right() - offset; - var twot = obj2.get_top() + offset, twob = obj2.get_bottom() - offset; - - //When bouncing, check velocity to make sure they are 'incoming' to each other - //This avoids them getting stuck (makes sure they didn't just collide) - //bounce vertically - var y_vel = obj1.get_vel().y; - var x_vel = obj1.get_vel().x; - if ((onet >= twob && y_vel <= 0) || (oneb <= twot && y_vel >= 0)) { - obj1.reverse_y(); - obj2.reverse_y(); - } - if ((oner <= twol && x_vel >= 0) - || (onel > twor && x_vel <= 0)) { //bounce horizontally - obj1.reverse_x(); - obj2.reverse_x(); - } - }; - - // handles collisions between different object types - var handle_collision = function(obj1, obj2) { - var ot1 = obj1.get_type(); - var ot2 = obj2.get_type(); - - // try first with one order - var handler = retrieve(collision_handlers, ot1, ot2); - if (handler) { - handler(obj1, obj2); - } - // if it didn't work - else { - // try the other order - handler = retrieve(collision_handlers, ot2, ot1); - if (handler) { - handler(obj2, obj1); - } - else { - //Not an error now? - //throw "Unsupported collision type!"; - } - - } - - // Bounce if appropriate - //bounce_collided(obj1, obj2); - }; - - // object to store all the handlers - // created once with a closure - // dont manage bouncing/changing direction here - var collision_handlers = (function() { - var nothing = function(obj1, obj2) {}; - - // infects the cell, kills the particle - var infect = function(par, cell) { - // only if cell is "alive" - // (ie only one particle per cell) - assert(cell, "Not a cell in infect!"); - if (cell.get_state() !== "dead" - && cell.get_state() !== "dying") { - par.die(); - } - if (cell.get_state() === "alive") { - tut_manager.popup("spacebar"); - //Play sound - sounds.play_sound("cell_infect"); - - // increase mutation percentage if level is highest on screen - // must be done before setting state of infected cell - // only happens if infected by particle of cur level - if (par.get_level() === mutation.get_level()) { - mutation.infected_cell(); - } - - cell.set_state("infected"); - cell.set_mutation_info(par.get_mutation_info()); - - // Add 10 to score - score.incr(10 * par.get_level() * mult.get_num()); - } - else { - // otherwise deflect - //bounce(par, cell); - } - }; - - - var handlers = { - "particle": { - // particle vs. particle - // do nothing? - "particle": nothing, - - // particle vs. cell - // infect the cell, kill the particle - "cell": infect, - - // particle vs. wall_cell - // bounce particle off cell - // cell doesn't move - "wall_cell": bounce, - - // particle vs. empty_cell - // // infect the cell, kill the particle - // kill the particle - "empty_cell": function(par, cell) { - // TODO diff sound? - sounds.play_sound("cell_infect"); - par.die(); - }, - - // particle vs. floater - // kill the particle - // floater takes on color of particle - "floater": function(par, flo) { - par.die(); - if (flo.is_alive()) { - // update flo if not activated || level < - // par.level - if (!flo.is_activated() || - flo.get_level() < - par.get_level()) { - flo.set_mutation_info(par.get_mutation_info()); - flo.activate(); - alert_b_cell(flo); - sounds.play_sound("macrophage_infect"); - tut_manager.popup("macrophage"); - } - notify("Macrophage activated!", BAD_NOTIFICATION_COLOR); - } - }, - - // particle vs. tkiller - // nothing? - "tkiller": nothing, - - // particle vs. multiplier - // get rid of the mult and incr mult - "multiplier": function(par, mul) { - //par.die(); - mul.die(); - mult.incr(1); - }, - - // particle vs wall - // Kill particle - "wall_segment": function(par, wall) { - par.die(); - } - }, - - // cell vs. cell - // cell vs. wall_cell - // cell vs. empty_cell - // wall_cell vs. wall_cell - // wall_cell vs. empty_cell - // empty_cell vs. empty_cell - // don't let them overlap (is bouncing necessary?) - "cell": { - "cell": nothing, - "wall_cell": nothing, - "empty_cell": nothing - }, - "wall_cell": { - "wall_cell": nothing, - "empty_cell": nothing - }, - "empty_cell": { - "empty_cell": nothing - }, - - // floater vs. cell - // floater vs. wall_cell - // floater vs. empty_cell - // floater vs. floater - // no overlap? - "floater": { - "cell": bounce, - "wall_cell": bounce, - "empty_cell": bounce, - "floater": bounce - }, - - "tkiller": { - // tkiller vs. cell - "cell": function(tk, cell) { - if ((cell.get_state() === "infected" || - cell.get_state() === "active") - && cell.has_antibody() - && same_mutation_level(tk, cell)) { - tut_manager.popup("killer"); - cell.die(); - sounds.play_sound("kill"); - tk.set_target(null); - if (active_cell === cell) { - //last_active_cell = active_cell; - //active_cell = null; - kill_active_cell(); - } - } - }, - - // tkiller vs. wall_cell - // tkiller vs. empty_cell - // tkiller vs. floater - // tkiller vs. tkiller - // nothing? TODO bounce? - "wall_cell": nothing, - "empty_cell": nothing, - "floater": nothing, - "tkiller": nothing - }, - - "antibody": { - "cell": function(a, c) { - if (same_mutation_level(a, c)) { - if (!c.has_antibody() && - (c.get_state() === "infected" || - c.get_state() === "active")) { - c.set_antibody(a); - } - } - } - }, - - "multiplier": { - // multiplier vs wall - // do nothing - "wall_segment": bounce - }, - - "b_cell": { - "floater": function(b, flo) { - if (b.is_alive() && flo.is_activated()) { - b.set_mutation_info(flo.get_mutation_info()); - b.activate(get_bcell_slot()); - bounce(b, flo); - notify("B cell activated!", BAD_NOTIFICATION_COLOR); - } - // trying to avoid getting stuck - if (b.is_outdated()) { - bounce(b, flo); - b.set_target(null); - } - }, - "wall_segment": function(b, wall) { - //console.log("collision"); - if (b.is_activated()) { - tut_manager.popup("antibodies"); - // start making antibodies - b.make_antibodies(); - // make a tkiller - var tk = make_tkiller(); - tk.set_mutation_info(b.get_mutation_info()); - - notify("Incoming antibodies!", BAD_NOTIFICATION_COLOR); - } - else if (b.is_alive()) { - bounce(b, wall); - } - else if (b.is_outdated()) { - } - } - } - }; - return handlers; - }()); - - //Removes all objs which are either off screen or dead - var remove_objs = function() { - var filter_fun = function(x) { - //Check offscreen, but don't remove newly generated - var offscreen = false; - if (x.is_offscreen()) { - //Only remove particles that are off the right - if (x.is_off_right()) { - if (x.get_type() === "particle") { - offscreen = true; - } - //else false - } - else { - //console.log("removing "+x.to_string()); - offscreen = true; - } - } - return (! (offscreen || x.is_dead())); - }; - for (var i = 0; i < game_objects.length; i++) { - game_objects[i] = game_objects[i].filter(filter_fun); - } - - // check offscreen for active cell - if (active_cell && active_cell.is_offscreen()) { - //active_cell = null; - kill_active_cell(); - } - }; - - // Returns whether the 2 objects have the same mutation level - var same_mutation_level = function(o1, o2) { - var o1level = o1.get_mutation_info().level; - var o2level = o2.get_mutation_info().level; - return (o1level === o2level); - }; - - - // adds a new background tile if the rightmost is onscreen - // ASSUMES ALL WALL TILES ARE SAME SIZE - var back_top = null; - var back_btm = null; - var add_back = (function() { - - var add_one = function(edge_tile) { - if (!goes_off_right(edge_tile)) { - //console.log("adding edge"); - - var new_spec = {}; - var x = edge_tile.get_pos().x - + edge_tile.get_width(); - - var y = status_bar_height; - new_spec.is_top = true; - // switch if it's a bottom edge - if (edge_tile === back_btm) { - // this will be changed in the edge object - y = p.height; - new_spec.is_top = false; - } - - new_spec.pos = new p.PVector(x, y); - - var new_tile = background_edge(p, new_spec); - obj.add_object(new_tile); - - if (edge_tile === back_top) { - back_top = new_tile; - } - else { - back_btm = new_tile; - } - //console.log("added tile "+new_tile.to_string()); - } - }; - - var add_both = function() { - add_one(back_top); - add_one(back_btm); - }; - - return add_both; - }()); - - // initialized the background - var init_back = function() { - // initial edges - back_top = background_edge(p, { - pos: new p.PVector(-100, status_bar_height), - is_top: true - }); - obj.add_object(back_top); - - back_btm = background_edge(p, { - pos: new p.PVector(-10, p.height), - is_top: false - }); - obj.add_object(back_btm); - - // add one more tile to fill screen - add_back(); - }; - - // tells if a background tile goes off the right of the screen - var goes_off_right = function(tile) { - return tile.get_pos().x + tile.get_width() > p.width; - }; - - // adds a new wall segment if the rightmost wall - // segment is onscreen - var rightmost_top = null; - var rightmost_btm = null; - var add_wall = (function() { - - // adds either a top or bottom wall - var add_one = function(rightmost) { - // if the rightmost has entered the screen - if (!rightmost.is_off_right()) { - var new_spec = {}; - - // note that new wall coords should be at - // bottom left corner of seg - // should be next to last seg - var x = rightmost.get_pos().x - + rightmost.get_width()/2 - 5; - - // set y for top wall - var y = 95; - new_spec.is_top = true; - // switch if it's a bottom wall - if (rightmost === rightmost_top) { - y = p.height+5; - new_spec.is_top = false; - } - - new_spec.pos = new p.PVector(x, y); - - // add the new segment - var new_seg = wall_segment(p, new_spec); - obj.add_object(new_seg); - - // update the corresponding rightmost - if (rightmost === rightmost_top) { - rightmost_top = new_seg; - } - else { - rightmost_btm = new_seg; - } - } - }; - - var add_both = function() { - add_one(rightmost_top); - add_one(rightmost_btm); - }; - - return add_both; - }()); - - var init_walls = function() { - // add first empty segments - // the values used here are important so don't change them - rightmost_top = wall_segment(p, { - pos: new p.PVector(-10, 0), - width: 5 - }); - - rightmost_btm = wall_segment(p, { - pos: new p.PVector(-10, p.height), - width: 5 - }); - - // while both walls don't span the screen - while(!(rightmost_top.is_off_right() - && rightmost_btm.is_off_right())) { - // add new walls - add_wall(); - } - }; - - //Does a function to every object - //Pass in a function that takes an object - var do_to_all_objs = function(f) { - for (var i=0; i= 0) ) { - do_to_all_objs(function(o) { o.get_pos().add( - new p.PVector(-dist/10, 0)); }); - //["particle", "cell", "enemy"], false); - } - } - }; - - - // --- public methods --- - - obj.get_type = function() { - return "game"; - }; - - //Calls update() on every obj - //after updating, calls remove_objs - obj.update = (function() { - var game_types = ["background", "wall", "particle", - "cell", "enemy", "multiplier", "antibody"]; - - var update_fun = function() { - // Can't be set when object is initialized - // Takes time every update though to check - if (!set_time) { - //Set interval to update time elapsed - var update_time = function() { - if (!paused) { - time_elapsed += 1; - time_status.set_num(time_elapsed); - } - } - setInterval(update_time, 1000); - set_time = true; - } - if (!paused) { - // if we don't have an active cell - if (active_cell === null) { - // try to find the next one - next_active_cell(); - } - // THIS MUST COME BEFORE GAME OVER CHECK - - // check for game over - // (if no particles are left and no active cell) - //console.log("num of particles: " + level("particle").length); - if (active_cell === null && - level("particle").length === 0) { - var go_state = game_over_state(p, previous_state, { - score : score.get_num(), - mutation_level : mutation.get_level() - }, game_type); - sounds.pause_background_music(); - obj.set_next_state(go_state); - - // stop the animations - do_to_all_objs( - function(o) { - if (o.stop_animation) { - o.stop_animation(); - } - } - ); - - // stop notifications - all_notifications = []; - - // stop the time and stuff - paused = true; - - // Add to the high score table - // If fb user name and id are set - if (g_user_name && g_user_id) { - scores.submit_score(score.get_num(), - mutation.get_level(), g_user_name, g_user_id); - // Update the high score table - // (not necessary now) - //scores.do_scores(); - } - - // simply don't do the rest of update - return; - } - - //Add any newly generated objs - generator.update(); - - // Make antibodies seek any infected cells they are near - make_antibodies_seek(); - - // Add antibodies generated from b cells - do_to_type( - function(b) { - obj.add_objects(b.get_antibodies()); - }, - "b_cell", true - ); - - // adds a new segment of wall if necessary - add_wall(); - // adds a new background tile if necessary - add_back(); - - add_tkillers(); - update_tkillers_targets(); - - // set outdated t/b cells - set_all_outdated(); - - // scroll all objects - - do_to_all_objs(function(o){ - o.scroll(scroll_factor); - }); - - //dynamic_scroll(); - - // update distance travelled - distance += scroll_factor; - - // update all objects - do_to_all_objs(function(o){ - o.update(); - }); - - check_collisions(); - - remove_objs(); - - update_mutation(); - - /* - // for debugging - var count = 0; - do_to_all_objs(function() { count += 1; }); - console.log(count); - console.log("fr "+p.__frameRate); - */ - } - }; - - var update_mutation = function() { - // check for a new mutation - // if mutation occurred - if (mutation.has_new_mutation() && active_cell) { - // pick infected cell closest to active cell with the current - // mutation level - var choices = get_all_of_type("cell").filter( - function(c) { - return ((c.get_state() === "infected" - || c.get_state() === "active") - && c.get_level() === mutation.get_level()); - } - ); - choices.sort( - function(c1, c2) { - return dist_less_than(active_cell, c1, c2) ? -1 : 1; - } - ); - var cell_to_mutate = choices[0]; - - // do the actual mutation and hold onto new ability - //var new_ability = - mutation.do_mutation(); - // mutate the active cell - cell_to_mutate.set_mutation_info(mutation.get_info()); - // update the scroll factor - scroll_factor += 0.15; - - //if (new_ability) { - // notify("New Ability: " + new_ability); - //} - //else { - notify("Mutation occurred!", GOOD_NOTIFICATION_COLOR); - //} - - - tut_manager.popup("mutation"); - - console.log("mutation occurred!"); - } - // otherwise check for downgrades - else { - // check for the highest mutation level on screen - var max_level = 0; - var find_max = function(o) { - if (o.get_level() > max_level) { - max_level = o.get_level(); - } - }; - do_to_type(find_max, "cell", false); - do_to_type(find_max, "particle", false); - - // if max level lower than mutation level - if (max_level > 0 && max_level < mutation.get_level()) { - // downgrade to that level - mutation.set_level(max_level); - // reset the counters - mutation.reset_mutation(); - - notify("Lost new strain!", BAD_NOTIFICATION_COLOR); - tut_manager.popup("strain"); - console.log("downgraded to mutation level "+max_level); - - scroll_factor -= 0.15; - - // TODO do enemies become not outdated? - } - } - }; - - return update_fun; - }()); - - //Calls draw() on every obj - obj.render = function(){ - - // put the active cell at the end of the list - // so it is drawn on top - if (active_cell) { - var cells = level("cell"); - remove_elt(cells, active_cell); - cells.push(active_cell); - } - - p.background(g.background_color); - - for (var i=0; i -Virion - - - - - - -
      - - - - - - - diff --git a/game/fb/index.html.BASE.17064.html b/game/fb/index.html.BASE.17064.html deleted file mode 100644 index b4ee629..0000000 --- a/game/fb/index.html.BASE.17064.html +++ /dev/null @@ -1,104 +0,0 @@ - -Virion - - - - - - -
      - - - - - - diff --git a/game/fb/index.html.LOCAL.17064.html b/game/fb/index.html.LOCAL.17064.html deleted file mode 100644 index 160b267..0000000 --- a/game/fb/index.html.LOCAL.17064.html +++ /dev/null @@ -1,104 +0,0 @@ - -Virion - - - - - - -
      - - - - - - diff --git a/game/fb/index.html.REMOTE.17064.html b/game/fb/index.html.REMOTE.17064.html deleted file mode 100644 index 0d44769..0000000 --- a/game/fb/index.html.REMOTE.17064.html +++ /dev/null @@ -1,104 +0,0 @@ - -Virion - - - - - - -
      - - - - - - diff --git a/game/fb/index1.html b/game/fb/index1.html deleted file mode 100644 index 5e756e6..0000000 --- a/game/fb/index1.html +++ /dev/null @@ -1,301 +0,0 @@ - - - -Virion - - - - - - - - - - -
      - - - - - - - -
      - - -
      - -
      -
      - Could not load high scores! You may want to check your internet connection. -
      -
      - - - Your browser does not support the HTML5 canvas element. Upgrade to Chrome, Firefox 4, Safari, or Opera to play this game. - - -
      - -
      -
      - Note: Virion was built entirely using the new open HTML5 standard and the Processing.js JavaScript library. This means that you will never have to install a proprietary plugin to play our game, and in the near future will be able to play our game on any browser on any platform. Currently, however, some browsers do not yet have full support for the HTML5 standard, so please note the following browser compatibility issues:

      - Google Chrome has no problems, and is highly recommended for the best overall performance
      - If you are using Firefox 3 and the game is not loading or running slowly, try updating to Firefox 4
      - If you are using Safari and seeing performance issues, try turning off the sound effects
      - If you are using Internet Explorer, please ensure that you have updated to the latest version (Internet Explorer 9), or the game will not run. -

      -
      -
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/fb/indexTest.html b/game/fb/indexTest.html deleted file mode 100644 index 15c3b4d..0000000 --- a/game/fb/indexTest.html +++ /dev/null @@ -1,105 +0,0 @@ - -Virion - - - - - - - -
      - - - - - - diff --git a/game/fb/jplayer/Jplayer.swf b/game/fb/jplayer/Jplayer.swf deleted file mode 100755 index 9487f49..0000000 Binary files a/game/fb/jplayer/Jplayer.swf and /dev/null differ diff --git a/game/fb/jplayer/jquery.jplayer.min.js b/game/fb/jplayer/jquery.jplayer.min.js deleted file mode 100755 index b9b7007..0000000 --- a/game/fb/jplayer/jquery.jplayer.min.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - * jPlayer Plugin for jQuery JavaScript Library - * http://www.happyworm.com/jquery/jplayer - * - * Copyright (c) 2009 - 2010 Happyworm Ltd - * Dual licensed under the MIT and GPL licenses. - * - http://www.opensource.org/licenses/mit-license.php - * - http://www.gnu.org/copyleft/gpl.html - * - * Author: Mark J Panaghiston - * Version: 2.0.0 - * Date: 20th December 2010 - */ - -(function(c,h){c.fn.jPlayer=function(a){var b=typeof a==="string",d=Array.prototype.slice.call(arguments,1),f=this;a=!b&&d.length?c.extend.apply(null,[true,a].concat(d)):a;if(b&&a.charAt(0)==="_")return f;b?this.each(function(){var e=c.data(this,"jPlayer"),g=e&&c.isFunction(e[a])?e[a].apply(e,d):e;if(g!==e&&g!==h){f=g;return false}}):this.each(function(){var e=c.data(this,"jPlayer");if(e){e.option(a||{})._init();e.option(a||{})}else c.data(this,"jPlayer",new c.jPlayer(a,this))});return f};c.jPlayer= -function(a,b){if(arguments.length){this.element=c(b);this.options=c.extend(true,{},this.options,a);var d=this;this.element.bind("remove.jPlayer",function(){d.destroy()});this._init()}};c.jPlayer.event={ready:"jPlayer_ready",resize:"jPlayer_resize",error:"jPlayer_error",warning:"jPlayer_warning",loadstart:"jPlayer_loadstart",progress:"jPlayer_progress",suspend:"jPlayer_suspend",abort:"jPlayer_abort",emptied:"jPlayer_emptied",stalled:"jPlayer_stalled",play:"jPlayer_play",pause:"jPlayer_pause",loadedmetadata:"jPlayer_loadedmetadata", -loadeddata:"jPlayer_loadeddata",waiting:"jPlayer_waiting",playing:"jPlayer_playing",canplay:"jPlayer_canplay",canplaythrough:"jPlayer_canplaythrough",seeking:"jPlayer_seeking",seeked:"jPlayer_seeked",timeupdate:"jPlayer_timeupdate",ended:"jPlayer_ended",ratechange:"jPlayer_ratechange",durationchange:"jPlayer_durationchange",volumechange:"jPlayer_volumechange"};c.jPlayer.htmlEvent=["loadstart","abort","emptied","stalled","loadedmetadata","loadeddata","canplaythrough","ratechange"];c.jPlayer.pause= -function(){c.each(c.jPlayer.prototype.instances,function(a,b){b.data("jPlayer").status.srcSet&&b.jPlayer("pause")})};c.jPlayer.timeFormat={showHour:false,showMin:true,showSec:true,padHour:false,padMin:true,padSec:true,sepHour:":",sepMin:":",sepSec:""};c.jPlayer.convertTime=function(a){a=new Date(a*1E3);var b=a.getUTCHours(),d=a.getUTCMinutes();a=a.getUTCSeconds();b=c.jPlayer.timeFormat.padHour&&b<10?"0"+b:b;d=c.jPlayer.timeFormat.padMin&&d<10?"0"+d:d;a=c.jPlayer.timeFormat.padSec&&a<10?"0"+a:a;return(c.jPlayer.timeFormat.showHour? -b+c.jPlayer.timeFormat.sepHour:"")+(c.jPlayer.timeFormat.showMin?d+c.jPlayer.timeFormat.sepMin:"")+(c.jPlayer.timeFormat.showSec?a+c.jPlayer.timeFormat.sepSec:"")};c.jPlayer.uaMatch=function(a){a=a.toLowerCase();var b=/(opera)(?:.*version)?[ \/]([\w.]+)/,d=/(msie) ([\w.]+)/,f=/(mozilla)(?:.*? rv:([\w.]+))?/;a=/(webkit)[ \/]([\w.]+)/.exec(a)||b.exec(a)||d.exec(a)||a.indexOf("compatible")<0&&f.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}};c.jPlayer.browser={};var m=c.jPlayer.uaMatch(navigator.userAgent); -if(m.browser){c.jPlayer.browser[m.browser]=true;c.jPlayer.browser.version=m.version}c.jPlayer.prototype={count:0,version:{script:"2.0.0",needFlash:"2.0.0",flash:"unknown"},options:{swfPath:"./",solution:"html, flash",supplied:"mp3",preload:"metadata",volume:0.8,muted:false,backgroundColor:"#000000",cssSelectorAncestor:"#jp_interface_1",cssSelector:{videoPlay:".jp-video-play",play:".jp-play",pause:".jp-pause",stop:".jp-stop",seekBar:".jp-seek-bar",playBar:".jp-play-bar",mute:".jp-mute",unmute:".jp-unmute", -volumeBar:".jp-volume-bar",volumeBarValue:".jp-volume-bar-value",currentTime:".jp-current-time",duration:".jp-duration"},idPrefix:"jp",errorAlerts:false,warningAlerts:false},instances:{},status:{src:"",media:{},paused:true,format:{},formatType:"",waitForPlay:true,waitForLoad:true,srcSet:false,video:false,seekPercent:0,currentPercentRelative:0,currentPercentAbsolute:0,currentTime:0,duration:0},_status:{volume:h,muted:false,width:0,height:0},internal:{ready:false,instance:h,htmlDlyCmdId:h},solution:{html:true, -flash:true},format:{mp3:{codec:'audio/mpeg; codecs="mp3"',flashCanPlay:true,media:"audio"},m4a:{codec:'audio/mp4; codecs="mp4a.40.2"',flashCanPlay:true,media:"audio"},oga:{codec:'audio/ogg; codecs="vorbis"',flashCanPlay:false,media:"audio"},wav:{codec:'audio/wav; codecs="1"',flashCanPlay:false,media:"audio"},webma:{codec:'audio/webm; codecs="vorbis"',flashCanPlay:false,media:"audio"},m4v:{codec:'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',flashCanPlay:true,media:"video"},ogv:{codec:'video/ogg; codecs="theora, vorbis"', -flashCanPlay:false,media:"video"},webmv:{codec:'video/webm; codecs="vorbis, vp8"',flashCanPlay:false,media:"video"}},_init:function(){var a=this;this.element.empty();this.status=c.extend({},this.status,this._status);this.internal=c.extend({},this.internal);this.formats=[];this.solutions=[];this.require={};this.htmlElement={};this.html={};this.html.audio={};this.html.video={};this.flash={};this.css={};this.css.cs={};this.css.jq={};this.status.volume=this._limitValue(this.options.volume,0,1);this.status.muted= -this.options.muted;this.status.width=this.element.css("width");this.status.height=this.element.css("height");this.element.css({"background-color":this.options.backgroundColor});c.each(this.options.supplied.toLowerCase().split(","),function(e,g){var i=g.replace(/^\s+|\s+$/g,"");if(a.format[i]){var j=false;c.each(a.formats,function(n,k){if(i===k){j=true;return false}});j||a.formats.push(i)}});c.each(this.options.solution.toLowerCase().split(","),function(e,g){var i=g.replace(/^\s+|\s+$/g,"");if(a.solution[i]){var j= -false;c.each(a.solutions,function(n,k){if(i===k){j=true;return false}});j||a.solutions.push(i)}});this.internal.instance="jp_"+this.count;this.instances[this.internal.instance]=this.element;this.element.attr("id")===""&&this.element.attr("id",this.options.idPrefix+"_jplayer_"+this.count);this.internal.self=c.extend({},{id:this.element.attr("id"),jq:this.element});this.internal.audio=c.extend({},{id:this.options.idPrefix+"_audio_"+this.count,jq:h});this.internal.video=c.extend({},{id:this.options.idPrefix+ -"_video_"+this.count,jq:h});this.internal.flash=c.extend({},{id:this.options.idPrefix+"_flash_"+this.count,jq:h,swf:this.options.swfPath+(this.options.swfPath!==""&&this.options.swfPath.slice(-1)!=="/"?"/":"")+"Jplayer.swf"});this.internal.poster=c.extend({},{id:this.options.idPrefix+"_poster_"+this.count,jq:h});c.each(c.jPlayer.event,function(e,g){if(a.options[e]!==h){a.element.bind(g+".jPlayer",a.options[e]);a.options[e]=h}});this.htmlElement.poster=document.createElement("img");this.htmlElement.poster.id= -this.internal.poster.id;this.htmlElement.poster.onload=function(){if(!a.status.video||a.status.waitForPlay)a.internal.poster.jq.show()};this.element.append(this.htmlElement.poster);this.internal.poster.jq=c("#"+this.internal.poster.id);this.internal.poster.jq.css({width:this.status.width,height:this.status.height});this.internal.poster.jq.hide();this.require.audio=false;this.require.video=false;c.each(this.formats,function(e,g){a.require[a.format[g].media]=true});this.html.audio.available=false;if(this.require.audio){this.htmlElement.audio= -document.createElement("audio");this.htmlElement.audio.id=this.internal.audio.id;this.html.audio.available=!!this.htmlElement.audio.canPlayType}this.html.video.available=false;if(this.require.video){this.htmlElement.video=document.createElement("video");this.htmlElement.video.id=this.internal.video.id;this.html.video.available=!!this.htmlElement.video.canPlayType}this.flash.available=this._checkForFlash(10);this.html.canPlay={};this.flash.canPlay={};c.each(this.formats,function(e,g){a.html.canPlay[g]= -a.html[a.format[g].media].available&&""!==a.htmlElement[a.format[g].media].canPlayType(a.format[g].codec);a.flash.canPlay[g]=a.format[g].flashCanPlay&&a.flash.available});this.html.desired=false;this.flash.desired=false;c.each(this.solutions,function(e,g){if(e===0)a[g].desired=true;else{var i=false,j=false;c.each(a.formats,function(n,k){if(a[a.solutions[0]].canPlay[k])if(a.format[k].media==="video")j=true;else i=true});a[g].desired=a.require.audio&&!i||a.require.video&&!j}});this.html.support={}; -this.flash.support={};c.each(this.formats,function(e,g){a.html.support[g]=a.html.canPlay[g]&&a.html.desired;a.flash.support[g]=a.flash.canPlay[g]&&a.flash.desired});this.html.used=false;this.flash.used=false;c.each(this.solutions,function(e,g){c.each(a.formats,function(i,j){if(a[g].support[j]){a[g].used=true;return false}})});this.html.used||this.flash.used||this._error({type:c.jPlayer.error.NO_SOLUTION,context:"{solution:'"+this.options.solution+"', supplied:'"+this.options.supplied+"'}",message:c.jPlayer.errorMsg.NO_SOLUTION, -hint:c.jPlayer.errorHint.NO_SOLUTION});this.html.active=false;this.html.audio.gate=false;this.html.video.gate=false;this.flash.active=false;this.flash.gate=false;if(this.flash.used){var b="id="+escape(this.internal.self.id)+"&vol="+this.status.volume+"&muted="+this.status.muted;if(c.browser.msie&&Number(c.browser.version)<=8){var d='';f[1]='';f[2]='';f[3]='';f[4]='';b=document.createElement(d);for(d=0;d0?100*d/this.status.duration:0;if(typeof a.seekable==="object"&&a.seekable.length>0){e=this.status.duration>0?100*a.seekable.end(a.seekable.length-1)/this.status.duration:100;g=100*a.currentTime/a.seekable.end(a.seekable.length-1)}else{e=100;g=f}if(b)f=g=d=0;this.status.seekPercent=e;this.status.currentPercentRelative=g;this.status.currentPercentAbsolute=f;this.status.currentTime=d},_resetStatus:function(){this.status=c.extend({},this.status,c.jPlayer.prototype.status)}, -_trigger:function(a,b,d){a=c.Event(a);a.jPlayer={};a.jPlayer.version=c.extend({},this.version);a.jPlayer.status=c.extend(true,{},this.status);a.jPlayer.html=c.extend(true,{},this.html);a.jPlayer.flash=c.extend(true,{},this.flash);if(b)a.jPlayer.error=c.extend({},b);if(d)a.jPlayer.warning=c.extend({},d);this.element.trigger(a)},jPlayerFlashEvent:function(a,b){if(a===c.jPlayer.event.ready&&!this.internal.ready){this.internal.ready=true;this.version.flash=b.version;this.version.needFlash!==this.version.flash&& -this._error({type:c.jPlayer.error.VERSION,context:this.version.flash,message:c.jPlayer.errorMsg.VERSION+this.version.flash,hint:c.jPlayer.errorHint.VERSION});this._trigger(a)}if(this.flash.gate)switch(a){case c.jPlayer.event.progress:this._getFlashStatus(b);this._updateInterface();this._trigger(a);break;case c.jPlayer.event.timeupdate:this._getFlashStatus(b);this._updateInterface();this._trigger(a);break;case c.jPlayer.event.play:this._seeked();this._updateButtons(true);this._trigger(a);break;case c.jPlayer.event.pause:this._updateButtons(false); -this._trigger(a);break;case c.jPlayer.event.ended:this._updateButtons(false);this._trigger(a);break;case c.jPlayer.event.error:this.status.waitForLoad=true;this.status.waitForPlay=true;this.status.video&&this.internal.flash.jq.css({width:"0px",height:"0px"});this._validString(this.status.media.poster)&&this.internal.poster.jq.show();this.css.jq.videoPlay.length&&this.css.jq.videoPlay.show();this.status.video?this._flash_setVideo(this.status.media):this._flash_setAudio(this.status.media);this._error({type:c.jPlayer.error.URL, -context:b.src,message:c.jPlayer.errorMsg.URL,hint:c.jPlayer.errorHint.URL});break;case c.jPlayer.event.seeking:this._seeking();this._trigger(a);break;case c.jPlayer.event.seeked:this._seeked();this._trigger(a);break;default:this._trigger(a)}return false},_getFlashStatus:function(a){this.status.seekPercent=a.seekPercent;this.status.currentPercentRelative=a.currentPercentRelative;this.status.currentPercentAbsolute=a.currentPercentAbsolute;this.status.currentTime=a.currentTime;this.status.duration=a.duration}, -_updateButtons:function(a){this.status.paused=!a;if(this.css.jq.play.length&&this.css.jq.pause.length)if(a){this.css.jq.play.hide();this.css.jq.pause.show()}else{this.css.jq.play.show();this.css.jq.pause.hide()}},_updateInterface:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.width(this.status.seekPercent+"%");this.css.jq.playBar.length&&this.css.jq.playBar.width(this.status.currentPercentRelative+"%");this.css.jq.currentTime.length&&this.css.jq.currentTime.text(c.jPlayer.convertTime(this.status.currentTime)); -this.css.jq.duration.length&&this.css.jq.duration.text(c.jPlayer.convertTime(this.status.duration))},_seeking:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.addClass("jp-seeking-bg")},_seeked:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.removeClass("jp-seeking-bg")},setMedia:function(a){var b=this;this._seeked();clearTimeout(this.internal.htmlDlyCmdId);var d=this.html.audio.gate,f=this.html.video.gate,e=false;c.each(this.formats,function(g,i){var j=b.format[i].media==="video"; -c.each(b.solutions,function(n,k){if(b[k].support[i]&&b._validString(a[i])){var l=k==="html";if(j)if(l){b.html.audio.gate=false;b.html.video.gate=true;b.flash.gate=false}else{b.html.audio.gate=false;b.html.video.gate=false;b.flash.gate=true}else if(l){b.html.audio.gate=true;b.html.video.gate=false;b.flash.gate=false}else{b.html.audio.gate=false;b.html.video.gate=false;b.flash.gate=true}if(b.flash.active||b.html.active&&b.flash.gate||d===b.html.audio.gate&&f===b.html.video.gate)b.clearMedia();else if(d!== -b.html.audio.gate&&f!==b.html.video.gate){b._html_pause();b.status.video&&b.internal.video.jq.css({width:"0px",height:"0px"});b._resetStatus()}if(j){if(l){b._html_setVideo(a);b.html.active=true;b.flash.active=false}else{b._flash_setVideo(a);b.html.active=false;b.flash.active=true}b.css.jq.videoPlay.length&&b.css.jq.videoPlay.show();b.status.video=true}else{if(l){b._html_setAudio(a);b.html.active=true;b.flash.active=false}else{b._flash_setAudio(a);b.html.active=false;b.flash.active=true}b.css.jq.videoPlay.length&& -b.css.jq.videoPlay.hide();b.status.video=false}e=true;return false}});if(e)return false});if(e){if(this._validString(a.poster))if(this.htmlElement.poster.src!==a.poster)this.htmlElement.poster.src=a.poster;else this.internal.poster.jq.show();else this.internal.poster.jq.hide();this.status.srcSet=true;this.status.media=c.extend({},a);this._updateButtons(false);this._updateInterface()}else{this.status.srcSet&&!this.status.waitForPlay&&this.pause();this.html.audio.gate=false;this.html.video.gate=false; -this.flash.gate=false;this.html.active=false;this.flash.active=false;this._resetStatus();this._updateInterface();this._updateButtons(false);this.internal.poster.jq.hide();this.html.used&&this.require.video&&this.internal.video.jq.css({width:"0px",height:"0px"});this.flash.used&&this.internal.flash.jq.css({width:"0px",height:"0px"});this._error({type:c.jPlayer.error.NO_SUPPORT,context:"{supplied:'"+this.options.supplied+"'}",message:c.jPlayer.errorMsg.NO_SUPPORT,hint:c.jPlayer.errorHint.NO_SUPPORT})}}, -clearMedia:function(){this._resetStatus();this._updateButtons(false);this.internal.poster.jq.hide();clearTimeout(this.internal.htmlDlyCmdId);if(this.html.active)this._html_clearMedia();else this.flash.active&&this._flash_clearMedia()},load:function(){if(this.status.srcSet)if(this.html.active)this._html_load();else this.flash.active&&this._flash_load();else this._urlNotSetError("load")},play:function(a){a=typeof a==="number"?a:NaN;if(this.status.srcSet)if(this.html.active)this._html_play(a);else this.flash.active&& -this._flash_play(a);else this._urlNotSetError("play")},videoPlay:function(){this.play()},pause:function(a){a=typeof a==="number"?a:NaN;if(this.status.srcSet)if(this.html.active)this._html_pause(a);else this.flash.active&&this._flash_pause(a);else this._urlNotSetError("pause")},pauseOthers:function(){var a=this;c.each(this.instances,function(b,d){a.element!==d&&d.data("jPlayer").status.srcSet&&d.jPlayer("pause")})},stop:function(){if(this.status.srcSet)if(this.html.active)this._html_pause(0);else this.flash.active&& -this._flash_pause(0);else this._urlNotSetError("stop")},playHead:function(a){a=this._limitValue(a,0,100);if(this.status.srcSet)if(this.html.active)this._html_playHead(a);else this.flash.active&&this._flash_playHead(a);else this._urlNotSetError("playHead")},mute:function(){this.status.muted=true;this.html.used&&this._html_mute(true);this.flash.used&&this._flash_mute(true);this._updateMute(true);this._updateVolume(0);this._trigger(c.jPlayer.event.volumechange)},unmute:function(){this.status.muted=false; -this.html.used&&this._html_mute(false);this.flash.used&&this._flash_mute(false);this._updateMute(false);this._updateVolume(this.status.volume);this._trigger(c.jPlayer.event.volumechange)},_updateMute:function(a){if(this.css.jq.mute.length&&this.css.jq.unmute.length)if(a){this.css.jq.mute.hide();this.css.jq.unmute.show()}else{this.css.jq.mute.show();this.css.jq.unmute.hide()}},volume:function(a){a=this._limitValue(a,0,1);this.status.volume=a;this.html.used&&this._html_volume(a);this.flash.used&&this._flash_volume(a); -this.status.muted||this._updateVolume(a);this._trigger(c.jPlayer.event.volumechange)},volumeBar:function(a){if(!this.status.muted&&this.css.jq.volumeBar){var b=this.css.jq.volumeBar.offset();a=a.pageX-b.left;b=this.css.jq.volumeBar.width();this.volume(a/b)}},volumeBarValue:function(a){this.volumeBar(a)},_updateVolume:function(a){this.css.jq.volumeBarValue.length&&this.css.jq.volumeBarValue.width(a*100+"%")},_volumeFix:function(a){var b=0.0010*Math.random();return a+(a<0.5?b:-b)},_cssSelectorAncestor:function(a, -b){this.options.cssSelectorAncestor=a;b&&c.each(this.options.cssSelector,function(d,f){self._cssSelector(d,f)})},_cssSelector:function(a,b){var d=this;if(typeof b==="string")if(c.jPlayer.prototype.options.cssSelector[a]){this.css.jq[a]&&this.css.jq[a].length&&this.css.jq[a].unbind(".jPlayer");this.options.cssSelector[a]=b;this.css.cs[a]=this.options.cssSelectorAncestor+" "+b;this.css.jq[a]=b?c(this.css.cs[a]):[];this.css.jq[a].length&&this.css.jq[a].bind("click.jPlayer",function(f){d[a](f);c(this).blur(); -return false});b&&this.css.jq[a].length!==1&&this._warning({type:c.jPlayer.warning.CSS_SELECTOR_COUNT,context:this.css.cs[a],message:c.jPlayer.warningMsg.CSS_SELECTOR_COUNT+this.css.jq[a].length+" found for "+a+" method.",hint:c.jPlayer.warningHint.CSS_SELECTOR_COUNT})}else this._warning({type:c.jPlayer.warning.CSS_SELECTOR_METHOD,context:a,message:c.jPlayer.warningMsg.CSS_SELECTOR_METHOD,hint:c.jPlayer.warningHint.CSS_SELECTOR_METHOD});else this._warning({type:c.jPlayer.warning.CSS_SELECTOR_STRING, -context:b,message:c.jPlayer.warningMsg.CSS_SELECTOR_STRING,hint:c.jPlayer.warningHint.CSS_SELECTOR_STRING})},seekBar:function(a){if(this.css.jq.seekBar){var b=this.css.jq.seekBar.offset();a=a.pageX-b.left;b=this.css.jq.seekBar.width();this.playHead(100*a/b)}},playBar:function(a){this.seekBar(a)},currentTime:function(){},duration:function(){},option:function(a,b){var d=a;if(arguments.length===0)return c.extend(true,{},this.options);if(typeof a==="string"){var f=a.split(".");if(b===h){for(var e=c.extend(true, -{},this.options),g=0;g=9||this.htmlElement.media.load()}},_html_load:function(){if(this.status.waitForLoad){this.status.waitForLoad=false;this.htmlElement.media.src=this.status.src; -try{this.htmlElement.media.load()}catch(a){}}clearTimeout(this.internal.htmlDlyCmdId)},_html_play:function(a){var b=this;this._html_load();this.htmlElement.media.play();if(!isNaN(a))try{this.htmlElement.media.currentTime=a}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.play(a)},100);return}this._html_checkWaitForPlay()},_html_pause:function(a){var b=this;a>0?this._html_load():clearTimeout(this.internal.htmlDlyCmdId);this.htmlElement.media.pause();if(!isNaN(a))try{this.htmlElement.media.currentTime= -a}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.pause(a)},100);return}a>0&&this._html_checkWaitForPlay()},_html_playHead:function(a){var b=this;this._html_load();try{if(typeof this.htmlElement.media.seekable==="object"&&this.htmlElement.media.seekable.length>0)this.htmlElement.media.currentTime=a*this.htmlElement.media.seekable.end(this.htmlElement.media.seekable.length-1)/100;else if(this.htmlElement.media.duration>0&&!isNaN(this.htmlElement.media.duration))this.htmlElement.media.currentTime= -a*this.htmlElement.media.duration/100;else throw"e";}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.playHead(a)},100);return}this.status.waitForLoad||this._html_checkWaitForPlay()},_html_checkWaitForPlay:function(){if(this.status.waitForPlay){this.status.waitForPlay=false;this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide();if(this.status.video){this.internal.poster.jq.hide();this.internal.video.jq.css({width:this.status.width,height:this.status.height})}}},_html_volume:function(a){if(this.html.audio.available)this.htmlElement.audio.volume= -a;if(this.html.video.available)this.htmlElement.video.volume=a},_html_mute:function(a){if(this.html.audio.available)this.htmlElement.audio.muted=a;if(this.html.video.available)this.htmlElement.video.muted=a},_flash_setAudio:function(a){var b=this;try{c.each(this.formats,function(f,e){if(b.flash.support[e]&&a[e]){switch(e){case "m4a":b._getMovie().fl_setAudio_m4a(a[e]);break;case "mp3":b._getMovie().fl_setAudio_mp3(a[e])}b.status.src=a[e];b.status.format[e]=true;b.status.formatType=e;return false}}); -if(this.options.preload==="auto"){this._flash_load();this.status.waitForLoad=false}}catch(d){this._flashError(d)}},_flash_setVideo:function(a){var b=this;try{c.each(this.formats,function(f,e){if(b.flash.support[e]&&a[e]){switch(e){case "m4v":b._getMovie().fl_setVideo_m4v(a[e])}b.status.src=a[e];b.status.format[e]=true;b.status.formatType=e;return false}});if(this.options.preload==="auto"){this._flash_load();this.status.waitForLoad=false}}catch(d){this._flashError(d)}},_flash_clearMedia:function(){this.internal.flash.jq.css({width:"0px", -height:"0px"});try{this._getMovie().fl_clearMedia()}catch(a){this._flashError(a)}},_flash_load:function(){try{this._getMovie().fl_load()}catch(a){this._flashError(a)}this.status.waitForLoad=false},_flash_play:function(a){try{this._getMovie().fl_play(a)}catch(b){this._flashError(b)}this.status.waitForLoad=false;this._flash_checkWaitForPlay()},_flash_pause:function(a){try{this._getMovie().fl_pause(a)}catch(b){this._flashError(b)}if(a>0){this.status.waitForLoad=false;this._flash_checkWaitForPlay()}}, -_flash_playHead:function(a){try{this._getMovie().fl_play_head(a)}catch(b){this._flashError(b)}this.status.waitForLoad||this._flash_checkWaitForPlay()},_flash_checkWaitForPlay:function(){if(this.status.waitForPlay){this.status.waitForPlay=false;this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide();if(this.status.video){this.internal.poster.jq.hide();this.internal.flash.jq.css({width:this.status.width,height:this.status.height})}}},_flash_volume:function(a){try{this._getMovie().fl_volume(a)}catch(b){this._flashError(b)}}, -_flash_mute:function(a){try{this._getMovie().fl_mute(a)}catch(b){this._flashError(b)}},_getMovie:function(){return document[this.internal.flash.id]},_checkForFlash:function(a){var b=false,d;if(window.ActiveXObject)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+a);b=true}catch(f){}else if(navigator.plugins&&navigator.mimeTypes.length>0)if(d=navigator.plugins["Shockwave Flash"])if(navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/,"$1")>=a)b=true;return c.browser.msie&& -Number(c.browser.version)>=9?false:b},_validString:function(a){return a&&typeof a==="string"},_limitValue:function(a,b,d){return ad?d:a},_urlNotSetError:function(a){this._error({type:c.jPlayer.error.URL_NOT_SET,context:a,message:c.jPlayer.errorMsg.URL_NOT_SET,hint:c.jPlayer.errorHint.URL_NOT_SET})},_flashError:function(a){this._error({type:c.jPlayer.error.FLASH,context:this.internal.flash.swf,message:c.jPlayer.errorMsg.FLASH+a.message,hint:c.jPlayer.errorHint.FLASH})},_error:function(a){this._trigger(c.jPlayer.event.error, -a);if(this.options.errorAlerts)this._alert("Error!"+(a.message?"\n\n"+a.message:"")+(a.hint?"\n\n"+a.hint:"")+"\n\nContext: "+a.context)},_warning:function(a){this._trigger(c.jPlayer.event.warning,h,a);if(this.options.errorAlerts)this._alert("Warning!"+(a.message?"\n\n"+a.message:"")+(a.hint?"\n\n"+a.hint:"")+"\n\nContext: "+a.context)},_alert:function(a){alert("jPlayer "+this.version.script+" : id='"+this.internal.self.id+"' : "+a)}};c.jPlayer.error={FLASH:"e_flash",NO_SOLUTION:"e_no_solution",NO_SUPPORT:"e_no_support", -URL:"e_url",URL_NOT_SET:"e_url_not_set",VERSION:"e_version"};c.jPlayer.errorMsg={FLASH:"jPlayer's Flash fallback is not configured correctly, or a command was issued before the jPlayer Ready event. Details: ",NO_SOLUTION:"No solution can be found by jPlayer in this browser. Neither HTML nor Flash can be used.",NO_SUPPORT:"It is not possible to play any media format provided in setMedia() on this browser using your current options.",URL:"Media URL could not be loaded.",URL_NOT_SET:"Attempt to issue media playback commands, while no media url is set.", -VERSION:"jPlayer "+c.jPlayer.prototype.version.script+" needs Jplayer.swf version "+c.jPlayer.prototype.version.needFlash+" but found "};c.jPlayer.errorHint={FLASH:"Check your swfPath option and that Jplayer.swf is there.",NO_SOLUTION:"Review the jPlayer options: support and supplied.",NO_SUPPORT:"Video or audio formats defined in the supplied option are missing.",URL:"Check media URL is valid.",URL_NOT_SET:"Use setMedia() to set the media URL.",VERSION:"Update jPlayer files."};c.jPlayer.warning= -{CSS_SELECTOR_COUNT:"e_css_selector_count",CSS_SELECTOR_METHOD:"e_css_selector_method",CSS_SELECTOR_STRING:"e_css_selector_string",OPTION_KEY:"e_option_key"};c.jPlayer.warningMsg={CSS_SELECTOR_COUNT:"The number of methodCssSelectors found did not equal one: ",CSS_SELECTOR_METHOD:"The methodName given in jPlayer('cssSelector') is not a valid jPlayer method.",CSS_SELECTOR_STRING:"The methodCssSelector given in jPlayer('cssSelector') is not a String or is empty.",OPTION_KEY:"The option requested in jPlayer('option') is undefined."}; -c.jPlayer.warningHint={CSS_SELECTOR_COUNT:"Check your css selector and the ancestor.",CSS_SELECTOR_METHOD:"Check your method name.",CSS_SELECTOR_STRING:"Check your css selector is a string.",OPTION_KEY:"Check your option name."}})(jQuery); diff --git a/game/fb/jquery-1.4.4.min.js b/game/fb/jquery-1.4.4.min.js deleted file mode 100644 index 8f3ca2e..0000000 --- a/game/fb/jquery-1.4.4.min.js +++ /dev/null @@ -1,167 +0,0 @@ -/*! - * jQuery JavaScript Library v1.4.4 - * http://jquery.com/ - * - * Copyright 2010, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * Copyright 2010, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * - * Date: Thu Nov 11 19:04:53 2010 -0500 - */ -(function(E,B){function ka(a,b,d){if(d===B&&a.nodeType===1){d=a.getAttribute("data-"+b);if(typeof d==="string"){try{d=d==="true"?true:d==="false"?false:d==="null"?null:!c.isNaN(d)?parseFloat(d):Ja.test(d)?c.parseJSON(d):d}catch(e){}c.data(a,b,d)}else d=B}return d}function U(){return false}function ca(){return true}function la(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function Ka(a){var b,d,e,f,h,l,k,o,x,r,A,C=[];f=[];h=c.data(this,this.nodeType?"events":"__events__");if(typeof h==="function")h= -h.events;if(!(a.liveFired===this||!h||!h.live||a.button&&a.type==="click")){if(a.namespace)A=RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)");a.liveFired=this;var J=h.live.slice(0);for(k=0;kd)break;a.currentTarget=f.elem;a.data=f.handleObj.data;a.handleObj=f.handleObj;A=f.handleObj.origHandler.apply(f.elem,arguments);if(A===false||a.isPropagationStopped()){d=f.level;if(A===false)b=false;if(a.isImmediatePropagationStopped())break}}return b}}function Y(a,b){return(a&&a!=="*"?a+".":"")+b.replace(La, -"`").replace(Ma,"&")}function ma(a,b,d){if(c.isFunction(b))return c.grep(a,function(f,h){return!!b.call(f,h,f)===d});else if(b.nodeType)return c.grep(a,function(f){return f===b===d});else if(typeof b==="string"){var e=c.grep(a,function(f){return f.nodeType===1});if(Na.test(b))return c.filter(b,e,!d);else b=c.filter(b,e)}return c.grep(a,function(f){return c.inArray(f,b)>=0===d})}function na(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var e=c.data(a[d++]),f=c.data(this, -e);if(e=e&&e.events){delete f.handle;f.events={};for(var h in e)for(var l in e[h])c.event.add(this,h,e[h][l],e[h][l].data)}}})}function Oa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function oa(a,b,d){var e=b==="width"?a.offsetWidth:a.offsetHeight;if(d==="border")return e;c.each(b==="width"?Pa:Qa,function(){d||(e-=parseFloat(c.css(a,"padding"+this))||0);if(d==="margin")e+=parseFloat(c.css(a, -"margin"+this))||0;else e-=parseFloat(c.css(a,"border"+this+"Width"))||0});return e}function da(a,b,d,e){if(c.isArray(b)&&b.length)c.each(b,function(f,h){d||Ra.test(a)?e(a,h):da(a+"["+(typeof h==="object"||c.isArray(h)?f:"")+"]",h,d,e)});else if(!d&&b!=null&&typeof b==="object")c.isEmptyObject(b)?e(a,""):c.each(b,function(f,h){da(a+"["+f+"]",h,d,e)});else e(a,b)}function S(a,b){var d={};c.each(pa.concat.apply([],pa.slice(0,b)),function(){d[this]=a});return d}function qa(a){if(!ea[a]){var b=c("<"+ -a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d==="")d="block";ea[a]=d}return ea[a]}function fa(a){return c.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var t=E.document,c=function(){function a(){if(!b.isReady){try{t.documentElement.doScroll("left")}catch(j){setTimeout(a,1);return}b.ready()}}var b=function(j,s){return new b.fn.init(j,s)},d=E.jQuery,e=E.$,f,h=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,l=/\S/,k=/^\s+/,o=/\s+$/,x=/\W/,r=/\d/,A=/^<(\w+)\s*\/?>(?:<\/\1>)?$/, -C=/^[\],:{}\s]*$/,J=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,w=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,I=/(?:^|:|,)(?:\s*\[)+/g,L=/(webkit)[ \/]([\w.]+)/,g=/(opera)(?:.*version)?[ \/]([\w.]+)/,i=/(msie) ([\w.]+)/,n=/(mozilla)(?:.*? rv:([\w.]+))?/,m=navigator.userAgent,p=false,q=[],u,y=Object.prototype.toString,F=Object.prototype.hasOwnProperty,M=Array.prototype.push,N=Array.prototype.slice,O=String.prototype.trim,D=Array.prototype.indexOf,R={};b.fn=b.prototype={init:function(j, -s){var v,z,H;if(!j)return this;if(j.nodeType){this.context=this[0]=j;this.length=1;return this}if(j==="body"&&!s&&t.body){this.context=t;this[0]=t.body;this.selector="body";this.length=1;return this}if(typeof j==="string")if((v=h.exec(j))&&(v[1]||!s))if(v[1]){H=s?s.ownerDocument||s:t;if(z=A.exec(j))if(b.isPlainObject(s)){j=[t.createElement(z[1])];b.fn.attr.call(j,s,true)}else j=[H.createElement(z[1])];else{z=b.buildFragment([v[1]],[H]);j=(z.cacheable?z.fragment.cloneNode(true):z.fragment).childNodes}return b.merge(this, -j)}else{if((z=t.getElementById(v[2]))&&z.parentNode){if(z.id!==v[2])return f.find(j);this.length=1;this[0]=z}this.context=t;this.selector=j;return this}else if(!s&&!x.test(j)){this.selector=j;this.context=t;j=t.getElementsByTagName(j);return b.merge(this,j)}else return!s||s.jquery?(s||f).find(j):b(s).find(j);else if(b.isFunction(j))return f.ready(j);if(j.selector!==B){this.selector=j.selector;this.context=j.context}return b.makeArray(j,this)},selector:"",jquery:"1.4.4",length:0,size:function(){return this.length}, -toArray:function(){return N.call(this,0)},get:function(j){return j==null?this.toArray():j<0?this.slice(j)[0]:this[j]},pushStack:function(j,s,v){var z=b();b.isArray(j)?M.apply(z,j):b.merge(z,j);z.prevObject=this;z.context=this.context;if(s==="find")z.selector=this.selector+(this.selector?" ":"")+v;else if(s)z.selector=this.selector+"."+s+"("+v+")";return z},each:function(j,s){return b.each(this,j,s)},ready:function(j){b.bindReady();if(b.isReady)j.call(t,b);else q&&q.push(j);return this},eq:function(j){return j=== --1?this.slice(j):this.slice(j,+j+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(N.apply(this,arguments),"slice",N.call(arguments).join(","))},map:function(j){return this.pushStack(b.map(this,function(s,v){return j.call(s,v,s)}))},end:function(){return this.prevObject||b(null)},push:M,sort:[].sort,splice:[].splice};b.fn.init.prototype=b.fn;b.extend=b.fn.extend=function(){var j,s,v,z,H,G=arguments[0]||{},K=1,Q=arguments.length,ga=false; -if(typeof G==="boolean"){ga=G;G=arguments[1]||{};K=2}if(typeof G!=="object"&&!b.isFunction(G))G={};if(Q===K){G=this;--K}for(;K0))if(q){var s=0,v=q;for(q=null;j=v[s++];)j.call(t,b);b.fn.trigger&&b(t).trigger("ready").unbind("ready")}}},bindReady:function(){if(!p){p=true;if(t.readyState==="complete")return setTimeout(b.ready,1);if(t.addEventListener){t.addEventListener("DOMContentLoaded",u,false);E.addEventListener("load",b.ready,false)}else if(t.attachEvent){t.attachEvent("onreadystatechange",u);E.attachEvent("onload", -b.ready);var j=false;try{j=E.frameElement==null}catch(s){}t.documentElement.doScroll&&j&&a()}}},isFunction:function(j){return b.type(j)==="function"},isArray:Array.isArray||function(j){return b.type(j)==="array"},isWindow:function(j){return j&&typeof j==="object"&&"setInterval"in j},isNaN:function(j){return j==null||!r.test(j)||isNaN(j)},type:function(j){return j==null?String(j):R[y.call(j)]||"object"},isPlainObject:function(j){if(!j||b.type(j)!=="object"||j.nodeType||b.isWindow(j))return false;if(j.constructor&& -!F.call(j,"constructor")&&!F.call(j.constructor.prototype,"isPrototypeOf"))return false;for(var s in j);return s===B||F.call(j,s)},isEmptyObject:function(j){for(var s in j)return false;return true},error:function(j){throw j;},parseJSON:function(j){if(typeof j!=="string"||!j)return null;j=b.trim(j);if(C.test(j.replace(J,"@").replace(w,"]").replace(I,"")))return E.JSON&&E.JSON.parse?E.JSON.parse(j):(new Function("return "+j))();else b.error("Invalid JSON: "+j)},noop:function(){},globalEval:function(j){if(j&& -l.test(j)){var s=t.getElementsByTagName("head")[0]||t.documentElement,v=t.createElement("script");v.type="text/javascript";if(b.support.scriptEval)v.appendChild(t.createTextNode(j));else v.text=j;s.insertBefore(v,s.firstChild);s.removeChild(v)}},nodeName:function(j,s){return j.nodeName&&j.nodeName.toUpperCase()===s.toUpperCase()},each:function(j,s,v){var z,H=0,G=j.length,K=G===B||b.isFunction(j);if(v)if(K)for(z in j){if(s.apply(j[z],v)===false)break}else for(;H
      a";var f=d.getElementsByTagName("*"),h=d.getElementsByTagName("a")[0],l=t.createElement("select"), -k=l.appendChild(t.createElement("option"));if(!(!f||!f.length||!h)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(h.getAttribute("style")),hrefNormalized:h.getAttribute("href")==="/a",opacity:/^0.55$/.test(h.style.opacity),cssFloat:!!h.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:k.selected,deleteExpando:true,optDisabled:false,checkClone:false, -scriptEval:false,noCloneEvent:true,boxModel:null,inlineBlockNeedsLayout:false,shrinkWrapBlocks:false,reliableHiddenOffsets:true};l.disabled=true;c.support.optDisabled=!k.disabled;b.type="text/javascript";try{b.appendChild(t.createTextNode("window."+e+"=1;"))}catch(o){}a.insertBefore(b,a.firstChild);if(E[e]){c.support.scriptEval=true;delete E[e]}try{delete b.test}catch(x){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function r(){c.support.noCloneEvent= -false;d.detachEvent("onclick",r)});d.cloneNode(true).fireEvent("onclick")}d=t.createElement("div");d.innerHTML="";a=t.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var r=t.createElement("div");r.style.width=r.style.paddingLeft="1px";t.body.appendChild(r);c.boxModel=c.support.boxModel=r.offsetWidth===2;if("zoom"in r.style){r.style.display="inline";r.style.zoom= -1;c.support.inlineBlockNeedsLayout=r.offsetWidth===2;r.style.display="";r.innerHTML="
      ";c.support.shrinkWrapBlocks=r.offsetWidth!==2}r.innerHTML="
      t
      ";var A=r.getElementsByTagName("td");c.support.reliableHiddenOffsets=A[0].offsetHeight===0;A[0].style.display="";A[1].style.display="none";c.support.reliableHiddenOffsets=c.support.reliableHiddenOffsets&&A[0].offsetHeight===0;r.innerHTML="";t.body.removeChild(r).style.display= -"none"});a=function(r){var A=t.createElement("div");r="on"+r;var C=r in A;if(!C){A.setAttribute(r,"return;");C=typeof A[r]==="function"}return C};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=f=h=null}})();var ra={},Ja=/^(?:\{.*\}|\[.*\])$/;c.extend({cache:{},uuid:0,expando:"jQuery"+c.now(),noData:{embed:true,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:true},data:function(a,b,d){if(c.acceptData(a)){a=a==E?ra:a;var e=a.nodeType,f=e?a[c.expando]:null,h= -c.cache;if(!(e&&!f&&typeof b==="string"&&d===B)){if(e)f||(a[c.expando]=f=++c.uuid);else h=a;if(typeof b==="object")if(e)h[f]=c.extend(h[f],b);else c.extend(h,b);else if(e&&!h[f])h[f]={};a=e?h[f]:h;if(d!==B)a[b]=d;return typeof b==="string"?a[b]:a}}},removeData:function(a,b){if(c.acceptData(a)){a=a==E?ra:a;var d=a.nodeType,e=d?a[c.expando]:a,f=c.cache,h=d?f[e]:e;if(b){if(h){delete h[b];d&&c.isEmptyObject(h)&&c.removeData(a)}}else if(d&&c.support.deleteExpando)delete a[c.expando];else if(a.removeAttribute)a.removeAttribute(c.expando); -else if(d)delete f[e];else for(var l in a)delete a[l]}},acceptData:function(a){if(a.nodeName){var b=c.noData[a.nodeName.toLowerCase()];if(b)return!(b===true||a.getAttribute("classid")!==b)}return true}});c.fn.extend({data:function(a,b){var d=null;if(typeof a==="undefined"){if(this.length){var e=this[0].attributes,f;d=c.data(this[0]);for(var h=0,l=e.length;h-1)return true;return false},val:function(a){if(!arguments.length){var b=this[0];if(b){if(c.nodeName(b,"option")){var d=b.attributes.value;return!d||d.specified?b.value:b.text}if(c.nodeName(b,"select")){var e=b.selectedIndex;d=[];var f=b.options;b=b.type==="select-one"; -if(e<0)return null;var h=b?e:0;for(e=b?e+1:f.length;h=0;else if(c.nodeName(this,"select")){var A=c.makeArray(r);c("option",this).each(function(){this.selected=c.inArray(c(this).val(),A)>=0});if(!A.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true}, -attr:function(a,b,d,e){if(!a||a.nodeType===3||a.nodeType===8)return B;if(e&&b in c.attrFn)return c(a)[b](d);e=a.nodeType!==1||!c.isXMLDoc(a);var f=d!==B;b=e&&c.props[b]||b;var h=Ta.test(b);if((b in a||a[b]!==B)&&e&&!h){if(f){b==="type"&&Ua.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");if(d===null)a.nodeType===1&&a.removeAttribute(b);else a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&& -b.specified?b.value:Va.test(a.nodeName)||Wa.test(a.nodeName)&&a.href?0:B;return a[b]}if(!c.support.style&&e&&b==="style"){if(f)a.style.cssText=""+d;return a.style.cssText}f&&a.setAttribute(b,""+d);if(!a.attributes[b]&&a.hasAttribute&&!a.hasAttribute(b))return B;a=!c.support.hrefNormalized&&e&&h?a.getAttribute(b,2):a.getAttribute(b);return a===null?B:a}});var X=/\.(.*)$/,ia=/^(?:textarea|input|select)$/i,La=/\./g,Ma=/ /g,Xa=/[^\w\s.|`]/g,Ya=function(a){return a.replace(Xa,"\\$&")},ua={focusin:0,focusout:0}; -c.event={add:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(c.isWindow(a)&&a!==E&&!a.frameElement)a=E;if(d===false)d=U;else if(!d)return;var f,h;if(d.handler){f=d;d=f.handler}if(!d.guid)d.guid=c.guid++;if(h=c.data(a)){var l=a.nodeType?"events":"__events__",k=h[l],o=h.handle;if(typeof k==="function"){o=k.handle;k=k.events}else if(!k){a.nodeType||(h[l]=h=function(){});h.events=k={}}if(!o)h.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem, -arguments):B};o.elem=a;b=b.split(" ");for(var x=0,r;l=b[x++];){h=f?c.extend({},f):{handler:d,data:e};if(l.indexOf(".")>-1){r=l.split(".");l=r.shift();h.namespace=r.slice(0).sort().join(".")}else{r=[];h.namespace=""}h.type=l;if(!h.guid)h.guid=d.guid;var A=k[l],C=c.event.special[l]||{};if(!A){A=k[l]=[];if(!C.setup||C.setup.call(a,e,r,o)===false)if(a.addEventListener)a.addEventListener(l,o,false);else a.attachEvent&&a.attachEvent("on"+l,o)}if(C.add){C.add.call(a,h);if(!h.handler.guid)h.handler.guid= -d.guid}A.push(h);c.event.global[l]=true}a=null}}},global:{},remove:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(d===false)d=U;var f,h,l=0,k,o,x,r,A,C,J=a.nodeType?"events":"__events__",w=c.data(a),I=w&&w[J];if(w&&I){if(typeof I==="function"){w=I;I=I.events}if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(f in I)c.event.remove(a,f+b)}else{for(b=b.split(" ");f=b[l++];){r=f;k=f.indexOf(".")<0;o=[];if(!k){o=f.split(".");f=o.shift();x=RegExp("(^|\\.)"+ -c.map(o.slice(0).sort(),Ya).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(A=I[f])if(d){r=c.event.special[f]||{};for(h=e||0;h=0){a.type=f=f.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[f]&&c.each(c.cache,function(){this.events&&this.events[f]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType=== -8)return B;a.result=B;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(e=d.nodeType?c.data(d,"handle"):(c.data(d,"__events__")||{}).handle)&&e.apply(d,b);e=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+f]&&d["on"+f].apply(d,b)===false){a.result=false;a.preventDefault()}}catch(h){}if(!a.isPropagationStopped()&&e)c.event.trigger(a,b,e,true);else if(!a.isDefaultPrevented()){var l;e=a.target;var k=f.replace(X,""),o=c.nodeName(e,"a")&&k=== -"click",x=c.event.special[k]||{};if((!x._default||x._default.call(d,a)===false)&&!o&&!(e&&e.nodeName&&c.noData[e.nodeName.toLowerCase()])){try{if(e[k]){if(l=e["on"+k])e["on"+k]=null;c.event.triggered=true;e[k]()}}catch(r){}if(l)e["on"+k]=l;c.event.triggered=false}}},handle:function(a){var b,d,e,f;d=[];var h=c.makeArray(arguments);a=h[0]=c.event.fix(a||E.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;if(!b){e=a.type.split(".");a.type=e.shift();d=e.slice(0).sort();e=RegExp("(^|\\.)"+ -d.join("\\.(?:.*\\.)?")+"(\\.|$)")}a.namespace=a.namespace||d.join(".");f=c.data(this,this.nodeType?"events":"__events__");if(typeof f==="function")f=f.events;d=(f||{})[a.type];if(f&&d){d=d.slice(0);f=0;for(var l=d.length;f-1?c.map(a.options,function(e){return e.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},Z=function(a,b){var d=a.target,e,f;if(!(!ia.test(d.nodeName)||d.readOnly)){e=c.data(d,"_change_data");f=xa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",f);if(!(e===B||f===e))if(e!=null||f){a.type="change";a.liveFired= -B;return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:Z,beforedeactivate:Z,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return Z.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return Z.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,"_change_data",xa(a))}},setup:function(){if(this.type=== -"file")return false;for(var a in V)c.event.add(this,a+".specialChange",V[a]);return ia.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return ia.test(this.nodeName)}};V=c.event.special.change.filters;V.focus=V.beforeactivate}t.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.trigger(e,null,e.target)}c.event.special[b]={setup:function(){ua[b]++===0&&t.addEventListener(a,d,true)},teardown:function(){--ua[b]=== -0&&t.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,e,f){if(typeof d==="object"){for(var h in d)this[b](h,e,d[h],f);return this}if(c.isFunction(e)||e===false){f=e;e=B}var l=b==="one"?c.proxy(f,function(o){c(this).unbind(o,l);return f.apply(this,arguments)}):f;if(d==="unload"&&b!=="one")this.one(d,e,f);else{h=0;for(var k=this.length;h0?this.bind(b,d,e):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});E.attachEvent&&!E.addEventListener&&c(E).bind("unload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}}); -(function(){function a(g,i,n,m,p,q){p=0;for(var u=m.length;p0){F=y;break}}y=y[g]}m[p]=F}}}var d=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,f=Object.prototype.toString,h=false,l=true;[0,0].sort(function(){l=false;return 0});var k=function(g,i,n,m){n=n||[];var p=i=i||t;if(i.nodeType!==1&&i.nodeType!==9)return[];if(!g||typeof g!=="string")return n;var q,u,y,F,M,N=true,O=k.isXML(i),D=[],R=g;do{d.exec("");if(q=d.exec(R)){R=q[3];D.push(q[1]);if(q[2]){F=q[3]; -break}}}while(q);if(D.length>1&&x.exec(g))if(D.length===2&&o.relative[D[0]])u=L(D[0]+D[1],i);else for(u=o.relative[D[0]]?[i]:k(D.shift(),i);D.length;){g=D.shift();if(o.relative[g])g+=D.shift();u=L(g,u)}else{if(!m&&D.length>1&&i.nodeType===9&&!O&&o.match.ID.test(D[0])&&!o.match.ID.test(D[D.length-1])){q=k.find(D.shift(),i,O);i=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]}if(i){q=m?{expr:D.pop(),set:C(m)}:k.find(D.pop(),D.length===1&&(D[0]==="~"||D[0]==="+")&&i.parentNode?i.parentNode:i,O);u=q.expr?k.filter(q.expr, -q.set):q.set;if(D.length>0)y=C(u);else N=false;for(;D.length;){q=M=D.pop();if(o.relative[M])q=D.pop();else M="";if(q==null)q=i;o.relative[M](y,q,O)}}else y=[]}y||(y=u);y||k.error(M||g);if(f.call(y)==="[object Array]")if(N)if(i&&i.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&k.contains(i,y[g])))n.push(u[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&n.push(u[g]);else n.push.apply(n,y);else C(y,n);if(F){k(F,p,n,m);k.uniqueSort(n)}return n};k.uniqueSort=function(g){if(w){h= -l;g.sort(w);if(h)for(var i=1;i0};k.find=function(g,i,n){var m;if(!g)return[];for(var p=0,q=o.order.length;p":function(g,i){var n,m=typeof i==="string",p=0,q=g.length;if(m&&!/\W/.test(i))for(i=i.toLowerCase();p=0))n||m.push(u);else if(n)i[q]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var i=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=i[1]+(i[2]||1)-0;g[3]=i[3]-0}g[0]=e++;return g},ATTR:function(g,i,n, -m,p,q){i=g[1].replace(/\\/g,"");if(!q&&o.attrMap[i])g[1]=o.attrMap[i];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,i,n,m,p){if(g[1]==="not")if((d.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,i);else{g=k.filter(g[3],i,n,true^p);n||m.push.apply(m,g);return false}else if(o.match.POS.test(g[0])||o.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled=== -true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,i,n){return!!k(n[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"=== -g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,i){return i===0},last:function(g,i,n,m){return i===m.length-1},even:function(g,i){return i%2===0},odd:function(g,i){return i%2===1},lt:function(g,i,n){return in[3]-0},nth:function(g,i,n){return n[3]- -0===i},eq:function(g,i,n){return n[3]-0===i}},filter:{PSEUDO:function(g,i,n,m){var p=i[1],q=o.filters[p];if(q)return q(g,n,i,m);else if(p==="contains")return(g.textContent||g.innerText||k.getText([g])||"").indexOf(i[3])>=0;else if(p==="not"){i=i[3];n=0;for(m=i.length;n=0}},ID:function(g,i){return g.nodeType===1&&g.getAttribute("id")===i},TAG:function(g,i){return i==="*"&&g.nodeType===1||g.nodeName.toLowerCase()=== -i},CLASS:function(g,i){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(i)>-1},ATTR:function(g,i){var n=i[1];n=o.attrHandle[n]?o.attrHandle[n](g):g[n]!=null?g[n]:g.getAttribute(n);var m=n+"",p=i[2],q=i[4];return n==null?p==="!=":p==="="?m===q:p==="*="?m.indexOf(q)>=0:p==="~="?(" "+m+" ").indexOf(q)>=0:!q?m&&n!==false:p==="!="?m!==q:p==="^="?m.indexOf(q)===0:p==="$="?m.substr(m.length-q.length)===q:p==="|="?m===q||m.substr(0,q.length+1)===q+"-":false},POS:function(g,i,n,m){var p=o.setFilters[i[2]]; -if(p)return p(g,n,i,m)}}},x=o.match.POS,r=function(g,i){return"\\"+(i-0+1)},A;for(A in o.match){o.match[A]=RegExp(o.match[A].source+/(?![^\[]*\])(?![^\(]*\))/.source);o.leftMatch[A]=RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[A].source.replace(/\\(\d+)/g,r))}var C=function(g,i){g=Array.prototype.slice.call(g,0);if(i){i.push.apply(i,g);return i}return g};try{Array.prototype.slice.call(t.documentElement.childNodes,0)}catch(J){C=function(g,i){var n=0,m=i||[];if(f.call(g)==="[object Array]")Array.prototype.push.apply(m, -g);else if(typeof g.length==="number")for(var p=g.length;n";n.insertBefore(g,n.firstChild);if(t.getElementById(i)){o.find.ID=function(m,p,q){if(typeof p.getElementById!=="undefined"&&!q)return(p=p.getElementById(m[1]))?p.id===m[1]||typeof p.getAttributeNode!=="undefined"&&p.getAttributeNode("id").nodeValue===m[1]?[p]:B:[]};o.filter.ID=function(m,p){var q=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&q&&q.nodeValue===p}}n.removeChild(g); -n=g=null})();(function(){var g=t.createElement("div");g.appendChild(t.createComment(""));if(g.getElementsByTagName("*").length>0)o.find.TAG=function(i,n){var m=n.getElementsByTagName(i[1]);if(i[1]==="*"){for(var p=[],q=0;m[q];q++)m[q].nodeType===1&&p.push(m[q]);m=p}return m};g.innerHTML="";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")o.attrHandle.href=function(i){return i.getAttribute("href",2)};g=null})();t.querySelectorAll&& -function(){var g=k,i=t.createElement("div");i.innerHTML="

      ";if(!(i.querySelectorAll&&i.querySelectorAll(".TEST").length===0)){k=function(m,p,q,u){p=p||t;m=m.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!u&&!k.isXML(p))if(p.nodeType===9)try{return C(p.querySelectorAll(m),q)}catch(y){}else if(p.nodeType===1&&p.nodeName.toLowerCase()!=="object"){var F=p.getAttribute("id"),M=F||"__sizzle__";F||p.setAttribute("id",M);try{return C(p.querySelectorAll("#"+M+" "+m),q)}catch(N){}finally{F|| -p.removeAttribute("id")}}return g(m,p,q,u)};for(var n in g)k[n]=g[n];i=null}}();(function(){var g=t.documentElement,i=g.matchesSelector||g.mozMatchesSelector||g.webkitMatchesSelector||g.msMatchesSelector,n=false;try{i.call(t.documentElement,"[test!='']:sizzle")}catch(m){n=true}if(i)k.matchesSelector=function(p,q){q=q.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(p))try{if(n||!o.match.PSEUDO.test(q)&&!/!=/.test(q))return i.call(p,q)}catch(u){}return k(q,null,null,[p]).length>0}})();(function(){var g= -t.createElement("div");g.innerHTML="
      ";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){o.order.splice(1,0,"CLASS");o.find.CLASS=function(i,n,m){if(typeof n.getElementsByClassName!=="undefined"&&!m)return n.getElementsByClassName(i[1])};g=null}}})();k.contains=t.documentElement.contains?function(g,i){return g!==i&&(g.contains?g.contains(i):true)}:t.documentElement.compareDocumentPosition? -function(g,i){return!!(g.compareDocumentPosition(i)&16)}:function(){return false};k.isXML=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false};var L=function(g,i){for(var n,m=[],p="",q=i.nodeType?[i]:i;n=o.match.PSEUDO.exec(g);){p+=n[0];g=g.replace(o.match.PSEUDO,"")}g=o.relative[g]?g+"*":g;n=0;for(var u=q.length;n0)for(var h=d;h0},closest:function(a,b){var d=[],e,f,h=this[0];if(c.isArray(a)){var l,k={},o=1;if(h&&a.length){e=0;for(f=a.length;e-1:c(h).is(e))d.push({selector:l,elem:h,level:o})}h= -h.parentNode;o++}}return d}l=cb.test(a)?c(a,b||this.context):null;e=0;for(f=this.length;e-1:c.find.matchesSelector(h,a)){d.push(h);break}else{h=h.parentNode;if(!h||!h.ownerDocument||h===b)break}d=d.length>1?c.unique(d):d;return this.pushStack(d,"closest",a)},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var d=typeof a==="string"?c(a,b||this.context): -c.makeArray(a),e=c.merge(this.get(),d);return this.pushStack(!d[0]||!d[0].parentNode||d[0].parentNode.nodeType===11||!e[0]||!e[0].parentNode||e[0].parentNode.nodeType===11?e:c.unique(e))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a, -2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a, -b){c.fn[a]=function(d,e){var f=c.map(this,b,d);Za.test(a)||(e=d);if(e&&typeof e==="string")f=c.filter(e,f);f=this.length>1?c.unique(f):f;if((this.length>1||ab.test(e))&&$a.test(a))f=f.reverse();return this.pushStack(f,a,bb.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return b.length===1?c.find.matchesSelector(b[0],a)?[b[0]]:[]:c.find.matches(a,b)},dir:function(a,b,d){var e=[];for(a=a[b];a&&a.nodeType!==9&&(d===B||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&& -e.push(a);a=a[b]}return e},nth:function(a,b,d){b=b||1;for(var e=0;a;a=a[d])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var za=/ jQuery\d+="(?:\d+|null)"/g,$=/^\s+/,Aa=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Ba=/<([\w:]+)/,db=/\s]+\/)>/g,P={option:[1, -""],legend:[1,"
      ","
      "],thead:[1,"","
      "],tr:[2,"","
      "],td:[3,"","
      "],col:[2,"","
      "],area:[1,"",""],_default:[0,"",""]};P.optgroup=P.option;P.tbody=P.tfoot=P.colgroup=P.caption=P.thead;P.th=P.td;if(!c.support.htmlSerialize)P._default=[1,"div
      ","
      "];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d= -c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==B)return this.empty().append((this[0]&&this[0].ownerDocument||t).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this}, -wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})}, -prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b, -this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,e;(e=this[d])!=null;d++)if(!a||c.filter(a,[e]).length){if(!b&&e.nodeType===1){c.cleanData(e.getElementsByTagName("*"));c.cleanData([e])}e.parentNode&&e.parentNode.removeChild(e)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild); -return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,e=this.ownerDocument;if(!d){d=e.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(za,"").replace(fb,'="$1">').replace($,"")],e)[0]}else return this.cloneNode(true)});if(a===true){na(this,b);na(this.find("*"),b.find("*"))}return b},html:function(a){if(a===B)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(za,""):null; -else if(typeof a==="string"&&!Ca.test(a)&&(c.support.leadingWhitespace||!$.test(a))&&!P[(Ba.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Aa,"<$1>");try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?h.cloneNode(true):h)}k.length&&c.each(k,Oa)}return this}});c.buildFragment=function(a,b,d){var e,f,h;b=b&&b[0]?b[0].ownerDocument||b[0]:t;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===t&&!Ca.test(a[0])&&(c.support.checkClone||!Da.test(a[0]))){f=true;if(h=c.fragments[a[0]])if(h!==1)e=h}if(!e){e=b.createDocumentFragment();c.clean(a,b,e,d)}if(f)c.fragments[a[0]]=h?e:1;return{fragment:e,cacheable:f}};c.fragments={};c.each({appendTo:"append", -prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var e=[];d=c(d);var f=this.length===1&&this[0].parentNode;if(f&&f.nodeType===11&&f.childNodes.length===1&&d.length===1){d[b](this[0]);return this}else{f=0;for(var h=d.length;f0?this.clone(true):this).get();c(d[f])[b](l);e=e.concat(l)}return this.pushStack(e,a,d.selector)}}});c.extend({clean:function(a,b,d,e){b=b||t;if(typeof b.createElement==="undefined")b=b.ownerDocument|| -b[0]&&b[0].ownerDocument||t;for(var f=[],h=0,l;(l=a[h])!=null;h++){if(typeof l==="number")l+="";if(l){if(typeof l==="string"&&!eb.test(l))l=b.createTextNode(l);else if(typeof l==="string"){l=l.replace(Aa,"<$1>");var k=(Ba.exec(l)||["",""])[1].toLowerCase(),o=P[k]||P._default,x=o[0],r=b.createElement("div");for(r.innerHTML=o[1]+l+o[2];x--;)r=r.lastChild;if(!c.support.tbody){x=db.test(l);k=k==="table"&&!x?r.firstChild&&r.firstChild.childNodes:o[1]===""&&!x?r.childNodes:[];for(o=k.length- -1;o>=0;--o)c.nodeName(k[o],"tbody")&&!k[o].childNodes.length&&k[o].parentNode.removeChild(k[o])}!c.support.leadingWhitespace&&$.test(l)&&r.insertBefore(b.createTextNode($.exec(l)[0]),r.firstChild);l=r.childNodes}if(l.nodeType)f.push(l);else f=c.merge(f,l)}}if(d)for(h=0;f[h];h++)if(e&&c.nodeName(f[h],"script")&&(!f[h].type||f[h].type.toLowerCase()==="text/javascript"))e.push(f[h].parentNode?f[h].parentNode.removeChild(f[h]):f[h]);else{f[h].nodeType===1&&f.splice.apply(f,[h+1,0].concat(c.makeArray(f[h].getElementsByTagName("script")))); -d.appendChild(f[h])}return f},cleanData:function(a){for(var b,d,e=c.cache,f=c.event.special,h=c.support.deleteExpando,l=0,k;(k=a[l])!=null;l++)if(!(k.nodeName&&c.noData[k.nodeName.toLowerCase()]))if(d=k[c.expando]){if((b=e[d])&&b.events)for(var o in b.events)f[o]?c.event.remove(k,o):c.removeEvent(k,o,b.handle);if(h)delete k[c.expando];else k.removeAttribute&&k.removeAttribute(c.expando);delete e[d]}}});var Ea=/alpha\([^)]*\)/i,gb=/opacity=([^)]*)/,hb=/-([a-z])/ig,ib=/([A-Z])/g,Fa=/^-?\d+(?:px)?$/i, -jb=/^-?\d/,kb={position:"absolute",visibility:"hidden",display:"block"},Pa=["Left","Right"],Qa=["Top","Bottom"],W,Ga,aa,lb=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){if(arguments.length===2&&b===B)return this;return c.access(this,a,b,true,function(d,e,f){return f!==B?c.style(d,e,f):c.css(d,e)})};c.extend({cssHooks:{opacity:{get:function(a,b){if(b){var d=W(a,"opacity","opacity");return d===""?"1":d}else return a.style.opacity}}},cssNumber:{zIndex:true,fontWeight:true,opacity:true, -zoom:true,lineHeight:true},cssProps:{"float":c.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,d,e){if(!(!a||a.nodeType===3||a.nodeType===8||!a.style)){var f,h=c.camelCase(b),l=a.style,k=c.cssHooks[h];b=c.cssProps[h]||h;if(d!==B){if(!(typeof d==="number"&&isNaN(d)||d==null)){if(typeof d==="number"&&!c.cssNumber[h])d+="px";if(!k||!("set"in k)||(d=k.set(a,d))!==B)try{l[b]=d}catch(o){}}}else{if(k&&"get"in k&&(f=k.get(a,false,e))!==B)return f;return l[b]}}},css:function(a,b,d){var e,f=c.camelCase(b), -h=c.cssHooks[f];b=c.cssProps[f]||f;if(h&&"get"in h&&(e=h.get(a,true,d))!==B)return e;else if(W)return W(a,b,f)},swap:function(a,b,d){var e={},f;for(f in b){e[f]=a.style[f];a.style[f]=b[f]}d.call(a);for(f in b)a.style[f]=e[f]},camelCase:function(a){return a.replace(hb,lb)}});c.curCSS=c.css;c.each(["height","width"],function(a,b){c.cssHooks[b]={get:function(d,e,f){var h;if(e){if(d.offsetWidth!==0)h=oa(d,b,f);else c.swap(d,kb,function(){h=oa(d,b,f)});if(h<=0){h=W(d,b,b);if(h==="0px"&&aa)h=aa(d,b,b); -if(h!=null)return h===""||h==="auto"?"0px":h}if(h<0||h==null){h=d.style[b];return h===""||h==="auto"?"0px":h}return typeof h==="string"?h:h+"px"}},set:function(d,e){if(Fa.test(e)){e=parseFloat(e);if(e>=0)return e+"px"}else return e}}});if(!c.support.opacity)c.cssHooks.opacity={get:function(a,b){return gb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var d=a.style;d.zoom=1;var e=c.isNaN(b)?"":"alpha(opacity="+b*100+")",f= -d.filter||"";d.filter=Ea.test(f)?f.replace(Ea,e):d.filter+" "+e}};if(t.defaultView&&t.defaultView.getComputedStyle)Ga=function(a,b,d){var e;d=d.replace(ib,"-$1").toLowerCase();if(!(b=a.ownerDocument.defaultView))return B;if(b=b.getComputedStyle(a,null)){e=b.getPropertyValue(d);if(e===""&&!c.contains(a.ownerDocument.documentElement,a))e=c.style(a,d)}return e};if(t.documentElement.currentStyle)aa=function(a,b){var d,e,f=a.currentStyle&&a.currentStyle[b],h=a.style;if(!Fa.test(f)&&jb.test(f)){d=h.left; -e=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;h.left=b==="fontSize"?"1em":f||0;f=h.pixelLeft+"px";h.left=d;a.runtimeStyle.left=e}return f===""?"auto":f};W=Ga||aa;if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetHeight;return a.offsetWidth===0&&b===0||!c.support.reliableHiddenOffsets&&(a.style.display||c.css(a,"display"))==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var mb=c.now(),nb=/)<[^<]*)*<\/script>/gi, -ob=/^(?:select|textarea)/i,pb=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,qb=/^(?:GET|HEAD)$/,Ra=/\[\]$/,T=/\=\?(&|$)/,ja=/\?/,rb=/([?&])_=[^&]*/,sb=/^(\w+:)?\/\/([^\/?#]+)/,tb=/%20/g,ub=/#.*$/,Ha=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!=="string"&&Ha)return Ha.apply(this,arguments);else if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var f=a.slice(e,a.length);a=a.slice(0,e)}e="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b=== -"object"){b=c.param(b,c.ajaxSettings.traditional);e="POST"}var h=this;c.ajax({url:a,type:e,dataType:"html",data:b,complete:function(l,k){if(k==="success"||k==="notmodified")h.html(f?c("
      ").append(l.responseText.replace(nb,"")).find(f):l.responseText);d&&h.each(d,[l.responseText,k,l])}});return this},serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&& -!this.disabled&&(this.checked||ob.test(this.nodeName)||pb.test(this.type))}).map(function(a,b){var d=c(this).val();return d==null?null:c.isArray(d)?c.map(d,function(e){return{name:b.name,value:e}}):{name:b.name,value:d}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:e})}, -getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:e})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return new E.XMLHttpRequest},accepts:{xml:"application/xml, text/xml",html:"text/html", -script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},ajax:function(a){var b=c.extend(true,{},c.ajaxSettings,a),d,e,f,h=b.type.toUpperCase(),l=qb.test(h);b.url=b.url.replace(ub,"");b.context=a&&a.context!=null?a.context:b;if(b.data&&b.processData&&typeof b.data!=="string")b.data=c.param(b.data,b.traditional);if(b.dataType==="jsonp"){if(h==="GET")T.test(b.url)||(b.url+=(ja.test(b.url)?"&":"?")+(b.jsonp||"callback")+"=?");else if(!b.data|| -!T.test(b.data))b.data=(b.data?b.data+"&":"")+(b.jsonp||"callback")+"=?";b.dataType="json"}if(b.dataType==="json"&&(b.data&&T.test(b.data)||T.test(b.url))){d=b.jsonpCallback||"jsonp"+mb++;if(b.data)b.data=(b.data+"").replace(T,"="+d+"$1");b.url=b.url.replace(T,"="+d+"$1");b.dataType="script";var k=E[d];E[d]=function(m){if(c.isFunction(k))k(m);else{E[d]=B;try{delete E[d]}catch(p){}}f=m;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);r&&r.removeChild(A)}}if(b.dataType==="script"&&b.cache===null)b.cache= -false;if(b.cache===false&&l){var o=c.now(),x=b.url.replace(rb,"$1_="+o);b.url=x+(x===b.url?(ja.test(b.url)?"&":"?")+"_="+o:"")}if(b.data&&l)b.url+=(ja.test(b.url)?"&":"?")+b.data;b.global&&c.active++===0&&c.event.trigger("ajaxStart");o=(o=sb.exec(b.url))&&(o[1]&&o[1].toLowerCase()!==location.protocol||o[2].toLowerCase()!==location.host);if(b.dataType==="script"&&h==="GET"&&o){var r=t.getElementsByTagName("head")[0]||t.documentElement,A=t.createElement("script");if(b.scriptCharset)A.charset=b.scriptCharset; -A.src=b.url;if(!d){var C=false;A.onload=A.onreadystatechange=function(){if(!C&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){C=true;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);A.onload=A.onreadystatechange=null;r&&A.parentNode&&r.removeChild(A)}}}r.insertBefore(A,r.firstChild);return B}var J=false,w=b.xhr();if(w){b.username?w.open(h,b.url,b.async,b.username,b.password):w.open(h,b.url,b.async);try{if(b.data!=null&&!l||a&&a.contentType)w.setRequestHeader("Content-Type", -b.contentType);if(b.ifModified){c.lastModified[b.url]&&w.setRequestHeader("If-Modified-Since",c.lastModified[b.url]);c.etag[b.url]&&w.setRequestHeader("If-None-Match",c.etag[b.url])}o||w.setRequestHeader("X-Requested-With","XMLHttpRequest");w.setRequestHeader("Accept",b.dataType&&b.accepts[b.dataType]?b.accepts[b.dataType]+", */*; q=0.01":b.accepts._default)}catch(I){}if(b.beforeSend&&b.beforeSend.call(b.context,w,b)===false){b.global&&c.active--===1&&c.event.trigger("ajaxStop");w.abort();return false}b.global&& -c.triggerGlobal(b,"ajaxSend",[w,b]);var L=w.onreadystatechange=function(m){if(!w||w.readyState===0||m==="abort"){J||c.handleComplete(b,w,e,f);J=true;if(w)w.onreadystatechange=c.noop}else if(!J&&w&&(w.readyState===4||m==="timeout")){J=true;w.onreadystatechange=c.noop;e=m==="timeout"?"timeout":!c.httpSuccess(w)?"error":b.ifModified&&c.httpNotModified(w,b.url)?"notmodified":"success";var p;if(e==="success")try{f=c.httpData(w,b.dataType,b)}catch(q){e="parsererror";p=q}if(e==="success"||e==="notmodified")d|| -c.handleSuccess(b,w,e,f);else c.handleError(b,w,e,p);d||c.handleComplete(b,w,e,f);m==="timeout"&&w.abort();if(b.async)w=null}};try{var g=w.abort;w.abort=function(){w&&Function.prototype.call.call(g,w);L("abort")}}catch(i){}b.async&&b.timeout>0&&setTimeout(function(){w&&!J&&L("timeout")},b.timeout);try{w.send(l||b.data==null?null:b.data)}catch(n){c.handleError(b,w,null,n);c.handleComplete(b,w,e,f)}b.async||L();return w}},param:function(a,b){var d=[],e=function(h,l){l=c.isFunction(l)?l():l;d[d.length]= -encodeURIComponent(h)+"="+encodeURIComponent(l)};if(b===B)b=c.ajaxSettings.traditional;if(c.isArray(a)||a.jquery)c.each(a,function(){e(this.name,this.value)});else for(var f in a)da(f,a[f],b,e);return d.join("&").replace(tb,"+")}});c.extend({active:0,lastModified:{},etag:{},handleError:function(a,b,d,e){a.error&&a.error.call(a.context,b,d,e);a.global&&c.triggerGlobal(a,"ajaxError",[b,a,e])},handleSuccess:function(a,b,d,e){a.success&&a.success.call(a.context,e,d,b);a.global&&c.triggerGlobal(a,"ajaxSuccess", -[b,a])},handleComplete:function(a,b,d){a.complete&&a.complete.call(a.context,b,d);a.global&&c.triggerGlobal(a,"ajaxComplete",[b,a]);a.global&&c.active--===1&&c.event.trigger("ajaxStop")},triggerGlobal:function(a,b,d){(a.context&&a.context.url==null?c(a.context):c.event).trigger(b,d)},httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"), -e=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(e)c.etag[b]=e;return a.status===304},httpData:function(a,b,d){var e=a.getResponseHeader("content-type")||"",f=b==="xml"||!b&&e.indexOf("xml")>=0;a=f?a.responseXML:a.responseText;f&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b==="json"||!b&&e.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&e.indexOf("javascript")>=0)c.globalEval(a);return a}}); -if(E.ActiveXObject)c.ajaxSettings.xhr=function(){if(E.location.protocol!=="file:")try{return new E.XMLHttpRequest}catch(a){}try{return new E.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}};c.support.ajax=!!c.ajaxSettings.xhr();var ea={},vb=/^(?:toggle|show|hide)$/,wb=/^([+\-]=)?([\d+.\-]+)(.*)$/,ba,pa=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b,d){if(a||a===0)return this.animate(S("show", -3),a,b,d);else{d=0;for(var e=this.length;d=0;e--)if(d[e].elem===this){b&&d[e](true);d.splice(e,1)}});b||this.dequeue();return this}});c.each({slideDown:S("show",1),slideUp:S("hide",1),slideToggle:S("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){c.fn[a]=function(d,e,f){return this.animate(b, -d,e,f)}});c.extend({speed:function(a,b,d){var e=a&&typeof a==="object"?c.extend({},a):{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};e.duration=c.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in c.fx.speeds?c.fx.speeds[e.duration]:c.fx.speeds._default;e.old=e.complete;e.complete=function(){e.queue!==false&&c(this).dequeue();c.isFunction(e.old)&&e.old.call(this)};return e},easing:{linear:function(a,b,d,e){return d+e*a},swing:function(a,b,d,e){return(-Math.cos(a* -Math.PI)/2+0.5)*e+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||c.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a=parseFloat(c.css(this.elem,this.prop));return a&&a>-1E4?a:0},custom:function(a,b,d){function e(l){return f.step(l)} -var f=this,h=c.fx;this.startTime=c.now();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;this.pos=this.state=0;e.elem=this.elem;if(e()&&c.timers.push(e)&&!ba)ba=setInterval(h.tick,h.interval)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true; -this.custom(this.cur(),0)},step:function(a){var b=c.now(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var e in this.options.curAnim)if(this.options.curAnim[e]!==true)d=false;if(d){if(this.options.overflow!=null&&!c.support.shrinkWrapBlocks){var f=this.elem,h=this.options;c.each(["","X","Y"],function(k,o){f.style["overflow"+o]=h.overflow[k]})}this.options.hide&&c(this.elem).hide();if(this.options.hide|| -this.options.show)for(var l in this.options.curAnim)c.style(this.elem,l,this.options.orig[l]);this.options.complete.call(this.elem)}return false}else{a=b-this.startTime;this.state=a/this.options.duration;b=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||b](this.state,a,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a= -c.timers,b=0;b-1;e={};var x={};if(o)x=f.position();l=o?x.top:parseInt(l,10)||0;k=o?x.left:parseInt(k,10)||0;if(c.isFunction(b))b=b.call(a,d,h);if(b.top!=null)e.top=b.top-h.top+l;if(b.left!=null)e.left=b.left-h.left+k;"using"in b?b.using.call(a, -e):f.css(e)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),e=Ia.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.css(a,"marginTop"))||0;d.left-=parseFloat(c.css(a,"marginLeft"))||0;e.top+=parseFloat(c.css(b[0],"borderTopWidth"))||0;e.left+=parseFloat(c.css(b[0],"borderLeftWidth"))||0;return{top:d.top-e.top,left:d.left-e.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||t.body;a&&!Ia.test(a.nodeName)&& -c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(e){var f=this[0],h;if(!f)return null;if(e!==B)return this.each(function(){if(h=fa(this))h.scrollTo(!a?e:c(h).scrollLeft(),a?e:c(h).scrollTop());else this[d]=e});else return(h=fa(f))?"pageXOffset"in h?h[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&h.document.documentElement[d]||h.document.body[d]:f[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase(); -c.fn["inner"+b]=function(){return this[0]?parseFloat(c.css(this[0],d,"padding")):null};c.fn["outer"+b]=function(e){return this[0]?parseFloat(c.css(this[0],d,e?"margin":"border")):null};c.fn[d]=function(e){var f=this[0];if(!f)return e==null?null:this;if(c.isFunction(e))return this.each(function(l){var k=c(this);k[d](e.call(this,l,k[d]()))});if(c.isWindow(f))return f.document.compatMode==="CSS1Compat"&&f.document.documentElement["client"+b]||f.document.body["client"+b];else if(f.nodeType===9)return Math.max(f.documentElement["client"+ -b],f.body["scroll"+b],f.documentElement["scroll"+b],f.body["offset"+b],f.documentElement["offset"+b]);else if(e===B){f=c.css(f,d);var h=parseFloat(f);return c.isNaN(h)?f:h}else return this.css(d,typeof e==="string"?e:e+"px")}})})(window); diff --git a/game/fb/jquery-ui-1.8.9.custom.min.js b/game/fb/jquery-ui-1.8.9.custom.min.js deleted file mode 100755 index 044d307..0000000 --- a/game/fb/jquery-ui-1.8.9.custom.min.js +++ /dev/null @@ -1,68 +0,0 @@ -/*! - * jQuery UI 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI - */ -(function(c,j){function k(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.9",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106, -NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this, -"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position"); -if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,l,m){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(l)g-=parseFloat(c.curCSS(f, -"border"+this+"Width",true))||0;if(m)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h, -d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){var b=a.nodeName.toLowerCase(),d=c.attr(a,"tabindex");if("area"===b){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&k(a)}return(/input|select|textarea|button|object/.test(b)?!a.disabled:"a"==b?a.href||!isNaN(d):!isNaN(d))&&k(a)},tabbable:function(a){var b=c.attr(a,"tabindex");return(isNaN(b)||b>=0)&&c(a).is(":focusable")}}); -c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a
      ",remove:null,select:null,show:null,spinner:"Loading…",tabTemplate:"
    • #{label}
    • "},_create:function(){this._tabify(true)},_setOption:function(b,e){if(b=="selected")this.options.collapsible&& -e==this.options.selected||this.select(e);else{this.options[b]=e;this._tabify()}},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+u()},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+w());return d.cookie.apply(null,[b].concat(d.makeArray(arguments)))},_ui:function(b,e){return{tab:b,panel:e,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b= -d(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(b){function e(g,f){g.css("display","");!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}var a=this,c=this.options,h=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=d(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);this.anchors.each(function(g,f){var i=d(f).attr("href"),l=i.split("#")[0],q;if(l&&(l===location.toString().split("#")[0]|| -(q=d("base")[0])&&l===q.href)){i=f.hash;f.href=i}if(h.test(i))a.panels=a.panels.add(a.element.find(a._sanitizeSelector(i)));else if(i&&i!=="#"){d.data(f,"href.tabs",i);d.data(f,"load.tabs",i.replace(/#.*$/,""));i=a._tabId(f);f.href="#"+i;f=a.element.find("#"+i);if(!f.length){f=d(c.panelTemplate).attr("id",i).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else c.disabled.push(g)});if(b){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"); -this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(c.selected===p){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){c.selected=g;return false}});if(typeof c.selected!=="number"&&c.cookie)c.selected=parseInt(a._cookie(),10);if(typeof c.selected!=="number"&&this.lis.filter(".ui-tabs-selected").length)c.selected= -this.lis.index(this.lis.filter(".ui-tabs-selected"));c.selected=c.selected||(this.lis.length?0:-1)}else if(c.selected===null)c.selected=-1;c.selected=c.selected>=0&&this.anchors[c.selected]||c.selected<0?c.selected:0;c.disabled=d.unique(c.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(c.selected,c.disabled)!=-1&&c.disabled.splice(d.inArray(c.selected,c.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active"); -if(c.selected>=0&&this.anchors.length){a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash)).removeClass("ui-tabs-hide");this.lis.eq(c.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[c.selected],a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash))[0]))});this.load(c.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else c.selected=this.lis.index(this.lis.filter(".ui-tabs-selected")); -this.element[c.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");c.cookie&&this._cookie(c.selected,c.cookie);b=0;for(var j;j=this.lis[b];b++)d(j)[d.inArray(b,c.disabled)!=-1&&!d(j).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");c.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(c.event!=="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+ -g)};this.lis.bind("mouseover.tabs",function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(c.fx)if(d.isArray(c.fx)){m=c.fx[0];o=c.fx[1]}else m=o=c.fx;var r=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal", -function(){e(f,o);a._trigger("show",null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},s=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")}; -this.anchors.bind(c.event+".tabs",function(){var g=this,f=d(g).closest("li"),i=a.panels.filter(":not(.ui-tabs-hide)"),l=a.element.find(a._sanitizeSelector(g.hash));if(f.hasClass("ui-tabs-selected")&&!c.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a.panels.filter(":animated").length||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}c.selected=a.anchors.index(this);a.abort();if(c.collapsible)if(f.hasClass("ui-tabs-selected")){c.selected= --1;c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){s(g,i)}).dequeue("tabs");this.blur();return false}else if(!i.length){c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this));this.blur();return false}c.cookie&&a._cookie(c.selected,c.cookie);if(l.length){i.length&&a.element.queue("tabs",function(){s(g,i)});a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier."; -d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(b){if(typeof b=="string")b=this.anchors.index(this.anchors.filter("[href$="+b+"]"));return b},destroy:function(){var b=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e= -d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(c,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});b.cookie&&this._cookie(null,b.cookie);return this},add:function(b, -e,a){if(a===p)a=this.anchors.length;var c=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,b).replace(/#\{label\}/g,e));b=!b.indexOf("#")?b.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var j=c.element.find("#"+b);j.length||(j=d(h.panelTemplate).attr("id",b).data("destroy.tabs",true));j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);j.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]); -j.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");j.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){c._trigger("show",null,c._ui(c.anchors[0],c.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(b){b=this._getIndex(b);var e=this.options,a=this.lis.eq(b).remove(),c=this.panels.eq(b).remove(); -if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(b+(b+1=b?--h:h});this._tabify();this._trigger("remove",null,this._ui(a.find("a")[0],c[0]));return this},enable:function(b){b=this._getIndex(b);var e=this.options;if(d.inArray(b,e.disabled)!=-1){this.lis.eq(b).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=b});this._trigger("enable",null, -this._ui(this.anchors[b],this.panels[b]));return this}},disable:function(b){b=this._getIndex(b);var e=this.options;if(b!=e.selected){this.lis.eq(b).addClass("ui-state-disabled");e.disabled.push(b);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[b],this.panels[b]))}return this},select:function(b){b=this._getIndex(b);if(b==-1)if(this.options.collapsible&&this.options.selected!=-1)b=this.options.selected;else return this;this.anchors.eq(b).trigger(this.options.event+".tabs");return this}, -load:function(b){b=this._getIndex(b);var e=this,a=this.options,c=this.anchors.eq(b)[0],h=d.data(c,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(c,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(b).addClass("ui-state-processing");if(a.spinner){var j=d("span",c);j.data("label.tabs",j.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){e.element.find(e._sanitizeSelector(c.hash)).html(k);e._cleanup();a.cache&&d.data(c, -"cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.error(k,n,b,c)}catch(m){}}}));e.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this}, -url:function(b,e){this.anchors.eq(b).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.9"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(b,e){var a=this,c=this.options,h=a._rotate||(a._rotate=function(j){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=c.selected;a.select(++k= load_max && - image_manager.is_done_preloading() && - sounds.sounds_loaded()){ - // init all image objects - image_manager.init_images(p); - loading_finished(); - } - }; - - - obj.get_all_buttons = function() { - return []; - }; - - obj.key_pressed = function() {}; - - return obj; -}; diff --git a/game/fb/multiplier.js b/game/fb/multiplier.js deleted file mode 100644 index 4fb7830..0000000 --- a/game/fb/multiplier.js +++ /dev/null @@ -1,56 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec - -var multiplier = function(p, spec) { - // --- defaults --- - - spec.width = spec.width || 5; - spec.height = spec.height || 5; - // make sure it goes left - spec.vel = new p.PVector(p.random(0, -1)* g_speed_factor, p.random()* g_speed_factor); - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "multiplier"; - }; - - // --- private variables --- - - var alive = true; - - // --- public methods --- - - // implementing game_object interface - - obj.update = function() { - obj.bounce(); - obj.move(); - }; - - // (rectangle for now) - obj.draw = function() { - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.fill(0, 255, 0); - p.noStroke(); - - p.ellipse(pos.x, pos.y, - obj.get_width(), obj.get_height()); - }; - - obj.die = function() { - alive = false; - } - - obj.is_dead = function() { - return (!alive); - }; - - return obj; -}; diff --git a/game/fb/mutation_obj.js b/game/fb/mutation_obj.js deleted file mode 100644 index 9403397..0000000 --- a/game/fb/mutation_obj.js +++ /dev/null @@ -1,328 +0,0 @@ -// Manages all information about the current state of mutation -// in the game -// Provides a num_status_obj, which is used for rendering -// spec: -// status_height = y value for status objects - -var mutation_obj = function(p, spec) { - - // obj to return - var obj = {}; - - // --- private variables --- - - var level = 1; - var cells_infected = 0; - var cells_needed; // init'd below - var new_mutation = false; - // Color array for all the mutation levels - var color_array = [ - /* - p.color(250, 250, 40), - p.color(60, 240, 240), - p.color(167, 17, 161), - p.color(100, 250, 110), - p.color(13, 28, 171), - p.color(118, 12, 25) - */ - 0xffff2a7f, - 0xffffff00, - 0xff7f2aff, - 0xff37c871, - 0xffd42aff, - 0xffff7f2a, - 0xff2ad4ff, - 0xffff2a2a, - 0xff7fff2a, - 0xffc8b7b7 - ]; - -/* - // Keeps track of all the abilities earned in the game so far - // If you lose a mutation level, must pop abilities off this array - var abilities = []; - - // All the possible abilities, sorted by level - // An ability can be earned at level x if it is in poss_abilities[0-x] - // TODO: add all abilities and change their levels - // TODO: Change these to be ready to be displayed to the user (or create a formatting mechanism) - var poss_abilities = [ - ["extra_particle"], - ["faster_particles", "bigger_particles"] - ]; -*/ - - // Flashing - var flash_color = null; - var is_flashing = false; - - // Shows the probability of getting a mutation - var bar_status_obj = num_status_obj(p, { - pos : new p.PVector(170, spec.status_height || 20), - text : "Mutation:", - num : 0, - bar : true, - max : 0 // init'd below - }); - - //Shows the curent mutation level - var level_spec = { - pos : new p.PVector(350, spec.status_height || 20), - text : "Strain ", - num : 1, - text_color : p.color(0) - }; - var level_status_obj = num_status_obj(p, level_spec); - - // --- private methods - -/* - // Returns a random ability, taking into account the current level - // Every possibile ability has an equal chance - var get_random_ability = function() { - var all_possible = []; - for(var i = 0; i < level; i++) { - for_each(poss_abilities[i], function(a) {all_possible.push(a);}); - } - assert(all_possible.length != 0); - return all_possible[Math.floor(Math.random() * all_possible.length)]; - } -*/ - - // Returns bool saying if a mutation should occur - // takes into account level, cells_infected, and a random probability - var mutation_occured = function() { - //return Math.random() + ( (cells_infected / 50) / (level + 1)) > .95; - //return (Math.random() * (cells_infected / 50)) > .3; - //return (Math.random() + (cells_infected / 100) - (level / 50)) > .98; - return (Math.random()*0.5 + (cells_infected / cells_needed)) > .98; - }; - - // returns the max number of cells the player needs to infect to have - // a 100% probability of mutating - var calc_cells_needed = function() { - return 30 + 20*level; - }; - cells_needed = calc_cells_needed(); - bar_status_obj.set_max(cells_needed); - - // Flashes the mutation bar red and white - var flash_bar = function() { - is_flashing = true; - - // Flash red and white every half second - flash_red(); - setTimeout(flash_white, 500); - setTimeout(flash_red, 1000); - setTimeout(flash_white, 1500); - setTimeout(flash_red, 2000); - setTimeout(flash_white, 2500); - // End flashing in 3 seconds - setTimeout(end_flash, 3000); - } - - // updates the flash color - var flash_red = function() { - flash_color = [255, 0, 0]; - } - var flash_white = function() { - flash_color = [255, 255, 255]; - } - - // Draws the bar with the appropriate flashing color - var draw_flashing_bar = function() { - bar_status_obj.draw_color(flash_color); - } - // Ends the flashing - var end_flash = function() { - is_flashing = false; - } - - // Gives us a rainbow gradient - // Taken from : http://snipplr.com/view.php?codeview&id=14590 - /** - * HSV to RGB color conversion - * - * H runs from 0 to 360 degrees - * S and V run from 0 to 100 - * - * Ported from the excellent java algorithm by Eugene Vishnevsky at: - * http://www.cs.rit.edu/~ncs/color/t_convert.html - */ - var hsvToRgb = function(h, s, v) { - var r, g, b; - var i; - var f, p, q, t; - - // Make sure our arguments stay in-range - h = Math.max(0, Math.min(360, h)); - s = Math.max(0, Math.min(100, s)); - v = Math.max(0, Math.min(100, v)); - - // We accept saturation and value arguments from 0 to 100 because that's - // how Photoshop represents those values. Internally, however, the - // saturation and value are calculated from a range of 0 to 1. We make - // That conversion here. - s /= 100; - v /= 100; - - if(s == 0) { - // Achromatic (grey) - r = g = b = v; - return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; - } - - h /= 60; // sector 0 to 5 - i = Math.floor(h); - f = h - i; // factorial part of h - p = v * (1 - s); - q = v * (1 - s * f); - t = v * (1 - s * (1 - f)); - - switch(i) { - case 0: - r = v; - g = t; - b = p; - break; - - case 1: - r = q; - g = v; - b = p; - break; - - case 2: - r = p; - g = v; - b = t; - break; - - case 3: - r = p; - g = q; - b = v; - break; - - case 4: - r = t; - g = p; - b = v; - break; - - default: // case 5: - r = v; - g = p; - b = q; - } - - return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; - } - - // --- public methods --- - - obj.draw = function() { - bar_status_obj.draw(); - if (is_flashing) { - draw_flashing_bar(); - } - - // draw mutation colored box under level num - p.fill(get_color()); - p.noStroke(); - var lpos = level_spec.pos; - p.rectMode(p.CORNER); - p.rect(lpos.x-30, lpos.y-10, 70, 20); - - level_status_obj.draw(); - }; - - // increments the mutation percentage - obj.infected_cell = function() { - cells_infected += 1; - bar_status_obj.incr(1); - // if a mutation occurs - if (mutation_occured()) { - // set the flag - new_mutation = true; - flash_bar(); - - // Play sounds - sounds.play_sound("level_up"); - } - }; - - // returns true if a new mutation is ready - obj.has_new_mutation = function() { - return new_mutation; - }; - - // to be called when in_game_state decides to enact the new mutation - // as signalled by the flag - // Returns a new ability if one was added - obj.do_mutation = function() { - flash_bar(); - // Add new ability before incrementing level - //var new_ability = get_random_ability(); - //abilities.push(new_ability); - level += 1; - level_status_obj.incr(1); - // update num cells needed - cells_needed = calc_cells_needed(); - bar_status_obj.set_max(cells_needed); - // reset counters - obj.reset_mutation(); - - //return new_ability; - }; - - - // resets the counters and the flag - // to be called after a mutation is enacted in the game - obj.reset_mutation = function() { - cells_infected = 0; - bar_status_obj.set_num(0); - // reset flag - new_mutation = false; - }; - - var get_color = function() { - return color_array[(level - 1) % color_array.length]; - }; - - // Returns the current mutation level and color - obj.get_info = function() { - // color level goes from 0 to 360 - //var new_color_level = (360 - (360 - level * 30)); - //var hue = new_color_level / 360; - //var rgb_arr = hsvToRgb(new_color_level, 75, 75); - return { - level: level, - //color: p.color(rgb_arr[0], rgb_arr[1], rgb_arr[2]), - // level starts at 1, so have to subtract 1 - color : get_color(), //% color_array.size], - // get one new particle every 10 levels - particles: 3+p.floor(level/3), - //abilities: abilities - }; - }; - - obj.get_level = function() { - return level; - }; - - obj.set_level = function(l) { - // decrement by the difference in levels - level_status_obj.incr(l-level); - // Pop off abilities - /* - for (var i = 0; i < (level - l); i++) { - abilities.pop(); - } - */ - // set the new level - level = l; - }; - - return obj; -}; diff --git a/game/fb/notification.js b/game/fb/notification.js deleted file mode 100644 index dfee58e..0000000 --- a/game/fb/notification.js +++ /dev/null @@ -1,64 +0,0 @@ -// Used to alert the user of new information -// draw() returns false if the status update is finished -// spec: -// text : text to display -// color : color of text (defaults to black) -// pos : pos of notification - -var notification = function(p, spec) { - - // object to return - var obj = {}; - - // --- private variables --- - - var time_counter = 0; // used to draw the object at various times - var total_time = 60; // ~ 2 seconds. If changed must be changed in notify in in_game_state to prevent overlap //200; // ~6 secs? - - var text_size = 20; - var box_color = spec.color || p.color(255, 255, 255); - - // --- public methods --- - - - obj.draw = function() { - var time_percent = time_counter / total_time; - //var text_size = 25 - 25*(time_percent); - var text_alpha = 255 - 200*time_percent; - - //var x_pos = (p.width * (5/8)); //+ (p.width / 2) *time_percent; - //var y_pos = (p.height * (5/8)) - (p.height / 2) *time_percent; - - var x_pos = spec.pos.x; - var y_pos = spec.pos.y; - - // I don't like the moving from the center - // so I'm trying it stationary - //var x_pos = p.width / 2; - //var y_pos = 70; - - // this needs to come before textWidth - p.textAlign(p.CENTER, p.CENTER); - p.textSize(text_size); - - var w = p.textWidth(spec.text); - - // draw a box behind it - //p.fill(box_color, text_alpha); - //p.rectMode(p.CORNER) - //p.rect(x_pos-w/2-5, y_pos-p.textAscent(), w+10, p.textAscent()*2); - - //p.fill(p.color(0, 0, 0), text_alpha); - //p.fill(p.color(255, 255, 255), text_alpha); - p.fill(box_color, text_alpha); - p.text(spec.text, x_pos, y_pos); - - if (time_counter > total_time) { // Finished - return false; - } - time_counter++; - return true; - } - - return obj; -}; diff --git a/game/fb/num_status_obj.js b/game/fb/num_status_obj.js deleted file mode 100644 index fc05e28..0000000 --- a/game/fb/num_status_obj.js +++ /dev/null @@ -1,115 +0,0 @@ -// Generic wrapper for a status that includes text and a num -// Can be drawn as a number or a bar -// Provides draw, incr, set_num, and get_num -// spec: -// pos : center pos of text -// text : Will display " " -// num : num to start at -// bar : bool (optional) -// max : num (required if bar) - -var num_status_obj = function(p, spec) { - - // obj to return - var obj = {}; - - // --- private variables --- - - var pos = spec.pos; - var number = spec.num; - var txt = spec.text; - var bar = spec.bar || false; - var max = spec.max; - var height = 20; - var max_width = 100; //for the bar, might need to be passed in - - var get_obj_text = function() { - if (bar) { - return txt; - } - else { - var num_txt = ""+number; - if (spec.format) { - num_txt = spec.format(number); - } - return txt + " " + num_txt; - } - } - - var rect = rectangle(p, { // Really just a text obj - pos : pos, - width : 0, - height : 0, - text : get_obj_text(), - text_size : 14, - text_color: spec.text_color || 255, - }); - - // --- private methods - - var update = function(n) { - - number = n; - - rect.update_text(get_obj_text()); - }; - var draw_full_rect = function(color) { - p.fill(color[0], color[1], color[2]); - //p.strokeWeight(1); - //p.stroke(0); - var topy = pos.y - (height / 2); - var leftx = pos.x + (txt.length * 4); - p.rect(leftx, topy, max_width, height); - }; - - // --- public methods --- - - obj.draw = function() { - rect.draw(); - // Draw the bar separately, if appropriate - if (bar) { - p.noStroke(); - // Draw empty rectangle first - draw_full_rect([255, 255, 255]); - - // Then draw mutation status bar - p.fill(150); - - var topy = pos.y - (height / 2); - var leftx = pos.x + (txt.length * 4); - var rect_width = (number / max) * max_width; - rect_width = rect_width > max_width ? max_width : rect_width; - p.rectMode(p.CORNER); - p.rect(leftx, topy, rect_width, height); - - p.fill(255) - } - }; - - // SHOULD ONLY BE CALLED IF bar IS TRUE - // Draws a full bar of the specified color - // color : 3 element rgb array - obj.draw_color = function(color) { - draw_full_rect(color); - }; - - obj.incr = function(n) { - update(number + n); - }; - - // Set and get - - obj.set_max = function(m) { - max = m; - }; - - obj.set_num = function(n) { - update(n); - }; - - obj.get_num = function() { - return number; - }; - - return obj; -}; diff --git a/game/fb/object_with_states.js b/game/fb/object_with_states.js deleted file mode 100644 index a18e993..0000000 --- a/game/fb/object_with_states.js +++ /dev/null @@ -1,26 +0,0 @@ -// Gives an object the capability to set and get states -// inherits from game_object -// spec: -// spec.state -- current state, default to 'alive' - -var object_with_states = function(p, spec) { - - var obj = game_object(p, spec); - - var state = spec.state || "alive"; - - // --- public methods --- - - obj.set_state = function(s) { - // If outdated, don't update state - if (state != "outdated") { - state = s; - } - }; - - obj.get_state = function() { - return state; - }; - - return obj; -} diff --git a/game/fb/old-index.html b/game/fb/old-index.html deleted file mode 100644 index 3f3eb4d..0000000 --- a/game/fb/old-index.html +++ /dev/null @@ -1,223 +0,0 @@ - - - -Virion - - - - - - - - - -
      - - -
      Login with Facebook to track your high scores!
      - - - - Login with Facebook - - - -

      - -
      You are not Logged In
      - - - - -
      -
      Welcome to Virion beta testing!  Give the game a try and then scroll down to give us your feedback.
      -
      - -
      -
      - Could not load high scores! You may want to check your internet connection. -
      -
      - - - Your browser does not support the HTML5 canvas element. Upgrade to Chrome, Firefox 4, Safari, or Opera to play this game. - -
      -
      -

      Virion Beta Testing Feedback

      -
      - Tell us what you thought of the game by filling out the survey below. You can also email us at viriongame at gmail dot com. Thanks! We appreciate your help.  — The Virion Team -
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/fb/option_button.js b/game/fb/option_button.js deleted file mode 100644 index 5154998..0000000 --- a/game/fb/option_button.js +++ /dev/null @@ -1,63 +0,0 @@ -// Have a rectangle representing their position and a state to go to when clicked -// spec: -// rect : spec for a rectangle representing the button -// click_fun : what to do when clicked -// global_var : var that determines whether this option is enabled or not - -var option_button = function(p, spec) { - - // --- defaults --- - //spec.rect.width = spec.width || 200; - //spec.rect.height = spec.height || 60; - - // obj to return - var obj = {}; - - // --- private variables --- - - var but = button(p, spec); - var rect = rectangle(p, spec.rect); - // Left-edge x and top-edge y coordinates of 'checkbox' indicating whether - // option is enabled - var status_x = rect.get_left_x() + 28//50; - var status_y = rect.get_top_y() + 30//37; - var tick_size = 30; - var tick_yes_image = image_manager.get_image("check1.png"); - var tick_no_image = image_manager.get_image("check0.png"); - - // --- public methods --- - - obj.draw = function() { - //rect.draw(); - but.draw(); - - p.imageMode(p.CENTER); - if (g[spec.global_var]) { - //p.fill(255, 255, 255); - //p.ellipse(status_x, status_y, 10, 10); - p.image(tick_yes_image, status_x, status_y, tick_size, tick_size); - } - else { - p.image(tick_no_image, status_x, status_y, tick_size, tick_size); - } - }; - - // Returns the state to go to if clicked, or - // null if not clicked - obj.click = function(x, y) { - //but.is_clicked(); - if (rect.is_in(x, y)) { - spec.click_fun(); - } - // Redraw in case anything changes - obj.draw(); - }; - - obj.is_clicked = function() { return null; }; - - obj.mouse_moved = function(x, y) { - but.mouse_moved(x, y); - }; - - return obj; -}; diff --git a/game/fb/options_state.js b/game/fb/options_state.js deleted file mode 100644 index 8333f7b..0000000 --- a/game/fb/options_state.js +++ /dev/null @@ -1,209 +0,0 @@ -var options_state = function (p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // Used to determine whether to play menu music when 'music' button is toggled - var prev_was_splash = false; - if (prev_state.get_type() === "splash") { - prev_was_splash = true; - } - - - // --- private variables --- - - var background_image = image_manager.get_image("settingssplash.png"); - - var button_style = { - text_x_offset : 60, - text_y_offset: -3, - text_align: p.LEFT - }; - - // Buttons - - var col1_x = p.width/2 - 120; - var col2_x = p.width/2 + 120; - - var back_button = button(p, { - state : function() { - sounds.play_button_back(); - return prev_state; - }, - rect : { - pos : new p.PVector(p.width / 2, p.height - 80), - //width : 120, - //height : 50, - //text: "Back", - //text_x_offset: 5, - //text_y_offset: -8, - image: "back.png", - } - }); - - // Options - //var option_image = "bullet_listcell.png"; - var sound_fx_button = option_button(p, { - click_fun : function() {sounds.play_button_click(); g.toggle_sound_fx();}, - global_var : "sound_fx", - rect : { - pos : new p.PVector(col1_x, p.height/2 - 70), - //text: "Sound Effects", - //text_x_offset: 60, - image : "set_sound.png",//option_image, - //over_image : "set_sound_a.png", - //style: button_style - } - }); - var music_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - // toggle the flag - g.toggle_music(); - - if (g.music) { - if (prev_was_splash) { - sounds.play_menu_music(); - } - } - else { - sounds.pause_menu_music(); - } - }, - global_var : "music", - rect : { - pos : new p.PVector(col1_x, p.height/2 + 40), - //text: "Music", - //text_x_offset: 60, - image : "set_music.png",//option_image, - //over_image : "set_music_a.png", - //style: button_style - } - }); - var spacebar_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - g.toggle_spacebar_to_fire(); - }, - global_var : "spacebar_to_fire", - rect : { - pos : new p.PVector(col2_x, p.height/2 - 70), - //text: "Spacebar to Fire", - //text_x_offset : 60, - image : "set_spacebar.png",//option_image, - //over_image : "set_spacebar_a.png", - //style: button_style - } - }); - var mouse_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - g.toggle_click_to_fire(); - }, - global_var : "click_to_fire", - rect : { - pos : new p.PVector(col2_x, p.height/2 + 40), - //text: "Mouse Click to Fire", - //text_x_offset : 60, - image : "set_click.png",//option_image, - //over_image : "set_click_a.png", - //style: button_style - } - }); - var mouse_to_select_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - g.toggle_mouse_to_select(); - }, - global_var : "mouse_to_select", - rect : { - pos : new p.PVector(col2_x, p.height/2 + 140), - //text: "Mouse to Select Cells\nInstead of Left/Right", - image : "set_mouseselect.png",//option_image, - //over_image : "set_mouseselect_a.png", - //text_x_offset : 60, - //style: button_style - } - }); - var track_left_button = button(p, { - state : function() { - sounds.play_button_click(); - g.prev_track(); - return obj; - }, - rect : { - pos : new p.PVector(col1_x - 50, p.height/2 + 145), - image : "track_left.png", - } - }); - var track_right_button = button(p, { - state : function() { - sounds.play_button_click(); - g.next_track(); - return obj; - }, - rect : { - pos : new p.PVector(col1_x + 50, p.height/2 + 145), - image : "track_right.png", - } - }); - - - - //Not ordered - var all_option_buttons = [sound_fx_button, music_button, - spacebar_button, mouse_button, mouse_to_select_button]; - var all_buttons = [back_button, track_left_button, track_right_button] - .concat(all_option_buttons); - - - // --- public methods --- - - obj.get_type = function() { - return "options"; - }; - - obj.update = function() { - //do nothing - }; - - obj.key_pressed = function(k) { - if (k === 115 || p.keyCode === 13 || k === 32) { //s, enter, space - } - else if (k === 104) { //h - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - obj.render = function() { - //p.background(g.background_color); - //p.fill(g.background_color); - //p.rect(100, 100, 500, 500); - p.imageMode(p.CORNERS); - p.image(background_image, 0, 0);//, p.width, p.height); - - // draw the track button background manually - var track_x = col1_x; - var track_y = p.height/2 + 140; - var track_image = image_manager.get_image("set_track.png"); - p.imageMode(p.CENTER); - p.image(track_image, track_x, track_y); - // draw current track - p.fill(0); - p.textAlign(p.CENTER); - p.textSize(14); - p.text(g.track, track_x, track_y+5); - - for_each(all_option_buttons, function(b) { b.draw(); }); - }; - - obj.mouse_click = function(x, y) { - for_each(all_option_buttons, function(b) { b.click(x, y); }); - }; - - return obj; -}; diff --git a/game/fb/particle.js b/game/fb/particle.js deleted file mode 100644 index 630645b..0000000 --- a/game/fb/particle.js +++ /dev/null @@ -1,437 +0,0 @@ -// *** particle *** -// --- inherits from game_object -// spec: -// game_object spec - -var particle = function(p, spec) { - - // --- defaults --- - - // was 15 - spec.width = spec.width || 10; - spec.height = spec.height || 10; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "particle"; - }; - - // --- private variables --- - - //var par_shape = p.loadShape("images/virusfinal.svg"); - //var par_image = p.loadImage("images/virus1.png"); - var par_image = image_manager.get_image("tinyvirus_trans.png"); - //var mutation = spec.mutation; - - // --- public methods --- - - // implementing game_object interface - - // update is default (move) - - // draw makes a small virus particle - // (circle for now) - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.get_mode()); - //var color = mutation.get_color(); - p.fill(obj.get_color()); - p.noStroke(); - p.ellipse(pos.x, pos.y, - obj.get_width() * .75, obj.get_height() * .75); - p.imageMode(obj.get_mode()); - p.image(par_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - //var d = new Date(); - //console.log(d.getMilliseconds()); - //p.shape(par_shape, pos.x, pos.y, - //obj.get_width() + 20, obj.get_height() + 20); - //draw(canvas.getContext('2d')); - //canvas.getContext('2d').drawSvg("images/virusFinal.svg", 300, 10, 20, 20); - //console.log("a " + d.getMilliseconds()); - - }; - - // override for circular object - obj.calc_radius = function() { - return obj.get_width()/2; - }; - obj.set_radius(obj.calc_radius()); - - return obj; -} - -// SVG -> Javascript code to draw the particle -/* -var draw = function(ctx) { -ctx.save(); -ctx.strokeStyle = 'rgba(0,0,0,0)'; -ctx.lineCap = 'butt'; -ctx.lineJoin = 'miter'; -ctx.miterLimit = 4; -ctx.save(); -ctx.restore(); -ctx.save(); -ctx.restore(); -ctx.save(); -ctx.scale(0.02,0.02); -ctx.save(); -ctx.fillStyle = "#fff1d0"; -ctx.strokeStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.lineWidth = 5; -ctx.miterLimit = 4; -ctx.beginPath(); -ctx.moveTo(411.42857,373.36218); -ctx.bezierCurveTo(378.29148999999995,373.36218,351.42857,400.2251,351.42857,433.36218); -ctx.bezierCurveTo(351.42857,435.74656000000004,351.59556999999995,438.08169000000004,351.86607,440.39343); -ctx.bezierCurveTo(333.68726999999996,446.05755000000005,316.62739,454.24753000000004,301.08482,464.54968); -ctx.bezierCurveTo(293.76497,456.45166,283.20419999999996,451.36218,271.42857,451.36218); -ctx.bezierCurveTo(249.33718,451.36218,231.42856999999998,469.27079000000003,231.42856999999998,491.36218); -ctx.bezierCurveTo(231.42856999999998,503.13781,236.51805,513.69858,244.61606999999998,521.0184300000001); -ctx.bezierCurveTo(234.27291999999997,536.6228600000001,226.0638,553.7583900000001,220.39731999999998,572.0184300000001); -ctx.bezierCurveTo(217.46769999999998,571.5787200000001,214.48073999999997,571.3621800000001,211.42856999999998,571.3621800000001); -ctx.bezierCurveTo(178.29148999999998,571.3621800000001,151.42856999999998,598.2251000000001,151.42856999999998,631.3621800000001); -ctx.bezierCurveTo(151.42856999999998,664.49926,178.29148999999998,691.3621800000001,211.42856999999998,691.3621800000001); -ctx.bezierCurveTo(214.48073999999997,691.3621800000001,217.46769999999998,691.1456400000001,220.39731999999998,690.7059300000001); -ctx.bezierCurveTo(226.0638,708.9659700000001,234.27291999999997,726.1015000000001,244.61606999999998,741.7059300000001); -ctx.bezierCurveTo(236.51805,749.02578,231.42856999999998,759.5865500000001,231.42856999999998,771.3621800000001); -ctx.bezierCurveTo(231.42856999999998,793.4535700000001,249.33718,811.3621800000001,271.42857,811.3621800000001); -ctx.bezierCurveTo(283.20419999999996,811.3621800000001,293.76497,806.2727000000001,301.08482,798.1746800000001); -ctx.bezierCurveTo(316.68924999999996,808.5178300000001,333.82478,816.7269500000001,352.08482,822.3934300000001); -ctx.bezierCurveTo(351.64511,825.3230500000001,351.42857,828.31001,351.42857,831.3621800000001); -ctx.bezierCurveTo(351.42857,864.49926,378.29148999999995,891.3621800000001,411.42857,891.3621800000001); -ctx.bezierCurveTo(444.56565,891.3621800000001,471.42857,864.49926,471.42857,831.3621800000001); -ctx.bezierCurveTo(471.42857,828.31001,471.21202999999997,825.3230500000001,470.77232,822.3934300000001); -ctx.bezierCurveTo(489.03236,816.7269500000001,506.16789,808.5178300000001,521.77232,798.1746800000001); -ctx.bezierCurveTo(529.09217,806.2727000000001,539.6529400000001,811.3621800000001,551.42857,811.3621800000001); -ctx.bezierCurveTo(573.5199600000001,811.3621800000001,591.42857,793.4535700000001,591.42857,771.3621800000001); -ctx.bezierCurveTo(591.42857,759.5865500000001,586.33909,749.02578,578.24107,741.7059300000001); -ctx.bezierCurveTo(588.5842200000001,726.1015000000001,596.7933400000001,708.9659700000001,602.45982,690.7059300000001); -ctx.bezierCurveTo(605.38944,691.1456400000001,608.3764,691.3621800000001,611.42857,691.3621800000001); -ctx.bezierCurveTo(644.56565,691.3621800000001,671.42857,664.49926,671.42857,631.3621800000001); -ctx.bezierCurveTo(671.42857,598.2251000000001,644.56565,571.3621800000001,611.42857,571.3621800000001); -ctx.bezierCurveTo(608.3764,571.3621800000001,605.38944,571.5787200000001,602.45982,572.0184300000001); -ctx.bezierCurveTo(596.7933400000001,553.7583900000001,588.5842200000001,536.6228600000001,578.24107,521.0184300000001); -ctx.bezierCurveTo(586.33909,513.6985800000001,591.42857,503.13781000000006,591.42857,491.3621800000001); -ctx.bezierCurveTo(591.42857,469.2707900000001,573.5199600000001,451.3621800000001,551.42857,451.3621800000001); -ctx.bezierCurveTo(539.6529400000001,451.3621800000001,529.09217,456.45166000000006,521.77232,464.5496800000001); -ctx.bezierCurveTo(506.22975,454.2475300000001,489.16987000000006,446.0575500000001,470.99107000000004,440.3934300000001); -ctx.bezierCurveTo(471.26157000000006,438.0816900000001,471.42857000000004,435.7465600000001,471.42857000000004,433.3621800000001); -ctx.bezierCurveTo(471.42857000000004,400.2251000000001,444.56565000000006,373.3621800000001,411.42857000000004,373.3621800000001); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "#d4d4d4"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.globalAlpha = 0.2752293646335602; -ctx.beginPath(); -ctx.moveTo(530.99107,472.99893); -ctx.bezierCurveTo(556.1068300000001,506.42843999999997,570.99107,547.96659,570.99107,592.99893); -ctx.bezierCurveTo(570.99107,640.61609,554.33443,684.34142,526.55357,718.68643); -ctx.bezierCurveTo(529.38723,724.17581,530.99107,730.39551,530.99107,736.99893); -ctx.bezierCurveTo(530.99107,759.09032,513.0824600000001,776.99893,490.99107000000004,776.99893); -ctx.bezierCurveTo(481.81567,776.99893,473.36493,773.91293,466.61607000000004,768.71768); -ctx.bezierCurveTo(459.44539000000003,772.62788,452.0033,776.1000799999999,444.33482000000004,779.12393); -ctx.bezierCurveTo(459.07273000000004,788.9998499999999,469.20043000000004,805.23816,470.77232000000004,823.90518); -ctx.bezierCurveTo(552.02543,798.48635,610.99107,722.63081,610.99107,632.99893); -ctx.bezierCurveTo(610.99107,567.57432,579.55868,509.48801,530.99107,472.99893); -ctx.closePath(); -ctx.moveTo(250.99107000000004,752.99893); -ctx.bezierCurveTo(275.86402000000004,786.1052599999999,310.78272000000004,811.21984,351.20982000000004,823.87393); -ctx.bezierCurveTo(352.19252000000006,812.2756499999999,356.47693000000004,801.61852,363.11607000000004,792.84268); -ctx.bezierCurveTo(321.11956000000004,791.21726,282.46387000000004,776.64461,250.99107000000004,752.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(330.99107,780.39343); -ctx.bezierCurveTo(353.16121999999996,780.39343,371.13367,763.9635099999999,371.13367,743.6961799999999); -ctx.bezierCurveTo(371.13367,742.58201,371.07697,741.48232,370.97059,740.39343); -ctx.bezierCurveTo(369.14252,759.1119,351.94243,773.78793,330.99107000000004,773.78793); -ctx.bezierCurveTo(310.03970000000004,773.78793,292.83962,759.1119,291.01155000000006,740.39343); -ctx.bezierCurveTo(290.90521000000007,741.48232,290.8484700000001,742.58201,290.8484700000001,743.6961799999999); -ctx.bezierCurveTo(290.8484700000001,763.9635099999999,308.82092000000006,780.3934299999999,330.9910700000001,780.3934299999999); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(530.99107,606.99893); -ctx.bezierCurveTo(553.1612200000001,606.99893,571.13367,590.5690099999999,571.13367,570.30168); -ctx.bezierCurveTo(571.13367,569.1875100000001,571.0769700000001,568.0878200000001,570.97059,566.9989300000001); -ctx.bezierCurveTo(569.14252,585.7174000000001,551.9424300000001,600.3934300000001,530.99107,600.3934300000001); -ctx.bezierCurveTo(510.03970000000004,600.3934300000001,492.83962,585.7174000000001,491.01155000000006,566.9989300000001); -ctx.bezierCurveTo(490.90521000000007,568.0878200000001,490.8484700000001,569.1875100000001,490.8484700000001,570.30168); -ctx.bezierCurveTo(490.8484700000001,590.56901,508.82092000000006,606.99893,530.99107,606.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(290.99107,606.99893); -ctx.bezierCurveTo(313.16121999999996,606.99893,331.13367,590.5690099999999,331.13367,570.30168); -ctx.bezierCurveTo(331.13367,569.1875100000001,331.07697,568.0878200000001,330.97059,566.9989300000001); -ctx.bezierCurveTo(329.14252,585.7174000000001,311.94243,600.3934300000001,290.99107000000004,600.3934300000001); -ctx.bezierCurveTo(270.03970000000004,600.3934300000001,252.83962000000002,585.7174000000001,251.01155000000003,566.9989300000001); -ctx.bezierCurveTo(250.90521000000004,568.0878200000001,250.84847000000002,569.1875100000001,250.84847000000002,570.30168); -ctx.bezierCurveTo(250.84847000000002,590.56901,268.82092,606.99893,290.99107000000004,606.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(410.99107,700.39343); -ctx.bezierCurveTo(444.23506999999995,700.39343,471.18464,675.74855,471.18464,645.34755); -ctx.bezierCurveTo(471.18464,643.6763,471.09964,642.02676,470.94010000000003,640.39343); -ctx.bezierCurveTo(468.19892000000004,668.47114,442.4075,690.48518,410.99107000000004,690.48518); -ctx.bezierCurveTo(379.57463,690.48518,353.78322000000003,668.47114,351.04204000000004,640.39343); -ctx.bezierCurveTo(350.88258,642.02676,350.79750000000007,643.6763,350.79750000000007,645.34755); -ctx.bezierCurveTo(350.79750000000007,675.7485499999999,377.74707000000006,700.39343,410.9910700000001,700.39343); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(379.52232,680.31143); -ctx.bezierCurveTo(369.29332,669.55083,362.99107,655.01762,362.99107,638.99893); -ctx.bezierCurveTo(362.99107,605.86185,389.85398999999995,578.99893,422.99107,578.99893); -ctx.bezierCurveTo(432.90058,578.99893,442.2231,581.43242,450.45982,585.68643); -ctx.bezierCurveTo(439.5286,574.18711,424.10945999999996,566.99893,406.99107,566.99893); -ctx.bezierCurveTo(373.85398999999995,566.99893,346.99107,593.86185,346.99107,626.99893); -ctx.bezierCurveTo(346.99107,650.22651,360.21569999999997,670.34016,379.52232,680.31143); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(385.52232,490.31143); -ctx.bezierCurveTo(375.29332,479.55082999999996,368.99107,465.01761999999997,368.99107,448.99893); -ctx.bezierCurveTo(368.99107,415.86185,395.85398999999995,388.99893,428.99107,388.99893); -ctx.bezierCurveTo(438.90058,388.99893,448.2231,391.43242,456.45982,395.68643); -ctx.bezierCurveTo(445.5286,384.18710999999996,430.10945999999996,376.99893,412.99107,376.99893); -ctx.bezierCurveTo(379.85398999999995,376.99893,352.99107,403.86184999999995,352.99107,436.99893); -ctx.bezierCurveTo(352.99107,460.22650999999996,366.21569999999997,480.34015999999997,385.52232,490.31143); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(410.99107,496.90718); -ctx.bezierCurveTo(444.23506999999995,496.90718,471.18464,472.2623,471.18464,441.86129999999997); -ctx.bezierCurveTo(471.18464,440.19005,471.09964,438.54051,470.94010000000003,436.90718); -ctx.bezierCurveTo(468.19892000000004,464.98489,442.4075,486.99893,410.99107000000004,486.99893); -ctx.bezierCurveTo(379.57463,486.99893,353.78322000000003,464.98488999999995,351.04204000000004,436.90718); -ctx.bezierCurveTo(350.88258,438.54051,350.79750000000007,440.19005,350.79750000000007,441.86129999999997); -ctx.bezierCurveTo(350.79750000000007,472.2623,377.74707000000006,496.90718,410.9910700000001,496.90718); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(385.52232,880.31143); -ctx.bezierCurveTo(375.29332,869.55083,368.99107,855.01762,368.99107,838.99893); -ctx.bezierCurveTo(368.99107,805.86185,395.85398999999995,778.99893,428.99107,778.99893); -ctx.bezierCurveTo(438.90058,778.99893,448.2231,781.43242,456.45982,785.68643); -ctx.bezierCurveTo(445.5286,774.18711,430.10945999999996,766.99893,412.99107,766.99893); -ctx.bezierCurveTo(379.85398999999995,766.99893,352.99107,793.86185,352.99107,826.99893); -ctx.bezierCurveTo(352.99107,850.22651,366.21569999999997,870.34016,385.52232,880.31143); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(214.99107,572.99893); -ctx.bezierCurveTo(181.85399,572.99893,154.99107,599.86185,154.99107,632.99893); -ctx.bezierCurveTo(154.99107,656.22651,168.2157,676.34016,187.52232,686.31143); -ctx.bezierCurveTo(177.29332,675.55083,170.99107,661.01762,170.99107,644.99893); -ctx.bezierCurveTo(170.99107,616.5388399999999,190.81059000000002,592.72182,217.39732,586.56143); -ctx.bezierCurveTo(218.55700000000002,582.09924,219.88045,577.67801,221.33482,573.34268); -ctx.bezierCurveTo(219.25357,573.12367,217.13087000000002,572.99893,214.99107,572.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(610.99107,572.99893); -ctx.bezierCurveTo(608.53101,572.99893,606.12354,573.18,603.74107,573.46768); -ctx.bezierCurveTo(605.0957900000001,578.3556199999999,606.25589,583.31197,607.24107,588.34268); -ctx.bezierCurveTo(613.4279,586.18599,620.06901,584.99893,626.99107,584.99893); -ctx.bezierCurveTo(636.90058,584.99893,646.2231,587.43242,654.45982,591.68643); -ctx.bezierCurveTo(643.5286,580.18711,628.10946,572.99893,610.99107,572.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(270.40757,590.02506); -ctx.bezierCurveTo(263.48731000000004,583.2801400000001,259.22363,574.1704900000001,259.22363,564.12971); -ctx.bezierCurveTo(259.22363,543.3588500000001,277.39728,526.5207300000001,299.81559000000004,526.5207300000001); -ctx.bezierCurveTo(306.51970000000006,526.5207300000001,312.82669000000004,528.0460800000001,318.39911000000006,530.71256); -ctx.bezierCurveTo(311.0037700000001,523.5046000000001,300.5722200000001,518.9989300000001,288.99107000000004,518.9989300000001); -ctx.bezierCurveTo(266.57276,518.9989300000001,248.39911000000004,535.8370500000001,248.39911000000004,556.6079100000001); -ctx.bezierCurveTo(248.39911000000004,571.1673400000001,257.34600000000006,583.7749000000001,270.40757,590.02506); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(509.82696,588.84012); -ctx.bezierCurveTo(503.02601999999996,582.03508,498.83585,572.84422,498.83585,562.71395); -ctx.bezierCurveTo(498.83585,541.75794,516.69616,524.76973,538.7279599999999,524.76973); -ctx.bezierCurveTo(545.31648,524.76973,551.51473,526.30868,556.9910699999999,528.99893); -ctx.bezierCurveTo(549.7232399999999,521.72672,539.4715399999999,517.18089,528.0900599999999,517.18089); -ctx.bezierCurveTo(506.0582699999999,517.18089,488.19795999999985,534.1691,488.19795999999985,555.1251); -ctx.bezierCurveTo(488.19795999999985,569.81431,496.9905899999998,582.5342499999999,509.8269599999999,588.84012); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(249.11607,744.46768); -ctx.bezierCurveTo(239.42177,750.46789,232.99107,761.00366,232.99107,772.99893); -ctx.bezierCurveTo(232.99107,786.0855399999999,240.67045000000002,797.41228,251.86607,803.03018); -ctx.bezierCurveTo(245.93443000000002,796.96757,242.27232,788.77399,242.27232,779.74893); -ctx.bezierCurveTo(242.27232,768.88478,247.54392,759.24582,255.74107,753.06143); -ctx.bezierCurveTo(253.45899,750.25464,251.24597,747.3976,249.11607,744.46768); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(572.05357,748.21768); -ctx.bezierCurveTo(571.2613600000001,749.2555,570.45924,750.28971,569.64732,751.31143); -ctx.bezierCurveTo(573.66413,751.8387799999999,577.4639400000001,753.04166,580.92857,754.78018); -ctx.bezierCurveTo(578.36622,752.16126,575.3596,749.93576,572.05357,748.21768); -ctx.closePath(); -ctx.moveTo(530.45982,788.87393); -ctx.bezierCurveTo(528.51967,790.28432,526.54551,791.65748,524.55357,792.99893); -ctx.bezierCurveTo(527.85458,799.46132,533.17976,804.78457,539.77232,808.09268); -ctx.bezierCurveTo(534.7460100000001,802.9553999999999,531.37795,796.27958,530.45982,788.87393); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(490.99107,780.99893); -ctx.bezierCurveTo(513.16122,780.99893,531.1336699999999,764.5690099999999,531.1336699999999,744.30168); -ctx.bezierCurveTo(531.1336699999999,743.1875100000001,531.07697,742.0878200000001,530.9705899999999,740.9989300000001); -ctx.bezierCurveTo(529.1425199999999,759.7174000000001,511.9424299999999,774.3934300000001,490.9910699999999,774.3934300000001); -ctx.bezierCurveTo(470.0396999999999,774.3934300000001,452.8396199999999,759.7174000000001,451.01154999999994,740.9989300000001); -ctx.bezierCurveTo(450.90520999999995,742.0878200000001,450.84846999999996,743.1875100000001,450.84846999999996,744.30168); -ctx.bezierCurveTo(450.84846999999996,764.56901,468.82091999999994,780.99893,490.99107,780.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(252.5773,518.27473); -ctx.bezierCurveTo(246.64565000000002,512.21212,242.99107,504.02398999999997,242.99107,494.99893); -ctx.bezierCurveTo(242.99107,476.32923,258.56848,461.19444,277.78418,461.19444); -ctx.bezierCurveTo(283.53056,461.19444,288.93655,462.56549,293.71290999999997,464.96223); -ctx.bezierCurveTo(287.37404999999995,458.48341999999997,278.43271999999996,454.43354,268.50602,454.43354); -ctx.bezierCurveTo(249.29031999999998,454.43354,233.71290999999997,469.56833,233.71290999999997,488.23803); -ctx.bezierCurveTo(233.71290999999997,501.32464,241.38166999999996,512.65684,252.57729999999998,518.27473); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(550.99107,456.99893); -ctx.bezierCurveTo(541.15601,456.99893,532.2878900000001,460.96844,525.95982,467.34268); -ctx.bezierCurveTo(529.09436,469.54866,532.14881,471.83973999999995,535.14732,474.21768); -ctx.bezierCurveTo(541.4817800000001,467.78294999999997,550.38418,463.74893,560.27232,463.74893); -ctx.bezierCurveTo(566.0187000000001,463.74893,571.43347,465.13343999999995,576.20982,467.53018); -ctx.bezierCurveTo(569.87097,461.05136999999996,560.91777,456.99893,550.99107,456.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(310.12323,762.27473); -ctx.bezierCurveTo(303.07660999999996,756.21629,298.73508,748.0337999999999,298.73508,739.01495); -ctx.bezierCurveTo(298.73508,720.35811,317.24055999999996,705.23373,340.06822999999997,705.23373); -ctx.bezierCurveTo(346.89475,705.23373,353.3169,706.60384,358.99107,708.9989300000001); -ctx.bezierCurveTo(351.4607,702.5245800000001,340.83867,698.4774900000001,329.04605999999995,698.4774900000001); -ctx.bezierCurveTo(306.2184,698.4774900000001,287.71290999999997,713.6018600000001,287.71290999999997,732.2587100000001); -ctx.bezierCurveTo(287.71290999999997,745.33631,296.82316,756.6607,310.12323,762.2747300000001); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(470.75204,762.27473); -ctx.bezierCurveTo(463.5077,756.21629,459.04435,748.0337999999999,459.04435,739.01495); -ctx.bezierCurveTo(459.04435,720.35811,478.06908,705.23373,501.53727000000003,705.23373); -ctx.bezierCurveTo(508.55534000000006,705.23373,515.15769,706.60384,520.99107,708.9989300000001); -ctx.bezierCurveTo(513.2494,702.5245800000001,502.32933,698.4774900000001,490.20583000000005,698.4774900000001); -ctx.bezierCurveTo(466.73764000000006,698.4774900000001,447.7129100000001,713.6018600000001,447.7129100000001,732.2587100000001); -ctx.bezierCurveTo(447.7129100000001,745.33631,457.0787900000001,756.6607,470.7520400000001,762.2747300000001); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.restore(); -ctx.restore(); -}; -*/ diff --git a/game/fb/pause_state.js b/game/fb/pause_state.js deleted file mode 100644 index 30e7767..0000000 --- a/game/fb/pause_state.js +++ /dev/null @@ -1,121 +0,0 @@ -var pause_state = function (p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - // Buttons - // Have a rectangle representing their position and - // a state to go to when pressed - var button_x = p.width / 2; - var button_top = 200; - var button_sep = 60; - - var button_style = { - text_size: 14, - text_align: p.LEFT, - text_x_offset: 25, - width: 120, - height: 50, - }; - - - var continue_button = button(p, { - state : function() { - sounds.play_button_click(); - return prev_state; - }, - rect : { - pos : new p.PVector(button_x, button_top), - //text: "Continue", - image: "continue.png", - width: 120, - height: 50 - //image_x_offset: 5, - //style: button_style - } - }); - - var options_button = button(p, { - state : function() { - sounds.play_button_click(); - return options_state(p, obj); - }, - rect : { - pos : new p.PVector(button_x, button_top+button_sep), - //text: "Settings", - image: "settings.png", - //style: button_style - } - }); - - var help_button = button(p, { - state : function() { - sounds.play_button_click(); - return help_state(p, obj); - }, - rect : { - pos : new p.PVector(button_x, button_top+2*button_sep), - //text: "Instructions", - //text_x_offset: 10, - image: "instructions.png", - //image_x_offset: 3, - //style: button_style - } - }); - - var quit_button = button(p, { - state : function() { - sounds.play_button_click(); - return splash_state(p); - }, - rect : { - pos : new p.PVector(button_x, button_top+3*button_sep), - //text: "Quit", - //text_x_offset: -5, - image: "quit.png", - //image_x_offset: -5, - //style: button_style - } - }); - - //Not ordered - var all_buttons = [ continue_button, options_button, - help_button, quit_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "pause"; - }; - - obj.update = function() { - //do nothing - }; - - obj.render = function() { - p.noStroke(); - p.fill(0, 150); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.fill(255); - p.textSize(40); - p.textAlign(p.CENTER); - p.text("Game Paused", p.width/2, 150); - }; - - obj.key_pressed = function(k) { - if (k === 112 || p.keyCode === 13 || p.keyCode === 27) { //p, enter, esc - obj.exit_state();; - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/game/fb/php_functions.php b/game/fb/php_functions.php deleted file mode 100644 index ac9629e..0000000 --- a/game/fb/php_functions.php +++ /dev/null @@ -1,104 +0,0 @@ - - -var g_soundDataMap = -{ - "cell_fire" : "", - "cell_infect" : "", - "macrophage_infect" : "", - "level_up" : "", - "kill" : "", - "buttonmain" : "", - "buttonback" : "", - "TextPopUp" : "", - "cell_firemp3" : "", - "cell_infectmp3" : "", - "macrophage_infectmp3" : "", - "level_upmp3" : "", - "killmp3" : "", - "buttonmainmp3" : "", - "buttonbackmp3" : "", - "TextPopUpmp3" : "", -}; - -/* -Not working -var dynamic_div_tag = null; -// Jplayer instances - -*/ - -//IMAGES - - -//var image_list = []; -//var g_infected_cell_images = []; -//var g_empty_cell_images = []; - -// to be used in image_manager -all_image_files = {}; - - - diff --git a/game/fb/processing-1.0.0.js b/game/fb/processing-1.0.0.js deleted file mode 100644 index 605223f..0000000 --- a/game/fb/processing-1.0.0.js +++ /dev/null @@ -1,18013 +0,0 @@ -/* - - P R O C E S S I N G . J S - 1.0.0 - a port of the Processing visualization language - - License : MIT - Developer : John Resig: http://ejohn.org - Web Site : http://processingjs.org - Java Version : http://processing.org - Github Repo. : http://github.com/jeresig/processing-js - Bug Tracking : http://processing-js.lighthouseapp.com - Mozilla POW! : http://wiki.Mozilla.org/Education/Projects/ProcessingForTheWeb - Maintained by : Seneca: http://zenit.senecac.on.ca/wiki/index.php/Processing.js - Hyper-Metrix: http://hyper-metrix.com/#Processing - BuildingSky: http://weare.buildingsky.net/pages/processing-js - - */ - -(function() { - - var undef; // intentionally left undefined - - var ajax = function ajax(url) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", url, false); - xhr.setRequestHeader("If-Modified-Since", "Fri, 01 Jan 1960 00:00:00 GMT"); - xhr.send(null); - // failed request? - if (xhr.status !== 200 && xhr.status !== 0) { throw ("XMLHttpRequest failed, status code " + xhr.status); } - return xhr.responseText; - }; - - /* Browsers fixes start */ - function fixReplaceByRegExp() { - var re = /t/g; - if ("t".replace(re,"") !== null && re.exec("t")) { - return; // it is not necessary - } - var _ie_replace = String.prototype.replace; - String.prototype.replace = function(searchValue, repaceValue) { - var result = _ie_replace.apply(this, arguments); - if (searchValue instanceof RegExp && searchValue.global) { - searchValue.lastIndex = 0; - } - return result; - }; - } - - function fixMatchByRegExp() { - var re = /t/g; - if ("t".match(re) !== null && re.exec("t")) { - return; // it is not necessary - } - var _ie_match = String.prototype.match; - String.prototype.match = function(searchValue) { - var result = _ie_match.apply(this, arguments); - if(searchValue instanceof RegExp && searchValue.global) { - searchValue.lastIndex = 0; - } - return result; - }; - } - fixReplaceByRegExp(); - fixMatchByRegExp(); - - (function fixOperaCreateImageData() { - try { - if (!("createImageData" in CanvasRenderingContext2D.prototype)) { - CanvasRenderingContext2D.prototype.createImageData = function (sw, sh) { - return new ImageData(sw, sh); - }; - } - } catch(e) {} - }()); - /* Browsers fixes end */ - - var PConstants = { - X: 0, - Y: 1, - Z: 2, - - R: 3, - G: 4, - B: 5, - A: 6, - - U: 7, - V: 8, - - NX: 9, - NY: 10, - NZ: 11, - - EDGE: 12, - - // Stroke - SR: 13, - SG: 14, - SB: 15, - SA: 16, - - SW: 17, - - // Transformations (2D and 3D) - TX: 18, - TY: 19, - TZ: 20, - - VX: 21, - VY: 22, - VZ: 23, - VW: 24, - - // Material properties - AR: 25, - AG: 26, - AB: 27, - - DR: 3, - DG: 4, - DB: 5, - DA: 6, - - SPR: 28, - SPG: 29, - SPB: 30, - - SHINE: 31, - - ER: 32, - EG: 33, - EB: 34, - - BEEN_LIT: 35, - - VERTEX_FIELD_COUNT: 36, - - // Renderers - P2D: 1, - JAVA2D: 1, - WEBGL: 2, - P3D: 2, - OPENGL: 2, - PDF: 0, - DXF: 0, - - // Platform IDs - OTHER: 0, - WINDOWS: 1, - MAXOSX: 2, - LINUX: 3, - - EPSILON: 0.0001, - - MAX_FLOAT: 3.4028235e+38, - MIN_FLOAT: -3.4028235e+38, - MAX_INT: 2147483647, - MIN_INT: -2147483648, - - PI: Math.PI, - TWO_PI: 2 * Math.PI, - HALF_PI: Math.PI / 2, - THIRD_PI: Math.PI / 3, - QUARTER_PI: Math.PI / 4, - - DEG_TO_RAD: Math.PI / 180, - RAD_TO_DEG: 180 / Math.PI, - - WHITESPACE: " \t\n\r\f\u00A0", - - // Color modes - RGB: 1, - ARGB: 2, - HSB: 3, - ALPHA: 4, - CMYK: 5, - - // Image file types - TIFF: 0, - TARGA: 1, - JPEG: 2, - GIF: 3, - - // Filter/convert types - BLUR: 11, - GRAY: 12, - INVERT: 13, - OPAQUE: 14, - POSTERIZE: 15, - THRESHOLD: 16, - ERODE: 17, - DILATE: 18, - - // Blend modes - REPLACE: 0, - BLEND: 1 << 0, - ADD: 1 << 1, - SUBTRACT: 1 << 2, - LIGHTEST: 1 << 3, - DARKEST: 1 << 4, - DIFFERENCE: 1 << 5, - EXCLUSION: 1 << 6, - MULTIPLY: 1 << 7, - SCREEN: 1 << 8, - OVERLAY: 1 << 9, - HARD_LIGHT: 1 << 10, - SOFT_LIGHT: 1 << 11, - DODGE: 1 << 12, - BURN: 1 << 13, - - // Color component bit masks - ALPHA_MASK: 0xff000000, - RED_MASK: 0x00ff0000, - GREEN_MASK: 0x0000ff00, - BLUE_MASK: 0x000000ff, - - // Projection matrices - CUSTOM: 0, - ORTHOGRAPHIC: 2, - PERSPECTIVE: 3, - - // Shapes - POINT: 2, - POINTS: 2, - LINE: 4, - LINES: 4, - TRIANGLE: 8, - TRIANGLES: 9, - TRIANGLE_STRIP: 10, - TRIANGLE_FAN: 11, - QUAD: 16, - QUADS: 16, - QUAD_STRIP: 17, - POLYGON: 20, - PATH: 21, - RECT: 30, - ELLIPSE: 31, - ARC: 32, - SPHERE: 40, - BOX: 41, - - GROUP: 0, - PRIMITIVE: 1, - //PATH: 21, // shared with Shape PATH - GEOMETRY: 3, - - // Shape Vertex - VERTEX: 0, - BEZIER_VERTEX: 1, - CURVE_VERTEX: 2, - BREAK: 3, - CLOSESHAPE: 4, - - // Shape closing modes - OPEN: 1, - CLOSE: 2, - - // Shape drawing modes - CORNER: 0, // Draw mode convention to use (x, y) to (width, height) - CORNERS: 1, // Draw mode convention to use (x1, y1) to (x2, y2) coordinates - RADIUS: 2, // Draw mode from the center, and using the radius - CENTER_RADIUS: 2, // Deprecated! Use RADIUS instead - CENTER: 3, // Draw from the center, using second pair of values as the diameter - DIAMETER: 3, // Synonym for the CENTER constant. Draw from the center - CENTER_DIAMETER: 3, // Deprecated! Use DIAMETER instead - - // Text vertical alignment modes - BASELINE: 0, // Default vertical alignment for text placement - TOP: 101, // Align text to the top - BOTTOM: 102, // Align text from the bottom, using the baseline - - // UV Texture coordinate modes - NORMAL: 1, - NORMALIZED: 1, - IMAGE: 2, - - // Text placement modes - MODEL: 4, - SHAPE: 5, - - // Stroke modes - SQUARE: 'butt', - ROUND: 'round', - PROJECT: 'square', - MITER: 'miter', - BEVEL: 'bevel', - - // Lighting modes - AMBIENT: 0, - DIRECTIONAL: 1, - //POINT: 2, Shared with Shape constant - SPOT: 3, - - // Key constants - - // Both key and keyCode will be equal to these values - BACKSPACE: 8, - TAB: 9, - ENTER: 10, - RETURN: 13, - ESC: 27, - DELETE: 127, - CODED: 0xffff, - - // p.key will be CODED and p.keyCode will be this value - SHIFT: 16, - CONTROL: 17, - ALT: 18, - CAPSLK: 20, - PGUP: 33, - PGDN: 34, - END: 35, - HOME: 36, - LEFT: 37, - UP: 38, - RIGHT: 39, - DOWN: 40, - INS: 45, - DEL: 46, - F1: 112, - F2: 113, - F3: 114, - F4: 115, - F5: 116, - F6: 117, - F7: 118, - F8: 119, - F9: 120, - F10: 121, - F11: 122, - F12: 123, - NUMLK: 144, - - // Cursor types - ARROW: 'default', - CROSS: 'crosshair', - HAND: 'pointer', - MOVE: 'move', - TEXT: 'text', - WAIT: 'wait', - NOCURSOR: "url('data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), auto", - - // Hints - DISABLE_OPENGL_2X_SMOOTH: 1, - ENABLE_OPENGL_2X_SMOOTH: -1, - ENABLE_OPENGL_4X_SMOOTH: 2, - ENABLE_NATIVE_FONTS: 3, - DISABLE_DEPTH_TEST: 4, - ENABLE_DEPTH_TEST: -4, - ENABLE_DEPTH_SORT: 5, - DISABLE_DEPTH_SORT: -5, - DISABLE_OPENGL_ERROR_REPORT: 6, - ENABLE_OPENGL_ERROR_REPORT: -6, - ENABLE_ACCURATE_TEXTURES: 7, - DISABLE_ACCURATE_TEXTURES: -7, - HINT_COUNT: 10, - - // PJS defined constants - SINCOS_LENGTH: parseInt(360 / 0.5, 10), - PRECISIONB: 15, // fixed point precision is limited to 15 bits!! - PRECISIONF: 1 << 15, - PREC_MAXVAL: (1 << 15) - 1, - PREC_ALPHA_SHIFT: 24 - 15, - PREC_RED_SHIFT: 16 - 15, - NORMAL_MODE_AUTO: 0, - NORMAL_MODE_SHAPE: 1, - NORMAL_MODE_VERTEX: 2, - MAX_LIGHTS: 8 - }; - - // Typed Arrays: fallback to WebGL arrays or Native JS arrays if unavailable - function setupTypedArray(name, fallback) { - // check if TypedArray exists - // typeof on Minefield and Chrome return function, typeof on Webkit returns object. - if (typeof this[name] !== "function" && typeof this[name] !== "object") { - // nope.. check if WebGLArray exists - if (typeof this[fallback] === "function") { - this[name] = this[fallback]; - } else { - // nope.. set as Native JS array - this[name] = function(obj) { - if (obj instanceof Array) { - return obj; - } else if (typeof obj === "number") { - return new Array(obj); - } - }; - } - } - } - - setupTypedArray("Float32Array", "WebGLFloatArray"); - setupTypedArray("Int32Array", "WebGLIntArray"); - setupTypedArray("Uint16Array", "WebGLUnsignedShortArray"); - setupTypedArray("Uint8Array", "WebGLUnsignedByteArray"); - - /** - * An ArrayList stores a variable number of objects. - * - * @param {int} initialCapacity optional defines the initial capacity of the list, it's empty by default - * - * @returns {ArrayList} new ArrayList object - */ - var ArrayList = (function() { - function Iterator(array) { - var index = 0; - this.hasNext = function() { - return index < array.length; - }; - - this.next = function() { - return array[index++]; - }; - - this.remove = function() { - array.splice(index, 1); - }; - } - - function ArrayList() { - var array = arguments.length === 0 ? [] : - typeof arguments[0] === 'number' ? new Array(0 | arguments[0]) : - arguments[0]; - - /** - * @member ArrayList - * ArrayList.get() Returns the element at the specified position in this list. - * - * @param {int} i index of element to return - * - * @returns {Object} the element at the specified position in this list. - */ - this.get = function(i) { - return array[i]; - }; - /** - * @member ArrayList - * ArrayList.contains() Returns true if this list contains the specified element. - * - * @param {Object} item element whose presence in this List is to be tested. - * - * @returns {boolean} true if the specified element is present; false otherwise. - */ - this.contains = function(item) { - return array.indexOf(item) !== -1; - }; - /** - * @member ArrayList - * ArrayList.add() Adds the specified element to this list. - * - * @param {int} index optional index at which the specified element is to be inserted - * @param {Object} object element to be added to the list - */ - this.add = function() { - if (arguments.length === 1) { - array.push(arguments[0]); // for add(Object) - } else if (arguments.length === 2) { - var arg0 = arguments[0]; - if (typeof arg0 === 'number') { - if (arg0 >= 0 && arg0 <= array.length) { - array.splice(arg0, 0, arguments[1]); // for add(i, Object) - } else { - throw(arg0 + " is not a valid index"); - } - } else { - throw(typeof arg0 + " is not a number"); - } - } else { - throw("Please use the proper number of parameters."); - } - }; - - /** - * @member ArrayList - * ArrayList.set() Replaces the element at the specified position in this list with the specified element. - * - * @param {int} index index of element to replace - * @param {Object} object element to be stored at the specified position - */ - this.set = function() { - if (arguments.length === 2) { - var arg0 = arguments[0]; - if (typeof arg0 === 'number') { - if (arg0 >= 0 && arg0 < array.length) { - array.splice(arg0, 1, arguments[1]); - } else { - throw(arg0 + " is not a valid index."); - } - } else { - throw(typeof arg0 + " is not a number"); - } - } else { - throw("Please use the proper number of parameters."); - } - }; - - /** - * @member ArrayList - * ArrayList.size() Returns the number of elements in this list. - * - * @returns {int} the number of elements in this list - */ - this.size = function() { - return array.length; - }; - - /** - * @member ArrayList - * ArrayList.clear() Removes all of the elements from this list. The list will be empty after this call returns. - */ - this.clear = function() { - array.length = 0; - }; - - /** - * @member ArrayList - * ArrayList.remove() Removes the element at the specified position in this list. - * Shifts any subsequent elements to the left (subtracts one from their indices). - * - * @param {int} index the index of the element to removed. - * - * @returns {Object} the element that was removed from the list - */ - this.remove = function(i) { - return array.splice(i, 1)[0]; - }; - - /** - * @member ArrayList - * ArrayList.isEmpty() Tests if this list has no elements. - * - * @returns {boolean} true if this list has no elements; false otherwise - */ - this.isEmpty = function() { - return !array.length; - }; - - /** - * @member ArrayList - * ArrayList.clone() Returns a shallow copy of this ArrayList instance. (The elements themselves are not copied.) - * - * @returns {ArrayList} a clone of this ArrayList instance - */ - this.clone = function() { - return new ArrayList(array.slice(0)); - }; - - /** - * @member ArrayList - * ArrayList.toArray() Returns an array containing all of the elements in this list in the correct order. - * - * @returns {Object[]} Returns an array containing all of the elements in this list in the correct order - */ - this.toArray = function() { - return array.slice(0); - }; - - this.iterator = function() { - return new Iterator(array); - }; - } - - return ArrayList; - }()); - - /** - * A HashMap stores a collection of objects, each referenced by a key. This is similar to an Array, only - * instead of accessing elements with a numeric index, a String is used. (If you are familiar with - * associative arrays from other languages, this is the same idea.) - * - * @param {int} initialCapacity defines the initial capacity of the map, it's 16 by default - * @param {float} loadFactor the load factor for the map, the default is 0.75 - * @param {Map} m gives the new HashMap the same mappings as this Map - */ - var HashMap = (function() { - function virtHashCode(obj) { - if (obj.constructor === String) { - var hash = 0; - for (var i = 0; i < obj.length; ++i) { - hash = (hash * 31 + obj.charCodeAt(i)) & 0xFFFFFFFF; - } - return hash; - } else if (typeof(obj) !== "object") { - return obj & 0xFFFFFFFF; - } else if ("hashCode" in obj) { - return obj.hashCode.call(obj); - } else { - if (obj.$id === undef) { - obj.$id = ((Math.floor(Math.random() * 0x10000) - 0x8000) << 16) | Math.floor(Math.random() * 0x10000); - } - return obj.$id; - } - } - - function virtEquals(obj, other) { - if (obj === null || other === null) { - return (obj === null) && (other === null); - } else if (obj.constructor === String) { - return obj === other; - } else if (typeof(obj) !== "object") { - return obj === other; - } else if ("equals" in obj) { - return obj.equals.call(obj, other); - } else { - return obj === other; - } - } - - /** - * @member HashMap - * A HashMap stores a collection of objects, each referenced by a key. This is similar to an Array, only - * instead of accessing elements with a numeric index, a String is used. (If you are familiar with - * associative arrays from other languages, this is the same idea.) - * - * @param {int} initialCapacity defines the initial capacity of the map, it's 16 by default - * @param {float} loadFactor the load factor for the map, the default is 0.75 - * @param {Map} m gives the new HashMap the same mappings as this Map - */ - function HashMap() { - if (arguments.length === 1 && arguments[0].constructor === HashMap) { - return arguments[0].clone(); - } - - var initialCapacity = arguments.length > 0 ? arguments[0] : 16; - var loadFactor = arguments.length > 1 ? arguments[1] : 0.75; - var buckets = new Array(initialCapacity); - var count = 0; - var hashMap = this; - - function ensureLoad() { - if (count <= loadFactor * buckets.length) { - return; - } - var allEntries = []; - for (var i = 0; i < buckets.length; ++i) { - if (buckets[i] !== undef) { - allEntries = allEntries.concat(buckets[i]); - } - } - buckets = new Array(buckets.length * 2); - for (var j = 0; j < allEntries.length; ++j) { - var index = virtHashCode(allEntries[j].key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - buckets[index] = bucket = []; - } - bucket.push(allEntries[j]); - } - } - - function Iterator(conversion, removeItem) { - var bucketIndex = 0; - var itemIndex = -1; - var endOfBuckets = false; - - function findNext() { - while (!endOfBuckets) { - ++itemIndex; - if (bucketIndex >= buckets.length) { - endOfBuckets = true; - } else if (buckets[bucketIndex] === undef || itemIndex >= buckets[bucketIndex].length) { - itemIndex = -1; - ++bucketIndex; - } else { - return; - } - } - } - - /* - * @member Iterator - * Checks if the Iterator has more items - */ - this.hasNext = function() { - return !endOfBuckets; - }; - - /* - * @member Iterator - * Return the next Item - */ - this.next = function() { - var result = conversion(buckets[bucketIndex][itemIndex]); - findNext(); - return result; - }; - - /* - * @member Iterator - * Remove the current item - */ - this.remove = function() { - removeItem(this.next()); - --itemIndex; - }; - - findNext(); - } - - function Set(conversion, isIn, removeItem) { - this.clear = function() { - hashMap.clear(); - }; - - this.contains = function(o) { - return isIn(o); - }; - - this.containsAll = function(o) { - var it = o.iterator(); - while (it.hasNext()) { - if (!this.contains(it.next())) { - return false; - } - } - return true; - }; - - this.isEmpty = function() { - return hashMap.isEmpty(); - }; - - this.iterator = function() { - return new Iterator(conversion, removeItem); - }; - - this.remove = function(o) { - if (this.contains(o)) { - removeItem(o); - return true; - } - return false; - }; - - this.removeAll = function(c) { - var it = c.iterator(); - var changed = false; - while (it.hasNext()) { - var item = it.next(); - if (this.contains(item)) { - removeItem(item); - changed = true; - } - } - return true; - }; - - this.retainAll = function(c) { - var it = this.iterator(); - var toRemove = []; - while (it.hasNext()) { - var entry = it.next(); - if (!c.contains(entry)) { - toRemove.push(entry); - } - } - for (var i = 0; i < toRemove.length; ++i) { - removeItem(toRemove[i]); - } - return toRemove.length > 0; - }; - - this.size = function() { - return hashMap.size(); - }; - - this.toArray = function() { - var result = new ArrayList(0); - var it = this.iterator(); - while (it.hasNext()) { - result.push(it.next()); - } - return result; - }; - } - - function Entry(pair) { - this._isIn = function(map) { - return map === hashMap && (pair.removed === undef); - }; - - this.equals = function(o) { - return virtEquals(pair.key, o.getKey()); - }; - - this.getKey = function() { - return pair.key; - }; - - this.getValue = function() { - return pair.value; - }; - - this.hashCode = function(o) { - return virtHashCode(pair.key); - }; - - this.setValue = function(value) { - var old = pair.value; - pair.value = value; - return old; - }; - } - - this.clear = function() { - count = 0; - buckets = new Array(initialCapacity); - }; - - this.clone = function() { - var map = new HashMap(); - map.putAll(this); - return map; - }; - - this.containsKey = function(key) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - return false; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - return true; - } - } - return false; - }; - - this.containsValue = function(value) { - for (var i = 0; i < buckets.length; ++i) { - var bucket = buckets[i]; - if (bucket === undef) { - continue; - } - for (var j = 0; j < bucket.length; ++j) { - if (virtEquals(bucket[j].value, value)) { - return true; - } - } - } - return false; - }; - - this.entrySet = function() { - return new Set( - - function(pair) { - return new Entry(pair); - }, - - function(pair) { - return pair.constructor === Entry && pair._isIn(hashMap); - }, - - function(pair) { - return hashMap.remove(pair.getKey()); - }); - }; - - this.get = function(key) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - return null; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - return bucket[i].value; - } - } - return null; - }; - - this.isEmpty = function() { - return count === 0; - }; - - this.keySet = function() { - return new Set( - - function(pair) { - return pair.key; - }, - - function(key) { - return hashMap.containsKey(key); - }, - - function(key) { - return hashMap.remove(key); - }); - }; - - this.put = function(key, value) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - ++count; - buckets[index] = [{ - key: key, - value: value - }]; - ensureLoad(); - return null; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - var previous = bucket[i].value; - bucket[i].value = value; - return previous; - } - } - ++count; - bucket.push({ - key: key, - value: value - }); - ensureLoad(); - return null; - }; - - this.putAll = function(m) { - var it = m.entrySet().iterator(); - while (it.hasNext()) { - var entry = it.next(); - this.put(entry.getKey(), entry.getValue()); - } - }; - - this.remove = function(key) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - return null; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - --count; - var previous = bucket[i].value; - bucket[i].removed = true; - if (bucket.length > 1) { - bucket.splice(i, 1); - } else { - buckets[index] = undef; - } - return previous; - } - } - return null; - }; - - this.size = function() { - return count; - }; - - this.values = function() { - var result = new ArrayList(0); - var it = this.entrySet().iterator(); - while (it.hasNext()) { - var entry = it.next(); - result.push(entry.getValue()); - } - return result; - }; - } - - return HashMap; - }()); - - var PVector = (function() { - function PVector(x, y, z) { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - } - - function createPVectorMethod(method) { - return function(v1, v2) { - var v = v1.get(); - v[method](v2); - return v; - }; - } - - function createSimplePVectorMethod(method) { - return function(v1, v2) { - return v1[method](v2); - }; - } - - var simplePVMethods = "dist dot cross".split(" "); - var method = simplePVMethods.length; - - PVector.angleBetween = function(v1, v2) { - return Math.acos(v1.dot(v2) / (v1.mag() * v2.mag())); - }; - - // Common vector operations for PVector - PVector.prototype = { - set: function(v, y, z) { - if (arguments.length === 1) { - this.set(v.x || v[0], v.y || v[1], v.z || v[2]); - } else { - this.x = v; - this.y = y; - this.z = z; - } - }, - get: function() { - return new PVector(this.x, this.y, this.z); - }, - mag: function() { - return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); - }, - add: function(v, y, z) { - if (arguments.length === 3) { - this.x += v; - this.y += y; - this.z += z; - } else if (arguments.length === 1) { - this.x += v.x; - this.y += v.y; - this.z += v.z; - } - }, - sub: function(v, y, z) { - if (arguments.length === 3) { - this.x -= v; - this.y -= y; - this.z -= z; - } else if (arguments.length === 1) { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z; - } - }, - mult: function(v) { - if (typeof v === 'number') { - this.x *= v; - this.y *= v; - this.z *= v; - } else if (typeof v === 'object') { - this.x *= v.x; - this.y *= v.y; - this.z *= v.z; - } - }, - div: function(v) { - if (typeof v === 'number') { - this.x /= v; - this.y /= v; - this.z /= v; - } else if (typeof v === 'object') { - this.x /= v.x; - this.y /= v.y; - this.z /= v.z; - } - }, - dist: function(v) { - var dx = this.x - v.x, - dy = this.y - v.y, - dz = this.z - v.z; - return Math.sqrt(dx * dx + dy * dy + dz * dz); - }, - dot: function(v, y, z) { - if (arguments.length === 3) { - return (this.x * v + this.y * y + this.z * z); - } else if (arguments.length === 1) { - return (this.x * v.x + this.y * v.y + this.z * v.z); - } - }, - cross: function(v) { - return new PVector(this.y * v.z - v.y * this.z, - this.z * v.x - v.z * this.x, - this.x * v.y - v.x * this.y); - }, - normalize: function() { - var m = this.mag(); - if (m > 0) { - this.div(m); - } - }, - limit: function(high) { - if (this.mag() > high) { - this.normalize(); - this.mult(high); - } - }, - heading2D: function() { - return (-Math.atan2(-this.y, this.x)); - }, - toString: function() { - return "[" + this.x + ", " + this.y + ", " + this.z + "]"; - }, - array: function() { - return [this.x, this.y, this.z]; - } - }; - - while (method--) { - PVector[simplePVMethods[method]] = createSimplePVectorMethod(simplePVMethods[method]); - } - - for (method in PVector.prototype) { - if (PVector.prototype.hasOwnProperty(method) && !PVector.hasOwnProperty(method)) { - PVector[method] = createPVectorMethod(method); - } - } - - return PVector; - }()); - - // Building defaultScope. Changing of the prototype protects - // internal Processing code from the changes in defaultScope - function DefaultScope() {} - DefaultScope.prototype = PConstants; - - var defaultScope = new DefaultScope(); - defaultScope.ArrayList = ArrayList; - defaultScope.HashMap = HashMap; - defaultScope.PVector = PVector; - //defaultScope.PImage = PImage; // TODO - //defaultScope.PShape = PShape; // TODO - //defaultScope.PShapeSVG = PShapeSVG; // TODO - - var Processing = this.Processing = function Processing(curElement, aCode) { - // Previously we allowed calling Processing as a func instead of ctor, but no longer. - if (!(this instanceof Processing)) { - throw("called Processing constructor as if it were a function: missing 'new'."); - } - - // When something new is added to "p." it must also be added to the "names" array. - // The names array contains the names of everything that is inside "p." - var p = this; - - // PJS specific (non-p5) methods and properties to externalize - p.externals = { - canvas: curElement, - context: undef, - sketch: undef, - onblur: function() {}, - onfocus: function() {} - }; - - p.name = 'Processing.js Instance'; // Set Processing defaults / environment variables - p.use3DContext = false; // default '2d' canvas context - - /** - * Confirms if a Processing program is "focused", meaning that it is - * active and will accept input from mouse or keyboard. This variable - * is "true" if it is focused and "false" if not. This variable is - * often used when you want to warn people they need to click on the - * browser before it will work. - */ - p.focused = true; - p.breakShape = false; - - // Glyph path storage for textFonts - p.glyphTable = {}; - - // Global vars for tracking mouse position - p.pmouseX = 0; - p.pmouseY = 0; - p.mouseX = 0; - p.mouseY = 0; - p.mouseButton = 0; - p.mouseScroll = 0; - - // Undefined event handlers to be replaced by user when needed - p.mouseClicked = undef; - p.mouseDragged = undef; - p.mouseMoved = undef; - p.mousePressed = undef; - p.mouseReleased = undef; - p.mouseScrolled = undef; - p.key = undef; - p.keyCode = undef; - p.keyPressed = function(){}; // needed to remove function checks - p.keyReleased = function(){}; - p.keyTyped = function(){}; - p.draw = undef; - p.setup = undef; - - // Remapped vars - p.__mousePressed = false; - p.__keyPressed = false; - p.__frameRate = 0; - - // The current animation frame - p.frameCount = 0; - - // The height/width of the canvas - p.width = curElement.width - 0; - p.height = curElement.height - 0; - - p.defineProperty = function(obj, name, desc) { - if("defineProperty" in Object) { - Object.defineProperty(obj, name, desc); - } else { - if (desc.hasOwnProperty("get")) { - obj.__defineGetter__(name, desc.get); - } - if (desc.hasOwnProperty("set")) { - obj.__defineSetter__(name, desc.set); - } - } - }; - - // "Private" variables used to maintain state - var curContext, - curSketch, - online = true, - doFill = true, - fillStyle = [1.0, 1.0, 1.0, 1.0], - currentFillColor = 0xFFFFFFFF, - isFillDirty = true, - doStroke = true, - strokeStyle = [0.8, 0.8, 0.8, 1.0], - currentStrokeColor = 0xFFFDFDFD, - isStrokeDirty = true, - lineWidth = 1, - loopStarted = false, - doLoop = true, - looping = 0, - curRectMode = PConstants.CORNER, - curEllipseMode = PConstants.CENTER, - normalX = 0, - normalY = 0, - normalZ = 0, - normalMode = PConstants.NORMAL_MODE_AUTO, - inDraw = false, - curFrameRate = 60, - curCursor = PConstants.ARROW, - oldCursor = curElement.style.cursor, - curMsPerFrame = 1, - curShape = PConstants.POLYGON, - curShapeCount = 0, - curvePoints = [], - curTightness = 0, - curveDet = 20, - curveInited = false, - bezDetail = 20, - colorModeA = 255, - colorModeX = 255, - colorModeY = 255, - colorModeZ = 255, - pathOpen = false, - mouseDragging = false, - curColorMode = PConstants.RGB, - curTint = null, - curTextSize = 12, - curTextFont = "Arial", - curTextLeading = 14, - getLoaded = false, - start = new Date().getTime(), - timeSinceLastFPS = start, - framesSinceLastFPS = 0, - textcanvas, - curveBasisMatrix, - curveToBezierMatrix, - curveDrawMatrix, - bezierDrawMatrix, - bezierBasisInverse, - bezierBasisMatrix, - // Keys and Keystrokes - firstCodedDown = true, // first coded key stroke - firstEDGKeyDown = true, // first Enter - Delete Google key stroke - firstEDMKeyDown = true, // first Enter - Delete Mozilla key stroke - firstMKeyDown = true, // first Mozilla key stroke - firstGKeyDown = true, // first Google key stroke - gRefire = false, // Google refire - curContextCache = { attributes: {}, locations: {} }, - // Shaders - programObject3D, - programObject2D, - programObjectUnlitShape, - boxBuffer, - boxNormBuffer, - boxOutlineBuffer, - rectBuffer, - rectNormBuffer, - sphereBuffer, - lineBuffer, - fillBuffer, - fillColorBuffer, - strokeColorBuffer, - pointBuffer, - shapeTexVBO, - canTex, // texture for createGraphics - textTex, // texture for 3d tex - curTexture = {width:0,height:0}, - curTextureMode = PConstants.IMAGE, - usingTexture = false, - textBuffer, - textureBuffer, - indexBuffer, - // Text alignment - horizontalTextAlignment = PConstants.LEFT, - verticalTextAlignment = PConstants.BASELINE, - baselineOffset = 0.2, // percent - tMode = PConstants.MODEL, - // Pixels cache - originalContext, - proxyContext = null, - isContextReplaced = false, - setPixelsCached, - maxPixelsCached = 1000, - codedKeys = [ PConstants.SHIFT, PConstants.CONTROL, PConstants.ALT, PConstants.CAPSLK, PConstants.PGUP, PConstants.PGDN, - PConstants.END, PConstants.HOME, PConstants.LEFT, PConstants.UP, PConstants.RIGHT, PConstants.DOWN, PConstants.NUMLK, - PConstants.INS, PConstants.F1, PConstants.F2, PConstants.F3, PConstants.F4, PConstants.F5, PConstants.F6, PConstants.F7, - PConstants.F8, PConstants.F9, PConstants.F10, PConstants.F11, PConstants.F12 ]; - - // Get padding and border style widths for mouse offsets - var stylePaddingLeft, stylePaddingTop, styleBorderLeft, styleBorderTop; - - if (document.defaultView && document.defaultView.getComputedStyle) { - stylePaddingLeft = parseInt(document.defaultView.getComputedStyle(curElement, null)['paddingLeft'], 10) || 0; - stylePaddingTop = parseInt(document.defaultView.getComputedStyle(curElement, null)['paddingTop'], 10) || 0; - styleBorderLeft = parseInt(document.defaultView.getComputedStyle(curElement, null)['borderLeftWidth'], 10) || 0; - styleBorderTop = parseInt(document.defaultView.getComputedStyle(curElement, null)['borderTopWidth'], 10) || 0; - } - - // User can only have MAX_LIGHTS lights - var lightCount = 0; - - //sphere stuff - var sphereDetailV = 0, - sphereDetailU = 0, - sphereX = [], - sphereY = [], - sphereZ = [], - sinLUT = new Array(PConstants.SINCOS_LENGTH), - cosLUT = new Array(PConstants.SINCOS_LENGTH), - sphereVerts, - sphereNorms; - - // Camera defaults and settings - var cam, - cameraInv, - forwardTransform, - reverseTransform, - modelView, - modelViewInv, - userMatrixStack, - inverseCopy, - projection, - manipulatingCamera = false, - frustumMode = false, - cameraFOV = 60 * (Math.PI / 180), - cameraX = curElement.width / 2, - cameraY = curElement.height / 2, - cameraZ = cameraY / Math.tan(cameraFOV / 2), - cameraNear = cameraZ / 10, - cameraFar = cameraZ * 10, - cameraAspect = curElement.width / curElement.height; - - var vertArray = [], - curveVertArray = [], - curveVertCount = 0, - isCurve = false, - isBezier = false, - firstVert = true; - - //PShape stuff - var curShapeMode = PConstants.CORNER; - - var colors = { - aliceblue: "#f0f8ff", - antiquewhite: "#faebd7", - aqua: "#00ffff", - aquamarine: "#7fffd4", - azure: "#f0ffff", - beige: "#f5f5dc", - bisque: "#ffe4c4", - black: "#000000", - blanchedalmond: "#ffebcd", - blue: "#0000ff", - blueviolet: "#8a2be2", - brown: "#a52a2a", - burlywood: "#deb887", - cadetblue: "#5f9ea0", - chartreuse: "#7fff00", - chocolate: "#d2691e", - coral: "#ff7f50", - cornflowerblue: "#6495ed", - cornsilk: "#fff8dc", - crimson: "#dc143c", - cyan: "#00ffff", - darkblue: "#00008b", - darkcyan: "#008b8b", - darkgoldenrod: "#b8860b", - darkgray: "#a9a9a9", - darkgreen: "#006400", - darkkhaki: "#bdb76b", - darkmagenta: "#8b008b", - darkolivegreen: "#556b2f", - darkorange: "#ff8c00", - darkorchid: "#9932cc", - darkred: "#8b0000", - darksalmon: "#e9967a", - darkseagreen: "#8fbc8f", - darkslateblue: "#483d8b", - darkslategray: "#2f4f4f", - darkturquoise: "#00ced1", - darkviolet: "#9400d3", - deeppink: "#ff1493", - deepskyblue: "#00bfff", - dimgray: "#696969", - dodgerblue: "#1e90ff", - firebrick: "#b22222", - floralwhite: "#fffaf0", - forestgreen: "#228b22", - fuchsia: "#ff00ff", - gainsboro: "#dcdcdc", - ghostwhite: "#f8f8ff", - gold: "#ffd700", - goldenrod: "#daa520", - gray: "#808080", - green: "#008000", - greenyellow: "#adff2f", - honeydew: "#f0fff0", - hotpink: "#ff69b4", - indianred: "#cd5c5c", - indigo: "#4b0082", - ivory: "#fffff0", - khaki: "#f0e68c", - lavender: "#e6e6fa", - lavenderblush: "#fff0f5", - lawngreen: "#7cfc00", - lemonchiffon: "#fffacd", - lightblue: "#add8e6", - lightcoral: "#f08080", - lightcyan: "#e0ffff", - lightgoldenrodyellow: "#fafad2", - lightgrey: "#d3d3d3", - lightgreen: "#90ee90", - lightpink: "#ffb6c1", - lightsalmon: "#ffa07a", - lightseagreen: "#20b2aa", - lightskyblue: "#87cefa", - lightslategray: "#778899", - lightsteelblue: "#b0c4de", - lightyellow: "#ffffe0", - lime: "#00ff00", - limegreen: "#32cd32", - linen: "#faf0e6", - magenta: "#ff00ff", - maroon: "#800000", - mediumaquamarine: "#66cdaa", - mediumblue: "#0000cd", - mediumorchid: "#ba55d3", - mediumpurple: "#9370d8", - mediumseagreen: "#3cb371", - mediumslateblue: "#7b68ee", - mediumspringgreen: "#00fa9a", - mediumturquoise: "#48d1cc", - mediumvioletred: "#c71585", - midnightblue: "#191970", - mintcream: "#f5fffa", - mistyrose: "#ffe4e1", - moccasin: "#ffe4b5", - navajowhite: "#ffdead", - navy: "#000080", - oldlace: "#fdf5e6", - olive: "#808000", - olivedrab: "#6b8e23", - orange: "#ffa500", - orangered: "#ff4500", - orchid: "#da70d6", - palegoldenrod: "#eee8aa", - palegreen: "#98fb98", - paleturquoise: "#afeeee", - palevioletred: "#d87093", - papayawhip: "#ffefd5", - peachpuff: "#ffdab9", - peru: "#cd853f", - pink: "#ffc0cb", - plum: "#dda0dd", - powderblue: "#b0e0e6", - purple: "#800080", - red: "#ff0000", - rosybrown: "#bc8f8f", - royalblue: "#4169e1", - saddlebrown: "#8b4513", - salmon: "#fa8072", - sandybrown: "#f4a460", - seagreen: "#2e8b57", - seashell: "#fff5ee", - sienna: "#a0522d", - silver: "#c0c0c0", - skyblue: "#87ceeb", - slateblue: "#6a5acd", - slategray: "#708090", - snow: "#fffafa", - springgreen: "#00ff7f", - steelblue: "#4682b4", - tan: "#d2b48c", - teal: "#008080", - thistle: "#d8bfd8", - tomato: "#ff6347", - turquoise: "#40e0d0", - violet: "#ee82ee", - wheat: "#f5deb3", - white: "#ffffff", - whitesmoke: "#f5f5f5", - yellow: "#ffff00", - yellowgreen: "#9acd32" - }; - - // Stores states for pushStyle() and popStyle(). - var styleArray = new Array(0); - - // Vertices are specified in a counter-clockwise order - // triangles are in this order: back, front, right, bottom, left, top - var boxVerts = new Float32Array([ - 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, - -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, - -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, - 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, - 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, - -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, - -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, - -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, - -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5]); - - var boxOutlineVerts = new Float32Array([ - 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, - -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, - 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, - -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, - 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, - -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5]); - - var boxNorms = new Float32Array([ - 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, - 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, - 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, - -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, - 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]); - - // These verts are used for the fill and stroke using TRIANGLE_FAN and LINE_LOOP - var rectVerts = new Float32Array([0,0,0, 0,1,0, 1,1,0, 1,0,0]); - - var rectNorms = new Float32Array([0,0,-1, 0,0,-1, 0,0,-1, 0,0,-1]); - - // Vertex shader for points and lines - var vShaderSrcUnlitShape = - "varying vec4 frontColor;" + - - "attribute vec3 aVertex;" + - "attribute vec4 aColor;" + - - "uniform mat4 uView;" + - "uniform mat4 uProjection;" + - - "void main(void) {" + - " frontColor = aColor;" + - " gl_Position = uProjection * uView * vec4(aVertex, 1.0);" + - "}"; - - var fShaderSrcUnlitShape = - "#ifdef GL_ES\n" + - "precision highp float;\n" + - "#endif\n" + - - "varying vec4 frontColor;" + - - "void main(void){" + - " gl_FragColor = frontColor;" + - "}"; - - // Vertex shader for points and lines - var vertexShaderSource2D = - "varying vec4 frontColor;" + - - "attribute vec3 Vertex;" + - "attribute vec2 aTextureCoord;" + - "uniform vec4 color;" + - - "uniform mat4 model;" + - "uniform mat4 view;" + - "uniform mat4 projection;" + - "uniform float pointSize;" + - "varying vec2 vTextureCoord;"+ - - "void main(void) {" + - " gl_PointSize = pointSize;" + - " frontColor = color;" + - " gl_Position = projection * view * model * vec4(Vertex, 1.0);" + - " vTextureCoord = aTextureCoord;" + - "}"; - - var fragmentShaderSource2D = - "#ifdef GL_ES\n" + - "precision highp float;\n" + - "#endif\n" + - - "varying vec4 frontColor;" + - "varying vec2 vTextureCoord;"+ - - "uniform sampler2D uSampler;"+ - "uniform int picktype;"+ - - "void main(void){" + - " if(picktype == 0){"+ - " gl_FragColor = frontColor;" + - " }" + - " else if(picktype == 1){"+ - " float alpha = texture2D(uSampler, vTextureCoord).a;"+ - " gl_FragColor = vec4(frontColor.rgb*alpha, alpha);\n"+ - " }"+ - "}"; - - // Vertex shader for boxes and spheres - var vertexShaderSource3D = - "varying vec4 frontColor;" + - - "attribute vec3 Vertex;" + - "attribute vec3 Normal;" + - "attribute vec4 aColor;" + - "attribute vec2 aTexture;" + - "varying vec2 vTexture;" + - - "uniform vec4 color;" + - - "uniform bool usingMat;" + - "uniform vec3 specular;" + - "uniform vec3 mat_emissive;" + - "uniform vec3 mat_ambient;" + - "uniform vec3 mat_specular;" + - "uniform float shininess;" + - - "uniform mat4 model;" + - "uniform mat4 view;" + - "uniform mat4 projection;" + - "uniform mat4 normalTransform;" + - - "uniform int lightCount;" + - "uniform vec3 falloff;" + - - "struct Light {" + - " bool dummy;" + - " int type;" + - " vec3 color;" + - " vec3 position;" + - " vec3 direction;" + - " float angle;" + - " vec3 halfVector;" + - " float concentration;" + - "};" + - "uniform Light lights[8];" + - - "void AmbientLight( inout vec3 totalAmbient, in vec3 ecPos, in Light light ) {" + - // Get the vector from the light to the vertex - // Get the distance from the current vector to the light position - " float d = length( light.position - ecPos );" + - " float attenuation = 1.0 / ( falloff[0] + ( falloff[1] * d ) + ( falloff[2] * d * d ));" + " totalAmbient += light.color * attenuation;" + - "}" + - - "void DirectionalLight( inout vec3 col, in vec3 ecPos, inout vec3 spec, in vec3 vertNormal, in Light light ) {" + - " float powerfactor = 0.0;" + - " float nDotVP = max(0.0, dot( vertNormal, light.position ));" + - " float nDotVH = max(0.0, dot( vertNormal, normalize( light.position-ecPos )));" + - - " if( nDotVP != 0.0 ){" + - " powerfactor = pow( nDotVH, shininess );" + - " }" + - - " col += light.color * nDotVP;" + - " spec += specular * powerfactor;" + - "}" + - - "void PointLight( inout vec3 col, inout vec3 spec, in vec3 vertNormal, in vec3 ecPos, in vec3 eye, in Light light ) {" + - " float powerfactor;" + - - // Get the vector from the light to the vertex - " vec3 VP = light.position - ecPos;" + - - // Get the distance from the current vector to the light position - " float d = length( VP ); " + - - // Normalize the light ray so it can be used in the dot product operation. - " VP = normalize( VP );" + - - " float attenuation = 1.0 / ( falloff[0] + ( falloff[1] * d ) + ( falloff[2] * d * d ));" + - - " float nDotVP = max( 0.0, dot( vertNormal, VP ));" + - " vec3 halfVector = normalize( VP + eye );" + - " float nDotHV = max( 0.0, dot( vertNormal, halfVector ));" + - - " if( nDotVP == 0.0) {" + - " powerfactor = 0.0;" + - " }" + - " else{" + - " powerfactor = pow( nDotHV, shininess );" + - " }" + - - " spec += specular * powerfactor * attenuation;" + - " col += light.color * nDotVP * attenuation;" + - "}" + - - /* - */ - "void SpotLight( inout vec3 col, inout vec3 spec, in vec3 vertNormal, in vec3 ecPos, in vec3 eye, in Light light ) {" + - " float spotAttenuation;" + - " float powerfactor;" + - - // calculate the vector from the current vertex to the light. - " vec3 VP = light.position - ecPos; " + - " vec3 ldir = normalize( light.direction );" + - - // get the distance from the spotlight and the vertex - " float d = length( VP );" + - " VP = normalize( VP );" + - - " float attenuation = 1.0 / ( falloff[0] + ( falloff[1] * d ) + ( falloff[2] * d * d ) );" + - - // dot product of the vector from vertex to light and light direction. - " float spotDot = dot( VP, ldir );" + - - // if the vertex falls inside the cone - " if( spotDot < cos( light.angle ) ) {" + - " spotAttenuation = pow( spotDot, light.concentration );" + - " }" + - " else{" + - " spotAttenuation = 1.0;" + - " }" + - " attenuation *= spotAttenuation;" + - - " float nDotVP = max( 0.0, dot( vertNormal, VP ));" + - " vec3 halfVector = normalize( VP + eye );" + - " float nDotHV = max( 0.0, dot( vertNormal, halfVector ));" + - - " if( nDotVP == 0.0 ) {" + - " powerfactor = 0.0;" + - " }" + - " else {" + - " powerfactor = pow( nDotHV, shininess );" + - " }" + - - " spec += specular * powerfactor * attenuation;" + - " col += light.color * nDotVP * attenuation;" + - "}" + - - "void main(void) {" + - " vec3 finalAmbient = vec3( 0.0, 0.0, 0.0 );" + - " vec3 finalDiffuse = vec3( 0.0, 0.0, 0.0 );" + - " vec3 finalSpecular = vec3( 0.0, 0.0, 0.0 );" + - - " vec4 col = color;" + - " if(color[0] == -1.0){" + - " col = aColor;" + - " }" + - - " vec3 norm = vec3( normalTransform * vec4( Normal, 0.0 ) );" + - - " vec4 ecPos4 = view * model * vec4(Vertex,1.0);" + - " vec3 ecPos = (vec3(ecPos4))/ecPos4.w;" + - " vec3 eye = vec3( 0.0, 0.0, 1.0 );" + - - // If there were no lights this draw call, just use the - // assigned fill color of the shape and the specular value - " if( lightCount == 0 ) {" + - " frontColor = col + vec4(mat_specular,1.0);" + - " }" + - " else {" + - " for( int i = 0; i < lightCount; i++ ) {" + - " if( lights[i].type == 0 ) {" + - " AmbientLight( finalAmbient, ecPos, lights[i] );" + - " }" + - " else if( lights[i].type == 1 ) {" + - " DirectionalLight( finalDiffuse,ecPos, finalSpecular, norm, lights[i] );" + - " }" + - " else if( lights[i].type == 2 ) {" + - " PointLight( finalDiffuse, finalSpecular, norm, ecPos, eye, lights[i] );" + - " }" + - " else if( lights[i].type == 3 ) {" + - " SpotLight( finalDiffuse, finalSpecular, norm, ecPos, eye, lights[i] );" + - " }" + - " }" + - - " if( usingMat == false ) {" + - " frontColor = vec4( " + - " vec3(col) * finalAmbient +" + - " vec3(col) * finalDiffuse +" + - " vec3(col) * finalSpecular," + - " col[3] );" + - " }" + - " else{" + - " frontColor = vec4( " + - " mat_emissive + " + - " (vec3(col) * mat_ambient * finalAmbient) + " + - " (vec3(col) * finalDiffuse) + " + - " (mat_specular * finalSpecular), " + - " col[3] );" + - " }" + - " }" + - " vTexture.xy = aTexture.xy;" + - " gl_Position = projection * view * model * vec4( Vertex, 1.0 );" + - "}"; - - var fragmentShaderSource3D = - "#ifdef GL_ES\n" + - "precision highp float;\n" + - "#endif\n" + - - "varying vec4 frontColor;" + - - "uniform sampler2D sampler;" + - "uniform bool usingTexture;" + - "varying vec2 vTexture;" + - - // In Processing, when a texture is used, the fill color is ignored - "void main(void){" + - " if(usingTexture){" + - " gl_FragColor = vec4(texture2D(sampler, vTexture.xy));" + - " }"+ - " else{" + - " gl_FragColor = frontColor;" + - " }" + - "}"; - - //////////////////////////////////////////////////////////////////////////// - // 3D Functions - //////////////////////////////////////////////////////////////////////////// - - /* - * Sets a uniform variable in a program object to a particular - * value. Before calling this function, ensure the correct - * program object has been installed as part of the current - * rendering state by calling useProgram. - * - * On some systems, if the variable exists in the shader but isn't used, - * the compiler will optimize it out and this function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {float | Array} varValue either a scalar value or an Array - * - * @returns none - * - * @see uniformi - * @see uniformMatrix - */ - function uniformf(cacheId, programObj, varName, varValue) { - var varLocation = curContextCache.locations[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getUniformLocation(programObj, varName); - curContextCache.locations[cacheId] = varLocation; - } - // the variable won't be found if it was optimized out. - if (varLocation !== -1) { - if (varValue.length === 4) { - curContext.uniform4fv(varLocation, varValue); - } else if (varValue.length === 3) { - curContext.uniform3fv(varLocation, varValue); - } else if (varValue.length === 2) { - curContext.uniform2fv(varLocation, varValue); - } else { - curContext.uniform1f(varLocation, varValue); - } - } - } - - /** - * Sets a uniform int or int array in a program object to a particular - * value. Before calling this function, ensure the correct - * program object has been installed as part of the current - * rendering state. - * - * On some systems, if the variable exists in the shader but isn't used, - * the compiler will optimize it out and this function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {int | Array} varValue either a scalar value or an Array - * - * @returns none - * - * @see uniformf - * @see uniformMatrix - */ - function uniformi(cacheId, programObj, varName, varValue) { - var varLocation = curContextCache.locations[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getUniformLocation(programObj, varName); - curContextCache.locations[cacheId] = varLocation; - } - // the variable won't be found if it was optimized out. - if (varLocation !== -1) { - if (varValue.length === 4) { - curContext.uniform4iv(varLocation, varValue); - } else if (varValue.length === 3) { - curContext.uniform3iv(varLocation, varValue); - } else if (varValue.length === 2) { - curContext.uniform2iv(varLocation, varValue); - } else { - curContext.uniform1i(varLocation, varValue); - } - } - } - - /** - * Binds the VBO, sets the vertex attribute data for the program - * object and enables the attribute. - * - * On some systems, if the attribute exists in the shader but - * isn't used, the compiler will optimize it out and this - * function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {int} size the number of components per vertex attribute - * @param {WebGLBuffer} VBO Vertex Buffer Object - * - * @returns none - * - * @see disableVertexAttribPointer - */ - function vertexAttribPointer(cacheId, programObj, varName, size, VBO) { - var varLocation = curContextCache.attributes[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getAttribLocation(programObj, varName); - curContextCache.attributes[cacheId] = varLocation; - } - if (varLocation !== -1) { - curContext.bindBuffer(curContext.ARRAY_BUFFER, VBO); - curContext.vertexAttribPointer(varLocation, size, curContext.FLOAT, false, 0, 0); - curContext.enableVertexAttribArray(varLocation); - } - } - - /** - * Disables a program object attribute from being sent to WebGL. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName name of the attribute - * - * @returns none - * - * @see vertexAttribPointer - */ - function disableVertexAttribPointer(cacheId, programObj, varName){ - var varLocation = curContextCache.attributes[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getAttribLocation(programObj, varName); - curContextCache.attributes[cacheId] = varLocation; - } - if (varLocation !== -1) { - curContext.disableVertexAttribArray(varLocation); - } - } - - /** - * Sets the value of a uniform matrix variable in a program - * object. Before calling this function, ensure the correct - * program object has been installed as part of the current - * rendering state. - * - * On some systems, if the variable exists in the shader but - * isn't used, the compiler will optimize it out and this - * function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {boolean} transpose must be false - * @param {Array} matrix an array of 4, 9 or 16 values - * - * @returns none - * - * @see uniformi - * @see uniformf - */ - function uniformMatrix(cacheId, programObj, varName, transpose, matrix) { - var varLocation = curContextCache.locations[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getUniformLocation(programObj, varName); - curContextCache.locations[cacheId] = varLocation; - } - // the variable won't be found if it was optimized out. - if (varLocation !== -1) { - if (matrix.length === 16) { - curContext.uniformMatrix4fv(varLocation, transpose, matrix); - } else if (matrix.length === 9) { - curContext.uniformMatrix3fv(varLocation, transpose, matrix); - } else { - curContext.uniformMatrix2fv(varLocation, transpose, matrix); - } - } - } - - var imageModeCorner = function imageModeCorner(x, y, w, h, whAreSizes) { - return { - x: x, - y: y, - w: w, - h: h - }; - }; - var imageModeConvert = imageModeCorner; - - var imageModeCorners = function imageModeCorners(x, y, w, h, whAreSizes) { - return { - x: x, - y: y, - w: whAreSizes ? w : w - x, - h: whAreSizes ? h : h - y - }; - }; - - var imageModeCenter = function imageModeCenter(x, y, w, h, whAreSizes) { - return { - x: x - w / 2, - y: y - h / 2, - w: w, - h: h - }; - }; - - /** - * Creates a WebGL program object. - * - * @param {String} vetexShaderSource - * @param {String} fragmentShaderSource - * - * @returns {WebGLProgram} A program object - */ - var createProgramObject = function(curContext, vetexShaderSource, fragmentShaderSource) { - var vertexShaderObject = curContext.createShader(curContext.VERTEX_SHADER); - curContext.shaderSource(vertexShaderObject, vetexShaderSource); - curContext.compileShader(vertexShaderObject); - if (!curContext.getShaderParameter(vertexShaderObject, curContext.COMPILE_STATUS)) { - throw curContext.getShaderInfoLog(vertexShaderObject); - } - - var fragmentShaderObject = curContext.createShader(curContext.FRAGMENT_SHADER); - curContext.shaderSource(fragmentShaderObject, fragmentShaderSource); - curContext.compileShader(fragmentShaderObject); - if (!curContext.getShaderParameter(fragmentShaderObject, curContext.COMPILE_STATUS)) { - throw curContext.getShaderInfoLog(fragmentShaderObject); - } - - var programObject = curContext.createProgram(); - curContext.attachShader(programObject, vertexShaderObject); - curContext.attachShader(programObject, fragmentShaderObject); - curContext.linkProgram(programObject); - if (!curContext.getProgramParameter(programObject, curContext.LINK_STATUS)) { - throw "Error linking shaders."; - } - - return programObject; - }; - - //////////////////////////////////////////////////////////////////////////// - // Char handling - //////////////////////////////////////////////////////////////////////////// - var charMap = {}; - - var Char = p.Character = function Char(chr) { - if (typeof chr === 'string' && chr.length === 1) { - this.code = chr.charCodeAt(0); - } else { - this.code = NaN; - } - - return (charMap[this.code] === undef) ? charMap[this.code] = this : charMap[this.code]; - }; - - Char.prototype.toString = function() { - return String.fromCharCode(this.code); - }; - - Char.prototype.valueOf = function() { - return this.code; - }; - - /** - * Datatype for storing shapes. Processing can currently load and display SVG (Scalable Vector Graphics) shapes. - * Before a shape is used, it must be loaded with the loadShape() function. The shape() function is used to draw the shape to the display window. - * The PShape object contain a group of methods, linked below, that can operate on the shape data. - *

      The loadShape() method supports SVG files created with Inkscape and Adobe Illustrator. - * It is not a full SVG implementation, but offers some straightforward support for handling vector data. - * - * @param {int} family the shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY - * - * @see #shape() - * @see #loadShape() - * @see #shapeMode() - */ - var PShape = p.PShape = function(family) { - this.family = family || PConstants.GROUP; - this.visible = true; - this.style = true; - this.children = []; - this.nameTable = []; - this.params = []; - this.name = ""; - this.image = null; //type PImage - this.matrix = null; - this.kind = null; - this.close = null; - this.width = null; - this.height = null; - this.parent = null; - - /** - * PShape methods - * missing: findChild(), apply(), contains(), findChild(), getPrimitive(), getParams(), getVertex() , getVertexCount(), - * getVertexCode() , getVertexCodes() , getVertexCodeCount(), getVertexX(), getVertexY(), getVertexZ() - */ - - /** - * @member PShape - * The isVisible() function returns a boolean value "true" if the image is set to be visible, "false" if not. This is modified with the setVisible() parameter. - *

      The visibility of a shape is usually controlled by whatever program created the SVG file. - * For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator. - * - * @return {boolean} returns "true" if the image is set to be visible, "false" if not - */ - this.isVisible = function(){ - return this.visible; - }; - /** - * @member PShape - * The setVisible() function sets the shape to be visible or invisible. This is determined by the value of the visible parameter. - *

      The visibility of a shape is usually controlled by whatever program created the SVG file. - * For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator. - * - * @param {boolean} visible "false" makes the shape invisible and "true" makes it visible - */ - this.setVisible = function (visible){ - this.visible = visible; - }; - /** - * @member PShape - * The disableStyle() function disables the shape's style data and uses Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints. - * Overrides this shape's style information and uses PGraphics styles and colors. Identical to ignoreStyles(true). Also disables styles for all child shapes. - */ - this.disableStyle = function(){ - this.style = false; - for(var i = 0; i < this.children.length; i++) - { - this.children[i].disableStyle(); - } - }; - /** - * @member PShape - * The enableStyle() function enables the shape's style data and ignores Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints. - */ - this.enableStyle = function(){ - this.style = true; - for(var i = 0; i < this.children.length; i++) - { - this.children[i].enableStyle(); - } - }; - /** - * @member PShape - * The getFamily function returns the shape type - * - * @return {int} the shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY - */ - this.getFamily = function(){ - return this.family; - }; - /** - * @member PShape - * The getWidth() function gets the width of the drawing area (not necessarily the shape boundary). - */ - this.getWidth = function(){ - return this.width; - }; - /** - * @member PShape - * The getHeight() function gets the height of the drawing area (not necessarily the shape boundary). - */ - this.getHeight = function(){ - return this.height; - }; - /** - * @member PShape - * The setName() function sets the name of the shape - * - * @param {String} name the name of the shape - */ - this.setName = function(name){ - this.name = name; - }; - /** - * @member PShape - * The getName() function returns the name of the shape - * - * @return {String} the name of the shape - */ - this.getName = function(){ - return this.name; - }; - /** - * @member PShape - * Called by the following (the shape() command adds the g) - * PShape s = loadShapes("blah.svg"); - * shape(s); - */ - this.draw = function(){ - if (this.visible) { - this.pre(); - this.drawImpl(); - this.post(); - } - }; - /** - * @member PShape - * the drawImpl() function draws the SVG document. - */ - this.drawImpl = function(){ - if (this.family === PConstants.GROUP) { - this.drawGroup(); - } else if (this.family === PConstants.PRIMITIVE) { - this.drawPrimitive(); - } else if (this.family === PConstants.GEOMETRY) { - this.drawGeometry(); - } else if (this.family === PConstants.PATH) { - this.drawPath(); - } - }; - /** - * @member PShape - * The drawPath() function draws the part of the SVG document. - */ - this.drawPath = function(){ - if (this.vertices.length === 0) { return; } - - p.beginShape(); - var i; - if (this.vertexCodes.length === 0) { // each point is a simple vertex - if (this.vertices[0].length === 2) { // drawing 2D vertices - for (i = 0; i < this.vertices.length; i++) { - p.vertex(this.vertices[i][0], this.vertices[i][1]); - } - } else { // drawing 3D vertices - for (i = 0; i < this.vertices.length; i++) { - p.vertex(this.vertices[i][0], this.vertices[i][1], this.vertices[i][2]); - } - } - } else { // coded set of vertices - var index = 0; - var j; - if (this.vertices[0].length === 2) { // drawing a 2D path - for (j = 0; j < this.vertexCodes.length; j++) { - switch (this.vertexCodes[j]) { - case PConstants.VERTEX: - p.vertex(this.vertices[index][0], this.vertices[index][1]); - if ( this.vertices[index]["moveTo"] === true) { - vertArray[vertArray.length-1]["moveTo"] = true; - } else if ( this.vertices[index]["moveTo"] === false) { - vertArray[vertArray.length-1]["moveTo"] = false; - } - p.breakShape = false; - index++; - break; - case PConstants.BEZIER_VERTEX: - p.bezierVertex(this.vertices[index+0][0], this.vertices[index+0][1], - this.vertices[index+1][0], this.vertices[index+1][1], - this.vertices[index+2][0], this.vertices[index+2][1]); - index += 3; - break; - case PConstants.CURVE_VERTEX: - p.curveVertex(this.vertices[index][0], this.vertices[index][1]); - index++; - break; - case PConstants.BREAK: - p.breakShape = true; - break; - } - } - } else { // drawing a 3D path - for (j = 0; j < this.vertexCodes.length; j++) { - switch (this.vertexCodes[j]) { - case PConstants.VERTEX: - p.vertex(this.vertices[index][0], this.vertices[index][1], this.vertices[index][2]); - if (this.vertices[index]["moveTo"] === true) { - vertArray[vertArray.length-1]["moveTo"] = true; - } else if (this.vertices[index]["moveTo"] === false) { - vertArray[vertArray.length-1]["moveTo"] = false; - } - p.breakShape = false; - break; - case PConstants.BEZIER_VERTEX: - p.bezierVertex(this.vertices[index+0][0], this.vertices[index+0][1], this.vertices[index+0][2], - this.vertices[index+1][0], this.vertices[index+1][1], this.vertices[index+1][2], - this.vertices[index+2][0], this.vertices[index+2][1], this.vertices[index+2][2]); - index += 3; - break; - case PConstants.CURVE_VERTEX: - p.curveVertex(this.vertices[index][0], this.vertices[index][1], this.vertices[index][2]); - index++; - break; - case PConstants.BREAK: - p.breakShape = true; - break; - } - } - } - } - p.endShape(this.close ? PConstants.CLOSE : PConstants.OPEN); - }; - /** - * @member PShape - * The drawGeometry() function draws the geometry part of the SVG document. - */ - this.drawGeometry = function() { - p.beginShape(this.kind); - var i; - if (this.style) { - for (i = 0; i < this.vertices.length; i++) { - p.vertex(this.vertices[i]); - } - } else { - for (i = 0; i < this.vertices.length; i++) { - var vert = this.vertices[i]; - if (vert[2] === 0) { - p.vertex(vert[0], vert[1]); - } else { - p.vertex(vert[0], vert[1], vert[2]); - } - } - } - p.endShape(); - }; - /** - * @member PShape - * The drawGroup() function draws the part of the SVG document. - */ - this.drawGroup = function() { - for (var i = 0; i < this.children.length; i++) { - this.children[i].draw(); - } - }; - /** - * @member PShape - * The drawPrimitive() function draws SVG document shape elements. These can be point, line, triangle, quad, rect, ellipse, arc, box, or sphere. - */ - this.drawPrimitive = function() { - switch (this.kind) { - case PConstants.POINT: - p.point(this.params[0], this.params[1]); - break; - case PConstants.LINE: - if (this.params.length === 4) { // 2D - p.line(this.params[0], this.params[1], - this.params[2], this.params[3]); - } else { // 3D - p.line(this.params[0], this.params[1], this.params[2], - this.params[3], this.params[4], this.params[5]); - } - break; - case PConstants.TRIANGLE: - p.triangle(this.params[0], this.params[1], - this.params[2], this.params[3], - this.params[4], this.params[5]); - break; - case PConstants.QUAD: - p.quad(this.params[0], this.params[1], - this.params[2], this.params[3], - this.params[4], this.params[5], - this.params[6], this.params[7]); - break; - case PConstants.RECT: - if (this.image !== null) { - p.imageMode(PConstants.CORNER); - p.image(this.image, this.params[0], this.params[1], this.params[2], this.params[3]); - } else { - p.rectMode(PConstants.CORNER); - p.rect(this.params[0], this.params[1], this.params[2], this.params[3]); - } - break; - case PConstants.ELLIPSE: - p.ellipseMode(PConstants.CORNER); - p.ellipse(this.params[0], this.params[1], this.params[2], this.params[3]); - break; - case PConstants.ARC: - p.ellipseMode(PConstants.CORNER); - p.arc(this.params[0], this.params[1], this.params[2], this.params[3], this.params[4], this.params[5]); - break; - case PConstants.BOX: - if (this.params.length === 1) { - p.box(this.params[0]); - } else { - p.box(this.params[0], this.params[1], this.params[2]); - } - break; - case PConstants.SPHERE: - p.sphere(this.params[0]); - break; - } - }; - /** - * @member PShape - * The pre() function performs the preparations before the SVG is drawn. This includes doing transformations and storing previous styles. - */ - this.pre = function() { - if (this.matrix) { - p.pushMatrix(); - curContext.transform(this.matrix.elements[0], this.matrix.elements[3], this.matrix.elements[1], this.matrix.elements[4], this.matrix.elements[2], this.matrix.elements[5]); - //p.applyMatrix(this.matrix.elements[0],this.matrix.elements[0]); - } - if (this.style) { - p.pushStyle(); - this.styles(); - } - }; - /** - * @member PShape - * The post() function performs the necessary actions after the SVG is drawn. This includes removing transformations and removing added styles. - */ - this.post = function() { - if (this.matrix) { - p.popMatrix(); - } - if (this.style) { - p.popStyle(); - } - }; - /** - * @member PShape - * The styles() function changes the Processing's current styles - */ - this.styles = function() { - if (this.stroke) { - p.stroke(this.strokeColor); - p.strokeWeight(this.strokeWeight); - p.strokeCap(this.strokeCap); - p.strokeJoin(this.strokeJoin); - } else { - p.noStroke(); - } - - if (this.fill) { - p.fill(this.fillColor); - - } else { - p.noFill(); - } - }; - /** - * @member PShape - * The getChild() function extracts a child shape from a parent shape. Specify the name of the shape with the target parameter or the - * layer position of the shape to get with the index parameter. - * The shape is returned as a PShape object, or null is returned if there is an error. - * - * @param {String} target the name of the shape to get - * @param {int} index the layer position of the shape to get - * - * @return {PShape} returns a child element of a shape as a PShape object or null if there is an error - */ - this.getChild = function() { - if (typeof arguments[0] === 'number') { - return this.children[arguments[0]]; - } else { - var found, - i; - if(arguments[0] === "" || this.name === arguments[0]){ - return this; - } else { - if(this.nameTable.length > 0) - { - for(i = 0; i < this.nameTable.length || found; i++) - { - if(this.nameTable[i].getName === arguments[0]) { - found = this.nameTable[i]; - } - } - if (found) { return found; } - } - for(i = 0; i < this.children.lenth; i++) - { - found = this.children[i].getChild(arguments[0]); - if(found) { return found; } - } - } - return null; - } - }; - /** - * @member PShape - * The getChildCount() returns the number of children - * - * @return {int} returns a count of children - */ - this.getChildCount = function () { - return this.children.length; - }; - /** - * @member PShape - * The addChild() adds a child to the PShape. - * - * @param {PShape} child the child to add - */ - this.addChild = function( child ) { - this.children.push(child); - child.parent = this; - if (child.getName() !== null) { - this.addName(child.getName(), child); - } - }; - /** - * @member PShape - * The addName() functions adds a shape to the name lookup table. - * - * @param {String} name the name to be added - * @param {PShape} shape the shape - */ - this.addName = function(name, shape) { - if (this.parent !== null) { - this.parent.addName( name, shape ); - } else { - this.nameTable.push( [name, shape] ); - } - }; - /** - * @member PShape - * The translate() function specifies an amount to displace the shape. The x parameter specifies left/right translation, the y parameter specifies up/down translation, and the z parameter specifies translations toward/away from the screen. - * Subsequent calls to the method accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

      Using this method with the z parameter requires using the P3D or OPENGL parameter in combination with size. - * - * @param {int|float} x left/right translation - * @param {int|float} y up/down translation - * @param {int|float} z forward/back translation - * - * @see PMatrix2D#translate - * @see PMatrix3D#translate - */ - this.translate = function() { - if(arguments.length === 2) - { - this.checkMatrix(2); - this.matrix.translate(arguments[0], arguments[1]); - } else { - this.checkMatrix(3); - this.matrix.translate(arguments[0], arguments[1], 0); - } - }; - /** - * @member PShape - * The checkMatrix() function makes sure that the shape's matrix is 1) not null, and 2) has a matrix - * that can handle at least the specified number of dimensions. - * - * @param {int} dimensions the specified number of dimensions - */ - this.checkMatrix = function(dimensions) { - if(this.matrix === null) { - if(dimensions === 2) { - this.matrix = new p.PMatrix2D(); - } else { - this.matrix = new p.PMatrix3D(); - } - }else if(dimensions === 3 && this.matrix instanceof p.PMatrix2D) { - this.matrix = new p.PMatrix3D(); - } - }; - /** - * @member PShape - * The rotateX() function rotates a shape around the x-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

      Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Subsequent calls to the method accumulates the effect. For example, calling rotateX(HALF_PI) and then rotateX(HALF_PI) is the same as rotateX(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

      This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above. - * - * @param {float}angle angle of rotation specified in radians - * - * @see PMatrix3D#rotateX - */ - this.rotateX = function(angle) { - this.rotate(angle, 1, 0, 0); - }; - /** - * @member PShape - * The rotateY() function rotates a shape around the y-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

      Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Subsequent calls to the method accumulates the effect. For example, calling rotateY(HALF_PI) and then rotateY(HALF_PI) is the same as rotateY(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

      This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above. - * - * @param {float}angle angle of rotation specified in radians - * - * @see PMatrix3D#rotateY - */ - this.rotateY = function(angle) { - this.rotate(angle, 0, 1, 0); - }; - /** - * @member PShape - * The rotateZ() function rotates a shape around the z-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

      Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Subsequent calls to the method accumulates the effect. For example, calling rotateZ(HALF_PI) and then rotateZ(HALF_PI) is the same as rotateZ(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

      This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above. - * - * @param {float}angle angle of rotation specified in radians - * - * @see PMatrix3D#rotateZ - */ - this.rotateZ = function(angle) { - this.rotate(angle, 0, 0, 1); - }; - /** - * @member PShape - * The rotate() function rotates a shape the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

      Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Transformations apply to everything that happens after and subsequent calls to the method accumulates the effect. - * For example, calling rotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - * If optional parameters x,y,z are supplied, the rotate is about the point (x, y, z). - * - * @param {float}angle angle of rotation specified in radians - * @param {float}x x-coordinate of the point - * @param {float}y y-coordinate of the point - * @param {float}z z-coordinate of the point - * @see PMatrix2D#rotate - * @see PMatrix3D#rotate - */ - this.rotate = function() { - if(arguments.length === 1){ - this.checkMatrix(2); - this.matrix.rotate(arguments[0]); - } else { - this.checkMatrix(3); - this.matrix.rotate(arguments[0], arguments[1], arguments[2] ,arguments[3]); - } - }; - /** - * @member PShape - * The scale() function increases or decreases the size of a shape by expanding and contracting vertices. Shapes always scale from the relative origin of their bounding box. - * Scale values are specified as decimal percentages. For example, the method call scale(2.0) increases the dimension of a shape by 200%. - * Subsequent calls to the method multiply the effect. For example, calling scale(2.0) and then scale(1.5) is the same as scale(3.0). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

      Using this fuction with the z parameter requires passing P3D or OPENGL into the size() parameter. - * - * @param {float}s percentage to scale the object - * @param {float}x percentage to scale the object in the x-axis - * @param {float}y percentage to scale the object in the y-axis - * @param {float}z percentage to scale the object in the z-axis - * - * @see PMatrix2D#scale - * @see PMatrix3D#scale - */ - this.scale = function() { - if(arguments.length === 2) { - this.checkMatrix(2); - this.matrix.scale(arguments[0], arguments[1]); - } else if (arguments.length === 3) { - this.checkMatrix(2); - this.matrix.scale(arguments[0], arguments[1], arguments[2]); - } else { - this.checkMatrix(2); - this.matrix.scale(arguments[0]); - } - }; - /** - * @member PShape - * The resetMatrix() function resets the matrix - * - * @see PMatrix2D#reset - * @see PMatrix3D#reset - */ - this.resetMatrix = function() { - this.checkMatrix(2); - this.matrix.reset(); - }; - /** - * @member PShape - * The applyMatrix() function multiplies this matrix by another matrix of type PMatrix3D or PMatrix2D. - * Individual elements can also be provided - * - * @param {PMatrix3D|PMatrix2D} matrix the matrix to multiply by - * - * @see PMatrix2D#apply - * @see PMatrix3D#apply - */ - this.applyMatrix = function(matrix) { - if (arguments.length === 1) { - this.applyMatrix(matrix.elements[0], matrix.elements[1], 0, matrix.elements[2], - matrix.elements[3], matrix.elements[4], 0, matrix.elements[5], - 0, 0, 1, 0, - 0, 0, 0, 1); - } else if (arguments.length === 6) { - this.checkMatrix(2); - this.matrix.apply(arguments[0], arguments[1], arguments[2], 0, - arguments[3], arguments[4], arguments[5], 0, - 0, 0, 1, 0, - 0, 0, 0, 1); - - } else if (arguments.length === 16) { - this.checkMatrix(3); - this.matrix.apply(arguments[0], arguments[1], arguments[2], arguments[3], - arguments[4], arguments[5], arguments[6], arguments[7], - arguments[8], arguments[9], arguments[10], arguments[11], - arguments[12], arguments[13], arguments[14], arguments[15]); - } - }; - }; - - /** - * SVG stands for Scalable Vector Graphics, a portable graphics format. It is - * a vector format so it allows for infinite resolution and relatively small - * file sizes. Most modern media software can view SVG files, including Adobe - * products, Firefox, etc. Illustrator and Inkscape can edit SVG files. - * - * @param {PApplet} parent typically use "this" - * @param {String} filename name of the SVG file to load - * @param {XMLElement} xml an XMLElement element - * @param {PShapeSVG} parent the parent PShapeSVG - * - * @see PShape - */ - var PShapeSVG = p.PShapeSVG = function() { - p.PShape.call( this ); // PShape is the base class. - if (arguments.length === 1) { //xml element coming in - this.element = arguments[0] ;//new p.XMLElement(null, arguments[0]); - // set values to their defaults according to the SVG spec - this.vertexCodes = []; - this.vertices = []; - this.opacity = 1; - - this.stroke = false; - this.strokeColor = PConstants.ALPHA_MASK; - this.strokeWeight = 1; - this.strokeCap = PConstants.SQUARE; // equivalent to BUTT in svg spec - this.strokeJoin = PConstants.MITER; - this.strokeGradient = null; - this.strokeGradientPaint = null; - this.strokeName = null; - this.strokeOpacity = 1; - - this.fill = true; - this.fillColor = PConstants.ALPHA_MASK; - this.fillGradient = null; - this.fillGradientPaint = null; - this.fillName = null; - this.fillOpacity = 1; - - if (this.element.getName() !== "svg") { - throw("root is not , it's <" + this.element.getName() + ">"); - } - } - else if (arguments.length === 2) { - if (typeof arguments[1] === 'string') { - if (arguments[1].indexOf(".svg") > -1) { //its a filename - this.element = new p.XMLElement(null, arguments[1]); - // set values to their defaults according to the SVG spec - this.vertexCodes = []; - this.vertices = []; - this.opacity = 1; - - this.stroke = false; - this.strokeColor = PConstants.ALPHA_MASK; - this.strokeWeight = 1; - this.strokeCap = PConstants.SQUARE; // equivalent to BUTT in svg spec - this.strokeJoin = PConstants.MITER; - this.strokeGradient = ""; - this.strokeGradientPaint = ""; - this.strokeName = ""; - this.strokeOpacity = 1; - - this.fill = true; - this.fillColor = PConstants.ALPHA_MASK; - this.fillGradient = null; - this.fillGradientPaint = null; - this.fillOpacity = 1; - - } - } else { // XMLElement - if (arguments[0]) { // PShapeSVG - this.element = arguments[1]; - this.vertexCodes = arguments[0].vertexCodes.slice(); - this.vertices = arguments[0].vertices.slice(); - - this.stroke = arguments[0].stroke; - this.strokeColor = arguments[0].strokeColor; - this.strokeWeight = arguments[0].strokeWeight; - this.strokeCap = arguments[0].strokeCap; - this.strokeJoin = arguments[0].strokeJoin; - this.strokeGradient = arguments[0].strokeGradient; - this.strokeGradientPaint = arguments[0].strokeGradientPaint; - this.strokeName = arguments[0].strokeName; - - this.fill = arguments[0].fill; - this.fillColor = arguments[0].fillColor; - this.fillGradient = arguments[0].fillGradient; - this.fillGradientPaint = arguments[0].fillGradientPaint; - this.fillName = arguments[0].fillName; - this.strokeOpacity = arguments[0].strokeOpacity; - this.fillOpacity = arguments[0].fillOpacity; - this.opacity = arguments[0].opacity; - } - } - } - - this.name = this.element.getStringAttribute("id"); - var displayStr = this.element.getStringAttribute("display", "inline"); - this.visible = displayStr !== "none"; - var str = this.element.getAttribute("transform"); - if (str) { - this.matrix = this.parseMatrix(str); - } - // not proper parsing of the viewBox, but will cover us for cases where - // the width and height of the object is not specified - var viewBoxStr = this.element.getStringAttribute("viewBox"); - if ( viewBoxStr !== null ) { - var viewBox = viewBoxStr.split(" "); - this.width = viewBox[2]; - this.height = viewBox[3]; - } - - // TODO if viewbox is not same as width/height, then use it to scale - // the original objects. for now, viewbox only used when width/height - // are empty values (which by the spec means w/h of "100%" - var unitWidth = this.element.getStringAttribute("width"); - var unitHeight = this.element.getStringAttribute("height"); - if (unitWidth !== null) { - this.width = this.parseUnitSize(unitWidth); - this.height = this.parseUnitSize(unitHeight); - } else { - if ((this.width === 0) || (this.height === 0)) { - // For the spec, the default is 100% and 100%. For purposes - // here, insert a dummy value because this is prolly just a - // font or something for which the w/h doesn't matter. - this.width = 1; - this.height = 1; - - //show warning - throw("The width and/or height is not " + - "readable in the tag of this file."); - } - } - this.parseColors(this.element); - this.parseChildren(this.element); - - }; - /** - * PShapeSVG methods - * missing: getChild(), print(), parseStyleAttributes(), styles() - deals with strokeGradient and fillGradient - */ - PShapeSVG.prototype = { - /** - * @member PShapeSVG - * The parseMatrix() function parses the specified SVG matrix into a PMatrix2D. Note that PMatrix2D - * is rotated relative to the SVG definition, so parameters are rearranged - * here. More about the transformation matrices in - * this section - * of the SVG documentation. - * - * @param {String} str text of the matrix param. - * - * @return {PMatrix2D} a PMatrix2D - */ - parseMatrix: function(str) { - this.checkMatrix(2); - var pieces = []; - str.replace(/\s*(\w+)\((.*?)\)/g, function(all) { - // get a list of transform definitions - pieces.push(p.trim(all)); - }); - if (pieces.length === 0) { - p.println("Transformation:" + str + " is empty"); - return null; - } - for (var i =0; i< pieces.length; i++) { - var m = []; - pieces[i].replace(/\((.*?)\)/, (function() { - return function(all, params) { - // get the coordinates that can be separated by spaces or a comma - m = params.replace(/,+/g, " ").split(/\s+/); - }; - }())); - - if (pieces[i].indexOf("matrix") !== -1) { - this.matrix.set(m[0], m[2], m[4], m[1], m[3], m[5]); - } else if (pieces[i].indexOf("translate") !== -1) { - var tx = m[0]; - var ty = (m.length === 2) ? m[1] : 0; - this.matrix.translate(tx,ty); - } else if (pieces[i].indexOf("scale") !== -1) { - var sx = m[0]; - var sy = (m.length === 2) ? m[1] : m[0]; - this.matrix.scale(sx,sy); - } else if (pieces[i].indexOf("rotate") !== -1) { - var angle = m[0]; - if (m.length === 1) { - this.matrix.rotate(p.radians(angle)); - } else if (m.length === 3) { - this.matrix.translate(m[1], m[2]); - this.matrix.rotate(p.radians(m[0])); - this.matrix.translate(-m[1], -m[2]); - } - } else if (pieces[i].indexOf("skewX") !== -1) { - this.matrix.skewX(parseFloat(m[0])); - } else if (pieces[i].indexOf("skewY") !== -1) { - this.matrix.skewY(m[0]); - } - } - return this.matrix; - }, - /** - * @member PShapeSVG - * The parseChildren() function parses the specified XMLElement - * - * @param {XMLElement}element the XMLElement to parse - */ - parseChildren:function(element) { - var newelement = element.getChildren(); - var children = new p.PShape(); - for (var i = 0; i < newelement.length; i++) { - var kid = this.parseChild(newelement[i]); - if (kid) { - children.addChild(kid); - } - } - this.children.push(children); - }, - /** - * @member PShapeSVG - * The getName() function returns the name - * - * @return {String} the name - */ - getName: function() { - return this.name; - }, - /** - * @member PShapeSVG - * The parseChild() function parses a child XML element. - * - * @param {XMLElement} elem the element to parse - * - * @return {PShape} the newly created PShape - */ - parseChild: function( elem ) { - var name = elem.getName(); - var shape; - switch (name) { - case "g": - shape = new PShapeSVG(this, elem); - break; - case "defs": - // generally this will contain gradient info, so may - // as well just throw it into a group element for parsing - shape = new PShapeSVG(this, elem); - break; - case "line": - shape = new PShapeSVG(this, elem); - shape.parseLine(); - break; - case "circle": - shape = new PShapeSVG(this, elem); - shape.parseEllipse(true); - break; - case "ellipse": - shape = new PShapeSVG(this, elem); - shape.parseEllipse(false); - break; - case "rect": - shape = new PShapeSVG(this, elem); - shape.parseRect(); - break; - case "polygon": - shape = new PShapeSVG(this, elem); - shape.parsePoly(true); - break; - case "polyline": - shape = new PShapeSVG(this, elem); - shape.parsePoly(false); - break; - case "path": - shape = new PShapeSVG(this, elem); - shape.parsePath(); - break; - case "radialGradient": - //return new RadialGradient(this, elem); - break; - case "linearGradient": - //return new LinearGradient(this, elem); - break; - case "text": - p.println("Text in SVG files is not currently supported, convert text to outlines instead." ); - break; - case "filter": - p.println("Filters are not supported."); - break; - case "mask": - p.println("Masks are not supported."); - break; - default: - p.println("Ignoring <" + name + "> tag."); - break; - } - return shape; - }, - /** - * @member PShapeSVG - * The parsePath() function parses the element of the svg file - * A path is defined by including a path element which contains a d="(path data)" attribute, where the d attribute contains - * the moveto, line, curve (both cubic and quadratic Beziers), arc and closepath instructions. - **/ - parsePath: function() { - this.family = PConstants.PATH; - this.kind = 0; - var pathDataChars = []; - var c; - var pathData = p.trim(this.element.getStringAttribute("d").replace(/[\s,]+/g,' ')); //change multiple spaces and commas to single space - if (pathData === null) { return; } - pathData = pathData.toCharArray(); - var cx = 0, - cy = 0, - ctrlX = 0, - ctrlY = 0, - ctrlX1 = 0, - ctrlX2 = 0, - ctrlY1 = 0, - ctrlY2 = 0, - endX = 0, - endY = 0, - ppx = 0, - ppy = 0, - px = 0, - py = 0, - i = 0, - j = 0, - valOf = 0; - var str = ""; - var tmpArray =[]; - var flag = false; - var lastInstruction; - var command; - while (i< pathData.length) { - valOf = pathData[i].valueOf(); - if ((valOf >= 65 && valOf <= 90) || (valOf >= 97 && valOf <= 122)) { // if its a letter - // populate the tmpArray with coordinates - j = i; - i++; - if (i < pathData.length) { // dont go over boundary of array - tmpArray = []; - valOf = pathData[i].valueOf(); - while (!((valOf >= 65 && valOf <= 90) || (valOf >= 97 && valOf <= 100) || (valOf >= 102 && valOf <= 122)) && flag === false) { // if its NOT a letter - if (valOf === 32) { //if its a space and the str isn't empty - // somethimes you get a space after the letter - if (str !== "") { - tmpArray.push(parseFloat(str)); - str = ""; - } - i++; - } else if (valOf === 45) { //if its a - - // allow for 'e' notation in numbers, e.g. 2.10e-9 - if (pathData[i-1].valueOf() === 101) { - str += pathData[i].toString(); - i++; - } else { - // sometimes no space separator after (ex: 104.535-16.322) - if (str !== "") { - tmpArray.push(parseFloat(str)); - } - str = pathData[i].toString(); - i++; - } - } else { - str += pathData[i].toString(); - i++; - } - if (i === pathData.length) { // dont go over boundary of array - flag = true; - } else { - valOf = pathData[i].valueOf(); - } - } - } - if (str !== "") { - tmpArray.push(parseFloat(str)); - str = ""; - } - command = pathData[j]; - switch (command.valueOf()) { - case 77: // M - move to (absolute) - if (tmpArray.length >= 2 && tmpArray.length % 2 ===0) { // need one+ pairs of co-ordinates - cx = tmpArray[0]; - cy = tmpArray[1]; - this.parsePathMoveto(cx, cy); - if (tmpArray.length > 2) { - for (j = 2; j < tmpArray.length; j+=2) { - // absolute line to - cx = tmpArray[j]; - cy = tmpArray[j+1]; - this.parsePathLineto(cx,cy); - } - } - } - break; - case 109: // m - move to (relative) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - cx += tmpArray[0]; - cy += tmpArray[1]; - this.parsePathMoveto(cx,cy); - if (tmpArray.length > 2) { - for (j = 2; j < tmpArray.length; j+=2) { - // relative line to - cx += tmpArray[j]; - cy += tmpArray[j + 1]; - this.parsePathLineto(cx,cy); - } - } - } - break; - case 76: // L - lineto (absolute) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - cx = tmpArray[j]; - cy = tmpArray[j + 1]; - this.parsePathLineto(cx,cy); - } - } - break; - - case 108: // l - lineto (relative) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - cx += tmpArray[j]; - cy += tmpArray[j+1]; - this.parsePathLineto(cx,cy); - } - } - break; - - case 72: // H - horizontal lineto (absolute) - for (j = 0; j < tmpArray.length; j++) { // multiple x co-ordinates can be provided - cx = tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 104: // h - horizontal lineto (relative) - for (j = 0; j < tmpArray.length; j++) { // multiple x co-ordinates can be provided - cx += tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 86: // V - vertical lineto (absolute) - for (j = 0; j < tmpArray.length; j++) { // multiple y co-ordinates can be provided - cy = tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 118: // v - vertical lineto (relative) - for (j = 0; j < tmpArray.length; j++) { // multiple y co-ordinates can be provided - cy += tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 67: // C - curve to (absolute) - if (tmpArray.length >= 6 && tmpArray.length % 6 === 0) { // need one+ multiples of 6 co-ordinates - for (j = 0; j < tmpArray.length; j+=6) { - ctrlX1 = tmpArray[j]; - ctrlY1 = tmpArray[j + 1]; - ctrlX2 = tmpArray[j + 2]; - ctrlY2 = tmpArray[j + 3]; - endX = tmpArray[j + 4]; - endY = tmpArray[j + 5]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 99: // c - curve to (relative) - if (tmpArray.length >= 6 && tmpArray.length % 6 === 0) { // need one+ multiples of 6 co-ordinates - for (j = 0; j < tmpArray.length; j+=6) { - ctrlX1 = cx + tmpArray[j]; - ctrlY1 = cy + tmpArray[j + 1]; - ctrlX2 = cx + tmpArray[j + 2]; - ctrlY2 = cy + tmpArray[j + 3]; - endX = cx + tmpArray[j + 4]; - endY = cy + tmpArray[j + 5]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 83: // S - curve to shorthand (absolute) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - if (lastInstruction.toLowerCase() === "c" || lastInstruction.toLowerCase() === "s") { - ppx = this.vertices[ this.vertices.length-2 ][0]; - ppy = this.vertices[ this.vertices.length-2 ][1]; - px = this.vertices[ this.vertices.length-1 ][0]; - py = this.vertices[ this.vertices.length-1 ][1]; - ctrlX1 = px + (px - ppx); - ctrlY1 = py + (py - ppy); - } else { - //If there is no previous curve, the current point will be used as the first control point. - ctrlX1 = this.vertices[this.vertices.length-1][0]; - ctrlY1 = this.vertices[this.vertices.length-1][1]; - } - ctrlX2 = tmpArray[j]; - ctrlY2 = tmpArray[j + 1]; - endX = tmpArray[j + 2]; - endY = tmpArray[j + 3]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 115: // s - curve to shorthand (relative) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - if (lastInstruction.toLowerCase() === "c" || lastInstruction.toLowerCase() === "s") { - ppx = this.vertices[this.vertices.length-2][0]; - ppy = this.vertices[this.vertices.length-2][1]; - px = this.vertices[this.vertices.length-1][0]; - py = this.vertices[this.vertices.length-1][1]; - ctrlX1 = px + (px - ppx); - ctrlY1 = py + (py - ppy); - } else { - //If there is no previous curve, the current point will be used as the first control point. - ctrlX1 = this.vertices[this.vertices.length-1][0]; - ctrlY1 = this.vertices[this.vertices.length-1][1]; - } - ctrlX2 = cx + tmpArray[j]; - ctrlY2 = cy + tmpArray[j + 1]; - endX = cx + tmpArray[j + 2]; - endY = cy + tmpArray[j + 3]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 81: // Q - quadratic curve to (absolute) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - ctrlX = tmpArray[j]; - ctrlY = tmpArray[j + 1]; - endX = tmpArray[j + 2]; - endY = tmpArray[j + 3]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 113: // q - quadratic curve to (relative) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - ctrlX = cx + tmpArray[j]; - ctrlY = cy + tmpArray[j + 1]; - endX = cx + tmpArray[j + 2]; - endY = cy + tmpArray[j + 3]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 84: // T - quadratic curve to shorthand (absolute) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - if (lastInstruction.toLowerCase() === "q" || lastInstruction.toLowerCase() === "t") { - ppx = this.vertices[this.vertices.length-2][0]; - ppy = this.vertices[this.vertices.length-2][1]; - px = this.vertices[this.vertices.length-1][0]; - py = this.vertices[this.vertices.length-1][1]; - ctrlX = px + (px - ppx); - ctrlY = py + (py - ppy); - } else { - // If there is no previous command or if the previous command was not a Q, q, T or t, - // assume the control point is coincident with the current point. - ctrlX = cx; - ctrlY = cy; - } - endX = tmpArray[j]; - endY = tmpArray[j + 1]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 116: // t - quadratic curve to shorthand (relative) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - if (lastInstruction.toLowerCase() === "q" || lastInstruction.toLowerCase() === "t") { - ppx = this.vertices[this.vertices.length-2][0]; - ppy = this.vertices[this.vertices.length-2][1]; - px = this.vertices[this.vertices.length-1][0]; - py = this.vertices[this.vertices.length-1][1]; - ctrlX = px + (px - ppx); - ctrlY = py + (py - ppy); - } else { - // If there is no previous command or if the previous command was not a Q, q, T or t, - // assume the control point is coincident with the current point. - ctrlX = cx; - ctrlY = cy; - } - endX = cx + tmpArray[j]; - endY = cy + tmpArray[j + 1]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 90: //Z - case 122: //z - this.close = true; - break; - } - lastInstruction = command.toString(); - } else { i++;} - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathQuadto: function(x1, y1, cx, cy, x2, y2) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.BEZIER_VERTEX); - // x1/y1 already covered by last moveto, lineto, or curveto - this.parsePathVertex(x1 + ((cx-x1)*2/3), y1 + ((cy-y1)*2/3)); - this.parsePathVertex(x2 + ((cx-x2)*2/3), y2 + ((cy-y2)*2/3)); - this.parsePathVertex(x2, y2); - } else { - throw ("Path must start with M/m"); - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathCurveto : function(x1, y1, x2, y2, x3, y3) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.BEZIER_VERTEX ); - this.parsePathVertex(x1, y1); - this.parsePathVertex(x2, y2); - this.parsePathVertex(x3, y3); - } else { - throw ("Path must start with M/m"); - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathLineto: function(px, py) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.VERTEX); - this.parsePathVertex(px, py); - // add property to distinguish between curContext.moveTo or curContext.lineTo - this.vertices[this.vertices.length-1]["moveTo"] = false; - } else { - throw ("Path must start with M/m"); - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathMoveto: function(px, py) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.BREAK); - } - this.parsePathCode(PConstants.VERTEX); - this.parsePathVertex(px, py); - // add property to distinguish between curContext.moveTo or curContext.lineTo - this.vertices[this.vertices.length-1]["moveTo"] = true; - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathVertex: function(x, y) { - var verts = []; - verts[0] = x; - verts[1] = y; - this.vertices.push(verts); - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathCode: function(what) { - this.vertexCodes.push(what); - }, - /** - * @member PShapeSVG - * The parsePoly() function parses a polyline or polygon from an SVG file. - * - * @param {boolean}val true if shape is closed (polygon), false if not (polyline) - */ - parsePoly: function(val) { - this.family = PConstants.PATH; - this.close = val; - var pointsAttr = p.trim(this.element.getStringAttribute("points").replace(/[,\s]+/g,' ')); - if (pointsAttr !== null) { - //split into array - var pointsBuffer = pointsAttr.split(" "); - if (pointsBuffer.length % 2 === 0) { - for (var i = 0; i < pointsBuffer.length; i++) { - var verts = []; - verts[0] = pointsBuffer[i]; - verts[1] = pointsBuffer[++i]; - this.vertices.push(verts); - } - } else { - p.println("Error parsing polygon points: odd number of coordinates provided"); - } - } - }, - /** - * @member PShapeSVG - * The parseRect() function parses a rect from an SVG file. - */ - parseRect: function() { - this.kind = PConstants.RECT; - this.family = PConstants.PRIMITIVE; - this.params = []; - this.params[0] = this.element.getFloatAttribute("x"); - this.params[1] = this.element.getFloatAttribute("y"); - this.params[2] = this.element.getFloatAttribute("width"); - this.params[3] = this.element.getFloatAttribute("height"); - if (this.params[2] < 0 || this.params[3] < 0) { - throw("svg error: negative width or height found while parsing "); - } - - }, - /** - * @member PShapeSVG - * The parseEllipse() function handles parsing ellipse and circle tags. - * - * @param {boolean}val true if this is a circle and not an ellipse - */ - parseEllipse: function(val) { - this.kind = PConstants.ELLIPSE; - this.family = PConstants.PRIMITIVE; - this.params = []; - - this.params[0] = this.element.getFloatAttribute("cx") | 0; - this.params[1] = this.element.getFloatAttribute("cy") | 0; - - var rx, ry; - if (val) { //this is a circle - rx = ry = this.element.getFloatAttribute("r"); - if (rx < 0) { - throw("svg error: negative radius found while parsing "); - } - } else { - rx = this.element.getFloatAttribute("rx"); - ry = this.element.getFloatAttribute("ry"); - if (rx < 0 || ry < 0) { - throw("svg error: negative x-axis radius or y-axis radius found while parsing "); - } - } - this.params[0] -= rx; - this.params[1] -= ry; - - this.params[2] = rx*2; - this.params[3] = ry*2; - }, - /** - * @member PShapeSVG - * The parseLine() function handles parsing line tags. - * - * @param {boolean}val true if this is a circle and not an ellipse - */ - parseLine: function() { - this.kind = PConstants.LINE; - this.family = PConstants.PRIMITIVE; - this.params = []; - this.params[0] = this.element.getFloatAttribute("x1"); - this.params[1] = this.element.getFloatAttribute("y1"); - this.params[2] = this.element.getFloatAttribute("x2"); - this.params[3] = this.element.getFloatAttribute("y2"); - }, - /** - * @member PShapeSVG - * The parseColors() function handles parsing the opacity, strijem stroke-width, stroke-linejoin,stroke-linecap, fill, and style attributes - * - * @param {XMLElement}element the element of which attributes to parse - */ - parseColors: function(element) { - if (element.hasAttribute("opacity")) { - this.setOpacity(element.getAttribute("opacity")); - } - if (element.hasAttribute("stroke")) { - this.setStroke(element.getAttribute("stroke")); - } - if (element.hasAttribute("stroke-width")) { - // if NaN (i.e. if it's 'inherit') then default back to the inherit setting - this.setStrokeWeight(element.getAttribute("stroke-width")); - } - if (element.hasAttribute("stroke-linejoin") ) { - this.setStrokeJoin(element.getAttribute("stroke-linejoin")); - } - if (element.hasAttribute("stroke-linecap")) { - this.setStrokeCap(element.getStringAttribute("stroke-linecap")); - } - // fill defaults to black (though stroke defaults to "none") - // http://www.w3.org/TR/SVG/painting.html#FillProperties - if (element.hasAttribute("fill")) { - this.setFill(element.getStringAttribute("fill")); - } - if (element.hasAttribute("style")) { - var styleText = element.getStringAttribute("style"); - var styleTokens = styleText.toString().split( ";" ); - - for (var i = 0; i < styleTokens.length; i++) { - var tokens = p.trim(styleTokens[i].split( ":" )); - switch(tokens[0]){ - case "fill": - this.setFill(tokens[1]); - break; - case "fill-opacity": - this.setFillOpacity(tokens[1]); - break; - case "stroke": - this.setStroke(tokens[1]); - break; - case "stroke-width": - this.setStrokeWeight(tokens[1]); - break; - case "stroke-linecap": - this.setStrokeCap(tokens[1]); - break; - case "stroke-linejoin": - this.setStrokeJoin(tokens[1]); - break; - case "stroke-opacity": - this.setStrokeOpacity(tokens[1]); - break; - case "opacity": - this.setOpacity(tokens[1]); - break; - // Other attributes are not yet implemented - } - } - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} opacityText the value of fillOpacity - * - * @see PShapeSVG#parseColors - */ - setFillOpacity: function(opacityText) { - this.fillOpacity = parseFloat(opacityText); - this.fillColor = this.fillOpacity * 255 << 24 | this.fillColor & 0xFFFFFF; - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} fillText the value of fill - * - * @see PShapeSVG#parseColors - */ - setFill: function (fillText) { - var opacityMask = this.fillColor & 0xFF000000; - if (fillText === "none") { - this.fill = false; - } else if (fillText.indexOf("#") === 0) { - this.fill = true; - if (fillText.length === 4) { - // convert #00F to #0000FF - fillText = fillText.replace(/#(.)(.)(.)/,"#$1$1$2$2$3$3"); - } - this.fillColor = opacityMask | (parseInt(fillText.substring(1), 16)) & 0xFFFFFF; - } else if (fillText.indexOf("rgb") === 0) { - this.fill = true; - this.fillColor = opacityMask | this.parseRGB(fillText); - } else if (fillText.indexOf("url(#") === 0) { - this.fillName = fillText.substring(5, fillText.length - 1 ); - /*Object fillObject = findChild(fillName); - if (fillObject instanceof Gradient) { - fill = true; - fillGradient = (Gradient) fillObject; - fillGradientPaint = calcGradientPaint(fillGradient); //, opacity); - } else { - System.err.println("url " + fillName + " refers to unexpected data"); - }*/ - } else { - if (colors[fillText]) { - this.fill = true; - this.fillColor = opacityMask | (parseInt(colors[fillText].substring(1), 16)) & 0xFFFFFF; - } - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} opacity the value of opacity - * - * @see PShapeSVG#parseColors - */ - setOpacity: function(opacity) { - this.strokeColor = parseFloat(opacity) * 255 << 24 | this.strokeColor & 0xFFFFFF; - this.fillColor = parseFloat(opacity) * 255 << 24 | this.fillColor & 0xFFFFFF; - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} strokeText the value to set stroke to - * - * @see PShapeSVG#parseColors - */ - setStroke: function(strokeText) { - var opacityMask = this.strokeColor & 0xFF000000; - if (strokeText === "none") { - this.stroke = false; - } else if (strokeText.charAt( 0 ) === "#") { - this.stroke = true; - if (strokeText.length === 4) { - // convert #00F to #0000FF - strokeText = strokeText.replace(/#(.)(.)(.)/,"#$1$1$2$2$3$3"); - } - this.strokeColor = opacityMask | (parseInt( strokeText.substring(1), 16)) & 0xFFFFFF; - } else if (strokeText.indexOf( "rgb" ) === 0 ) { - this.stroke = true; - this.strokeColor = opacityMask | this.parseRGB(strokeText); - } else if (strokeText.indexOf( "url(#" ) === 0) { - this.strokeName = strokeText.substring(5, strokeText.length - 1); - //this.strokeObject = findChild(strokeName); - /*if (strokeObject instanceof Gradient) { - strokeGradient = (Gradient) strokeObject; - strokeGradientPaint = calcGradientPaint(strokeGradient); //, opacity); - } else { - System.err.println("url " + strokeName + " refers to unexpected data"); - }*/ - } else { - if (colors[strokeText]){ - this.stroke = true; - this.strokeColor = opacityMask | (parseInt(colors[strokeText].substring(1), 16)) & 0xFFFFFF; - } - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} weight the value to set strokeWeight to - * - * @see PShapeSVG#parseColors - */ - setStrokeWeight: function(weight) { - this.strokeWeight = this.parseUnitSize(weight); - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} linejoin the value to set strokeJoin to - * - * @see PShapeSVG#parseColors - */ - setStrokeJoin: function(linejoin) { - if (linejoin === "miter") { - this.strokeJoin = PConstants.MITER; - - } else if (linejoin === "round") { - this.strokeJoin = PConstants.ROUND; - - } else if (linejoin === "bevel") { - this.strokeJoin = PConstants.BEVEL; - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} linecap the value to set strokeCap to - * - * @see PShapeSVG#parseColors - */ - setStrokeCap: function (linecap) { - if (linecap === "butt") { - this.strokeCap = PConstants.SQUARE; - - } else if (linecap === "round") { - this.strokeCap = PConstants.ROUND; - - } else if (linecap === "square") { - this.strokeCap = PConstants.PROJECT; - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} opacityText the value to set stroke opacity to - * - * @see PShapeSVG#parseColors - */ - setStrokeOpacity: function (opacityText) { - this.strokeOpacity = parseFloat(opacityText); - this.strokeColor = this.strokeOpacity * 255 << 24 | this.strokeColor & 0xFFFFFF; - }, - /** - * @member PShapeSVG - * The parseRGB() function parses an rbg() color string and returns a color int - * - * @param {String} color the color to parse in rbg() format - * - * @return {int} the equivalent color int - */ - parseRGB: function(color) { - var sub = color.substring(color.indexOf('(') + 1, color.indexOf(')')); - var values = sub.split(", "); - return (values[0] << 16) | (values[1] << 8) | (values[2]); - }, - /** - * @member PShapeSVG - * The parseUnitSize() function parse a size that may have a suffix for its units. - * Ignoring cases where this could also be a percentage. - * The units spec: - *
        - *
      • "1pt" equals "1.25px" (and therefore 1.25 user units) - *
      • "1pc" equals "15px" (and therefore 15 user units) - *
      • "1mm" would be "3.543307px" (3.543307 user units) - *
      • "1cm" equals "35.43307px" (and therefore 35.43307 user units) - *
      • "1in" equals "90px" (and therefore 90 user units) - *
      - */ - parseUnitSize: function (text) { - var len = text.length - 2; - if (len < 0) { return text; } - if (text.indexOf("pt") === len) { - return parseFloat(text.substring(0, len)) * 1.25; - } else if (text.indexOf("pc") === len) { - return parseFloat( text.substring( 0, len)) * 15; - } else if (text.indexOf("mm") === len) { - return parseFloat( text.substring(0, len)) * 3.543307; - } else if (text.indexOf("cm") === len) { - return parseFloat(text.substring(0, len)) * 35.43307; - } else if (text.indexOf("in") === len) { - return parseFloat(text.substring(0, len)) * 90; - } else if (text.indexOf("px") === len) { - return parseFloat(text.substring(0, len)); - } else { - return parseFloat(text); - } - } - }; - /** - * The shape() function displays shapes to the screen. - * Processing currently works with SVG shapes only. - * The shape parameter specifies the shape to display and the x - * and y parameters define the location of the shape from its - * upper-left corner. - * The shape is displayed at its original size unless the width - * and height parameters specify a different size. - * The shapeMode() function changes the way the parameters work. - * A call to shapeMode(CORNERS), for example, will change the width - * and height parameters to define the x and y values of the opposite corner - * of the shape. - *

      - * Note complex shapes may draw awkwardly with P2D, P3D, and OPENGL. Those - * renderers do not yet support shapes that have holes or complicated breaks. - * - * @param {PShape} shape the shape to display - * @param {int|float} x x-coordinate of the shape - * @param {int|float} y y-coordinate of the shape - * @param {int|float} width width to display the shape - * @param {int|float} height height to display the shape - * - * @see PShape - * @see loadShape() - * @see shapeMode() - */ - p.shape = function(shape, x, y, width, height) { - if (arguments.length >= 1 && arguments[0] !== null) { - if (shape.isVisible()) { - p.pushMatrix(); - if (curShapeMode === PConstants.CENTER) { - if (arguments.length === 5) { - p.translate(x - width/2, y - height/2); - p.scale(width / shape.getWidth(), height / shape.getHeight()); - } else if (arguments.length === 3) { - p.translate(x - shape.getWidth()/2, - shape.getHeight()/2); - } else { - p.translate(-shape.getWidth()/2, -shape.getHeight()/2); - } - } else if (curShapeMode === PConstants.CORNER) { - if (arguments.length === 5) { - p.translate(x, y); - p.scale(width / shape.getWidth(), height / shape.getHeight()); - } else if (arguments.length === 3) { - p.translate(x, y); - } - } else if (curShapeMode === PConstants.CORNERS) { - if (arguments.length === 5) { - width -= x; - height -= y; - p.translate(x, y); - p.scale(width / shape.getWidth(), height / shape.getHeight()); - } else if (arguments.length === 3) { - p.translate(x, y); - } - } - shape.draw(); - if ((arguments.length === 1 && curShapeMode === PConstants.CENTER ) || arguments.length > 1) { - p.popMatrix(); - } - } - } - }; - - /** - * The shapeMode() function modifies the location from which shapes draw. - * The default mode is shapeMode(CORNER), which specifies the - * location to be the upper left corner of the shape and uses the third - * and fourth parameters of shape() to specify the width and height. - * The syntax shapeMode(CORNERS) uses the first and second parameters - * of shape() to set the location of one corner and uses the third - * and fourth parameters to set the opposite corner. - * The syntax shapeMode(CENTER) draws the shape from its center point - * and uses the third and forth parameters of shape() to specify the - * width and height. - * The parameter must be written in "ALL CAPS" because Processing syntax - * is case sensitive. - * - * @param {int} mode One of CORNER, CORNERS, CENTER - * - * @see shape() - * @see rectMode() - */ - p.shapeMode = function (mode) { - curShapeMode = mode; - }; - - /** - * The loadShape() function loads vector shapes into a variable of type PShape. Currently, only SVG files may be loaded. - * In most cases, loadShape() should be used inside setup() because loading shapes inside draw() will reduce the speed of a sketch. - * - * @param {String} filename an SVG file - * - * @return {PShape} a object of type PShape or null - * @see PShape - * @see PApplet#shape() - * @see PApplet#shapeMode() - */ - p.loadShape = function (filename) { - if (arguments.length === 1) { - if (filename.indexOf(".svg") > -1) { - return new PShapeSVG(null, filename); - } - } - return null; - }; - - /** - * XMLAttribute is an attribute of a XML element. This is an internal class - * - * @param {String} fname the full name of the attribute - * @param {String} n the short name of the attribute - * @param {String} namespace the namespace URI of the attribute - * @param {String} v the value of the attribute - * @param {String }t the type of the attribute - * - * @see XMLElement - */ - var XMLAttribute = function(fname, n, nameSpace, v, t){ - this.fullName = fname || ""; - this.name = n || ""; - this.namespace = nameSpace || ""; - this.value = v; - this.type = t; - }; - /** - * XMLAttribute methods - */ - XMLAttribute.prototype = { - /** - * @member XMLAttribute - * The getName() function returns the short name of the attribute - * - * @return {String} the short name of the attribute - */ - getName: function() { - return this.name; - }, - /** - * @member XMLAttribute - * The getFullName() function returns the full name of the attribute - * - * @return {String} the full name of the attribute - */ - getFullName: function() { - return this.fullName; - }, - /** - * @member XMLAttribute - * The getNamespace() function returns the namespace of the attribute - * - * @return {String} the namespace of the attribute - */ - getNamespace: function() { - return this.namespace; - }, - /** - * @member XMLAttribute - * The getValue() function returns the value of the attribute - * - * @return {String} the value of the attribute - */ - getValue: function() { - return this.value; - }, - /** - * @member XMLAttribute - * The getValue() function returns the type of the attribute - * - * @return {String} the type of the attribute - */ - getType: function() { - return this.type; - }, - /** - * @member XMLAttribute - * The setValue() function sets the value of the attribute - * - * @param {String} newval the new value - */ - setValue: function(newval) { - this.value = newval; - } - }; - - /** - * XMLElement is a representation of an XML object. The object is able to parse XML code - * - * @param {PApplet} parent typically use "this" - * @param {String} filename name of the XML/SVG file to load - * @param {String} xml the xml/svg string - * @param {String} fullname the full name of the element - * @param {String} namespace the namespace of the URI - * @param {String} systemID the system ID of the XML data where the element starts - * @param {Integer }lineNr the line in the XML data where the element starts - */ - var XMLElement = p.XMLElement = function() { - if (arguments.length === 4) { - this.attributes = []; - this.children = []; - this.fullName = arguments[0] || ""; - if (arguments[1]) { - this.name = arguments[1]; - } else { - var index = this.fullName.indexOf(':'); - if (index >= 0) { - this.name = this.fullName.substring(index + 1); - } else { - this.name = this.fullName; - } - } - this.namespace = arguments[1]; - this.content = ""; - this.lineNr = arguments[3]; - this.systemID = arguments[2]; - this.parent = null; - } - else if ((arguments.length === 2 && arguments[1].indexOf(".") > -1) ) { // filename or svg xml element - this.attributes = []; - this.children = []; - this.fullName = ""; - this.name = ""; - this.namespace = ""; - this.content = ""; - this.systemID = ""; - this.lineNr = ""; - this.parent = null; - this.parse(arguments[arguments.length -1]); - } else if (arguments.length === 1 && typeof arguments[0] === "string"){ - //xml string - this.attributes = []; - this.children = []; - this.fullName = ""; - this.name = ""; - this.namespace = ""; - this.content = ""; - this.systemID = ""; - this.lineNr = ""; - this.parent = null; - this.parse(arguments[0]); - } - else { //empty ctor - this.attributes = []; - this.children = []; - this.fullName = ""; - this.name = ""; - this.namespace = ""; - this.content = ""; - this.systemID = ""; - this.lineNr = ""; - this.parent = null; - - } - return this; - }; - /** - * XMLElement methods - * missing: enumerateAttributeNames(), enumerateChildren(), - * NOTE: parse does not work when a url is passed in - */ - XMLElement.prototype = { - /** - * @member XMLElement - * The parse() function retrieves the file via ajax() and uses DOMParser() parseFromString method to make an XML document - * @addon - * - * @param {String} filename name of the XML/SVG file to load - * - * @throws ExceptionType Error loading document - * - * @see XMLElement#parseChildrenRecursive - */ - parse: function(filename) { - var xmlDoc; - try { - if (filename.indexOf(".xml") > -1 || filename.indexOf(".svg") > -1) { - filename = ajax(filename); - } - xmlDoc = new DOMParser().parseFromString(filename, "text/xml"); - var elements = xmlDoc.documentElement; - if (elements) { - this.parseChildrenRecursive(null, elements); - } else { - throw ("Error loading document"); - } - return this; - } catch(e) { - throw(e); - } - }, - /** - * @member XMLElement - * The createElement() function Creates an empty element - * - * @param {String} fullName the full name of the element - * @param {String} namespace the namespace URI - * @param {String} systemID the system ID of the XML data where the element starts - * @param {int} lineNr the line in the XML data where the element starts - */ - createElement: function () { - if (arguments.length === 2) { - return new XMLElement(arguments[0], arguments[1], null, null); - } else { - return new XMLElement(arguments[0], arguments[1], arguments[2], arguments[3]); - } - }, - /** - * @member XMLElement - * The hasAttribute() function returns whether an attribute exists - * - * @param {String} name name of the attribute - * @param {String} namespace the namespace URI of the attribute - * - * @return {boolean} true if the attribute exists - */ - hasAttribute: function () { - if (arguments.length === 1) { - return this.getAttribute(arguments[0]) !== null; - } else if (arguments.length === 2) { - return this.getAttribute(arguments[0],arguments[1]) !== null; - } - }, - /** - * @member XMLElement - * The createPCDataElement() function creates an element to be used for #PCDATA content - * - * @return {XMLElement} new XMLElement element - */ - createPCDataElement: function () { - return new XMLElement(); - }, - /** - * @member XMLElement - * The equals() function checks to see if the element being passed in equals another element - * - * @param {Object} rawElement the element to compare to - * - * @return {boolean} true if the element equals another element - */ - equals: function(object){ - if (typeof object === "Object") { - return this.equalsXMLElement(object); - } - }, - /** - * @member XMLElement - * The equalsXMLElement() function checks to see if the XMLElement being passed in equals another XMLElement - * - * @param {XMLElement} rawElement the element to compare to - * - * @return {boolean} true if the element equals another element - */ - equalsXMLElement: function (object) { - if (object instanceof XMLElement) { - if (this.name !== object.getLocalName()) { return false; } - if (this.attributes.length !== object.getAttributeCount()) { return false; } - for (var i = 0; i < this.attributes.length; i++){ - if (! object.hasAttribute(this.attributes[i].getName(), this.attributes[i].getNamespace())) { return false; } - if (this.attributes[i].getValue() !== object.attributes[i].getValue()) { return false; } - if (this.attributes[i].getType() !== object.attributes[i].getType()) { return false; } - } - if (this.children.length !== object.getChildCount()) { return false; } - var child1, child2; - for (i = 0; i < this.children.length; i++) { - child1 = this.getChildAtIndex(i); - child2 = object.getChildAtIndex(i); - if (! child1.equalsXMLElement(child2)) { return false; } - } - return true; - } - }, - /** - * @member XMLElement - * The getContent() function returns the content of an element. If there is no such content, null is returned - * - * @return {String} the (possibly null) content - */ - getContent: function(){ - return this.content; - }, - /** - * @member XMLElement - * The getAttribute() function returns the value of an attribute - * - * @param {String} name the non-null full name of the attribute - * @param {String} namespace the namespace URI, which may be null - * @param {String} defaultValue the default value of the attribute - * - * @return {String} the value, or defaultValue if the attribute does not exist - */ - getAttribute: function (){ - var attribute; - if( arguments.length === 2 ){ - attribute = this.findAttribute(arguments[0]); - if (attribute) { - return attribute.getValue(); - } else { - return arguments[1]; - } - } else if (arguments.length === 1) { - attribute = this.findAttribute(arguments[0]); - if (attribute) { - return attribute.getValue(); - } else { - return null; - } - } else if (arguments.length === 3) { - attribute = this.findAttribute(arguments[0],arguments[1]); - if (attribute) { - return attribute.getValue(); - } else { - return arguments[2]; - } - } - }, - /** - * @member XMLElement - * The getStringAttribute() function returns the string attribute of the element - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue value is returned. - * When calling the function without the defaultValue parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return {String} the value, or defaultValue if the attribute does not exist - */ - getStringAttribute: function() { - if (arguments.length === 1) { - return this.getAttribute(arguments[0]); - } else if (arguments.length === 2){ - return this.getAttribute(arguments[0], arguments[1]); - } else { - return this.getAttribute(arguments[0], arguments[1],arguments[2]); - } - }, - /** - * @member XMLElement - * The getFloatAttribute() function returns the float attribute of the element. - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue value is returned. - * When calling the function without the defaultValue parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return {float} the value, or defaultValue if the attribute does not exist - */ - getFloatAttribute: function() { - if (arguments.length === 1 ) { - return parseFloat(this.getAttribute(arguments[0], 0)); - } else if (arguments.length === 2 ){ - return this.getAttribute(arguments[0], arguments[1]); - } else { - return this.getAttribute(arguments[0], arguments[1],arguments[2]); - } - }, - /** - * @member XMLElement - * The getIntAttribute() function returns the integer attribute of the element. - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue value is returned. - * When calling the function without the defaultValue parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return {int} the value, or defaultValue if the attribute does not exist - */ - getIntAttribute: function () { - if (arguments.length === 1) { - return this.getAttribute( arguments[0], 0 ); - } else if (arguments.length === 2) { - return this.getAttribute(arguments[0], arguments[1]); - } else { - return this.getAttribute(arguments[0], arguments[1],arguments[2]); - } - }, - /** - * @member XMLElement - * The hasChildren() function returns whether the element has children. - * - * @return {boolean} true if the element has children. - */ - hasChildren: function () { - return this.children.length > 0 ; - }, - /** - * @member XMLElement - * The addChild() function adds a child element - * - * @param {XMLElement} child the non-null child to add. - */ - addChild: function (child) { - if (child !== null) { - child.parent = this; - this.children.push(child); - } - }, - /** - * @member XMLElement - * The insertChild() function inserts a child element at the index provided - * - * @param {XMLElement} child the non-null child to add. - * @param {int} index where to put the child. - */ - insertChild: function (child, index) { - if (child) { - if ((child.getLocalName() === null) && (! this.hasChildren())) { - var lastChild = this.children[this.children.length -1]; - if (lastChild.getLocalName() === null) { - lastChild.setContent(lastChild.getContent() + child.getContent()); - return; - } - } - child.parent = this; - this.children.splice(index,0,child); - } - }, - /** - * @member XMLElement - * The getChild() returns the child XMLElement as specified by the index parameter. - * The value of the index parameter must be less than the total number of children to avoid going out of the array storing the child elements. - * When the path parameter is specified, then it will return all children that match that path. The path is a series of elements and sub-elements, separated by slashes. - * - * @param {int} index where to put the child. - * @param {String} path path to a particular element - * - * @return {XMLElement} the element - */ - getChild: function (){ - if (typeof arguments[0] === "number") { - return this.children[arguments[0]]; - } - else if (arguments[0].indexOf('/') !== -1) { // path was given - this.getChildRecursive(arguments[0].split("/"), 0); - } else { - var kid, kidName; - for (var i = 0; i < this.getChildCount(); i++) { - kid = this.getChild(i); - kidName = kid.getName(); - if (kidName !== null && kidName === arguments[0]) { - return kid; - } - } - return null; - } - }, - /** - * @member XMLElement - * The getChildren() returns all of the children as an XMLElement array. - * When the path parameter is specified, then it will return all children that match that path. - * The path is a series of elements and sub-elements, separated by slashes. - * - * @param {String} path element name or path/to/element - * - * @return {XMLElement} array of child elements that match - * - * @see XMLElement#getChildCount() - * @see XMLElement#getChild() - */ - getChildren: function(){ - if (arguments.length === 1) { - if (typeof arguments[0] === "number") { - return this.getChild( arguments[0]); - } else if (arguments[0].indexOf('/') !== -1) { // path was given - return this.getChildrenRecursive( arguments[0].split("/"), 0); - } else { - var matches = []; - var kid, kidName; - for (var i = 0; i < this.getChildCount(); i++) { - kid = this.getChild(i); - kidName = kid.getName(); - if (kidName !== null && kidName === arguments[0]) { - matches.push(kid); - } - } - return matches; - } - }else { - return this.children; - } - }, - /** - * @member XMLElement - * The getChildCount() returns the number of children for the element. - * - * @return {int} the count - * - * @see XMLElement#getChild() - * @see XMLElement#getChildren() - */ - getChildCount: function(){ - return this.children.length; - }, - /** - * @member XMLElement - * Internal helper function for getChild(). - * - * @param {String[]} items result of splitting the query on slashes - * @param {int} offset where in the items[] array we're currently looking - * - * @return {XMLElement} matching element or null if no match - */ - getChildRecursive: function (items, offset) { - var kid, kidName; - for(var i = 0; i < this.getChildCount(); i++) { - kid = this.getChild(i); - kidName = kid.getName(); - if (kidName !== null && kidName === items[offset]) { - if (offset === items.length-1) { - return kid; - } else { - offset += 1; - return kid.getChildRecursive(items, offset); - } - } - } - return null; - }, - /** - * @member XMLElement - * Internal helper function for getChildren(). - * - * @param {String[]} items result of splitting the query on slashes - * @param {int} offset where in the items[] array we're currently looking - * - * @return {XMLElement[]} matching elements or empty array if no match - */ - getChildrenRecursive: function (items, offset) { - if (offset === items.length-1) { - return this.getChildren(items[offset]); - } - var matches = this.getChildren(items[offset]); - var kidMatches; - for (var i = 0; i < matches.length; i++) { - kidMatches = matches[i].getChildrenRecursive(items, offset+1); - } - return kidMatches; - }, - /** - * @member XMLElement - * Internal helper function for parse(). - * Loops through the - * @addon - * - * @param {XMLElement} parent the parent node - * @param {XML document childNodes} elementpath the remaining nodes that need parsing - * - * @return {XMLElement} the new element and its children elements - */ - parseChildrenRecursive: function (parent , elementpath){ - var xmlelement, - xmlattribute, - tmpattrib; - if (!parent) { - this.fullName = elementpath.localName; - this.name = elementpath.nodeName; - this.content = elementpath.textContent || ""; - xmlelement = this; - } else { // a parent - xmlelement = new XMLElement(elementpath.localName, elementpath.nodeName, "", ""); - xmlelement.content = elementpath.textContent || ""; - xmlelement.parent = parent; - } - - for (var l = 0; l < elementpath.attributes.length; l++) { - tmpattrib = elementpath.attributes[l]; - xmlattribute = new XMLAttribute(tmpattrib.getname , tmpattrib.nodeName, tmpattrib.namespaceURI , tmpattrib.nodeValue , tmpattrib.nodeType); - xmlelement.attributes.push(xmlattribute); - } - - for (var node in elementpath.childNodes){ - if(elementpath.childNodes[node].nodeType === 1) { //ELEMENT_NODE type - xmlelement.children.push( xmlelement.parseChildrenRecursive(xmlelement, elementpath.childNodes[node])); - } - } - return xmlelement; - }, - /** - * @member XMLElement - * The isLeaf() function returns whether the element is a leaf element. - * - * @return {boolean} true if the element has no children. - */ - isLeaf: function(){ - return !this.hasChildren(); - }, - /** - * @member XMLElement - * The listChildren() function put the names of all children into an array. Same as looping through - * each child and calling getName() on each XMLElement. - * - * @return {String[]} a list of element names. - */ - listChildren: function() { - var arr = []; - for (var i = 0; i < this.children.length; i++) { - arr.push( this.getChild(i).getName()); - } - return arr; - }, - /** - * @member XMLElement - * The removeAttribute() function removes an attribute - * - * @param {String} name the non-null name of the attribute. - * @param {String} namespace the namespace URI of the attribute, which may be null. - */ - removeAttribute: function (name , namespace) { - this.namespace = namespace || ""; - for (var i = 0; i < this.attributes.length; i++){ - if (this.attributes[i].getName() === name && this.attributes[i].getNamespace() === this.namespace) { - this.attributes.splice(i, 1); - } - } - }, - /** - * @member XMLElement - * The removeChild() removes a child element. - * - * @param {XMLElement} child the the non-null child to be renoved - */ - removeChild: function(child) { - if (child) { - for (var i = 0; i < this.children.length; i++) { - if (this.children[i].equalsXMLElement(child)) { - this.children.splice(i, 1); - } - } - } - }, - /** - * @member XMLElement - * The removeChildAtIndex() removes the child located at a certain index - * - * @param {int} index the index of the child, where the first child has index 0 - */ - removeChildAtIndex: function(index) { - if (this.children.length > index) { //make sure its not outofbounds - this.children.splice(index, 1); - } - }, - /** - * @member XMLElement - * The findAttribute() function searches an attribute - * - * @param {String} name fullName the non-null full name of the attribute - * @param {String} namespace the name space, which may be null - * - * @return {XMLAttribute} the attribute, or null if the attribute does not exist. - */ - findAttribute: function (name, namespace) { - this.namespace = namespace || ""; - for (var i = 0; i < this.attributes.length; i++ ) { - if (this.attributes[i].getName() === name && this.attributes[i].getNamespace() === this.namespace) { - return this.attributes[i]; - } - } - }, - /** - * @member XMLElement - * The setAttribute() function sets an attribute. - * - * @param {String} name the non-null full name of the attribute - * @param {String} namespace the non-null value of the attribute - */ - setAttribute: function() { - var attr; - if (arguments.length === 3) { - var index = arguments[0].indexOf(':'); - var name = arguments[0].substring(index + 1); - attr = this.findAttribute( name, arguments[1] ); - if (attr) { - attr.setValue(arguments[2]); - } else { - attr = new XMLAttribute(arguments[0], name, arguments[1], arguments[2], "CDATA"); - this.attributes.push(attr); - } - } else { - attr = this.findAttribute(arguments[0]); - if (attr) { - attr.setValue(arguments[1]); - } else { - attr = new XMLAttribute(arguments[0], arguments[0], null, arguments[1], "CDATA"); - this.attributes.push(attr); - } - } - }, - /** - * @member XMLElement - * The setContent() function sets the #PCDATA content. It is an error to call this method with a - * non-null value if there are child objects. - * - * @param {String} content the (possibly null) content - */ - setContent: function(content) { - this.content = content; - }, - /** - * @member XMLElement - * The setName() function sets the full name. This method also sets the short name and clears the - * namespace URI. - * - * @param {String} name the non-null name - * @param {String} namespace the namespace URI, which may be null. - */ - setName: function() { - if (arguments.length === 1) { - this.name = arguments[0]; - this.fullName = arguments[0]; - this.namespace = null; - } else { - var index = arguments[0].indexOf(':'); - if ((arguments[1] === null) || (index < 0)) { - this.name = arguments[0]; - } else { - this.name = arguments[0].substring(index + 1); - } - this.fullName = arguments[0]; - this.namespace = arguments[1]; - } - }, - /** - * @member XMLElement - * The getName() function returns the full name (i.e. the name including an eventual namespace - * prefix) of the element. - * - * @return {String} the name, or null if the element only contains #PCDATA. - */ - getName: function() { - return this.fullName; - }, - getLocalName: function() { - return this.name; - }, - getAttributeCount: function() { - return this.attributes.length; - } - }; - - - //////////////////////////////////////////////////////////////////////////// - // 2D Matrix - //////////////////////////////////////////////////////////////////////////// - /** - * Helper function for printMatrix(). Finds the largest scalar - * in the matrix, then number of digits left of the decimal. - * Call from PMatrix2D and PMatrix3D's print() function. - */ - var printMatrixHelper = function printMatrixHelper(elements) { - var big = 0; - for (var i = 0; i < elements.length; i++) { - if (i !== 0) { - big = Math.max(big, Math.abs(elements[i])); - } else { - big = Math.abs(elements[i]); - } - } - - var digits = (big + "").indexOf("."); - if (digits === 0) { - digits = 1; - } else if (digits === -1) { - digits = (big + "").length; - } - - return digits; - }; - /** - * PMatrix2D is a 3x2 affine matrix implementation. The constructor accepts another PMatrix2D or a list of six float elements. - * If no parameters are provided the matrix is set to the identity matrix. - * - * @param {PMatrix2D} matrix the initial matrix to set to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fifth element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - var PMatrix2D = p.PMatrix2D = function() { - if (arguments.length === 0) { - this.reset(); - } else if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - this.set(arguments[0].array()); - } else if (arguments.length === 6) { - this.set(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); - } - }; - /** - * PMatrix2D methods - */ - PMatrix2D.prototype = { - /** - * @member PMatrix2D - * The set() function sets the matrix elements. The function accepts either another PMatrix2D, an array of elements, or a list of six floats. - * - * @param {PMatrix2D} matrix the matrix to set this matrix to - * @param {float[]} elements an array of elements to set this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fith element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - set: function() { - if (arguments.length === 6) { - var a = arguments; - this.set([a[0], a[1], a[2], - a[3], a[4], a[5]]); - } else if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - this.elements = arguments[0].array(); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - this.elements = arguments[0].slice(); - } - }, - /** - * @member PMatrix2D - * The get() function returns a copy of this PMatrix2D. - * - * @return {PMatrix2D} a copy of this PMatrix2D - */ - get: function() { - var outgoing = new PMatrix2D(); - outgoing.set(this.elements); - return outgoing; - }, - /** - * @member PMatrix2D - * The reset() function sets this PMatrix2D to the identity matrix. - */ - reset: function() { - this.set([1, 0, 0, 0, 1, 0]); - }, - /** - * @member PMatrix2D - * The array() function returns a copy of the element values. - * @addon - * - * @return {float[]} returns a copy of the element values - */ - array: function array() { - return this.elements.slice(); - }, - /** - * @member PMatrix2D - * The translate() function translates this matrix by moving the current coordinates to the location specified by tx and ty. - * - * @param {float} tx the x-axis coordinate to move to - * @param {float} ty the y-axis coordinate to move to - */ - translate: function(tx, ty) { - this.elements[2] = tx * this.elements[0] + ty * this.elements[1] + this.elements[2]; - this.elements[5] = tx * this.elements[3] + ty * this.elements[4] + this.elements[5]; - }, - /** - * @member PMatrix2D - * The transpose() function is not used in processingjs. - */ - transpose: function() { - // Does nothing in Processing. - }, - /** - * @member PMatrix2D - * The mult() function multiplied this matrix. - * If two array elements are passed in the function will multiply a two element vector against this matrix. - * If target is null or not length four, a new float array will be returned. - * The values for vec and target can be the same (though that's less efficient). - * If two PVectors are passed in the function multiply the x and y coordinates of a PVector against this matrix. - * - * @param {PVector} source, target the PVectors used to multiply this matrix - * @param {float[]} source, target the arrays used to multiply this matrix - * - * @return {PVector|float[]} returns a PVector or an array representing the new matrix - */ - mult: function(source, target) { - var x, y; - if (source instanceof PVector) { - x = source.x; - y = source.y; - if (!target) { - target = new PVector(); - } - } else if (source instanceof Array) { - x = source[0]; - y = source[1]; - if (!target) { - target = []; - } - } - if (target instanceof Array) { - target[0] = this.elements[0] * x + this.elements[1] * y + this.elements[2]; - target[1] = this.elements[3] * x + this.elements[4] * y + this.elements[5]; - } else if (target instanceof PVector) { - target.x = this.elements[0] * x + this.elements[1] * y + this.elements[2]; - target.y = this.elements[3] * x + this.elements[4] * y + this.elements[5]; - target.z = 0; - } - return target; - }, - /** - * @member PMatrix2D - * The multX() function calculates the x component of a vector from a transformation. - * - * @param {float} x the x component of the vector being transformed - * @param {float} y the y component of the vector being transformed - * - * @return {float} returnes the result of the calculation - */ - multX: function(x, y) { - return (x * this.elements[0] + y * this.elements[1] + this.elements[2]); - }, - /** - * @member PMatrix2D - * The multY() function calculates the y component of a vector from a transformation. - * - * @param {float} x the x component of the vector being transformed - * @param {float} y the y component of the vector being transformed - * - * @return {float} returnes the result of the calculation - */ - multY: function(x, y) { - return (x * this.elements[3] + y * this.elements[4] + this.elements[5]); - }, - /** - * @member PMatrix2D - * The skewX() function skews the matrix along the x-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewX: function(angle) { - this.apply(1, 0, 1, angle, 0, 0); - }, - /** - * @member PMatrix2D - * The skewY() function skews the matrix along the y-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewY: function(angle) { - this.apply(1, 0, 1, 0, angle, 0); - }, - /** - * @member PMatrix2D - * The determinant() function calvculates the determinant of this matrix. - * - * @return {float} the determinant of the matrix - */ - determinant: function() { - return (this.elements[0] * this.elements[4] - this.elements[1] * this.elements[3]); - }, - /** - * @member PMatrix2D - * The invert() function inverts this matrix - * - * @return {boolean} true if successful - */ - invert: function() { - var d = this.determinant(); - if (Math.abs( d ) > PConstants.MIN_INT) { - var old00 = this.elements[0]; - var old01 = this.elements[1]; - var old02 = this.elements[2]; - var old10 = this.elements[3]; - var old11 = this.elements[4]; - var old12 = this.elements[5]; - this.elements[0] = old11 / d; - this.elements[3] = -old10 / d; - this.elements[1] = -old01 / d; - this.elements[4] = old00 / d; - this.elements[2] = (old01 * old12 - old11 * old02) / d; - this.elements[5] = (old10 * old02 - old00 * old12) / d; - return true; - } - return false; - }, - /** - * @member PMatrix2D - * The scale() function increases or decreases the size of a shape by expanding and contracting vertices. When only one parameter is specified scale will occur in all dimensions. - * This is equivalent to a two parameter call. - * - * @param {float} sx the amount to scale on the x-axis - * @param {float} sy the amount to scale on the y-axis - */ - scale: function(sx, sy) { - if (sx && !sy) { - sy = sx; - } - if (sx && sy) { - this.elements[0] *= sx; - this.elements[1] *= sy; - this.elements[3] *= sx; - this.elements[4] *= sy; - } - }, - /** - * @member PMatrix2D - * The apply() function multiplies the current matrix by the one specified through the parameters. Note that either a PMatrix2D or a list of floats can be passed in. - * - * @param {PMatrix2D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fith element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - apply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - source = arguments[0].array(); - } else if (arguments.length === 6) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - - var result = [0, 0, this.elements[2], - 0, 0, this.elements[5]]; - var e = 0; - for (var row = 0; row < 2; row++) { - for (var col = 0; col < 3; col++, e++) { - result[e] += this.elements[row * 3 + 0] * source[col + 0] + - this.elements[row * 3 + 1] * source[col + 3]; - } - } - this.elements = result.slice(); - }, - /** - * @member PMatrix2D - * The preApply() function applies another matrix to the left of this one. Note that either a PMatrix2D or elements of a matrix can be passed in. - * - * @param {PMatrix2D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fith element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - preApply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - source = arguments[0].array(); - } else if (arguments.length === 6) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - var result = [0, 0, source[2], - 0, 0, source[5]]; - result[2] = source[2] + this.elements[2] * source[0] + this.elements[5] * source[1]; - result[5] = source[5] + this.elements[2] * source[3] + this.elements[5] * source[4]; - result[0] = this.elements[0] * source[0] + this.elements[3] * source[1]; - result[3] = this.elements[0] * source[3] + this.elements[3] * source[4]; - result[1] = this.elements[1] * source[0] + this.elements[4] * source[1]; - result[4] = this.elements[1] * source[3] + this.elements[4] * source[4]; - this.elements = result.slice(); - }, - /** - * @member PMatrix2D - * The rotate() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotate: function(angle) { - var c = Math.cos(angle); - var s = Math.sin(angle); - var temp1 = this.elements[0]; - var temp2 = this.elements[1]; - this.elements[0] = c * temp1 + s * temp2; - this.elements[1] = -s * temp1 + c * temp2; - temp1 = this.elements[3]; - temp2 = this.elements[4]; - this.elements[3] = c * temp1 + s * temp2; - this.elements[4] = -s * temp1 + c * temp2; - }, - /** - * @member PMatrix2D - * The rotateZ() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateZ: function(angle) { - this.rotate(angle); - }, - /** - * @member PMatrix2D - * The print() function prints out the elements of this matrix - */ - print: function() { - var digits = printMatrixHelper(this.elements); - var output = "" + p.nfs(this.elements[0], digits, 4) + " " + - p.nfs(this.elements[1], digits, 4) + " " + - p.nfs(this.elements[2], digits, 4) + "\n" + - p.nfs(this.elements[3], digits, 4) + " " + - p.nfs(this.elements[4], digits, 4) + " " + - p.nfs(this.elements[5], digits, 4) + "\n\n"; - p.println(output); - } - }; - - /** - * PMatrix3D is a 4x4 matrix implementation. The constructor accepts another PMatrix3D or a list of six or sixteen float elements. - * If no parameters are provided the matrix is set to the identity matrix. - */ - var PMatrix3D = p.PMatrix3D = function PMatrix3D() { - // When a matrix is created, it is set to an identity matrix - this.reset(); - }; - /** - * PMatrix3D methods - */ - PMatrix3D.prototype = { - /** - * @member PMatrix2D - * The set() function sets the matrix elements. The function accepts either another PMatrix3D, an array of elements, or a list of six or sixteen floats. - * - * @param {PMatrix3D} matrix the initial matrix to set to - * @param {float[]} elements an array of elements to set this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - */ - set: function() { - if (arguments.length === 16) { - this.elements = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof PMatrix3D) { - this.elements = arguments[0].array(); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - this.elements = arguments[0].slice(); - } - }, - /** - * @member PMatrix3D - * The get() function returns a copy of this PMatrix3D. - * - * @return {PMatrix3D} a copy of this PMatrix3D - */ - get: function() { - var outgoing = new PMatrix3D(); - outgoing.set(this.elements); - return outgoing; - }, - /** - * @member PMatrix3D - * The reset() function sets this PMatrix3D to the identity matrix. - */ - reset: function() { - this.set([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The array() function returns a copy of the element values. - * @addon - * - * @return {float[]} returns a copy of the element values - */ - array: function array() { - return this.elements.slice(); - }, - /** - * @member PMatrix3D - * The translate() function translates this matrix by moving the current coordinates to the location specified by tx, ty, and tz. - * - * @param {float} tx the x-axis coordinate to move to - * @param {float} ty the y-axis coordinate to move to - * @param {float} tz the z-axis coordinate to move to - */ - translate: function(tx, ty, tz) { - if (tz === undef) { - tz = 0; - } - - this.elements[3] += tx * this.elements[0] + ty * this.elements[1] + tz * this.elements[2]; - this.elements[7] += tx * this.elements[4] + ty * this.elements[5] + tz * this.elements[6]; - this.elements[11] += tx * this.elements[8] + ty * this.elements[9] + tz * this.elements[10]; - this.elements[15] += tx * this.elements[12] + ty * this.elements[13] + tz * this.elements[14]; - }, - /** - * @member PMatrix2D - * The transpose() function transpose this matrix. - */ - transpose: function() { - var temp = this.elements.slice(); - this.elements[0] = temp[0]; - this.elements[1] = temp[4]; - this.elements[2] = temp[8]; - this.elements[3] = temp[12]; - this.elements[4] = temp[1]; - this.elements[5] = temp[5]; - this.elements[6] = temp[9]; - this.elements[7] = temp[13]; - this.elements[8] = temp[2]; - this.elements[9] = temp[6]; - this.elements[10] = temp[10]; - this.elements[11] = temp[14]; - this.elements[12] = temp[3]; - this.elements[13] = temp[7]; - this.elements[14] = temp[11]; - this.elements[15] = temp[15]; - }, - /** - * @member PMatrix3D - * The mult() function multiplied this matrix. - * If two array elements are passed in the function will multiply a two element vector against this matrix. - * If target is null or not length four, a new float array will be returned. - * The values for vec and target can be the same (though that's less efficient). - * If two PVectors are passed in the function multiply the x and y coordinates of a PVector against this matrix. - * - * @param {PVector} source, target the PVectors used to multiply this matrix - * @param {float[]} source, target the arrays used to multiply this matrix - * - * @return {PVector|float[]} returns a PVector or an array representing the new matrix - */ - mult: function(source, target) { - var x, y, z, w; - if (source instanceof PVector) { - x = source.x; - y = source.y; - z = source.z; - w = 1; - if (!target) { - target = new PVector(); - } - } else if (source instanceof Array) { - x = source[0]; - y = source[1]; - z = source[2]; - w = source[3] || 1; - - if (!target || target.length !== 3 && target.length !== 4) { - target = [0, 0, 0]; - } - } - - if (target instanceof Array) { - if (target.length === 3) { - target[0] = this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3]; - target[1] = this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7]; - target[2] = this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11]; - } else if (target.length === 4) { - target[0] = this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3] * w; - target[1] = this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7] * w; - target[2] = this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11] * w; - target[3] = this.elements[12] * x + this.elements[13] * y + this.elements[14] * z + this.elements[15] * w; - } - } - if (target instanceof PVector) { - target.x = this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3]; - target.y = this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7]; - target.z = this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11]; - } - return target; - }, - /** - * @member PMatrix3D - * The preApply() function applies another matrix to the left of this one. Note that either a PMatrix3D or elements of a matrix can be passed in. - * - * @param {PMatrix3D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - */ - preApply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix3D) { - source = arguments[0].array(); - } else if (arguments.length === 16) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - - var result = [0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0]; - var e = 0; - for (var row = 0; row < 4; row++) { - for (var col = 0; col < 4; col++, e++) { - result[e] += this.elements[col + 0] * source[row * 4 + 0] + this.elements[col + 4] * - source[row * 4 + 1] + this.elements[col + 8] * source[row * 4 + 2] + - this.elements[col + 12] * source[row * 4 + 3]; - } - } - this.elements = result.slice(); - }, - /** - * @member PMatrix3D - * The apply() function multiplies the current matrix by the one specified through the parameters. Note that either a PMatrix3D or a list of floats can be passed in. - * - * @param {PMatrix3D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - */ - apply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix3D) { - source = arguments[0].array(); - } else if (arguments.length === 16) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - - var result = [0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0]; - var e = 0; - for (var row = 0; row < 4; row++) { - for (var col = 0; col < 4; col++, e++) { - result[e] += this.elements[row * 4 + 0] * source[col + 0] + this.elements[row * 4 + 1] * - source[col + 4] + this.elements[row * 4 + 2] * source[col + 8] + - this.elements[row * 4 + 3] * source[col + 12]; - } - } - this.elements = result.slice(); - }, - /** - * @member PMatrix3D - * The rotate() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotate: function(angle, v0, v1, v2) { - if (!v1) { - this.rotateZ(angle); - } else { - // TODO should make sure this vector is normalized - var c = p.cos(angle); - var s = p.sin(angle); - var t = 1.0 - c; - - this.apply((t * v0 * v0) + c, - (t * v0 * v1) - (s * v2), - (t * v0 * v2) + (s * v1), - 0, - (t * v0 * v1) + (s * v2), - (t * v1 * v1) + c, - (t * v1 * v2) - (s * v0), - 0, - (t * v0 * v2) - (s * v1), - (t * v1 * v2) + (s * v0), - (t * v2 * v2) + c, - 0, 0, 0, 0, 1); - } - }, - /** - * @member PMatrix2D - * The invApply() function applies the inverted matrix to this matrix. - * - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - * - * @return {boolean} returns true if the operation was successful. - */ - invApply: function() { - if (inverseCopy === undef) { - inverseCopy = new PMatrix3D(); - } - var a = arguments; - inverseCopy.set(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], - a[9], a[10], a[11], a[12], a[13], a[14], a[15]); - - if (!inverseCopy.invert()) { - return false; - } - this.preApply(inverseCopy); - return true; - }, - /** - * @member PMatrix3D - * The rotateZ() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateX: function(angle) { - var c = p.cos(angle); - var s = p.sin(angle); - this.apply([1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The rotateY() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateY: function(angle) { - var c = p.cos(angle); - var s = p.sin(angle); - this.apply([c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The rotateZ() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateZ: function(angle) { - var c = Math.cos(angle); - var s = Math.sin(angle); - this.apply([c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The scale() function increases or decreases the size of a matrix by expanding and contracting vertices. When only one parameter is specified scale will occur in all dimensions. - * This is equivalent to a three parameter call. - * - * @param {float} sx the amount to scale on the x-axis - * @param {float} sy the amount to scale on the y-axis - * @param {float} sz the amount to scale on the z-axis - */ - scale: function(sx, sy, sz) { - if (sx && !sy && !sz) { - sy = sz = sx; - } else if (sx && sy && !sz) { - sz = 1; - } - - if (sx && sy && sz) { - this.elements[0] *= sx; - this.elements[1] *= sy; - this.elements[2] *= sz; - this.elements[4] *= sx; - this.elements[5] *= sy; - this.elements[6] *= sz; - this.elements[8] *= sx; - this.elements[9] *= sy; - this.elements[10] *= sz; - this.elements[12] *= sx; - this.elements[13] *= sy; - this.elements[14] *= sz; - } - }, - /** - * @member PMatrix3D - * The skewX() function skews the matrix along the x-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewX: function(angle) { - var t = Math.tan(angle); - this.apply(1, t, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); - }, - /** - * @member PMatrix3D - * The skewY() function skews the matrix along the y-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewY: function(angle) { - var t = Math.tan(angle); - this.apply(1, 0, 0, 0, t, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); - }, - multX: function(x, y, z, w) { - if (!z) { - return this.elements[0] * x + this.elements[1] * y + this.elements[3]; - } else if (!w) { - return this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3]; - } else { - return this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3] * w; - } - }, - multY: function(x, y, z, w) { - if (!z) { - return this.elements[4] * x + this.elements[5] * y + this.elements[7]; - } else if (!w) { - return this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7]; - } else { - return this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7] * w; - } - }, - multZ: function(x, y, z, w) { - if (!w) { - return this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11]; - } else { - return this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11] * w; - } - }, - multW: function(x, y, z, w) { - if (!w) { - return this.elements[12] * x + this.elements[13] * y + this.elements[14] * z + this.elements[15]; - } else { - return this.elements[12] * x + this.elements[13] * y + this.elements[14] * z + this.elements[15] * w; - } - }, - /** - * @member PMatrix3D - * The invert() function inverts this matrix - * - * @return {boolean} true if successful - */ - invert: function() { - var fA0 = this.elements[0] * this.elements[5] - this.elements[1] * this.elements[4]; - var fA1 = this.elements[0] * this.elements[6] - this.elements[2] * this.elements[4]; - var fA2 = this.elements[0] * this.elements[7] - this.elements[3] * this.elements[4]; - var fA3 = this.elements[1] * this.elements[6] - this.elements[2] * this.elements[5]; - var fA4 = this.elements[1] * this.elements[7] - this.elements[3] * this.elements[5]; - var fA5 = this.elements[2] * this.elements[7] - this.elements[3] * this.elements[6]; - var fB0 = this.elements[8] * this.elements[13] - this.elements[9] * this.elements[12]; - var fB1 = this.elements[8] * this.elements[14] - this.elements[10] * this.elements[12]; - var fB2 = this.elements[8] * this.elements[15] - this.elements[11] * this.elements[12]; - var fB3 = this.elements[9] * this.elements[14] - this.elements[10] * this.elements[13]; - var fB4 = this.elements[9] * this.elements[15] - this.elements[11] * this.elements[13]; - var fB5 = this.elements[10] * this.elements[15] - this.elements[11] * this.elements[14]; - - // Determinant - var fDet = fA0 * fB5 - fA1 * fB4 + fA2 * fB3 + fA3 * fB2 - fA4 * fB1 + fA5 * fB0; - - // Account for a very small value - // return false if not successful. - if (Math.abs(fDet) <= 1e-9) { - return false; - } - - var kInv = []; - kInv[0] = +this.elements[5] * fB5 - this.elements[6] * fB4 + this.elements[7] * fB3; - kInv[4] = -this.elements[4] * fB5 + this.elements[6] * fB2 - this.elements[7] * fB1; - kInv[8] = +this.elements[4] * fB4 - this.elements[5] * fB2 + this.elements[7] * fB0; - kInv[12] = -this.elements[4] * fB3 + this.elements[5] * fB1 - this.elements[6] * fB0; - kInv[1] = -this.elements[1] * fB5 + this.elements[2] * fB4 - this.elements[3] * fB3; - kInv[5] = +this.elements[0] * fB5 - this.elements[2] * fB2 + this.elements[3] * fB1; - kInv[9] = -this.elements[0] * fB4 + this.elements[1] * fB2 - this.elements[3] * fB0; - kInv[13] = +this.elements[0] * fB3 - this.elements[1] * fB1 + this.elements[2] * fB0; - kInv[2] = +this.elements[13] * fA5 - this.elements[14] * fA4 + this.elements[15] * fA3; - kInv[6] = -this.elements[12] * fA5 + this.elements[14] * fA2 - this.elements[15] * fA1; - kInv[10] = +this.elements[12] * fA4 - this.elements[13] * fA2 + this.elements[15] * fA0; - kInv[14] = -this.elements[12] * fA3 + this.elements[13] * fA1 - this.elements[14] * fA0; - kInv[3] = -this.elements[9] * fA5 + this.elements[10] * fA4 - this.elements[11] * fA3; - kInv[7] = +this.elements[8] * fA5 - this.elements[10] * fA2 + this.elements[11] * fA1; - kInv[11] = -this.elements[8] * fA4 + this.elements[9] * fA2 - this.elements[11] * fA0; - kInv[15] = +this.elements[8] * fA3 - this.elements[9] * fA1 + this.elements[10] * fA0; - - // Inverse using Determinant - var fInvDet = 1.0 / fDet; - kInv[0] *= fInvDet; - kInv[1] *= fInvDet; - kInv[2] *= fInvDet; - kInv[3] *= fInvDet; - kInv[4] *= fInvDet; - kInv[5] *= fInvDet; - kInv[6] *= fInvDet; - kInv[7] *= fInvDet; - kInv[8] *= fInvDet; - kInv[9] *= fInvDet; - kInv[10] *= fInvDet; - kInv[11] *= fInvDet; - kInv[12] *= fInvDet; - kInv[13] *= fInvDet; - kInv[14] *= fInvDet; - kInv[15] *= fInvDet; - - this.elements = kInv.slice(); - return true; - }, - toString: function() { - var str = ""; - for (var i = 0; i < 15; i++) { - str += this.elements[i] + ", "; - } - str += this.elements[15]; - return str; - }, - /** - * @member PMatrix3D - * The print() function prints out the elements of this matrix - */ - print: function() { - var digits = printMatrixHelper(this.elements); - - var output = "" + p.nfs(this.elements[0], digits, 4) + " " + p.nfs(this.elements[1], digits, 4) + - " " + p.nfs(this.elements[2], digits, 4) + " " + p.nfs(this.elements[3], digits, 4) + - "\n" + p.nfs(this.elements[4], digits, 4) + " " + p.nfs(this.elements[5], digits, 4) + - " " + p.nfs(this.elements[6], digits, 4) + " " + p.nfs(this.elements[7], digits, 4) + - "\n" + p.nfs(this.elements[8], digits, 4) + " " + p.nfs(this.elements[9], digits, 4) + - " " + p.nfs(this.elements[10], digits, 4) + " " + p.nfs(this.elements[11], digits, 4) + - "\n" + p.nfs(this.elements[12], digits, 4) + " " + p.nfs(this.elements[13], digits, 4) + - " " + p.nfs(this.elements[14], digits, 4) + " " + p.nfs(this.elements[15], digits, 4) + "\n\n"; - p.println(output); - }, - invTranslate: function(tx, ty, tz) { - this.preApply(1, 0, 0, -tx, 0, 1, 0, -ty, 0, 0, 1, -tz, 0, 0, 0, 1); - }, - invRotateX: function(angle) { - var c = Math.cos(-angle); - var s = Math.sin(-angle); - this.preApply([1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1]); - }, - invRotateY: function(angle) { - var c = Math.cos(-angle); - var s = Math.sin(-angle); - this.preApply([c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1]); - }, - invRotateZ: function(angle) { - var c = Math.cos(-angle); - var s = Math.sin(-angle); - this.preApply([c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }, - invScale: function(x, y, z) { - this.preApply([1 / x, 0, 0, 0, 0, 1 / y, 0, 0, 0, 0, 1 / z, 0, 0, 0, 0, 1]); - } - }; - - /** - * @private - * The matrix stack stores the transformations and translations that occur within the space. - */ - var PMatrixStack = p.PMatrixStack = function PMatrixStack() { - this.matrixStack = []; - }; - - /** - * @member PMatrixStack - * load pushes the matrix given in the function into the stack - * - * @param {Object | Array} matrix the matrix to be pushed into the stack - */ - PMatrixStack.prototype.load = function load() { - var tmpMatrix; - if (p.use3DContext) { - tmpMatrix = new PMatrix3D(); - } else { - tmpMatrix = new PMatrix2D(); - } - - if (arguments.length === 1) { - tmpMatrix.set(arguments[0]); - } else { - tmpMatrix.set(arguments); - } - this.matrixStack.push(tmpMatrix); - }; - - /** - * @member PMatrixStack - * push adds a duplicate of the top of the stack onto the stack - uses the peek function - */ - PMatrixStack.prototype.push = function push() { - this.matrixStack.push(this.peek()); - }; - - /** - * @member PMatrixStack - * pop removes returns the matrix at the top of the stack - * - * @returns {Object} the matrix at the top of the stack - */ - PMatrixStack.prototype.pop = function pop() { - return this.matrixStack.pop(); - }; - - /** - * @member PMatrixStack - * peek returns but doesn't remove the matrix at the top of the stack - * - * @returns {Object} the matrix at the top of the stack - */ - PMatrixStack.prototype.peek = function peek() { - var tmpMatrix; - if (p.use3DContext) { - tmpMatrix = new PMatrix3D(); - } else { - tmpMatrix = new PMatrix2D(); - } - - tmpMatrix.set(this.matrixStack[this.matrixStack.length - 1]); - return tmpMatrix; - }; - - /** - * @member PMatrixStack - * this function multiplies the matrix at the top of the stack with the matrix given as a parameter - * - * @param {Object | Array} matrix the matrix to be multiplied into the stack - */ - PMatrixStack.prototype.mult = function mult(matrix) { - this.matrixStack[this.matrixStack.length - 1].apply(matrix); - }; - - //////////////////////////////////////////////////////////////////////////// - // Array handling - //////////////////////////////////////////////////////////////////////////// - - /** - * The split() function breaks a string into pieces using a character or string - * as the divider. The delim parameter specifies the character or characters that - * mark the boundaries between each piece. A String[] array is returned that contains - * each of the pieces. - * If the result is a set of numbers, you can convert the String[] array to to a float[] - * or int[] array using the datatype conversion functions int() and float() (see example above). - * The splitTokens() function works in a similar fashion, except that it splits using a range - * of characters instead of a specific character or sequence. - * - * @param {String} str the String to be split - * @param {String} delim the character or String used to separate the data - * - * @returns {string[]} The new string array - * - * @see splitTokens - * @see join - * @see trim - */ - p.split = function(str, delim) { - return str.split(delim); - }; - - /** - * The splitTokens() function splits a String at one or many character "tokens." The tokens - * parameter specifies the character or characters to be used as a boundary. - * If no tokens character is specified, any whitespace character is used to split. - * Whitespace characters include tab (\t), line feed (\n), carriage return (\r), form - * feed (\f), and space. To convert a String to an array of integers or floats, use the - * datatype conversion functions int() and float() to convert the array of Strings. - * - * @param {String} str the String to be split - * @param {Char[]} tokens list of individual characters that will be used as separators - * - * @returns {string[]} The new string array - * - * @see split - * @see join - * @see trim - */ - p.splitTokens = function(str, tokens) { - if (arguments.length === 1) { - tokens = "\n\t\r\f "; - } - - tokens = "[" + tokens + "]"; - - var ary = []; - var index = 0; - var pos = str.search(tokens); - - while (pos >= 0) { - if (pos === 0) { - str = str.substring(1); - } else { - ary[index] = str.substring(0, pos); - index++; - str = str.substring(pos); - } - pos = str.search(tokens); - } - - if (str.length > 0) { - ary[index] = str; - } - - if (ary.length === 0) { - ary = undef; - } - - return ary; - }; - - /** - * Expands an array by one element and adds data to the new position. The datatype of - * the element parameter must be the same as the datatype of the array. - * When using an array of objects, the data returned from the function must be cast to - * the object array's data type. For example: SomeClass[] items = (SomeClass[]) - * append(originalArray, element). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array boolean[], - * byte[], char[], int[], float[], or String[], or an array of objects - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} element new data for the array - * - * @returns Array (the same datatype as the input) - * - * @see shorten - * @see expand - */ - p.append = function(array, element) { - array[array.length] = element; - return array; - }; - - /** - * Concatenates two arrays. For example, concatenating the array { 1, 2, 3 } and the - * array { 4, 5, 6 } yields { 1, 2, 3, 4, 5, 6 }. Both parameters must be arrays of the - * same datatype. - * When using an array of objects, the data returned from the function must be cast to the - * object array's data type. For example: SomeClass[] items = (SomeClass[]) concat(array1, array2). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array1 boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array2 boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * - * @returns Array (the same datatype as the input) - * - * @see splice - */ - p.concat = function(array1, array2) { - return array1.concat(array2); - }; - - /** - * Sorts an array of numbers from smallest to largest and puts an array of - * words in alphabetical order. The original array is not modified, a - * re-ordered array is returned. The count parameter states the number of - * elements to sort. For example if there are 12 elements in an array and - * if count is the value 5, only the first five elements on the array will - * be sorted. Alphabetical ordering is case insensitive. - * - * @param {String[] | int[] | float[]} array Array of elements to sort - * @param {int} numElem Number of elements to sort - * - * @returns {String[] | int[] | float[]} Array (same datatype as the input) - * - * @see reverse - */ - p.sort = function(array, numElem) { - var ret = []; - - // depending on the type used (int, float) or string - // we'll need to use a different compare function - if (array.length > 0) { - // copy since we need to return another array - var elemsToCopy = numElem > 0 ? numElem : array.length; - for (var i = 0; i < elemsToCopy; i++) { - ret.push(array[i]); - } - if (typeof array[0] === "string") { - ret.sort(); - } - // int or float - else { - ret.sort(function(a, b) { - return a - b; - }); - } - - // copy on the rest of the elements that were not sorted in case the user - // only wanted a subset of an array to be sorted. - if (numElem > 0) { - for (var j = ret.length; j < array.length; j++) { - ret.push(array[j]); - } - } - } - return ret; - }; - - /** - * Inserts a value or array of values into an existing array. The first two parameters must - * be of the same datatype. The array parameter defines the array which will be modified - * and the second parameter defines the data which will be inserted. When using an array - * of objects, the data returned from the function must be cast to the object array's data - * type. For example: SomeClass[] items = (SomeClass[]) splice(array1, array2, index). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * @param {boolean|byte|char|int|float|String|boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} - * value boolean, byte, char, int, float, String, boolean[], byte[], char[], int[], - * float[], String[], or other Object: value or an array of objects to be spliced in - * @param {int} index position in the array from which to insert data - * - * @returns Array (the same datatype as the input) - * - * @see contract - * @see subset - */ - p.splice = function(array, value, index) { - - // Trying to splice an empty array into "array" in P5 won't do - // anything, just return the original. - if(value.length === 0) - { - return array; - } - - // If the second argument was an array, we'll need to iterate over all - // the "value" elements and add one by one because - // array.splice(index, 0, value); - // would create a multi-dimensional array which isn't what we want. - if(value instanceof Array) { - for(var i = 0, j = index; i < value.length; j++,i++) { - array.splice(j, 0, value[i]); - } - } else { - array.splice(index, 0, value); - } - - return array; - }; - - /** - * Extracts an array of elements from an existing array. The array parameter defines the - * array from which the elements will be copied and the offset and length parameters determine - * which elements to extract. If no length is given, elements will be extracted from the offset - * to the end of the array. When specifying the offset remember the first array element is 0. - * This function does not change the source array. - * When using an array of objects, the data returned from the function must be cast to the - * object array's data type. - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * @param {int} offset position to begin - * @param {int} length number of values to extract - * - * @returns Array (the same datatype as the input) - * - * @see splice - */ - p.subset = function(array, offset, length) { - if (arguments.length === 2) { - return array.slice(offset, array.length - offset); - } else if (arguments.length === 3) { - return array.slice(offset, offset + length); - } - }; - - /** - * Combines an array of Strings into one String, each separated by the character(s) used for - * the separator parameter. To join arrays of ints or floats, it's necessary to first convert - * them to strings using nf() or nfs(). - * - * @param {Array} array array of Strings - * @param {char|String} separator char or String to be placed between each item - * - * @returns {String} The combined string - * - * @see split - * @see trim - * @see nf - * @see nfs - */ - p.join = function(array, seperator) { - return array.join(seperator); - }; - - /** - * Decreases an array by one element and returns the shortened array. When using an - * array of objects, the data returned from the function must be cast to the object array's - * data type. For example: SomeClass[] items = (SomeClass[]) shorten(originalArray). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array - * boolean[], byte[], char[], int[], float[], or String[], or an array of objects - * - * @returns Array (the same datatype as the input) - * - * @see append - * @see expand - */ - p.shorten = function(ary) { - var newary = []; - - // copy array into new array - var len = ary.length; - for (var i = 0; i < len; i++) { - newary[i] = ary[i]; - } - newary.pop(); - - return newary; - }; - - /** - * Increases the size of an array. By default, this function doubles the size of the array, - * but the optional newSize parameter provides precise control over the increase in size. - * When using an array of objects, the data returned from the function must be cast to the - * object array's data type. For example: SomeClass[] items = (SomeClass[]) expand(originalArray). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} ary - * boolean[], byte[], char[], int[], float[], String[], or an array of objects - * @param {int} newSize positive int: new size for the array - * - * @returns Array (the same datatype as the input) - * - * @see contract - */ - p.expand = function(ary, newSize) { - var temp = ary.slice(0); - if (arguments.length === 1) { - // double size of array - temp.length = ary.length * 2; - return temp; - } else if (arguments.length === 2) { - // size is newSize - temp.length = newSize; - return temp; - } - }; - - /** - * Copies an array (or part of an array) to another array. The src array is copied to the - * dst array, beginning at the position specified by srcPos and into the position specified - * by dstPos. The number of elements to copy is determined by length. The simplified version - * with two arguments copies an entire array to another of the same size. It is equivalent - * to "arrayCopy(src, 0, dst, 0, src.length)". This function is far more efficient for copying - * array data than iterating through a for and copying each element. - * - * @param {Array} src an array of any data type: the source array - * @param {Array} dest an array of any data type (as long as it's the same as src): the destination array - * @param {int} srcPos starting position in the source array - * @param {int} destPos starting position in the destination array - * @param {int} length number of array elements to be copied - * - * @returns none - */ - p.arrayCopy = function() { // src, srcPos, dest, destPos, length) { - var src, srcPos = 0, dest, destPos = 0, length; - - if (arguments.length === 2) { - // recall itself and copy src to dest from start index 0 to 0 of src.length - src = arguments[0]; - dest = arguments[1]; - length = src.length; - } else if (arguments.length === 3) { - // recall itself and copy src to dest from start index 0 to 0 of length - src = arguments[0]; - dest = arguments[1]; - length = arguments[2]; - } else if (arguments.length === 5) { - src = arguments[0]; - srcPos = arguments[1]; - dest = arguments[2]; - destPos = arguments[3]; - length = arguments[4]; - } - - // copy src to dest from index srcPos to index destPos of length recursivly on objects - for (var i = srcPos, j = destPos; i < length + srcPos; i++, j++) { - if (dest[j] !== undef) { - dest[j] = src[i]; - } else { - throw "array index out of bounds exception"; - } - } - }; - - /** - * Reverses the order of an array. - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]} array - * boolean[], byte[], char[], int[], float[], or String[] - * - * @returns Array (the same datatype as the input) - * - * @see sort - */ - p.reverse = function(array) { - return array.reverse(); - }; - - - //////////////////////////////////////////////////////////////////////////// - // Color functions - //////////////////////////////////////////////////////////////////////////// - - // helper functions for internal blending modes - p.mix = function(a, b, f) { - return a + (((b - a) * f) >> 8); - }; - - p.peg = function(n) { - return (n < 0) ? 0 : ((n > 255) ? 255 : n); - }; - - // blending modes - /** - * These are internal blending modes used for BlendColor() - * - * @param {Color} c1 First Color to blend - * @param {Color} c2 Second Color to blend - * - * @returns {Color} The blended Color - * - * @see BlendColor - * @see Blend - */ - p.modes = { - replace: function(c1, c2) { - return c2; - }, - blend: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - p.mix(c1 & PConstants.RED_MASK, c2 & PConstants.RED_MASK, f) & PConstants.RED_MASK | - p.mix(c1 & PConstants.GREEN_MASK, c2 & PConstants.GREEN_MASK, f) & PConstants.GREEN_MASK | - p.mix(c1 & PConstants.BLUE_MASK, c2 & PConstants.BLUE_MASK, f)); - }, - add: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - Math.min(((c1 & PConstants.RED_MASK) + ((c2 & PConstants.RED_MASK) >> 8) * f), PConstants.RED_MASK) & PConstants.RED_MASK | - Math.min(((c1 & PConstants.GREEN_MASK) + ((c2 & PConstants.GREEN_MASK) >> 8) * f), PConstants.GREEN_MASK) & PConstants.GREEN_MASK | - Math.min((c1 & PConstants.BLUE_MASK) + (((c2 & PConstants.BLUE_MASK) * f) >> 8), PConstants.BLUE_MASK)); - }, - subtract: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - Math.max(((c1 & PConstants.RED_MASK) - ((c2 & PConstants.RED_MASK) >> 8) * f), PConstants.GREEN_MASK) & PConstants.RED_MASK | - Math.max(((c1 & PConstants.GREEN_MASK) - ((c2 & PConstants.GREEN_MASK) >> 8) * f), PConstants.BLUE_MASK) & PConstants.GREEN_MASK | - Math.max((c1 & PConstants.BLUE_MASK) - (((c2 & PConstants.BLUE_MASK) * f) >> 8), 0)); - }, - lightest: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - Math.max(c1 & PConstants.RED_MASK, ((c2 & PConstants.RED_MASK) >> 8) * f) & PConstants.RED_MASK | - Math.max(c1 & PConstants.GREEN_MASK, ((c2 & PConstants.GREEN_MASK) >> 8) * f) & PConstants.GREEN_MASK | - Math.max(c1 & PConstants.BLUE_MASK, ((c2 & PConstants.BLUE_MASK) * f) >> 8)); - }, - darkest: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - p.mix(c1 & PConstants.RED_MASK, Math.min(c1 & PConstants.RED_MASK, ((c2 & PConstants.RED_MASK) >> 8) * f), f) & PConstants.RED_MASK | - p.mix(c1 & PConstants.GREEN_MASK, Math.min(c1 & PConstants.GREEN_MASK, ((c2 & PConstants.GREEN_MASK) >> 8) * f), f) & PConstants.GREEN_MASK | - p.mix(c1 & PConstants.BLUE_MASK, Math.min(c1 & PConstants.BLUE_MASK, ((c2 & PConstants.BLUE_MASK) * f) >> 8), f)); - }, - difference: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (ar > br) ? (ar - br) : (br - ar); - var cg = (ag > bg) ? (ag - bg) : (bg - ag); - var cb = (ab > bb) ? (ab - bb) : (bb - ab); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - exclusion: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = ar + br - ((ar * br) >> 7); - var cg = ag + bg - ((ag * bg) >> 7); - var cb = ab + bb - ((ab * bb) >> 7); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - multiply: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (ar * br) >> 8; - var cg = (ag * bg) >> 8; - var cb = (ab * bb) >> 8; - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - screen: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = 255 - (((255 - ar) * (255 - br)) >> 8); - var cg = 255 - (((255 - ag) * (255 - bg)) >> 8); - var cb = 255 - (((255 - ab) * (255 - bb)) >> 8); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - hard_light: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (br < 128) ? ((ar * br) >> 7) : (255 - (((255 - ar) * (255 - br)) >> 7)); - var cg = (bg < 128) ? ((ag * bg) >> 7) : (255 - (((255 - ag) * (255 - bg)) >> 7)); - var cb = (bb < 128) ? ((ab * bb) >> 7) : (255 - (((255 - ab) * (255 - bb)) >> 7)); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - soft_light: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = ((ar * br) >> 7) + ((ar * ar) >> 8) - ((ar * ar * br) >> 15); - var cg = ((ag * bg) >> 7) + ((ag * ag) >> 8) - ((ag * ag * bg) >> 15); - var cb = ((ab * bb) >> 7) + ((ab * ab) >> 8) - ((ab * ab * bb) >> 15); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - overlay: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (ar < 128) ? ((ar * br) >> 7) : (255 - (((255 - ar) * (255 - br)) >> 7)); - var cg = (ag < 128) ? ((ag * bg) >> 7) : (255 - (((255 - ag) * (255 - bg)) >> 7)); - var cb = (ab < 128) ? ((ab * bb) >> 7) : (255 - (((255 - ab) * (255 - bb)) >> 7)); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - dodge: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (br === 255) ? 255 : p.peg((ar << 8) / (255 - br)); // division requires pre-peg()-ing - var cg = (bg === 255) ? 255 : p.peg((ag << 8) / (255 - bg)); // " - var cb = (bb === 255) ? 255 : p.peg((ab << 8) / (255 - bb)); // " - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - burn: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (br === 0) ? 0 : 255 - p.peg(((255 - ar) << 8) / br); // division requires pre-peg()-ing - var cg = (bg === 0) ? 0 : 255 - p.peg(((255 - ag) << 8) / bg); // " - var cb = (bb === 0) ? 0 : 255 - p.peg(((255 - ab) << 8) / bb); // " - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - } - }; - - function color$4(aValue1, aValue2, aValue3, aValue4) { - var r, g, b, a; - - if (curColorMode === PConstants.HSB) { - var rgb = p.color.toRGB(aValue1, aValue2, aValue3); - r = rgb[0]; - g = rgb[1]; - b = rgb[2]; - } else { - r = Math.round(255 * (aValue1 / colorModeX)); - g = Math.round(255 * (aValue2 / colorModeY)); - b = Math.round(255 * (aValue3 / colorModeZ)); - } - - a = Math.round(255 * (aValue4 / colorModeA)); - - // Limit values greater than 255 - r = (r > 255) ? 255 : r; - g = (g > 255) ? 255 : g; - b = (b > 255) ? 255 : b; - a = (a > 255) ? 255 : a; - - // Create color int - return (a << 24) & PConstants.ALPHA_MASK | (r << 16) & PConstants.RED_MASK | (g << 8) & PConstants.GREEN_MASK | b & PConstants.BLUE_MASK; - } - - function color$2(aValue1, aValue2) { - var a; - - // Color int and alpha - if (aValue1 & PConstants.ALPHA_MASK) { - a = Math.round(255 * (aValue2 / colorModeA)); - a = (a > 255) ? 255 : a; - - return aValue1 - (aValue1 & PConstants.ALPHA_MASK) + ((a << 24) & PConstants.ALPHA_MASK); - } - // Grayscale and alpha - else { - if (curColorMode === PConstants.RGB) { - return color$4(aValue1, aValue1, aValue1, aValue2); - } else if (curColorMode === PConstants.HSB) { - return color$4(0, 0, (aValue1 / colorModeX) * colorModeZ, aValue2); - } - } - } - - function color$1(aValue1) { - // Grayscale - if (aValue1 <= colorModeX && aValue1 >= 0) { - if (curColorMode === PConstants.RGB) { - return color$4(aValue1, aValue1, aValue1, colorModeA); - } else if (curColorMode === PConstants.HSB) { - return color$4(0, 0, (aValue1 / colorModeX) * colorModeZ, colorModeA); - } - } - // Color int - else if (aValue1) { - return aValue1; - } - } - - /** - * Creates colors for storing in variables of the color datatype. The parameters are - * interpreted as RGB or HSB values depending on the current colorMode(). The default - * mode is RGB values from 0 to 255 and therefore, the function call color(255, 204, 0) - * will return a bright yellow color. More about how colors are stored can be found in - * the reference for the color datatype. - * - * @param {int|float} aValue1 red or hue or grey values relative to the current color range. - * Also can be color value in hexadecimal notation (i.e. #FFCC00 or 0xFFFFCC00) - * @param {int|float} aValue2 green or saturation values relative to the current color range - * @param {int|float} aValue3 blue or brightness values relative to the current color range - * @param {int|float} aValue4 relative to current color range. Represents alpha - * - * @returns {color} the color - * - * @see colorMode - */ - p.color = function color(aValue1, aValue2, aValue3, aValue4) { - // 4 arguments: (R, G, B, A) or (H, S, B, A) - if (aValue1 !== undef && aValue2 !== undef && aValue3 !== undef && aValue4 !== undef) { - return color$4(aValue1, aValue2, aValue3, aValue4); - } - - // 3 arguments: (R, G, B) or (H, S, B) - else if (aValue1 !== undef && aValue2 !== undef && aValue3 !== undef) { - return color$4(aValue1, aValue2, aValue3, colorModeA); - } - - // 2 arguments: (Color, A) or (Grayscale, A) - else if (aValue1 !== undef && aValue2 !== undef) { - return color$2(aValue1, aValue2); - } - - // 1 argument: (Grayscale) or (Color) - else if (typeof aValue1 === "number") { - return color$1(aValue1); - } - - // Default - else { - return color$4(colorModeX, colorModeY, colorModeZ, colorModeA); - } - }; - - // Ease of use function to extract the colour bits into a string - p.color.toString = function(colorInt) { - return "rgba(" + ((colorInt & PConstants.RED_MASK) >>> 16) + "," + ((colorInt & PConstants.GREEN_MASK) >>> 8) + - "," + ((colorInt & PConstants.BLUE_MASK)) + "," + ((colorInt & PConstants.ALPHA_MASK) >>> 24) / 255 + ")"; - }; - - // Easy of use function to pack rgba values into a single bit-shifted color int. - p.color.toInt = function(r, g, b, a) { - return (a << 24) & PConstants.ALPHA_MASK | (r << 16) & PConstants.RED_MASK | (g << 8) & PConstants.GREEN_MASK | b & PConstants.BLUE_MASK; - }; - - // Creates a simple array in [R, G, B, A] format, [255, 255, 255, 255] - p.color.toArray = function(colorInt) { - return [(colorInt & PConstants.RED_MASK) >>> 16, (colorInt & PConstants.GREEN_MASK) >>> 8, - colorInt & PConstants.BLUE_MASK, (colorInt & PConstants.ALPHA_MASK) >>> 24]; - }; - - // Creates a WebGL color array in [R, G, B, A] format. WebGL wants the color ranges between 0 and 1, [1, 1, 1, 1] - p.color.toGLArray = function(colorInt) { - return [((colorInt & PConstants.RED_MASK) >>> 16) / 255, ((colorInt & PConstants.GREEN_MASK) >>> 8) / 255, - (colorInt & PConstants.BLUE_MASK) / 255, ((colorInt & PConstants.ALPHA_MASK) >>> 24) / 255]; - }; - - // HSB conversion function from Mootools, MIT Licensed - p.color.toRGB = function(h, s, b) { - // Limit values greater than range - h = (h > colorModeX) ? colorModeX : h; - s = (s > colorModeY) ? colorModeY : s; - b = (b > colorModeZ) ? colorModeZ : b; - - h = (h / colorModeX) * 360; - s = (s / colorModeY) * 100; - b = (b / colorModeZ) * 100; - - var br = Math.round(b / 100 * 255); - - if (s === 0) { // Grayscale - return [br, br, br]; - } else { - var hue = h % 360; - var f = hue % 60; - var p = Math.round((b * (100 - s)) / 10000 * 255); - var q = Math.round((b * (6000 - s * f)) / 600000 * 255); - var t = Math.round((b * (6000 - s * (60 - f))) / 600000 * 255); - switch (Math.floor(hue / 60)) { - case 0: - return [br, t, p]; - case 1: - return [q, br, p]; - case 2: - return [p, br, t]; - case 3: - return [p, q, br]; - case 4: - return [t, p, br]; - case 5: - return [br, p, q]; - } - } - }; - - p.color.toHSB = function( colorInt ) { - var red, green, blue; - - red = ((colorInt & PConstants.RED_MASK) >>> 16) / 255; - green = ((colorInt & PConstants.GREEN_MASK) >>> 8) / 255; - blue = (colorInt & PConstants.BLUE_MASK) / 255; - - var max = p.max(p.max(red,green), blue), - min = p.min(p.min(red,green), blue), - hue, saturation; - - if (min === max) { - return [0, 0, max]; - } else { - saturation = (max - min) / max; - - if (red === max) { - hue = (green - blue) / (max - min); - } else if (green === max) { - hue = 2 + ((blue - red) / (max - min)); - } else { - hue = 4 + ((red - green) / (max - min)); - } - - hue /= 6; - - if (hue < 0) { - hue += 1; - } else if (hue > 1) { - hue -= 1; - } - } - return [hue*colorModeX, saturation*colorModeY, max*colorModeZ]; - }; - - /** - * Extracts the brightness value from a color. - * - * @param {color} colInt any value of the color datatype - * - * @returns {float} The brightness color value. - * - * @see red - * @see green - * @see blue - * @see hue - * @see saturation - */ - p.brightness = function(colInt){ - return p.color.toHSB(colInt)[2]; - }; - - /** - * Extracts the saturation value from a color. - * - * @param {color} colInt any value of the color datatype - * - * @returns {float} The saturation color value. - * - * @see red - * @see green - * @see blue - * @see hue - * @see brightness - */ - p.saturation = function(colInt){ - return p.color.toHSB(colInt)[1]; - }; - - /** - * Extracts the hue value from a color. - * - * @param {color} colInt any value of the color datatype - * - * @returns {float} The hue color value. - * - * @see red - * @see green - * @see blue - * @see saturation - * @see brightness - */ - p.hue = function(colInt){ - return p.color.toHSB(colInt)[0]; - }; - - var verifyChannel = function verifyChannel(aColor) { - if (aColor.constructor === Array) { - return aColor; - } else { - return p.color(aColor); - } - }; - - /** - * Extracts the red value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The red color value. - * - * @see green - * @see blue - * @see alpha - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.red = function(aColor) { - return ((aColor & PConstants.RED_MASK) >>> 16) / 255 * colorModeX; - }; - - /** - * Extracts the green value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The green color value. - * - * @see red - * @see blue - * @see alpha - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.green = function(aColor) { - return ((aColor & PConstants.GREEN_MASK) >>> 8) / 255 * colorModeY; - }; - - /** - * Extracts the blue value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The blue color value. - * - * @see red - * @see green - * @see alpha - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.blue = function(aColor) { - return (aColor & PConstants.BLUE_MASK) / 255 * colorModeZ; - }; - - /** - * Extracts the alpha value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The alpha color value. - * - * @see red - * @see green - * @see blue - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.alpha = function(aColor) { - return ((aColor & PConstants.ALPHA_MASK) >>> 24) / 255 * colorModeA; - }; - - /** - * Calculates a color or colors between two colors at a specific increment. - * The amt parameter is the amount to interpolate between the two values where 0.0 - * equal to the first point, 0.1 is very near the first point, 0.5 is half-way in between, etc. - * - * @param {color} c1 interpolate from this color - * @param {color} c2 interpolate to this color - * @param {float} amt between 0.0 and 1.0 - * - * @returns {float} The blended color. - * - * @see blendColor - * @see color - */ - p.lerpColor = function lerpColor(c1, c2, amt) { - // Get RGBA values for Color 1 to floats - var colorBits1 = p.color(c1); - var r1 = (colorBits1 & PConstants.RED_MASK) >>> 16; - var g1 = (colorBits1 & PConstants.GREEN_MASK) >>> 8; - var b1 = (colorBits1 & PConstants.BLUE_MASK); - var a1 = ((colorBits1 & PConstants.ALPHA_MASK) >>> 24) / colorModeA; - - // Get RGBA values for Color 2 to floats - var colorBits2 = p.color(c2); - var r2 = (colorBits2 & PConstants.RED_MASK) >>> 16; - var g2 = (colorBits2 & PConstants.GREEN_MASK) >>> 8; - var b2 = (colorBits2 & PConstants.BLUE_MASK); - var a2 = ((colorBits2 & PConstants.ALPHA_MASK) >>> 24) / colorModeA; - - // Return lerp value for each channel, INT for color, Float for Alpha-range - var r = parseInt(p.lerp(r1, r2, amt), 10); - var g = parseInt(p.lerp(g1, g2, amt), 10); - var b = parseInt(p.lerp(b1, b2, amt), 10); - var a = parseFloat(p.lerp(a1, a2, amt) * colorModeA); - - return p.color.toInt(r, g, b, a); - }; - - // Forced default color mode for #aaaaaa style - /** - * Convert 3 int values to a color in the default color mode RGB even if curColorMode is not set to RGB - * - * @param {int} aValue1 range for the red color - * @param {int} aValue2 range for the green color - * @param {int} aValue3 range for the blue color - * - * @returns {Color} - * - * @see color - */ - p.defaultColor = function(aValue1, aValue2, aValue3) { - var tmpColorMode = curColorMode; - curColorMode = PConstants.RGB; - var c = p.color(aValue1 / 255 * colorModeX, aValue2 / 255 * colorModeY, aValue3 / 255 * colorModeZ); - curColorMode = tmpColorMode; - return c; - }; - - /** - * Changes the way Processing interprets color data. By default, fill(), stroke(), and background() - * colors are set by values between 0 and 255 using the RGB color model. It is possible to change the - * numerical range used for specifying colors and to switch color systems. For example, calling colorMode(RGB, 1.0) - * will specify that values are specified between 0 and 1. The limits for defining colors are altered by setting the - * parameters range1, range2, range3, and range 4. - * - * @param {MODE} mode Either RGB or HSB, corresponding to Red/Green/Blue and Hue/Saturation/Brightness - * @param {int|float} range range for all color elements - * @param {int|float} range1 range for the red or hue depending on the current color mode - * @param {int|float} range2 range for the green or saturation depending on the current color mode - * @param {int|float} range3 range for the blue or brightness depending on the current color mode - * @param {int|float} range4 range for the alpha - * - * @returns none - * - * @see background - * @see fill - * @see stroke - */ - p.colorMode = function colorMode() { // mode, range1, range2, range3, range4 - curColorMode = arguments[0]; - if (arguments.length > 1) { - colorModeX = arguments[1]; - colorModeY = arguments[2] || arguments[1]; - colorModeZ = arguments[3] || arguments[1]; - colorModeA = arguments[4] || arguments[1]; - } - }; - - /** - * Blends two color values together based on the blending mode given as the MODE parameter. - * The possible modes are described in the reference for the blend() function. - * - * @param {color} c1 color: the first color to blend - * @param {color} c2 color: the second color to blend - * @param {MODE} MODE Either BLEND, ADD, SUBTRACT, DARKEST, LIGHTEST, DIFFERENCE, EXCLUSION, MULTIPLY, - * SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, or BURN - * - * @returns {float} The blended color. - * - * @see blend - * @see color - */ - p.blendColor = function(c1, c2, mode) { - var color = 0; - switch (mode) { - case PConstants.REPLACE: - color = p.modes.replace(c1, c2); - break; - case PConstants.BLEND: - color = p.modes.blend(c1, c2); - break; - case PConstants.ADD: - color = p.modes.add(c1, c2); - break; - case PConstants.SUBTRACT: - color = p.modes.subtract(c1, c2); - break; - case PConstants.LIGHTEST: - color = p.modes.lightest(c1, c2); - break; - case PConstants.DARKEST: - color = p.modes.darkest(c1, c2); - break; - case PConstants.DIFFERENCE: - color = p.modes.difference(c1, c2); - break; - case PConstants.EXCLUSION: - color = p.modes.exclusion(c1, c2); - break; - case PConstants.MULTIPLY: - color = p.modes.multiply(c1, c2); - break; - case PConstants.SCREEN: - color = p.modes.screen(c1, c2); - break; - case PConstants.HARD_LIGHT: - color = p.modes.hard_light(c1, c2); - break; - case PConstants.SOFT_LIGHT: - color = p.modes.soft_light(c1, c2); - break; - case PConstants.OVERLAY: - color = p.modes.overlay(c1, c2); - break; - case PConstants.DODGE: - color = p.modes.dodge(c1, c2); - break; - case PConstants.BURN: - color = p.modes.burn(c1, c2); - break; - } - return color; - }; - - //////////////////////////////////////////////////////////////////////////// - // Canvas-Matrix manipulation - //////////////////////////////////////////////////////////////////////////// - - function saveContext() { - curContext.save(); - } - - function restoreContext() { - curContext.restore(); - isStrokeDirty = true; - isFillDirty = true; - } - - /** - * Prints the current matrix to the text window. - * - * @returns none - * - * @see pushMatrix - * @see popMatrix - * @see resetMatrix - * @see applyMatrix - */ - p.printMatrix = function printMatrix() { - modelView.print(); - }; - - /** - * Specifies an amount to displace objects within the display window. The x parameter specifies left/right translation, - * the y parameter specifies up/down translation, and the z parameter specifies translations toward/away from the screen. - * Using this function with the z parameter requires using the P3D or OPENGL parameter in combination with size as shown - * in the above example. Transformations apply to everything that happens after and subsequent calls to the function - * accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). - * If translate() is called within draw(), the transformation is reset when the loop begins again. - * This function can be further controlled by the pushMatrix() and popMatrix(). - * - * @param {int|float} x left/right translation - * @param {int|float} y up/down translation - * @param {int|float} z forward/back translation - * - * @returns none - * - * @see pushMatrix - * @see popMatrix - * @see scale - * @see rotate - * @see rotateX - * @see rotateY - * @see rotateZ - */ - p.translate = function translate(x, y, z) { - if (p.use3DContext) { - forwardTransform.translate(x, y, z); - reverseTransform.invTranslate(x, y, z); - } else { - curContext.translate(x, y); - } - }; - - /** - * Increases or decreases the size of a shape by expanding and contracting vertices. Objects always scale from their - * relative origin to the coordinate system. Scale values are specified as decimal percentages. For example, the - * function call scale(2.0) increases the dimension of a shape by 200%. Transformations apply to everything that - * happens after and subsequent calls to the function multiply the effect. For example, calling scale(2.0) and - * then scale(1.5) is the same as scale(3.0). If scale() is called within draw(), the transformation is reset when - * the loop begins again. Using this fuction with the z parameter requires passing P3D or OPENGL into the size() - * parameter as shown in the example above. This function can be further controlled by pushMatrix() and popMatrix(). - * - * @param {int|float} size percentage to scale the object - * @param {int|float} x percentage to scale the object in the x-axis - * @param {int|float} y percentage to scale the object in the y-axis - * @param {int|float} z percentage to scale the object in the z-axis - * - * @returns none - * - * @see pushMatrix - * @see popMatrix - * @see translate - * @see rotate - * @see rotateX - * @see rotateY - * @see rotateZ - */ - p.scale = function scale(x, y, z) { - if (p.use3DContext) { - forwardTransform.scale(x, y, z); - reverseTransform.invScale(x, y, z); - } else { - curContext.scale(x, y || x); - } - }; - - /** - * Pushes the current transformation matrix onto the matrix stack. Understanding pushMatrix() and popMatrix() - * requires understanding the concept of a matrix stack. The pushMatrix() function saves the current coordinate - * system to the stack and popMatrix() restores the prior coordinate system. pushMatrix() and popMatrix() are - * used in conjuction with the other transformation methods and may be embedded to control the scope of - * the transformations. - * - * @returns none - * - * @see popMatrix - * @see translate - * @see rotate - * @see rotateX - * @see rotateY - * @see rotateZ - */ - p.pushMatrix = function pushMatrix() { - if (p.use3DContext) { - userMatrixStack.load(modelView); - } else { - saveContext(); - } - }; - - /** - * Pops the current transformation matrix off the matrix stack. Understanding pushing and popping requires - * understanding the concept of a matrix stack. The pushMatrix() function saves the current coordinate system to - * the stack and popMatrix() restores the prior coordinate system. pushMatrix() and popMatrix() are used in - * conjuction with the other transformation methods and may be embedded to control the scope of the transformations. - * - * @returns none - * - * @see popMatrix - * @see pushMatrix - */ - p.popMatrix = function popMatrix() { - if (p.use3DContext) { - modelView.set(userMatrixStack.pop()); - } else { - restoreContext(); - } - }; - - /** - * Replaces the current matrix with the identity matrix. The equivalent function in OpenGL is glLoadIdentity(). - * - * @returns none - * - * @see popMatrix - * @see pushMatrix - * @see applyMatrix - * @see printMatrix - */ - p.resetMatrix = function resetMatrix() { - if (p.use3DContext) { - forwardTransform.reset(); - reverseTransform.reset(); - } else { - curContext.setTransform(1,0,0,1,0,0); - } - }; - - /** - * Multiplies the current matrix by the one specified through the parameters. This is very slow because it will - * try to calculate the inverse of the transform, so avoid it whenever possible. The equivalent function - * in OpenGL is glMultMatrix(). - * - * @param {int|float} n00-n15 numbers which define the 4x4 matrix to be multiplied - * - * @returns none - * - * @see popMatrix - * @see pushMatrix - * @see resetMatrix - * @see printMatrix - */ - p.applyMatrix = function applyMatrix() { - var a = arguments; - if (!p.use3DContext) { - for (var cnt = a.length; cnt < 16; cnt++) { - a[cnt] = 0; - } - a[10] = a[15] = 1; - } - - forwardTransform.apply(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]); - reverseTransform.invApply(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]); - }; - - /** - * Rotates a shape around the x-axis the amount specified by the angle parameter. Angles should be - * specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * Objects are always rotated around their relative position to the origin and positive numbers - * rotate objects in a counterclockwise direction. Transformations apply to everything that happens - * after and subsequent calls to the function accumulates the effect. For example, calling rotateX(PI/2) - * and then rotateX(PI/2) is the same as rotateX(PI). If rotateX() is called within the draw(), the - * transformation is reset when the loop begins again. This function requires passing P3D or OPENGL - * into the size() parameter as shown in the example above. - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateY - * @see rotateZ - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotateX = function(angleInRadians) { - forwardTransform.rotateX(angleInRadians); - reverseTransform.invRotateX(angleInRadians); - }; - - /** - * Rotates a shape around the z-axis the amount specified by the angle parameter. Angles should be - * specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * Objects are always rotated around their relative position to the origin and positive numbers - * rotate objects in a counterclockwise direction. Transformations apply to everything that happens - * after and subsequent calls to the function accumulates the effect. For example, calling rotateZ(PI/2) - * and then rotateZ(PI/2) is the same as rotateZ(PI). If rotateZ() is called within the draw(), the - * transformation is reset when the loop begins again. This function requires passing P3D or OPENGL - * into the size() parameter as shown in the example above. - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateX - * @see rotateY - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotateZ = function(angleInRadians) { - forwardTransform.rotateZ(angleInRadians); - reverseTransform.invRotateZ(angleInRadians); - }; - - /** - * Rotates a shape around the y-axis the amount specified by the angle parameter. Angles should be - * specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * Objects are always rotated around their relative position to the origin and positive numbers - * rotate objects in a counterclockwise direction. Transformations apply to everything that happens - * after and subsequent calls to the function accumulates the effect. For example, calling rotateY(PI/2) - * and then rotateY(PI/2) is the same as rotateY(PI). If rotateY() is called within the draw(), the - * transformation is reset when the loop begins again. This function requires passing P3D or OPENGL - * into the size() parameter as shown in the example above. - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateX - * @see rotateZ - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotateY = function(angleInRadians) { - forwardTransform.rotateY(angleInRadians); - reverseTransform.invRotateY(angleInRadians); - }; - - /** - * Rotates a shape the amount specified by the angle parameter. Angles should be specified in radians - * (values from 0 to TWO_PI) or converted to radians with the radians() function. Objects are always - * rotated around their relative position to the origin and positive numbers rotate objects in a - * clockwise direction. Transformations apply to everything that happens after and subsequent calls - * to the function accumulates the effect. For example, calling rotate(HALF_PI) and then rotate(HALF_PI) - * is the same as rotate(PI). All tranformations are reset when draw() begins again. Technically, - * rotate() multiplies the current transformation matrix by a rotation matrix. This function can be - * further controlled by the pushMatrix() and popMatrix(). - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateX - * @see rotateY - * @see rotateZ - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotate = function rotate(angleInRadians) { - if (p.use3DContext) { - forwardTransform.rotateZ(angleInRadians); - reverseTransform.invRotateZ(angleInRadians); - } else { - curContext.rotate(angleInRadians); - } - }; - - /** - * The pushStyle() function saves the current style settings and popStyle() restores the prior settings. - * Note that these functions are always used together. They allow you to change the style settings and later - * return to what you had. When a new style is started with pushStyle(), it builds on the current style information. - * The pushStyle() and popStyle() functions can be embedded to provide more control (see the second example - * above for a demonstration.) - * The style information controlled by the following functions are included in the style: fill(), stroke(), tint(), - * strokeWeight(), strokeCap(), strokeJoin(), imageMode(), rectMode(), ellipseMode(), shapeMode(), colorMode(), - * textAlign(), textFont(), textMode(), textSize(), textLeading(), emissive(), specular(), shininess(), ambient() - * - * @returns none - * - * @see popStyle - */ - p.pushStyle = function pushStyle() { - // Save the canvas state. - saveContext(); - - p.pushMatrix(); - - var newState = { - 'doFill': doFill, - 'currentFillColor': currentFillColor, - 'doStroke': doStroke, - 'currentStrokeColor': currentStrokeColor, - 'curTint': curTint, - 'curRectMode': curRectMode, - 'curColorMode': curColorMode, - 'colorModeX': colorModeX, - 'colorModeZ': colorModeZ, - 'colorModeY': colorModeY, - 'colorModeA': colorModeA, - 'curTextFont': curTextFont, - 'curTextSize': curTextSize - }; - - styleArray.push(newState); - }; - - /** - * The pushStyle() function saves the current style settings and popStyle() restores the prior settings; these - * functions are always used together. They allow you to change the style settings and later return to what you had. - * When a new style is started with pushStyle(), it builds on the current style information. The pushStyle() and - * popStyle() functions can be embedded to provide more control (see the second example above for a demonstration.) - * - * @returns none - * - * @see pushStyle - */ - p.popStyle = function popStyle() { - var oldState = styleArray.pop(); - - if (oldState) { - restoreContext(); - - p.popMatrix(); - - doFill = oldState.doFill; - currentFillColor = oldState.currentFillColor; - doStroke = oldState.doStroke; - currentStrokeColor = oldState.currentStrokeColor; - curTint = oldState.curTint; - curRectMode = oldState.curRectmode; - curColorMode = oldState.curColorMode; - colorModeX = oldState.colorModeX; - colorModeZ = oldState.colorModeZ; - colorModeY = oldState.colorModeY; - colorModeA = oldState.colorModeA; - curTextFont = oldState.curTextFont; - curTextSize = oldState.curTextSize; - } else { - throw "Too many popStyle() without enough pushStyle()"; - } - }; - - //////////////////////////////////////////////////////////////////////////// - // Time based functions - //////////////////////////////////////////////////////////////////////////// - - /** - * Processing communicates with the clock on your computer. - * The year() function returns the current year as an integer (2003, 2004, 2005, etc). - * - * @returns {float} The current year. - * - * @see millis - * @see second - * @see minute - * @see hour - * @see day - * @see month - */ - p.year = function year() { - return new Date().getFullYear(); - }; - /** - * Processing communicates with the clock on your computer. - * The month() function returns the current month as a value from 1 - 12. - * - * @returns {float} The current month. - * - * @see millis - * @see second - * @see minute - * @see hour - * @see day - * @see year - */ - p.month = function month() { - return new Date().getMonth() + 1; - }; - /** - * Processing communicates with the clock on your computer. - * The day() function returns the current day as a value from 1 - 31. - * - * @returns {float} The current day. - * - * @see millis - * @see second - * @see minute - * @see hour - * @see month - * @see year - */ - p.day = function day() { - return new Date().getDate(); - }; - /** - * Processing communicates with the clock on your computer. - * The hour() function returns the current hour as a value from 0 - 23. - * - * @returns {float} The current hour. - * - * @see millis - * @see second - * @see minute - * @see month - * @see day - * @see year - */ - p.hour = function hour() { - return new Date().getHours(); - }; - /** - * Processing communicates with the clock on your computer. - * The minute() function returns the current minute as a value from 0 - 59. - * - * @returns {float} The current minute. - * - * @see millis - * @see second - * @see month - * @see hour - * @see day - * @see year - */ - p.minute = function minute() { - return new Date().getMinutes(); - }; - /** - * Processing communicates with the clock on your computer. - * The second() function returns the current second as a value from 0 - 59. - * - * @returns {float} The current minute. - * - * @see millis - * @see month - * @see minute - * @see hour - * @see day - * @see year - */ - p.second = function second() { - return new Date().getSeconds(); - }; - /** - * Returns the number of milliseconds (thousandths of a second) since starting a sketch. - * This information is often used for timing animation sequences. - * - * @returns {long} The number of milliseconds since starting the sketch. - * - * @see month - * @see second - * @see minute - * @see hour - * @see day - * @see year - */ - p.millis = function millis() { - return new Date().getTime() - start; - }; - - /** - * Executes the code within draw() one time. This functions allows the program to update - * the display window only when necessary, for example when an event registered by - * mousePressed() or keyPressed() occurs. - * In structuring a program, it only makes sense to call redraw() within events such as - * mousePressed(). This is because redraw() does not run draw() immediately (it only sets - * a flag that indicates an update is needed). - * Calling redraw() within draw() has no effect because draw() is continuously called anyway. - * - * @returns none - * - * @see noLoop - * @see loop - */ - p.redraw = function redraw() { - var sec = (new Date().getTime() - timeSinceLastFPS) / 1000; - framesSinceLastFPS++; - var fps = framesSinceLastFPS / sec; - - // recalculate FPS every half second for better accuracy. - if (sec > 0.5) { - timeSinceLastFPS = new Date().getTime(); - framesSinceLastFPS = 0; - p.__frameRate = fps; - } - - p.frameCount++; - - inDraw = true; - - if (p.use3DContext) { - // even if the color buffer isn't cleared with background(), - // the depth buffer needs to be cleared regardless. - curContext.clear(curContext.DEPTH_BUFFER_BIT); - curContextCache = { attributes: {}, locations: {} }; - // Delete all the lighting states and the materials the - // user set in the last draw() call. - p.noLights(); - p.lightFalloff(1, 0, 0); - p.shininess(1); - p.ambient(255, 255, 255); - p.specular(0, 0, 0); - p.camera(); - p.draw(); - } else { - saveContext(); - p.draw(); - restoreContext(); - } - - inDraw = false; - }; - - /** - * Stops Processing from continuously executing the code within draw(). If loop() is - * called, the code in draw() begin to run continuously again. If using noLoop() in - * setup(), it should be the last line inside the block. - * When noLoop() is used, it's not possible to manipulate or access the screen inside event - * handling functions such as mousePressed() or keyPressed(). Instead, use those functions - * to call redraw() or loop(), which will run draw(), which can update the screen properly. - * This means that when noLoop() has been called, no drawing can happen, and functions like - * saveFrame() or loadPixels() may not be used. - * Note that if the sketch is resized, redraw() will be called to update the sketch, even - * after noLoop() has been specified. Otherwise, the sketch would enter an odd state until - * loop() was called. - * - * @returns none - * - * @see redraw - * @see draw - * @see loop - */ - p.noLoop = function noLoop() { - doLoop = false; - loopStarted = false; - clearInterval(looping); - }; - - /** - * Causes Processing to continuously execute the code within draw(). If noLoop() is called, - * the code in draw() stops executing. - * - * @returns none - * - * @see noLoop - */ - p.loop = function loop() { - if (loopStarted) { - return; - } - - looping = window.setInterval(function() { - //try { - if (document.hasFocus instanceof Function) { - p.focused = document.hasFocus(); - } - p.redraw(); - //} catch(e_loop) { - //window.clearInterval(looping); - //throw e_loop; - //} - }, curMsPerFrame); - doLoop = true; - loopStarted = true; - }; - - /** - * Specifies the number of frames to be displayed every second. If the processor is not - * fast enough to maintain the specified rate, it will not be achieved. For example, the - * function call frameRate(30) will attempt to refresh 30 times a second. It is recommended - * to set the frame rate within setup(). The default rate is 60 frames per second. - * - * @param {int} aRate number of frames per second. - * - * @returns none - * - * @see delay - */ - p.frameRate = function frameRate(aRate) { - curFrameRate = aRate; - curMsPerFrame = 1000 / curFrameRate; - - // clear and reset interval - if (doLoop) { - p.noLoop(); - p.loop(); - } - }; - - var eventHandlers = []; - - /** - * Quits/stops/exits the program. Programs without a draw() function exit automatically - * after the last line has run, but programs with draw() run continuously until the - * program is manually stopped or exit() is run. - * Rather than terminating immediately, exit() will cause the sketch to exit after draw() - * has completed (or after setup() completes if called during the setup() method). - * - * @returns none - */ - p.exit = function exit() { - window.clearInterval(looping); - - Processing.removeInstance(p.externals.canvas.id); - - // Step through the libraries to detach them - for (var lib in Processing.lib) { - if (Processing.lib.hasOwnProperty(lib)) { - if (Processing.lib[lib].hasOwnProperty("detach")) { - Processing.lib[lib].detach(p); - } - } - } - - for (var i=0, ehl=eventHandlers.length; i 1 || (arguments.length === 1 && arguments[0] instanceof p.PImage)) { - var image = arguments[0], - x, y; - if (arguments.length >= 3) { - x = arguments[1]; - y = arguments[2]; - if (x < 0 || y < 0 || y >= image.height || x >= image.width) { - throw "x and y must be non-negative and less than the dimensions of the image"; - } - } else { - x = image.width >>> 1; - y = image.height >>> 1; - } - - // see https://developer.mozilla.org/en/Using_URL_values_for_the_cursor_property - var imageDataURL = image.toDataURL(); - var style = "url(\"" + imageDataURL + "\") " + x + " " + y + ", default"; - curCursor = curElement.style.cursor = style; - } else if (arguments.length === 1) { - var mode = arguments[0]; - curCursor = curElement.style.cursor = mode; - } else { - curCursor = curElement.style.cursor = oldCursor; - } - }; - - /** - * Hides the cursor from view. - * - * @returns none - * - * @see cursor - */ - p.noCursor = function noCursor() { - curCursor = curElement.style.cursor = PConstants.NOCURSOR; - }; - - /** - * Links to a webpage either in the same window or in a new window. The complete URL - * must be specified. - * - * @param {String} href complete url as a String in quotes - * @param {String} target name of the window to load the URL as a string in quotes - * - * @returns none - */ - p.link = function(href, target) { - if (target !== undef) { - window.open(href, target); - } else { - window.location = href; - } - }; - - // PGraphics methods - // TODO: These functions are suppose to be called before any operations are called on the - // PGraphics object. They currently do nothing. - p.beginDraw = function beginDraw() {}; - p.endDraw = function endDraw() {}; - - // Imports an external Processing.js library - p.Import = function Import(lib) { - // Replace evil-eval method with a DOM - - - - - - - - -
      - - -
      -
      - diff --git a/game/fb/scores/scores.js b/game/fb/scores/scores.js deleted file mode 100644 index d6403b2..0000000 --- a/game/fb/scores/scores.js +++ /dev/null @@ -1,221 +0,0 @@ -var make_scores = function(){ - var obj = {}; - - var num_rows = 15; - - // async gets scores and feeds to callback - var get_scores = function(callback){ - // ajax request to get scores - - // want to do them sequentially so we - // chain the callbacks - - // this comes third via callback - var do_global = function() { - // Global High Scores - $.post("scores/get_scores.php", { - num: num_rows, - }, callback("Global Scores", - // at the end of last callback we need to - // make the tabs - function() { - console.log("making tabs"); - $("#scores").tabs(); - - // remove the loading message - console.log("removing loading msg"); - $("#scores-loading").remove(); - - $("#scores").show(); - } - )); - }; - - // this comes second via callback - var do_friends = function() { - var friends = g_get_friends(); - if (friends.length !== 0) { - // Global High Scores - $.post("scores/get_scores.php", { - num: num_rows, - uid: g_user_id, - friends: friends - }, callback("Friends' Scores", do_global)); - console.log("got friends scores"); - } - else { - do_global(); - console.log("skipped friends scores"); - } - }; - - // this comes first - // Personal high scores - if (g_user_id) { - $.post("scores/get_scores.php", { - num: num_rows, - uid : g_user_id - }, callback("Your Scores", do_friends)); - console.log("getting user high scores"); - } - else { - do_global(); - } - }; - - var get_user_scores = function(callback) { - $.post("scores/get_scores.php", { - num : num_rows - }, callback); - }; - - // interprets json and displays it - // Passing it a header returns the actual function - // Must use this style so long as get_scores is async - // Passing a function as do_more does it at the end of the callback - var tab_count = 1; - var display_scores = function(header, do_more) { - var headers = [ "Rank", "Score", "Level", "Name", "Date" ]; - var formatters = { - "score": add_commas, - "date": function(date_str) { - //var d = new Date(date_str); - var d = new Date(); - // date_str must be of format yyyy-mm-dd - var year = parseInt(date_str.substring(0, 4)); - var month = parseInt(date_str.substring(5, 7))-1; - var day = parseInt(date_str.substring(8)); - d.setFullYear(year, month, day); - //return d.f("NNN d, yyyy"); - return d.format("mmm d, yyyy"); - }, - }; - return function(data){ - //console.log(data); - - var link = "
    • " - + header + "
    • "; - $("#tab-list").append(link); - - // con is the content to put in the score tab - var con = "
      "; - - try { - var scores = jQuery.parseJSON(data); - if (!scores) { - throw "No scores loaded"; - } - } - catch (e) { - con += "
      Error loading scores." - +" Please check your internet connection."; - } - if (scores) { - - con += "
      "; - - // -- start header row -- - con += ""; - for_each(headers, function(header) { - con += ""; - }); - con += ""; - // -- end header row -- - - //console.log(scores); - // scores is an array of row objects - var row_count = 1; - for_each(scores, function(row){ - con += ""; - con += ""; - for_each(keys(row), function(key){ - var f = formatters[key] || function(x) { return x; }; - // dont show uid - if (key !== "userid") { - con += ""; - } - }); - con += ""; - row_count += 1; - }); - // fill up rest of table for beauty's sake - while (row_count <= num_rows) { - con += ""; - for_each(headers, function(header){ - con += ""; - }); - con += ""; - row_count += 1; - } - - con += "
      " + header + "
      " + row_count + "." + f(row[key]) + "
       
      "; - con += ""; - - } - - // add it to page - $("#scores").append(con); - // update tab num - tab_count += 1; - - // do some more stuff if necessary - if (do_more) { - do_more(); - } - }; - }; - - // gets and displays scores - obj.do_scores = function(){ - console.log("trying to load scores"); - $("#scores").empty(); - $("#scores").hide(); - $("#scores").append("
        "); - // reset tab count - tab_count = 1; - get_scores(display_scores); - }; - - // inserts a score into the db - // score_obj: - // - score: int score - // - level: mutation level - // - userid: unique id for the user (from fb?) - var post_score = function(score_obj, callback){ - $.post("scores/post_score.php", score_obj, callback); - }; - - // testing function to use with form - obj.submit_score = function(score, level, name, uid){ - /* - var form = document.forms[0]; - var score = form.elements[0].value; - var level = form.elements[1].value; - var userid = form.elements[2].value; - */ - var date_str = (new Date()).format("yyyy-mm-dd"); - - var score_obj = { - /* - score: parseInt(score), - level: parseInt(level), - */ - score: score, - level: level, - name: name, - userid: uid, - //date: new Date().f('yyyy-MM-dd') - date: date_str - }; - console.log(score_obj); - - post_score(score_obj, function(data){ - console.log(data); - //obj.do_scores(); - }); - }; - - return obj; -} - -var scores = make_scores(); diff --git a/game/fb/seeker.js b/game/fb/seeker.js deleted file mode 100644 index ba3c879..0000000 --- a/game/fb/seeker.js +++ /dev/null @@ -1,127 +0,0 @@ -// ABSTRACT class for game objects that seek other game objects -// Classes that implement must override "my_update" instead of "update" -// --- inherits from object_with_states -// spec: -// game_object spec + -// speed = how fast the seeker approaches the target -// no_target_speed = how fast the object moves when there is no target -// target = object to move towards - -var seeker = function(p, spec) { - - // --- defaults --- - - // obj to return - var obj = object_with_states(p, spec); - - // --- private variables --- - - var speed = spec.speed || 0.2; - var no_target_speed = spec.no_target_speed || 0.2; - var alive = true; - var target = spec.target || null; - // initialized to random val at bottom - var target_angle = 0; - - // --- public methods --- - - // implementing game_object interface - - // update makes tkiller chase target cell - obj.update = function() { - var pos = obj.get_pos(); - var speed_to_use = speed; - - if (target && target.is_dead()) { - target = null; - } - - // if no target - if (target === null) { - // meander - if (parseInt(p.random(150)) === 0) { - target_angle += p.random(-p.PI/16, p.PI/16); - } - // laze - speed_to_use = no_target_speed; - } - else { - obj.face_target(); - } - - // change velocity to point towards target - var new_vel = new p.PVector( - p.cos(target_angle), p.sin(target_angle)); - new_vel.mult(speed_to_use); - obj.set_vel(new_vel); - - obj.my_update(); - }; - - // MUST BE OVERWRITTEN - obj.my_update = function() { - console.log("my_update (in seeker) not overwritten!"); - }; - - // Indicates that a mutation has occured and this object - // should float off the screen - // Makes this object stop and float off screen - obj.outdated = function() { - obj.set_state("outdated"); - obj.set_vel(new p.PVector(0,0)); - obj.set_target(null); - }; - - obj.is_outdated = function() { - return obj.get_state() === "outdated"; - }; - - // faces tar, or if tar not supplied, the object's - // target - obj.face_target = function(tar) { - var pos = obj.get_pos(); - if (target) { - var tpos = target.get_pos(); - } - if (tar) { - var tpos = tar.get_pos(); - } - if (tpos) { - // update target_angle - target_angle = p.atan2(tpos.y-pos.y, tpos.x-pos.x); // y first! - } - }; - - - obj.set_target = function(new_target) { - if (obj.get_state() !== "outdated") { - target = new_target; - } - }; - - obj.set_speed = function(new_speed) { - speed = new_speed; - }; - - obj.set_target_angle = function(new_target_angle) { - target_angle = new_target_angle; - }; - - obj.get_target = function() { - return target; - }; - - obj.get_target_angle = function() { - return target_angle; - }; - - // creates a random angle for init'ing - obj.random_target_angle = function() { - return p.random(-p.PI, p.PI); - //Math.random() * (p.PI * 2) - p.PI; //random angle - }; - target_angle = obj.random_target_angle(); - - - return obj; -} diff --git a/game/fb/settings.js b/game/fb/settings.js deleted file mode 100644 index ef1251b..0000000 --- a/game/fb/settings.js +++ /dev/null @@ -1,61 +0,0 @@ -// Global settings -// Have to be wrapped in an object since primitives are pass-by-value -var game_settings = function() { - var settings = { - sound_fx : true, - music : true, - track: "no track", - click_to_fire : true, - mouse_to_select : false, - spacebar_to_fire : true, - background_color : 0xFF3a0101 - // 0xFF371010 - }; - - var toggle = function(name) { - settings[name] = !settings[name]; - }; - - settings.toggle_sound_fx = function() { toggle("sound_fx"); }; - settings.toggle_click_to_fire = function() { toggle("click_to_fire"); }; - settings.toggle_spacebar_to_fire = function() { toggle("spacebar_to_fire"); }; - settings.toggle_mouse_to_select = function() { toggle("mouse_to_select"); }; - // note that this only toggles the flag, not the actual music - // that should be done with a sound manager method - settings.toggle_music = function() { - toggle("music"); - //console.log(settings.music); - }; - - settings.next_track = function() { - var t = sounds.next_track(); - settings.track = t; - }; - - settings.prev_track = function() { - var t = sounds.prev_track(); - settings.track = t; - }; - - settings.set_track = function(t) { - settings.track = t; - }; - - return settings; -}; -// abbreviate it -var g = game_settings(); - - -//getters -/* -var g_sound_fx_on = function() { - return g_game_settings.sound_fx; -} -var g_music_on = function() { - return g_game_settings.music; -} -var g_click_to_fire = function() { - return g_game_settings.click_to_fire; -} -*/ diff --git a/game/fb/sound.js b/game/fb/sound.js deleted file mode 100644 index 6de2aa9..0000000 --- a/game/fb/sound.js +++ /dev/null @@ -1,345 +0,0 @@ -// sound_manager -// utility object to play or not play sounds -// settings for sound still stored in settings object -var sound_manager = function() { - var obj = {}; - - var the_swf_path = "./jplayer/"; - // Taken from http://www.storiesinflight.com/html5/audio.html - - //g_divs_loaded_init_sounds = function() { - //console.log("AAAAA initing sounds"); - obj.play_sound = (function() { - var channel_max = 10; // number of channels - audiochannels = new Array(); - for (var a=0;a= all_bg_music.length) { - track_index = 0; - } - // pause the old one - obj.pause_background_music(); - // set the new one - set_background_music(); - //obj.play_background_music(); - return all_bg_music[track_index].name; - }; - - obj.prev_track = function() { - track_index -= 1; - if (track_index < 0) { - track_index = all_bg_music.length-1; - } - // pause the old one - obj.pause_background_music(); - // set the new one - set_background_music(); - return all_bg_music[track_index].name; - }; - - // sets the background music to the current track index - var set_background_music = function() { - // note that random must be the LAST track - var music = all_bg_music[track_index].music; - if (!music) { - music = all_bg_music - [Math.floor(Math.random()*(track_index-1))] - .music; - } - assert(music, "Random wasn't the last track index or a music div was undefined."); - background_music = music; - }; - - obj.resume_background_music = function() { - if (background_music) - background_music.jPlayer("play"); - } - - obj.pause_background_music = function() { - console.log("Pausing bg music"); - if (background_music) - background_music.jPlayer("pause"); - }; - - var menu_music = null; - var button_sounds = null; - - // Really resume menu music, menu music never restarts - obj.play_menu_music = function() { - if (g.music) - menu_music.jPlayer("play"); - } - obj.resume_menu_music = function() { - if (g.music) - menu_music.jPlayer("play"); - } - obj.pause_menu_music = function() { - menu_music.jPlayer("pause"); - } - obj.play_button_click = function() { - if (g.sound_fx) - play_a_sound(button_sounds, "buttonmain"); - } - obj.play_button_back = function() { - if (g.sound_fx) - play_a_sound(button_sounds, "buttonback"); - } - - var play_a_sound = function(jplayer_instance, sound_name) { - jplayer_instance.jPlayer("setMedia", { - //mp3 : g_soundDataMap[sound_name + "mp3"], - mp3 : "sounds/" + sound_name + ".mp3", - oga : g_soundDataMap[sound_name] - }); - //jplayer_instance.jPlayer.event.ready = function() {console.log("read");}; - jplayer_instance.jPlayer("play"); - } - - obj.load_sounds = function() { - // init all bg music - var all_supplied = "oga, mp3"; - var init_jplayer = function(name, mp3name, oggname, should_loop) { - $(name).jPlayer( { - swfPath : the_swf_path, - ready: function () { - $(this).jPlayer("setMedia", { - mp3 : "sounds/"+mp3name, - oga : "sounds/"+oggname - }); - //console.log(name + " is ready"); - bg_music_loaded(); - $(this).bind($.jPlayer.event.progress, - function(event) { - //console.log(event.jPlayer.status.seekPercent); - if (event.jPlayer.status.seekPercent === 100) { - //console.log("percent = 100, name: " + mp3name); - //bg_music_loaded(); - } - }); - $(this).bind($.jPlayer.error.NO_SOLUTION, - function(event) { - //bg_music_loaded(); - console.log("No audio solutions"); - }); - }, - ended : function() { // loop - if (should_loop) { - $(this).jPlayer("play"); - } - }, - supplied : all_supplied, - preload : "auto", - oggSupport: true - //errorAlerts : true - }); - } - - var init_bg_jplayer = function(num, file_name, oggfn) { - init_jplayer("#jquery_jplayer_bg_"+num, file_name, oggfn, true) - } - /* - console.log("loading heart loop"); - init_bg_jplayer(0, "heart_loop1.mp3"); - console.log("loaded heart loop"); - */ - console.log("loading sinister"); - init_bg_jplayer(0, "sinister.mp3", "sinister.ogg", true); - console.log("loaded sinister"); - - init_bg_jplayer(1, "gameloop2.mp3", "gameloop2.ogg", true); - init_bg_jplayer(2, "Infiltration.mp3", "Infiltration.ogg", true); - init_bg_jplayer(3, "Incubation.mp3", "Incubation.ogg", true); - - for (var i = 0; i < num_bg_music; i++) { - all_bg_music.push({ - music: $("#jquery_jplayer_bg_"+i), - name: track_names[i] - }); - } - - init_jplayer("#jquery_jplayer_menu", "menu_loop.mp3", "menu_loop.ogg", true); - menu_music = $("#jquery_jplayer_menu"); - - init_jplayer("#jquery_jplayer_buttons", "buttonmain.mp3", "buttonmain.ogg", false); - button_sounds = $("#jquery_jplayer_buttons"); - - // add random option - // THIS MUST BE THE LAST OBJ IN THE ARRAY - all_bg_music.push({ - name: "Random", - // don't try to access this music! - music: null - }); - track_names.push("Random"); - num_bg_music += 1; - track_index = num_bg_music-1; - // set initial track (random) - g.set_track(track_names[track_index]); - }; - - var num_loaded = 0; - var max_loaded = num_bg_music + 2 // + 1 for menu music, + 1 for button - var bg_music_loaded = function() { - num_loaded++; - console.log("Loaded " + num_loaded + " out of " + max_loaded); - }; - - obj.sounds_loaded = function() { - //console.log(num_loaded); - return num_loaded >= max_loaded; - } - return obj; -}; - -// make a global object -var sounds = sound_manager(); - -// to debug without sounds, use this object -/* -var sounds = { - sounds_loaded: function() { return true; }, - play_sound: function() {}, - play_background_music: function() {}, - pause_background_music: function() {}, - resume_background_music: function() {}, - load_sounds: function() {}, -}; -*/ - - - -/* -var jplayer = $("#jquery_jplayer_1").jPlayer( { - ready: function () { - $(this).jPlayer("setMedia", { - oga :g_soundDataMap["kill"] // "/sounds/kill.ogg" - //mp3 : "sounds/heart_loop1.mp3" - }); - $(this).jPlayer("play"); - //asdf_play(); - console.log("ready"); - }, - supplied : "oga" -}); -//$("#jquery_jplayer_1").jPlayer("setMedia", {mp3 : "sounds/heart_loop1.mp3"}); -var asdf_play = function(){ - $("#jquery_jplayer_1").jPlayer("play"); -}; - -*/ diff --git a/game/fb/sounds/Incubation.mp3 b/game/fb/sounds/Incubation.mp3 deleted file mode 100755 index aecc196..0000000 Binary files a/game/fb/sounds/Incubation.mp3 and /dev/null differ diff --git a/game/fb/sounds/Incubation.ogg b/game/fb/sounds/Incubation.ogg deleted file mode 100755 index f15e5eb..0000000 Binary files a/game/fb/sounds/Incubation.ogg and /dev/null differ diff --git a/game/fb/sounds/Infiltration.mp3 b/game/fb/sounds/Infiltration.mp3 deleted file mode 100755 index eb48089..0000000 Binary files a/game/fb/sounds/Infiltration.mp3 and /dev/null differ diff --git a/game/fb/sounds/Infiltration.ogg b/game/fb/sounds/Infiltration.ogg deleted file mode 100755 index 5cce4b5..0000000 Binary files a/game/fb/sounds/Infiltration.ogg and /dev/null differ diff --git a/game/fb/sounds/TextPopUp.mp3 b/game/fb/sounds/TextPopUp.mp3 deleted file mode 100755 index 86bbfc9..0000000 Binary files a/game/fb/sounds/TextPopUp.mp3 and /dev/null differ diff --git a/game/fb/sounds/TextPopUp.ogg b/game/fb/sounds/TextPopUp.ogg deleted file mode 100755 index 237fe4b..0000000 Binary files a/game/fb/sounds/TextPopUp.ogg and /dev/null differ diff --git a/game/fb/sounds/buttonback.mp3 b/game/fb/sounds/buttonback.mp3 deleted file mode 100755 index 730c75f..0000000 Binary files a/game/fb/sounds/buttonback.mp3 and /dev/null differ diff --git a/game/fb/sounds/buttonback.ogg b/game/fb/sounds/buttonback.ogg deleted file mode 100755 index 109a1e9..0000000 Binary files a/game/fb/sounds/buttonback.ogg and /dev/null differ diff --git a/game/fb/sounds/buttonmain.mp3 b/game/fb/sounds/buttonmain.mp3 deleted file mode 100755 index aea705c..0000000 Binary files a/game/fb/sounds/buttonmain.mp3 and /dev/null differ diff --git a/game/fb/sounds/buttonmain.ogg b/game/fb/sounds/buttonmain.ogg deleted file mode 100755 index 81c13d7..0000000 Binary files a/game/fb/sounds/buttonmain.ogg and /dev/null differ diff --git a/game/fb/sounds/cell_fire.mp3 b/game/fb/sounds/cell_fire.mp3 deleted file mode 100755 index 0e3ebf3..0000000 Binary files a/game/fb/sounds/cell_fire.mp3 and /dev/null differ diff --git a/game/fb/sounds/cell_fire.ogg b/game/fb/sounds/cell_fire.ogg deleted file mode 100755 index 7e91316..0000000 Binary files a/game/fb/sounds/cell_fire.ogg and /dev/null differ diff --git a/game/fb/sounds/cell_infect.mp3 b/game/fb/sounds/cell_infect.mp3 deleted file mode 100755 index 5bc1007..0000000 Binary files a/game/fb/sounds/cell_infect.mp3 and /dev/null differ diff --git a/game/fb/sounds/cell_infect.ogg b/game/fb/sounds/cell_infect.ogg deleted file mode 100755 index 57aaaea..0000000 Binary files a/game/fb/sounds/cell_infect.ogg and /dev/null differ diff --git a/game/fb/sounds/gameloop2.mp3 b/game/fb/sounds/gameloop2.mp3 deleted file mode 100755 index 5c8f4c3..0000000 Binary files a/game/fb/sounds/gameloop2.mp3 and /dev/null differ diff --git a/game/fb/sounds/gameloop2.ogg b/game/fb/sounds/gameloop2.ogg deleted file mode 100755 index 1c94d25..0000000 Binary files a/game/fb/sounds/gameloop2.ogg and /dev/null differ diff --git a/game/fb/sounds/kill.mp3 b/game/fb/sounds/kill.mp3 deleted file mode 100755 index 6bdfebe..0000000 Binary files a/game/fb/sounds/kill.mp3 and /dev/null differ diff --git a/game/fb/sounds/kill.ogg b/game/fb/sounds/kill.ogg deleted file mode 100755 index deed4fc..0000000 Binary files a/game/fb/sounds/kill.ogg and /dev/null differ diff --git a/game/fb/sounds/level_up.mp3 b/game/fb/sounds/level_up.mp3 deleted file mode 100755 index 55e3fcf..0000000 Binary files a/game/fb/sounds/level_up.mp3 and /dev/null differ diff --git a/game/fb/sounds/level_up.ogg b/game/fb/sounds/level_up.ogg deleted file mode 100755 index 468cae0..0000000 Binary files a/game/fb/sounds/level_up.ogg and /dev/null differ diff --git a/game/fb/sounds/macrophage_infect.mp3 b/game/fb/sounds/macrophage_infect.mp3 deleted file mode 100755 index 472498e..0000000 Binary files a/game/fb/sounds/macrophage_infect.mp3 and /dev/null differ diff --git a/game/fb/sounds/macrophage_infect.ogg b/game/fb/sounds/macrophage_infect.ogg deleted file mode 100755 index 0a49c6f..0000000 Binary files a/game/fb/sounds/macrophage_infect.ogg and /dev/null differ diff --git a/game/fb/sounds/menu_loop.mp3 b/game/fb/sounds/menu_loop.mp3 deleted file mode 100755 index 10f3c1d..0000000 Binary files a/game/fb/sounds/menu_loop.mp3 and /dev/null differ diff --git a/game/fb/sounds/menu_loop.ogg b/game/fb/sounds/menu_loop.ogg deleted file mode 100755 index 2008e2f..0000000 Binary files a/game/fb/sounds/menu_loop.ogg and /dev/null differ diff --git a/game/fb/sounds/old/Level Up!2 Trimmed.ogg b/game/fb/sounds/old/Level Up!2 Trimmed.ogg deleted file mode 100755 index ee8fa82..0000000 Binary files a/game/fb/sounds/old/Level Up!2 Trimmed.ogg and /dev/null differ diff --git a/game/fb/sounds/old/cell_fire.ogg b/game/fb/sounds/old/cell_fire.ogg deleted file mode 100644 index bbec785..0000000 Binary files a/game/fb/sounds/old/cell_fire.ogg and /dev/null differ diff --git a/game/fb/sounds/old/cell_fire.wav b/game/fb/sounds/old/cell_fire.wav deleted file mode 100644 index 77f1ba9..0000000 Binary files a/game/fb/sounds/old/cell_fire.wav and /dev/null differ diff --git a/game/fb/sounds/old/cell_infect.ogg b/game/fb/sounds/old/cell_infect.ogg deleted file mode 100644 index a3d5cf8..0000000 Binary files a/game/fb/sounds/old/cell_infect.ogg and /dev/null differ diff --git a/game/fb/sounds/old/cell_infect.wav b/game/fb/sounds/old/cell_infect.wav deleted file mode 100644 index 8cb4011..0000000 Binary files a/game/fb/sounds/old/cell_infect.wav and /dev/null differ diff --git a/game/fb/sounds/old/kill.ogg b/game/fb/sounds/old/kill.ogg deleted file mode 100755 index c127f02..0000000 Binary files a/game/fb/sounds/old/kill.ogg and /dev/null differ diff --git a/game/fb/sounds/old/level_up.ogg b/game/fb/sounds/old/level_up.ogg deleted file mode 100755 index d1b818c..0000000 Binary files a/game/fb/sounds/old/level_up.ogg and /dev/null differ diff --git a/game/fb/sounds/old/macrophage_infect.ogg b/game/fb/sounds/old/macrophage_infect.ogg deleted file mode 100644 index 684fc34..0000000 Binary files a/game/fb/sounds/old/macrophage_infect.ogg and /dev/null differ diff --git a/game/fb/sounds/sinister.mp3 b/game/fb/sounds/sinister.mp3 deleted file mode 100755 index 95905df..0000000 Binary files a/game/fb/sounds/sinister.mp3 and /dev/null differ diff --git a/game/fb/sounds/sinister.ogg b/game/fb/sounds/sinister.ogg deleted file mode 100755 index e5e2d94..0000000 Binary files a/game/fb/sounds/sinister.ogg and /dev/null differ diff --git a/game/fb/splash_state.js b/game/fb/splash_state.js deleted file mode 100644 index 2ebe87a..0000000 --- a/game/fb/splash_state.js +++ /dev/null @@ -1,238 +0,0 @@ -var splash_state = function (p) { - - // object to return - var obj = game_state(p); - - // --- private variables --- - - //var header_image = p.loadImage("images/screens/header.png"); - var back_image = image_manager.get_image("mainscreenbase.png"); - var back_color = g.background_color; - - // Buttons - // Have a rectangle representing their position and - // a state to go to when pressed - - var top_row_y = 150; - var btm_row_y = 420; - var left_x_top = 465; - var left_x_btm = 500; - var incr_x = 40; - var incr_y = 60; - var button_style = { - //height: 160, - rect_color: back_color - }; - - // Play menu music - sounds.play_menu_music(); - - var pause_menu_music = function() { - sounds.pause_menu_music(); - }; - - var normal_button = button(p, { - state : function() { - pause_menu_music(); - sounds.play_button_click(); - return in_game_state(p, obj, 2); - }, - rect: { - pos: new p.PVector(left_x_top+2*incr_x, top_row_y), - image: "mnormal.png", - over_image: "mnormal_r.png", - //width: 80, - style: button_style, - } - }); - - var easy_button = button(p, { - state : function() { - pause_menu_music(); - sounds.play_button_click(); - return in_game_state(p, obj, 0); - }, - rect: { - pos: new p.PVector(left_x_top+incr_x, top_row_y+incr_y), - //text : "Easy", - image: "mbeginner.png", - over_image: "mbeginner_r.png", - //width: 80, - style: button_style, - } - }); - - var tut_button = button(p, { - state : function() { - pause_menu_music(); - sounds.play_button_click(); - return in_game_state(p, obj, 1); - }, - rect: { - pos: new p.PVector(left_x_top, top_row_y+2*incr_y), - //text : "Tutorial", - image: "mtutorial.png", - over_image: "mtutorial_r.png", - //width: 80, - style: button_style, - } - }); - - - var help_button = button(p, { - state : function() { - sounds.play_button_click(); - return help_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x_btm, btm_row_y), - image: "mhowtoplay.png", - over_image: "mhowtoplay_r.png", - //width: 100, - style: button_style, - } - }); - - var scores_button = button(p, { - state : function() { - sounds.play_button_click(); - return high_scores_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x_btm+incr_x, btm_row_y+incr_y), - image: "mhighscores.png", - over_image: "mhighscores_r.png", - //text: "High Scores", - //width: 100, - style: button_style, - } - }); - - var options_button = button(p, { - state : function() { - sounds.play_button_click(); - return options_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x_btm+2*incr_x-10, btm_row_y+2*incr_y), - image: "msettings.png", - over_image: "msettings_r.png", - //width: 120, - style: button_style, - } - }); - - var credits_button = button(p, { - state : function() { - sounds.play_button_click(); - return credits_state(p, obj); - }, - rect: { - pos: new p.PVector(p.width-100, 30), - image: "credits.png", - width: 200, - height: 50, - } - }); - - /* - var splash_style = { - width : 170, - height : 40, - text_color: 0xFFEE0000, - rect_color: back_color, - text_size: 30, - text_align: p.LEFT - }; - - var button_x = 500; - var button_top = 150; - var button_sep = 60; - - var start_button = button(p, { - state : function() { return in_game_state(p, obj); }, - rect : { - pos : new p.PVector(button_x, button_top), - style : splash_style, - text : "New Game" - //image : "images/screens/newgame_listcell.png" - } - }); - - var options_button = button(p, { - state : function() { return options_state(p, obj); }, - rect : { - pos : new p.PVector(button_x, button_top+button_sep), - style : splash_style, - text : "Settings" - } - }); - - var help_button = button(p, { - state : function() { return help_state(p, obj); }, - rect : { - pos : new p.PVector(button_x, button_top+2*button_sep), - style : splash_style, - text : "How To Play" - } - }); - /* - var high_scores_button = { - state : high_scores_state(), - rectangle : rectangle(p, { - pos : new p.PVector(20, 20), - width : 20, - height : 20 - }) - }; - */ - - //Not ordered - var all_buttons = [easy_button, tut_button, normal_button, options_button, - help_button, scores_button, credits_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "splash"; - }; - - obj.update = function() { - //do nothing - }; - - obj.key_pressed = function(k) { - if (k === 115 || p.keyCode === 13 || k === 32) { //s, enter, space - obj.set_next_state(start_button.get_state()); - pause_menu_music(); - } - else if (k === 104) { //h - obj.set_next_state(help_button.get_state()); - } - }; - - /* - obj.mouse_moved = function(x, y) { - - for_each( - all_buttons, - function(b) { - b.mouse_moved(x, y); - } - ); - }; - */ - - obj.get_all_buttons = function() { - return all_buttons; - }; - - obj.render = function() { - p.background(back_color); - p.imageMode(p.CENTER); - //p.image(header_image, p.width / 2, 100, p.width * 3/4, 100); - p.image(back_image, p.width/2, p.height/2); - }; - - return obj; -}; diff --git a/game/fb/state_manager.js b/game/fb/state_manager.js deleted file mode 100644 index 811716b..0000000 --- a/game/fb/state_manager.js +++ /dev/null @@ -1,187 +0,0 @@ -// *** state_manager *** -// The game engine; manages all of the games states -// Provides update(), mouse_click(x, y), and key_pressed(k) -// The next state to go to, if applicable, is returned by state.update() - -var state_manager = function (p) { - - // object to return - var obj = {}; - - // --- private variables --- - - var curr_state = loading_state(p); //The currently active state - //p.noLoop(); - var displayed_states = [curr_state]; //THIS MUST ALWAYS BE SORTED BY RENDERING LEVEL - - //A mapping from game states to their rendering levels - var type_to_level = { - "splash": 0, - "loading" : 0, - "game": 1, - "game_over": 2, - "pause": 2, - "credits": 2, - "help": 2, - "options" : 2 - }; - - // --- private methods --- - - //Removes a state from the displayed_states - //The state must be in displayed_states, or will throw an error - function remove_from_displayed(s) { - var index = displayed_states.indexOf(s); - if (index === -1) { - throw "error in remove_from_displayed in state_manager"; - } - displayed_states.splice(index, 1); //remove the element - } - - //Adds a state to displayed_states - //Ensures that displayed_states is sorted by ascending rendering level - var add_to_displayed_states = function(s) { - var render_level = type_to_level[s.get_type()]; - //Insert in the array right before a render level that is higher than it, or - //at the end if none - var inserted = false; - for (var i = 0; i < displayed_states.length; i++) { - var old_render_level = type_to_level[displayed_states[i].get_type()]; - if (old_render_level > render_level) { - displayed_states.splice(i, 0, s); - inserted = true; - } - } - if (inserted === false) { //add to end - displayed_states.push(s); - } - } - - - // --- public methods --- - - //Updates the current state and renders all appropriate states - obj.update = function() { - // Update all the states, and get next_state from curr_state.update_wrapper(); - var next_state = null; - var update_function = function(s) { - if (s === curr_state) { - next_state = s.update_wrapper(); - } - else { - // i see no reason to update not current states - //s.update_wrapper(); - } - }; - for_each(displayed_states, update_function); - - //If we have a new state to go to - if (next_state && next_state !== curr_state) { - //console.log("next is "+next_state.get_type()); - //Figure out if next state is an overlay - var state_type = next_state.get_type(); - var is_overlay = -1; - switch (state_type) { - case "splash": - is_overlay = false; - p.noLoop(); - break; - case "game": - is_overlay = false; - p.loop(); - break; - case "pause": - is_overlay = true; - p.noLoop(); - break; - case "help": - is_overlay = true; - p.noLoop(); - break; - case "game_over": - is_overlay = true; - p.noLoop(); - break; - case "options": - is_overlay = true; - p.noLoop(); - break; - case "loading": - is_overlay = false; - p.loop(); - break; - case "high_scores": - is_overlay = true; - p.noLoop(); - break; - case "credits": - is_overlay = true; - p.noLoop(); - break; - } - - //Error checking - if (is_overlay === -1) { - throw "error in update in state_manager"; - } - - //If overlay, add to displayed, otherwise reset displayed - if (is_overlay) { - // account for multiple overlays - // so we can go back to an overlay - if (member(displayed_states, next_state)) { - remove_from_displayed(curr_state); - } - else { - add_to_displayed_states(next_state); - } - } - else { - displayed_states = [next_state]; - } - curr_state = next_state; - //Potentially a problem, we do this even if not returning to a state - curr_state.resume(); - // updating its buttons - curr_state.update_wrapper(); - } - - for (var i = 0; i < displayed_states.length; i++) { - displayed_states[i].render_wrapper(); - } - - /* - if (curr_state.get_type() !== "game") { - p.noLoop(); - } - else { - p.loop(); - } - */ - }; - - //Passes clicks on to curr_state - obj.mouse_click = function (x, y) { - curr_state.mouse_click_wrapper(x, y); - if (curr_state.get_type() !== "game") { - obj.update(); - } - }; - - obj.key_pressed = function(k) { - curr_state.key_pressed(k); - if (curr_state.get_type() !== "game") { - obj.update(); - } - }; - - obj.mouse_moved = function(x,y) { - curr_state.mouse_moved_wrapper(x, y); - if (curr_state.get_type() !== "game") { - obj.update(); - } - //obj.update(); - } - - return obj; -}; diff --git a/game/fb/test.js b/game/fb/test.js deleted file mode 100644 index cc645eb..0000000 --- a/game/fb/test.js +++ /dev/null @@ -1,92 +0,0 @@ -// all the processing code goes in the function -// which gets passed in a processing instance p -var p_code = function(p) { - - var sm, t1, c1, c2; - - p.setup = function() { - p.size(700, 600); - - // deal with console issues - // TODO move this code - if (!window.console) { - console = { log: function() {} }; - } - Processing.logger = console; - - var f = new p.loadFont("_sans"); - p.textFont(f, 14); - - sm = state_manager(p); - - p.frameRate(30); - }; - - update_counter = 0; - // draw is called repeatedly - p.draw = function() { - update_counter += 1; - if (update_counter === 30) { - //console.log("frame "+p.millis()); - //console.log(p.__frameRate); - update_counter = 0; - } - sm.update(); // Also renders - }; - - //Mouse and Keyboard input - p.keyPressed = function() { - sm.key_pressed(p.key); - }; - p.mousePressed = function() { - sm.mouse_click(p.mouseX, p.mouseY); - }; - p.mouseMoved = function() { - sm.mouse_moved(p.mouseX, p.mouseY); - }; -}; - - -// want this to be global -var sketch; - -var start_game = function() { - // attaches the processing code to the canvas - // note that we need to do this AFTER the canvas element is created - var canvas = document.getElementById("test_canvas"); - sketch = new Processing.Sketch(p_code); - //sketch.options.isTransparent = true; - var pInstance = new Processing(canvas, sketch); -}; -window.onload = start_game; - -/* -var back_code = function(p) { - var tiles = []; - p.setup = function() { - p.size(700, 600); - p.frameRate(30); - tiles.push(background(p, { - pos: new p.PVector(0, 0) - })); - tiles.push(background(p, { - pos: new p.PVector(700, 0) - })); - }; - p.draw = function() { - p.background(200); - for_each(tiles, function(tile) { - tile.update(); - tile.scroll(1); - tile.draw(); - }); - }; -}; -*/ -//var back_canvas = document.getElementById("back_canvas"); -//var backInstance = new Processing(back_canvas, back_code); - -// Make spacebar not move the window down -window.onkeydown = function(e) { - return !(e.keyCode == 32); -}; diff --git a/game/fb/tkiller.js b/game/fb/tkiller.js deleted file mode 100644 index db7d2c0..0000000 --- a/game/fb/tkiller.js +++ /dev/null @@ -1,121 +0,0 @@ -// *** tkiller *** -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards - -var tkiller = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 35; - spec.height = spec.height || 35; - spec.speed = (spec.speed || 1.5) * g_speed_factor; - - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "tkiller"; - }; - - // --- private variables --- - - var alive = true; - /* @pjs preload="images/tcell2.png"; */ - var t_image = image_manager.get_image("tcell_2.png"); - - // Rect to fill in - var rectx_offset = -(8/30)*obj.get_width(); - var recty_offset = -(7/30) * obj.get_height(); - var rect_width = (13 / 30) * obj.get_width(); - var rect_height = (17 / 30) * obj.get_height(); - - - var t_anim = animated_image("t_animation", {anim_rate : 6}); - var t_image; - t_anim.start(); - t_anim.loop(); - - // --- public methods --- - - // implementing game_object interface - - // update makes tkiller chase target cell - obj.my_update = function() { - obj.move(); - obj.set_speed(obj.get_level()/2 + 1); - }; - - // should point towards target - // (triangle for now) - obj.draw = function() { - var pos = obj.get_pos(); - /* - p.pushMatrix(); - - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.fill(50); - p.noStroke(); - - // rightward triangle - p.triangle(-w/2, -h/2, -w/2, h/2, w/2, 0); - - p.popMatrix(); - */ - p.pushMatrix(); - p.imageMode(obj.get_mode()); - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle() + p.PI / 2); - p.fill(obj.get_color()); - p.noStroke(); - p.rectMode(p.CORNER); - p.rect(rectx_offset, recty_offset, rect_width, rect_height); - //p.image(t_image, 0, 0, obj.get_width(), obj.get_height()); - if (obj.get_target() === null) { - t_anim.set_rate(6); - } - else { - t_anim.set_rate(3); - } - t_image = t_anim.get_frame(); - - if (obj.is_illustration()) { - t_image = image_manager.get_image("tcell_2.png"); - // to make it less transparent draw twice - p.image(t_image, 0, 0, - obj.get_width(), obj.get_height()); - } - - p.image(t_image, 0, 0, - obj.get_width(), obj.get_height()); - p.popMatrix(); - }; - - // is_dead just returns whether it isn't alive - obj.is_dead = function() { - return !alive; - }; - - // which means we need a way to die - obj.die = function() { - alive = false; - }; - - obj.stop_animation = function() { - t_anim.pause(); - }; - - obj.resume_animation = function() { - t_anim.start(); - }; - - return obj; -} diff --git a/game/fb/wall_cell.js b/game/fb/wall_cell.js deleted file mode 100644 index 62be000..0000000 --- a/game/fb/wall_cell.js +++ /dev/null @@ -1,63 +0,0 @@ -// *** wall_cell *** -// --- inherits from game_object -// spec: -// game_object spec - -var wall_cell = function(p, spec) { - - var wall_image = image_manager.get_image("wallcell_1.png"); - - // --- defaults --- - - // temporarily dividing by 2 cuz image is too big - spec.width = spec.width || wall_image.width;///2 || 40; - spec.height = spec.height || wall_image.height;///2 || 20; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "wall_cell"; - }; - - // --- private variables --- - - var alive = true; - - // --- public methods --- - - // implementing game_object interface - - // update is back to the default - obj.update = function() { - obj.move(); - }; - - // (rect for now) - obj.draw = function() { - var pos = obj.get_pos(); - /* - p.shapeMode(obj.mode); - - p.fill(100); - p.noStroke(); - - var w = obj.get_width(); - var h = obj.get_height(); - p.rect(pos.x-w/2, pos.y-h/2, w, h); - */ - p.imageMode(obj.get_mode()); - p.image(wall_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - }; - - obj.is_dead = function() { - return !alive; - }; - - obj.die = function() { - alive = false; - }; - - - return obj; -} diff --git a/game/fb/wall_segment.js b/game/fb/wall_segment.js deleted file mode 100644 index db886ac..0000000 --- a/game/fb/wall_segment.js +++ /dev/null @@ -1,114 +0,0 @@ -// list of specs for wall segments to use in the game -// later can include which image/shape to use -// MUST HAVE WIDTH AND HEIGHT SPECIFIED -/* -var wall_specs = [ - { width: 100, height: 51 } - //{ width: 100, height: 30, fill: 0 }, - //{ width: 200, height: 30, fill: 50 }, - //{ width: 50, height: 30, fill: 100 }, - //{ width: 150, height: 30, fill: 150 } -]; -*/ - -// *** wall_segment *** -// --- inherits from game_object -// spec: -// game_object spec -// boolean is_top = true if it is on the top of the screen -// pos should be at bottom left corner -// -// Each wall segment must match up with the other -// wall segments at each end -// Segment images should be formatted for the bottom wall - -var wall_segment = function(p, spec) { - - //var wall_shape = p.loadShape("images/cellwall1draft.svg"); - var wall_image = random_from( - image_manager.get_images("wall_segments")).image; - - // --- defaults --- - - // temporarily dividing by 3 because the images are 3x too big - spec.width = spec.width || wall_image.width;///3;// || 60; - spec.height = spec.height || wall_image.height;///3;// || 60; - spec.fill = spec.fill || 150; - spec.mode = p.CENTER; - // adjust to center coords - spec.pos.add(new p.PVector(spec.width/2, -spec.height/2)); - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "wall_segment"; - }; - - // --- private variables --- - - // --- public methods --- - - obj.get_y_offset = function() { - return obj.get_height()/2; - }; - - // implementing game_object interface - - // update is default (move) - - // (flat rect for now) - obj.draw = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - p.shapeMode(obj.mode); - // all diff colors for testing - p.fill(0);//spec.fill); - p.noStroke(); - - var w = obj.get_width(); - var h = obj.get_height(); - - p.translate(pos.x, pos.y); - - if (spec.is_top) { - p.rotate(p.PI); - } - - //p.rect(-w/2, -h/2, w, h); - p.imageMode(obj.get_mode()); - p.image(wall_image, 0, 0, w, h); - //p.set(0, 0, wall_shape); - //draw(canvas.getContext('2d')); - //var d = new Date(); - //console.log(d.getMilliseconds()); - //canvas.getContext('2d').drawSvg("images/virusFinal.svg", 300, 10, 20, 20); - //console.log(d.getMilliseconds()); - - p.popMatrix(); - }; - - obj.draw_circle = function() {}; - - // walls can't die - obj.is_dead = function() { - return false; - }; - - //var count = 0; - obj.scroll = function(scroll_factor) { - //count += 1; - //if (count === 1) { - //count = 0; - obj.get_pos().add(new p.PVector(obj.get_scroll_dist(), 0)); - //} - }; - - obj.get_scroll_dist = function() { - return -1; - }; - - return obj; -}; - diff --git a/game/old/README b/game/old/README deleted file mode 100644 index e69de29..0000000 diff --git a/game/old/all.js b/game/old/all.js deleted file mode 100644 index 7050da9..0000000 --- a/game/old/all.js +++ /dev/null @@ -1,70 +0,0 @@ -/*1295489895,169565300,JIT Construction: v334085,en_US*/ - -if(!window.FB)window.FB={_apiKey:null,_session:null,_userStatus:'unknown',_logging:true,_inCanvas:((window.location.search.indexOf('fb_sig_in_iframe=1')>-1)||(window.location.search.indexOf('session=')>-1)||(window.location.search.indexOf('signed_request=')>-1)),_https:(window.name.indexOf('_fb_https')>-1),_domain:{api:'https://api.facebook.com/',api_read:'https://api-read.facebook.com/',cdn:'http://static.ak.fbcdn.net/',https_cdn:'https://s-static.ak.fbcdn.net/',graph:'https://graph.facebook.com/',staticfb:'http://static.ak.facebook.com/',https_staticfb:'https://s-static.ak.facebook.com/',www:window.location.protocol+'//www.facebook.com/',https_www:'https://www.facebook.com/'},_locale:null,_localeIsRtl:false,getDomain:function(a){switch(a){case 'api':return FB._domain.api;case 'api_read':return FB._domain.api_read;case 'cdn':return (window.location.protocol=='https:'||FB._https)?FB._domain.https_cdn:FB._domain.cdn;case 'graph':return FB._domain.graph;case 'staticfb':return FB._https?FB._domain.https_staticfb:FB._domain.staticfb;case 'https_staticfb':return FB._domain.https_staticfb;case 'www':return FB._https?FB._domain.https_www:FB._domain.www;case 'https_www':return FB._domain.https_www;}},copy:function(d,c,b,e){for(var a in c)if(b||typeof d[a]==='undefined')d[a]=e?e(c[a]):c[a];return d;},create:function(c,h){var e=window.FB,d=c?c.split('.'):[],a=d.length;for(var b=0;b');e.root.innerHTML='';f=true;window.setTimeout(function(){e.root.innerHTML=b;},0);}else{var c=document.createElement('iframe');c.id=e.id;c.name=e.name;c.onload=FB.Content._callbacks[a];c.scrolling='no';c.style.border='none';c.style.overflow='hidden';if(e.title)c.title=e.title;if(e.className)c.className=e.className;if(e.height)c.style.height=e.height+'px';if(e.width)c.style.width=e.width+'px';e.root.appendChild(c);f=true;c.src=e.url;}},postTarget:function(b){var a=document.createElement('form');a.action=b.url;a.target=b.target;a.method='POST';FB.Content.appendHidden(a);FB.Array.forEach(b.params,function(e,d){if(e!==null&&e!==undefined){var c=document.createElement('input');c.name=d;c.value=e;a.appendChild(c);}});a.submit();a.parentNode.removeChild(a);}}); -FB.provide('Flash',{_minVersions:[[9,0,159,0],[10,0,22,87]],_swfPath:'swf/XdComm.swf',_callbacks:[],init:function(){if(FB.Flash._init)return;FB.Flash._init=true;window.FB_OnFlashXdCommReady=function(){FB.Flash._ready=true;for(var d=0,e=FB.Flash._callbacks.length;d'+''+''+'
        ');FB.Content.appendHidden(b);},hasMinVersion:function(){if(typeof FB.Flash._hasMinVersion==='undefined'){var i,a,b,h=[];try{i=new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');}catch(j){if(navigator.mimeTypes.length>0){var mimeType='application/x-shockwave-flash';if(navigator.mimeTypes[mimeType].enabledPlugin){var name='Shockwave Flash';i=(navigator.plugins[name+' 2.0']||navigator.plugins[name]).description;}}}if(i){var f=i.replace(/\D+/g,',').match(/^,?(.+),?$/)[1].split(',');for(a=0,b=f.length;ag[c])break majorVersion;}};}return FB.Flash._hasMinVersion;},onReady:function(a){FB.Flash.init();if(FB.Flash._ready){window.setTimeout(a,0);}else FB.Flash._callbacks.push(a);}}); -if(!this.JSON)this.JSON={};(function(){function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function')value=value.toJSON(key);if(typeof rep==='function')value=rep.call(holder,key,value);switch(typeof value){case 'string':return quote(value);case 'number':return isFinite(value)?String(value):'null';case 'boolean':case 'null':return String(value);case 'object':if(!value)return 'null';gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i-1?'&':'?')+FB.QS.encode(e));if(h.length>2000)throw new Error('JSONP only support a maximum of 2000 bytes of input.');FB.ApiServer._callbacks[c]=function(i){a&&a(i);delete FB.ApiServer._callbacks[c];g.parentNode.removeChild(g);};g.src=h;document.getElementsByTagName('head')[0].appendChild(g);},flash:function(b,e,c,d,a){if(!window.FB_OnXdHttpResult)window.FB_OnXdHttpResult=function(g,f){FB.ApiServer._callbacks[g](decodeURIComponent(f));};FB.Flash.onReady(function(){var h=FB.getDomain(b)+e,f=FB.QS.encode(d);if(c==='get'){if(h.length+f.length>2000){if(b==='graph')d.method='get';c='post';f=FB.QS.encode(d);}else{h+=(h.indexOf('?')>-1?'&':'?')+f;f='';}}else if(c!=='post'){if(b==='graph')d.method=c;c='post';f=FB.QS.encode(d);}var g=document.XdComm.sendXdHttpRequest(c.toUpperCase(),h,f,null);FB.ApiServer._callbacks[g]=function(i){a&&a(FB.JSON.parse(i));delete FB.ApiServer._callbacks[g];};});}}); -FB.provide('EventProvider',{subscribers:function(){if(!this._subscribersMap)this._subscribersMap={};return this._subscribersMap;},subscribe:function(b,a){var c=this.subscribers();if(!c[b]){c[b]=[a];}else c[b].push(a);},unsubscribe:function(b,a){var c=this.subscribers()[b];FB.Array.forEach(c,function(e,d){if(e==a)c[d]=null;});},monitor:function(d,a){if(!a()){var b=this,c=function(){if(a.apply(a,arguments))b.unsubscribe(d,c);};this.subscribe(d,c);}},clear:function(a){delete this.subscribers()[a];},fire:function(){var a=Array.prototype.slice.call(arguments),b=a.shift();FB.Array.forEach(this.subscribers()[b],function(c){if(c)c.apply(this,a);});}});FB.provide('Event',FB.EventProvider); -FB.provide('Intl',{_punctCharClass:('['+'.!?'+'\u3002'+'\uFF01'+'\uFF1F'+'\u0964'+'\u2026'+'\u0EAF'+'\u1801'+'\u0E2F'+'\uFF0E'+']'),_endsInPunct:function(a){if(typeof a!='string')return false;return a.match(new RegExp(FB.Intl._punctCharClass+'['+')"'+"'"+'\u00BB'+'\u0F3B'+'\u0F3D'+'\u2019'+'\u201D'+'\u203A'+'\u3009'+'\u300B'+'\u300D'+'\u300F'+'\u3011'+'\u3015'+'\u3017'+'\u3019'+'\u301B'+'\u301E'+'\u301F'+'\uFD3F'+'\uFF07'+'\uFF09'+'\uFF3D'+'\s'+']*$'));},_tx:function(d,a){if(a!==undefined)if(typeof a!='object'){FB.log('The second arg to FB.Intl._tx() must be an Object for '+'tx('+d+', ...)');}else{var c;for(var b in a)if(a.hasOwnProperty(b)){if(FB.Intl._endsInPunct(a[b])){c=new RegExp('\{'+b+'\}'+FB.Intl._punctCharClass+'*','g');}else c=new RegExp('\{'+b+'\}','g');d=d.replace(c,a[b]);}}return d;},tx:function(b,a){function c(e,d){void(0);}if(!FB.Intl._stringTable)return null;return FBIntern.Intl._tx(FB.Intl._stringTable[b],a);}}); -FB.provide('String',{trim:function(a){return a.replace(/^\s*|\s*$/g,'');},format:function(a){if(!FB.String.format._formatRE)FB.String.format._formatRE=/(\{[^\}^\{]+\})/g;var b=arguments;return a.replace(FB.String.format._formatRE,function(e,d){var c=parseInt(d.substr(1),10),f=b[c+1];if(f===null||f===undefined)return '';return f.toString();});},escapeHTML:function(b){var a=document.createElement('div');a.appendChild(document.createTextNode(b));return a.innerHTML.replace(/"/g,'"').replace(/'/g,''');},quote:function(c){var a=/["\\\x00-\x1f\x7f-\x9f]/g,b={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};return a.test(c)?'"'+c.replace(a,function(d){var e=b[d];if(e)return e;e=d.charCodeAt();return '\\u00'+Math.floor(e/16).toString(16)+(e%16).toString(16);})+'"':'"'+c+'"';}}); -FB.provide('Dom',{containsCss:function(c,a){var b=' '+c.className+' ';return b.indexOf(' '+a+' ')>=0;},addCss:function(b,a){if(!FB.Dom.containsCss(b,a))b.className=b.className+' '+a;},removeCss:function(b,a){if(FB.Dom.containsCss(b,a)){b.className=b.className.replace(a,'');FB.Dom.removeCss(b,a);}},getStyle:function(a,c){var d=false,b=a.style;if(a.currentStyle){FB.Array.forEach(c.match(/\-([a-z])/g),function(e){c=c.replace(e,e.substr(1,1).toUpperCase());});d=a.currentStyle[c];}else{FB.Array.forEach(c.match(/[A-Z]/g),function(e){c=c.replace(e,'-'+e.toLowerCase());});if(window.getComputedStyle){d=document.defaultView.getComputedStyle(a,null).getPropertyValue(c);if(c=='background-position-y'||c=='background-position-x')if(d=='top'||d=='left')d='0px';}}if(c=='opacity'){if(a.filters&&a.filters.alpha)return d;return d*100;}return d;},setStyle:function(a,c,d){var b=a.style;if(c=='opacity'){if(d>=100)d=99.999;if(d<0)d=0;b.opacity=d/100;b.MozOpacity=d/100;b.KhtmlOpacity=d/100;if(a.filters)if(a.filters.alpha==undefined){a.filter="alpha(opacity="+d+")";}else a.filters.alpha.opacity=d;}else b[c]=d;},addScript:function(b){var a=document.createElement('script');a.type="text/javascript";a.src=b;return document.getElementsByTagName('head')[0].appendChild(a);},addCssRules:function(e,c){if(!FB.Dom._cssRules)FB.Dom._cssRules={};var a=true;FB.Array.forEach(c,function(f){if(!(f in FB.Dom._cssRules)){a=false;FB.Dom._cssRules[f]=true;}});if(a)return;if(FB.Dom.getBrowserType()!='ie'){var d=document.createElement('style');d.type='text/css';d.textContent=e;document.getElementsByTagName('head')[0].appendChild(d);}else try{document.createStyleSheet().cssText=e;}catch(b){if(document.styleSheets[0])document.styleSheets[0].cssText+=e;}},getBrowserType:function(){if(!FB.Dom._browserType){var d=window.navigator.userAgent.toLowerCase(),b=['msie','firefox','safari','gecko'],c=['ie','mozilla','safari','mozilla'];for(var a=0;a=0){FB.Dom._browserType=c[a];break;}}return FB.Dom._browserType;},getViewportInfo:function(){var a=(document.documentElement&&document.compatMode=='CSS1Compat')?document.documentElement:document.body;return {scrollTop:a.scrollTop,scrollLeft:a.scrollLeft,width:self.innerWidth?self.innerWidth:a.clientWidth,height:self.innerHeight?self.innerHeight:a.clientHeight};},ready:function(a){if(FB.Dom._isReady){a();}else FB.Event.subscribe('dom.ready',a);}});(function(){function domReady(){FB.Dom._isReady=true;FB.Event.fire('dom.ready');FB.Event.clear('dom.ready');}if(FB.Dom._isReady||document.readyState=='complete')return domReady();if(document.addEventListener){document.addEventListener('DOMContentLoaded',domReady,false);}else if(document.attachEvent)document.attachEvent('onreadystatechange',domReady);if(FB.Dom.getBrowserType()=='ie'&&window===top)(function(){try{document.documentElement.doScroll('left');}catch(error){setTimeout(arguments.callee,0);return;}domReady();})();var oldonload=window.onload;window.onload=function(){domReady();if(oldonload)if(typeof oldonload=='string'){eval(oldonload);}else oldonload();};})(); -FB.provide('Dialog',{_loaderEl:null,_stack:[],_active:null,_findRoot:function(a){while(a){if(FB.Dom.containsCss(a,'fb_dialog'))return a;a=a.parentNode;}},_showLoader:function(a,c){if(!FB.Dialog._loaderEl){c=parseInt(c,10);c=c?c:460;FB.Dialog._loaderEl=FB.Dialog._findRoot(FB.Dialog.create({content:('
        '+' '+'
        '+'
        '+' Facebook'+'
        '+'
        '+'
        '+''),width:c}));}if(!a)a=function(){};var b=FB.$('fb_dialog_loader_close');FB.Dom.removeCss(b,'fb_hidden');b.onclick=function(){FB.Dialog._hideLoader();a();};FB.Dialog._makeActive(FB.Dialog._loaderEl);},_hideLoader:function(){if(FB.Dialog._loaderEl&&FB.Dialog._loaderEl==FB.Dialog._active)FB.Dialog._loaderEl.style.top='-10000px';},_makeActive:function(b){FB.Dialog._lowerActive();var a={width:parseInt(b.offsetWidth,10),height:parseInt(b.offsetHeight,10)},e=FB.Dom.getViewportInfo(),c=(e.scrollLeft+(e.width-a.width)/2),d=(e.scrollTop+(e.height-a.height)/2.5);b.style.left=(c>0?c:0)+'px';b.style.top=(d>0?d:0)+'px';FB.Dialog._active=b;},_lowerActive:function(){if(!FB.Dialog._active)return;FB.Dialog._active.style.top='-10000px';FB.Dialog._active=null;},_removeStacked:function(a){FB.Dialog._stack=FB.Array.filter(FB.Dialog._stack,function(b){return b!=a;});},create:function(e){e=e||{};if(e.loader)FB.Dialog._showLoader(e.onClose,e.loaderWidth);var d=document.createElement('div'),c=document.createElement('div'),a='fb_dialog';if(e.closeIcon&&e.onClose){var b=document.createElement('a');b.className='fb_dialog_close_icon';b.onclick=e.onClose;d.appendChild(b);}if(FB.Dom.getBrowserType()=='ie'){a+=' fb_dialog_legacy';FB.Array.forEach(['vert_left','vert_right','horiz_top','horiz_bottom','top_left','top_right','bottom_left','bottom_right'],function(g){var h=document.createElement('span');h.className='fb_dialog_'+g;d.appendChild(h);});}else a+=' fb_dialog_advanced';if(e.content)FB.Content.append(e.content,c);d.className=a;var f=parseInt(e.width,10);if(!isNaN(f))d.style.width=f+'px';c.className='fb_dialog_content';d.appendChild(c);FB.Content.append(d);if(e.visible)FB.Dialog.show(d);return c;},show:function(a){a=FB.Dialog._findRoot(a);if(a){FB.Dialog._removeStacked(a);FB.Dialog._hideLoader();FB.Dialog._makeActive(a);FB.Dialog._stack.push(a);}},remove:function(a){a=FB.Dialog._findRoot(a);if(a){var b=FB.Dialog._active==a;FB.Dialog._removeStacked(a);FB.Dialog._hideLoader();if(b)if(FB.Dialog._stack.length>0){FB.Dialog.show(FB.Dialog._stack.pop());}else FB.Dialog._lowerActive();window.setTimeout(function(){a.parentNode.removeChild(a);},3000);}}}); -FB.provide('XD',{_origin:null,_transport:null,_callbacks:{},_forever:{},init:function(a){if(FB.XD._origin)return;if(window.addEventListener&&!window.attachEvent&&window.postMessage){FB.XD._origin=(window.location.protocol+'//'+window.location.host+'/'+FB.guid());FB.XD.PostMessage.init();FB.XD._transport='postmessage';}else if(!a&&FB.Flash.hasMinVersion()){FB.XD._origin=(window.location.protocol+'//'+document.domain+'/'+FB.guid());FB.XD.Flash.init();FB.XD._transport='flash';}else{FB.XD._transport='fragment';FB.XD.Fragment._channelUrl=a||window.location.toString();}},resolveRelation:function(b){var g,d,f=b.split('.'),e=window;for(var a=0,c=f.length;a0)return 'javascript:false;//';var f=FB.getDomain('cdn')+'connect/xd_proxy.php#',c=FB.guid();if(FB.XD._transport=='fragment'){f=FB.XD.Fragment._channelUrl;var d=f.indexOf('#');if(d>0)f=f.substr(0,d);f+=((f.indexOf('?')<0?'?':'&')+FB.XD.Fragment._magic+'#?=&');}if(b)FB.XD._forever[c]=true;FB.XD._callbacks[c]=a;return f+FB.QS.encode({cb:c,origin:FB.XD._origin,relation:e||'opener',transport:FB.XD._transport});},recv:function(b){if(typeof b=='string')b=FB.QS.decode(b);var a=FB.XD._callbacks[b.cb];if(!FB.XD._forever[b.cb])delete FB.XD._callbacks[b.cb];a&&a(b);},PostMessage:{init:function(){var a=FB.XD.PostMessage.onMessage;window.addEventListener?window.addEventListener('message',a,false):window.attachEvent('onmessage',a);},onMessage:function(event){FB.XD.recv(event.data);}},Flash:{init:function(){FB.Flash.onReady(function(){document.XdComm.postMessage_init('FB.XD.Flash.onMessage',FB.XD._origin);});},onMessage:function(a){FB.XD.recv(decodeURIComponent(a));}},Fragment:{_magic:'fb_xd_fragment',checkAndDispatch:function(){var b=window.location.toString(),a=b.substr(b.indexOf('#')+1),c=b.indexOf(FB.XD.Fragment._magic);if(c>0){FB.init=FB.getLoginStatus=FB.api=function(){};document.documentElement.style.display='none';FB.XD.resolveRelation(FB.QS.decode(a).relation).FB.XD.recv(a);}}}});FB.XD.Fragment.checkAndDispatch(); -FB.provide('Arbiter',{inform:function(c,e,f,b){if(window.name.indexOf('app_runner_')===0){var d=FB.JSON.stringify({method:c,params:e});if(window.postMessage){FB.XD.resolveRelation(f||'parent').postMessage(d,'*');return;}else try{window.opener.postMessage(d);return;}catch(a){}}var h=(FB.getDomain((b?'https_':'')+'staticfb')+'connect/canvas_proxy.php#'+FB.QS.encode({method:c,params:FB.JSON.stringify(e||{}),relation:f}));var g=FB.Content.appendHidden('');FB.Content.insertIframe({url:h,root:g,width:1,height:1,onload:function(){setTimeout(function(){g.parentNode.removeChild(g);},10);}});}}); -FB.provide('',{ui:function(e,b){if(!e.method){FB.log('"method" is a required parameter for FB.ui().');return;}var a=FB.UIServer.prepareCall(e,b);if(!a)return;var d=a.params.display;if(d=='dialog')d='iframe';var c=FB.UIServer[d];if(!c){FB.log('"display" must be one of "popup", "iframe" or "hidden".');return;}c(a);}});FB.provide('UIServer',{Methods:{},_active:{},_defaultCb:{},_resultToken:'"xxRESULTTOKENxx"',genericTransform:function(a){if(a.params.display=='dialog'||a.params.display=='iframe'){a.params.display='iframe';a.params.channel=FB.UIServer._xdChannelHandler(a.id,'parent.parent');}return a;},prepareCall:function(h,b){var g=h.method.toLowerCase(),f=FB.UIServer.Methods[g]||{size:{width:575,height:240}},e=FB.guid(),d=FB._https||(g!=='auth.status');FB.copy(h,{api_key:FB._apiKey,app_id:FB._apiKey,locale:FB._locale,sdk:'joey',access_token:d&&FB._session&&FB._session.access_token||undefined});h.display=FB.UIServer.getDisplayMode(f,h);if(!f.url){f.url='dialog/'+g;delete h.method;}var a={cb:b,id:e,size:f.size||{},url:FB.getDomain(d?'https_www':'www')+f.url,params:h};var j=f.transform?f.transform:FB.UIServer.genericTransform;if(j){a=j(a);if(!a)return;}var i=FB.UIServer.getXdRelation(a.params.display);if(!(a.id in FB.UIServer._defaultCb)&&!('next' in a.params))a.params.next=FB.UIServer._xdResult(a.cb,a.id,i,true);if(i==='parent')a.params.channel_url=FB.UIServer._xdChannelHandler(e,'parent.parent');a.params=FB.JSON.flatten(a.params);var c=FB.QS.encode(a.params);if((a.url+c).length>2000){a.post=true;}else if(c)a.url+='?'+c;return a;},getDisplayMode:function(a,b){if(b.display==='hidden')return 'hidden';if(window.name.indexOf('app_runner_')===0)return 'async';if(!FB._session&&b.display=='dialog'&&!a.loggedOutIframe){FB.log('"dialog" mode can only be used when the user is connected.');return 'popup';}return b.display||(FB._session?'dialog':'popup');},getXdRelation:function(a){if(a==='popup')return 'opener';if(a==='dialog'||a==='iframe')return 'parent';if(a==='async')return 'parent.frames['+window.name+']';},popup:function(b){var a=typeof window.screenX!='undefined'?window.screenX:window.screenLeft,i=typeof window.screenY!='undefined'?window.screenY:window.screenTop,g=typeof window.outerWidth!='undefined'?window.outerWidth:document.documentElement.clientWidth,f=typeof window.outerHeight!='undefined'?window.outerHeight:(document.documentElement.clientHeight-22),k=b.size.width,d=b.size.height,h=(a<0)?window.screen.width+a:a,e=parseInt(h+((g-k)/2),10),j=parseInt(i+((f-d)/2.5),10),c=('width='+k+',height='+d+',left='+e+',top='+j+',scrollbars=1');if(b.params.method=='permissions.request')c+=',location=1,toolbar=0';if(b.post){FB.UIServer._active[b.id]=window.open('about:blank',b.id,c);FB.Content.postTarget({url:b.url,target:b.id,params:b.params});}else FB.UIServer._active[b.id]=window.open(b.url,b.id,c);if(b.id in FB.UIServer._defaultCb)FB.UIServer._popupMonitor();},hidden:function(a){a.className='FB_UI_Hidden';a.root=FB.Content.appendHidden('');FB.UIServer._insertIframe(a);},iframe:function(a){a.className='FB_UI_Dialog';a.root=FB.Dialog.create({onClose:function(){FB.UIServer._triggerDefault(a.id);},loader:true,loaderWidth:a.size.width,closeIcon:true});FB.Dom.addCss(a.root,'fb_dialog_iframe');FB.UIServer._insertIframe(a);},async:function(a){a.frame=window.name;delete a.url;delete a.size;FB.Arbiter.inform('showDialog',a);},_insertIframe:function(b){FB.UIServer._active[b.id]=false;var a=function(c){if(b.id in FB.UIServer._active)FB.UIServer._active[b.id]=c;};if(b.post){FB.Content.insertIframe({url:'about:blank',root:b.root,className:b.className,width:b.size.width,height:b.size.height,onload:function(c){a(c);FB.Content.postTarget({url:b.url,target:c.name,params:b.params});}});}else FB.Content.insertIframe({url:b.url,root:b.root,className:b.className,width:b.size.width,height:b.size.height,onload:a});},_triggerDefault:function(a){FB.UIServer._xdRecv({frame:a},FB.UIServer._defaultCb[a]||function(){});},_popupMonitor:function(){var a;for(var b in FB.UIServer._active)if(FB.UIServer._active.hasOwnProperty(b)&&b in FB.UIServer._defaultCb){var c=FB.UIServer._active[b];try{if(c.tagName)continue;}catch(d){}try{if(c.closed){FB.UIServer._triggerDefault(b);}else a=true;}catch(e){}}if(a&&!FB.UIServer._popupInterval){FB.UIServer._popupInterval=window.setInterval(FB.UIServer._popupMonitor,100);}else if(!a&&FB.UIServer._popupInterval){window.clearInterval(FB.UIServer._popupInterval);FB.UIServer._popupInterval=null;}},_xdChannelHandler:function(a,b){return FB.XD.handler(function(c){var d=FB.UIServer._active[a];if(!d)return;if(c.type=='resize'){if(c.height)d.style.height=c.height+'px';if(c.width)d.style.width=c.width+'px';FB.Arbiter.inform('resize.ack',{},'parent.frames['+d.name+']',true);FB.Dialog.show(d);}},b,true);},_xdNextHandler:function(a,b,d,c){if(c)FB.UIServer._defaultCb[b]=a;return FB.XD.handler(function(e){FB.UIServer._xdRecv(e,a);},d)+'&frame='+b;},_xdRecv:function(b,a){var c=FB.UIServer._active[b.frame];try{if(FB.Dom.containsCss(c,'FB_UI_Hidden')){window.setTimeout(function(){c.parentNode.parentNode.removeChild(c.parentNode);},3000);}else if(FB.Dom.containsCss(c,'FB_UI_Dialog'))FB.Dialog.remove(c);}catch(d){}try{if(c.close){c.close();FB.UIServer._popupCount--;}}catch(e){}delete FB.UIServer._active[b.frame];delete FB.UIServer._defaultCb[b.frame];a(b);},_xdResult:function(a,b,d,c){return (FB.UIServer._xdNextHandler(function(e){a&&a(e.result&&e.result!=FB.UIServer._resultToken&&FB.JSON.parse(e.result));},b,d,c)+'&result='+encodeURIComponent(FB.UIServer._resultToken));}}); -FB.provide('',{getLoginStatus:function(a,b){if(!FB._apiKey){FB.log('FB.getLoginStatus() called before calling FB.init().');return;}if(a)if(!b&&FB.Auth._loadState=='loaded'){a({status:FB._userStatus,session:FB._session});return;}else FB.Event.subscribe('FB.loginStatus',a);if(!b&&FB.Auth._loadState=='loading')return;FB.Auth._loadState='loading';var c=function(d){FB.Auth._loadState='loaded';FB.Event.fire('FB.loginStatus',d);FB.Event.clear('FB.loginStatus');};FB.ui({method:'auth.status',display:'hidden'},c);},getSession:function(){return FB._session;},login:function(a,b){FB.ui(FB.copy({method:'permissions.request',display:'popup'},b||{}),a);},logout:function(a){FB.ui({method:'auth.logout',display:'hidden'},a);}});FB.provide('Auth',{_callbacks:[],setSession:function(e,g){var b=!FB._session&&e,c=FB._session&&!e,a=FB._session&&e&&FB._session.uid!=e.uid,f=b||c||(FB._session&&e&&FB._session.access_token!=e.access_token),h=g!=FB._userStatus;var d={session:e,status:g};FB._session=e;FB._userStatus=g;if(f&&FB.Cookie&&FB.Cookie.getEnabled())FB.Cookie.set(e);if(h)FB.Event.fire('auth.statusChange',d);if(c||a)FB.Event.fire('auth.logout',d);if(b||a)FB.Event.fire('auth.login',d);if(f)FB.Event.fire('auth.sessionChange',d);if(FB.Auth._refreshTimer){window.clearTimeout(FB.Auth._refreshTimer);delete FB.Auth._refreshTimer;}if(FB.Auth._loadState&&e&&e.expires)FB.Auth._refreshTimer=window.setTimeout(function(){FB.getLoginStatus(null,true);},1200000);return d;},xdHandler:function(a,b,f,c,e,d){return FB.UIServer._xdNextHandler(FB.Auth.xdResponseWrapper(a,e,d),b,f,c);},xdResponseWrapper:function(a,c,b){return function(d){try{b=FB.JSON.parse(d.session);}catch(f){}if(b)c='connected';if(d.fb_https&&!FB._https)FB._https=true;var e=FB.Auth.setSession(b||null,c);e.perms=d&&d.perms||null;a&&a(e);};}});FB.provide('UIServer.Methods',{'permissions.request':{size:{width:627,height:326},transform:function(a){if(!FB._apiKey){FB.log('FB.login() called before calling FB.init().');return;}if(FB._session&&!a.params.perms){FB.log('FB.login() called when user is already connected.');a.cb&&a.cb({status:FB._userStatus,session:FB._session});return;}a=FB.UIServer.genericTransform(a);a.cb=FB.Auth.xdResponseWrapper(a.cb,FB._userStatus,FB._session);a.params.method='permissions.request';FB.copy(a.params,{fbconnect:FB._inCanvas?0:1,return_session:1,session_version:3});return a;}},'auth.logout':{url:'logout.php',transform:function(a){if(!FB._apiKey){FB.log('FB.logout() called before calling FB.init().');}else if(!FB._session){FB.log('FB.logout() called without a session.');}else{a.params.next=FB.Auth.xdHandler(a.cb,a.id,'parent',false,'unknown');return a;}}},'auth.status':{url:'extern/login_status.php',transform:function(a){var b=a.cb,c=a.id,d=FB.Auth.xdHandler;delete a.cb;FB.copy(a.params,{no_session:d(b,c,'parent',false,'notConnected'),no_user:d(b,c,'parent',false,'unknown'),ok_session:d(b,c,'parent',false,'connected'),session_version:3,extern:FB._inCanvas?0:2});return a;}}}); -FB.provide('Canvas',{_timer:null,_lastSize:{},setSize:function(b){if(typeof b!="object")b={};b=FB.copy(b||{},FB.Canvas._computeContentSize());b=FB.copy(b,{frame:window.name||'iframe_canvas'});if(FB.Canvas._lastSize[b.frame]){var a=FB.Canvas._lastSize[b.frame].height;if(FB.Canvas._lastSize[b.frame].width==b.width&&(b.height<=a&&(a-b.height<=16)))return false;}FB.Canvas._lastSize[b.frame]=b;FB.Arbiter.inform('setSize',b);return true;},setAutoResize:function(b,a){if(a===undefined&&typeof b=="number"){a=b;b=true;}if(b===undefined||b){if(FB.Canvas._timer===null)FB.Canvas._timer=window.setInterval(FB.Canvas.setSize,a||100);FB.Canvas.setSize();}else if(FB.Canvas._timer!==null){window.clearInterval(FB.Canvas._timer);FB.Canvas._timer=null;}},_computeContentSize:function(){var a=document.body,c=document.documentElement,d=0,b=Math.max(Math.max(a.offsetHeight,a.scrollHeight)+a.offsetTop,Math.max(c.offsetHeight,c.scrollHeight)+c.offsetTop);if(a.offsetWidthd)d=f;});if(c.clientLeft>0)d+=(c.clientLeft*2);if(c.clientTop>0)b+=(c.clientTop*2);return {height:b,width:d};}}); -FB.provide('UIServer.Methods',{'stream.share':{size:{width:575,height:380},url:'sharer.php',transform:function(a){if(!a.params.u)a.params.u=window.location.toString();return a;}},'fbml.dialog':{size:{width:575,height:300},url:'render_fbml.php',loggedOutIframe:true,transform:function(a){return a;}},'auth.logintofacebook':{size:{width:530,height:287},url:'login.php',transform:function(a){a.params.skip_api_login=1;var c=FB.UIServer.getXdRelation(a.params.display);var b=FB.UIServer._xdResult(a.cb,a.id,c,true);a.params.next=FB.getDomain(FB._https?'https_www':'www')+"login.php?"+FB.QS.encode({api_key:FB._apiKey,next:b,skip_api_login:1});return a;}}}); -FB.provide('',{share:function(a){FB.log('FB.share() has been deprecated. Please use FB.ui() instead.');FB.ui({display:'popup',method:'stream.share',u:a});},publish:function(b,a){FB.log('FB.publish() has been deprecated. Please use FB.ui() instead.');b=b||{};FB.ui(FB.copy({display:'popup',method:'stream.publish',preview:1},b||{}),a);},addFriend:function(b,a){FB.log('FB.addFriend() has been deprecated. Please use FB.ui() instead.');FB.ui({display:'popup',id:b,method:'friend.add'},a);}});FB.UIServer.Methods['auth.login']=FB.UIServer.Methods['permissions.request']; -FB.provide('XFBML',{_renderTimeout:30000,parse:function(c,a){c=c||document.body;var b=1,d=function(){b--;if(b===0){a&&a();FB.Event.fire('xfbml.render');}};FB.Array.forEach(FB.XFBML._tagInfos,function(f){if(!f.xmlns)f.xmlns='fb';var g=FB.XFBML._getDomElements(c,f.xmlns,f.localName);for(var e=0;e0)FB.log(b+' XFBML tags failed to render in '+FB.XFBML._renderTimeout+'ms.');},FB.XFBML._renderTimeout);d();},registerTag:function(a){FB.XFBML._tagInfos.push(a);},_processElement:function(dom,tagInfo,cb){var element=dom._element;if(element){element.subscribe('render',cb);element.process();}else{var processor=function(){var fn=eval(tagInfo.className);var getBoolAttr=function(attr){var attr=dom.getAttribute(attr);return (attr&&FB.Array.indexOf(['true','1','yes','on'],attr.toLowerCase())>-1);};var isLogin=false;var showFaces=true;var renderInIframe=false;if(tagInfo.className==='FB.XFBML.LoginButton'){renderInIframe=getBoolAttr('render-in-iframe');showFaces=getBoolAttr('show-faces')||getBoolAttr('show_faces');isLogin=renderInIframe||showFaces;if(isLogin)fn=FB.XFBML.Login;}element=dom._element=new fn(dom);if(isLogin){var extraParams={show_faces:showFaces};var perms=dom.getAttribute('perms');if(perms)extraParams.perms=perms;element.setExtraParams(extraParams);}element.subscribe('render',cb);element.process();};if(FB.CLASSES[tagInfo.className.substr(3)]){processor();}else FB.log('Tag '+tagInfo.className+' was not found.');}},_getDomElements:function(a,e,d){var c=e+':'+d;switch(FB.Dom.getBrowserType()){case 'mozilla':return a.getElementsByTagNameNS(document.body.namespaceURI,c);case 'ie':try{var docNamespaces=document.namespaces;if(docNamespaces&&docNamespaces[e]){var nodes=a.getElementsByTagName(d);if(!document.addEventListener||nodes.length>0)return nodes;}}catch(b){}return a.getElementsByTagName(c);default:return a.getElementsByTagName(c);}},_tagInfos:[{localName:'activity',className:'FB.XFBML.Activity'},{localName:'add-profile-tab',className:'FB.XFBML.AddProfileTab'},{localName:'bookmark',className:'FB.XFBML.Bookmark'},{localName:'comments',className:'FB.XFBML.Comments'},{localName:'connect-bar',className:'FB.XFBML.ConnectBar'},{localName:'fan',className:'FB.XFBML.Fan'},{localName:'like',className:'FB.XFBML.Like'},{localName:'like-box',className:'FB.XFBML.LikeBox'},{localName:'live-stream',className:'FB.XFBML.LiveStream'},{localName:'login',className:'FB.XFBML.Login'},{localName:'login-button',className:'FB.XFBML.LoginButton'},{localName:'facepile',className:'FB.XFBML.Facepile'},{localName:'friendpile',className:'FB.XFBML.Friendpile'},{localName:'name',className:'FB.XFBML.Name'},{localName:'profile-pic',className:'FB.XFBML.ProfilePic'},{localName:'recommendations',className:'FB.XFBML.Recommendations'},{localName:'registration',className:'FB.XFBML.Registration'},{localName:'send',className:'FB.XFBML.Send'},{localName:'serverfbml',className:'FB.XFBML.ServerFbml'},{localName:'share-button',className:'FB.XFBML.ShareButton'},{localName:'social-bar',className:'FB.XFBML.SocialBar'}]});(function(){try{if(document.namespaces&&!document.namespaces.item.fb)document.namespaces.add('fb');}catch(a){}}()); -FB.provide('XFBML',{set:function(b,c,a){FB.log('FB.XFBML.set() has been deprecated.');b.innerHTML=c;FB.XFBML.parse(b,a);}}); -FB.provide('',{bind:function(){var a=Array.prototype.slice.call(arguments),c=a.shift(),b=a.shift();return function(){return c.apply(b,a.concat(Array.prototype.slice.call(arguments)));};},Class:function(b,a,d){if(FB.CLASSES[b])return FB.CLASSES[b];var c=a||function(){};c.prototype=d;c.prototype.bind=function(e){return FB.bind(e,this);};c.prototype.constructor=c;FB.create(b,c);FB.CLASSES[b]=c;return c;},subclass:function(d,b,c,e){if(FB.CLASSES[d])return FB.CLASSES[d];var a=FB.create(b);FB.copy(e,a.prototype);e._base=a;e._callBase=function(g){var f=Array.prototype.slice.call(arguments,1);return a.prototype[g].apply(this,f);};return FB.Class(d,c?c:function(){if(a.apply)a.apply(this,arguments);},e);},CLASSES:{}});FB.provide('Type',{isType:function(a,b){while(a)if(a.constructor===b||a===b){return true;}else a=a._base;return false;}}); -FB.Class('Obj',null,FB.copy({setProperty:function(a,b){if(FB.JSON.stringify(b)!=FB.JSON.stringify(this[a])){this[a]=b;this.fire(a,b);}}},FB.EventProvider)); -FB.subclass('Waitable','Obj',function(){},{set:function(a){this.setProperty('value',a);},error:function(a){this.fire("error",a);},wait:function(a,b){if(b)this.subscribe('error',b);this.monitor('value',this.bind(function(){if(this.value!==undefined){a(this.value);return true;}}));}}); -FB.subclass('Data.Query','Waitable',function(){if(!FB.Data.Query._c)FB.Data.Query._c=1;this.name='v_'+FB.Data.Query._c++;},{parse:function(a){var b=FB.String.format.apply(null,a),d=(/^select (.*?) from (\w+)\s+where (.*)$/i).exec(b);this.fields=this._toFields(d[1]);this.table=d[2];this.where=this._parseWhere(d[3]);for(var c=1;c-1){return d;}else return b;});},isValid:function(){for(var a=this.dom;a;a=a.parentNode)if(a==document.body)return true;},clear:function(){this.dom.innerHTML='';}},FB.EventProvider)); -FB.subclass('XFBML.IframeWidget','XFBML.Element',null,{_showLoader:true,_refreshOnAuthChange:false,_allowReProcess:false,_fetchPreCachedLoader:false,_visibleAfter:'load',getUrlBits:function(){throw new Error('Inheriting class needs to implement getUrlBits().');},setupAndValidate:function(){return true;},oneTimeSetup:function(){},getSize:function(){},getIframeName:function(){},getIframeTitle:function(){},getChannelUrl:function(){if(!this._channelUrl){var a=this;this._channelUrl=FB.XD.handler(function(b){a.fire('xd.'+b.type,b);},'parent.parent',true);}return this._channelUrl;},getIframeNode:function(){return this.dom.getElementsByTagName('iframe')[0];},process:function(a){if(this._done){if(!this._allowReProcess&&!a)return;this.clear();}else this._oneTimeSetup();this._done=true;if(!this.setupAndValidate()){this.fire('render');return;}if(this._showLoader)this._addLoader();FB.Dom.addCss(this.dom,'fb_iframe_widget');if(this._visibleAfter!='immediate'){FB.Dom.addCss(this.dom,'fb_hide_iframes');}else this.subscribe('iframe.onload',FB.bind(this.fire,this,'render'));var c=this.getSize()||{};var d=this._getURL();if(!this._fetchPreCachedLoader)d+='?'+FB.QS.encode(this._getQS());if(d.length>2000){d='about:blank';var b=FB.bind(function(){this._postRequest();this.unsubscribe('iframe.onload',b);},this);this.subscribe('iframe.onload',b);}FB.Content.insertIframe({url:d,root:this.dom.appendChild(document.createElement('span')),name:this.getIframeName(),title:this.getIframeTitle(),className:FB._localeIsRtl?'fb_rtl':'fb_ltr',height:c.height,width:c.width,onload:FB.bind(this.fire,this,'iframe.onload')});},_oneTimeSetup:function(){this.subscribe('xd.resize',FB.bind(this._handleResizeMsg,this));if(FB.getLoginStatus){this.subscribe('xd.refreshLoginStatus',FB.bind(FB.getLoginStatus,FB,function(){},true));this.subscribe('xd.logout',FB.bind(FB.logout,FB,function(){}));}if(this._refreshOnAuthChange)this._setupAuthRefresh();if(this._visibleAfter=='load')this.subscribe('iframe.onload',FB.bind(this._makeVisible,this));this.oneTimeSetup();},_makeVisible:function(){this._removeLoader();FB.Dom.removeCss(this.dom,'fb_hide_iframes');this.fire('render');},_setupAuthRefresh:function(){FB.getLoginStatus(FB.bind(function(b){var a=b.status;FB.Event.subscribe('auth.statusChange',FB.bind(function(c){if(!this.isValid())return;if(a=='unknown'||c.status=='unknown')this.process(true);a=c.status;},this));},this));},_handleResizeMsg:function(b){if(!this.isValid())return;var a=this.getIframeNode();a.style.height=b.height+'px';if(b.width)a.style.width=b.width+'px';a.style.border='none';this._makeVisible();},_addLoader:function(){if(!this._loaderDiv){FB.Dom.addCss(this.dom,'fb_iframe_widget_loader');this._loaderDiv=document.createElement('div');this._loaderDiv.className='FB_Loader';this.dom.appendChild(this._loaderDiv);}},_removeLoader:function(){if(this._loaderDiv){FB.Dom.removeCss(this.dom,'fb_iframe_widget_loader');if(this._loaderDiv.parentNode)this._loaderDiv.parentNode.removeChild(this._loaderDiv);this._loaderDiv=null;}},_getQS:function(){return FB.copy({api_key:FB._apiKey,locale:FB._locale,sdk:'joey',session_key:FB._session&&FB._session.session_key,ref:this.getAttribute('ref')},this.getUrlBits().params);},_getURL:function(){var a='www',b='';if(this._fetchPreCachedLoader){a='cdn';b='static/';}return FB.getDomain(a)+'plugins/'+b+this.getUrlBits().name+'.php';},_postRequest:function(){FB.Content.postTarget({url:this._getURL(),target:this.getIframeNode().name,params:this._getQS()});}}); -FB.subclass('XFBML.Activity','XFBML.IframeWidget',null,{_visibleAfter:'load',_refreshOnAuthChange:true,setupAndValidate:function(){this._attr={border_color:this.getAttribute('border-color'),colorscheme:this.getAttribute('color-scheme'),filter:this.getAttribute('filter'),font:this.getAttribute('font'),header:this._getBoolAttribute('header'),height:this._getPxAttribute('height',300),recommendations:this._getBoolAttribute('recommendations'),site:this.getAttribute('site',location.hostname),width:this._getPxAttribute('width',300)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'activity',params:this._attr};}}); -FB.subclass('XFBML.ButtonElement','XFBML.Element',null,{_allowedSizes:['icon','small','medium','large','xlarge'],onClick:function(){throw new Error('Inheriting class needs to implement onClick().');},setupAndValidate:function(){return true;},getButtonMarkup:function(){return this.getOriginalHTML();},getOriginalHTML:function(){return this._originalHTML;},process:function(){if(!('_originalHTML' in this))this._originalHTML=FB.String.trim(this.dom.innerHTML);if(!this.setupAndValidate()){this.fire('render');return;}var d=this._getAttributeFromList('size','medium',this._allowedSizes),a='',b='';if(d=='icon'){a='fb_button_simple';}else{var c=FB._localeIsRtl?'_rtl':'';b=this.getButtonMarkup();a='fb_button'+c+' fb_button_'+d+c;}this.dom.innerHTML=(''+''+b+''+'');this.dom.firstChild.onclick=FB.bind(this.onClick,this);this.fire('render');}}); -FB.provide('Helper',{isUser:function(a){return a<2.2e+09||(a>=1e+14&&a<=100099999989999);},getLoggedInUser:function(){return FB._session?FB._session.uid:null;},upperCaseFirstChar:function(a){if(a.length>0){return a.substr(0,1).toUpperCase()+a.substr(1);}else return a;},getProfileLink:function(c,b,a){a=a||(c?FB.getDomain('www')+'profile.php?id='+c.uid:null);if(a)b=''+b+'';return b;},invokeHandler:function(handler,scope,args){if(handler)if(typeof handler==='string'){eval(handler);}else if(handler.apply)handler.apply(scope,args||[]);},fireEvent:function(a,b){var c=b._attr.href;b.fire(a,c);FB.Event.fire(a,c,b);},executeFunctionByName:function(d){var a=Array.prototype.slice.call(arguments,1);var f=d.split(".");var c=f.pop();var b=window;for(var e=0;e0){a.xid=encodeURIComponent(document.URL.substring(0,b));}else a.xid=encodeURIComponent(document.URL);}if(a.migrated&&!a.href)a.href='http://www.facebook.com/plugins/comments_v1.php?'+'app_id='+FB._apiKey+'&xid='+encodeURIComponent(a.xid)+'&url='+encodeURIComponent(a.url);this._attr=a;return true;},oneTimeSetup:function(){this.subscribe('xd.addComment',FB.bind(this._handleCommentMsg,this));},getSize:function(){return {width:this._attr.width,height:200};},getUrlBits:function(){return {name:'comments',params:this._attr};},_handleCommentMsg:function(a){if(!this.isValid())return;FB.Event.fire('comments.add',{post:a.post,user:a.user,widget:this});}}); -FB.provide('Anim',{ate:function(c,g,d,b){d=!isNaN(parseFloat(d))&&d>=0?d:750;var e=40,f={},j={},a=null,h=c.style,i=setInterval(FB.bind(function(){if(!a)a=new Date().getTime();var k=1;if(d!=0)k=Math.min((new Date().getTime()-a)/d,1);FB.Array.forEach(g,FB.bind(function(o,m){if(!f[m]){var n=FB.Dom.getStyle(c,m);if(n===false)return;f[m]=this._parseCSS(n+'');}if(!j[m])j[m]=this._parseCSS(o.toString());var l='';FB.Array.forEach(f[m],function(q,p){if(isNaN(j[m][p].numPart)&&j[m][p].textPart=='?'){l=q.numPart+q.textPart;}else if(isNaN(q.numPart)){l=q.textPart;}else l+=(q.numPart+Math.ceil((j[m][p].numPart-q.numPart)*Math.sin(Math.PI/2*k)))+j[m][p].textPart+' ';});FB.Dom.setStyle(c,m,l);},this));if(k==1){clearInterval(i);if(b)b(c);}},this),e);},_parseCSS:function(a){var b=[];FB.Array.forEach(a.split(' '),function(d){var c=parseInt(d,10);b.push({numPart:c,textPart:d.replace(c,'')});});return b;}}); -FB.provide('Insights',{impression:function(e,a){var b=FB.guid(),g="//ah8.facebook.com/impression.php/"+b+"/",c=new Image(1,1),f=[];if(!e.api_key&&FB._apiKey)e.api_key=FB._apiKey;for(var d in e)f.push(encodeURIComponent(d)+'='+encodeURIComponent(e[d]));g+='?'+f.join('&');if(a)c.onload=a;c.src=g;}}); -FB.subclass('XFBML.ConnectBar','XFBML.Element',null,{_initialHeight:null,_initTopMargin:0,_picFieldName:'pic_square',_page:null,_displayed:false,_notDisplayed:false,_container:null,_animationSpeed:0,process:function(){FB.getLoginStatus(this.bind(function(a){FB.Event.monitor('auth.statusChange',this.bind(function(){if(this.isValid()&&FB._userStatus=='connected'){this._uid=FB.Helper.getLoggedInUser();FB.api({method:'Connect.shouldShowConnectBar'},this.bind(function(b){if(b!=2){this._animationSpeed=(b==0)?750:0;this._showBar();}else this._noRender();}));}else this._noRender();return false;}));}));},_showBar:function(){var a=FB.Data._selectByIndex(['first_name','profile_url',this._picFieldName],'user','uid',this._uid);var b=FB.Data._selectByIndex(['display_name'],'application','api_key',FB._apiKey);FB.Data.waitOn([a,b],FB.bind(function(c){c[0][0].site_name=c[1][0].display_name;if(!this._displayed){this._displayed=true;this._notDisplayed=false;this._renderConnectBar(c[0][0]);this.fire('render');FB.Insights.impression({lid:104,name:'widget_load'});this.fire('connectbar.ondisplay');FB.Event.fire('connectbar.ondisplay',this);FB.Helper.invokeHandler(this.getAttribute('on-display'),this);}},this));},_noRender:function(){if(this._displayed){this._displayed=false;this._closeConnectBar();}if(!this._notDisplayed){this._notDisplayed=true;this.fire('render');this.fire('connectbar.onnotdisplay');FB.Event.fire('connectbar.onnotdisplay',this);FB.Helper.invokeHandler(this.getAttribute('on-not-display'),this);}},_renderConnectBar:function(d){var b=document.createElement('div'),c=document.createElement('div');b.className='fb_connect_bar';c.className='fb_reset fb_connect_bar_container';c.appendChild(b);document.body.appendChild(c);this._container=c;this._initialHeight=Math.round(parseFloat(FB.Dom.getStyle(c,'height'))+parseFloat(FB.Dom.getStyle(c,'borderBottomWidth')));b.innerHTML=FB.String.format('
        '+''+'{2}'+''+'
        '+''+'{4}'+''+'{5}'+' '+'{6} – '+'{0}'+'',FB.Intl._tx("No Thanks"),FB.getDomain('cdn')+FB.XFBML.ConnectBar.imgs.buttonUrl,FB.Intl._tx("Close"),d[this._picFieldName]||FB.getDomain('cdn')+FB.XFBML.ConnectBar.imgs.missingProfileUrl,FB.String.escapeHTML(d.first_name),FB.Intl._tx("Hi {firstName}. \u003cstrong>{siteName}\u003c\/strong> is using Facebook to personalize your experience.",{firstName:FB.String.escapeHTML(d.first_name),siteName:FB.String.escapeHTML(d.site_name)}),FB.Intl._tx("Learn More"),d.profile_url,FB.getDomain('www')+'sitetour/connect.php');var a=this;FB.Array.forEach(b.getElementsByTagName('a'),function(g){g.onclick=FB.bind(a._clickHandler,a);});this._page=document.body;var f=0;if(this._page.parentNode){f=Math.round((parseFloat(FB.Dom.getStyle(this._page.parentNode,'height'))-parseFloat(FB.Dom.getStyle(this._page,'height')))/2);}else f=parseInt(FB.Dom.getStyle(this._page,'marginTop'),10);f=isNaN(f)?0:f;this._initTopMargin=f;if(!window.XMLHttpRequest){c.className+=" fb_connect_bar_container_ie6";}else{c.style.top=(-1*this._initialHeight)+'px';FB.Anim.ate(c,{top:'0px'},this._animationSpeed);}var e={marginTop:this._initTopMargin+this._initialHeight+'px'};if(FB.Dom.getBrowserType()=='ie'){e.backgroundPositionY=this._initialHeight+'px';}else e.backgroundPosition='? '+this._initialHeight+'px';FB.Anim.ate(this._page,e,this._animationSpeed);},_clickHandler:function(a){a=a||window.event;var b=a.target||a.srcElement;while(b.nodeName!='A')b=b.parentNode;switch(b.className){case 'fb_bar_close':FB.api({method:'Connect.connectBarMarkAcknowledged'});FB.Insights.impression({lid:104,name:'widget_user_closed'});this._closeConnectBar();break;case 'fb_learn_more':case 'fb_profile':window.open(b.href);break;case 'fb_no_thanks':this._closeConnectBar();FB.api({method:'Connect.connectBarMarkAcknowledged'});FB.Insights.impression({lid:104,name:'widget_user_no_thanks'});FB.api({method:'auth.revokeAuthorization',block:true},this.bind(function(){this.fire('connectbar.ondeauth');FB.Event.fire('connectbar.ondeauth',this);FB.Helper.invokeHandler(this.getAttribute('on-deauth'),this);if(this._getBoolAttribute('auto-refresh',true))window.location.reload();}));break;}return false;},_closeConnectBar:function(){this._notDisplayed=true;var a={marginTop:this._initTopMargin+'px'};if(FB.Dom.getBrowserType()=='ie'){a.backgroundPositionY='0px';}else a.backgroundPosition='? 0px';var b=(this._animationSpeed==0)?0:300;FB.Anim.ate(this._page,a,b);FB.Anim.ate(this._container,{top:(-1*this._initialHeight)+'px'},b,function(c){c.parentNode.removeChild(c);});this.fire('connectbar.onclose');FB.Event.fire('connectbar.onclose',this);FB.Helper.invokeHandler(this.getAttribute('on-close'),this);}});FB.provide('XFBML.ConnectBar',{imgs:{buttonUrl:'images/facebook-widgets/close_btn.png',missingProfileUrl:'pics/q_silhouette.gif'}}); -FB.subclass('XFBML.Facepile','XFBML.IframeWidget',null,{_visibleAfter:'load',_extraParams:{},setupAndValidate:function(){this._attr={href:this.getAttribute('href'),channel:this.getChannelUrl(),max_rows:this.getAttribute('max-rows'),width:this._getPxAttribute('width',200),ref:this.getAttribute('ref')};for(var a in this._extraParams)this._attr[a]=this._extraParams[a];return true;},setExtraParams:function(a){this._extraParams=a;},oneTimeSetup:function(){var a=FB._userStatus;FB.Event.subscribe('auth.statusChange',FB.bind(function(b){if(a=='connected'||b.status=='connected')this.process(true);a=b.status;},this));},getSize:function(){return {width:this._attr.width,height:70};},getUrlBits:function(){return {name:'facepile',params:this._attr};}}); -FB.subclass('XFBML.Fan','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={api_key:FB._apiKey,connections:this.getAttribute('connections','10'),css:this.getAttribute('css'),height:this._getPxAttribute('height'),id:this.getAttribute('profile-id'),logobar:this._getBoolAttribute('logo-bar'),name:this.getAttribute('name'),stream:this._getBoolAttribute('stream',true),width:this._getPxAttribute('width',300)};if(!this._attr.id&&!this._attr.name){FB.log(' requires one of the "id" or "name" attributes.');return false;}var a=this._attr.height;if(!a)if((!this._attr.connections||this._attr.connections==='0')&&!this._attr.stream){a=65;}else if(!this._attr.connections||this._attr.connections==='0'){a=375;}else if(!this._attr.stream){a=250;}else a=550;if(this._attr.logobar)a+=25;this._attr.height=a;return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'fan',params:this._attr};}}); -FB.subclass('XFBML.Friendpile','XFBML.Facepile',null,{}); -FB.subclass('XFBML.EdgeCommentWidget','XFBML.IframeWidget',function(a){this._iframeWidth=a.width;this._iframeHeight=a.height;this._attr={master_frame_name:a.masterFrameName};this.dom=a.commentNode;this.dom.style.top=a.relativeHeightOffset;if(a.relativeWidthOffset)if(FB._localeIsRtl){this.dom.style.right=a.relativeWidthOffset;}else this.dom.style.left=a.relativeWidthOffset;this.dom.style.zIndex=FB.XFBML.EdgeCommentWidget.NextZIndex++;FB.Dom.addCss(this.dom,'fb_edge_comment_widget');},{_visibleAfter:'load',_showLoader:false,getSize:function(){return {width:this._iframeWidth,height:this._iframeHeight};},getUrlBits:function(){return {name:'comment_widget_shell',params:this._attr};}});FB.provide('XFBML.EdgeCommentWidget',{NextZIndex:10000}); -FB.subclass('XFBML.EdgeWidget','XFBML.IframeWidget',null,{_visibleAfter:'immediate',_showLoader:false,setupAndValidate:function(){FB.Dom.addCss(this.dom,'fb_edge_widget_with_comment');this._attr={channel_url:this.getChannelUrl(),debug:this._getBoolAttribute('debug'),href:this.getAttribute('href',window.location.href),is_permalink:this._getBoolAttribute('is-permalink'),node_type:this.getAttribute('node-type','link'),width:this._getWidgetWidth(),font:this.getAttribute('font'),layout:this._getLayout(),colorscheme:this.getAttribute('color-scheme'),action:this.getAttribute('action'),ref:this.getAttribute('ref'),show_faces:this._shouldShowFaces(),no_resize:this._getBoolAttribute('no_resize')};return true;},oneTimeSetup:function(){this.subscribe('xd.edgeCreated',FB.bind(this._onEdgeCreate,this));this.subscribe('xd.edgeRemoved',FB.bind(this._onEdgeRemove,this));this.subscribe('xd.presentEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogPresentation,this));this.subscribe('xd.dismissEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogDismissal,this));this.subscribe('xd.hideEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogHide,this));this.subscribe('xd.showEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogShow,this));},getSize:function(){return {width:this._getWidgetWidth(),height:this._getWidgetHeight()};},_getWidgetHeight:function(){var a=this._getLayout();var c=this._shouldShowFaces()?'show':'hide';var b={standard:{show:80,hide:35},box_count:{show:65,hide:65},button_count:{show:21,hide:21}};return b[a][c];},_getWidgetWidth:function(){var e=this._getLayout();var g=this._shouldShowFaces()?'show':'hide';var c=this.getAttribute('action')==='recommend'?130:90;var b=this.getAttribute('action')==='recommend'?100:55;var f={standard:{show:450,hide:450},box_count:{show:b,hide:b},button_count:{show:c,hide:c}};var d=f[e][g];var h=this._getPxAttribute('width',d);var a={standard:{min:225,max:900},box_count:{min:b,max:900},button_count:{min:c,max:900}};if(ha[e].max)h=a[e].max;return h;},_getLayout:function(){return this._getAttributeFromList('layout','standard',['standard','button_count','box_count']);},_shouldShowFaces:function(){return this._getLayout()==='standard'&&this._getBoolAttribute('show-faces',true);},_handleEdgeCommentDialogPresentation:function(b){if(!this.isValid())return;var a=document.createElement('span');this._commentSlave=this._createEdgeCommentWidget(b,a);this.dom.appendChild(a);this._commentSlave.process();this._commentWidgetNode=a;},_createEdgeCommentWidget:function(b,a){var c={commentNode:a,externalUrl:b.externalURL,width:330,height:200,masterFrameName:b.masterFrameName,layout:this._getLayout(),relativeHeightOffset:this._getHeightOffset(),relativeWidthOffset:this._getWidthOffset(b)};return new FB.XFBML.EdgeCommentWidget(c);},_getHeightOffset:function(){var a=this._getLayout();var b={standard:'20px',button_count:'17px',box_count:'-5px'};return b[a];},_getWidthOffset:function(c){if(c.preComputedWidthOffset)return parseInt(c.preComputedWidthOffset,10)+'px';var a=this._getLayout();var b={standard:'17px',box_count:'0px',button_count:'0px'};return b[a];},_handleEdgeCommentDialogDismissal:function(a){if(this._commentWidgetNode){this.dom.removeChild(this._commentWidgetNode);delete this._commentWidgetNode;}},_handleEdgeCommentDialogHide:function(){if(this._commentWidgetNode)this._commentWidgetNode.style.display="none";},_handleEdgeCommentDialogShow:function(){if(this._commentWidgetNode)this._commentWidgetNode.style.display="block";},_fireEventAndInvokeHandler:function(b,a){FB.Helper.fireEvent(b,this);FB.Helper.invokeHandler(this.getAttribute(a),this,[this._attr.href]);},_onEdgeCreate:function(){this._fireEventAndInvokeHandler('edge.create','on-create');},_onEdgeRemove:function(){this._fireEventAndInvokeHandler('edge.remove','on-remove');}}); -FB.subclass('XFBML.Like','XFBML.EdgeWidget',null,{getUrlBits:function(){return {name:'like',params:this._attr};},getIframeTitle:function(){return 'Like this content on Facebook.';}}); -FB.subclass('XFBML.LikeBox','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={channel:this.getChannelUrl(),api_key:FB._apiKey,connections:this.getAttribute('connections'),css:this.getAttribute('css'),height:this.getAttribute('height'),id:this.getAttribute('profile-id'),header:this._getBoolAttribute('header',true),name:this.getAttribute('name'),show_faces:this._getBoolAttribute('show-faces',true),stream:this._getBoolAttribute('stream',true),width:this._getPxAttribute('width',300),href:this.getAttribute('href'),colorscheme:this.getAttribute('colorscheme','light')};if(this._attr.connections==='0'){this._attr.show_faces=false;}else if(this._attr.connections)this._attr.show_faces=true;if(!this._attr.id&&!this._attr.name&&!this._attr.href){FB.log(' requires one of the "id" or "name" attributes.');return false;}var a=this._attr.height;if(!a)if(!this._attr.show_faces&&!this._attr.stream){a=62;}else{a=95;if(this._attr.show_faces)a+=163;if(this._attr.stream)a+=300;if(this._attr.header&&this._attr.header!=='0')a+=32;}this._attr.height=a;this.subscribe('xd.likeboxLiked',FB.bind(this._onLiked,this));this.subscribe('xd.likeboxUnliked',FB.bind(this._onUnliked,this));return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'likebox',params:this._attr};},_onLiked:function(){FB.Helper.fireEvent('edge.create',this);},_onUnliked:function(){FB.Helper.fireEvent('edge.remove',this);}}); -FB.subclass('XFBML.LiveStream','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={height:this._getPxAttribute('height',500),hideFriendsTab:this.getAttribute('hide-friends-tab'),redesigned:this._getBoolAttribute('redesigned-stream'),width:this._getPxAttribute('width',400),xid:this.getAttribute('xid','default'),always_post_to_friends:this._getBoolAttribute('always-post-to-friends',false)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){var a=this._attr.redesigned?'live_stream_box':'livefeed';return {name:a,params:this._attr};}}); -FB.subclass('XFBML.Login','XFBML.Facepile',null,{_visibleAfter:'load',getSize:function(){return {width:this._attr.width,height:94};},getUrlBits:function(){return {name:'login',params:this._attr};}}); -FB.subclass('XFBML.LoginButton','XFBML.ButtonElement',null,{setupAndValidate:function(){if(this._alreadySetup)return true;this._alreadySetup=true;this._attr={autologoutlink:this._getBoolAttribute('auto-logout-link'),length:this._getAttributeFromList('length','short',['long','short']),onlogin:this.getAttribute('on-login'),perms:this.getAttribute('perms'),registration_url:this.getAttribute('registration-url'),status:'unknown'};if(this._attr.autologoutlink)FB.Event.subscribe('auth.statusChange',FB.bind(this.process,this));if(this._attr.registration_url){FB.Event.subscribe('auth.statusChange',this._saveStatus(this.process));FB.getLoginStatus(this._saveStatus(this.process));}return true;},getButtonMarkup:function(){var a=this.getOriginalHTML();if(a)return a;if(!this._attr.registration_url){if(FB.getSession()&&this._attr.autologoutlink){return FB.Intl._tx("Facebook Logout");}else return this._getLoginText();}else switch(this._attr.status){case 'unknown':return this._getLoginText();case 'notConnected':return FB.Intl._tx("Register");case 'connected':if(FB.getSession()&&this._attr.autologoutlink)return FB.Intl._tx("Facebook Logout");return this._getLoginText();default:FB.log('Unknown status: '+this.status);return FB.Intl._tx("Login");}},_getLoginText:function(){return this._attr.length=='short'?FB.Intl._tx("Login"):FB.Intl._tx("Login with Facebook");},onClick:function(){if(!this._attr.registration_url){if(!FB.getSession()||!this._attr.autologoutlink){FB.login(FB.bind(this._authCallback,this),{perms:this._attr.perms});}else FB.logout(FB.bind(this._authCallback,this));}else switch(this._attr.status){case 'unknown':FB.ui({method:'auth.loginToFacebook'},FB.bind(function(a){FB.getLoginStatus(this._saveStatus(this._authCallback),true);},this));break;case 'notConnected':window.top.location=this._attr.registration_url;break;case 'connected':if(!FB.getSession()||!this._attr.autologoutlink){this._authCallback();}else FB.logout(FB.bind(this._authCallback,this));break;default:FB.log('Unknown status: '+this.status);}},_authCallback:function(a){FB.Helper.invokeHandler(this._attr.onlogin,this,[a]);},_saveStatus:function(a){return FB.bind(function(b){this._attr.status=b.status;if(a){a=this.bind(a,this);return a(b);}},this);}}); -FB.subclass('XFBML.Name','XFBML.Element',null,{process:function(){FB.copy(this,{_uid:this.getAttribute('uid'),_firstnameonly:this._getBoolAttribute('first-name-only'),_lastnameonly:this._getBoolAttribute('last-name-only'),_possessive:this._getBoolAttribute('possessive'),_reflexive:this._getBoolAttribute('reflexive'),_objective:this._getBoolAttribute('objective'),_linked:this._getBoolAttribute('linked',true),_subjectId:this.getAttribute('subject-id')});if(!this._uid){FB.log('"uid" is a required attribute for ');this.fire('render');return;}var b=[];if(this._firstnameonly){b.push('first_name');}else if(this._lastnameonly){b.push('last_name');}else b.push('name');if(this._subjectId){b.push('sex');if(this._subjectId==FB.Helper.getLoggedInUser())this._reflexive=true;}var a;FB.Event.monitor('auth.statusChange',this.bind(function(){if(!this.isValid()){this.fire('render');return true;}if(!this._uid||this._uid=='loggedinuser')this._uid=FB.Helper.getLoggedInUser();if(!this._uid)return;if(FB.Helper.isUser(this._uid)){a=FB.Data._selectByIndex(b,'user','uid',this._uid);}else a=FB.Data._selectByIndex(['name','id'],'profile','id',this._uid);a.wait(this.bind(function(c){if(this._subjectId==this._uid){this._renderPronoun(c[0]);}else this._renderOther(c[0]);this.fire('render');}));}));},_renderPronoun:function(b){var c='',a=this._objective;if(this._subjectId){a=true;if(this._subjectId===this._uid)this._reflexive=true;}if(this._uid==FB.Connect.get_loggedInUser()&&this._getBoolAttribute('use-you',true)){if(this._possessive){if(this._reflexive){c='your own';}else c='your';}else if(this._reflexive){c='yourself';}else c='you';}else switch(b.sex){case 'male':if(this._possessive){c=this._reflexive?'his own':'his';}else if(this._reflexive){c='himself';}else if(a){c='him';}else c='he';break;case 'female':if(this._possessive){c=this._reflexive?'her own':'her';}else if(this._reflexive){c='herself';}else if(a){c='her';}else c='she';break;default:if(this._getBoolAttribute('use-they',true)){if(this._possessive){if(this._reflexive){c='their own';}else c='their';}else if(this._reflexive){c='themselves';}else if(a){c='them';}else c='they';}else if(this._possessive){if(this._reflexive){c='his/her own';}else c='his/her';}else if(this._reflexive){c='himself/herself';}else if(a){c='him/her';}else c='he/she';break;}if(this._getBoolAttribute('capitalize',false))c=FB.Helper.upperCaseFirstChar(c);this.dom.innerHTML=c;},_renderOther:function(c){if(!c)return;var b='',a='';if(this._uid==FB.Helper.getLoggedInUser()&&this._getBoolAttribute('use-you',true)){if(this._reflexive){if(this._possessive){b='your own';}else b='yourself';}else if(this._possessive){b='your';}else b='you';}else{if(null===c.first_name)c.first_name='';if(null===c.last_name)c.last_name='';if(this._firstnameonly){b=FB.String.escapeHTML(c.first_name);}else if(this._lastnameonly)b=FB.String.escapeHTML(c.last_name);if(!b)b=FB.String.escapeHTML(c.name);if(b!==''&&this._possessive)b+='\'s';}if(!b)b=FB.String.escapeHTML(this.getAttribute('if-cant-see','Facebook User'));if(b){if(this._getBoolAttribute('capitalize',false))b=FB.Helper.upperCaseFirstChar(b);if(this._linked){a=FB.Helper.getProfileLink(c,b,this.getAttribute('href',null));}else a=b;}this.dom.innerHTML=a;}}); -FB.subclass('XFBML.ProfilePic','XFBML.Element',null,{process:function(){var d=this.getAttribute('size','thumb'),b=FB.XFBML.ProfilePic._sizeToPicFieldMap[d],g=this._getPxAttribute('width'),a=this._getPxAttribute('height'),e=this.dom.style,f=this.getAttribute('uid');if(this._getBoolAttribute('facebook-logo'))b+='_with_logo';if(g){g=g+'px';e.width=g;}if(a){a=a+'px';e.height=a;}var c=this.bind(function(j){var l=j?j[0]:null,i=l?l[b]:null;if(!i)i=FB.getDomain('cdn')+FB.XFBML.ProfilePic._defPicMap[b];var k=((g?'width:'+g+';':'')+(a?'height:'+g+';':'')),h=FB.String.format('{1}',i,l?FB.String.escapeHTML(l.name):'',k,this.dom.className);if(this._getBoolAttribute('linked',true))h=FB.Helper.getProfileLink(l,h,this.getAttribute('href',null));this.dom.innerHTML=h;FB.Dom.addCss(this.dom,'fb_profile_pic_rendered');this.fire('render');});FB.Event.monitor('auth.statusChange',this.bind(function(){if(!this.isValid()){this.fire('render');return true;}if(this.getAttribute('uid',null)=='loggedinuser')f=FB.Helper.getLoggedInUser();if(FB._userStatus&&f){FB.Data._selectByIndex(['name',b],FB.Helper.isUser(f)?'user':'profile',FB.Helper.isUser(f)?'uid':'id',f).wait(c);}else c();}));}});FB.provide('XFBML.ProfilePic',{_defPicMap:{pic:'pics/s_silhouette.jpg',pic_big:'pics/d_silhouette.gif',pic_big_with_logo:'pics/d_silhouette_logo.gif',pic_small:'pics/t_silhouette.jpg',pic_small_with_logo:'pics/t_silhouette_logo.gif',pic_square:'pics/q_silhouette.gif',pic_square_with_logo:'pics/q_silhouette_logo.gif',pic_with_logo:'pics/s_silhouette_logo.gif'},_sizeToPicFieldMap:{n:'pic_big',normal:'pic_big',q:'pic_square',s:'pic',small:'pic',square:'pic_square',t:'pic_small',thumb:'pic_small'}}); -FB.subclass('XFBML.Recommendations','XFBML.IframeWidget',null,{_visibleAfter:'load',_refreshOnAuthChange:true,setupAndValidate:function(){this._attr={border_color:this.getAttribute('border-color'),colorscheme:this.getAttribute('color-scheme'),filter:this.getAttribute('filter'),font:this.getAttribute('font'),header:this._getBoolAttribute('header'),height:this._getPxAttribute('height',300),site:this.getAttribute('site',location.hostname),width:this._getPxAttribute('width',300)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'recommendations',params:this._attr};}}); -FB.subclass('XFBML.Registration','XFBML.IframeWidget',null,{_visibleAfter:'immediate',_baseHeight:167,_fieldHeight:28,_skinnyWidth:520,_skinnyBaseHeight:173,_skinnyFieldHeight:52,setupAndValidate:function(){this._attr={channel_url:this.getChannelUrl(),client_id:FB._apiKey,fb_only:this._getBoolAttribute('fb-only',false),fields:this.getAttribute('fields'),height:this._getPxAttribute('height'),redirect_uri:this.getAttribute('redirect-uri',window.location.href),onvalidate:this.getAttribute('onvalidate'),width:this._getPxAttribute('width',600)};if(this._attr.onvalidate)this.subscribe('xd.validate',this.bind(function(b){var d=FB.JSON.parse(b.value);var a=this.bind(function(e){FB.Arbiter.inform('Registration.Validation',{errors:e,id:b.id},'parent.frames["'+this.getIframeNode().name+'"]');});var c=FB.Helper.executeFunctionByName(this._attr.onvalidate,d,a);if(c)a(c);}));return true;},getSize:function(){return {width:this._attr.width,height:this._getHeight()};},_getHeight:function(){if(this._attr.height)return this._attr.height;var b;if(!this._attr.fields){b=['name'];}else try{b=FB.JSON.parse(this._attr.fields);}catch(a){b=this._attr.fields.split(/,/);}if(this._attr.width requires the "fbml" attribute.');return false;}return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'serverfbml',params:this._attr};}}); -FB.subclass('XFBML.ShareButton','XFBML.Element',null,{process:function(){this._href=this.getAttribute('href',window.location.href);this._type=this.getAttribute('type','icon_link');FB.Dom.addCss(this.dom,'fb_share_count_hidden');this._renderButton(true);},_renderButton:function(f){if(!this.isValid()){this.fire('render');return;}var b='',c='',d='',a='',e=FB.Intl._tx("Share"),g='';switch(this._type){case 'icon':case 'icon_link':a='fb_button_simple';b=(''+(this._type=='icon_link'?e:' ')+'');f=false;break;case 'link':b=FB.Intl._tx("Share on Facebook");f=false;break;case 'button':b=''+e+'';a='fb_button fb_button_small';f=false;break;case 'button_count':b=''+e+'';c=(' '+''+this._getCounterMarkup()+'');a='fb_button fb_button_small';break;default:b=''+e+'';d=(' '+''+this._getCounterMarkup()+'');a='fb_button fb_button_small';g='fb_share_count_wrapper';}this.dom.innerHTML=FB.String.format('{4}{3}{5}',g,this._href,a,b,d,c,FB.JSON.stringify({method:'stream.share',u:this._href}));if(!f)this.fire('render');},_getCounterMarkup:function(){if(!this._count)this._count=FB.Data._selectByIndex(['total_count'],'link_stat','url',this._href);var b='0';if(this._count.value!==undefined){if(this._count.value.length>0){var a=this._count.value[0].total_count;if(a>3){FB.Dom.removeCss(this.dom,'fb_share_count_hidden');b=a>=1e+07?Math.round(a/1e+06)+'M':(a>=10000?Math.round(a/1000)+'K':a);}}}else this._count.wait(FB.bind(this._renderButton,this,false));return ''+b+'';}}); -void(0); - - -FB.provide("", {"_domain":{"api":"https:\/\/api.facebook.com\/","api_read":"https:\/\/api-read.facebook.com\/","cdn":"http:\/\/static.ak.fbcdn.net\/","graph":"https:\/\/graph.facebook.com\/","https_cdn":"https:\/\/s-static.ak.fbcdn.net\/","https_staticfb":"https:\/\/s-static.ak.facebook.com\/","https_www":"https:\/\/www.facebook.com\/","staticfb":"http:\/\/static.ak.facebook.com\/","www":"http:\/\/www.facebook.com\/"},"_locale":"en_US","_localeIsRtl":false}, true); -FB.provide("Flash", {"_minVersions":[[10,0,22,87]],"_swfPath":"rsrc.php\/v1\/yF\/r\/Y7YCBKX-HZn.swf"}, true); -FB.provide("XFBML.ConnectBar", {"imgs":{"buttonUrl":"rsrc.php\/yY\/r\/h_Y6u1wrZPW.png","missingProfileUrl":"rsrc.php\/yo\/r\/UlIqmHJn-SK.gif"}}, true); -FB.provide("XFBML.ProfilePic", {"_defPicMap":{"pic":"rsrc.php\/yh\/r\/C5yt7Cqf3zU.jpg","pic_big":"rsrc.php\/yL\/r\/HsTZSDw4avx.gif","pic_big_with_logo":"rsrc.php\/y5\/r\/SRDCaeCL7hM.gif","pic_small":"rsrc.php\/yi\/r\/odA9sNLrE86.jpg","pic_small_with_logo":"rsrc.php\/yD\/r\/k1xiRXKnlGd.gif","pic_square":"rsrc.php\/yo\/r\/UlIqmHJn-SK.gif","pic_square_with_logo":"rsrc.php\/yX\/r\/9dYJBPDHXwZ.gif","pic_with_logo":"rsrc.php\/yu\/r\/fPPR9f2FJ3t.gif"}}, true); -if (FB.Dom && FB.Dom.addCssRules) { FB.Dom.addCssRules(".fb_hidden{position:absolute;top:-10000px;z-index:10001}\n.fb_reset{background:none;border-spacing:0;border:0;color:#000;cursor:auto;direction:ltr;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;font-size:11px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal}\n.fb_link img{border:none}\n.fb_dialog{position:absolute;top:-10000px;z-index:10001}\n.fb_dialog_advanced{background:rgba(82, 82, 82, .7);padding:10px;-moz-border-radius:8px;-webkit-border-radius:8px}\n.fb_dialog_content{background:#fff;color:#333}\n.fb_dialog_close_icon{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 0 transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif);cursor:pointer;display:block;height:15px;position:absolute;right:18px;top:17px;width:15px;top:8px\\9;right:7px\\9}\n.fb_dialog_close_icon:hover{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -15px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif)}\n.fb_dialog_close_icon:active{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -30px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif)}\n.fb_dialog_loader{background-color:#f2f2f2;border:1px solid #606060;font-size:24px;padding:20px}\n.fb_dialog_top_left,\n.fb_dialog_top_right,\n.fb_dialog_bottom_left,\n.fb_dialog_bottom_right{height:10px;width:10px;overflow:hidden;position:absolute}\n.fb_dialog_top_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 0;left:-10px;top:-10px}\n.fb_dialog_top_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -10px;right:-10px;top:-10px}\n.fb_dialog_bottom_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -20px;bottom:-10px;left:-10px}\n.fb_dialog_bottom_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -30px;right:-10px;bottom:-10px}\n.fb_dialog_vert_left,\n.fb_dialog_vert_right,\n.fb_dialog_horiz_top,\n.fb_dialog_horiz_bottom{position:absolute;background:#525252;filter:alpha(opacity=70);opacity:.7}\n.fb_dialog_vert_left,\n.fb_dialog_vert_right{width:10px;height:100\u0025}\n.fb_dialog_vert_left{margin-left:-10px}\n.fb_dialog_vert_right{right:0;margin-right:-10px}\n.fb_dialog_horiz_top,\n.fb_dialog_horiz_bottom{width:100\u0025;height:10px}\n.fb_dialog_horiz_top{margin-top:-10px}\n.fb_dialog_horiz_bottom{bottom:0;margin-bottom:-10px}\n.fb_dialog_iframe{line-height:0}\n.fb_dialog_content .dialog_title{background:#6d84b4;border:1px solid #3b5998;color:#fff;font-size:14px;font-weight:bold;margin:0}\n.fb_dialog_content .dialog_title > span{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zd\/r\/Cou7n-nqK52.gif) no-repeat 5px 50\u0025;float:left;padding:5px 0 7px 26px}\n.fb_dialog_content .dialog_content{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/z9\/r\/jKEcVPZFk-2.gif) no-repeat 50\u0025 50\u0025;border:1px solid #555;border-bottom:0;border-top:0;height:150px}\n.fb_dialog_content .dialog_footer{background:#f2f2f2;border:1px solid #555;border-top-color:#ccc;height:40px}\n#fb_dialog_loader_close{float:right}\n.fb_iframe_widget{position:relative;display:-moz-inline-block;display:inline-block}\n.fb_iframe_widget iframe{position:relative;vertical-align:text-bottom}\n.fb_iframe_widget span{position:relative}\n.fb_hide_iframes iframe{position:relative;left:-10000px}\n.fb_iframe_widget_loader{position:relative;display:inline-block}\n.fb_iframe_widget_loader iframe{min-height:32px;z-index:2;zoom:1}\n.fb_iframe_widget_loader .FB_Loader{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/z9\/r\/jKEcVPZFk-2.gif) no-repeat;height:32px;width:32px;margin-left:-16px;position:absolute;left:50\u0025;z-index:4}\n.fb_button_simple,\n.fb_button_simple_rtl{background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zH\/r\/eIpbnVKI9lR.png);background-repeat:no-repeat;cursor:pointer;outline:none;text-decoration:none}\n.fb_button_simple_rtl{background-position:right 0}\n.fb_button_simple .fb_button_text{margin:0 0 0 20px;padding-bottom:1px}\n.fb_button_simple_rtl .fb_button_text{margin:0 10px 0 0}\na.fb_button_simple:hover .fb_button_text,\na.fb_button_simple_rtl:hover .fb_button_text,\n.fb_button_simple:hover .fb_button_text,\n.fb_button_simple_rtl:hover .fb_button_text{text-decoration:underline}\n.fb_button,\n.fb_button_rtl{background:#29447e url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/FGFbc80dUKj.png);background-repeat:no-repeat;cursor:pointer;display:inline-block;padding:0 0 0 1px;text-decoration:none;outline:none}\n.fb_button .fb_button_text,\n.fb_button_rtl .fb_button_text{background:#5f78ab url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/FGFbc80dUKj.png);border-top:solid 1px #879ac0;border-bottom:solid 1px #1a356e;color:#fff;display:block;font-family:\"lucida grande\",tahoma,verdana,arial,sans-serif;font-weight:bold;padding:2px 6px 3px 6px;margin:1px 1px 0 21px;text-shadow:none}\na.fb_button,\na.fb_button_rtl,\n.fb_button,\n.fb_button_rtl{text-decoration:none}\na.fb_button:active .fb_button_text,\na.fb_button_rtl:active .fb_button_text,\n.fb_button:active .fb_button_text,\n.fb_button_rtl:active .fb_button_text{border-bottom:solid 1px #29447e;border-top:solid 1px #45619d;background:#4f6aa3;text-shadow:none}\n.fb_button_xlarge,\n.fb_button_xlarge_rtl{background-position:left -60px;font-size:24px;line-height:30px}\n.fb_button_xlarge .fb_button_text{padding:3px 8px 3px 12px;margin-left:38px}\na.fb_button_xlarge:active{background-position:left -99px}\n.fb_button_xlarge_rtl{background-position:right -268px}\n.fb_button_xlarge_rtl .fb_button_text{padding:3px 8px 3px 12px;margin-right:39px}\na.fb_button_xlarge_rtl:active{background-position:right -307px}\n.fb_button_large,\n.fb_button_large_rtl{background-position:left -138px;font-size:13px;line-height:16px}\n.fb_button_large .fb_button_text{margin-left:24px;padding:2px 6px 4px 6px}\na.fb_button_large:active{background-position:left -163px}\n.fb_button_large_rtl{background-position:right -346px}\n.fb_button_large_rtl .fb_button_text{margin-right:25px}\na.fb_button_large_rtl:active{background-position:right -371px}\n.fb_button_medium,\n.fb_button_medium_rtl{background-position:left -188px;font-size:11px;line-height:14px}\na.fb_button_medium:active{background-position:left -210px}\n.fb_button_medium_rtl{background-position:right -396px}\n.fb_button_text_rtl,\n.fb_button_medium_rtl .fb_button_text{padding:2px 6px 3px 6px;margin-right:22px}\na.fb_button_medium_rtl:active{background-position:right -418px}\n.fb_button_small,\n.fb_button_small_rtl{background-position:left -232px;font-size:10px;line-height:10px}\n.fb_button_small .fb_button_text{padding:2px 6px 3px;margin-left:17px}\na.fb_button_small:active,\n.fb_button_small:active{background-position:left -250px}\n.fb_button_small_rtl{background-position:right -440px}\n.fb_button_small_rtl .fb_button_text{padding:2px 6px;margin-right:18px}\na.fb_button_small_rtl:active{background-position:right -458px}\n.fb_connect_bar_container div,\n.fb_connect_bar_container span,\n.fb_connect_bar_container a,\n.fb_connect_bar_container img,\n.fb_connect_bar_container strong{background:none;border-spacing:0;border:0;direction:ltr;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal;vertical-align:baseline}\n.fb_connect_bar_container{position:fixed;left:0 !important;right:0 !important;height:42px !important;padding:0 25px !important;margin:0 !important;vertical-align:middle !important;border-bottom:1px solid #333 !important;background:#3b5998 !important;z-index:99999999 !important;overflow:hidden !important}\n.fb_connect_bar_container_ie6{position:absolute;top:expression(document.compatMode==\"CSS1Compat\"? document.documentElement.scrollTop+\"px\":body.scrollTop+\"px\")}\n.fb_connect_bar{position:relative;margin:auto;height:100\u0025;width:100\u0025;padding:6px 0 0 0 !important;background:none;color:#fff !important;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif !important;font-size:13px !important;font-style:normal !important;font-variant:normal !important;font-weight:normal !important;letter-spacing:normal !important;line-height:1 !important;text-decoration:none !important;text-indent:0 !important;text-shadow:none !important;text-transform:none !important;white-space:normal !important;word-spacing:normal !important}\n.fb_connect_bar a:hover{color:#fff}\n.fb_connect_bar .fb_profile img{height:30px;width:30px;vertical-align:middle;margin:0 6px 5px 0}\n.fb_connect_bar div a,\n.fb_connect_bar span,\n.fb_connect_bar span a{color:#bac6da;font-size:11px;text-decoration:none}\n.fb_connect_bar .fb_buttons{float:right;margin-top:7px}\n.fb_edge_widget_with_comment{position:relative;*z-index:1000}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget{position:absolute}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_ltr{left:-4px}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_rtl{left:2px}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget{left:0}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget .FB_Loader{left:10\u0025}\n.fb_share_count_wrapper{position:relative;float:left}\n.fb_share_count{background:#b0b9ec none repeat scroll 0 0;color:#333;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;text-align:center}\n.fb_share_count_inner{background:#e8ebf2;display:block}\n.fb_share_count_right{margin-left:-1px;display:inline-block}\n.fb_share_count_right .fb_share_count_inner{border-top:solid 1px #e8ebf2;border-bottom:solid 1px #b0b9ec;margin:1px 1px 0 1px;font-size:10px;line-height:10px;padding:2px 6px 3px;font-weight:bold}\n.fb_share_count_top{display:block;letter-spacing:-1px;line-height:34px;margin-bottom:7px;font-size:22px;border:solid 1px #b0b9ec}\n.fb_share_count_nub_top{border:none;display:block;position:absolute;left:7px;top:35px;margin:0;padding:0;width:6px;height:7px;background-repeat:no-repeat;background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zU\/r\/bSOHtKbCGYI.png)}\n.fb_share_count_nub_right{border:none;display:inline-block;padding:0;width:5px;height:10px;background-repeat:no-repeat;background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zX\/r\/i_oIVTKMYsL.png);vertical-align:top;background-position:right 5px;z-index:10;left:2px;margin:0 2px 0 0;position:relative}\n.fb_share_no_count{display:none}\n.fb_share_size_Small .fb_share_count_right .fb_share_count_inner{font-size:10px}\n.fb_share_size_Medium .fb_share_count_right .fb_share_count_inner{font-size:11px;padding:2px 6px 3px;letter-spacing:-1px;line-height:14px}\n.fb_share_size_Large .fb_share_count_right .fb_share_count_inner{font-size:13px;line-height:16px;padding:2px 6px 4px;font-weight:normal;letter-spacing:-1px}\n.fb_share_count_hidden .fb_share_count_nub_top,\n.fb_share_count_hidden .fb_share_count_top,\n.fb_share_count_hidden .fb_share_count_nub_right,\n.fb_share_count_hidden .fb_share_count_right{visibility:hidden}\n", ["fb.css.base","fb.css.dialog","fb.css.iframewidget","fb.css.button","fb.css.connectbarwidget","fb.css.edgecommentwidget","fb.css.sendbuttonformwidget","fb.css.sharebutton"]); } \ No newline at end of file diff --git a/game/old/animated_image.js b/game/old/animated_image.js deleted file mode 100644 index fbec113..0000000 --- a/game/old/animated_image.js +++ /dev/null @@ -1,93 +0,0 @@ -// Manages an animated image. Assumes that while it is active, -// get_image is called once per game loop -// Defaults to starting immediately -// Unless you call loop, will only run through the images once -// spec: -// All optional -// anim_rate : the number of frames to display each image -// reverse : whether to go backwards in the images when you reach the end or not - -var animated_image = function(image_name, spec) { - - // obj to return - var obj = []; - - // private vars - - var all_images = image_manager.get_images(image_name); - all_images.sort( - function(i1, i2) { - //return i1.path < i2.path; - return i1.path < i2.path ? -1 : (i1.path > i2.path ? 1 : 0); - } - ); - //for_each(all_images, function(i) { console.log(i.path); }); - var curr_index = 0; - var active = true; - var loop = false; - var rate_counter = 0; // Goes from 0 to anim_rate - 1 - var anim_rate = spec.anim_rate || 3; - - // If we are reversing, add all the images in the opposite - // order to all_images - if (spec.reverse || false) { - for (var i = (all_images.length - 1); i >=0; i--) { - all_images.push(all_images[i]); - } - } - - //public methods - - obj.start = function() { - active = true; - }; - - obj.pause = function() { - active = false; - }; - - obj.loop = function() { - loop = true; - }; - - obj.is_finished = function() { - // changed to && cuz it should be not looping - // and at the end to be finished - return (!loop && curr_index === (all_images.length - 1)); - }; - - // Returns the current image - obj.get_frame = function() { - var curr_image = all_images[curr_index].image; - update(); - return curr_image; - }; - - obj.set_rate = function(r) { - anim_rate = r; - }; - - // private methods - - var update = function() { - if (active) { - if (rate_counter >= (anim_rate - 1)) { - next_frame(); - rate_counter = 0; - } - else { - rate_counter++; - } - } - }; - - var next_frame = function() { - // If not 'at the end and not looping', - // increment curr_index, restarting if we reach the end - if (!(curr_index === all_images.length && !loop)) { - curr_index = (curr_index + 1) % all_images.length; - } - } - - return obj; -} diff --git a/game/old/antibody.js b/game/old/antibody.js deleted file mode 100644 index e6c6e17..0000000 --- a/game/old/antibody.js +++ /dev/null @@ -1,86 +0,0 @@ -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards - -var antibody = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 11; - spec.height = spec.height || 7; - spec.speed = spec.speed || 4; - spec.no_target_speed = spec.no_target_speed || 2 - - //spec.vel = random_vel(); - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "antibody"; - }; - - // --- private variables --- - - // flag denoting whether the antibody is attached to a cell - var attached = false; - - // --- public methods --- - - // should be called when an antibody attaches to a cell - // tar will be the cell that it is attaching to (may not be its target) - obj.attach = function(tar) { - attached = true; - obj.face_target(tar); - // scoot it out just a bit - obj.get_vel().mult(-1); - obj.move(); - - //obj.set_target(null); - }; - - // implementing game_object interface - - obj.my_update = function() { - if (!attached) { - obj.set_speed(obj.get_level() / 4 + 1) - obj.move(); - // don't want two antibodies attacking one cell - var tar = obj.get_target(); - if (tar && (tar.has_antibody() - // also don't want them to keep target - // if the target changes level - || tar.get_level() !== obj.get_level() - // or if it starts to die - || tar.get_state() === "dying")) { - obj.set_target(null); - } - } - }; - - // should point towards target - // Y-shaped (top of Y is front) - obj.draw = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.stroke(obj.get_color()); - p.strokeWeight(2); - - p.line(-w, 0, w/3, 0); - p.line(w/3, 0, w, h/2); - p.line(w/3, 0, w, -h/2); - - p.popMatrix(); - }; - - return obj; -} diff --git a/game/old/b_cell.js b/game/old/b_cell.js deleted file mode 100644 index 5d3747a..0000000 --- a/game/old/b_cell.js +++ /dev/null @@ -1,249 +0,0 @@ -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards -// state = just leave to be default (alive) - -var b_cell = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 30; - spec.height = spec.height || 30; - spec.speed = spec.speed || 5; - - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "b_cell"; - }; - - // --- private variables --- - - var b_anim = animated_image("bcell", {reverse : true}); - // for illustration - var b_image = image_manager.get_image("bcell_normal.png"); - // where to go and shoot from - var slot = null; - - // state can be "alive", "active", "shooting", "outdated" - - // Antibodies are created in update, and returned in get_antibodies() - var new_antibodies = null; - - // --- private methods - - // Makes one antibody and adds it to new_antibodies - var make_antibody = function() { - if (!new_antibodies) { - new_antibodies = []; - } - var obj_pos = obj.get_pos(); - var new_antibody = antibody(p, { - pos : new p.PVector(obj_pos.x, obj_pos.y + (obj.get_height() / 2)), - mutation_info: obj.get_mutation_info() - }); - new_antibodies.push(new_antibody); - return new_antibody; - }; - - - // --- public methods --- - - // Makes this target stop and begin producing antibodies - obj.make_antibodies = function() { - obj.set_state("shooting"); - obj.set_target(null); - // production will happen in update - }; - - // to be called on collision with floater - // takes a slot pos - obj.activate = function(aslot) { - obj.set_state("active"); - slot = aslot; - // send the bcell to the top - obj.set_target(game_object(p, { - pos: slot.pos //new p.PVector(p.width - (obj.get_width() / 2), 0) - })); - }; - - obj.get_slot = function() { - return slot; - }; - - // Returns any newly created antibodies - obj.get_antibodies = function() { - if (new_antibodies) { - var to_return = new_antibodies; - new_antibodies = null; - return to_return; - } - else { - return []; - } - }; - - obj.is_activated = function() { - return obj.get_state() === "active"; - }; - - obj.is_alive = function() { - return obj.get_state() === "alive"; - }; - - obj.is_shooting = function() { - return obj.get_state() === "shooting"; - }; - - obj.get_scroll_dist = function() { - var state = obj.get_state(); - if (state === "shooting" - //|| state === "alive" - || state === "active" ) { - return 0; - } - else if (state === "outdated") { - return obj.DEFAULT_SCROLL_DIST;// * 2; - } - else { - return obj.DEFAULT_SCROLL_DIST; - } - }; - - // implementing game_object interface - - obj.my_update = function() { - if (obj.get_state() === "shooting") { - //obj.stop(); - // make it face downwards - var angle = p.PI/2 - // switch if at bottom - if (!slot.is_top) { - angle = -p.PI/2; - } - obj.set_target_angle(angle); - if (Math.random() < .03) { - var new_anti = make_antibody(); - new_anti.set_target_angle(p.random(0, 2*angle)); - } - } - else { - obj.move(); - } - }; - - var draw_antibody = function() { - // private vars - var counter = 0; - var c_max = 30; - var ascending = true; - - // for illustrations - obj.set_anti_count = function(c) { - counter = c; - }; - - return function(){ - - p.pushMatrix(); - - var pos = obj.get_pos(); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - // Copied from antibody.js to avoid overhead of - // creating new antibody every time - p.stroke(obj.get_color()); - p.strokeWeight(1 + (counter / 6)); - - var w = 11; - var h = 7; - p.line(-w, 0, w / 3, 0); - p.line(w / 3, 0, w, h / 2); - p.line(w / 3, 0, w, -h / 2); - - p.popMatrix(); - - if (ascending === true) { - counter++; - } - else if (ascending === false) { - counter--; - } - if (counter === c_max) { - ascending = false; - } - else if (counter === 0) { - ascending = true; - } - }; - }(); - - // should point towards target - // (triangle for now) - obj.draw = function() { - /* - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.fill(obj.get_color()); - // If outdated, draw differently? - if (obj.get_state() === "outdated") { - p.fill(0); - } - p.noStroke(); - - // rightward triangle - p.triangle(-w/2, -h/2, -w/2, h/2, w/2, 0); - - p.fill(255); - p.ellipse(-w/4, 0, 10, 10); - - p.popMatrix(); - */ - - p.pushMatrix(); - - var pos = obj.get_pos(); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle() + p.PI / 2); - p.fill(obj.get_color()); - p.noStroke(); - //p.rect(rectx_offset, recty_offset, rect_width, rect_height); - p.imageMode(obj.get_mode()); - - if (!obj.is_illustration()) { - b_image = b_anim.get_frame(); - } - p.image(b_image, 0, 0, obj.get_width(), obj.get_height()); - - p.popMatrix(); - - var state = obj.get_state(); - if (state === "active" || state === "shooting") { - draw_antibody(); - } - }; - - obj.stop_animation = function() { - b_anim.pause(); - }; - - obj.resume_animation = function() { - b_anim.start(); - }; - - return obj; -} diff --git a/game/old/background_edge.js b/game/old/background_edge.js deleted file mode 100644 index 6d8bb09..0000000 --- a/game/old/background_edge.js +++ /dev/null @@ -1,54 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec -// boolean is_top = true if its a top edge, otherwise false -// - -var background_edge = function(p, spec) { - - //var background_image = p.loadImage("images/background.jpg"); - //var background_image = p.loadImage("images/background1.png"); - var edge = spec.is_top ? - image_manager.get_image("background_topside.png") : - image_manager.get_image("background_bottomside.png"); - - // --- defaults --- - - spec.mode = p.CORNERS; - spec.width = spec.width || edge.width; - spec.height = spec.height || edge.height; - - // if bottom, height should have been set to bottom of screen - // so we need to shift it up - if (!spec.is_top) { - spec.pos.add(new p.PVector(0, -spec.height)); - } - - // obj to return - var obj = background_object(p, spec); - - obj.get_type = function() { - return "background_edge"; - }; - - - // --- private variables --- - - - // --- public methods --- - - // override draw method only - obj.draw = function() { - p.imageMode(obj.get_mode()); - p.image(edge, obj.get_pos().x, obj.get_pos().y); - }; - - // override offscreen check cuz we draw from the corners - obj.is_offscreen = function() { - // only need to check left edge of screen - return obj.get_pos().x + obj.get_width() < 0; - }; - - return obj; -}; - diff --git a/game/old/background_object.js b/game/old/background_object.js deleted file mode 100644 index 0f96f4e..0000000 --- a/game/old/background_object.js +++ /dev/null @@ -1,76 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec -// - -var background_object = function(p, spec) { - - var obj_image = random_from( - image_manager.get_images("background")).image; - - - // --- defaults --- - - spec.mode = spec.mode || p.CENTER; - spec.width = spec.width || obj_image.width; - spec.height = spec.height || obj_image.height; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "background_object"; - }; - - // --- private variables --- - - - // --- public methods --- - - // implementing game_object interface - - // update is default (move) - - // (flat rect for now) - obj.draw = function() { - //var x_pos = obj.get_pos().x; - - //p.fill(p.color(49, 0, 0)); - //p.rect(x_pos, 0, obj.get_width() - x_pos, obj.get_height()); - //background_image.resize(p.width, p.height); - //p.image(background_image, 0, 0); - //console.log(obj.get_pos().x); - p.imageMode(obj.get_mode()); - p.image(obj_image, obj.get_pos().x, obj.get_pos().y); - //p.set(obj.get_pos().x, 0, background_image); - //p.fill(255, 70); - //p.noStroke(); - //p.rect(obj.get_pos().x, 0, obj.get_width(), obj.get_height()); - }; - - // background can't go off screen or die - obj.is_dead = function() { - return false; - }; - /* - obj.is_offscreen = function() { - return false; - }; - */ - //var count = 0; - - obj.scroll = function(scroll_factor) { - // count += 1; - //if (count === 1) { - // count = 0; - obj.get_pos().add(new p.PVector(obj.get_scroll_dist(), 0)); - // } - }; - - obj.get_scroll_dist = function() { - return -1; - }; - - return obj; -}; - diff --git a/game/old/button.js b/game/old/button.js deleted file mode 100644 index 995dde5..0000000 --- a/game/old/button.js +++ /dev/null @@ -1,122 +0,0 @@ -// Have a rectangle representing their position and a state to go to when clicked -// spec: -// state : function that returns a new state to go to when clicked -// (think of it like a thunk) -// rect : spec for a rectangle representing the button - -var button = function(p, spec) { - - // --- defaults --- - //spec.rect.width = spec.rect.width || 100; - //spec.rect.height = spec.rect.height || 35; - - // obj to return - var obj = {}; - - // --- private variables --- - - var next_state_fun = spec.state; - var active = spec.active || true; - - var image = spec.rect.image ? - image_manager.get_image(spec.rect.image) : null; - var over_image = spec.rect.over_image ? - image_manager.get_image(spec.rect.over_image) : null; - - // if no width is given but an image is - // use the image width - if (!spec.rect.width && image) { - spec.rect.width = image.width; - } - // and for height - if (!spec.rect.height && image) { - spec.rect.height = image.height; - } - - var rect = rectangle(p, spec.rect); - - // --- public methods --- - - obj.draw = function() { - if (!active) { - rect.set_tint(100); - /* - var r = spec.rect; - p.noStroke(); - p.fill(0, 150); - p.rectMode(p.CENTER); - p.rect(r.pos.x, r.pos.y, r.width, r.height); - */ - } - else { - //rect.set_tint(255); - } - rect.draw(); - }; - - // makes a button not active - obj.deactivate = function() { - // hack to make sure button tint updates - obj.mouse_moved(-1, -1); - active = false; - }; - - // makes a button active - obj.activate = function() { - // hack to make sure button tint updates - obj.mouse_moved(-1, -1); - active = true; - }; - - // Returns the state to go to if clicked, or - // null if not clicked - obj.is_clicked = function(x, y) { - if (active && rect.is_in(x, y)) { - // after click go back to normal image - if (over_image) { - rect.set_image(image); - } - return obj.get_state(); - } - else { - return null; - } - }; - - // special case for track buttons - obj.click = obj.is_clicked; - - obj.mouse_moved = function(x, y) { - if (active && rect.is_in(x, y)) { - if (over_image) { - rect.set_image(over_image); - } - else { - //rect.set_tint(0); - rect.set_tint(255, 255); - //rect.draw_twice(); - //console.log("tinting"); - } - } - else { - if (!over_image) { - rect.set_tint(200, 255); - } - //rect.draw_once(); - rect.set_image(image); - } - }; - // call once to init button tints - obj.mouse_moved(-1, -1); - - // Returns the state to go to - obj.get_state = function() { - return next_state_fun(); - }; - - obj.get_rect = function() { - return spec.rect; - }; - - return obj; -}; diff --git a/game/old/cache.manifest-old b/game/old/cache.manifest-old deleted file mode 100644 index 1fbb9e6..0000000 --- a/game/old/cache.manifest-old +++ /dev/null @@ -1,9 +0,0 @@ -CACHE MANIFEST -#v .012 -CACHE: -sounds/cell_infect.wav -sounds/cell_fire.wav -#sounds/heart_loop1.mp3 -php_functions.php -NETWORK: -* diff --git a/game/old/cell.js b/game/old/cell.js deleted file mode 100644 index 149fd6b..0000000 --- a/game/old/cell.js +++ /dev/null @@ -1,308 +0,0 @@ -// *** cell *** -// --- inherits from game_object -// spec: -// game_object spec + -// String state = "alive" or "dead" or "infected" or "active" -// mutation : Mutation_obj so cell can get current mutation color - -var cell = function(p, spec) { - - // --- defaults --- - - // was 40 - spec.width = spec.width || 25; - spec.height = spec.height || 25; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "cell"; - }; - - // --- private variables --- - - // images - var cell_image = random_from( - image_manager.get_images("infectable_cell")).image; - var burst_anim = animated_image("burst", {}); - var infect_anim = animated_image("cell_infect", {}); - - // state can be "alive", "infected", "active", or "dead" - var state = spec.state || "alive"; - // random initial angle - var arrow_angle = p.random(-p.PI/2, p.PI/2); - // random dir (1 or -1) - var arrow_dir = p.random() >= 0.5 ? 1 : -1; - - // indicates whether has been hit by an arrow and is being targeted - //var is_targeted = false; - - // holds an antibody that is attached to the cell, or null - var anti = null; - - // --- public methods --- - - // implementing game_object interface - - // update is different depending on state - obj.update = function() { - obj.move(); - if (state === "alive") { - // just chill - } - else if (state === "infected") { - // still chill - } - else if (state === "active") { - // spin the arrow - rotateArrow(); - } - else if (state === "dying") { - if (burst_anim.is_finished()) { - obj.set_state("dead"); - } - } - /* - else if (state === "dead") { - } - */ - }; - - // draw makes a cell with a different color depending on state - // (circle for now) - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.get_mode()); - - p.noStroke(); - - if (state === "dying") { - // draw frame and advance anim - p.image(burst_anim.get_frame(), pos.x, pos.y, - obj.get_width(), obj.get_height()); - // skip the rest of the method - return; - } - - - if (state === "alive") { - p.fill(p.color(200, 50, 50)); - } - else { - if (state === "infected") { - p.fill(obj.get_color()); - // draw after drawing the image - } - else if (state === "active") { - drawArrow(); - - // Draw a separate circle for the red outline - // so that we can more accurately fill in the cell - // red outline for now - p.stroke(255, 0, 0); - p.strokeWeight(4); - p.ellipse(pos.x, pos.y, obj.get_width(), obj.get_height()); - - p.noStroke(); - p.fill(obj.get_color()); - } - //if (infect_anim.is_finished() || obj.is_illustration()) { - p.ellipse(pos.x, pos.y, obj.get_width() * 4/5, obj.get_height() * 4/5); - //} - } - - p.imageMode(obj.get_mode()); - p.image(cell_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - - if (state === "infected" || state === "active") { - // draw after the image - if (!infect_anim.is_finished() && !obj.is_illustration()) { - // draw frame and advance anim - p.image(infect_anim.get_frame(), pos.x, pos.y, - obj.get_width(), obj.get_height()); - //p.fill(obj.get_color()); - } - } - - /* - else if (state === "dead") { - p.fill(0); - p.ellipse(pos.x, pos.y, - obj.get_width(), obj.get_height()); - } - */ - - }; - - // to be used in illustration only - obj.set_image = function(i) { - cell_image = i; - }; - - obj.get_image = function() { - return cell_image; - }; - - obj.is_dead = function() { - //console.log(burst_anim.is_finished()); - return state === "dead"; - }; - - obj.stop_animation = function() { - burst_anim.pause(); - infect_anim.pause(); - }; - - obj.resume_animation = function() { - burst_anim.start(); - infect_anim.start(); - }; - - obj.set_state = function(s) { - if (s === "infected") { - infect_anim.start(); - } - state = s; - }; - - obj.set_antibody = function(a) { - anti = a; - anti.attach(obj); - }; - - obj.has_antibody = function() { - return (anti !== null); - }; - - obj.get_state = function() { - return state; - }; - - obj.die = function() { - if (anti) { - anti.die(); - } - obj.set_state("dying"); - burst_anim.start(); - }; - - // explodes this cell if it is active - obj.fire = function() { - if (state === "active") { - // Make sounds - sounds.play_sound("cell_fire"); - - // TODO: need a slower death - obj.die(); - - var pos = obj.get_pos(); - var ang = arrow_angle; - // use width cuz it's a circle - var r = obj.get_width()/2; - - // gen particles at edge of cell for now - var x = r*p.cos(ang) + pos.x; - var y = r*p.sin(ang) + pos.y; - - var num_particles = get_num_particles(); - // angle between all the shots - var range = p.PI/6; - var incr = range/num_particles; - - var particles = []; - - ang = arrow_angle - range/2; - // special case - if (num_particles === 1) { - ang = arrow_angle; - } - while (num_particles > 0) { - var new_vel = new p.PVector(p.cos(ang), p.sin(ang)); - // mult by speed scalar - new_vel.mult(7); - // if we want to add velocity of cell - new_vel.add(obj.get_vel()); - - particles.push(particle(p, { - pos: new p.PVector(x, y), - vel: new_vel, - mutation_info: obj.get_mutation_info() - })); - - num_particles--; - ang += incr; - } - - return particles; - } - throw "Can't fire on "+state+" cell!"; - }; - - // override for circular object - obj.calc_radius = function() { - return obj.get_width()/2; - }; - obj.set_radius(obj.calc_radius()); - - // --- private functions --- - - // rotates according to arrow_dir - // switches direction at certain angles - var rotateArrow = function() { - if (arrow_angle > p.PI/2 - || arrow_angle < -p.PI/2) { - arrow_dir = (2-arrow_dir)-2; - } - arrow_angle += p.radians(5+obj.get_level()/2)*arrow_dir; - }; - - var drawArrow = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - - // move to center of circle - p.translate(pos.x, pos.y); - // rotate first - p.rotate(arrow_angle); - // move out to right edge of circle - p.translate(w/2, 0); - - // red outline for now - p.stroke(255, 0, 0); - p.strokeWeight(2); - p.fill(obj.get_color()); - - var x1 = w/2; - // draw facing out to right - p.beginShape(); - p.vertex(0, -5); - p.vertex(x1, -5); - p.vertex(x1, -10); - p.vertex(x1+15, 0); - p.vertex(x1, 10); - p.vertex(x1, 5); - p.vertex(0, 5); - p.endShape(); - - p.popMatrix(); - }; - - var get_num_particles = function() { - - var extra_particles = 0; - var mut_info = obj.get_mutation_info(); - /* - for_each(mut_info.abilities, function(a) { - if (a === "extra_particle") { - extra_particles++; - } - }); - */ - return mut_info.particles + extra_particles; - }; - - return obj; -}; diff --git a/game/old/credits_state.js b/game/old/credits_state.js deleted file mode 100644 index 9d79008..0000000 --- a/game/old/credits_state.js +++ /dev/null @@ -1,59 +0,0 @@ -var credits_state = function(p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var credits_back = image_manager.get_image("creditsscreen.png"); - - // Buttons - - var back_button = button(p, { - state : function() { return prev_state; }, - rect : { - pos : new p.PVector(p.width * (3/4), 500), - width: 120, - height: 50, - image: "back.png", - } - }); - - - //Not ordered - var all_buttons = [ back_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "credits"; - }; - - obj.update = function() { - //do nothing - }; - - obj.render = function() { - // fill the background - p.noStroke(); - p.fill(g.background_color); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.imageMode(p.CENTER); - p.image(credits_back, p.width/2, p.height/2); - }; - - obj.key_pressed = function(k) { - if (p.keyCode === 13 || p.keyCode === 27) { // enter, esc - obj.exit_state(); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/game/old/css/styles.css b/game/old/css/styles.css deleted file mode 100644 index 44efae4..0000000 --- a/game/old/css/styles.css +++ /dev/null @@ -1,60 +0,0 @@ -canvas { - border: 3px solid gray; - z-index: 1; - width: 700; - height: 600; - position: relative; -} -#scores-wrap { - z-index: 2; - /*background: white;*/ - /*color: black;*/ - width: 500; - height: 400; - /* use top/left to center manually */ - /* add in border width */ - left: 103px; - top: 83px; - position: absolute; - /* start hidden */ - display: none; -} -#scores { - height: 430; -} -table.score-table { - border-collapse: collapse; - width: 100%; - background: black; - color: white; - /*padding: 0.2em;*/ -} -.score-table, .score-table tr, .score-table td { - /*color: black;*/ - border: 2px solid #666; - font-size: 14; - text-align: right; -} -.score-table th { - font-size: 16; - text-align: center; - color: #000; - background: #fff; - border: 2px solid #666; - border-top: 5px solid #666; -} -.score-table th, .score-table tr, .score-table td { - padding: 0.2em 0.4em; -} -.Score-header { - width: 120; -} -.Name-header { - width: 140; -} -.Level-header { - width: 50; -} -.Date-header { - width: 100; -} diff --git a/game/old/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png b/game/old/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png deleted file mode 100755 index 5473aff..0000000 Binary files a/game/old/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png and /dev/null differ diff --git a/game/old/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png b/game/old/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png deleted file mode 100755 index 5950a8d..0000000 Binary files a/game/old/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png and /dev/null differ diff --git a/game/old/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png b/game/old/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png deleted file mode 100755 index 1ad224a..0000000 Binary files a/game/old/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png and /dev/null differ diff --git a/game/old/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png b/game/old/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png deleted file mode 100755 index 1cf1cac..0000000 Binary files a/game/old/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png and /dev/null differ diff --git a/game/old/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png b/game/old/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png deleted file mode 100755 index 35ec0d9..0000000 Binary files a/game/old/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png and /dev/null differ diff --git a/game/old/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png b/game/old/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png deleted file mode 100755 index b1b03b6..0000000 Binary files a/game/old/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png and /dev/null differ diff --git a/game/old/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png b/game/old/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png deleted file mode 100755 index e56eefd..0000000 Binary files a/game/old/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png and /dev/null differ diff --git a/game/old/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png b/game/old/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png deleted file mode 100755 index 3525eb9..0000000 Binary files a/game/old/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png and /dev/null differ diff --git a/game/old/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png b/game/old/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png deleted file mode 100755 index 2b6a9f9..0000000 Binary files a/game/old/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png and /dev/null differ diff --git a/game/old/css/ui-darkness/images/ui-icons_222222_256x240.png b/game/old/css/ui-darkness/images/ui-icons_222222_256x240.png deleted file mode 100755 index b273ff1..0000000 Binary files a/game/old/css/ui-darkness/images/ui-icons_222222_256x240.png and /dev/null differ diff --git a/game/old/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png b/game/old/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png deleted file mode 100755 index c5d93b6..0000000 Binary files a/game/old/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png and /dev/null differ diff --git a/game/old/css/ui-darkness/images/ui-icons_a83300_256x240.png b/game/old/css/ui-darkness/images/ui-icons_a83300_256x240.png deleted file mode 100755 index 95993ea..0000000 Binary files a/game/old/css/ui-darkness/images/ui-icons_a83300_256x240.png and /dev/null differ diff --git a/game/old/css/ui-darkness/images/ui-icons_cccccc_256x240.png b/game/old/css/ui-darkness/images/ui-icons_cccccc_256x240.png deleted file mode 100755 index 9254e05..0000000 Binary files a/game/old/css/ui-darkness/images/ui-icons_cccccc_256x240.png and /dev/null differ diff --git a/game/old/css/ui-darkness/images/ui-icons_ffffff_256x240.png b/game/old/css/ui-darkness/images/ui-icons_ffffff_256x240.png deleted file mode 100755 index 42f8f99..0000000 Binary files a/game/old/css/ui-darkness/images/ui-icons_ffffff_256x240.png and /dev/null differ diff --git a/game/old/css/ui-darkness/jquery-ui-1.8.9.custom.css b/game/old/css/ui-darkness/jquery-ui-1.8.9.custom.css deleted file mode 100755 index 164af9f..0000000 --- a/game/old/css/ui-darkness/jquery-ui-1.8.9.custom.css +++ /dev/null @@ -1,312 +0,0 @@ -/* - * jQuery UI CSS Framework 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - */ - -/* Layout helpers -----------------------------------*/ -.ui-helper-hidden { display: none; } -.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } -.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } -.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } -.ui-helper-clearfix { display: inline-block; } -/* required comment for clearfix to work in Opera \*/ -* html .ui-helper-clearfix { height:1%; } -.ui-helper-clearfix { display:block; } -/* end clearfix */ -.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } - - -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { cursor: default !important; } - - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } - - -/* - * jQuery UI CSS Framework 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - * - * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Segoe%20UI,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=6px&bgColorHeader=333333&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=25&borderColorHeader=333333&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=000000&bgTextureContent=05_inset_soft.png&bgImgOpacityContent=25&borderColorContent=666666&fcContent=ffffff&iconColorContent=cccccc&bgColorDefault=555555&bgTextureDefault=02_glass.png&bgImgOpacityDefault=20&borderColorDefault=666666&fcDefault=eeeeee&iconColorDefault=cccccc&bgColorHover=0078a3&bgTextureHover=02_glass.png&bgImgOpacityHover=40&borderColorHover=59b4d4&fcHover=ffffff&iconColorHover=ffffff&bgColorActive=f58400&bgTextureActive=05_inset_soft.png&bgImgOpacityActive=30&borderColorActive=ffaf0f&fcActive=ffffff&iconColorActive=222222&bgColorHighlight=eeeeee&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=80&borderColorHighlight=cccccc&fcHighlight=2e7db2&iconColorHighlight=4b8e0b&bgColorError=ffc73d&bgTextureError=02_glass.png&bgImgOpacityError=40&borderColorError=ffb73d&fcError=111111&iconColorError=a83300&bgColorOverlay=5c5c5c&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=50&opacityOverlay=80&bgColorShadow=cccccc&bgTextureShadow=01_flat.png&bgImgOpacityShadow=30&opacityShadow=60&thicknessShadow=7px&offsetTopShadow=-7px&offsetLeftShadow=-7px&cornerRadiusShadow=8px - */ - - -/* Component containers -----------------------------------*/ -.ui-widget { font-family: Segoe UI, Arial, sans-serif; font-size: 1.1em; } -.ui-widget .ui-widget { font-size: 1em; } -.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Segoe UI, Arial, sans-serif; font-size: 1em; } -.ui-widget-content { border: 1px solid #666666; background: #000000 url(images/ui-bg_inset-soft_25_000000_1x100.png) 50% bottom repeat-x; color: #ffffff; } -.ui-widget-content a { color: #ffffff; } -.ui-widget-header { border: 1px solid #333333; background: #333333 url(images/ui-bg_gloss-wave_25_333333_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; } -.ui-widget-header a { color: #ffffff; } - -/* Interaction states -----------------------------------*/ -.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #666666; background: #555555 url(images/ui-bg_glass_20_555555_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #eeeeee; } -.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #eeeeee; text-decoration: none; } -.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #59b4d4; background: #0078a3 url(images/ui-bg_glass_40_0078a3_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #ffffff; } -.ui-state-hover a, .ui-state-hover a:hover { color: #ffffff; text-decoration: none; } -.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #ffaf0f; background: #f58400 url(images/ui-bg_inset-soft_30_f58400_1x100.png) 50% 50% repeat-x; font-weight: bold; color: #ffffff; } -.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #ffffff; text-decoration: none; } -.ui-widget :active { outline: none; } - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #cccccc; background: #eeeeee url(images/ui-bg_highlight-soft_80_eeeeee_1x100.png) 50% top repeat-x; color: #2e7db2; } -.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #2e7db2; } -.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #ffb73d; background: #ffc73d url(images/ui-bg_glass_40_ffc73d_1x400.png) 50% 50% repeat-x; color: #111111; } -.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #111111; } -.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #111111; } -.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } -.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } -.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_cccccc_256x240.png); } -.ui-widget-content .ui-icon {background-image: url(images/ui-icons_cccccc_256x240.png); } -.ui-widget-header .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); } -.ui-state-default .ui-icon { background-image: url(images/ui-icons_cccccc_256x240.png); } -.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); } -.ui-state-active .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); } -.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_4b8e0b_256x240.png); } -.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_a83300_256x240.png); } - -/* positioning */ -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-off { background-position: -96px -144px; } -.ui-icon-radio-on { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-start { background-position: -80px -160px; } -/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-tl { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px; } -.ui-corner-tr { -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px; } -.ui-corner-bl { -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; } -.ui-corner-br { -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } -.ui-corner-top { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px; -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px; } -.ui-corner-bottom { -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } -.ui-corner-right { -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px; -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } -.ui-corner-left { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px; -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; } -.ui-corner-all { -moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px; } - -/* Overlays */ -.ui-widget-overlay { background: #5c5c5c url(images/ui-bg_flat_50_5c5c5c_40x100.png) 50% 50% repeat-x; opacity: .80;filter:Alpha(Opacity=80); } -.ui-widget-shadow { margin: -7px 0 0 -7px; padding: 7px; background: #cccccc url(images/ui-bg_flat_30_cccccc_40x100.png) 50% 50% repeat-x; opacity: .60;filter:Alpha(Opacity=60); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/* - * jQuery UI Tabs 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Tabs#theming - */ -.ui-tabs { position: relative; /*padding: .2em;*/ zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ -.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; } -.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; } -.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; } -.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */ -.ui-tabs .ui-tabs-panel { display: block; border-width: 0;/* padding: 1em 1.4em;*/ background: none; } -.ui-tabs .ui-tabs-hide { display: none !important; } diff --git a/game/old/date.format.js b/game/old/date.format.js deleted file mode 100644 index 3992c50..0000000 --- a/game/old/date.format.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Date Format 1.2.3 - * (c) 2007-2009 Steven Levithan - * MIT license - * - * Includes enhancements by Scott Trenda - * and Kris Kowal - * - * Accepts a date, a mask, or a date and a mask. - * Returns a formatted version of the given date. - * The date defaults to the current date/time. - * The mask defaults to dateFormat.masks.default. - */ - -var dateFormat = function () { - var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, - timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, - timezoneClip = /[^-+\dA-Z]/g, - pad = function (val, len) { - val = String(val); - len = len || 2; - while (val.length < len) val = "0" + val; - return val; - }; - - // Regexes and supporting functions are cached through closure - return function (date, mask, utc) { - var dF = dateFormat; - - // You can't provide utc if you skip other args (use the "UTC:" mask prefix) - if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { - mask = date; - date = undefined; - } - - // Passing date through Date applies Date.parse, if necessary - date = date ? new Date(date) : new Date; - if (isNaN(date)) throw SyntaxError("invalid date"); - - mask = String(dF.masks[mask] || mask || dF.masks["default"]); - - // Allow setting the utc argument via the mask - if (mask.slice(0, 4) == "UTC:") { - mask = mask.slice(4); - utc = true; - } - - var _ = utc ? "getUTC" : "get", - d = date[_ + "Date"](), - D = date[_ + "Day"](), - m = date[_ + "Month"](), - y = date[_ + "FullYear"](), - H = date[_ + "Hours"](), - M = date[_ + "Minutes"](), - s = date[_ + "Seconds"](), - L = date[_ + "Milliseconds"](), - o = utc ? 0 : date.getTimezoneOffset(), - flags = { - d: d, - dd: pad(d), - ddd: dF.i18n.dayNames[D], - dddd: dF.i18n.dayNames[D + 7], - m: m + 1, - mm: pad(m + 1), - mmm: dF.i18n.monthNames[m], - mmmm: dF.i18n.monthNames[m + 12], - yy: String(y).slice(2), - yyyy: y, - h: H % 12 || 12, - hh: pad(H % 12 || 12), - H: H, - HH: pad(H), - M: M, - MM: pad(M), - s: s, - ss: pad(s), - l: pad(L, 3), - L: pad(L > 99 ? Math.round(L / 10) : L), - t: H < 12 ? "a" : "p", - tt: H < 12 ? "am" : "pm", - T: H < 12 ? "A" : "P", - TT: H < 12 ? "AM" : "PM", - Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""), - o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), - S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10] - }; - - return mask.replace(token, function ($0) { - return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); - }); - }; -}(); - -// Some common format strings -dateFormat.masks = { - "default": "ddd mmm dd yyyy HH:MM:ss", - shortDate: "m/d/yy", - mediumDate: "mmm d, yyyy", - longDate: "mmmm d, yyyy", - fullDate: "dddd, mmmm d, yyyy", - shortTime: "h:MM TT", - mediumTime: "h:MM:ss TT", - longTime: "h:MM:ss TT Z", - isoDate: "yyyy-mm-dd", - isoTime: "HH:MM:ss", - isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", - isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" -}; - -// Internationalization strings -dateFormat.i18n = { - dayNames: [ - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" - ], - monthNames: [ - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", - "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" - ] -}; - -// For convenience... -Date.prototype.format = function (mask, utc) { - return dateFormat(this, mask, utc); -}; - diff --git a/game/old/dev/README b/game/old/dev/README deleted file mode 100644 index e69de29..0000000 diff --git a/game/old/dev/all.js b/game/old/dev/all.js deleted file mode 100644 index 7050da9..0000000 --- a/game/old/dev/all.js +++ /dev/null @@ -1,70 +0,0 @@ -/*1295489895,169565300,JIT Construction: v334085,en_US*/ - -if(!window.FB)window.FB={_apiKey:null,_session:null,_userStatus:'unknown',_logging:true,_inCanvas:((window.location.search.indexOf('fb_sig_in_iframe=1')>-1)||(window.location.search.indexOf('session=')>-1)||(window.location.search.indexOf('signed_request=')>-1)),_https:(window.name.indexOf('_fb_https')>-1),_domain:{api:'https://api.facebook.com/',api_read:'https://api-read.facebook.com/',cdn:'http://static.ak.fbcdn.net/',https_cdn:'https://s-static.ak.fbcdn.net/',graph:'https://graph.facebook.com/',staticfb:'http://static.ak.facebook.com/',https_staticfb:'https://s-static.ak.facebook.com/',www:window.location.protocol+'//www.facebook.com/',https_www:'https://www.facebook.com/'},_locale:null,_localeIsRtl:false,getDomain:function(a){switch(a){case 'api':return FB._domain.api;case 'api_read':return FB._domain.api_read;case 'cdn':return (window.location.protocol=='https:'||FB._https)?FB._domain.https_cdn:FB._domain.cdn;case 'graph':return FB._domain.graph;case 'staticfb':return FB._https?FB._domain.https_staticfb:FB._domain.staticfb;case 'https_staticfb':return FB._domain.https_staticfb;case 'www':return FB._https?FB._domain.https_www:FB._domain.www;case 'https_www':return FB._domain.https_www;}},copy:function(d,c,b,e){for(var a in c)if(b||typeof d[a]==='undefined')d[a]=e?e(c[a]):c[a];return d;},create:function(c,h){var e=window.FB,d=c?c.split('.'):[],a=d.length;for(var b=0;b');e.root.innerHTML='';f=true;window.setTimeout(function(){e.root.innerHTML=b;},0);}else{var c=document.createElement('iframe');c.id=e.id;c.name=e.name;c.onload=FB.Content._callbacks[a];c.scrolling='no';c.style.border='none';c.style.overflow='hidden';if(e.title)c.title=e.title;if(e.className)c.className=e.className;if(e.height)c.style.height=e.height+'px';if(e.width)c.style.width=e.width+'px';e.root.appendChild(c);f=true;c.src=e.url;}},postTarget:function(b){var a=document.createElement('form');a.action=b.url;a.target=b.target;a.method='POST';FB.Content.appendHidden(a);FB.Array.forEach(b.params,function(e,d){if(e!==null&&e!==undefined){var c=document.createElement('input');c.name=d;c.value=e;a.appendChild(c);}});a.submit();a.parentNode.removeChild(a);}}); -FB.provide('Flash',{_minVersions:[[9,0,159,0],[10,0,22,87]],_swfPath:'swf/XdComm.swf',_callbacks:[],init:function(){if(FB.Flash._init)return;FB.Flash._init=true;window.FB_OnFlashXdCommReady=function(){FB.Flash._ready=true;for(var d=0,e=FB.Flash._callbacks.length;d'+''+''+'');FB.Content.appendHidden(b);},hasMinVersion:function(){if(typeof FB.Flash._hasMinVersion==='undefined'){var i,a,b,h=[];try{i=new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');}catch(j){if(navigator.mimeTypes.length>0){var mimeType='application/x-shockwave-flash';if(navigator.mimeTypes[mimeType].enabledPlugin){var name='Shockwave Flash';i=(navigator.plugins[name+' 2.0']||navigator.plugins[name]).description;}}}if(i){var f=i.replace(/\D+/g,',').match(/^,?(.+),?$/)[1].split(',');for(a=0,b=f.length;ag[c])break majorVersion;}};}return FB.Flash._hasMinVersion;},onReady:function(a){FB.Flash.init();if(FB.Flash._ready){window.setTimeout(a,0);}else FB.Flash._callbacks.push(a);}}); -if(!this.JSON)this.JSON={};(function(){function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function')value=value.toJSON(key);if(typeof rep==='function')value=rep.call(holder,key,value);switch(typeof value){case 'string':return quote(value);case 'number':return isFinite(value)?String(value):'null';case 'boolean':case 'null':return String(value);case 'object':if(!value)return 'null';gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i-1?'&':'?')+FB.QS.encode(e));if(h.length>2000)throw new Error('JSONP only support a maximum of 2000 bytes of input.');FB.ApiServer._callbacks[c]=function(i){a&&a(i);delete FB.ApiServer._callbacks[c];g.parentNode.removeChild(g);};g.src=h;document.getElementsByTagName('head')[0].appendChild(g);},flash:function(b,e,c,d,a){if(!window.FB_OnXdHttpResult)window.FB_OnXdHttpResult=function(g,f){FB.ApiServer._callbacks[g](decodeURIComponent(f));};FB.Flash.onReady(function(){var h=FB.getDomain(b)+e,f=FB.QS.encode(d);if(c==='get'){if(h.length+f.length>2000){if(b==='graph')d.method='get';c='post';f=FB.QS.encode(d);}else{h+=(h.indexOf('?')>-1?'&':'?')+f;f='';}}else if(c!=='post'){if(b==='graph')d.method=c;c='post';f=FB.QS.encode(d);}var g=document.XdComm.sendXdHttpRequest(c.toUpperCase(),h,f,null);FB.ApiServer._callbacks[g]=function(i){a&&a(FB.JSON.parse(i));delete FB.ApiServer._callbacks[g];};});}}); -FB.provide('EventProvider',{subscribers:function(){if(!this._subscribersMap)this._subscribersMap={};return this._subscribersMap;},subscribe:function(b,a){var c=this.subscribers();if(!c[b]){c[b]=[a];}else c[b].push(a);},unsubscribe:function(b,a){var c=this.subscribers()[b];FB.Array.forEach(c,function(e,d){if(e==a)c[d]=null;});},monitor:function(d,a){if(!a()){var b=this,c=function(){if(a.apply(a,arguments))b.unsubscribe(d,c);};this.subscribe(d,c);}},clear:function(a){delete this.subscribers()[a];},fire:function(){var a=Array.prototype.slice.call(arguments),b=a.shift();FB.Array.forEach(this.subscribers()[b],function(c){if(c)c.apply(this,a);});}});FB.provide('Event',FB.EventProvider); -FB.provide('Intl',{_punctCharClass:('['+'.!?'+'\u3002'+'\uFF01'+'\uFF1F'+'\u0964'+'\u2026'+'\u0EAF'+'\u1801'+'\u0E2F'+'\uFF0E'+']'),_endsInPunct:function(a){if(typeof a!='string')return false;return a.match(new RegExp(FB.Intl._punctCharClass+'['+')"'+"'"+'\u00BB'+'\u0F3B'+'\u0F3D'+'\u2019'+'\u201D'+'\u203A'+'\u3009'+'\u300B'+'\u300D'+'\u300F'+'\u3011'+'\u3015'+'\u3017'+'\u3019'+'\u301B'+'\u301E'+'\u301F'+'\uFD3F'+'\uFF07'+'\uFF09'+'\uFF3D'+'\s'+']*$'));},_tx:function(d,a){if(a!==undefined)if(typeof a!='object'){FB.log('The second arg to FB.Intl._tx() must be an Object for '+'tx('+d+', ...)');}else{var c;for(var b in a)if(a.hasOwnProperty(b)){if(FB.Intl._endsInPunct(a[b])){c=new RegExp('\{'+b+'\}'+FB.Intl._punctCharClass+'*','g');}else c=new RegExp('\{'+b+'\}','g');d=d.replace(c,a[b]);}}return d;},tx:function(b,a){function c(e,d){void(0);}if(!FB.Intl._stringTable)return null;return FBIntern.Intl._tx(FB.Intl._stringTable[b],a);}}); -FB.provide('String',{trim:function(a){return a.replace(/^\s*|\s*$/g,'');},format:function(a){if(!FB.String.format._formatRE)FB.String.format._formatRE=/(\{[^\}^\{]+\})/g;var b=arguments;return a.replace(FB.String.format._formatRE,function(e,d){var c=parseInt(d.substr(1),10),f=b[c+1];if(f===null||f===undefined)return '';return f.toString();});},escapeHTML:function(b){var a=document.createElement('div');a.appendChild(document.createTextNode(b));return a.innerHTML.replace(/"/g,'"').replace(/'/g,''');},quote:function(c){var a=/["\\\x00-\x1f\x7f-\x9f]/g,b={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};return a.test(c)?'"'+c.replace(a,function(d){var e=b[d];if(e)return e;e=d.charCodeAt();return '\\u00'+Math.floor(e/16).toString(16)+(e%16).toString(16);})+'"':'"'+c+'"';}}); -FB.provide('Dom',{containsCss:function(c,a){var b=' '+c.className+' ';return b.indexOf(' '+a+' ')>=0;},addCss:function(b,a){if(!FB.Dom.containsCss(b,a))b.className=b.className+' '+a;},removeCss:function(b,a){if(FB.Dom.containsCss(b,a)){b.className=b.className.replace(a,'');FB.Dom.removeCss(b,a);}},getStyle:function(a,c){var d=false,b=a.style;if(a.currentStyle){FB.Array.forEach(c.match(/\-([a-z])/g),function(e){c=c.replace(e,e.substr(1,1).toUpperCase());});d=a.currentStyle[c];}else{FB.Array.forEach(c.match(/[A-Z]/g),function(e){c=c.replace(e,'-'+e.toLowerCase());});if(window.getComputedStyle){d=document.defaultView.getComputedStyle(a,null).getPropertyValue(c);if(c=='background-position-y'||c=='background-position-x')if(d=='top'||d=='left')d='0px';}}if(c=='opacity'){if(a.filters&&a.filters.alpha)return d;return d*100;}return d;},setStyle:function(a,c,d){var b=a.style;if(c=='opacity'){if(d>=100)d=99.999;if(d<0)d=0;b.opacity=d/100;b.MozOpacity=d/100;b.KhtmlOpacity=d/100;if(a.filters)if(a.filters.alpha==undefined){a.filter="alpha(opacity="+d+")";}else a.filters.alpha.opacity=d;}else b[c]=d;},addScript:function(b){var a=document.createElement('script');a.type="text/javascript";a.src=b;return document.getElementsByTagName('head')[0].appendChild(a);},addCssRules:function(e,c){if(!FB.Dom._cssRules)FB.Dom._cssRules={};var a=true;FB.Array.forEach(c,function(f){if(!(f in FB.Dom._cssRules)){a=false;FB.Dom._cssRules[f]=true;}});if(a)return;if(FB.Dom.getBrowserType()!='ie'){var d=document.createElement('style');d.type='text/css';d.textContent=e;document.getElementsByTagName('head')[0].appendChild(d);}else try{document.createStyleSheet().cssText=e;}catch(b){if(document.styleSheets[0])document.styleSheets[0].cssText+=e;}},getBrowserType:function(){if(!FB.Dom._browserType){var d=window.navigator.userAgent.toLowerCase(),b=['msie','firefox','safari','gecko'],c=['ie','mozilla','safari','mozilla'];for(var a=0;a=0){FB.Dom._browserType=c[a];break;}}return FB.Dom._browserType;},getViewportInfo:function(){var a=(document.documentElement&&document.compatMode=='CSS1Compat')?document.documentElement:document.body;return {scrollTop:a.scrollTop,scrollLeft:a.scrollLeft,width:self.innerWidth?self.innerWidth:a.clientWidth,height:self.innerHeight?self.innerHeight:a.clientHeight};},ready:function(a){if(FB.Dom._isReady){a();}else FB.Event.subscribe('dom.ready',a);}});(function(){function domReady(){FB.Dom._isReady=true;FB.Event.fire('dom.ready');FB.Event.clear('dom.ready');}if(FB.Dom._isReady||document.readyState=='complete')return domReady();if(document.addEventListener){document.addEventListener('DOMContentLoaded',domReady,false);}else if(document.attachEvent)document.attachEvent('onreadystatechange',domReady);if(FB.Dom.getBrowserType()=='ie'&&window===top)(function(){try{document.documentElement.doScroll('left');}catch(error){setTimeout(arguments.callee,0);return;}domReady();})();var oldonload=window.onload;window.onload=function(){domReady();if(oldonload)if(typeof oldonload=='string'){eval(oldonload);}else oldonload();};})(); -FB.provide('Dialog',{_loaderEl:null,_stack:[],_active:null,_findRoot:function(a){while(a){if(FB.Dom.containsCss(a,'fb_dialog'))return a;a=a.parentNode;}},_showLoader:function(a,c){if(!FB.Dialog._loaderEl){c=parseInt(c,10);c=c?c:460;FB.Dialog._loaderEl=FB.Dialog._findRoot(FB.Dialog.create({content:('
        '+' '+'
        '+'
        '+' Facebook'+'
        '+'
        '+'
        '+''),width:c}));}if(!a)a=function(){};var b=FB.$('fb_dialog_loader_close');FB.Dom.removeCss(b,'fb_hidden');b.onclick=function(){FB.Dialog._hideLoader();a();};FB.Dialog._makeActive(FB.Dialog._loaderEl);},_hideLoader:function(){if(FB.Dialog._loaderEl&&FB.Dialog._loaderEl==FB.Dialog._active)FB.Dialog._loaderEl.style.top='-10000px';},_makeActive:function(b){FB.Dialog._lowerActive();var a={width:parseInt(b.offsetWidth,10),height:parseInt(b.offsetHeight,10)},e=FB.Dom.getViewportInfo(),c=(e.scrollLeft+(e.width-a.width)/2),d=(e.scrollTop+(e.height-a.height)/2.5);b.style.left=(c>0?c:0)+'px';b.style.top=(d>0?d:0)+'px';FB.Dialog._active=b;},_lowerActive:function(){if(!FB.Dialog._active)return;FB.Dialog._active.style.top='-10000px';FB.Dialog._active=null;},_removeStacked:function(a){FB.Dialog._stack=FB.Array.filter(FB.Dialog._stack,function(b){return b!=a;});},create:function(e){e=e||{};if(e.loader)FB.Dialog._showLoader(e.onClose,e.loaderWidth);var d=document.createElement('div'),c=document.createElement('div'),a='fb_dialog';if(e.closeIcon&&e.onClose){var b=document.createElement('a');b.className='fb_dialog_close_icon';b.onclick=e.onClose;d.appendChild(b);}if(FB.Dom.getBrowserType()=='ie'){a+=' fb_dialog_legacy';FB.Array.forEach(['vert_left','vert_right','horiz_top','horiz_bottom','top_left','top_right','bottom_left','bottom_right'],function(g){var h=document.createElement('span');h.className='fb_dialog_'+g;d.appendChild(h);});}else a+=' fb_dialog_advanced';if(e.content)FB.Content.append(e.content,c);d.className=a;var f=parseInt(e.width,10);if(!isNaN(f))d.style.width=f+'px';c.className='fb_dialog_content';d.appendChild(c);FB.Content.append(d);if(e.visible)FB.Dialog.show(d);return c;},show:function(a){a=FB.Dialog._findRoot(a);if(a){FB.Dialog._removeStacked(a);FB.Dialog._hideLoader();FB.Dialog._makeActive(a);FB.Dialog._stack.push(a);}},remove:function(a){a=FB.Dialog._findRoot(a);if(a){var b=FB.Dialog._active==a;FB.Dialog._removeStacked(a);FB.Dialog._hideLoader();if(b)if(FB.Dialog._stack.length>0){FB.Dialog.show(FB.Dialog._stack.pop());}else FB.Dialog._lowerActive();window.setTimeout(function(){a.parentNode.removeChild(a);},3000);}}}); -FB.provide('XD',{_origin:null,_transport:null,_callbacks:{},_forever:{},init:function(a){if(FB.XD._origin)return;if(window.addEventListener&&!window.attachEvent&&window.postMessage){FB.XD._origin=(window.location.protocol+'//'+window.location.host+'/'+FB.guid());FB.XD.PostMessage.init();FB.XD._transport='postmessage';}else if(!a&&FB.Flash.hasMinVersion()){FB.XD._origin=(window.location.protocol+'//'+document.domain+'/'+FB.guid());FB.XD.Flash.init();FB.XD._transport='flash';}else{FB.XD._transport='fragment';FB.XD.Fragment._channelUrl=a||window.location.toString();}},resolveRelation:function(b){var g,d,f=b.split('.'),e=window;for(var a=0,c=f.length;a0)return 'javascript:false;//';var f=FB.getDomain('cdn')+'connect/xd_proxy.php#',c=FB.guid();if(FB.XD._transport=='fragment'){f=FB.XD.Fragment._channelUrl;var d=f.indexOf('#');if(d>0)f=f.substr(0,d);f+=((f.indexOf('?')<0?'?':'&')+FB.XD.Fragment._magic+'#?=&');}if(b)FB.XD._forever[c]=true;FB.XD._callbacks[c]=a;return f+FB.QS.encode({cb:c,origin:FB.XD._origin,relation:e||'opener',transport:FB.XD._transport});},recv:function(b){if(typeof b=='string')b=FB.QS.decode(b);var a=FB.XD._callbacks[b.cb];if(!FB.XD._forever[b.cb])delete FB.XD._callbacks[b.cb];a&&a(b);},PostMessage:{init:function(){var a=FB.XD.PostMessage.onMessage;window.addEventListener?window.addEventListener('message',a,false):window.attachEvent('onmessage',a);},onMessage:function(event){FB.XD.recv(event.data);}},Flash:{init:function(){FB.Flash.onReady(function(){document.XdComm.postMessage_init('FB.XD.Flash.onMessage',FB.XD._origin);});},onMessage:function(a){FB.XD.recv(decodeURIComponent(a));}},Fragment:{_magic:'fb_xd_fragment',checkAndDispatch:function(){var b=window.location.toString(),a=b.substr(b.indexOf('#')+1),c=b.indexOf(FB.XD.Fragment._magic);if(c>0){FB.init=FB.getLoginStatus=FB.api=function(){};document.documentElement.style.display='none';FB.XD.resolveRelation(FB.QS.decode(a).relation).FB.XD.recv(a);}}}});FB.XD.Fragment.checkAndDispatch(); -FB.provide('Arbiter',{inform:function(c,e,f,b){if(window.name.indexOf('app_runner_')===0){var d=FB.JSON.stringify({method:c,params:e});if(window.postMessage){FB.XD.resolveRelation(f||'parent').postMessage(d,'*');return;}else try{window.opener.postMessage(d);return;}catch(a){}}var h=(FB.getDomain((b?'https_':'')+'staticfb')+'connect/canvas_proxy.php#'+FB.QS.encode({method:c,params:FB.JSON.stringify(e||{}),relation:f}));var g=FB.Content.appendHidden('');FB.Content.insertIframe({url:h,root:g,width:1,height:1,onload:function(){setTimeout(function(){g.parentNode.removeChild(g);},10);}});}}); -FB.provide('',{ui:function(e,b){if(!e.method){FB.log('"method" is a required parameter for FB.ui().');return;}var a=FB.UIServer.prepareCall(e,b);if(!a)return;var d=a.params.display;if(d=='dialog')d='iframe';var c=FB.UIServer[d];if(!c){FB.log('"display" must be one of "popup", "iframe" or "hidden".');return;}c(a);}});FB.provide('UIServer',{Methods:{},_active:{},_defaultCb:{},_resultToken:'"xxRESULTTOKENxx"',genericTransform:function(a){if(a.params.display=='dialog'||a.params.display=='iframe'){a.params.display='iframe';a.params.channel=FB.UIServer._xdChannelHandler(a.id,'parent.parent');}return a;},prepareCall:function(h,b){var g=h.method.toLowerCase(),f=FB.UIServer.Methods[g]||{size:{width:575,height:240}},e=FB.guid(),d=FB._https||(g!=='auth.status');FB.copy(h,{api_key:FB._apiKey,app_id:FB._apiKey,locale:FB._locale,sdk:'joey',access_token:d&&FB._session&&FB._session.access_token||undefined});h.display=FB.UIServer.getDisplayMode(f,h);if(!f.url){f.url='dialog/'+g;delete h.method;}var a={cb:b,id:e,size:f.size||{},url:FB.getDomain(d?'https_www':'www')+f.url,params:h};var j=f.transform?f.transform:FB.UIServer.genericTransform;if(j){a=j(a);if(!a)return;}var i=FB.UIServer.getXdRelation(a.params.display);if(!(a.id in FB.UIServer._defaultCb)&&!('next' in a.params))a.params.next=FB.UIServer._xdResult(a.cb,a.id,i,true);if(i==='parent')a.params.channel_url=FB.UIServer._xdChannelHandler(e,'parent.parent');a.params=FB.JSON.flatten(a.params);var c=FB.QS.encode(a.params);if((a.url+c).length>2000){a.post=true;}else if(c)a.url+='?'+c;return a;},getDisplayMode:function(a,b){if(b.display==='hidden')return 'hidden';if(window.name.indexOf('app_runner_')===0)return 'async';if(!FB._session&&b.display=='dialog'&&!a.loggedOutIframe){FB.log('"dialog" mode can only be used when the user is connected.');return 'popup';}return b.display||(FB._session?'dialog':'popup');},getXdRelation:function(a){if(a==='popup')return 'opener';if(a==='dialog'||a==='iframe')return 'parent';if(a==='async')return 'parent.frames['+window.name+']';},popup:function(b){var a=typeof window.screenX!='undefined'?window.screenX:window.screenLeft,i=typeof window.screenY!='undefined'?window.screenY:window.screenTop,g=typeof window.outerWidth!='undefined'?window.outerWidth:document.documentElement.clientWidth,f=typeof window.outerHeight!='undefined'?window.outerHeight:(document.documentElement.clientHeight-22),k=b.size.width,d=b.size.height,h=(a<0)?window.screen.width+a:a,e=parseInt(h+((g-k)/2),10),j=parseInt(i+((f-d)/2.5),10),c=('width='+k+',height='+d+',left='+e+',top='+j+',scrollbars=1');if(b.params.method=='permissions.request')c+=',location=1,toolbar=0';if(b.post){FB.UIServer._active[b.id]=window.open('about:blank',b.id,c);FB.Content.postTarget({url:b.url,target:b.id,params:b.params});}else FB.UIServer._active[b.id]=window.open(b.url,b.id,c);if(b.id in FB.UIServer._defaultCb)FB.UIServer._popupMonitor();},hidden:function(a){a.className='FB_UI_Hidden';a.root=FB.Content.appendHidden('');FB.UIServer._insertIframe(a);},iframe:function(a){a.className='FB_UI_Dialog';a.root=FB.Dialog.create({onClose:function(){FB.UIServer._triggerDefault(a.id);},loader:true,loaderWidth:a.size.width,closeIcon:true});FB.Dom.addCss(a.root,'fb_dialog_iframe');FB.UIServer._insertIframe(a);},async:function(a){a.frame=window.name;delete a.url;delete a.size;FB.Arbiter.inform('showDialog',a);},_insertIframe:function(b){FB.UIServer._active[b.id]=false;var a=function(c){if(b.id in FB.UIServer._active)FB.UIServer._active[b.id]=c;};if(b.post){FB.Content.insertIframe({url:'about:blank',root:b.root,className:b.className,width:b.size.width,height:b.size.height,onload:function(c){a(c);FB.Content.postTarget({url:b.url,target:c.name,params:b.params});}});}else FB.Content.insertIframe({url:b.url,root:b.root,className:b.className,width:b.size.width,height:b.size.height,onload:a});},_triggerDefault:function(a){FB.UIServer._xdRecv({frame:a},FB.UIServer._defaultCb[a]||function(){});},_popupMonitor:function(){var a;for(var b in FB.UIServer._active)if(FB.UIServer._active.hasOwnProperty(b)&&b in FB.UIServer._defaultCb){var c=FB.UIServer._active[b];try{if(c.tagName)continue;}catch(d){}try{if(c.closed){FB.UIServer._triggerDefault(b);}else a=true;}catch(e){}}if(a&&!FB.UIServer._popupInterval){FB.UIServer._popupInterval=window.setInterval(FB.UIServer._popupMonitor,100);}else if(!a&&FB.UIServer._popupInterval){window.clearInterval(FB.UIServer._popupInterval);FB.UIServer._popupInterval=null;}},_xdChannelHandler:function(a,b){return FB.XD.handler(function(c){var d=FB.UIServer._active[a];if(!d)return;if(c.type=='resize'){if(c.height)d.style.height=c.height+'px';if(c.width)d.style.width=c.width+'px';FB.Arbiter.inform('resize.ack',{},'parent.frames['+d.name+']',true);FB.Dialog.show(d);}},b,true);},_xdNextHandler:function(a,b,d,c){if(c)FB.UIServer._defaultCb[b]=a;return FB.XD.handler(function(e){FB.UIServer._xdRecv(e,a);},d)+'&frame='+b;},_xdRecv:function(b,a){var c=FB.UIServer._active[b.frame];try{if(FB.Dom.containsCss(c,'FB_UI_Hidden')){window.setTimeout(function(){c.parentNode.parentNode.removeChild(c.parentNode);},3000);}else if(FB.Dom.containsCss(c,'FB_UI_Dialog'))FB.Dialog.remove(c);}catch(d){}try{if(c.close){c.close();FB.UIServer._popupCount--;}}catch(e){}delete FB.UIServer._active[b.frame];delete FB.UIServer._defaultCb[b.frame];a(b);},_xdResult:function(a,b,d,c){return (FB.UIServer._xdNextHandler(function(e){a&&a(e.result&&e.result!=FB.UIServer._resultToken&&FB.JSON.parse(e.result));},b,d,c)+'&result='+encodeURIComponent(FB.UIServer._resultToken));}}); -FB.provide('',{getLoginStatus:function(a,b){if(!FB._apiKey){FB.log('FB.getLoginStatus() called before calling FB.init().');return;}if(a)if(!b&&FB.Auth._loadState=='loaded'){a({status:FB._userStatus,session:FB._session});return;}else FB.Event.subscribe('FB.loginStatus',a);if(!b&&FB.Auth._loadState=='loading')return;FB.Auth._loadState='loading';var c=function(d){FB.Auth._loadState='loaded';FB.Event.fire('FB.loginStatus',d);FB.Event.clear('FB.loginStatus');};FB.ui({method:'auth.status',display:'hidden'},c);},getSession:function(){return FB._session;},login:function(a,b){FB.ui(FB.copy({method:'permissions.request',display:'popup'},b||{}),a);},logout:function(a){FB.ui({method:'auth.logout',display:'hidden'},a);}});FB.provide('Auth',{_callbacks:[],setSession:function(e,g){var b=!FB._session&&e,c=FB._session&&!e,a=FB._session&&e&&FB._session.uid!=e.uid,f=b||c||(FB._session&&e&&FB._session.access_token!=e.access_token),h=g!=FB._userStatus;var d={session:e,status:g};FB._session=e;FB._userStatus=g;if(f&&FB.Cookie&&FB.Cookie.getEnabled())FB.Cookie.set(e);if(h)FB.Event.fire('auth.statusChange',d);if(c||a)FB.Event.fire('auth.logout',d);if(b||a)FB.Event.fire('auth.login',d);if(f)FB.Event.fire('auth.sessionChange',d);if(FB.Auth._refreshTimer){window.clearTimeout(FB.Auth._refreshTimer);delete FB.Auth._refreshTimer;}if(FB.Auth._loadState&&e&&e.expires)FB.Auth._refreshTimer=window.setTimeout(function(){FB.getLoginStatus(null,true);},1200000);return d;},xdHandler:function(a,b,f,c,e,d){return FB.UIServer._xdNextHandler(FB.Auth.xdResponseWrapper(a,e,d),b,f,c);},xdResponseWrapper:function(a,c,b){return function(d){try{b=FB.JSON.parse(d.session);}catch(f){}if(b)c='connected';if(d.fb_https&&!FB._https)FB._https=true;var e=FB.Auth.setSession(b||null,c);e.perms=d&&d.perms||null;a&&a(e);};}});FB.provide('UIServer.Methods',{'permissions.request':{size:{width:627,height:326},transform:function(a){if(!FB._apiKey){FB.log('FB.login() called before calling FB.init().');return;}if(FB._session&&!a.params.perms){FB.log('FB.login() called when user is already connected.');a.cb&&a.cb({status:FB._userStatus,session:FB._session});return;}a=FB.UIServer.genericTransform(a);a.cb=FB.Auth.xdResponseWrapper(a.cb,FB._userStatus,FB._session);a.params.method='permissions.request';FB.copy(a.params,{fbconnect:FB._inCanvas?0:1,return_session:1,session_version:3});return a;}},'auth.logout':{url:'logout.php',transform:function(a){if(!FB._apiKey){FB.log('FB.logout() called before calling FB.init().');}else if(!FB._session){FB.log('FB.logout() called without a session.');}else{a.params.next=FB.Auth.xdHandler(a.cb,a.id,'parent',false,'unknown');return a;}}},'auth.status':{url:'extern/login_status.php',transform:function(a){var b=a.cb,c=a.id,d=FB.Auth.xdHandler;delete a.cb;FB.copy(a.params,{no_session:d(b,c,'parent',false,'notConnected'),no_user:d(b,c,'parent',false,'unknown'),ok_session:d(b,c,'parent',false,'connected'),session_version:3,extern:FB._inCanvas?0:2});return a;}}}); -FB.provide('Canvas',{_timer:null,_lastSize:{},setSize:function(b){if(typeof b!="object")b={};b=FB.copy(b||{},FB.Canvas._computeContentSize());b=FB.copy(b,{frame:window.name||'iframe_canvas'});if(FB.Canvas._lastSize[b.frame]){var a=FB.Canvas._lastSize[b.frame].height;if(FB.Canvas._lastSize[b.frame].width==b.width&&(b.height<=a&&(a-b.height<=16)))return false;}FB.Canvas._lastSize[b.frame]=b;FB.Arbiter.inform('setSize',b);return true;},setAutoResize:function(b,a){if(a===undefined&&typeof b=="number"){a=b;b=true;}if(b===undefined||b){if(FB.Canvas._timer===null)FB.Canvas._timer=window.setInterval(FB.Canvas.setSize,a||100);FB.Canvas.setSize();}else if(FB.Canvas._timer!==null){window.clearInterval(FB.Canvas._timer);FB.Canvas._timer=null;}},_computeContentSize:function(){var a=document.body,c=document.documentElement,d=0,b=Math.max(Math.max(a.offsetHeight,a.scrollHeight)+a.offsetTop,Math.max(c.offsetHeight,c.scrollHeight)+c.offsetTop);if(a.offsetWidthd)d=f;});if(c.clientLeft>0)d+=(c.clientLeft*2);if(c.clientTop>0)b+=(c.clientTop*2);return {height:b,width:d};}}); -FB.provide('UIServer.Methods',{'stream.share':{size:{width:575,height:380},url:'sharer.php',transform:function(a){if(!a.params.u)a.params.u=window.location.toString();return a;}},'fbml.dialog':{size:{width:575,height:300},url:'render_fbml.php',loggedOutIframe:true,transform:function(a){return a;}},'auth.logintofacebook':{size:{width:530,height:287},url:'login.php',transform:function(a){a.params.skip_api_login=1;var c=FB.UIServer.getXdRelation(a.params.display);var b=FB.UIServer._xdResult(a.cb,a.id,c,true);a.params.next=FB.getDomain(FB._https?'https_www':'www')+"login.php?"+FB.QS.encode({api_key:FB._apiKey,next:b,skip_api_login:1});return a;}}}); -FB.provide('',{share:function(a){FB.log('FB.share() has been deprecated. Please use FB.ui() instead.');FB.ui({display:'popup',method:'stream.share',u:a});},publish:function(b,a){FB.log('FB.publish() has been deprecated. Please use FB.ui() instead.');b=b||{};FB.ui(FB.copy({display:'popup',method:'stream.publish',preview:1},b||{}),a);},addFriend:function(b,a){FB.log('FB.addFriend() has been deprecated. Please use FB.ui() instead.');FB.ui({display:'popup',id:b,method:'friend.add'},a);}});FB.UIServer.Methods['auth.login']=FB.UIServer.Methods['permissions.request']; -FB.provide('XFBML',{_renderTimeout:30000,parse:function(c,a){c=c||document.body;var b=1,d=function(){b--;if(b===0){a&&a();FB.Event.fire('xfbml.render');}};FB.Array.forEach(FB.XFBML._tagInfos,function(f){if(!f.xmlns)f.xmlns='fb';var g=FB.XFBML._getDomElements(c,f.xmlns,f.localName);for(var e=0;e0)FB.log(b+' XFBML tags failed to render in '+FB.XFBML._renderTimeout+'ms.');},FB.XFBML._renderTimeout);d();},registerTag:function(a){FB.XFBML._tagInfos.push(a);},_processElement:function(dom,tagInfo,cb){var element=dom._element;if(element){element.subscribe('render',cb);element.process();}else{var processor=function(){var fn=eval(tagInfo.className);var getBoolAttr=function(attr){var attr=dom.getAttribute(attr);return (attr&&FB.Array.indexOf(['true','1','yes','on'],attr.toLowerCase())>-1);};var isLogin=false;var showFaces=true;var renderInIframe=false;if(tagInfo.className==='FB.XFBML.LoginButton'){renderInIframe=getBoolAttr('render-in-iframe');showFaces=getBoolAttr('show-faces')||getBoolAttr('show_faces');isLogin=renderInIframe||showFaces;if(isLogin)fn=FB.XFBML.Login;}element=dom._element=new fn(dom);if(isLogin){var extraParams={show_faces:showFaces};var perms=dom.getAttribute('perms');if(perms)extraParams.perms=perms;element.setExtraParams(extraParams);}element.subscribe('render',cb);element.process();};if(FB.CLASSES[tagInfo.className.substr(3)]){processor();}else FB.log('Tag '+tagInfo.className+' was not found.');}},_getDomElements:function(a,e,d){var c=e+':'+d;switch(FB.Dom.getBrowserType()){case 'mozilla':return a.getElementsByTagNameNS(document.body.namespaceURI,c);case 'ie':try{var docNamespaces=document.namespaces;if(docNamespaces&&docNamespaces[e]){var nodes=a.getElementsByTagName(d);if(!document.addEventListener||nodes.length>0)return nodes;}}catch(b){}return a.getElementsByTagName(c);default:return a.getElementsByTagName(c);}},_tagInfos:[{localName:'activity',className:'FB.XFBML.Activity'},{localName:'add-profile-tab',className:'FB.XFBML.AddProfileTab'},{localName:'bookmark',className:'FB.XFBML.Bookmark'},{localName:'comments',className:'FB.XFBML.Comments'},{localName:'connect-bar',className:'FB.XFBML.ConnectBar'},{localName:'fan',className:'FB.XFBML.Fan'},{localName:'like',className:'FB.XFBML.Like'},{localName:'like-box',className:'FB.XFBML.LikeBox'},{localName:'live-stream',className:'FB.XFBML.LiveStream'},{localName:'login',className:'FB.XFBML.Login'},{localName:'login-button',className:'FB.XFBML.LoginButton'},{localName:'facepile',className:'FB.XFBML.Facepile'},{localName:'friendpile',className:'FB.XFBML.Friendpile'},{localName:'name',className:'FB.XFBML.Name'},{localName:'profile-pic',className:'FB.XFBML.ProfilePic'},{localName:'recommendations',className:'FB.XFBML.Recommendations'},{localName:'registration',className:'FB.XFBML.Registration'},{localName:'send',className:'FB.XFBML.Send'},{localName:'serverfbml',className:'FB.XFBML.ServerFbml'},{localName:'share-button',className:'FB.XFBML.ShareButton'},{localName:'social-bar',className:'FB.XFBML.SocialBar'}]});(function(){try{if(document.namespaces&&!document.namespaces.item.fb)document.namespaces.add('fb');}catch(a){}}()); -FB.provide('XFBML',{set:function(b,c,a){FB.log('FB.XFBML.set() has been deprecated.');b.innerHTML=c;FB.XFBML.parse(b,a);}}); -FB.provide('',{bind:function(){var a=Array.prototype.slice.call(arguments),c=a.shift(),b=a.shift();return function(){return c.apply(b,a.concat(Array.prototype.slice.call(arguments)));};},Class:function(b,a,d){if(FB.CLASSES[b])return FB.CLASSES[b];var c=a||function(){};c.prototype=d;c.prototype.bind=function(e){return FB.bind(e,this);};c.prototype.constructor=c;FB.create(b,c);FB.CLASSES[b]=c;return c;},subclass:function(d,b,c,e){if(FB.CLASSES[d])return FB.CLASSES[d];var a=FB.create(b);FB.copy(e,a.prototype);e._base=a;e._callBase=function(g){var f=Array.prototype.slice.call(arguments,1);return a.prototype[g].apply(this,f);};return FB.Class(d,c?c:function(){if(a.apply)a.apply(this,arguments);},e);},CLASSES:{}});FB.provide('Type',{isType:function(a,b){while(a)if(a.constructor===b||a===b){return true;}else a=a._base;return false;}}); -FB.Class('Obj',null,FB.copy({setProperty:function(a,b){if(FB.JSON.stringify(b)!=FB.JSON.stringify(this[a])){this[a]=b;this.fire(a,b);}}},FB.EventProvider)); -FB.subclass('Waitable','Obj',function(){},{set:function(a){this.setProperty('value',a);},error:function(a){this.fire("error",a);},wait:function(a,b){if(b)this.subscribe('error',b);this.monitor('value',this.bind(function(){if(this.value!==undefined){a(this.value);return true;}}));}}); -FB.subclass('Data.Query','Waitable',function(){if(!FB.Data.Query._c)FB.Data.Query._c=1;this.name='v_'+FB.Data.Query._c++;},{parse:function(a){var b=FB.String.format.apply(null,a),d=(/^select (.*?) from (\w+)\s+where (.*)$/i).exec(b);this.fields=this._toFields(d[1]);this.table=d[2];this.where=this._parseWhere(d[3]);for(var c=1;c-1){return d;}else return b;});},isValid:function(){for(var a=this.dom;a;a=a.parentNode)if(a==document.body)return true;},clear:function(){this.dom.innerHTML='';}},FB.EventProvider)); -FB.subclass('XFBML.IframeWidget','XFBML.Element',null,{_showLoader:true,_refreshOnAuthChange:false,_allowReProcess:false,_fetchPreCachedLoader:false,_visibleAfter:'load',getUrlBits:function(){throw new Error('Inheriting class needs to implement getUrlBits().');},setupAndValidate:function(){return true;},oneTimeSetup:function(){},getSize:function(){},getIframeName:function(){},getIframeTitle:function(){},getChannelUrl:function(){if(!this._channelUrl){var a=this;this._channelUrl=FB.XD.handler(function(b){a.fire('xd.'+b.type,b);},'parent.parent',true);}return this._channelUrl;},getIframeNode:function(){return this.dom.getElementsByTagName('iframe')[0];},process:function(a){if(this._done){if(!this._allowReProcess&&!a)return;this.clear();}else this._oneTimeSetup();this._done=true;if(!this.setupAndValidate()){this.fire('render');return;}if(this._showLoader)this._addLoader();FB.Dom.addCss(this.dom,'fb_iframe_widget');if(this._visibleAfter!='immediate'){FB.Dom.addCss(this.dom,'fb_hide_iframes');}else this.subscribe('iframe.onload',FB.bind(this.fire,this,'render'));var c=this.getSize()||{};var d=this._getURL();if(!this._fetchPreCachedLoader)d+='?'+FB.QS.encode(this._getQS());if(d.length>2000){d='about:blank';var b=FB.bind(function(){this._postRequest();this.unsubscribe('iframe.onload',b);},this);this.subscribe('iframe.onload',b);}FB.Content.insertIframe({url:d,root:this.dom.appendChild(document.createElement('span')),name:this.getIframeName(),title:this.getIframeTitle(),className:FB._localeIsRtl?'fb_rtl':'fb_ltr',height:c.height,width:c.width,onload:FB.bind(this.fire,this,'iframe.onload')});},_oneTimeSetup:function(){this.subscribe('xd.resize',FB.bind(this._handleResizeMsg,this));if(FB.getLoginStatus){this.subscribe('xd.refreshLoginStatus',FB.bind(FB.getLoginStatus,FB,function(){},true));this.subscribe('xd.logout',FB.bind(FB.logout,FB,function(){}));}if(this._refreshOnAuthChange)this._setupAuthRefresh();if(this._visibleAfter=='load')this.subscribe('iframe.onload',FB.bind(this._makeVisible,this));this.oneTimeSetup();},_makeVisible:function(){this._removeLoader();FB.Dom.removeCss(this.dom,'fb_hide_iframes');this.fire('render');},_setupAuthRefresh:function(){FB.getLoginStatus(FB.bind(function(b){var a=b.status;FB.Event.subscribe('auth.statusChange',FB.bind(function(c){if(!this.isValid())return;if(a=='unknown'||c.status=='unknown')this.process(true);a=c.status;},this));},this));},_handleResizeMsg:function(b){if(!this.isValid())return;var a=this.getIframeNode();a.style.height=b.height+'px';if(b.width)a.style.width=b.width+'px';a.style.border='none';this._makeVisible();},_addLoader:function(){if(!this._loaderDiv){FB.Dom.addCss(this.dom,'fb_iframe_widget_loader');this._loaderDiv=document.createElement('div');this._loaderDiv.className='FB_Loader';this.dom.appendChild(this._loaderDiv);}},_removeLoader:function(){if(this._loaderDiv){FB.Dom.removeCss(this.dom,'fb_iframe_widget_loader');if(this._loaderDiv.parentNode)this._loaderDiv.parentNode.removeChild(this._loaderDiv);this._loaderDiv=null;}},_getQS:function(){return FB.copy({api_key:FB._apiKey,locale:FB._locale,sdk:'joey',session_key:FB._session&&FB._session.session_key,ref:this.getAttribute('ref')},this.getUrlBits().params);},_getURL:function(){var a='www',b='';if(this._fetchPreCachedLoader){a='cdn';b='static/';}return FB.getDomain(a)+'plugins/'+b+this.getUrlBits().name+'.php';},_postRequest:function(){FB.Content.postTarget({url:this._getURL(),target:this.getIframeNode().name,params:this._getQS()});}}); -FB.subclass('XFBML.Activity','XFBML.IframeWidget',null,{_visibleAfter:'load',_refreshOnAuthChange:true,setupAndValidate:function(){this._attr={border_color:this.getAttribute('border-color'),colorscheme:this.getAttribute('color-scheme'),filter:this.getAttribute('filter'),font:this.getAttribute('font'),header:this._getBoolAttribute('header'),height:this._getPxAttribute('height',300),recommendations:this._getBoolAttribute('recommendations'),site:this.getAttribute('site',location.hostname),width:this._getPxAttribute('width',300)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'activity',params:this._attr};}}); -FB.subclass('XFBML.ButtonElement','XFBML.Element',null,{_allowedSizes:['icon','small','medium','large','xlarge'],onClick:function(){throw new Error('Inheriting class needs to implement onClick().');},setupAndValidate:function(){return true;},getButtonMarkup:function(){return this.getOriginalHTML();},getOriginalHTML:function(){return this._originalHTML;},process:function(){if(!('_originalHTML' in this))this._originalHTML=FB.String.trim(this.dom.innerHTML);if(!this.setupAndValidate()){this.fire('render');return;}var d=this._getAttributeFromList('size','medium',this._allowedSizes),a='',b='';if(d=='icon'){a='fb_button_simple';}else{var c=FB._localeIsRtl?'_rtl':'';b=this.getButtonMarkup();a='fb_button'+c+' fb_button_'+d+c;}this.dom.innerHTML=(''+''+b+''+'');this.dom.firstChild.onclick=FB.bind(this.onClick,this);this.fire('render');}}); -FB.provide('Helper',{isUser:function(a){return a<2.2e+09||(a>=1e+14&&a<=100099999989999);},getLoggedInUser:function(){return FB._session?FB._session.uid:null;},upperCaseFirstChar:function(a){if(a.length>0){return a.substr(0,1).toUpperCase()+a.substr(1);}else return a;},getProfileLink:function(c,b,a){a=a||(c?FB.getDomain('www')+'profile.php?id='+c.uid:null);if(a)b=''+b+'';return b;},invokeHandler:function(handler,scope,args){if(handler)if(typeof handler==='string'){eval(handler);}else if(handler.apply)handler.apply(scope,args||[]);},fireEvent:function(a,b){var c=b._attr.href;b.fire(a,c);FB.Event.fire(a,c,b);},executeFunctionByName:function(d){var a=Array.prototype.slice.call(arguments,1);var f=d.split(".");var c=f.pop();var b=window;for(var e=0;e0){a.xid=encodeURIComponent(document.URL.substring(0,b));}else a.xid=encodeURIComponent(document.URL);}if(a.migrated&&!a.href)a.href='http://www.facebook.com/plugins/comments_v1.php?'+'app_id='+FB._apiKey+'&xid='+encodeURIComponent(a.xid)+'&url='+encodeURIComponent(a.url);this._attr=a;return true;},oneTimeSetup:function(){this.subscribe('xd.addComment',FB.bind(this._handleCommentMsg,this));},getSize:function(){return {width:this._attr.width,height:200};},getUrlBits:function(){return {name:'comments',params:this._attr};},_handleCommentMsg:function(a){if(!this.isValid())return;FB.Event.fire('comments.add',{post:a.post,user:a.user,widget:this});}}); -FB.provide('Anim',{ate:function(c,g,d,b){d=!isNaN(parseFloat(d))&&d>=0?d:750;var e=40,f={},j={},a=null,h=c.style,i=setInterval(FB.bind(function(){if(!a)a=new Date().getTime();var k=1;if(d!=0)k=Math.min((new Date().getTime()-a)/d,1);FB.Array.forEach(g,FB.bind(function(o,m){if(!f[m]){var n=FB.Dom.getStyle(c,m);if(n===false)return;f[m]=this._parseCSS(n+'');}if(!j[m])j[m]=this._parseCSS(o.toString());var l='';FB.Array.forEach(f[m],function(q,p){if(isNaN(j[m][p].numPart)&&j[m][p].textPart=='?'){l=q.numPart+q.textPart;}else if(isNaN(q.numPart)){l=q.textPart;}else l+=(q.numPart+Math.ceil((j[m][p].numPart-q.numPart)*Math.sin(Math.PI/2*k)))+j[m][p].textPart+' ';});FB.Dom.setStyle(c,m,l);},this));if(k==1){clearInterval(i);if(b)b(c);}},this),e);},_parseCSS:function(a){var b=[];FB.Array.forEach(a.split(' '),function(d){var c=parseInt(d,10);b.push({numPart:c,textPart:d.replace(c,'')});});return b;}}); -FB.provide('Insights',{impression:function(e,a){var b=FB.guid(),g="//ah8.facebook.com/impression.php/"+b+"/",c=new Image(1,1),f=[];if(!e.api_key&&FB._apiKey)e.api_key=FB._apiKey;for(var d in e)f.push(encodeURIComponent(d)+'='+encodeURIComponent(e[d]));g+='?'+f.join('&');if(a)c.onload=a;c.src=g;}}); -FB.subclass('XFBML.ConnectBar','XFBML.Element',null,{_initialHeight:null,_initTopMargin:0,_picFieldName:'pic_square',_page:null,_displayed:false,_notDisplayed:false,_container:null,_animationSpeed:0,process:function(){FB.getLoginStatus(this.bind(function(a){FB.Event.monitor('auth.statusChange',this.bind(function(){if(this.isValid()&&FB._userStatus=='connected'){this._uid=FB.Helper.getLoggedInUser();FB.api({method:'Connect.shouldShowConnectBar'},this.bind(function(b){if(b!=2){this._animationSpeed=(b==0)?750:0;this._showBar();}else this._noRender();}));}else this._noRender();return false;}));}));},_showBar:function(){var a=FB.Data._selectByIndex(['first_name','profile_url',this._picFieldName],'user','uid',this._uid);var b=FB.Data._selectByIndex(['display_name'],'application','api_key',FB._apiKey);FB.Data.waitOn([a,b],FB.bind(function(c){c[0][0].site_name=c[1][0].display_name;if(!this._displayed){this._displayed=true;this._notDisplayed=false;this._renderConnectBar(c[0][0]);this.fire('render');FB.Insights.impression({lid:104,name:'widget_load'});this.fire('connectbar.ondisplay');FB.Event.fire('connectbar.ondisplay',this);FB.Helper.invokeHandler(this.getAttribute('on-display'),this);}},this));},_noRender:function(){if(this._displayed){this._displayed=false;this._closeConnectBar();}if(!this._notDisplayed){this._notDisplayed=true;this.fire('render');this.fire('connectbar.onnotdisplay');FB.Event.fire('connectbar.onnotdisplay',this);FB.Helper.invokeHandler(this.getAttribute('on-not-display'),this);}},_renderConnectBar:function(d){var b=document.createElement('div'),c=document.createElement('div');b.className='fb_connect_bar';c.className='fb_reset fb_connect_bar_container';c.appendChild(b);document.body.appendChild(c);this._container=c;this._initialHeight=Math.round(parseFloat(FB.Dom.getStyle(c,'height'))+parseFloat(FB.Dom.getStyle(c,'borderBottomWidth')));b.innerHTML=FB.String.format('
        '+''+'{2}'+''+'
        '+''+'{4}'+''+'{5}'+' '+'{6} – '+'{0}'+'',FB.Intl._tx("No Thanks"),FB.getDomain('cdn')+FB.XFBML.ConnectBar.imgs.buttonUrl,FB.Intl._tx("Close"),d[this._picFieldName]||FB.getDomain('cdn')+FB.XFBML.ConnectBar.imgs.missingProfileUrl,FB.String.escapeHTML(d.first_name),FB.Intl._tx("Hi {firstName}. \u003cstrong>{siteName}\u003c\/strong> is using Facebook to personalize your experience.",{firstName:FB.String.escapeHTML(d.first_name),siteName:FB.String.escapeHTML(d.site_name)}),FB.Intl._tx("Learn More"),d.profile_url,FB.getDomain('www')+'sitetour/connect.php');var a=this;FB.Array.forEach(b.getElementsByTagName('a'),function(g){g.onclick=FB.bind(a._clickHandler,a);});this._page=document.body;var f=0;if(this._page.parentNode){f=Math.round((parseFloat(FB.Dom.getStyle(this._page.parentNode,'height'))-parseFloat(FB.Dom.getStyle(this._page,'height')))/2);}else f=parseInt(FB.Dom.getStyle(this._page,'marginTop'),10);f=isNaN(f)?0:f;this._initTopMargin=f;if(!window.XMLHttpRequest){c.className+=" fb_connect_bar_container_ie6";}else{c.style.top=(-1*this._initialHeight)+'px';FB.Anim.ate(c,{top:'0px'},this._animationSpeed);}var e={marginTop:this._initTopMargin+this._initialHeight+'px'};if(FB.Dom.getBrowserType()=='ie'){e.backgroundPositionY=this._initialHeight+'px';}else e.backgroundPosition='? '+this._initialHeight+'px';FB.Anim.ate(this._page,e,this._animationSpeed);},_clickHandler:function(a){a=a||window.event;var b=a.target||a.srcElement;while(b.nodeName!='A')b=b.parentNode;switch(b.className){case 'fb_bar_close':FB.api({method:'Connect.connectBarMarkAcknowledged'});FB.Insights.impression({lid:104,name:'widget_user_closed'});this._closeConnectBar();break;case 'fb_learn_more':case 'fb_profile':window.open(b.href);break;case 'fb_no_thanks':this._closeConnectBar();FB.api({method:'Connect.connectBarMarkAcknowledged'});FB.Insights.impression({lid:104,name:'widget_user_no_thanks'});FB.api({method:'auth.revokeAuthorization',block:true},this.bind(function(){this.fire('connectbar.ondeauth');FB.Event.fire('connectbar.ondeauth',this);FB.Helper.invokeHandler(this.getAttribute('on-deauth'),this);if(this._getBoolAttribute('auto-refresh',true))window.location.reload();}));break;}return false;},_closeConnectBar:function(){this._notDisplayed=true;var a={marginTop:this._initTopMargin+'px'};if(FB.Dom.getBrowserType()=='ie'){a.backgroundPositionY='0px';}else a.backgroundPosition='? 0px';var b=(this._animationSpeed==0)?0:300;FB.Anim.ate(this._page,a,b);FB.Anim.ate(this._container,{top:(-1*this._initialHeight)+'px'},b,function(c){c.parentNode.removeChild(c);});this.fire('connectbar.onclose');FB.Event.fire('connectbar.onclose',this);FB.Helper.invokeHandler(this.getAttribute('on-close'),this);}});FB.provide('XFBML.ConnectBar',{imgs:{buttonUrl:'images/facebook-widgets/close_btn.png',missingProfileUrl:'pics/q_silhouette.gif'}}); -FB.subclass('XFBML.Facepile','XFBML.IframeWidget',null,{_visibleAfter:'load',_extraParams:{},setupAndValidate:function(){this._attr={href:this.getAttribute('href'),channel:this.getChannelUrl(),max_rows:this.getAttribute('max-rows'),width:this._getPxAttribute('width',200),ref:this.getAttribute('ref')};for(var a in this._extraParams)this._attr[a]=this._extraParams[a];return true;},setExtraParams:function(a){this._extraParams=a;},oneTimeSetup:function(){var a=FB._userStatus;FB.Event.subscribe('auth.statusChange',FB.bind(function(b){if(a=='connected'||b.status=='connected')this.process(true);a=b.status;},this));},getSize:function(){return {width:this._attr.width,height:70};},getUrlBits:function(){return {name:'facepile',params:this._attr};}}); -FB.subclass('XFBML.Fan','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={api_key:FB._apiKey,connections:this.getAttribute('connections','10'),css:this.getAttribute('css'),height:this._getPxAttribute('height'),id:this.getAttribute('profile-id'),logobar:this._getBoolAttribute('logo-bar'),name:this.getAttribute('name'),stream:this._getBoolAttribute('stream',true),width:this._getPxAttribute('width',300)};if(!this._attr.id&&!this._attr.name){FB.log(' requires one of the "id" or "name" attributes.');return false;}var a=this._attr.height;if(!a)if((!this._attr.connections||this._attr.connections==='0')&&!this._attr.stream){a=65;}else if(!this._attr.connections||this._attr.connections==='0'){a=375;}else if(!this._attr.stream){a=250;}else a=550;if(this._attr.logobar)a+=25;this._attr.height=a;return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'fan',params:this._attr};}}); -FB.subclass('XFBML.Friendpile','XFBML.Facepile',null,{}); -FB.subclass('XFBML.EdgeCommentWidget','XFBML.IframeWidget',function(a){this._iframeWidth=a.width;this._iframeHeight=a.height;this._attr={master_frame_name:a.masterFrameName};this.dom=a.commentNode;this.dom.style.top=a.relativeHeightOffset;if(a.relativeWidthOffset)if(FB._localeIsRtl){this.dom.style.right=a.relativeWidthOffset;}else this.dom.style.left=a.relativeWidthOffset;this.dom.style.zIndex=FB.XFBML.EdgeCommentWidget.NextZIndex++;FB.Dom.addCss(this.dom,'fb_edge_comment_widget');},{_visibleAfter:'load',_showLoader:false,getSize:function(){return {width:this._iframeWidth,height:this._iframeHeight};},getUrlBits:function(){return {name:'comment_widget_shell',params:this._attr};}});FB.provide('XFBML.EdgeCommentWidget',{NextZIndex:10000}); -FB.subclass('XFBML.EdgeWidget','XFBML.IframeWidget',null,{_visibleAfter:'immediate',_showLoader:false,setupAndValidate:function(){FB.Dom.addCss(this.dom,'fb_edge_widget_with_comment');this._attr={channel_url:this.getChannelUrl(),debug:this._getBoolAttribute('debug'),href:this.getAttribute('href',window.location.href),is_permalink:this._getBoolAttribute('is-permalink'),node_type:this.getAttribute('node-type','link'),width:this._getWidgetWidth(),font:this.getAttribute('font'),layout:this._getLayout(),colorscheme:this.getAttribute('color-scheme'),action:this.getAttribute('action'),ref:this.getAttribute('ref'),show_faces:this._shouldShowFaces(),no_resize:this._getBoolAttribute('no_resize')};return true;},oneTimeSetup:function(){this.subscribe('xd.edgeCreated',FB.bind(this._onEdgeCreate,this));this.subscribe('xd.edgeRemoved',FB.bind(this._onEdgeRemove,this));this.subscribe('xd.presentEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogPresentation,this));this.subscribe('xd.dismissEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogDismissal,this));this.subscribe('xd.hideEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogHide,this));this.subscribe('xd.showEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogShow,this));},getSize:function(){return {width:this._getWidgetWidth(),height:this._getWidgetHeight()};},_getWidgetHeight:function(){var a=this._getLayout();var c=this._shouldShowFaces()?'show':'hide';var b={standard:{show:80,hide:35},box_count:{show:65,hide:65},button_count:{show:21,hide:21}};return b[a][c];},_getWidgetWidth:function(){var e=this._getLayout();var g=this._shouldShowFaces()?'show':'hide';var c=this.getAttribute('action')==='recommend'?130:90;var b=this.getAttribute('action')==='recommend'?100:55;var f={standard:{show:450,hide:450},box_count:{show:b,hide:b},button_count:{show:c,hide:c}};var d=f[e][g];var h=this._getPxAttribute('width',d);var a={standard:{min:225,max:900},box_count:{min:b,max:900},button_count:{min:c,max:900}};if(ha[e].max)h=a[e].max;return h;},_getLayout:function(){return this._getAttributeFromList('layout','standard',['standard','button_count','box_count']);},_shouldShowFaces:function(){return this._getLayout()==='standard'&&this._getBoolAttribute('show-faces',true);},_handleEdgeCommentDialogPresentation:function(b){if(!this.isValid())return;var a=document.createElement('span');this._commentSlave=this._createEdgeCommentWidget(b,a);this.dom.appendChild(a);this._commentSlave.process();this._commentWidgetNode=a;},_createEdgeCommentWidget:function(b,a){var c={commentNode:a,externalUrl:b.externalURL,width:330,height:200,masterFrameName:b.masterFrameName,layout:this._getLayout(),relativeHeightOffset:this._getHeightOffset(),relativeWidthOffset:this._getWidthOffset(b)};return new FB.XFBML.EdgeCommentWidget(c);},_getHeightOffset:function(){var a=this._getLayout();var b={standard:'20px',button_count:'17px',box_count:'-5px'};return b[a];},_getWidthOffset:function(c){if(c.preComputedWidthOffset)return parseInt(c.preComputedWidthOffset,10)+'px';var a=this._getLayout();var b={standard:'17px',box_count:'0px',button_count:'0px'};return b[a];},_handleEdgeCommentDialogDismissal:function(a){if(this._commentWidgetNode){this.dom.removeChild(this._commentWidgetNode);delete this._commentWidgetNode;}},_handleEdgeCommentDialogHide:function(){if(this._commentWidgetNode)this._commentWidgetNode.style.display="none";},_handleEdgeCommentDialogShow:function(){if(this._commentWidgetNode)this._commentWidgetNode.style.display="block";},_fireEventAndInvokeHandler:function(b,a){FB.Helper.fireEvent(b,this);FB.Helper.invokeHandler(this.getAttribute(a),this,[this._attr.href]);},_onEdgeCreate:function(){this._fireEventAndInvokeHandler('edge.create','on-create');},_onEdgeRemove:function(){this._fireEventAndInvokeHandler('edge.remove','on-remove');}}); -FB.subclass('XFBML.Like','XFBML.EdgeWidget',null,{getUrlBits:function(){return {name:'like',params:this._attr};},getIframeTitle:function(){return 'Like this content on Facebook.';}}); -FB.subclass('XFBML.LikeBox','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={channel:this.getChannelUrl(),api_key:FB._apiKey,connections:this.getAttribute('connections'),css:this.getAttribute('css'),height:this.getAttribute('height'),id:this.getAttribute('profile-id'),header:this._getBoolAttribute('header',true),name:this.getAttribute('name'),show_faces:this._getBoolAttribute('show-faces',true),stream:this._getBoolAttribute('stream',true),width:this._getPxAttribute('width',300),href:this.getAttribute('href'),colorscheme:this.getAttribute('colorscheme','light')};if(this._attr.connections==='0'){this._attr.show_faces=false;}else if(this._attr.connections)this._attr.show_faces=true;if(!this._attr.id&&!this._attr.name&&!this._attr.href){FB.log(' requires one of the "id" or "name" attributes.');return false;}var a=this._attr.height;if(!a)if(!this._attr.show_faces&&!this._attr.stream){a=62;}else{a=95;if(this._attr.show_faces)a+=163;if(this._attr.stream)a+=300;if(this._attr.header&&this._attr.header!=='0')a+=32;}this._attr.height=a;this.subscribe('xd.likeboxLiked',FB.bind(this._onLiked,this));this.subscribe('xd.likeboxUnliked',FB.bind(this._onUnliked,this));return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'likebox',params:this._attr};},_onLiked:function(){FB.Helper.fireEvent('edge.create',this);},_onUnliked:function(){FB.Helper.fireEvent('edge.remove',this);}}); -FB.subclass('XFBML.LiveStream','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={height:this._getPxAttribute('height',500),hideFriendsTab:this.getAttribute('hide-friends-tab'),redesigned:this._getBoolAttribute('redesigned-stream'),width:this._getPxAttribute('width',400),xid:this.getAttribute('xid','default'),always_post_to_friends:this._getBoolAttribute('always-post-to-friends',false)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){var a=this._attr.redesigned?'live_stream_box':'livefeed';return {name:a,params:this._attr};}}); -FB.subclass('XFBML.Login','XFBML.Facepile',null,{_visibleAfter:'load',getSize:function(){return {width:this._attr.width,height:94};},getUrlBits:function(){return {name:'login',params:this._attr};}}); -FB.subclass('XFBML.LoginButton','XFBML.ButtonElement',null,{setupAndValidate:function(){if(this._alreadySetup)return true;this._alreadySetup=true;this._attr={autologoutlink:this._getBoolAttribute('auto-logout-link'),length:this._getAttributeFromList('length','short',['long','short']),onlogin:this.getAttribute('on-login'),perms:this.getAttribute('perms'),registration_url:this.getAttribute('registration-url'),status:'unknown'};if(this._attr.autologoutlink)FB.Event.subscribe('auth.statusChange',FB.bind(this.process,this));if(this._attr.registration_url){FB.Event.subscribe('auth.statusChange',this._saveStatus(this.process));FB.getLoginStatus(this._saveStatus(this.process));}return true;},getButtonMarkup:function(){var a=this.getOriginalHTML();if(a)return a;if(!this._attr.registration_url){if(FB.getSession()&&this._attr.autologoutlink){return FB.Intl._tx("Facebook Logout");}else return this._getLoginText();}else switch(this._attr.status){case 'unknown':return this._getLoginText();case 'notConnected':return FB.Intl._tx("Register");case 'connected':if(FB.getSession()&&this._attr.autologoutlink)return FB.Intl._tx("Facebook Logout");return this._getLoginText();default:FB.log('Unknown status: '+this.status);return FB.Intl._tx("Login");}},_getLoginText:function(){return this._attr.length=='short'?FB.Intl._tx("Login"):FB.Intl._tx("Login with Facebook");},onClick:function(){if(!this._attr.registration_url){if(!FB.getSession()||!this._attr.autologoutlink){FB.login(FB.bind(this._authCallback,this),{perms:this._attr.perms});}else FB.logout(FB.bind(this._authCallback,this));}else switch(this._attr.status){case 'unknown':FB.ui({method:'auth.loginToFacebook'},FB.bind(function(a){FB.getLoginStatus(this._saveStatus(this._authCallback),true);},this));break;case 'notConnected':window.top.location=this._attr.registration_url;break;case 'connected':if(!FB.getSession()||!this._attr.autologoutlink){this._authCallback();}else FB.logout(FB.bind(this._authCallback,this));break;default:FB.log('Unknown status: '+this.status);}},_authCallback:function(a){FB.Helper.invokeHandler(this._attr.onlogin,this,[a]);},_saveStatus:function(a){return FB.bind(function(b){this._attr.status=b.status;if(a){a=this.bind(a,this);return a(b);}},this);}}); -FB.subclass('XFBML.Name','XFBML.Element',null,{process:function(){FB.copy(this,{_uid:this.getAttribute('uid'),_firstnameonly:this._getBoolAttribute('first-name-only'),_lastnameonly:this._getBoolAttribute('last-name-only'),_possessive:this._getBoolAttribute('possessive'),_reflexive:this._getBoolAttribute('reflexive'),_objective:this._getBoolAttribute('objective'),_linked:this._getBoolAttribute('linked',true),_subjectId:this.getAttribute('subject-id')});if(!this._uid){FB.log('"uid" is a required attribute for ');this.fire('render');return;}var b=[];if(this._firstnameonly){b.push('first_name');}else if(this._lastnameonly){b.push('last_name');}else b.push('name');if(this._subjectId){b.push('sex');if(this._subjectId==FB.Helper.getLoggedInUser())this._reflexive=true;}var a;FB.Event.monitor('auth.statusChange',this.bind(function(){if(!this.isValid()){this.fire('render');return true;}if(!this._uid||this._uid=='loggedinuser')this._uid=FB.Helper.getLoggedInUser();if(!this._uid)return;if(FB.Helper.isUser(this._uid)){a=FB.Data._selectByIndex(b,'user','uid',this._uid);}else a=FB.Data._selectByIndex(['name','id'],'profile','id',this._uid);a.wait(this.bind(function(c){if(this._subjectId==this._uid){this._renderPronoun(c[0]);}else this._renderOther(c[0]);this.fire('render');}));}));},_renderPronoun:function(b){var c='',a=this._objective;if(this._subjectId){a=true;if(this._subjectId===this._uid)this._reflexive=true;}if(this._uid==FB.Connect.get_loggedInUser()&&this._getBoolAttribute('use-you',true)){if(this._possessive){if(this._reflexive){c='your own';}else c='your';}else if(this._reflexive){c='yourself';}else c='you';}else switch(b.sex){case 'male':if(this._possessive){c=this._reflexive?'his own':'his';}else if(this._reflexive){c='himself';}else if(a){c='him';}else c='he';break;case 'female':if(this._possessive){c=this._reflexive?'her own':'her';}else if(this._reflexive){c='herself';}else if(a){c='her';}else c='she';break;default:if(this._getBoolAttribute('use-they',true)){if(this._possessive){if(this._reflexive){c='their own';}else c='their';}else if(this._reflexive){c='themselves';}else if(a){c='them';}else c='they';}else if(this._possessive){if(this._reflexive){c='his/her own';}else c='his/her';}else if(this._reflexive){c='himself/herself';}else if(a){c='him/her';}else c='he/she';break;}if(this._getBoolAttribute('capitalize',false))c=FB.Helper.upperCaseFirstChar(c);this.dom.innerHTML=c;},_renderOther:function(c){if(!c)return;var b='',a='';if(this._uid==FB.Helper.getLoggedInUser()&&this._getBoolAttribute('use-you',true)){if(this._reflexive){if(this._possessive){b='your own';}else b='yourself';}else if(this._possessive){b='your';}else b='you';}else{if(null===c.first_name)c.first_name='';if(null===c.last_name)c.last_name='';if(this._firstnameonly){b=FB.String.escapeHTML(c.first_name);}else if(this._lastnameonly)b=FB.String.escapeHTML(c.last_name);if(!b)b=FB.String.escapeHTML(c.name);if(b!==''&&this._possessive)b+='\'s';}if(!b)b=FB.String.escapeHTML(this.getAttribute('if-cant-see','Facebook User'));if(b){if(this._getBoolAttribute('capitalize',false))b=FB.Helper.upperCaseFirstChar(b);if(this._linked){a=FB.Helper.getProfileLink(c,b,this.getAttribute('href',null));}else a=b;}this.dom.innerHTML=a;}}); -FB.subclass('XFBML.ProfilePic','XFBML.Element',null,{process:function(){var d=this.getAttribute('size','thumb'),b=FB.XFBML.ProfilePic._sizeToPicFieldMap[d],g=this._getPxAttribute('width'),a=this._getPxAttribute('height'),e=this.dom.style,f=this.getAttribute('uid');if(this._getBoolAttribute('facebook-logo'))b+='_with_logo';if(g){g=g+'px';e.width=g;}if(a){a=a+'px';e.height=a;}var c=this.bind(function(j){var l=j?j[0]:null,i=l?l[b]:null;if(!i)i=FB.getDomain('cdn')+FB.XFBML.ProfilePic._defPicMap[b];var k=((g?'width:'+g+';':'')+(a?'height:'+g+';':'')),h=FB.String.format('{1}',i,l?FB.String.escapeHTML(l.name):'',k,this.dom.className);if(this._getBoolAttribute('linked',true))h=FB.Helper.getProfileLink(l,h,this.getAttribute('href',null));this.dom.innerHTML=h;FB.Dom.addCss(this.dom,'fb_profile_pic_rendered');this.fire('render');});FB.Event.monitor('auth.statusChange',this.bind(function(){if(!this.isValid()){this.fire('render');return true;}if(this.getAttribute('uid',null)=='loggedinuser')f=FB.Helper.getLoggedInUser();if(FB._userStatus&&f){FB.Data._selectByIndex(['name',b],FB.Helper.isUser(f)?'user':'profile',FB.Helper.isUser(f)?'uid':'id',f).wait(c);}else c();}));}});FB.provide('XFBML.ProfilePic',{_defPicMap:{pic:'pics/s_silhouette.jpg',pic_big:'pics/d_silhouette.gif',pic_big_with_logo:'pics/d_silhouette_logo.gif',pic_small:'pics/t_silhouette.jpg',pic_small_with_logo:'pics/t_silhouette_logo.gif',pic_square:'pics/q_silhouette.gif',pic_square_with_logo:'pics/q_silhouette_logo.gif',pic_with_logo:'pics/s_silhouette_logo.gif'},_sizeToPicFieldMap:{n:'pic_big',normal:'pic_big',q:'pic_square',s:'pic',small:'pic',square:'pic_square',t:'pic_small',thumb:'pic_small'}}); -FB.subclass('XFBML.Recommendations','XFBML.IframeWidget',null,{_visibleAfter:'load',_refreshOnAuthChange:true,setupAndValidate:function(){this._attr={border_color:this.getAttribute('border-color'),colorscheme:this.getAttribute('color-scheme'),filter:this.getAttribute('filter'),font:this.getAttribute('font'),header:this._getBoolAttribute('header'),height:this._getPxAttribute('height',300),site:this.getAttribute('site',location.hostname),width:this._getPxAttribute('width',300)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'recommendations',params:this._attr};}}); -FB.subclass('XFBML.Registration','XFBML.IframeWidget',null,{_visibleAfter:'immediate',_baseHeight:167,_fieldHeight:28,_skinnyWidth:520,_skinnyBaseHeight:173,_skinnyFieldHeight:52,setupAndValidate:function(){this._attr={channel_url:this.getChannelUrl(),client_id:FB._apiKey,fb_only:this._getBoolAttribute('fb-only',false),fields:this.getAttribute('fields'),height:this._getPxAttribute('height'),redirect_uri:this.getAttribute('redirect-uri',window.location.href),onvalidate:this.getAttribute('onvalidate'),width:this._getPxAttribute('width',600)};if(this._attr.onvalidate)this.subscribe('xd.validate',this.bind(function(b){var d=FB.JSON.parse(b.value);var a=this.bind(function(e){FB.Arbiter.inform('Registration.Validation',{errors:e,id:b.id},'parent.frames["'+this.getIframeNode().name+'"]');});var c=FB.Helper.executeFunctionByName(this._attr.onvalidate,d,a);if(c)a(c);}));return true;},getSize:function(){return {width:this._attr.width,height:this._getHeight()};},_getHeight:function(){if(this._attr.height)return this._attr.height;var b;if(!this._attr.fields){b=['name'];}else try{b=FB.JSON.parse(this._attr.fields);}catch(a){b=this._attr.fields.split(/,/);}if(this._attr.width requires the "fbml" attribute.');return false;}return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'serverfbml',params:this._attr};}}); -FB.subclass('XFBML.ShareButton','XFBML.Element',null,{process:function(){this._href=this.getAttribute('href',window.location.href);this._type=this.getAttribute('type','icon_link');FB.Dom.addCss(this.dom,'fb_share_count_hidden');this._renderButton(true);},_renderButton:function(f){if(!this.isValid()){this.fire('render');return;}var b='',c='',d='',a='',e=FB.Intl._tx("Share"),g='';switch(this._type){case 'icon':case 'icon_link':a='fb_button_simple';b=(''+(this._type=='icon_link'?e:' ')+'');f=false;break;case 'link':b=FB.Intl._tx("Share on Facebook");f=false;break;case 'button':b=''+e+'';a='fb_button fb_button_small';f=false;break;case 'button_count':b=''+e+'';c=(' '+''+this._getCounterMarkup()+'');a='fb_button fb_button_small';break;default:b=''+e+'';d=(' '+''+this._getCounterMarkup()+'');a='fb_button fb_button_small';g='fb_share_count_wrapper';}this.dom.innerHTML=FB.String.format('{4}{3}{5}',g,this._href,a,b,d,c,FB.JSON.stringify({method:'stream.share',u:this._href}));if(!f)this.fire('render');},_getCounterMarkup:function(){if(!this._count)this._count=FB.Data._selectByIndex(['total_count'],'link_stat','url',this._href);var b='0';if(this._count.value!==undefined){if(this._count.value.length>0){var a=this._count.value[0].total_count;if(a>3){FB.Dom.removeCss(this.dom,'fb_share_count_hidden');b=a>=1e+07?Math.round(a/1e+06)+'M':(a>=10000?Math.round(a/1000)+'K':a);}}}else this._count.wait(FB.bind(this._renderButton,this,false));return ''+b+'';}}); -void(0); - - -FB.provide("", {"_domain":{"api":"https:\/\/api.facebook.com\/","api_read":"https:\/\/api-read.facebook.com\/","cdn":"http:\/\/static.ak.fbcdn.net\/","graph":"https:\/\/graph.facebook.com\/","https_cdn":"https:\/\/s-static.ak.fbcdn.net\/","https_staticfb":"https:\/\/s-static.ak.facebook.com\/","https_www":"https:\/\/www.facebook.com\/","staticfb":"http:\/\/static.ak.facebook.com\/","www":"http:\/\/www.facebook.com\/"},"_locale":"en_US","_localeIsRtl":false}, true); -FB.provide("Flash", {"_minVersions":[[10,0,22,87]],"_swfPath":"rsrc.php\/v1\/yF\/r\/Y7YCBKX-HZn.swf"}, true); -FB.provide("XFBML.ConnectBar", {"imgs":{"buttonUrl":"rsrc.php\/yY\/r\/h_Y6u1wrZPW.png","missingProfileUrl":"rsrc.php\/yo\/r\/UlIqmHJn-SK.gif"}}, true); -FB.provide("XFBML.ProfilePic", {"_defPicMap":{"pic":"rsrc.php\/yh\/r\/C5yt7Cqf3zU.jpg","pic_big":"rsrc.php\/yL\/r\/HsTZSDw4avx.gif","pic_big_with_logo":"rsrc.php\/y5\/r\/SRDCaeCL7hM.gif","pic_small":"rsrc.php\/yi\/r\/odA9sNLrE86.jpg","pic_small_with_logo":"rsrc.php\/yD\/r\/k1xiRXKnlGd.gif","pic_square":"rsrc.php\/yo\/r\/UlIqmHJn-SK.gif","pic_square_with_logo":"rsrc.php\/yX\/r\/9dYJBPDHXwZ.gif","pic_with_logo":"rsrc.php\/yu\/r\/fPPR9f2FJ3t.gif"}}, true); -if (FB.Dom && FB.Dom.addCssRules) { FB.Dom.addCssRules(".fb_hidden{position:absolute;top:-10000px;z-index:10001}\n.fb_reset{background:none;border-spacing:0;border:0;color:#000;cursor:auto;direction:ltr;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;font-size:11px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal}\n.fb_link img{border:none}\n.fb_dialog{position:absolute;top:-10000px;z-index:10001}\n.fb_dialog_advanced{background:rgba(82, 82, 82, .7);padding:10px;-moz-border-radius:8px;-webkit-border-radius:8px}\n.fb_dialog_content{background:#fff;color:#333}\n.fb_dialog_close_icon{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 0 transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif);cursor:pointer;display:block;height:15px;position:absolute;right:18px;top:17px;width:15px;top:8px\\9;right:7px\\9}\n.fb_dialog_close_icon:hover{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -15px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif)}\n.fb_dialog_close_icon:active{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -30px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif)}\n.fb_dialog_loader{background-color:#f2f2f2;border:1px solid #606060;font-size:24px;padding:20px}\n.fb_dialog_top_left,\n.fb_dialog_top_right,\n.fb_dialog_bottom_left,\n.fb_dialog_bottom_right{height:10px;width:10px;overflow:hidden;position:absolute}\n.fb_dialog_top_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 0;left:-10px;top:-10px}\n.fb_dialog_top_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -10px;right:-10px;top:-10px}\n.fb_dialog_bottom_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -20px;bottom:-10px;left:-10px}\n.fb_dialog_bottom_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -30px;right:-10px;bottom:-10px}\n.fb_dialog_vert_left,\n.fb_dialog_vert_right,\n.fb_dialog_horiz_top,\n.fb_dialog_horiz_bottom{position:absolute;background:#525252;filter:alpha(opacity=70);opacity:.7}\n.fb_dialog_vert_left,\n.fb_dialog_vert_right{width:10px;height:100\u0025}\n.fb_dialog_vert_left{margin-left:-10px}\n.fb_dialog_vert_right{right:0;margin-right:-10px}\n.fb_dialog_horiz_top,\n.fb_dialog_horiz_bottom{width:100\u0025;height:10px}\n.fb_dialog_horiz_top{margin-top:-10px}\n.fb_dialog_horiz_bottom{bottom:0;margin-bottom:-10px}\n.fb_dialog_iframe{line-height:0}\n.fb_dialog_content .dialog_title{background:#6d84b4;border:1px solid #3b5998;color:#fff;font-size:14px;font-weight:bold;margin:0}\n.fb_dialog_content .dialog_title > span{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zd\/r\/Cou7n-nqK52.gif) no-repeat 5px 50\u0025;float:left;padding:5px 0 7px 26px}\n.fb_dialog_content .dialog_content{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/z9\/r\/jKEcVPZFk-2.gif) no-repeat 50\u0025 50\u0025;border:1px solid #555;border-bottom:0;border-top:0;height:150px}\n.fb_dialog_content .dialog_footer{background:#f2f2f2;border:1px solid #555;border-top-color:#ccc;height:40px}\n#fb_dialog_loader_close{float:right}\n.fb_iframe_widget{position:relative;display:-moz-inline-block;display:inline-block}\n.fb_iframe_widget iframe{position:relative;vertical-align:text-bottom}\n.fb_iframe_widget span{position:relative}\n.fb_hide_iframes iframe{position:relative;left:-10000px}\n.fb_iframe_widget_loader{position:relative;display:inline-block}\n.fb_iframe_widget_loader iframe{min-height:32px;z-index:2;zoom:1}\n.fb_iframe_widget_loader .FB_Loader{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/z9\/r\/jKEcVPZFk-2.gif) no-repeat;height:32px;width:32px;margin-left:-16px;position:absolute;left:50\u0025;z-index:4}\n.fb_button_simple,\n.fb_button_simple_rtl{background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zH\/r\/eIpbnVKI9lR.png);background-repeat:no-repeat;cursor:pointer;outline:none;text-decoration:none}\n.fb_button_simple_rtl{background-position:right 0}\n.fb_button_simple .fb_button_text{margin:0 0 0 20px;padding-bottom:1px}\n.fb_button_simple_rtl .fb_button_text{margin:0 10px 0 0}\na.fb_button_simple:hover .fb_button_text,\na.fb_button_simple_rtl:hover .fb_button_text,\n.fb_button_simple:hover .fb_button_text,\n.fb_button_simple_rtl:hover .fb_button_text{text-decoration:underline}\n.fb_button,\n.fb_button_rtl{background:#29447e url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/FGFbc80dUKj.png);background-repeat:no-repeat;cursor:pointer;display:inline-block;padding:0 0 0 1px;text-decoration:none;outline:none}\n.fb_button .fb_button_text,\n.fb_button_rtl .fb_button_text{background:#5f78ab url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/FGFbc80dUKj.png);border-top:solid 1px #879ac0;border-bottom:solid 1px #1a356e;color:#fff;display:block;font-family:\"lucida grande\",tahoma,verdana,arial,sans-serif;font-weight:bold;padding:2px 6px 3px 6px;margin:1px 1px 0 21px;text-shadow:none}\na.fb_button,\na.fb_button_rtl,\n.fb_button,\n.fb_button_rtl{text-decoration:none}\na.fb_button:active .fb_button_text,\na.fb_button_rtl:active .fb_button_text,\n.fb_button:active .fb_button_text,\n.fb_button_rtl:active .fb_button_text{border-bottom:solid 1px #29447e;border-top:solid 1px #45619d;background:#4f6aa3;text-shadow:none}\n.fb_button_xlarge,\n.fb_button_xlarge_rtl{background-position:left -60px;font-size:24px;line-height:30px}\n.fb_button_xlarge .fb_button_text{padding:3px 8px 3px 12px;margin-left:38px}\na.fb_button_xlarge:active{background-position:left -99px}\n.fb_button_xlarge_rtl{background-position:right -268px}\n.fb_button_xlarge_rtl .fb_button_text{padding:3px 8px 3px 12px;margin-right:39px}\na.fb_button_xlarge_rtl:active{background-position:right -307px}\n.fb_button_large,\n.fb_button_large_rtl{background-position:left -138px;font-size:13px;line-height:16px}\n.fb_button_large .fb_button_text{margin-left:24px;padding:2px 6px 4px 6px}\na.fb_button_large:active{background-position:left -163px}\n.fb_button_large_rtl{background-position:right -346px}\n.fb_button_large_rtl .fb_button_text{margin-right:25px}\na.fb_button_large_rtl:active{background-position:right -371px}\n.fb_button_medium,\n.fb_button_medium_rtl{background-position:left -188px;font-size:11px;line-height:14px}\na.fb_button_medium:active{background-position:left -210px}\n.fb_button_medium_rtl{background-position:right -396px}\n.fb_button_text_rtl,\n.fb_button_medium_rtl .fb_button_text{padding:2px 6px 3px 6px;margin-right:22px}\na.fb_button_medium_rtl:active{background-position:right -418px}\n.fb_button_small,\n.fb_button_small_rtl{background-position:left -232px;font-size:10px;line-height:10px}\n.fb_button_small .fb_button_text{padding:2px 6px 3px;margin-left:17px}\na.fb_button_small:active,\n.fb_button_small:active{background-position:left -250px}\n.fb_button_small_rtl{background-position:right -440px}\n.fb_button_small_rtl .fb_button_text{padding:2px 6px;margin-right:18px}\na.fb_button_small_rtl:active{background-position:right -458px}\n.fb_connect_bar_container div,\n.fb_connect_bar_container span,\n.fb_connect_bar_container a,\n.fb_connect_bar_container img,\n.fb_connect_bar_container strong{background:none;border-spacing:0;border:0;direction:ltr;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal;vertical-align:baseline}\n.fb_connect_bar_container{position:fixed;left:0 !important;right:0 !important;height:42px !important;padding:0 25px !important;margin:0 !important;vertical-align:middle !important;border-bottom:1px solid #333 !important;background:#3b5998 !important;z-index:99999999 !important;overflow:hidden !important}\n.fb_connect_bar_container_ie6{position:absolute;top:expression(document.compatMode==\"CSS1Compat\"? document.documentElement.scrollTop+\"px\":body.scrollTop+\"px\")}\n.fb_connect_bar{position:relative;margin:auto;height:100\u0025;width:100\u0025;padding:6px 0 0 0 !important;background:none;color:#fff !important;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif !important;font-size:13px !important;font-style:normal !important;font-variant:normal !important;font-weight:normal !important;letter-spacing:normal !important;line-height:1 !important;text-decoration:none !important;text-indent:0 !important;text-shadow:none !important;text-transform:none !important;white-space:normal !important;word-spacing:normal !important}\n.fb_connect_bar a:hover{color:#fff}\n.fb_connect_bar .fb_profile img{height:30px;width:30px;vertical-align:middle;margin:0 6px 5px 0}\n.fb_connect_bar div a,\n.fb_connect_bar span,\n.fb_connect_bar span a{color:#bac6da;font-size:11px;text-decoration:none}\n.fb_connect_bar .fb_buttons{float:right;margin-top:7px}\n.fb_edge_widget_with_comment{position:relative;*z-index:1000}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget{position:absolute}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_ltr{left:-4px}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_rtl{left:2px}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget{left:0}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget .FB_Loader{left:10\u0025}\n.fb_share_count_wrapper{position:relative;float:left}\n.fb_share_count{background:#b0b9ec none repeat scroll 0 0;color:#333;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;text-align:center}\n.fb_share_count_inner{background:#e8ebf2;display:block}\n.fb_share_count_right{margin-left:-1px;display:inline-block}\n.fb_share_count_right .fb_share_count_inner{border-top:solid 1px #e8ebf2;border-bottom:solid 1px #b0b9ec;margin:1px 1px 0 1px;font-size:10px;line-height:10px;padding:2px 6px 3px;font-weight:bold}\n.fb_share_count_top{display:block;letter-spacing:-1px;line-height:34px;margin-bottom:7px;font-size:22px;border:solid 1px #b0b9ec}\n.fb_share_count_nub_top{border:none;display:block;position:absolute;left:7px;top:35px;margin:0;padding:0;width:6px;height:7px;background-repeat:no-repeat;background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zU\/r\/bSOHtKbCGYI.png)}\n.fb_share_count_nub_right{border:none;display:inline-block;padding:0;width:5px;height:10px;background-repeat:no-repeat;background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zX\/r\/i_oIVTKMYsL.png);vertical-align:top;background-position:right 5px;z-index:10;left:2px;margin:0 2px 0 0;position:relative}\n.fb_share_no_count{display:none}\n.fb_share_size_Small .fb_share_count_right .fb_share_count_inner{font-size:10px}\n.fb_share_size_Medium .fb_share_count_right .fb_share_count_inner{font-size:11px;padding:2px 6px 3px;letter-spacing:-1px;line-height:14px}\n.fb_share_size_Large .fb_share_count_right .fb_share_count_inner{font-size:13px;line-height:16px;padding:2px 6px 4px;font-weight:normal;letter-spacing:-1px}\n.fb_share_count_hidden .fb_share_count_nub_top,\n.fb_share_count_hidden .fb_share_count_top,\n.fb_share_count_hidden .fb_share_count_nub_right,\n.fb_share_count_hidden .fb_share_count_right{visibility:hidden}\n", ["fb.css.base","fb.css.dialog","fb.css.iframewidget","fb.css.button","fb.css.connectbarwidget","fb.css.edgecommentwidget","fb.css.sendbuttonformwidget","fb.css.sharebutton"]); } \ No newline at end of file diff --git a/game/old/dev/animated_image.js b/game/old/dev/animated_image.js deleted file mode 100644 index fbec113..0000000 --- a/game/old/dev/animated_image.js +++ /dev/null @@ -1,93 +0,0 @@ -// Manages an animated image. Assumes that while it is active, -// get_image is called once per game loop -// Defaults to starting immediately -// Unless you call loop, will only run through the images once -// spec: -// All optional -// anim_rate : the number of frames to display each image -// reverse : whether to go backwards in the images when you reach the end or not - -var animated_image = function(image_name, spec) { - - // obj to return - var obj = []; - - // private vars - - var all_images = image_manager.get_images(image_name); - all_images.sort( - function(i1, i2) { - //return i1.path < i2.path; - return i1.path < i2.path ? -1 : (i1.path > i2.path ? 1 : 0); - } - ); - //for_each(all_images, function(i) { console.log(i.path); }); - var curr_index = 0; - var active = true; - var loop = false; - var rate_counter = 0; // Goes from 0 to anim_rate - 1 - var anim_rate = spec.anim_rate || 3; - - // If we are reversing, add all the images in the opposite - // order to all_images - if (spec.reverse || false) { - for (var i = (all_images.length - 1); i >=0; i--) { - all_images.push(all_images[i]); - } - } - - //public methods - - obj.start = function() { - active = true; - }; - - obj.pause = function() { - active = false; - }; - - obj.loop = function() { - loop = true; - }; - - obj.is_finished = function() { - // changed to && cuz it should be not looping - // and at the end to be finished - return (!loop && curr_index === (all_images.length - 1)); - }; - - // Returns the current image - obj.get_frame = function() { - var curr_image = all_images[curr_index].image; - update(); - return curr_image; - }; - - obj.set_rate = function(r) { - anim_rate = r; - }; - - // private methods - - var update = function() { - if (active) { - if (rate_counter >= (anim_rate - 1)) { - next_frame(); - rate_counter = 0; - } - else { - rate_counter++; - } - } - }; - - var next_frame = function() { - // If not 'at the end and not looping', - // increment curr_index, restarting if we reach the end - if (!(curr_index === all_images.length && !loop)) { - curr_index = (curr_index + 1) % all_images.length; - } - } - - return obj; -} diff --git a/game/old/dev/antibody.js b/game/old/dev/antibody.js deleted file mode 100644 index e6c6e17..0000000 --- a/game/old/dev/antibody.js +++ /dev/null @@ -1,86 +0,0 @@ -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards - -var antibody = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 11; - spec.height = spec.height || 7; - spec.speed = spec.speed || 4; - spec.no_target_speed = spec.no_target_speed || 2 - - //spec.vel = random_vel(); - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "antibody"; - }; - - // --- private variables --- - - // flag denoting whether the antibody is attached to a cell - var attached = false; - - // --- public methods --- - - // should be called when an antibody attaches to a cell - // tar will be the cell that it is attaching to (may not be its target) - obj.attach = function(tar) { - attached = true; - obj.face_target(tar); - // scoot it out just a bit - obj.get_vel().mult(-1); - obj.move(); - - //obj.set_target(null); - }; - - // implementing game_object interface - - obj.my_update = function() { - if (!attached) { - obj.set_speed(obj.get_level() / 4 + 1) - obj.move(); - // don't want two antibodies attacking one cell - var tar = obj.get_target(); - if (tar && (tar.has_antibody() - // also don't want them to keep target - // if the target changes level - || tar.get_level() !== obj.get_level() - // or if it starts to die - || tar.get_state() === "dying")) { - obj.set_target(null); - } - } - }; - - // should point towards target - // Y-shaped (top of Y is front) - obj.draw = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.stroke(obj.get_color()); - p.strokeWeight(2); - - p.line(-w, 0, w/3, 0); - p.line(w/3, 0, w, h/2); - p.line(w/3, 0, w, -h/2); - - p.popMatrix(); - }; - - return obj; -} diff --git a/game/old/dev/b_cell.js b/game/old/dev/b_cell.js deleted file mode 100644 index 5d3747a..0000000 --- a/game/old/dev/b_cell.js +++ /dev/null @@ -1,249 +0,0 @@ -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards -// state = just leave to be default (alive) - -var b_cell = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 30; - spec.height = spec.height || 30; - spec.speed = spec.speed || 5; - - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "b_cell"; - }; - - // --- private variables --- - - var b_anim = animated_image("bcell", {reverse : true}); - // for illustration - var b_image = image_manager.get_image("bcell_normal.png"); - // where to go and shoot from - var slot = null; - - // state can be "alive", "active", "shooting", "outdated" - - // Antibodies are created in update, and returned in get_antibodies() - var new_antibodies = null; - - // --- private methods - - // Makes one antibody and adds it to new_antibodies - var make_antibody = function() { - if (!new_antibodies) { - new_antibodies = []; - } - var obj_pos = obj.get_pos(); - var new_antibody = antibody(p, { - pos : new p.PVector(obj_pos.x, obj_pos.y + (obj.get_height() / 2)), - mutation_info: obj.get_mutation_info() - }); - new_antibodies.push(new_antibody); - return new_antibody; - }; - - - // --- public methods --- - - // Makes this target stop and begin producing antibodies - obj.make_antibodies = function() { - obj.set_state("shooting"); - obj.set_target(null); - // production will happen in update - }; - - // to be called on collision with floater - // takes a slot pos - obj.activate = function(aslot) { - obj.set_state("active"); - slot = aslot; - // send the bcell to the top - obj.set_target(game_object(p, { - pos: slot.pos //new p.PVector(p.width - (obj.get_width() / 2), 0) - })); - }; - - obj.get_slot = function() { - return slot; - }; - - // Returns any newly created antibodies - obj.get_antibodies = function() { - if (new_antibodies) { - var to_return = new_antibodies; - new_antibodies = null; - return to_return; - } - else { - return []; - } - }; - - obj.is_activated = function() { - return obj.get_state() === "active"; - }; - - obj.is_alive = function() { - return obj.get_state() === "alive"; - }; - - obj.is_shooting = function() { - return obj.get_state() === "shooting"; - }; - - obj.get_scroll_dist = function() { - var state = obj.get_state(); - if (state === "shooting" - //|| state === "alive" - || state === "active" ) { - return 0; - } - else if (state === "outdated") { - return obj.DEFAULT_SCROLL_DIST;// * 2; - } - else { - return obj.DEFAULT_SCROLL_DIST; - } - }; - - // implementing game_object interface - - obj.my_update = function() { - if (obj.get_state() === "shooting") { - //obj.stop(); - // make it face downwards - var angle = p.PI/2 - // switch if at bottom - if (!slot.is_top) { - angle = -p.PI/2; - } - obj.set_target_angle(angle); - if (Math.random() < .03) { - var new_anti = make_antibody(); - new_anti.set_target_angle(p.random(0, 2*angle)); - } - } - else { - obj.move(); - } - }; - - var draw_antibody = function() { - // private vars - var counter = 0; - var c_max = 30; - var ascending = true; - - // for illustrations - obj.set_anti_count = function(c) { - counter = c; - }; - - return function(){ - - p.pushMatrix(); - - var pos = obj.get_pos(); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - // Copied from antibody.js to avoid overhead of - // creating new antibody every time - p.stroke(obj.get_color()); - p.strokeWeight(1 + (counter / 6)); - - var w = 11; - var h = 7; - p.line(-w, 0, w / 3, 0); - p.line(w / 3, 0, w, h / 2); - p.line(w / 3, 0, w, -h / 2); - - p.popMatrix(); - - if (ascending === true) { - counter++; - } - else if (ascending === false) { - counter--; - } - if (counter === c_max) { - ascending = false; - } - else if (counter === 0) { - ascending = true; - } - }; - }(); - - // should point towards target - // (triangle for now) - obj.draw = function() { - /* - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.fill(obj.get_color()); - // If outdated, draw differently? - if (obj.get_state() === "outdated") { - p.fill(0); - } - p.noStroke(); - - // rightward triangle - p.triangle(-w/2, -h/2, -w/2, h/2, w/2, 0); - - p.fill(255); - p.ellipse(-w/4, 0, 10, 10); - - p.popMatrix(); - */ - - p.pushMatrix(); - - var pos = obj.get_pos(); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle() + p.PI / 2); - p.fill(obj.get_color()); - p.noStroke(); - //p.rect(rectx_offset, recty_offset, rect_width, rect_height); - p.imageMode(obj.get_mode()); - - if (!obj.is_illustration()) { - b_image = b_anim.get_frame(); - } - p.image(b_image, 0, 0, obj.get_width(), obj.get_height()); - - p.popMatrix(); - - var state = obj.get_state(); - if (state === "active" || state === "shooting") { - draw_antibody(); - } - }; - - obj.stop_animation = function() { - b_anim.pause(); - }; - - obj.resume_animation = function() { - b_anim.start(); - }; - - return obj; -} diff --git a/game/old/dev/background_edge.js b/game/old/dev/background_edge.js deleted file mode 100644 index 6d8bb09..0000000 --- a/game/old/dev/background_edge.js +++ /dev/null @@ -1,54 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec -// boolean is_top = true if its a top edge, otherwise false -// - -var background_edge = function(p, spec) { - - //var background_image = p.loadImage("images/background.jpg"); - //var background_image = p.loadImage("images/background1.png"); - var edge = spec.is_top ? - image_manager.get_image("background_topside.png") : - image_manager.get_image("background_bottomside.png"); - - // --- defaults --- - - spec.mode = p.CORNERS; - spec.width = spec.width || edge.width; - spec.height = spec.height || edge.height; - - // if bottom, height should have been set to bottom of screen - // so we need to shift it up - if (!spec.is_top) { - spec.pos.add(new p.PVector(0, -spec.height)); - } - - // obj to return - var obj = background_object(p, spec); - - obj.get_type = function() { - return "background_edge"; - }; - - - // --- private variables --- - - - // --- public methods --- - - // override draw method only - obj.draw = function() { - p.imageMode(obj.get_mode()); - p.image(edge, obj.get_pos().x, obj.get_pos().y); - }; - - // override offscreen check cuz we draw from the corners - obj.is_offscreen = function() { - // only need to check left edge of screen - return obj.get_pos().x + obj.get_width() < 0; - }; - - return obj; -}; - diff --git a/game/old/dev/background_object.js b/game/old/dev/background_object.js deleted file mode 100644 index 0f96f4e..0000000 --- a/game/old/dev/background_object.js +++ /dev/null @@ -1,76 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec -// - -var background_object = function(p, spec) { - - var obj_image = random_from( - image_manager.get_images("background")).image; - - - // --- defaults --- - - spec.mode = spec.mode || p.CENTER; - spec.width = spec.width || obj_image.width; - spec.height = spec.height || obj_image.height; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "background_object"; - }; - - // --- private variables --- - - - // --- public methods --- - - // implementing game_object interface - - // update is default (move) - - // (flat rect for now) - obj.draw = function() { - //var x_pos = obj.get_pos().x; - - //p.fill(p.color(49, 0, 0)); - //p.rect(x_pos, 0, obj.get_width() - x_pos, obj.get_height()); - //background_image.resize(p.width, p.height); - //p.image(background_image, 0, 0); - //console.log(obj.get_pos().x); - p.imageMode(obj.get_mode()); - p.image(obj_image, obj.get_pos().x, obj.get_pos().y); - //p.set(obj.get_pos().x, 0, background_image); - //p.fill(255, 70); - //p.noStroke(); - //p.rect(obj.get_pos().x, 0, obj.get_width(), obj.get_height()); - }; - - // background can't go off screen or die - obj.is_dead = function() { - return false; - }; - /* - obj.is_offscreen = function() { - return false; - }; - */ - //var count = 0; - - obj.scroll = function(scroll_factor) { - // count += 1; - //if (count === 1) { - // count = 0; - obj.get_pos().add(new p.PVector(obj.get_scroll_dist(), 0)); - // } - }; - - obj.get_scroll_dist = function() { - return -1; - }; - - return obj; -}; - diff --git a/game/old/dev/button.js b/game/old/dev/button.js deleted file mode 100644 index 995dde5..0000000 --- a/game/old/dev/button.js +++ /dev/null @@ -1,122 +0,0 @@ -// Have a rectangle representing their position and a state to go to when clicked -// spec: -// state : function that returns a new state to go to when clicked -// (think of it like a thunk) -// rect : spec for a rectangle representing the button - -var button = function(p, spec) { - - // --- defaults --- - //spec.rect.width = spec.rect.width || 100; - //spec.rect.height = spec.rect.height || 35; - - // obj to return - var obj = {}; - - // --- private variables --- - - var next_state_fun = spec.state; - var active = spec.active || true; - - var image = spec.rect.image ? - image_manager.get_image(spec.rect.image) : null; - var over_image = spec.rect.over_image ? - image_manager.get_image(spec.rect.over_image) : null; - - // if no width is given but an image is - // use the image width - if (!spec.rect.width && image) { - spec.rect.width = image.width; - } - // and for height - if (!spec.rect.height && image) { - spec.rect.height = image.height; - } - - var rect = rectangle(p, spec.rect); - - // --- public methods --- - - obj.draw = function() { - if (!active) { - rect.set_tint(100); - /* - var r = spec.rect; - p.noStroke(); - p.fill(0, 150); - p.rectMode(p.CENTER); - p.rect(r.pos.x, r.pos.y, r.width, r.height); - */ - } - else { - //rect.set_tint(255); - } - rect.draw(); - }; - - // makes a button not active - obj.deactivate = function() { - // hack to make sure button tint updates - obj.mouse_moved(-1, -1); - active = false; - }; - - // makes a button active - obj.activate = function() { - // hack to make sure button tint updates - obj.mouse_moved(-1, -1); - active = true; - }; - - // Returns the state to go to if clicked, or - // null if not clicked - obj.is_clicked = function(x, y) { - if (active && rect.is_in(x, y)) { - // after click go back to normal image - if (over_image) { - rect.set_image(image); - } - return obj.get_state(); - } - else { - return null; - } - }; - - // special case for track buttons - obj.click = obj.is_clicked; - - obj.mouse_moved = function(x, y) { - if (active && rect.is_in(x, y)) { - if (over_image) { - rect.set_image(over_image); - } - else { - //rect.set_tint(0); - rect.set_tint(255, 255); - //rect.draw_twice(); - //console.log("tinting"); - } - } - else { - if (!over_image) { - rect.set_tint(200, 255); - } - //rect.draw_once(); - rect.set_image(image); - } - }; - // call once to init button tints - obj.mouse_moved(-1, -1); - - // Returns the state to go to - obj.get_state = function() { - return next_state_fun(); - }; - - obj.get_rect = function() { - return spec.rect; - }; - - return obj; -}; diff --git a/game/old/dev/cache.manifest-old b/game/old/dev/cache.manifest-old deleted file mode 100644 index 1fbb9e6..0000000 --- a/game/old/dev/cache.manifest-old +++ /dev/null @@ -1,9 +0,0 @@ -CACHE MANIFEST -#v .012 -CACHE: -sounds/cell_infect.wav -sounds/cell_fire.wav -#sounds/heart_loop1.mp3 -php_functions.php -NETWORK: -* diff --git a/game/old/dev/cell.js b/game/old/dev/cell.js deleted file mode 100644 index 149fd6b..0000000 --- a/game/old/dev/cell.js +++ /dev/null @@ -1,308 +0,0 @@ -// *** cell *** -// --- inherits from game_object -// spec: -// game_object spec + -// String state = "alive" or "dead" or "infected" or "active" -// mutation : Mutation_obj so cell can get current mutation color - -var cell = function(p, spec) { - - // --- defaults --- - - // was 40 - spec.width = spec.width || 25; - spec.height = spec.height || 25; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "cell"; - }; - - // --- private variables --- - - // images - var cell_image = random_from( - image_manager.get_images("infectable_cell")).image; - var burst_anim = animated_image("burst", {}); - var infect_anim = animated_image("cell_infect", {}); - - // state can be "alive", "infected", "active", or "dead" - var state = spec.state || "alive"; - // random initial angle - var arrow_angle = p.random(-p.PI/2, p.PI/2); - // random dir (1 or -1) - var arrow_dir = p.random() >= 0.5 ? 1 : -1; - - // indicates whether has been hit by an arrow and is being targeted - //var is_targeted = false; - - // holds an antibody that is attached to the cell, or null - var anti = null; - - // --- public methods --- - - // implementing game_object interface - - // update is different depending on state - obj.update = function() { - obj.move(); - if (state === "alive") { - // just chill - } - else if (state === "infected") { - // still chill - } - else if (state === "active") { - // spin the arrow - rotateArrow(); - } - else if (state === "dying") { - if (burst_anim.is_finished()) { - obj.set_state("dead"); - } - } - /* - else if (state === "dead") { - } - */ - }; - - // draw makes a cell with a different color depending on state - // (circle for now) - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.get_mode()); - - p.noStroke(); - - if (state === "dying") { - // draw frame and advance anim - p.image(burst_anim.get_frame(), pos.x, pos.y, - obj.get_width(), obj.get_height()); - // skip the rest of the method - return; - } - - - if (state === "alive") { - p.fill(p.color(200, 50, 50)); - } - else { - if (state === "infected") { - p.fill(obj.get_color()); - // draw after drawing the image - } - else if (state === "active") { - drawArrow(); - - // Draw a separate circle for the red outline - // so that we can more accurately fill in the cell - // red outline for now - p.stroke(255, 0, 0); - p.strokeWeight(4); - p.ellipse(pos.x, pos.y, obj.get_width(), obj.get_height()); - - p.noStroke(); - p.fill(obj.get_color()); - } - //if (infect_anim.is_finished() || obj.is_illustration()) { - p.ellipse(pos.x, pos.y, obj.get_width() * 4/5, obj.get_height() * 4/5); - //} - } - - p.imageMode(obj.get_mode()); - p.image(cell_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - - if (state === "infected" || state === "active") { - // draw after the image - if (!infect_anim.is_finished() && !obj.is_illustration()) { - // draw frame and advance anim - p.image(infect_anim.get_frame(), pos.x, pos.y, - obj.get_width(), obj.get_height()); - //p.fill(obj.get_color()); - } - } - - /* - else if (state === "dead") { - p.fill(0); - p.ellipse(pos.x, pos.y, - obj.get_width(), obj.get_height()); - } - */ - - }; - - // to be used in illustration only - obj.set_image = function(i) { - cell_image = i; - }; - - obj.get_image = function() { - return cell_image; - }; - - obj.is_dead = function() { - //console.log(burst_anim.is_finished()); - return state === "dead"; - }; - - obj.stop_animation = function() { - burst_anim.pause(); - infect_anim.pause(); - }; - - obj.resume_animation = function() { - burst_anim.start(); - infect_anim.start(); - }; - - obj.set_state = function(s) { - if (s === "infected") { - infect_anim.start(); - } - state = s; - }; - - obj.set_antibody = function(a) { - anti = a; - anti.attach(obj); - }; - - obj.has_antibody = function() { - return (anti !== null); - }; - - obj.get_state = function() { - return state; - }; - - obj.die = function() { - if (anti) { - anti.die(); - } - obj.set_state("dying"); - burst_anim.start(); - }; - - // explodes this cell if it is active - obj.fire = function() { - if (state === "active") { - // Make sounds - sounds.play_sound("cell_fire"); - - // TODO: need a slower death - obj.die(); - - var pos = obj.get_pos(); - var ang = arrow_angle; - // use width cuz it's a circle - var r = obj.get_width()/2; - - // gen particles at edge of cell for now - var x = r*p.cos(ang) + pos.x; - var y = r*p.sin(ang) + pos.y; - - var num_particles = get_num_particles(); - // angle between all the shots - var range = p.PI/6; - var incr = range/num_particles; - - var particles = []; - - ang = arrow_angle - range/2; - // special case - if (num_particles === 1) { - ang = arrow_angle; - } - while (num_particles > 0) { - var new_vel = new p.PVector(p.cos(ang), p.sin(ang)); - // mult by speed scalar - new_vel.mult(7); - // if we want to add velocity of cell - new_vel.add(obj.get_vel()); - - particles.push(particle(p, { - pos: new p.PVector(x, y), - vel: new_vel, - mutation_info: obj.get_mutation_info() - })); - - num_particles--; - ang += incr; - } - - return particles; - } - throw "Can't fire on "+state+" cell!"; - }; - - // override for circular object - obj.calc_radius = function() { - return obj.get_width()/2; - }; - obj.set_radius(obj.calc_radius()); - - // --- private functions --- - - // rotates according to arrow_dir - // switches direction at certain angles - var rotateArrow = function() { - if (arrow_angle > p.PI/2 - || arrow_angle < -p.PI/2) { - arrow_dir = (2-arrow_dir)-2; - } - arrow_angle += p.radians(5+obj.get_level()/2)*arrow_dir; - }; - - var drawArrow = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - - // move to center of circle - p.translate(pos.x, pos.y); - // rotate first - p.rotate(arrow_angle); - // move out to right edge of circle - p.translate(w/2, 0); - - // red outline for now - p.stroke(255, 0, 0); - p.strokeWeight(2); - p.fill(obj.get_color()); - - var x1 = w/2; - // draw facing out to right - p.beginShape(); - p.vertex(0, -5); - p.vertex(x1, -5); - p.vertex(x1, -10); - p.vertex(x1+15, 0); - p.vertex(x1, 10); - p.vertex(x1, 5); - p.vertex(0, 5); - p.endShape(); - - p.popMatrix(); - }; - - var get_num_particles = function() { - - var extra_particles = 0; - var mut_info = obj.get_mutation_info(); - /* - for_each(mut_info.abilities, function(a) { - if (a === "extra_particle") { - extra_particles++; - } - }); - */ - return mut_info.particles + extra_particles; - }; - - return obj; -}; diff --git a/game/old/dev/credits_state.js b/game/old/dev/credits_state.js deleted file mode 100644 index 9d79008..0000000 --- a/game/old/dev/credits_state.js +++ /dev/null @@ -1,59 +0,0 @@ -var credits_state = function(p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var credits_back = image_manager.get_image("creditsscreen.png"); - - // Buttons - - var back_button = button(p, { - state : function() { return prev_state; }, - rect : { - pos : new p.PVector(p.width * (3/4), 500), - width: 120, - height: 50, - image: "back.png", - } - }); - - - //Not ordered - var all_buttons = [ back_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "credits"; - }; - - obj.update = function() { - //do nothing - }; - - obj.render = function() { - // fill the background - p.noStroke(); - p.fill(g.background_color); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.imageMode(p.CENTER); - p.image(credits_back, p.width/2, p.height/2); - }; - - obj.key_pressed = function(k) { - if (p.keyCode === 13 || p.keyCode === 27) { // enter, esc - obj.exit_state(); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/game/old/dev/date.format.js b/game/old/dev/date.format.js deleted file mode 100644 index 3992c50..0000000 --- a/game/old/dev/date.format.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Date Format 1.2.3 - * (c) 2007-2009 Steven Levithan - * MIT license - * - * Includes enhancements by Scott Trenda - * and Kris Kowal - * - * Accepts a date, a mask, or a date and a mask. - * Returns a formatted version of the given date. - * The date defaults to the current date/time. - * The mask defaults to dateFormat.masks.default. - */ - -var dateFormat = function () { - var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, - timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, - timezoneClip = /[^-+\dA-Z]/g, - pad = function (val, len) { - val = String(val); - len = len || 2; - while (val.length < len) val = "0" + val; - return val; - }; - - // Regexes and supporting functions are cached through closure - return function (date, mask, utc) { - var dF = dateFormat; - - // You can't provide utc if you skip other args (use the "UTC:" mask prefix) - if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { - mask = date; - date = undefined; - } - - // Passing date through Date applies Date.parse, if necessary - date = date ? new Date(date) : new Date; - if (isNaN(date)) throw SyntaxError("invalid date"); - - mask = String(dF.masks[mask] || mask || dF.masks["default"]); - - // Allow setting the utc argument via the mask - if (mask.slice(0, 4) == "UTC:") { - mask = mask.slice(4); - utc = true; - } - - var _ = utc ? "getUTC" : "get", - d = date[_ + "Date"](), - D = date[_ + "Day"](), - m = date[_ + "Month"](), - y = date[_ + "FullYear"](), - H = date[_ + "Hours"](), - M = date[_ + "Minutes"](), - s = date[_ + "Seconds"](), - L = date[_ + "Milliseconds"](), - o = utc ? 0 : date.getTimezoneOffset(), - flags = { - d: d, - dd: pad(d), - ddd: dF.i18n.dayNames[D], - dddd: dF.i18n.dayNames[D + 7], - m: m + 1, - mm: pad(m + 1), - mmm: dF.i18n.monthNames[m], - mmmm: dF.i18n.monthNames[m + 12], - yy: String(y).slice(2), - yyyy: y, - h: H % 12 || 12, - hh: pad(H % 12 || 12), - H: H, - HH: pad(H), - M: M, - MM: pad(M), - s: s, - ss: pad(s), - l: pad(L, 3), - L: pad(L > 99 ? Math.round(L / 10) : L), - t: H < 12 ? "a" : "p", - tt: H < 12 ? "am" : "pm", - T: H < 12 ? "A" : "P", - TT: H < 12 ? "AM" : "PM", - Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""), - o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), - S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10] - }; - - return mask.replace(token, function ($0) { - return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); - }); - }; -}(); - -// Some common format strings -dateFormat.masks = { - "default": "ddd mmm dd yyyy HH:MM:ss", - shortDate: "m/d/yy", - mediumDate: "mmm d, yyyy", - longDate: "mmmm d, yyyy", - fullDate: "dddd, mmmm d, yyyy", - shortTime: "h:MM TT", - mediumTime: "h:MM:ss TT", - longTime: "h:MM:ss TT Z", - isoDate: "yyyy-mm-dd", - isoTime: "HH:MM:ss", - isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", - isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" -}; - -// Internationalization strings -dateFormat.i18n = { - dayNames: [ - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" - ], - monthNames: [ - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", - "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" - ] -}; - -// For convenience... -Date.prototype.format = function (mask, utc) { - return dateFormat(this, mask, utc); -}; - diff --git a/game/old/empty_cell.js b/game/old/empty_cell.js deleted file mode 100644 index 76e58c9..0000000 --- a/game/old/empty_cell.js +++ /dev/null @@ -1,91 +0,0 @@ -// *** empty_cell *** -// --- inherits from cell -// spec: -// cell spec - -var empty_cell = function(p, spec) { - - // --- defaults --- - // inherited from cell - - // obj to return - var obj = cell(p, spec); - - obj.get_type = function() { - return "empty_cell"; - }; - - // --- private variables --- - - // state can be "alive", "infected", or "dead" - //var state = spec.state || "alive"; - - //var empty_image = p.loadImage("images/noninfectable1.png"); - /* - var images = random_image_selector(); - var empty_image = null; - if (on_server) { // so itwill work locally - for_each(g_empty_cell_images, function(i){ - images.add(p.loadImage(i)); - }); - empty_image = images.get_image(); - } - else { - empty_image = p.loadImage("images/new/noninfectable.png"); - } - */ - var empty_image = random_from( - image_manager.get_images("empty_cell")).image; - - // --- public methods --- - - // implementing game_object interface - - // update is different depending on state - obj.update = function() { - obj.move(); - if (obj.get_state() === "alive") { - // just chill - } - else if (obj.get_state() === "infected") { - // prepare to die - } - else if (obj.get_state() === "dead") { - // explode!! - } - }; - - // draw makes a cell with a different color depending on state - // just an outline for empty cell - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.mode); - - p.strokeWeight(2); - p.stroke(0); - p.noFill(); - - if (obj.get_state() === "alive") { - p.stroke(0); - } - else if (obj.get_state() === "infected") { - p.stroke(150); - } - else if (obj.get_state() === "dead") { - p.fill(0); - } - - p.imageMode(obj.get_mode()); - p.image(empty_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - }; - - obj.is_dead = function() { - return obj.get_state() === "dead"; - }; - - obj.die = function() { - obj.set_state("dead") = "dead"; - }; - - return obj; -} diff --git a/game/old/facebook.php b/game/old/facebook.php deleted file mode 100644 index 6d4fa72..0000000 --- a/game/old/facebook.php +++ /dev/null @@ -1,1845 +0,0 @@ - - - - - - - - - - - - src/facebook.php at master from facebook's php-sdk - GitHub - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        -
        - - - -
        -

        Your current locale selection: English. Choose another?

        - - - - - - - - - - - - -
        - -
        -
        -
        - - - - - - - - - - - - - - - - diff --git a/game/old/fb/README b/game/old/fb/README deleted file mode 100644 index e69de29..0000000 diff --git a/game/old/fb/all.js b/game/old/fb/all.js deleted file mode 100644 index 7050da9..0000000 --- a/game/old/fb/all.js +++ /dev/null @@ -1,70 +0,0 @@ -/*1295489895,169565300,JIT Construction: v334085,en_US*/ - -if(!window.FB)window.FB={_apiKey:null,_session:null,_userStatus:'unknown',_logging:true,_inCanvas:((window.location.search.indexOf('fb_sig_in_iframe=1')>-1)||(window.location.search.indexOf('session=')>-1)||(window.location.search.indexOf('signed_request=')>-1)),_https:(window.name.indexOf('_fb_https')>-1),_domain:{api:'https://api.facebook.com/',api_read:'https://api-read.facebook.com/',cdn:'http://static.ak.fbcdn.net/',https_cdn:'https://s-static.ak.fbcdn.net/',graph:'https://graph.facebook.com/',staticfb:'http://static.ak.facebook.com/',https_staticfb:'https://s-static.ak.facebook.com/',www:window.location.protocol+'//www.facebook.com/',https_www:'https://www.facebook.com/'},_locale:null,_localeIsRtl:false,getDomain:function(a){switch(a){case 'api':return FB._domain.api;case 'api_read':return FB._domain.api_read;case 'cdn':return (window.location.protocol=='https:'||FB._https)?FB._domain.https_cdn:FB._domain.cdn;case 'graph':return FB._domain.graph;case 'staticfb':return FB._https?FB._domain.https_staticfb:FB._domain.staticfb;case 'https_staticfb':return FB._domain.https_staticfb;case 'www':return FB._https?FB._domain.https_www:FB._domain.www;case 'https_www':return FB._domain.https_www;}},copy:function(d,c,b,e){for(var a in c)if(b||typeof d[a]==='undefined')d[a]=e?e(c[a]):c[a];return d;},create:function(c,h){var e=window.FB,d=c?c.split('.'):[],a=d.length;for(var b=0;b');e.root.innerHTML='';f=true;window.setTimeout(function(){e.root.innerHTML=b;},0);}else{var c=document.createElement('iframe');c.id=e.id;c.name=e.name;c.onload=FB.Content._callbacks[a];c.scrolling='no';c.style.border='none';c.style.overflow='hidden';if(e.title)c.title=e.title;if(e.className)c.className=e.className;if(e.height)c.style.height=e.height+'px';if(e.width)c.style.width=e.width+'px';e.root.appendChild(c);f=true;c.src=e.url;}},postTarget:function(b){var a=document.createElement('form');a.action=b.url;a.target=b.target;a.method='POST';FB.Content.appendHidden(a);FB.Array.forEach(b.params,function(e,d){if(e!==null&&e!==undefined){var c=document.createElement('input');c.name=d;c.value=e;a.appendChild(c);}});a.submit();a.parentNode.removeChild(a);}}); -FB.provide('Flash',{_minVersions:[[9,0,159,0],[10,0,22,87]],_swfPath:'swf/XdComm.swf',_callbacks:[],init:function(){if(FB.Flash._init)return;FB.Flash._init=true;window.FB_OnFlashXdCommReady=function(){FB.Flash._ready=true;for(var d=0,e=FB.Flash._callbacks.length;d'+''+''+'');FB.Content.appendHidden(b);},hasMinVersion:function(){if(typeof FB.Flash._hasMinVersion==='undefined'){var i,a,b,h=[];try{i=new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');}catch(j){if(navigator.mimeTypes.length>0){var mimeType='application/x-shockwave-flash';if(navigator.mimeTypes[mimeType].enabledPlugin){var name='Shockwave Flash';i=(navigator.plugins[name+' 2.0']||navigator.plugins[name]).description;}}}if(i){var f=i.replace(/\D+/g,',').match(/^,?(.+),?$/)[1].split(',');for(a=0,b=f.length;ag[c])break majorVersion;}};}return FB.Flash._hasMinVersion;},onReady:function(a){FB.Flash.init();if(FB.Flash._ready){window.setTimeout(a,0);}else FB.Flash._callbacks.push(a);}}); -if(!this.JSON)this.JSON={};(function(){function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function')value=value.toJSON(key);if(typeof rep==='function')value=rep.call(holder,key,value);switch(typeof value){case 'string':return quote(value);case 'number':return isFinite(value)?String(value):'null';case 'boolean':case 'null':return String(value);case 'object':if(!value)return 'null';gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i-1?'&':'?')+FB.QS.encode(e));if(h.length>2000)throw new Error('JSONP only support a maximum of 2000 bytes of input.');FB.ApiServer._callbacks[c]=function(i){a&&a(i);delete FB.ApiServer._callbacks[c];g.parentNode.removeChild(g);};g.src=h;document.getElementsByTagName('head')[0].appendChild(g);},flash:function(b,e,c,d,a){if(!window.FB_OnXdHttpResult)window.FB_OnXdHttpResult=function(g,f){FB.ApiServer._callbacks[g](decodeURIComponent(f));};FB.Flash.onReady(function(){var h=FB.getDomain(b)+e,f=FB.QS.encode(d);if(c==='get'){if(h.length+f.length>2000){if(b==='graph')d.method='get';c='post';f=FB.QS.encode(d);}else{h+=(h.indexOf('?')>-1?'&':'?')+f;f='';}}else if(c!=='post'){if(b==='graph')d.method=c;c='post';f=FB.QS.encode(d);}var g=document.XdComm.sendXdHttpRequest(c.toUpperCase(),h,f,null);FB.ApiServer._callbacks[g]=function(i){a&&a(FB.JSON.parse(i));delete FB.ApiServer._callbacks[g];};});}}); -FB.provide('EventProvider',{subscribers:function(){if(!this._subscribersMap)this._subscribersMap={};return this._subscribersMap;},subscribe:function(b,a){var c=this.subscribers();if(!c[b]){c[b]=[a];}else c[b].push(a);},unsubscribe:function(b,a){var c=this.subscribers()[b];FB.Array.forEach(c,function(e,d){if(e==a)c[d]=null;});},monitor:function(d,a){if(!a()){var b=this,c=function(){if(a.apply(a,arguments))b.unsubscribe(d,c);};this.subscribe(d,c);}},clear:function(a){delete this.subscribers()[a];},fire:function(){var a=Array.prototype.slice.call(arguments),b=a.shift();FB.Array.forEach(this.subscribers()[b],function(c){if(c)c.apply(this,a);});}});FB.provide('Event',FB.EventProvider); -FB.provide('Intl',{_punctCharClass:('['+'.!?'+'\u3002'+'\uFF01'+'\uFF1F'+'\u0964'+'\u2026'+'\u0EAF'+'\u1801'+'\u0E2F'+'\uFF0E'+']'),_endsInPunct:function(a){if(typeof a!='string')return false;return a.match(new RegExp(FB.Intl._punctCharClass+'['+')"'+"'"+'\u00BB'+'\u0F3B'+'\u0F3D'+'\u2019'+'\u201D'+'\u203A'+'\u3009'+'\u300B'+'\u300D'+'\u300F'+'\u3011'+'\u3015'+'\u3017'+'\u3019'+'\u301B'+'\u301E'+'\u301F'+'\uFD3F'+'\uFF07'+'\uFF09'+'\uFF3D'+'\s'+']*$'));},_tx:function(d,a){if(a!==undefined)if(typeof a!='object'){FB.log('The second arg to FB.Intl._tx() must be an Object for '+'tx('+d+', ...)');}else{var c;for(var b in a)if(a.hasOwnProperty(b)){if(FB.Intl._endsInPunct(a[b])){c=new RegExp('\{'+b+'\}'+FB.Intl._punctCharClass+'*','g');}else c=new RegExp('\{'+b+'\}','g');d=d.replace(c,a[b]);}}return d;},tx:function(b,a){function c(e,d){void(0);}if(!FB.Intl._stringTable)return null;return FBIntern.Intl._tx(FB.Intl._stringTable[b],a);}}); -FB.provide('String',{trim:function(a){return a.replace(/^\s*|\s*$/g,'');},format:function(a){if(!FB.String.format._formatRE)FB.String.format._formatRE=/(\{[^\}^\{]+\})/g;var b=arguments;return a.replace(FB.String.format._formatRE,function(e,d){var c=parseInt(d.substr(1),10),f=b[c+1];if(f===null||f===undefined)return '';return f.toString();});},escapeHTML:function(b){var a=document.createElement('div');a.appendChild(document.createTextNode(b));return a.innerHTML.replace(/"/g,'"').replace(/'/g,''');},quote:function(c){var a=/["\\\x00-\x1f\x7f-\x9f]/g,b={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};return a.test(c)?'"'+c.replace(a,function(d){var e=b[d];if(e)return e;e=d.charCodeAt();return '\\u00'+Math.floor(e/16).toString(16)+(e%16).toString(16);})+'"':'"'+c+'"';}}); -FB.provide('Dom',{containsCss:function(c,a){var b=' '+c.className+' ';return b.indexOf(' '+a+' ')>=0;},addCss:function(b,a){if(!FB.Dom.containsCss(b,a))b.className=b.className+' '+a;},removeCss:function(b,a){if(FB.Dom.containsCss(b,a)){b.className=b.className.replace(a,'');FB.Dom.removeCss(b,a);}},getStyle:function(a,c){var d=false,b=a.style;if(a.currentStyle){FB.Array.forEach(c.match(/\-([a-z])/g),function(e){c=c.replace(e,e.substr(1,1).toUpperCase());});d=a.currentStyle[c];}else{FB.Array.forEach(c.match(/[A-Z]/g),function(e){c=c.replace(e,'-'+e.toLowerCase());});if(window.getComputedStyle){d=document.defaultView.getComputedStyle(a,null).getPropertyValue(c);if(c=='background-position-y'||c=='background-position-x')if(d=='top'||d=='left')d='0px';}}if(c=='opacity'){if(a.filters&&a.filters.alpha)return d;return d*100;}return d;},setStyle:function(a,c,d){var b=a.style;if(c=='opacity'){if(d>=100)d=99.999;if(d<0)d=0;b.opacity=d/100;b.MozOpacity=d/100;b.KhtmlOpacity=d/100;if(a.filters)if(a.filters.alpha==undefined){a.filter="alpha(opacity="+d+")";}else a.filters.alpha.opacity=d;}else b[c]=d;},addScript:function(b){var a=document.createElement('script');a.type="text/javascript";a.src=b;return document.getElementsByTagName('head')[0].appendChild(a);},addCssRules:function(e,c){if(!FB.Dom._cssRules)FB.Dom._cssRules={};var a=true;FB.Array.forEach(c,function(f){if(!(f in FB.Dom._cssRules)){a=false;FB.Dom._cssRules[f]=true;}});if(a)return;if(FB.Dom.getBrowserType()!='ie'){var d=document.createElement('style');d.type='text/css';d.textContent=e;document.getElementsByTagName('head')[0].appendChild(d);}else try{document.createStyleSheet().cssText=e;}catch(b){if(document.styleSheets[0])document.styleSheets[0].cssText+=e;}},getBrowserType:function(){if(!FB.Dom._browserType){var d=window.navigator.userAgent.toLowerCase(),b=['msie','firefox','safari','gecko'],c=['ie','mozilla','safari','mozilla'];for(var a=0;a=0){FB.Dom._browserType=c[a];break;}}return FB.Dom._browserType;},getViewportInfo:function(){var a=(document.documentElement&&document.compatMode=='CSS1Compat')?document.documentElement:document.body;return {scrollTop:a.scrollTop,scrollLeft:a.scrollLeft,width:self.innerWidth?self.innerWidth:a.clientWidth,height:self.innerHeight?self.innerHeight:a.clientHeight};},ready:function(a){if(FB.Dom._isReady){a();}else FB.Event.subscribe('dom.ready',a);}});(function(){function domReady(){FB.Dom._isReady=true;FB.Event.fire('dom.ready');FB.Event.clear('dom.ready');}if(FB.Dom._isReady||document.readyState=='complete')return domReady();if(document.addEventListener){document.addEventListener('DOMContentLoaded',domReady,false);}else if(document.attachEvent)document.attachEvent('onreadystatechange',domReady);if(FB.Dom.getBrowserType()=='ie'&&window===top)(function(){try{document.documentElement.doScroll('left');}catch(error){setTimeout(arguments.callee,0);return;}domReady();})();var oldonload=window.onload;window.onload=function(){domReady();if(oldonload)if(typeof oldonload=='string'){eval(oldonload);}else oldonload();};})(); -FB.provide('Dialog',{_loaderEl:null,_stack:[],_active:null,_findRoot:function(a){while(a){if(FB.Dom.containsCss(a,'fb_dialog'))return a;a=a.parentNode;}},_showLoader:function(a,c){if(!FB.Dialog._loaderEl){c=parseInt(c,10);c=c?c:460;FB.Dialog._loaderEl=FB.Dialog._findRoot(FB.Dialog.create({content:('
        '+' '+'
        '+'
        '+' Facebook'+'
        '+'
        '+'
        '+''),width:c}));}if(!a)a=function(){};var b=FB.$('fb_dialog_loader_close');FB.Dom.removeCss(b,'fb_hidden');b.onclick=function(){FB.Dialog._hideLoader();a();};FB.Dialog._makeActive(FB.Dialog._loaderEl);},_hideLoader:function(){if(FB.Dialog._loaderEl&&FB.Dialog._loaderEl==FB.Dialog._active)FB.Dialog._loaderEl.style.top='-10000px';},_makeActive:function(b){FB.Dialog._lowerActive();var a={width:parseInt(b.offsetWidth,10),height:parseInt(b.offsetHeight,10)},e=FB.Dom.getViewportInfo(),c=(e.scrollLeft+(e.width-a.width)/2),d=(e.scrollTop+(e.height-a.height)/2.5);b.style.left=(c>0?c:0)+'px';b.style.top=(d>0?d:0)+'px';FB.Dialog._active=b;},_lowerActive:function(){if(!FB.Dialog._active)return;FB.Dialog._active.style.top='-10000px';FB.Dialog._active=null;},_removeStacked:function(a){FB.Dialog._stack=FB.Array.filter(FB.Dialog._stack,function(b){return b!=a;});},create:function(e){e=e||{};if(e.loader)FB.Dialog._showLoader(e.onClose,e.loaderWidth);var d=document.createElement('div'),c=document.createElement('div'),a='fb_dialog';if(e.closeIcon&&e.onClose){var b=document.createElement('a');b.className='fb_dialog_close_icon';b.onclick=e.onClose;d.appendChild(b);}if(FB.Dom.getBrowserType()=='ie'){a+=' fb_dialog_legacy';FB.Array.forEach(['vert_left','vert_right','horiz_top','horiz_bottom','top_left','top_right','bottom_left','bottom_right'],function(g){var h=document.createElement('span');h.className='fb_dialog_'+g;d.appendChild(h);});}else a+=' fb_dialog_advanced';if(e.content)FB.Content.append(e.content,c);d.className=a;var f=parseInt(e.width,10);if(!isNaN(f))d.style.width=f+'px';c.className='fb_dialog_content';d.appendChild(c);FB.Content.append(d);if(e.visible)FB.Dialog.show(d);return c;},show:function(a){a=FB.Dialog._findRoot(a);if(a){FB.Dialog._removeStacked(a);FB.Dialog._hideLoader();FB.Dialog._makeActive(a);FB.Dialog._stack.push(a);}},remove:function(a){a=FB.Dialog._findRoot(a);if(a){var b=FB.Dialog._active==a;FB.Dialog._removeStacked(a);FB.Dialog._hideLoader();if(b)if(FB.Dialog._stack.length>0){FB.Dialog.show(FB.Dialog._stack.pop());}else FB.Dialog._lowerActive();window.setTimeout(function(){a.parentNode.removeChild(a);},3000);}}}); -FB.provide('XD',{_origin:null,_transport:null,_callbacks:{},_forever:{},init:function(a){if(FB.XD._origin)return;if(window.addEventListener&&!window.attachEvent&&window.postMessage){FB.XD._origin=(window.location.protocol+'//'+window.location.host+'/'+FB.guid());FB.XD.PostMessage.init();FB.XD._transport='postmessage';}else if(!a&&FB.Flash.hasMinVersion()){FB.XD._origin=(window.location.protocol+'//'+document.domain+'/'+FB.guid());FB.XD.Flash.init();FB.XD._transport='flash';}else{FB.XD._transport='fragment';FB.XD.Fragment._channelUrl=a||window.location.toString();}},resolveRelation:function(b){var g,d,f=b.split('.'),e=window;for(var a=0,c=f.length;a0)return 'javascript:false;//';var f=FB.getDomain('cdn')+'connect/xd_proxy.php#',c=FB.guid();if(FB.XD._transport=='fragment'){f=FB.XD.Fragment._channelUrl;var d=f.indexOf('#');if(d>0)f=f.substr(0,d);f+=((f.indexOf('?')<0?'?':'&')+FB.XD.Fragment._magic+'#?=&');}if(b)FB.XD._forever[c]=true;FB.XD._callbacks[c]=a;return f+FB.QS.encode({cb:c,origin:FB.XD._origin,relation:e||'opener',transport:FB.XD._transport});},recv:function(b){if(typeof b=='string')b=FB.QS.decode(b);var a=FB.XD._callbacks[b.cb];if(!FB.XD._forever[b.cb])delete FB.XD._callbacks[b.cb];a&&a(b);},PostMessage:{init:function(){var a=FB.XD.PostMessage.onMessage;window.addEventListener?window.addEventListener('message',a,false):window.attachEvent('onmessage',a);},onMessage:function(event){FB.XD.recv(event.data);}},Flash:{init:function(){FB.Flash.onReady(function(){document.XdComm.postMessage_init('FB.XD.Flash.onMessage',FB.XD._origin);});},onMessage:function(a){FB.XD.recv(decodeURIComponent(a));}},Fragment:{_magic:'fb_xd_fragment',checkAndDispatch:function(){var b=window.location.toString(),a=b.substr(b.indexOf('#')+1),c=b.indexOf(FB.XD.Fragment._magic);if(c>0){FB.init=FB.getLoginStatus=FB.api=function(){};document.documentElement.style.display='none';FB.XD.resolveRelation(FB.QS.decode(a).relation).FB.XD.recv(a);}}}});FB.XD.Fragment.checkAndDispatch(); -FB.provide('Arbiter',{inform:function(c,e,f,b){if(window.name.indexOf('app_runner_')===0){var d=FB.JSON.stringify({method:c,params:e});if(window.postMessage){FB.XD.resolveRelation(f||'parent').postMessage(d,'*');return;}else try{window.opener.postMessage(d);return;}catch(a){}}var h=(FB.getDomain((b?'https_':'')+'staticfb')+'connect/canvas_proxy.php#'+FB.QS.encode({method:c,params:FB.JSON.stringify(e||{}),relation:f}));var g=FB.Content.appendHidden('');FB.Content.insertIframe({url:h,root:g,width:1,height:1,onload:function(){setTimeout(function(){g.parentNode.removeChild(g);},10);}});}}); -FB.provide('',{ui:function(e,b){if(!e.method){FB.log('"method" is a required parameter for FB.ui().');return;}var a=FB.UIServer.prepareCall(e,b);if(!a)return;var d=a.params.display;if(d=='dialog')d='iframe';var c=FB.UIServer[d];if(!c){FB.log('"display" must be one of "popup", "iframe" or "hidden".');return;}c(a);}});FB.provide('UIServer',{Methods:{},_active:{},_defaultCb:{},_resultToken:'"xxRESULTTOKENxx"',genericTransform:function(a){if(a.params.display=='dialog'||a.params.display=='iframe'){a.params.display='iframe';a.params.channel=FB.UIServer._xdChannelHandler(a.id,'parent.parent');}return a;},prepareCall:function(h,b){var g=h.method.toLowerCase(),f=FB.UIServer.Methods[g]||{size:{width:575,height:240}},e=FB.guid(),d=FB._https||(g!=='auth.status');FB.copy(h,{api_key:FB._apiKey,app_id:FB._apiKey,locale:FB._locale,sdk:'joey',access_token:d&&FB._session&&FB._session.access_token||undefined});h.display=FB.UIServer.getDisplayMode(f,h);if(!f.url){f.url='dialog/'+g;delete h.method;}var a={cb:b,id:e,size:f.size||{},url:FB.getDomain(d?'https_www':'www')+f.url,params:h};var j=f.transform?f.transform:FB.UIServer.genericTransform;if(j){a=j(a);if(!a)return;}var i=FB.UIServer.getXdRelation(a.params.display);if(!(a.id in FB.UIServer._defaultCb)&&!('next' in a.params))a.params.next=FB.UIServer._xdResult(a.cb,a.id,i,true);if(i==='parent')a.params.channel_url=FB.UIServer._xdChannelHandler(e,'parent.parent');a.params=FB.JSON.flatten(a.params);var c=FB.QS.encode(a.params);if((a.url+c).length>2000){a.post=true;}else if(c)a.url+='?'+c;return a;},getDisplayMode:function(a,b){if(b.display==='hidden')return 'hidden';if(window.name.indexOf('app_runner_')===0)return 'async';if(!FB._session&&b.display=='dialog'&&!a.loggedOutIframe){FB.log('"dialog" mode can only be used when the user is connected.');return 'popup';}return b.display||(FB._session?'dialog':'popup');},getXdRelation:function(a){if(a==='popup')return 'opener';if(a==='dialog'||a==='iframe')return 'parent';if(a==='async')return 'parent.frames['+window.name+']';},popup:function(b){var a=typeof window.screenX!='undefined'?window.screenX:window.screenLeft,i=typeof window.screenY!='undefined'?window.screenY:window.screenTop,g=typeof window.outerWidth!='undefined'?window.outerWidth:document.documentElement.clientWidth,f=typeof window.outerHeight!='undefined'?window.outerHeight:(document.documentElement.clientHeight-22),k=b.size.width,d=b.size.height,h=(a<0)?window.screen.width+a:a,e=parseInt(h+((g-k)/2),10),j=parseInt(i+((f-d)/2.5),10),c=('width='+k+',height='+d+',left='+e+',top='+j+',scrollbars=1');if(b.params.method=='permissions.request')c+=',location=1,toolbar=0';if(b.post){FB.UIServer._active[b.id]=window.open('about:blank',b.id,c);FB.Content.postTarget({url:b.url,target:b.id,params:b.params});}else FB.UIServer._active[b.id]=window.open(b.url,b.id,c);if(b.id in FB.UIServer._defaultCb)FB.UIServer._popupMonitor();},hidden:function(a){a.className='FB_UI_Hidden';a.root=FB.Content.appendHidden('');FB.UIServer._insertIframe(a);},iframe:function(a){a.className='FB_UI_Dialog';a.root=FB.Dialog.create({onClose:function(){FB.UIServer._triggerDefault(a.id);},loader:true,loaderWidth:a.size.width,closeIcon:true});FB.Dom.addCss(a.root,'fb_dialog_iframe');FB.UIServer._insertIframe(a);},async:function(a){a.frame=window.name;delete a.url;delete a.size;FB.Arbiter.inform('showDialog',a);},_insertIframe:function(b){FB.UIServer._active[b.id]=false;var a=function(c){if(b.id in FB.UIServer._active)FB.UIServer._active[b.id]=c;};if(b.post){FB.Content.insertIframe({url:'about:blank',root:b.root,className:b.className,width:b.size.width,height:b.size.height,onload:function(c){a(c);FB.Content.postTarget({url:b.url,target:c.name,params:b.params});}});}else FB.Content.insertIframe({url:b.url,root:b.root,className:b.className,width:b.size.width,height:b.size.height,onload:a});},_triggerDefault:function(a){FB.UIServer._xdRecv({frame:a},FB.UIServer._defaultCb[a]||function(){});},_popupMonitor:function(){var a;for(var b in FB.UIServer._active)if(FB.UIServer._active.hasOwnProperty(b)&&b in FB.UIServer._defaultCb){var c=FB.UIServer._active[b];try{if(c.tagName)continue;}catch(d){}try{if(c.closed){FB.UIServer._triggerDefault(b);}else a=true;}catch(e){}}if(a&&!FB.UIServer._popupInterval){FB.UIServer._popupInterval=window.setInterval(FB.UIServer._popupMonitor,100);}else if(!a&&FB.UIServer._popupInterval){window.clearInterval(FB.UIServer._popupInterval);FB.UIServer._popupInterval=null;}},_xdChannelHandler:function(a,b){return FB.XD.handler(function(c){var d=FB.UIServer._active[a];if(!d)return;if(c.type=='resize'){if(c.height)d.style.height=c.height+'px';if(c.width)d.style.width=c.width+'px';FB.Arbiter.inform('resize.ack',{},'parent.frames['+d.name+']',true);FB.Dialog.show(d);}},b,true);},_xdNextHandler:function(a,b,d,c){if(c)FB.UIServer._defaultCb[b]=a;return FB.XD.handler(function(e){FB.UIServer._xdRecv(e,a);},d)+'&frame='+b;},_xdRecv:function(b,a){var c=FB.UIServer._active[b.frame];try{if(FB.Dom.containsCss(c,'FB_UI_Hidden')){window.setTimeout(function(){c.parentNode.parentNode.removeChild(c.parentNode);},3000);}else if(FB.Dom.containsCss(c,'FB_UI_Dialog'))FB.Dialog.remove(c);}catch(d){}try{if(c.close){c.close();FB.UIServer._popupCount--;}}catch(e){}delete FB.UIServer._active[b.frame];delete FB.UIServer._defaultCb[b.frame];a(b);},_xdResult:function(a,b,d,c){return (FB.UIServer._xdNextHandler(function(e){a&&a(e.result&&e.result!=FB.UIServer._resultToken&&FB.JSON.parse(e.result));},b,d,c)+'&result='+encodeURIComponent(FB.UIServer._resultToken));}}); -FB.provide('',{getLoginStatus:function(a,b){if(!FB._apiKey){FB.log('FB.getLoginStatus() called before calling FB.init().');return;}if(a)if(!b&&FB.Auth._loadState=='loaded'){a({status:FB._userStatus,session:FB._session});return;}else FB.Event.subscribe('FB.loginStatus',a);if(!b&&FB.Auth._loadState=='loading')return;FB.Auth._loadState='loading';var c=function(d){FB.Auth._loadState='loaded';FB.Event.fire('FB.loginStatus',d);FB.Event.clear('FB.loginStatus');};FB.ui({method:'auth.status',display:'hidden'},c);},getSession:function(){return FB._session;},login:function(a,b){FB.ui(FB.copy({method:'permissions.request',display:'popup'},b||{}),a);},logout:function(a){FB.ui({method:'auth.logout',display:'hidden'},a);}});FB.provide('Auth',{_callbacks:[],setSession:function(e,g){var b=!FB._session&&e,c=FB._session&&!e,a=FB._session&&e&&FB._session.uid!=e.uid,f=b||c||(FB._session&&e&&FB._session.access_token!=e.access_token),h=g!=FB._userStatus;var d={session:e,status:g};FB._session=e;FB._userStatus=g;if(f&&FB.Cookie&&FB.Cookie.getEnabled())FB.Cookie.set(e);if(h)FB.Event.fire('auth.statusChange',d);if(c||a)FB.Event.fire('auth.logout',d);if(b||a)FB.Event.fire('auth.login',d);if(f)FB.Event.fire('auth.sessionChange',d);if(FB.Auth._refreshTimer){window.clearTimeout(FB.Auth._refreshTimer);delete FB.Auth._refreshTimer;}if(FB.Auth._loadState&&e&&e.expires)FB.Auth._refreshTimer=window.setTimeout(function(){FB.getLoginStatus(null,true);},1200000);return d;},xdHandler:function(a,b,f,c,e,d){return FB.UIServer._xdNextHandler(FB.Auth.xdResponseWrapper(a,e,d),b,f,c);},xdResponseWrapper:function(a,c,b){return function(d){try{b=FB.JSON.parse(d.session);}catch(f){}if(b)c='connected';if(d.fb_https&&!FB._https)FB._https=true;var e=FB.Auth.setSession(b||null,c);e.perms=d&&d.perms||null;a&&a(e);};}});FB.provide('UIServer.Methods',{'permissions.request':{size:{width:627,height:326},transform:function(a){if(!FB._apiKey){FB.log('FB.login() called before calling FB.init().');return;}if(FB._session&&!a.params.perms){FB.log('FB.login() called when user is already connected.');a.cb&&a.cb({status:FB._userStatus,session:FB._session});return;}a=FB.UIServer.genericTransform(a);a.cb=FB.Auth.xdResponseWrapper(a.cb,FB._userStatus,FB._session);a.params.method='permissions.request';FB.copy(a.params,{fbconnect:FB._inCanvas?0:1,return_session:1,session_version:3});return a;}},'auth.logout':{url:'logout.php',transform:function(a){if(!FB._apiKey){FB.log('FB.logout() called before calling FB.init().');}else if(!FB._session){FB.log('FB.logout() called without a session.');}else{a.params.next=FB.Auth.xdHandler(a.cb,a.id,'parent',false,'unknown');return a;}}},'auth.status':{url:'extern/login_status.php',transform:function(a){var b=a.cb,c=a.id,d=FB.Auth.xdHandler;delete a.cb;FB.copy(a.params,{no_session:d(b,c,'parent',false,'notConnected'),no_user:d(b,c,'parent',false,'unknown'),ok_session:d(b,c,'parent',false,'connected'),session_version:3,extern:FB._inCanvas?0:2});return a;}}}); -FB.provide('Canvas',{_timer:null,_lastSize:{},setSize:function(b){if(typeof b!="object")b={};b=FB.copy(b||{},FB.Canvas._computeContentSize());b=FB.copy(b,{frame:window.name||'iframe_canvas'});if(FB.Canvas._lastSize[b.frame]){var a=FB.Canvas._lastSize[b.frame].height;if(FB.Canvas._lastSize[b.frame].width==b.width&&(b.height<=a&&(a-b.height<=16)))return false;}FB.Canvas._lastSize[b.frame]=b;FB.Arbiter.inform('setSize',b);return true;},setAutoResize:function(b,a){if(a===undefined&&typeof b=="number"){a=b;b=true;}if(b===undefined||b){if(FB.Canvas._timer===null)FB.Canvas._timer=window.setInterval(FB.Canvas.setSize,a||100);FB.Canvas.setSize();}else if(FB.Canvas._timer!==null){window.clearInterval(FB.Canvas._timer);FB.Canvas._timer=null;}},_computeContentSize:function(){var a=document.body,c=document.documentElement,d=0,b=Math.max(Math.max(a.offsetHeight,a.scrollHeight)+a.offsetTop,Math.max(c.offsetHeight,c.scrollHeight)+c.offsetTop);if(a.offsetWidthd)d=f;});if(c.clientLeft>0)d+=(c.clientLeft*2);if(c.clientTop>0)b+=(c.clientTop*2);return {height:b,width:d};}}); -FB.provide('UIServer.Methods',{'stream.share':{size:{width:575,height:380},url:'sharer.php',transform:function(a){if(!a.params.u)a.params.u=window.location.toString();return a;}},'fbml.dialog':{size:{width:575,height:300},url:'render_fbml.php',loggedOutIframe:true,transform:function(a){return a;}},'auth.logintofacebook':{size:{width:530,height:287},url:'login.php',transform:function(a){a.params.skip_api_login=1;var c=FB.UIServer.getXdRelation(a.params.display);var b=FB.UIServer._xdResult(a.cb,a.id,c,true);a.params.next=FB.getDomain(FB._https?'https_www':'www')+"login.php?"+FB.QS.encode({api_key:FB._apiKey,next:b,skip_api_login:1});return a;}}}); -FB.provide('',{share:function(a){FB.log('FB.share() has been deprecated. Please use FB.ui() instead.');FB.ui({display:'popup',method:'stream.share',u:a});},publish:function(b,a){FB.log('FB.publish() has been deprecated. Please use FB.ui() instead.');b=b||{};FB.ui(FB.copy({display:'popup',method:'stream.publish',preview:1},b||{}),a);},addFriend:function(b,a){FB.log('FB.addFriend() has been deprecated. Please use FB.ui() instead.');FB.ui({display:'popup',id:b,method:'friend.add'},a);}});FB.UIServer.Methods['auth.login']=FB.UIServer.Methods['permissions.request']; -FB.provide('XFBML',{_renderTimeout:30000,parse:function(c,a){c=c||document.body;var b=1,d=function(){b--;if(b===0){a&&a();FB.Event.fire('xfbml.render');}};FB.Array.forEach(FB.XFBML._tagInfos,function(f){if(!f.xmlns)f.xmlns='fb';var g=FB.XFBML._getDomElements(c,f.xmlns,f.localName);for(var e=0;e0)FB.log(b+' XFBML tags failed to render in '+FB.XFBML._renderTimeout+'ms.');},FB.XFBML._renderTimeout);d();},registerTag:function(a){FB.XFBML._tagInfos.push(a);},_processElement:function(dom,tagInfo,cb){var element=dom._element;if(element){element.subscribe('render',cb);element.process();}else{var processor=function(){var fn=eval(tagInfo.className);var getBoolAttr=function(attr){var attr=dom.getAttribute(attr);return (attr&&FB.Array.indexOf(['true','1','yes','on'],attr.toLowerCase())>-1);};var isLogin=false;var showFaces=true;var renderInIframe=false;if(tagInfo.className==='FB.XFBML.LoginButton'){renderInIframe=getBoolAttr('render-in-iframe');showFaces=getBoolAttr('show-faces')||getBoolAttr('show_faces');isLogin=renderInIframe||showFaces;if(isLogin)fn=FB.XFBML.Login;}element=dom._element=new fn(dom);if(isLogin){var extraParams={show_faces:showFaces};var perms=dom.getAttribute('perms');if(perms)extraParams.perms=perms;element.setExtraParams(extraParams);}element.subscribe('render',cb);element.process();};if(FB.CLASSES[tagInfo.className.substr(3)]){processor();}else FB.log('Tag '+tagInfo.className+' was not found.');}},_getDomElements:function(a,e,d){var c=e+':'+d;switch(FB.Dom.getBrowserType()){case 'mozilla':return a.getElementsByTagNameNS(document.body.namespaceURI,c);case 'ie':try{var docNamespaces=document.namespaces;if(docNamespaces&&docNamespaces[e]){var nodes=a.getElementsByTagName(d);if(!document.addEventListener||nodes.length>0)return nodes;}}catch(b){}return a.getElementsByTagName(c);default:return a.getElementsByTagName(c);}},_tagInfos:[{localName:'activity',className:'FB.XFBML.Activity'},{localName:'add-profile-tab',className:'FB.XFBML.AddProfileTab'},{localName:'bookmark',className:'FB.XFBML.Bookmark'},{localName:'comments',className:'FB.XFBML.Comments'},{localName:'connect-bar',className:'FB.XFBML.ConnectBar'},{localName:'fan',className:'FB.XFBML.Fan'},{localName:'like',className:'FB.XFBML.Like'},{localName:'like-box',className:'FB.XFBML.LikeBox'},{localName:'live-stream',className:'FB.XFBML.LiveStream'},{localName:'login',className:'FB.XFBML.Login'},{localName:'login-button',className:'FB.XFBML.LoginButton'},{localName:'facepile',className:'FB.XFBML.Facepile'},{localName:'friendpile',className:'FB.XFBML.Friendpile'},{localName:'name',className:'FB.XFBML.Name'},{localName:'profile-pic',className:'FB.XFBML.ProfilePic'},{localName:'recommendations',className:'FB.XFBML.Recommendations'},{localName:'registration',className:'FB.XFBML.Registration'},{localName:'send',className:'FB.XFBML.Send'},{localName:'serverfbml',className:'FB.XFBML.ServerFbml'},{localName:'share-button',className:'FB.XFBML.ShareButton'},{localName:'social-bar',className:'FB.XFBML.SocialBar'}]});(function(){try{if(document.namespaces&&!document.namespaces.item.fb)document.namespaces.add('fb');}catch(a){}}()); -FB.provide('XFBML',{set:function(b,c,a){FB.log('FB.XFBML.set() has been deprecated.');b.innerHTML=c;FB.XFBML.parse(b,a);}}); -FB.provide('',{bind:function(){var a=Array.prototype.slice.call(arguments),c=a.shift(),b=a.shift();return function(){return c.apply(b,a.concat(Array.prototype.slice.call(arguments)));};},Class:function(b,a,d){if(FB.CLASSES[b])return FB.CLASSES[b];var c=a||function(){};c.prototype=d;c.prototype.bind=function(e){return FB.bind(e,this);};c.prototype.constructor=c;FB.create(b,c);FB.CLASSES[b]=c;return c;},subclass:function(d,b,c,e){if(FB.CLASSES[d])return FB.CLASSES[d];var a=FB.create(b);FB.copy(e,a.prototype);e._base=a;e._callBase=function(g){var f=Array.prototype.slice.call(arguments,1);return a.prototype[g].apply(this,f);};return FB.Class(d,c?c:function(){if(a.apply)a.apply(this,arguments);},e);},CLASSES:{}});FB.provide('Type',{isType:function(a,b){while(a)if(a.constructor===b||a===b){return true;}else a=a._base;return false;}}); -FB.Class('Obj',null,FB.copy({setProperty:function(a,b){if(FB.JSON.stringify(b)!=FB.JSON.stringify(this[a])){this[a]=b;this.fire(a,b);}}},FB.EventProvider)); -FB.subclass('Waitable','Obj',function(){},{set:function(a){this.setProperty('value',a);},error:function(a){this.fire("error",a);},wait:function(a,b){if(b)this.subscribe('error',b);this.monitor('value',this.bind(function(){if(this.value!==undefined){a(this.value);return true;}}));}}); -FB.subclass('Data.Query','Waitable',function(){if(!FB.Data.Query._c)FB.Data.Query._c=1;this.name='v_'+FB.Data.Query._c++;},{parse:function(a){var b=FB.String.format.apply(null,a),d=(/^select (.*?) from (\w+)\s+where (.*)$/i).exec(b);this.fields=this._toFields(d[1]);this.table=d[2];this.where=this._parseWhere(d[3]);for(var c=1;c-1){return d;}else return b;});},isValid:function(){for(var a=this.dom;a;a=a.parentNode)if(a==document.body)return true;},clear:function(){this.dom.innerHTML='';}},FB.EventProvider)); -FB.subclass('XFBML.IframeWidget','XFBML.Element',null,{_showLoader:true,_refreshOnAuthChange:false,_allowReProcess:false,_fetchPreCachedLoader:false,_visibleAfter:'load',getUrlBits:function(){throw new Error('Inheriting class needs to implement getUrlBits().');},setupAndValidate:function(){return true;},oneTimeSetup:function(){},getSize:function(){},getIframeName:function(){},getIframeTitle:function(){},getChannelUrl:function(){if(!this._channelUrl){var a=this;this._channelUrl=FB.XD.handler(function(b){a.fire('xd.'+b.type,b);},'parent.parent',true);}return this._channelUrl;},getIframeNode:function(){return this.dom.getElementsByTagName('iframe')[0];},process:function(a){if(this._done){if(!this._allowReProcess&&!a)return;this.clear();}else this._oneTimeSetup();this._done=true;if(!this.setupAndValidate()){this.fire('render');return;}if(this._showLoader)this._addLoader();FB.Dom.addCss(this.dom,'fb_iframe_widget');if(this._visibleAfter!='immediate'){FB.Dom.addCss(this.dom,'fb_hide_iframes');}else this.subscribe('iframe.onload',FB.bind(this.fire,this,'render'));var c=this.getSize()||{};var d=this._getURL();if(!this._fetchPreCachedLoader)d+='?'+FB.QS.encode(this._getQS());if(d.length>2000){d='about:blank';var b=FB.bind(function(){this._postRequest();this.unsubscribe('iframe.onload',b);},this);this.subscribe('iframe.onload',b);}FB.Content.insertIframe({url:d,root:this.dom.appendChild(document.createElement('span')),name:this.getIframeName(),title:this.getIframeTitle(),className:FB._localeIsRtl?'fb_rtl':'fb_ltr',height:c.height,width:c.width,onload:FB.bind(this.fire,this,'iframe.onload')});},_oneTimeSetup:function(){this.subscribe('xd.resize',FB.bind(this._handleResizeMsg,this));if(FB.getLoginStatus){this.subscribe('xd.refreshLoginStatus',FB.bind(FB.getLoginStatus,FB,function(){},true));this.subscribe('xd.logout',FB.bind(FB.logout,FB,function(){}));}if(this._refreshOnAuthChange)this._setupAuthRefresh();if(this._visibleAfter=='load')this.subscribe('iframe.onload',FB.bind(this._makeVisible,this));this.oneTimeSetup();},_makeVisible:function(){this._removeLoader();FB.Dom.removeCss(this.dom,'fb_hide_iframes');this.fire('render');},_setupAuthRefresh:function(){FB.getLoginStatus(FB.bind(function(b){var a=b.status;FB.Event.subscribe('auth.statusChange',FB.bind(function(c){if(!this.isValid())return;if(a=='unknown'||c.status=='unknown')this.process(true);a=c.status;},this));},this));},_handleResizeMsg:function(b){if(!this.isValid())return;var a=this.getIframeNode();a.style.height=b.height+'px';if(b.width)a.style.width=b.width+'px';a.style.border='none';this._makeVisible();},_addLoader:function(){if(!this._loaderDiv){FB.Dom.addCss(this.dom,'fb_iframe_widget_loader');this._loaderDiv=document.createElement('div');this._loaderDiv.className='FB_Loader';this.dom.appendChild(this._loaderDiv);}},_removeLoader:function(){if(this._loaderDiv){FB.Dom.removeCss(this.dom,'fb_iframe_widget_loader');if(this._loaderDiv.parentNode)this._loaderDiv.parentNode.removeChild(this._loaderDiv);this._loaderDiv=null;}},_getQS:function(){return FB.copy({api_key:FB._apiKey,locale:FB._locale,sdk:'joey',session_key:FB._session&&FB._session.session_key,ref:this.getAttribute('ref')},this.getUrlBits().params);},_getURL:function(){var a='www',b='';if(this._fetchPreCachedLoader){a='cdn';b='static/';}return FB.getDomain(a)+'plugins/'+b+this.getUrlBits().name+'.php';},_postRequest:function(){FB.Content.postTarget({url:this._getURL(),target:this.getIframeNode().name,params:this._getQS()});}}); -FB.subclass('XFBML.Activity','XFBML.IframeWidget',null,{_visibleAfter:'load',_refreshOnAuthChange:true,setupAndValidate:function(){this._attr={border_color:this.getAttribute('border-color'),colorscheme:this.getAttribute('color-scheme'),filter:this.getAttribute('filter'),font:this.getAttribute('font'),header:this._getBoolAttribute('header'),height:this._getPxAttribute('height',300),recommendations:this._getBoolAttribute('recommendations'),site:this.getAttribute('site',location.hostname),width:this._getPxAttribute('width',300)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'activity',params:this._attr};}}); -FB.subclass('XFBML.ButtonElement','XFBML.Element',null,{_allowedSizes:['icon','small','medium','large','xlarge'],onClick:function(){throw new Error('Inheriting class needs to implement onClick().');},setupAndValidate:function(){return true;},getButtonMarkup:function(){return this.getOriginalHTML();},getOriginalHTML:function(){return this._originalHTML;},process:function(){if(!('_originalHTML' in this))this._originalHTML=FB.String.trim(this.dom.innerHTML);if(!this.setupAndValidate()){this.fire('render');return;}var d=this._getAttributeFromList('size','medium',this._allowedSizes),a='',b='';if(d=='icon'){a='fb_button_simple';}else{var c=FB._localeIsRtl?'_rtl':'';b=this.getButtonMarkup();a='fb_button'+c+' fb_button_'+d+c;}this.dom.innerHTML=(''+''+b+''+'');this.dom.firstChild.onclick=FB.bind(this.onClick,this);this.fire('render');}}); -FB.provide('Helper',{isUser:function(a){return a<2.2e+09||(a>=1e+14&&a<=100099999989999);},getLoggedInUser:function(){return FB._session?FB._session.uid:null;},upperCaseFirstChar:function(a){if(a.length>0){return a.substr(0,1).toUpperCase()+a.substr(1);}else return a;},getProfileLink:function(c,b,a){a=a||(c?FB.getDomain('www')+'profile.php?id='+c.uid:null);if(a)b=''+b+'';return b;},invokeHandler:function(handler,scope,args){if(handler)if(typeof handler==='string'){eval(handler);}else if(handler.apply)handler.apply(scope,args||[]);},fireEvent:function(a,b){var c=b._attr.href;b.fire(a,c);FB.Event.fire(a,c,b);},executeFunctionByName:function(d){var a=Array.prototype.slice.call(arguments,1);var f=d.split(".");var c=f.pop();var b=window;for(var e=0;e0){a.xid=encodeURIComponent(document.URL.substring(0,b));}else a.xid=encodeURIComponent(document.URL);}if(a.migrated&&!a.href)a.href='http://www.facebook.com/plugins/comments_v1.php?'+'app_id='+FB._apiKey+'&xid='+encodeURIComponent(a.xid)+'&url='+encodeURIComponent(a.url);this._attr=a;return true;},oneTimeSetup:function(){this.subscribe('xd.addComment',FB.bind(this._handleCommentMsg,this));},getSize:function(){return {width:this._attr.width,height:200};},getUrlBits:function(){return {name:'comments',params:this._attr};},_handleCommentMsg:function(a){if(!this.isValid())return;FB.Event.fire('comments.add',{post:a.post,user:a.user,widget:this});}}); -FB.provide('Anim',{ate:function(c,g,d,b){d=!isNaN(parseFloat(d))&&d>=0?d:750;var e=40,f={},j={},a=null,h=c.style,i=setInterval(FB.bind(function(){if(!a)a=new Date().getTime();var k=1;if(d!=0)k=Math.min((new Date().getTime()-a)/d,1);FB.Array.forEach(g,FB.bind(function(o,m){if(!f[m]){var n=FB.Dom.getStyle(c,m);if(n===false)return;f[m]=this._parseCSS(n+'');}if(!j[m])j[m]=this._parseCSS(o.toString());var l='';FB.Array.forEach(f[m],function(q,p){if(isNaN(j[m][p].numPart)&&j[m][p].textPart=='?'){l=q.numPart+q.textPart;}else if(isNaN(q.numPart)){l=q.textPart;}else l+=(q.numPart+Math.ceil((j[m][p].numPart-q.numPart)*Math.sin(Math.PI/2*k)))+j[m][p].textPart+' ';});FB.Dom.setStyle(c,m,l);},this));if(k==1){clearInterval(i);if(b)b(c);}},this),e);},_parseCSS:function(a){var b=[];FB.Array.forEach(a.split(' '),function(d){var c=parseInt(d,10);b.push({numPart:c,textPart:d.replace(c,'')});});return b;}}); -FB.provide('Insights',{impression:function(e,a){var b=FB.guid(),g="//ah8.facebook.com/impression.php/"+b+"/",c=new Image(1,1),f=[];if(!e.api_key&&FB._apiKey)e.api_key=FB._apiKey;for(var d in e)f.push(encodeURIComponent(d)+'='+encodeURIComponent(e[d]));g+='?'+f.join('&');if(a)c.onload=a;c.src=g;}}); -FB.subclass('XFBML.ConnectBar','XFBML.Element',null,{_initialHeight:null,_initTopMargin:0,_picFieldName:'pic_square',_page:null,_displayed:false,_notDisplayed:false,_container:null,_animationSpeed:0,process:function(){FB.getLoginStatus(this.bind(function(a){FB.Event.monitor('auth.statusChange',this.bind(function(){if(this.isValid()&&FB._userStatus=='connected'){this._uid=FB.Helper.getLoggedInUser();FB.api({method:'Connect.shouldShowConnectBar'},this.bind(function(b){if(b!=2){this._animationSpeed=(b==0)?750:0;this._showBar();}else this._noRender();}));}else this._noRender();return false;}));}));},_showBar:function(){var a=FB.Data._selectByIndex(['first_name','profile_url',this._picFieldName],'user','uid',this._uid);var b=FB.Data._selectByIndex(['display_name'],'application','api_key',FB._apiKey);FB.Data.waitOn([a,b],FB.bind(function(c){c[0][0].site_name=c[1][0].display_name;if(!this._displayed){this._displayed=true;this._notDisplayed=false;this._renderConnectBar(c[0][0]);this.fire('render');FB.Insights.impression({lid:104,name:'widget_load'});this.fire('connectbar.ondisplay');FB.Event.fire('connectbar.ondisplay',this);FB.Helper.invokeHandler(this.getAttribute('on-display'),this);}},this));},_noRender:function(){if(this._displayed){this._displayed=false;this._closeConnectBar();}if(!this._notDisplayed){this._notDisplayed=true;this.fire('render');this.fire('connectbar.onnotdisplay');FB.Event.fire('connectbar.onnotdisplay',this);FB.Helper.invokeHandler(this.getAttribute('on-not-display'),this);}},_renderConnectBar:function(d){var b=document.createElement('div'),c=document.createElement('div');b.className='fb_connect_bar';c.className='fb_reset fb_connect_bar_container';c.appendChild(b);document.body.appendChild(c);this._container=c;this._initialHeight=Math.round(parseFloat(FB.Dom.getStyle(c,'height'))+parseFloat(FB.Dom.getStyle(c,'borderBottomWidth')));b.innerHTML=FB.String.format('
        '+''+'{2}'+''+'
        '+''+'{4}'+''+'{5}'+' '+'{6} – '+'{0}'+'',FB.Intl._tx("No Thanks"),FB.getDomain('cdn')+FB.XFBML.ConnectBar.imgs.buttonUrl,FB.Intl._tx("Close"),d[this._picFieldName]||FB.getDomain('cdn')+FB.XFBML.ConnectBar.imgs.missingProfileUrl,FB.String.escapeHTML(d.first_name),FB.Intl._tx("Hi {firstName}. \u003cstrong>{siteName}\u003c\/strong> is using Facebook to personalize your experience.",{firstName:FB.String.escapeHTML(d.first_name),siteName:FB.String.escapeHTML(d.site_name)}),FB.Intl._tx("Learn More"),d.profile_url,FB.getDomain('www')+'sitetour/connect.php');var a=this;FB.Array.forEach(b.getElementsByTagName('a'),function(g){g.onclick=FB.bind(a._clickHandler,a);});this._page=document.body;var f=0;if(this._page.parentNode){f=Math.round((parseFloat(FB.Dom.getStyle(this._page.parentNode,'height'))-parseFloat(FB.Dom.getStyle(this._page,'height')))/2);}else f=parseInt(FB.Dom.getStyle(this._page,'marginTop'),10);f=isNaN(f)?0:f;this._initTopMargin=f;if(!window.XMLHttpRequest){c.className+=" fb_connect_bar_container_ie6";}else{c.style.top=(-1*this._initialHeight)+'px';FB.Anim.ate(c,{top:'0px'},this._animationSpeed);}var e={marginTop:this._initTopMargin+this._initialHeight+'px'};if(FB.Dom.getBrowserType()=='ie'){e.backgroundPositionY=this._initialHeight+'px';}else e.backgroundPosition='? '+this._initialHeight+'px';FB.Anim.ate(this._page,e,this._animationSpeed);},_clickHandler:function(a){a=a||window.event;var b=a.target||a.srcElement;while(b.nodeName!='A')b=b.parentNode;switch(b.className){case 'fb_bar_close':FB.api({method:'Connect.connectBarMarkAcknowledged'});FB.Insights.impression({lid:104,name:'widget_user_closed'});this._closeConnectBar();break;case 'fb_learn_more':case 'fb_profile':window.open(b.href);break;case 'fb_no_thanks':this._closeConnectBar();FB.api({method:'Connect.connectBarMarkAcknowledged'});FB.Insights.impression({lid:104,name:'widget_user_no_thanks'});FB.api({method:'auth.revokeAuthorization',block:true},this.bind(function(){this.fire('connectbar.ondeauth');FB.Event.fire('connectbar.ondeauth',this);FB.Helper.invokeHandler(this.getAttribute('on-deauth'),this);if(this._getBoolAttribute('auto-refresh',true))window.location.reload();}));break;}return false;},_closeConnectBar:function(){this._notDisplayed=true;var a={marginTop:this._initTopMargin+'px'};if(FB.Dom.getBrowserType()=='ie'){a.backgroundPositionY='0px';}else a.backgroundPosition='? 0px';var b=(this._animationSpeed==0)?0:300;FB.Anim.ate(this._page,a,b);FB.Anim.ate(this._container,{top:(-1*this._initialHeight)+'px'},b,function(c){c.parentNode.removeChild(c);});this.fire('connectbar.onclose');FB.Event.fire('connectbar.onclose',this);FB.Helper.invokeHandler(this.getAttribute('on-close'),this);}});FB.provide('XFBML.ConnectBar',{imgs:{buttonUrl:'images/facebook-widgets/close_btn.png',missingProfileUrl:'pics/q_silhouette.gif'}}); -FB.subclass('XFBML.Facepile','XFBML.IframeWidget',null,{_visibleAfter:'load',_extraParams:{},setupAndValidate:function(){this._attr={href:this.getAttribute('href'),channel:this.getChannelUrl(),max_rows:this.getAttribute('max-rows'),width:this._getPxAttribute('width',200),ref:this.getAttribute('ref')};for(var a in this._extraParams)this._attr[a]=this._extraParams[a];return true;},setExtraParams:function(a){this._extraParams=a;},oneTimeSetup:function(){var a=FB._userStatus;FB.Event.subscribe('auth.statusChange',FB.bind(function(b){if(a=='connected'||b.status=='connected')this.process(true);a=b.status;},this));},getSize:function(){return {width:this._attr.width,height:70};},getUrlBits:function(){return {name:'facepile',params:this._attr};}}); -FB.subclass('XFBML.Fan','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={api_key:FB._apiKey,connections:this.getAttribute('connections','10'),css:this.getAttribute('css'),height:this._getPxAttribute('height'),id:this.getAttribute('profile-id'),logobar:this._getBoolAttribute('logo-bar'),name:this.getAttribute('name'),stream:this._getBoolAttribute('stream',true),width:this._getPxAttribute('width',300)};if(!this._attr.id&&!this._attr.name){FB.log(' requires one of the "id" or "name" attributes.');return false;}var a=this._attr.height;if(!a)if((!this._attr.connections||this._attr.connections==='0')&&!this._attr.stream){a=65;}else if(!this._attr.connections||this._attr.connections==='0'){a=375;}else if(!this._attr.stream){a=250;}else a=550;if(this._attr.logobar)a+=25;this._attr.height=a;return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'fan',params:this._attr};}}); -FB.subclass('XFBML.Friendpile','XFBML.Facepile',null,{}); -FB.subclass('XFBML.EdgeCommentWidget','XFBML.IframeWidget',function(a){this._iframeWidth=a.width;this._iframeHeight=a.height;this._attr={master_frame_name:a.masterFrameName};this.dom=a.commentNode;this.dom.style.top=a.relativeHeightOffset;if(a.relativeWidthOffset)if(FB._localeIsRtl){this.dom.style.right=a.relativeWidthOffset;}else this.dom.style.left=a.relativeWidthOffset;this.dom.style.zIndex=FB.XFBML.EdgeCommentWidget.NextZIndex++;FB.Dom.addCss(this.dom,'fb_edge_comment_widget');},{_visibleAfter:'load',_showLoader:false,getSize:function(){return {width:this._iframeWidth,height:this._iframeHeight};},getUrlBits:function(){return {name:'comment_widget_shell',params:this._attr};}});FB.provide('XFBML.EdgeCommentWidget',{NextZIndex:10000}); -FB.subclass('XFBML.EdgeWidget','XFBML.IframeWidget',null,{_visibleAfter:'immediate',_showLoader:false,setupAndValidate:function(){FB.Dom.addCss(this.dom,'fb_edge_widget_with_comment');this._attr={channel_url:this.getChannelUrl(),debug:this._getBoolAttribute('debug'),href:this.getAttribute('href',window.location.href),is_permalink:this._getBoolAttribute('is-permalink'),node_type:this.getAttribute('node-type','link'),width:this._getWidgetWidth(),font:this.getAttribute('font'),layout:this._getLayout(),colorscheme:this.getAttribute('color-scheme'),action:this.getAttribute('action'),ref:this.getAttribute('ref'),show_faces:this._shouldShowFaces(),no_resize:this._getBoolAttribute('no_resize')};return true;},oneTimeSetup:function(){this.subscribe('xd.edgeCreated',FB.bind(this._onEdgeCreate,this));this.subscribe('xd.edgeRemoved',FB.bind(this._onEdgeRemove,this));this.subscribe('xd.presentEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogPresentation,this));this.subscribe('xd.dismissEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogDismissal,this));this.subscribe('xd.hideEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogHide,this));this.subscribe('xd.showEdgeCommentDialog',FB.bind(this._handleEdgeCommentDialogShow,this));},getSize:function(){return {width:this._getWidgetWidth(),height:this._getWidgetHeight()};},_getWidgetHeight:function(){var a=this._getLayout();var c=this._shouldShowFaces()?'show':'hide';var b={standard:{show:80,hide:35},box_count:{show:65,hide:65},button_count:{show:21,hide:21}};return b[a][c];},_getWidgetWidth:function(){var e=this._getLayout();var g=this._shouldShowFaces()?'show':'hide';var c=this.getAttribute('action')==='recommend'?130:90;var b=this.getAttribute('action')==='recommend'?100:55;var f={standard:{show:450,hide:450},box_count:{show:b,hide:b},button_count:{show:c,hide:c}};var d=f[e][g];var h=this._getPxAttribute('width',d);var a={standard:{min:225,max:900},box_count:{min:b,max:900},button_count:{min:c,max:900}};if(ha[e].max)h=a[e].max;return h;},_getLayout:function(){return this._getAttributeFromList('layout','standard',['standard','button_count','box_count']);},_shouldShowFaces:function(){return this._getLayout()==='standard'&&this._getBoolAttribute('show-faces',true);},_handleEdgeCommentDialogPresentation:function(b){if(!this.isValid())return;var a=document.createElement('span');this._commentSlave=this._createEdgeCommentWidget(b,a);this.dom.appendChild(a);this._commentSlave.process();this._commentWidgetNode=a;},_createEdgeCommentWidget:function(b,a){var c={commentNode:a,externalUrl:b.externalURL,width:330,height:200,masterFrameName:b.masterFrameName,layout:this._getLayout(),relativeHeightOffset:this._getHeightOffset(),relativeWidthOffset:this._getWidthOffset(b)};return new FB.XFBML.EdgeCommentWidget(c);},_getHeightOffset:function(){var a=this._getLayout();var b={standard:'20px',button_count:'17px',box_count:'-5px'};return b[a];},_getWidthOffset:function(c){if(c.preComputedWidthOffset)return parseInt(c.preComputedWidthOffset,10)+'px';var a=this._getLayout();var b={standard:'17px',box_count:'0px',button_count:'0px'};return b[a];},_handleEdgeCommentDialogDismissal:function(a){if(this._commentWidgetNode){this.dom.removeChild(this._commentWidgetNode);delete this._commentWidgetNode;}},_handleEdgeCommentDialogHide:function(){if(this._commentWidgetNode)this._commentWidgetNode.style.display="none";},_handleEdgeCommentDialogShow:function(){if(this._commentWidgetNode)this._commentWidgetNode.style.display="block";},_fireEventAndInvokeHandler:function(b,a){FB.Helper.fireEvent(b,this);FB.Helper.invokeHandler(this.getAttribute(a),this,[this._attr.href]);},_onEdgeCreate:function(){this._fireEventAndInvokeHandler('edge.create','on-create');},_onEdgeRemove:function(){this._fireEventAndInvokeHandler('edge.remove','on-remove');}}); -FB.subclass('XFBML.Like','XFBML.EdgeWidget',null,{getUrlBits:function(){return {name:'like',params:this._attr};},getIframeTitle:function(){return 'Like this content on Facebook.';}}); -FB.subclass('XFBML.LikeBox','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={channel:this.getChannelUrl(),api_key:FB._apiKey,connections:this.getAttribute('connections'),css:this.getAttribute('css'),height:this.getAttribute('height'),id:this.getAttribute('profile-id'),header:this._getBoolAttribute('header',true),name:this.getAttribute('name'),show_faces:this._getBoolAttribute('show-faces',true),stream:this._getBoolAttribute('stream',true),width:this._getPxAttribute('width',300),href:this.getAttribute('href'),colorscheme:this.getAttribute('colorscheme','light')};if(this._attr.connections==='0'){this._attr.show_faces=false;}else if(this._attr.connections)this._attr.show_faces=true;if(!this._attr.id&&!this._attr.name&&!this._attr.href){FB.log(' requires one of the "id" or "name" attributes.');return false;}var a=this._attr.height;if(!a)if(!this._attr.show_faces&&!this._attr.stream){a=62;}else{a=95;if(this._attr.show_faces)a+=163;if(this._attr.stream)a+=300;if(this._attr.header&&this._attr.header!=='0')a+=32;}this._attr.height=a;this.subscribe('xd.likeboxLiked',FB.bind(this._onLiked,this));this.subscribe('xd.likeboxUnliked',FB.bind(this._onUnliked,this));return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'likebox',params:this._attr};},_onLiked:function(){FB.Helper.fireEvent('edge.create',this);},_onUnliked:function(){FB.Helper.fireEvent('edge.remove',this);}}); -FB.subclass('XFBML.LiveStream','XFBML.IframeWidget',null,{_visibleAfter:'load',setupAndValidate:function(){this._attr={height:this._getPxAttribute('height',500),hideFriendsTab:this.getAttribute('hide-friends-tab'),redesigned:this._getBoolAttribute('redesigned-stream'),width:this._getPxAttribute('width',400),xid:this.getAttribute('xid','default'),always_post_to_friends:this._getBoolAttribute('always-post-to-friends',false)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){var a=this._attr.redesigned?'live_stream_box':'livefeed';return {name:a,params:this._attr};}}); -FB.subclass('XFBML.Login','XFBML.Facepile',null,{_visibleAfter:'load',getSize:function(){return {width:this._attr.width,height:94};},getUrlBits:function(){return {name:'login',params:this._attr};}}); -FB.subclass('XFBML.LoginButton','XFBML.ButtonElement',null,{setupAndValidate:function(){if(this._alreadySetup)return true;this._alreadySetup=true;this._attr={autologoutlink:this._getBoolAttribute('auto-logout-link'),length:this._getAttributeFromList('length','short',['long','short']),onlogin:this.getAttribute('on-login'),perms:this.getAttribute('perms'),registration_url:this.getAttribute('registration-url'),status:'unknown'};if(this._attr.autologoutlink)FB.Event.subscribe('auth.statusChange',FB.bind(this.process,this));if(this._attr.registration_url){FB.Event.subscribe('auth.statusChange',this._saveStatus(this.process));FB.getLoginStatus(this._saveStatus(this.process));}return true;},getButtonMarkup:function(){var a=this.getOriginalHTML();if(a)return a;if(!this._attr.registration_url){if(FB.getSession()&&this._attr.autologoutlink){return FB.Intl._tx("Facebook Logout");}else return this._getLoginText();}else switch(this._attr.status){case 'unknown':return this._getLoginText();case 'notConnected':return FB.Intl._tx("Register");case 'connected':if(FB.getSession()&&this._attr.autologoutlink)return FB.Intl._tx("Facebook Logout");return this._getLoginText();default:FB.log('Unknown status: '+this.status);return FB.Intl._tx("Login");}},_getLoginText:function(){return this._attr.length=='short'?FB.Intl._tx("Login"):FB.Intl._tx("Login with Facebook");},onClick:function(){if(!this._attr.registration_url){if(!FB.getSession()||!this._attr.autologoutlink){FB.login(FB.bind(this._authCallback,this),{perms:this._attr.perms});}else FB.logout(FB.bind(this._authCallback,this));}else switch(this._attr.status){case 'unknown':FB.ui({method:'auth.loginToFacebook'},FB.bind(function(a){FB.getLoginStatus(this._saveStatus(this._authCallback),true);},this));break;case 'notConnected':window.top.location=this._attr.registration_url;break;case 'connected':if(!FB.getSession()||!this._attr.autologoutlink){this._authCallback();}else FB.logout(FB.bind(this._authCallback,this));break;default:FB.log('Unknown status: '+this.status);}},_authCallback:function(a){FB.Helper.invokeHandler(this._attr.onlogin,this,[a]);},_saveStatus:function(a){return FB.bind(function(b){this._attr.status=b.status;if(a){a=this.bind(a,this);return a(b);}},this);}}); -FB.subclass('XFBML.Name','XFBML.Element',null,{process:function(){FB.copy(this,{_uid:this.getAttribute('uid'),_firstnameonly:this._getBoolAttribute('first-name-only'),_lastnameonly:this._getBoolAttribute('last-name-only'),_possessive:this._getBoolAttribute('possessive'),_reflexive:this._getBoolAttribute('reflexive'),_objective:this._getBoolAttribute('objective'),_linked:this._getBoolAttribute('linked',true),_subjectId:this.getAttribute('subject-id')});if(!this._uid){FB.log('"uid" is a required attribute for ');this.fire('render');return;}var b=[];if(this._firstnameonly){b.push('first_name');}else if(this._lastnameonly){b.push('last_name');}else b.push('name');if(this._subjectId){b.push('sex');if(this._subjectId==FB.Helper.getLoggedInUser())this._reflexive=true;}var a;FB.Event.monitor('auth.statusChange',this.bind(function(){if(!this.isValid()){this.fire('render');return true;}if(!this._uid||this._uid=='loggedinuser')this._uid=FB.Helper.getLoggedInUser();if(!this._uid)return;if(FB.Helper.isUser(this._uid)){a=FB.Data._selectByIndex(b,'user','uid',this._uid);}else a=FB.Data._selectByIndex(['name','id'],'profile','id',this._uid);a.wait(this.bind(function(c){if(this._subjectId==this._uid){this._renderPronoun(c[0]);}else this._renderOther(c[0]);this.fire('render');}));}));},_renderPronoun:function(b){var c='',a=this._objective;if(this._subjectId){a=true;if(this._subjectId===this._uid)this._reflexive=true;}if(this._uid==FB.Connect.get_loggedInUser()&&this._getBoolAttribute('use-you',true)){if(this._possessive){if(this._reflexive){c='your own';}else c='your';}else if(this._reflexive){c='yourself';}else c='you';}else switch(b.sex){case 'male':if(this._possessive){c=this._reflexive?'his own':'his';}else if(this._reflexive){c='himself';}else if(a){c='him';}else c='he';break;case 'female':if(this._possessive){c=this._reflexive?'her own':'her';}else if(this._reflexive){c='herself';}else if(a){c='her';}else c='she';break;default:if(this._getBoolAttribute('use-they',true)){if(this._possessive){if(this._reflexive){c='their own';}else c='their';}else if(this._reflexive){c='themselves';}else if(a){c='them';}else c='they';}else if(this._possessive){if(this._reflexive){c='his/her own';}else c='his/her';}else if(this._reflexive){c='himself/herself';}else if(a){c='him/her';}else c='he/she';break;}if(this._getBoolAttribute('capitalize',false))c=FB.Helper.upperCaseFirstChar(c);this.dom.innerHTML=c;},_renderOther:function(c){if(!c)return;var b='',a='';if(this._uid==FB.Helper.getLoggedInUser()&&this._getBoolAttribute('use-you',true)){if(this._reflexive){if(this._possessive){b='your own';}else b='yourself';}else if(this._possessive){b='your';}else b='you';}else{if(null===c.first_name)c.first_name='';if(null===c.last_name)c.last_name='';if(this._firstnameonly){b=FB.String.escapeHTML(c.first_name);}else if(this._lastnameonly)b=FB.String.escapeHTML(c.last_name);if(!b)b=FB.String.escapeHTML(c.name);if(b!==''&&this._possessive)b+='\'s';}if(!b)b=FB.String.escapeHTML(this.getAttribute('if-cant-see','Facebook User'));if(b){if(this._getBoolAttribute('capitalize',false))b=FB.Helper.upperCaseFirstChar(b);if(this._linked){a=FB.Helper.getProfileLink(c,b,this.getAttribute('href',null));}else a=b;}this.dom.innerHTML=a;}}); -FB.subclass('XFBML.ProfilePic','XFBML.Element',null,{process:function(){var d=this.getAttribute('size','thumb'),b=FB.XFBML.ProfilePic._sizeToPicFieldMap[d],g=this._getPxAttribute('width'),a=this._getPxAttribute('height'),e=this.dom.style,f=this.getAttribute('uid');if(this._getBoolAttribute('facebook-logo'))b+='_with_logo';if(g){g=g+'px';e.width=g;}if(a){a=a+'px';e.height=a;}var c=this.bind(function(j){var l=j?j[0]:null,i=l?l[b]:null;if(!i)i=FB.getDomain('cdn')+FB.XFBML.ProfilePic._defPicMap[b];var k=((g?'width:'+g+';':'')+(a?'height:'+g+';':'')),h=FB.String.format('{1}',i,l?FB.String.escapeHTML(l.name):'',k,this.dom.className);if(this._getBoolAttribute('linked',true))h=FB.Helper.getProfileLink(l,h,this.getAttribute('href',null));this.dom.innerHTML=h;FB.Dom.addCss(this.dom,'fb_profile_pic_rendered');this.fire('render');});FB.Event.monitor('auth.statusChange',this.bind(function(){if(!this.isValid()){this.fire('render');return true;}if(this.getAttribute('uid',null)=='loggedinuser')f=FB.Helper.getLoggedInUser();if(FB._userStatus&&f){FB.Data._selectByIndex(['name',b],FB.Helper.isUser(f)?'user':'profile',FB.Helper.isUser(f)?'uid':'id',f).wait(c);}else c();}));}});FB.provide('XFBML.ProfilePic',{_defPicMap:{pic:'pics/s_silhouette.jpg',pic_big:'pics/d_silhouette.gif',pic_big_with_logo:'pics/d_silhouette_logo.gif',pic_small:'pics/t_silhouette.jpg',pic_small_with_logo:'pics/t_silhouette_logo.gif',pic_square:'pics/q_silhouette.gif',pic_square_with_logo:'pics/q_silhouette_logo.gif',pic_with_logo:'pics/s_silhouette_logo.gif'},_sizeToPicFieldMap:{n:'pic_big',normal:'pic_big',q:'pic_square',s:'pic',small:'pic',square:'pic_square',t:'pic_small',thumb:'pic_small'}}); -FB.subclass('XFBML.Recommendations','XFBML.IframeWidget',null,{_visibleAfter:'load',_refreshOnAuthChange:true,setupAndValidate:function(){this._attr={border_color:this.getAttribute('border-color'),colorscheme:this.getAttribute('color-scheme'),filter:this.getAttribute('filter'),font:this.getAttribute('font'),header:this._getBoolAttribute('header'),height:this._getPxAttribute('height',300),site:this.getAttribute('site',location.hostname),width:this._getPxAttribute('width',300)};return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'recommendations',params:this._attr};}}); -FB.subclass('XFBML.Registration','XFBML.IframeWidget',null,{_visibleAfter:'immediate',_baseHeight:167,_fieldHeight:28,_skinnyWidth:520,_skinnyBaseHeight:173,_skinnyFieldHeight:52,setupAndValidate:function(){this._attr={channel_url:this.getChannelUrl(),client_id:FB._apiKey,fb_only:this._getBoolAttribute('fb-only',false),fields:this.getAttribute('fields'),height:this._getPxAttribute('height'),redirect_uri:this.getAttribute('redirect-uri',window.location.href),onvalidate:this.getAttribute('onvalidate'),width:this._getPxAttribute('width',600)};if(this._attr.onvalidate)this.subscribe('xd.validate',this.bind(function(b){var d=FB.JSON.parse(b.value);var a=this.bind(function(e){FB.Arbiter.inform('Registration.Validation',{errors:e,id:b.id},'parent.frames["'+this.getIframeNode().name+'"]');});var c=FB.Helper.executeFunctionByName(this._attr.onvalidate,d,a);if(c)a(c);}));return true;},getSize:function(){return {width:this._attr.width,height:this._getHeight()};},_getHeight:function(){if(this._attr.height)return this._attr.height;var b;if(!this._attr.fields){b=['name'];}else try{b=FB.JSON.parse(this._attr.fields);}catch(a){b=this._attr.fields.split(/,/);}if(this._attr.width requires the "fbml" attribute.');return false;}return true;},getSize:function(){return {width:this._attr.width,height:this._attr.height};},getUrlBits:function(){return {name:'serverfbml',params:this._attr};}}); -FB.subclass('XFBML.ShareButton','XFBML.Element',null,{process:function(){this._href=this.getAttribute('href',window.location.href);this._type=this.getAttribute('type','icon_link');FB.Dom.addCss(this.dom,'fb_share_count_hidden');this._renderButton(true);},_renderButton:function(f){if(!this.isValid()){this.fire('render');return;}var b='',c='',d='',a='',e=FB.Intl._tx("Share"),g='';switch(this._type){case 'icon':case 'icon_link':a='fb_button_simple';b=(''+(this._type=='icon_link'?e:' ')+'');f=false;break;case 'link':b=FB.Intl._tx("Share on Facebook");f=false;break;case 'button':b=''+e+'';a='fb_button fb_button_small';f=false;break;case 'button_count':b=''+e+'';c=(' '+''+this._getCounterMarkup()+'');a='fb_button fb_button_small';break;default:b=''+e+'';d=(' '+''+this._getCounterMarkup()+'');a='fb_button fb_button_small';g='fb_share_count_wrapper';}this.dom.innerHTML=FB.String.format('{4}{3}{5}',g,this._href,a,b,d,c,FB.JSON.stringify({method:'stream.share',u:this._href}));if(!f)this.fire('render');},_getCounterMarkup:function(){if(!this._count)this._count=FB.Data._selectByIndex(['total_count'],'link_stat','url',this._href);var b='0';if(this._count.value!==undefined){if(this._count.value.length>0){var a=this._count.value[0].total_count;if(a>3){FB.Dom.removeCss(this.dom,'fb_share_count_hidden');b=a>=1e+07?Math.round(a/1e+06)+'M':(a>=10000?Math.round(a/1000)+'K':a);}}}else this._count.wait(FB.bind(this._renderButton,this,false));return ''+b+'';}}); -void(0); - - -FB.provide("", {"_domain":{"api":"https:\/\/api.facebook.com\/","api_read":"https:\/\/api-read.facebook.com\/","cdn":"http:\/\/static.ak.fbcdn.net\/","graph":"https:\/\/graph.facebook.com\/","https_cdn":"https:\/\/s-static.ak.fbcdn.net\/","https_staticfb":"https:\/\/s-static.ak.facebook.com\/","https_www":"https:\/\/www.facebook.com\/","staticfb":"http:\/\/static.ak.facebook.com\/","www":"http:\/\/www.facebook.com\/"},"_locale":"en_US","_localeIsRtl":false}, true); -FB.provide("Flash", {"_minVersions":[[10,0,22,87]],"_swfPath":"rsrc.php\/v1\/yF\/r\/Y7YCBKX-HZn.swf"}, true); -FB.provide("XFBML.ConnectBar", {"imgs":{"buttonUrl":"rsrc.php\/yY\/r\/h_Y6u1wrZPW.png","missingProfileUrl":"rsrc.php\/yo\/r\/UlIqmHJn-SK.gif"}}, true); -FB.provide("XFBML.ProfilePic", {"_defPicMap":{"pic":"rsrc.php\/yh\/r\/C5yt7Cqf3zU.jpg","pic_big":"rsrc.php\/yL\/r\/HsTZSDw4avx.gif","pic_big_with_logo":"rsrc.php\/y5\/r\/SRDCaeCL7hM.gif","pic_small":"rsrc.php\/yi\/r\/odA9sNLrE86.jpg","pic_small_with_logo":"rsrc.php\/yD\/r\/k1xiRXKnlGd.gif","pic_square":"rsrc.php\/yo\/r\/UlIqmHJn-SK.gif","pic_square_with_logo":"rsrc.php\/yX\/r\/9dYJBPDHXwZ.gif","pic_with_logo":"rsrc.php\/yu\/r\/fPPR9f2FJ3t.gif"}}, true); -if (FB.Dom && FB.Dom.addCssRules) { FB.Dom.addCssRules(".fb_hidden{position:absolute;top:-10000px;z-index:10001}\n.fb_reset{background:none;border-spacing:0;border:0;color:#000;cursor:auto;direction:ltr;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;font-size:11px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal}\n.fb_link img{border:none}\n.fb_dialog{position:absolute;top:-10000px;z-index:10001}\n.fb_dialog_advanced{background:rgba(82, 82, 82, .7);padding:10px;-moz-border-radius:8px;-webkit-border-radius:8px}\n.fb_dialog_content{background:#fff;color:#333}\n.fb_dialog_close_icon{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 0 transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif);cursor:pointer;display:block;height:15px;position:absolute;right:18px;top:17px;width:15px;top:8px\\9;right:7px\\9}\n.fb_dialog_close_icon:hover{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -15px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif)}\n.fb_dialog_close_icon:active{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zq\/r\/IE9JII6Z1Ys.png) no-repeat scroll 0 -30px transparent;_background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/s816eWC-2sl.gif)}\n.fb_dialog_loader{background-color:#f2f2f2;border:1px solid #606060;font-size:24px;padding:20px}\n.fb_dialog_top_left,\n.fb_dialog_top_right,\n.fb_dialog_bottom_left,\n.fb_dialog_bottom_right{height:10px;width:10px;overflow:hidden;position:absolute}\n.fb_dialog_top_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 0;left:-10px;top:-10px}\n.fb_dialog_top_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -10px;right:-10px;top:-10px}\n.fb_dialog_bottom_left{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -20px;bottom:-10px;left:-10px}\n.fb_dialog_bottom_right{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/ze\/r\/8YeTNIlTZjm.png) no-repeat 0 -30px;right:-10px;bottom:-10px}\n.fb_dialog_vert_left,\n.fb_dialog_vert_right,\n.fb_dialog_horiz_top,\n.fb_dialog_horiz_bottom{position:absolute;background:#525252;filter:alpha(opacity=70);opacity:.7}\n.fb_dialog_vert_left,\n.fb_dialog_vert_right{width:10px;height:100\u0025}\n.fb_dialog_vert_left{margin-left:-10px}\n.fb_dialog_vert_right{right:0;margin-right:-10px}\n.fb_dialog_horiz_top,\n.fb_dialog_horiz_bottom{width:100\u0025;height:10px}\n.fb_dialog_horiz_top{margin-top:-10px}\n.fb_dialog_horiz_bottom{bottom:0;margin-bottom:-10px}\n.fb_dialog_iframe{line-height:0}\n.fb_dialog_content .dialog_title{background:#6d84b4;border:1px solid #3b5998;color:#fff;font-size:14px;font-weight:bold;margin:0}\n.fb_dialog_content .dialog_title > span{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zd\/r\/Cou7n-nqK52.gif) no-repeat 5px 50\u0025;float:left;padding:5px 0 7px 26px}\n.fb_dialog_content .dialog_content{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/z9\/r\/jKEcVPZFk-2.gif) no-repeat 50\u0025 50\u0025;border:1px solid #555;border-bottom:0;border-top:0;height:150px}\n.fb_dialog_content .dialog_footer{background:#f2f2f2;border:1px solid #555;border-top-color:#ccc;height:40px}\n#fb_dialog_loader_close{float:right}\n.fb_iframe_widget{position:relative;display:-moz-inline-block;display:inline-block}\n.fb_iframe_widget iframe{position:relative;vertical-align:text-bottom}\n.fb_iframe_widget span{position:relative}\n.fb_hide_iframes iframe{position:relative;left:-10000px}\n.fb_iframe_widget_loader{position:relative;display:inline-block}\n.fb_iframe_widget_loader iframe{min-height:32px;z-index:2;zoom:1}\n.fb_iframe_widget_loader .FB_Loader{background:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/z9\/r\/jKEcVPZFk-2.gif) no-repeat;height:32px;width:32px;margin-left:-16px;position:absolute;left:50\u0025;z-index:4}\n.fb_button_simple,\n.fb_button_simple_rtl{background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zH\/r\/eIpbnVKI9lR.png);background-repeat:no-repeat;cursor:pointer;outline:none;text-decoration:none}\n.fb_button_simple_rtl{background-position:right 0}\n.fb_button_simple .fb_button_text{margin:0 0 0 20px;padding-bottom:1px}\n.fb_button_simple_rtl .fb_button_text{margin:0 10px 0 0}\na.fb_button_simple:hover .fb_button_text,\na.fb_button_simple_rtl:hover .fb_button_text,\n.fb_button_simple:hover .fb_button_text,\n.fb_button_simple_rtl:hover .fb_button_text{text-decoration:underline}\n.fb_button,\n.fb_button_rtl{background:#29447e url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/FGFbc80dUKj.png);background-repeat:no-repeat;cursor:pointer;display:inline-block;padding:0 0 0 1px;text-decoration:none;outline:none}\n.fb_button .fb_button_text,\n.fb_button_rtl .fb_button_text{background:#5f78ab url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zL\/r\/FGFbc80dUKj.png);border-top:solid 1px #879ac0;border-bottom:solid 1px #1a356e;color:#fff;display:block;font-family:\"lucida grande\",tahoma,verdana,arial,sans-serif;font-weight:bold;padding:2px 6px 3px 6px;margin:1px 1px 0 21px;text-shadow:none}\na.fb_button,\na.fb_button_rtl,\n.fb_button,\n.fb_button_rtl{text-decoration:none}\na.fb_button:active .fb_button_text,\na.fb_button_rtl:active .fb_button_text,\n.fb_button:active .fb_button_text,\n.fb_button_rtl:active .fb_button_text{border-bottom:solid 1px #29447e;border-top:solid 1px #45619d;background:#4f6aa3;text-shadow:none}\n.fb_button_xlarge,\n.fb_button_xlarge_rtl{background-position:left -60px;font-size:24px;line-height:30px}\n.fb_button_xlarge .fb_button_text{padding:3px 8px 3px 12px;margin-left:38px}\na.fb_button_xlarge:active{background-position:left -99px}\n.fb_button_xlarge_rtl{background-position:right -268px}\n.fb_button_xlarge_rtl .fb_button_text{padding:3px 8px 3px 12px;margin-right:39px}\na.fb_button_xlarge_rtl:active{background-position:right -307px}\n.fb_button_large,\n.fb_button_large_rtl{background-position:left -138px;font-size:13px;line-height:16px}\n.fb_button_large .fb_button_text{margin-left:24px;padding:2px 6px 4px 6px}\na.fb_button_large:active{background-position:left -163px}\n.fb_button_large_rtl{background-position:right -346px}\n.fb_button_large_rtl .fb_button_text{margin-right:25px}\na.fb_button_large_rtl:active{background-position:right -371px}\n.fb_button_medium,\n.fb_button_medium_rtl{background-position:left -188px;font-size:11px;line-height:14px}\na.fb_button_medium:active{background-position:left -210px}\n.fb_button_medium_rtl{background-position:right -396px}\n.fb_button_text_rtl,\n.fb_button_medium_rtl .fb_button_text{padding:2px 6px 3px 6px;margin-right:22px}\na.fb_button_medium_rtl:active{background-position:right -418px}\n.fb_button_small,\n.fb_button_small_rtl{background-position:left -232px;font-size:10px;line-height:10px}\n.fb_button_small .fb_button_text{padding:2px 6px 3px;margin-left:17px}\na.fb_button_small:active,\n.fb_button_small:active{background-position:left -250px}\n.fb_button_small_rtl{background-position:right -440px}\n.fb_button_small_rtl .fb_button_text{padding:2px 6px;margin-right:18px}\na.fb_button_small_rtl:active{background-position:right -458px}\n.fb_connect_bar_container div,\n.fb_connect_bar_container span,\n.fb_connect_bar_container a,\n.fb_connect_bar_container img,\n.fb_connect_bar_container strong{background:none;border-spacing:0;border:0;direction:ltr;font-style:normal;font-variant:normal;letter-spacing:normal;line-height:1;margin:0;overflow:visible;padding:0;text-align:left;text-decoration:none;text-indent:0;text-shadow:none;text-transform:none;visibility:visible;white-space:normal;word-spacing:normal;vertical-align:baseline}\n.fb_connect_bar_container{position:fixed;left:0 !important;right:0 !important;height:42px !important;padding:0 25px !important;margin:0 !important;vertical-align:middle !important;border-bottom:1px solid #333 !important;background:#3b5998 !important;z-index:99999999 !important;overflow:hidden !important}\n.fb_connect_bar_container_ie6{position:absolute;top:expression(document.compatMode==\"CSS1Compat\"? document.documentElement.scrollTop+\"px\":body.scrollTop+\"px\")}\n.fb_connect_bar{position:relative;margin:auto;height:100\u0025;width:100\u0025;padding:6px 0 0 0 !important;background:none;color:#fff !important;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif !important;font-size:13px !important;font-style:normal !important;font-variant:normal !important;font-weight:normal !important;letter-spacing:normal !important;line-height:1 !important;text-decoration:none !important;text-indent:0 !important;text-shadow:none !important;text-transform:none !important;white-space:normal !important;word-spacing:normal !important}\n.fb_connect_bar a:hover{color:#fff}\n.fb_connect_bar .fb_profile img{height:30px;width:30px;vertical-align:middle;margin:0 6px 5px 0}\n.fb_connect_bar div a,\n.fb_connect_bar span,\n.fb_connect_bar span a{color:#bac6da;font-size:11px;text-decoration:none}\n.fb_connect_bar .fb_buttons{float:right;margin-top:7px}\n.fb_edge_widget_with_comment{position:relative;*z-index:1000}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget{position:absolute}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_ltr{left:-4px}\n.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_rtl{left:2px}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget{left:0}\n.fb_edge_widget_with_comment span.fb_send_button_form_widget .FB_Loader{left:10\u0025}\n.fb_share_count_wrapper{position:relative;float:left}\n.fb_share_count{background:#b0b9ec none repeat scroll 0 0;color:#333;font-family:\"lucida grande\", tahoma, verdana, arial, sans-serif;text-align:center}\n.fb_share_count_inner{background:#e8ebf2;display:block}\n.fb_share_count_right{margin-left:-1px;display:inline-block}\n.fb_share_count_right .fb_share_count_inner{border-top:solid 1px #e8ebf2;border-bottom:solid 1px #b0b9ec;margin:1px 1px 0 1px;font-size:10px;line-height:10px;padding:2px 6px 3px;font-weight:bold}\n.fb_share_count_top{display:block;letter-spacing:-1px;line-height:34px;margin-bottom:7px;font-size:22px;border:solid 1px #b0b9ec}\n.fb_share_count_nub_top{border:none;display:block;position:absolute;left:7px;top:35px;margin:0;padding:0;width:6px;height:7px;background-repeat:no-repeat;background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zU\/r\/bSOHtKbCGYI.png)}\n.fb_share_count_nub_right{border:none;display:inline-block;padding:0;width:5px;height:10px;background-repeat:no-repeat;background-image:url(http:\/\/static.ak.fbcdn.net\/rsrc.php\/zX\/r\/i_oIVTKMYsL.png);vertical-align:top;background-position:right 5px;z-index:10;left:2px;margin:0 2px 0 0;position:relative}\n.fb_share_no_count{display:none}\n.fb_share_size_Small .fb_share_count_right .fb_share_count_inner{font-size:10px}\n.fb_share_size_Medium .fb_share_count_right .fb_share_count_inner{font-size:11px;padding:2px 6px 3px;letter-spacing:-1px;line-height:14px}\n.fb_share_size_Large .fb_share_count_right .fb_share_count_inner{font-size:13px;line-height:16px;padding:2px 6px 4px;font-weight:normal;letter-spacing:-1px}\n.fb_share_count_hidden .fb_share_count_nub_top,\n.fb_share_count_hidden .fb_share_count_top,\n.fb_share_count_hidden .fb_share_count_nub_right,\n.fb_share_count_hidden .fb_share_count_right{visibility:hidden}\n", ["fb.css.base","fb.css.dialog","fb.css.iframewidget","fb.css.button","fb.css.connectbarwidget","fb.css.edgecommentwidget","fb.css.sendbuttonformwidget","fb.css.sharebutton"]); } \ No newline at end of file diff --git a/game/old/fb/animated_image.js b/game/old/fb/animated_image.js deleted file mode 100644 index fbec113..0000000 --- a/game/old/fb/animated_image.js +++ /dev/null @@ -1,93 +0,0 @@ -// Manages an animated image. Assumes that while it is active, -// get_image is called once per game loop -// Defaults to starting immediately -// Unless you call loop, will only run through the images once -// spec: -// All optional -// anim_rate : the number of frames to display each image -// reverse : whether to go backwards in the images when you reach the end or not - -var animated_image = function(image_name, spec) { - - // obj to return - var obj = []; - - // private vars - - var all_images = image_manager.get_images(image_name); - all_images.sort( - function(i1, i2) { - //return i1.path < i2.path; - return i1.path < i2.path ? -1 : (i1.path > i2.path ? 1 : 0); - } - ); - //for_each(all_images, function(i) { console.log(i.path); }); - var curr_index = 0; - var active = true; - var loop = false; - var rate_counter = 0; // Goes from 0 to anim_rate - 1 - var anim_rate = spec.anim_rate || 3; - - // If we are reversing, add all the images in the opposite - // order to all_images - if (spec.reverse || false) { - for (var i = (all_images.length - 1); i >=0; i--) { - all_images.push(all_images[i]); - } - } - - //public methods - - obj.start = function() { - active = true; - }; - - obj.pause = function() { - active = false; - }; - - obj.loop = function() { - loop = true; - }; - - obj.is_finished = function() { - // changed to && cuz it should be not looping - // and at the end to be finished - return (!loop && curr_index === (all_images.length - 1)); - }; - - // Returns the current image - obj.get_frame = function() { - var curr_image = all_images[curr_index].image; - update(); - return curr_image; - }; - - obj.set_rate = function(r) { - anim_rate = r; - }; - - // private methods - - var update = function() { - if (active) { - if (rate_counter >= (anim_rate - 1)) { - next_frame(); - rate_counter = 0; - } - else { - rate_counter++; - } - } - }; - - var next_frame = function() { - // If not 'at the end and not looping', - // increment curr_index, restarting if we reach the end - if (!(curr_index === all_images.length && !loop)) { - curr_index = (curr_index + 1) % all_images.length; - } - } - - return obj; -} diff --git a/game/old/fb/antibody.js b/game/old/fb/antibody.js deleted file mode 100644 index e6c6e17..0000000 --- a/game/old/fb/antibody.js +++ /dev/null @@ -1,86 +0,0 @@ -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards - -var antibody = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 11; - spec.height = spec.height || 7; - spec.speed = spec.speed || 4; - spec.no_target_speed = spec.no_target_speed || 2 - - //spec.vel = random_vel(); - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "antibody"; - }; - - // --- private variables --- - - // flag denoting whether the antibody is attached to a cell - var attached = false; - - // --- public methods --- - - // should be called when an antibody attaches to a cell - // tar will be the cell that it is attaching to (may not be its target) - obj.attach = function(tar) { - attached = true; - obj.face_target(tar); - // scoot it out just a bit - obj.get_vel().mult(-1); - obj.move(); - - //obj.set_target(null); - }; - - // implementing game_object interface - - obj.my_update = function() { - if (!attached) { - obj.set_speed(obj.get_level() / 4 + 1) - obj.move(); - // don't want two antibodies attacking one cell - var tar = obj.get_target(); - if (tar && (tar.has_antibody() - // also don't want them to keep target - // if the target changes level - || tar.get_level() !== obj.get_level() - // or if it starts to die - || tar.get_state() === "dying")) { - obj.set_target(null); - } - } - }; - - // should point towards target - // Y-shaped (top of Y is front) - obj.draw = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.stroke(obj.get_color()); - p.strokeWeight(2); - - p.line(-w, 0, w/3, 0); - p.line(w/3, 0, w, h/2); - p.line(w/3, 0, w, -h/2); - - p.popMatrix(); - }; - - return obj; -} diff --git a/game/old/fb/b_cell.js b/game/old/fb/b_cell.js deleted file mode 100644 index 5d3747a..0000000 --- a/game/old/fb/b_cell.js +++ /dev/null @@ -1,249 +0,0 @@ -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards -// state = just leave to be default (alive) - -var b_cell = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 30; - spec.height = spec.height || 30; - spec.speed = spec.speed || 5; - - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "b_cell"; - }; - - // --- private variables --- - - var b_anim = animated_image("bcell", {reverse : true}); - // for illustration - var b_image = image_manager.get_image("bcell_normal.png"); - // where to go and shoot from - var slot = null; - - // state can be "alive", "active", "shooting", "outdated" - - // Antibodies are created in update, and returned in get_antibodies() - var new_antibodies = null; - - // --- private methods - - // Makes one antibody and adds it to new_antibodies - var make_antibody = function() { - if (!new_antibodies) { - new_antibodies = []; - } - var obj_pos = obj.get_pos(); - var new_antibody = antibody(p, { - pos : new p.PVector(obj_pos.x, obj_pos.y + (obj.get_height() / 2)), - mutation_info: obj.get_mutation_info() - }); - new_antibodies.push(new_antibody); - return new_antibody; - }; - - - // --- public methods --- - - // Makes this target stop and begin producing antibodies - obj.make_antibodies = function() { - obj.set_state("shooting"); - obj.set_target(null); - // production will happen in update - }; - - // to be called on collision with floater - // takes a slot pos - obj.activate = function(aslot) { - obj.set_state("active"); - slot = aslot; - // send the bcell to the top - obj.set_target(game_object(p, { - pos: slot.pos //new p.PVector(p.width - (obj.get_width() / 2), 0) - })); - }; - - obj.get_slot = function() { - return slot; - }; - - // Returns any newly created antibodies - obj.get_antibodies = function() { - if (new_antibodies) { - var to_return = new_antibodies; - new_antibodies = null; - return to_return; - } - else { - return []; - } - }; - - obj.is_activated = function() { - return obj.get_state() === "active"; - }; - - obj.is_alive = function() { - return obj.get_state() === "alive"; - }; - - obj.is_shooting = function() { - return obj.get_state() === "shooting"; - }; - - obj.get_scroll_dist = function() { - var state = obj.get_state(); - if (state === "shooting" - //|| state === "alive" - || state === "active" ) { - return 0; - } - else if (state === "outdated") { - return obj.DEFAULT_SCROLL_DIST;// * 2; - } - else { - return obj.DEFAULT_SCROLL_DIST; - } - }; - - // implementing game_object interface - - obj.my_update = function() { - if (obj.get_state() === "shooting") { - //obj.stop(); - // make it face downwards - var angle = p.PI/2 - // switch if at bottom - if (!slot.is_top) { - angle = -p.PI/2; - } - obj.set_target_angle(angle); - if (Math.random() < .03) { - var new_anti = make_antibody(); - new_anti.set_target_angle(p.random(0, 2*angle)); - } - } - else { - obj.move(); - } - }; - - var draw_antibody = function() { - // private vars - var counter = 0; - var c_max = 30; - var ascending = true; - - // for illustrations - obj.set_anti_count = function(c) { - counter = c; - }; - - return function(){ - - p.pushMatrix(); - - var pos = obj.get_pos(); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - // Copied from antibody.js to avoid overhead of - // creating new antibody every time - p.stroke(obj.get_color()); - p.strokeWeight(1 + (counter / 6)); - - var w = 11; - var h = 7; - p.line(-w, 0, w / 3, 0); - p.line(w / 3, 0, w, h / 2); - p.line(w / 3, 0, w, -h / 2); - - p.popMatrix(); - - if (ascending === true) { - counter++; - } - else if (ascending === false) { - counter--; - } - if (counter === c_max) { - ascending = false; - } - else if (counter === 0) { - ascending = true; - } - }; - }(); - - // should point towards target - // (triangle for now) - obj.draw = function() { - /* - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.fill(obj.get_color()); - // If outdated, draw differently? - if (obj.get_state() === "outdated") { - p.fill(0); - } - p.noStroke(); - - // rightward triangle - p.triangle(-w/2, -h/2, -w/2, h/2, w/2, 0); - - p.fill(255); - p.ellipse(-w/4, 0, 10, 10); - - p.popMatrix(); - */ - - p.pushMatrix(); - - var pos = obj.get_pos(); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle() + p.PI / 2); - p.fill(obj.get_color()); - p.noStroke(); - //p.rect(rectx_offset, recty_offset, rect_width, rect_height); - p.imageMode(obj.get_mode()); - - if (!obj.is_illustration()) { - b_image = b_anim.get_frame(); - } - p.image(b_image, 0, 0, obj.get_width(), obj.get_height()); - - p.popMatrix(); - - var state = obj.get_state(); - if (state === "active" || state === "shooting") { - draw_antibody(); - } - }; - - obj.stop_animation = function() { - b_anim.pause(); - }; - - obj.resume_animation = function() { - b_anim.start(); - }; - - return obj; -} diff --git a/game/old/fb/background_edge.js b/game/old/fb/background_edge.js deleted file mode 100644 index 6d8bb09..0000000 --- a/game/old/fb/background_edge.js +++ /dev/null @@ -1,54 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec -// boolean is_top = true if its a top edge, otherwise false -// - -var background_edge = function(p, spec) { - - //var background_image = p.loadImage("images/background.jpg"); - //var background_image = p.loadImage("images/background1.png"); - var edge = spec.is_top ? - image_manager.get_image("background_topside.png") : - image_manager.get_image("background_bottomside.png"); - - // --- defaults --- - - spec.mode = p.CORNERS; - spec.width = spec.width || edge.width; - spec.height = spec.height || edge.height; - - // if bottom, height should have been set to bottom of screen - // so we need to shift it up - if (!spec.is_top) { - spec.pos.add(new p.PVector(0, -spec.height)); - } - - // obj to return - var obj = background_object(p, spec); - - obj.get_type = function() { - return "background_edge"; - }; - - - // --- private variables --- - - - // --- public methods --- - - // override draw method only - obj.draw = function() { - p.imageMode(obj.get_mode()); - p.image(edge, obj.get_pos().x, obj.get_pos().y); - }; - - // override offscreen check cuz we draw from the corners - obj.is_offscreen = function() { - // only need to check left edge of screen - return obj.get_pos().x + obj.get_width() < 0; - }; - - return obj; -}; - diff --git a/game/old/fb/background_object.js b/game/old/fb/background_object.js deleted file mode 100644 index 0f96f4e..0000000 --- a/game/old/fb/background_object.js +++ /dev/null @@ -1,76 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec -// - -var background_object = function(p, spec) { - - var obj_image = random_from( - image_manager.get_images("background")).image; - - - // --- defaults --- - - spec.mode = spec.mode || p.CENTER; - spec.width = spec.width || obj_image.width; - spec.height = spec.height || obj_image.height; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "background_object"; - }; - - // --- private variables --- - - - // --- public methods --- - - // implementing game_object interface - - // update is default (move) - - // (flat rect for now) - obj.draw = function() { - //var x_pos = obj.get_pos().x; - - //p.fill(p.color(49, 0, 0)); - //p.rect(x_pos, 0, obj.get_width() - x_pos, obj.get_height()); - //background_image.resize(p.width, p.height); - //p.image(background_image, 0, 0); - //console.log(obj.get_pos().x); - p.imageMode(obj.get_mode()); - p.image(obj_image, obj.get_pos().x, obj.get_pos().y); - //p.set(obj.get_pos().x, 0, background_image); - //p.fill(255, 70); - //p.noStroke(); - //p.rect(obj.get_pos().x, 0, obj.get_width(), obj.get_height()); - }; - - // background can't go off screen or die - obj.is_dead = function() { - return false; - }; - /* - obj.is_offscreen = function() { - return false; - }; - */ - //var count = 0; - - obj.scroll = function(scroll_factor) { - // count += 1; - //if (count === 1) { - // count = 0; - obj.get_pos().add(new p.PVector(obj.get_scroll_dist(), 0)); - // } - }; - - obj.get_scroll_dist = function() { - return -1; - }; - - return obj; -}; - diff --git a/game/old/fb/button.js b/game/old/fb/button.js deleted file mode 100644 index 995dde5..0000000 --- a/game/old/fb/button.js +++ /dev/null @@ -1,122 +0,0 @@ -// Have a rectangle representing their position and a state to go to when clicked -// spec: -// state : function that returns a new state to go to when clicked -// (think of it like a thunk) -// rect : spec for a rectangle representing the button - -var button = function(p, spec) { - - // --- defaults --- - //spec.rect.width = spec.rect.width || 100; - //spec.rect.height = spec.rect.height || 35; - - // obj to return - var obj = {}; - - // --- private variables --- - - var next_state_fun = spec.state; - var active = spec.active || true; - - var image = spec.rect.image ? - image_manager.get_image(spec.rect.image) : null; - var over_image = spec.rect.over_image ? - image_manager.get_image(spec.rect.over_image) : null; - - // if no width is given but an image is - // use the image width - if (!spec.rect.width && image) { - spec.rect.width = image.width; - } - // and for height - if (!spec.rect.height && image) { - spec.rect.height = image.height; - } - - var rect = rectangle(p, spec.rect); - - // --- public methods --- - - obj.draw = function() { - if (!active) { - rect.set_tint(100); - /* - var r = spec.rect; - p.noStroke(); - p.fill(0, 150); - p.rectMode(p.CENTER); - p.rect(r.pos.x, r.pos.y, r.width, r.height); - */ - } - else { - //rect.set_tint(255); - } - rect.draw(); - }; - - // makes a button not active - obj.deactivate = function() { - // hack to make sure button tint updates - obj.mouse_moved(-1, -1); - active = false; - }; - - // makes a button active - obj.activate = function() { - // hack to make sure button tint updates - obj.mouse_moved(-1, -1); - active = true; - }; - - // Returns the state to go to if clicked, or - // null if not clicked - obj.is_clicked = function(x, y) { - if (active && rect.is_in(x, y)) { - // after click go back to normal image - if (over_image) { - rect.set_image(image); - } - return obj.get_state(); - } - else { - return null; - } - }; - - // special case for track buttons - obj.click = obj.is_clicked; - - obj.mouse_moved = function(x, y) { - if (active && rect.is_in(x, y)) { - if (over_image) { - rect.set_image(over_image); - } - else { - //rect.set_tint(0); - rect.set_tint(255, 255); - //rect.draw_twice(); - //console.log("tinting"); - } - } - else { - if (!over_image) { - rect.set_tint(200, 255); - } - //rect.draw_once(); - rect.set_image(image); - } - }; - // call once to init button tints - obj.mouse_moved(-1, -1); - - // Returns the state to go to - obj.get_state = function() { - return next_state_fun(); - }; - - obj.get_rect = function() { - return spec.rect; - }; - - return obj; -}; diff --git a/game/old/fb/cache.manifest-old b/game/old/fb/cache.manifest-old deleted file mode 100644 index 1fbb9e6..0000000 --- a/game/old/fb/cache.manifest-old +++ /dev/null @@ -1,9 +0,0 @@ -CACHE MANIFEST -#v .012 -CACHE: -sounds/cell_infect.wav -sounds/cell_fire.wav -#sounds/heart_loop1.mp3 -php_functions.php -NETWORK: -* diff --git a/game/old/fb/cell.js b/game/old/fb/cell.js deleted file mode 100644 index 149fd6b..0000000 --- a/game/old/fb/cell.js +++ /dev/null @@ -1,308 +0,0 @@ -// *** cell *** -// --- inherits from game_object -// spec: -// game_object spec + -// String state = "alive" or "dead" or "infected" or "active" -// mutation : Mutation_obj so cell can get current mutation color - -var cell = function(p, spec) { - - // --- defaults --- - - // was 40 - spec.width = spec.width || 25; - spec.height = spec.height || 25; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "cell"; - }; - - // --- private variables --- - - // images - var cell_image = random_from( - image_manager.get_images("infectable_cell")).image; - var burst_anim = animated_image("burst", {}); - var infect_anim = animated_image("cell_infect", {}); - - // state can be "alive", "infected", "active", or "dead" - var state = spec.state || "alive"; - // random initial angle - var arrow_angle = p.random(-p.PI/2, p.PI/2); - // random dir (1 or -1) - var arrow_dir = p.random() >= 0.5 ? 1 : -1; - - // indicates whether has been hit by an arrow and is being targeted - //var is_targeted = false; - - // holds an antibody that is attached to the cell, or null - var anti = null; - - // --- public methods --- - - // implementing game_object interface - - // update is different depending on state - obj.update = function() { - obj.move(); - if (state === "alive") { - // just chill - } - else if (state === "infected") { - // still chill - } - else if (state === "active") { - // spin the arrow - rotateArrow(); - } - else if (state === "dying") { - if (burst_anim.is_finished()) { - obj.set_state("dead"); - } - } - /* - else if (state === "dead") { - } - */ - }; - - // draw makes a cell with a different color depending on state - // (circle for now) - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.get_mode()); - - p.noStroke(); - - if (state === "dying") { - // draw frame and advance anim - p.image(burst_anim.get_frame(), pos.x, pos.y, - obj.get_width(), obj.get_height()); - // skip the rest of the method - return; - } - - - if (state === "alive") { - p.fill(p.color(200, 50, 50)); - } - else { - if (state === "infected") { - p.fill(obj.get_color()); - // draw after drawing the image - } - else if (state === "active") { - drawArrow(); - - // Draw a separate circle for the red outline - // so that we can more accurately fill in the cell - // red outline for now - p.stroke(255, 0, 0); - p.strokeWeight(4); - p.ellipse(pos.x, pos.y, obj.get_width(), obj.get_height()); - - p.noStroke(); - p.fill(obj.get_color()); - } - //if (infect_anim.is_finished() || obj.is_illustration()) { - p.ellipse(pos.x, pos.y, obj.get_width() * 4/5, obj.get_height() * 4/5); - //} - } - - p.imageMode(obj.get_mode()); - p.image(cell_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - - if (state === "infected" || state === "active") { - // draw after the image - if (!infect_anim.is_finished() && !obj.is_illustration()) { - // draw frame and advance anim - p.image(infect_anim.get_frame(), pos.x, pos.y, - obj.get_width(), obj.get_height()); - //p.fill(obj.get_color()); - } - } - - /* - else if (state === "dead") { - p.fill(0); - p.ellipse(pos.x, pos.y, - obj.get_width(), obj.get_height()); - } - */ - - }; - - // to be used in illustration only - obj.set_image = function(i) { - cell_image = i; - }; - - obj.get_image = function() { - return cell_image; - }; - - obj.is_dead = function() { - //console.log(burst_anim.is_finished()); - return state === "dead"; - }; - - obj.stop_animation = function() { - burst_anim.pause(); - infect_anim.pause(); - }; - - obj.resume_animation = function() { - burst_anim.start(); - infect_anim.start(); - }; - - obj.set_state = function(s) { - if (s === "infected") { - infect_anim.start(); - } - state = s; - }; - - obj.set_antibody = function(a) { - anti = a; - anti.attach(obj); - }; - - obj.has_antibody = function() { - return (anti !== null); - }; - - obj.get_state = function() { - return state; - }; - - obj.die = function() { - if (anti) { - anti.die(); - } - obj.set_state("dying"); - burst_anim.start(); - }; - - // explodes this cell if it is active - obj.fire = function() { - if (state === "active") { - // Make sounds - sounds.play_sound("cell_fire"); - - // TODO: need a slower death - obj.die(); - - var pos = obj.get_pos(); - var ang = arrow_angle; - // use width cuz it's a circle - var r = obj.get_width()/2; - - // gen particles at edge of cell for now - var x = r*p.cos(ang) + pos.x; - var y = r*p.sin(ang) + pos.y; - - var num_particles = get_num_particles(); - // angle between all the shots - var range = p.PI/6; - var incr = range/num_particles; - - var particles = []; - - ang = arrow_angle - range/2; - // special case - if (num_particles === 1) { - ang = arrow_angle; - } - while (num_particles > 0) { - var new_vel = new p.PVector(p.cos(ang), p.sin(ang)); - // mult by speed scalar - new_vel.mult(7); - // if we want to add velocity of cell - new_vel.add(obj.get_vel()); - - particles.push(particle(p, { - pos: new p.PVector(x, y), - vel: new_vel, - mutation_info: obj.get_mutation_info() - })); - - num_particles--; - ang += incr; - } - - return particles; - } - throw "Can't fire on "+state+" cell!"; - }; - - // override for circular object - obj.calc_radius = function() { - return obj.get_width()/2; - }; - obj.set_radius(obj.calc_radius()); - - // --- private functions --- - - // rotates according to arrow_dir - // switches direction at certain angles - var rotateArrow = function() { - if (arrow_angle > p.PI/2 - || arrow_angle < -p.PI/2) { - arrow_dir = (2-arrow_dir)-2; - } - arrow_angle += p.radians(5+obj.get_level()/2)*arrow_dir; - }; - - var drawArrow = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - var w = obj.get_width(); - - // move to center of circle - p.translate(pos.x, pos.y); - // rotate first - p.rotate(arrow_angle); - // move out to right edge of circle - p.translate(w/2, 0); - - // red outline for now - p.stroke(255, 0, 0); - p.strokeWeight(2); - p.fill(obj.get_color()); - - var x1 = w/2; - // draw facing out to right - p.beginShape(); - p.vertex(0, -5); - p.vertex(x1, -5); - p.vertex(x1, -10); - p.vertex(x1+15, 0); - p.vertex(x1, 10); - p.vertex(x1, 5); - p.vertex(0, 5); - p.endShape(); - - p.popMatrix(); - }; - - var get_num_particles = function() { - - var extra_particles = 0; - var mut_info = obj.get_mutation_info(); - /* - for_each(mut_info.abilities, function(a) { - if (a === "extra_particle") { - extra_particles++; - } - }); - */ - return mut_info.particles + extra_particles; - }; - - return obj; -}; diff --git a/game/old/fb/credits_state.js b/game/old/fb/credits_state.js deleted file mode 100644 index 9d79008..0000000 --- a/game/old/fb/credits_state.js +++ /dev/null @@ -1,59 +0,0 @@ -var credits_state = function(p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var credits_back = image_manager.get_image("creditsscreen.png"); - - // Buttons - - var back_button = button(p, { - state : function() { return prev_state; }, - rect : { - pos : new p.PVector(p.width * (3/4), 500), - width: 120, - height: 50, - image: "back.png", - } - }); - - - //Not ordered - var all_buttons = [ back_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "credits"; - }; - - obj.update = function() { - //do nothing - }; - - obj.render = function() { - // fill the background - p.noStroke(); - p.fill(g.background_color); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.imageMode(p.CENTER); - p.image(credits_back, p.width/2, p.height/2); - }; - - obj.key_pressed = function(k) { - if (p.keyCode === 13 || p.keyCode === 27) { // enter, esc - obj.exit_state(); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/game/old/fb/css/styles.css b/game/old/fb/css/styles.css deleted file mode 100644 index 44efae4..0000000 --- a/game/old/fb/css/styles.css +++ /dev/null @@ -1,60 +0,0 @@ -canvas { - border: 3px solid gray; - z-index: 1; - width: 700; - height: 600; - position: relative; -} -#scores-wrap { - z-index: 2; - /*background: white;*/ - /*color: black;*/ - width: 500; - height: 400; - /* use top/left to center manually */ - /* add in border width */ - left: 103px; - top: 83px; - position: absolute; - /* start hidden */ - display: none; -} -#scores { - height: 430; -} -table.score-table { - border-collapse: collapse; - width: 100%; - background: black; - color: white; - /*padding: 0.2em;*/ -} -.score-table, .score-table tr, .score-table td { - /*color: black;*/ - border: 2px solid #666; - font-size: 14; - text-align: right; -} -.score-table th { - font-size: 16; - text-align: center; - color: #000; - background: #fff; - border: 2px solid #666; - border-top: 5px solid #666; -} -.score-table th, .score-table tr, .score-table td { - padding: 0.2em 0.4em; -} -.Score-header { - width: 120; -} -.Name-header { - width: 140; -} -.Level-header { - width: 50; -} -.Date-header { - width: 100; -} diff --git a/game/old/fb/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png b/game/old/fb/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png deleted file mode 100755 index 5473aff..0000000 Binary files a/game/old/fb/css/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png and /dev/null differ diff --git a/game/old/fb/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png b/game/old/fb/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png deleted file mode 100755 index 5950a8d..0000000 Binary files a/game/old/fb/css/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png and /dev/null differ diff --git a/game/old/fb/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png b/game/old/fb/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png deleted file mode 100755 index 1ad224a..0000000 Binary files a/game/old/fb/css/ui-darkness/images/ui-bg_glass_20_555555_1x400.png and /dev/null differ diff --git a/game/old/fb/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png b/game/old/fb/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png deleted file mode 100755 index 1cf1cac..0000000 Binary files a/game/old/fb/css/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png and /dev/null differ diff --git a/game/old/fb/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png b/game/old/fb/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png deleted file mode 100755 index 35ec0d9..0000000 Binary files a/game/old/fb/css/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png and /dev/null differ diff --git a/game/old/fb/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png b/game/old/fb/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png deleted file mode 100755 index b1b03b6..0000000 Binary files a/game/old/fb/css/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png and /dev/null differ diff --git a/game/old/fb/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png b/game/old/fb/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png deleted file mode 100755 index e56eefd..0000000 Binary files a/game/old/fb/css/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png and /dev/null differ diff --git a/game/old/fb/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png b/game/old/fb/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png deleted file mode 100755 index 3525eb9..0000000 Binary files a/game/old/fb/css/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png and /dev/null differ diff --git a/game/old/fb/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png b/game/old/fb/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png deleted file mode 100755 index 2b6a9f9..0000000 Binary files a/game/old/fb/css/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png and /dev/null differ diff --git a/game/old/fb/css/ui-darkness/images/ui-icons_222222_256x240.png b/game/old/fb/css/ui-darkness/images/ui-icons_222222_256x240.png deleted file mode 100755 index b273ff1..0000000 Binary files a/game/old/fb/css/ui-darkness/images/ui-icons_222222_256x240.png and /dev/null differ diff --git a/game/old/fb/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png b/game/old/fb/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png deleted file mode 100755 index c5d93b6..0000000 Binary files a/game/old/fb/css/ui-darkness/images/ui-icons_4b8e0b_256x240.png and /dev/null differ diff --git a/game/old/fb/css/ui-darkness/images/ui-icons_a83300_256x240.png b/game/old/fb/css/ui-darkness/images/ui-icons_a83300_256x240.png deleted file mode 100755 index 95993ea..0000000 Binary files a/game/old/fb/css/ui-darkness/images/ui-icons_a83300_256x240.png and /dev/null differ diff --git a/game/old/fb/css/ui-darkness/images/ui-icons_cccccc_256x240.png b/game/old/fb/css/ui-darkness/images/ui-icons_cccccc_256x240.png deleted file mode 100755 index 9254e05..0000000 Binary files a/game/old/fb/css/ui-darkness/images/ui-icons_cccccc_256x240.png and /dev/null differ diff --git a/game/old/fb/css/ui-darkness/images/ui-icons_ffffff_256x240.png b/game/old/fb/css/ui-darkness/images/ui-icons_ffffff_256x240.png deleted file mode 100755 index 42f8f99..0000000 Binary files a/game/old/fb/css/ui-darkness/images/ui-icons_ffffff_256x240.png and /dev/null differ diff --git a/game/old/fb/css/ui-darkness/jquery-ui-1.8.9.custom.css b/game/old/fb/css/ui-darkness/jquery-ui-1.8.9.custom.css deleted file mode 100755 index 164af9f..0000000 --- a/game/old/fb/css/ui-darkness/jquery-ui-1.8.9.custom.css +++ /dev/null @@ -1,312 +0,0 @@ -/* - * jQuery UI CSS Framework 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - */ - -/* Layout helpers -----------------------------------*/ -.ui-helper-hidden { display: none; } -.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } -.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } -.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } -.ui-helper-clearfix { display: inline-block; } -/* required comment for clearfix to work in Opera \*/ -* html .ui-helper-clearfix { height:1%; } -.ui-helper-clearfix { display:block; } -/* end clearfix */ -.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } - - -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { cursor: default !important; } - - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } - - -/* - * jQuery UI CSS Framework 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - * - * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Segoe%20UI,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=6px&bgColorHeader=333333&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=25&borderColorHeader=333333&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=000000&bgTextureContent=05_inset_soft.png&bgImgOpacityContent=25&borderColorContent=666666&fcContent=ffffff&iconColorContent=cccccc&bgColorDefault=555555&bgTextureDefault=02_glass.png&bgImgOpacityDefault=20&borderColorDefault=666666&fcDefault=eeeeee&iconColorDefault=cccccc&bgColorHover=0078a3&bgTextureHover=02_glass.png&bgImgOpacityHover=40&borderColorHover=59b4d4&fcHover=ffffff&iconColorHover=ffffff&bgColorActive=f58400&bgTextureActive=05_inset_soft.png&bgImgOpacityActive=30&borderColorActive=ffaf0f&fcActive=ffffff&iconColorActive=222222&bgColorHighlight=eeeeee&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=80&borderColorHighlight=cccccc&fcHighlight=2e7db2&iconColorHighlight=4b8e0b&bgColorError=ffc73d&bgTextureError=02_glass.png&bgImgOpacityError=40&borderColorError=ffb73d&fcError=111111&iconColorError=a83300&bgColorOverlay=5c5c5c&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=50&opacityOverlay=80&bgColorShadow=cccccc&bgTextureShadow=01_flat.png&bgImgOpacityShadow=30&opacityShadow=60&thicknessShadow=7px&offsetTopShadow=-7px&offsetLeftShadow=-7px&cornerRadiusShadow=8px - */ - - -/* Component containers -----------------------------------*/ -.ui-widget { font-family: Segoe UI, Arial, sans-serif; font-size: 1.1em; } -.ui-widget .ui-widget { font-size: 1em; } -.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Segoe UI, Arial, sans-serif; font-size: 1em; } -.ui-widget-content { border: 1px solid #666666; background: #000000 url(images/ui-bg_inset-soft_25_000000_1x100.png) 50% bottom repeat-x; color: #ffffff; } -.ui-widget-content a { color: #ffffff; } -.ui-widget-header { border: 1px solid #333333; background: #333333 url(images/ui-bg_gloss-wave_25_333333_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; } -.ui-widget-header a { color: #ffffff; } - -/* Interaction states -----------------------------------*/ -.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #666666; background: #555555 url(images/ui-bg_glass_20_555555_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #eeeeee; } -.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #eeeeee; text-decoration: none; } -.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #59b4d4; background: #0078a3 url(images/ui-bg_glass_40_0078a3_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #ffffff; } -.ui-state-hover a, .ui-state-hover a:hover { color: #ffffff; text-decoration: none; } -.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #ffaf0f; background: #f58400 url(images/ui-bg_inset-soft_30_f58400_1x100.png) 50% 50% repeat-x; font-weight: bold; color: #ffffff; } -.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #ffffff; text-decoration: none; } -.ui-widget :active { outline: none; } - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #cccccc; background: #eeeeee url(images/ui-bg_highlight-soft_80_eeeeee_1x100.png) 50% top repeat-x; color: #2e7db2; } -.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #2e7db2; } -.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #ffb73d; background: #ffc73d url(images/ui-bg_glass_40_ffc73d_1x400.png) 50% 50% repeat-x; color: #111111; } -.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #111111; } -.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #111111; } -.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } -.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } -.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_cccccc_256x240.png); } -.ui-widget-content .ui-icon {background-image: url(images/ui-icons_cccccc_256x240.png); } -.ui-widget-header .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); } -.ui-state-default .ui-icon { background-image: url(images/ui-icons_cccccc_256x240.png); } -.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); } -.ui-state-active .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); } -.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_4b8e0b_256x240.png); } -.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_a83300_256x240.png); } - -/* positioning */ -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-off { background-position: -96px -144px; } -.ui-icon-radio-on { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-start { background-position: -80px -160px; } -/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-tl { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px; } -.ui-corner-tr { -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px; } -.ui-corner-bl { -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; } -.ui-corner-br { -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } -.ui-corner-top { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px; -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px; } -.ui-corner-bottom { -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } -.ui-corner-right { -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; border-top-right-radius: 6px; -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; } -.ui-corner-left { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; border-top-left-radius: 6px; -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; } -.ui-corner-all { -moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px; } - -/* Overlays */ -.ui-widget-overlay { background: #5c5c5c url(images/ui-bg_flat_50_5c5c5c_40x100.png) 50% 50% repeat-x; opacity: .80;filter:Alpha(Opacity=80); } -.ui-widget-shadow { margin: -7px 0 0 -7px; padding: 7px; background: #cccccc url(images/ui-bg_flat_30_cccccc_40x100.png) 50% 50% repeat-x; opacity: .60;filter:Alpha(Opacity=60); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/* - * jQuery UI Tabs 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Tabs#theming - */ -.ui-tabs { position: relative; /*padding: .2em;*/ zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ -.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; } -.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; } -.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; } -.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; } -.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */ -.ui-tabs .ui-tabs-panel { display: block; border-width: 0;/* padding: 1em 1.4em;*/ background: none; } -.ui-tabs .ui-tabs-hide { display: none !important; } diff --git a/game/old/fb/date.format.js b/game/old/fb/date.format.js deleted file mode 100644 index 3992c50..0000000 --- a/game/old/fb/date.format.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Date Format 1.2.3 - * (c) 2007-2009 Steven Levithan - * MIT license - * - * Includes enhancements by Scott Trenda - * and Kris Kowal - * - * Accepts a date, a mask, or a date and a mask. - * Returns a formatted version of the given date. - * The date defaults to the current date/time. - * The mask defaults to dateFormat.masks.default. - */ - -var dateFormat = function () { - var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, - timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, - timezoneClip = /[^-+\dA-Z]/g, - pad = function (val, len) { - val = String(val); - len = len || 2; - while (val.length < len) val = "0" + val; - return val; - }; - - // Regexes and supporting functions are cached through closure - return function (date, mask, utc) { - var dF = dateFormat; - - // You can't provide utc if you skip other args (use the "UTC:" mask prefix) - if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) { - mask = date; - date = undefined; - } - - // Passing date through Date applies Date.parse, if necessary - date = date ? new Date(date) : new Date; - if (isNaN(date)) throw SyntaxError("invalid date"); - - mask = String(dF.masks[mask] || mask || dF.masks["default"]); - - // Allow setting the utc argument via the mask - if (mask.slice(0, 4) == "UTC:") { - mask = mask.slice(4); - utc = true; - } - - var _ = utc ? "getUTC" : "get", - d = date[_ + "Date"](), - D = date[_ + "Day"](), - m = date[_ + "Month"](), - y = date[_ + "FullYear"](), - H = date[_ + "Hours"](), - M = date[_ + "Minutes"](), - s = date[_ + "Seconds"](), - L = date[_ + "Milliseconds"](), - o = utc ? 0 : date.getTimezoneOffset(), - flags = { - d: d, - dd: pad(d), - ddd: dF.i18n.dayNames[D], - dddd: dF.i18n.dayNames[D + 7], - m: m + 1, - mm: pad(m + 1), - mmm: dF.i18n.monthNames[m], - mmmm: dF.i18n.monthNames[m + 12], - yy: String(y).slice(2), - yyyy: y, - h: H % 12 || 12, - hh: pad(H % 12 || 12), - H: H, - HH: pad(H), - M: M, - MM: pad(M), - s: s, - ss: pad(s), - l: pad(L, 3), - L: pad(L > 99 ? Math.round(L / 10) : L), - t: H < 12 ? "a" : "p", - tt: H < 12 ? "am" : "pm", - T: H < 12 ? "A" : "P", - TT: H < 12 ? "AM" : "PM", - Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""), - o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), - S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10] - }; - - return mask.replace(token, function ($0) { - return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); - }); - }; -}(); - -// Some common format strings -dateFormat.masks = { - "default": "ddd mmm dd yyyy HH:MM:ss", - shortDate: "m/d/yy", - mediumDate: "mmm d, yyyy", - longDate: "mmmm d, yyyy", - fullDate: "dddd, mmmm d, yyyy", - shortTime: "h:MM TT", - mediumTime: "h:MM:ss TT", - longTime: "h:MM:ss TT Z", - isoDate: "yyyy-mm-dd", - isoTime: "HH:MM:ss", - isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", - isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" -}; - -// Internationalization strings -dateFormat.i18n = { - dayNames: [ - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" - ], - monthNames: [ - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", - "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" - ] -}; - -// For convenience... -Date.prototype.format = function (mask, utc) { - return dateFormat(this, mask, utc); -}; - diff --git a/game/old/fb/empty_cell.js b/game/old/fb/empty_cell.js deleted file mode 100644 index 76e58c9..0000000 --- a/game/old/fb/empty_cell.js +++ /dev/null @@ -1,91 +0,0 @@ -// *** empty_cell *** -// --- inherits from cell -// spec: -// cell spec - -var empty_cell = function(p, spec) { - - // --- defaults --- - // inherited from cell - - // obj to return - var obj = cell(p, spec); - - obj.get_type = function() { - return "empty_cell"; - }; - - // --- private variables --- - - // state can be "alive", "infected", or "dead" - //var state = spec.state || "alive"; - - //var empty_image = p.loadImage("images/noninfectable1.png"); - /* - var images = random_image_selector(); - var empty_image = null; - if (on_server) { // so itwill work locally - for_each(g_empty_cell_images, function(i){ - images.add(p.loadImage(i)); - }); - empty_image = images.get_image(); - } - else { - empty_image = p.loadImage("images/new/noninfectable.png"); - } - */ - var empty_image = random_from( - image_manager.get_images("empty_cell")).image; - - // --- public methods --- - - // implementing game_object interface - - // update is different depending on state - obj.update = function() { - obj.move(); - if (obj.get_state() === "alive") { - // just chill - } - else if (obj.get_state() === "infected") { - // prepare to die - } - else if (obj.get_state() === "dead") { - // explode!! - } - }; - - // draw makes a cell with a different color depending on state - // just an outline for empty cell - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.mode); - - p.strokeWeight(2); - p.stroke(0); - p.noFill(); - - if (obj.get_state() === "alive") { - p.stroke(0); - } - else if (obj.get_state() === "infected") { - p.stroke(150); - } - else if (obj.get_state() === "dead") { - p.fill(0); - } - - p.imageMode(obj.get_mode()); - p.image(empty_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - }; - - obj.is_dead = function() { - return obj.get_state() === "dead"; - }; - - obj.die = function() { - obj.set_state("dead") = "dead"; - }; - - return obj; -} diff --git a/game/old/fb/facebook.php b/game/old/fb/facebook.php deleted file mode 100644 index 6d4fa72..0000000 --- a/game/old/fb/facebook.php +++ /dev/null @@ -1,1845 +0,0 @@ - - - - - - - - - - - - src/facebook.php at master from facebook's php-sdk - GitHub - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        -
        - - - -
        -

        Your current locale selection: English. Choose another?

        - - - - - - - - - - - - -
        - -
        -
        -
        - - - - - - - - - - - - - - - - diff --git a/game/old/fb/fisforformat.min.js b/game/old/fb/fisforformat.min.js deleted file mode 100644 index d890718..0000000 --- a/game/old/fb/fisforformat.min.js +++ /dev/null @@ -1,11 +0,0 @@ -/* - * "f" is for Format & WHAT THE diff?? v0.5.0 - * - * Copyright (c) 2009 Joshua Faulkenberry - * Dual licensed under the MIT and GPL licenses. - * http://docs.jquery.com/License - * - * Date: 2009-03-20 22:15:23 -0700 (Fri, 20 Mar 2009) - * Revision: 6 - */ -window.Date.prototype.f=function(format){if(format=="@"){return this.getTime()}else{if(format=="REL"){var diff=(((new Date()).getTime()-this.getTime())/1000),day_diff=Math.floor(diff/86400);return day_diff==0&&(diff>-60&&"right now"||diff>-120&&"1 minute from now"||diff>-3600&&-(Math.floor(diff/60))+" minutes from now"||diff>-7200&&"1 hour ago"||diff>-86400&&-(Math.floor(diff/3600))+" hours from now"||diff<60&&"just now"||diff<120&&"1 minute ago"||diff<3600&&Math.floor(diff/60)+" minutes ago"||diff<7200&&"1 hour ago"||diff<86400&&Math.floor(diff/3600)+" hours ago")||day_diff==0&&"Tomorrow"||day_diff>-7&&-(day_diff)+" days from now"||-(Math.ceil(day_diff/7))==1&&"1 week from now"||day_diff>-78&&-(Math.ceil(day_diff/7))+" weeks from now"||day_diff>-730&&-(Math.ceil(day_diff/30))+" months from now"||day_diff<=-730&&-(Math.ceil(day_diff/365))+" years from now"||day_diff==1&&"Yesterday"||day_diff<7&&day_diff+" days ago"||(Math.ceil(day_diff/7))==1&&"1 week ago"||day_diff<78&&Math.ceil(day_diff/7)+" weeks ago"||day_diff<730&&Math.ceil(day_diff/30)+" months ago"||Math.ceil(day_diff/365)+" years ago"}}var MONTH_NAMES=["January","February","March","April","May","June","July","August","September","October","November","December"],DAY_NAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],LZ=function(x){return(x<0||x>9?"":"0")+x},date=this,format=format+"",result="",i_format=0,c="",token="",y=date.getYear()+"",M=date.getMonth()+1,d=date.getDate(),E=date.getDay(),H=date.getHours(),m=date.getMinutes(),s=date.getSeconds(),yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k,value=new Object();if(y.length<4){y=""+(y-0+1900)}value.y=""+y;value.yyyy=y;value.yy=y.substr(2,4);value.M=M;value.MM=LZ(M);value.MMM=MONTH_NAMES[M-1];value.NNN=MONTH_NAMES[M-1].substr(0,3);value.N=MONTH_NAMES[M-1].substr(0,1);value.d=d;value.dd=LZ(d);value.e=DAY_NAMES[E].substr(0,1);value.ee=DAY_NAMES[E].substr(0,2);value.E=DAY_NAMES[E].substr(0,3);value.EE=DAY_NAMES[E];value.H=H;value.HH=LZ(H);if(H==0){value.h=12}else{if(H>12){value.h=H-12}else{value.h=H}}value.hh=LZ(value.h);if(H>11){value.K=H-12}else{value.K=H}value.k=H+1;value.KK=LZ(value.K);value.kk=LZ(value.k);if(H>11){value.a="PM"}else{value.a="AM"}value.m=m;value.mm=LZ(m);value.s=s;value.ss=LZ(s);while(i_format=tl[trg]){if(trg=="Y"||trg=="D"||trg=="C"||trg=="T"){for(var yr=(min);yr.getFullYear()<=max.getFullYear();yr.setYear(yr.getFullYear()+1)){if(yr.isLeapYear()){diff-=tl.d}}}if(diff>=tl[trg]){result=Math.floor(diff/tl[trg])+" "+(Math.floor(diff/tl[trg])==1&&names[trg][0]||names[trg][1]);diff=diff%tl[trg]}}eval("breakdown = breakdown.replace(/"+trg+'/g, "")');return result}var min=date<=this&&date||date>this&&this,max=date>this&&date||date<=this&&this,diff=(max.getTime()-min.getTime()),tl={T:1000*60*60*24*365*100*10,C:1000*60*60*24*365*100,D:1000*60*60*24*365*10,Y:1000*60*60*24*365,M:1000*60*60*24*28,W:1000*60*60*24*7,d:1000*60*60*24,H:1000*60*60,m:1000*60,S:1000,N:1},names={T:options.labels.T||["Mellinium","Mellinia"],C:options.labels.C||["Century","Centuries"],D:options.labels.D||["Decade","Decades"],Y:options.labels.Y||["Year","Years"],M:options.labels.M||["Month","Months"],W:options.labels.W||["Week","Weeks"],d:options.labels.d||["Day","Days"],H:options.labels.H||["Hour","Hours"],m:options.labels.m||["Minute","Minutes"],S:options.labels.S||["Second","Seconds"],N:options.labels.N||["Millisecond","Milliseconds"]};if(options.len){for(var x in names){names[x]=names[x].substr(0,options.len)}}var testDt=new Date(min.toString());if(max.getFullYear()-testDt.getFullYear()>1){testDt.setYear(max.getFullYear()-1)}while(testDtmin.getDayLightSavingsDays()[1].getDate())||min.getMonth()0){if(breakdown=="*"){breakdown="TCDYMWdHmSN"}else{if(breakdown.indexOf("T")>-1){if(out=processTime("T")){result[result.length]=out}}else{if(breakdown.indexOf("C")>-1){if(out=processTime("C")){result[result.length]=out}}else{if(breakdown.indexOf("D")>-1){if(out=processTime("D")){result[result.length]=out}}else{if(breakdown.indexOf("Y")>-1){if(out=processTime("Y")){result[result.length]=out}}else{if(breakdown.indexOf("M")>-1){if(diff>=tl.M){var cur=(new Date(max.getTime()-diff));var monthCount=0;var lastVal=0;for(var yr=cur.getFullYear();yr<=max.getFullYear();yr++){while(cur.getFullYear()==yr){lastVal=cur.getTime();cur.setMonth(cur.getMonth()+1);if(diff-(cur.getTime()-lastVal)>=0){monthCount++;diff-=(cur.getTime()-lastVal)}if(yr==max.getFullYear()&&cur.getMonth()==max.getMonth()){break}}}if(monthCount){result[result.length]=monthCount+" "+(monthCount==1&&names.M[0]||names.M[1])}}breakdown=breakdown.replace(/M/g,"")}else{if(breakdown.indexOf("W")>-1){if(out=processTime("W")){result[result.length]=out}}else{if(breakdown.indexOf("d")>-1){if(out=processTime("d")){result[result.length]=out}}else{if(breakdown.indexOf("H")>-1){if(out=processTime("H")){result[result.length]=out}}else{if(breakdown.indexOf("m")>-1){if(out=processTime("m")){result[result.length]=out}}else{if(breakdown.indexOf("S")>-1){if(out=processTime("S")){result[result.length]=out}}else{if(breakdown.indexOf("N")>-1){if(out=processTime("N")){result[result.length]=out}}else{diff=0}}}}}}}}}}}}}options.divider=options.divider||", ";if(options.divider==", "&&result.length>1&&!options.hideAnd){result[result.length-1]="and "+result[result.length-1]}diff=result.join(options.divider)}if(diff==""){diff="Same"}if(options.lc){diff=diff.toLowerCase()}return diff};window.Date.prototype.getDaysInMonth=function(){return[31,28,31,30,31,30,31,31,30,31,30,31][this.getMonth()]};window.Date.prototype.isLeapYear=function(){return(new Date(this.getFullYear(),2-1,29)).getDate()==29};window.Date.prototype.getDayLightSavingsDays=function(){var result=[];var day1=new Date("03/07/"+this.getFullYear());var day2=new Date("03/06/"+this.getFullYear());while(day1.getMonth()<3||(day1.getMonth()==3&&day1.getDate()<16)){if((day1.getTime()-day2.getTime())/1000/60/60!=24){result[result.length]=new Date(day2.getTime())}day1.setDate(day1.getDate()+1);day2.setDate(day2.getDate()+1)}var day1=new Date("10/31/"+this.getFullYear());var day2=new Date("10/30/"+this.getFullYear());while(day1.getMonth()<11||(day1.getMonth()==10&&day1.getDate()<9)){if((day1.getTime()-day2.getTime())/1000/60/60!=24){result[result.length]=new Date(day2.getTime())}day1.setDate(day1.getDate()+1);day2.setDate(day2.getDate()+1)}return result};window.Date.prototype.isDayLightSavingsDay=function(){var comp=new Date(this.getTime());comp.setDate(comp.getDate()+1);return(comp.getTime()-this.getTime())/1000/60/60!=24}; \ No newline at end of file diff --git a/game/old/fb/floater.js b/game/old/fb/floater.js deleted file mode 100644 index 7272c01..0000000 --- a/game/old/fb/floater.js +++ /dev/null @@ -1,122 +0,0 @@ -// *** floater *** -// --- inherits from game_object -// spec: -// game_object spec -// state = leave to be default "alive" - -var floater = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 43; - spec.height = spec.height || 50; - spec.vel = new p.PVector(0, 0.3); - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "floater"; - }; - - // --- private variables --- - - var macrophage_alive = animated_image("macrophage", {reverse : true}); - var macrophage_active = animated_image("macrophage_active", {reverse : true}); - // for illustration - var macro_active_img = image_manager.get_image("macrophage_1_active.png"); - var macro_alive_img = image_manager.get_image("macrophage_1.png"); - - // how far up or down it can move - var range = 50; - var btm_lim = obj.get_pos().y + range; - var top_lim = obj.get_pos().y - range; - // state can be "alive", "activated", or "dead" - var state = spec.state || "alive"; - - // --- public methods --- - - // implementing game_object interface - - obj.update = function() { - // if we reach a limit - var y = obj.get_pos().y; - if (y <= top_lim || y >= btm_lim) { - // turn around - var v = obj.get_vel(); - obj.set_vel(new p.PVector(v.x, -v.y)); - } - obj.move(); - }; - - // (rectangle for now) - obj.draw = function() { - /* - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.fill(obj.get_color()); - - p.stroke(0); - p.strokeWeight(1); - - // had to hack to center rect - // might need to change - p.rect(pos.x-w/2, pos.y-h/2, w, h); - */ - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.imageMode(obj.get_mode()); - if (state === "active") { - p.shapeMode(obj.mode); - p.fill(obj.get_color()); - p.noStroke(); - p.ellipse(pos.x + w / 8, pos.y - w / 8 + 1, w/2, w/2); - if (!obj.is_illustration()) { - macro_active_img = macrophage_active.get_frame(); - } - p.image(macro_active_img, pos.x, pos.y, w, h); - } - else { - if (!obj.is_illustration()) { - macro_alive_img = macrophage_alive.get_frame(); - } - p.image(macro_alive_img, pos.x, pos.y, w, h); - } - }; - - obj.stop_animation = function() { - macrophage_alive.pause(); - macrophage_active.pause(); - }; - - obj.stop_animation = function() { - macrophage_alive.start(); - macrophage_active.start(); - }; - - obj.is_dead = function() { - return state === "dead"; - }; - - obj.is_alive = function() { - return state === "alive"; - }; - - obj.is_activated = function() { - return state === "active"; - }; - - obj.get_state = function() { - return state; - }; - - obj.activate = function() { - state = "active"; - }; - - return obj; -} diff --git a/game/old/fb/game_object.js b/game/old/fb/game_object.js deleted file mode 100644 index 71d409d..0000000 --- a/game/old/fb/game_object.js +++ /dev/null @@ -1,276 +0,0 @@ -// *** game_object *** -// spec: -// mode = p.CENTER or p.CORNERS (constants from processing) -// - describes how the coords work, set by p.shapeMode() -// p.PVector pos = initial position (x,y) -// float width = width of the entire object -// float height = height of the entire object -// float radius = circle collision radius (will be auto-calced) -// p.PVector vel = initial velocity -// p.PVector accel = initial acceleration -// mutation_info = object with level, num_particles and color props -// illustration = boolean that says whether or not to draw animations - -var game_object = function (p, spec) { - - - // object to return - var obj = {}; - - // should be overridden by subtypes - obj.get_type = function() { - return "game_object"; - }; - - obj.DEFAULT_SCROLL_DIST = -1.2; - - // --- private variables --- - - var mode = spec.mode || p.CENTER; - var pos = spec.pos || new p.PVector(0, 0); - var width = spec.width || 0; - var height = spec.height || 0; - var vel = spec.vel || new p.PVector(0, 0); - var accel = spec.accel || new p.PVector(0, 0); - // used for circle collision testing - var radius = spec.radius // default set at bottom of file - // used for mutation - var mutation_info = spec.mutation_info || - { level: -1, color: p.color(0, 0, 0), particles: 0 }; - var illustration = spec.illustration || false; - - var alive = true; - - // --- public methods --- - - // all game_objects must implement this interface: - // void update() - called each frame to move/update objects - // void draw() - called each frame to display the object - // void scroll() - moves the object left by a certain amount - - // update moves obj by default - obj.update = function() { obj.move(); }; - - // draw does nothing by default - obj.draw = function() {}; - - // by default returns the negated alive variable - obj.is_dead = function() { return !alive; }; - - // Generic methods for all game_objects: - // returns true if the object is completely offscreen - // i.e. checks pos + dimensions - obj.is_offscreen = function() { - var left_edge = pos.x - width/2; - var right_edge = pos.x + width/2; - var top_edge = pos.y - height/2; - var btm_edge = pos.y + height/2; - return (left_edge > p.width - || right_edge < 0 - || top_edge > p.height - || btm_edge < 0); - }; - - // Returns if the obj is off the right of the screen - obj.is_off_right = function() { - var left_edge = pos.x - width/2; - return left_edge > p.width; - }; - - - // Bounces the object off a wall, if it is at one - obj.bounce = function() { - var left_edge = pos.x - width; - var right_edge = pos.x + width; - var top_edge = pos.y - height; - var btm_edge = pos.y + height; - if (top_edge <= 0 && vel.y < 0) { - vel.y = -vel.y; - } - if (btm_edge >= p.height && vel.y > 0) { - vel.y = -vel.y; - } - if (left_edge <= 0 && vel.x < 0) { - vel.x = -vel.x; - } - if (right_edge >= p.width && vel.x > 0) { - vel.x = -vel.x; - } - }; - - // reverses the y velocity - // used for bouncing vertically - obj.reverse_y = function() { - var vel = obj.get_vel(); - obj.set_vel(new p.PVector(vel.x, -vel.y)); - }; - - // reverses the x velocity - // used for bouncing horizontally - obj.reverse_x = function() { - var vel = obj.get_vel(); - obj.set_vel(new p.PVector(- vel.x, vel.y)); - }; - - // updates the position according to accel and vel - // Bounces off walls - obj.move = function() { - vel.add(accel); - pos.add(vel); - }; - - // stops the object in its tracks by zeroing out vel - obj.stop = function() { - vel = new p.PVector(0, 0); - }; - - // Scrolls the obj a specified distance left or right (positive is right) - obj.scroll = function(scroll_factor) { - var scroll_x = obj.get_scroll_dist(); - if (scroll_x === null) { - scroll_x = obj.DEFAULT_SCROLL_DIST; - } - pos.add(new p.PVector(scroll_x*scroll_factor, 0)); - }; - - obj.die = function() { - alive = false; - }; - - obj.is_illustration = function() { - return illustration; - }; - - // --- setters --- - - obj.set_illustration = function(i) { - illustration = i; - }; - - obj.set_pos = function(new_pos) { - pos = new_pos; - }; - - obj.set_accel = function(new_accel) { - accel = new_accel; - }; - - obj.set_vel = function(new_vel) { - vel = new_vel; - }; - - // should only be used once, just for circular objects - obj.set_radius = function(new_radius) { - radius = new_radius; - }; - - // Should only be used for collisions - obj.set_pos = function(posn) { - pos = posn; - }; - - obj.set_mutation_info = function(m) { - mutation_info = m; - }; - - // --- getters --- - - // Override to set different scroll dist - // or leave as null to use default - obj.get_scroll_dist = function() { - return null; - }; - - obj.get_pos = function() { - return pos; - }; - - obj.get_left = function() { - return pos.x - (width / 2); - }; - - obj.get_top = function() { - return pos.y - (height / 2); - }; - - obj.get_right = function() { - return pos.x + (width / 2); - }; - - obj.get_bottom = function() { - return pos.y + (height / 2); - }; - - // returns the x offset for rectangle collisions - // should be overridden for rectangular objects - obj.get_x_offset = function() { - return 0; - }; - // returns the y offset for rectangle collisions - // should be overridden for rectangular objects - obj.get_y_offset = function() { - return 0; - }; - - obj.get_width = function() { - return width; - }; - - obj.get_height = function() { - return height; - }; - - obj.get_mode = function() { - return mode; - }; - - obj.get_vel = function() { - return vel; - }; - - obj.get_accel = function() { - return accel; - }; - - obj.get_radius = function() { - return radius; - }; - - obj.get_mutation_info = function() { - return mutation_info; - }; - - obj.get_color = function() { - return mutation_info.color; - }; - - obj.get_level = function() { - return mutation_info.level; - }; - - obj.is = function(type) { - return obj.get_type() === type; - }; - - obj.to_string = function() { - return obj.get_type()+" ("+pos.x+", "+pos.y+")"; - }; - - // draws the collision circle as an overlay - obj.draw_circle = function() { - p.fill(255, 50); - p.noStroke(); - p.shapeMode(p.CENTER); - p.ellipse(pos.x, pos.y, 2*radius, 2*radius); - }; - - // uses pythagorean theorem to calc radius of bounding circle - obj.calc_radius = function() { - return 0.5*p.sqrt(width*width+height*height); - }; - - // calc radius if not already set - radius = radius || obj.calc_radius(); - - return obj; -} diff --git a/game/old/fb/game_over_state.js b/game/old/fb/game_over_state.js deleted file mode 100644 index 99662c2..0000000 --- a/game/old/fb/game_over_state.js +++ /dev/null @@ -1,175 +0,0 @@ -// spec: -// score : num representing score of game -// mutation_level : num representing mutation level at end of game - -var game_over_state = function (p, prev_state, spec) { - //right now, prev_state is not used - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var topy = 100; - // Score display - var score_rect = rectangle(p, { - pos : new p.PVector(p.width / 2, topy+80),// 230), - width : 0, - height : 0, - text : "Score: " + add_commas(spec.score), - text_size : 30, - text_color : 255 - }); - - var mutation_rect = rectangle(p, { - pos : new p.PVector(p.width / 2, topy+130),//280), - width : 0, - height : 0, - text : "Mutation Level: " + spec.mutation_level, - text_size : 30, - text_color : 255 - }); - - var b_top = topy+180; - var b_spc = 60; - var button_style = { - width: 120, height: 50, - text_align: p.LEFT, - }; - // Buttons - var restart_button = button(p, { - state : function() { - sounds.play_button_click(); - return in_game_state(p, prev_state); - }, - rect : { - pos : new p.PVector(p.width / 2, b_top),//330), - //text : "Restart", - //text_x_offset: 40, - image: "restart.png", - //style: button_style - } - }); - var post_button = button(p, { - state : function() { - // only post if they are logged in - if (g_user_id) { - sounds.play_button_click(); - FB.ui({ - method: 'feed', - name: "Play Virion!", - picture: "http://virus-game.cs.brown.edu/images/logo/vlogolarge.png", - link: "http://apps.facebook.com/viriongame", - caption: "I just scored "+add_commas(spec.score)+ - " playing Virion!", - }); - } - return obj; - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+b_spc),//390), - //text : "Post Score to Wall", - //text_x_offset: 35, - image: "postscore.png", - //style: button_style - } - }); - var invite_button = button(p, { - state : function() { - // only post if they are logged in - if (g_user_id) { - sounds.play_button_click(); - FB.ui({ - method: 'apprequests', - title: "Infect Your Friends", - message: 'Check out this awesome game!', - }); - } - return obj; - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+2*b_spc),//450), - //text : "Infect Your Friends", - //text_x_offset: 35, - image: "infectfriends.png", - //style: button_style - } - }); - - // only allow posts/invites if logged in - if (!g_user_id) { - post_button.deactivate(); - invite_button.deactivate(); - } - - var scores_button = button(p, { - state : function() { - sounds.play_button_click(); - return high_scores_state(p, obj); - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+3*b_spc),//510), - //text : "High Scores", - //text_x_offset: 35, - image: "highscores.png", - //style: button_style - } - }); - var splash_button = button(p, { - state : function() { - sounds.play_button_click(); - return splash_state(p); - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+4*b_spc),//570), - //text : "Main Menu", - //text_x_offset: 35, - image: "mainmenu.png", - //style: button_style - } - }); - - //Not ordered - var all_buttons = [restart_button, post_button, - invite_button, splash_button, scores_button]; - var all_rectangles = [score_rect, mutation_rect]; - - // --- public methods --- - - obj.get_type = function() { - return "game_over"; - }; - - obj.update = function() { - //do nothing - }; - - obj.key_pressed = function(k) { - if (k === 114 || p.keyCode === 13) { //r, enter - obj.set_next_state(restart_button.get_state()); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - obj.render = function() { - p.fill(0, 150); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.fill(255); - p.textAlign(p.CENTER); - - p.textSize(50); - p.text("Game Over", p.width/2, topy); - p.textSize(20); - p.text("Your virus was wiped out!", p.width/2, topy+30); - - for_each(all_rectangles, function(r) {r.draw();}); - }; - - return obj; -}; diff --git a/game/old/fb/game_state.js b/game/old/fb/game_state.js deleted file mode 100644 index 775f8f9..0000000 --- a/game/old/fb/game_state.js +++ /dev/null @@ -1,124 +0,0 @@ -// *** game_state *** -// Interface for all game states - -// NOTE ALL OF THE FOLLOWING WHEN CREATING A GAME STATE: -// All game states must take a previous_state in their constructor, and then call set_previous_state() -// The exception to this is splash, which is the base state and should never be exited -// If a state change happens in: -// update() - return the new state -// mouse_click/key_pressed: Call set_next_state(new_state) with the state to go to -// Buttons: -// Drawing and clicking of buttons is taken care of -// You must take care of key strokes - -var game_state = function (p) { - - // object to return - var obj = {}; - - // --- private variables --- - var next_state = null; - var previous_state = null; - var all_buttons = []; //TODO: This is static but is updated every update() - - - // --- public methods --- - - //Wrapper for every states render function - //First draws all the buttons, then calls render - obj.render_wrapper = function() { - obj.render(); - for_each(all_buttons, function(b) { b.draw(); }); - }; - - //Do not over-ride these methods - obj.set_next_state = function(ns) { - next_state = ns; - }; - obj.set_previous_state = function(ps) { - previous_state = ps; - }; - obj.exit_state = function() { - if (previous_state === null) { - throw "error previous state not set in game_state"; - } - assert(previous_state !== null, "Previous state was null in game_state.exit_state"); - next_state = previous_state; - }; - - // Wrapper for every states update function - // Goes to the next state (by returning it) if next_state has been set - obj.update_wrapper = function() { - all_buttons = obj.get_all_buttons(); - if (next_state !== null) { - var to_return = next_state; - //in case we return to this state (CURRENTLY, SHOULDN'T EVER HAPPEN I THINK) - next_state = null; - return to_return; - } - //else - obj.update(); - obj.render_wrapper(); - }; - - // Wrapper for mouse clicks - // First checks if any of the buttons are clicked, then calls mouse_click - obj.mouse_click_wrapper = function(x, y) { - var click_function = function(b) { - var next_state = b.is_clicked(x, y); - if (next_state !== null) { - obj.set_next_state(next_state); - } - } - for_each(all_buttons, click_function); - obj.mouse_click(x, y); - }; - - obj.mouse_moved_wrapper = function(x, y) { - for_each( - all_buttons, - function(b) { - b.mouse_moved(x, y); - } - ); - obj.mouse_moved(x, y); - }; - - - // all game_states must implement the following functions: - - //Returns the type of the state - obj.get_type = function() { - return "get_type not overwritten"; - }; - - //Takes in the key pressed and handles a key press - obj.key_pressed = function(k) {throw "key_pressed not overwritten"}; - - // Do nothing unless overwritten - obj.mouse_moved = function(x, y) {}; - - //Updates the current state, and returns the next state to go to - //next state can be: - // null, if no state change - // a state representing a state to go to (either previous state or newly created next state - obj.update = function() {throw "update not overwritten"}; - - // Returns all of the buttons on the screen - obj.get_all_buttons = function() {throw "get_all_buttons not overwritten"}; - - // --- Optionally implement these, they default to nothing --- - - //Renders the current state - obj.render = function(){ }; //throw "render not overwritten"}; - - //Takes in the x and y coordinates of the mouse, and handles a mouse click - obj.mouse_click = function(x, y){}; //throw "mouse_click not overwritten"}; - - //Called when returning to this state - obj.resume = function() {}; - - - - return obj; -}; diff --git a/game/old/fb/generator.js b/game/old/fb/generator.js deleted file mode 100644 index acad075..0000000 --- a/game/old/fb/generator.js +++ /dev/null @@ -1,393 +0,0 @@ -// *** generator *** -// generates random enemies -// spec: -// game : an in_game_state -// Is going to access: (through getters since we're so safe) -// game_objects - array -// distance - a num -// type_to_level - hash from type to level -// active_cell -// mutation : a mutation obj, so it can get current mutation color - -var make_generator = function(p, spec) { - // --- defaults --- - - // obj to return - var obj = {}; - - // --- private variables --- - - //These will be updated at every call of update() - var game_objects = null; - var distance = null; - var mutation = spec.mutation; - var game = spec.game; - var last_obj = null; // The last object generated - - var default_gen_speed = 10; - // structure that stores the generation settings - // for each type of object - // - start = distance after which to start generating - // - num = how many total on screen - // - cap = upper limit on num - // - rate = determines when to increment num - // when dist % rate = 0, num increments - // - gen_speed = speed with which to generate the object - // 1 (1/100 frames) to 100 (100/100 frames) - // If not specified, defaults to DEFAULT_GEN_SPEED - // - spacing = diagonal space to put b/w objects of this type (optional) - // - gen_x = how far offscreen to gen this type (optional) - // - gen_y = function that returns random y pos for this object (optional) - // - make_new = function that takes a pos and returns a new enemy - // - diminish = Include to make enemy's num decrease over time instead of increasing (optional) - var gen_info = { - "cell": { - // was 8 - start: 0, num: 30, cap: 10, rate: 2000, gen_speed: 55, diminish : true, - spacing: 50, - make_new: function(en_pos) { - return cell(p, { - pos: en_pos, - state: "alive", - }); - } - }, - "wall_cell": { - start: 0, num: 3, cap: 7, rate: 3000, //non testing value: 1000 - spacing: "dynamic",//100, - make_new: function(en_pos) { - return wall_cell(p, { pos: en_pos }); - } - }, - "empty_cell": { - start: 5000, num: 1, cap: 10, rate: 5000, - make_new: function(en_pos) { - return empty_cell(p, { pos: en_pos }); - } - }, - "floater": { - start: 1000, num: 3, cap: 7, rate: 7000, - spacing: "dynamic",//100, - make_new: function(en_pos) { - return floater(p, { pos: en_pos }); - } - }, - /* - "tkiller": { - start: 1000, num: 1, cap: 5, rate: 20000, - make_new: function(en_pos) { - // target will get set later - return tkiller(p, { - pos: en_pos, - mutation_info: game.get_mutation_info() - }); - } - }, - */ - "multiplier": { - start:0, num: 10, cap: 20, rate: 20000, - make_new: function(en_pos) { - return multiplier(p, { pos : en_pos }); - } - }, - /* - "b_cell": { - start:0, num: 1, cap: 1, rate: 999999, - make_new: function(en_pos) { - return b_cell(p, { pos : en_pos }); - } - }, - */ - "background_object": { - start:0, num: 8, cap: 8, rate: 999999, - spacing: p.width/5, gen_x: 500, - gen_y: function() { - return p.random(200, p.height - 180); - }, - make_new: function(en_pos) { - return background_object(p, { pos: en_pos }); - } - }, - }; - - // list of types of enemies - var enemy_types = keys(gen_info); - /*var random_type = function() { - return random_from(enemy_types);//[p.floor(p.random( - //enemy_types.length))]; - }; - */ - - // just some wrappers - var start = function(type) { - return gen_info[type].start; - }; - var num = function(type) { - return gen_info[type].num; - }; - var cap = function(type) { - return gen_info[type].cap; - }; - var rate = function(type) { - return gen_info[type].rate; - }; - var spacing = function(type) { - // dynamic spacing - if(gen_info[type].spacing === "dynamic") { - return p.width/num(type); - } - return gen_info[type].spacing; - }; - var gen_x_pos = function(type) { - return p.width + (gen_info[type].gen_x || 50); - }; - var gen_y_pos = function(type) { - if (gen_info[type].gen_y) { - return gen_info[type].gen_y(); - } - return p.floor(p.random(90, p.height-50)); - }; - var gen_speed = function(type) { - return gen_info[type].gen_speed; - }; - var make_new = function(type) { - return gen_info[type].make_new; - }; - var diminish = function(type) { - return gen_info[type].diminish || false; - } - var gen_more = function(type) { - if (diminish(type)) { - if (num(type) > cap(type)) { - gen_info[type].num = num(type)-1; - } - } - else { - if (num(type) < cap(type)) { - gen_info[type].num = num(type)+1; - } - } - }; - - // Returns whether it is not too soon to generate another - // object, based on last_obj - var ok_to_generate = function() { - if (last_obj) { - if (last_obj.get_type() === "cell") { - // 2 times width spacing - return last_obj.get_pos().x < - (gen_x_pos(last_obj.get_type()) - last_obj.get_width() * 2); - } - } - // else - return true; - }; - - // --- public methods --- - - //Should be called every time the game updates - obj.update = function() { - //game_objects = game.get_game_objects(); - distance = p.floor(game.get_distance()); - - update_types(); - - var enemy_type = random_from(enemy_types);//random_type(); - var num_enemies = count_enemy(enemy_type); - - // if there aren't enough of that enemy on the board - if (num_enemies < num(enemy_type) - // and some random factor - && p.random(100) < (gen_speed(enemy_type) || default_gen_speed ) - // and we are ready to start making this enemy - && distance >= start(enemy_type)) { - //&& ok_to_generate()) { - - var enemy_y = gen_y_pos(enemy_type); - var enemy_pos = new p.PVector(gen_x_pos(enemy_type), enemy_y); - - var new_enemy = make_new(enemy_type)(enemy_pos); - assert(new_enemy, "Error in generator.update()"); - - // make sure it's far enough away from the last object - // of its type - if (!spaced_out_enough(new_enemy)) { - return; - } - - // make sure it's not overlapping anything else - if (is_overlapping(new_enemy) - && !new_enemy.is("background_object")) { - //console.log("overlapped"); - return; - } - - //Add the new enemy to game_objects - game.add_object(new_enemy); - - // If b cell, must update b cells targets - if (new_enemy.get_type() === "b_cell") { - console.log("made new b_cell"); - game.set_b_cell_target(new_enemy); - } - - last_obj = new_enemy; - } - - }; - - // --- private methods --- - - var update_types = function() { - /* - if (distance % 100 <= 0.5) { - console.log(distance); - } - */ - // update nums for types based on rate - for_each( - enemy_types, - function(type) { - if (distance % rate(type) <= 0.1 - && distance >= 10) { - gen_more(type); - console.log("increased num of "+type+ - "s to "+num(type)); - } - } - ); - }; - - // returns how many of given enemy there are - var count_enemy = function(enemy_type) { - var n = 0; - game.do_to_type(function(o) { n++; }, - enemy_type, true); - return n; - } - - // returns true if the enemy overlaps any game objects - var is_overlapping = function(enemy) { - var overlap = false; - var check_overlap = function(obj) { - if (game.check_circle_collision(enemy, obj)) { - overlap = true; - } - }; - game.do_to_type(check_overlap, "particle", false); - game.do_to_type(check_overlap, "cell", false); - game.do_to_type(check_overlap, "enemy", false); - game.do_to_type(check_overlap, "wall_segment", false); - return overlap; - }; - - // returns true if the new enemy if far enough away (in x coord) - // from the rightmost of its type - // or if there is no spacing requirement for that type - var spaced_out_enough = function(new_enemy) { - var to_return = true; - // if there is spacing defined for this type - if (spacing(new_enemy.get_type())) { - var min_dist = 99999; - // find the closest object of the type - game.do_to_type( - function(o) { - var dist = new_enemy.get_pos().dist(o.get_pos()); - if (dist < min_dist) { - min_dist = dist; - // check if it is too close - if (dist < spacing(new_enemy.get_type())) { - to_return = false; - } - } - }, - new_enemy.get_type(), true - ); - } - return to_return; - }; - - - - /* - // return true if it is far enough apart from rightmost of its type - return new_enemy.get_pos().dist( - rightmost(new_enemy.get_type()).get_pos()) - > spacing(new_enemy.get_type()); - } - return true; - }; - - /* - var rightmost = function(type) { - var rightmost_x = 0; - var rightmost; - game.do_to_type( - function(o) { - if (o.get_pos().x > rightmost_x) { - rightmost = o; - rightmost_x = o.get_pos().x; - } - }, - type, true - ); - return rightmost; - }; - */ - - // returns an object: - // cell: number of cells on the screen - // wall_cell: number of wall_cells - // empty_cell: number of empty_cells - // tkiller: number of tkillers - // floater: number of floaters - var get_enemies = (function() { - var total = 0; - - // These are the types to check - //var types = ["cell", "wall_cell", "empty_cell", - // "floater", "tkiller"]; - - //Checks if an element is in an array - var member = function(arr, elem) { - return (arr.indexOf(elem) != -1); - }; - - var get_em = function() { - var enemies = { "cell":0, "wall_cell":0, - "empty_cell":0, "floater":0, "tkiller":0, - "multiplier":0, "b_cell":0}; - - // increment counter for each object - var incr = function(o) { - enemies[o.get_type()] += 1; - }; - game.do_to_type(incr, "cell", false); - game.do_to_type(incr, "enemy", false); - }; - /*for (var type in enemies) { - if (enemies.hasOwnProperty(type)) { - game.do_to_type( - function(o) { - enemies[type] += 1; - }, - type, true); - } - } - /*for (var i = 0; i < game_objects.length; i++) { - var lst = game_objects[i]; - for (var j = 0; j < lst.length; j++) { - var obj = lst[j]; - if (member(types, obj.get_type())) { - total++; - } - } - } - return total; - */ - - return get_em; - }()); - - return obj; -}; diff --git a/game/old/fb/global_functions.js b/game/old/fb/global_functions.js deleted file mode 100644 index d6c3167..0000000 --- a/game/old/fb/global_functions.js +++ /dev/null @@ -1,90 +0,0 @@ -// ** Global Constants -//DEFAULT_SCROLL_DIST = -0.8; - -// *** global_functions *** -// Holds functions used in the whole project - -//Have to catch it so fuck it -/* -function AssertException(message) { this.message = message}; -function assert(exp, message) { - if (!exp) { - throw new AssertException(message); - } -} -*/ - -var assert = function(exp, message) { - if (!exp) { - console.error("Assert error!: " + message); - } -}; - -//Does something to every element of an arr -var for_each = function(arr, fun) { - for (var i = 0; i < arr.length; i++) { - fun(arr[i]); - } -}; - -// returns the index+1 of an element in a list, -// otherwise false -// can't return just the index because 0 is false in js -var member = function(arr, elt) { - for (var i=0; i 1 ? '.' + x[1] : ''; - var rgx = /(\d+)(\d{3})/; - while (rgx.test(x1)) { - x1 = x1.replace(rgx, '$1' + ',' + '$2'); - } - return prefix + x1 + x2; -}; - diff --git a/game/old/fb/help.txt b/game/old/fb/help.txt deleted file mode 100644 index 7bdf35b..0000000 --- a/game/old/fb/help.txt +++ /dev/null @@ -1,9 +0,0 @@ -You've managed to infiltrate the human body's defenses and get your virus particle into the bloodstream! Now you must infect cells and use them to make more copies of your virus before the immune system wipes you out. - -After a particle infects a cell, the virus will use the cell's machinery to start making copies of itself. Once the cell is full of new virus particles, press the SPACEBAR or click the MOUSE to kill the cell, causing virus particles to burst through the cell wall towards other cells in the direction the arrow is pointing. You can pick which cell to burst using the LEFT and RIGHT arrow keys. - -Aim carefully though, because the immune system has sent out macrophages to absorb your particles. If a particle hits a macrophage, it will signal a B-cell, which will start producing antibodies. If an antibody attaches to an infected cell, a T-cell will attack it. If you don't burst the cell in time, the T-cell will kill it, destroying all the particles inside! - -Luckily, your virus can mutate and temporarily escape the immune system. Every time the virus replicates, there are errors when copying the virus's genetic material. These errors may cause mutations in the virus. Each time you infect a cell, the virus becomes more and more likely to mutate. Once you mutate, the immune system will not be able to attack you until a macrophage absorbs a virus particle from the new strain. - -How long will your virus be able to survive? diff --git a/game/old/fb/help_state.js b/game/old/fb/help_state.js deleted file mode 100644 index e848712..0000000 --- a/game/old/fb/help_state.js +++ /dev/null @@ -1,627 +0,0 @@ -var help_state = function (p, prev_state) { - - var help_image = image_manager.get_image("helpsplash.png"); - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var screens = []; - var screen_w = help_image.width - 180; - var screen_h = help_image.height - 200; - var screen_pos = new p.PVector(p.width/2, p.height/2-15); - - var screen_index = 0; - var cur_screen = function() { - return screens[screen_index]; - }; - var next_screen = function() { - if (screen_index <= screens.length-1) { - screen_index += 1; - if (screen_index === screens.length-1) { - next_button.deactivate(); - } - previous_button.activate(); - return true; - } - return false; - }; - var previous_screen = function() { - if (screen_index >= 0) { - screen_index -= 1; - if (screen_index === 0) { - previous_button.deactivate(); - } - next_button.activate(); - return true; - } - return false; - }; - - // a screen is a panel that goes in the screens array - // it displays one or more item - // spec: - // - pos: PVector representing the center of the screen - // - width - // - height - var screen = function(spec) { - var obj = {}; - var items = []; - obj.add_item = function(item) { - items.push(item); - }; - - obj.render = function() { - p.pushMatrix(); - - p.translate(spec.pos.x-spec.width/2, spec.pos.y-spec.height/2); - - // debugging - /* - p.noFill(); - p.stroke(255); - p.rect(0, 0, spec.width, spec.height); - */ - - // translate and render each item - var padding = 15; - for_each( - items, - function(item) { - item.render(); - p.translate(0, item.height()+padding); - } - ); - - p.popMatrix(); - }; - - return obj; - }; - - var new_screen = function() { - return screen({ - pos: screen_pos, - width: screen_w, - height: screen_h - }); - }; - - // item displays text and an image as part of a screen - // spec: - // - width - // - height - // - text - the text to display - // - title - the name of this item (optional) - // - image - image to display - // - illustration (obj) - // - width, height - dimensions for the illustration - // - draw - function that draws some illustration - // (origin at top left corner) - // - img_left - boolean, true if the image/ill should go on the left, - // false for the right - // (should only have image or illustration) - // - var item = function(spec) { - var obj = {}; - - // auto height - spec.height = spec.height - // the 0 here just takes us to the next cond - || (spec.image ? spec.image.height : 0) - // the actual default is at the end of this - || (spec.illustration ? spec.illustration.height : 80); - spec.width = spec.width || screen_w; - spec.padding = spec.padding || 10; - - obj.height = function() { return spec.height; }; - - obj.render = function() { - var text_x = 0; - var text_y = 0; - var text_w = spec.width; - - if (spec.image || spec.illustration) { - // make adjustments based on either one - var i = spec.image || spec.illustration; - text_w -= i.width + spec.padding; - var img_x = spec.width - i.width; - if (spec.img_left) { - img_x = 0; - text_x = i.width + spec.padding; - } - // draw either - if (spec.image) { - p.imageMode(p.CORNER); - p.image(spec.image, img_x, 0); - } - else { - p.pushMatrix(); - p.translate(img_x, 0); - spec.illustration.draw(); - p.popMatrix(); - } - } - - if (spec.title) { - p.textSize(18); - p.textAlign(p.LEFT, p.TOP); - p.fill(255); - p.text(spec.title, text_x, 0); - text_y += p.textAscent(); - } - p.textSize(14); - p.textAlign(p.LEFT, p.TOP); - p.fill(255); - p.text(spec.text, text_x, text_y, text_w, spec.height-text_y); - }; - - return obj; - }; - - // init the help screens - // eval'd immediately - var init_screens = (function() { - var color1 = 0xffffff00; - var color2 = 0xff7f2aff; - var cimg = image_manager.get_image("infectable_cell_2n.png"); - - var s1 = new_screen(); - screens.push(s1); - s1.add_item(item({ - text: "You've infiltrated the human body's defenses and gotten your virus particle (or virion) into the bloodstream! Here are the cells you may encounter:", - height: 45, - padding: 1, - illustration: { - width: 30, height: 30, - draw: function() { - var img = image_manager.get_image("tinyvirus_trans.png"); - var w = 15; - var h = 15; - p.fill(color1); - p.noStroke(); - p.ellipse(w, h, w*.75, h*.75); - p.imageMode(p.CENTER); - p.image(img, w, h, w, h); - } - }, - img_left: false - })); - s1.add_item(item({ - title: "Infectable Cells", - text: "Hit an infectable cell with a virion to infect it. After penetrating the cell wall, the virion will use the cell's machinery to make copies of itself.", - //image: cimg, - illustration: { - width: 50, height: 60, - draw: (function() { - var c = cell(p, { - pos: new p.PVector(30, 30), - width: 30, height: 30, - illustration: true - }); - c.set_image(cimg); - //c.set_state("active"); - return function() { - c.draw(); - }; - }()), - }, - img_left: true - })); - s1.add_item(item({ - text: "Press SPACEBAR or click the MOUSE to burst an infected cell and shoot the new virions in the direction of the arrow. Pick which cell to burst using the LEFT and RIGHT arrow keys.", - //image: image_manager.get_image("infectable_cell_2n.png"), - illustration: { - width: 30, height: 60, - draw: (function() { - var c = cell(p, { - pos: new p.PVector(20, 30), - width: 30, height: 30, - mutation_info: { color: color1 }, - illustration: true - }); - c.set_image(cimg); - c.set_state("active"); - return function() { - c.draw(); - }; - }()), - }, - img_left: false - })); - s1.add_item(item({ - title: "Tolerant Cells", - text: "Some cells can be infected, but will not let your virion replicate. A virion that infects a tolerant cell is as good as dead.", - illustration: { - width: 50, height: 60, - draw: (function() { - var c = empty_cell(p, { - pos: new p.PVector(30, 30), - width: 30, height: 30, - }); - return function() { - c.draw(); - }; - }()), - }, - img_left: true - })); - s1.add_item(item({ - title: "Resistant Cells", - text: "Virions can't break through the cell wall of resistant cells - they will just bounce off in the other direction.", - height: 60, - illustration: { - width: 30, height: 60, - draw: (function() { - var c = wall_cell(p, { - pos: new p.PVector(20, 30), - //width: 30, height: 30, - }); - return function() { - c.draw(); - }; - }()), - }, - img_left: false - })); - - var s2 = new_screen(); - screens.push(s2); - s2.add_item(item({ - text: "Be careful! The immune system will try to destroy your virus. Here are the enemies you should look out for:", - height: 30 - })); - s2.add_item(item({ - title: "Macrophages", - text: "The immune system's first line of defense. They will absorb any virion that hits them and then signal a B cell to give it information about your virus.", - height: 80, - //image: image_manager.get_image("macrophage_1.png"), - illustration: { - width: 50, height: 70, - draw: (function() { - var m = floater(p, { - pos: new p.PVector(25, 35), - width: 50, height: 70, - mutation_info: { color: color1 }, - illustration: true - }); - m.activate(); - return function() { - m.draw(); - }; - }()) - }, - img_left: true - })); - s2.add_item(item({ - title: "B Cells", - text: "Once a B cell knows about your virus, it will produce Y-shaped antibodies that will attach to infected cells, marking them for destruction.", - height: 70, - //image: image_manager.get_image("bcell_normal.png"), - illustration: { - width: 60, height: 60, - draw: (function() { - var b = b_cell(p, { - pos: new p.PVector(30, 55), - width: 40, height: 40, - mutation_info: { color: color1 }, - illustration: true - }); - b.set_state("active"); - b.set_target_angle(-p.PI/2); - - var a1 = antibody(p, { - pos: new p.PVector(40, 17), - mutation_info: { color: color1 }, - }); - a1.set_target_angle(-p.PI/4); - - var a2 = antibody(p, { - pos: new p.PVector(18, 23), - mutation_info: { color: color1 }, - }); - a2.set_target_angle(-3*p.PI/4+.2); - - return function() { - // make a thicker antibody - b.set_anti_count(10); - b.draw(); - a1.draw(); - a2.draw(); - }; - }()) - }, - img_left: false - })); - s2.add_item(item({ - title: "Killer T Cells", - text: "If an infected cell is marked with an antibody, the killer T cell will hunt it down and destroy it, along with all the virions inside!", - //image: image_manager.get_image("tcell_2.png"), - illustration: { - width: 60, height: 60, - draw: (function() { - var tk = tkiller(p, { - pos: new p.PVector(30, 30), - width: 60, height: 60, - mutation_info: { color: color1 }, - illustration: true - }); - //tk.set_state("alive"); - - return function() { - tk.draw(); - }; - }()) - }, - img_left: true - })); - - var s3 = new_screen(); - screens.push(s3); - s3.add_item(item({ - title: "Mutation", - text: "Luckily, in the process of replicating a virus's genetic material, mistakes are often made, causing the virus to mutate! If a mutation occurs, a new strain of the virus will be created. Every time you infect a cell, the chance of a mutation occurring increases.", - height: 120, - padding: 15, - illustration: { - width: 90, height: 90, - draw: (function() { - var c1 = cell(p, { - pos: new p.PVector(10, 20), - width: 30, height: 30, - mutation_info: { color: color1 }, - illustration: true - }); - c1.set_image(cimg); - c1.set_state("infected"); - - var c2 = cell(p, { - pos: new p.PVector(70, 80), - width: 30, height: 30, - mutation_info: { color: color2 }, - illustration: true - }); - c2.set_image(cimg); - c2.set_state("infected"); - - return function() { - c1.draw(); - c2.draw(); - p.stroke(255); - p.strokeWeight(3); - p.line(30, 40, 50, 60); - p.line(50, 60, 50, 50); - p.line(50, 60, 40, 60); - }; - }()), - }, - img_left: false - })); - s3.add_item(item({ - text: "Macrophages, B cells, T cells, and antibodies are created to attack a specific strain of a virus. So when your virus mutates, the new strain will be safe from the old enemies.", - //image: image_manager.get_image("macrophage_1.png"), - padding: 15, - illustration: { - width: 60, height: 60, - draw: (function() { - var tk = tkiller(p, { - pos: new p.PVector(50, 10), - mutation_info: { color: color1 }, - illustration: true - }); - tk.set_target_angle(-p.PI/4); - //tk.set_state("illustration"); - - var c = cell(p, { - pos: new p.PVector(10, 40), - width: 30, height: 30, - mutation_info: { color: color2 }, - illustration: true - }); - c.set_image(cimg); - c.set_state("infected"); - - var a = antibody(p, { - pos: new p.PVector(20, 15), - mutation_info: { color: color2 } - }); - a.set_target(c); - a.update(); - - return function() { - tk.draw(); - c.draw(); - a.draw(); - }; - }()), - }, - img_left: true - })); - s3.add_item(item({ - text: "Each new strain will be represented by a different color. Therefore, an infected cell can only be attacked by enemies of the same color.", - //image: image_manager.get_image("tcell_2.png"), - //padding: 15, - illustration: { - width: 60, height: 50, - draw: (function() { - var tk = tkiller(p, { - pos: new p.PVector(50, 12), - mutation_info: { color: color2 }, - illustration: true - }); - //tk.set_target_angle(p.PI/4); - //tk.set_state("illustration"); - - var c = cell(p, { - pos: new p.PVector(15, 40), - width: 30, height: 30, - mutation_info: { color: color2 }, - illustration: true - }); - c.set_image(cimg); - c.set_state("infected"); - - tk.set_target(c); - tk.update(); - - var a = antibody(p, { - pos: new p.PVector(5, 15), - mutation_info: { color: color2 } - }); - a.set_target(c); - a.update(); - - return function() { - tk.draw(); - c.draw(); - a.draw(); - }; - }()), - }, - img_left: false - })); - s3.add_item(item({ - title: "Multiplier Particles", - text: "Higher mutation levels will give you more points, as will collecting multiplier particles. When you infect a cell, the amount of points you get is multiplied by your multiplier and level.", - illustration: { - width: 50, height: 90, - draw: (function() { - var poss = [ - new p.PVector(10, 10), - new p.PVector(27, 25), - new p.PVector(20, 45), - new p.PVector(35, 50), - //new p.PVector(23, 30), - new p.PVector(40, 12) - ]; - var ms = []; - for_each(poss, - function(pos) { - ms.push(multiplier(p, { pos: pos })); - } - ); - - return function() { - for_each(ms, function(m) { m.draw(); }); - }; - }()), - }, - img_left: true - })); - - - }()); - - - /* - var box_w = 370; - var box_h = 500; - var box_x = p.width/2 - box_w/2; - var box_y = p.height/2 - box_h/2; - */ - - // Buttons - var button_y = p.height/2 + 190; - var button_style = { - width: 120, - height: 50, - }; - - var back_button = button(p, { - state : function() { sounds.play_button_back(); return prev_state; }, - rect : { - pos : new p.PVector(p.width/2, button_y), //box_x+box_w-80, box_y+box_h-30), - //text: "Back", - //text_x_offset: 5, - //text_y_offset: -8, - image: "back.png", - } - }); - - var next_button = button(p, { - state: function() { - sounds.play_button_click(); - next_screen(); - return obj; - }, - rect: { - pos: new p.PVector(p.width/2+120, button_y), - //text: "Next", - image: "next.png", - //style: button_style - } - }); - - var previous_button = button(p, { - state: function() { - sounds.play_button_back(); - previous_screen(); - return obj; - }, - rect: { - pos: new p.PVector(p.width/2-120, button_y), - //text: "Previous", - image: "previous.png", - //style: button_style - } - }); - previous_button.deactivate(); - - //Not ordered - var all_buttons = [ previous_button, back_button, next_button ]; - - var instruction_text = "You've managed to infiltrate the human body's defenses and get your virus particle into the bloodstream! Now you must infect cells and use them to make more copies of your virus before the immune system wipes you out.\n\nAfter a particle infects a cell, the virus will use the cell's machinery to start making copies of itself. Once the cell is full of new virus particles, press the SPACEBAR or click the MOUSE to kill the cell, causing virus particles to burst through the cell wall towards other cells in the direction the arrow is pointing. You can pick which cell to burst using the LEFT and RIGHT arrow keys.\n\nAim carefully though, because the immune system has sent out macrophages to absorb your particles. If a particle hits a macrophage, it will signal a B-cell, which will start producing antibodies. If an antibody attaches to an infected cell, a T-cell will attack it. If you don't burst the cell in time, the T-cell will kill it, destroying all the particles inside!\n\nLuckily, your virus can mutate and temporarily escape the immune system. Every time the virus replicates, there are errors when copying the virus's genetic material. These errors may cause mutations in the virus. Each time you infect a cell, the virus becomes more and more likely to mutate. Once you mutate, the immune system will not be able to attack you until a macrophage absorbs a virus particle from the new strain."; - - // --- public methods --- - - obj.get_type = function() { - return "help"; - }; - - obj.update = function() { - //do nothing - }; - - - obj.render = function() { - //p.pushMatrix(); - - p.imageMode(p.CENTER); - p.image(help_image, p.width/2, p.height/2); - - cur_screen().render(); - - //p.translate(box_x, box_y); - - //p.fill(0); - //p.rect(0, 0, box_w, box_h); - - //p.noStroke(); - //p.fill(255); - - //p.textAlign(p.CENTER, p.CENTER); - //p.textSize(24); - //p.text("Instructions", box_w/2, 30); - - //p.textAlign(p.LEFT, p.CENTER); - //p.textSize(13); - //p.text(instruction_text, - //5, 20, box_w, box_h-50); - - //p.popMatrix(); - }; - - obj.key_pressed = function(k) { - if (k === 104) { //h - obj.set_next_state(help_button.get_state()); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/game/old/fb/high_scores_state.js b/game/old/fb/high_scores_state.js deleted file mode 100644 index 4f3583f..0000000 --- a/game/old/fb/high_scores_state.js +++ /dev/null @@ -1,83 +0,0 @@ -var high_scores_state = function (p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - // Buttons - - var button_style = { - text_size: 14, - text_align: p.LEFT, - text_x_offset: 25, - width: 120, - height: 50, - }; - - var back_button = button(p, { - state : function() { - sounds.play_button_back(); - - // hide the div - $("#scores-wrap").hide(); - $("#scores").tabs("destroy"); - return prev_state;//splash_state(p); - }, - rect : { - pos : new p.PVector(540, 550), - //text: "Main Menu", - //text_x_offset: -5, - image: "back.png", - //image_x_offset: -5, - //style: button_style - } - }); - - //Not ordered - var all_buttons = [ back_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "high_scores"; - }; - - obj.update = function() { - }; - - obj.render = function() { - p.noStroke(); - p.fill(0, 150); - p.rect(0, 0, p.width, p.height); - }; - - obj.key_pressed = function(k) { - /* - if (k === 112 || p.keyCode == 13) { //p, enter - obj.exit_state(); - } - */ - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - // init the scores immediately - var init = (function() { - // add a loading message to be removed on load - $("#scores-wrap").prepend( - "
        Loading high score data...
        " - ); - - // show the div - $("#scores-wrap").show(); - // update and render scores - // TODO what if it fails? - scores.do_scores(); - }()); - - return obj; -}; diff --git a/game/old/fb/image_manager.js b/game/old/fb/image_manager.js deleted file mode 100644 index 0b7192e..0000000 --- a/game/old/fb/image_manager.js +++ /dev/null @@ -1,171 +0,0 @@ -// image_manager preloads and holds all the images used in the game - -var make_image_manager = function() { - - // obj to return - var obj = []; - - // --- private variables --- - - // this will be counted in preloading - var num_images = 0; - - // object to hold all arrays of image paths - // and the dir name that they come from - // dir should be name after "images/" and must end in '/' - var all_images = { - infectable_cell : { dir : "infectable_cell/" }, - empty_cell : { dir : "noninfectable_cell/" }, - background : { dir : "background_objects/" }, - screens : { dir : "screens/" }, - wall_segments : { dir : "wall_segments/" }, - macrophage : {dir : "macrophage_animation/"}, - macrophage_active : {dir : "holemacrophage_animation/"}, - bcell : {dir : "b_animation/"}, - burst : { dir : "burstingcell_animation/"}, - cell_infect : { dir : "cellinfect_animation/"}, - t_animation : { dir : "t_animation/"}, - buttons : { dir : "buttons/"}, - // catches all images in images/ - other : { dir : "" }, - }; - - // add "arr" property to each image - for_each( - keys(all_images), - function(key) { - all_images[key].images = []; - } - ); - - // filter out non-images from global image file list - var image_types = ["png", "jpg", "gif"]; - for_each( - keys(all_image_files), - function(key) { - all_image_files[key] = all_image_files[key].filter( - function(name) { - return member(image_types, - name.substring(name.lastIndexOf('.')+1)); - } - ); - } - ); - - // --- public methods --- - - // returns all the image objects of a given type - // if preloading and initing is done - // NOTE: returns a copy of the array of pointers, but the pointers - // will all point to the same objects so don't change the objects - obj.get_images = function(type) { - if (!all_images[type]) { - console.error("Invalid image type: "+type); - } - //for_each(all_images[type], console.log() - return all_images[type].images.slice(); - }; - - // finds and returns the first image with the given name - // (no path necessary) - obj.get_image = function(name) { - var to_return; - for_each( - keys(all_images), - function(key) { - for_each( - all_images[key].images, - function(img_obj) { - if (name === img_obj.path.substring( - img_obj.path.lastIndexOf('/')+1)) { - to_return = img_obj.image; - } - } - ); - } - ); - if (!to_return) { - console.error("Invalid image name: "+name); - } - return to_return; - }; - - // preloads all the images - obj.preload_images = function() { - console.log("preloading images"); - for_each_image( - function(path) { - // let processing load it in the cache - sketch.imageCache.add(path); - // count it - num_images += 1; - console.log("loading "+path); - } - ); - }; - - // DO NOT CALL BEFORE CALLING PRELOAD - obj.num_loaded = function() { - return num_images - sketch.imageCache.pending; - }; - - // DO NOT CALL BEFORE CALLING PRELOAD - obj.num_images = function() { - return num_images; - }; - - // DO NOT CALL BEFORE CALLING PRELOAD - obj.is_done_preloading = function() { - return !sketch.imageCache.pending; - }; - - // DO NOT CALL BEFORE PRELOADING IS DONE - // should be called after preloading is done - // to make the image objects - // note: must be passed a processing instance p - obj.init_images = function(p) { - console.log("initing images"); - for_each_image( - function(img_path, type) { - // make an actual image object for each preloaded image - all_images[type].images.push({ - path: img_path, - image: p.loadImage(img_path), - }); - } - ); - }; - - // --- private methods --- - - // gets array of paths from the object populated by the php function - var files_in_dir = function(dir_path) { - if (!all_image_files[dir_path]) { - console.error("Invalid dir: "+dir_path); - } - return all_image_files[dir_path]; - }; - - // applies f to each image path - // f takes a path and an image type (key) - var for_each_image = function(f) { - // for each type of image - for_each( - keys(all_images), - function(key) { - // for each image in the dir - for_each( - files_in_dir("images/"+all_images[key].dir), - function(path) { - f(path, key); - } - ); - } - ); - }; - - return obj; -}; - -// make a global instance -var image_manager = make_image_manager(); diff --git a/game/old/fb/images/b_animation/bcell_a01.png b/game/old/fb/images/b_animation/bcell_a01.png deleted file mode 100644 index a11fd65..0000000 Binary files a/game/old/fb/images/b_animation/bcell_a01.png and /dev/null differ diff --git a/game/old/fb/images/b_animation/bcell_a02.png b/game/old/fb/images/b_animation/bcell_a02.png deleted file mode 100644 index 2cdf59d..0000000 Binary files a/game/old/fb/images/b_animation/bcell_a02.png and /dev/null differ diff --git a/game/old/fb/images/b_animation/bcell_a03.png b/game/old/fb/images/b_animation/bcell_a03.png deleted file mode 100644 index 0751bbe..0000000 Binary files a/game/old/fb/images/b_animation/bcell_a03.png and /dev/null differ diff --git a/game/old/fb/images/b_animation/bcell_a04.png b/game/old/fb/images/b_animation/bcell_a04.png deleted file mode 100644 index e1ff517..0000000 Binary files a/game/old/fb/images/b_animation/bcell_a04.png and /dev/null differ diff --git a/game/old/fb/images/b_animation/bcell_a05.png b/game/old/fb/images/b_animation/bcell_a05.png deleted file mode 100644 index d95d849..0000000 Binary files a/game/old/fb/images/b_animation/bcell_a05.png and /dev/null differ diff --git a/game/old/fb/images/b_animation/bcell_a06.png b/game/old/fb/images/b_animation/bcell_a06.png deleted file mode 100644 index 4d11066..0000000 Binary files a/game/old/fb/images/b_animation/bcell_a06.png and /dev/null differ diff --git a/game/old/fb/images/b_animation/bcell_a07.png b/game/old/fb/images/b_animation/bcell_a07.png deleted file mode 100644 index 1f2efb1..0000000 Binary files a/game/old/fb/images/b_animation/bcell_a07.png and /dev/null differ diff --git a/game/old/fb/images/background1.png b/game/old/fb/images/background1.png deleted file mode 100644 index 0232c24..0000000 Binary files a/game/old/fb/images/background1.png and /dev/null differ diff --git a/game/old/fb/images/background_bottomside.png b/game/old/fb/images/background_bottomside.png deleted file mode 100644 index 039dd50..0000000 Binary files a/game/old/fb/images/background_bottomside.png and /dev/null differ diff --git a/game/old/fb/images/background_objects/.DS_Store b/game/old/fb/images/background_objects/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/old/fb/images/background_objects/.DS_Store and /dev/null differ diff --git a/game/old/fb/images/background_objects/background_bcells1.png b/game/old/fb/images/background_objects/background_bcells1.png deleted file mode 100644 index 6de753b..0000000 Binary files a/game/old/fb/images/background_objects/background_bcells1.png and /dev/null differ diff --git a/game/old/fb/images/background_objects/background_bcells2.png b/game/old/fb/images/background_objects/background_bcells2.png deleted file mode 100644 index 3a523d9..0000000 Binary files a/game/old/fb/images/background_objects/background_bcells2.png and /dev/null differ diff --git a/game/old/fb/images/background_objects/background_bcells3.png b/game/old/fb/images/background_objects/background_bcells3.png deleted file mode 100644 index ef718b9..0000000 Binary files a/game/old/fb/images/background_objects/background_bcells3.png and /dev/null differ diff --git a/game/old/fb/images/background_objects/background_bcells4.png b/game/old/fb/images/background_objects/background_bcells4.png deleted file mode 100644 index 6295cbd..0000000 Binary files a/game/old/fb/images/background_objects/background_bcells4.png and /dev/null differ diff --git a/game/old/fb/images/background_objects/background_dstreaks1.png b/game/old/fb/images/background_objects/background_dstreaks1.png deleted file mode 100644 index 825f60f..0000000 Binary files a/game/old/fb/images/background_objects/background_dstreaks1.png and /dev/null differ diff --git a/game/old/fb/images/background_objects/background_dstreaks2.png b/game/old/fb/images/background_objects/background_dstreaks2.png deleted file mode 100644 index a6f0582..0000000 Binary files a/game/old/fb/images/background_objects/background_dstreaks2.png and /dev/null differ diff --git a/game/old/fb/images/background_objects/background_dstreaks3.png b/game/old/fb/images/background_objects/background_dstreaks3.png deleted file mode 100644 index c65a2f8..0000000 Binary files a/game/old/fb/images/background_objects/background_dstreaks3.png and /dev/null differ diff --git a/game/old/fb/images/background_objects/background_lstreaks1.png b/game/old/fb/images/background_objects/background_lstreaks1.png deleted file mode 100644 index 74595f5..0000000 Binary files a/game/old/fb/images/background_objects/background_lstreaks1.png and /dev/null differ diff --git a/game/old/fb/images/background_objects/background_lstreaks2.png b/game/old/fb/images/background_objects/background_lstreaks2.png deleted file mode 100644 index 62d1f4e..0000000 Binary files a/game/old/fb/images/background_objects/background_lstreaks2.png and /dev/null differ diff --git a/game/old/fb/images/background_topside.png b/game/old/fb/images/background_topside.png deleted file mode 100644 index 613f9ac..0000000 Binary files a/game/old/fb/images/background_topside.png and /dev/null differ diff --git a/game/old/fb/images/bcell_normal.png b/game/old/fb/images/bcell_normal.png deleted file mode 100644 index 60b8545..0000000 Binary files a/game/old/fb/images/bcell_normal.png and /dev/null differ diff --git a/game/old/fb/images/bullet_listcell.png b/game/old/fb/images/bullet_listcell.png deleted file mode 100644 index b778d5c..0000000 Binary files a/game/old/fb/images/bullet_listcell.png and /dev/null differ diff --git a/game/old/fb/images/burstingcell_animation/burst_a01.png b/game/old/fb/images/burstingcell_animation/burst_a01.png deleted file mode 100644 index 464828e..0000000 Binary files a/game/old/fb/images/burstingcell_animation/burst_a01.png and /dev/null differ diff --git a/game/old/fb/images/burstingcell_animation/burst_a02.png b/game/old/fb/images/burstingcell_animation/burst_a02.png deleted file mode 100644 index 87f6492..0000000 Binary files a/game/old/fb/images/burstingcell_animation/burst_a02.png and /dev/null differ diff --git a/game/old/fb/images/burstingcell_animation/burst_a03.png b/game/old/fb/images/burstingcell_animation/burst_a03.png deleted file mode 100644 index bb6d224..0000000 Binary files a/game/old/fb/images/burstingcell_animation/burst_a03.png and /dev/null differ diff --git a/game/old/fb/images/burstingcell_animation/burst_a04.png b/game/old/fb/images/burstingcell_animation/burst_a04.png deleted file mode 100644 index 174dd4a..0000000 Binary files a/game/old/fb/images/burstingcell_animation/burst_a04.png and /dev/null differ diff --git a/game/old/fb/images/burstingcell_animation/burst_a05.png b/game/old/fb/images/burstingcell_animation/burst_a05.png deleted file mode 100644 index 50fa69f..0000000 Binary files a/game/old/fb/images/burstingcell_animation/burst_a05.png and /dev/null differ diff --git a/game/old/fb/images/burstingcell_animation/burst_a06.png b/game/old/fb/images/burstingcell_animation/burst_a06.png deleted file mode 100644 index 414accb..0000000 Binary files a/game/old/fb/images/burstingcell_animation/burst_a06.png and /dev/null differ diff --git a/game/old/fb/images/burstingcell_animation/burst_a07.png b/game/old/fb/images/burstingcell_animation/burst_a07.png deleted file mode 100644 index 0aa533b..0000000 Binary files a/game/old/fb/images/burstingcell_animation/burst_a07.png and /dev/null differ diff --git a/game/old/fb/images/burstingcell_animation/burst_a08.png b/game/old/fb/images/burstingcell_animation/burst_a08.png deleted file mode 100644 index 735a858..0000000 Binary files a/game/old/fb/images/burstingcell_animation/burst_a08.png and /dev/null differ diff --git a/game/old/fb/images/burstingcell_animation/burst_a09.png b/game/old/fb/images/burstingcell_animation/burst_a09.png deleted file mode 100644 index 74f67d9..0000000 Binary files a/game/old/fb/images/burstingcell_animation/burst_a09.png and /dev/null differ diff --git a/game/old/fb/images/burstingcell_animation/burst_a10.png b/game/old/fb/images/burstingcell_animation/burst_a10.png deleted file mode 100644 index 5182129..0000000 Binary files a/game/old/fb/images/burstingcell_animation/burst_a10.png and /dev/null differ diff --git a/game/old/fb/images/burstingcell_animation/burst_a11.png b/game/old/fb/images/burstingcell_animation/burst_a11.png deleted file mode 100644 index cb79f9a..0000000 Binary files a/game/old/fb/images/burstingcell_animation/burst_a11.png and /dev/null differ diff --git a/game/old/fb/images/burstingcell_animation/burst_a12.png b/game/old/fb/images/burstingcell_animation/burst_a12.png deleted file mode 100644 index 7a75730..0000000 Binary files a/game/old/fb/images/burstingcell_animation/burst_a12.png and /dev/null differ diff --git a/game/old/fb/images/burstingcell_animation/burst_a13.png b/game/old/fb/images/burstingcell_animation/burst_a13.png deleted file mode 100644 index d1054f6..0000000 Binary files a/game/old/fb/images/burstingcell_animation/burst_a13.png and /dev/null differ diff --git a/game/old/fb/images/buttons/back.png b/game/old/fb/images/buttons/back.png deleted file mode 100644 index a6e28a9..0000000 Binary files a/game/old/fb/images/buttons/back.png and /dev/null differ diff --git a/game/old/fb/images/buttons/check0.png b/game/old/fb/images/buttons/check0.png deleted file mode 100644 index 993c88a..0000000 Binary files a/game/old/fb/images/buttons/check0.png and /dev/null differ diff --git a/game/old/fb/images/buttons/check1.png b/game/old/fb/images/buttons/check1.png deleted file mode 100644 index 0207b44..0000000 Binary files a/game/old/fb/images/buttons/check1.png and /dev/null differ diff --git a/game/old/fb/images/buttons/continue.png b/game/old/fb/images/buttons/continue.png deleted file mode 100644 index f5f4bed..0000000 Binary files a/game/old/fb/images/buttons/continue.png and /dev/null differ diff --git a/game/old/fb/images/buttons/credits.png b/game/old/fb/images/buttons/credits.png deleted file mode 100644 index 567677e..0000000 Binary files a/game/old/fb/images/buttons/credits.png and /dev/null differ diff --git a/game/old/fb/images/buttons/highscores.png b/game/old/fb/images/buttons/highscores.png deleted file mode 100644 index e59ce26..0000000 Binary files a/game/old/fb/images/buttons/highscores.png and /dev/null differ diff --git a/game/old/fb/images/buttons/infectfriends.png b/game/old/fb/images/buttons/infectfriends.png deleted file mode 100644 index 6bd07d4..0000000 Binary files a/game/old/fb/images/buttons/infectfriends.png and /dev/null differ diff --git a/game/old/fb/images/buttons/instructions.png b/game/old/fb/images/buttons/instructions.png deleted file mode 100644 index ab6ee9b..0000000 Binary files a/game/old/fb/images/buttons/instructions.png and /dev/null differ diff --git a/game/old/fb/images/buttons/mainmenu.png b/game/old/fb/images/buttons/mainmenu.png deleted file mode 100644 index 3778426..0000000 Binary files a/game/old/fb/images/buttons/mainmenu.png and /dev/null differ diff --git a/game/old/fb/images/buttons/mhighscores.png b/game/old/fb/images/buttons/mhighscores.png deleted file mode 100644 index cbbb52a..0000000 Binary files a/game/old/fb/images/buttons/mhighscores.png and /dev/null differ diff --git a/game/old/fb/images/buttons/mhighscores_r.png b/game/old/fb/images/buttons/mhighscores_r.png deleted file mode 100644 index 9a2d36f..0000000 Binary files a/game/old/fb/images/buttons/mhighscores_r.png and /dev/null differ diff --git a/game/old/fb/images/buttons/mhowtoplay.png b/game/old/fb/images/buttons/mhowtoplay.png deleted file mode 100644 index d125cde..0000000 Binary files a/game/old/fb/images/buttons/mhowtoplay.png and /dev/null differ diff --git a/game/old/fb/images/buttons/mhowtoplay_r.png b/game/old/fb/images/buttons/mhowtoplay_r.png deleted file mode 100644 index 8721cd5..0000000 Binary files a/game/old/fb/images/buttons/mhowtoplay_r.png and /dev/null differ diff --git a/game/old/fb/images/buttons/mnewgame.png b/game/old/fb/images/buttons/mnewgame.png deleted file mode 100644 index 37ae877..0000000 Binary files a/game/old/fb/images/buttons/mnewgame.png and /dev/null differ diff --git a/game/old/fb/images/buttons/mnewgame_r.png b/game/old/fb/images/buttons/mnewgame_r.png deleted file mode 100644 index b8359c5..0000000 Binary files a/game/old/fb/images/buttons/mnewgame_r.png and /dev/null differ diff --git a/game/old/fb/images/buttons/msettings.png b/game/old/fb/images/buttons/msettings.png deleted file mode 100644 index cbc4aa5..0000000 Binary files a/game/old/fb/images/buttons/msettings.png and /dev/null differ diff --git a/game/old/fb/images/buttons/msettings_r.png b/game/old/fb/images/buttons/msettings_r.png deleted file mode 100644 index 065cd11..0000000 Binary files a/game/old/fb/images/buttons/msettings_r.png and /dev/null differ diff --git a/game/old/fb/images/buttons/next.png b/game/old/fb/images/buttons/next.png deleted file mode 100644 index ee4b257..0000000 Binary files a/game/old/fb/images/buttons/next.png and /dev/null differ diff --git a/game/old/fb/images/buttons/postscore.png b/game/old/fb/images/buttons/postscore.png deleted file mode 100644 index bd6a40d..0000000 Binary files a/game/old/fb/images/buttons/postscore.png and /dev/null differ diff --git a/game/old/fb/images/buttons/previous.png b/game/old/fb/images/buttons/previous.png deleted file mode 100644 index 1d1d0cb..0000000 Binary files a/game/old/fb/images/buttons/previous.png and /dev/null differ diff --git a/game/old/fb/images/buttons/quit.png b/game/old/fb/images/buttons/quit.png deleted file mode 100644 index ca30b7e..0000000 Binary files a/game/old/fb/images/buttons/quit.png and /dev/null differ diff --git a/game/old/fb/images/buttons/restart.png b/game/old/fb/images/buttons/restart.png deleted file mode 100644 index 0a986b5..0000000 Binary files a/game/old/fb/images/buttons/restart.png and /dev/null differ diff --git a/game/old/fb/images/buttons/return.png b/game/old/fb/images/buttons/return.png deleted file mode 100644 index a3f4981..0000000 Binary files a/game/old/fb/images/buttons/return.png and /dev/null differ diff --git a/game/old/fb/images/buttons/set_click.png b/game/old/fb/images/buttons/set_click.png deleted file mode 100644 index f7dbec3..0000000 Binary files a/game/old/fb/images/buttons/set_click.png and /dev/null differ diff --git a/game/old/fb/images/buttons/set_mouseselect.png b/game/old/fb/images/buttons/set_mouseselect.png deleted file mode 100644 index a29db1e..0000000 Binary files a/game/old/fb/images/buttons/set_mouseselect.png and /dev/null differ diff --git a/game/old/fb/images/buttons/set_music.png b/game/old/fb/images/buttons/set_music.png deleted file mode 100644 index 70146ec..0000000 Binary files a/game/old/fb/images/buttons/set_music.png and /dev/null differ diff --git a/game/old/fb/images/buttons/set_sound.png b/game/old/fb/images/buttons/set_sound.png deleted file mode 100644 index 5f0d487..0000000 Binary files a/game/old/fb/images/buttons/set_sound.png and /dev/null differ diff --git a/game/old/fb/images/buttons/set_spacebar.png b/game/old/fb/images/buttons/set_spacebar.png deleted file mode 100644 index 153275c..0000000 Binary files a/game/old/fb/images/buttons/set_spacebar.png and /dev/null differ diff --git a/game/old/fb/images/buttons/set_track.png b/game/old/fb/images/buttons/set_track.png deleted file mode 100644 index c2489cb..0000000 Binary files a/game/old/fb/images/buttons/set_track.png and /dev/null differ diff --git a/game/old/fb/images/buttons/settings.png b/game/old/fb/images/buttons/settings.png deleted file mode 100644 index cb52726..0000000 Binary files a/game/old/fb/images/buttons/settings.png and /dev/null differ diff --git a/game/old/fb/images/buttons/track_left.png b/game/old/fb/images/buttons/track_left.png deleted file mode 100644 index 0ad83cd..0000000 Binary files a/game/old/fb/images/buttons/track_left.png and /dev/null differ diff --git a/game/old/fb/images/buttons/track_right.png b/game/old/fb/images/buttons/track_right.png deleted file mode 100644 index 0890c6e..0000000 Binary files a/game/old/fb/images/buttons/track_right.png and /dev/null differ diff --git a/game/old/fb/images/cellinfect_animation/infect_a01.png b/game/old/fb/images/cellinfect_animation/infect_a01.png deleted file mode 100644 index 7d02b1a..0000000 Binary files a/game/old/fb/images/cellinfect_animation/infect_a01.png and /dev/null differ diff --git a/game/old/fb/images/cellinfect_animation/infect_a02.png b/game/old/fb/images/cellinfect_animation/infect_a02.png deleted file mode 100644 index cd5d557..0000000 Binary files a/game/old/fb/images/cellinfect_animation/infect_a02.png and /dev/null differ diff --git a/game/old/fb/images/cellinfect_animation/infect_a03.png b/game/old/fb/images/cellinfect_animation/infect_a03.png deleted file mode 100644 index 070d4d9..0000000 Binary files a/game/old/fb/images/cellinfect_animation/infect_a03.png and /dev/null differ diff --git a/game/old/fb/images/cellinfect_animation/infect_a04.png b/game/old/fb/images/cellinfect_animation/infect_a04.png deleted file mode 100644 index 45c2d2c..0000000 Binary files a/game/old/fb/images/cellinfect_animation/infect_a04.png and /dev/null differ diff --git a/game/old/fb/images/cellinfect_animation/infect_a05.png b/game/old/fb/images/cellinfect_animation/infect_a05.png deleted file mode 100644 index 6b0cf04..0000000 Binary files a/game/old/fb/images/cellinfect_animation/infect_a05.png and /dev/null differ diff --git a/game/old/fb/images/cellinfect_animation/infect_a06.png b/game/old/fb/images/cellinfect_animation/infect_a06.png deleted file mode 100644 index caf6ac5..0000000 Binary files a/game/old/fb/images/cellinfect_animation/infect_a06.png and /dev/null differ diff --git a/game/old/fb/images/cellinfect_animation/infect_a07.png b/game/old/fb/images/cellinfect_animation/infect_a07.png deleted file mode 100644 index fedb457..0000000 Binary files a/game/old/fb/images/cellinfect_animation/infect_a07.png and /dev/null differ diff --git a/game/old/fb/images/cellinfect_animation/infect_a08.png b/game/old/fb/images/cellinfect_animation/infect_a08.png deleted file mode 100644 index 1e0ca69..0000000 Binary files a/game/old/fb/images/cellinfect_animation/infect_a08.png and /dev/null differ diff --git a/game/old/fb/images/cellinfect_animation/infect_a09.png b/game/old/fb/images/cellinfect_animation/infect_a09.png deleted file mode 100644 index 43d1b04..0000000 Binary files a/game/old/fb/images/cellinfect_animation/infect_a09.png and /dev/null differ diff --git a/game/old/fb/images/cellinfect_animation/infect_a10.png b/game/old/fb/images/cellinfect_animation/infect_a10.png deleted file mode 100644 index 0aee860..0000000 Binary files a/game/old/fb/images/cellinfect_animation/infect_a10.png and /dev/null differ diff --git a/game/old/fb/images/cellinfect_animation/infect_a11.png b/game/old/fb/images/cellinfect_animation/infect_a11.png deleted file mode 100644 index 542e505..0000000 Binary files a/game/old/fb/images/cellinfect_animation/infect_a11.png and /dev/null differ diff --git a/game/old/fb/images/cellinfect_animation/infect_a12.png b/game/old/fb/images/cellinfect_animation/infect_a12.png deleted file mode 100644 index 1bcc3ab..0000000 Binary files a/game/old/fb/images/cellinfect_animation/infect_a12.png and /dev/null differ diff --git a/game/old/fb/images/halogo.jpg b/game/old/fb/images/halogo.jpg deleted file mode 100644 index e6e43c0..0000000 Binary files a/game/old/fb/images/halogo.jpg and /dev/null differ diff --git a/game/old/fb/images/holemacrophage_animation/hmacrophage_a01.png b/game/old/fb/images/holemacrophage_animation/hmacrophage_a01.png deleted file mode 100644 index 739eea8..0000000 Binary files a/game/old/fb/images/holemacrophage_animation/hmacrophage_a01.png and /dev/null differ diff --git a/game/old/fb/images/holemacrophage_animation/hmacrophage_a02.png b/game/old/fb/images/holemacrophage_animation/hmacrophage_a02.png deleted file mode 100644 index 189ed3d..0000000 Binary files a/game/old/fb/images/holemacrophage_animation/hmacrophage_a02.png and /dev/null differ diff --git a/game/old/fb/images/holemacrophage_animation/hmacrophage_a03.png b/game/old/fb/images/holemacrophage_animation/hmacrophage_a03.png deleted file mode 100644 index b9011c3..0000000 Binary files a/game/old/fb/images/holemacrophage_animation/hmacrophage_a03.png and /dev/null differ diff --git a/game/old/fb/images/holemacrophage_animation/hmacrophage_a04.png b/game/old/fb/images/holemacrophage_animation/hmacrophage_a04.png deleted file mode 100644 index 315daee..0000000 Binary files a/game/old/fb/images/holemacrophage_animation/hmacrophage_a04.png and /dev/null differ diff --git a/game/old/fb/images/holemacrophage_animation/hmacrophage_a05.png b/game/old/fb/images/holemacrophage_animation/hmacrophage_a05.png deleted file mode 100644 index 6510538..0000000 Binary files a/game/old/fb/images/holemacrophage_animation/hmacrophage_a05.png and /dev/null differ diff --git a/game/old/fb/images/holemacrophage_animation/hmacrophage_a06.png b/game/old/fb/images/holemacrophage_animation/hmacrophage_a06.png deleted file mode 100644 index e4387c2..0000000 Binary files a/game/old/fb/images/holemacrophage_animation/hmacrophage_a06.png and /dev/null differ diff --git a/game/old/fb/images/holemacrophage_animation/hmacrophage_a07.png b/game/old/fb/images/holemacrophage_animation/hmacrophage_a07.png deleted file mode 100644 index 4aefeb5..0000000 Binary files a/game/old/fb/images/holemacrophage_animation/hmacrophage_a07.png and /dev/null differ diff --git a/game/old/fb/images/holemacrophage_animation/hmacrophage_a08.png b/game/old/fb/images/holemacrophage_animation/hmacrophage_a08.png deleted file mode 100644 index f1c0e9c..0000000 Binary files a/game/old/fb/images/holemacrophage_animation/hmacrophage_a08.png and /dev/null differ diff --git a/game/old/fb/images/holemacrophage_animation/hmacrophage_a09.png b/game/old/fb/images/holemacrophage_animation/hmacrophage_a09.png deleted file mode 100644 index aad7670..0000000 Binary files a/game/old/fb/images/holemacrophage_animation/hmacrophage_a09.png and /dev/null differ diff --git a/game/old/fb/images/holemacrophage_animation/hmacrophage_a10.png b/game/old/fb/images/holemacrophage_animation/hmacrophage_a10.png deleted file mode 100644 index 84499ec..0000000 Binary files a/game/old/fb/images/holemacrophage_animation/hmacrophage_a10.png and /dev/null differ diff --git a/game/old/fb/images/holemacrophage_animation/hmacrophage_a11.png b/game/old/fb/images/holemacrophage_animation/hmacrophage_a11.png deleted file mode 100644 index cf9c8e4..0000000 Binary files a/game/old/fb/images/holemacrophage_animation/hmacrophage_a11.png and /dev/null differ diff --git a/game/old/fb/images/holemacrophage_animation/hmacrophage_a12.png b/game/old/fb/images/holemacrophage_animation/hmacrophage_a12.png deleted file mode 100644 index d7d1da2..0000000 Binary files a/game/old/fb/images/holemacrophage_animation/hmacrophage_a12.png and /dev/null differ diff --git a/game/old/fb/images/holemacrophage_animation/hmacrophage_a13.png b/game/old/fb/images/holemacrophage_animation/hmacrophage_a13.png deleted file mode 100644 index 7c7161b..0000000 Binary files a/game/old/fb/images/holemacrophage_animation/hmacrophage_a13.png and /dev/null differ diff --git a/game/old/fb/images/holemacrophage_animation/hmacrophage_a14.png b/game/old/fb/images/holemacrophage_animation/hmacrophage_a14.png deleted file mode 100644 index 3d54eba..0000000 Binary files a/game/old/fb/images/holemacrophage_animation/hmacrophage_a14.png and /dev/null differ diff --git a/game/old/fb/images/infectable_cell/infectable_cell_2n.png b/game/old/fb/images/infectable_cell/infectable_cell_2n.png deleted file mode 100644 index ac98c48..0000000 Binary files a/game/old/fb/images/infectable_cell/infectable_cell_2n.png and /dev/null differ diff --git a/game/old/fb/images/infectable_cell/infectable_cell_3n.png b/game/old/fb/images/infectable_cell/infectable_cell_3n.png deleted file mode 100644 index 5cb97e8..0000000 Binary files a/game/old/fb/images/infectable_cell/infectable_cell_3n.png and /dev/null differ diff --git a/game/old/fb/images/infectable_cell/infectable_cell_4n.png b/game/old/fb/images/infectable_cell/infectable_cell_4n.png deleted file mode 100644 index 8027852..0000000 Binary files a/game/old/fb/images/infectable_cell/infectable_cell_4n.png and /dev/null differ diff --git a/game/old/fb/images/infectable_cell/infectable_cell_5n.png b/game/old/fb/images/infectable_cell/infectable_cell_5n.png deleted file mode 100644 index 6503050..0000000 Binary files a/game/old/fb/images/infectable_cell/infectable_cell_5n.png and /dev/null differ diff --git a/game/old/fb/images/infectable_cell/infectable_cell_6n.png b/game/old/fb/images/infectable_cell/infectable_cell_6n.png deleted file mode 100644 index 41e450e..0000000 Binary files a/game/old/fb/images/infectable_cell/infectable_cell_6n.png and /dev/null differ diff --git a/game/old/fb/images/infectable_cell/infectable_cell_7n.png b/game/old/fb/images/infectable_cell/infectable_cell_7n.png deleted file mode 100644 index f9cbc94..0000000 Binary files a/game/old/fb/images/infectable_cell/infectable_cell_7n.png and /dev/null differ diff --git a/game/old/fb/images/listcell.png b/game/old/fb/images/listcell.png deleted file mode 100644 index 27af90c..0000000 Binary files a/game/old/fb/images/listcell.png and /dev/null differ diff --git a/game/old/fb/images/logo/logo128.png b/game/old/fb/images/logo/logo128.png deleted file mode 100644 index d370aed..0000000 Binary files a/game/old/fb/images/logo/logo128.png and /dev/null differ diff --git a/game/old/fb/images/logo/logo32.png b/game/old/fb/images/logo/logo32.png deleted file mode 100644 index b076f80..0000000 Binary files a/game/old/fb/images/logo/logo32.png and /dev/null differ diff --git a/game/old/fb/images/logo/logo64.png b/game/old/fb/images/logo/logo64.png deleted file mode 100644 index ca134e5..0000000 Binary files a/game/old/fb/images/logo/logo64.png and /dev/null differ diff --git a/game/old/fb/images/logo/vlogolarge.png b/game/old/fb/images/logo/vlogolarge.png deleted file mode 100644 index 274bab9..0000000 Binary files a/game/old/fb/images/logo/vlogolarge.png and /dev/null differ diff --git a/game/old/fb/images/logo/vlogolargetext.png b/game/old/fb/images/logo/vlogolargetext.png deleted file mode 100644 index 6004b8e..0000000 Binary files a/game/old/fb/images/logo/vlogolargetext.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_1.png b/game/old/fb/images/macrophage_1.png deleted file mode 100644 index b03e4cd..0000000 Binary files a/game/old/fb/images/macrophage_1.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_1_active.png b/game/old/fb/images/macrophage_1_active.png deleted file mode 100644 index 4b858d4..0000000 Binary files a/game/old/fb/images/macrophage_1_active.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_animation/macrophage_a01.png b/game/old/fb/images/macrophage_animation/macrophage_a01.png deleted file mode 100644 index 34e9035..0000000 Binary files a/game/old/fb/images/macrophage_animation/macrophage_a01.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_animation/macrophage_a02.png b/game/old/fb/images/macrophage_animation/macrophage_a02.png deleted file mode 100644 index 0cb1089..0000000 Binary files a/game/old/fb/images/macrophage_animation/macrophage_a02.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_animation/macrophage_a03.png b/game/old/fb/images/macrophage_animation/macrophage_a03.png deleted file mode 100644 index 12f9af3..0000000 Binary files a/game/old/fb/images/macrophage_animation/macrophage_a03.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_animation/macrophage_a04.png b/game/old/fb/images/macrophage_animation/macrophage_a04.png deleted file mode 100644 index 3ccaca9..0000000 Binary files a/game/old/fb/images/macrophage_animation/macrophage_a04.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_animation/macrophage_a05.png b/game/old/fb/images/macrophage_animation/macrophage_a05.png deleted file mode 100644 index b5e97c1..0000000 Binary files a/game/old/fb/images/macrophage_animation/macrophage_a05.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_animation/macrophage_a06.png b/game/old/fb/images/macrophage_animation/macrophage_a06.png deleted file mode 100644 index e8a1b97..0000000 Binary files a/game/old/fb/images/macrophage_animation/macrophage_a06.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_animation/macrophage_a07.png b/game/old/fb/images/macrophage_animation/macrophage_a07.png deleted file mode 100644 index 13ab22f..0000000 Binary files a/game/old/fb/images/macrophage_animation/macrophage_a07.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_animation/macrophage_a08.png b/game/old/fb/images/macrophage_animation/macrophage_a08.png deleted file mode 100644 index 7ac4102..0000000 Binary files a/game/old/fb/images/macrophage_animation/macrophage_a08.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_animation/macrophage_a09.png b/game/old/fb/images/macrophage_animation/macrophage_a09.png deleted file mode 100644 index 32f7c20..0000000 Binary files a/game/old/fb/images/macrophage_animation/macrophage_a09.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_animation/macrophage_a10.png b/game/old/fb/images/macrophage_animation/macrophage_a10.png deleted file mode 100644 index 4f64246..0000000 Binary files a/game/old/fb/images/macrophage_animation/macrophage_a10.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_animation/macrophage_a11.png b/game/old/fb/images/macrophage_animation/macrophage_a11.png deleted file mode 100644 index bb1870f..0000000 Binary files a/game/old/fb/images/macrophage_animation/macrophage_a11.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_animation/macrophage_a12.png b/game/old/fb/images/macrophage_animation/macrophage_a12.png deleted file mode 100644 index 506e48b..0000000 Binary files a/game/old/fb/images/macrophage_animation/macrophage_a12.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_animation/macrophage_a13.png b/game/old/fb/images/macrophage_animation/macrophage_a13.png deleted file mode 100644 index 7b14bd9..0000000 Binary files a/game/old/fb/images/macrophage_animation/macrophage_a13.png and /dev/null differ diff --git a/game/old/fb/images/macrophage_animation/macrophage_a14.png b/game/old/fb/images/macrophage_animation/macrophage_a14.png deleted file mode 100644 index f78597b..0000000 Binary files a/game/old/fb/images/macrophage_animation/macrophage_a14.png and /dev/null differ diff --git a/game/old/fb/images/noninfectable_cell/noninfectable_cell_1n.png b/game/old/fb/images/noninfectable_cell/noninfectable_cell_1n.png deleted file mode 100644 index 9768618..0000000 Binary files a/game/old/fb/images/noninfectable_cell/noninfectable_cell_1n.png and /dev/null differ diff --git a/game/old/fb/images/noninfectable_cell/noninfectable_cell_2n.png b/game/old/fb/images/noninfectable_cell/noninfectable_cell_2n.png deleted file mode 100644 index c6b582c..0000000 Binary files a/game/old/fb/images/noninfectable_cell/noninfectable_cell_2n.png and /dev/null differ diff --git a/game/old/fb/images/noninfectable_cell/noninfectable_cell_3n.png b/game/old/fb/images/noninfectable_cell/noninfectable_cell_3n.png deleted file mode 100644 index a387eb0..0000000 Binary files a/game/old/fb/images/noninfectable_cell/noninfectable_cell_3n.png and /dev/null differ diff --git a/game/old/fb/images/noninfectable_cell/noninfectable_cell_4n.png b/game/old/fb/images/noninfectable_cell/noninfectable_cell_4n.png deleted file mode 100644 index 1bf02a8..0000000 Binary files a/game/old/fb/images/noninfectable_cell/noninfectable_cell_4n.png and /dev/null differ diff --git a/game/old/fb/images/noninfectable_cell/noninfectable_cell_5n.png b/game/old/fb/images/noninfectable_cell/noninfectable_cell_5n.png deleted file mode 100644 index 841dd45..0000000 Binary files a/game/old/fb/images/noninfectable_cell/noninfectable_cell_5n.png and /dev/null differ diff --git a/game/old/fb/images/old/.DS_Store b/game/old/fb/images/old/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/old/fb/images/old/.DS_Store and /dev/null differ diff --git a/game/old/fb/images/old/b/.DS_Store b/game/old/fb/images/old/b/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/old/fb/images/old/b/.DS_Store and /dev/null differ diff --git a/game/old/fb/images/old/b/macrophage_a1.gif b/game/old/fb/images/old/b/macrophage_a1.gif deleted file mode 100755 index ea1ba06..0000000 Binary files a/game/old/fb/images/old/b/macrophage_a1.gif and /dev/null differ diff --git a/game/old/fb/images/old/background/background_bcells1.png b/game/old/fb/images/old/background/background_bcells1.png deleted file mode 100755 index f809f50..0000000 Binary files a/game/old/fb/images/old/background/background_bcells1.png and /dev/null differ diff --git a/game/old/fb/images/old/background/background_bcells2.png b/game/old/fb/images/old/background/background_bcells2.png deleted file mode 100755 index d99ee15..0000000 Binary files a/game/old/fb/images/old/background/background_bcells2.png and /dev/null differ diff --git a/game/old/fb/images/old/background/background_bcells3.png b/game/old/fb/images/old/background/background_bcells3.png deleted file mode 100755 index 099a0f7..0000000 Binary files a/game/old/fb/images/old/background/background_bcells3.png and /dev/null differ diff --git a/game/old/fb/images/old/background/background_bcells4.png b/game/old/fb/images/old/background/background_bcells4.png deleted file mode 100755 index 9ed69c7..0000000 Binary files a/game/old/fb/images/old/background/background_bcells4.png and /dev/null differ diff --git a/game/old/fb/images/old/background/background_bottomside.png b/game/old/fb/images/old/background/background_bottomside.png deleted file mode 100755 index 90bda8d..0000000 Binary files a/game/old/fb/images/old/background/background_bottomside.png and /dev/null differ diff --git a/game/old/fb/images/old/background/background_dstreaks1.png b/game/old/fb/images/old/background/background_dstreaks1.png deleted file mode 100755 index 9f553e6..0000000 Binary files a/game/old/fb/images/old/background/background_dstreaks1.png and /dev/null differ diff --git a/game/old/fb/images/old/background/background_dstreaks2.png b/game/old/fb/images/old/background/background_dstreaks2.png deleted file mode 100755 index 258b8c6..0000000 Binary files a/game/old/fb/images/old/background/background_dstreaks2.png and /dev/null differ diff --git a/game/old/fb/images/old/background/background_dstreaks3.png b/game/old/fb/images/old/background/background_dstreaks3.png deleted file mode 100755 index fcbcbb7..0000000 Binary files a/game/old/fb/images/old/background/background_dstreaks3.png and /dev/null differ diff --git a/game/old/fb/images/old/background/background_lstreaks1.png b/game/old/fb/images/old/background/background_lstreaks1.png deleted file mode 100755 index 3f313ce..0000000 Binary files a/game/old/fb/images/old/background/background_lstreaks1.png and /dev/null differ diff --git a/game/old/fb/images/old/background/background_lstreaks2.png b/game/old/fb/images/old/background/background_lstreaks2.png deleted file mode 100755 index 6d9e38e..0000000 Binary files a/game/old/fb/images/old/background/background_lstreaks2.png and /dev/null differ diff --git a/game/old/fb/images/old/background/background_topside.png b/game/old/fb/images/old/background/background_topside.png deleted file mode 100755 index 70573ac..0000000 Binary files a/game/old/fb/images/old/background/background_topside.png and /dev/null differ diff --git a/game/old/fb/images/old/bcell1.png b/game/old/fb/images/old/bcell1.png deleted file mode 100644 index f383cdd..0000000 Binary files a/game/old/fb/images/old/bcell1.png and /dev/null differ diff --git a/game/old/fb/images/old/cellwall1.png b/game/old/fb/images/old/cellwall1.png deleted file mode 100644 index ac5e3c1..0000000 Binary files a/game/old/fb/images/old/cellwall1.png and /dev/null differ diff --git a/game/old/fb/images/old/cellwall1draft.svg b/game/old/fb/images/old/cellwall1draft.svg deleted file mode 100644 index 0c2ae5a..0000000 --- a/game/old/fb/images/old/cellwall1draft.svg +++ /dev/null @@ -1,1120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/old/fb/images/old/infectable1.png b/game/old/fb/images/old/infectable1.png deleted file mode 100644 index 29f9eb1..0000000 Binary files a/game/old/fb/images/old/infectable1.png and /dev/null differ diff --git a/game/old/fb/images/old/infectable2.png b/game/old/fb/images/old/infectable2.png deleted file mode 100644 index 40d0d7d..0000000 Binary files a/game/old/fb/images/old/infectable2.png and /dev/null differ diff --git a/game/old/fb/images/old/infectable3.png b/game/old/fb/images/old/infectable3.png deleted file mode 100644 index 69567be..0000000 Binary files a/game/old/fb/images/old/infectable3.png and /dev/null differ diff --git a/game/old/fb/images/old/infectable_cell/infectable_cell_2n.png b/game/old/fb/images/old/infectable_cell/infectable_cell_2n.png deleted file mode 100755 index 29f9eb1..0000000 Binary files a/game/old/fb/images/old/infectable_cell/infectable_cell_2n.png and /dev/null differ diff --git a/game/old/fb/images/old/infectable_cell/infectable_cell_3n.png b/game/old/fb/images/old/infectable_cell/infectable_cell_3n.png deleted file mode 100755 index 40d0d7d..0000000 Binary files a/game/old/fb/images/old/infectable_cell/infectable_cell_3n.png and /dev/null differ diff --git a/game/old/fb/images/old/infectable_cell/infectable_cell_4n.png b/game/old/fb/images/old/infectable_cell/infectable_cell_4n.png deleted file mode 100755 index 69567be..0000000 Binary files a/game/old/fb/images/old/infectable_cell/infectable_cell_4n.png and /dev/null differ diff --git a/game/old/fb/images/old/infectable_cell/infectable_cell_5n.png b/game/old/fb/images/old/infectable_cell/infectable_cell_5n.png deleted file mode 100755 index 620adbb..0000000 Binary files a/game/old/fb/images/old/infectable_cell/infectable_cell_5n.png and /dev/null differ diff --git a/game/old/fb/images/old/infectable_cell/infectable_cell_6n.png b/game/old/fb/images/old/infectable_cell/infectable_cell_6n.png deleted file mode 100755 index aa65877..0000000 Binary files a/game/old/fb/images/old/infectable_cell/infectable_cell_6n.png and /dev/null differ diff --git a/game/old/fb/images/old/infectable_cell/infectable_cell_7n.png b/game/old/fb/images/old/infectable_cell/infectable_cell_7n.png deleted file mode 100755 index 2951a73..0000000 Binary files a/game/old/fb/images/old/infectable_cell/infectable_cell_7n.png and /dev/null differ diff --git a/game/old/fb/images/old/macrophage1.png b/game/old/fb/images/old/macrophage1.png deleted file mode 100644 index 4dc0f6b..0000000 Binary files a/game/old/fb/images/old/macrophage1.png and /dev/null differ diff --git a/game/old/fb/images/old/macrophage_active.png b/game/old/fb/images/old/macrophage_active.png deleted file mode 100644 index ed7d1ee..0000000 Binary files a/game/old/fb/images/old/macrophage_active.png and /dev/null differ diff --git a/game/old/fb/images/old/new/.DS_Store b/game/old/fb/images/old/new/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/old/fb/images/old/new/.DS_Store and /dev/null differ diff --git a/game/old/fb/images/old/new/infectable1.png b/game/old/fb/images/old/new/infectable1.png deleted file mode 100755 index 298f24c..0000000 Binary files a/game/old/fb/images/old/new/infectable1.png and /dev/null differ diff --git a/game/old/fb/images/old/new/infectable2.png b/game/old/fb/images/old/new/infectable2.png deleted file mode 100755 index 01100dd..0000000 Binary files a/game/old/fb/images/old/new/infectable2.png and /dev/null differ diff --git a/game/old/fb/images/old/new/infectable3.png b/game/old/fb/images/old/new/infectable3.png deleted file mode 100755 index 9bc043f..0000000 Binary files a/game/old/fb/images/old/new/infectable3.png and /dev/null differ diff --git a/game/old/fb/images/old/new/noninfectable.png b/game/old/fb/images/old/new/noninfectable.png deleted file mode 100755 index bbe312b..0000000 Binary files a/game/old/fb/images/old/new/noninfectable.png and /dev/null differ diff --git a/game/old/fb/images/old/noninfectable1.png b/game/old/fb/images/old/noninfectable1.png deleted file mode 100644 index dde08a7..0000000 Binary files a/game/old/fb/images/old/noninfectable1.png and /dev/null differ diff --git a/game/old/fb/images/old/noninfectable_cell/noninfectable_cell_2n.png b/game/old/fb/images/old/noninfectable_cell/noninfectable_cell_2n.png deleted file mode 100755 index e586a95..0000000 Binary files a/game/old/fb/images/old/noninfectable_cell/noninfectable_cell_2n.png and /dev/null differ diff --git a/game/old/fb/images/old/noninfectable_cell/noninfectable_cell_3.png b/game/old/fb/images/old/noninfectable_cell/noninfectable_cell_3.png deleted file mode 100755 index a04f17c..0000000 Binary files a/game/old/fb/images/old/noninfectable_cell/noninfectable_cell_3.png and /dev/null differ diff --git a/game/old/fb/images/old/noninfectable_cell/noninfectable_cell_4.png b/game/old/fb/images/old/noninfectable_cell/noninfectable_cell_4.png deleted file mode 100755 index 5114e1d..0000000 Binary files a/game/old/fb/images/old/noninfectable_cell/noninfectable_cell_4.png and /dev/null differ diff --git a/game/old/fb/images/old/noninfectable_cell/noninfectable_cell_5.png b/game/old/fb/images/old/noninfectable_cell/noninfectable_cell_5.png deleted file mode 100755 index 86a67e3..0000000 Binary files a/game/old/fb/images/old/noninfectable_cell/noninfectable_cell_5.png and /dev/null differ diff --git a/game/old/fb/images/old/particle.png b/game/old/fb/images/old/particle.png deleted file mode 100644 index e2c8a15..0000000 Binary files a/game/old/fb/images/old/particle.png and /dev/null differ diff --git a/game/old/fb/images/old/screens/.DS_Store b/game/old/fb/images/old/screens/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/old/fb/images/old/screens/.DS_Store and /dev/null differ diff --git a/game/old/fb/images/old/screens/bullet_listcell.png b/game/old/fb/images/old/screens/bullet_listcell.png deleted file mode 100755 index 7525958..0000000 Binary files a/game/old/fb/images/old/screens/bullet_listcell.png and /dev/null differ diff --git a/game/old/fb/images/old/screens/header.png b/game/old/fb/images/old/screens/header.png deleted file mode 100755 index 8b83ea6..0000000 Binary files a/game/old/fb/images/old/screens/header.png and /dev/null differ diff --git a/game/old/fb/images/old/screens/listcell.png b/game/old/fb/images/old/screens/listcell.png deleted file mode 100755 index ef2eba2..0000000 Binary files a/game/old/fb/images/old/screens/listcell.png and /dev/null differ diff --git a/game/old/fb/images/old/screens/loading.png b/game/old/fb/images/old/screens/loading.png deleted file mode 100755 index a20886e..0000000 Binary files a/game/old/fb/images/old/screens/loading.png and /dev/null differ diff --git a/game/old/fb/images/old/screens/loadingsplash.png b/game/old/fb/images/old/screens/loadingsplash.png deleted file mode 100755 index 9c3d6bc..0000000 Binary files a/game/old/fb/images/old/screens/loadingsplash.png and /dev/null differ diff --git a/game/old/fb/images/old/screens/mainscreenbase.png b/game/old/fb/images/old/screens/mainscreenbase.png deleted file mode 100755 index 2287e53..0000000 Binary files a/game/old/fb/images/old/screens/mainscreenbase.png and /dev/null differ diff --git a/game/old/fb/images/old/screens/newgame_listcell.png b/game/old/fb/images/old/screens/newgame_listcell.png deleted file mode 100755 index 3360fb7..0000000 Binary files a/game/old/fb/images/old/screens/newgame_listcell.png and /dev/null differ diff --git a/game/old/fb/images/old/screens/settings.png b/game/old/fb/images/old/screens/settings.png deleted file mode 100755 index 3041eea..0000000 Binary files a/game/old/fb/images/old/screens/settings.png and /dev/null differ diff --git a/game/old/fb/images/old/screens/settingssplash.png b/game/old/fb/images/old/screens/settingssplash.png deleted file mode 100755 index ac1891a..0000000 Binary files a/game/old/fb/images/old/screens/settingssplash.png and /dev/null differ diff --git a/game/old/fb/images/old/tcells/tcell1.png b/game/old/fb/images/old/tcells/tcell1.png deleted file mode 100755 index a49799f..0000000 Binary files a/game/old/fb/images/old/tcells/tcell1.png and /dev/null differ diff --git a/game/old/fb/images/old/tcells/tcell2.png b/game/old/fb/images/old/tcells/tcell2.png deleted file mode 100755 index 24b6ac2..0000000 Binary files a/game/old/fb/images/old/tcells/tcell2.png and /dev/null differ diff --git a/game/old/fb/images/old/tcells/tcell3.png b/game/old/fb/images/old/tcells/tcell3.png deleted file mode 100755 index 98dbc44..0000000 Binary files a/game/old/fb/images/old/tcells/tcell3.png and /dev/null differ diff --git a/game/old/fb/images/old/tcells/tcell4.png b/game/old/fb/images/old/tcells/tcell4.png deleted file mode 100755 index 891c32b..0000000 Binary files a/game/old/fb/images/old/tcells/tcell4.png and /dev/null differ diff --git a/game/old/fb/images/old/virus1.png b/game/old/fb/images/old/virus1.png deleted file mode 100644 index d9db175..0000000 Binary files a/game/old/fb/images/old/virus1.png and /dev/null differ diff --git a/game/old/fb/images/old/virusfinal.svg b/game/old/fb/images/old/virusfinal.svg deleted file mode 100644 index 3b61a61..0000000 --- a/game/old/fb/images/old/virusfinal.svg +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/old/fb/images/old/wall_segments/cellwall1.png b/game/old/fb/images/old/wall_segments/cellwall1.png deleted file mode 100755 index 0d71d6e..0000000 Binary files a/game/old/fb/images/old/wall_segments/cellwall1.png and /dev/null differ diff --git a/game/old/fb/images/old/wall_segments/cellwall2.png b/game/old/fb/images/old/wall_segments/cellwall2.png deleted file mode 100755 index f06bf92..0000000 Binary files a/game/old/fb/images/old/wall_segments/cellwall2.png and /dev/null differ diff --git a/game/old/fb/images/old/wall_segments/cellwall3.png b/game/old/fb/images/old/wall_segments/cellwall3.png deleted file mode 100755 index 2b7f3c7..0000000 Binary files a/game/old/fb/images/old/wall_segments/cellwall3.png and /dev/null differ diff --git a/game/old/fb/images/old/wall_segments/cellwall4.png b/game/old/fb/images/old/wall_segments/cellwall4.png deleted file mode 100755 index d33f471..0000000 Binary files a/game/old/fb/images/old/wall_segments/cellwall4.png and /dev/null differ diff --git a/game/old/fb/images/old/wall_segments/cellwall5.png b/game/old/fb/images/old/wall_segments/cellwall5.png deleted file mode 100755 index c0bbabd..0000000 Binary files a/game/old/fb/images/old/wall_segments/cellwall5.png and /dev/null differ diff --git a/game/old/fb/images/old/wall_segments/cellwall6.png b/game/old/fb/images/old/wall_segments/cellwall6.png deleted file mode 100755 index 203950f..0000000 Binary files a/game/old/fb/images/old/wall_segments/cellwall6.png and /dev/null differ diff --git a/game/old/fb/images/old/wall_segments/cellwall7.png b/game/old/fb/images/old/wall_segments/cellwall7.png deleted file mode 100755 index 262a9b3..0000000 Binary files a/game/old/fb/images/old/wall_segments/cellwall7.png and /dev/null differ diff --git a/game/old/fb/images/old/wallcell1.png b/game/old/fb/images/old/wallcell1.png deleted file mode 100644 index 30c4535..0000000 Binary files a/game/old/fb/images/old/wallcell1.png and /dev/null differ diff --git a/game/old/fb/images/screens/creditsscreen.png b/game/old/fb/images/screens/creditsscreen.png deleted file mode 100644 index 40ff9db..0000000 Binary files a/game/old/fb/images/screens/creditsscreen.png and /dev/null differ diff --git a/game/old/fb/images/screens/helpsplash.png b/game/old/fb/images/screens/helpsplash.png deleted file mode 100644 index f92663b..0000000 Binary files a/game/old/fb/images/screens/helpsplash.png and /dev/null differ diff --git a/game/old/fb/images/screens/loadingsplash.png b/game/old/fb/images/screens/loadingsplash.png deleted file mode 100644 index 7825408..0000000 Binary files a/game/old/fb/images/screens/loadingsplash.png and /dev/null differ diff --git a/game/old/fb/images/screens/mainscreenbase.png b/game/old/fb/images/screens/mainscreenbase.png deleted file mode 100644 index dd63a98..0000000 Binary files a/game/old/fb/images/screens/mainscreenbase.png and /dev/null differ diff --git a/game/old/fb/images/screens/settingssplash.png b/game/old/fb/images/screens/settingssplash.png deleted file mode 100644 index 7cd9b4e..0000000 Binary files a/game/old/fb/images/screens/settingssplash.png and /dev/null differ diff --git a/game/old/fb/images/t_animation/tcell_a01.png b/game/old/fb/images/t_animation/tcell_a01.png deleted file mode 100644 index 22b4364..0000000 Binary files a/game/old/fb/images/t_animation/tcell_a01.png and /dev/null differ diff --git a/game/old/fb/images/t_animation/tcell_a02.png b/game/old/fb/images/t_animation/tcell_a02.png deleted file mode 100644 index 6743fbc..0000000 Binary files a/game/old/fb/images/t_animation/tcell_a02.png and /dev/null differ diff --git a/game/old/fb/images/t_animation/tcell_a03.png b/game/old/fb/images/t_animation/tcell_a03.png deleted file mode 100644 index d6b30c9..0000000 Binary files a/game/old/fb/images/t_animation/tcell_a03.png and /dev/null differ diff --git a/game/old/fb/images/t_animation/tcell_a04.png b/game/old/fb/images/t_animation/tcell_a04.png deleted file mode 100644 index 17e9836..0000000 Binary files a/game/old/fb/images/t_animation/tcell_a04.png and /dev/null differ diff --git a/game/old/fb/images/t_animation/tcell_a05.png b/game/old/fb/images/t_animation/tcell_a05.png deleted file mode 100644 index a909794..0000000 Binary files a/game/old/fb/images/t_animation/tcell_a05.png and /dev/null differ diff --git a/game/old/fb/images/t_animation/tcell_a06.png b/game/old/fb/images/t_animation/tcell_a06.png deleted file mode 100644 index af2bf7f..0000000 Binary files a/game/old/fb/images/t_animation/tcell_a06.png and /dev/null differ diff --git a/game/old/fb/images/t_animation/tcell_a07.png b/game/old/fb/images/t_animation/tcell_a07.png deleted file mode 100644 index e6a1f7c..0000000 Binary files a/game/old/fb/images/t_animation/tcell_a07.png and /dev/null differ diff --git a/game/old/fb/images/tcell_2.png b/game/old/fb/images/tcell_2.png deleted file mode 100644 index bcdfd37..0000000 Binary files a/game/old/fb/images/tcell_2.png and /dev/null differ diff --git a/game/old/fb/images/tinyvirus_shadowtrans.png b/game/old/fb/images/tinyvirus_shadowtrans.png deleted file mode 100644 index 06f8178..0000000 Binary files a/game/old/fb/images/tinyvirus_shadowtrans.png and /dev/null differ diff --git a/game/old/fb/images/tinyvirus_trans.png b/game/old/fb/images/tinyvirus_trans.png deleted file mode 100644 index ffad22b..0000000 Binary files a/game/old/fb/images/tinyvirus_trans.png and /dev/null differ diff --git a/game/old/fb/images/wall_segments/cellwall1.png b/game/old/fb/images/wall_segments/cellwall1.png deleted file mode 100644 index 0e4aa10..0000000 Binary files a/game/old/fb/images/wall_segments/cellwall1.png and /dev/null differ diff --git a/game/old/fb/images/wall_segments/cellwall2.png b/game/old/fb/images/wall_segments/cellwall2.png deleted file mode 100644 index 8b07659..0000000 Binary files a/game/old/fb/images/wall_segments/cellwall2.png and /dev/null differ diff --git a/game/old/fb/images/wall_segments/cellwall3.png b/game/old/fb/images/wall_segments/cellwall3.png deleted file mode 100644 index d91f9ac..0000000 Binary files a/game/old/fb/images/wall_segments/cellwall3.png and /dev/null differ diff --git a/game/old/fb/images/wall_segments/cellwall4.png b/game/old/fb/images/wall_segments/cellwall4.png deleted file mode 100644 index aaf96ad..0000000 Binary files a/game/old/fb/images/wall_segments/cellwall4.png and /dev/null differ diff --git a/game/old/fb/images/wall_segments/cellwall5.png b/game/old/fb/images/wall_segments/cellwall5.png deleted file mode 100644 index edb9fa1..0000000 Binary files a/game/old/fb/images/wall_segments/cellwall5.png and /dev/null differ diff --git a/game/old/fb/images/wall_segments/cellwall6.png b/game/old/fb/images/wall_segments/cellwall6.png deleted file mode 100644 index 175ed0f..0000000 Binary files a/game/old/fb/images/wall_segments/cellwall6.png and /dev/null differ diff --git a/game/old/fb/images/wall_segments/cellwall7.png b/game/old/fb/images/wall_segments/cellwall7.png deleted file mode 100644 index e1d20e5..0000000 Binary files a/game/old/fb/images/wall_segments/cellwall7.png and /dev/null differ diff --git a/game/old/fb/images/wallcell_1.png b/game/old/fb/images/wallcell_1.png deleted file mode 100644 index 9f5f197..0000000 Binary files a/game/old/fb/images/wallcell_1.png and /dev/null differ diff --git a/game/old/fb/in_game_state.js b/game/old/fb/in_game_state.js deleted file mode 100644 index d243684..0000000 --- a/game/old/fb/in_game_state.js +++ /dev/null @@ -1,1770 +0,0 @@ -// *** game *** -// NOTE: get_type() returns "game" not "in_game" - -var in_game_state = function (p, previous_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - - // whether or not we are testing - // use it wherever - var testing = false; - obj.testing = function() { return testing; }; - - // --- constants --- - //var num_of_render_levels = 5; Now auto-calculating in init so don't have to change - - // --- private variables --- - - var GOOD_NOTIFICATION_COLOR = p.color(0, 255, 0); - var BAD_NOTIFICATION_COLOR = p.color(255, 0, 0); - - var prev_state = previous_state; - // distance is the x-coordinate of the total distance traveled - // increments with scroll - var distance = 0; - //var score = 0; - var active_cell = null; - var last_active_cell = null; - // multiply each object's scroll amount by this - // factor, which increases throughout the game - var scroll_factor = 1; - - var game_objects = []; - var paused = false; - - var status_bar_height = 40; - var status_height = 20; - - var score = num_status_obj(p, { - pos : new p.PVector(p.width - 100, status_height), - text : "Score:", - num : 0, - format : add_commas - }); - var mult = num_status_obj(p, { - pos : new p.PVector(p.width - 200, status_height), - text : "Multiplier:", - num : 1, - format : function(num) { - return num+"x"; - } - }); - var time_elapsed = 0; // Time elapsed in seconds - var set_time = false; //bool that says if we've started counting time - var time_status = num_status_obj(p, { - pos : new p.PVector(85, status_height), - text : "Time:", - num : time_elapsed, - // formats time to mins:secs - format : function(num) { - var secs = num%60; - if (secs < 10) { secs = "0" + secs; } - return p.floor(num/60) + ":" + secs; - } - }); - var mutation = mutation_obj(p, { status_height : status_height }); - - var pause_button = button(p, { - state: function() { - do_pause(); - console.log("pause button"); - return pause_state(p, obj); - }, - rect: { - pos: new p.PVector(25, status_height), - width: 25, height: 25, - } - }); - // draw two vertical rects - pause_button.draw = function() { - p.pushMatrix(); - // get the rect spec back - var r = pause_button.get_rect(); - var w = r.width; - var h = r.height; - p.translate(r.pos.x-w/2, r.pos.y-h/2); - p.strokeWeight(2); - p.stroke(255); - p.noFill(); - p.ellipse(w/2, h/2, w, h); - p.noStroke(); - p.fill(255); - p.rectMode(p.CORNER); - p.rect(w/4, h/5, w/5, 3*h/5); - p.rect(w-w/4-w/5, h/5, w/5, 3*h/5); - p.popMatrix(); - }; - - // Used to draw all of the statuses (must implement draw) - var all_status_objs = [score, mult, time_status, mutation]; - var all_buttons = [pause_button]; - - var all_notifications = []; - var last_notification_time = -1 - // takes a string and adds a new notification - var notify = function(note, color) { - var the_pos = null; - if (active_cell) { - console.log("Setting to active cell"); - a_pos = active_cell.get_pos(); - the_pos = new p.PVector(a_pos.x, a_pos.y - 30); - } - else { - console.log("Setting to default"); - the_pos = new p.PVector(p.width * (5/8), p.height * (5/8)); - } - if (new Date().getTime() > (last_notification_time + 2000)) { // two seconds - all_notifications.push(notification(p, { "text": note, "color": color, - "pos" : the_pos})); - last_notification_time = new Date().getTime(); - } - }; - - var generator = make_generator(p, { - game : obj, - mutation : mutation - }); - - // temporary flag TODO - //var game_over = false; - - //A mapping from game_object types to their rendering levels - var type_to_level = { - "background_object":0, - "background_edge":0, - "wall":1, - "wall_segment":1, - "particle":2, // general name for level - "cell":3, // general name for level - "wall_cell": 3, - "empty_cell": 3, - "enemy":4, // general name for level - "floater":4, - "tkiller":4, - "antibody":4, - "b_cell": 5, - "multiplier":6, - "info":7 - }; - - // given a type returns the array of objects - // corresponding to that type's level - var level = function(type) { - var lvl = game_objects[type_to_level[type]]; - assert (lvl, type+" not a valid type!"); - return lvl; - }; - - -/* - // Buttons - // Have a rectangle representing their position and - // a state to go to when pressed - var pause_button = { - state : pause_state(), - rectangle : rectangle(p, { - pos : new p.PVector(p.width - 20, 20), - width : 20, - height : 20 - }) - }; - var help_button = { - state : help_state(), - rectangle : rectangle(p, { - pos : new p.PVector(p.width - 80, 20), - width : 20, - height : 20 - }) - }; - var exit_button = { - state : exit_state(), - rectangle : rectangle(p, { - pos : new p.PVector(20, 20), - width : 20, - height : 20 - }) - }; -*/ - //Not ordered - - - // --- private methods --- - - // initialization code goes here - // gets called at the bottom - var init = function() { - // Start playing the game music - if (g.music) { - sounds.play_background_music(); - } - - //Initialize game_objects to be a list of num_of_render_levels empty lists - var num_of_render_levels = 0; - for (var key in type_to_level){ - if (type_to_level.hasOwnProperty(key)) { - var new_level = type_to_level[key]; - if (new_level > num_of_render_levels) { - num_of_render_levels = new_level; - } - } - } - for (var i = 0; i < num_of_render_levels; i++) { - game_objects[i] = []; - } - - var startx = p.width-150; - if (testing) { - var startx = 150; - } - - var initial_cells = [ - cell(p, { - pos: new p.PVector(startx, p.height/2), - vel: new p.PVector(0, 0), - state: "alive", - }), - cell(p, { - pos: new p.PVector(startx+170, p.height/2-40), - vel: new p.PVector(0, 0), - state: "alive", - }), - cell(p, { - pos: new p.PVector(startx+170, p.height/2), - vel: new p.PVector(0, 0), - state: "alive", - }), - cell(p, { - pos: new p.PVector(startx+170, p.height/2+40), - vel: new p.PVector(0, 0), - state: "alive", - }) - ]; - //var cell_level = type_to_level["cell"]; - //game_objects[cell_level].push(initial_cell); - obj.add_objects(initial_cells); - - var initial_par = particle(p, { - pos: new p.PVector(0, p.height/2), - vel: new p.PVector(8, 0), - // start with some gray - mutation_info: mutation.get_info()//p.color(250, 250, 250) - //mutation : mutation - }); - - obj.add_object(initial_par); - - init_walls(); - init_back(); - - //active_cell = initial_cell; - - // Add background - //var bg = background(p, { pos : new p.PVector(0, 0)}); - //obj.add_object(bg); - //console.log(level("background")[0]); - }; - - // creates, adds, and returns a new b_cell with no target - var make_b_cell = function() { - var new_b_cell = b_cell(p, { - pos: new p.PVector(p.width+50, p.random(p.height/4, 3*p.height/4)), - }); - obj.add_object(new_b_cell); - return new_b_cell; - }; - - // creates, adds, and returns a new tkiller with no target - var make_tkiller = function() { - var new_tkiller = tkiller(p, { - pos: new p.PVector(p.width+50, p.random(p.height/4, 3*p.height/4)), - }); - obj.add_object(new_tkiller); - return new_tkiller; - }; - - // Returns the current b cell on the screen, if there is one - var get_b_cell = function(level) { - var the_b_cell = null; - do_to_type( - function(b) { - if (b.get_level() === level) { - the_b_cell = b; - } - }, - "b_cell", true - ); - return the_b_cell; - }; - - var alert_b_cell = function(flo) { - // gets b_cell of the flo's level - var b = get_b_cell(flo.get_level()); - // if there isn't one - if (!b) { - // make one - b = make_b_cell(); - b.set_mutation_info(flo.get_mutation_info()); - b.set_target(flo); - } - // if there is one - else { - // it should be either active, shooting, or outdated - // so do nothing - } - }; - - // Alerts the b cell (only one on screen at a time?) to a newly mutated - // obj. - // If o.mutation_level >= b cells current target.mutation_level and o is - // closer than the b cells curr target (or if b cells curr - // target is null), updates b_cells curr target to be o - /* - var alert_b_cell = function(o) { - //var cell_objs = level("b_cell"); - //var cell_obj = null; - /*for (var i = 0; i < cell_objs.length; i++) { - cell_obj = cell_objs[i]; - if (cell_obj.get_type() === "b_cell") { - the_b_cell = cell_obj; - } - } - / - - var the_b_cell = get_b_cell(); - - if (the_b_cell && the_b_cell.is_alive()) { - var old_target = the_b_cell.get_target(); - - if (old_target) { - // if new macro has higher or equal level - if (//o.get_level() >= old_target.get_level() - // if new macro has current mutation level - o.get_level() === mutation.get_level() - // and it is closer - && old_target.get_pos().dist(the_b_cell.get_pos()) > - o.get_pos().dist(the_b_cell.get_pos())) { - the_b_cell.set_target(o); - } - } - else { - the_b_cell.set_target(o); - } - } - }; - */ - - // sets active_cell to the leftmost infected cell - // if there is one - var next_active_cell = function() { - var sort_fun = function(active_c) { // don't care about active - if (last_active_cell) { - // let's try the nearest cell to the one that died - return function(c1, c2) { - return dist_less_than(last_active_cell, c1, c2) ? -1 : 1; - }; - } - // otherwise leftmost - return function(c1, c2) { - return c1.get_pos().x - c2.get_pos().x; - }; - } - choose_cell(sort_fun); - }; - - // Set the next-left or next-right cell to be active, and - // if appropriate sets current active to be not active - - // Chooses the closest cell to a_pos - var choose_closest_cell = function(a_pos) { - if (active_cell) { // for the beginning - var old_active = active_cell; - var sort_fun = function(active_cell){ - return function(c1, c2){ - return c1.get_pos().dist(a_pos) - - c2.get_pos().dist(a_pos); - } - }; - choose_cell(sort_fun); - - // In case it doesn't change (choose_cell assumes - // that the cell is diff from the curr active) - if (old_active.get_pos().dist(a_pos) < - active_cell.get_pos().dist(a_pos)) { - active_cell.set_state("infected"); - active_cell = old_active; - active_cell.set_state("active"); - } - } - } - - // Chooses the closest cell to the active cell in the direction of comp, - // i.e. such that comp(c1.x, active.x) is true - var choose_cell_helper = function(comp) { - var sort_fun = function(active_c) { //don't rename to active_cell - return function(c1, c2) { - c1x = c1.get_pos().x; - c2x = c2.get_pos().x; - actx = active_c.get_pos().x; - // If one is in the right dir and the other isnt, - // return the one that is - if (comp(c1x, actx) && !(comp(c2x, actx))) { - return -1; - } - else if (!(comp(c1x, actx)) && comp(c2x, actx)) { - return 1; - } - // If they are on the same side, return opposite of comp - else { - if (comp(c1x, c2x)) { - return 1; - } - else { - return -1; - } - } - } - }; - choose_cell(sort_fun); - }; - - // Chooses the next left cell to be active - var choose_left_cell = function() { - choose_cell_helper(function (x, y) {return x < y;}); - - }; - - // Same in the right dir - var choose_right_cell = function() { - choose_cell_helper(function (x, y) {return x > y;}); - }; - - // Sets a cell to be active based on sort_fun, and if this is diff - // from curr cell, sets curr cell to not be active - // sort_fun must take the currently active cell, and return a function - // that takes 2 cells, ad returns true if the first is 'better' than - // the second - var choose_cell = function(sort_fun) { - var cells = level("cell");//game_objects[type_to_level["cell"]]; - var infecteds = cells.filter( - function(cell) { - // don't want empty_cells - return cell.get_type() === "cell" - && cell.get_state() === "infected"; - }); - var sort_f = sort_fun(active_cell); - infecteds.sort(sort_f); - - var curr_active = active_cell; - if (infecteds.length > 0) { - active_cell = infecteds[0]; - //If same as current - if (curr_active) { // for the beginning - curr_active.set_state("infected"); //if same, about to change - } - active_cell.set_state("active"); - //console.log("got next "+active_cell.to_string()); - } - }; - - // Returns true if source is closer to target1 than target2 - // All 3 args are game_objs - var dist_less_than = function(source, target1, target2) { - var source_pos = source.get_pos(); - return source_pos.dist(target1.get_pos()) < - source_pos.dist(target2.get_pos()); - }; - - // Updates all tkillers targets - // Tkillers target the closest infected and targeted cell - var update_tkillers_targets = function(){ - var all_infected_cells = get_all_infected_cells(); - do_to_type(function(tkill){ - // remove bad targets - if (tkill.get_target() - // if it's dead - && (tkill.get_target().is_dead() - // or dying - || tkill.get_target().get_state() === "dying" - // or offscreen - || tkill.get_target().is_offscreen() - // or the target mutated - || !same_mutation_level(tkill, tkill.get_target()))) { - tkill.set_target(null); - } - // set a new target - for_each( - all_infected_cells, - function(infected_cell) { - if (infected_cell.has_antibody() - && same_mutation_level(infected_cell, tkill) - && (!tkill.get_target() || - dist_less_than(tkill, - infected_cell, tkill.get_target()))) { - tkill.set_target(infected_cell); - } - } - ); - }, "tkiller", true); - }; - - // adds new tkillers if need be - var add_tkillers = function() { - var tks = get_all_of_type("tkiller"); - do_to_type( - // for each b_cell - function(b) { - // if it needs a tkiller - if (b.is_shooting()) { - // check if one exists - var has_tkiller = false; - for_each(tks, function(tk) { - if (same_mutation_level(b, tk)) { - has_tkiller = true; - } - }); - // if one doesn't - if (!has_tkiller) { - console.log("made tkiller for lvl "+b.get_level()); - // make one - var tk = make_tkiller(); - tk.set_mutation_info(b.get_mutation_info()); - } - } - }, - "b_cell", true - ); - }; - - - // kills the active cell and updates the targets - // of all the tkillers - var kill_active_cell = function() { - active_cell.die(); - last_active_cell = active_cell; - active_cell = null; - update_tkillers_targets(); - }; - - //Checks whether any 2 objs are colliding, and if so calls handle_collision on them - var check_collisions = (function() { - // rendering levels to check collisions for: - var to_check = [ - //["particle", "particle"], - ["particle", "cell"], - ["particle", "enemy"], - ["particle", "multiplier"], - //["cell", "cell"], - ["cell", "enemy"], - //["enemy", "enemy"], - ["enemy", "b_cell"], - ["b_cell", "wall"], - ["particle", "wall"], - ["multiplier", "wall"], - ["enemy", "wall"] - ]; - - // hey this looks like combinations! - var do_comb = function(arr1, start1, end1, - arr2, start2, end2, fun) { - var i = start1, j = start2; - while (i <= end1) { - while (j <= end2) { - fun(arr1[i], arr2[j]); - j++; - } - i++; - // when arrays are the same - // don't do repeats - if (arr1 === arr2) { - j = i; - } - else { - j = 0; - } - } - }; - - var collision_fun = function() { - // double combinations! - // for each pair of rendering groups - // do_comb(game_objects, 1, 3, - // game_objects, 1, 3, - for_each(to_check, function(pair) { - var lvl1 = level(pair[0]); - var lvl2 = level(pair[1]); - // for each pair of objects in the groups - do_comb(lvl1, 0, lvl1.length-1, - lvl2, 0, lvl2.length-1, check); - }); - //); - }; - - - var check = function(obj1, obj2) { - //console.log("checking "+obj1.to_string() - // +", "+obj2.to_string()); - // check the collisions - // don't check collisions with self - if (obj1 !== obj2 - && check_collision(obj1, obj2)) { - handle_collision(obj1, obj2); - //console.log("collision! " +obj1.to_string() - // +", "+obj2.to_string()); - } - } - - return collision_fun; - }()); - - // Returns whether 2 objects are colliding - var check_collision = function(obj1, obj2) { - var type1 = obj1.get_type(); - var type2 = obj2.get_type(); - - if (check_circle_collision(obj1, obj2)) { - var check_again = retrieve(extra_check, type1, type2); - if (check_again !== undefined) { - return check_again(obj1, obj2); - } - else { - check_again = retrieve(extra_check, type2, type1); - if (check_again !== undefined) { - return check_again(obj2, obj1); - } - else { - return true; - } - } - } - else { - return false; - } - }; - - // Checks for a collision between circle (obj2) and rectangle (obj1) - var check_rectangle_collision = function(rect, circ) { - return overlapping_vertically(circ, rect, rect.get_y_offset()) && - overlapping_horizontally(circ, rect, rect.get_x_offset()); - }; - - // Rectangle and circle collision helper functions - // Returns whether the circle is overlapping the rectangle, horizontally, - // by offset num of pixels - var overlapping_horizontally = function(circ, rect, offset) { - var circlel = circ.get_left(), circler = circ.get_right(); - var rectl = rect.get_left(), rectr = rect.get_right(); - return ((circler <= rectr && circler >= (rectl + offset)) || - (circlel >= rectl && circlel <= (rectr - offset))); - }; - // Returns whether the circle is overlapping the rectangle, vertically, - // by offset num of pixels - var overlapping_vertically = function(circ, rect, offset) { - var circlet = circ.get_top(), circleb = circ.get_bottom(); - var rectt = rect.get_top(), rectb = rect.get_bottom(); - - return (circleb <= rectb && circleb >= (rectt + offset) || - (circlet >= rectt && circlet <= (rectb - offset))); - }; - - // holds extra collision checking functions for certain - // pairs of types - var extra_check = { - "wall_segment": { - "particle": check_rectangle_collision, - "b_cell": check_rectangle_collision, - "multiplier": //check_rectangle_collision - // had to do manually cuz offset was messed up - function(rect, circ) { - return overlapping_vertically(circ, rect, 0) && - overlapping_horizontally(circ, rect, 0); - } - }, - "floater": { - "b_cell": check_rectangle_collision - }, - "wall_cell": { - "particle": check_rectangle_collision - } - }; - - // checks for collisions between two objects by - // checking if their bounding circles are overlapping - // returns true if they are colliding - var check_circle_collision = function(obj1, obj2) { - // if the distance between their center points - // is <= the sum of their radii then they are colliding - // ONLY WORKS FOR CENTERED SHAPES - return (obj1.get_pos().dist(obj2.get_pos()) - <= obj1.get_radius() + obj2.get_radius()); - }; - // make it public - obj.check_circle_collision = check_circle_collision; - - /* - // Reverses 2 objs appropriate velocities - var bounce_collided = (function() { - // A list containing 2 element lists - // Inner lists represent object type pairs to not bounce off each other - var to_exclude = [ ["particle", "multiplier"], - ["particle", "particle"], - ["wall_segment", "b_cell"], - ["particle", "antibody"]]; - - var is_excluded = function(o1, o2) { - var is_excluded = false; - var type1 = o1.get_type(), type2 = o2.get_type(); - var objs_in_list = function(list) { - return ((list[0] === type1 && list[1] === type2) || - (list[0] === type2 && list[1] === type1)); - } - for_each(to_exclude, function(l) { - if (objs_in_list(l)) { - is_excluded = true; - } - }); - return is_excluded; - } - return function(obj1, obj2) { - if (!is_excluded(obj1, obj2)) { - bounce(obj1, obj2); - } - } - }()); - */ - - var bounce = function(obj1, obj2) { - //offset adjusts how closely we check, since we can't check exactly when they collide every time - var offset = 5; - var onel = obj1.get_left(), oner = obj1.get_right(); - var onet = obj1.get_top(), oneb = obj1.get_bottom(); - var twol = obj2.get_left() + offset, twor = obj2.get_right() - offset; - var twot = obj2.get_top() + offset, twob = obj2.get_bottom() - offset; - - //When bouncing, check velocity to make sure they are 'incoming' to each other - //This avoids them getting stuck (makes sure they didn't just collide) - //bounce vertically - var y_vel = obj1.get_vel().y; - var x_vel = obj1.get_vel().x; - if ((onet >= twob && y_vel <= 0) || (oneb <= twot && y_vel >= 0)) { - obj1.reverse_y(); - obj2.reverse_y(); - } - if ((oner <= twol && x_vel >= 0) - || (onel > twor && x_vel <= 0)) { //bounce horizontally - obj1.reverse_x(); - obj2.reverse_x(); - } - }; - - // handles collisions between different object types - var handle_collision = function(obj1, obj2) { - var ot1 = obj1.get_type(); - var ot2 = obj2.get_type(); - - // try first with one order - var handler = retrieve(collision_handlers, ot1, ot2); - if (handler) { - handler(obj1, obj2); - } - // if it didn't work - else { - // try the other order - handler = retrieve(collision_handlers, ot2, ot1); - if (handler) { - handler(obj2, obj1); - } - else { - //Not an error now? - //throw "Unsupported collision type!"; - } - - } - - // Bounce if appropriate - //bounce_collided(obj1, obj2); - }; - - // object to store all the handlers - // created once with a closure - // dont manage bouncing/changing direction here - var collision_handlers = (function() { - var nothing = function(obj1, obj2) {}; - - // infects the cell, kills the particle - var infect = function(par, cell) { - // only if cell is "alive" - // (ie only one particle per cell) - assert(cell, "Not a cell in infect!"); - if (cell.get_state() !== "dead" - && cell.get_state() !== "dying") { - par.die(); - } - if (cell.get_state() === "alive") { - //Play sound - sounds.play_sound("cell_infect"); - - // increase mutation percentage if level is highest on screen - // must be done before setting state of infected cell - // only happens if infected by particle of cur level - if (par.get_level() === mutation.get_level()) { - mutation.infected_cell(); - } - - cell.set_state("infected"); - cell.set_mutation_info(par.get_mutation_info()); - - // Add 10 to score - score.incr(10 * par.get_level() * mult.get_num()); - } - else { - // otherwise deflect - //bounce(par, cell); - } - }; - - - var handlers = { - "particle": { - // particle vs. particle - // do nothing? - "particle": nothing, - - // particle vs. cell - // infect the cell, kill the particle - "cell": infect, - - // particle vs. wall_cell - // bounce particle off cell - // cell doesn't move - "wall_cell": bounce, - - // particle vs. empty_cell - // // infect the cell, kill the particle - // kill the particle - "empty_cell": function(par, cell) { - // TODO diff sound? - sounds.play_sound("cell_infect"); - par.die(); - }, - - // particle vs. floater - // kill the particle - // floater takes on color of particle - "floater": function(par, flo) { - par.die(); - if (flo.is_alive()) { - // update flo if not activated || level < - // par.level - if (!flo.is_activated() || - flo.get_level() < - par.get_level()) { - flo.set_mutation_info(par.get_mutation_info()); - flo.activate(); - alert_b_cell(flo); - sounds.play_sound("macrophage_infect"); - } - notify("Macrophage activated!", BAD_NOTIFICATION_COLOR); - } - }, - - // particle vs. tkiller - // nothing? - "tkiller": nothing, - - // particle vs. multiplier - // get rid of the mult and incr mult - "multiplier": function(par, mul) { - //par.die(); - mul.die(); - mult.incr(1); - }, - - // particle vs wall - // Kill particle - "wall_segment": function(par, wall) { - par.die(); - } - }, - - // cell vs. cell - // cell vs. wall_cell - // cell vs. empty_cell - // wall_cell vs. wall_cell - // wall_cell vs. empty_cell - // empty_cell vs. empty_cell - // don't let them overlap (is bouncing necessary?) - "cell": { - "cell": nothing, - "wall_cell": nothing, - "empty_cell": nothing - }, - "wall_cell": { - "wall_cell": nothing, - "empty_cell": nothing - }, - "empty_cell": { - "empty_cell": nothing - }, - - // floater vs. cell - // floater vs. wall_cell - // floater vs. empty_cell - // floater vs. floater - // no overlap? - "floater": { - "cell": bounce, - "wall_cell": bounce, - "empty_cell": bounce, - "floater": bounce - }, - - "tkiller": { - // tkiller vs. cell - "cell": function(tk, cell) { - if ((cell.get_state() === "infected" || - cell.get_state() === "active") - && cell.has_antibody() - && same_mutation_level(tk, cell)) { - cell.die(); - sounds.play_sound("kill"); - tk.set_target(null); - if (active_cell === cell) { - //last_active_cell = active_cell; - //active_cell = null; - kill_active_cell(); - } - } - }, - - // tkiller vs. wall_cell - // tkiller vs. empty_cell - // tkiller vs. floater - // tkiller vs. tkiller - // nothing? TODO bounce? - "wall_cell": nothing, - "empty_cell": nothing, - "floater": nothing, - "tkiller": nothing - }, - - "antibody": { - "cell": function(a, c) { - if (same_mutation_level(a, c)) { - if (!c.has_antibody() && - (c.get_state() === "infected" || - c.get_state() === "active")) { - c.set_antibody(a); - } - } - } - }, - - "multiplier": { - // multiplier vs wall - // do nothing - "wall_segment": bounce - }, - - "b_cell": { - "floater": function(b, flo) { - if (b.is_alive() && flo.is_activated()) { - b.set_mutation_info(flo.get_mutation_info()); - b.activate(get_bcell_slot()); - bounce(b, flo); - notify("B-cell activated!", BAD_NOTIFICATION_COLOR); - } - // trying to avoid getting stuck - if (b.is_outdated()) { - bounce(b, flo); - b.set_target(null); - } - }, - "wall_segment": function(b, wall) { - //console.log("collision"); - if (b.is_activated()) { - // start making antibodies - b.make_antibodies(); - // make a tkiller - var tk = make_tkiller(); - tk.set_mutation_info(b.get_mutation_info()); - - notify("Incoming antibodies!", BAD_NOTIFICATION_COLOR); - } - else if (b.is_alive()) { - bounce(b, wall); - } - else if (b.is_outdated()) { - } - } - } - }; - return handlers; - }()); - - //Removes all objs which are either off screen or dead - var remove_objs = function() { - var filter_fun = function(x) { - //Check offscreen, but don't remove newly generated - var offscreen = false; - if (x.is_offscreen()) { - //Only remove particles that are off the right - if (x.is_off_right()) { - if (x.get_type() === "particle") { - offscreen = true; - } - //else false - } - else { - //console.log("removing "+x.to_string()); - offscreen = true; - } - } - return (! (offscreen || x.is_dead())); - }; - for (var i = 0; i < game_objects.length; i++) { - game_objects[i] = game_objects[i].filter(filter_fun); - } - - // check offscreen for active cell - if (active_cell && active_cell.is_offscreen()) { - //active_cell = null; - kill_active_cell(); - } - }; - - // Returns whether the 2 objects have the same mutation level - var same_mutation_level = function(o1, o2) { - var o1level = o1.get_mutation_info().level; - var o2level = o2.get_mutation_info().level; - return (o1level === o2level); - }; - - - // adds a new background tile if the rightmost is onscreen - // ASSUMES ALL WALL TILES ARE SAME SIZE - var back_top = null; - var back_btm = null; - var add_back = (function() { - - var add_one = function(edge_tile) { - if (!goes_off_right(edge_tile)) { - //console.log("adding edge"); - - var new_spec = {}; - var x = edge_tile.get_pos().x - + edge_tile.get_width(); - - var y = status_bar_height; - new_spec.is_top = true; - // switch if it's a bottom edge - if (edge_tile === back_btm) { - // this will be changed in the edge object - y = p.height; - new_spec.is_top = false; - } - - new_spec.pos = new p.PVector(x, y); - - var new_tile = background_edge(p, new_spec); - obj.add_object(new_tile); - - if (edge_tile === back_top) { - back_top = new_tile; - } - else { - back_btm = new_tile; - } - //console.log("added tile "+new_tile.to_string()); - } - }; - - var add_both = function() { - add_one(back_top); - add_one(back_btm); - }; - - return add_both; - }()); - - // initialized the background - var init_back = function() { - // initial edges - back_top = background_edge(p, { - pos: new p.PVector(-100, status_bar_height), - is_top: true - }); - obj.add_object(back_top); - - back_btm = background_edge(p, { - pos: new p.PVector(-10, p.height), - is_top: false - }); - obj.add_object(back_btm); - - // add one more tile to fill screen - add_back(); - }; - - // tells if a background tile goes off the right of the screen - var goes_off_right = function(tile) { - return tile.get_pos().x + tile.get_width() > p.width; - }; - - // adds a new wall segment if the rightmost wall - // segment is onscreen - var rightmost_top = null; - var rightmost_btm = null; - var add_wall = (function() { - - // adds either a top or bottom wall - var add_one = function(rightmost) { - // if the rightmost has entered the screen - if (!rightmost.is_off_right()) { - var new_spec = {}; - - // note that new wall coords should be at - // bottom left corner of seg - // should be next to last seg - var x = rightmost.get_pos().x - + rightmost.get_width()/2 - 5; - - // set y for top wall - var y = 95; - new_spec.is_top = true; - // switch if it's a bottom wall - if (rightmost === rightmost_top) { - y = p.height+5; - new_spec.is_top = false; - } - - new_spec.pos = new p.PVector(x, y); - - // add the new segment - var new_seg = wall_segment(p, new_spec); - obj.add_object(new_seg); - - // update the corresponding rightmost - if (rightmost === rightmost_top) { - rightmost_top = new_seg; - } - else { - rightmost_btm = new_seg; - } - } - }; - - var add_both = function() { - add_one(rightmost_top); - add_one(rightmost_btm); - }; - - return add_both; - }()); - - var init_walls = function() { - // add first empty segments - // the values used here are important so don't change them - rightmost_top = wall_segment(p, { - pos: new p.PVector(-10, 0), - width: 5 - }); - - rightmost_btm = wall_segment(p, { - pos: new p.PVector(-10, p.height), - width: 5 - }); - - // while both walls don't span the screen - while(!(rightmost_top.is_off_right() - && rightmost_btm.is_off_right())) { - // add new walls - add_wall(); - } - }; - - //Does a function to every object - //Pass in a function that takes an object - var do_to_all_objs = function(f) { - for (var i=0; i= 0) ) { - do_to_all_objs(function(o) { o.get_pos().add( - new p.PVector(-dist/10, 0)); }); - //["particle", "cell", "enemy"], false); - } - } - }; - - - // --- public methods --- - - obj.get_type = function() { - return "game"; - }; - - //Calls update() on every obj - //after updating, calls remove_objs - obj.update = (function() { - var game_types = ["background", "wall", "particle", - "cell", "enemy", "multiplier", "antibody"]; - - var update_fun = function() { - // Can't be set when object is initialized - // Takes time every update though to check - if (!set_time) { - //Set interval to update time elapsed - var update_time = function() { - if (!paused) { - time_elapsed += 1; - time_status.set_num(time_elapsed); - } - } - setInterval(update_time, 1000); - set_time = true; - } - if (!paused) { - // if we don't have an active cell - if (active_cell === null) { - // try to find the next one - next_active_cell(); - } - // THIS MUST COME BEFORE GAME OVER CHECK - - // check for game over - // (if no particles are left and no active cell) - //console.log("num of particles: " + level("particle").length); - if (active_cell === null && - level("particle").length === 0) { - var go_state = game_over_state(p, previous_state, { - score : score.get_num(), - mutation_level : mutation.get_level() - }); - sounds.pause_background_music(); - obj.set_next_state(go_state); - - // stop the animations - do_to_all_objs( - function(o) { - if (o.stop_animation) { - o.stop_animation(); - } - } - ); - - // stop notifications - all_notifications = []; - - // stop the time and stuff - paused = true; - - // Add to the high score table - // If fb user name and id are set - if (g_user_name && g_user_id) { - scores.submit_score(score.get_num(), - mutation.get_level(), g_user_name, g_user_id); - // Update the high score table - // (not necessary now) - //scores.do_scores(); - } - - // simply don't do the rest of update - return; - } - - //Add any newly generated objs - generator.update(); - - // Make antibodies seek any infected cells they are near - make_antibodies_seek(); - - // Add antibodies generated from b cells - do_to_type( - function(b) { - obj.add_objects(b.get_antibodies()); - }, - "b_cell", true - ); - - // adds a new segment of wall if necessary - add_wall(); - // adds a new background tile if necessary - add_back(); - - add_tkillers(); - update_tkillers_targets(); - - // set outdated t/b cells - set_all_outdated(); - - // scroll all objects - - do_to_all_objs(function(o){ - o.scroll(scroll_factor); - }); - - //dynamic_scroll(); - - // update distance travelled - distance += scroll_factor; - - // update all objects - do_to_all_objs(function(o){ - o.update(); - }); - - check_collisions(); - - remove_objs(); - - update_mutation(); - - /* - // for debugging - var count = 0; - do_to_all_objs(function() { count += 1; }); - console.log(count); - console.log("fr "+p.__frameRate); - */ - } - }; - - var update_mutation = function() { - // check for a new mutation - // if mutation occurred - if (mutation.has_new_mutation() && active_cell) { - // pick infected cell closest to active cell with the current - // mutation level - var choices = get_all_of_type("cell").filter( - function(c) { - return ((c.get_state() === "infected" - || c.get_state() === "active") - && c.get_level() === mutation.get_level()); - } - ); - choices.sort( - function(c1, c2) { - return dist_less_than(active_cell, c1, c2) ? -1 : 1; - } - ); - var cell_to_mutate = choices[0]; - - // do the actual mutation and hold onto new ability - //var new_ability = - mutation.do_mutation(); - // mutate the active cell - cell_to_mutate.set_mutation_info(mutation.get_info()); - // update the scroll factor - scroll_factor += 0.15; - - //if (new_ability) { - // notify("New Ability: " + new_ability); - //} - //else { - notify("Mutation occurred!", GOOD_NOTIFICATION_COLOR); - //} - - console.log("mutation occurred!"); - } - // otherwise check for downgrades - else { - // check for the highest mutation level on screen - var max_level = 0; - var find_max = function(o) { - if (o.get_level() > max_level) { - max_level = o.get_level(); - } - }; - do_to_type(find_max, "cell", false); - do_to_type(find_max, "particle", false); - - // if max level lower than mutation level - if (max_level > 0 && max_level < mutation.get_level()) { - // downgrade to that level - mutation.set_level(max_level); - // reset the counters - mutation.reset_mutation(); - - notify("Lost new strain!", BAD_NOTIFICATION_COLOR); - console.log("downgraded to mutation level "+max_level); - - scroll_factor -= 0.15; - - // TODO do enemies become not outdated? - } - } - }; - - return update_fun; - }()); - - //Calls draw() on every obj - obj.render = function(){ - - // put the active cell at the end of the list - // so it is drawn on top - if (active_cell) { - var cells = level("cell"); - remove_elt(cells, active_cell); - cells.push(active_cell); - } - - p.background(g.background_color); - - for (var i=0; i -Virion - - - - - - -
        - - - - - - diff --git a/game/old/fb/index1.html b/game/old/fb/index1.html deleted file mode 100644 index a096db5..0000000 --- a/game/old/fb/index1.html +++ /dev/null @@ -1,298 +0,0 @@ - - - -Virion - - - - - - - - - - -
        - - - - - - - -
        - - -
        - -
        -
        - Could not load high scores! You may want to check your internet connection. -
        -
        - - - Your browser does not support the HTML5 canvas element. Upgrade to Chrome, Firefox 4, Safari, or Opera to play this game. - -
        -
        Virion was created as an entry in the Hidden Agenda contest.
        If you like the game, leave some feedback on the Hidden Agenda page to help Virion win!
        - -
        -
        - -
        -
        - Note: Virion was built entirely using the new open HTML5 standard and the Processing.js JavaScript library. This means that you will never have to install a proprietary plugin to play our game, and in the near future will be able to play our game on any browser on any platform. Currently, however, some browsers do not yet have full support for the HTML5 standard, so please note the following browser compatibility issues:

        - Google Chrome has no problems, and is highly recommended for the best overall performance
        - If you are using Firefox 3 and the game is not loading or running slowly, try updating to Firefox 4
        - If you are using Safari and seeing performance issues, try turning off the sound effects
        - If you are using Internet Explorer, please switch to any of the above browsers immediately! -

        -
        -
        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/old/fb/indexTest.html b/game/old/fb/indexTest.html deleted file mode 100644 index 15c3b4d..0000000 --- a/game/old/fb/indexTest.html +++ /dev/null @@ -1,105 +0,0 @@ - -Virion - - - - - - - -
        - - - - - - diff --git a/game/old/fb/jplayer/Jplayer.swf b/game/old/fb/jplayer/Jplayer.swf deleted file mode 100755 index 9487f49..0000000 Binary files a/game/old/fb/jplayer/Jplayer.swf and /dev/null differ diff --git a/game/old/fb/jplayer/jquery.jplayer.min.js b/game/old/fb/jplayer/jquery.jplayer.min.js deleted file mode 100755 index b9b7007..0000000 --- a/game/old/fb/jplayer/jquery.jplayer.min.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - * jPlayer Plugin for jQuery JavaScript Library - * http://www.happyworm.com/jquery/jplayer - * - * Copyright (c) 2009 - 2010 Happyworm Ltd - * Dual licensed under the MIT and GPL licenses. - * - http://www.opensource.org/licenses/mit-license.php - * - http://www.gnu.org/copyleft/gpl.html - * - * Author: Mark J Panaghiston - * Version: 2.0.0 - * Date: 20th December 2010 - */ - -(function(c,h){c.fn.jPlayer=function(a){var b=typeof a==="string",d=Array.prototype.slice.call(arguments,1),f=this;a=!b&&d.length?c.extend.apply(null,[true,a].concat(d)):a;if(b&&a.charAt(0)==="_")return f;b?this.each(function(){var e=c.data(this,"jPlayer"),g=e&&c.isFunction(e[a])?e[a].apply(e,d):e;if(g!==e&&g!==h){f=g;return false}}):this.each(function(){var e=c.data(this,"jPlayer");if(e){e.option(a||{})._init();e.option(a||{})}else c.data(this,"jPlayer",new c.jPlayer(a,this))});return f};c.jPlayer= -function(a,b){if(arguments.length){this.element=c(b);this.options=c.extend(true,{},this.options,a);var d=this;this.element.bind("remove.jPlayer",function(){d.destroy()});this._init()}};c.jPlayer.event={ready:"jPlayer_ready",resize:"jPlayer_resize",error:"jPlayer_error",warning:"jPlayer_warning",loadstart:"jPlayer_loadstart",progress:"jPlayer_progress",suspend:"jPlayer_suspend",abort:"jPlayer_abort",emptied:"jPlayer_emptied",stalled:"jPlayer_stalled",play:"jPlayer_play",pause:"jPlayer_pause",loadedmetadata:"jPlayer_loadedmetadata", -loadeddata:"jPlayer_loadeddata",waiting:"jPlayer_waiting",playing:"jPlayer_playing",canplay:"jPlayer_canplay",canplaythrough:"jPlayer_canplaythrough",seeking:"jPlayer_seeking",seeked:"jPlayer_seeked",timeupdate:"jPlayer_timeupdate",ended:"jPlayer_ended",ratechange:"jPlayer_ratechange",durationchange:"jPlayer_durationchange",volumechange:"jPlayer_volumechange"};c.jPlayer.htmlEvent=["loadstart","abort","emptied","stalled","loadedmetadata","loadeddata","canplaythrough","ratechange"];c.jPlayer.pause= -function(){c.each(c.jPlayer.prototype.instances,function(a,b){b.data("jPlayer").status.srcSet&&b.jPlayer("pause")})};c.jPlayer.timeFormat={showHour:false,showMin:true,showSec:true,padHour:false,padMin:true,padSec:true,sepHour:":",sepMin:":",sepSec:""};c.jPlayer.convertTime=function(a){a=new Date(a*1E3);var b=a.getUTCHours(),d=a.getUTCMinutes();a=a.getUTCSeconds();b=c.jPlayer.timeFormat.padHour&&b<10?"0"+b:b;d=c.jPlayer.timeFormat.padMin&&d<10?"0"+d:d;a=c.jPlayer.timeFormat.padSec&&a<10?"0"+a:a;return(c.jPlayer.timeFormat.showHour? -b+c.jPlayer.timeFormat.sepHour:"")+(c.jPlayer.timeFormat.showMin?d+c.jPlayer.timeFormat.sepMin:"")+(c.jPlayer.timeFormat.showSec?a+c.jPlayer.timeFormat.sepSec:"")};c.jPlayer.uaMatch=function(a){a=a.toLowerCase();var b=/(opera)(?:.*version)?[ \/]([\w.]+)/,d=/(msie) ([\w.]+)/,f=/(mozilla)(?:.*? rv:([\w.]+))?/;a=/(webkit)[ \/]([\w.]+)/.exec(a)||b.exec(a)||d.exec(a)||a.indexOf("compatible")<0&&f.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}};c.jPlayer.browser={};var m=c.jPlayer.uaMatch(navigator.userAgent); -if(m.browser){c.jPlayer.browser[m.browser]=true;c.jPlayer.browser.version=m.version}c.jPlayer.prototype={count:0,version:{script:"2.0.0",needFlash:"2.0.0",flash:"unknown"},options:{swfPath:"./",solution:"html, flash",supplied:"mp3",preload:"metadata",volume:0.8,muted:false,backgroundColor:"#000000",cssSelectorAncestor:"#jp_interface_1",cssSelector:{videoPlay:".jp-video-play",play:".jp-play",pause:".jp-pause",stop:".jp-stop",seekBar:".jp-seek-bar",playBar:".jp-play-bar",mute:".jp-mute",unmute:".jp-unmute", -volumeBar:".jp-volume-bar",volumeBarValue:".jp-volume-bar-value",currentTime:".jp-current-time",duration:".jp-duration"},idPrefix:"jp",errorAlerts:false,warningAlerts:false},instances:{},status:{src:"",media:{},paused:true,format:{},formatType:"",waitForPlay:true,waitForLoad:true,srcSet:false,video:false,seekPercent:0,currentPercentRelative:0,currentPercentAbsolute:0,currentTime:0,duration:0},_status:{volume:h,muted:false,width:0,height:0},internal:{ready:false,instance:h,htmlDlyCmdId:h},solution:{html:true, -flash:true},format:{mp3:{codec:'audio/mpeg; codecs="mp3"',flashCanPlay:true,media:"audio"},m4a:{codec:'audio/mp4; codecs="mp4a.40.2"',flashCanPlay:true,media:"audio"},oga:{codec:'audio/ogg; codecs="vorbis"',flashCanPlay:false,media:"audio"},wav:{codec:'audio/wav; codecs="1"',flashCanPlay:false,media:"audio"},webma:{codec:'audio/webm; codecs="vorbis"',flashCanPlay:false,media:"audio"},m4v:{codec:'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',flashCanPlay:true,media:"video"},ogv:{codec:'video/ogg; codecs="theora, vorbis"', -flashCanPlay:false,media:"video"},webmv:{codec:'video/webm; codecs="vorbis, vp8"',flashCanPlay:false,media:"video"}},_init:function(){var a=this;this.element.empty();this.status=c.extend({},this.status,this._status);this.internal=c.extend({},this.internal);this.formats=[];this.solutions=[];this.require={};this.htmlElement={};this.html={};this.html.audio={};this.html.video={};this.flash={};this.css={};this.css.cs={};this.css.jq={};this.status.volume=this._limitValue(this.options.volume,0,1);this.status.muted= -this.options.muted;this.status.width=this.element.css("width");this.status.height=this.element.css("height");this.element.css({"background-color":this.options.backgroundColor});c.each(this.options.supplied.toLowerCase().split(","),function(e,g){var i=g.replace(/^\s+|\s+$/g,"");if(a.format[i]){var j=false;c.each(a.formats,function(n,k){if(i===k){j=true;return false}});j||a.formats.push(i)}});c.each(this.options.solution.toLowerCase().split(","),function(e,g){var i=g.replace(/^\s+|\s+$/g,"");if(a.solution[i]){var j= -false;c.each(a.solutions,function(n,k){if(i===k){j=true;return false}});j||a.solutions.push(i)}});this.internal.instance="jp_"+this.count;this.instances[this.internal.instance]=this.element;this.element.attr("id")===""&&this.element.attr("id",this.options.idPrefix+"_jplayer_"+this.count);this.internal.self=c.extend({},{id:this.element.attr("id"),jq:this.element});this.internal.audio=c.extend({},{id:this.options.idPrefix+"_audio_"+this.count,jq:h});this.internal.video=c.extend({},{id:this.options.idPrefix+ -"_video_"+this.count,jq:h});this.internal.flash=c.extend({},{id:this.options.idPrefix+"_flash_"+this.count,jq:h,swf:this.options.swfPath+(this.options.swfPath!==""&&this.options.swfPath.slice(-1)!=="/"?"/":"")+"Jplayer.swf"});this.internal.poster=c.extend({},{id:this.options.idPrefix+"_poster_"+this.count,jq:h});c.each(c.jPlayer.event,function(e,g){if(a.options[e]!==h){a.element.bind(g+".jPlayer",a.options[e]);a.options[e]=h}});this.htmlElement.poster=document.createElement("img");this.htmlElement.poster.id= -this.internal.poster.id;this.htmlElement.poster.onload=function(){if(!a.status.video||a.status.waitForPlay)a.internal.poster.jq.show()};this.element.append(this.htmlElement.poster);this.internal.poster.jq=c("#"+this.internal.poster.id);this.internal.poster.jq.css({width:this.status.width,height:this.status.height});this.internal.poster.jq.hide();this.require.audio=false;this.require.video=false;c.each(this.formats,function(e,g){a.require[a.format[g].media]=true});this.html.audio.available=false;if(this.require.audio){this.htmlElement.audio= -document.createElement("audio");this.htmlElement.audio.id=this.internal.audio.id;this.html.audio.available=!!this.htmlElement.audio.canPlayType}this.html.video.available=false;if(this.require.video){this.htmlElement.video=document.createElement("video");this.htmlElement.video.id=this.internal.video.id;this.html.video.available=!!this.htmlElement.video.canPlayType}this.flash.available=this._checkForFlash(10);this.html.canPlay={};this.flash.canPlay={};c.each(this.formats,function(e,g){a.html.canPlay[g]= -a.html[a.format[g].media].available&&""!==a.htmlElement[a.format[g].media].canPlayType(a.format[g].codec);a.flash.canPlay[g]=a.format[g].flashCanPlay&&a.flash.available});this.html.desired=false;this.flash.desired=false;c.each(this.solutions,function(e,g){if(e===0)a[g].desired=true;else{var i=false,j=false;c.each(a.formats,function(n,k){if(a[a.solutions[0]].canPlay[k])if(a.format[k].media==="video")j=true;else i=true});a[g].desired=a.require.audio&&!i||a.require.video&&!j}});this.html.support={}; -this.flash.support={};c.each(this.formats,function(e,g){a.html.support[g]=a.html.canPlay[g]&&a.html.desired;a.flash.support[g]=a.flash.canPlay[g]&&a.flash.desired});this.html.used=false;this.flash.used=false;c.each(this.solutions,function(e,g){c.each(a.formats,function(i,j){if(a[g].support[j]){a[g].used=true;return false}})});this.html.used||this.flash.used||this._error({type:c.jPlayer.error.NO_SOLUTION,context:"{solution:'"+this.options.solution+"', supplied:'"+this.options.supplied+"'}",message:c.jPlayer.errorMsg.NO_SOLUTION, -hint:c.jPlayer.errorHint.NO_SOLUTION});this.html.active=false;this.html.audio.gate=false;this.html.video.gate=false;this.flash.active=false;this.flash.gate=false;if(this.flash.used){var b="id="+escape(this.internal.self.id)+"&vol="+this.status.volume+"&muted="+this.status.muted;if(c.browser.msie&&Number(c.browser.version)<=8){var d='';f[1]='';f[2]='';f[3]='';f[4]='';b=document.createElement(d);for(d=0;d0?100*d/this.status.duration:0;if(typeof a.seekable==="object"&&a.seekable.length>0){e=this.status.duration>0?100*a.seekable.end(a.seekable.length-1)/this.status.duration:100;g=100*a.currentTime/a.seekable.end(a.seekable.length-1)}else{e=100;g=f}if(b)f=g=d=0;this.status.seekPercent=e;this.status.currentPercentRelative=g;this.status.currentPercentAbsolute=f;this.status.currentTime=d},_resetStatus:function(){this.status=c.extend({},this.status,c.jPlayer.prototype.status)}, -_trigger:function(a,b,d){a=c.Event(a);a.jPlayer={};a.jPlayer.version=c.extend({},this.version);a.jPlayer.status=c.extend(true,{},this.status);a.jPlayer.html=c.extend(true,{},this.html);a.jPlayer.flash=c.extend(true,{},this.flash);if(b)a.jPlayer.error=c.extend({},b);if(d)a.jPlayer.warning=c.extend({},d);this.element.trigger(a)},jPlayerFlashEvent:function(a,b){if(a===c.jPlayer.event.ready&&!this.internal.ready){this.internal.ready=true;this.version.flash=b.version;this.version.needFlash!==this.version.flash&& -this._error({type:c.jPlayer.error.VERSION,context:this.version.flash,message:c.jPlayer.errorMsg.VERSION+this.version.flash,hint:c.jPlayer.errorHint.VERSION});this._trigger(a)}if(this.flash.gate)switch(a){case c.jPlayer.event.progress:this._getFlashStatus(b);this._updateInterface();this._trigger(a);break;case c.jPlayer.event.timeupdate:this._getFlashStatus(b);this._updateInterface();this._trigger(a);break;case c.jPlayer.event.play:this._seeked();this._updateButtons(true);this._trigger(a);break;case c.jPlayer.event.pause:this._updateButtons(false); -this._trigger(a);break;case c.jPlayer.event.ended:this._updateButtons(false);this._trigger(a);break;case c.jPlayer.event.error:this.status.waitForLoad=true;this.status.waitForPlay=true;this.status.video&&this.internal.flash.jq.css({width:"0px",height:"0px"});this._validString(this.status.media.poster)&&this.internal.poster.jq.show();this.css.jq.videoPlay.length&&this.css.jq.videoPlay.show();this.status.video?this._flash_setVideo(this.status.media):this._flash_setAudio(this.status.media);this._error({type:c.jPlayer.error.URL, -context:b.src,message:c.jPlayer.errorMsg.URL,hint:c.jPlayer.errorHint.URL});break;case c.jPlayer.event.seeking:this._seeking();this._trigger(a);break;case c.jPlayer.event.seeked:this._seeked();this._trigger(a);break;default:this._trigger(a)}return false},_getFlashStatus:function(a){this.status.seekPercent=a.seekPercent;this.status.currentPercentRelative=a.currentPercentRelative;this.status.currentPercentAbsolute=a.currentPercentAbsolute;this.status.currentTime=a.currentTime;this.status.duration=a.duration}, -_updateButtons:function(a){this.status.paused=!a;if(this.css.jq.play.length&&this.css.jq.pause.length)if(a){this.css.jq.play.hide();this.css.jq.pause.show()}else{this.css.jq.play.show();this.css.jq.pause.hide()}},_updateInterface:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.width(this.status.seekPercent+"%");this.css.jq.playBar.length&&this.css.jq.playBar.width(this.status.currentPercentRelative+"%");this.css.jq.currentTime.length&&this.css.jq.currentTime.text(c.jPlayer.convertTime(this.status.currentTime)); -this.css.jq.duration.length&&this.css.jq.duration.text(c.jPlayer.convertTime(this.status.duration))},_seeking:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.addClass("jp-seeking-bg")},_seeked:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.removeClass("jp-seeking-bg")},setMedia:function(a){var b=this;this._seeked();clearTimeout(this.internal.htmlDlyCmdId);var d=this.html.audio.gate,f=this.html.video.gate,e=false;c.each(this.formats,function(g,i){var j=b.format[i].media==="video"; -c.each(b.solutions,function(n,k){if(b[k].support[i]&&b._validString(a[i])){var l=k==="html";if(j)if(l){b.html.audio.gate=false;b.html.video.gate=true;b.flash.gate=false}else{b.html.audio.gate=false;b.html.video.gate=false;b.flash.gate=true}else if(l){b.html.audio.gate=true;b.html.video.gate=false;b.flash.gate=false}else{b.html.audio.gate=false;b.html.video.gate=false;b.flash.gate=true}if(b.flash.active||b.html.active&&b.flash.gate||d===b.html.audio.gate&&f===b.html.video.gate)b.clearMedia();else if(d!== -b.html.audio.gate&&f!==b.html.video.gate){b._html_pause();b.status.video&&b.internal.video.jq.css({width:"0px",height:"0px"});b._resetStatus()}if(j){if(l){b._html_setVideo(a);b.html.active=true;b.flash.active=false}else{b._flash_setVideo(a);b.html.active=false;b.flash.active=true}b.css.jq.videoPlay.length&&b.css.jq.videoPlay.show();b.status.video=true}else{if(l){b._html_setAudio(a);b.html.active=true;b.flash.active=false}else{b._flash_setAudio(a);b.html.active=false;b.flash.active=true}b.css.jq.videoPlay.length&& -b.css.jq.videoPlay.hide();b.status.video=false}e=true;return false}});if(e)return false});if(e){if(this._validString(a.poster))if(this.htmlElement.poster.src!==a.poster)this.htmlElement.poster.src=a.poster;else this.internal.poster.jq.show();else this.internal.poster.jq.hide();this.status.srcSet=true;this.status.media=c.extend({},a);this._updateButtons(false);this._updateInterface()}else{this.status.srcSet&&!this.status.waitForPlay&&this.pause();this.html.audio.gate=false;this.html.video.gate=false; -this.flash.gate=false;this.html.active=false;this.flash.active=false;this._resetStatus();this._updateInterface();this._updateButtons(false);this.internal.poster.jq.hide();this.html.used&&this.require.video&&this.internal.video.jq.css({width:"0px",height:"0px"});this.flash.used&&this.internal.flash.jq.css({width:"0px",height:"0px"});this._error({type:c.jPlayer.error.NO_SUPPORT,context:"{supplied:'"+this.options.supplied+"'}",message:c.jPlayer.errorMsg.NO_SUPPORT,hint:c.jPlayer.errorHint.NO_SUPPORT})}}, -clearMedia:function(){this._resetStatus();this._updateButtons(false);this.internal.poster.jq.hide();clearTimeout(this.internal.htmlDlyCmdId);if(this.html.active)this._html_clearMedia();else this.flash.active&&this._flash_clearMedia()},load:function(){if(this.status.srcSet)if(this.html.active)this._html_load();else this.flash.active&&this._flash_load();else this._urlNotSetError("load")},play:function(a){a=typeof a==="number"?a:NaN;if(this.status.srcSet)if(this.html.active)this._html_play(a);else this.flash.active&& -this._flash_play(a);else this._urlNotSetError("play")},videoPlay:function(){this.play()},pause:function(a){a=typeof a==="number"?a:NaN;if(this.status.srcSet)if(this.html.active)this._html_pause(a);else this.flash.active&&this._flash_pause(a);else this._urlNotSetError("pause")},pauseOthers:function(){var a=this;c.each(this.instances,function(b,d){a.element!==d&&d.data("jPlayer").status.srcSet&&d.jPlayer("pause")})},stop:function(){if(this.status.srcSet)if(this.html.active)this._html_pause(0);else this.flash.active&& -this._flash_pause(0);else this._urlNotSetError("stop")},playHead:function(a){a=this._limitValue(a,0,100);if(this.status.srcSet)if(this.html.active)this._html_playHead(a);else this.flash.active&&this._flash_playHead(a);else this._urlNotSetError("playHead")},mute:function(){this.status.muted=true;this.html.used&&this._html_mute(true);this.flash.used&&this._flash_mute(true);this._updateMute(true);this._updateVolume(0);this._trigger(c.jPlayer.event.volumechange)},unmute:function(){this.status.muted=false; -this.html.used&&this._html_mute(false);this.flash.used&&this._flash_mute(false);this._updateMute(false);this._updateVolume(this.status.volume);this._trigger(c.jPlayer.event.volumechange)},_updateMute:function(a){if(this.css.jq.mute.length&&this.css.jq.unmute.length)if(a){this.css.jq.mute.hide();this.css.jq.unmute.show()}else{this.css.jq.mute.show();this.css.jq.unmute.hide()}},volume:function(a){a=this._limitValue(a,0,1);this.status.volume=a;this.html.used&&this._html_volume(a);this.flash.used&&this._flash_volume(a); -this.status.muted||this._updateVolume(a);this._trigger(c.jPlayer.event.volumechange)},volumeBar:function(a){if(!this.status.muted&&this.css.jq.volumeBar){var b=this.css.jq.volumeBar.offset();a=a.pageX-b.left;b=this.css.jq.volumeBar.width();this.volume(a/b)}},volumeBarValue:function(a){this.volumeBar(a)},_updateVolume:function(a){this.css.jq.volumeBarValue.length&&this.css.jq.volumeBarValue.width(a*100+"%")},_volumeFix:function(a){var b=0.0010*Math.random();return a+(a<0.5?b:-b)},_cssSelectorAncestor:function(a, -b){this.options.cssSelectorAncestor=a;b&&c.each(this.options.cssSelector,function(d,f){self._cssSelector(d,f)})},_cssSelector:function(a,b){var d=this;if(typeof b==="string")if(c.jPlayer.prototype.options.cssSelector[a]){this.css.jq[a]&&this.css.jq[a].length&&this.css.jq[a].unbind(".jPlayer");this.options.cssSelector[a]=b;this.css.cs[a]=this.options.cssSelectorAncestor+" "+b;this.css.jq[a]=b?c(this.css.cs[a]):[];this.css.jq[a].length&&this.css.jq[a].bind("click.jPlayer",function(f){d[a](f);c(this).blur(); -return false});b&&this.css.jq[a].length!==1&&this._warning({type:c.jPlayer.warning.CSS_SELECTOR_COUNT,context:this.css.cs[a],message:c.jPlayer.warningMsg.CSS_SELECTOR_COUNT+this.css.jq[a].length+" found for "+a+" method.",hint:c.jPlayer.warningHint.CSS_SELECTOR_COUNT})}else this._warning({type:c.jPlayer.warning.CSS_SELECTOR_METHOD,context:a,message:c.jPlayer.warningMsg.CSS_SELECTOR_METHOD,hint:c.jPlayer.warningHint.CSS_SELECTOR_METHOD});else this._warning({type:c.jPlayer.warning.CSS_SELECTOR_STRING, -context:b,message:c.jPlayer.warningMsg.CSS_SELECTOR_STRING,hint:c.jPlayer.warningHint.CSS_SELECTOR_STRING})},seekBar:function(a){if(this.css.jq.seekBar){var b=this.css.jq.seekBar.offset();a=a.pageX-b.left;b=this.css.jq.seekBar.width();this.playHead(100*a/b)}},playBar:function(a){this.seekBar(a)},currentTime:function(){},duration:function(){},option:function(a,b){var d=a;if(arguments.length===0)return c.extend(true,{},this.options);if(typeof a==="string"){var f=a.split(".");if(b===h){for(var e=c.extend(true, -{},this.options),g=0;g=9||this.htmlElement.media.load()}},_html_load:function(){if(this.status.waitForLoad){this.status.waitForLoad=false;this.htmlElement.media.src=this.status.src; -try{this.htmlElement.media.load()}catch(a){}}clearTimeout(this.internal.htmlDlyCmdId)},_html_play:function(a){var b=this;this._html_load();this.htmlElement.media.play();if(!isNaN(a))try{this.htmlElement.media.currentTime=a}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.play(a)},100);return}this._html_checkWaitForPlay()},_html_pause:function(a){var b=this;a>0?this._html_load():clearTimeout(this.internal.htmlDlyCmdId);this.htmlElement.media.pause();if(!isNaN(a))try{this.htmlElement.media.currentTime= -a}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.pause(a)},100);return}a>0&&this._html_checkWaitForPlay()},_html_playHead:function(a){var b=this;this._html_load();try{if(typeof this.htmlElement.media.seekable==="object"&&this.htmlElement.media.seekable.length>0)this.htmlElement.media.currentTime=a*this.htmlElement.media.seekable.end(this.htmlElement.media.seekable.length-1)/100;else if(this.htmlElement.media.duration>0&&!isNaN(this.htmlElement.media.duration))this.htmlElement.media.currentTime= -a*this.htmlElement.media.duration/100;else throw"e";}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.playHead(a)},100);return}this.status.waitForLoad||this._html_checkWaitForPlay()},_html_checkWaitForPlay:function(){if(this.status.waitForPlay){this.status.waitForPlay=false;this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide();if(this.status.video){this.internal.poster.jq.hide();this.internal.video.jq.css({width:this.status.width,height:this.status.height})}}},_html_volume:function(a){if(this.html.audio.available)this.htmlElement.audio.volume= -a;if(this.html.video.available)this.htmlElement.video.volume=a},_html_mute:function(a){if(this.html.audio.available)this.htmlElement.audio.muted=a;if(this.html.video.available)this.htmlElement.video.muted=a},_flash_setAudio:function(a){var b=this;try{c.each(this.formats,function(f,e){if(b.flash.support[e]&&a[e]){switch(e){case "m4a":b._getMovie().fl_setAudio_m4a(a[e]);break;case "mp3":b._getMovie().fl_setAudio_mp3(a[e])}b.status.src=a[e];b.status.format[e]=true;b.status.formatType=e;return false}}); -if(this.options.preload==="auto"){this._flash_load();this.status.waitForLoad=false}}catch(d){this._flashError(d)}},_flash_setVideo:function(a){var b=this;try{c.each(this.formats,function(f,e){if(b.flash.support[e]&&a[e]){switch(e){case "m4v":b._getMovie().fl_setVideo_m4v(a[e])}b.status.src=a[e];b.status.format[e]=true;b.status.formatType=e;return false}});if(this.options.preload==="auto"){this._flash_load();this.status.waitForLoad=false}}catch(d){this._flashError(d)}},_flash_clearMedia:function(){this.internal.flash.jq.css({width:"0px", -height:"0px"});try{this._getMovie().fl_clearMedia()}catch(a){this._flashError(a)}},_flash_load:function(){try{this._getMovie().fl_load()}catch(a){this._flashError(a)}this.status.waitForLoad=false},_flash_play:function(a){try{this._getMovie().fl_play(a)}catch(b){this._flashError(b)}this.status.waitForLoad=false;this._flash_checkWaitForPlay()},_flash_pause:function(a){try{this._getMovie().fl_pause(a)}catch(b){this._flashError(b)}if(a>0){this.status.waitForLoad=false;this._flash_checkWaitForPlay()}}, -_flash_playHead:function(a){try{this._getMovie().fl_play_head(a)}catch(b){this._flashError(b)}this.status.waitForLoad||this._flash_checkWaitForPlay()},_flash_checkWaitForPlay:function(){if(this.status.waitForPlay){this.status.waitForPlay=false;this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide();if(this.status.video){this.internal.poster.jq.hide();this.internal.flash.jq.css({width:this.status.width,height:this.status.height})}}},_flash_volume:function(a){try{this._getMovie().fl_volume(a)}catch(b){this._flashError(b)}}, -_flash_mute:function(a){try{this._getMovie().fl_mute(a)}catch(b){this._flashError(b)}},_getMovie:function(){return document[this.internal.flash.id]},_checkForFlash:function(a){var b=false,d;if(window.ActiveXObject)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+a);b=true}catch(f){}else if(navigator.plugins&&navigator.mimeTypes.length>0)if(d=navigator.plugins["Shockwave Flash"])if(navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/,"$1")>=a)b=true;return c.browser.msie&& -Number(c.browser.version)>=9?false:b},_validString:function(a){return a&&typeof a==="string"},_limitValue:function(a,b,d){return ad?d:a},_urlNotSetError:function(a){this._error({type:c.jPlayer.error.URL_NOT_SET,context:a,message:c.jPlayer.errorMsg.URL_NOT_SET,hint:c.jPlayer.errorHint.URL_NOT_SET})},_flashError:function(a){this._error({type:c.jPlayer.error.FLASH,context:this.internal.flash.swf,message:c.jPlayer.errorMsg.FLASH+a.message,hint:c.jPlayer.errorHint.FLASH})},_error:function(a){this._trigger(c.jPlayer.event.error, -a);if(this.options.errorAlerts)this._alert("Error!"+(a.message?"\n\n"+a.message:"")+(a.hint?"\n\n"+a.hint:"")+"\n\nContext: "+a.context)},_warning:function(a){this._trigger(c.jPlayer.event.warning,h,a);if(this.options.errorAlerts)this._alert("Warning!"+(a.message?"\n\n"+a.message:"")+(a.hint?"\n\n"+a.hint:"")+"\n\nContext: "+a.context)},_alert:function(a){alert("jPlayer "+this.version.script+" : id='"+this.internal.self.id+"' : "+a)}};c.jPlayer.error={FLASH:"e_flash",NO_SOLUTION:"e_no_solution",NO_SUPPORT:"e_no_support", -URL:"e_url",URL_NOT_SET:"e_url_not_set",VERSION:"e_version"};c.jPlayer.errorMsg={FLASH:"jPlayer's Flash fallback is not configured correctly, or a command was issued before the jPlayer Ready event. Details: ",NO_SOLUTION:"No solution can be found by jPlayer in this browser. Neither HTML nor Flash can be used.",NO_SUPPORT:"It is not possible to play any media format provided in setMedia() on this browser using your current options.",URL:"Media URL could not be loaded.",URL_NOT_SET:"Attempt to issue media playback commands, while no media url is set.", -VERSION:"jPlayer "+c.jPlayer.prototype.version.script+" needs Jplayer.swf version "+c.jPlayer.prototype.version.needFlash+" but found "};c.jPlayer.errorHint={FLASH:"Check your swfPath option and that Jplayer.swf is there.",NO_SOLUTION:"Review the jPlayer options: support and supplied.",NO_SUPPORT:"Video or audio formats defined in the supplied option are missing.",URL:"Check media URL is valid.",URL_NOT_SET:"Use setMedia() to set the media URL.",VERSION:"Update jPlayer files."};c.jPlayer.warning= -{CSS_SELECTOR_COUNT:"e_css_selector_count",CSS_SELECTOR_METHOD:"e_css_selector_method",CSS_SELECTOR_STRING:"e_css_selector_string",OPTION_KEY:"e_option_key"};c.jPlayer.warningMsg={CSS_SELECTOR_COUNT:"The number of methodCssSelectors found did not equal one: ",CSS_SELECTOR_METHOD:"The methodName given in jPlayer('cssSelector') is not a valid jPlayer method.",CSS_SELECTOR_STRING:"The methodCssSelector given in jPlayer('cssSelector') is not a String or is empty.",OPTION_KEY:"The option requested in jPlayer('option') is undefined."}; -c.jPlayer.warningHint={CSS_SELECTOR_COUNT:"Check your css selector and the ancestor.",CSS_SELECTOR_METHOD:"Check your method name.",CSS_SELECTOR_STRING:"Check your css selector is a string.",OPTION_KEY:"Check your option name."}})(jQuery); diff --git a/game/old/fb/jquery-1.4.4.min.js b/game/old/fb/jquery-1.4.4.min.js deleted file mode 100644 index 8f3ca2e..0000000 --- a/game/old/fb/jquery-1.4.4.min.js +++ /dev/null @@ -1,167 +0,0 @@ -/*! - * jQuery JavaScript Library v1.4.4 - * http://jquery.com/ - * - * Copyright 2010, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * Copyright 2010, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * - * Date: Thu Nov 11 19:04:53 2010 -0500 - */ -(function(E,B){function ka(a,b,d){if(d===B&&a.nodeType===1){d=a.getAttribute("data-"+b);if(typeof d==="string"){try{d=d==="true"?true:d==="false"?false:d==="null"?null:!c.isNaN(d)?parseFloat(d):Ja.test(d)?c.parseJSON(d):d}catch(e){}c.data(a,b,d)}else d=B}return d}function U(){return false}function ca(){return true}function la(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function Ka(a){var b,d,e,f,h,l,k,o,x,r,A,C=[];f=[];h=c.data(this,this.nodeType?"events":"__events__");if(typeof h==="function")h= -h.events;if(!(a.liveFired===this||!h||!h.live||a.button&&a.type==="click")){if(a.namespace)A=RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)");a.liveFired=this;var J=h.live.slice(0);for(k=0;kd)break;a.currentTarget=f.elem;a.data=f.handleObj.data;a.handleObj=f.handleObj;A=f.handleObj.origHandler.apply(f.elem,arguments);if(A===false||a.isPropagationStopped()){d=f.level;if(A===false)b=false;if(a.isImmediatePropagationStopped())break}}return b}}function Y(a,b){return(a&&a!=="*"?a+".":"")+b.replace(La, -"`").replace(Ma,"&")}function ma(a,b,d){if(c.isFunction(b))return c.grep(a,function(f,h){return!!b.call(f,h,f)===d});else if(b.nodeType)return c.grep(a,function(f){return f===b===d});else if(typeof b==="string"){var e=c.grep(a,function(f){return f.nodeType===1});if(Na.test(b))return c.filter(b,e,!d);else b=c.filter(b,e)}return c.grep(a,function(f){return c.inArray(f,b)>=0===d})}function na(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var e=c.data(a[d++]),f=c.data(this, -e);if(e=e&&e.events){delete f.handle;f.events={};for(var h in e)for(var l in e[h])c.event.add(this,h,e[h][l],e[h][l].data)}}})}function Oa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function oa(a,b,d){var e=b==="width"?a.offsetWidth:a.offsetHeight;if(d==="border")return e;c.each(b==="width"?Pa:Qa,function(){d||(e-=parseFloat(c.css(a,"padding"+this))||0);if(d==="margin")e+=parseFloat(c.css(a, -"margin"+this))||0;else e-=parseFloat(c.css(a,"border"+this+"Width"))||0});return e}function da(a,b,d,e){if(c.isArray(b)&&b.length)c.each(b,function(f,h){d||Ra.test(a)?e(a,h):da(a+"["+(typeof h==="object"||c.isArray(h)?f:"")+"]",h,d,e)});else if(!d&&b!=null&&typeof b==="object")c.isEmptyObject(b)?e(a,""):c.each(b,function(f,h){da(a+"["+f+"]",h,d,e)});else e(a,b)}function S(a,b){var d={};c.each(pa.concat.apply([],pa.slice(0,b)),function(){d[this]=a});return d}function qa(a){if(!ea[a]){var b=c("<"+ -a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d==="")d="block";ea[a]=d}return ea[a]}function fa(a){return c.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var t=E.document,c=function(){function a(){if(!b.isReady){try{t.documentElement.doScroll("left")}catch(j){setTimeout(a,1);return}b.ready()}}var b=function(j,s){return new b.fn.init(j,s)},d=E.jQuery,e=E.$,f,h=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,l=/\S/,k=/^\s+/,o=/\s+$/,x=/\W/,r=/\d/,A=/^<(\w+)\s*\/?>(?:<\/\1>)?$/, -C=/^[\],:{}\s]*$/,J=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,w=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,I=/(?:^|:|,)(?:\s*\[)+/g,L=/(webkit)[ \/]([\w.]+)/,g=/(opera)(?:.*version)?[ \/]([\w.]+)/,i=/(msie) ([\w.]+)/,n=/(mozilla)(?:.*? rv:([\w.]+))?/,m=navigator.userAgent,p=false,q=[],u,y=Object.prototype.toString,F=Object.prototype.hasOwnProperty,M=Array.prototype.push,N=Array.prototype.slice,O=String.prototype.trim,D=Array.prototype.indexOf,R={};b.fn=b.prototype={init:function(j, -s){var v,z,H;if(!j)return this;if(j.nodeType){this.context=this[0]=j;this.length=1;return this}if(j==="body"&&!s&&t.body){this.context=t;this[0]=t.body;this.selector="body";this.length=1;return this}if(typeof j==="string")if((v=h.exec(j))&&(v[1]||!s))if(v[1]){H=s?s.ownerDocument||s:t;if(z=A.exec(j))if(b.isPlainObject(s)){j=[t.createElement(z[1])];b.fn.attr.call(j,s,true)}else j=[H.createElement(z[1])];else{z=b.buildFragment([v[1]],[H]);j=(z.cacheable?z.fragment.cloneNode(true):z.fragment).childNodes}return b.merge(this, -j)}else{if((z=t.getElementById(v[2]))&&z.parentNode){if(z.id!==v[2])return f.find(j);this.length=1;this[0]=z}this.context=t;this.selector=j;return this}else if(!s&&!x.test(j)){this.selector=j;this.context=t;j=t.getElementsByTagName(j);return b.merge(this,j)}else return!s||s.jquery?(s||f).find(j):b(s).find(j);else if(b.isFunction(j))return f.ready(j);if(j.selector!==B){this.selector=j.selector;this.context=j.context}return b.makeArray(j,this)},selector:"",jquery:"1.4.4",length:0,size:function(){return this.length}, -toArray:function(){return N.call(this,0)},get:function(j){return j==null?this.toArray():j<0?this.slice(j)[0]:this[j]},pushStack:function(j,s,v){var z=b();b.isArray(j)?M.apply(z,j):b.merge(z,j);z.prevObject=this;z.context=this.context;if(s==="find")z.selector=this.selector+(this.selector?" ":"")+v;else if(s)z.selector=this.selector+"."+s+"("+v+")";return z},each:function(j,s){return b.each(this,j,s)},ready:function(j){b.bindReady();if(b.isReady)j.call(t,b);else q&&q.push(j);return this},eq:function(j){return j=== --1?this.slice(j):this.slice(j,+j+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(N.apply(this,arguments),"slice",N.call(arguments).join(","))},map:function(j){return this.pushStack(b.map(this,function(s,v){return j.call(s,v,s)}))},end:function(){return this.prevObject||b(null)},push:M,sort:[].sort,splice:[].splice};b.fn.init.prototype=b.fn;b.extend=b.fn.extend=function(){var j,s,v,z,H,G=arguments[0]||{},K=1,Q=arguments.length,ga=false; -if(typeof G==="boolean"){ga=G;G=arguments[1]||{};K=2}if(typeof G!=="object"&&!b.isFunction(G))G={};if(Q===K){G=this;--K}for(;K0))if(q){var s=0,v=q;for(q=null;j=v[s++];)j.call(t,b);b.fn.trigger&&b(t).trigger("ready").unbind("ready")}}},bindReady:function(){if(!p){p=true;if(t.readyState==="complete")return setTimeout(b.ready,1);if(t.addEventListener){t.addEventListener("DOMContentLoaded",u,false);E.addEventListener("load",b.ready,false)}else if(t.attachEvent){t.attachEvent("onreadystatechange",u);E.attachEvent("onload", -b.ready);var j=false;try{j=E.frameElement==null}catch(s){}t.documentElement.doScroll&&j&&a()}}},isFunction:function(j){return b.type(j)==="function"},isArray:Array.isArray||function(j){return b.type(j)==="array"},isWindow:function(j){return j&&typeof j==="object"&&"setInterval"in j},isNaN:function(j){return j==null||!r.test(j)||isNaN(j)},type:function(j){return j==null?String(j):R[y.call(j)]||"object"},isPlainObject:function(j){if(!j||b.type(j)!=="object"||j.nodeType||b.isWindow(j))return false;if(j.constructor&& -!F.call(j,"constructor")&&!F.call(j.constructor.prototype,"isPrototypeOf"))return false;for(var s in j);return s===B||F.call(j,s)},isEmptyObject:function(j){for(var s in j)return false;return true},error:function(j){throw j;},parseJSON:function(j){if(typeof j!=="string"||!j)return null;j=b.trim(j);if(C.test(j.replace(J,"@").replace(w,"]").replace(I,"")))return E.JSON&&E.JSON.parse?E.JSON.parse(j):(new Function("return "+j))();else b.error("Invalid JSON: "+j)},noop:function(){},globalEval:function(j){if(j&& -l.test(j)){var s=t.getElementsByTagName("head")[0]||t.documentElement,v=t.createElement("script");v.type="text/javascript";if(b.support.scriptEval)v.appendChild(t.createTextNode(j));else v.text=j;s.insertBefore(v,s.firstChild);s.removeChild(v)}},nodeName:function(j,s){return j.nodeName&&j.nodeName.toUpperCase()===s.toUpperCase()},each:function(j,s,v){var z,H=0,G=j.length,K=G===B||b.isFunction(j);if(v)if(K)for(z in j){if(s.apply(j[z],v)===false)break}else for(;H
        a";var f=d.getElementsByTagName("*"),h=d.getElementsByTagName("a")[0],l=t.createElement("select"), -k=l.appendChild(t.createElement("option"));if(!(!f||!f.length||!h)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(h.getAttribute("style")),hrefNormalized:h.getAttribute("href")==="/a",opacity:/^0.55$/.test(h.style.opacity),cssFloat:!!h.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:k.selected,deleteExpando:true,optDisabled:false,checkClone:false, -scriptEval:false,noCloneEvent:true,boxModel:null,inlineBlockNeedsLayout:false,shrinkWrapBlocks:false,reliableHiddenOffsets:true};l.disabled=true;c.support.optDisabled=!k.disabled;b.type="text/javascript";try{b.appendChild(t.createTextNode("window."+e+"=1;"))}catch(o){}a.insertBefore(b,a.firstChild);if(E[e]){c.support.scriptEval=true;delete E[e]}try{delete b.test}catch(x){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function r(){c.support.noCloneEvent= -false;d.detachEvent("onclick",r)});d.cloneNode(true).fireEvent("onclick")}d=t.createElement("div");d.innerHTML="";a=t.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var r=t.createElement("div");r.style.width=r.style.paddingLeft="1px";t.body.appendChild(r);c.boxModel=c.support.boxModel=r.offsetWidth===2;if("zoom"in r.style){r.style.display="inline";r.style.zoom= -1;c.support.inlineBlockNeedsLayout=r.offsetWidth===2;r.style.display="";r.innerHTML="
        ";c.support.shrinkWrapBlocks=r.offsetWidth!==2}r.innerHTML="
        t
        ";var A=r.getElementsByTagName("td");c.support.reliableHiddenOffsets=A[0].offsetHeight===0;A[0].style.display="";A[1].style.display="none";c.support.reliableHiddenOffsets=c.support.reliableHiddenOffsets&&A[0].offsetHeight===0;r.innerHTML="";t.body.removeChild(r).style.display= -"none"});a=function(r){var A=t.createElement("div");r="on"+r;var C=r in A;if(!C){A.setAttribute(r,"return;");C=typeof A[r]==="function"}return C};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=f=h=null}})();var ra={},Ja=/^(?:\{.*\}|\[.*\])$/;c.extend({cache:{},uuid:0,expando:"jQuery"+c.now(),noData:{embed:true,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:true},data:function(a,b,d){if(c.acceptData(a)){a=a==E?ra:a;var e=a.nodeType,f=e?a[c.expando]:null,h= -c.cache;if(!(e&&!f&&typeof b==="string"&&d===B)){if(e)f||(a[c.expando]=f=++c.uuid);else h=a;if(typeof b==="object")if(e)h[f]=c.extend(h[f],b);else c.extend(h,b);else if(e&&!h[f])h[f]={};a=e?h[f]:h;if(d!==B)a[b]=d;return typeof b==="string"?a[b]:a}}},removeData:function(a,b){if(c.acceptData(a)){a=a==E?ra:a;var d=a.nodeType,e=d?a[c.expando]:a,f=c.cache,h=d?f[e]:e;if(b){if(h){delete h[b];d&&c.isEmptyObject(h)&&c.removeData(a)}}else if(d&&c.support.deleteExpando)delete a[c.expando];else if(a.removeAttribute)a.removeAttribute(c.expando); -else if(d)delete f[e];else for(var l in a)delete a[l]}},acceptData:function(a){if(a.nodeName){var b=c.noData[a.nodeName.toLowerCase()];if(b)return!(b===true||a.getAttribute("classid")!==b)}return true}});c.fn.extend({data:function(a,b){var d=null;if(typeof a==="undefined"){if(this.length){var e=this[0].attributes,f;d=c.data(this[0]);for(var h=0,l=e.length;h-1)return true;return false},val:function(a){if(!arguments.length){var b=this[0];if(b){if(c.nodeName(b,"option")){var d=b.attributes.value;return!d||d.specified?b.value:b.text}if(c.nodeName(b,"select")){var e=b.selectedIndex;d=[];var f=b.options;b=b.type==="select-one"; -if(e<0)return null;var h=b?e:0;for(e=b?e+1:f.length;h=0;else if(c.nodeName(this,"select")){var A=c.makeArray(r);c("option",this).each(function(){this.selected=c.inArray(c(this).val(),A)>=0});if(!A.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true}, -attr:function(a,b,d,e){if(!a||a.nodeType===3||a.nodeType===8)return B;if(e&&b in c.attrFn)return c(a)[b](d);e=a.nodeType!==1||!c.isXMLDoc(a);var f=d!==B;b=e&&c.props[b]||b;var h=Ta.test(b);if((b in a||a[b]!==B)&&e&&!h){if(f){b==="type"&&Ua.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");if(d===null)a.nodeType===1&&a.removeAttribute(b);else a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&& -b.specified?b.value:Va.test(a.nodeName)||Wa.test(a.nodeName)&&a.href?0:B;return a[b]}if(!c.support.style&&e&&b==="style"){if(f)a.style.cssText=""+d;return a.style.cssText}f&&a.setAttribute(b,""+d);if(!a.attributes[b]&&a.hasAttribute&&!a.hasAttribute(b))return B;a=!c.support.hrefNormalized&&e&&h?a.getAttribute(b,2):a.getAttribute(b);return a===null?B:a}});var X=/\.(.*)$/,ia=/^(?:textarea|input|select)$/i,La=/\./g,Ma=/ /g,Xa=/[^\w\s.|`]/g,Ya=function(a){return a.replace(Xa,"\\$&")},ua={focusin:0,focusout:0}; -c.event={add:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(c.isWindow(a)&&a!==E&&!a.frameElement)a=E;if(d===false)d=U;else if(!d)return;var f,h;if(d.handler){f=d;d=f.handler}if(!d.guid)d.guid=c.guid++;if(h=c.data(a)){var l=a.nodeType?"events":"__events__",k=h[l],o=h.handle;if(typeof k==="function"){o=k.handle;k=k.events}else if(!k){a.nodeType||(h[l]=h=function(){});h.events=k={}}if(!o)h.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem, -arguments):B};o.elem=a;b=b.split(" ");for(var x=0,r;l=b[x++];){h=f?c.extend({},f):{handler:d,data:e};if(l.indexOf(".")>-1){r=l.split(".");l=r.shift();h.namespace=r.slice(0).sort().join(".")}else{r=[];h.namespace=""}h.type=l;if(!h.guid)h.guid=d.guid;var A=k[l],C=c.event.special[l]||{};if(!A){A=k[l]=[];if(!C.setup||C.setup.call(a,e,r,o)===false)if(a.addEventListener)a.addEventListener(l,o,false);else a.attachEvent&&a.attachEvent("on"+l,o)}if(C.add){C.add.call(a,h);if(!h.handler.guid)h.handler.guid= -d.guid}A.push(h);c.event.global[l]=true}a=null}}},global:{},remove:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(d===false)d=U;var f,h,l=0,k,o,x,r,A,C,J=a.nodeType?"events":"__events__",w=c.data(a),I=w&&w[J];if(w&&I){if(typeof I==="function"){w=I;I=I.events}if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(f in I)c.event.remove(a,f+b)}else{for(b=b.split(" ");f=b[l++];){r=f;k=f.indexOf(".")<0;o=[];if(!k){o=f.split(".");f=o.shift();x=RegExp("(^|\\.)"+ -c.map(o.slice(0).sort(),Ya).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(A=I[f])if(d){r=c.event.special[f]||{};for(h=e||0;h=0){a.type=f=f.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[f]&&c.each(c.cache,function(){this.events&&this.events[f]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType=== -8)return B;a.result=B;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(e=d.nodeType?c.data(d,"handle"):(c.data(d,"__events__")||{}).handle)&&e.apply(d,b);e=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+f]&&d["on"+f].apply(d,b)===false){a.result=false;a.preventDefault()}}catch(h){}if(!a.isPropagationStopped()&&e)c.event.trigger(a,b,e,true);else if(!a.isDefaultPrevented()){var l;e=a.target;var k=f.replace(X,""),o=c.nodeName(e,"a")&&k=== -"click",x=c.event.special[k]||{};if((!x._default||x._default.call(d,a)===false)&&!o&&!(e&&e.nodeName&&c.noData[e.nodeName.toLowerCase()])){try{if(e[k]){if(l=e["on"+k])e["on"+k]=null;c.event.triggered=true;e[k]()}}catch(r){}if(l)e["on"+k]=l;c.event.triggered=false}}},handle:function(a){var b,d,e,f;d=[];var h=c.makeArray(arguments);a=h[0]=c.event.fix(a||E.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;if(!b){e=a.type.split(".");a.type=e.shift();d=e.slice(0).sort();e=RegExp("(^|\\.)"+ -d.join("\\.(?:.*\\.)?")+"(\\.|$)")}a.namespace=a.namespace||d.join(".");f=c.data(this,this.nodeType?"events":"__events__");if(typeof f==="function")f=f.events;d=(f||{})[a.type];if(f&&d){d=d.slice(0);f=0;for(var l=d.length;f-1?c.map(a.options,function(e){return e.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},Z=function(a,b){var d=a.target,e,f;if(!(!ia.test(d.nodeName)||d.readOnly)){e=c.data(d,"_change_data");f=xa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",f);if(!(e===B||f===e))if(e!=null||f){a.type="change";a.liveFired= -B;return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:Z,beforedeactivate:Z,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return Z.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return Z.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,"_change_data",xa(a))}},setup:function(){if(this.type=== -"file")return false;for(var a in V)c.event.add(this,a+".specialChange",V[a]);return ia.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return ia.test(this.nodeName)}};V=c.event.special.change.filters;V.focus=V.beforeactivate}t.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.trigger(e,null,e.target)}c.event.special[b]={setup:function(){ua[b]++===0&&t.addEventListener(a,d,true)},teardown:function(){--ua[b]=== -0&&t.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,e,f){if(typeof d==="object"){for(var h in d)this[b](h,e,d[h],f);return this}if(c.isFunction(e)||e===false){f=e;e=B}var l=b==="one"?c.proxy(f,function(o){c(this).unbind(o,l);return f.apply(this,arguments)}):f;if(d==="unload"&&b!=="one")this.one(d,e,f);else{h=0;for(var k=this.length;h0?this.bind(b,d,e):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});E.attachEvent&&!E.addEventListener&&c(E).bind("unload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}}); -(function(){function a(g,i,n,m,p,q){p=0;for(var u=m.length;p0){F=y;break}}y=y[g]}m[p]=F}}}var d=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,f=Object.prototype.toString,h=false,l=true;[0,0].sort(function(){l=false;return 0});var k=function(g,i,n,m){n=n||[];var p=i=i||t;if(i.nodeType!==1&&i.nodeType!==9)return[];if(!g||typeof g!=="string")return n;var q,u,y,F,M,N=true,O=k.isXML(i),D=[],R=g;do{d.exec("");if(q=d.exec(R)){R=q[3];D.push(q[1]);if(q[2]){F=q[3]; -break}}}while(q);if(D.length>1&&x.exec(g))if(D.length===2&&o.relative[D[0]])u=L(D[0]+D[1],i);else for(u=o.relative[D[0]]?[i]:k(D.shift(),i);D.length;){g=D.shift();if(o.relative[g])g+=D.shift();u=L(g,u)}else{if(!m&&D.length>1&&i.nodeType===9&&!O&&o.match.ID.test(D[0])&&!o.match.ID.test(D[D.length-1])){q=k.find(D.shift(),i,O);i=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]}if(i){q=m?{expr:D.pop(),set:C(m)}:k.find(D.pop(),D.length===1&&(D[0]==="~"||D[0]==="+")&&i.parentNode?i.parentNode:i,O);u=q.expr?k.filter(q.expr, -q.set):q.set;if(D.length>0)y=C(u);else N=false;for(;D.length;){q=M=D.pop();if(o.relative[M])q=D.pop();else M="";if(q==null)q=i;o.relative[M](y,q,O)}}else y=[]}y||(y=u);y||k.error(M||g);if(f.call(y)==="[object Array]")if(N)if(i&&i.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&k.contains(i,y[g])))n.push(u[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&n.push(u[g]);else n.push.apply(n,y);else C(y,n);if(F){k(F,p,n,m);k.uniqueSort(n)}return n};k.uniqueSort=function(g){if(w){h= -l;g.sort(w);if(h)for(var i=1;i0};k.find=function(g,i,n){var m;if(!g)return[];for(var p=0,q=o.order.length;p":function(g,i){var n,m=typeof i==="string",p=0,q=g.length;if(m&&!/\W/.test(i))for(i=i.toLowerCase();p=0))n||m.push(u);else if(n)i[q]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var i=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=i[1]+(i[2]||1)-0;g[3]=i[3]-0}g[0]=e++;return g},ATTR:function(g,i,n, -m,p,q){i=g[1].replace(/\\/g,"");if(!q&&o.attrMap[i])g[1]=o.attrMap[i];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,i,n,m,p){if(g[1]==="not")if((d.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,i);else{g=k.filter(g[3],i,n,true^p);n||m.push.apply(m,g);return false}else if(o.match.POS.test(g[0])||o.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled=== -true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,i,n){return!!k(n[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"=== -g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,i){return i===0},last:function(g,i,n,m){return i===m.length-1},even:function(g,i){return i%2===0},odd:function(g,i){return i%2===1},lt:function(g,i,n){return in[3]-0},nth:function(g,i,n){return n[3]- -0===i},eq:function(g,i,n){return n[3]-0===i}},filter:{PSEUDO:function(g,i,n,m){var p=i[1],q=o.filters[p];if(q)return q(g,n,i,m);else if(p==="contains")return(g.textContent||g.innerText||k.getText([g])||"").indexOf(i[3])>=0;else if(p==="not"){i=i[3];n=0;for(m=i.length;n=0}},ID:function(g,i){return g.nodeType===1&&g.getAttribute("id")===i},TAG:function(g,i){return i==="*"&&g.nodeType===1||g.nodeName.toLowerCase()=== -i},CLASS:function(g,i){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(i)>-1},ATTR:function(g,i){var n=i[1];n=o.attrHandle[n]?o.attrHandle[n](g):g[n]!=null?g[n]:g.getAttribute(n);var m=n+"",p=i[2],q=i[4];return n==null?p==="!=":p==="="?m===q:p==="*="?m.indexOf(q)>=0:p==="~="?(" "+m+" ").indexOf(q)>=0:!q?m&&n!==false:p==="!="?m!==q:p==="^="?m.indexOf(q)===0:p==="$="?m.substr(m.length-q.length)===q:p==="|="?m===q||m.substr(0,q.length+1)===q+"-":false},POS:function(g,i,n,m){var p=o.setFilters[i[2]]; -if(p)return p(g,n,i,m)}}},x=o.match.POS,r=function(g,i){return"\\"+(i-0+1)},A;for(A in o.match){o.match[A]=RegExp(o.match[A].source+/(?![^\[]*\])(?![^\(]*\))/.source);o.leftMatch[A]=RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[A].source.replace(/\\(\d+)/g,r))}var C=function(g,i){g=Array.prototype.slice.call(g,0);if(i){i.push.apply(i,g);return i}return g};try{Array.prototype.slice.call(t.documentElement.childNodes,0)}catch(J){C=function(g,i){var n=0,m=i||[];if(f.call(g)==="[object Array]")Array.prototype.push.apply(m, -g);else if(typeof g.length==="number")for(var p=g.length;n";n.insertBefore(g,n.firstChild);if(t.getElementById(i)){o.find.ID=function(m,p,q){if(typeof p.getElementById!=="undefined"&&!q)return(p=p.getElementById(m[1]))?p.id===m[1]||typeof p.getAttributeNode!=="undefined"&&p.getAttributeNode("id").nodeValue===m[1]?[p]:B:[]};o.filter.ID=function(m,p){var q=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&q&&q.nodeValue===p}}n.removeChild(g); -n=g=null})();(function(){var g=t.createElement("div");g.appendChild(t.createComment(""));if(g.getElementsByTagName("*").length>0)o.find.TAG=function(i,n){var m=n.getElementsByTagName(i[1]);if(i[1]==="*"){for(var p=[],q=0;m[q];q++)m[q].nodeType===1&&p.push(m[q]);m=p}return m};g.innerHTML="";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")o.attrHandle.href=function(i){return i.getAttribute("href",2)};g=null})();t.querySelectorAll&& -function(){var g=k,i=t.createElement("div");i.innerHTML="

        ";if(!(i.querySelectorAll&&i.querySelectorAll(".TEST").length===0)){k=function(m,p,q,u){p=p||t;m=m.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!u&&!k.isXML(p))if(p.nodeType===9)try{return C(p.querySelectorAll(m),q)}catch(y){}else if(p.nodeType===1&&p.nodeName.toLowerCase()!=="object"){var F=p.getAttribute("id"),M=F||"__sizzle__";F||p.setAttribute("id",M);try{return C(p.querySelectorAll("#"+M+" "+m),q)}catch(N){}finally{F|| -p.removeAttribute("id")}}return g(m,p,q,u)};for(var n in g)k[n]=g[n];i=null}}();(function(){var g=t.documentElement,i=g.matchesSelector||g.mozMatchesSelector||g.webkitMatchesSelector||g.msMatchesSelector,n=false;try{i.call(t.documentElement,"[test!='']:sizzle")}catch(m){n=true}if(i)k.matchesSelector=function(p,q){q=q.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(p))try{if(n||!o.match.PSEUDO.test(q)&&!/!=/.test(q))return i.call(p,q)}catch(u){}return k(q,null,null,[p]).length>0}})();(function(){var g= -t.createElement("div");g.innerHTML="
        ";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){o.order.splice(1,0,"CLASS");o.find.CLASS=function(i,n,m){if(typeof n.getElementsByClassName!=="undefined"&&!m)return n.getElementsByClassName(i[1])};g=null}}})();k.contains=t.documentElement.contains?function(g,i){return g!==i&&(g.contains?g.contains(i):true)}:t.documentElement.compareDocumentPosition? -function(g,i){return!!(g.compareDocumentPosition(i)&16)}:function(){return false};k.isXML=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false};var L=function(g,i){for(var n,m=[],p="",q=i.nodeType?[i]:i;n=o.match.PSEUDO.exec(g);){p+=n[0];g=g.replace(o.match.PSEUDO,"")}g=o.relative[g]?g+"*":g;n=0;for(var u=q.length;n0)for(var h=d;h0},closest:function(a,b){var d=[],e,f,h=this[0];if(c.isArray(a)){var l,k={},o=1;if(h&&a.length){e=0;for(f=a.length;e-1:c(h).is(e))d.push({selector:l,elem:h,level:o})}h= -h.parentNode;o++}}return d}l=cb.test(a)?c(a,b||this.context):null;e=0;for(f=this.length;e-1:c.find.matchesSelector(h,a)){d.push(h);break}else{h=h.parentNode;if(!h||!h.ownerDocument||h===b)break}d=d.length>1?c.unique(d):d;return this.pushStack(d,"closest",a)},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var d=typeof a==="string"?c(a,b||this.context): -c.makeArray(a),e=c.merge(this.get(),d);return this.pushStack(!d[0]||!d[0].parentNode||d[0].parentNode.nodeType===11||!e[0]||!e[0].parentNode||e[0].parentNode.nodeType===11?e:c.unique(e))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a, -2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a, -b){c.fn[a]=function(d,e){var f=c.map(this,b,d);Za.test(a)||(e=d);if(e&&typeof e==="string")f=c.filter(e,f);f=this.length>1?c.unique(f):f;if((this.length>1||ab.test(e))&&$a.test(a))f=f.reverse();return this.pushStack(f,a,bb.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return b.length===1?c.find.matchesSelector(b[0],a)?[b[0]]:[]:c.find.matches(a,b)},dir:function(a,b,d){var e=[];for(a=a[b];a&&a.nodeType!==9&&(d===B||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&& -e.push(a);a=a[b]}return e},nth:function(a,b,d){b=b||1;for(var e=0;a;a=a[d])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var za=/ jQuery\d+="(?:\d+|null)"/g,$=/^\s+/,Aa=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Ba=/<([\w:]+)/,db=/\s]+\/)>/g,P={option:[1, -""],legend:[1,"
        ","
        "],thead:[1,"","
        "],tr:[2,"","
        "],td:[3,"","
        "],col:[2,"","
        "],area:[1,"",""],_default:[0,"",""]};P.optgroup=P.option;P.tbody=P.tfoot=P.colgroup=P.caption=P.thead;P.th=P.td;if(!c.support.htmlSerialize)P._default=[1,"div
        ","
        "];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d= -c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==B)return this.empty().append((this[0]&&this[0].ownerDocument||t).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this}, -wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})}, -prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b, -this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,e;(e=this[d])!=null;d++)if(!a||c.filter(a,[e]).length){if(!b&&e.nodeType===1){c.cleanData(e.getElementsByTagName("*"));c.cleanData([e])}e.parentNode&&e.parentNode.removeChild(e)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild); -return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,e=this.ownerDocument;if(!d){d=e.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(za,"").replace(fb,'="$1">').replace($,"")],e)[0]}else return this.cloneNode(true)});if(a===true){na(this,b);na(this.find("*"),b.find("*"))}return b},html:function(a){if(a===B)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(za,""):null; -else if(typeof a==="string"&&!Ca.test(a)&&(c.support.leadingWhitespace||!$.test(a))&&!P[(Ba.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Aa,"<$1>");try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?h.cloneNode(true):h)}k.length&&c.each(k,Oa)}return this}});c.buildFragment=function(a,b,d){var e,f,h;b=b&&b[0]?b[0].ownerDocument||b[0]:t;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===t&&!Ca.test(a[0])&&(c.support.checkClone||!Da.test(a[0]))){f=true;if(h=c.fragments[a[0]])if(h!==1)e=h}if(!e){e=b.createDocumentFragment();c.clean(a,b,e,d)}if(f)c.fragments[a[0]]=h?e:1;return{fragment:e,cacheable:f}};c.fragments={};c.each({appendTo:"append", -prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var e=[];d=c(d);var f=this.length===1&&this[0].parentNode;if(f&&f.nodeType===11&&f.childNodes.length===1&&d.length===1){d[b](this[0]);return this}else{f=0;for(var h=d.length;f0?this.clone(true):this).get();c(d[f])[b](l);e=e.concat(l)}return this.pushStack(e,a,d.selector)}}});c.extend({clean:function(a,b,d,e){b=b||t;if(typeof b.createElement==="undefined")b=b.ownerDocument|| -b[0]&&b[0].ownerDocument||t;for(var f=[],h=0,l;(l=a[h])!=null;h++){if(typeof l==="number")l+="";if(l){if(typeof l==="string"&&!eb.test(l))l=b.createTextNode(l);else if(typeof l==="string"){l=l.replace(Aa,"<$1>");var k=(Ba.exec(l)||["",""])[1].toLowerCase(),o=P[k]||P._default,x=o[0],r=b.createElement("div");for(r.innerHTML=o[1]+l+o[2];x--;)r=r.lastChild;if(!c.support.tbody){x=db.test(l);k=k==="table"&&!x?r.firstChild&&r.firstChild.childNodes:o[1]===""&&!x?r.childNodes:[];for(o=k.length- -1;o>=0;--o)c.nodeName(k[o],"tbody")&&!k[o].childNodes.length&&k[o].parentNode.removeChild(k[o])}!c.support.leadingWhitespace&&$.test(l)&&r.insertBefore(b.createTextNode($.exec(l)[0]),r.firstChild);l=r.childNodes}if(l.nodeType)f.push(l);else f=c.merge(f,l)}}if(d)for(h=0;f[h];h++)if(e&&c.nodeName(f[h],"script")&&(!f[h].type||f[h].type.toLowerCase()==="text/javascript"))e.push(f[h].parentNode?f[h].parentNode.removeChild(f[h]):f[h]);else{f[h].nodeType===1&&f.splice.apply(f,[h+1,0].concat(c.makeArray(f[h].getElementsByTagName("script")))); -d.appendChild(f[h])}return f},cleanData:function(a){for(var b,d,e=c.cache,f=c.event.special,h=c.support.deleteExpando,l=0,k;(k=a[l])!=null;l++)if(!(k.nodeName&&c.noData[k.nodeName.toLowerCase()]))if(d=k[c.expando]){if((b=e[d])&&b.events)for(var o in b.events)f[o]?c.event.remove(k,o):c.removeEvent(k,o,b.handle);if(h)delete k[c.expando];else k.removeAttribute&&k.removeAttribute(c.expando);delete e[d]}}});var Ea=/alpha\([^)]*\)/i,gb=/opacity=([^)]*)/,hb=/-([a-z])/ig,ib=/([A-Z])/g,Fa=/^-?\d+(?:px)?$/i, -jb=/^-?\d/,kb={position:"absolute",visibility:"hidden",display:"block"},Pa=["Left","Right"],Qa=["Top","Bottom"],W,Ga,aa,lb=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){if(arguments.length===2&&b===B)return this;return c.access(this,a,b,true,function(d,e,f){return f!==B?c.style(d,e,f):c.css(d,e)})};c.extend({cssHooks:{opacity:{get:function(a,b){if(b){var d=W(a,"opacity","opacity");return d===""?"1":d}else return a.style.opacity}}},cssNumber:{zIndex:true,fontWeight:true,opacity:true, -zoom:true,lineHeight:true},cssProps:{"float":c.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,d,e){if(!(!a||a.nodeType===3||a.nodeType===8||!a.style)){var f,h=c.camelCase(b),l=a.style,k=c.cssHooks[h];b=c.cssProps[h]||h;if(d!==B){if(!(typeof d==="number"&&isNaN(d)||d==null)){if(typeof d==="number"&&!c.cssNumber[h])d+="px";if(!k||!("set"in k)||(d=k.set(a,d))!==B)try{l[b]=d}catch(o){}}}else{if(k&&"get"in k&&(f=k.get(a,false,e))!==B)return f;return l[b]}}},css:function(a,b,d){var e,f=c.camelCase(b), -h=c.cssHooks[f];b=c.cssProps[f]||f;if(h&&"get"in h&&(e=h.get(a,true,d))!==B)return e;else if(W)return W(a,b,f)},swap:function(a,b,d){var e={},f;for(f in b){e[f]=a.style[f];a.style[f]=b[f]}d.call(a);for(f in b)a.style[f]=e[f]},camelCase:function(a){return a.replace(hb,lb)}});c.curCSS=c.css;c.each(["height","width"],function(a,b){c.cssHooks[b]={get:function(d,e,f){var h;if(e){if(d.offsetWidth!==0)h=oa(d,b,f);else c.swap(d,kb,function(){h=oa(d,b,f)});if(h<=0){h=W(d,b,b);if(h==="0px"&&aa)h=aa(d,b,b); -if(h!=null)return h===""||h==="auto"?"0px":h}if(h<0||h==null){h=d.style[b];return h===""||h==="auto"?"0px":h}return typeof h==="string"?h:h+"px"}},set:function(d,e){if(Fa.test(e)){e=parseFloat(e);if(e>=0)return e+"px"}else return e}}});if(!c.support.opacity)c.cssHooks.opacity={get:function(a,b){return gb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var d=a.style;d.zoom=1;var e=c.isNaN(b)?"":"alpha(opacity="+b*100+")",f= -d.filter||"";d.filter=Ea.test(f)?f.replace(Ea,e):d.filter+" "+e}};if(t.defaultView&&t.defaultView.getComputedStyle)Ga=function(a,b,d){var e;d=d.replace(ib,"-$1").toLowerCase();if(!(b=a.ownerDocument.defaultView))return B;if(b=b.getComputedStyle(a,null)){e=b.getPropertyValue(d);if(e===""&&!c.contains(a.ownerDocument.documentElement,a))e=c.style(a,d)}return e};if(t.documentElement.currentStyle)aa=function(a,b){var d,e,f=a.currentStyle&&a.currentStyle[b],h=a.style;if(!Fa.test(f)&&jb.test(f)){d=h.left; -e=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;h.left=b==="fontSize"?"1em":f||0;f=h.pixelLeft+"px";h.left=d;a.runtimeStyle.left=e}return f===""?"auto":f};W=Ga||aa;if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetHeight;return a.offsetWidth===0&&b===0||!c.support.reliableHiddenOffsets&&(a.style.display||c.css(a,"display"))==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var mb=c.now(),nb=/)<[^<]*)*<\/script>/gi, -ob=/^(?:select|textarea)/i,pb=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,qb=/^(?:GET|HEAD)$/,Ra=/\[\]$/,T=/\=\?(&|$)/,ja=/\?/,rb=/([?&])_=[^&]*/,sb=/^(\w+:)?\/\/([^\/?#]+)/,tb=/%20/g,ub=/#.*$/,Ha=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!=="string"&&Ha)return Ha.apply(this,arguments);else if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var f=a.slice(e,a.length);a=a.slice(0,e)}e="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b=== -"object"){b=c.param(b,c.ajaxSettings.traditional);e="POST"}var h=this;c.ajax({url:a,type:e,dataType:"html",data:b,complete:function(l,k){if(k==="success"||k==="notmodified")h.html(f?c("
        ").append(l.responseText.replace(nb,"")).find(f):l.responseText);d&&h.each(d,[l.responseText,k,l])}});return this},serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&& -!this.disabled&&(this.checked||ob.test(this.nodeName)||pb.test(this.type))}).map(function(a,b){var d=c(this).val();return d==null?null:c.isArray(d)?c.map(d,function(e){return{name:b.name,value:e}}):{name:b.name,value:d}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:e})}, -getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:e})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return new E.XMLHttpRequest},accepts:{xml:"application/xml, text/xml",html:"text/html", -script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},ajax:function(a){var b=c.extend(true,{},c.ajaxSettings,a),d,e,f,h=b.type.toUpperCase(),l=qb.test(h);b.url=b.url.replace(ub,"");b.context=a&&a.context!=null?a.context:b;if(b.data&&b.processData&&typeof b.data!=="string")b.data=c.param(b.data,b.traditional);if(b.dataType==="jsonp"){if(h==="GET")T.test(b.url)||(b.url+=(ja.test(b.url)?"&":"?")+(b.jsonp||"callback")+"=?");else if(!b.data|| -!T.test(b.data))b.data=(b.data?b.data+"&":"")+(b.jsonp||"callback")+"=?";b.dataType="json"}if(b.dataType==="json"&&(b.data&&T.test(b.data)||T.test(b.url))){d=b.jsonpCallback||"jsonp"+mb++;if(b.data)b.data=(b.data+"").replace(T,"="+d+"$1");b.url=b.url.replace(T,"="+d+"$1");b.dataType="script";var k=E[d];E[d]=function(m){if(c.isFunction(k))k(m);else{E[d]=B;try{delete E[d]}catch(p){}}f=m;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);r&&r.removeChild(A)}}if(b.dataType==="script"&&b.cache===null)b.cache= -false;if(b.cache===false&&l){var o=c.now(),x=b.url.replace(rb,"$1_="+o);b.url=x+(x===b.url?(ja.test(b.url)?"&":"?")+"_="+o:"")}if(b.data&&l)b.url+=(ja.test(b.url)?"&":"?")+b.data;b.global&&c.active++===0&&c.event.trigger("ajaxStart");o=(o=sb.exec(b.url))&&(o[1]&&o[1].toLowerCase()!==location.protocol||o[2].toLowerCase()!==location.host);if(b.dataType==="script"&&h==="GET"&&o){var r=t.getElementsByTagName("head")[0]||t.documentElement,A=t.createElement("script");if(b.scriptCharset)A.charset=b.scriptCharset; -A.src=b.url;if(!d){var C=false;A.onload=A.onreadystatechange=function(){if(!C&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){C=true;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);A.onload=A.onreadystatechange=null;r&&A.parentNode&&r.removeChild(A)}}}r.insertBefore(A,r.firstChild);return B}var J=false,w=b.xhr();if(w){b.username?w.open(h,b.url,b.async,b.username,b.password):w.open(h,b.url,b.async);try{if(b.data!=null&&!l||a&&a.contentType)w.setRequestHeader("Content-Type", -b.contentType);if(b.ifModified){c.lastModified[b.url]&&w.setRequestHeader("If-Modified-Since",c.lastModified[b.url]);c.etag[b.url]&&w.setRequestHeader("If-None-Match",c.etag[b.url])}o||w.setRequestHeader("X-Requested-With","XMLHttpRequest");w.setRequestHeader("Accept",b.dataType&&b.accepts[b.dataType]?b.accepts[b.dataType]+", */*; q=0.01":b.accepts._default)}catch(I){}if(b.beforeSend&&b.beforeSend.call(b.context,w,b)===false){b.global&&c.active--===1&&c.event.trigger("ajaxStop");w.abort();return false}b.global&& -c.triggerGlobal(b,"ajaxSend",[w,b]);var L=w.onreadystatechange=function(m){if(!w||w.readyState===0||m==="abort"){J||c.handleComplete(b,w,e,f);J=true;if(w)w.onreadystatechange=c.noop}else if(!J&&w&&(w.readyState===4||m==="timeout")){J=true;w.onreadystatechange=c.noop;e=m==="timeout"?"timeout":!c.httpSuccess(w)?"error":b.ifModified&&c.httpNotModified(w,b.url)?"notmodified":"success";var p;if(e==="success")try{f=c.httpData(w,b.dataType,b)}catch(q){e="parsererror";p=q}if(e==="success"||e==="notmodified")d|| -c.handleSuccess(b,w,e,f);else c.handleError(b,w,e,p);d||c.handleComplete(b,w,e,f);m==="timeout"&&w.abort();if(b.async)w=null}};try{var g=w.abort;w.abort=function(){w&&Function.prototype.call.call(g,w);L("abort")}}catch(i){}b.async&&b.timeout>0&&setTimeout(function(){w&&!J&&L("timeout")},b.timeout);try{w.send(l||b.data==null?null:b.data)}catch(n){c.handleError(b,w,null,n);c.handleComplete(b,w,e,f)}b.async||L();return w}},param:function(a,b){var d=[],e=function(h,l){l=c.isFunction(l)?l():l;d[d.length]= -encodeURIComponent(h)+"="+encodeURIComponent(l)};if(b===B)b=c.ajaxSettings.traditional;if(c.isArray(a)||a.jquery)c.each(a,function(){e(this.name,this.value)});else for(var f in a)da(f,a[f],b,e);return d.join("&").replace(tb,"+")}});c.extend({active:0,lastModified:{},etag:{},handleError:function(a,b,d,e){a.error&&a.error.call(a.context,b,d,e);a.global&&c.triggerGlobal(a,"ajaxError",[b,a,e])},handleSuccess:function(a,b,d,e){a.success&&a.success.call(a.context,e,d,b);a.global&&c.triggerGlobal(a,"ajaxSuccess", -[b,a])},handleComplete:function(a,b,d){a.complete&&a.complete.call(a.context,b,d);a.global&&c.triggerGlobal(a,"ajaxComplete",[b,a]);a.global&&c.active--===1&&c.event.trigger("ajaxStop")},triggerGlobal:function(a,b,d){(a.context&&a.context.url==null?c(a.context):c.event).trigger(b,d)},httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"), -e=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(e)c.etag[b]=e;return a.status===304},httpData:function(a,b,d){var e=a.getResponseHeader("content-type")||"",f=b==="xml"||!b&&e.indexOf("xml")>=0;a=f?a.responseXML:a.responseText;f&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b==="json"||!b&&e.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&e.indexOf("javascript")>=0)c.globalEval(a);return a}}); -if(E.ActiveXObject)c.ajaxSettings.xhr=function(){if(E.location.protocol!=="file:")try{return new E.XMLHttpRequest}catch(a){}try{return new E.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}};c.support.ajax=!!c.ajaxSettings.xhr();var ea={},vb=/^(?:toggle|show|hide)$/,wb=/^([+\-]=)?([\d+.\-]+)(.*)$/,ba,pa=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b,d){if(a||a===0)return this.animate(S("show", -3),a,b,d);else{d=0;for(var e=this.length;d=0;e--)if(d[e].elem===this){b&&d[e](true);d.splice(e,1)}});b||this.dequeue();return this}});c.each({slideDown:S("show",1),slideUp:S("hide",1),slideToggle:S("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){c.fn[a]=function(d,e,f){return this.animate(b, -d,e,f)}});c.extend({speed:function(a,b,d){var e=a&&typeof a==="object"?c.extend({},a):{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};e.duration=c.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in c.fx.speeds?c.fx.speeds[e.duration]:c.fx.speeds._default;e.old=e.complete;e.complete=function(){e.queue!==false&&c(this).dequeue();c.isFunction(e.old)&&e.old.call(this)};return e},easing:{linear:function(a,b,d,e){return d+e*a},swing:function(a,b,d,e){return(-Math.cos(a* -Math.PI)/2+0.5)*e+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||c.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a=parseFloat(c.css(this.elem,this.prop));return a&&a>-1E4?a:0},custom:function(a,b,d){function e(l){return f.step(l)} -var f=this,h=c.fx;this.startTime=c.now();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;this.pos=this.state=0;e.elem=this.elem;if(e()&&c.timers.push(e)&&!ba)ba=setInterval(h.tick,h.interval)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true; -this.custom(this.cur(),0)},step:function(a){var b=c.now(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var e in this.options.curAnim)if(this.options.curAnim[e]!==true)d=false;if(d){if(this.options.overflow!=null&&!c.support.shrinkWrapBlocks){var f=this.elem,h=this.options;c.each(["","X","Y"],function(k,o){f.style["overflow"+o]=h.overflow[k]})}this.options.hide&&c(this.elem).hide();if(this.options.hide|| -this.options.show)for(var l in this.options.curAnim)c.style(this.elem,l,this.options.orig[l]);this.options.complete.call(this.elem)}return false}else{a=b-this.startTime;this.state=a/this.options.duration;b=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||b](this.state,a,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a= -c.timers,b=0;b-1;e={};var x={};if(o)x=f.position();l=o?x.top:parseInt(l,10)||0;k=o?x.left:parseInt(k,10)||0;if(c.isFunction(b))b=b.call(a,d,h);if(b.top!=null)e.top=b.top-h.top+l;if(b.left!=null)e.left=b.left-h.left+k;"using"in b?b.using.call(a, -e):f.css(e)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),e=Ia.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.css(a,"marginTop"))||0;d.left-=parseFloat(c.css(a,"marginLeft"))||0;e.top+=parseFloat(c.css(b[0],"borderTopWidth"))||0;e.left+=parseFloat(c.css(b[0],"borderLeftWidth"))||0;return{top:d.top-e.top,left:d.left-e.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||t.body;a&&!Ia.test(a.nodeName)&& -c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(e){var f=this[0],h;if(!f)return null;if(e!==B)return this.each(function(){if(h=fa(this))h.scrollTo(!a?e:c(h).scrollLeft(),a?e:c(h).scrollTop());else this[d]=e});else return(h=fa(f))?"pageXOffset"in h?h[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&h.document.documentElement[d]||h.document.body[d]:f[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase(); -c.fn["inner"+b]=function(){return this[0]?parseFloat(c.css(this[0],d,"padding")):null};c.fn["outer"+b]=function(e){return this[0]?parseFloat(c.css(this[0],d,e?"margin":"border")):null};c.fn[d]=function(e){var f=this[0];if(!f)return e==null?null:this;if(c.isFunction(e))return this.each(function(l){var k=c(this);k[d](e.call(this,l,k[d]()))});if(c.isWindow(f))return f.document.compatMode==="CSS1Compat"&&f.document.documentElement["client"+b]||f.document.body["client"+b];else if(f.nodeType===9)return Math.max(f.documentElement["client"+ -b],f.body["scroll"+b],f.documentElement["scroll"+b],f.body["offset"+b],f.documentElement["offset"+b]);else if(e===B){f=c.css(f,d);var h=parseFloat(f);return c.isNaN(h)?f:h}else return this.css(d,typeof e==="string"?e:e+"px")}})})(window); diff --git a/game/old/fb/jquery-ui-1.8.9.custom.min.js b/game/old/fb/jquery-ui-1.8.9.custom.min.js deleted file mode 100755 index 044d307..0000000 --- a/game/old/fb/jquery-ui-1.8.9.custom.min.js +++ /dev/null @@ -1,68 +0,0 @@ -/*! - * jQuery UI 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI - */ -(function(c,j){function k(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.9",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106, -NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this, -"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position"); -if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,l,m){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(l)g-=parseFloat(c.curCSS(f, -"border"+this+"Width",true))||0;if(m)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h, -d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){var b=a.nodeName.toLowerCase(),d=c.attr(a,"tabindex");if("area"===b){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&k(a)}return(/input|select|textarea|button|object/.test(b)?!a.disabled:"a"==b?a.href||!isNaN(d):!isNaN(d))&&k(a)},tabbable:function(a){var b=c.attr(a,"tabindex");return(isNaN(b)||b>=0)&&c(a).is(":focusable")}}); -c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a
        ",remove:null,select:null,show:null,spinner:"Loading…",tabTemplate:"
      • #{label}
      • "},_create:function(){this._tabify(true)},_setOption:function(b,e){if(b=="selected")this.options.collapsible&& -e==this.options.selected||this.select(e);else{this.options[b]=e;this._tabify()}},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+u()},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+w());return d.cookie.apply(null,[b].concat(d.makeArray(arguments)))},_ui:function(b,e){return{tab:b,panel:e,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b= -d(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(b){function e(g,f){g.css("display","");!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}var a=this,c=this.options,h=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=d(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);this.anchors.each(function(g,f){var i=d(f).attr("href"),l=i.split("#")[0],q;if(l&&(l===location.toString().split("#")[0]|| -(q=d("base")[0])&&l===q.href)){i=f.hash;f.href=i}if(h.test(i))a.panels=a.panels.add(a.element.find(a._sanitizeSelector(i)));else if(i&&i!=="#"){d.data(f,"href.tabs",i);d.data(f,"load.tabs",i.replace(/#.*$/,""));i=a._tabId(f);f.href="#"+i;f=a.element.find("#"+i);if(!f.length){f=d(c.panelTemplate).attr("id",i).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else c.disabled.push(g)});if(b){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"); -this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(c.selected===p){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){c.selected=g;return false}});if(typeof c.selected!=="number"&&c.cookie)c.selected=parseInt(a._cookie(),10);if(typeof c.selected!=="number"&&this.lis.filter(".ui-tabs-selected").length)c.selected= -this.lis.index(this.lis.filter(".ui-tabs-selected"));c.selected=c.selected||(this.lis.length?0:-1)}else if(c.selected===null)c.selected=-1;c.selected=c.selected>=0&&this.anchors[c.selected]||c.selected<0?c.selected:0;c.disabled=d.unique(c.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(c.selected,c.disabled)!=-1&&c.disabled.splice(d.inArray(c.selected,c.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active"); -if(c.selected>=0&&this.anchors.length){a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash)).removeClass("ui-tabs-hide");this.lis.eq(c.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[c.selected],a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash))[0]))});this.load(c.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else c.selected=this.lis.index(this.lis.filter(".ui-tabs-selected")); -this.element[c.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");c.cookie&&this._cookie(c.selected,c.cookie);b=0;for(var j;j=this.lis[b];b++)d(j)[d.inArray(b,c.disabled)!=-1&&!d(j).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");c.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(c.event!=="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+ -g)};this.lis.bind("mouseover.tabs",function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(c.fx)if(d.isArray(c.fx)){m=c.fx[0];o=c.fx[1]}else m=o=c.fx;var r=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal", -function(){e(f,o);a._trigger("show",null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},s=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")}; -this.anchors.bind(c.event+".tabs",function(){var g=this,f=d(g).closest("li"),i=a.panels.filter(":not(.ui-tabs-hide)"),l=a.element.find(a._sanitizeSelector(g.hash));if(f.hasClass("ui-tabs-selected")&&!c.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a.panels.filter(":animated").length||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}c.selected=a.anchors.index(this);a.abort();if(c.collapsible)if(f.hasClass("ui-tabs-selected")){c.selected= --1;c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){s(g,i)}).dequeue("tabs");this.blur();return false}else if(!i.length){c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this));this.blur();return false}c.cookie&&a._cookie(c.selected,c.cookie);if(l.length){i.length&&a.element.queue("tabs",function(){s(g,i)});a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier."; -d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(b){if(typeof b=="string")b=this.anchors.index(this.anchors.filter("[href$="+b+"]"));return b},destroy:function(){var b=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e= -d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(c,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});b.cookie&&this._cookie(null,b.cookie);return this},add:function(b, -e,a){if(a===p)a=this.anchors.length;var c=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,b).replace(/#\{label\}/g,e));b=!b.indexOf("#")?b.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var j=c.element.find("#"+b);j.length||(j=d(h.panelTemplate).attr("id",b).data("destroy.tabs",true));j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);j.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]); -j.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");j.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){c._trigger("show",null,c._ui(c.anchors[0],c.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(b){b=this._getIndex(b);var e=this.options,a=this.lis.eq(b).remove(),c=this.panels.eq(b).remove(); -if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(b+(b+1=b?--h:h});this._tabify();this._trigger("remove",null,this._ui(a.find("a")[0],c[0]));return this},enable:function(b){b=this._getIndex(b);var e=this.options;if(d.inArray(b,e.disabled)!=-1){this.lis.eq(b).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=b});this._trigger("enable",null, -this._ui(this.anchors[b],this.panels[b]));return this}},disable:function(b){b=this._getIndex(b);var e=this.options;if(b!=e.selected){this.lis.eq(b).addClass("ui-state-disabled");e.disabled.push(b);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[b],this.panels[b]))}return this},select:function(b){b=this._getIndex(b);if(b==-1)if(this.options.collapsible&&this.options.selected!=-1)b=this.options.selected;else return this;this.anchors.eq(b).trigger(this.options.event+".tabs");return this}, -load:function(b){b=this._getIndex(b);var e=this,a=this.options,c=this.anchors.eq(b)[0],h=d.data(c,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(c,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(b).addClass("ui-state-processing");if(a.spinner){var j=d("span",c);j.data("label.tabs",j.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){e.element.find(e._sanitizeSelector(c.hash)).html(k);e._cleanup();a.cache&&d.data(c, -"cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.error(k,n,b,c)}catch(m){}}}));e.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this}, -url:function(b,e){this.anchors.eq(b).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.9"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(b,e){var a=this,c=this.options,h=a._rotate||(a._rotate=function(j){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=c.selected;a.select(++k= load_max && - image_manager.is_done_preloading() && - sounds.sounds_loaded()){ - // init all image objects - image_manager.init_images(p); - loading_finished(); - } - }; - - - obj.get_all_buttons = function() { - return []; - }; - - obj.key_pressed = function() {}; - - return obj; -}; diff --git a/game/old/fb/multiplier.js b/game/old/fb/multiplier.js deleted file mode 100644 index 569ef0e..0000000 --- a/game/old/fb/multiplier.js +++ /dev/null @@ -1,56 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec - -var multiplier = function(p, spec) { - // --- defaults --- - - spec.width = spec.width || 5; - spec.height = spec.height || 5; - // make sure it goes left - spec.vel = new p.PVector(p.random(0, -1), p.random()); - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "multiplier"; - }; - - // --- private variables --- - - var alive = true; - - // --- public methods --- - - // implementing game_object interface - - obj.update = function() { - obj.bounce(); - obj.move(); - }; - - // (rectangle for now) - obj.draw = function() { - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.fill(0, 255, 0); - p.noStroke(); - - p.ellipse(pos.x, pos.y, - obj.get_width(), obj.get_height()); - }; - - obj.die = function() { - alive = false; - } - - obj.is_dead = function() { - return (!alive); - }; - - return obj; -}; diff --git a/game/old/fb/mutation_obj.js b/game/old/fb/mutation_obj.js deleted file mode 100644 index 3df5fa6..0000000 --- a/game/old/fb/mutation_obj.js +++ /dev/null @@ -1,328 +0,0 @@ -// Manages all information about the current state of mutation -// in the game -// Provides a num_status_obj, which is used for rendering -// spec: -// status_height = y value for status objects - -var mutation_obj = function(p, spec) { - - // obj to return - var obj = {}; - - // --- private variables --- - - var level = 1; - var cells_infected = 0; - var cells_needed; // init'd below - var new_mutation = false; - // Color array for all the mutation levels - var color_array = [ - /* - p.color(250, 250, 40), - p.color(60, 240, 240), - p.color(167, 17, 161), - p.color(100, 250, 110), - p.color(13, 28, 171), - p.color(118, 12, 25) - */ - 0xffff2a7f, - 0xffffff00, - 0xff7f2aff, - 0xff37c871, - 0xffd42aff, - 0xffff7f2a, - 0xff2ad4ff, - 0xffff2a2a, - 0xff7fff2a, - 0xffc8b7b7 - ]; - -/* - // Keeps track of all the abilities earned in the game so far - // If you lose a mutation level, must pop abilities off this array - var abilities = []; - - // All the possible abilities, sorted by level - // An ability can be earned at level x if it is in poss_abilities[0-x] - // TODO: add all abilities and change their levels - // TODO: Change these to be ready to be displayed to the user (or create a formatting mechanism) - var poss_abilities = [ - ["extra_particle"], - ["faster_particles", "bigger_particles"] - ]; -*/ - - // Flashing - var flash_color = null; - var is_flashing = false; - - // Shows the probability of getting a mutation - var bar_status_obj = num_status_obj(p, { - pos : new p.PVector(170, spec.status_height || 20), - text : "Mutation:", - num : 0, - bar : true, - max : 0 // init'd below - }); - - //Shows the curent mutation level - var level_spec = { - pos : new p.PVector(350, spec.status_height || 20), - text : "Level ", - num : 1, - text_color : p.color(0) - }; - var level_status_obj = num_status_obj(p, level_spec); - - // --- private methods - -/* - // Returns a random ability, taking into account the current level - // Every possibile ability has an equal chance - var get_random_ability = function() { - var all_possible = []; - for(var i = 0; i < level; i++) { - for_each(poss_abilities[i], function(a) {all_possible.push(a);}); - } - assert(all_possible.length != 0); - return all_possible[Math.floor(Math.random() * all_possible.length)]; - } -*/ - - // Returns bool saying if a mutation should occur - // takes into account level, cells_infected, and a random probability - var mutation_occured = function() { - //return Math.random() + ( (cells_infected / 50) / (level + 1)) > .95; - //return (Math.random() * (cells_infected / 50)) > .3; - //return (Math.random() + (cells_infected / 100) - (level / 50)) > .98; - return (Math.random()*0.5 + (cells_infected / cells_needed)) > .98; - }; - - // returns the max number of cells the player needs to infect to have - // a 100% probability of mutating - var calc_cells_needed = function() { - return 30 + 20*level; - }; - cells_needed = calc_cells_needed(); - bar_status_obj.set_max(cells_needed); - - // Flashes the mutation bar red and white - var flash_bar = function() { - is_flashing = true; - - // Flash red and white every half second - flash_red(); - setTimeout(flash_white, 500); - setTimeout(flash_red, 1000); - setTimeout(flash_white, 1500); - setTimeout(flash_red, 2000); - setTimeout(flash_white, 2500); - // End flashing in 3 seconds - setTimeout(end_flash, 3000); - } - - // updates the flash color - var flash_red = function() { - flash_color = [255, 0, 0]; - } - var flash_white = function() { - flash_color = [255, 255, 255]; - } - - // Draws the bar with the appropriate flashing color - var draw_flashing_bar = function() { - bar_status_obj.draw_color(flash_color); - } - // Ends the flashing - var end_flash = function() { - is_flashing = false; - } - - // Gives us a rainbow gradient - // Taken from : http://snipplr.com/view.php?codeview&id=14590 - /** - * HSV to RGB color conversion - * - * H runs from 0 to 360 degrees - * S and V run from 0 to 100 - * - * Ported from the excellent java algorithm by Eugene Vishnevsky at: - * http://www.cs.rit.edu/~ncs/color/t_convert.html - */ - var hsvToRgb = function(h, s, v) { - var r, g, b; - var i; - var f, p, q, t; - - // Make sure our arguments stay in-range - h = Math.max(0, Math.min(360, h)); - s = Math.max(0, Math.min(100, s)); - v = Math.max(0, Math.min(100, v)); - - // We accept saturation and value arguments from 0 to 100 because that's - // how Photoshop represents those values. Internally, however, the - // saturation and value are calculated from a range of 0 to 1. We make - // That conversion here. - s /= 100; - v /= 100; - - if(s == 0) { - // Achromatic (grey) - r = g = b = v; - return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; - } - - h /= 60; // sector 0 to 5 - i = Math.floor(h); - f = h - i; // factorial part of h - p = v * (1 - s); - q = v * (1 - s * f); - t = v * (1 - s * (1 - f)); - - switch(i) { - case 0: - r = v; - g = t; - b = p; - break; - - case 1: - r = q; - g = v; - b = p; - break; - - case 2: - r = p; - g = v; - b = t; - break; - - case 3: - r = p; - g = q; - b = v; - break; - - case 4: - r = t; - g = p; - b = v; - break; - - default: // case 5: - r = v; - g = p; - b = q; - } - - return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; - } - - // --- public methods --- - - obj.draw = function() { - bar_status_obj.draw(); - if (is_flashing) { - draw_flashing_bar(); - } - - // draw mutation colored box under level num - p.fill(get_color()); - p.noStroke(); - var lpos = level_spec.pos; - p.rectMode(p.CORNER); - p.rect(lpos.x-30, lpos.y-10, 70, 20); - - level_status_obj.draw(); - }; - - // increments the mutation percentage - obj.infected_cell = function() { - cells_infected += 1; - bar_status_obj.incr(1); - // if a mutation occurs - if (mutation_occured()) { - // set the flag - new_mutation = true; - flash_bar(); - - // Play sounds - sounds.play_sound("level_up"); - } - }; - - // returns true if a new mutation is ready - obj.has_new_mutation = function() { - return new_mutation; - }; - - // to be called when in_game_state decides to enact the new mutation - // as signalled by the flag - // Returns a new ability if one was added - obj.do_mutation = function() { - flash_bar(); - // Add new ability before incrementing level - //var new_ability = get_random_ability(); - //abilities.push(new_ability); - level += 1; - level_status_obj.incr(1); - // update num cells needed - cells_needed = calc_cells_needed(); - bar_status_obj.set_max(cells_needed); - // reset counters - obj.reset_mutation(); - - //return new_ability; - }; - - - // resets the counters and the flag - // to be called after a mutation is enacted in the game - obj.reset_mutation = function() { - cells_infected = 0; - bar_status_obj.set_num(0); - // reset flag - new_mutation = false; - }; - - var get_color = function() { - return color_array[(level - 1) % color_array.length]; - }; - - // Returns the current mutation level and color - obj.get_info = function() { - // color level goes from 0 to 360 - //var new_color_level = (360 - (360 - level * 30)); - //var hue = new_color_level / 360; - //var rgb_arr = hsvToRgb(new_color_level, 75, 75); - return { - level: level, - //color: p.color(rgb_arr[0], rgb_arr[1], rgb_arr[2]), - // level starts at 1, so have to subtract 1 - color : get_color(), //% color_array.size], - // get one new particle every 10 levels - particles: 3+p.floor(level/3), - //abilities: abilities - }; - }; - - obj.get_level = function() { - return level; - }; - - obj.set_level = function(l) { - // decrement by the difference in levels - level_status_obj.incr(l-level); - // Pop off abilities - /* - for (var i = 0; i < (level - l); i++) { - abilities.pop(); - } - */ - // set the new level - level = l; - }; - - return obj; -}; diff --git a/game/old/fb/notification.js b/game/old/fb/notification.js deleted file mode 100644 index dfee58e..0000000 --- a/game/old/fb/notification.js +++ /dev/null @@ -1,64 +0,0 @@ -// Used to alert the user of new information -// draw() returns false if the status update is finished -// spec: -// text : text to display -// color : color of text (defaults to black) -// pos : pos of notification - -var notification = function(p, spec) { - - // object to return - var obj = {}; - - // --- private variables --- - - var time_counter = 0; // used to draw the object at various times - var total_time = 60; // ~ 2 seconds. If changed must be changed in notify in in_game_state to prevent overlap //200; // ~6 secs? - - var text_size = 20; - var box_color = spec.color || p.color(255, 255, 255); - - // --- public methods --- - - - obj.draw = function() { - var time_percent = time_counter / total_time; - //var text_size = 25 - 25*(time_percent); - var text_alpha = 255 - 200*time_percent; - - //var x_pos = (p.width * (5/8)); //+ (p.width / 2) *time_percent; - //var y_pos = (p.height * (5/8)) - (p.height / 2) *time_percent; - - var x_pos = spec.pos.x; - var y_pos = spec.pos.y; - - // I don't like the moving from the center - // so I'm trying it stationary - //var x_pos = p.width / 2; - //var y_pos = 70; - - // this needs to come before textWidth - p.textAlign(p.CENTER, p.CENTER); - p.textSize(text_size); - - var w = p.textWidth(spec.text); - - // draw a box behind it - //p.fill(box_color, text_alpha); - //p.rectMode(p.CORNER) - //p.rect(x_pos-w/2-5, y_pos-p.textAscent(), w+10, p.textAscent()*2); - - //p.fill(p.color(0, 0, 0), text_alpha); - //p.fill(p.color(255, 255, 255), text_alpha); - p.fill(box_color, text_alpha); - p.text(spec.text, x_pos, y_pos); - - if (time_counter > total_time) { // Finished - return false; - } - time_counter++; - return true; - } - - return obj; -}; diff --git a/game/old/fb/num_status_obj.js b/game/old/fb/num_status_obj.js deleted file mode 100644 index fc05e28..0000000 --- a/game/old/fb/num_status_obj.js +++ /dev/null @@ -1,115 +0,0 @@ -// Generic wrapper for a status that includes text and a num -// Can be drawn as a number or a bar -// Provides draw, incr, set_num, and get_num -// spec: -// pos : center pos of text -// text : Will display " " -// num : num to start at -// bar : bool (optional) -// max : num (required if bar) - -var num_status_obj = function(p, spec) { - - // obj to return - var obj = {}; - - // --- private variables --- - - var pos = spec.pos; - var number = spec.num; - var txt = spec.text; - var bar = spec.bar || false; - var max = spec.max; - var height = 20; - var max_width = 100; //for the bar, might need to be passed in - - var get_obj_text = function() { - if (bar) { - return txt; - } - else { - var num_txt = ""+number; - if (spec.format) { - num_txt = spec.format(number); - } - return txt + " " + num_txt; - } - } - - var rect = rectangle(p, { // Really just a text obj - pos : pos, - width : 0, - height : 0, - text : get_obj_text(), - text_size : 14, - text_color: spec.text_color || 255, - }); - - // --- private methods - - var update = function(n) { - - number = n; - - rect.update_text(get_obj_text()); - }; - var draw_full_rect = function(color) { - p.fill(color[0], color[1], color[2]); - //p.strokeWeight(1); - //p.stroke(0); - var topy = pos.y - (height / 2); - var leftx = pos.x + (txt.length * 4); - p.rect(leftx, topy, max_width, height); - }; - - // --- public methods --- - - obj.draw = function() { - rect.draw(); - // Draw the bar separately, if appropriate - if (bar) { - p.noStroke(); - // Draw empty rectangle first - draw_full_rect([255, 255, 255]); - - // Then draw mutation status bar - p.fill(150); - - var topy = pos.y - (height / 2); - var leftx = pos.x + (txt.length * 4); - var rect_width = (number / max) * max_width; - rect_width = rect_width > max_width ? max_width : rect_width; - p.rectMode(p.CORNER); - p.rect(leftx, topy, rect_width, height); - - p.fill(255) - } - }; - - // SHOULD ONLY BE CALLED IF bar IS TRUE - // Draws a full bar of the specified color - // color : 3 element rgb array - obj.draw_color = function(color) { - draw_full_rect(color); - }; - - obj.incr = function(n) { - update(number + n); - }; - - // Set and get - - obj.set_max = function(m) { - max = m; - }; - - obj.set_num = function(n) { - update(n); - }; - - obj.get_num = function() { - return number; - }; - - return obj; -}; diff --git a/game/old/fb/object_with_states.js b/game/old/fb/object_with_states.js deleted file mode 100644 index a18e993..0000000 --- a/game/old/fb/object_with_states.js +++ /dev/null @@ -1,26 +0,0 @@ -// Gives an object the capability to set and get states -// inherits from game_object -// spec: -// spec.state -- current state, default to 'alive' - -var object_with_states = function(p, spec) { - - var obj = game_object(p, spec); - - var state = spec.state || "alive"; - - // --- public methods --- - - obj.set_state = function(s) { - // If outdated, don't update state - if (state != "outdated") { - state = s; - } - }; - - obj.get_state = function() { - return state; - }; - - return obj; -} diff --git a/game/old/fb/old-index.html b/game/old/fb/old-index.html deleted file mode 100644 index 3f3eb4d..0000000 --- a/game/old/fb/old-index.html +++ /dev/null @@ -1,223 +0,0 @@ - - - -Virion - - - - - - - - - -
        - - -
        Login with Facebook to track your high scores!
        - - - - Login with Facebook - - - -

        - -
        You are not Logged In
        - - - - -
        -
        Welcome to Virion beta testing!  Give the game a try and then scroll down to give us your feedback.
        -
        - -
        -
        - Could not load high scores! You may want to check your internet connection. -
        -
        - - - Your browser does not support the HTML5 canvas element. Upgrade to Chrome, Firefox 4, Safari, or Opera to play this game. - -
        -
        -

        Virion Beta Testing Feedback

        -
        - Tell us what you thought of the game by filling out the survey below. You can also email us at viriongame at gmail dot com. Thanks! We appreciate your help.  — The Virion Team -
        -
        - -
        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/old/fb/option_button.js b/game/old/fb/option_button.js deleted file mode 100644 index 5154998..0000000 --- a/game/old/fb/option_button.js +++ /dev/null @@ -1,63 +0,0 @@ -// Have a rectangle representing their position and a state to go to when clicked -// spec: -// rect : spec for a rectangle representing the button -// click_fun : what to do when clicked -// global_var : var that determines whether this option is enabled or not - -var option_button = function(p, spec) { - - // --- defaults --- - //spec.rect.width = spec.width || 200; - //spec.rect.height = spec.height || 60; - - // obj to return - var obj = {}; - - // --- private variables --- - - var but = button(p, spec); - var rect = rectangle(p, spec.rect); - // Left-edge x and top-edge y coordinates of 'checkbox' indicating whether - // option is enabled - var status_x = rect.get_left_x() + 28//50; - var status_y = rect.get_top_y() + 30//37; - var tick_size = 30; - var tick_yes_image = image_manager.get_image("check1.png"); - var tick_no_image = image_manager.get_image("check0.png"); - - // --- public methods --- - - obj.draw = function() { - //rect.draw(); - but.draw(); - - p.imageMode(p.CENTER); - if (g[spec.global_var]) { - //p.fill(255, 255, 255); - //p.ellipse(status_x, status_y, 10, 10); - p.image(tick_yes_image, status_x, status_y, tick_size, tick_size); - } - else { - p.image(tick_no_image, status_x, status_y, tick_size, tick_size); - } - }; - - // Returns the state to go to if clicked, or - // null if not clicked - obj.click = function(x, y) { - //but.is_clicked(); - if (rect.is_in(x, y)) { - spec.click_fun(); - } - // Redraw in case anything changes - obj.draw(); - }; - - obj.is_clicked = function() { return null; }; - - obj.mouse_moved = function(x, y) { - but.mouse_moved(x, y); - }; - - return obj; -}; diff --git a/game/old/fb/options_state.js b/game/old/fb/options_state.js deleted file mode 100644 index fa0bdfb..0000000 --- a/game/old/fb/options_state.js +++ /dev/null @@ -1,193 +0,0 @@ -var options_state = function (p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var background_image = image_manager.get_image("settingssplash.png"); - - var button_style = { - text_x_offset : 60, - text_y_offset: -3, - text_align: p.LEFT - }; - - // Buttons - - var col1_x = p.width/2 - 120; - var col2_x = p.width/2 + 120; - - var back_button = button(p, { - state : function() { - sounds.play_button_back(); - return prev_state; - }, - rect : { - pos : new p.PVector(p.width / 2, p.height - 80), - //width : 120, - //height : 50, - //text: "Back", - //text_x_offset: 5, - //text_y_offset: -8, - image: "back.png", - } - }); - - // Options - //var option_image = "bullet_listcell.png"; - var sound_fx_button = option_button(p, { - click_fun : function() {sounds.play_button_click(); g.toggle_sound_fx();}, - global_var : "sound_fx", - rect : { - pos : new p.PVector(col1_x, p.height/2 - 70), - //text: "Sound Effects", - //text_x_offset: 60, - image : "set_sound.png",//option_image, - //over_image : "set_sound_a.png", - //style: button_style - } - }); - var music_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - // toggle the flag - g.toggle_music(); - }, - global_var : "music", - rect : { - pos : new p.PVector(col1_x, p.height/2 + 40), - //text: "Music", - //text_x_offset: 60, - image : "set_music.png",//option_image, - //over_image : "set_music_a.png", - //style: button_style - } - }); - var spacebar_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - g.toggle_spacebar_to_fire(); - }, - global_var : "spacebar_to_fire", - rect : { - pos : new p.PVector(col2_x, p.height/2 - 70), - //text: "Spacebar to Fire", - //text_x_offset : 60, - image : "set_spacebar.png",//option_image, - //over_image : "set_spacebar_a.png", - //style: button_style - } - }); - var mouse_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - g.toggle_click_to_fire(); - }, - global_var : "click_to_fire", - rect : { - pos : new p.PVector(col2_x, p.height/2 + 40), - //text: "Mouse Click to Fire", - //text_x_offset : 60, - image : "set_click.png",//option_image, - //over_image : "set_click_a.png", - //style: button_style - } - }); - var mouse_to_select_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - g.toggle_mouse_to_select(); - }, - global_var : "mouse_to_select", - rect : { - pos : new p.PVector(col2_x, p.height/2 + 140), - //text: "Mouse to Select Cells\nInstead of Left/Right", - image : "set_mouseselect.png",//option_image, - //over_image : "set_mouseselect_a.png", - //text_x_offset : 60, - //style: button_style - } - }); - var track_left_button = button(p, { - state : function() { - sounds.play_button_click(); - g.prev_track(); - return obj; - }, - rect : { - pos : new p.PVector(col1_x - 50, p.height/2 + 145), - image : "track_left.png", - } - }); - var track_right_button = button(p, { - state : function() { - sounds.play_button_click(); - g.next_track(); - return obj; - }, - rect : { - pos : new p.PVector(col1_x + 50, p.height/2 + 145), - image : "track_right.png", - } - }); - - - - //Not ordered - var all_option_buttons = [sound_fx_button, music_button, - spacebar_button, mouse_button, mouse_to_select_button]; - var all_buttons = [back_button, track_left_button, track_right_button] - .concat(all_option_buttons); - - - // --- public methods --- - - obj.get_type = function() { - return "options"; - }; - - obj.update = function() { - //do nothing - }; - - obj.key_pressed = function(k) { - if (k === 115 || p.keyCode === 13 || k === 32) { //s, enter, space - } - else if (k === 104) { //h - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - obj.render = function() { - //p.background(g.background_color); - //p.fill(g.background_color); - //p.rect(100, 100, 500, 500); - p.imageMode(p.CORNERS); - p.image(background_image, 0, 0);//, p.width, p.height); - - // draw the track button background manually - var track_x = col1_x; - var track_y = p.height/2 + 140; - var track_image = image_manager.get_image("set_track.png"); - p.imageMode(p.CENTER); - p.image(track_image, track_x, track_y); - // draw current track - p.fill(0); - p.textAlign(p.CENTER); - p.textSize(14); - p.text(g.track, track_x, track_y+5); - - for_each(all_option_buttons, function(b) { b.draw(); }); - }; - - obj.mouse_click = function(x, y) { - for_each(all_option_buttons, function(b) { b.click(x, y); }); - }; - - return obj; -}; diff --git a/game/old/fb/particle.js b/game/old/fb/particle.js deleted file mode 100644 index 630645b..0000000 --- a/game/old/fb/particle.js +++ /dev/null @@ -1,437 +0,0 @@ -// *** particle *** -// --- inherits from game_object -// spec: -// game_object spec - -var particle = function(p, spec) { - - // --- defaults --- - - // was 15 - spec.width = spec.width || 10; - spec.height = spec.height || 10; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "particle"; - }; - - // --- private variables --- - - //var par_shape = p.loadShape("images/virusfinal.svg"); - //var par_image = p.loadImage("images/virus1.png"); - var par_image = image_manager.get_image("tinyvirus_trans.png"); - //var mutation = spec.mutation; - - // --- public methods --- - - // implementing game_object interface - - // update is default (move) - - // draw makes a small virus particle - // (circle for now) - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.get_mode()); - //var color = mutation.get_color(); - p.fill(obj.get_color()); - p.noStroke(); - p.ellipse(pos.x, pos.y, - obj.get_width() * .75, obj.get_height() * .75); - p.imageMode(obj.get_mode()); - p.image(par_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - //var d = new Date(); - //console.log(d.getMilliseconds()); - //p.shape(par_shape, pos.x, pos.y, - //obj.get_width() + 20, obj.get_height() + 20); - //draw(canvas.getContext('2d')); - //canvas.getContext('2d').drawSvg("images/virusFinal.svg", 300, 10, 20, 20); - //console.log("a " + d.getMilliseconds()); - - }; - - // override for circular object - obj.calc_radius = function() { - return obj.get_width()/2; - }; - obj.set_radius(obj.calc_radius()); - - return obj; -} - -// SVG -> Javascript code to draw the particle -/* -var draw = function(ctx) { -ctx.save(); -ctx.strokeStyle = 'rgba(0,0,0,0)'; -ctx.lineCap = 'butt'; -ctx.lineJoin = 'miter'; -ctx.miterLimit = 4; -ctx.save(); -ctx.restore(); -ctx.save(); -ctx.restore(); -ctx.save(); -ctx.scale(0.02,0.02); -ctx.save(); -ctx.fillStyle = "#fff1d0"; -ctx.strokeStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.lineWidth = 5; -ctx.miterLimit = 4; -ctx.beginPath(); -ctx.moveTo(411.42857,373.36218); -ctx.bezierCurveTo(378.29148999999995,373.36218,351.42857,400.2251,351.42857,433.36218); -ctx.bezierCurveTo(351.42857,435.74656000000004,351.59556999999995,438.08169000000004,351.86607,440.39343); -ctx.bezierCurveTo(333.68726999999996,446.05755000000005,316.62739,454.24753000000004,301.08482,464.54968); -ctx.bezierCurveTo(293.76497,456.45166,283.20419999999996,451.36218,271.42857,451.36218); -ctx.bezierCurveTo(249.33718,451.36218,231.42856999999998,469.27079000000003,231.42856999999998,491.36218); -ctx.bezierCurveTo(231.42856999999998,503.13781,236.51805,513.69858,244.61606999999998,521.0184300000001); -ctx.bezierCurveTo(234.27291999999997,536.6228600000001,226.0638,553.7583900000001,220.39731999999998,572.0184300000001); -ctx.bezierCurveTo(217.46769999999998,571.5787200000001,214.48073999999997,571.3621800000001,211.42856999999998,571.3621800000001); -ctx.bezierCurveTo(178.29148999999998,571.3621800000001,151.42856999999998,598.2251000000001,151.42856999999998,631.3621800000001); -ctx.bezierCurveTo(151.42856999999998,664.49926,178.29148999999998,691.3621800000001,211.42856999999998,691.3621800000001); -ctx.bezierCurveTo(214.48073999999997,691.3621800000001,217.46769999999998,691.1456400000001,220.39731999999998,690.7059300000001); -ctx.bezierCurveTo(226.0638,708.9659700000001,234.27291999999997,726.1015000000001,244.61606999999998,741.7059300000001); -ctx.bezierCurveTo(236.51805,749.02578,231.42856999999998,759.5865500000001,231.42856999999998,771.3621800000001); -ctx.bezierCurveTo(231.42856999999998,793.4535700000001,249.33718,811.3621800000001,271.42857,811.3621800000001); -ctx.bezierCurveTo(283.20419999999996,811.3621800000001,293.76497,806.2727000000001,301.08482,798.1746800000001); -ctx.bezierCurveTo(316.68924999999996,808.5178300000001,333.82478,816.7269500000001,352.08482,822.3934300000001); -ctx.bezierCurveTo(351.64511,825.3230500000001,351.42857,828.31001,351.42857,831.3621800000001); -ctx.bezierCurveTo(351.42857,864.49926,378.29148999999995,891.3621800000001,411.42857,891.3621800000001); -ctx.bezierCurveTo(444.56565,891.3621800000001,471.42857,864.49926,471.42857,831.3621800000001); -ctx.bezierCurveTo(471.42857,828.31001,471.21202999999997,825.3230500000001,470.77232,822.3934300000001); -ctx.bezierCurveTo(489.03236,816.7269500000001,506.16789,808.5178300000001,521.77232,798.1746800000001); -ctx.bezierCurveTo(529.09217,806.2727000000001,539.6529400000001,811.3621800000001,551.42857,811.3621800000001); -ctx.bezierCurveTo(573.5199600000001,811.3621800000001,591.42857,793.4535700000001,591.42857,771.3621800000001); -ctx.bezierCurveTo(591.42857,759.5865500000001,586.33909,749.02578,578.24107,741.7059300000001); -ctx.bezierCurveTo(588.5842200000001,726.1015000000001,596.7933400000001,708.9659700000001,602.45982,690.7059300000001); -ctx.bezierCurveTo(605.38944,691.1456400000001,608.3764,691.3621800000001,611.42857,691.3621800000001); -ctx.bezierCurveTo(644.56565,691.3621800000001,671.42857,664.49926,671.42857,631.3621800000001); -ctx.bezierCurveTo(671.42857,598.2251000000001,644.56565,571.3621800000001,611.42857,571.3621800000001); -ctx.bezierCurveTo(608.3764,571.3621800000001,605.38944,571.5787200000001,602.45982,572.0184300000001); -ctx.bezierCurveTo(596.7933400000001,553.7583900000001,588.5842200000001,536.6228600000001,578.24107,521.0184300000001); -ctx.bezierCurveTo(586.33909,513.6985800000001,591.42857,503.13781000000006,591.42857,491.3621800000001); -ctx.bezierCurveTo(591.42857,469.2707900000001,573.5199600000001,451.3621800000001,551.42857,451.3621800000001); -ctx.bezierCurveTo(539.6529400000001,451.3621800000001,529.09217,456.45166000000006,521.77232,464.5496800000001); -ctx.bezierCurveTo(506.22975,454.2475300000001,489.16987000000006,446.0575500000001,470.99107000000004,440.3934300000001); -ctx.bezierCurveTo(471.26157000000006,438.0816900000001,471.42857000000004,435.7465600000001,471.42857000000004,433.3621800000001); -ctx.bezierCurveTo(471.42857000000004,400.2251000000001,444.56565000000006,373.3621800000001,411.42857000000004,373.3621800000001); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "#d4d4d4"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.globalAlpha = 0.2752293646335602; -ctx.beginPath(); -ctx.moveTo(530.99107,472.99893); -ctx.bezierCurveTo(556.1068300000001,506.42843999999997,570.99107,547.96659,570.99107,592.99893); -ctx.bezierCurveTo(570.99107,640.61609,554.33443,684.34142,526.55357,718.68643); -ctx.bezierCurveTo(529.38723,724.17581,530.99107,730.39551,530.99107,736.99893); -ctx.bezierCurveTo(530.99107,759.09032,513.0824600000001,776.99893,490.99107000000004,776.99893); -ctx.bezierCurveTo(481.81567,776.99893,473.36493,773.91293,466.61607000000004,768.71768); -ctx.bezierCurveTo(459.44539000000003,772.62788,452.0033,776.1000799999999,444.33482000000004,779.12393); -ctx.bezierCurveTo(459.07273000000004,788.9998499999999,469.20043000000004,805.23816,470.77232000000004,823.90518); -ctx.bezierCurveTo(552.02543,798.48635,610.99107,722.63081,610.99107,632.99893); -ctx.bezierCurveTo(610.99107,567.57432,579.55868,509.48801,530.99107,472.99893); -ctx.closePath(); -ctx.moveTo(250.99107000000004,752.99893); -ctx.bezierCurveTo(275.86402000000004,786.1052599999999,310.78272000000004,811.21984,351.20982000000004,823.87393); -ctx.bezierCurveTo(352.19252000000006,812.2756499999999,356.47693000000004,801.61852,363.11607000000004,792.84268); -ctx.bezierCurveTo(321.11956000000004,791.21726,282.46387000000004,776.64461,250.99107000000004,752.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(330.99107,780.39343); -ctx.bezierCurveTo(353.16121999999996,780.39343,371.13367,763.9635099999999,371.13367,743.6961799999999); -ctx.bezierCurveTo(371.13367,742.58201,371.07697,741.48232,370.97059,740.39343); -ctx.bezierCurveTo(369.14252,759.1119,351.94243,773.78793,330.99107000000004,773.78793); -ctx.bezierCurveTo(310.03970000000004,773.78793,292.83962,759.1119,291.01155000000006,740.39343); -ctx.bezierCurveTo(290.90521000000007,741.48232,290.8484700000001,742.58201,290.8484700000001,743.6961799999999); -ctx.bezierCurveTo(290.8484700000001,763.9635099999999,308.82092000000006,780.3934299999999,330.9910700000001,780.3934299999999); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(530.99107,606.99893); -ctx.bezierCurveTo(553.1612200000001,606.99893,571.13367,590.5690099999999,571.13367,570.30168); -ctx.bezierCurveTo(571.13367,569.1875100000001,571.0769700000001,568.0878200000001,570.97059,566.9989300000001); -ctx.bezierCurveTo(569.14252,585.7174000000001,551.9424300000001,600.3934300000001,530.99107,600.3934300000001); -ctx.bezierCurveTo(510.03970000000004,600.3934300000001,492.83962,585.7174000000001,491.01155000000006,566.9989300000001); -ctx.bezierCurveTo(490.90521000000007,568.0878200000001,490.8484700000001,569.1875100000001,490.8484700000001,570.30168); -ctx.bezierCurveTo(490.8484700000001,590.56901,508.82092000000006,606.99893,530.99107,606.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(290.99107,606.99893); -ctx.bezierCurveTo(313.16121999999996,606.99893,331.13367,590.5690099999999,331.13367,570.30168); -ctx.bezierCurveTo(331.13367,569.1875100000001,331.07697,568.0878200000001,330.97059,566.9989300000001); -ctx.bezierCurveTo(329.14252,585.7174000000001,311.94243,600.3934300000001,290.99107000000004,600.3934300000001); -ctx.bezierCurveTo(270.03970000000004,600.3934300000001,252.83962000000002,585.7174000000001,251.01155000000003,566.9989300000001); -ctx.bezierCurveTo(250.90521000000004,568.0878200000001,250.84847000000002,569.1875100000001,250.84847000000002,570.30168); -ctx.bezierCurveTo(250.84847000000002,590.56901,268.82092,606.99893,290.99107000000004,606.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(410.99107,700.39343); -ctx.bezierCurveTo(444.23506999999995,700.39343,471.18464,675.74855,471.18464,645.34755); -ctx.bezierCurveTo(471.18464,643.6763,471.09964,642.02676,470.94010000000003,640.39343); -ctx.bezierCurveTo(468.19892000000004,668.47114,442.4075,690.48518,410.99107000000004,690.48518); -ctx.bezierCurveTo(379.57463,690.48518,353.78322000000003,668.47114,351.04204000000004,640.39343); -ctx.bezierCurveTo(350.88258,642.02676,350.79750000000007,643.6763,350.79750000000007,645.34755); -ctx.bezierCurveTo(350.79750000000007,675.7485499999999,377.74707000000006,700.39343,410.9910700000001,700.39343); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(379.52232,680.31143); -ctx.bezierCurveTo(369.29332,669.55083,362.99107,655.01762,362.99107,638.99893); -ctx.bezierCurveTo(362.99107,605.86185,389.85398999999995,578.99893,422.99107,578.99893); -ctx.bezierCurveTo(432.90058,578.99893,442.2231,581.43242,450.45982,585.68643); -ctx.bezierCurveTo(439.5286,574.18711,424.10945999999996,566.99893,406.99107,566.99893); -ctx.bezierCurveTo(373.85398999999995,566.99893,346.99107,593.86185,346.99107,626.99893); -ctx.bezierCurveTo(346.99107,650.22651,360.21569999999997,670.34016,379.52232,680.31143); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(385.52232,490.31143); -ctx.bezierCurveTo(375.29332,479.55082999999996,368.99107,465.01761999999997,368.99107,448.99893); -ctx.bezierCurveTo(368.99107,415.86185,395.85398999999995,388.99893,428.99107,388.99893); -ctx.bezierCurveTo(438.90058,388.99893,448.2231,391.43242,456.45982,395.68643); -ctx.bezierCurveTo(445.5286,384.18710999999996,430.10945999999996,376.99893,412.99107,376.99893); -ctx.bezierCurveTo(379.85398999999995,376.99893,352.99107,403.86184999999995,352.99107,436.99893); -ctx.bezierCurveTo(352.99107,460.22650999999996,366.21569999999997,480.34015999999997,385.52232,490.31143); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(410.99107,496.90718); -ctx.bezierCurveTo(444.23506999999995,496.90718,471.18464,472.2623,471.18464,441.86129999999997); -ctx.bezierCurveTo(471.18464,440.19005,471.09964,438.54051,470.94010000000003,436.90718); -ctx.bezierCurveTo(468.19892000000004,464.98489,442.4075,486.99893,410.99107000000004,486.99893); -ctx.bezierCurveTo(379.57463,486.99893,353.78322000000003,464.98488999999995,351.04204000000004,436.90718); -ctx.bezierCurveTo(350.88258,438.54051,350.79750000000007,440.19005,350.79750000000007,441.86129999999997); -ctx.bezierCurveTo(350.79750000000007,472.2623,377.74707000000006,496.90718,410.9910700000001,496.90718); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(385.52232,880.31143); -ctx.bezierCurveTo(375.29332,869.55083,368.99107,855.01762,368.99107,838.99893); -ctx.bezierCurveTo(368.99107,805.86185,395.85398999999995,778.99893,428.99107,778.99893); -ctx.bezierCurveTo(438.90058,778.99893,448.2231,781.43242,456.45982,785.68643); -ctx.bezierCurveTo(445.5286,774.18711,430.10945999999996,766.99893,412.99107,766.99893); -ctx.bezierCurveTo(379.85398999999995,766.99893,352.99107,793.86185,352.99107,826.99893); -ctx.bezierCurveTo(352.99107,850.22651,366.21569999999997,870.34016,385.52232,880.31143); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(214.99107,572.99893); -ctx.bezierCurveTo(181.85399,572.99893,154.99107,599.86185,154.99107,632.99893); -ctx.bezierCurveTo(154.99107,656.22651,168.2157,676.34016,187.52232,686.31143); -ctx.bezierCurveTo(177.29332,675.55083,170.99107,661.01762,170.99107,644.99893); -ctx.bezierCurveTo(170.99107,616.5388399999999,190.81059000000002,592.72182,217.39732,586.56143); -ctx.bezierCurveTo(218.55700000000002,582.09924,219.88045,577.67801,221.33482,573.34268); -ctx.bezierCurveTo(219.25357,573.12367,217.13087000000002,572.99893,214.99107,572.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(610.99107,572.99893); -ctx.bezierCurveTo(608.53101,572.99893,606.12354,573.18,603.74107,573.46768); -ctx.bezierCurveTo(605.0957900000001,578.3556199999999,606.25589,583.31197,607.24107,588.34268); -ctx.bezierCurveTo(613.4279,586.18599,620.06901,584.99893,626.99107,584.99893); -ctx.bezierCurveTo(636.90058,584.99893,646.2231,587.43242,654.45982,591.68643); -ctx.bezierCurveTo(643.5286,580.18711,628.10946,572.99893,610.99107,572.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(270.40757,590.02506); -ctx.bezierCurveTo(263.48731000000004,583.2801400000001,259.22363,574.1704900000001,259.22363,564.12971); -ctx.bezierCurveTo(259.22363,543.3588500000001,277.39728,526.5207300000001,299.81559000000004,526.5207300000001); -ctx.bezierCurveTo(306.51970000000006,526.5207300000001,312.82669000000004,528.0460800000001,318.39911000000006,530.71256); -ctx.bezierCurveTo(311.0037700000001,523.5046000000001,300.5722200000001,518.9989300000001,288.99107000000004,518.9989300000001); -ctx.bezierCurveTo(266.57276,518.9989300000001,248.39911000000004,535.8370500000001,248.39911000000004,556.6079100000001); -ctx.bezierCurveTo(248.39911000000004,571.1673400000001,257.34600000000006,583.7749000000001,270.40757,590.02506); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(509.82696,588.84012); -ctx.bezierCurveTo(503.02601999999996,582.03508,498.83585,572.84422,498.83585,562.71395); -ctx.bezierCurveTo(498.83585,541.75794,516.69616,524.76973,538.7279599999999,524.76973); -ctx.bezierCurveTo(545.31648,524.76973,551.51473,526.30868,556.9910699999999,528.99893); -ctx.bezierCurveTo(549.7232399999999,521.72672,539.4715399999999,517.18089,528.0900599999999,517.18089); -ctx.bezierCurveTo(506.0582699999999,517.18089,488.19795999999985,534.1691,488.19795999999985,555.1251); -ctx.bezierCurveTo(488.19795999999985,569.81431,496.9905899999998,582.5342499999999,509.8269599999999,588.84012); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(249.11607,744.46768); -ctx.bezierCurveTo(239.42177,750.46789,232.99107,761.00366,232.99107,772.99893); -ctx.bezierCurveTo(232.99107,786.0855399999999,240.67045000000002,797.41228,251.86607,803.03018); -ctx.bezierCurveTo(245.93443000000002,796.96757,242.27232,788.77399,242.27232,779.74893); -ctx.bezierCurveTo(242.27232,768.88478,247.54392,759.24582,255.74107,753.06143); -ctx.bezierCurveTo(253.45899,750.25464,251.24597,747.3976,249.11607,744.46768); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(572.05357,748.21768); -ctx.bezierCurveTo(571.2613600000001,749.2555,570.45924,750.28971,569.64732,751.31143); -ctx.bezierCurveTo(573.66413,751.8387799999999,577.4639400000001,753.04166,580.92857,754.78018); -ctx.bezierCurveTo(578.36622,752.16126,575.3596,749.93576,572.05357,748.21768); -ctx.closePath(); -ctx.moveTo(530.45982,788.87393); -ctx.bezierCurveTo(528.51967,790.28432,526.54551,791.65748,524.55357,792.99893); -ctx.bezierCurveTo(527.85458,799.46132,533.17976,804.78457,539.77232,808.09268); -ctx.bezierCurveTo(534.7460100000001,802.9553999999999,531.37795,796.27958,530.45982,788.87393); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(490.99107,780.99893); -ctx.bezierCurveTo(513.16122,780.99893,531.1336699999999,764.5690099999999,531.1336699999999,744.30168); -ctx.bezierCurveTo(531.1336699999999,743.1875100000001,531.07697,742.0878200000001,530.9705899999999,740.9989300000001); -ctx.bezierCurveTo(529.1425199999999,759.7174000000001,511.9424299999999,774.3934300000001,490.9910699999999,774.3934300000001); -ctx.bezierCurveTo(470.0396999999999,774.3934300000001,452.8396199999999,759.7174000000001,451.01154999999994,740.9989300000001); -ctx.bezierCurveTo(450.90520999999995,742.0878200000001,450.84846999999996,743.1875100000001,450.84846999999996,744.30168); -ctx.bezierCurveTo(450.84846999999996,764.56901,468.82091999999994,780.99893,490.99107,780.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(252.5773,518.27473); -ctx.bezierCurveTo(246.64565000000002,512.21212,242.99107,504.02398999999997,242.99107,494.99893); -ctx.bezierCurveTo(242.99107,476.32923,258.56848,461.19444,277.78418,461.19444); -ctx.bezierCurveTo(283.53056,461.19444,288.93655,462.56549,293.71290999999997,464.96223); -ctx.bezierCurveTo(287.37404999999995,458.48341999999997,278.43271999999996,454.43354,268.50602,454.43354); -ctx.bezierCurveTo(249.29031999999998,454.43354,233.71290999999997,469.56833,233.71290999999997,488.23803); -ctx.bezierCurveTo(233.71290999999997,501.32464,241.38166999999996,512.65684,252.57729999999998,518.27473); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(550.99107,456.99893); -ctx.bezierCurveTo(541.15601,456.99893,532.2878900000001,460.96844,525.95982,467.34268); -ctx.bezierCurveTo(529.09436,469.54866,532.14881,471.83973999999995,535.14732,474.21768); -ctx.bezierCurveTo(541.4817800000001,467.78294999999997,550.38418,463.74893,560.27232,463.74893); -ctx.bezierCurveTo(566.0187000000001,463.74893,571.43347,465.13343999999995,576.20982,467.53018); -ctx.bezierCurveTo(569.87097,461.05136999999996,560.91777,456.99893,550.99107,456.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(310.12323,762.27473); -ctx.bezierCurveTo(303.07660999999996,756.21629,298.73508,748.0337999999999,298.73508,739.01495); -ctx.bezierCurveTo(298.73508,720.35811,317.24055999999996,705.23373,340.06822999999997,705.23373); -ctx.bezierCurveTo(346.89475,705.23373,353.3169,706.60384,358.99107,708.9989300000001); -ctx.bezierCurveTo(351.4607,702.5245800000001,340.83867,698.4774900000001,329.04605999999995,698.4774900000001); -ctx.bezierCurveTo(306.2184,698.4774900000001,287.71290999999997,713.6018600000001,287.71290999999997,732.2587100000001); -ctx.bezierCurveTo(287.71290999999997,745.33631,296.82316,756.6607,310.12323,762.2747300000001); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(470.75204,762.27473); -ctx.bezierCurveTo(463.5077,756.21629,459.04435,748.0337999999999,459.04435,739.01495); -ctx.bezierCurveTo(459.04435,720.35811,478.06908,705.23373,501.53727000000003,705.23373); -ctx.bezierCurveTo(508.55534000000006,705.23373,515.15769,706.60384,520.99107,708.9989300000001); -ctx.bezierCurveTo(513.2494,702.5245800000001,502.32933,698.4774900000001,490.20583000000005,698.4774900000001); -ctx.bezierCurveTo(466.73764000000006,698.4774900000001,447.7129100000001,713.6018600000001,447.7129100000001,732.2587100000001); -ctx.bezierCurveTo(447.7129100000001,745.33631,457.0787900000001,756.6607,470.7520400000001,762.2747300000001); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.restore(); -ctx.restore(); -}; -*/ diff --git a/game/old/fb/pause_state.js b/game/old/fb/pause_state.js deleted file mode 100644 index 30e7767..0000000 --- a/game/old/fb/pause_state.js +++ /dev/null @@ -1,121 +0,0 @@ -var pause_state = function (p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - // Buttons - // Have a rectangle representing their position and - // a state to go to when pressed - var button_x = p.width / 2; - var button_top = 200; - var button_sep = 60; - - var button_style = { - text_size: 14, - text_align: p.LEFT, - text_x_offset: 25, - width: 120, - height: 50, - }; - - - var continue_button = button(p, { - state : function() { - sounds.play_button_click(); - return prev_state; - }, - rect : { - pos : new p.PVector(button_x, button_top), - //text: "Continue", - image: "continue.png", - width: 120, - height: 50 - //image_x_offset: 5, - //style: button_style - } - }); - - var options_button = button(p, { - state : function() { - sounds.play_button_click(); - return options_state(p, obj); - }, - rect : { - pos : new p.PVector(button_x, button_top+button_sep), - //text: "Settings", - image: "settings.png", - //style: button_style - } - }); - - var help_button = button(p, { - state : function() { - sounds.play_button_click(); - return help_state(p, obj); - }, - rect : { - pos : new p.PVector(button_x, button_top+2*button_sep), - //text: "Instructions", - //text_x_offset: 10, - image: "instructions.png", - //image_x_offset: 3, - //style: button_style - } - }); - - var quit_button = button(p, { - state : function() { - sounds.play_button_click(); - return splash_state(p); - }, - rect : { - pos : new p.PVector(button_x, button_top+3*button_sep), - //text: "Quit", - //text_x_offset: -5, - image: "quit.png", - //image_x_offset: -5, - //style: button_style - } - }); - - //Not ordered - var all_buttons = [ continue_button, options_button, - help_button, quit_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "pause"; - }; - - obj.update = function() { - //do nothing - }; - - obj.render = function() { - p.noStroke(); - p.fill(0, 150); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.fill(255); - p.textSize(40); - p.textAlign(p.CENTER); - p.text("Game Paused", p.width/2, 150); - }; - - obj.key_pressed = function(k) { - if (k === 112 || p.keyCode === 13 || p.keyCode === 27) { //p, enter, esc - obj.exit_state();; - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/game/old/fb/php_functions.php b/game/old/fb/php_functions.php deleted file mode 100644 index fc47660..0000000 --- a/game/old/fb/php_functions.php +++ /dev/null @@ -1,102 +0,0 @@ - - -var g_soundDataMap = -{ - "cell_fire" : "", - "cell_infect" : "", - "macrophage_infect" : "", - "level_up" : "", - "kill" : "", - "buttonmain" : "", - "buttonback" : "", - "cell_firemp3" : "", - "cell_infectmp3" : "", - "macrophage_infectmp3" : "", - "level_upmp3" : "", - "killmp3" : "", - "buttonmainmp3" : "", - "buttonbackmp3" : "", -}; - -/* -Not working -var dynamic_div_tag = null; -// Jplayer instances - -*/ - -//IMAGES - - -//var image_list = []; -//var g_infected_cell_images = []; -//var g_empty_cell_images = []; - -// to be used in image_manager -all_image_files = {}; - - - diff --git a/game/old/fb/processing-1.0.0.js b/game/old/fb/processing-1.0.0.js deleted file mode 100644 index 605223f..0000000 --- a/game/old/fb/processing-1.0.0.js +++ /dev/null @@ -1,18013 +0,0 @@ -/* - - P R O C E S S I N G . J S - 1.0.0 - a port of the Processing visualization language - - License : MIT - Developer : John Resig: http://ejohn.org - Web Site : http://processingjs.org - Java Version : http://processing.org - Github Repo. : http://github.com/jeresig/processing-js - Bug Tracking : http://processing-js.lighthouseapp.com - Mozilla POW! : http://wiki.Mozilla.org/Education/Projects/ProcessingForTheWeb - Maintained by : Seneca: http://zenit.senecac.on.ca/wiki/index.php/Processing.js - Hyper-Metrix: http://hyper-metrix.com/#Processing - BuildingSky: http://weare.buildingsky.net/pages/processing-js - - */ - -(function() { - - var undef; // intentionally left undefined - - var ajax = function ajax(url) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", url, false); - xhr.setRequestHeader("If-Modified-Since", "Fri, 01 Jan 1960 00:00:00 GMT"); - xhr.send(null); - // failed request? - if (xhr.status !== 200 && xhr.status !== 0) { throw ("XMLHttpRequest failed, status code " + xhr.status); } - return xhr.responseText; - }; - - /* Browsers fixes start */ - function fixReplaceByRegExp() { - var re = /t/g; - if ("t".replace(re,"") !== null && re.exec("t")) { - return; // it is not necessary - } - var _ie_replace = String.prototype.replace; - String.prototype.replace = function(searchValue, repaceValue) { - var result = _ie_replace.apply(this, arguments); - if (searchValue instanceof RegExp && searchValue.global) { - searchValue.lastIndex = 0; - } - return result; - }; - } - - function fixMatchByRegExp() { - var re = /t/g; - if ("t".match(re) !== null && re.exec("t")) { - return; // it is not necessary - } - var _ie_match = String.prototype.match; - String.prototype.match = function(searchValue) { - var result = _ie_match.apply(this, arguments); - if(searchValue instanceof RegExp && searchValue.global) { - searchValue.lastIndex = 0; - } - return result; - }; - } - fixReplaceByRegExp(); - fixMatchByRegExp(); - - (function fixOperaCreateImageData() { - try { - if (!("createImageData" in CanvasRenderingContext2D.prototype)) { - CanvasRenderingContext2D.prototype.createImageData = function (sw, sh) { - return new ImageData(sw, sh); - }; - } - } catch(e) {} - }()); - /* Browsers fixes end */ - - var PConstants = { - X: 0, - Y: 1, - Z: 2, - - R: 3, - G: 4, - B: 5, - A: 6, - - U: 7, - V: 8, - - NX: 9, - NY: 10, - NZ: 11, - - EDGE: 12, - - // Stroke - SR: 13, - SG: 14, - SB: 15, - SA: 16, - - SW: 17, - - // Transformations (2D and 3D) - TX: 18, - TY: 19, - TZ: 20, - - VX: 21, - VY: 22, - VZ: 23, - VW: 24, - - // Material properties - AR: 25, - AG: 26, - AB: 27, - - DR: 3, - DG: 4, - DB: 5, - DA: 6, - - SPR: 28, - SPG: 29, - SPB: 30, - - SHINE: 31, - - ER: 32, - EG: 33, - EB: 34, - - BEEN_LIT: 35, - - VERTEX_FIELD_COUNT: 36, - - // Renderers - P2D: 1, - JAVA2D: 1, - WEBGL: 2, - P3D: 2, - OPENGL: 2, - PDF: 0, - DXF: 0, - - // Platform IDs - OTHER: 0, - WINDOWS: 1, - MAXOSX: 2, - LINUX: 3, - - EPSILON: 0.0001, - - MAX_FLOAT: 3.4028235e+38, - MIN_FLOAT: -3.4028235e+38, - MAX_INT: 2147483647, - MIN_INT: -2147483648, - - PI: Math.PI, - TWO_PI: 2 * Math.PI, - HALF_PI: Math.PI / 2, - THIRD_PI: Math.PI / 3, - QUARTER_PI: Math.PI / 4, - - DEG_TO_RAD: Math.PI / 180, - RAD_TO_DEG: 180 / Math.PI, - - WHITESPACE: " \t\n\r\f\u00A0", - - // Color modes - RGB: 1, - ARGB: 2, - HSB: 3, - ALPHA: 4, - CMYK: 5, - - // Image file types - TIFF: 0, - TARGA: 1, - JPEG: 2, - GIF: 3, - - // Filter/convert types - BLUR: 11, - GRAY: 12, - INVERT: 13, - OPAQUE: 14, - POSTERIZE: 15, - THRESHOLD: 16, - ERODE: 17, - DILATE: 18, - - // Blend modes - REPLACE: 0, - BLEND: 1 << 0, - ADD: 1 << 1, - SUBTRACT: 1 << 2, - LIGHTEST: 1 << 3, - DARKEST: 1 << 4, - DIFFERENCE: 1 << 5, - EXCLUSION: 1 << 6, - MULTIPLY: 1 << 7, - SCREEN: 1 << 8, - OVERLAY: 1 << 9, - HARD_LIGHT: 1 << 10, - SOFT_LIGHT: 1 << 11, - DODGE: 1 << 12, - BURN: 1 << 13, - - // Color component bit masks - ALPHA_MASK: 0xff000000, - RED_MASK: 0x00ff0000, - GREEN_MASK: 0x0000ff00, - BLUE_MASK: 0x000000ff, - - // Projection matrices - CUSTOM: 0, - ORTHOGRAPHIC: 2, - PERSPECTIVE: 3, - - // Shapes - POINT: 2, - POINTS: 2, - LINE: 4, - LINES: 4, - TRIANGLE: 8, - TRIANGLES: 9, - TRIANGLE_STRIP: 10, - TRIANGLE_FAN: 11, - QUAD: 16, - QUADS: 16, - QUAD_STRIP: 17, - POLYGON: 20, - PATH: 21, - RECT: 30, - ELLIPSE: 31, - ARC: 32, - SPHERE: 40, - BOX: 41, - - GROUP: 0, - PRIMITIVE: 1, - //PATH: 21, // shared with Shape PATH - GEOMETRY: 3, - - // Shape Vertex - VERTEX: 0, - BEZIER_VERTEX: 1, - CURVE_VERTEX: 2, - BREAK: 3, - CLOSESHAPE: 4, - - // Shape closing modes - OPEN: 1, - CLOSE: 2, - - // Shape drawing modes - CORNER: 0, // Draw mode convention to use (x, y) to (width, height) - CORNERS: 1, // Draw mode convention to use (x1, y1) to (x2, y2) coordinates - RADIUS: 2, // Draw mode from the center, and using the radius - CENTER_RADIUS: 2, // Deprecated! Use RADIUS instead - CENTER: 3, // Draw from the center, using second pair of values as the diameter - DIAMETER: 3, // Synonym for the CENTER constant. Draw from the center - CENTER_DIAMETER: 3, // Deprecated! Use DIAMETER instead - - // Text vertical alignment modes - BASELINE: 0, // Default vertical alignment for text placement - TOP: 101, // Align text to the top - BOTTOM: 102, // Align text from the bottom, using the baseline - - // UV Texture coordinate modes - NORMAL: 1, - NORMALIZED: 1, - IMAGE: 2, - - // Text placement modes - MODEL: 4, - SHAPE: 5, - - // Stroke modes - SQUARE: 'butt', - ROUND: 'round', - PROJECT: 'square', - MITER: 'miter', - BEVEL: 'bevel', - - // Lighting modes - AMBIENT: 0, - DIRECTIONAL: 1, - //POINT: 2, Shared with Shape constant - SPOT: 3, - - // Key constants - - // Both key and keyCode will be equal to these values - BACKSPACE: 8, - TAB: 9, - ENTER: 10, - RETURN: 13, - ESC: 27, - DELETE: 127, - CODED: 0xffff, - - // p.key will be CODED and p.keyCode will be this value - SHIFT: 16, - CONTROL: 17, - ALT: 18, - CAPSLK: 20, - PGUP: 33, - PGDN: 34, - END: 35, - HOME: 36, - LEFT: 37, - UP: 38, - RIGHT: 39, - DOWN: 40, - INS: 45, - DEL: 46, - F1: 112, - F2: 113, - F3: 114, - F4: 115, - F5: 116, - F6: 117, - F7: 118, - F8: 119, - F9: 120, - F10: 121, - F11: 122, - F12: 123, - NUMLK: 144, - - // Cursor types - ARROW: 'default', - CROSS: 'crosshair', - HAND: 'pointer', - MOVE: 'move', - TEXT: 'text', - WAIT: 'wait', - NOCURSOR: "url('data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), auto", - - // Hints - DISABLE_OPENGL_2X_SMOOTH: 1, - ENABLE_OPENGL_2X_SMOOTH: -1, - ENABLE_OPENGL_4X_SMOOTH: 2, - ENABLE_NATIVE_FONTS: 3, - DISABLE_DEPTH_TEST: 4, - ENABLE_DEPTH_TEST: -4, - ENABLE_DEPTH_SORT: 5, - DISABLE_DEPTH_SORT: -5, - DISABLE_OPENGL_ERROR_REPORT: 6, - ENABLE_OPENGL_ERROR_REPORT: -6, - ENABLE_ACCURATE_TEXTURES: 7, - DISABLE_ACCURATE_TEXTURES: -7, - HINT_COUNT: 10, - - // PJS defined constants - SINCOS_LENGTH: parseInt(360 / 0.5, 10), - PRECISIONB: 15, // fixed point precision is limited to 15 bits!! - PRECISIONF: 1 << 15, - PREC_MAXVAL: (1 << 15) - 1, - PREC_ALPHA_SHIFT: 24 - 15, - PREC_RED_SHIFT: 16 - 15, - NORMAL_MODE_AUTO: 0, - NORMAL_MODE_SHAPE: 1, - NORMAL_MODE_VERTEX: 2, - MAX_LIGHTS: 8 - }; - - // Typed Arrays: fallback to WebGL arrays or Native JS arrays if unavailable - function setupTypedArray(name, fallback) { - // check if TypedArray exists - // typeof on Minefield and Chrome return function, typeof on Webkit returns object. - if (typeof this[name] !== "function" && typeof this[name] !== "object") { - // nope.. check if WebGLArray exists - if (typeof this[fallback] === "function") { - this[name] = this[fallback]; - } else { - // nope.. set as Native JS array - this[name] = function(obj) { - if (obj instanceof Array) { - return obj; - } else if (typeof obj === "number") { - return new Array(obj); - } - }; - } - } - } - - setupTypedArray("Float32Array", "WebGLFloatArray"); - setupTypedArray("Int32Array", "WebGLIntArray"); - setupTypedArray("Uint16Array", "WebGLUnsignedShortArray"); - setupTypedArray("Uint8Array", "WebGLUnsignedByteArray"); - - /** - * An ArrayList stores a variable number of objects. - * - * @param {int} initialCapacity optional defines the initial capacity of the list, it's empty by default - * - * @returns {ArrayList} new ArrayList object - */ - var ArrayList = (function() { - function Iterator(array) { - var index = 0; - this.hasNext = function() { - return index < array.length; - }; - - this.next = function() { - return array[index++]; - }; - - this.remove = function() { - array.splice(index, 1); - }; - } - - function ArrayList() { - var array = arguments.length === 0 ? [] : - typeof arguments[0] === 'number' ? new Array(0 | arguments[0]) : - arguments[0]; - - /** - * @member ArrayList - * ArrayList.get() Returns the element at the specified position in this list. - * - * @param {int} i index of element to return - * - * @returns {Object} the element at the specified position in this list. - */ - this.get = function(i) { - return array[i]; - }; - /** - * @member ArrayList - * ArrayList.contains() Returns true if this list contains the specified element. - * - * @param {Object} item element whose presence in this List is to be tested. - * - * @returns {boolean} true if the specified element is present; false otherwise. - */ - this.contains = function(item) { - return array.indexOf(item) !== -1; - }; - /** - * @member ArrayList - * ArrayList.add() Adds the specified element to this list. - * - * @param {int} index optional index at which the specified element is to be inserted - * @param {Object} object element to be added to the list - */ - this.add = function() { - if (arguments.length === 1) { - array.push(arguments[0]); // for add(Object) - } else if (arguments.length === 2) { - var arg0 = arguments[0]; - if (typeof arg0 === 'number') { - if (arg0 >= 0 && arg0 <= array.length) { - array.splice(arg0, 0, arguments[1]); // for add(i, Object) - } else { - throw(arg0 + " is not a valid index"); - } - } else { - throw(typeof arg0 + " is not a number"); - } - } else { - throw("Please use the proper number of parameters."); - } - }; - - /** - * @member ArrayList - * ArrayList.set() Replaces the element at the specified position in this list with the specified element. - * - * @param {int} index index of element to replace - * @param {Object} object element to be stored at the specified position - */ - this.set = function() { - if (arguments.length === 2) { - var arg0 = arguments[0]; - if (typeof arg0 === 'number') { - if (arg0 >= 0 && arg0 < array.length) { - array.splice(arg0, 1, arguments[1]); - } else { - throw(arg0 + " is not a valid index."); - } - } else { - throw(typeof arg0 + " is not a number"); - } - } else { - throw("Please use the proper number of parameters."); - } - }; - - /** - * @member ArrayList - * ArrayList.size() Returns the number of elements in this list. - * - * @returns {int} the number of elements in this list - */ - this.size = function() { - return array.length; - }; - - /** - * @member ArrayList - * ArrayList.clear() Removes all of the elements from this list. The list will be empty after this call returns. - */ - this.clear = function() { - array.length = 0; - }; - - /** - * @member ArrayList - * ArrayList.remove() Removes the element at the specified position in this list. - * Shifts any subsequent elements to the left (subtracts one from their indices). - * - * @param {int} index the index of the element to removed. - * - * @returns {Object} the element that was removed from the list - */ - this.remove = function(i) { - return array.splice(i, 1)[0]; - }; - - /** - * @member ArrayList - * ArrayList.isEmpty() Tests if this list has no elements. - * - * @returns {boolean} true if this list has no elements; false otherwise - */ - this.isEmpty = function() { - return !array.length; - }; - - /** - * @member ArrayList - * ArrayList.clone() Returns a shallow copy of this ArrayList instance. (The elements themselves are not copied.) - * - * @returns {ArrayList} a clone of this ArrayList instance - */ - this.clone = function() { - return new ArrayList(array.slice(0)); - }; - - /** - * @member ArrayList - * ArrayList.toArray() Returns an array containing all of the elements in this list in the correct order. - * - * @returns {Object[]} Returns an array containing all of the elements in this list in the correct order - */ - this.toArray = function() { - return array.slice(0); - }; - - this.iterator = function() { - return new Iterator(array); - }; - } - - return ArrayList; - }()); - - /** - * A HashMap stores a collection of objects, each referenced by a key. This is similar to an Array, only - * instead of accessing elements with a numeric index, a String is used. (If you are familiar with - * associative arrays from other languages, this is the same idea.) - * - * @param {int} initialCapacity defines the initial capacity of the map, it's 16 by default - * @param {float} loadFactor the load factor for the map, the default is 0.75 - * @param {Map} m gives the new HashMap the same mappings as this Map - */ - var HashMap = (function() { - function virtHashCode(obj) { - if (obj.constructor === String) { - var hash = 0; - for (var i = 0; i < obj.length; ++i) { - hash = (hash * 31 + obj.charCodeAt(i)) & 0xFFFFFFFF; - } - return hash; - } else if (typeof(obj) !== "object") { - return obj & 0xFFFFFFFF; - } else if ("hashCode" in obj) { - return obj.hashCode.call(obj); - } else { - if (obj.$id === undef) { - obj.$id = ((Math.floor(Math.random() * 0x10000) - 0x8000) << 16) | Math.floor(Math.random() * 0x10000); - } - return obj.$id; - } - } - - function virtEquals(obj, other) { - if (obj === null || other === null) { - return (obj === null) && (other === null); - } else if (obj.constructor === String) { - return obj === other; - } else if (typeof(obj) !== "object") { - return obj === other; - } else if ("equals" in obj) { - return obj.equals.call(obj, other); - } else { - return obj === other; - } - } - - /** - * @member HashMap - * A HashMap stores a collection of objects, each referenced by a key. This is similar to an Array, only - * instead of accessing elements with a numeric index, a String is used. (If you are familiar with - * associative arrays from other languages, this is the same idea.) - * - * @param {int} initialCapacity defines the initial capacity of the map, it's 16 by default - * @param {float} loadFactor the load factor for the map, the default is 0.75 - * @param {Map} m gives the new HashMap the same mappings as this Map - */ - function HashMap() { - if (arguments.length === 1 && arguments[0].constructor === HashMap) { - return arguments[0].clone(); - } - - var initialCapacity = arguments.length > 0 ? arguments[0] : 16; - var loadFactor = arguments.length > 1 ? arguments[1] : 0.75; - var buckets = new Array(initialCapacity); - var count = 0; - var hashMap = this; - - function ensureLoad() { - if (count <= loadFactor * buckets.length) { - return; - } - var allEntries = []; - for (var i = 0; i < buckets.length; ++i) { - if (buckets[i] !== undef) { - allEntries = allEntries.concat(buckets[i]); - } - } - buckets = new Array(buckets.length * 2); - for (var j = 0; j < allEntries.length; ++j) { - var index = virtHashCode(allEntries[j].key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - buckets[index] = bucket = []; - } - bucket.push(allEntries[j]); - } - } - - function Iterator(conversion, removeItem) { - var bucketIndex = 0; - var itemIndex = -1; - var endOfBuckets = false; - - function findNext() { - while (!endOfBuckets) { - ++itemIndex; - if (bucketIndex >= buckets.length) { - endOfBuckets = true; - } else if (buckets[bucketIndex] === undef || itemIndex >= buckets[bucketIndex].length) { - itemIndex = -1; - ++bucketIndex; - } else { - return; - } - } - } - - /* - * @member Iterator - * Checks if the Iterator has more items - */ - this.hasNext = function() { - return !endOfBuckets; - }; - - /* - * @member Iterator - * Return the next Item - */ - this.next = function() { - var result = conversion(buckets[bucketIndex][itemIndex]); - findNext(); - return result; - }; - - /* - * @member Iterator - * Remove the current item - */ - this.remove = function() { - removeItem(this.next()); - --itemIndex; - }; - - findNext(); - } - - function Set(conversion, isIn, removeItem) { - this.clear = function() { - hashMap.clear(); - }; - - this.contains = function(o) { - return isIn(o); - }; - - this.containsAll = function(o) { - var it = o.iterator(); - while (it.hasNext()) { - if (!this.contains(it.next())) { - return false; - } - } - return true; - }; - - this.isEmpty = function() { - return hashMap.isEmpty(); - }; - - this.iterator = function() { - return new Iterator(conversion, removeItem); - }; - - this.remove = function(o) { - if (this.contains(o)) { - removeItem(o); - return true; - } - return false; - }; - - this.removeAll = function(c) { - var it = c.iterator(); - var changed = false; - while (it.hasNext()) { - var item = it.next(); - if (this.contains(item)) { - removeItem(item); - changed = true; - } - } - return true; - }; - - this.retainAll = function(c) { - var it = this.iterator(); - var toRemove = []; - while (it.hasNext()) { - var entry = it.next(); - if (!c.contains(entry)) { - toRemove.push(entry); - } - } - for (var i = 0; i < toRemove.length; ++i) { - removeItem(toRemove[i]); - } - return toRemove.length > 0; - }; - - this.size = function() { - return hashMap.size(); - }; - - this.toArray = function() { - var result = new ArrayList(0); - var it = this.iterator(); - while (it.hasNext()) { - result.push(it.next()); - } - return result; - }; - } - - function Entry(pair) { - this._isIn = function(map) { - return map === hashMap && (pair.removed === undef); - }; - - this.equals = function(o) { - return virtEquals(pair.key, o.getKey()); - }; - - this.getKey = function() { - return pair.key; - }; - - this.getValue = function() { - return pair.value; - }; - - this.hashCode = function(o) { - return virtHashCode(pair.key); - }; - - this.setValue = function(value) { - var old = pair.value; - pair.value = value; - return old; - }; - } - - this.clear = function() { - count = 0; - buckets = new Array(initialCapacity); - }; - - this.clone = function() { - var map = new HashMap(); - map.putAll(this); - return map; - }; - - this.containsKey = function(key) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - return false; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - return true; - } - } - return false; - }; - - this.containsValue = function(value) { - for (var i = 0; i < buckets.length; ++i) { - var bucket = buckets[i]; - if (bucket === undef) { - continue; - } - for (var j = 0; j < bucket.length; ++j) { - if (virtEquals(bucket[j].value, value)) { - return true; - } - } - } - return false; - }; - - this.entrySet = function() { - return new Set( - - function(pair) { - return new Entry(pair); - }, - - function(pair) { - return pair.constructor === Entry && pair._isIn(hashMap); - }, - - function(pair) { - return hashMap.remove(pair.getKey()); - }); - }; - - this.get = function(key) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - return null; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - return bucket[i].value; - } - } - return null; - }; - - this.isEmpty = function() { - return count === 0; - }; - - this.keySet = function() { - return new Set( - - function(pair) { - return pair.key; - }, - - function(key) { - return hashMap.containsKey(key); - }, - - function(key) { - return hashMap.remove(key); - }); - }; - - this.put = function(key, value) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - ++count; - buckets[index] = [{ - key: key, - value: value - }]; - ensureLoad(); - return null; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - var previous = bucket[i].value; - bucket[i].value = value; - return previous; - } - } - ++count; - bucket.push({ - key: key, - value: value - }); - ensureLoad(); - return null; - }; - - this.putAll = function(m) { - var it = m.entrySet().iterator(); - while (it.hasNext()) { - var entry = it.next(); - this.put(entry.getKey(), entry.getValue()); - } - }; - - this.remove = function(key) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - return null; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - --count; - var previous = bucket[i].value; - bucket[i].removed = true; - if (bucket.length > 1) { - bucket.splice(i, 1); - } else { - buckets[index] = undef; - } - return previous; - } - } - return null; - }; - - this.size = function() { - return count; - }; - - this.values = function() { - var result = new ArrayList(0); - var it = this.entrySet().iterator(); - while (it.hasNext()) { - var entry = it.next(); - result.push(entry.getValue()); - } - return result; - }; - } - - return HashMap; - }()); - - var PVector = (function() { - function PVector(x, y, z) { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - } - - function createPVectorMethod(method) { - return function(v1, v2) { - var v = v1.get(); - v[method](v2); - return v; - }; - } - - function createSimplePVectorMethod(method) { - return function(v1, v2) { - return v1[method](v2); - }; - } - - var simplePVMethods = "dist dot cross".split(" "); - var method = simplePVMethods.length; - - PVector.angleBetween = function(v1, v2) { - return Math.acos(v1.dot(v2) / (v1.mag() * v2.mag())); - }; - - // Common vector operations for PVector - PVector.prototype = { - set: function(v, y, z) { - if (arguments.length === 1) { - this.set(v.x || v[0], v.y || v[1], v.z || v[2]); - } else { - this.x = v; - this.y = y; - this.z = z; - } - }, - get: function() { - return new PVector(this.x, this.y, this.z); - }, - mag: function() { - return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); - }, - add: function(v, y, z) { - if (arguments.length === 3) { - this.x += v; - this.y += y; - this.z += z; - } else if (arguments.length === 1) { - this.x += v.x; - this.y += v.y; - this.z += v.z; - } - }, - sub: function(v, y, z) { - if (arguments.length === 3) { - this.x -= v; - this.y -= y; - this.z -= z; - } else if (arguments.length === 1) { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z; - } - }, - mult: function(v) { - if (typeof v === 'number') { - this.x *= v; - this.y *= v; - this.z *= v; - } else if (typeof v === 'object') { - this.x *= v.x; - this.y *= v.y; - this.z *= v.z; - } - }, - div: function(v) { - if (typeof v === 'number') { - this.x /= v; - this.y /= v; - this.z /= v; - } else if (typeof v === 'object') { - this.x /= v.x; - this.y /= v.y; - this.z /= v.z; - } - }, - dist: function(v) { - var dx = this.x - v.x, - dy = this.y - v.y, - dz = this.z - v.z; - return Math.sqrt(dx * dx + dy * dy + dz * dz); - }, - dot: function(v, y, z) { - if (arguments.length === 3) { - return (this.x * v + this.y * y + this.z * z); - } else if (arguments.length === 1) { - return (this.x * v.x + this.y * v.y + this.z * v.z); - } - }, - cross: function(v) { - return new PVector(this.y * v.z - v.y * this.z, - this.z * v.x - v.z * this.x, - this.x * v.y - v.x * this.y); - }, - normalize: function() { - var m = this.mag(); - if (m > 0) { - this.div(m); - } - }, - limit: function(high) { - if (this.mag() > high) { - this.normalize(); - this.mult(high); - } - }, - heading2D: function() { - return (-Math.atan2(-this.y, this.x)); - }, - toString: function() { - return "[" + this.x + ", " + this.y + ", " + this.z + "]"; - }, - array: function() { - return [this.x, this.y, this.z]; - } - }; - - while (method--) { - PVector[simplePVMethods[method]] = createSimplePVectorMethod(simplePVMethods[method]); - } - - for (method in PVector.prototype) { - if (PVector.prototype.hasOwnProperty(method) && !PVector.hasOwnProperty(method)) { - PVector[method] = createPVectorMethod(method); - } - } - - return PVector; - }()); - - // Building defaultScope. Changing of the prototype protects - // internal Processing code from the changes in defaultScope - function DefaultScope() {} - DefaultScope.prototype = PConstants; - - var defaultScope = new DefaultScope(); - defaultScope.ArrayList = ArrayList; - defaultScope.HashMap = HashMap; - defaultScope.PVector = PVector; - //defaultScope.PImage = PImage; // TODO - //defaultScope.PShape = PShape; // TODO - //defaultScope.PShapeSVG = PShapeSVG; // TODO - - var Processing = this.Processing = function Processing(curElement, aCode) { - // Previously we allowed calling Processing as a func instead of ctor, but no longer. - if (!(this instanceof Processing)) { - throw("called Processing constructor as if it were a function: missing 'new'."); - } - - // When something new is added to "p." it must also be added to the "names" array. - // The names array contains the names of everything that is inside "p." - var p = this; - - // PJS specific (non-p5) methods and properties to externalize - p.externals = { - canvas: curElement, - context: undef, - sketch: undef, - onblur: function() {}, - onfocus: function() {} - }; - - p.name = 'Processing.js Instance'; // Set Processing defaults / environment variables - p.use3DContext = false; // default '2d' canvas context - - /** - * Confirms if a Processing program is "focused", meaning that it is - * active and will accept input from mouse or keyboard. This variable - * is "true" if it is focused and "false" if not. This variable is - * often used when you want to warn people they need to click on the - * browser before it will work. - */ - p.focused = true; - p.breakShape = false; - - // Glyph path storage for textFonts - p.glyphTable = {}; - - // Global vars for tracking mouse position - p.pmouseX = 0; - p.pmouseY = 0; - p.mouseX = 0; - p.mouseY = 0; - p.mouseButton = 0; - p.mouseScroll = 0; - - // Undefined event handlers to be replaced by user when needed - p.mouseClicked = undef; - p.mouseDragged = undef; - p.mouseMoved = undef; - p.mousePressed = undef; - p.mouseReleased = undef; - p.mouseScrolled = undef; - p.key = undef; - p.keyCode = undef; - p.keyPressed = function(){}; // needed to remove function checks - p.keyReleased = function(){}; - p.keyTyped = function(){}; - p.draw = undef; - p.setup = undef; - - // Remapped vars - p.__mousePressed = false; - p.__keyPressed = false; - p.__frameRate = 0; - - // The current animation frame - p.frameCount = 0; - - // The height/width of the canvas - p.width = curElement.width - 0; - p.height = curElement.height - 0; - - p.defineProperty = function(obj, name, desc) { - if("defineProperty" in Object) { - Object.defineProperty(obj, name, desc); - } else { - if (desc.hasOwnProperty("get")) { - obj.__defineGetter__(name, desc.get); - } - if (desc.hasOwnProperty("set")) { - obj.__defineSetter__(name, desc.set); - } - } - }; - - // "Private" variables used to maintain state - var curContext, - curSketch, - online = true, - doFill = true, - fillStyle = [1.0, 1.0, 1.0, 1.0], - currentFillColor = 0xFFFFFFFF, - isFillDirty = true, - doStroke = true, - strokeStyle = [0.8, 0.8, 0.8, 1.0], - currentStrokeColor = 0xFFFDFDFD, - isStrokeDirty = true, - lineWidth = 1, - loopStarted = false, - doLoop = true, - looping = 0, - curRectMode = PConstants.CORNER, - curEllipseMode = PConstants.CENTER, - normalX = 0, - normalY = 0, - normalZ = 0, - normalMode = PConstants.NORMAL_MODE_AUTO, - inDraw = false, - curFrameRate = 60, - curCursor = PConstants.ARROW, - oldCursor = curElement.style.cursor, - curMsPerFrame = 1, - curShape = PConstants.POLYGON, - curShapeCount = 0, - curvePoints = [], - curTightness = 0, - curveDet = 20, - curveInited = false, - bezDetail = 20, - colorModeA = 255, - colorModeX = 255, - colorModeY = 255, - colorModeZ = 255, - pathOpen = false, - mouseDragging = false, - curColorMode = PConstants.RGB, - curTint = null, - curTextSize = 12, - curTextFont = "Arial", - curTextLeading = 14, - getLoaded = false, - start = new Date().getTime(), - timeSinceLastFPS = start, - framesSinceLastFPS = 0, - textcanvas, - curveBasisMatrix, - curveToBezierMatrix, - curveDrawMatrix, - bezierDrawMatrix, - bezierBasisInverse, - bezierBasisMatrix, - // Keys and Keystrokes - firstCodedDown = true, // first coded key stroke - firstEDGKeyDown = true, // first Enter - Delete Google key stroke - firstEDMKeyDown = true, // first Enter - Delete Mozilla key stroke - firstMKeyDown = true, // first Mozilla key stroke - firstGKeyDown = true, // first Google key stroke - gRefire = false, // Google refire - curContextCache = { attributes: {}, locations: {} }, - // Shaders - programObject3D, - programObject2D, - programObjectUnlitShape, - boxBuffer, - boxNormBuffer, - boxOutlineBuffer, - rectBuffer, - rectNormBuffer, - sphereBuffer, - lineBuffer, - fillBuffer, - fillColorBuffer, - strokeColorBuffer, - pointBuffer, - shapeTexVBO, - canTex, // texture for createGraphics - textTex, // texture for 3d tex - curTexture = {width:0,height:0}, - curTextureMode = PConstants.IMAGE, - usingTexture = false, - textBuffer, - textureBuffer, - indexBuffer, - // Text alignment - horizontalTextAlignment = PConstants.LEFT, - verticalTextAlignment = PConstants.BASELINE, - baselineOffset = 0.2, // percent - tMode = PConstants.MODEL, - // Pixels cache - originalContext, - proxyContext = null, - isContextReplaced = false, - setPixelsCached, - maxPixelsCached = 1000, - codedKeys = [ PConstants.SHIFT, PConstants.CONTROL, PConstants.ALT, PConstants.CAPSLK, PConstants.PGUP, PConstants.PGDN, - PConstants.END, PConstants.HOME, PConstants.LEFT, PConstants.UP, PConstants.RIGHT, PConstants.DOWN, PConstants.NUMLK, - PConstants.INS, PConstants.F1, PConstants.F2, PConstants.F3, PConstants.F4, PConstants.F5, PConstants.F6, PConstants.F7, - PConstants.F8, PConstants.F9, PConstants.F10, PConstants.F11, PConstants.F12 ]; - - // Get padding and border style widths for mouse offsets - var stylePaddingLeft, stylePaddingTop, styleBorderLeft, styleBorderTop; - - if (document.defaultView && document.defaultView.getComputedStyle) { - stylePaddingLeft = parseInt(document.defaultView.getComputedStyle(curElement, null)['paddingLeft'], 10) || 0; - stylePaddingTop = parseInt(document.defaultView.getComputedStyle(curElement, null)['paddingTop'], 10) || 0; - styleBorderLeft = parseInt(document.defaultView.getComputedStyle(curElement, null)['borderLeftWidth'], 10) || 0; - styleBorderTop = parseInt(document.defaultView.getComputedStyle(curElement, null)['borderTopWidth'], 10) || 0; - } - - // User can only have MAX_LIGHTS lights - var lightCount = 0; - - //sphere stuff - var sphereDetailV = 0, - sphereDetailU = 0, - sphereX = [], - sphereY = [], - sphereZ = [], - sinLUT = new Array(PConstants.SINCOS_LENGTH), - cosLUT = new Array(PConstants.SINCOS_LENGTH), - sphereVerts, - sphereNorms; - - // Camera defaults and settings - var cam, - cameraInv, - forwardTransform, - reverseTransform, - modelView, - modelViewInv, - userMatrixStack, - inverseCopy, - projection, - manipulatingCamera = false, - frustumMode = false, - cameraFOV = 60 * (Math.PI / 180), - cameraX = curElement.width / 2, - cameraY = curElement.height / 2, - cameraZ = cameraY / Math.tan(cameraFOV / 2), - cameraNear = cameraZ / 10, - cameraFar = cameraZ * 10, - cameraAspect = curElement.width / curElement.height; - - var vertArray = [], - curveVertArray = [], - curveVertCount = 0, - isCurve = false, - isBezier = false, - firstVert = true; - - //PShape stuff - var curShapeMode = PConstants.CORNER; - - var colors = { - aliceblue: "#f0f8ff", - antiquewhite: "#faebd7", - aqua: "#00ffff", - aquamarine: "#7fffd4", - azure: "#f0ffff", - beige: "#f5f5dc", - bisque: "#ffe4c4", - black: "#000000", - blanchedalmond: "#ffebcd", - blue: "#0000ff", - blueviolet: "#8a2be2", - brown: "#a52a2a", - burlywood: "#deb887", - cadetblue: "#5f9ea0", - chartreuse: "#7fff00", - chocolate: "#d2691e", - coral: "#ff7f50", - cornflowerblue: "#6495ed", - cornsilk: "#fff8dc", - crimson: "#dc143c", - cyan: "#00ffff", - darkblue: "#00008b", - darkcyan: "#008b8b", - darkgoldenrod: "#b8860b", - darkgray: "#a9a9a9", - darkgreen: "#006400", - darkkhaki: "#bdb76b", - darkmagenta: "#8b008b", - darkolivegreen: "#556b2f", - darkorange: "#ff8c00", - darkorchid: "#9932cc", - darkred: "#8b0000", - darksalmon: "#e9967a", - darkseagreen: "#8fbc8f", - darkslateblue: "#483d8b", - darkslategray: "#2f4f4f", - darkturquoise: "#00ced1", - darkviolet: "#9400d3", - deeppink: "#ff1493", - deepskyblue: "#00bfff", - dimgray: "#696969", - dodgerblue: "#1e90ff", - firebrick: "#b22222", - floralwhite: "#fffaf0", - forestgreen: "#228b22", - fuchsia: "#ff00ff", - gainsboro: "#dcdcdc", - ghostwhite: "#f8f8ff", - gold: "#ffd700", - goldenrod: "#daa520", - gray: "#808080", - green: "#008000", - greenyellow: "#adff2f", - honeydew: "#f0fff0", - hotpink: "#ff69b4", - indianred: "#cd5c5c", - indigo: "#4b0082", - ivory: "#fffff0", - khaki: "#f0e68c", - lavender: "#e6e6fa", - lavenderblush: "#fff0f5", - lawngreen: "#7cfc00", - lemonchiffon: "#fffacd", - lightblue: "#add8e6", - lightcoral: "#f08080", - lightcyan: "#e0ffff", - lightgoldenrodyellow: "#fafad2", - lightgrey: "#d3d3d3", - lightgreen: "#90ee90", - lightpink: "#ffb6c1", - lightsalmon: "#ffa07a", - lightseagreen: "#20b2aa", - lightskyblue: "#87cefa", - lightslategray: "#778899", - lightsteelblue: "#b0c4de", - lightyellow: "#ffffe0", - lime: "#00ff00", - limegreen: "#32cd32", - linen: "#faf0e6", - magenta: "#ff00ff", - maroon: "#800000", - mediumaquamarine: "#66cdaa", - mediumblue: "#0000cd", - mediumorchid: "#ba55d3", - mediumpurple: "#9370d8", - mediumseagreen: "#3cb371", - mediumslateblue: "#7b68ee", - mediumspringgreen: "#00fa9a", - mediumturquoise: "#48d1cc", - mediumvioletred: "#c71585", - midnightblue: "#191970", - mintcream: "#f5fffa", - mistyrose: "#ffe4e1", - moccasin: "#ffe4b5", - navajowhite: "#ffdead", - navy: "#000080", - oldlace: "#fdf5e6", - olive: "#808000", - olivedrab: "#6b8e23", - orange: "#ffa500", - orangered: "#ff4500", - orchid: "#da70d6", - palegoldenrod: "#eee8aa", - palegreen: "#98fb98", - paleturquoise: "#afeeee", - palevioletred: "#d87093", - papayawhip: "#ffefd5", - peachpuff: "#ffdab9", - peru: "#cd853f", - pink: "#ffc0cb", - plum: "#dda0dd", - powderblue: "#b0e0e6", - purple: "#800080", - red: "#ff0000", - rosybrown: "#bc8f8f", - royalblue: "#4169e1", - saddlebrown: "#8b4513", - salmon: "#fa8072", - sandybrown: "#f4a460", - seagreen: "#2e8b57", - seashell: "#fff5ee", - sienna: "#a0522d", - silver: "#c0c0c0", - skyblue: "#87ceeb", - slateblue: "#6a5acd", - slategray: "#708090", - snow: "#fffafa", - springgreen: "#00ff7f", - steelblue: "#4682b4", - tan: "#d2b48c", - teal: "#008080", - thistle: "#d8bfd8", - tomato: "#ff6347", - turquoise: "#40e0d0", - violet: "#ee82ee", - wheat: "#f5deb3", - white: "#ffffff", - whitesmoke: "#f5f5f5", - yellow: "#ffff00", - yellowgreen: "#9acd32" - }; - - // Stores states for pushStyle() and popStyle(). - var styleArray = new Array(0); - - // Vertices are specified in a counter-clockwise order - // triangles are in this order: back, front, right, bottom, left, top - var boxVerts = new Float32Array([ - 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, - -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, - -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, - 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, - 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, - -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, - -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, - -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, - -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5]); - - var boxOutlineVerts = new Float32Array([ - 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, - -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, - 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, - -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, - 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, - -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5]); - - var boxNorms = new Float32Array([ - 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, - 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, - 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, - -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, - 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]); - - // These verts are used for the fill and stroke using TRIANGLE_FAN and LINE_LOOP - var rectVerts = new Float32Array([0,0,0, 0,1,0, 1,1,0, 1,0,0]); - - var rectNorms = new Float32Array([0,0,-1, 0,0,-1, 0,0,-1, 0,0,-1]); - - // Vertex shader for points and lines - var vShaderSrcUnlitShape = - "varying vec4 frontColor;" + - - "attribute vec3 aVertex;" + - "attribute vec4 aColor;" + - - "uniform mat4 uView;" + - "uniform mat4 uProjection;" + - - "void main(void) {" + - " frontColor = aColor;" + - " gl_Position = uProjection * uView * vec4(aVertex, 1.0);" + - "}"; - - var fShaderSrcUnlitShape = - "#ifdef GL_ES\n" + - "precision highp float;\n" + - "#endif\n" + - - "varying vec4 frontColor;" + - - "void main(void){" + - " gl_FragColor = frontColor;" + - "}"; - - // Vertex shader for points and lines - var vertexShaderSource2D = - "varying vec4 frontColor;" + - - "attribute vec3 Vertex;" + - "attribute vec2 aTextureCoord;" + - "uniform vec4 color;" + - - "uniform mat4 model;" + - "uniform mat4 view;" + - "uniform mat4 projection;" + - "uniform float pointSize;" + - "varying vec2 vTextureCoord;"+ - - "void main(void) {" + - " gl_PointSize = pointSize;" + - " frontColor = color;" + - " gl_Position = projection * view * model * vec4(Vertex, 1.0);" + - " vTextureCoord = aTextureCoord;" + - "}"; - - var fragmentShaderSource2D = - "#ifdef GL_ES\n" + - "precision highp float;\n" + - "#endif\n" + - - "varying vec4 frontColor;" + - "varying vec2 vTextureCoord;"+ - - "uniform sampler2D uSampler;"+ - "uniform int picktype;"+ - - "void main(void){" + - " if(picktype == 0){"+ - " gl_FragColor = frontColor;" + - " }" + - " else if(picktype == 1){"+ - " float alpha = texture2D(uSampler, vTextureCoord).a;"+ - " gl_FragColor = vec4(frontColor.rgb*alpha, alpha);\n"+ - " }"+ - "}"; - - // Vertex shader for boxes and spheres - var vertexShaderSource3D = - "varying vec4 frontColor;" + - - "attribute vec3 Vertex;" + - "attribute vec3 Normal;" + - "attribute vec4 aColor;" + - "attribute vec2 aTexture;" + - "varying vec2 vTexture;" + - - "uniform vec4 color;" + - - "uniform bool usingMat;" + - "uniform vec3 specular;" + - "uniform vec3 mat_emissive;" + - "uniform vec3 mat_ambient;" + - "uniform vec3 mat_specular;" + - "uniform float shininess;" + - - "uniform mat4 model;" + - "uniform mat4 view;" + - "uniform mat4 projection;" + - "uniform mat4 normalTransform;" + - - "uniform int lightCount;" + - "uniform vec3 falloff;" + - - "struct Light {" + - " bool dummy;" + - " int type;" + - " vec3 color;" + - " vec3 position;" + - " vec3 direction;" + - " float angle;" + - " vec3 halfVector;" + - " float concentration;" + - "};" + - "uniform Light lights[8];" + - - "void AmbientLight( inout vec3 totalAmbient, in vec3 ecPos, in Light light ) {" + - // Get the vector from the light to the vertex - // Get the distance from the current vector to the light position - " float d = length( light.position - ecPos );" + - " float attenuation = 1.0 / ( falloff[0] + ( falloff[1] * d ) + ( falloff[2] * d * d ));" + " totalAmbient += light.color * attenuation;" + - "}" + - - "void DirectionalLight( inout vec3 col, in vec3 ecPos, inout vec3 spec, in vec3 vertNormal, in Light light ) {" + - " float powerfactor = 0.0;" + - " float nDotVP = max(0.0, dot( vertNormal, light.position ));" + - " float nDotVH = max(0.0, dot( vertNormal, normalize( light.position-ecPos )));" + - - " if( nDotVP != 0.0 ){" + - " powerfactor = pow( nDotVH, shininess );" + - " }" + - - " col += light.color * nDotVP;" + - " spec += specular * powerfactor;" + - "}" + - - "void PointLight( inout vec3 col, inout vec3 spec, in vec3 vertNormal, in vec3 ecPos, in vec3 eye, in Light light ) {" + - " float powerfactor;" + - - // Get the vector from the light to the vertex - " vec3 VP = light.position - ecPos;" + - - // Get the distance from the current vector to the light position - " float d = length( VP ); " + - - // Normalize the light ray so it can be used in the dot product operation. - " VP = normalize( VP );" + - - " float attenuation = 1.0 / ( falloff[0] + ( falloff[1] * d ) + ( falloff[2] * d * d ));" + - - " float nDotVP = max( 0.0, dot( vertNormal, VP ));" + - " vec3 halfVector = normalize( VP + eye );" + - " float nDotHV = max( 0.0, dot( vertNormal, halfVector ));" + - - " if( nDotVP == 0.0) {" + - " powerfactor = 0.0;" + - " }" + - " else{" + - " powerfactor = pow( nDotHV, shininess );" + - " }" + - - " spec += specular * powerfactor * attenuation;" + - " col += light.color * nDotVP * attenuation;" + - "}" + - - /* - */ - "void SpotLight( inout vec3 col, inout vec3 spec, in vec3 vertNormal, in vec3 ecPos, in vec3 eye, in Light light ) {" + - " float spotAttenuation;" + - " float powerfactor;" + - - // calculate the vector from the current vertex to the light. - " vec3 VP = light.position - ecPos; " + - " vec3 ldir = normalize( light.direction );" + - - // get the distance from the spotlight and the vertex - " float d = length( VP );" + - " VP = normalize( VP );" + - - " float attenuation = 1.0 / ( falloff[0] + ( falloff[1] * d ) + ( falloff[2] * d * d ) );" + - - // dot product of the vector from vertex to light and light direction. - " float spotDot = dot( VP, ldir );" + - - // if the vertex falls inside the cone - " if( spotDot < cos( light.angle ) ) {" + - " spotAttenuation = pow( spotDot, light.concentration );" + - " }" + - " else{" + - " spotAttenuation = 1.0;" + - " }" + - " attenuation *= spotAttenuation;" + - - " float nDotVP = max( 0.0, dot( vertNormal, VP ));" + - " vec3 halfVector = normalize( VP + eye );" + - " float nDotHV = max( 0.0, dot( vertNormal, halfVector ));" + - - " if( nDotVP == 0.0 ) {" + - " powerfactor = 0.0;" + - " }" + - " else {" + - " powerfactor = pow( nDotHV, shininess );" + - " }" + - - " spec += specular * powerfactor * attenuation;" + - " col += light.color * nDotVP * attenuation;" + - "}" + - - "void main(void) {" + - " vec3 finalAmbient = vec3( 0.0, 0.0, 0.0 );" + - " vec3 finalDiffuse = vec3( 0.0, 0.0, 0.0 );" + - " vec3 finalSpecular = vec3( 0.0, 0.0, 0.0 );" + - - " vec4 col = color;" + - " if(color[0] == -1.0){" + - " col = aColor;" + - " }" + - - " vec3 norm = vec3( normalTransform * vec4( Normal, 0.0 ) );" + - - " vec4 ecPos4 = view * model * vec4(Vertex,1.0);" + - " vec3 ecPos = (vec3(ecPos4))/ecPos4.w;" + - " vec3 eye = vec3( 0.0, 0.0, 1.0 );" + - - // If there were no lights this draw call, just use the - // assigned fill color of the shape and the specular value - " if( lightCount == 0 ) {" + - " frontColor = col + vec4(mat_specular,1.0);" + - " }" + - " else {" + - " for( int i = 0; i < lightCount; i++ ) {" + - " if( lights[i].type == 0 ) {" + - " AmbientLight( finalAmbient, ecPos, lights[i] );" + - " }" + - " else if( lights[i].type == 1 ) {" + - " DirectionalLight( finalDiffuse,ecPos, finalSpecular, norm, lights[i] );" + - " }" + - " else if( lights[i].type == 2 ) {" + - " PointLight( finalDiffuse, finalSpecular, norm, ecPos, eye, lights[i] );" + - " }" + - " else if( lights[i].type == 3 ) {" + - " SpotLight( finalDiffuse, finalSpecular, norm, ecPos, eye, lights[i] );" + - " }" + - " }" + - - " if( usingMat == false ) {" + - " frontColor = vec4( " + - " vec3(col) * finalAmbient +" + - " vec3(col) * finalDiffuse +" + - " vec3(col) * finalSpecular," + - " col[3] );" + - " }" + - " else{" + - " frontColor = vec4( " + - " mat_emissive + " + - " (vec3(col) * mat_ambient * finalAmbient) + " + - " (vec3(col) * finalDiffuse) + " + - " (mat_specular * finalSpecular), " + - " col[3] );" + - " }" + - " }" + - " vTexture.xy = aTexture.xy;" + - " gl_Position = projection * view * model * vec4( Vertex, 1.0 );" + - "}"; - - var fragmentShaderSource3D = - "#ifdef GL_ES\n" + - "precision highp float;\n" + - "#endif\n" + - - "varying vec4 frontColor;" + - - "uniform sampler2D sampler;" + - "uniform bool usingTexture;" + - "varying vec2 vTexture;" + - - // In Processing, when a texture is used, the fill color is ignored - "void main(void){" + - " if(usingTexture){" + - " gl_FragColor = vec4(texture2D(sampler, vTexture.xy));" + - " }"+ - " else{" + - " gl_FragColor = frontColor;" + - " }" + - "}"; - - //////////////////////////////////////////////////////////////////////////// - // 3D Functions - //////////////////////////////////////////////////////////////////////////// - - /* - * Sets a uniform variable in a program object to a particular - * value. Before calling this function, ensure the correct - * program object has been installed as part of the current - * rendering state by calling useProgram. - * - * On some systems, if the variable exists in the shader but isn't used, - * the compiler will optimize it out and this function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {float | Array} varValue either a scalar value or an Array - * - * @returns none - * - * @see uniformi - * @see uniformMatrix - */ - function uniformf(cacheId, programObj, varName, varValue) { - var varLocation = curContextCache.locations[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getUniformLocation(programObj, varName); - curContextCache.locations[cacheId] = varLocation; - } - // the variable won't be found if it was optimized out. - if (varLocation !== -1) { - if (varValue.length === 4) { - curContext.uniform4fv(varLocation, varValue); - } else if (varValue.length === 3) { - curContext.uniform3fv(varLocation, varValue); - } else if (varValue.length === 2) { - curContext.uniform2fv(varLocation, varValue); - } else { - curContext.uniform1f(varLocation, varValue); - } - } - } - - /** - * Sets a uniform int or int array in a program object to a particular - * value. Before calling this function, ensure the correct - * program object has been installed as part of the current - * rendering state. - * - * On some systems, if the variable exists in the shader but isn't used, - * the compiler will optimize it out and this function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {int | Array} varValue either a scalar value or an Array - * - * @returns none - * - * @see uniformf - * @see uniformMatrix - */ - function uniformi(cacheId, programObj, varName, varValue) { - var varLocation = curContextCache.locations[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getUniformLocation(programObj, varName); - curContextCache.locations[cacheId] = varLocation; - } - // the variable won't be found if it was optimized out. - if (varLocation !== -1) { - if (varValue.length === 4) { - curContext.uniform4iv(varLocation, varValue); - } else if (varValue.length === 3) { - curContext.uniform3iv(varLocation, varValue); - } else if (varValue.length === 2) { - curContext.uniform2iv(varLocation, varValue); - } else { - curContext.uniform1i(varLocation, varValue); - } - } - } - - /** - * Binds the VBO, sets the vertex attribute data for the program - * object and enables the attribute. - * - * On some systems, if the attribute exists in the shader but - * isn't used, the compiler will optimize it out and this - * function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {int} size the number of components per vertex attribute - * @param {WebGLBuffer} VBO Vertex Buffer Object - * - * @returns none - * - * @see disableVertexAttribPointer - */ - function vertexAttribPointer(cacheId, programObj, varName, size, VBO) { - var varLocation = curContextCache.attributes[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getAttribLocation(programObj, varName); - curContextCache.attributes[cacheId] = varLocation; - } - if (varLocation !== -1) { - curContext.bindBuffer(curContext.ARRAY_BUFFER, VBO); - curContext.vertexAttribPointer(varLocation, size, curContext.FLOAT, false, 0, 0); - curContext.enableVertexAttribArray(varLocation); - } - } - - /** - * Disables a program object attribute from being sent to WebGL. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName name of the attribute - * - * @returns none - * - * @see vertexAttribPointer - */ - function disableVertexAttribPointer(cacheId, programObj, varName){ - var varLocation = curContextCache.attributes[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getAttribLocation(programObj, varName); - curContextCache.attributes[cacheId] = varLocation; - } - if (varLocation !== -1) { - curContext.disableVertexAttribArray(varLocation); - } - } - - /** - * Sets the value of a uniform matrix variable in a program - * object. Before calling this function, ensure the correct - * program object has been installed as part of the current - * rendering state. - * - * On some systems, if the variable exists in the shader but - * isn't used, the compiler will optimize it out and this - * function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {boolean} transpose must be false - * @param {Array} matrix an array of 4, 9 or 16 values - * - * @returns none - * - * @see uniformi - * @see uniformf - */ - function uniformMatrix(cacheId, programObj, varName, transpose, matrix) { - var varLocation = curContextCache.locations[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getUniformLocation(programObj, varName); - curContextCache.locations[cacheId] = varLocation; - } - // the variable won't be found if it was optimized out. - if (varLocation !== -1) { - if (matrix.length === 16) { - curContext.uniformMatrix4fv(varLocation, transpose, matrix); - } else if (matrix.length === 9) { - curContext.uniformMatrix3fv(varLocation, transpose, matrix); - } else { - curContext.uniformMatrix2fv(varLocation, transpose, matrix); - } - } - } - - var imageModeCorner = function imageModeCorner(x, y, w, h, whAreSizes) { - return { - x: x, - y: y, - w: w, - h: h - }; - }; - var imageModeConvert = imageModeCorner; - - var imageModeCorners = function imageModeCorners(x, y, w, h, whAreSizes) { - return { - x: x, - y: y, - w: whAreSizes ? w : w - x, - h: whAreSizes ? h : h - y - }; - }; - - var imageModeCenter = function imageModeCenter(x, y, w, h, whAreSizes) { - return { - x: x - w / 2, - y: y - h / 2, - w: w, - h: h - }; - }; - - /** - * Creates a WebGL program object. - * - * @param {String} vetexShaderSource - * @param {String} fragmentShaderSource - * - * @returns {WebGLProgram} A program object - */ - var createProgramObject = function(curContext, vetexShaderSource, fragmentShaderSource) { - var vertexShaderObject = curContext.createShader(curContext.VERTEX_SHADER); - curContext.shaderSource(vertexShaderObject, vetexShaderSource); - curContext.compileShader(vertexShaderObject); - if (!curContext.getShaderParameter(vertexShaderObject, curContext.COMPILE_STATUS)) { - throw curContext.getShaderInfoLog(vertexShaderObject); - } - - var fragmentShaderObject = curContext.createShader(curContext.FRAGMENT_SHADER); - curContext.shaderSource(fragmentShaderObject, fragmentShaderSource); - curContext.compileShader(fragmentShaderObject); - if (!curContext.getShaderParameter(fragmentShaderObject, curContext.COMPILE_STATUS)) { - throw curContext.getShaderInfoLog(fragmentShaderObject); - } - - var programObject = curContext.createProgram(); - curContext.attachShader(programObject, vertexShaderObject); - curContext.attachShader(programObject, fragmentShaderObject); - curContext.linkProgram(programObject); - if (!curContext.getProgramParameter(programObject, curContext.LINK_STATUS)) { - throw "Error linking shaders."; - } - - return programObject; - }; - - //////////////////////////////////////////////////////////////////////////// - // Char handling - //////////////////////////////////////////////////////////////////////////// - var charMap = {}; - - var Char = p.Character = function Char(chr) { - if (typeof chr === 'string' && chr.length === 1) { - this.code = chr.charCodeAt(0); - } else { - this.code = NaN; - } - - return (charMap[this.code] === undef) ? charMap[this.code] = this : charMap[this.code]; - }; - - Char.prototype.toString = function() { - return String.fromCharCode(this.code); - }; - - Char.prototype.valueOf = function() { - return this.code; - }; - - /** - * Datatype for storing shapes. Processing can currently load and display SVG (Scalable Vector Graphics) shapes. - * Before a shape is used, it must be loaded with the loadShape() function. The shape() function is used to draw the shape to the display window. - * The PShape object contain a group of methods, linked below, that can operate on the shape data. - *

        The loadShape() method supports SVG files created with Inkscape and Adobe Illustrator. - * It is not a full SVG implementation, but offers some straightforward support for handling vector data. - * - * @param {int} family the shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY - * - * @see #shape() - * @see #loadShape() - * @see #shapeMode() - */ - var PShape = p.PShape = function(family) { - this.family = family || PConstants.GROUP; - this.visible = true; - this.style = true; - this.children = []; - this.nameTable = []; - this.params = []; - this.name = ""; - this.image = null; //type PImage - this.matrix = null; - this.kind = null; - this.close = null; - this.width = null; - this.height = null; - this.parent = null; - - /** - * PShape methods - * missing: findChild(), apply(), contains(), findChild(), getPrimitive(), getParams(), getVertex() , getVertexCount(), - * getVertexCode() , getVertexCodes() , getVertexCodeCount(), getVertexX(), getVertexY(), getVertexZ() - */ - - /** - * @member PShape - * The isVisible() function returns a boolean value "true" if the image is set to be visible, "false" if not. This is modified with the setVisible() parameter. - *

        The visibility of a shape is usually controlled by whatever program created the SVG file. - * For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator. - * - * @return {boolean} returns "true" if the image is set to be visible, "false" if not - */ - this.isVisible = function(){ - return this.visible; - }; - /** - * @member PShape - * The setVisible() function sets the shape to be visible or invisible. This is determined by the value of the visible parameter. - *

        The visibility of a shape is usually controlled by whatever program created the SVG file. - * For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator. - * - * @param {boolean} visible "false" makes the shape invisible and "true" makes it visible - */ - this.setVisible = function (visible){ - this.visible = visible; - }; - /** - * @member PShape - * The disableStyle() function disables the shape's style data and uses Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints. - * Overrides this shape's style information and uses PGraphics styles and colors. Identical to ignoreStyles(true). Also disables styles for all child shapes. - */ - this.disableStyle = function(){ - this.style = false; - for(var i = 0; i < this.children.length; i++) - { - this.children[i].disableStyle(); - } - }; - /** - * @member PShape - * The enableStyle() function enables the shape's style data and ignores Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints. - */ - this.enableStyle = function(){ - this.style = true; - for(var i = 0; i < this.children.length; i++) - { - this.children[i].enableStyle(); - } - }; - /** - * @member PShape - * The getFamily function returns the shape type - * - * @return {int} the shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY - */ - this.getFamily = function(){ - return this.family; - }; - /** - * @member PShape - * The getWidth() function gets the width of the drawing area (not necessarily the shape boundary). - */ - this.getWidth = function(){ - return this.width; - }; - /** - * @member PShape - * The getHeight() function gets the height of the drawing area (not necessarily the shape boundary). - */ - this.getHeight = function(){ - return this.height; - }; - /** - * @member PShape - * The setName() function sets the name of the shape - * - * @param {String} name the name of the shape - */ - this.setName = function(name){ - this.name = name; - }; - /** - * @member PShape - * The getName() function returns the name of the shape - * - * @return {String} the name of the shape - */ - this.getName = function(){ - return this.name; - }; - /** - * @member PShape - * Called by the following (the shape() command adds the g) - * PShape s = loadShapes("blah.svg"); - * shape(s); - */ - this.draw = function(){ - if (this.visible) { - this.pre(); - this.drawImpl(); - this.post(); - } - }; - /** - * @member PShape - * the drawImpl() function draws the SVG document. - */ - this.drawImpl = function(){ - if (this.family === PConstants.GROUP) { - this.drawGroup(); - } else if (this.family === PConstants.PRIMITIVE) { - this.drawPrimitive(); - } else if (this.family === PConstants.GEOMETRY) { - this.drawGeometry(); - } else if (this.family === PConstants.PATH) { - this.drawPath(); - } - }; - /** - * @member PShape - * The drawPath() function draws the part of the SVG document. - */ - this.drawPath = function(){ - if (this.vertices.length === 0) { return; } - - p.beginShape(); - var i; - if (this.vertexCodes.length === 0) { // each point is a simple vertex - if (this.vertices[0].length === 2) { // drawing 2D vertices - for (i = 0; i < this.vertices.length; i++) { - p.vertex(this.vertices[i][0], this.vertices[i][1]); - } - } else { // drawing 3D vertices - for (i = 0; i < this.vertices.length; i++) { - p.vertex(this.vertices[i][0], this.vertices[i][1], this.vertices[i][2]); - } - } - } else { // coded set of vertices - var index = 0; - var j; - if (this.vertices[0].length === 2) { // drawing a 2D path - for (j = 0; j < this.vertexCodes.length; j++) { - switch (this.vertexCodes[j]) { - case PConstants.VERTEX: - p.vertex(this.vertices[index][0], this.vertices[index][1]); - if ( this.vertices[index]["moveTo"] === true) { - vertArray[vertArray.length-1]["moveTo"] = true; - } else if ( this.vertices[index]["moveTo"] === false) { - vertArray[vertArray.length-1]["moveTo"] = false; - } - p.breakShape = false; - index++; - break; - case PConstants.BEZIER_VERTEX: - p.bezierVertex(this.vertices[index+0][0], this.vertices[index+0][1], - this.vertices[index+1][0], this.vertices[index+1][1], - this.vertices[index+2][0], this.vertices[index+2][1]); - index += 3; - break; - case PConstants.CURVE_VERTEX: - p.curveVertex(this.vertices[index][0], this.vertices[index][1]); - index++; - break; - case PConstants.BREAK: - p.breakShape = true; - break; - } - } - } else { // drawing a 3D path - for (j = 0; j < this.vertexCodes.length; j++) { - switch (this.vertexCodes[j]) { - case PConstants.VERTEX: - p.vertex(this.vertices[index][0], this.vertices[index][1], this.vertices[index][2]); - if (this.vertices[index]["moveTo"] === true) { - vertArray[vertArray.length-1]["moveTo"] = true; - } else if (this.vertices[index]["moveTo"] === false) { - vertArray[vertArray.length-1]["moveTo"] = false; - } - p.breakShape = false; - break; - case PConstants.BEZIER_VERTEX: - p.bezierVertex(this.vertices[index+0][0], this.vertices[index+0][1], this.vertices[index+0][2], - this.vertices[index+1][0], this.vertices[index+1][1], this.vertices[index+1][2], - this.vertices[index+2][0], this.vertices[index+2][1], this.vertices[index+2][2]); - index += 3; - break; - case PConstants.CURVE_VERTEX: - p.curveVertex(this.vertices[index][0], this.vertices[index][1], this.vertices[index][2]); - index++; - break; - case PConstants.BREAK: - p.breakShape = true; - break; - } - } - } - } - p.endShape(this.close ? PConstants.CLOSE : PConstants.OPEN); - }; - /** - * @member PShape - * The drawGeometry() function draws the geometry part of the SVG document. - */ - this.drawGeometry = function() { - p.beginShape(this.kind); - var i; - if (this.style) { - for (i = 0; i < this.vertices.length; i++) { - p.vertex(this.vertices[i]); - } - } else { - for (i = 0; i < this.vertices.length; i++) { - var vert = this.vertices[i]; - if (vert[2] === 0) { - p.vertex(vert[0], vert[1]); - } else { - p.vertex(vert[0], vert[1], vert[2]); - } - } - } - p.endShape(); - }; - /** - * @member PShape - * The drawGroup() function draws the part of the SVG document. - */ - this.drawGroup = function() { - for (var i = 0; i < this.children.length; i++) { - this.children[i].draw(); - } - }; - /** - * @member PShape - * The drawPrimitive() function draws SVG document shape elements. These can be point, line, triangle, quad, rect, ellipse, arc, box, or sphere. - */ - this.drawPrimitive = function() { - switch (this.kind) { - case PConstants.POINT: - p.point(this.params[0], this.params[1]); - break; - case PConstants.LINE: - if (this.params.length === 4) { // 2D - p.line(this.params[0], this.params[1], - this.params[2], this.params[3]); - } else { // 3D - p.line(this.params[0], this.params[1], this.params[2], - this.params[3], this.params[4], this.params[5]); - } - break; - case PConstants.TRIANGLE: - p.triangle(this.params[0], this.params[1], - this.params[2], this.params[3], - this.params[4], this.params[5]); - break; - case PConstants.QUAD: - p.quad(this.params[0], this.params[1], - this.params[2], this.params[3], - this.params[4], this.params[5], - this.params[6], this.params[7]); - break; - case PConstants.RECT: - if (this.image !== null) { - p.imageMode(PConstants.CORNER); - p.image(this.image, this.params[0], this.params[1], this.params[2], this.params[3]); - } else { - p.rectMode(PConstants.CORNER); - p.rect(this.params[0], this.params[1], this.params[2], this.params[3]); - } - break; - case PConstants.ELLIPSE: - p.ellipseMode(PConstants.CORNER); - p.ellipse(this.params[0], this.params[1], this.params[2], this.params[3]); - break; - case PConstants.ARC: - p.ellipseMode(PConstants.CORNER); - p.arc(this.params[0], this.params[1], this.params[2], this.params[3], this.params[4], this.params[5]); - break; - case PConstants.BOX: - if (this.params.length === 1) { - p.box(this.params[0]); - } else { - p.box(this.params[0], this.params[1], this.params[2]); - } - break; - case PConstants.SPHERE: - p.sphere(this.params[0]); - break; - } - }; - /** - * @member PShape - * The pre() function performs the preparations before the SVG is drawn. This includes doing transformations and storing previous styles. - */ - this.pre = function() { - if (this.matrix) { - p.pushMatrix(); - curContext.transform(this.matrix.elements[0], this.matrix.elements[3], this.matrix.elements[1], this.matrix.elements[4], this.matrix.elements[2], this.matrix.elements[5]); - //p.applyMatrix(this.matrix.elements[0],this.matrix.elements[0]); - } - if (this.style) { - p.pushStyle(); - this.styles(); - } - }; - /** - * @member PShape - * The post() function performs the necessary actions after the SVG is drawn. This includes removing transformations and removing added styles. - */ - this.post = function() { - if (this.matrix) { - p.popMatrix(); - } - if (this.style) { - p.popStyle(); - } - }; - /** - * @member PShape - * The styles() function changes the Processing's current styles - */ - this.styles = function() { - if (this.stroke) { - p.stroke(this.strokeColor); - p.strokeWeight(this.strokeWeight); - p.strokeCap(this.strokeCap); - p.strokeJoin(this.strokeJoin); - } else { - p.noStroke(); - } - - if (this.fill) { - p.fill(this.fillColor); - - } else { - p.noFill(); - } - }; - /** - * @member PShape - * The getChild() function extracts a child shape from a parent shape. Specify the name of the shape with the target parameter or the - * layer position of the shape to get with the index parameter. - * The shape is returned as a PShape object, or null is returned if there is an error. - * - * @param {String} target the name of the shape to get - * @param {int} index the layer position of the shape to get - * - * @return {PShape} returns a child element of a shape as a PShape object or null if there is an error - */ - this.getChild = function() { - if (typeof arguments[0] === 'number') { - return this.children[arguments[0]]; - } else { - var found, - i; - if(arguments[0] === "" || this.name === arguments[0]){ - return this; - } else { - if(this.nameTable.length > 0) - { - for(i = 0; i < this.nameTable.length || found; i++) - { - if(this.nameTable[i].getName === arguments[0]) { - found = this.nameTable[i]; - } - } - if (found) { return found; } - } - for(i = 0; i < this.children.lenth; i++) - { - found = this.children[i].getChild(arguments[0]); - if(found) { return found; } - } - } - return null; - } - }; - /** - * @member PShape - * The getChildCount() returns the number of children - * - * @return {int} returns a count of children - */ - this.getChildCount = function () { - return this.children.length; - }; - /** - * @member PShape - * The addChild() adds a child to the PShape. - * - * @param {PShape} child the child to add - */ - this.addChild = function( child ) { - this.children.push(child); - child.parent = this; - if (child.getName() !== null) { - this.addName(child.getName(), child); - } - }; - /** - * @member PShape - * The addName() functions adds a shape to the name lookup table. - * - * @param {String} name the name to be added - * @param {PShape} shape the shape - */ - this.addName = function(name, shape) { - if (this.parent !== null) { - this.parent.addName( name, shape ); - } else { - this.nameTable.push( [name, shape] ); - } - }; - /** - * @member PShape - * The translate() function specifies an amount to displace the shape. The x parameter specifies left/right translation, the y parameter specifies up/down translation, and the z parameter specifies translations toward/away from the screen. - * Subsequent calls to the method accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

        Using this method with the z parameter requires using the P3D or OPENGL parameter in combination with size. - * - * @param {int|float} x left/right translation - * @param {int|float} y up/down translation - * @param {int|float} z forward/back translation - * - * @see PMatrix2D#translate - * @see PMatrix3D#translate - */ - this.translate = function() { - if(arguments.length === 2) - { - this.checkMatrix(2); - this.matrix.translate(arguments[0], arguments[1]); - } else { - this.checkMatrix(3); - this.matrix.translate(arguments[0], arguments[1], 0); - } - }; - /** - * @member PShape - * The checkMatrix() function makes sure that the shape's matrix is 1) not null, and 2) has a matrix - * that can handle at least the specified number of dimensions. - * - * @param {int} dimensions the specified number of dimensions - */ - this.checkMatrix = function(dimensions) { - if(this.matrix === null) { - if(dimensions === 2) { - this.matrix = new p.PMatrix2D(); - } else { - this.matrix = new p.PMatrix3D(); - } - }else if(dimensions === 3 && this.matrix instanceof p.PMatrix2D) { - this.matrix = new p.PMatrix3D(); - } - }; - /** - * @member PShape - * The rotateX() function rotates a shape around the x-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

        Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Subsequent calls to the method accumulates the effect. For example, calling rotateX(HALF_PI) and then rotateX(HALF_PI) is the same as rotateX(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

        This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above. - * - * @param {float}angle angle of rotation specified in radians - * - * @see PMatrix3D#rotateX - */ - this.rotateX = function(angle) { - this.rotate(angle, 1, 0, 0); - }; - /** - * @member PShape - * The rotateY() function rotates a shape around the y-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

        Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Subsequent calls to the method accumulates the effect. For example, calling rotateY(HALF_PI) and then rotateY(HALF_PI) is the same as rotateY(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

        This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above. - * - * @param {float}angle angle of rotation specified in radians - * - * @see PMatrix3D#rotateY - */ - this.rotateY = function(angle) { - this.rotate(angle, 0, 1, 0); - }; - /** - * @member PShape - * The rotateZ() function rotates a shape around the z-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

        Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Subsequent calls to the method accumulates the effect. For example, calling rotateZ(HALF_PI) and then rotateZ(HALF_PI) is the same as rotateZ(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

        This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above. - * - * @param {float}angle angle of rotation specified in radians - * - * @see PMatrix3D#rotateZ - */ - this.rotateZ = function(angle) { - this.rotate(angle, 0, 0, 1); - }; - /** - * @member PShape - * The rotate() function rotates a shape the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

        Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Transformations apply to everything that happens after and subsequent calls to the method accumulates the effect. - * For example, calling rotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - * If optional parameters x,y,z are supplied, the rotate is about the point (x, y, z). - * - * @param {float}angle angle of rotation specified in radians - * @param {float}x x-coordinate of the point - * @param {float}y y-coordinate of the point - * @param {float}z z-coordinate of the point - * @see PMatrix2D#rotate - * @see PMatrix3D#rotate - */ - this.rotate = function() { - if(arguments.length === 1){ - this.checkMatrix(2); - this.matrix.rotate(arguments[0]); - } else { - this.checkMatrix(3); - this.matrix.rotate(arguments[0], arguments[1], arguments[2] ,arguments[3]); - } - }; - /** - * @member PShape - * The scale() function increases or decreases the size of a shape by expanding and contracting vertices. Shapes always scale from the relative origin of their bounding box. - * Scale values are specified as decimal percentages. For example, the method call scale(2.0) increases the dimension of a shape by 200%. - * Subsequent calls to the method multiply the effect. For example, calling scale(2.0) and then scale(1.5) is the same as scale(3.0). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

        Using this fuction with the z parameter requires passing P3D or OPENGL into the size() parameter. - * - * @param {float}s percentage to scale the object - * @param {float}x percentage to scale the object in the x-axis - * @param {float}y percentage to scale the object in the y-axis - * @param {float}z percentage to scale the object in the z-axis - * - * @see PMatrix2D#scale - * @see PMatrix3D#scale - */ - this.scale = function() { - if(arguments.length === 2) { - this.checkMatrix(2); - this.matrix.scale(arguments[0], arguments[1]); - } else if (arguments.length === 3) { - this.checkMatrix(2); - this.matrix.scale(arguments[0], arguments[1], arguments[2]); - } else { - this.checkMatrix(2); - this.matrix.scale(arguments[0]); - } - }; - /** - * @member PShape - * The resetMatrix() function resets the matrix - * - * @see PMatrix2D#reset - * @see PMatrix3D#reset - */ - this.resetMatrix = function() { - this.checkMatrix(2); - this.matrix.reset(); - }; - /** - * @member PShape - * The applyMatrix() function multiplies this matrix by another matrix of type PMatrix3D or PMatrix2D. - * Individual elements can also be provided - * - * @param {PMatrix3D|PMatrix2D} matrix the matrix to multiply by - * - * @see PMatrix2D#apply - * @see PMatrix3D#apply - */ - this.applyMatrix = function(matrix) { - if (arguments.length === 1) { - this.applyMatrix(matrix.elements[0], matrix.elements[1], 0, matrix.elements[2], - matrix.elements[3], matrix.elements[4], 0, matrix.elements[5], - 0, 0, 1, 0, - 0, 0, 0, 1); - } else if (arguments.length === 6) { - this.checkMatrix(2); - this.matrix.apply(arguments[0], arguments[1], arguments[2], 0, - arguments[3], arguments[4], arguments[5], 0, - 0, 0, 1, 0, - 0, 0, 0, 1); - - } else if (arguments.length === 16) { - this.checkMatrix(3); - this.matrix.apply(arguments[0], arguments[1], arguments[2], arguments[3], - arguments[4], arguments[5], arguments[6], arguments[7], - arguments[8], arguments[9], arguments[10], arguments[11], - arguments[12], arguments[13], arguments[14], arguments[15]); - } - }; - }; - - /** - * SVG stands for Scalable Vector Graphics, a portable graphics format. It is - * a vector format so it allows for infinite resolution and relatively small - * file sizes. Most modern media software can view SVG files, including Adobe - * products, Firefox, etc. Illustrator and Inkscape can edit SVG files. - * - * @param {PApplet} parent typically use "this" - * @param {String} filename name of the SVG file to load - * @param {XMLElement} xml an XMLElement element - * @param {PShapeSVG} parent the parent PShapeSVG - * - * @see PShape - */ - var PShapeSVG = p.PShapeSVG = function() { - p.PShape.call( this ); // PShape is the base class. - if (arguments.length === 1) { //xml element coming in - this.element = arguments[0] ;//new p.XMLElement(null, arguments[0]); - // set values to their defaults according to the SVG spec - this.vertexCodes = []; - this.vertices = []; - this.opacity = 1; - - this.stroke = false; - this.strokeColor = PConstants.ALPHA_MASK; - this.strokeWeight = 1; - this.strokeCap = PConstants.SQUARE; // equivalent to BUTT in svg spec - this.strokeJoin = PConstants.MITER; - this.strokeGradient = null; - this.strokeGradientPaint = null; - this.strokeName = null; - this.strokeOpacity = 1; - - this.fill = true; - this.fillColor = PConstants.ALPHA_MASK; - this.fillGradient = null; - this.fillGradientPaint = null; - this.fillName = null; - this.fillOpacity = 1; - - if (this.element.getName() !== "svg") { - throw("root is not , it's <" + this.element.getName() + ">"); - } - } - else if (arguments.length === 2) { - if (typeof arguments[1] === 'string') { - if (arguments[1].indexOf(".svg") > -1) { //its a filename - this.element = new p.XMLElement(null, arguments[1]); - // set values to their defaults according to the SVG spec - this.vertexCodes = []; - this.vertices = []; - this.opacity = 1; - - this.stroke = false; - this.strokeColor = PConstants.ALPHA_MASK; - this.strokeWeight = 1; - this.strokeCap = PConstants.SQUARE; // equivalent to BUTT in svg spec - this.strokeJoin = PConstants.MITER; - this.strokeGradient = ""; - this.strokeGradientPaint = ""; - this.strokeName = ""; - this.strokeOpacity = 1; - - this.fill = true; - this.fillColor = PConstants.ALPHA_MASK; - this.fillGradient = null; - this.fillGradientPaint = null; - this.fillOpacity = 1; - - } - } else { // XMLElement - if (arguments[0]) { // PShapeSVG - this.element = arguments[1]; - this.vertexCodes = arguments[0].vertexCodes.slice(); - this.vertices = arguments[0].vertices.slice(); - - this.stroke = arguments[0].stroke; - this.strokeColor = arguments[0].strokeColor; - this.strokeWeight = arguments[0].strokeWeight; - this.strokeCap = arguments[0].strokeCap; - this.strokeJoin = arguments[0].strokeJoin; - this.strokeGradient = arguments[0].strokeGradient; - this.strokeGradientPaint = arguments[0].strokeGradientPaint; - this.strokeName = arguments[0].strokeName; - - this.fill = arguments[0].fill; - this.fillColor = arguments[0].fillColor; - this.fillGradient = arguments[0].fillGradient; - this.fillGradientPaint = arguments[0].fillGradientPaint; - this.fillName = arguments[0].fillName; - this.strokeOpacity = arguments[0].strokeOpacity; - this.fillOpacity = arguments[0].fillOpacity; - this.opacity = arguments[0].opacity; - } - } - } - - this.name = this.element.getStringAttribute("id"); - var displayStr = this.element.getStringAttribute("display", "inline"); - this.visible = displayStr !== "none"; - var str = this.element.getAttribute("transform"); - if (str) { - this.matrix = this.parseMatrix(str); - } - // not proper parsing of the viewBox, but will cover us for cases where - // the width and height of the object is not specified - var viewBoxStr = this.element.getStringAttribute("viewBox"); - if ( viewBoxStr !== null ) { - var viewBox = viewBoxStr.split(" "); - this.width = viewBox[2]; - this.height = viewBox[3]; - } - - // TODO if viewbox is not same as width/height, then use it to scale - // the original objects. for now, viewbox only used when width/height - // are empty values (which by the spec means w/h of "100%" - var unitWidth = this.element.getStringAttribute("width"); - var unitHeight = this.element.getStringAttribute("height"); - if (unitWidth !== null) { - this.width = this.parseUnitSize(unitWidth); - this.height = this.parseUnitSize(unitHeight); - } else { - if ((this.width === 0) || (this.height === 0)) { - // For the spec, the default is 100% and 100%. For purposes - // here, insert a dummy value because this is prolly just a - // font or something for which the w/h doesn't matter. - this.width = 1; - this.height = 1; - - //show warning - throw("The width and/or height is not " + - "readable in the tag of this file."); - } - } - this.parseColors(this.element); - this.parseChildren(this.element); - - }; - /** - * PShapeSVG methods - * missing: getChild(), print(), parseStyleAttributes(), styles() - deals with strokeGradient and fillGradient - */ - PShapeSVG.prototype = { - /** - * @member PShapeSVG - * The parseMatrix() function parses the specified SVG matrix into a PMatrix2D. Note that PMatrix2D - * is rotated relative to the SVG definition, so parameters are rearranged - * here. More about the transformation matrices in - * this section - * of the SVG documentation. - * - * @param {String} str text of the matrix param. - * - * @return {PMatrix2D} a PMatrix2D - */ - parseMatrix: function(str) { - this.checkMatrix(2); - var pieces = []; - str.replace(/\s*(\w+)\((.*?)\)/g, function(all) { - // get a list of transform definitions - pieces.push(p.trim(all)); - }); - if (pieces.length === 0) { - p.println("Transformation:" + str + " is empty"); - return null; - } - for (var i =0; i< pieces.length; i++) { - var m = []; - pieces[i].replace(/\((.*?)\)/, (function() { - return function(all, params) { - // get the coordinates that can be separated by spaces or a comma - m = params.replace(/,+/g, " ").split(/\s+/); - }; - }())); - - if (pieces[i].indexOf("matrix") !== -1) { - this.matrix.set(m[0], m[2], m[4], m[1], m[3], m[5]); - } else if (pieces[i].indexOf("translate") !== -1) { - var tx = m[0]; - var ty = (m.length === 2) ? m[1] : 0; - this.matrix.translate(tx,ty); - } else if (pieces[i].indexOf("scale") !== -1) { - var sx = m[0]; - var sy = (m.length === 2) ? m[1] : m[0]; - this.matrix.scale(sx,sy); - } else if (pieces[i].indexOf("rotate") !== -1) { - var angle = m[0]; - if (m.length === 1) { - this.matrix.rotate(p.radians(angle)); - } else if (m.length === 3) { - this.matrix.translate(m[1], m[2]); - this.matrix.rotate(p.radians(m[0])); - this.matrix.translate(-m[1], -m[2]); - } - } else if (pieces[i].indexOf("skewX") !== -1) { - this.matrix.skewX(parseFloat(m[0])); - } else if (pieces[i].indexOf("skewY") !== -1) { - this.matrix.skewY(m[0]); - } - } - return this.matrix; - }, - /** - * @member PShapeSVG - * The parseChildren() function parses the specified XMLElement - * - * @param {XMLElement}element the XMLElement to parse - */ - parseChildren:function(element) { - var newelement = element.getChildren(); - var children = new p.PShape(); - for (var i = 0; i < newelement.length; i++) { - var kid = this.parseChild(newelement[i]); - if (kid) { - children.addChild(kid); - } - } - this.children.push(children); - }, - /** - * @member PShapeSVG - * The getName() function returns the name - * - * @return {String} the name - */ - getName: function() { - return this.name; - }, - /** - * @member PShapeSVG - * The parseChild() function parses a child XML element. - * - * @param {XMLElement} elem the element to parse - * - * @return {PShape} the newly created PShape - */ - parseChild: function( elem ) { - var name = elem.getName(); - var shape; - switch (name) { - case "g": - shape = new PShapeSVG(this, elem); - break; - case "defs": - // generally this will contain gradient info, so may - // as well just throw it into a group element for parsing - shape = new PShapeSVG(this, elem); - break; - case "line": - shape = new PShapeSVG(this, elem); - shape.parseLine(); - break; - case "circle": - shape = new PShapeSVG(this, elem); - shape.parseEllipse(true); - break; - case "ellipse": - shape = new PShapeSVG(this, elem); - shape.parseEllipse(false); - break; - case "rect": - shape = new PShapeSVG(this, elem); - shape.parseRect(); - break; - case "polygon": - shape = new PShapeSVG(this, elem); - shape.parsePoly(true); - break; - case "polyline": - shape = new PShapeSVG(this, elem); - shape.parsePoly(false); - break; - case "path": - shape = new PShapeSVG(this, elem); - shape.parsePath(); - break; - case "radialGradient": - //return new RadialGradient(this, elem); - break; - case "linearGradient": - //return new LinearGradient(this, elem); - break; - case "text": - p.println("Text in SVG files is not currently supported, convert text to outlines instead." ); - break; - case "filter": - p.println("Filters are not supported."); - break; - case "mask": - p.println("Masks are not supported."); - break; - default: - p.println("Ignoring <" + name + "> tag."); - break; - } - return shape; - }, - /** - * @member PShapeSVG - * The parsePath() function parses the element of the svg file - * A path is defined by including a path element which contains a d="(path data)" attribute, where the d attribute contains - * the moveto, line, curve (both cubic and quadratic Beziers), arc and closepath instructions. - **/ - parsePath: function() { - this.family = PConstants.PATH; - this.kind = 0; - var pathDataChars = []; - var c; - var pathData = p.trim(this.element.getStringAttribute("d").replace(/[\s,]+/g,' ')); //change multiple spaces and commas to single space - if (pathData === null) { return; } - pathData = pathData.toCharArray(); - var cx = 0, - cy = 0, - ctrlX = 0, - ctrlY = 0, - ctrlX1 = 0, - ctrlX2 = 0, - ctrlY1 = 0, - ctrlY2 = 0, - endX = 0, - endY = 0, - ppx = 0, - ppy = 0, - px = 0, - py = 0, - i = 0, - j = 0, - valOf = 0; - var str = ""; - var tmpArray =[]; - var flag = false; - var lastInstruction; - var command; - while (i< pathData.length) { - valOf = pathData[i].valueOf(); - if ((valOf >= 65 && valOf <= 90) || (valOf >= 97 && valOf <= 122)) { // if its a letter - // populate the tmpArray with coordinates - j = i; - i++; - if (i < pathData.length) { // dont go over boundary of array - tmpArray = []; - valOf = pathData[i].valueOf(); - while (!((valOf >= 65 && valOf <= 90) || (valOf >= 97 && valOf <= 100) || (valOf >= 102 && valOf <= 122)) && flag === false) { // if its NOT a letter - if (valOf === 32) { //if its a space and the str isn't empty - // somethimes you get a space after the letter - if (str !== "") { - tmpArray.push(parseFloat(str)); - str = ""; - } - i++; - } else if (valOf === 45) { //if its a - - // allow for 'e' notation in numbers, e.g. 2.10e-9 - if (pathData[i-1].valueOf() === 101) { - str += pathData[i].toString(); - i++; - } else { - // sometimes no space separator after (ex: 104.535-16.322) - if (str !== "") { - tmpArray.push(parseFloat(str)); - } - str = pathData[i].toString(); - i++; - } - } else { - str += pathData[i].toString(); - i++; - } - if (i === pathData.length) { // dont go over boundary of array - flag = true; - } else { - valOf = pathData[i].valueOf(); - } - } - } - if (str !== "") { - tmpArray.push(parseFloat(str)); - str = ""; - } - command = pathData[j]; - switch (command.valueOf()) { - case 77: // M - move to (absolute) - if (tmpArray.length >= 2 && tmpArray.length % 2 ===0) { // need one+ pairs of co-ordinates - cx = tmpArray[0]; - cy = tmpArray[1]; - this.parsePathMoveto(cx, cy); - if (tmpArray.length > 2) { - for (j = 2; j < tmpArray.length; j+=2) { - // absolute line to - cx = tmpArray[j]; - cy = tmpArray[j+1]; - this.parsePathLineto(cx,cy); - } - } - } - break; - case 109: // m - move to (relative) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - cx += tmpArray[0]; - cy += tmpArray[1]; - this.parsePathMoveto(cx,cy); - if (tmpArray.length > 2) { - for (j = 2; j < tmpArray.length; j+=2) { - // relative line to - cx += tmpArray[j]; - cy += tmpArray[j + 1]; - this.parsePathLineto(cx,cy); - } - } - } - break; - case 76: // L - lineto (absolute) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - cx = tmpArray[j]; - cy = tmpArray[j + 1]; - this.parsePathLineto(cx,cy); - } - } - break; - - case 108: // l - lineto (relative) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - cx += tmpArray[j]; - cy += tmpArray[j+1]; - this.parsePathLineto(cx,cy); - } - } - break; - - case 72: // H - horizontal lineto (absolute) - for (j = 0; j < tmpArray.length; j++) { // multiple x co-ordinates can be provided - cx = tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 104: // h - horizontal lineto (relative) - for (j = 0; j < tmpArray.length; j++) { // multiple x co-ordinates can be provided - cx += tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 86: // V - vertical lineto (absolute) - for (j = 0; j < tmpArray.length; j++) { // multiple y co-ordinates can be provided - cy = tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 118: // v - vertical lineto (relative) - for (j = 0; j < tmpArray.length; j++) { // multiple y co-ordinates can be provided - cy += tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 67: // C - curve to (absolute) - if (tmpArray.length >= 6 && tmpArray.length % 6 === 0) { // need one+ multiples of 6 co-ordinates - for (j = 0; j < tmpArray.length; j+=6) { - ctrlX1 = tmpArray[j]; - ctrlY1 = tmpArray[j + 1]; - ctrlX2 = tmpArray[j + 2]; - ctrlY2 = tmpArray[j + 3]; - endX = tmpArray[j + 4]; - endY = tmpArray[j + 5]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 99: // c - curve to (relative) - if (tmpArray.length >= 6 && tmpArray.length % 6 === 0) { // need one+ multiples of 6 co-ordinates - for (j = 0; j < tmpArray.length; j+=6) { - ctrlX1 = cx + tmpArray[j]; - ctrlY1 = cy + tmpArray[j + 1]; - ctrlX2 = cx + tmpArray[j + 2]; - ctrlY2 = cy + tmpArray[j + 3]; - endX = cx + tmpArray[j + 4]; - endY = cy + tmpArray[j + 5]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 83: // S - curve to shorthand (absolute) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - if (lastInstruction.toLowerCase() === "c" || lastInstruction.toLowerCase() === "s") { - ppx = this.vertices[ this.vertices.length-2 ][0]; - ppy = this.vertices[ this.vertices.length-2 ][1]; - px = this.vertices[ this.vertices.length-1 ][0]; - py = this.vertices[ this.vertices.length-1 ][1]; - ctrlX1 = px + (px - ppx); - ctrlY1 = py + (py - ppy); - } else { - //If there is no previous curve, the current point will be used as the first control point. - ctrlX1 = this.vertices[this.vertices.length-1][0]; - ctrlY1 = this.vertices[this.vertices.length-1][1]; - } - ctrlX2 = tmpArray[j]; - ctrlY2 = tmpArray[j + 1]; - endX = tmpArray[j + 2]; - endY = tmpArray[j + 3]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 115: // s - curve to shorthand (relative) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - if (lastInstruction.toLowerCase() === "c" || lastInstruction.toLowerCase() === "s") { - ppx = this.vertices[this.vertices.length-2][0]; - ppy = this.vertices[this.vertices.length-2][1]; - px = this.vertices[this.vertices.length-1][0]; - py = this.vertices[this.vertices.length-1][1]; - ctrlX1 = px + (px - ppx); - ctrlY1 = py + (py - ppy); - } else { - //If there is no previous curve, the current point will be used as the first control point. - ctrlX1 = this.vertices[this.vertices.length-1][0]; - ctrlY1 = this.vertices[this.vertices.length-1][1]; - } - ctrlX2 = cx + tmpArray[j]; - ctrlY2 = cy + tmpArray[j + 1]; - endX = cx + tmpArray[j + 2]; - endY = cy + tmpArray[j + 3]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 81: // Q - quadratic curve to (absolute) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - ctrlX = tmpArray[j]; - ctrlY = tmpArray[j + 1]; - endX = tmpArray[j + 2]; - endY = tmpArray[j + 3]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 113: // q - quadratic curve to (relative) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - ctrlX = cx + tmpArray[j]; - ctrlY = cy + tmpArray[j + 1]; - endX = cx + tmpArray[j + 2]; - endY = cy + tmpArray[j + 3]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 84: // T - quadratic curve to shorthand (absolute) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - if (lastInstruction.toLowerCase() === "q" || lastInstruction.toLowerCase() === "t") { - ppx = this.vertices[this.vertices.length-2][0]; - ppy = this.vertices[this.vertices.length-2][1]; - px = this.vertices[this.vertices.length-1][0]; - py = this.vertices[this.vertices.length-1][1]; - ctrlX = px + (px - ppx); - ctrlY = py + (py - ppy); - } else { - // If there is no previous command or if the previous command was not a Q, q, T or t, - // assume the control point is coincident with the current point. - ctrlX = cx; - ctrlY = cy; - } - endX = tmpArray[j]; - endY = tmpArray[j + 1]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 116: // t - quadratic curve to shorthand (relative) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - if (lastInstruction.toLowerCase() === "q" || lastInstruction.toLowerCase() === "t") { - ppx = this.vertices[this.vertices.length-2][0]; - ppy = this.vertices[this.vertices.length-2][1]; - px = this.vertices[this.vertices.length-1][0]; - py = this.vertices[this.vertices.length-1][1]; - ctrlX = px + (px - ppx); - ctrlY = py + (py - ppy); - } else { - // If there is no previous command or if the previous command was not a Q, q, T or t, - // assume the control point is coincident with the current point. - ctrlX = cx; - ctrlY = cy; - } - endX = cx + tmpArray[j]; - endY = cy + tmpArray[j + 1]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 90: //Z - case 122: //z - this.close = true; - break; - } - lastInstruction = command.toString(); - } else { i++;} - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathQuadto: function(x1, y1, cx, cy, x2, y2) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.BEZIER_VERTEX); - // x1/y1 already covered by last moveto, lineto, or curveto - this.parsePathVertex(x1 + ((cx-x1)*2/3), y1 + ((cy-y1)*2/3)); - this.parsePathVertex(x2 + ((cx-x2)*2/3), y2 + ((cy-y2)*2/3)); - this.parsePathVertex(x2, y2); - } else { - throw ("Path must start with M/m"); - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathCurveto : function(x1, y1, x2, y2, x3, y3) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.BEZIER_VERTEX ); - this.parsePathVertex(x1, y1); - this.parsePathVertex(x2, y2); - this.parsePathVertex(x3, y3); - } else { - throw ("Path must start with M/m"); - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathLineto: function(px, py) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.VERTEX); - this.parsePathVertex(px, py); - // add property to distinguish between curContext.moveTo or curContext.lineTo - this.vertices[this.vertices.length-1]["moveTo"] = false; - } else { - throw ("Path must start with M/m"); - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathMoveto: function(px, py) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.BREAK); - } - this.parsePathCode(PConstants.VERTEX); - this.parsePathVertex(px, py); - // add property to distinguish between curContext.moveTo or curContext.lineTo - this.vertices[this.vertices.length-1]["moveTo"] = true; - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathVertex: function(x, y) { - var verts = []; - verts[0] = x; - verts[1] = y; - this.vertices.push(verts); - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathCode: function(what) { - this.vertexCodes.push(what); - }, - /** - * @member PShapeSVG - * The parsePoly() function parses a polyline or polygon from an SVG file. - * - * @param {boolean}val true if shape is closed (polygon), false if not (polyline) - */ - parsePoly: function(val) { - this.family = PConstants.PATH; - this.close = val; - var pointsAttr = p.trim(this.element.getStringAttribute("points").replace(/[,\s]+/g,' ')); - if (pointsAttr !== null) { - //split into array - var pointsBuffer = pointsAttr.split(" "); - if (pointsBuffer.length % 2 === 0) { - for (var i = 0; i < pointsBuffer.length; i++) { - var verts = []; - verts[0] = pointsBuffer[i]; - verts[1] = pointsBuffer[++i]; - this.vertices.push(verts); - } - } else { - p.println("Error parsing polygon points: odd number of coordinates provided"); - } - } - }, - /** - * @member PShapeSVG - * The parseRect() function parses a rect from an SVG file. - */ - parseRect: function() { - this.kind = PConstants.RECT; - this.family = PConstants.PRIMITIVE; - this.params = []; - this.params[0] = this.element.getFloatAttribute("x"); - this.params[1] = this.element.getFloatAttribute("y"); - this.params[2] = this.element.getFloatAttribute("width"); - this.params[3] = this.element.getFloatAttribute("height"); - if (this.params[2] < 0 || this.params[3] < 0) { - throw("svg error: negative width or height found while parsing "); - } - - }, - /** - * @member PShapeSVG - * The parseEllipse() function handles parsing ellipse and circle tags. - * - * @param {boolean}val true if this is a circle and not an ellipse - */ - parseEllipse: function(val) { - this.kind = PConstants.ELLIPSE; - this.family = PConstants.PRIMITIVE; - this.params = []; - - this.params[0] = this.element.getFloatAttribute("cx") | 0; - this.params[1] = this.element.getFloatAttribute("cy") | 0; - - var rx, ry; - if (val) { //this is a circle - rx = ry = this.element.getFloatAttribute("r"); - if (rx < 0) { - throw("svg error: negative radius found while parsing "); - } - } else { - rx = this.element.getFloatAttribute("rx"); - ry = this.element.getFloatAttribute("ry"); - if (rx < 0 || ry < 0) { - throw("svg error: negative x-axis radius or y-axis radius found while parsing "); - } - } - this.params[0] -= rx; - this.params[1] -= ry; - - this.params[2] = rx*2; - this.params[3] = ry*2; - }, - /** - * @member PShapeSVG - * The parseLine() function handles parsing line tags. - * - * @param {boolean}val true if this is a circle and not an ellipse - */ - parseLine: function() { - this.kind = PConstants.LINE; - this.family = PConstants.PRIMITIVE; - this.params = []; - this.params[0] = this.element.getFloatAttribute("x1"); - this.params[1] = this.element.getFloatAttribute("y1"); - this.params[2] = this.element.getFloatAttribute("x2"); - this.params[3] = this.element.getFloatAttribute("y2"); - }, - /** - * @member PShapeSVG - * The parseColors() function handles parsing the opacity, strijem stroke-width, stroke-linejoin,stroke-linecap, fill, and style attributes - * - * @param {XMLElement}element the element of which attributes to parse - */ - parseColors: function(element) { - if (element.hasAttribute("opacity")) { - this.setOpacity(element.getAttribute("opacity")); - } - if (element.hasAttribute("stroke")) { - this.setStroke(element.getAttribute("stroke")); - } - if (element.hasAttribute("stroke-width")) { - // if NaN (i.e. if it's 'inherit') then default back to the inherit setting - this.setStrokeWeight(element.getAttribute("stroke-width")); - } - if (element.hasAttribute("stroke-linejoin") ) { - this.setStrokeJoin(element.getAttribute("stroke-linejoin")); - } - if (element.hasAttribute("stroke-linecap")) { - this.setStrokeCap(element.getStringAttribute("stroke-linecap")); - } - // fill defaults to black (though stroke defaults to "none") - // http://www.w3.org/TR/SVG/painting.html#FillProperties - if (element.hasAttribute("fill")) { - this.setFill(element.getStringAttribute("fill")); - } - if (element.hasAttribute("style")) { - var styleText = element.getStringAttribute("style"); - var styleTokens = styleText.toString().split( ";" ); - - for (var i = 0; i < styleTokens.length; i++) { - var tokens = p.trim(styleTokens[i].split( ":" )); - switch(tokens[0]){ - case "fill": - this.setFill(tokens[1]); - break; - case "fill-opacity": - this.setFillOpacity(tokens[1]); - break; - case "stroke": - this.setStroke(tokens[1]); - break; - case "stroke-width": - this.setStrokeWeight(tokens[1]); - break; - case "stroke-linecap": - this.setStrokeCap(tokens[1]); - break; - case "stroke-linejoin": - this.setStrokeJoin(tokens[1]); - break; - case "stroke-opacity": - this.setStrokeOpacity(tokens[1]); - break; - case "opacity": - this.setOpacity(tokens[1]); - break; - // Other attributes are not yet implemented - } - } - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} opacityText the value of fillOpacity - * - * @see PShapeSVG#parseColors - */ - setFillOpacity: function(opacityText) { - this.fillOpacity = parseFloat(opacityText); - this.fillColor = this.fillOpacity * 255 << 24 | this.fillColor & 0xFFFFFF; - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} fillText the value of fill - * - * @see PShapeSVG#parseColors - */ - setFill: function (fillText) { - var opacityMask = this.fillColor & 0xFF000000; - if (fillText === "none") { - this.fill = false; - } else if (fillText.indexOf("#") === 0) { - this.fill = true; - if (fillText.length === 4) { - // convert #00F to #0000FF - fillText = fillText.replace(/#(.)(.)(.)/,"#$1$1$2$2$3$3"); - } - this.fillColor = opacityMask | (parseInt(fillText.substring(1), 16)) & 0xFFFFFF; - } else if (fillText.indexOf("rgb") === 0) { - this.fill = true; - this.fillColor = opacityMask | this.parseRGB(fillText); - } else if (fillText.indexOf("url(#") === 0) { - this.fillName = fillText.substring(5, fillText.length - 1 ); - /*Object fillObject = findChild(fillName); - if (fillObject instanceof Gradient) { - fill = true; - fillGradient = (Gradient) fillObject; - fillGradientPaint = calcGradientPaint(fillGradient); //, opacity); - } else { - System.err.println("url " + fillName + " refers to unexpected data"); - }*/ - } else { - if (colors[fillText]) { - this.fill = true; - this.fillColor = opacityMask | (parseInt(colors[fillText].substring(1), 16)) & 0xFFFFFF; - } - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} opacity the value of opacity - * - * @see PShapeSVG#parseColors - */ - setOpacity: function(opacity) { - this.strokeColor = parseFloat(opacity) * 255 << 24 | this.strokeColor & 0xFFFFFF; - this.fillColor = parseFloat(opacity) * 255 << 24 | this.fillColor & 0xFFFFFF; - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} strokeText the value to set stroke to - * - * @see PShapeSVG#parseColors - */ - setStroke: function(strokeText) { - var opacityMask = this.strokeColor & 0xFF000000; - if (strokeText === "none") { - this.stroke = false; - } else if (strokeText.charAt( 0 ) === "#") { - this.stroke = true; - if (strokeText.length === 4) { - // convert #00F to #0000FF - strokeText = strokeText.replace(/#(.)(.)(.)/,"#$1$1$2$2$3$3"); - } - this.strokeColor = opacityMask | (parseInt( strokeText.substring(1), 16)) & 0xFFFFFF; - } else if (strokeText.indexOf( "rgb" ) === 0 ) { - this.stroke = true; - this.strokeColor = opacityMask | this.parseRGB(strokeText); - } else if (strokeText.indexOf( "url(#" ) === 0) { - this.strokeName = strokeText.substring(5, strokeText.length - 1); - //this.strokeObject = findChild(strokeName); - /*if (strokeObject instanceof Gradient) { - strokeGradient = (Gradient) strokeObject; - strokeGradientPaint = calcGradientPaint(strokeGradient); //, opacity); - } else { - System.err.println("url " + strokeName + " refers to unexpected data"); - }*/ - } else { - if (colors[strokeText]){ - this.stroke = true; - this.strokeColor = opacityMask | (parseInt(colors[strokeText].substring(1), 16)) & 0xFFFFFF; - } - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} weight the value to set strokeWeight to - * - * @see PShapeSVG#parseColors - */ - setStrokeWeight: function(weight) { - this.strokeWeight = this.parseUnitSize(weight); - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} linejoin the value to set strokeJoin to - * - * @see PShapeSVG#parseColors - */ - setStrokeJoin: function(linejoin) { - if (linejoin === "miter") { - this.strokeJoin = PConstants.MITER; - - } else if (linejoin === "round") { - this.strokeJoin = PConstants.ROUND; - - } else if (linejoin === "bevel") { - this.strokeJoin = PConstants.BEVEL; - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} linecap the value to set strokeCap to - * - * @see PShapeSVG#parseColors - */ - setStrokeCap: function (linecap) { - if (linecap === "butt") { - this.strokeCap = PConstants.SQUARE; - - } else if (linecap === "round") { - this.strokeCap = PConstants.ROUND; - - } else if (linecap === "square") { - this.strokeCap = PConstants.PROJECT; - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} opacityText the value to set stroke opacity to - * - * @see PShapeSVG#parseColors - */ - setStrokeOpacity: function (opacityText) { - this.strokeOpacity = parseFloat(opacityText); - this.strokeColor = this.strokeOpacity * 255 << 24 | this.strokeColor & 0xFFFFFF; - }, - /** - * @member PShapeSVG - * The parseRGB() function parses an rbg() color string and returns a color int - * - * @param {String} color the color to parse in rbg() format - * - * @return {int} the equivalent color int - */ - parseRGB: function(color) { - var sub = color.substring(color.indexOf('(') + 1, color.indexOf(')')); - var values = sub.split(", "); - return (values[0] << 16) | (values[1] << 8) | (values[2]); - }, - /** - * @member PShapeSVG - * The parseUnitSize() function parse a size that may have a suffix for its units. - * Ignoring cases where this could also be a percentage. - * The units spec: - *
          - *
        • "1pt" equals "1.25px" (and therefore 1.25 user units) - *
        • "1pc" equals "15px" (and therefore 15 user units) - *
        • "1mm" would be "3.543307px" (3.543307 user units) - *
        • "1cm" equals "35.43307px" (and therefore 35.43307 user units) - *
        • "1in" equals "90px" (and therefore 90 user units) - *
        - */ - parseUnitSize: function (text) { - var len = text.length - 2; - if (len < 0) { return text; } - if (text.indexOf("pt") === len) { - return parseFloat(text.substring(0, len)) * 1.25; - } else if (text.indexOf("pc") === len) { - return parseFloat( text.substring( 0, len)) * 15; - } else if (text.indexOf("mm") === len) { - return parseFloat( text.substring(0, len)) * 3.543307; - } else if (text.indexOf("cm") === len) { - return parseFloat(text.substring(0, len)) * 35.43307; - } else if (text.indexOf("in") === len) { - return parseFloat(text.substring(0, len)) * 90; - } else if (text.indexOf("px") === len) { - return parseFloat(text.substring(0, len)); - } else { - return parseFloat(text); - } - } - }; - /** - * The shape() function displays shapes to the screen. - * Processing currently works with SVG shapes only. - * The shape parameter specifies the shape to display and the x - * and y parameters define the location of the shape from its - * upper-left corner. - * The shape is displayed at its original size unless the width - * and height parameters specify a different size. - * The shapeMode() function changes the way the parameters work. - * A call to shapeMode(CORNERS), for example, will change the width - * and height parameters to define the x and y values of the opposite corner - * of the shape. - *

        - * Note complex shapes may draw awkwardly with P2D, P3D, and OPENGL. Those - * renderers do not yet support shapes that have holes or complicated breaks. - * - * @param {PShape} shape the shape to display - * @param {int|float} x x-coordinate of the shape - * @param {int|float} y y-coordinate of the shape - * @param {int|float} width width to display the shape - * @param {int|float} height height to display the shape - * - * @see PShape - * @see loadShape() - * @see shapeMode() - */ - p.shape = function(shape, x, y, width, height) { - if (arguments.length >= 1 && arguments[0] !== null) { - if (shape.isVisible()) { - p.pushMatrix(); - if (curShapeMode === PConstants.CENTER) { - if (arguments.length === 5) { - p.translate(x - width/2, y - height/2); - p.scale(width / shape.getWidth(), height / shape.getHeight()); - } else if (arguments.length === 3) { - p.translate(x - shape.getWidth()/2, - shape.getHeight()/2); - } else { - p.translate(-shape.getWidth()/2, -shape.getHeight()/2); - } - } else if (curShapeMode === PConstants.CORNER) { - if (arguments.length === 5) { - p.translate(x, y); - p.scale(width / shape.getWidth(), height / shape.getHeight()); - } else if (arguments.length === 3) { - p.translate(x, y); - } - } else if (curShapeMode === PConstants.CORNERS) { - if (arguments.length === 5) { - width -= x; - height -= y; - p.translate(x, y); - p.scale(width / shape.getWidth(), height / shape.getHeight()); - } else if (arguments.length === 3) { - p.translate(x, y); - } - } - shape.draw(); - if ((arguments.length === 1 && curShapeMode === PConstants.CENTER ) || arguments.length > 1) { - p.popMatrix(); - } - } - } - }; - - /** - * The shapeMode() function modifies the location from which shapes draw. - * The default mode is shapeMode(CORNER), which specifies the - * location to be the upper left corner of the shape and uses the third - * and fourth parameters of shape() to specify the width and height. - * The syntax shapeMode(CORNERS) uses the first and second parameters - * of shape() to set the location of one corner and uses the third - * and fourth parameters to set the opposite corner. - * The syntax shapeMode(CENTER) draws the shape from its center point - * and uses the third and forth parameters of shape() to specify the - * width and height. - * The parameter must be written in "ALL CAPS" because Processing syntax - * is case sensitive. - * - * @param {int} mode One of CORNER, CORNERS, CENTER - * - * @see shape() - * @see rectMode() - */ - p.shapeMode = function (mode) { - curShapeMode = mode; - }; - - /** - * The loadShape() function loads vector shapes into a variable of type PShape. Currently, only SVG files may be loaded. - * In most cases, loadShape() should be used inside setup() because loading shapes inside draw() will reduce the speed of a sketch. - * - * @param {String} filename an SVG file - * - * @return {PShape} a object of type PShape or null - * @see PShape - * @see PApplet#shape() - * @see PApplet#shapeMode() - */ - p.loadShape = function (filename) { - if (arguments.length === 1) { - if (filename.indexOf(".svg") > -1) { - return new PShapeSVG(null, filename); - } - } - return null; - }; - - /** - * XMLAttribute is an attribute of a XML element. This is an internal class - * - * @param {String} fname the full name of the attribute - * @param {String} n the short name of the attribute - * @param {String} namespace the namespace URI of the attribute - * @param {String} v the value of the attribute - * @param {String }t the type of the attribute - * - * @see XMLElement - */ - var XMLAttribute = function(fname, n, nameSpace, v, t){ - this.fullName = fname || ""; - this.name = n || ""; - this.namespace = nameSpace || ""; - this.value = v; - this.type = t; - }; - /** - * XMLAttribute methods - */ - XMLAttribute.prototype = { - /** - * @member XMLAttribute - * The getName() function returns the short name of the attribute - * - * @return {String} the short name of the attribute - */ - getName: function() { - return this.name; - }, - /** - * @member XMLAttribute - * The getFullName() function returns the full name of the attribute - * - * @return {String} the full name of the attribute - */ - getFullName: function() { - return this.fullName; - }, - /** - * @member XMLAttribute - * The getNamespace() function returns the namespace of the attribute - * - * @return {String} the namespace of the attribute - */ - getNamespace: function() { - return this.namespace; - }, - /** - * @member XMLAttribute - * The getValue() function returns the value of the attribute - * - * @return {String} the value of the attribute - */ - getValue: function() { - return this.value; - }, - /** - * @member XMLAttribute - * The getValue() function returns the type of the attribute - * - * @return {String} the type of the attribute - */ - getType: function() { - return this.type; - }, - /** - * @member XMLAttribute - * The setValue() function sets the value of the attribute - * - * @param {String} newval the new value - */ - setValue: function(newval) { - this.value = newval; - } - }; - - /** - * XMLElement is a representation of an XML object. The object is able to parse XML code - * - * @param {PApplet} parent typically use "this" - * @param {String} filename name of the XML/SVG file to load - * @param {String} xml the xml/svg string - * @param {String} fullname the full name of the element - * @param {String} namespace the namespace of the URI - * @param {String} systemID the system ID of the XML data where the element starts - * @param {Integer }lineNr the line in the XML data where the element starts - */ - var XMLElement = p.XMLElement = function() { - if (arguments.length === 4) { - this.attributes = []; - this.children = []; - this.fullName = arguments[0] || ""; - if (arguments[1]) { - this.name = arguments[1]; - } else { - var index = this.fullName.indexOf(':'); - if (index >= 0) { - this.name = this.fullName.substring(index + 1); - } else { - this.name = this.fullName; - } - } - this.namespace = arguments[1]; - this.content = ""; - this.lineNr = arguments[3]; - this.systemID = arguments[2]; - this.parent = null; - } - else if ((arguments.length === 2 && arguments[1].indexOf(".") > -1) ) { // filename or svg xml element - this.attributes = []; - this.children = []; - this.fullName = ""; - this.name = ""; - this.namespace = ""; - this.content = ""; - this.systemID = ""; - this.lineNr = ""; - this.parent = null; - this.parse(arguments[arguments.length -1]); - } else if (arguments.length === 1 && typeof arguments[0] === "string"){ - //xml string - this.attributes = []; - this.children = []; - this.fullName = ""; - this.name = ""; - this.namespace = ""; - this.content = ""; - this.systemID = ""; - this.lineNr = ""; - this.parent = null; - this.parse(arguments[0]); - } - else { //empty ctor - this.attributes = []; - this.children = []; - this.fullName = ""; - this.name = ""; - this.namespace = ""; - this.content = ""; - this.systemID = ""; - this.lineNr = ""; - this.parent = null; - - } - return this; - }; - /** - * XMLElement methods - * missing: enumerateAttributeNames(), enumerateChildren(), - * NOTE: parse does not work when a url is passed in - */ - XMLElement.prototype = { - /** - * @member XMLElement - * The parse() function retrieves the file via ajax() and uses DOMParser() parseFromString method to make an XML document - * @addon - * - * @param {String} filename name of the XML/SVG file to load - * - * @throws ExceptionType Error loading document - * - * @see XMLElement#parseChildrenRecursive - */ - parse: function(filename) { - var xmlDoc; - try { - if (filename.indexOf(".xml") > -1 || filename.indexOf(".svg") > -1) { - filename = ajax(filename); - } - xmlDoc = new DOMParser().parseFromString(filename, "text/xml"); - var elements = xmlDoc.documentElement; - if (elements) { - this.parseChildrenRecursive(null, elements); - } else { - throw ("Error loading document"); - } - return this; - } catch(e) { - throw(e); - } - }, - /** - * @member XMLElement - * The createElement() function Creates an empty element - * - * @param {String} fullName the full name of the element - * @param {String} namespace the namespace URI - * @param {String} systemID the system ID of the XML data where the element starts - * @param {int} lineNr the line in the XML data where the element starts - */ - createElement: function () { - if (arguments.length === 2) { - return new XMLElement(arguments[0], arguments[1], null, null); - } else { - return new XMLElement(arguments[0], arguments[1], arguments[2], arguments[3]); - } - }, - /** - * @member XMLElement - * The hasAttribute() function returns whether an attribute exists - * - * @param {String} name name of the attribute - * @param {String} namespace the namespace URI of the attribute - * - * @return {boolean} true if the attribute exists - */ - hasAttribute: function () { - if (arguments.length === 1) { - return this.getAttribute(arguments[0]) !== null; - } else if (arguments.length === 2) { - return this.getAttribute(arguments[0],arguments[1]) !== null; - } - }, - /** - * @member XMLElement - * The createPCDataElement() function creates an element to be used for #PCDATA content - * - * @return {XMLElement} new XMLElement element - */ - createPCDataElement: function () { - return new XMLElement(); - }, - /** - * @member XMLElement - * The equals() function checks to see if the element being passed in equals another element - * - * @param {Object} rawElement the element to compare to - * - * @return {boolean} true if the element equals another element - */ - equals: function(object){ - if (typeof object === "Object") { - return this.equalsXMLElement(object); - } - }, - /** - * @member XMLElement - * The equalsXMLElement() function checks to see if the XMLElement being passed in equals another XMLElement - * - * @param {XMLElement} rawElement the element to compare to - * - * @return {boolean} true if the element equals another element - */ - equalsXMLElement: function (object) { - if (object instanceof XMLElement) { - if (this.name !== object.getLocalName()) { return false; } - if (this.attributes.length !== object.getAttributeCount()) { return false; } - for (var i = 0; i < this.attributes.length; i++){ - if (! object.hasAttribute(this.attributes[i].getName(), this.attributes[i].getNamespace())) { return false; } - if (this.attributes[i].getValue() !== object.attributes[i].getValue()) { return false; } - if (this.attributes[i].getType() !== object.attributes[i].getType()) { return false; } - } - if (this.children.length !== object.getChildCount()) { return false; } - var child1, child2; - for (i = 0; i < this.children.length; i++) { - child1 = this.getChildAtIndex(i); - child2 = object.getChildAtIndex(i); - if (! child1.equalsXMLElement(child2)) { return false; } - } - return true; - } - }, - /** - * @member XMLElement - * The getContent() function returns the content of an element. If there is no such content, null is returned - * - * @return {String} the (possibly null) content - */ - getContent: function(){ - return this.content; - }, - /** - * @member XMLElement - * The getAttribute() function returns the value of an attribute - * - * @param {String} name the non-null full name of the attribute - * @param {String} namespace the namespace URI, which may be null - * @param {String} defaultValue the default value of the attribute - * - * @return {String} the value, or defaultValue if the attribute does not exist - */ - getAttribute: function (){ - var attribute; - if( arguments.length === 2 ){ - attribute = this.findAttribute(arguments[0]); - if (attribute) { - return attribute.getValue(); - } else { - return arguments[1]; - } - } else if (arguments.length === 1) { - attribute = this.findAttribute(arguments[0]); - if (attribute) { - return attribute.getValue(); - } else { - return null; - } - } else if (arguments.length === 3) { - attribute = this.findAttribute(arguments[0],arguments[1]); - if (attribute) { - return attribute.getValue(); - } else { - return arguments[2]; - } - } - }, - /** - * @member XMLElement - * The getStringAttribute() function returns the string attribute of the element - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue value is returned. - * When calling the function without the defaultValue parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return {String} the value, or defaultValue if the attribute does not exist - */ - getStringAttribute: function() { - if (arguments.length === 1) { - return this.getAttribute(arguments[0]); - } else if (arguments.length === 2){ - return this.getAttribute(arguments[0], arguments[1]); - } else { - return this.getAttribute(arguments[0], arguments[1],arguments[2]); - } - }, - /** - * @member XMLElement - * The getFloatAttribute() function returns the float attribute of the element. - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue value is returned. - * When calling the function without the defaultValue parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return {float} the value, or defaultValue if the attribute does not exist - */ - getFloatAttribute: function() { - if (arguments.length === 1 ) { - return parseFloat(this.getAttribute(arguments[0], 0)); - } else if (arguments.length === 2 ){ - return this.getAttribute(arguments[0], arguments[1]); - } else { - return this.getAttribute(arguments[0], arguments[1],arguments[2]); - } - }, - /** - * @member XMLElement - * The getIntAttribute() function returns the integer attribute of the element. - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue value is returned. - * When calling the function without the defaultValue parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return {int} the value, or defaultValue if the attribute does not exist - */ - getIntAttribute: function () { - if (arguments.length === 1) { - return this.getAttribute( arguments[0], 0 ); - } else if (arguments.length === 2) { - return this.getAttribute(arguments[0], arguments[1]); - } else { - return this.getAttribute(arguments[0], arguments[1],arguments[2]); - } - }, - /** - * @member XMLElement - * The hasChildren() function returns whether the element has children. - * - * @return {boolean} true if the element has children. - */ - hasChildren: function () { - return this.children.length > 0 ; - }, - /** - * @member XMLElement - * The addChild() function adds a child element - * - * @param {XMLElement} child the non-null child to add. - */ - addChild: function (child) { - if (child !== null) { - child.parent = this; - this.children.push(child); - } - }, - /** - * @member XMLElement - * The insertChild() function inserts a child element at the index provided - * - * @param {XMLElement} child the non-null child to add. - * @param {int} index where to put the child. - */ - insertChild: function (child, index) { - if (child) { - if ((child.getLocalName() === null) && (! this.hasChildren())) { - var lastChild = this.children[this.children.length -1]; - if (lastChild.getLocalName() === null) { - lastChild.setContent(lastChild.getContent() + child.getContent()); - return; - } - } - child.parent = this; - this.children.splice(index,0,child); - } - }, - /** - * @member XMLElement - * The getChild() returns the child XMLElement as specified by the index parameter. - * The value of the index parameter must be less than the total number of children to avoid going out of the array storing the child elements. - * When the path parameter is specified, then it will return all children that match that path. The path is a series of elements and sub-elements, separated by slashes. - * - * @param {int} index where to put the child. - * @param {String} path path to a particular element - * - * @return {XMLElement} the element - */ - getChild: function (){ - if (typeof arguments[0] === "number") { - return this.children[arguments[0]]; - } - else if (arguments[0].indexOf('/') !== -1) { // path was given - this.getChildRecursive(arguments[0].split("/"), 0); - } else { - var kid, kidName; - for (var i = 0; i < this.getChildCount(); i++) { - kid = this.getChild(i); - kidName = kid.getName(); - if (kidName !== null && kidName === arguments[0]) { - return kid; - } - } - return null; - } - }, - /** - * @member XMLElement - * The getChildren() returns all of the children as an XMLElement array. - * When the path parameter is specified, then it will return all children that match that path. - * The path is a series of elements and sub-elements, separated by slashes. - * - * @param {String} path element name or path/to/element - * - * @return {XMLElement} array of child elements that match - * - * @see XMLElement#getChildCount() - * @see XMLElement#getChild() - */ - getChildren: function(){ - if (arguments.length === 1) { - if (typeof arguments[0] === "number") { - return this.getChild( arguments[0]); - } else if (arguments[0].indexOf('/') !== -1) { // path was given - return this.getChildrenRecursive( arguments[0].split("/"), 0); - } else { - var matches = []; - var kid, kidName; - for (var i = 0; i < this.getChildCount(); i++) { - kid = this.getChild(i); - kidName = kid.getName(); - if (kidName !== null && kidName === arguments[0]) { - matches.push(kid); - } - } - return matches; - } - }else { - return this.children; - } - }, - /** - * @member XMLElement - * The getChildCount() returns the number of children for the element. - * - * @return {int} the count - * - * @see XMLElement#getChild() - * @see XMLElement#getChildren() - */ - getChildCount: function(){ - return this.children.length; - }, - /** - * @member XMLElement - * Internal helper function for getChild(). - * - * @param {String[]} items result of splitting the query on slashes - * @param {int} offset where in the items[] array we're currently looking - * - * @return {XMLElement} matching element or null if no match - */ - getChildRecursive: function (items, offset) { - var kid, kidName; - for(var i = 0; i < this.getChildCount(); i++) { - kid = this.getChild(i); - kidName = kid.getName(); - if (kidName !== null && kidName === items[offset]) { - if (offset === items.length-1) { - return kid; - } else { - offset += 1; - return kid.getChildRecursive(items, offset); - } - } - } - return null; - }, - /** - * @member XMLElement - * Internal helper function for getChildren(). - * - * @param {String[]} items result of splitting the query on slashes - * @param {int} offset where in the items[] array we're currently looking - * - * @return {XMLElement[]} matching elements or empty array if no match - */ - getChildrenRecursive: function (items, offset) { - if (offset === items.length-1) { - return this.getChildren(items[offset]); - } - var matches = this.getChildren(items[offset]); - var kidMatches; - for (var i = 0; i < matches.length; i++) { - kidMatches = matches[i].getChildrenRecursive(items, offset+1); - } - return kidMatches; - }, - /** - * @member XMLElement - * Internal helper function for parse(). - * Loops through the - * @addon - * - * @param {XMLElement} parent the parent node - * @param {XML document childNodes} elementpath the remaining nodes that need parsing - * - * @return {XMLElement} the new element and its children elements - */ - parseChildrenRecursive: function (parent , elementpath){ - var xmlelement, - xmlattribute, - tmpattrib; - if (!parent) { - this.fullName = elementpath.localName; - this.name = elementpath.nodeName; - this.content = elementpath.textContent || ""; - xmlelement = this; - } else { // a parent - xmlelement = new XMLElement(elementpath.localName, elementpath.nodeName, "", ""); - xmlelement.content = elementpath.textContent || ""; - xmlelement.parent = parent; - } - - for (var l = 0; l < elementpath.attributes.length; l++) { - tmpattrib = elementpath.attributes[l]; - xmlattribute = new XMLAttribute(tmpattrib.getname , tmpattrib.nodeName, tmpattrib.namespaceURI , tmpattrib.nodeValue , tmpattrib.nodeType); - xmlelement.attributes.push(xmlattribute); - } - - for (var node in elementpath.childNodes){ - if(elementpath.childNodes[node].nodeType === 1) { //ELEMENT_NODE type - xmlelement.children.push( xmlelement.parseChildrenRecursive(xmlelement, elementpath.childNodes[node])); - } - } - return xmlelement; - }, - /** - * @member XMLElement - * The isLeaf() function returns whether the element is a leaf element. - * - * @return {boolean} true if the element has no children. - */ - isLeaf: function(){ - return !this.hasChildren(); - }, - /** - * @member XMLElement - * The listChildren() function put the names of all children into an array. Same as looping through - * each child and calling getName() on each XMLElement. - * - * @return {String[]} a list of element names. - */ - listChildren: function() { - var arr = []; - for (var i = 0; i < this.children.length; i++) { - arr.push( this.getChild(i).getName()); - } - return arr; - }, - /** - * @member XMLElement - * The removeAttribute() function removes an attribute - * - * @param {String} name the non-null name of the attribute. - * @param {String} namespace the namespace URI of the attribute, which may be null. - */ - removeAttribute: function (name , namespace) { - this.namespace = namespace || ""; - for (var i = 0; i < this.attributes.length; i++){ - if (this.attributes[i].getName() === name && this.attributes[i].getNamespace() === this.namespace) { - this.attributes.splice(i, 1); - } - } - }, - /** - * @member XMLElement - * The removeChild() removes a child element. - * - * @param {XMLElement} child the the non-null child to be renoved - */ - removeChild: function(child) { - if (child) { - for (var i = 0; i < this.children.length; i++) { - if (this.children[i].equalsXMLElement(child)) { - this.children.splice(i, 1); - } - } - } - }, - /** - * @member XMLElement - * The removeChildAtIndex() removes the child located at a certain index - * - * @param {int} index the index of the child, where the first child has index 0 - */ - removeChildAtIndex: function(index) { - if (this.children.length > index) { //make sure its not outofbounds - this.children.splice(index, 1); - } - }, - /** - * @member XMLElement - * The findAttribute() function searches an attribute - * - * @param {String} name fullName the non-null full name of the attribute - * @param {String} namespace the name space, which may be null - * - * @return {XMLAttribute} the attribute, or null if the attribute does not exist. - */ - findAttribute: function (name, namespace) { - this.namespace = namespace || ""; - for (var i = 0; i < this.attributes.length; i++ ) { - if (this.attributes[i].getName() === name && this.attributes[i].getNamespace() === this.namespace) { - return this.attributes[i]; - } - } - }, - /** - * @member XMLElement - * The setAttribute() function sets an attribute. - * - * @param {String} name the non-null full name of the attribute - * @param {String} namespace the non-null value of the attribute - */ - setAttribute: function() { - var attr; - if (arguments.length === 3) { - var index = arguments[0].indexOf(':'); - var name = arguments[0].substring(index + 1); - attr = this.findAttribute( name, arguments[1] ); - if (attr) { - attr.setValue(arguments[2]); - } else { - attr = new XMLAttribute(arguments[0], name, arguments[1], arguments[2], "CDATA"); - this.attributes.push(attr); - } - } else { - attr = this.findAttribute(arguments[0]); - if (attr) { - attr.setValue(arguments[1]); - } else { - attr = new XMLAttribute(arguments[0], arguments[0], null, arguments[1], "CDATA"); - this.attributes.push(attr); - } - } - }, - /** - * @member XMLElement - * The setContent() function sets the #PCDATA content. It is an error to call this method with a - * non-null value if there are child objects. - * - * @param {String} content the (possibly null) content - */ - setContent: function(content) { - this.content = content; - }, - /** - * @member XMLElement - * The setName() function sets the full name. This method also sets the short name and clears the - * namespace URI. - * - * @param {String} name the non-null name - * @param {String} namespace the namespace URI, which may be null. - */ - setName: function() { - if (arguments.length === 1) { - this.name = arguments[0]; - this.fullName = arguments[0]; - this.namespace = null; - } else { - var index = arguments[0].indexOf(':'); - if ((arguments[1] === null) || (index < 0)) { - this.name = arguments[0]; - } else { - this.name = arguments[0].substring(index + 1); - } - this.fullName = arguments[0]; - this.namespace = arguments[1]; - } - }, - /** - * @member XMLElement - * The getName() function returns the full name (i.e. the name including an eventual namespace - * prefix) of the element. - * - * @return {String} the name, or null if the element only contains #PCDATA. - */ - getName: function() { - return this.fullName; - }, - getLocalName: function() { - return this.name; - }, - getAttributeCount: function() { - return this.attributes.length; - } - }; - - - //////////////////////////////////////////////////////////////////////////// - // 2D Matrix - //////////////////////////////////////////////////////////////////////////// - /** - * Helper function for printMatrix(). Finds the largest scalar - * in the matrix, then number of digits left of the decimal. - * Call from PMatrix2D and PMatrix3D's print() function. - */ - var printMatrixHelper = function printMatrixHelper(elements) { - var big = 0; - for (var i = 0; i < elements.length; i++) { - if (i !== 0) { - big = Math.max(big, Math.abs(elements[i])); - } else { - big = Math.abs(elements[i]); - } - } - - var digits = (big + "").indexOf("."); - if (digits === 0) { - digits = 1; - } else if (digits === -1) { - digits = (big + "").length; - } - - return digits; - }; - /** - * PMatrix2D is a 3x2 affine matrix implementation. The constructor accepts another PMatrix2D or a list of six float elements. - * If no parameters are provided the matrix is set to the identity matrix. - * - * @param {PMatrix2D} matrix the initial matrix to set to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fifth element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - var PMatrix2D = p.PMatrix2D = function() { - if (arguments.length === 0) { - this.reset(); - } else if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - this.set(arguments[0].array()); - } else if (arguments.length === 6) { - this.set(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); - } - }; - /** - * PMatrix2D methods - */ - PMatrix2D.prototype = { - /** - * @member PMatrix2D - * The set() function sets the matrix elements. The function accepts either another PMatrix2D, an array of elements, or a list of six floats. - * - * @param {PMatrix2D} matrix the matrix to set this matrix to - * @param {float[]} elements an array of elements to set this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fith element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - set: function() { - if (arguments.length === 6) { - var a = arguments; - this.set([a[0], a[1], a[2], - a[3], a[4], a[5]]); - } else if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - this.elements = arguments[0].array(); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - this.elements = arguments[0].slice(); - } - }, - /** - * @member PMatrix2D - * The get() function returns a copy of this PMatrix2D. - * - * @return {PMatrix2D} a copy of this PMatrix2D - */ - get: function() { - var outgoing = new PMatrix2D(); - outgoing.set(this.elements); - return outgoing; - }, - /** - * @member PMatrix2D - * The reset() function sets this PMatrix2D to the identity matrix. - */ - reset: function() { - this.set([1, 0, 0, 0, 1, 0]); - }, - /** - * @member PMatrix2D - * The array() function returns a copy of the element values. - * @addon - * - * @return {float[]} returns a copy of the element values - */ - array: function array() { - return this.elements.slice(); - }, - /** - * @member PMatrix2D - * The translate() function translates this matrix by moving the current coordinates to the location specified by tx and ty. - * - * @param {float} tx the x-axis coordinate to move to - * @param {float} ty the y-axis coordinate to move to - */ - translate: function(tx, ty) { - this.elements[2] = tx * this.elements[0] + ty * this.elements[1] + this.elements[2]; - this.elements[5] = tx * this.elements[3] + ty * this.elements[4] + this.elements[5]; - }, - /** - * @member PMatrix2D - * The transpose() function is not used in processingjs. - */ - transpose: function() { - // Does nothing in Processing. - }, - /** - * @member PMatrix2D - * The mult() function multiplied this matrix. - * If two array elements are passed in the function will multiply a two element vector against this matrix. - * If target is null or not length four, a new float array will be returned. - * The values for vec and target can be the same (though that's less efficient). - * If two PVectors are passed in the function multiply the x and y coordinates of a PVector against this matrix. - * - * @param {PVector} source, target the PVectors used to multiply this matrix - * @param {float[]} source, target the arrays used to multiply this matrix - * - * @return {PVector|float[]} returns a PVector or an array representing the new matrix - */ - mult: function(source, target) { - var x, y; - if (source instanceof PVector) { - x = source.x; - y = source.y; - if (!target) { - target = new PVector(); - } - } else if (source instanceof Array) { - x = source[0]; - y = source[1]; - if (!target) { - target = []; - } - } - if (target instanceof Array) { - target[0] = this.elements[0] * x + this.elements[1] * y + this.elements[2]; - target[1] = this.elements[3] * x + this.elements[4] * y + this.elements[5]; - } else if (target instanceof PVector) { - target.x = this.elements[0] * x + this.elements[1] * y + this.elements[2]; - target.y = this.elements[3] * x + this.elements[4] * y + this.elements[5]; - target.z = 0; - } - return target; - }, - /** - * @member PMatrix2D - * The multX() function calculates the x component of a vector from a transformation. - * - * @param {float} x the x component of the vector being transformed - * @param {float} y the y component of the vector being transformed - * - * @return {float} returnes the result of the calculation - */ - multX: function(x, y) { - return (x * this.elements[0] + y * this.elements[1] + this.elements[2]); - }, - /** - * @member PMatrix2D - * The multY() function calculates the y component of a vector from a transformation. - * - * @param {float} x the x component of the vector being transformed - * @param {float} y the y component of the vector being transformed - * - * @return {float} returnes the result of the calculation - */ - multY: function(x, y) { - return (x * this.elements[3] + y * this.elements[4] + this.elements[5]); - }, - /** - * @member PMatrix2D - * The skewX() function skews the matrix along the x-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewX: function(angle) { - this.apply(1, 0, 1, angle, 0, 0); - }, - /** - * @member PMatrix2D - * The skewY() function skews the matrix along the y-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewY: function(angle) { - this.apply(1, 0, 1, 0, angle, 0); - }, - /** - * @member PMatrix2D - * The determinant() function calvculates the determinant of this matrix. - * - * @return {float} the determinant of the matrix - */ - determinant: function() { - return (this.elements[0] * this.elements[4] - this.elements[1] * this.elements[3]); - }, - /** - * @member PMatrix2D - * The invert() function inverts this matrix - * - * @return {boolean} true if successful - */ - invert: function() { - var d = this.determinant(); - if (Math.abs( d ) > PConstants.MIN_INT) { - var old00 = this.elements[0]; - var old01 = this.elements[1]; - var old02 = this.elements[2]; - var old10 = this.elements[3]; - var old11 = this.elements[4]; - var old12 = this.elements[5]; - this.elements[0] = old11 / d; - this.elements[3] = -old10 / d; - this.elements[1] = -old01 / d; - this.elements[4] = old00 / d; - this.elements[2] = (old01 * old12 - old11 * old02) / d; - this.elements[5] = (old10 * old02 - old00 * old12) / d; - return true; - } - return false; - }, - /** - * @member PMatrix2D - * The scale() function increases or decreases the size of a shape by expanding and contracting vertices. When only one parameter is specified scale will occur in all dimensions. - * This is equivalent to a two parameter call. - * - * @param {float} sx the amount to scale on the x-axis - * @param {float} sy the amount to scale on the y-axis - */ - scale: function(sx, sy) { - if (sx && !sy) { - sy = sx; - } - if (sx && sy) { - this.elements[0] *= sx; - this.elements[1] *= sy; - this.elements[3] *= sx; - this.elements[4] *= sy; - } - }, - /** - * @member PMatrix2D - * The apply() function multiplies the current matrix by the one specified through the parameters. Note that either a PMatrix2D or a list of floats can be passed in. - * - * @param {PMatrix2D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fith element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - apply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - source = arguments[0].array(); - } else if (arguments.length === 6) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - - var result = [0, 0, this.elements[2], - 0, 0, this.elements[5]]; - var e = 0; - for (var row = 0; row < 2; row++) { - for (var col = 0; col < 3; col++, e++) { - result[e] += this.elements[row * 3 + 0] * source[col + 0] + - this.elements[row * 3 + 1] * source[col + 3]; - } - } - this.elements = result.slice(); - }, - /** - * @member PMatrix2D - * The preApply() function applies another matrix to the left of this one. Note that either a PMatrix2D or elements of a matrix can be passed in. - * - * @param {PMatrix2D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fith element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - preApply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - source = arguments[0].array(); - } else if (arguments.length === 6) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - var result = [0, 0, source[2], - 0, 0, source[5]]; - result[2] = source[2] + this.elements[2] * source[0] + this.elements[5] * source[1]; - result[5] = source[5] + this.elements[2] * source[3] + this.elements[5] * source[4]; - result[0] = this.elements[0] * source[0] + this.elements[3] * source[1]; - result[3] = this.elements[0] * source[3] + this.elements[3] * source[4]; - result[1] = this.elements[1] * source[0] + this.elements[4] * source[1]; - result[4] = this.elements[1] * source[3] + this.elements[4] * source[4]; - this.elements = result.slice(); - }, - /** - * @member PMatrix2D - * The rotate() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotate: function(angle) { - var c = Math.cos(angle); - var s = Math.sin(angle); - var temp1 = this.elements[0]; - var temp2 = this.elements[1]; - this.elements[0] = c * temp1 + s * temp2; - this.elements[1] = -s * temp1 + c * temp2; - temp1 = this.elements[3]; - temp2 = this.elements[4]; - this.elements[3] = c * temp1 + s * temp2; - this.elements[4] = -s * temp1 + c * temp2; - }, - /** - * @member PMatrix2D - * The rotateZ() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateZ: function(angle) { - this.rotate(angle); - }, - /** - * @member PMatrix2D - * The print() function prints out the elements of this matrix - */ - print: function() { - var digits = printMatrixHelper(this.elements); - var output = "" + p.nfs(this.elements[0], digits, 4) + " " + - p.nfs(this.elements[1], digits, 4) + " " + - p.nfs(this.elements[2], digits, 4) + "\n" + - p.nfs(this.elements[3], digits, 4) + " " + - p.nfs(this.elements[4], digits, 4) + " " + - p.nfs(this.elements[5], digits, 4) + "\n\n"; - p.println(output); - } - }; - - /** - * PMatrix3D is a 4x4 matrix implementation. The constructor accepts another PMatrix3D or a list of six or sixteen float elements. - * If no parameters are provided the matrix is set to the identity matrix. - */ - var PMatrix3D = p.PMatrix3D = function PMatrix3D() { - // When a matrix is created, it is set to an identity matrix - this.reset(); - }; - /** - * PMatrix3D methods - */ - PMatrix3D.prototype = { - /** - * @member PMatrix2D - * The set() function sets the matrix elements. The function accepts either another PMatrix3D, an array of elements, or a list of six or sixteen floats. - * - * @param {PMatrix3D} matrix the initial matrix to set to - * @param {float[]} elements an array of elements to set this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - */ - set: function() { - if (arguments.length === 16) { - this.elements = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof PMatrix3D) { - this.elements = arguments[0].array(); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - this.elements = arguments[0].slice(); - } - }, - /** - * @member PMatrix3D - * The get() function returns a copy of this PMatrix3D. - * - * @return {PMatrix3D} a copy of this PMatrix3D - */ - get: function() { - var outgoing = new PMatrix3D(); - outgoing.set(this.elements); - return outgoing; - }, - /** - * @member PMatrix3D - * The reset() function sets this PMatrix3D to the identity matrix. - */ - reset: function() { - this.set([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The array() function returns a copy of the element values. - * @addon - * - * @return {float[]} returns a copy of the element values - */ - array: function array() { - return this.elements.slice(); - }, - /** - * @member PMatrix3D - * The translate() function translates this matrix by moving the current coordinates to the location specified by tx, ty, and tz. - * - * @param {float} tx the x-axis coordinate to move to - * @param {float} ty the y-axis coordinate to move to - * @param {float} tz the z-axis coordinate to move to - */ - translate: function(tx, ty, tz) { - if (tz === undef) { - tz = 0; - } - - this.elements[3] += tx * this.elements[0] + ty * this.elements[1] + tz * this.elements[2]; - this.elements[7] += tx * this.elements[4] + ty * this.elements[5] + tz * this.elements[6]; - this.elements[11] += tx * this.elements[8] + ty * this.elements[9] + tz * this.elements[10]; - this.elements[15] += tx * this.elements[12] + ty * this.elements[13] + tz * this.elements[14]; - }, - /** - * @member PMatrix2D - * The transpose() function transpose this matrix. - */ - transpose: function() { - var temp = this.elements.slice(); - this.elements[0] = temp[0]; - this.elements[1] = temp[4]; - this.elements[2] = temp[8]; - this.elements[3] = temp[12]; - this.elements[4] = temp[1]; - this.elements[5] = temp[5]; - this.elements[6] = temp[9]; - this.elements[7] = temp[13]; - this.elements[8] = temp[2]; - this.elements[9] = temp[6]; - this.elements[10] = temp[10]; - this.elements[11] = temp[14]; - this.elements[12] = temp[3]; - this.elements[13] = temp[7]; - this.elements[14] = temp[11]; - this.elements[15] = temp[15]; - }, - /** - * @member PMatrix3D - * The mult() function multiplied this matrix. - * If two array elements are passed in the function will multiply a two element vector against this matrix. - * If target is null or not length four, a new float array will be returned. - * The values for vec and target can be the same (though that's less efficient). - * If two PVectors are passed in the function multiply the x and y coordinates of a PVector against this matrix. - * - * @param {PVector} source, target the PVectors used to multiply this matrix - * @param {float[]} source, target the arrays used to multiply this matrix - * - * @return {PVector|float[]} returns a PVector or an array representing the new matrix - */ - mult: function(source, target) { - var x, y, z, w; - if (source instanceof PVector) { - x = source.x; - y = source.y; - z = source.z; - w = 1; - if (!target) { - target = new PVector(); - } - } else if (source instanceof Array) { - x = source[0]; - y = source[1]; - z = source[2]; - w = source[3] || 1; - - if (!target || target.length !== 3 && target.length !== 4) { - target = [0, 0, 0]; - } - } - - if (target instanceof Array) { - if (target.length === 3) { - target[0] = this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3]; - target[1] = this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7]; - target[2] = this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11]; - } else if (target.length === 4) { - target[0] = this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3] * w; - target[1] = this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7] * w; - target[2] = this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11] * w; - target[3] = this.elements[12] * x + this.elements[13] * y + this.elements[14] * z + this.elements[15] * w; - } - } - if (target instanceof PVector) { - target.x = this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3]; - target.y = this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7]; - target.z = this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11]; - } - return target; - }, - /** - * @member PMatrix3D - * The preApply() function applies another matrix to the left of this one. Note that either a PMatrix3D or elements of a matrix can be passed in. - * - * @param {PMatrix3D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - */ - preApply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix3D) { - source = arguments[0].array(); - } else if (arguments.length === 16) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - - var result = [0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0]; - var e = 0; - for (var row = 0; row < 4; row++) { - for (var col = 0; col < 4; col++, e++) { - result[e] += this.elements[col + 0] * source[row * 4 + 0] + this.elements[col + 4] * - source[row * 4 + 1] + this.elements[col + 8] * source[row * 4 + 2] + - this.elements[col + 12] * source[row * 4 + 3]; - } - } - this.elements = result.slice(); - }, - /** - * @member PMatrix3D - * The apply() function multiplies the current matrix by the one specified through the parameters. Note that either a PMatrix3D or a list of floats can be passed in. - * - * @param {PMatrix3D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - */ - apply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix3D) { - source = arguments[0].array(); - } else if (arguments.length === 16) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - - var result = [0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0]; - var e = 0; - for (var row = 0; row < 4; row++) { - for (var col = 0; col < 4; col++, e++) { - result[e] += this.elements[row * 4 + 0] * source[col + 0] + this.elements[row * 4 + 1] * - source[col + 4] + this.elements[row * 4 + 2] * source[col + 8] + - this.elements[row * 4 + 3] * source[col + 12]; - } - } - this.elements = result.slice(); - }, - /** - * @member PMatrix3D - * The rotate() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotate: function(angle, v0, v1, v2) { - if (!v1) { - this.rotateZ(angle); - } else { - // TODO should make sure this vector is normalized - var c = p.cos(angle); - var s = p.sin(angle); - var t = 1.0 - c; - - this.apply((t * v0 * v0) + c, - (t * v0 * v1) - (s * v2), - (t * v0 * v2) + (s * v1), - 0, - (t * v0 * v1) + (s * v2), - (t * v1 * v1) + c, - (t * v1 * v2) - (s * v0), - 0, - (t * v0 * v2) - (s * v1), - (t * v1 * v2) + (s * v0), - (t * v2 * v2) + c, - 0, 0, 0, 0, 1); - } - }, - /** - * @member PMatrix2D - * The invApply() function applies the inverted matrix to this matrix. - * - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - * - * @return {boolean} returns true if the operation was successful. - */ - invApply: function() { - if (inverseCopy === undef) { - inverseCopy = new PMatrix3D(); - } - var a = arguments; - inverseCopy.set(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], - a[9], a[10], a[11], a[12], a[13], a[14], a[15]); - - if (!inverseCopy.invert()) { - return false; - } - this.preApply(inverseCopy); - return true; - }, - /** - * @member PMatrix3D - * The rotateZ() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateX: function(angle) { - var c = p.cos(angle); - var s = p.sin(angle); - this.apply([1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The rotateY() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateY: function(angle) { - var c = p.cos(angle); - var s = p.sin(angle); - this.apply([c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The rotateZ() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateZ: function(angle) { - var c = Math.cos(angle); - var s = Math.sin(angle); - this.apply([c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The scale() function increases or decreases the size of a matrix by expanding and contracting vertices. When only one parameter is specified scale will occur in all dimensions. - * This is equivalent to a three parameter call. - * - * @param {float} sx the amount to scale on the x-axis - * @param {float} sy the amount to scale on the y-axis - * @param {float} sz the amount to scale on the z-axis - */ - scale: function(sx, sy, sz) { - if (sx && !sy && !sz) { - sy = sz = sx; - } else if (sx && sy && !sz) { - sz = 1; - } - - if (sx && sy && sz) { - this.elements[0] *= sx; - this.elements[1] *= sy; - this.elements[2] *= sz; - this.elements[4] *= sx; - this.elements[5] *= sy; - this.elements[6] *= sz; - this.elements[8] *= sx; - this.elements[9] *= sy; - this.elements[10] *= sz; - this.elements[12] *= sx; - this.elements[13] *= sy; - this.elements[14] *= sz; - } - }, - /** - * @member PMatrix3D - * The skewX() function skews the matrix along the x-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewX: function(angle) { - var t = Math.tan(angle); - this.apply(1, t, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); - }, - /** - * @member PMatrix3D - * The skewY() function skews the matrix along the y-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewY: function(angle) { - var t = Math.tan(angle); - this.apply(1, 0, 0, 0, t, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); - }, - multX: function(x, y, z, w) { - if (!z) { - return this.elements[0] * x + this.elements[1] * y + this.elements[3]; - } else if (!w) { - return this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3]; - } else { - return this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3] * w; - } - }, - multY: function(x, y, z, w) { - if (!z) { - return this.elements[4] * x + this.elements[5] * y + this.elements[7]; - } else if (!w) { - return this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7]; - } else { - return this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7] * w; - } - }, - multZ: function(x, y, z, w) { - if (!w) { - return this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11]; - } else { - return this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11] * w; - } - }, - multW: function(x, y, z, w) { - if (!w) { - return this.elements[12] * x + this.elements[13] * y + this.elements[14] * z + this.elements[15]; - } else { - return this.elements[12] * x + this.elements[13] * y + this.elements[14] * z + this.elements[15] * w; - } - }, - /** - * @member PMatrix3D - * The invert() function inverts this matrix - * - * @return {boolean} true if successful - */ - invert: function() { - var fA0 = this.elements[0] * this.elements[5] - this.elements[1] * this.elements[4]; - var fA1 = this.elements[0] * this.elements[6] - this.elements[2] * this.elements[4]; - var fA2 = this.elements[0] * this.elements[7] - this.elements[3] * this.elements[4]; - var fA3 = this.elements[1] * this.elements[6] - this.elements[2] * this.elements[5]; - var fA4 = this.elements[1] * this.elements[7] - this.elements[3] * this.elements[5]; - var fA5 = this.elements[2] * this.elements[7] - this.elements[3] * this.elements[6]; - var fB0 = this.elements[8] * this.elements[13] - this.elements[9] * this.elements[12]; - var fB1 = this.elements[8] * this.elements[14] - this.elements[10] * this.elements[12]; - var fB2 = this.elements[8] * this.elements[15] - this.elements[11] * this.elements[12]; - var fB3 = this.elements[9] * this.elements[14] - this.elements[10] * this.elements[13]; - var fB4 = this.elements[9] * this.elements[15] - this.elements[11] * this.elements[13]; - var fB5 = this.elements[10] * this.elements[15] - this.elements[11] * this.elements[14]; - - // Determinant - var fDet = fA0 * fB5 - fA1 * fB4 + fA2 * fB3 + fA3 * fB2 - fA4 * fB1 + fA5 * fB0; - - // Account for a very small value - // return false if not successful. - if (Math.abs(fDet) <= 1e-9) { - return false; - } - - var kInv = []; - kInv[0] = +this.elements[5] * fB5 - this.elements[6] * fB4 + this.elements[7] * fB3; - kInv[4] = -this.elements[4] * fB5 + this.elements[6] * fB2 - this.elements[7] * fB1; - kInv[8] = +this.elements[4] * fB4 - this.elements[5] * fB2 + this.elements[7] * fB0; - kInv[12] = -this.elements[4] * fB3 + this.elements[5] * fB1 - this.elements[6] * fB0; - kInv[1] = -this.elements[1] * fB5 + this.elements[2] * fB4 - this.elements[3] * fB3; - kInv[5] = +this.elements[0] * fB5 - this.elements[2] * fB2 + this.elements[3] * fB1; - kInv[9] = -this.elements[0] * fB4 + this.elements[1] * fB2 - this.elements[3] * fB0; - kInv[13] = +this.elements[0] * fB3 - this.elements[1] * fB1 + this.elements[2] * fB0; - kInv[2] = +this.elements[13] * fA5 - this.elements[14] * fA4 + this.elements[15] * fA3; - kInv[6] = -this.elements[12] * fA5 + this.elements[14] * fA2 - this.elements[15] * fA1; - kInv[10] = +this.elements[12] * fA4 - this.elements[13] * fA2 + this.elements[15] * fA0; - kInv[14] = -this.elements[12] * fA3 + this.elements[13] * fA1 - this.elements[14] * fA0; - kInv[3] = -this.elements[9] * fA5 + this.elements[10] * fA4 - this.elements[11] * fA3; - kInv[7] = +this.elements[8] * fA5 - this.elements[10] * fA2 + this.elements[11] * fA1; - kInv[11] = -this.elements[8] * fA4 + this.elements[9] * fA2 - this.elements[11] * fA0; - kInv[15] = +this.elements[8] * fA3 - this.elements[9] * fA1 + this.elements[10] * fA0; - - // Inverse using Determinant - var fInvDet = 1.0 / fDet; - kInv[0] *= fInvDet; - kInv[1] *= fInvDet; - kInv[2] *= fInvDet; - kInv[3] *= fInvDet; - kInv[4] *= fInvDet; - kInv[5] *= fInvDet; - kInv[6] *= fInvDet; - kInv[7] *= fInvDet; - kInv[8] *= fInvDet; - kInv[9] *= fInvDet; - kInv[10] *= fInvDet; - kInv[11] *= fInvDet; - kInv[12] *= fInvDet; - kInv[13] *= fInvDet; - kInv[14] *= fInvDet; - kInv[15] *= fInvDet; - - this.elements = kInv.slice(); - return true; - }, - toString: function() { - var str = ""; - for (var i = 0; i < 15; i++) { - str += this.elements[i] + ", "; - } - str += this.elements[15]; - return str; - }, - /** - * @member PMatrix3D - * The print() function prints out the elements of this matrix - */ - print: function() { - var digits = printMatrixHelper(this.elements); - - var output = "" + p.nfs(this.elements[0], digits, 4) + " " + p.nfs(this.elements[1], digits, 4) + - " " + p.nfs(this.elements[2], digits, 4) + " " + p.nfs(this.elements[3], digits, 4) + - "\n" + p.nfs(this.elements[4], digits, 4) + " " + p.nfs(this.elements[5], digits, 4) + - " " + p.nfs(this.elements[6], digits, 4) + " " + p.nfs(this.elements[7], digits, 4) + - "\n" + p.nfs(this.elements[8], digits, 4) + " " + p.nfs(this.elements[9], digits, 4) + - " " + p.nfs(this.elements[10], digits, 4) + " " + p.nfs(this.elements[11], digits, 4) + - "\n" + p.nfs(this.elements[12], digits, 4) + " " + p.nfs(this.elements[13], digits, 4) + - " " + p.nfs(this.elements[14], digits, 4) + " " + p.nfs(this.elements[15], digits, 4) + "\n\n"; - p.println(output); - }, - invTranslate: function(tx, ty, tz) { - this.preApply(1, 0, 0, -tx, 0, 1, 0, -ty, 0, 0, 1, -tz, 0, 0, 0, 1); - }, - invRotateX: function(angle) { - var c = Math.cos(-angle); - var s = Math.sin(-angle); - this.preApply([1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1]); - }, - invRotateY: function(angle) { - var c = Math.cos(-angle); - var s = Math.sin(-angle); - this.preApply([c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1]); - }, - invRotateZ: function(angle) { - var c = Math.cos(-angle); - var s = Math.sin(-angle); - this.preApply([c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }, - invScale: function(x, y, z) { - this.preApply([1 / x, 0, 0, 0, 0, 1 / y, 0, 0, 0, 0, 1 / z, 0, 0, 0, 0, 1]); - } - }; - - /** - * @private - * The matrix stack stores the transformations and translations that occur within the space. - */ - var PMatrixStack = p.PMatrixStack = function PMatrixStack() { - this.matrixStack = []; - }; - - /** - * @member PMatrixStack - * load pushes the matrix given in the function into the stack - * - * @param {Object | Array} matrix the matrix to be pushed into the stack - */ - PMatrixStack.prototype.load = function load() { - var tmpMatrix; - if (p.use3DContext) { - tmpMatrix = new PMatrix3D(); - } else { - tmpMatrix = new PMatrix2D(); - } - - if (arguments.length === 1) { - tmpMatrix.set(arguments[0]); - } else { - tmpMatrix.set(arguments); - } - this.matrixStack.push(tmpMatrix); - }; - - /** - * @member PMatrixStack - * push adds a duplicate of the top of the stack onto the stack - uses the peek function - */ - PMatrixStack.prototype.push = function push() { - this.matrixStack.push(this.peek()); - }; - - /** - * @member PMatrixStack - * pop removes returns the matrix at the top of the stack - * - * @returns {Object} the matrix at the top of the stack - */ - PMatrixStack.prototype.pop = function pop() { - return this.matrixStack.pop(); - }; - - /** - * @member PMatrixStack - * peek returns but doesn't remove the matrix at the top of the stack - * - * @returns {Object} the matrix at the top of the stack - */ - PMatrixStack.prototype.peek = function peek() { - var tmpMatrix; - if (p.use3DContext) { - tmpMatrix = new PMatrix3D(); - } else { - tmpMatrix = new PMatrix2D(); - } - - tmpMatrix.set(this.matrixStack[this.matrixStack.length - 1]); - return tmpMatrix; - }; - - /** - * @member PMatrixStack - * this function multiplies the matrix at the top of the stack with the matrix given as a parameter - * - * @param {Object | Array} matrix the matrix to be multiplied into the stack - */ - PMatrixStack.prototype.mult = function mult(matrix) { - this.matrixStack[this.matrixStack.length - 1].apply(matrix); - }; - - //////////////////////////////////////////////////////////////////////////// - // Array handling - //////////////////////////////////////////////////////////////////////////// - - /** - * The split() function breaks a string into pieces using a character or string - * as the divider. The delim parameter specifies the character or characters that - * mark the boundaries between each piece. A String[] array is returned that contains - * each of the pieces. - * If the result is a set of numbers, you can convert the String[] array to to a float[] - * or int[] array using the datatype conversion functions int() and float() (see example above). - * The splitTokens() function works in a similar fashion, except that it splits using a range - * of characters instead of a specific character or sequence. - * - * @param {String} str the String to be split - * @param {String} delim the character or String used to separate the data - * - * @returns {string[]} The new string array - * - * @see splitTokens - * @see join - * @see trim - */ - p.split = function(str, delim) { - return str.split(delim); - }; - - /** - * The splitTokens() function splits a String at one or many character "tokens." The tokens - * parameter specifies the character or characters to be used as a boundary. - * If no tokens character is specified, any whitespace character is used to split. - * Whitespace characters include tab (\t), line feed (\n), carriage return (\r), form - * feed (\f), and space. To convert a String to an array of integers or floats, use the - * datatype conversion functions int() and float() to convert the array of Strings. - * - * @param {String} str the String to be split - * @param {Char[]} tokens list of individual characters that will be used as separators - * - * @returns {string[]} The new string array - * - * @see split - * @see join - * @see trim - */ - p.splitTokens = function(str, tokens) { - if (arguments.length === 1) { - tokens = "\n\t\r\f "; - } - - tokens = "[" + tokens + "]"; - - var ary = []; - var index = 0; - var pos = str.search(tokens); - - while (pos >= 0) { - if (pos === 0) { - str = str.substring(1); - } else { - ary[index] = str.substring(0, pos); - index++; - str = str.substring(pos); - } - pos = str.search(tokens); - } - - if (str.length > 0) { - ary[index] = str; - } - - if (ary.length === 0) { - ary = undef; - } - - return ary; - }; - - /** - * Expands an array by one element and adds data to the new position. The datatype of - * the element parameter must be the same as the datatype of the array. - * When using an array of objects, the data returned from the function must be cast to - * the object array's data type. For example: SomeClass[] items = (SomeClass[]) - * append(originalArray, element). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array boolean[], - * byte[], char[], int[], float[], or String[], or an array of objects - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} element new data for the array - * - * @returns Array (the same datatype as the input) - * - * @see shorten - * @see expand - */ - p.append = function(array, element) { - array[array.length] = element; - return array; - }; - - /** - * Concatenates two arrays. For example, concatenating the array { 1, 2, 3 } and the - * array { 4, 5, 6 } yields { 1, 2, 3, 4, 5, 6 }. Both parameters must be arrays of the - * same datatype. - * When using an array of objects, the data returned from the function must be cast to the - * object array's data type. For example: SomeClass[] items = (SomeClass[]) concat(array1, array2). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array1 boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array2 boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * - * @returns Array (the same datatype as the input) - * - * @see splice - */ - p.concat = function(array1, array2) { - return array1.concat(array2); - }; - - /** - * Sorts an array of numbers from smallest to largest and puts an array of - * words in alphabetical order. The original array is not modified, a - * re-ordered array is returned. The count parameter states the number of - * elements to sort. For example if there are 12 elements in an array and - * if count is the value 5, only the first five elements on the array will - * be sorted. Alphabetical ordering is case insensitive. - * - * @param {String[] | int[] | float[]} array Array of elements to sort - * @param {int} numElem Number of elements to sort - * - * @returns {String[] | int[] | float[]} Array (same datatype as the input) - * - * @see reverse - */ - p.sort = function(array, numElem) { - var ret = []; - - // depending on the type used (int, float) or string - // we'll need to use a different compare function - if (array.length > 0) { - // copy since we need to return another array - var elemsToCopy = numElem > 0 ? numElem : array.length; - for (var i = 0; i < elemsToCopy; i++) { - ret.push(array[i]); - } - if (typeof array[0] === "string") { - ret.sort(); - } - // int or float - else { - ret.sort(function(a, b) { - return a - b; - }); - } - - // copy on the rest of the elements that were not sorted in case the user - // only wanted a subset of an array to be sorted. - if (numElem > 0) { - for (var j = ret.length; j < array.length; j++) { - ret.push(array[j]); - } - } - } - return ret; - }; - - /** - * Inserts a value or array of values into an existing array. The first two parameters must - * be of the same datatype. The array parameter defines the array which will be modified - * and the second parameter defines the data which will be inserted. When using an array - * of objects, the data returned from the function must be cast to the object array's data - * type. For example: SomeClass[] items = (SomeClass[]) splice(array1, array2, index). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * @param {boolean|byte|char|int|float|String|boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} - * value boolean, byte, char, int, float, String, boolean[], byte[], char[], int[], - * float[], String[], or other Object: value or an array of objects to be spliced in - * @param {int} index position in the array from which to insert data - * - * @returns Array (the same datatype as the input) - * - * @see contract - * @see subset - */ - p.splice = function(array, value, index) { - - // Trying to splice an empty array into "array" in P5 won't do - // anything, just return the original. - if(value.length === 0) - { - return array; - } - - // If the second argument was an array, we'll need to iterate over all - // the "value" elements and add one by one because - // array.splice(index, 0, value); - // would create a multi-dimensional array which isn't what we want. - if(value instanceof Array) { - for(var i = 0, j = index; i < value.length; j++,i++) { - array.splice(j, 0, value[i]); - } - } else { - array.splice(index, 0, value); - } - - return array; - }; - - /** - * Extracts an array of elements from an existing array. The array parameter defines the - * array from which the elements will be copied and the offset and length parameters determine - * which elements to extract. If no length is given, elements will be extracted from the offset - * to the end of the array. When specifying the offset remember the first array element is 0. - * This function does not change the source array. - * When using an array of objects, the data returned from the function must be cast to the - * object array's data type. - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * @param {int} offset position to begin - * @param {int} length number of values to extract - * - * @returns Array (the same datatype as the input) - * - * @see splice - */ - p.subset = function(array, offset, length) { - if (arguments.length === 2) { - return array.slice(offset, array.length - offset); - } else if (arguments.length === 3) { - return array.slice(offset, offset + length); - } - }; - - /** - * Combines an array of Strings into one String, each separated by the character(s) used for - * the separator parameter. To join arrays of ints or floats, it's necessary to first convert - * them to strings using nf() or nfs(). - * - * @param {Array} array array of Strings - * @param {char|String} separator char or String to be placed between each item - * - * @returns {String} The combined string - * - * @see split - * @see trim - * @see nf - * @see nfs - */ - p.join = function(array, seperator) { - return array.join(seperator); - }; - - /** - * Decreases an array by one element and returns the shortened array. When using an - * array of objects, the data returned from the function must be cast to the object array's - * data type. For example: SomeClass[] items = (SomeClass[]) shorten(originalArray). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array - * boolean[], byte[], char[], int[], float[], or String[], or an array of objects - * - * @returns Array (the same datatype as the input) - * - * @see append - * @see expand - */ - p.shorten = function(ary) { - var newary = []; - - // copy array into new array - var len = ary.length; - for (var i = 0; i < len; i++) { - newary[i] = ary[i]; - } - newary.pop(); - - return newary; - }; - - /** - * Increases the size of an array. By default, this function doubles the size of the array, - * but the optional newSize parameter provides precise control over the increase in size. - * When using an array of objects, the data returned from the function must be cast to the - * object array's data type. For example: SomeClass[] items = (SomeClass[]) expand(originalArray). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} ary - * boolean[], byte[], char[], int[], float[], String[], or an array of objects - * @param {int} newSize positive int: new size for the array - * - * @returns Array (the same datatype as the input) - * - * @see contract - */ - p.expand = function(ary, newSize) { - var temp = ary.slice(0); - if (arguments.length === 1) { - // double size of array - temp.length = ary.length * 2; - return temp; - } else if (arguments.length === 2) { - // size is newSize - temp.length = newSize; - return temp; - } - }; - - /** - * Copies an array (or part of an array) to another array. The src array is copied to the - * dst array, beginning at the position specified by srcPos and into the position specified - * by dstPos. The number of elements to copy is determined by length. The simplified version - * with two arguments copies an entire array to another of the same size. It is equivalent - * to "arrayCopy(src, 0, dst, 0, src.length)". This function is far more efficient for copying - * array data than iterating through a for and copying each element. - * - * @param {Array} src an array of any data type: the source array - * @param {Array} dest an array of any data type (as long as it's the same as src): the destination array - * @param {int} srcPos starting position in the source array - * @param {int} destPos starting position in the destination array - * @param {int} length number of array elements to be copied - * - * @returns none - */ - p.arrayCopy = function() { // src, srcPos, dest, destPos, length) { - var src, srcPos = 0, dest, destPos = 0, length; - - if (arguments.length === 2) { - // recall itself and copy src to dest from start index 0 to 0 of src.length - src = arguments[0]; - dest = arguments[1]; - length = src.length; - } else if (arguments.length === 3) { - // recall itself and copy src to dest from start index 0 to 0 of length - src = arguments[0]; - dest = arguments[1]; - length = arguments[2]; - } else if (arguments.length === 5) { - src = arguments[0]; - srcPos = arguments[1]; - dest = arguments[2]; - destPos = arguments[3]; - length = arguments[4]; - } - - // copy src to dest from index srcPos to index destPos of length recursivly on objects - for (var i = srcPos, j = destPos; i < length + srcPos; i++, j++) { - if (dest[j] !== undef) { - dest[j] = src[i]; - } else { - throw "array index out of bounds exception"; - } - } - }; - - /** - * Reverses the order of an array. - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]} array - * boolean[], byte[], char[], int[], float[], or String[] - * - * @returns Array (the same datatype as the input) - * - * @see sort - */ - p.reverse = function(array) { - return array.reverse(); - }; - - - //////////////////////////////////////////////////////////////////////////// - // Color functions - //////////////////////////////////////////////////////////////////////////// - - // helper functions for internal blending modes - p.mix = function(a, b, f) { - return a + (((b - a) * f) >> 8); - }; - - p.peg = function(n) { - return (n < 0) ? 0 : ((n > 255) ? 255 : n); - }; - - // blending modes - /** - * These are internal blending modes used for BlendColor() - * - * @param {Color} c1 First Color to blend - * @param {Color} c2 Second Color to blend - * - * @returns {Color} The blended Color - * - * @see BlendColor - * @see Blend - */ - p.modes = { - replace: function(c1, c2) { - return c2; - }, - blend: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - p.mix(c1 & PConstants.RED_MASK, c2 & PConstants.RED_MASK, f) & PConstants.RED_MASK | - p.mix(c1 & PConstants.GREEN_MASK, c2 & PConstants.GREEN_MASK, f) & PConstants.GREEN_MASK | - p.mix(c1 & PConstants.BLUE_MASK, c2 & PConstants.BLUE_MASK, f)); - }, - add: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - Math.min(((c1 & PConstants.RED_MASK) + ((c2 & PConstants.RED_MASK) >> 8) * f), PConstants.RED_MASK) & PConstants.RED_MASK | - Math.min(((c1 & PConstants.GREEN_MASK) + ((c2 & PConstants.GREEN_MASK) >> 8) * f), PConstants.GREEN_MASK) & PConstants.GREEN_MASK | - Math.min((c1 & PConstants.BLUE_MASK) + (((c2 & PConstants.BLUE_MASK) * f) >> 8), PConstants.BLUE_MASK)); - }, - subtract: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - Math.max(((c1 & PConstants.RED_MASK) - ((c2 & PConstants.RED_MASK) >> 8) * f), PConstants.GREEN_MASK) & PConstants.RED_MASK | - Math.max(((c1 & PConstants.GREEN_MASK) - ((c2 & PConstants.GREEN_MASK) >> 8) * f), PConstants.BLUE_MASK) & PConstants.GREEN_MASK | - Math.max((c1 & PConstants.BLUE_MASK) - (((c2 & PConstants.BLUE_MASK) * f) >> 8), 0)); - }, - lightest: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - Math.max(c1 & PConstants.RED_MASK, ((c2 & PConstants.RED_MASK) >> 8) * f) & PConstants.RED_MASK | - Math.max(c1 & PConstants.GREEN_MASK, ((c2 & PConstants.GREEN_MASK) >> 8) * f) & PConstants.GREEN_MASK | - Math.max(c1 & PConstants.BLUE_MASK, ((c2 & PConstants.BLUE_MASK) * f) >> 8)); - }, - darkest: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - p.mix(c1 & PConstants.RED_MASK, Math.min(c1 & PConstants.RED_MASK, ((c2 & PConstants.RED_MASK) >> 8) * f), f) & PConstants.RED_MASK | - p.mix(c1 & PConstants.GREEN_MASK, Math.min(c1 & PConstants.GREEN_MASK, ((c2 & PConstants.GREEN_MASK) >> 8) * f), f) & PConstants.GREEN_MASK | - p.mix(c1 & PConstants.BLUE_MASK, Math.min(c1 & PConstants.BLUE_MASK, ((c2 & PConstants.BLUE_MASK) * f) >> 8), f)); - }, - difference: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (ar > br) ? (ar - br) : (br - ar); - var cg = (ag > bg) ? (ag - bg) : (bg - ag); - var cb = (ab > bb) ? (ab - bb) : (bb - ab); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - exclusion: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = ar + br - ((ar * br) >> 7); - var cg = ag + bg - ((ag * bg) >> 7); - var cb = ab + bb - ((ab * bb) >> 7); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - multiply: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (ar * br) >> 8; - var cg = (ag * bg) >> 8; - var cb = (ab * bb) >> 8; - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - screen: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = 255 - (((255 - ar) * (255 - br)) >> 8); - var cg = 255 - (((255 - ag) * (255 - bg)) >> 8); - var cb = 255 - (((255 - ab) * (255 - bb)) >> 8); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - hard_light: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (br < 128) ? ((ar * br) >> 7) : (255 - (((255 - ar) * (255 - br)) >> 7)); - var cg = (bg < 128) ? ((ag * bg) >> 7) : (255 - (((255 - ag) * (255 - bg)) >> 7)); - var cb = (bb < 128) ? ((ab * bb) >> 7) : (255 - (((255 - ab) * (255 - bb)) >> 7)); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - soft_light: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = ((ar * br) >> 7) + ((ar * ar) >> 8) - ((ar * ar * br) >> 15); - var cg = ((ag * bg) >> 7) + ((ag * ag) >> 8) - ((ag * ag * bg) >> 15); - var cb = ((ab * bb) >> 7) + ((ab * ab) >> 8) - ((ab * ab * bb) >> 15); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - overlay: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (ar < 128) ? ((ar * br) >> 7) : (255 - (((255 - ar) * (255 - br)) >> 7)); - var cg = (ag < 128) ? ((ag * bg) >> 7) : (255 - (((255 - ag) * (255 - bg)) >> 7)); - var cb = (ab < 128) ? ((ab * bb) >> 7) : (255 - (((255 - ab) * (255 - bb)) >> 7)); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - dodge: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (br === 255) ? 255 : p.peg((ar << 8) / (255 - br)); // division requires pre-peg()-ing - var cg = (bg === 255) ? 255 : p.peg((ag << 8) / (255 - bg)); // " - var cb = (bb === 255) ? 255 : p.peg((ab << 8) / (255 - bb)); // " - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - burn: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (br === 0) ? 0 : 255 - p.peg(((255 - ar) << 8) / br); // division requires pre-peg()-ing - var cg = (bg === 0) ? 0 : 255 - p.peg(((255 - ag) << 8) / bg); // " - var cb = (bb === 0) ? 0 : 255 - p.peg(((255 - ab) << 8) / bb); // " - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - } - }; - - function color$4(aValue1, aValue2, aValue3, aValue4) { - var r, g, b, a; - - if (curColorMode === PConstants.HSB) { - var rgb = p.color.toRGB(aValue1, aValue2, aValue3); - r = rgb[0]; - g = rgb[1]; - b = rgb[2]; - } else { - r = Math.round(255 * (aValue1 / colorModeX)); - g = Math.round(255 * (aValue2 / colorModeY)); - b = Math.round(255 * (aValue3 / colorModeZ)); - } - - a = Math.round(255 * (aValue4 / colorModeA)); - - // Limit values greater than 255 - r = (r > 255) ? 255 : r; - g = (g > 255) ? 255 : g; - b = (b > 255) ? 255 : b; - a = (a > 255) ? 255 : a; - - // Create color int - return (a << 24) & PConstants.ALPHA_MASK | (r << 16) & PConstants.RED_MASK | (g << 8) & PConstants.GREEN_MASK | b & PConstants.BLUE_MASK; - } - - function color$2(aValue1, aValue2) { - var a; - - // Color int and alpha - if (aValue1 & PConstants.ALPHA_MASK) { - a = Math.round(255 * (aValue2 / colorModeA)); - a = (a > 255) ? 255 : a; - - return aValue1 - (aValue1 & PConstants.ALPHA_MASK) + ((a << 24) & PConstants.ALPHA_MASK); - } - // Grayscale and alpha - else { - if (curColorMode === PConstants.RGB) { - return color$4(aValue1, aValue1, aValue1, aValue2); - } else if (curColorMode === PConstants.HSB) { - return color$4(0, 0, (aValue1 / colorModeX) * colorModeZ, aValue2); - } - } - } - - function color$1(aValue1) { - // Grayscale - if (aValue1 <= colorModeX && aValue1 >= 0) { - if (curColorMode === PConstants.RGB) { - return color$4(aValue1, aValue1, aValue1, colorModeA); - } else if (curColorMode === PConstants.HSB) { - return color$4(0, 0, (aValue1 / colorModeX) * colorModeZ, colorModeA); - } - } - // Color int - else if (aValue1) { - return aValue1; - } - } - - /** - * Creates colors for storing in variables of the color datatype. The parameters are - * interpreted as RGB or HSB values depending on the current colorMode(). The default - * mode is RGB values from 0 to 255 and therefore, the function call color(255, 204, 0) - * will return a bright yellow color. More about how colors are stored can be found in - * the reference for the color datatype. - * - * @param {int|float} aValue1 red or hue or grey values relative to the current color range. - * Also can be color value in hexadecimal notation (i.e. #FFCC00 or 0xFFFFCC00) - * @param {int|float} aValue2 green or saturation values relative to the current color range - * @param {int|float} aValue3 blue or brightness values relative to the current color range - * @param {int|float} aValue4 relative to current color range. Represents alpha - * - * @returns {color} the color - * - * @see colorMode - */ - p.color = function color(aValue1, aValue2, aValue3, aValue4) { - // 4 arguments: (R, G, B, A) or (H, S, B, A) - if (aValue1 !== undef && aValue2 !== undef && aValue3 !== undef && aValue4 !== undef) { - return color$4(aValue1, aValue2, aValue3, aValue4); - } - - // 3 arguments: (R, G, B) or (H, S, B) - else if (aValue1 !== undef && aValue2 !== undef && aValue3 !== undef) { - return color$4(aValue1, aValue2, aValue3, colorModeA); - } - - // 2 arguments: (Color, A) or (Grayscale, A) - else if (aValue1 !== undef && aValue2 !== undef) { - return color$2(aValue1, aValue2); - } - - // 1 argument: (Grayscale) or (Color) - else if (typeof aValue1 === "number") { - return color$1(aValue1); - } - - // Default - else { - return color$4(colorModeX, colorModeY, colorModeZ, colorModeA); - } - }; - - // Ease of use function to extract the colour bits into a string - p.color.toString = function(colorInt) { - return "rgba(" + ((colorInt & PConstants.RED_MASK) >>> 16) + "," + ((colorInt & PConstants.GREEN_MASK) >>> 8) + - "," + ((colorInt & PConstants.BLUE_MASK)) + "," + ((colorInt & PConstants.ALPHA_MASK) >>> 24) / 255 + ")"; - }; - - // Easy of use function to pack rgba values into a single bit-shifted color int. - p.color.toInt = function(r, g, b, a) { - return (a << 24) & PConstants.ALPHA_MASK | (r << 16) & PConstants.RED_MASK | (g << 8) & PConstants.GREEN_MASK | b & PConstants.BLUE_MASK; - }; - - // Creates a simple array in [R, G, B, A] format, [255, 255, 255, 255] - p.color.toArray = function(colorInt) { - return [(colorInt & PConstants.RED_MASK) >>> 16, (colorInt & PConstants.GREEN_MASK) >>> 8, - colorInt & PConstants.BLUE_MASK, (colorInt & PConstants.ALPHA_MASK) >>> 24]; - }; - - // Creates a WebGL color array in [R, G, B, A] format. WebGL wants the color ranges between 0 and 1, [1, 1, 1, 1] - p.color.toGLArray = function(colorInt) { - return [((colorInt & PConstants.RED_MASK) >>> 16) / 255, ((colorInt & PConstants.GREEN_MASK) >>> 8) / 255, - (colorInt & PConstants.BLUE_MASK) / 255, ((colorInt & PConstants.ALPHA_MASK) >>> 24) / 255]; - }; - - // HSB conversion function from Mootools, MIT Licensed - p.color.toRGB = function(h, s, b) { - // Limit values greater than range - h = (h > colorModeX) ? colorModeX : h; - s = (s > colorModeY) ? colorModeY : s; - b = (b > colorModeZ) ? colorModeZ : b; - - h = (h / colorModeX) * 360; - s = (s / colorModeY) * 100; - b = (b / colorModeZ) * 100; - - var br = Math.round(b / 100 * 255); - - if (s === 0) { // Grayscale - return [br, br, br]; - } else { - var hue = h % 360; - var f = hue % 60; - var p = Math.round((b * (100 - s)) / 10000 * 255); - var q = Math.round((b * (6000 - s * f)) / 600000 * 255); - var t = Math.round((b * (6000 - s * (60 - f))) / 600000 * 255); - switch (Math.floor(hue / 60)) { - case 0: - return [br, t, p]; - case 1: - return [q, br, p]; - case 2: - return [p, br, t]; - case 3: - return [p, q, br]; - case 4: - return [t, p, br]; - case 5: - return [br, p, q]; - } - } - }; - - p.color.toHSB = function( colorInt ) { - var red, green, blue; - - red = ((colorInt & PConstants.RED_MASK) >>> 16) / 255; - green = ((colorInt & PConstants.GREEN_MASK) >>> 8) / 255; - blue = (colorInt & PConstants.BLUE_MASK) / 255; - - var max = p.max(p.max(red,green), blue), - min = p.min(p.min(red,green), blue), - hue, saturation; - - if (min === max) { - return [0, 0, max]; - } else { - saturation = (max - min) / max; - - if (red === max) { - hue = (green - blue) / (max - min); - } else if (green === max) { - hue = 2 + ((blue - red) / (max - min)); - } else { - hue = 4 + ((red - green) / (max - min)); - } - - hue /= 6; - - if (hue < 0) { - hue += 1; - } else if (hue > 1) { - hue -= 1; - } - } - return [hue*colorModeX, saturation*colorModeY, max*colorModeZ]; - }; - - /** - * Extracts the brightness value from a color. - * - * @param {color} colInt any value of the color datatype - * - * @returns {float} The brightness color value. - * - * @see red - * @see green - * @see blue - * @see hue - * @see saturation - */ - p.brightness = function(colInt){ - return p.color.toHSB(colInt)[2]; - }; - - /** - * Extracts the saturation value from a color. - * - * @param {color} colInt any value of the color datatype - * - * @returns {float} The saturation color value. - * - * @see red - * @see green - * @see blue - * @see hue - * @see brightness - */ - p.saturation = function(colInt){ - return p.color.toHSB(colInt)[1]; - }; - - /** - * Extracts the hue value from a color. - * - * @param {color} colInt any value of the color datatype - * - * @returns {float} The hue color value. - * - * @see red - * @see green - * @see blue - * @see saturation - * @see brightness - */ - p.hue = function(colInt){ - return p.color.toHSB(colInt)[0]; - }; - - var verifyChannel = function verifyChannel(aColor) { - if (aColor.constructor === Array) { - return aColor; - } else { - return p.color(aColor); - } - }; - - /** - * Extracts the red value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The red color value. - * - * @see green - * @see blue - * @see alpha - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.red = function(aColor) { - return ((aColor & PConstants.RED_MASK) >>> 16) / 255 * colorModeX; - }; - - /** - * Extracts the green value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The green color value. - * - * @see red - * @see blue - * @see alpha - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.green = function(aColor) { - return ((aColor & PConstants.GREEN_MASK) >>> 8) / 255 * colorModeY; - }; - - /** - * Extracts the blue value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The blue color value. - * - * @see red - * @see green - * @see alpha - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.blue = function(aColor) { - return (aColor & PConstants.BLUE_MASK) / 255 * colorModeZ; - }; - - /** - * Extracts the alpha value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The alpha color value. - * - * @see red - * @see green - * @see blue - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.alpha = function(aColor) { - return ((aColor & PConstants.ALPHA_MASK) >>> 24) / 255 * colorModeA; - }; - - /** - * Calculates a color or colors between two colors at a specific increment. - * The amt parameter is the amount to interpolate between the two values where 0.0 - * equal to the first point, 0.1 is very near the first point, 0.5 is half-way in between, etc. - * - * @param {color} c1 interpolate from this color - * @param {color} c2 interpolate to this color - * @param {float} amt between 0.0 and 1.0 - * - * @returns {float} The blended color. - * - * @see blendColor - * @see color - */ - p.lerpColor = function lerpColor(c1, c2, amt) { - // Get RGBA values for Color 1 to floats - var colorBits1 = p.color(c1); - var r1 = (colorBits1 & PConstants.RED_MASK) >>> 16; - var g1 = (colorBits1 & PConstants.GREEN_MASK) >>> 8; - var b1 = (colorBits1 & PConstants.BLUE_MASK); - var a1 = ((colorBits1 & PConstants.ALPHA_MASK) >>> 24) / colorModeA; - - // Get RGBA values for Color 2 to floats - var colorBits2 = p.color(c2); - var r2 = (colorBits2 & PConstants.RED_MASK) >>> 16; - var g2 = (colorBits2 & PConstants.GREEN_MASK) >>> 8; - var b2 = (colorBits2 & PConstants.BLUE_MASK); - var a2 = ((colorBits2 & PConstants.ALPHA_MASK) >>> 24) / colorModeA; - - // Return lerp value for each channel, INT for color, Float for Alpha-range - var r = parseInt(p.lerp(r1, r2, amt), 10); - var g = parseInt(p.lerp(g1, g2, amt), 10); - var b = parseInt(p.lerp(b1, b2, amt), 10); - var a = parseFloat(p.lerp(a1, a2, amt) * colorModeA); - - return p.color.toInt(r, g, b, a); - }; - - // Forced default color mode for #aaaaaa style - /** - * Convert 3 int values to a color in the default color mode RGB even if curColorMode is not set to RGB - * - * @param {int} aValue1 range for the red color - * @param {int} aValue2 range for the green color - * @param {int} aValue3 range for the blue color - * - * @returns {Color} - * - * @see color - */ - p.defaultColor = function(aValue1, aValue2, aValue3) { - var tmpColorMode = curColorMode; - curColorMode = PConstants.RGB; - var c = p.color(aValue1 / 255 * colorModeX, aValue2 / 255 * colorModeY, aValue3 / 255 * colorModeZ); - curColorMode = tmpColorMode; - return c; - }; - - /** - * Changes the way Processing interprets color data. By default, fill(), stroke(), and background() - * colors are set by values between 0 and 255 using the RGB color model. It is possible to change the - * numerical range used for specifying colors and to switch color systems. For example, calling colorMode(RGB, 1.0) - * will specify that values are specified between 0 and 1. The limits for defining colors are altered by setting the - * parameters range1, range2, range3, and range 4. - * - * @param {MODE} mode Either RGB or HSB, corresponding to Red/Green/Blue and Hue/Saturation/Brightness - * @param {int|float} range range for all color elements - * @param {int|float} range1 range for the red or hue depending on the current color mode - * @param {int|float} range2 range for the green or saturation depending on the current color mode - * @param {int|float} range3 range for the blue or brightness depending on the current color mode - * @param {int|float} range4 range for the alpha - * - * @returns none - * - * @see background - * @see fill - * @see stroke - */ - p.colorMode = function colorMode() { // mode, range1, range2, range3, range4 - curColorMode = arguments[0]; - if (arguments.length > 1) { - colorModeX = arguments[1]; - colorModeY = arguments[2] || arguments[1]; - colorModeZ = arguments[3] || arguments[1]; - colorModeA = arguments[4] || arguments[1]; - } - }; - - /** - * Blends two color values together based on the blending mode given as the MODE parameter. - * The possible modes are described in the reference for the blend() function. - * - * @param {color} c1 color: the first color to blend - * @param {color} c2 color: the second color to blend - * @param {MODE} MODE Either BLEND, ADD, SUBTRACT, DARKEST, LIGHTEST, DIFFERENCE, EXCLUSION, MULTIPLY, - * SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, or BURN - * - * @returns {float} The blended color. - * - * @see blend - * @see color - */ - p.blendColor = function(c1, c2, mode) { - var color = 0; - switch (mode) { - case PConstants.REPLACE: - color = p.modes.replace(c1, c2); - break; - case PConstants.BLEND: - color = p.modes.blend(c1, c2); - break; - case PConstants.ADD: - color = p.modes.add(c1, c2); - break; - case PConstants.SUBTRACT: - color = p.modes.subtract(c1, c2); - break; - case PConstants.LIGHTEST: - color = p.modes.lightest(c1, c2); - break; - case PConstants.DARKEST: - color = p.modes.darkest(c1, c2); - break; - case PConstants.DIFFERENCE: - color = p.modes.difference(c1, c2); - break; - case PConstants.EXCLUSION: - color = p.modes.exclusion(c1, c2); - break; - case PConstants.MULTIPLY: - color = p.modes.multiply(c1, c2); - break; - case PConstants.SCREEN: - color = p.modes.screen(c1, c2); - break; - case PConstants.HARD_LIGHT: - color = p.modes.hard_light(c1, c2); - break; - case PConstants.SOFT_LIGHT: - color = p.modes.soft_light(c1, c2); - break; - case PConstants.OVERLAY: - color = p.modes.overlay(c1, c2); - break; - case PConstants.DODGE: - color = p.modes.dodge(c1, c2); - break; - case PConstants.BURN: - color = p.modes.burn(c1, c2); - break; - } - return color; - }; - - //////////////////////////////////////////////////////////////////////////// - // Canvas-Matrix manipulation - //////////////////////////////////////////////////////////////////////////// - - function saveContext() { - curContext.save(); - } - - function restoreContext() { - curContext.restore(); - isStrokeDirty = true; - isFillDirty = true; - } - - /** - * Prints the current matrix to the text window. - * - * @returns none - * - * @see pushMatrix - * @see popMatrix - * @see resetMatrix - * @see applyMatrix - */ - p.printMatrix = function printMatrix() { - modelView.print(); - }; - - /** - * Specifies an amount to displace objects within the display window. The x parameter specifies left/right translation, - * the y parameter specifies up/down translation, and the z parameter specifies translations toward/away from the screen. - * Using this function with the z parameter requires using the P3D or OPENGL parameter in combination with size as shown - * in the above example. Transformations apply to everything that happens after and subsequent calls to the function - * accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). - * If translate() is called within draw(), the transformation is reset when the loop begins again. - * This function can be further controlled by the pushMatrix() and popMatrix(). - * - * @param {int|float} x left/right translation - * @param {int|float} y up/down translation - * @param {int|float} z forward/back translation - * - * @returns none - * - * @see pushMatrix - * @see popMatrix - * @see scale - * @see rotate - * @see rotateX - * @see rotateY - * @see rotateZ - */ - p.translate = function translate(x, y, z) { - if (p.use3DContext) { - forwardTransform.translate(x, y, z); - reverseTransform.invTranslate(x, y, z); - } else { - curContext.translate(x, y); - } - }; - - /** - * Increases or decreases the size of a shape by expanding and contracting vertices. Objects always scale from their - * relative origin to the coordinate system. Scale values are specified as decimal percentages. For example, the - * function call scale(2.0) increases the dimension of a shape by 200%. Transformations apply to everything that - * happens after and subsequent calls to the function multiply the effect. For example, calling scale(2.0) and - * then scale(1.5) is the same as scale(3.0). If scale() is called within draw(), the transformation is reset when - * the loop begins again. Using this fuction with the z parameter requires passing P3D or OPENGL into the size() - * parameter as shown in the example above. This function can be further controlled by pushMatrix() and popMatrix(). - * - * @param {int|float} size percentage to scale the object - * @param {int|float} x percentage to scale the object in the x-axis - * @param {int|float} y percentage to scale the object in the y-axis - * @param {int|float} z percentage to scale the object in the z-axis - * - * @returns none - * - * @see pushMatrix - * @see popMatrix - * @see translate - * @see rotate - * @see rotateX - * @see rotateY - * @see rotateZ - */ - p.scale = function scale(x, y, z) { - if (p.use3DContext) { - forwardTransform.scale(x, y, z); - reverseTransform.invScale(x, y, z); - } else { - curContext.scale(x, y || x); - } - }; - - /** - * Pushes the current transformation matrix onto the matrix stack. Understanding pushMatrix() and popMatrix() - * requires understanding the concept of a matrix stack. The pushMatrix() function saves the current coordinate - * system to the stack and popMatrix() restores the prior coordinate system. pushMatrix() and popMatrix() are - * used in conjuction with the other transformation methods and may be embedded to control the scope of - * the transformations. - * - * @returns none - * - * @see popMatrix - * @see translate - * @see rotate - * @see rotateX - * @see rotateY - * @see rotateZ - */ - p.pushMatrix = function pushMatrix() { - if (p.use3DContext) { - userMatrixStack.load(modelView); - } else { - saveContext(); - } - }; - - /** - * Pops the current transformation matrix off the matrix stack. Understanding pushing and popping requires - * understanding the concept of a matrix stack. The pushMatrix() function saves the current coordinate system to - * the stack and popMatrix() restores the prior coordinate system. pushMatrix() and popMatrix() are used in - * conjuction with the other transformation methods and may be embedded to control the scope of the transformations. - * - * @returns none - * - * @see popMatrix - * @see pushMatrix - */ - p.popMatrix = function popMatrix() { - if (p.use3DContext) { - modelView.set(userMatrixStack.pop()); - } else { - restoreContext(); - } - }; - - /** - * Replaces the current matrix with the identity matrix. The equivalent function in OpenGL is glLoadIdentity(). - * - * @returns none - * - * @see popMatrix - * @see pushMatrix - * @see applyMatrix - * @see printMatrix - */ - p.resetMatrix = function resetMatrix() { - if (p.use3DContext) { - forwardTransform.reset(); - reverseTransform.reset(); - } else { - curContext.setTransform(1,0,0,1,0,0); - } - }; - - /** - * Multiplies the current matrix by the one specified through the parameters. This is very slow because it will - * try to calculate the inverse of the transform, so avoid it whenever possible. The equivalent function - * in OpenGL is glMultMatrix(). - * - * @param {int|float} n00-n15 numbers which define the 4x4 matrix to be multiplied - * - * @returns none - * - * @see popMatrix - * @see pushMatrix - * @see resetMatrix - * @see printMatrix - */ - p.applyMatrix = function applyMatrix() { - var a = arguments; - if (!p.use3DContext) { - for (var cnt = a.length; cnt < 16; cnt++) { - a[cnt] = 0; - } - a[10] = a[15] = 1; - } - - forwardTransform.apply(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]); - reverseTransform.invApply(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]); - }; - - /** - * Rotates a shape around the x-axis the amount specified by the angle parameter. Angles should be - * specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * Objects are always rotated around their relative position to the origin and positive numbers - * rotate objects in a counterclockwise direction. Transformations apply to everything that happens - * after and subsequent calls to the function accumulates the effect. For example, calling rotateX(PI/2) - * and then rotateX(PI/2) is the same as rotateX(PI). If rotateX() is called within the draw(), the - * transformation is reset when the loop begins again. This function requires passing P3D or OPENGL - * into the size() parameter as shown in the example above. - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateY - * @see rotateZ - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotateX = function(angleInRadians) { - forwardTransform.rotateX(angleInRadians); - reverseTransform.invRotateX(angleInRadians); - }; - - /** - * Rotates a shape around the z-axis the amount specified by the angle parameter. Angles should be - * specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * Objects are always rotated around their relative position to the origin and positive numbers - * rotate objects in a counterclockwise direction. Transformations apply to everything that happens - * after and subsequent calls to the function accumulates the effect. For example, calling rotateZ(PI/2) - * and then rotateZ(PI/2) is the same as rotateZ(PI). If rotateZ() is called within the draw(), the - * transformation is reset when the loop begins again. This function requires passing P3D or OPENGL - * into the size() parameter as shown in the example above. - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateX - * @see rotateY - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotateZ = function(angleInRadians) { - forwardTransform.rotateZ(angleInRadians); - reverseTransform.invRotateZ(angleInRadians); - }; - - /** - * Rotates a shape around the y-axis the amount specified by the angle parameter. Angles should be - * specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * Objects are always rotated around their relative position to the origin and positive numbers - * rotate objects in a counterclockwise direction. Transformations apply to everything that happens - * after and subsequent calls to the function accumulates the effect. For example, calling rotateY(PI/2) - * and then rotateY(PI/2) is the same as rotateY(PI). If rotateY() is called within the draw(), the - * transformation is reset when the loop begins again. This function requires passing P3D or OPENGL - * into the size() parameter as shown in the example above. - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateX - * @see rotateZ - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotateY = function(angleInRadians) { - forwardTransform.rotateY(angleInRadians); - reverseTransform.invRotateY(angleInRadians); - }; - - /** - * Rotates a shape the amount specified by the angle parameter. Angles should be specified in radians - * (values from 0 to TWO_PI) or converted to radians with the radians() function. Objects are always - * rotated around their relative position to the origin and positive numbers rotate objects in a - * clockwise direction. Transformations apply to everything that happens after and subsequent calls - * to the function accumulates the effect. For example, calling rotate(HALF_PI) and then rotate(HALF_PI) - * is the same as rotate(PI). All tranformations are reset when draw() begins again. Technically, - * rotate() multiplies the current transformation matrix by a rotation matrix. This function can be - * further controlled by the pushMatrix() and popMatrix(). - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateX - * @see rotateY - * @see rotateZ - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotate = function rotate(angleInRadians) { - if (p.use3DContext) { - forwardTransform.rotateZ(angleInRadians); - reverseTransform.invRotateZ(angleInRadians); - } else { - curContext.rotate(angleInRadians); - } - }; - - /** - * The pushStyle() function saves the current style settings and popStyle() restores the prior settings. - * Note that these functions are always used together. They allow you to change the style settings and later - * return to what you had. When a new style is started with pushStyle(), it builds on the current style information. - * The pushStyle() and popStyle() functions can be embedded to provide more control (see the second example - * above for a demonstration.) - * The style information controlled by the following functions are included in the style: fill(), stroke(), tint(), - * strokeWeight(), strokeCap(), strokeJoin(), imageMode(), rectMode(), ellipseMode(), shapeMode(), colorMode(), - * textAlign(), textFont(), textMode(), textSize(), textLeading(), emissive(), specular(), shininess(), ambient() - * - * @returns none - * - * @see popStyle - */ - p.pushStyle = function pushStyle() { - // Save the canvas state. - saveContext(); - - p.pushMatrix(); - - var newState = { - 'doFill': doFill, - 'currentFillColor': currentFillColor, - 'doStroke': doStroke, - 'currentStrokeColor': currentStrokeColor, - 'curTint': curTint, - 'curRectMode': curRectMode, - 'curColorMode': curColorMode, - 'colorModeX': colorModeX, - 'colorModeZ': colorModeZ, - 'colorModeY': colorModeY, - 'colorModeA': colorModeA, - 'curTextFont': curTextFont, - 'curTextSize': curTextSize - }; - - styleArray.push(newState); - }; - - /** - * The pushStyle() function saves the current style settings and popStyle() restores the prior settings; these - * functions are always used together. They allow you to change the style settings and later return to what you had. - * When a new style is started with pushStyle(), it builds on the current style information. The pushStyle() and - * popStyle() functions can be embedded to provide more control (see the second example above for a demonstration.) - * - * @returns none - * - * @see pushStyle - */ - p.popStyle = function popStyle() { - var oldState = styleArray.pop(); - - if (oldState) { - restoreContext(); - - p.popMatrix(); - - doFill = oldState.doFill; - currentFillColor = oldState.currentFillColor; - doStroke = oldState.doStroke; - currentStrokeColor = oldState.currentStrokeColor; - curTint = oldState.curTint; - curRectMode = oldState.curRectmode; - curColorMode = oldState.curColorMode; - colorModeX = oldState.colorModeX; - colorModeZ = oldState.colorModeZ; - colorModeY = oldState.colorModeY; - colorModeA = oldState.colorModeA; - curTextFont = oldState.curTextFont; - curTextSize = oldState.curTextSize; - } else { - throw "Too many popStyle() without enough pushStyle()"; - } - }; - - //////////////////////////////////////////////////////////////////////////// - // Time based functions - //////////////////////////////////////////////////////////////////////////// - - /** - * Processing communicates with the clock on your computer. - * The year() function returns the current year as an integer (2003, 2004, 2005, etc). - * - * @returns {float} The current year. - * - * @see millis - * @see second - * @see minute - * @see hour - * @see day - * @see month - */ - p.year = function year() { - return new Date().getFullYear(); - }; - /** - * Processing communicates with the clock on your computer. - * The month() function returns the current month as a value from 1 - 12. - * - * @returns {float} The current month. - * - * @see millis - * @see second - * @see minute - * @see hour - * @see day - * @see year - */ - p.month = function month() { - return new Date().getMonth() + 1; - }; - /** - * Processing communicates with the clock on your computer. - * The day() function returns the current day as a value from 1 - 31. - * - * @returns {float} The current day. - * - * @see millis - * @see second - * @see minute - * @see hour - * @see month - * @see year - */ - p.day = function day() { - return new Date().getDate(); - }; - /** - * Processing communicates with the clock on your computer. - * The hour() function returns the current hour as a value from 0 - 23. - * - * @returns {float} The current hour. - * - * @see millis - * @see second - * @see minute - * @see month - * @see day - * @see year - */ - p.hour = function hour() { - return new Date().getHours(); - }; - /** - * Processing communicates with the clock on your computer. - * The minute() function returns the current minute as a value from 0 - 59. - * - * @returns {float} The current minute. - * - * @see millis - * @see second - * @see month - * @see hour - * @see day - * @see year - */ - p.minute = function minute() { - return new Date().getMinutes(); - }; - /** - * Processing communicates with the clock on your computer. - * The second() function returns the current second as a value from 0 - 59. - * - * @returns {float} The current minute. - * - * @see millis - * @see month - * @see minute - * @see hour - * @see day - * @see year - */ - p.second = function second() { - return new Date().getSeconds(); - }; - /** - * Returns the number of milliseconds (thousandths of a second) since starting a sketch. - * This information is often used for timing animation sequences. - * - * @returns {long} The number of milliseconds since starting the sketch. - * - * @see month - * @see second - * @see minute - * @see hour - * @see day - * @see year - */ - p.millis = function millis() { - return new Date().getTime() - start; - }; - - /** - * Executes the code within draw() one time. This functions allows the program to update - * the display window only when necessary, for example when an event registered by - * mousePressed() or keyPressed() occurs. - * In structuring a program, it only makes sense to call redraw() within events such as - * mousePressed(). This is because redraw() does not run draw() immediately (it only sets - * a flag that indicates an update is needed). - * Calling redraw() within draw() has no effect because draw() is continuously called anyway. - * - * @returns none - * - * @see noLoop - * @see loop - */ - p.redraw = function redraw() { - var sec = (new Date().getTime() - timeSinceLastFPS) / 1000; - framesSinceLastFPS++; - var fps = framesSinceLastFPS / sec; - - // recalculate FPS every half second for better accuracy. - if (sec > 0.5) { - timeSinceLastFPS = new Date().getTime(); - framesSinceLastFPS = 0; - p.__frameRate = fps; - } - - p.frameCount++; - - inDraw = true; - - if (p.use3DContext) { - // even if the color buffer isn't cleared with background(), - // the depth buffer needs to be cleared regardless. - curContext.clear(curContext.DEPTH_BUFFER_BIT); - curContextCache = { attributes: {}, locations: {} }; - // Delete all the lighting states and the materials the - // user set in the last draw() call. - p.noLights(); - p.lightFalloff(1, 0, 0); - p.shininess(1); - p.ambient(255, 255, 255); - p.specular(0, 0, 0); - p.camera(); - p.draw(); - } else { - saveContext(); - p.draw(); - restoreContext(); - } - - inDraw = false; - }; - - /** - * Stops Processing from continuously executing the code within draw(). If loop() is - * called, the code in draw() begin to run continuously again. If using noLoop() in - * setup(), it should be the last line inside the block. - * When noLoop() is used, it's not possible to manipulate or access the screen inside event - * handling functions such as mousePressed() or keyPressed(). Instead, use those functions - * to call redraw() or loop(), which will run draw(), which can update the screen properly. - * This means that when noLoop() has been called, no drawing can happen, and functions like - * saveFrame() or loadPixels() may not be used. - * Note that if the sketch is resized, redraw() will be called to update the sketch, even - * after noLoop() has been specified. Otherwise, the sketch would enter an odd state until - * loop() was called. - * - * @returns none - * - * @see redraw - * @see draw - * @see loop - */ - p.noLoop = function noLoop() { - doLoop = false; - loopStarted = false; - clearInterval(looping); - }; - - /** - * Causes Processing to continuously execute the code within draw(). If noLoop() is called, - * the code in draw() stops executing. - * - * @returns none - * - * @see noLoop - */ - p.loop = function loop() { - if (loopStarted) { - return; - } - - looping = window.setInterval(function() { - //try { - if (document.hasFocus instanceof Function) { - p.focused = document.hasFocus(); - } - p.redraw(); - //} catch(e_loop) { - //window.clearInterval(looping); - //throw e_loop; - //} - }, curMsPerFrame); - doLoop = true; - loopStarted = true; - }; - - /** - * Specifies the number of frames to be displayed every second. If the processor is not - * fast enough to maintain the specified rate, it will not be achieved. For example, the - * function call frameRate(30) will attempt to refresh 30 times a second. It is recommended - * to set the frame rate within setup(). The default rate is 60 frames per second. - * - * @param {int} aRate number of frames per second. - * - * @returns none - * - * @see delay - */ - p.frameRate = function frameRate(aRate) { - curFrameRate = aRate; - curMsPerFrame = 1000 / curFrameRate; - - // clear and reset interval - if (doLoop) { - p.noLoop(); - p.loop(); - } - }; - - var eventHandlers = []; - - /** - * Quits/stops/exits the program. Programs without a draw() function exit automatically - * after the last line has run, but programs with draw() run continuously until the - * program is manually stopped or exit() is run. - * Rather than terminating immediately, exit() will cause the sketch to exit after draw() - * has completed (or after setup() completes if called during the setup() method). - * - * @returns none - */ - p.exit = function exit() { - window.clearInterval(looping); - - Processing.removeInstance(p.externals.canvas.id); - - // Step through the libraries to detach them - for (var lib in Processing.lib) { - if (Processing.lib.hasOwnProperty(lib)) { - if (Processing.lib[lib].hasOwnProperty("detach")) { - Processing.lib[lib].detach(p); - } - } - } - - for (var i=0, ehl=eventHandlers.length; i 1 || (arguments.length === 1 && arguments[0] instanceof p.PImage)) { - var image = arguments[0], - x, y; - if (arguments.length >= 3) { - x = arguments[1]; - y = arguments[2]; - if (x < 0 || y < 0 || y >= image.height || x >= image.width) { - throw "x and y must be non-negative and less than the dimensions of the image"; - } - } else { - x = image.width >>> 1; - y = image.height >>> 1; - } - - // see https://developer.mozilla.org/en/Using_URL_values_for_the_cursor_property - var imageDataURL = image.toDataURL(); - var style = "url(\"" + imageDataURL + "\") " + x + " " + y + ", default"; - curCursor = curElement.style.cursor = style; - } else if (arguments.length === 1) { - var mode = arguments[0]; - curCursor = curElement.style.cursor = mode; - } else { - curCursor = curElement.style.cursor = oldCursor; - } - }; - - /** - * Hides the cursor from view. - * - * @returns none - * - * @see cursor - */ - p.noCursor = function noCursor() { - curCursor = curElement.style.cursor = PConstants.NOCURSOR; - }; - - /** - * Links to a webpage either in the same window or in a new window. The complete URL - * must be specified. - * - * @param {String} href complete url as a String in quotes - * @param {String} target name of the window to load the URL as a string in quotes - * - * @returns none - */ - p.link = function(href, target) { - if (target !== undef) { - window.open(href, target); - } else { - window.location = href; - } - }; - - // PGraphics methods - // TODO: These functions are suppose to be called before any operations are called on the - // PGraphics object. They currently do nothing. - p.beginDraw = function beginDraw() {}; - p.endDraw = function endDraw() {}; - - // Imports an external Processing.js library - p.Import = function Import(lib) { - // Replace evil-eval method with a DOM - - - - - - - - -
        - - -
        -
        - diff --git a/game/old/fb/scores/scores.js b/game/old/fb/scores/scores.js deleted file mode 100644 index d6403b2..0000000 --- a/game/old/fb/scores/scores.js +++ /dev/null @@ -1,221 +0,0 @@ -var make_scores = function(){ - var obj = {}; - - var num_rows = 15; - - // async gets scores and feeds to callback - var get_scores = function(callback){ - // ajax request to get scores - - // want to do them sequentially so we - // chain the callbacks - - // this comes third via callback - var do_global = function() { - // Global High Scores - $.post("scores/get_scores.php", { - num: num_rows, - }, callback("Global Scores", - // at the end of last callback we need to - // make the tabs - function() { - console.log("making tabs"); - $("#scores").tabs(); - - // remove the loading message - console.log("removing loading msg"); - $("#scores-loading").remove(); - - $("#scores").show(); - } - )); - }; - - // this comes second via callback - var do_friends = function() { - var friends = g_get_friends(); - if (friends.length !== 0) { - // Global High Scores - $.post("scores/get_scores.php", { - num: num_rows, - uid: g_user_id, - friends: friends - }, callback("Friends' Scores", do_global)); - console.log("got friends scores"); - } - else { - do_global(); - console.log("skipped friends scores"); - } - }; - - // this comes first - // Personal high scores - if (g_user_id) { - $.post("scores/get_scores.php", { - num: num_rows, - uid : g_user_id - }, callback("Your Scores", do_friends)); - console.log("getting user high scores"); - } - else { - do_global(); - } - }; - - var get_user_scores = function(callback) { - $.post("scores/get_scores.php", { - num : num_rows - }, callback); - }; - - // interprets json and displays it - // Passing it a header returns the actual function - // Must use this style so long as get_scores is async - // Passing a function as do_more does it at the end of the callback - var tab_count = 1; - var display_scores = function(header, do_more) { - var headers = [ "Rank", "Score", "Level", "Name", "Date" ]; - var formatters = { - "score": add_commas, - "date": function(date_str) { - //var d = new Date(date_str); - var d = new Date(); - // date_str must be of format yyyy-mm-dd - var year = parseInt(date_str.substring(0, 4)); - var month = parseInt(date_str.substring(5, 7))-1; - var day = parseInt(date_str.substring(8)); - d.setFullYear(year, month, day); - //return d.f("NNN d, yyyy"); - return d.format("mmm d, yyyy"); - }, - }; - return function(data){ - //console.log(data); - - var link = "
      • " - + header + "
      • "; - $("#tab-list").append(link); - - // con is the content to put in the score tab - var con = "
        "; - - try { - var scores = jQuery.parseJSON(data); - if (!scores) { - throw "No scores loaded"; - } - } - catch (e) { - con += "
        Error loading scores." - +" Please check your internet connection."; - } - if (scores) { - - con += "
        "; - - // -- start header row -- - con += ""; - for_each(headers, function(header) { - con += ""; - }); - con += ""; - // -- end header row -- - - //console.log(scores); - // scores is an array of row objects - var row_count = 1; - for_each(scores, function(row){ - con += ""; - con += ""; - for_each(keys(row), function(key){ - var f = formatters[key] || function(x) { return x; }; - // dont show uid - if (key !== "userid") { - con += ""; - } - }); - con += ""; - row_count += 1; - }); - // fill up rest of table for beauty's sake - while (row_count <= num_rows) { - con += ""; - for_each(headers, function(header){ - con += ""; - }); - con += ""; - row_count += 1; - } - - con += "
        " + header + "
        " + row_count + "." + f(row[key]) + "
         
        "; - con += ""; - - } - - // add it to page - $("#scores").append(con); - // update tab num - tab_count += 1; - - // do some more stuff if necessary - if (do_more) { - do_more(); - } - }; - }; - - // gets and displays scores - obj.do_scores = function(){ - console.log("trying to load scores"); - $("#scores").empty(); - $("#scores").hide(); - $("#scores").append("
          "); - // reset tab count - tab_count = 1; - get_scores(display_scores); - }; - - // inserts a score into the db - // score_obj: - // - score: int score - // - level: mutation level - // - userid: unique id for the user (from fb?) - var post_score = function(score_obj, callback){ - $.post("scores/post_score.php", score_obj, callback); - }; - - // testing function to use with form - obj.submit_score = function(score, level, name, uid){ - /* - var form = document.forms[0]; - var score = form.elements[0].value; - var level = form.elements[1].value; - var userid = form.elements[2].value; - */ - var date_str = (new Date()).format("yyyy-mm-dd"); - - var score_obj = { - /* - score: parseInt(score), - level: parseInt(level), - */ - score: score, - level: level, - name: name, - userid: uid, - //date: new Date().f('yyyy-MM-dd') - date: date_str - }; - console.log(score_obj); - - post_score(score_obj, function(data){ - console.log(data); - //obj.do_scores(); - }); - }; - - return obj; -} - -var scores = make_scores(); diff --git a/game/old/fb/seeker.js b/game/old/fb/seeker.js deleted file mode 100644 index ba3c879..0000000 --- a/game/old/fb/seeker.js +++ /dev/null @@ -1,127 +0,0 @@ -// ABSTRACT class for game objects that seek other game objects -// Classes that implement must override "my_update" instead of "update" -// --- inherits from object_with_states -// spec: -// game_object spec + -// speed = how fast the seeker approaches the target -// no_target_speed = how fast the object moves when there is no target -// target = object to move towards - -var seeker = function(p, spec) { - - // --- defaults --- - - // obj to return - var obj = object_with_states(p, spec); - - // --- private variables --- - - var speed = spec.speed || 0.2; - var no_target_speed = spec.no_target_speed || 0.2; - var alive = true; - var target = spec.target || null; - // initialized to random val at bottom - var target_angle = 0; - - // --- public methods --- - - // implementing game_object interface - - // update makes tkiller chase target cell - obj.update = function() { - var pos = obj.get_pos(); - var speed_to_use = speed; - - if (target && target.is_dead()) { - target = null; - } - - // if no target - if (target === null) { - // meander - if (parseInt(p.random(150)) === 0) { - target_angle += p.random(-p.PI/16, p.PI/16); - } - // laze - speed_to_use = no_target_speed; - } - else { - obj.face_target(); - } - - // change velocity to point towards target - var new_vel = new p.PVector( - p.cos(target_angle), p.sin(target_angle)); - new_vel.mult(speed_to_use); - obj.set_vel(new_vel); - - obj.my_update(); - }; - - // MUST BE OVERWRITTEN - obj.my_update = function() { - console.log("my_update (in seeker) not overwritten!"); - }; - - // Indicates that a mutation has occured and this object - // should float off the screen - // Makes this object stop and float off screen - obj.outdated = function() { - obj.set_state("outdated"); - obj.set_vel(new p.PVector(0,0)); - obj.set_target(null); - }; - - obj.is_outdated = function() { - return obj.get_state() === "outdated"; - }; - - // faces tar, or if tar not supplied, the object's - // target - obj.face_target = function(tar) { - var pos = obj.get_pos(); - if (target) { - var tpos = target.get_pos(); - } - if (tar) { - var tpos = tar.get_pos(); - } - if (tpos) { - // update target_angle - target_angle = p.atan2(tpos.y-pos.y, tpos.x-pos.x); // y first! - } - }; - - - obj.set_target = function(new_target) { - if (obj.get_state() !== "outdated") { - target = new_target; - } - }; - - obj.set_speed = function(new_speed) { - speed = new_speed; - }; - - obj.set_target_angle = function(new_target_angle) { - target_angle = new_target_angle; - }; - - obj.get_target = function() { - return target; - }; - - obj.get_target_angle = function() { - return target_angle; - }; - - // creates a random angle for init'ing - obj.random_target_angle = function() { - return p.random(-p.PI, p.PI); - //Math.random() * (p.PI * 2) - p.PI; //random angle - }; - target_angle = obj.random_target_angle(); - - - return obj; -} diff --git a/game/old/fb/settings.js b/game/old/fb/settings.js deleted file mode 100644 index 691f6e2..0000000 --- a/game/old/fb/settings.js +++ /dev/null @@ -1,66 +0,0 @@ -// Global settings -// Have to be wrapped in an object since primitives are pass-by-value -var game_settings = function() { - var settings = { - sound_fx : true, - music : true, - track: "no track", - click_to_fire : true, - mouse_to_select : false, - spacebar_to_fire : true, - background_color : 0xFF371010 - }; - - var toggle = function(name) { - settings[name] = !settings[name]; - }; - - settings.toggle_sound_fx = function() { toggle("sound_fx"); }; - settings.toggle_click_to_fire = function() { toggle("click_to_fire"); }; - settings.toggle_spacebar_to_fire = function() { toggle("spacebar_to_fire"); }; - settings.toggle_mouse_to_select = function() { toggle("mouse_to_select"); }; - // note that this only toggles the flag, not the actual music - // that should be done with a sound manager method - settings.toggle_music = function() { - toggle("music"); - //console.log(settings.music); - if (settings.music) { - sounds.play_menu_music(); - } - else { - sounds.pause_menu_music(); - } - }; - - settings.next_track = function() { - var t = sounds.next_track(); - settings.track = t; - }; - - settings.prev_track = function() { - var t = sounds.prev_track(); - settings.track = t; - }; - - settings.set_track = function(t) { - settings.track = t; - }; - - return settings; -}; -// abbreviate it -var g = game_settings(); - - -//getters -/* -var g_sound_fx_on = function() { - return g_game_settings.sound_fx; -} -var g_music_on = function() { - return g_game_settings.music; -} -var g_click_to_fire = function() { - return g_game_settings.click_to_fire; -} -*/ diff --git a/game/old/fb/sound.js b/game/old/fb/sound.js deleted file mode 100644 index 092bba8..0000000 --- a/game/old/fb/sound.js +++ /dev/null @@ -1,344 +0,0 @@ -// sound_manager -// utility object to play or not play sounds -// settings for sound still stored in settings object -var sound_manager = function() { - var obj = {}; - - var the_swf_path = "./jplayer/"; - // Taken from http://www.storiesinflight.com/html5/audio.html - - //g_divs_loaded_init_sounds = function() { - //console.log("AAAAA initing sounds"); - obj.play_sound = (function() { - var channel_max = 10; // number of channels - audiochannels = new Array(); - for (var a=0;a= all_bg_music.length) { - track_index = 0; - } - // pause the old one - obj.pause_background_music(); - // set the new one - set_background_music(); - //obj.play_background_music(); - return all_bg_music[track_index].name; - }; - - obj.prev_track = function() { - track_index -= 1; - if (track_index < 0) { - track_index = all_bg_music.length-1; - } - // pause the old one - obj.pause_background_music(); - // set the new one - set_background_music(); - return all_bg_music[track_index].name; - }; - - // sets the background music to the current track index - var set_background_music = function() { - // note that random must be the LAST track - var music = all_bg_music[track_index].music; - if (!music) { - music = all_bg_music - [Math.floor(Math.random()*(track_index-1))] - .music; - } - assert(music, "Random wasn't the last track index or a music div was undefined."); - background_music = music; - }; - - obj.resume_background_music = function() { - if (background_music) - background_music.jPlayer("play"); - } - - obj.pause_background_music = function() { - console.log("Pausing bg music"); - if (background_music) - background_music.jPlayer("pause"); - }; - - var menu_music = null; - var button_sounds = null; - - // Really resume menu music, menu music never restarts - obj.play_menu_music = function() { - if (g.music) - menu_music.jPlayer("play"); - } - obj.resume_menu_music = function() { - if (g.music) - menu_music.jPlayer("play"); - } - obj.pause_menu_music = function() { - menu_music.jPlayer("pause"); - } - obj.play_button_click = function() { - if (g.sound_fx) - play_a_sound(button_sounds, "buttonmain"); - } - obj.play_button_back = function() { - if (g.sound_fx) - play_a_sound(button_sounds, "buttonback"); - } - - var play_a_sound = function(jplayer_instance, sound_name) { - jplayer_instance.jPlayer("setMedia", { - //mp3 : g_soundDataMap[sound_name + "mp3"], - mp3 : "sounds/" + sound_name + ".mp3", - oga : g_soundDataMap[sound_name] - }); - //jplayer_instance.jPlayer.event.ready = function() {console.log("read");}; - jplayer_instance.jPlayer("play"); - } - - obj.load_sounds = function() { - // init all bg music - var all_supplied = "oga, mp3"; - var init_jplayer = function(name, mp3name, oggname, should_loop) { - $(name).jPlayer( { - swfPath : the_swf_path, - ready: function () { - $(this).jPlayer("setMedia", { - mp3 : "sounds/"+mp3name, - oga : "sounds/"+oggname - }); - //console.log(name + " is ready"); - bg_music_loaded(); - $(this).bind($.jPlayer.event.progress, - function(event) { - //console.log(event.jPlayer.status.seekPercent); - if (event.jPlayer.status.seekPercent === 100) { - //console.log("percent = 100, name: " + mp3name); - //bg_music_loaded(); - } - }); - $(this).bind($.jPlayer.error.NO_SOLUTION, - function(event) { - //bg_music_loaded(); - console.log("No audio solutions"); - }); - }, - ended : function() { // loop - if (should_loop) { - $(this).jPlayer("play"); - } - }, - supplied : all_supplied, - preload : "auto", - oggSupport: true - //errorAlerts : true - }); - } - - var init_bg_jplayer = function(num, file_name, oggfn) { - init_jplayer("#jquery_jplayer_bg_"+num, file_name, oggfn, true) - } - /* - console.log("loading heart loop"); - init_bg_jplayer(0, "heart_loop1.mp3"); - console.log("loaded heart loop"); - */ - console.log("loading sinister"); - init_bg_jplayer(0, "sinister.mp3", "sinister.ogg", true); - console.log("loaded sinister"); - - init_bg_jplayer(1, "gameloop2.mp3", "gameloop2.ogg", true); - init_bg_jplayer(2, "Infiltration.mp3", "Infiltration.ogg", true); - - for (var i = 0; i < num_bg_music; i++) { - all_bg_music.push({ - music: $("#jquery_jplayer_bg_"+i), - name: track_names[i] - }); - } - - init_jplayer("#jquery_jplayer_menu", "menu_loop.mp3", "menu_loop.ogg", true); - menu_music = $("#jquery_jplayer_menu"); - - init_jplayer("#jquery_jplayer_buttons", "buttonmain.mp3", "buttonmain.ogg", false); - button_sounds = $("#jquery_jplayer_buttons"); - - // add random option - // THIS MUST BE THE LAST OBJ IN THE ARRAY - all_bg_music.push({ - name: "Random", - // don't try to access this music! - music: null - }); - track_names.push("Random"); - num_bg_music += 1; - track_index = num_bg_music-1; - // set initial track (random) - g.set_track(track_names[track_index]); - }; - - var num_loaded = 0; - var max_loaded = num_bg_music + 2 // + 1 for menu music, + 1 for button - var bg_music_loaded = function() { - num_loaded++; - console.log("Loaded " + num_loaded + " out of " + max_loaded); - }; - - obj.sounds_loaded = function() { - //console.log(num_loaded); - return num_loaded >= max_loaded; - } - return obj; -}; - -// make a global object -var sounds = sound_manager(); - -// to debug without sounds, use this object -/* -var sounds = { - sounds_loaded: function() { return true; }, - play_sound: function() {}, - play_background_music: function() {}, - pause_background_music: function() {}, - resume_background_music: function() {}, - load_sounds: function() {}, -}; -*/ - - - -/* -var jplayer = $("#jquery_jplayer_1").jPlayer( { - ready: function () { - $(this).jPlayer("setMedia", { - oga :g_soundDataMap["kill"] // "/sounds/kill.ogg" - //mp3 : "sounds/heart_loop1.mp3" - }); - $(this).jPlayer("play"); - //asdf_play(); - console.log("ready"); - }, - supplied : "oga" -}); -//$("#jquery_jplayer_1").jPlayer("setMedia", {mp3 : "sounds/heart_loop1.mp3"}); -var asdf_play = function(){ - $("#jquery_jplayer_1").jPlayer("play"); -}; - -*/ diff --git a/game/old/fb/sounds/Infiltration.mp3 b/game/old/fb/sounds/Infiltration.mp3 deleted file mode 100755 index eb48089..0000000 Binary files a/game/old/fb/sounds/Infiltration.mp3 and /dev/null differ diff --git a/game/old/fb/sounds/Infiltration.ogg b/game/old/fb/sounds/Infiltration.ogg deleted file mode 100755 index 5cce4b5..0000000 Binary files a/game/old/fb/sounds/Infiltration.ogg and /dev/null differ diff --git a/game/old/fb/sounds/buttonback.mp3 b/game/old/fb/sounds/buttonback.mp3 deleted file mode 100755 index 730c75f..0000000 Binary files a/game/old/fb/sounds/buttonback.mp3 and /dev/null differ diff --git a/game/old/fb/sounds/buttonback.ogg b/game/old/fb/sounds/buttonback.ogg deleted file mode 100755 index 109a1e9..0000000 Binary files a/game/old/fb/sounds/buttonback.ogg and /dev/null differ diff --git a/game/old/fb/sounds/buttonmain.mp3 b/game/old/fb/sounds/buttonmain.mp3 deleted file mode 100755 index aea705c..0000000 Binary files a/game/old/fb/sounds/buttonmain.mp3 and /dev/null differ diff --git a/game/old/fb/sounds/buttonmain.ogg b/game/old/fb/sounds/buttonmain.ogg deleted file mode 100755 index 81c13d7..0000000 Binary files a/game/old/fb/sounds/buttonmain.ogg and /dev/null differ diff --git a/game/old/fb/sounds/cell_fire.mp3 b/game/old/fb/sounds/cell_fire.mp3 deleted file mode 100755 index 0e3ebf3..0000000 Binary files a/game/old/fb/sounds/cell_fire.mp3 and /dev/null differ diff --git a/game/old/fb/sounds/cell_fire.ogg b/game/old/fb/sounds/cell_fire.ogg deleted file mode 100755 index 7e91316..0000000 Binary files a/game/old/fb/sounds/cell_fire.ogg and /dev/null differ diff --git a/game/old/fb/sounds/cell_infect.mp3 b/game/old/fb/sounds/cell_infect.mp3 deleted file mode 100755 index 5bc1007..0000000 Binary files a/game/old/fb/sounds/cell_infect.mp3 and /dev/null differ diff --git a/game/old/fb/sounds/cell_infect.ogg b/game/old/fb/sounds/cell_infect.ogg deleted file mode 100755 index 57aaaea..0000000 Binary files a/game/old/fb/sounds/cell_infect.ogg and /dev/null differ diff --git a/game/old/fb/sounds/gameloop2.mp3 b/game/old/fb/sounds/gameloop2.mp3 deleted file mode 100755 index 5c8f4c3..0000000 Binary files a/game/old/fb/sounds/gameloop2.mp3 and /dev/null differ diff --git a/game/old/fb/sounds/gameloop2.ogg b/game/old/fb/sounds/gameloop2.ogg deleted file mode 100755 index 1c94d25..0000000 Binary files a/game/old/fb/sounds/gameloop2.ogg and /dev/null differ diff --git a/game/old/fb/sounds/kill.mp3 b/game/old/fb/sounds/kill.mp3 deleted file mode 100755 index 6bdfebe..0000000 Binary files a/game/old/fb/sounds/kill.mp3 and /dev/null differ diff --git a/game/old/fb/sounds/kill.ogg b/game/old/fb/sounds/kill.ogg deleted file mode 100755 index deed4fc..0000000 Binary files a/game/old/fb/sounds/kill.ogg and /dev/null differ diff --git a/game/old/fb/sounds/level_up.mp3 b/game/old/fb/sounds/level_up.mp3 deleted file mode 100755 index 55e3fcf..0000000 Binary files a/game/old/fb/sounds/level_up.mp3 and /dev/null differ diff --git a/game/old/fb/sounds/level_up.ogg b/game/old/fb/sounds/level_up.ogg deleted file mode 100755 index 468cae0..0000000 Binary files a/game/old/fb/sounds/level_up.ogg and /dev/null differ diff --git a/game/old/fb/sounds/macrophage_infect.mp3 b/game/old/fb/sounds/macrophage_infect.mp3 deleted file mode 100755 index 472498e..0000000 Binary files a/game/old/fb/sounds/macrophage_infect.mp3 and /dev/null differ diff --git a/game/old/fb/sounds/macrophage_infect.ogg b/game/old/fb/sounds/macrophage_infect.ogg deleted file mode 100755 index 0a49c6f..0000000 Binary files a/game/old/fb/sounds/macrophage_infect.ogg and /dev/null differ diff --git a/game/old/fb/sounds/menu_loop.mp3 b/game/old/fb/sounds/menu_loop.mp3 deleted file mode 100755 index 10f3c1d..0000000 Binary files a/game/old/fb/sounds/menu_loop.mp3 and /dev/null differ diff --git a/game/old/fb/sounds/menu_loop.ogg b/game/old/fb/sounds/menu_loop.ogg deleted file mode 100755 index 2008e2f..0000000 Binary files a/game/old/fb/sounds/menu_loop.ogg and /dev/null differ diff --git a/game/old/fb/sounds/old/Level Up!2 Trimmed.ogg b/game/old/fb/sounds/old/Level Up!2 Trimmed.ogg deleted file mode 100755 index ee8fa82..0000000 Binary files a/game/old/fb/sounds/old/Level Up!2 Trimmed.ogg and /dev/null differ diff --git a/game/old/fb/sounds/old/cell_fire.ogg b/game/old/fb/sounds/old/cell_fire.ogg deleted file mode 100644 index bbec785..0000000 Binary files a/game/old/fb/sounds/old/cell_fire.ogg and /dev/null differ diff --git a/game/old/fb/sounds/old/cell_fire.wav b/game/old/fb/sounds/old/cell_fire.wav deleted file mode 100644 index 77f1ba9..0000000 Binary files a/game/old/fb/sounds/old/cell_fire.wav and /dev/null differ diff --git a/game/old/fb/sounds/old/cell_infect.ogg b/game/old/fb/sounds/old/cell_infect.ogg deleted file mode 100644 index a3d5cf8..0000000 Binary files a/game/old/fb/sounds/old/cell_infect.ogg and /dev/null differ diff --git a/game/old/fb/sounds/old/cell_infect.wav b/game/old/fb/sounds/old/cell_infect.wav deleted file mode 100644 index 8cb4011..0000000 Binary files a/game/old/fb/sounds/old/cell_infect.wav and /dev/null differ diff --git a/game/old/fb/sounds/old/kill.ogg b/game/old/fb/sounds/old/kill.ogg deleted file mode 100755 index c127f02..0000000 Binary files a/game/old/fb/sounds/old/kill.ogg and /dev/null differ diff --git a/game/old/fb/sounds/old/level_up.ogg b/game/old/fb/sounds/old/level_up.ogg deleted file mode 100755 index d1b818c..0000000 Binary files a/game/old/fb/sounds/old/level_up.ogg and /dev/null differ diff --git a/game/old/fb/sounds/old/macrophage_infect.ogg b/game/old/fb/sounds/old/macrophage_infect.ogg deleted file mode 100644 index 684fc34..0000000 Binary files a/game/old/fb/sounds/old/macrophage_infect.ogg and /dev/null differ diff --git a/game/old/fb/sounds/sinister.mp3 b/game/old/fb/sounds/sinister.mp3 deleted file mode 100755 index 95905df..0000000 Binary files a/game/old/fb/sounds/sinister.mp3 and /dev/null differ diff --git a/game/old/fb/sounds/sinister.ogg b/game/old/fb/sounds/sinister.ogg deleted file mode 100755 index e5e2d94..0000000 Binary files a/game/old/fb/sounds/sinister.ogg and /dev/null differ diff --git a/game/old/fb/splash_state.js b/game/old/fb/splash_state.js deleted file mode 100644 index 9b57b58..0000000 --- a/game/old/fb/splash_state.js +++ /dev/null @@ -1,202 +0,0 @@ -var splash_state = function (p) { - - // object to return - var obj = game_state(p); - - // --- private variables --- - - //var header_image = p.loadImage("images/screens/header.png"); - var back_image = image_manager.get_image("mainscreenbase.png"); - var back_color = g.background_color; - - // Buttons - // Have a rectangle representing their position and - // a state to go to when pressed - - var top_row_y = 200; - var btm_row_y = 480; - var left_x = 460; - var button_style = { - height: 160, - rect_color: back_color - }; - - // Play menu music - sounds.play_menu_music(); - - var pause_menu_music = function() { - sounds.pause_menu_music(); - }; - - var start_button = button(p, { - state : function() { - pause_menu_music(); - sounds.play_button_click(); - return in_game_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x, top_row_y), - image: "mnewgame.png", - over_image: "mnewgame_r.png", - width: 80, - style: button_style, - } - }); - - var help_button = button(p, { - state : function() { - sounds.play_button_click(); - return help_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x+150, top_row_y), - image: "mhowtoplay.png", - over_image: "mhowtoplay_r.png", - width: 100, - style: button_style, - } - }); - - var options_button = button(p, { - state : function() { - sounds.play_button_click(); - return options_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x, btm_row_y), - image: "msettings.png", - over_image: "msettings_r.png", - width: 120, - style: button_style, - } - }); - - var scores_button = button(p, { - state : function() { - sounds.play_button_click(); - return high_scores_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x+150, btm_row_y), - image: "mhighscores.png", - over_image: "mhighscores_r.png", - //text: "High Scores", - width: 100, - style: button_style, - } - }); - - var credits_button = button(p, { - state : function() { - sounds.play_button_click(); - return credits_state(p, obj); - }, - rect: { - pos: new p.PVector(p.width-100, 30), - image: "credits.png", - width: 200, - height: 50, - } - }); - - /* - var splash_style = { - width : 170, - height : 40, - text_color: 0xFFEE0000, - rect_color: back_color, - text_size: 30, - text_align: p.LEFT - }; - - var button_x = 500; - var button_top = 150; - var button_sep = 60; - - var start_button = button(p, { - state : function() { return in_game_state(p, obj); }, - rect : { - pos : new p.PVector(button_x, button_top), - style : splash_style, - text : "New Game" - //image : "images/screens/newgame_listcell.png" - } - }); - - var options_button = button(p, { - state : function() { return options_state(p, obj); }, - rect : { - pos : new p.PVector(button_x, button_top+button_sep), - style : splash_style, - text : "Settings" - } - }); - - var help_button = button(p, { - state : function() { return help_state(p, obj); }, - rect : { - pos : new p.PVector(button_x, button_top+2*button_sep), - style : splash_style, - text : "How To Play" - } - }); - /* - var high_scores_button = { - state : high_scores_state(), - rectangle : rectangle(p, { - pos : new p.PVector(20, 20), - width : 20, - height : 20 - }) - }; - */ - - //Not ordered - var all_buttons = [start_button, options_button, - help_button, scores_button, credits_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "splash"; - }; - - obj.update = function() { - //do nothing - }; - - obj.key_pressed = function(k) { - if (k === 115 || p.keyCode === 13 || k === 32) { //s, enter, space - obj.set_next_state(start_button.get_state()); - pause_menu_music(); - } - else if (k === 104) { //h - obj.set_next_state(help_button.get_state()); - } - }; - - /* - obj.mouse_moved = function(x, y) { - - for_each( - all_buttons, - function(b) { - b.mouse_moved(x, y); - } - ); - }; - */ - - obj.get_all_buttons = function() { - return all_buttons; - }; - - obj.render = function() { - p.background(back_color); - p.imageMode(p.CENTER); - //p.image(header_image, p.width / 2, 100, p.width * 3/4, 100); - p.image(back_image, p.width/2, p.height/2); - }; - - return obj; -}; diff --git a/game/old/fb/state_manager.js b/game/old/fb/state_manager.js deleted file mode 100644 index 811716b..0000000 --- a/game/old/fb/state_manager.js +++ /dev/null @@ -1,187 +0,0 @@ -// *** state_manager *** -// The game engine; manages all of the games states -// Provides update(), mouse_click(x, y), and key_pressed(k) -// The next state to go to, if applicable, is returned by state.update() - -var state_manager = function (p) { - - // object to return - var obj = {}; - - // --- private variables --- - - var curr_state = loading_state(p); //The currently active state - //p.noLoop(); - var displayed_states = [curr_state]; //THIS MUST ALWAYS BE SORTED BY RENDERING LEVEL - - //A mapping from game states to their rendering levels - var type_to_level = { - "splash": 0, - "loading" : 0, - "game": 1, - "game_over": 2, - "pause": 2, - "credits": 2, - "help": 2, - "options" : 2 - }; - - // --- private methods --- - - //Removes a state from the displayed_states - //The state must be in displayed_states, or will throw an error - function remove_from_displayed(s) { - var index = displayed_states.indexOf(s); - if (index === -1) { - throw "error in remove_from_displayed in state_manager"; - } - displayed_states.splice(index, 1); //remove the element - } - - //Adds a state to displayed_states - //Ensures that displayed_states is sorted by ascending rendering level - var add_to_displayed_states = function(s) { - var render_level = type_to_level[s.get_type()]; - //Insert in the array right before a render level that is higher than it, or - //at the end if none - var inserted = false; - for (var i = 0; i < displayed_states.length; i++) { - var old_render_level = type_to_level[displayed_states[i].get_type()]; - if (old_render_level > render_level) { - displayed_states.splice(i, 0, s); - inserted = true; - } - } - if (inserted === false) { //add to end - displayed_states.push(s); - } - } - - - // --- public methods --- - - //Updates the current state and renders all appropriate states - obj.update = function() { - // Update all the states, and get next_state from curr_state.update_wrapper(); - var next_state = null; - var update_function = function(s) { - if (s === curr_state) { - next_state = s.update_wrapper(); - } - else { - // i see no reason to update not current states - //s.update_wrapper(); - } - }; - for_each(displayed_states, update_function); - - //If we have a new state to go to - if (next_state && next_state !== curr_state) { - //console.log("next is "+next_state.get_type()); - //Figure out if next state is an overlay - var state_type = next_state.get_type(); - var is_overlay = -1; - switch (state_type) { - case "splash": - is_overlay = false; - p.noLoop(); - break; - case "game": - is_overlay = false; - p.loop(); - break; - case "pause": - is_overlay = true; - p.noLoop(); - break; - case "help": - is_overlay = true; - p.noLoop(); - break; - case "game_over": - is_overlay = true; - p.noLoop(); - break; - case "options": - is_overlay = true; - p.noLoop(); - break; - case "loading": - is_overlay = false; - p.loop(); - break; - case "high_scores": - is_overlay = true; - p.noLoop(); - break; - case "credits": - is_overlay = true; - p.noLoop(); - break; - } - - //Error checking - if (is_overlay === -1) { - throw "error in update in state_manager"; - } - - //If overlay, add to displayed, otherwise reset displayed - if (is_overlay) { - // account for multiple overlays - // so we can go back to an overlay - if (member(displayed_states, next_state)) { - remove_from_displayed(curr_state); - } - else { - add_to_displayed_states(next_state); - } - } - else { - displayed_states = [next_state]; - } - curr_state = next_state; - //Potentially a problem, we do this even if not returning to a state - curr_state.resume(); - // updating its buttons - curr_state.update_wrapper(); - } - - for (var i = 0; i < displayed_states.length; i++) { - displayed_states[i].render_wrapper(); - } - - /* - if (curr_state.get_type() !== "game") { - p.noLoop(); - } - else { - p.loop(); - } - */ - }; - - //Passes clicks on to curr_state - obj.mouse_click = function (x, y) { - curr_state.mouse_click_wrapper(x, y); - if (curr_state.get_type() !== "game") { - obj.update(); - } - }; - - obj.key_pressed = function(k) { - curr_state.key_pressed(k); - if (curr_state.get_type() !== "game") { - obj.update(); - } - }; - - obj.mouse_moved = function(x,y) { - curr_state.mouse_moved_wrapper(x, y); - if (curr_state.get_type() !== "game") { - obj.update(); - } - //obj.update(); - } - - return obj; -}; diff --git a/game/old/fb/test.js b/game/old/fb/test.js deleted file mode 100644 index cc645eb..0000000 --- a/game/old/fb/test.js +++ /dev/null @@ -1,92 +0,0 @@ -// all the processing code goes in the function -// which gets passed in a processing instance p -var p_code = function(p) { - - var sm, t1, c1, c2; - - p.setup = function() { - p.size(700, 600); - - // deal with console issues - // TODO move this code - if (!window.console) { - console = { log: function() {} }; - } - Processing.logger = console; - - var f = new p.loadFont("_sans"); - p.textFont(f, 14); - - sm = state_manager(p); - - p.frameRate(30); - }; - - update_counter = 0; - // draw is called repeatedly - p.draw = function() { - update_counter += 1; - if (update_counter === 30) { - //console.log("frame "+p.millis()); - //console.log(p.__frameRate); - update_counter = 0; - } - sm.update(); // Also renders - }; - - //Mouse and Keyboard input - p.keyPressed = function() { - sm.key_pressed(p.key); - }; - p.mousePressed = function() { - sm.mouse_click(p.mouseX, p.mouseY); - }; - p.mouseMoved = function() { - sm.mouse_moved(p.mouseX, p.mouseY); - }; -}; - - -// want this to be global -var sketch; - -var start_game = function() { - // attaches the processing code to the canvas - // note that we need to do this AFTER the canvas element is created - var canvas = document.getElementById("test_canvas"); - sketch = new Processing.Sketch(p_code); - //sketch.options.isTransparent = true; - var pInstance = new Processing(canvas, sketch); -}; -window.onload = start_game; - -/* -var back_code = function(p) { - var tiles = []; - p.setup = function() { - p.size(700, 600); - p.frameRate(30); - tiles.push(background(p, { - pos: new p.PVector(0, 0) - })); - tiles.push(background(p, { - pos: new p.PVector(700, 0) - })); - }; - p.draw = function() { - p.background(200); - for_each(tiles, function(tile) { - tile.update(); - tile.scroll(1); - tile.draw(); - }); - }; -}; -*/ -//var back_canvas = document.getElementById("back_canvas"); -//var backInstance = new Processing(back_canvas, back_code); - -// Make spacebar not move the window down -window.onkeydown = function(e) { - return !(e.keyCode == 32); -}; diff --git a/game/old/fb/tkiller.js b/game/old/fb/tkiller.js deleted file mode 100644 index 1ae4dbb..0000000 --- a/game/old/fb/tkiller.js +++ /dev/null @@ -1,121 +0,0 @@ -// *** tkiller *** -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards - -var tkiller = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 35; - spec.height = spec.height || 35; - spec.speed = spec.speed || 1.5; - - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "tkiller"; - }; - - // --- private variables --- - - var alive = true; - /* @pjs preload="images/tcell2.png"; */ - var t_image = image_manager.get_image("tcell_2.png"); - - // Rect to fill in - var rectx_offset = -(8/30)*obj.get_width(); - var recty_offset = -(7/30) * obj.get_height(); - var rect_width = (13 / 30) * obj.get_width(); - var rect_height = (17 / 30) * obj.get_height(); - - - var t_anim = animated_image("t_animation", {anim_rate : 6}); - var t_image; - t_anim.start(); - t_anim.loop(); - - // --- public methods --- - - // implementing game_object interface - - // update makes tkiller chase target cell - obj.my_update = function() { - obj.move(); - obj.set_speed(obj.get_level()/2 + 1); - }; - - // should point towards target - // (triangle for now) - obj.draw = function() { - var pos = obj.get_pos(); - /* - p.pushMatrix(); - - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.fill(50); - p.noStroke(); - - // rightward triangle - p.triangle(-w/2, -h/2, -w/2, h/2, w/2, 0); - - p.popMatrix(); - */ - p.pushMatrix(); - p.imageMode(obj.get_mode()); - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle() + p.PI / 2); - p.fill(obj.get_color()); - p.noStroke(); - p.rectMode(p.CORNER); - p.rect(rectx_offset, recty_offset, rect_width, rect_height); - //p.image(t_image, 0, 0, obj.get_width(), obj.get_height()); - if (obj.get_target() === null) { - t_anim.set_rate(6); - } - else { - t_anim.set_rate(3); - } - t_image = t_anim.get_frame(); - - if (obj.is_illustration()) { - t_image = image_manager.get_image("tcell_2.png"); - // to make it less transparent draw twice - p.image(t_image, 0, 0, - obj.get_width(), obj.get_height()); - } - - p.image(t_image, 0, 0, - obj.get_width(), obj.get_height()); - p.popMatrix(); - }; - - // is_dead just returns whether it isn't alive - obj.is_dead = function() { - return !alive; - }; - - // which means we need a way to die - obj.die = function() { - alive = false; - }; - - obj.stop_animation = function() { - t_anim.pause(); - }; - - obj.resume_animation = function() { - t_anim.start(); - }; - - return obj; -} diff --git a/game/old/fb/wall_cell.js b/game/old/fb/wall_cell.js deleted file mode 100644 index 62be000..0000000 --- a/game/old/fb/wall_cell.js +++ /dev/null @@ -1,63 +0,0 @@ -// *** wall_cell *** -// --- inherits from game_object -// spec: -// game_object spec - -var wall_cell = function(p, spec) { - - var wall_image = image_manager.get_image("wallcell_1.png"); - - // --- defaults --- - - // temporarily dividing by 2 cuz image is too big - spec.width = spec.width || wall_image.width;///2 || 40; - spec.height = spec.height || wall_image.height;///2 || 20; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "wall_cell"; - }; - - // --- private variables --- - - var alive = true; - - // --- public methods --- - - // implementing game_object interface - - // update is back to the default - obj.update = function() { - obj.move(); - }; - - // (rect for now) - obj.draw = function() { - var pos = obj.get_pos(); - /* - p.shapeMode(obj.mode); - - p.fill(100); - p.noStroke(); - - var w = obj.get_width(); - var h = obj.get_height(); - p.rect(pos.x-w/2, pos.y-h/2, w, h); - */ - p.imageMode(obj.get_mode()); - p.image(wall_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - }; - - obj.is_dead = function() { - return !alive; - }; - - obj.die = function() { - alive = false; - }; - - - return obj; -} diff --git a/game/old/fb/wall_segment.js b/game/old/fb/wall_segment.js deleted file mode 100644 index db886ac..0000000 --- a/game/old/fb/wall_segment.js +++ /dev/null @@ -1,114 +0,0 @@ -// list of specs for wall segments to use in the game -// later can include which image/shape to use -// MUST HAVE WIDTH AND HEIGHT SPECIFIED -/* -var wall_specs = [ - { width: 100, height: 51 } - //{ width: 100, height: 30, fill: 0 }, - //{ width: 200, height: 30, fill: 50 }, - //{ width: 50, height: 30, fill: 100 }, - //{ width: 150, height: 30, fill: 150 } -]; -*/ - -// *** wall_segment *** -// --- inherits from game_object -// spec: -// game_object spec -// boolean is_top = true if it is on the top of the screen -// pos should be at bottom left corner -// -// Each wall segment must match up with the other -// wall segments at each end -// Segment images should be formatted for the bottom wall - -var wall_segment = function(p, spec) { - - //var wall_shape = p.loadShape("images/cellwall1draft.svg"); - var wall_image = random_from( - image_manager.get_images("wall_segments")).image; - - // --- defaults --- - - // temporarily dividing by 3 because the images are 3x too big - spec.width = spec.width || wall_image.width;///3;// || 60; - spec.height = spec.height || wall_image.height;///3;// || 60; - spec.fill = spec.fill || 150; - spec.mode = p.CENTER; - // adjust to center coords - spec.pos.add(new p.PVector(spec.width/2, -spec.height/2)); - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "wall_segment"; - }; - - // --- private variables --- - - // --- public methods --- - - obj.get_y_offset = function() { - return obj.get_height()/2; - }; - - // implementing game_object interface - - // update is default (move) - - // (flat rect for now) - obj.draw = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - p.shapeMode(obj.mode); - // all diff colors for testing - p.fill(0);//spec.fill); - p.noStroke(); - - var w = obj.get_width(); - var h = obj.get_height(); - - p.translate(pos.x, pos.y); - - if (spec.is_top) { - p.rotate(p.PI); - } - - //p.rect(-w/2, -h/2, w, h); - p.imageMode(obj.get_mode()); - p.image(wall_image, 0, 0, w, h); - //p.set(0, 0, wall_shape); - //draw(canvas.getContext('2d')); - //var d = new Date(); - //console.log(d.getMilliseconds()); - //canvas.getContext('2d').drawSvg("images/virusFinal.svg", 300, 10, 20, 20); - //console.log(d.getMilliseconds()); - - p.popMatrix(); - }; - - obj.draw_circle = function() {}; - - // walls can't die - obj.is_dead = function() { - return false; - }; - - //var count = 0; - obj.scroll = function(scroll_factor) { - //count += 1; - //if (count === 1) { - //count = 0; - obj.get_pos().add(new p.PVector(obj.get_scroll_dist(), 0)); - //} - }; - - obj.get_scroll_dist = function() { - return -1; - }; - - return obj; -}; - diff --git a/game/old/fisforformat.min.js b/game/old/fisforformat.min.js deleted file mode 100644 index d890718..0000000 --- a/game/old/fisforformat.min.js +++ /dev/null @@ -1,11 +0,0 @@ -/* - * "f" is for Format & WHAT THE diff?? v0.5.0 - * - * Copyright (c) 2009 Joshua Faulkenberry - * Dual licensed under the MIT and GPL licenses. - * http://docs.jquery.com/License - * - * Date: 2009-03-20 22:15:23 -0700 (Fri, 20 Mar 2009) - * Revision: 6 - */ -window.Date.prototype.f=function(format){if(format=="@"){return this.getTime()}else{if(format=="REL"){var diff=(((new Date()).getTime()-this.getTime())/1000),day_diff=Math.floor(diff/86400);return day_diff==0&&(diff>-60&&"right now"||diff>-120&&"1 minute from now"||diff>-3600&&-(Math.floor(diff/60))+" minutes from now"||diff>-7200&&"1 hour ago"||diff>-86400&&-(Math.floor(diff/3600))+" hours from now"||diff<60&&"just now"||diff<120&&"1 minute ago"||diff<3600&&Math.floor(diff/60)+" minutes ago"||diff<7200&&"1 hour ago"||diff<86400&&Math.floor(diff/3600)+" hours ago")||day_diff==0&&"Tomorrow"||day_diff>-7&&-(day_diff)+" days from now"||-(Math.ceil(day_diff/7))==1&&"1 week from now"||day_diff>-78&&-(Math.ceil(day_diff/7))+" weeks from now"||day_diff>-730&&-(Math.ceil(day_diff/30))+" months from now"||day_diff<=-730&&-(Math.ceil(day_diff/365))+" years from now"||day_diff==1&&"Yesterday"||day_diff<7&&day_diff+" days ago"||(Math.ceil(day_diff/7))==1&&"1 week ago"||day_diff<78&&Math.ceil(day_diff/7)+" weeks ago"||day_diff<730&&Math.ceil(day_diff/30)+" months ago"||Math.ceil(day_diff/365)+" years ago"}}var MONTH_NAMES=["January","February","March","April","May","June","July","August","September","October","November","December"],DAY_NAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],LZ=function(x){return(x<0||x>9?"":"0")+x},date=this,format=format+"",result="",i_format=0,c="",token="",y=date.getYear()+"",M=date.getMonth()+1,d=date.getDate(),E=date.getDay(),H=date.getHours(),m=date.getMinutes(),s=date.getSeconds(),yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k,value=new Object();if(y.length<4){y=""+(y-0+1900)}value.y=""+y;value.yyyy=y;value.yy=y.substr(2,4);value.M=M;value.MM=LZ(M);value.MMM=MONTH_NAMES[M-1];value.NNN=MONTH_NAMES[M-1].substr(0,3);value.N=MONTH_NAMES[M-1].substr(0,1);value.d=d;value.dd=LZ(d);value.e=DAY_NAMES[E].substr(0,1);value.ee=DAY_NAMES[E].substr(0,2);value.E=DAY_NAMES[E].substr(0,3);value.EE=DAY_NAMES[E];value.H=H;value.HH=LZ(H);if(H==0){value.h=12}else{if(H>12){value.h=H-12}else{value.h=H}}value.hh=LZ(value.h);if(H>11){value.K=H-12}else{value.K=H}value.k=H+1;value.KK=LZ(value.K);value.kk=LZ(value.k);if(H>11){value.a="PM"}else{value.a="AM"}value.m=m;value.mm=LZ(m);value.s=s;value.ss=LZ(s);while(i_format=tl[trg]){if(trg=="Y"||trg=="D"||trg=="C"||trg=="T"){for(var yr=(min);yr.getFullYear()<=max.getFullYear();yr.setYear(yr.getFullYear()+1)){if(yr.isLeapYear()){diff-=tl.d}}}if(diff>=tl[trg]){result=Math.floor(diff/tl[trg])+" "+(Math.floor(diff/tl[trg])==1&&names[trg][0]||names[trg][1]);diff=diff%tl[trg]}}eval("breakdown = breakdown.replace(/"+trg+'/g, "")');return result}var min=date<=this&&date||date>this&&this,max=date>this&&date||date<=this&&this,diff=(max.getTime()-min.getTime()),tl={T:1000*60*60*24*365*100*10,C:1000*60*60*24*365*100,D:1000*60*60*24*365*10,Y:1000*60*60*24*365,M:1000*60*60*24*28,W:1000*60*60*24*7,d:1000*60*60*24,H:1000*60*60,m:1000*60,S:1000,N:1},names={T:options.labels.T||["Mellinium","Mellinia"],C:options.labels.C||["Century","Centuries"],D:options.labels.D||["Decade","Decades"],Y:options.labels.Y||["Year","Years"],M:options.labels.M||["Month","Months"],W:options.labels.W||["Week","Weeks"],d:options.labels.d||["Day","Days"],H:options.labels.H||["Hour","Hours"],m:options.labels.m||["Minute","Minutes"],S:options.labels.S||["Second","Seconds"],N:options.labels.N||["Millisecond","Milliseconds"]};if(options.len){for(var x in names){names[x]=names[x].substr(0,options.len)}}var testDt=new Date(min.toString());if(max.getFullYear()-testDt.getFullYear()>1){testDt.setYear(max.getFullYear()-1)}while(testDtmin.getDayLightSavingsDays()[1].getDate())||min.getMonth()0){if(breakdown=="*"){breakdown="TCDYMWdHmSN"}else{if(breakdown.indexOf("T")>-1){if(out=processTime("T")){result[result.length]=out}}else{if(breakdown.indexOf("C")>-1){if(out=processTime("C")){result[result.length]=out}}else{if(breakdown.indexOf("D")>-1){if(out=processTime("D")){result[result.length]=out}}else{if(breakdown.indexOf("Y")>-1){if(out=processTime("Y")){result[result.length]=out}}else{if(breakdown.indexOf("M")>-1){if(diff>=tl.M){var cur=(new Date(max.getTime()-diff));var monthCount=0;var lastVal=0;for(var yr=cur.getFullYear();yr<=max.getFullYear();yr++){while(cur.getFullYear()==yr){lastVal=cur.getTime();cur.setMonth(cur.getMonth()+1);if(diff-(cur.getTime()-lastVal)>=0){monthCount++;diff-=(cur.getTime()-lastVal)}if(yr==max.getFullYear()&&cur.getMonth()==max.getMonth()){break}}}if(monthCount){result[result.length]=monthCount+" "+(monthCount==1&&names.M[0]||names.M[1])}}breakdown=breakdown.replace(/M/g,"")}else{if(breakdown.indexOf("W")>-1){if(out=processTime("W")){result[result.length]=out}}else{if(breakdown.indexOf("d")>-1){if(out=processTime("d")){result[result.length]=out}}else{if(breakdown.indexOf("H")>-1){if(out=processTime("H")){result[result.length]=out}}else{if(breakdown.indexOf("m")>-1){if(out=processTime("m")){result[result.length]=out}}else{if(breakdown.indexOf("S")>-1){if(out=processTime("S")){result[result.length]=out}}else{if(breakdown.indexOf("N")>-1){if(out=processTime("N")){result[result.length]=out}}else{diff=0}}}}}}}}}}}}}options.divider=options.divider||", ";if(options.divider==", "&&result.length>1&&!options.hideAnd){result[result.length-1]="and "+result[result.length-1]}diff=result.join(options.divider)}if(diff==""){diff="Same"}if(options.lc){diff=diff.toLowerCase()}return diff};window.Date.prototype.getDaysInMonth=function(){return[31,28,31,30,31,30,31,31,30,31,30,31][this.getMonth()]};window.Date.prototype.isLeapYear=function(){return(new Date(this.getFullYear(),2-1,29)).getDate()==29};window.Date.prototype.getDayLightSavingsDays=function(){var result=[];var day1=new Date("03/07/"+this.getFullYear());var day2=new Date("03/06/"+this.getFullYear());while(day1.getMonth()<3||(day1.getMonth()==3&&day1.getDate()<16)){if((day1.getTime()-day2.getTime())/1000/60/60!=24){result[result.length]=new Date(day2.getTime())}day1.setDate(day1.getDate()+1);day2.setDate(day2.getDate()+1)}var day1=new Date("10/31/"+this.getFullYear());var day2=new Date("10/30/"+this.getFullYear());while(day1.getMonth()<11||(day1.getMonth()==10&&day1.getDate()<9)){if((day1.getTime()-day2.getTime())/1000/60/60!=24){result[result.length]=new Date(day2.getTime())}day1.setDate(day1.getDate()+1);day2.setDate(day2.getDate()+1)}return result};window.Date.prototype.isDayLightSavingsDay=function(){var comp=new Date(this.getTime());comp.setDate(comp.getDate()+1);return(comp.getTime()-this.getTime())/1000/60/60!=24}; \ No newline at end of file diff --git a/game/old/floater.js b/game/old/floater.js deleted file mode 100644 index 7272c01..0000000 --- a/game/old/floater.js +++ /dev/null @@ -1,122 +0,0 @@ -// *** floater *** -// --- inherits from game_object -// spec: -// game_object spec -// state = leave to be default "alive" - -var floater = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 43; - spec.height = spec.height || 50; - spec.vel = new p.PVector(0, 0.3); - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "floater"; - }; - - // --- private variables --- - - var macrophage_alive = animated_image("macrophage", {reverse : true}); - var macrophage_active = animated_image("macrophage_active", {reverse : true}); - // for illustration - var macro_active_img = image_manager.get_image("macrophage_1_active.png"); - var macro_alive_img = image_manager.get_image("macrophage_1.png"); - - // how far up or down it can move - var range = 50; - var btm_lim = obj.get_pos().y + range; - var top_lim = obj.get_pos().y - range; - // state can be "alive", "activated", or "dead" - var state = spec.state || "alive"; - - // --- public methods --- - - // implementing game_object interface - - obj.update = function() { - // if we reach a limit - var y = obj.get_pos().y; - if (y <= top_lim || y >= btm_lim) { - // turn around - var v = obj.get_vel(); - obj.set_vel(new p.PVector(v.x, -v.y)); - } - obj.move(); - }; - - // (rectangle for now) - obj.draw = function() { - /* - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.fill(obj.get_color()); - - p.stroke(0); - p.strokeWeight(1); - - // had to hack to center rect - // might need to change - p.rect(pos.x-w/2, pos.y-h/2, w, h); - */ - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.imageMode(obj.get_mode()); - if (state === "active") { - p.shapeMode(obj.mode); - p.fill(obj.get_color()); - p.noStroke(); - p.ellipse(pos.x + w / 8, pos.y - w / 8 + 1, w/2, w/2); - if (!obj.is_illustration()) { - macro_active_img = macrophage_active.get_frame(); - } - p.image(macro_active_img, pos.x, pos.y, w, h); - } - else { - if (!obj.is_illustration()) { - macro_alive_img = macrophage_alive.get_frame(); - } - p.image(macro_alive_img, pos.x, pos.y, w, h); - } - }; - - obj.stop_animation = function() { - macrophage_alive.pause(); - macrophage_active.pause(); - }; - - obj.stop_animation = function() { - macrophage_alive.start(); - macrophage_active.start(); - }; - - obj.is_dead = function() { - return state === "dead"; - }; - - obj.is_alive = function() { - return state === "alive"; - }; - - obj.is_activated = function() { - return state === "active"; - }; - - obj.get_state = function() { - return state; - }; - - obj.activate = function() { - state = "active"; - }; - - return obj; -} diff --git a/game/old/game_object.js b/game/old/game_object.js deleted file mode 100644 index 71d409d..0000000 --- a/game/old/game_object.js +++ /dev/null @@ -1,276 +0,0 @@ -// *** game_object *** -// spec: -// mode = p.CENTER or p.CORNERS (constants from processing) -// - describes how the coords work, set by p.shapeMode() -// p.PVector pos = initial position (x,y) -// float width = width of the entire object -// float height = height of the entire object -// float radius = circle collision radius (will be auto-calced) -// p.PVector vel = initial velocity -// p.PVector accel = initial acceleration -// mutation_info = object with level, num_particles and color props -// illustration = boolean that says whether or not to draw animations - -var game_object = function (p, spec) { - - - // object to return - var obj = {}; - - // should be overridden by subtypes - obj.get_type = function() { - return "game_object"; - }; - - obj.DEFAULT_SCROLL_DIST = -1.2; - - // --- private variables --- - - var mode = spec.mode || p.CENTER; - var pos = spec.pos || new p.PVector(0, 0); - var width = spec.width || 0; - var height = spec.height || 0; - var vel = spec.vel || new p.PVector(0, 0); - var accel = spec.accel || new p.PVector(0, 0); - // used for circle collision testing - var radius = spec.radius // default set at bottom of file - // used for mutation - var mutation_info = spec.mutation_info || - { level: -1, color: p.color(0, 0, 0), particles: 0 }; - var illustration = spec.illustration || false; - - var alive = true; - - // --- public methods --- - - // all game_objects must implement this interface: - // void update() - called each frame to move/update objects - // void draw() - called each frame to display the object - // void scroll() - moves the object left by a certain amount - - // update moves obj by default - obj.update = function() { obj.move(); }; - - // draw does nothing by default - obj.draw = function() {}; - - // by default returns the negated alive variable - obj.is_dead = function() { return !alive; }; - - // Generic methods for all game_objects: - // returns true if the object is completely offscreen - // i.e. checks pos + dimensions - obj.is_offscreen = function() { - var left_edge = pos.x - width/2; - var right_edge = pos.x + width/2; - var top_edge = pos.y - height/2; - var btm_edge = pos.y + height/2; - return (left_edge > p.width - || right_edge < 0 - || top_edge > p.height - || btm_edge < 0); - }; - - // Returns if the obj is off the right of the screen - obj.is_off_right = function() { - var left_edge = pos.x - width/2; - return left_edge > p.width; - }; - - - // Bounces the object off a wall, if it is at one - obj.bounce = function() { - var left_edge = pos.x - width; - var right_edge = pos.x + width; - var top_edge = pos.y - height; - var btm_edge = pos.y + height; - if (top_edge <= 0 && vel.y < 0) { - vel.y = -vel.y; - } - if (btm_edge >= p.height && vel.y > 0) { - vel.y = -vel.y; - } - if (left_edge <= 0 && vel.x < 0) { - vel.x = -vel.x; - } - if (right_edge >= p.width && vel.x > 0) { - vel.x = -vel.x; - } - }; - - // reverses the y velocity - // used for bouncing vertically - obj.reverse_y = function() { - var vel = obj.get_vel(); - obj.set_vel(new p.PVector(vel.x, -vel.y)); - }; - - // reverses the x velocity - // used for bouncing horizontally - obj.reverse_x = function() { - var vel = obj.get_vel(); - obj.set_vel(new p.PVector(- vel.x, vel.y)); - }; - - // updates the position according to accel and vel - // Bounces off walls - obj.move = function() { - vel.add(accel); - pos.add(vel); - }; - - // stops the object in its tracks by zeroing out vel - obj.stop = function() { - vel = new p.PVector(0, 0); - }; - - // Scrolls the obj a specified distance left or right (positive is right) - obj.scroll = function(scroll_factor) { - var scroll_x = obj.get_scroll_dist(); - if (scroll_x === null) { - scroll_x = obj.DEFAULT_SCROLL_DIST; - } - pos.add(new p.PVector(scroll_x*scroll_factor, 0)); - }; - - obj.die = function() { - alive = false; - }; - - obj.is_illustration = function() { - return illustration; - }; - - // --- setters --- - - obj.set_illustration = function(i) { - illustration = i; - }; - - obj.set_pos = function(new_pos) { - pos = new_pos; - }; - - obj.set_accel = function(new_accel) { - accel = new_accel; - }; - - obj.set_vel = function(new_vel) { - vel = new_vel; - }; - - // should only be used once, just for circular objects - obj.set_radius = function(new_radius) { - radius = new_radius; - }; - - // Should only be used for collisions - obj.set_pos = function(posn) { - pos = posn; - }; - - obj.set_mutation_info = function(m) { - mutation_info = m; - }; - - // --- getters --- - - // Override to set different scroll dist - // or leave as null to use default - obj.get_scroll_dist = function() { - return null; - }; - - obj.get_pos = function() { - return pos; - }; - - obj.get_left = function() { - return pos.x - (width / 2); - }; - - obj.get_top = function() { - return pos.y - (height / 2); - }; - - obj.get_right = function() { - return pos.x + (width / 2); - }; - - obj.get_bottom = function() { - return pos.y + (height / 2); - }; - - // returns the x offset for rectangle collisions - // should be overridden for rectangular objects - obj.get_x_offset = function() { - return 0; - }; - // returns the y offset for rectangle collisions - // should be overridden for rectangular objects - obj.get_y_offset = function() { - return 0; - }; - - obj.get_width = function() { - return width; - }; - - obj.get_height = function() { - return height; - }; - - obj.get_mode = function() { - return mode; - }; - - obj.get_vel = function() { - return vel; - }; - - obj.get_accel = function() { - return accel; - }; - - obj.get_radius = function() { - return radius; - }; - - obj.get_mutation_info = function() { - return mutation_info; - }; - - obj.get_color = function() { - return mutation_info.color; - }; - - obj.get_level = function() { - return mutation_info.level; - }; - - obj.is = function(type) { - return obj.get_type() === type; - }; - - obj.to_string = function() { - return obj.get_type()+" ("+pos.x+", "+pos.y+")"; - }; - - // draws the collision circle as an overlay - obj.draw_circle = function() { - p.fill(255, 50); - p.noStroke(); - p.shapeMode(p.CENTER); - p.ellipse(pos.x, pos.y, 2*radius, 2*radius); - }; - - // uses pythagorean theorem to calc radius of bounding circle - obj.calc_radius = function() { - return 0.5*p.sqrt(width*width+height*height); - }; - - // calc radius if not already set - radius = radius || obj.calc_radius(); - - return obj; -} diff --git a/game/old/game_over_state.js b/game/old/game_over_state.js deleted file mode 100644 index 99662c2..0000000 --- a/game/old/game_over_state.js +++ /dev/null @@ -1,175 +0,0 @@ -// spec: -// score : num representing score of game -// mutation_level : num representing mutation level at end of game - -var game_over_state = function (p, prev_state, spec) { - //right now, prev_state is not used - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var topy = 100; - // Score display - var score_rect = rectangle(p, { - pos : new p.PVector(p.width / 2, topy+80),// 230), - width : 0, - height : 0, - text : "Score: " + add_commas(spec.score), - text_size : 30, - text_color : 255 - }); - - var mutation_rect = rectangle(p, { - pos : new p.PVector(p.width / 2, topy+130),//280), - width : 0, - height : 0, - text : "Mutation Level: " + spec.mutation_level, - text_size : 30, - text_color : 255 - }); - - var b_top = topy+180; - var b_spc = 60; - var button_style = { - width: 120, height: 50, - text_align: p.LEFT, - }; - // Buttons - var restart_button = button(p, { - state : function() { - sounds.play_button_click(); - return in_game_state(p, prev_state); - }, - rect : { - pos : new p.PVector(p.width / 2, b_top),//330), - //text : "Restart", - //text_x_offset: 40, - image: "restart.png", - //style: button_style - } - }); - var post_button = button(p, { - state : function() { - // only post if they are logged in - if (g_user_id) { - sounds.play_button_click(); - FB.ui({ - method: 'feed', - name: "Play Virion!", - picture: "http://virus-game.cs.brown.edu/images/logo/vlogolarge.png", - link: "http://apps.facebook.com/viriongame", - caption: "I just scored "+add_commas(spec.score)+ - " playing Virion!", - }); - } - return obj; - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+b_spc),//390), - //text : "Post Score to Wall", - //text_x_offset: 35, - image: "postscore.png", - //style: button_style - } - }); - var invite_button = button(p, { - state : function() { - // only post if they are logged in - if (g_user_id) { - sounds.play_button_click(); - FB.ui({ - method: 'apprequests', - title: "Infect Your Friends", - message: 'Check out this awesome game!', - }); - } - return obj; - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+2*b_spc),//450), - //text : "Infect Your Friends", - //text_x_offset: 35, - image: "infectfriends.png", - //style: button_style - } - }); - - // only allow posts/invites if logged in - if (!g_user_id) { - post_button.deactivate(); - invite_button.deactivate(); - } - - var scores_button = button(p, { - state : function() { - sounds.play_button_click(); - return high_scores_state(p, obj); - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+3*b_spc),//510), - //text : "High Scores", - //text_x_offset: 35, - image: "highscores.png", - //style: button_style - } - }); - var splash_button = button(p, { - state : function() { - sounds.play_button_click(); - return splash_state(p); - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+4*b_spc),//570), - //text : "Main Menu", - //text_x_offset: 35, - image: "mainmenu.png", - //style: button_style - } - }); - - //Not ordered - var all_buttons = [restart_button, post_button, - invite_button, splash_button, scores_button]; - var all_rectangles = [score_rect, mutation_rect]; - - // --- public methods --- - - obj.get_type = function() { - return "game_over"; - }; - - obj.update = function() { - //do nothing - }; - - obj.key_pressed = function(k) { - if (k === 114 || p.keyCode === 13) { //r, enter - obj.set_next_state(restart_button.get_state()); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - obj.render = function() { - p.fill(0, 150); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.fill(255); - p.textAlign(p.CENTER); - - p.textSize(50); - p.text("Game Over", p.width/2, topy); - p.textSize(20); - p.text("Your virus was wiped out!", p.width/2, topy+30); - - for_each(all_rectangles, function(r) {r.draw();}); - }; - - return obj; -}; diff --git a/game/old/game_state.js b/game/old/game_state.js deleted file mode 100644 index 775f8f9..0000000 --- a/game/old/game_state.js +++ /dev/null @@ -1,124 +0,0 @@ -// *** game_state *** -// Interface for all game states - -// NOTE ALL OF THE FOLLOWING WHEN CREATING A GAME STATE: -// All game states must take a previous_state in their constructor, and then call set_previous_state() -// The exception to this is splash, which is the base state and should never be exited -// If a state change happens in: -// update() - return the new state -// mouse_click/key_pressed: Call set_next_state(new_state) with the state to go to -// Buttons: -// Drawing and clicking of buttons is taken care of -// You must take care of key strokes - -var game_state = function (p) { - - // object to return - var obj = {}; - - // --- private variables --- - var next_state = null; - var previous_state = null; - var all_buttons = []; //TODO: This is static but is updated every update() - - - // --- public methods --- - - //Wrapper for every states render function - //First draws all the buttons, then calls render - obj.render_wrapper = function() { - obj.render(); - for_each(all_buttons, function(b) { b.draw(); }); - }; - - //Do not over-ride these methods - obj.set_next_state = function(ns) { - next_state = ns; - }; - obj.set_previous_state = function(ps) { - previous_state = ps; - }; - obj.exit_state = function() { - if (previous_state === null) { - throw "error previous state not set in game_state"; - } - assert(previous_state !== null, "Previous state was null in game_state.exit_state"); - next_state = previous_state; - }; - - // Wrapper for every states update function - // Goes to the next state (by returning it) if next_state has been set - obj.update_wrapper = function() { - all_buttons = obj.get_all_buttons(); - if (next_state !== null) { - var to_return = next_state; - //in case we return to this state (CURRENTLY, SHOULDN'T EVER HAPPEN I THINK) - next_state = null; - return to_return; - } - //else - obj.update(); - obj.render_wrapper(); - }; - - // Wrapper for mouse clicks - // First checks if any of the buttons are clicked, then calls mouse_click - obj.mouse_click_wrapper = function(x, y) { - var click_function = function(b) { - var next_state = b.is_clicked(x, y); - if (next_state !== null) { - obj.set_next_state(next_state); - } - } - for_each(all_buttons, click_function); - obj.mouse_click(x, y); - }; - - obj.mouse_moved_wrapper = function(x, y) { - for_each( - all_buttons, - function(b) { - b.mouse_moved(x, y); - } - ); - obj.mouse_moved(x, y); - }; - - - // all game_states must implement the following functions: - - //Returns the type of the state - obj.get_type = function() { - return "get_type not overwritten"; - }; - - //Takes in the key pressed and handles a key press - obj.key_pressed = function(k) {throw "key_pressed not overwritten"}; - - // Do nothing unless overwritten - obj.mouse_moved = function(x, y) {}; - - //Updates the current state, and returns the next state to go to - //next state can be: - // null, if no state change - // a state representing a state to go to (either previous state or newly created next state - obj.update = function() {throw "update not overwritten"}; - - // Returns all of the buttons on the screen - obj.get_all_buttons = function() {throw "get_all_buttons not overwritten"}; - - // --- Optionally implement these, they default to nothing --- - - //Renders the current state - obj.render = function(){ }; //throw "render not overwritten"}; - - //Takes in the x and y coordinates of the mouse, and handles a mouse click - obj.mouse_click = function(x, y){}; //throw "mouse_click not overwritten"}; - - //Called when returning to this state - obj.resume = function() {}; - - - - return obj; -}; diff --git a/game/old/generator.js b/game/old/generator.js deleted file mode 100644 index acad075..0000000 --- a/game/old/generator.js +++ /dev/null @@ -1,393 +0,0 @@ -// *** generator *** -// generates random enemies -// spec: -// game : an in_game_state -// Is going to access: (through getters since we're so safe) -// game_objects - array -// distance - a num -// type_to_level - hash from type to level -// active_cell -// mutation : a mutation obj, so it can get current mutation color - -var make_generator = function(p, spec) { - // --- defaults --- - - // obj to return - var obj = {}; - - // --- private variables --- - - //These will be updated at every call of update() - var game_objects = null; - var distance = null; - var mutation = spec.mutation; - var game = spec.game; - var last_obj = null; // The last object generated - - var default_gen_speed = 10; - // structure that stores the generation settings - // for each type of object - // - start = distance after which to start generating - // - num = how many total on screen - // - cap = upper limit on num - // - rate = determines when to increment num - // when dist % rate = 0, num increments - // - gen_speed = speed with which to generate the object - // 1 (1/100 frames) to 100 (100/100 frames) - // If not specified, defaults to DEFAULT_GEN_SPEED - // - spacing = diagonal space to put b/w objects of this type (optional) - // - gen_x = how far offscreen to gen this type (optional) - // - gen_y = function that returns random y pos for this object (optional) - // - make_new = function that takes a pos and returns a new enemy - // - diminish = Include to make enemy's num decrease over time instead of increasing (optional) - var gen_info = { - "cell": { - // was 8 - start: 0, num: 30, cap: 10, rate: 2000, gen_speed: 55, diminish : true, - spacing: 50, - make_new: function(en_pos) { - return cell(p, { - pos: en_pos, - state: "alive", - }); - } - }, - "wall_cell": { - start: 0, num: 3, cap: 7, rate: 3000, //non testing value: 1000 - spacing: "dynamic",//100, - make_new: function(en_pos) { - return wall_cell(p, { pos: en_pos }); - } - }, - "empty_cell": { - start: 5000, num: 1, cap: 10, rate: 5000, - make_new: function(en_pos) { - return empty_cell(p, { pos: en_pos }); - } - }, - "floater": { - start: 1000, num: 3, cap: 7, rate: 7000, - spacing: "dynamic",//100, - make_new: function(en_pos) { - return floater(p, { pos: en_pos }); - } - }, - /* - "tkiller": { - start: 1000, num: 1, cap: 5, rate: 20000, - make_new: function(en_pos) { - // target will get set later - return tkiller(p, { - pos: en_pos, - mutation_info: game.get_mutation_info() - }); - } - }, - */ - "multiplier": { - start:0, num: 10, cap: 20, rate: 20000, - make_new: function(en_pos) { - return multiplier(p, { pos : en_pos }); - } - }, - /* - "b_cell": { - start:0, num: 1, cap: 1, rate: 999999, - make_new: function(en_pos) { - return b_cell(p, { pos : en_pos }); - } - }, - */ - "background_object": { - start:0, num: 8, cap: 8, rate: 999999, - spacing: p.width/5, gen_x: 500, - gen_y: function() { - return p.random(200, p.height - 180); - }, - make_new: function(en_pos) { - return background_object(p, { pos: en_pos }); - } - }, - }; - - // list of types of enemies - var enemy_types = keys(gen_info); - /*var random_type = function() { - return random_from(enemy_types);//[p.floor(p.random( - //enemy_types.length))]; - }; - */ - - // just some wrappers - var start = function(type) { - return gen_info[type].start; - }; - var num = function(type) { - return gen_info[type].num; - }; - var cap = function(type) { - return gen_info[type].cap; - }; - var rate = function(type) { - return gen_info[type].rate; - }; - var spacing = function(type) { - // dynamic spacing - if(gen_info[type].spacing === "dynamic") { - return p.width/num(type); - } - return gen_info[type].spacing; - }; - var gen_x_pos = function(type) { - return p.width + (gen_info[type].gen_x || 50); - }; - var gen_y_pos = function(type) { - if (gen_info[type].gen_y) { - return gen_info[type].gen_y(); - } - return p.floor(p.random(90, p.height-50)); - }; - var gen_speed = function(type) { - return gen_info[type].gen_speed; - }; - var make_new = function(type) { - return gen_info[type].make_new; - }; - var diminish = function(type) { - return gen_info[type].diminish || false; - } - var gen_more = function(type) { - if (diminish(type)) { - if (num(type) > cap(type)) { - gen_info[type].num = num(type)-1; - } - } - else { - if (num(type) < cap(type)) { - gen_info[type].num = num(type)+1; - } - } - }; - - // Returns whether it is not too soon to generate another - // object, based on last_obj - var ok_to_generate = function() { - if (last_obj) { - if (last_obj.get_type() === "cell") { - // 2 times width spacing - return last_obj.get_pos().x < - (gen_x_pos(last_obj.get_type()) - last_obj.get_width() * 2); - } - } - // else - return true; - }; - - // --- public methods --- - - //Should be called every time the game updates - obj.update = function() { - //game_objects = game.get_game_objects(); - distance = p.floor(game.get_distance()); - - update_types(); - - var enemy_type = random_from(enemy_types);//random_type(); - var num_enemies = count_enemy(enemy_type); - - // if there aren't enough of that enemy on the board - if (num_enemies < num(enemy_type) - // and some random factor - && p.random(100) < (gen_speed(enemy_type) || default_gen_speed ) - // and we are ready to start making this enemy - && distance >= start(enemy_type)) { - //&& ok_to_generate()) { - - var enemy_y = gen_y_pos(enemy_type); - var enemy_pos = new p.PVector(gen_x_pos(enemy_type), enemy_y); - - var new_enemy = make_new(enemy_type)(enemy_pos); - assert(new_enemy, "Error in generator.update()"); - - // make sure it's far enough away from the last object - // of its type - if (!spaced_out_enough(new_enemy)) { - return; - } - - // make sure it's not overlapping anything else - if (is_overlapping(new_enemy) - && !new_enemy.is("background_object")) { - //console.log("overlapped"); - return; - } - - //Add the new enemy to game_objects - game.add_object(new_enemy); - - // If b cell, must update b cells targets - if (new_enemy.get_type() === "b_cell") { - console.log("made new b_cell"); - game.set_b_cell_target(new_enemy); - } - - last_obj = new_enemy; - } - - }; - - // --- private methods --- - - var update_types = function() { - /* - if (distance % 100 <= 0.5) { - console.log(distance); - } - */ - // update nums for types based on rate - for_each( - enemy_types, - function(type) { - if (distance % rate(type) <= 0.1 - && distance >= 10) { - gen_more(type); - console.log("increased num of "+type+ - "s to "+num(type)); - } - } - ); - }; - - // returns how many of given enemy there are - var count_enemy = function(enemy_type) { - var n = 0; - game.do_to_type(function(o) { n++; }, - enemy_type, true); - return n; - } - - // returns true if the enemy overlaps any game objects - var is_overlapping = function(enemy) { - var overlap = false; - var check_overlap = function(obj) { - if (game.check_circle_collision(enemy, obj)) { - overlap = true; - } - }; - game.do_to_type(check_overlap, "particle", false); - game.do_to_type(check_overlap, "cell", false); - game.do_to_type(check_overlap, "enemy", false); - game.do_to_type(check_overlap, "wall_segment", false); - return overlap; - }; - - // returns true if the new enemy if far enough away (in x coord) - // from the rightmost of its type - // or if there is no spacing requirement for that type - var spaced_out_enough = function(new_enemy) { - var to_return = true; - // if there is spacing defined for this type - if (spacing(new_enemy.get_type())) { - var min_dist = 99999; - // find the closest object of the type - game.do_to_type( - function(o) { - var dist = new_enemy.get_pos().dist(o.get_pos()); - if (dist < min_dist) { - min_dist = dist; - // check if it is too close - if (dist < spacing(new_enemy.get_type())) { - to_return = false; - } - } - }, - new_enemy.get_type(), true - ); - } - return to_return; - }; - - - - /* - // return true if it is far enough apart from rightmost of its type - return new_enemy.get_pos().dist( - rightmost(new_enemy.get_type()).get_pos()) - > spacing(new_enemy.get_type()); - } - return true; - }; - - /* - var rightmost = function(type) { - var rightmost_x = 0; - var rightmost; - game.do_to_type( - function(o) { - if (o.get_pos().x > rightmost_x) { - rightmost = o; - rightmost_x = o.get_pos().x; - } - }, - type, true - ); - return rightmost; - }; - */ - - // returns an object: - // cell: number of cells on the screen - // wall_cell: number of wall_cells - // empty_cell: number of empty_cells - // tkiller: number of tkillers - // floater: number of floaters - var get_enemies = (function() { - var total = 0; - - // These are the types to check - //var types = ["cell", "wall_cell", "empty_cell", - // "floater", "tkiller"]; - - //Checks if an element is in an array - var member = function(arr, elem) { - return (arr.indexOf(elem) != -1); - }; - - var get_em = function() { - var enemies = { "cell":0, "wall_cell":0, - "empty_cell":0, "floater":0, "tkiller":0, - "multiplier":0, "b_cell":0}; - - // increment counter for each object - var incr = function(o) { - enemies[o.get_type()] += 1; - }; - game.do_to_type(incr, "cell", false); - game.do_to_type(incr, "enemy", false); - }; - /*for (var type in enemies) { - if (enemies.hasOwnProperty(type)) { - game.do_to_type( - function(o) { - enemies[type] += 1; - }, - type, true); - } - } - /*for (var i = 0; i < game_objects.length; i++) { - var lst = game_objects[i]; - for (var j = 0; j < lst.length; j++) { - var obj = lst[j]; - if (member(types, obj.get_type())) { - total++; - } - } - } - return total; - */ - - return get_em; - }()); - - return obj; -}; diff --git a/game/old/global_functions.js b/game/old/global_functions.js deleted file mode 100644 index d6c3167..0000000 --- a/game/old/global_functions.js +++ /dev/null @@ -1,90 +0,0 @@ -// ** Global Constants -//DEFAULT_SCROLL_DIST = -0.8; - -// *** global_functions *** -// Holds functions used in the whole project - -//Have to catch it so fuck it -/* -function AssertException(message) { this.message = message}; -function assert(exp, message) { - if (!exp) { - throw new AssertException(message); - } -} -*/ - -var assert = function(exp, message) { - if (!exp) { - console.error("Assert error!: " + message); - } -}; - -//Does something to every element of an arr -var for_each = function(arr, fun) { - for (var i = 0; i < arr.length; i++) { - fun(arr[i]); - } -}; - -// returns the index+1 of an element in a list, -// otherwise false -// can't return just the index because 0 is false in js -var member = function(arr, elt) { - for (var i=0; i 1 ? '.' + x[1] : ''; - var rgx = /(\d+)(\d{3})/; - while (rgx.test(x1)) { - x1 = x1.replace(rgx, '$1' + ',' + '$2'); - } - return prefix + x1 + x2; -}; - diff --git a/game/old/help.txt b/game/old/help.txt deleted file mode 100644 index 7bdf35b..0000000 --- a/game/old/help.txt +++ /dev/null @@ -1,9 +0,0 @@ -You've managed to infiltrate the human body's defenses and get your virus particle into the bloodstream! Now you must infect cells and use them to make more copies of your virus before the immune system wipes you out. - -After a particle infects a cell, the virus will use the cell's machinery to start making copies of itself. Once the cell is full of new virus particles, press the SPACEBAR or click the MOUSE to kill the cell, causing virus particles to burst through the cell wall towards other cells in the direction the arrow is pointing. You can pick which cell to burst using the LEFT and RIGHT arrow keys. - -Aim carefully though, because the immune system has sent out macrophages to absorb your particles. If a particle hits a macrophage, it will signal a B-cell, which will start producing antibodies. If an antibody attaches to an infected cell, a T-cell will attack it. If you don't burst the cell in time, the T-cell will kill it, destroying all the particles inside! - -Luckily, your virus can mutate and temporarily escape the immune system. Every time the virus replicates, there are errors when copying the virus's genetic material. These errors may cause mutations in the virus. Each time you infect a cell, the virus becomes more and more likely to mutate. Once you mutate, the immune system will not be able to attack you until a macrophage absorbs a virus particle from the new strain. - -How long will your virus be able to survive? diff --git a/game/old/help_state.js b/game/old/help_state.js deleted file mode 100644 index e848712..0000000 --- a/game/old/help_state.js +++ /dev/null @@ -1,627 +0,0 @@ -var help_state = function (p, prev_state) { - - var help_image = image_manager.get_image("helpsplash.png"); - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var screens = []; - var screen_w = help_image.width - 180; - var screen_h = help_image.height - 200; - var screen_pos = new p.PVector(p.width/2, p.height/2-15); - - var screen_index = 0; - var cur_screen = function() { - return screens[screen_index]; - }; - var next_screen = function() { - if (screen_index <= screens.length-1) { - screen_index += 1; - if (screen_index === screens.length-1) { - next_button.deactivate(); - } - previous_button.activate(); - return true; - } - return false; - }; - var previous_screen = function() { - if (screen_index >= 0) { - screen_index -= 1; - if (screen_index === 0) { - previous_button.deactivate(); - } - next_button.activate(); - return true; - } - return false; - }; - - // a screen is a panel that goes in the screens array - // it displays one or more item - // spec: - // - pos: PVector representing the center of the screen - // - width - // - height - var screen = function(spec) { - var obj = {}; - var items = []; - obj.add_item = function(item) { - items.push(item); - }; - - obj.render = function() { - p.pushMatrix(); - - p.translate(spec.pos.x-spec.width/2, spec.pos.y-spec.height/2); - - // debugging - /* - p.noFill(); - p.stroke(255); - p.rect(0, 0, spec.width, spec.height); - */ - - // translate and render each item - var padding = 15; - for_each( - items, - function(item) { - item.render(); - p.translate(0, item.height()+padding); - } - ); - - p.popMatrix(); - }; - - return obj; - }; - - var new_screen = function() { - return screen({ - pos: screen_pos, - width: screen_w, - height: screen_h - }); - }; - - // item displays text and an image as part of a screen - // spec: - // - width - // - height - // - text - the text to display - // - title - the name of this item (optional) - // - image - image to display - // - illustration (obj) - // - width, height - dimensions for the illustration - // - draw - function that draws some illustration - // (origin at top left corner) - // - img_left - boolean, true if the image/ill should go on the left, - // false for the right - // (should only have image or illustration) - // - var item = function(spec) { - var obj = {}; - - // auto height - spec.height = spec.height - // the 0 here just takes us to the next cond - || (spec.image ? spec.image.height : 0) - // the actual default is at the end of this - || (spec.illustration ? spec.illustration.height : 80); - spec.width = spec.width || screen_w; - spec.padding = spec.padding || 10; - - obj.height = function() { return spec.height; }; - - obj.render = function() { - var text_x = 0; - var text_y = 0; - var text_w = spec.width; - - if (spec.image || spec.illustration) { - // make adjustments based on either one - var i = spec.image || spec.illustration; - text_w -= i.width + spec.padding; - var img_x = spec.width - i.width; - if (spec.img_left) { - img_x = 0; - text_x = i.width + spec.padding; - } - // draw either - if (spec.image) { - p.imageMode(p.CORNER); - p.image(spec.image, img_x, 0); - } - else { - p.pushMatrix(); - p.translate(img_x, 0); - spec.illustration.draw(); - p.popMatrix(); - } - } - - if (spec.title) { - p.textSize(18); - p.textAlign(p.LEFT, p.TOP); - p.fill(255); - p.text(spec.title, text_x, 0); - text_y += p.textAscent(); - } - p.textSize(14); - p.textAlign(p.LEFT, p.TOP); - p.fill(255); - p.text(spec.text, text_x, text_y, text_w, spec.height-text_y); - }; - - return obj; - }; - - // init the help screens - // eval'd immediately - var init_screens = (function() { - var color1 = 0xffffff00; - var color2 = 0xff7f2aff; - var cimg = image_manager.get_image("infectable_cell_2n.png"); - - var s1 = new_screen(); - screens.push(s1); - s1.add_item(item({ - text: "You've infiltrated the human body's defenses and gotten your virus particle (or virion) into the bloodstream! Here are the cells you may encounter:", - height: 45, - padding: 1, - illustration: { - width: 30, height: 30, - draw: function() { - var img = image_manager.get_image("tinyvirus_trans.png"); - var w = 15; - var h = 15; - p.fill(color1); - p.noStroke(); - p.ellipse(w, h, w*.75, h*.75); - p.imageMode(p.CENTER); - p.image(img, w, h, w, h); - } - }, - img_left: false - })); - s1.add_item(item({ - title: "Infectable Cells", - text: "Hit an infectable cell with a virion to infect it. After penetrating the cell wall, the virion will use the cell's machinery to make copies of itself.", - //image: cimg, - illustration: { - width: 50, height: 60, - draw: (function() { - var c = cell(p, { - pos: new p.PVector(30, 30), - width: 30, height: 30, - illustration: true - }); - c.set_image(cimg); - //c.set_state("active"); - return function() { - c.draw(); - }; - }()), - }, - img_left: true - })); - s1.add_item(item({ - text: "Press SPACEBAR or click the MOUSE to burst an infected cell and shoot the new virions in the direction of the arrow. Pick which cell to burst using the LEFT and RIGHT arrow keys.", - //image: image_manager.get_image("infectable_cell_2n.png"), - illustration: { - width: 30, height: 60, - draw: (function() { - var c = cell(p, { - pos: new p.PVector(20, 30), - width: 30, height: 30, - mutation_info: { color: color1 }, - illustration: true - }); - c.set_image(cimg); - c.set_state("active"); - return function() { - c.draw(); - }; - }()), - }, - img_left: false - })); - s1.add_item(item({ - title: "Tolerant Cells", - text: "Some cells can be infected, but will not let your virion replicate. A virion that infects a tolerant cell is as good as dead.", - illustration: { - width: 50, height: 60, - draw: (function() { - var c = empty_cell(p, { - pos: new p.PVector(30, 30), - width: 30, height: 30, - }); - return function() { - c.draw(); - }; - }()), - }, - img_left: true - })); - s1.add_item(item({ - title: "Resistant Cells", - text: "Virions can't break through the cell wall of resistant cells - they will just bounce off in the other direction.", - height: 60, - illustration: { - width: 30, height: 60, - draw: (function() { - var c = wall_cell(p, { - pos: new p.PVector(20, 30), - //width: 30, height: 30, - }); - return function() { - c.draw(); - }; - }()), - }, - img_left: false - })); - - var s2 = new_screen(); - screens.push(s2); - s2.add_item(item({ - text: "Be careful! The immune system will try to destroy your virus. Here are the enemies you should look out for:", - height: 30 - })); - s2.add_item(item({ - title: "Macrophages", - text: "The immune system's first line of defense. They will absorb any virion that hits them and then signal a B cell to give it information about your virus.", - height: 80, - //image: image_manager.get_image("macrophage_1.png"), - illustration: { - width: 50, height: 70, - draw: (function() { - var m = floater(p, { - pos: new p.PVector(25, 35), - width: 50, height: 70, - mutation_info: { color: color1 }, - illustration: true - }); - m.activate(); - return function() { - m.draw(); - }; - }()) - }, - img_left: true - })); - s2.add_item(item({ - title: "B Cells", - text: "Once a B cell knows about your virus, it will produce Y-shaped antibodies that will attach to infected cells, marking them for destruction.", - height: 70, - //image: image_manager.get_image("bcell_normal.png"), - illustration: { - width: 60, height: 60, - draw: (function() { - var b = b_cell(p, { - pos: new p.PVector(30, 55), - width: 40, height: 40, - mutation_info: { color: color1 }, - illustration: true - }); - b.set_state("active"); - b.set_target_angle(-p.PI/2); - - var a1 = antibody(p, { - pos: new p.PVector(40, 17), - mutation_info: { color: color1 }, - }); - a1.set_target_angle(-p.PI/4); - - var a2 = antibody(p, { - pos: new p.PVector(18, 23), - mutation_info: { color: color1 }, - }); - a2.set_target_angle(-3*p.PI/4+.2); - - return function() { - // make a thicker antibody - b.set_anti_count(10); - b.draw(); - a1.draw(); - a2.draw(); - }; - }()) - }, - img_left: false - })); - s2.add_item(item({ - title: "Killer T Cells", - text: "If an infected cell is marked with an antibody, the killer T cell will hunt it down and destroy it, along with all the virions inside!", - //image: image_manager.get_image("tcell_2.png"), - illustration: { - width: 60, height: 60, - draw: (function() { - var tk = tkiller(p, { - pos: new p.PVector(30, 30), - width: 60, height: 60, - mutation_info: { color: color1 }, - illustration: true - }); - //tk.set_state("alive"); - - return function() { - tk.draw(); - }; - }()) - }, - img_left: true - })); - - var s3 = new_screen(); - screens.push(s3); - s3.add_item(item({ - title: "Mutation", - text: "Luckily, in the process of replicating a virus's genetic material, mistakes are often made, causing the virus to mutate! If a mutation occurs, a new strain of the virus will be created. Every time you infect a cell, the chance of a mutation occurring increases.", - height: 120, - padding: 15, - illustration: { - width: 90, height: 90, - draw: (function() { - var c1 = cell(p, { - pos: new p.PVector(10, 20), - width: 30, height: 30, - mutation_info: { color: color1 }, - illustration: true - }); - c1.set_image(cimg); - c1.set_state("infected"); - - var c2 = cell(p, { - pos: new p.PVector(70, 80), - width: 30, height: 30, - mutation_info: { color: color2 }, - illustration: true - }); - c2.set_image(cimg); - c2.set_state("infected"); - - return function() { - c1.draw(); - c2.draw(); - p.stroke(255); - p.strokeWeight(3); - p.line(30, 40, 50, 60); - p.line(50, 60, 50, 50); - p.line(50, 60, 40, 60); - }; - }()), - }, - img_left: false - })); - s3.add_item(item({ - text: "Macrophages, B cells, T cells, and antibodies are created to attack a specific strain of a virus. So when your virus mutates, the new strain will be safe from the old enemies.", - //image: image_manager.get_image("macrophage_1.png"), - padding: 15, - illustration: { - width: 60, height: 60, - draw: (function() { - var tk = tkiller(p, { - pos: new p.PVector(50, 10), - mutation_info: { color: color1 }, - illustration: true - }); - tk.set_target_angle(-p.PI/4); - //tk.set_state("illustration"); - - var c = cell(p, { - pos: new p.PVector(10, 40), - width: 30, height: 30, - mutation_info: { color: color2 }, - illustration: true - }); - c.set_image(cimg); - c.set_state("infected"); - - var a = antibody(p, { - pos: new p.PVector(20, 15), - mutation_info: { color: color2 } - }); - a.set_target(c); - a.update(); - - return function() { - tk.draw(); - c.draw(); - a.draw(); - }; - }()), - }, - img_left: true - })); - s3.add_item(item({ - text: "Each new strain will be represented by a different color. Therefore, an infected cell can only be attacked by enemies of the same color.", - //image: image_manager.get_image("tcell_2.png"), - //padding: 15, - illustration: { - width: 60, height: 50, - draw: (function() { - var tk = tkiller(p, { - pos: new p.PVector(50, 12), - mutation_info: { color: color2 }, - illustration: true - }); - //tk.set_target_angle(p.PI/4); - //tk.set_state("illustration"); - - var c = cell(p, { - pos: new p.PVector(15, 40), - width: 30, height: 30, - mutation_info: { color: color2 }, - illustration: true - }); - c.set_image(cimg); - c.set_state("infected"); - - tk.set_target(c); - tk.update(); - - var a = antibody(p, { - pos: new p.PVector(5, 15), - mutation_info: { color: color2 } - }); - a.set_target(c); - a.update(); - - return function() { - tk.draw(); - c.draw(); - a.draw(); - }; - }()), - }, - img_left: false - })); - s3.add_item(item({ - title: "Multiplier Particles", - text: "Higher mutation levels will give you more points, as will collecting multiplier particles. When you infect a cell, the amount of points you get is multiplied by your multiplier and level.", - illustration: { - width: 50, height: 90, - draw: (function() { - var poss = [ - new p.PVector(10, 10), - new p.PVector(27, 25), - new p.PVector(20, 45), - new p.PVector(35, 50), - //new p.PVector(23, 30), - new p.PVector(40, 12) - ]; - var ms = []; - for_each(poss, - function(pos) { - ms.push(multiplier(p, { pos: pos })); - } - ); - - return function() { - for_each(ms, function(m) { m.draw(); }); - }; - }()), - }, - img_left: true - })); - - - }()); - - - /* - var box_w = 370; - var box_h = 500; - var box_x = p.width/2 - box_w/2; - var box_y = p.height/2 - box_h/2; - */ - - // Buttons - var button_y = p.height/2 + 190; - var button_style = { - width: 120, - height: 50, - }; - - var back_button = button(p, { - state : function() { sounds.play_button_back(); return prev_state; }, - rect : { - pos : new p.PVector(p.width/2, button_y), //box_x+box_w-80, box_y+box_h-30), - //text: "Back", - //text_x_offset: 5, - //text_y_offset: -8, - image: "back.png", - } - }); - - var next_button = button(p, { - state: function() { - sounds.play_button_click(); - next_screen(); - return obj; - }, - rect: { - pos: new p.PVector(p.width/2+120, button_y), - //text: "Next", - image: "next.png", - //style: button_style - } - }); - - var previous_button = button(p, { - state: function() { - sounds.play_button_back(); - previous_screen(); - return obj; - }, - rect: { - pos: new p.PVector(p.width/2-120, button_y), - //text: "Previous", - image: "previous.png", - //style: button_style - } - }); - previous_button.deactivate(); - - //Not ordered - var all_buttons = [ previous_button, back_button, next_button ]; - - var instruction_text = "You've managed to infiltrate the human body's defenses and get your virus particle into the bloodstream! Now you must infect cells and use them to make more copies of your virus before the immune system wipes you out.\n\nAfter a particle infects a cell, the virus will use the cell's machinery to start making copies of itself. Once the cell is full of new virus particles, press the SPACEBAR or click the MOUSE to kill the cell, causing virus particles to burst through the cell wall towards other cells in the direction the arrow is pointing. You can pick which cell to burst using the LEFT and RIGHT arrow keys.\n\nAim carefully though, because the immune system has sent out macrophages to absorb your particles. If a particle hits a macrophage, it will signal a B-cell, which will start producing antibodies. If an antibody attaches to an infected cell, a T-cell will attack it. If you don't burst the cell in time, the T-cell will kill it, destroying all the particles inside!\n\nLuckily, your virus can mutate and temporarily escape the immune system. Every time the virus replicates, there are errors when copying the virus's genetic material. These errors may cause mutations in the virus. Each time you infect a cell, the virus becomes more and more likely to mutate. Once you mutate, the immune system will not be able to attack you until a macrophage absorbs a virus particle from the new strain."; - - // --- public methods --- - - obj.get_type = function() { - return "help"; - }; - - obj.update = function() { - //do nothing - }; - - - obj.render = function() { - //p.pushMatrix(); - - p.imageMode(p.CENTER); - p.image(help_image, p.width/2, p.height/2); - - cur_screen().render(); - - //p.translate(box_x, box_y); - - //p.fill(0); - //p.rect(0, 0, box_w, box_h); - - //p.noStroke(); - //p.fill(255); - - //p.textAlign(p.CENTER, p.CENTER); - //p.textSize(24); - //p.text("Instructions", box_w/2, 30); - - //p.textAlign(p.LEFT, p.CENTER); - //p.textSize(13); - //p.text(instruction_text, - //5, 20, box_w, box_h-50); - - //p.popMatrix(); - }; - - obj.key_pressed = function(k) { - if (k === 104) { //h - obj.set_next_state(help_button.get_state()); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/game/old/high_scores_state.js b/game/old/high_scores_state.js deleted file mode 100644 index 4f3583f..0000000 --- a/game/old/high_scores_state.js +++ /dev/null @@ -1,83 +0,0 @@ -var high_scores_state = function (p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - // Buttons - - var button_style = { - text_size: 14, - text_align: p.LEFT, - text_x_offset: 25, - width: 120, - height: 50, - }; - - var back_button = button(p, { - state : function() { - sounds.play_button_back(); - - // hide the div - $("#scores-wrap").hide(); - $("#scores").tabs("destroy"); - return prev_state;//splash_state(p); - }, - rect : { - pos : new p.PVector(540, 550), - //text: "Main Menu", - //text_x_offset: -5, - image: "back.png", - //image_x_offset: -5, - //style: button_style - } - }); - - //Not ordered - var all_buttons = [ back_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "high_scores"; - }; - - obj.update = function() { - }; - - obj.render = function() { - p.noStroke(); - p.fill(0, 150); - p.rect(0, 0, p.width, p.height); - }; - - obj.key_pressed = function(k) { - /* - if (k === 112 || p.keyCode == 13) { //p, enter - obj.exit_state(); - } - */ - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - // init the scores immediately - var init = (function() { - // add a loading message to be removed on load - $("#scores-wrap").prepend( - "
          Loading high score data...
          " - ); - - // show the div - $("#scores-wrap").show(); - // update and render scores - // TODO what if it fails? - scores.do_scores(); - }()); - - return obj; -}; diff --git a/game/old/image_manager.js b/game/old/image_manager.js deleted file mode 100644 index 0b7192e..0000000 --- a/game/old/image_manager.js +++ /dev/null @@ -1,171 +0,0 @@ -// image_manager preloads and holds all the images used in the game - -var make_image_manager = function() { - - // obj to return - var obj = []; - - // --- private variables --- - - // this will be counted in preloading - var num_images = 0; - - // object to hold all arrays of image paths - // and the dir name that they come from - // dir should be name after "images/" and must end in '/' - var all_images = { - infectable_cell : { dir : "infectable_cell/" }, - empty_cell : { dir : "noninfectable_cell/" }, - background : { dir : "background_objects/" }, - screens : { dir : "screens/" }, - wall_segments : { dir : "wall_segments/" }, - macrophage : {dir : "macrophage_animation/"}, - macrophage_active : {dir : "holemacrophage_animation/"}, - bcell : {dir : "b_animation/"}, - burst : { dir : "burstingcell_animation/"}, - cell_infect : { dir : "cellinfect_animation/"}, - t_animation : { dir : "t_animation/"}, - buttons : { dir : "buttons/"}, - // catches all images in images/ - other : { dir : "" }, - }; - - // add "arr" property to each image - for_each( - keys(all_images), - function(key) { - all_images[key].images = []; - } - ); - - // filter out non-images from global image file list - var image_types = ["png", "jpg", "gif"]; - for_each( - keys(all_image_files), - function(key) { - all_image_files[key] = all_image_files[key].filter( - function(name) { - return member(image_types, - name.substring(name.lastIndexOf('.')+1)); - } - ); - } - ); - - // --- public methods --- - - // returns all the image objects of a given type - // if preloading and initing is done - // NOTE: returns a copy of the array of pointers, but the pointers - // will all point to the same objects so don't change the objects - obj.get_images = function(type) { - if (!all_images[type]) { - console.error("Invalid image type: "+type); - } - //for_each(all_images[type], console.log() - return all_images[type].images.slice(); - }; - - // finds and returns the first image with the given name - // (no path necessary) - obj.get_image = function(name) { - var to_return; - for_each( - keys(all_images), - function(key) { - for_each( - all_images[key].images, - function(img_obj) { - if (name === img_obj.path.substring( - img_obj.path.lastIndexOf('/')+1)) { - to_return = img_obj.image; - } - } - ); - } - ); - if (!to_return) { - console.error("Invalid image name: "+name); - } - return to_return; - }; - - // preloads all the images - obj.preload_images = function() { - console.log("preloading images"); - for_each_image( - function(path) { - // let processing load it in the cache - sketch.imageCache.add(path); - // count it - num_images += 1; - console.log("loading "+path); - } - ); - }; - - // DO NOT CALL BEFORE CALLING PRELOAD - obj.num_loaded = function() { - return num_images - sketch.imageCache.pending; - }; - - // DO NOT CALL BEFORE CALLING PRELOAD - obj.num_images = function() { - return num_images; - }; - - // DO NOT CALL BEFORE CALLING PRELOAD - obj.is_done_preloading = function() { - return !sketch.imageCache.pending; - }; - - // DO NOT CALL BEFORE PRELOADING IS DONE - // should be called after preloading is done - // to make the image objects - // note: must be passed a processing instance p - obj.init_images = function(p) { - console.log("initing images"); - for_each_image( - function(img_path, type) { - // make an actual image object for each preloaded image - all_images[type].images.push({ - path: img_path, - image: p.loadImage(img_path), - }); - } - ); - }; - - // --- private methods --- - - // gets array of paths from the object populated by the php function - var files_in_dir = function(dir_path) { - if (!all_image_files[dir_path]) { - console.error("Invalid dir: "+dir_path); - } - return all_image_files[dir_path]; - }; - - // applies f to each image path - // f takes a path and an image type (key) - var for_each_image = function(f) { - // for each type of image - for_each( - keys(all_images), - function(key) { - // for each image in the dir - for_each( - files_in_dir("images/"+all_images[key].dir), - function(path) { - f(path, key); - } - ); - } - ); - }; - - return obj; -}; - -// make a global instance -var image_manager = make_image_manager(); diff --git a/game/old/images/b_animation/bcell_a01.png b/game/old/images/b_animation/bcell_a01.png deleted file mode 100644 index a11fd65..0000000 Binary files a/game/old/images/b_animation/bcell_a01.png and /dev/null differ diff --git a/game/old/images/b_animation/bcell_a02.png b/game/old/images/b_animation/bcell_a02.png deleted file mode 100644 index 2cdf59d..0000000 Binary files a/game/old/images/b_animation/bcell_a02.png and /dev/null differ diff --git a/game/old/images/b_animation/bcell_a03.png b/game/old/images/b_animation/bcell_a03.png deleted file mode 100644 index 0751bbe..0000000 Binary files a/game/old/images/b_animation/bcell_a03.png and /dev/null differ diff --git a/game/old/images/b_animation/bcell_a04.png b/game/old/images/b_animation/bcell_a04.png deleted file mode 100644 index e1ff517..0000000 Binary files a/game/old/images/b_animation/bcell_a04.png and /dev/null differ diff --git a/game/old/images/b_animation/bcell_a05.png b/game/old/images/b_animation/bcell_a05.png deleted file mode 100644 index d95d849..0000000 Binary files a/game/old/images/b_animation/bcell_a05.png and /dev/null differ diff --git a/game/old/images/b_animation/bcell_a06.png b/game/old/images/b_animation/bcell_a06.png deleted file mode 100644 index 4d11066..0000000 Binary files a/game/old/images/b_animation/bcell_a06.png and /dev/null differ diff --git a/game/old/images/b_animation/bcell_a07.png b/game/old/images/b_animation/bcell_a07.png deleted file mode 100644 index 1f2efb1..0000000 Binary files a/game/old/images/b_animation/bcell_a07.png and /dev/null differ diff --git a/game/old/images/background1.png b/game/old/images/background1.png deleted file mode 100644 index 0232c24..0000000 Binary files a/game/old/images/background1.png and /dev/null differ diff --git a/game/old/images/background_bottomside.png b/game/old/images/background_bottomside.png deleted file mode 100644 index 039dd50..0000000 Binary files a/game/old/images/background_bottomside.png and /dev/null differ diff --git a/game/old/images/background_objects/.DS_Store b/game/old/images/background_objects/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/old/images/background_objects/.DS_Store and /dev/null differ diff --git a/game/old/images/background_objects/background_bcells1.png b/game/old/images/background_objects/background_bcells1.png deleted file mode 100644 index 6de753b..0000000 Binary files a/game/old/images/background_objects/background_bcells1.png and /dev/null differ diff --git a/game/old/images/background_objects/background_bcells2.png b/game/old/images/background_objects/background_bcells2.png deleted file mode 100644 index 3a523d9..0000000 Binary files a/game/old/images/background_objects/background_bcells2.png and /dev/null differ diff --git a/game/old/images/background_objects/background_bcells3.png b/game/old/images/background_objects/background_bcells3.png deleted file mode 100644 index ef718b9..0000000 Binary files a/game/old/images/background_objects/background_bcells3.png and /dev/null differ diff --git a/game/old/images/background_objects/background_bcells4.png b/game/old/images/background_objects/background_bcells4.png deleted file mode 100644 index 6295cbd..0000000 Binary files a/game/old/images/background_objects/background_bcells4.png and /dev/null differ diff --git a/game/old/images/background_objects/background_dstreaks1.png b/game/old/images/background_objects/background_dstreaks1.png deleted file mode 100644 index 825f60f..0000000 Binary files a/game/old/images/background_objects/background_dstreaks1.png and /dev/null differ diff --git a/game/old/images/background_objects/background_dstreaks2.png b/game/old/images/background_objects/background_dstreaks2.png deleted file mode 100644 index a6f0582..0000000 Binary files a/game/old/images/background_objects/background_dstreaks2.png and /dev/null differ diff --git a/game/old/images/background_objects/background_dstreaks3.png b/game/old/images/background_objects/background_dstreaks3.png deleted file mode 100644 index c65a2f8..0000000 Binary files a/game/old/images/background_objects/background_dstreaks3.png and /dev/null differ diff --git a/game/old/images/background_objects/background_lstreaks1.png b/game/old/images/background_objects/background_lstreaks1.png deleted file mode 100644 index 74595f5..0000000 Binary files a/game/old/images/background_objects/background_lstreaks1.png and /dev/null differ diff --git a/game/old/images/background_objects/background_lstreaks2.png b/game/old/images/background_objects/background_lstreaks2.png deleted file mode 100644 index 62d1f4e..0000000 Binary files a/game/old/images/background_objects/background_lstreaks2.png and /dev/null differ diff --git a/game/old/images/background_topside.png b/game/old/images/background_topside.png deleted file mode 100644 index 613f9ac..0000000 Binary files a/game/old/images/background_topside.png and /dev/null differ diff --git a/game/old/images/bcell_normal.png b/game/old/images/bcell_normal.png deleted file mode 100644 index 60b8545..0000000 Binary files a/game/old/images/bcell_normal.png and /dev/null differ diff --git a/game/old/images/bullet_listcell.png b/game/old/images/bullet_listcell.png deleted file mode 100644 index b778d5c..0000000 Binary files a/game/old/images/bullet_listcell.png and /dev/null differ diff --git a/game/old/images/burstingcell_animation/burst_a01.png b/game/old/images/burstingcell_animation/burst_a01.png deleted file mode 100644 index 464828e..0000000 Binary files a/game/old/images/burstingcell_animation/burst_a01.png and /dev/null differ diff --git a/game/old/images/burstingcell_animation/burst_a02.png b/game/old/images/burstingcell_animation/burst_a02.png deleted file mode 100644 index 87f6492..0000000 Binary files a/game/old/images/burstingcell_animation/burst_a02.png and /dev/null differ diff --git a/game/old/images/burstingcell_animation/burst_a03.png b/game/old/images/burstingcell_animation/burst_a03.png deleted file mode 100644 index bb6d224..0000000 Binary files a/game/old/images/burstingcell_animation/burst_a03.png and /dev/null differ diff --git a/game/old/images/burstingcell_animation/burst_a04.png b/game/old/images/burstingcell_animation/burst_a04.png deleted file mode 100644 index 174dd4a..0000000 Binary files a/game/old/images/burstingcell_animation/burst_a04.png and /dev/null differ diff --git a/game/old/images/burstingcell_animation/burst_a05.png b/game/old/images/burstingcell_animation/burst_a05.png deleted file mode 100644 index 50fa69f..0000000 Binary files a/game/old/images/burstingcell_animation/burst_a05.png and /dev/null differ diff --git a/game/old/images/burstingcell_animation/burst_a06.png b/game/old/images/burstingcell_animation/burst_a06.png deleted file mode 100644 index 414accb..0000000 Binary files a/game/old/images/burstingcell_animation/burst_a06.png and /dev/null differ diff --git a/game/old/images/burstingcell_animation/burst_a07.png b/game/old/images/burstingcell_animation/burst_a07.png deleted file mode 100644 index 0aa533b..0000000 Binary files a/game/old/images/burstingcell_animation/burst_a07.png and /dev/null differ diff --git a/game/old/images/burstingcell_animation/burst_a08.png b/game/old/images/burstingcell_animation/burst_a08.png deleted file mode 100644 index 735a858..0000000 Binary files a/game/old/images/burstingcell_animation/burst_a08.png and /dev/null differ diff --git a/game/old/images/burstingcell_animation/burst_a09.png b/game/old/images/burstingcell_animation/burst_a09.png deleted file mode 100644 index 74f67d9..0000000 Binary files a/game/old/images/burstingcell_animation/burst_a09.png and /dev/null differ diff --git a/game/old/images/burstingcell_animation/burst_a10.png b/game/old/images/burstingcell_animation/burst_a10.png deleted file mode 100644 index 5182129..0000000 Binary files a/game/old/images/burstingcell_animation/burst_a10.png and /dev/null differ diff --git a/game/old/images/burstingcell_animation/burst_a11.png b/game/old/images/burstingcell_animation/burst_a11.png deleted file mode 100644 index cb79f9a..0000000 Binary files a/game/old/images/burstingcell_animation/burst_a11.png and /dev/null differ diff --git a/game/old/images/burstingcell_animation/burst_a12.png b/game/old/images/burstingcell_animation/burst_a12.png deleted file mode 100644 index 7a75730..0000000 Binary files a/game/old/images/burstingcell_animation/burst_a12.png and /dev/null differ diff --git a/game/old/images/burstingcell_animation/burst_a13.png b/game/old/images/burstingcell_animation/burst_a13.png deleted file mode 100644 index d1054f6..0000000 Binary files a/game/old/images/burstingcell_animation/burst_a13.png and /dev/null differ diff --git a/game/old/images/buttons/back.png b/game/old/images/buttons/back.png deleted file mode 100644 index a6e28a9..0000000 Binary files a/game/old/images/buttons/back.png and /dev/null differ diff --git a/game/old/images/buttons/check0.png b/game/old/images/buttons/check0.png deleted file mode 100644 index 993c88a..0000000 Binary files a/game/old/images/buttons/check0.png and /dev/null differ diff --git a/game/old/images/buttons/check1.png b/game/old/images/buttons/check1.png deleted file mode 100644 index 0207b44..0000000 Binary files a/game/old/images/buttons/check1.png and /dev/null differ diff --git a/game/old/images/buttons/continue.png b/game/old/images/buttons/continue.png deleted file mode 100644 index f5f4bed..0000000 Binary files a/game/old/images/buttons/continue.png and /dev/null differ diff --git a/game/old/images/buttons/credits.png b/game/old/images/buttons/credits.png deleted file mode 100644 index 567677e..0000000 Binary files a/game/old/images/buttons/credits.png and /dev/null differ diff --git a/game/old/images/buttons/highscores.png b/game/old/images/buttons/highscores.png deleted file mode 100644 index e59ce26..0000000 Binary files a/game/old/images/buttons/highscores.png and /dev/null differ diff --git a/game/old/images/buttons/infectfriends.png b/game/old/images/buttons/infectfriends.png deleted file mode 100644 index 6bd07d4..0000000 Binary files a/game/old/images/buttons/infectfriends.png and /dev/null differ diff --git a/game/old/images/buttons/instructions.png b/game/old/images/buttons/instructions.png deleted file mode 100644 index ab6ee9b..0000000 Binary files a/game/old/images/buttons/instructions.png and /dev/null differ diff --git a/game/old/images/buttons/mainmenu.png b/game/old/images/buttons/mainmenu.png deleted file mode 100644 index 3778426..0000000 Binary files a/game/old/images/buttons/mainmenu.png and /dev/null differ diff --git a/game/old/images/buttons/mhighscores.png b/game/old/images/buttons/mhighscores.png deleted file mode 100644 index cbbb52a..0000000 Binary files a/game/old/images/buttons/mhighscores.png and /dev/null differ diff --git a/game/old/images/buttons/mhighscores_r.png b/game/old/images/buttons/mhighscores_r.png deleted file mode 100644 index 9a2d36f..0000000 Binary files a/game/old/images/buttons/mhighscores_r.png and /dev/null differ diff --git a/game/old/images/buttons/mhowtoplay.png b/game/old/images/buttons/mhowtoplay.png deleted file mode 100644 index d125cde..0000000 Binary files a/game/old/images/buttons/mhowtoplay.png and /dev/null differ diff --git a/game/old/images/buttons/mhowtoplay_r.png b/game/old/images/buttons/mhowtoplay_r.png deleted file mode 100644 index 8721cd5..0000000 Binary files a/game/old/images/buttons/mhowtoplay_r.png and /dev/null differ diff --git a/game/old/images/buttons/mnewgame.png b/game/old/images/buttons/mnewgame.png deleted file mode 100644 index 37ae877..0000000 Binary files a/game/old/images/buttons/mnewgame.png and /dev/null differ diff --git a/game/old/images/buttons/mnewgame_r.png b/game/old/images/buttons/mnewgame_r.png deleted file mode 100644 index b8359c5..0000000 Binary files a/game/old/images/buttons/mnewgame_r.png and /dev/null differ diff --git a/game/old/images/buttons/msettings.png b/game/old/images/buttons/msettings.png deleted file mode 100644 index cbc4aa5..0000000 Binary files a/game/old/images/buttons/msettings.png and /dev/null differ diff --git a/game/old/images/buttons/msettings_r.png b/game/old/images/buttons/msettings_r.png deleted file mode 100644 index 065cd11..0000000 Binary files a/game/old/images/buttons/msettings_r.png and /dev/null differ diff --git a/game/old/images/buttons/next.png b/game/old/images/buttons/next.png deleted file mode 100644 index ee4b257..0000000 Binary files a/game/old/images/buttons/next.png and /dev/null differ diff --git a/game/old/images/buttons/postscore.png b/game/old/images/buttons/postscore.png deleted file mode 100644 index bd6a40d..0000000 Binary files a/game/old/images/buttons/postscore.png and /dev/null differ diff --git a/game/old/images/buttons/previous.png b/game/old/images/buttons/previous.png deleted file mode 100644 index 1d1d0cb..0000000 Binary files a/game/old/images/buttons/previous.png and /dev/null differ diff --git a/game/old/images/buttons/quit.png b/game/old/images/buttons/quit.png deleted file mode 100644 index ca30b7e..0000000 Binary files a/game/old/images/buttons/quit.png and /dev/null differ diff --git a/game/old/images/buttons/restart.png b/game/old/images/buttons/restart.png deleted file mode 100644 index 0a986b5..0000000 Binary files a/game/old/images/buttons/restart.png and /dev/null differ diff --git a/game/old/images/buttons/return.png b/game/old/images/buttons/return.png deleted file mode 100644 index a3f4981..0000000 Binary files a/game/old/images/buttons/return.png and /dev/null differ diff --git a/game/old/images/buttons/set_click.png b/game/old/images/buttons/set_click.png deleted file mode 100644 index f7dbec3..0000000 Binary files a/game/old/images/buttons/set_click.png and /dev/null differ diff --git a/game/old/images/buttons/set_mouseselect.png b/game/old/images/buttons/set_mouseselect.png deleted file mode 100644 index a29db1e..0000000 Binary files a/game/old/images/buttons/set_mouseselect.png and /dev/null differ diff --git a/game/old/images/buttons/set_music.png b/game/old/images/buttons/set_music.png deleted file mode 100644 index 70146ec..0000000 Binary files a/game/old/images/buttons/set_music.png and /dev/null differ diff --git a/game/old/images/buttons/set_sound.png b/game/old/images/buttons/set_sound.png deleted file mode 100644 index 5f0d487..0000000 Binary files a/game/old/images/buttons/set_sound.png and /dev/null differ diff --git a/game/old/images/buttons/set_spacebar.png b/game/old/images/buttons/set_spacebar.png deleted file mode 100644 index 153275c..0000000 Binary files a/game/old/images/buttons/set_spacebar.png and /dev/null differ diff --git a/game/old/images/buttons/set_track.png b/game/old/images/buttons/set_track.png deleted file mode 100644 index c2489cb..0000000 Binary files a/game/old/images/buttons/set_track.png and /dev/null differ diff --git a/game/old/images/buttons/settings.png b/game/old/images/buttons/settings.png deleted file mode 100644 index cb52726..0000000 Binary files a/game/old/images/buttons/settings.png and /dev/null differ diff --git a/game/old/images/buttons/track_left.png b/game/old/images/buttons/track_left.png deleted file mode 100644 index 0ad83cd..0000000 Binary files a/game/old/images/buttons/track_left.png and /dev/null differ diff --git a/game/old/images/buttons/track_right.png b/game/old/images/buttons/track_right.png deleted file mode 100644 index 0890c6e..0000000 Binary files a/game/old/images/buttons/track_right.png and /dev/null differ diff --git a/game/old/images/cellinfect_animation/infect_a01.png b/game/old/images/cellinfect_animation/infect_a01.png deleted file mode 100644 index 7d02b1a..0000000 Binary files a/game/old/images/cellinfect_animation/infect_a01.png and /dev/null differ diff --git a/game/old/images/cellinfect_animation/infect_a02.png b/game/old/images/cellinfect_animation/infect_a02.png deleted file mode 100644 index cd5d557..0000000 Binary files a/game/old/images/cellinfect_animation/infect_a02.png and /dev/null differ diff --git a/game/old/images/cellinfect_animation/infect_a03.png b/game/old/images/cellinfect_animation/infect_a03.png deleted file mode 100644 index 070d4d9..0000000 Binary files a/game/old/images/cellinfect_animation/infect_a03.png and /dev/null differ diff --git a/game/old/images/cellinfect_animation/infect_a04.png b/game/old/images/cellinfect_animation/infect_a04.png deleted file mode 100644 index 45c2d2c..0000000 Binary files a/game/old/images/cellinfect_animation/infect_a04.png and /dev/null differ diff --git a/game/old/images/cellinfect_animation/infect_a05.png b/game/old/images/cellinfect_animation/infect_a05.png deleted file mode 100644 index 6b0cf04..0000000 Binary files a/game/old/images/cellinfect_animation/infect_a05.png and /dev/null differ diff --git a/game/old/images/cellinfect_animation/infect_a06.png b/game/old/images/cellinfect_animation/infect_a06.png deleted file mode 100644 index caf6ac5..0000000 Binary files a/game/old/images/cellinfect_animation/infect_a06.png and /dev/null differ diff --git a/game/old/images/cellinfect_animation/infect_a07.png b/game/old/images/cellinfect_animation/infect_a07.png deleted file mode 100644 index fedb457..0000000 Binary files a/game/old/images/cellinfect_animation/infect_a07.png and /dev/null differ diff --git a/game/old/images/cellinfect_animation/infect_a08.png b/game/old/images/cellinfect_animation/infect_a08.png deleted file mode 100644 index 1e0ca69..0000000 Binary files a/game/old/images/cellinfect_animation/infect_a08.png and /dev/null differ diff --git a/game/old/images/cellinfect_animation/infect_a09.png b/game/old/images/cellinfect_animation/infect_a09.png deleted file mode 100644 index 43d1b04..0000000 Binary files a/game/old/images/cellinfect_animation/infect_a09.png and /dev/null differ diff --git a/game/old/images/cellinfect_animation/infect_a10.png b/game/old/images/cellinfect_animation/infect_a10.png deleted file mode 100644 index 0aee860..0000000 Binary files a/game/old/images/cellinfect_animation/infect_a10.png and /dev/null differ diff --git a/game/old/images/cellinfect_animation/infect_a11.png b/game/old/images/cellinfect_animation/infect_a11.png deleted file mode 100644 index 542e505..0000000 Binary files a/game/old/images/cellinfect_animation/infect_a11.png and /dev/null differ diff --git a/game/old/images/cellinfect_animation/infect_a12.png b/game/old/images/cellinfect_animation/infect_a12.png deleted file mode 100644 index 1bcc3ab..0000000 Binary files a/game/old/images/cellinfect_animation/infect_a12.png and /dev/null differ diff --git a/game/old/images/halogo.jpg b/game/old/images/halogo.jpg deleted file mode 100644 index e6e43c0..0000000 Binary files a/game/old/images/halogo.jpg and /dev/null differ diff --git a/game/old/images/holemacrophage_animation/hmacrophage_a01.png b/game/old/images/holemacrophage_animation/hmacrophage_a01.png deleted file mode 100644 index 739eea8..0000000 Binary files a/game/old/images/holemacrophage_animation/hmacrophage_a01.png and /dev/null differ diff --git a/game/old/images/holemacrophage_animation/hmacrophage_a02.png b/game/old/images/holemacrophage_animation/hmacrophage_a02.png deleted file mode 100644 index 189ed3d..0000000 Binary files a/game/old/images/holemacrophage_animation/hmacrophage_a02.png and /dev/null differ diff --git a/game/old/images/holemacrophage_animation/hmacrophage_a03.png b/game/old/images/holemacrophage_animation/hmacrophage_a03.png deleted file mode 100644 index b9011c3..0000000 Binary files a/game/old/images/holemacrophage_animation/hmacrophage_a03.png and /dev/null differ diff --git a/game/old/images/holemacrophage_animation/hmacrophage_a04.png b/game/old/images/holemacrophage_animation/hmacrophage_a04.png deleted file mode 100644 index 315daee..0000000 Binary files a/game/old/images/holemacrophage_animation/hmacrophage_a04.png and /dev/null differ diff --git a/game/old/images/holemacrophage_animation/hmacrophage_a05.png b/game/old/images/holemacrophage_animation/hmacrophage_a05.png deleted file mode 100644 index 6510538..0000000 Binary files a/game/old/images/holemacrophage_animation/hmacrophage_a05.png and /dev/null differ diff --git a/game/old/images/holemacrophage_animation/hmacrophage_a06.png b/game/old/images/holemacrophage_animation/hmacrophage_a06.png deleted file mode 100644 index e4387c2..0000000 Binary files a/game/old/images/holemacrophage_animation/hmacrophage_a06.png and /dev/null differ diff --git a/game/old/images/holemacrophage_animation/hmacrophage_a07.png b/game/old/images/holemacrophage_animation/hmacrophage_a07.png deleted file mode 100644 index 4aefeb5..0000000 Binary files a/game/old/images/holemacrophage_animation/hmacrophage_a07.png and /dev/null differ diff --git a/game/old/images/holemacrophage_animation/hmacrophage_a08.png b/game/old/images/holemacrophage_animation/hmacrophage_a08.png deleted file mode 100644 index f1c0e9c..0000000 Binary files a/game/old/images/holemacrophage_animation/hmacrophage_a08.png and /dev/null differ diff --git a/game/old/images/holemacrophage_animation/hmacrophage_a09.png b/game/old/images/holemacrophage_animation/hmacrophage_a09.png deleted file mode 100644 index aad7670..0000000 Binary files a/game/old/images/holemacrophage_animation/hmacrophage_a09.png and /dev/null differ diff --git a/game/old/images/holemacrophage_animation/hmacrophage_a10.png b/game/old/images/holemacrophage_animation/hmacrophage_a10.png deleted file mode 100644 index 84499ec..0000000 Binary files a/game/old/images/holemacrophage_animation/hmacrophage_a10.png and /dev/null differ diff --git a/game/old/images/holemacrophage_animation/hmacrophage_a11.png b/game/old/images/holemacrophage_animation/hmacrophage_a11.png deleted file mode 100644 index cf9c8e4..0000000 Binary files a/game/old/images/holemacrophage_animation/hmacrophage_a11.png and /dev/null differ diff --git a/game/old/images/holemacrophage_animation/hmacrophage_a12.png b/game/old/images/holemacrophage_animation/hmacrophage_a12.png deleted file mode 100644 index d7d1da2..0000000 Binary files a/game/old/images/holemacrophage_animation/hmacrophage_a12.png and /dev/null differ diff --git a/game/old/images/holemacrophage_animation/hmacrophage_a13.png b/game/old/images/holemacrophage_animation/hmacrophage_a13.png deleted file mode 100644 index 7c7161b..0000000 Binary files a/game/old/images/holemacrophage_animation/hmacrophage_a13.png and /dev/null differ diff --git a/game/old/images/holemacrophage_animation/hmacrophage_a14.png b/game/old/images/holemacrophage_animation/hmacrophage_a14.png deleted file mode 100644 index 3d54eba..0000000 Binary files a/game/old/images/holemacrophage_animation/hmacrophage_a14.png and /dev/null differ diff --git a/game/old/images/infectable_cell/infectable_cell_2n.png b/game/old/images/infectable_cell/infectable_cell_2n.png deleted file mode 100644 index ac98c48..0000000 Binary files a/game/old/images/infectable_cell/infectable_cell_2n.png and /dev/null differ diff --git a/game/old/images/infectable_cell/infectable_cell_3n.png b/game/old/images/infectable_cell/infectable_cell_3n.png deleted file mode 100644 index 5cb97e8..0000000 Binary files a/game/old/images/infectable_cell/infectable_cell_3n.png and /dev/null differ diff --git a/game/old/images/infectable_cell/infectable_cell_4n.png b/game/old/images/infectable_cell/infectable_cell_4n.png deleted file mode 100644 index 8027852..0000000 Binary files a/game/old/images/infectable_cell/infectable_cell_4n.png and /dev/null differ diff --git a/game/old/images/infectable_cell/infectable_cell_5n.png b/game/old/images/infectable_cell/infectable_cell_5n.png deleted file mode 100644 index 6503050..0000000 Binary files a/game/old/images/infectable_cell/infectable_cell_5n.png and /dev/null differ diff --git a/game/old/images/infectable_cell/infectable_cell_6n.png b/game/old/images/infectable_cell/infectable_cell_6n.png deleted file mode 100644 index 41e450e..0000000 Binary files a/game/old/images/infectable_cell/infectable_cell_6n.png and /dev/null differ diff --git a/game/old/images/infectable_cell/infectable_cell_7n.png b/game/old/images/infectable_cell/infectable_cell_7n.png deleted file mode 100644 index f9cbc94..0000000 Binary files a/game/old/images/infectable_cell/infectable_cell_7n.png and /dev/null differ diff --git a/game/old/images/listcell.png b/game/old/images/listcell.png deleted file mode 100644 index 27af90c..0000000 Binary files a/game/old/images/listcell.png and /dev/null differ diff --git a/game/old/images/logo/logo128.png b/game/old/images/logo/logo128.png deleted file mode 100644 index d370aed..0000000 Binary files a/game/old/images/logo/logo128.png and /dev/null differ diff --git a/game/old/images/logo/logo32.png b/game/old/images/logo/logo32.png deleted file mode 100644 index b076f80..0000000 Binary files a/game/old/images/logo/logo32.png and /dev/null differ diff --git a/game/old/images/logo/logo64.png b/game/old/images/logo/logo64.png deleted file mode 100644 index ca134e5..0000000 Binary files a/game/old/images/logo/logo64.png and /dev/null differ diff --git a/game/old/images/logo/vlogolarge.png b/game/old/images/logo/vlogolarge.png deleted file mode 100644 index 274bab9..0000000 Binary files a/game/old/images/logo/vlogolarge.png and /dev/null differ diff --git a/game/old/images/logo/vlogolargetext.png b/game/old/images/logo/vlogolargetext.png deleted file mode 100644 index 6004b8e..0000000 Binary files a/game/old/images/logo/vlogolargetext.png and /dev/null differ diff --git a/game/old/images/macrophage_1.png b/game/old/images/macrophage_1.png deleted file mode 100644 index b03e4cd..0000000 Binary files a/game/old/images/macrophage_1.png and /dev/null differ diff --git a/game/old/images/macrophage_1_active.png b/game/old/images/macrophage_1_active.png deleted file mode 100644 index 4b858d4..0000000 Binary files a/game/old/images/macrophage_1_active.png and /dev/null differ diff --git a/game/old/images/macrophage_animation/macrophage_a01.png b/game/old/images/macrophage_animation/macrophage_a01.png deleted file mode 100644 index 34e9035..0000000 Binary files a/game/old/images/macrophage_animation/macrophage_a01.png and /dev/null differ diff --git a/game/old/images/macrophage_animation/macrophage_a02.png b/game/old/images/macrophage_animation/macrophage_a02.png deleted file mode 100644 index 0cb1089..0000000 Binary files a/game/old/images/macrophage_animation/macrophage_a02.png and /dev/null differ diff --git a/game/old/images/macrophage_animation/macrophage_a03.png b/game/old/images/macrophage_animation/macrophage_a03.png deleted file mode 100644 index 12f9af3..0000000 Binary files a/game/old/images/macrophage_animation/macrophage_a03.png and /dev/null differ diff --git a/game/old/images/macrophage_animation/macrophage_a04.png b/game/old/images/macrophage_animation/macrophage_a04.png deleted file mode 100644 index 3ccaca9..0000000 Binary files a/game/old/images/macrophage_animation/macrophage_a04.png and /dev/null differ diff --git a/game/old/images/macrophage_animation/macrophage_a05.png b/game/old/images/macrophage_animation/macrophage_a05.png deleted file mode 100644 index b5e97c1..0000000 Binary files a/game/old/images/macrophage_animation/macrophage_a05.png and /dev/null differ diff --git a/game/old/images/macrophage_animation/macrophage_a06.png b/game/old/images/macrophage_animation/macrophage_a06.png deleted file mode 100644 index e8a1b97..0000000 Binary files a/game/old/images/macrophage_animation/macrophage_a06.png and /dev/null differ diff --git a/game/old/images/macrophage_animation/macrophage_a07.png b/game/old/images/macrophage_animation/macrophage_a07.png deleted file mode 100644 index 13ab22f..0000000 Binary files a/game/old/images/macrophage_animation/macrophage_a07.png and /dev/null differ diff --git a/game/old/images/macrophage_animation/macrophage_a08.png b/game/old/images/macrophage_animation/macrophage_a08.png deleted file mode 100644 index 7ac4102..0000000 Binary files a/game/old/images/macrophage_animation/macrophage_a08.png and /dev/null differ diff --git a/game/old/images/macrophage_animation/macrophage_a09.png b/game/old/images/macrophage_animation/macrophage_a09.png deleted file mode 100644 index 32f7c20..0000000 Binary files a/game/old/images/macrophage_animation/macrophage_a09.png and /dev/null differ diff --git a/game/old/images/macrophage_animation/macrophage_a10.png b/game/old/images/macrophage_animation/macrophage_a10.png deleted file mode 100644 index 4f64246..0000000 Binary files a/game/old/images/macrophage_animation/macrophage_a10.png and /dev/null differ diff --git a/game/old/images/macrophage_animation/macrophage_a11.png b/game/old/images/macrophage_animation/macrophage_a11.png deleted file mode 100644 index bb1870f..0000000 Binary files a/game/old/images/macrophage_animation/macrophage_a11.png and /dev/null differ diff --git a/game/old/images/macrophage_animation/macrophage_a12.png b/game/old/images/macrophage_animation/macrophage_a12.png deleted file mode 100644 index 506e48b..0000000 Binary files a/game/old/images/macrophage_animation/macrophage_a12.png and /dev/null differ diff --git a/game/old/images/macrophage_animation/macrophage_a13.png b/game/old/images/macrophage_animation/macrophage_a13.png deleted file mode 100644 index 7b14bd9..0000000 Binary files a/game/old/images/macrophage_animation/macrophage_a13.png and /dev/null differ diff --git a/game/old/images/macrophage_animation/macrophage_a14.png b/game/old/images/macrophage_animation/macrophage_a14.png deleted file mode 100644 index f78597b..0000000 Binary files a/game/old/images/macrophage_animation/macrophage_a14.png and /dev/null differ diff --git a/game/old/images/noninfectable_cell/noninfectable_cell_1n.png b/game/old/images/noninfectable_cell/noninfectable_cell_1n.png deleted file mode 100644 index 9768618..0000000 Binary files a/game/old/images/noninfectable_cell/noninfectable_cell_1n.png and /dev/null differ diff --git a/game/old/images/noninfectable_cell/noninfectable_cell_2n.png b/game/old/images/noninfectable_cell/noninfectable_cell_2n.png deleted file mode 100644 index c6b582c..0000000 Binary files a/game/old/images/noninfectable_cell/noninfectable_cell_2n.png and /dev/null differ diff --git a/game/old/images/noninfectable_cell/noninfectable_cell_3n.png b/game/old/images/noninfectable_cell/noninfectable_cell_3n.png deleted file mode 100644 index a387eb0..0000000 Binary files a/game/old/images/noninfectable_cell/noninfectable_cell_3n.png and /dev/null differ diff --git a/game/old/images/noninfectable_cell/noninfectable_cell_4n.png b/game/old/images/noninfectable_cell/noninfectable_cell_4n.png deleted file mode 100644 index 1bf02a8..0000000 Binary files a/game/old/images/noninfectable_cell/noninfectable_cell_4n.png and /dev/null differ diff --git a/game/old/images/noninfectable_cell/noninfectable_cell_5n.png b/game/old/images/noninfectable_cell/noninfectable_cell_5n.png deleted file mode 100644 index 841dd45..0000000 Binary files a/game/old/images/noninfectable_cell/noninfectable_cell_5n.png and /dev/null differ diff --git a/game/old/images/old/.DS_Store b/game/old/images/old/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/old/images/old/.DS_Store and /dev/null differ diff --git a/game/old/images/old/b/.DS_Store b/game/old/images/old/b/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/old/images/old/b/.DS_Store and /dev/null differ diff --git a/game/old/images/old/b/macrophage_a1.gif b/game/old/images/old/b/macrophage_a1.gif deleted file mode 100755 index ea1ba06..0000000 Binary files a/game/old/images/old/b/macrophage_a1.gif and /dev/null differ diff --git a/game/old/images/old/background/background_bcells1.png b/game/old/images/old/background/background_bcells1.png deleted file mode 100755 index f809f50..0000000 Binary files a/game/old/images/old/background/background_bcells1.png and /dev/null differ diff --git a/game/old/images/old/background/background_bcells2.png b/game/old/images/old/background/background_bcells2.png deleted file mode 100755 index d99ee15..0000000 Binary files a/game/old/images/old/background/background_bcells2.png and /dev/null differ diff --git a/game/old/images/old/background/background_bcells3.png b/game/old/images/old/background/background_bcells3.png deleted file mode 100755 index 099a0f7..0000000 Binary files a/game/old/images/old/background/background_bcells3.png and /dev/null differ diff --git a/game/old/images/old/background/background_bcells4.png b/game/old/images/old/background/background_bcells4.png deleted file mode 100755 index 9ed69c7..0000000 Binary files a/game/old/images/old/background/background_bcells4.png and /dev/null differ diff --git a/game/old/images/old/background/background_bottomside.png b/game/old/images/old/background/background_bottomside.png deleted file mode 100755 index 90bda8d..0000000 Binary files a/game/old/images/old/background/background_bottomside.png and /dev/null differ diff --git a/game/old/images/old/background/background_dstreaks1.png b/game/old/images/old/background/background_dstreaks1.png deleted file mode 100755 index 9f553e6..0000000 Binary files a/game/old/images/old/background/background_dstreaks1.png and /dev/null differ diff --git a/game/old/images/old/background/background_dstreaks2.png b/game/old/images/old/background/background_dstreaks2.png deleted file mode 100755 index 258b8c6..0000000 Binary files a/game/old/images/old/background/background_dstreaks2.png and /dev/null differ diff --git a/game/old/images/old/background/background_dstreaks3.png b/game/old/images/old/background/background_dstreaks3.png deleted file mode 100755 index fcbcbb7..0000000 Binary files a/game/old/images/old/background/background_dstreaks3.png and /dev/null differ diff --git a/game/old/images/old/background/background_lstreaks1.png b/game/old/images/old/background/background_lstreaks1.png deleted file mode 100755 index 3f313ce..0000000 Binary files a/game/old/images/old/background/background_lstreaks1.png and /dev/null differ diff --git a/game/old/images/old/background/background_lstreaks2.png b/game/old/images/old/background/background_lstreaks2.png deleted file mode 100755 index 6d9e38e..0000000 Binary files a/game/old/images/old/background/background_lstreaks2.png and /dev/null differ diff --git a/game/old/images/old/background/background_topside.png b/game/old/images/old/background/background_topside.png deleted file mode 100755 index 70573ac..0000000 Binary files a/game/old/images/old/background/background_topside.png and /dev/null differ diff --git a/game/old/images/old/bcell1.png b/game/old/images/old/bcell1.png deleted file mode 100644 index f383cdd..0000000 Binary files a/game/old/images/old/bcell1.png and /dev/null differ diff --git a/game/old/images/old/cellwall1.png b/game/old/images/old/cellwall1.png deleted file mode 100644 index ac5e3c1..0000000 Binary files a/game/old/images/old/cellwall1.png and /dev/null differ diff --git a/game/old/images/old/cellwall1draft.svg b/game/old/images/old/cellwall1draft.svg deleted file mode 100644 index 0c2ae5a..0000000 --- a/game/old/images/old/cellwall1draft.svg +++ /dev/null @@ -1,1120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/old/images/old/infectable1.png b/game/old/images/old/infectable1.png deleted file mode 100644 index 29f9eb1..0000000 Binary files a/game/old/images/old/infectable1.png and /dev/null differ diff --git a/game/old/images/old/infectable2.png b/game/old/images/old/infectable2.png deleted file mode 100644 index 40d0d7d..0000000 Binary files a/game/old/images/old/infectable2.png and /dev/null differ diff --git a/game/old/images/old/infectable3.png b/game/old/images/old/infectable3.png deleted file mode 100644 index 69567be..0000000 Binary files a/game/old/images/old/infectable3.png and /dev/null differ diff --git a/game/old/images/old/infectable_cell/infectable_cell_2n.png b/game/old/images/old/infectable_cell/infectable_cell_2n.png deleted file mode 100755 index 29f9eb1..0000000 Binary files a/game/old/images/old/infectable_cell/infectable_cell_2n.png and /dev/null differ diff --git a/game/old/images/old/infectable_cell/infectable_cell_3n.png b/game/old/images/old/infectable_cell/infectable_cell_3n.png deleted file mode 100755 index 40d0d7d..0000000 Binary files a/game/old/images/old/infectable_cell/infectable_cell_3n.png and /dev/null differ diff --git a/game/old/images/old/infectable_cell/infectable_cell_4n.png b/game/old/images/old/infectable_cell/infectable_cell_4n.png deleted file mode 100755 index 69567be..0000000 Binary files a/game/old/images/old/infectable_cell/infectable_cell_4n.png and /dev/null differ diff --git a/game/old/images/old/infectable_cell/infectable_cell_5n.png b/game/old/images/old/infectable_cell/infectable_cell_5n.png deleted file mode 100755 index 620adbb..0000000 Binary files a/game/old/images/old/infectable_cell/infectable_cell_5n.png and /dev/null differ diff --git a/game/old/images/old/infectable_cell/infectable_cell_6n.png b/game/old/images/old/infectable_cell/infectable_cell_6n.png deleted file mode 100755 index aa65877..0000000 Binary files a/game/old/images/old/infectable_cell/infectable_cell_6n.png and /dev/null differ diff --git a/game/old/images/old/infectable_cell/infectable_cell_7n.png b/game/old/images/old/infectable_cell/infectable_cell_7n.png deleted file mode 100755 index 2951a73..0000000 Binary files a/game/old/images/old/infectable_cell/infectable_cell_7n.png and /dev/null differ diff --git a/game/old/images/old/macrophage1.png b/game/old/images/old/macrophage1.png deleted file mode 100644 index 4dc0f6b..0000000 Binary files a/game/old/images/old/macrophage1.png and /dev/null differ diff --git a/game/old/images/old/macrophage_active.png b/game/old/images/old/macrophage_active.png deleted file mode 100644 index ed7d1ee..0000000 Binary files a/game/old/images/old/macrophage_active.png and /dev/null differ diff --git a/game/old/images/old/new/.DS_Store b/game/old/images/old/new/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/old/images/old/new/.DS_Store and /dev/null differ diff --git a/game/old/images/old/new/infectable1.png b/game/old/images/old/new/infectable1.png deleted file mode 100755 index 298f24c..0000000 Binary files a/game/old/images/old/new/infectable1.png and /dev/null differ diff --git a/game/old/images/old/new/infectable2.png b/game/old/images/old/new/infectable2.png deleted file mode 100755 index 01100dd..0000000 Binary files a/game/old/images/old/new/infectable2.png and /dev/null differ diff --git a/game/old/images/old/new/infectable3.png b/game/old/images/old/new/infectable3.png deleted file mode 100755 index 9bc043f..0000000 Binary files a/game/old/images/old/new/infectable3.png and /dev/null differ diff --git a/game/old/images/old/new/noninfectable.png b/game/old/images/old/new/noninfectable.png deleted file mode 100755 index bbe312b..0000000 Binary files a/game/old/images/old/new/noninfectable.png and /dev/null differ diff --git a/game/old/images/old/noninfectable1.png b/game/old/images/old/noninfectable1.png deleted file mode 100644 index dde08a7..0000000 Binary files a/game/old/images/old/noninfectable1.png and /dev/null differ diff --git a/game/old/images/old/noninfectable_cell/noninfectable_cell_2n.png b/game/old/images/old/noninfectable_cell/noninfectable_cell_2n.png deleted file mode 100755 index e586a95..0000000 Binary files a/game/old/images/old/noninfectable_cell/noninfectable_cell_2n.png and /dev/null differ diff --git a/game/old/images/old/noninfectable_cell/noninfectable_cell_3.png b/game/old/images/old/noninfectable_cell/noninfectable_cell_3.png deleted file mode 100755 index a04f17c..0000000 Binary files a/game/old/images/old/noninfectable_cell/noninfectable_cell_3.png and /dev/null differ diff --git a/game/old/images/old/noninfectable_cell/noninfectable_cell_4.png b/game/old/images/old/noninfectable_cell/noninfectable_cell_4.png deleted file mode 100755 index 5114e1d..0000000 Binary files a/game/old/images/old/noninfectable_cell/noninfectable_cell_4.png and /dev/null differ diff --git a/game/old/images/old/noninfectable_cell/noninfectable_cell_5.png b/game/old/images/old/noninfectable_cell/noninfectable_cell_5.png deleted file mode 100755 index 86a67e3..0000000 Binary files a/game/old/images/old/noninfectable_cell/noninfectable_cell_5.png and /dev/null differ diff --git a/game/old/images/old/particle.png b/game/old/images/old/particle.png deleted file mode 100644 index e2c8a15..0000000 Binary files a/game/old/images/old/particle.png and /dev/null differ diff --git a/game/old/images/old/screens/.DS_Store b/game/old/images/old/screens/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/game/old/images/old/screens/.DS_Store and /dev/null differ diff --git a/game/old/images/old/screens/bullet_listcell.png b/game/old/images/old/screens/bullet_listcell.png deleted file mode 100755 index 7525958..0000000 Binary files a/game/old/images/old/screens/bullet_listcell.png and /dev/null differ diff --git a/game/old/images/old/screens/header.png b/game/old/images/old/screens/header.png deleted file mode 100755 index 8b83ea6..0000000 Binary files a/game/old/images/old/screens/header.png and /dev/null differ diff --git a/game/old/images/old/screens/listcell.png b/game/old/images/old/screens/listcell.png deleted file mode 100755 index ef2eba2..0000000 Binary files a/game/old/images/old/screens/listcell.png and /dev/null differ diff --git a/game/old/images/old/screens/loading.png b/game/old/images/old/screens/loading.png deleted file mode 100755 index a20886e..0000000 Binary files a/game/old/images/old/screens/loading.png and /dev/null differ diff --git a/game/old/images/old/screens/loadingsplash.png b/game/old/images/old/screens/loadingsplash.png deleted file mode 100755 index 9c3d6bc..0000000 Binary files a/game/old/images/old/screens/loadingsplash.png and /dev/null differ diff --git a/game/old/images/old/screens/mainscreenbase.png b/game/old/images/old/screens/mainscreenbase.png deleted file mode 100755 index 2287e53..0000000 Binary files a/game/old/images/old/screens/mainscreenbase.png and /dev/null differ diff --git a/game/old/images/old/screens/newgame_listcell.png b/game/old/images/old/screens/newgame_listcell.png deleted file mode 100755 index 3360fb7..0000000 Binary files a/game/old/images/old/screens/newgame_listcell.png and /dev/null differ diff --git a/game/old/images/old/screens/settings.png b/game/old/images/old/screens/settings.png deleted file mode 100755 index 3041eea..0000000 Binary files a/game/old/images/old/screens/settings.png and /dev/null differ diff --git a/game/old/images/old/screens/settingssplash.png b/game/old/images/old/screens/settingssplash.png deleted file mode 100755 index ac1891a..0000000 Binary files a/game/old/images/old/screens/settingssplash.png and /dev/null differ diff --git a/game/old/images/old/tcells/tcell1.png b/game/old/images/old/tcells/tcell1.png deleted file mode 100755 index a49799f..0000000 Binary files a/game/old/images/old/tcells/tcell1.png and /dev/null differ diff --git a/game/old/images/old/tcells/tcell2.png b/game/old/images/old/tcells/tcell2.png deleted file mode 100755 index 24b6ac2..0000000 Binary files a/game/old/images/old/tcells/tcell2.png and /dev/null differ diff --git a/game/old/images/old/tcells/tcell3.png b/game/old/images/old/tcells/tcell3.png deleted file mode 100755 index 98dbc44..0000000 Binary files a/game/old/images/old/tcells/tcell3.png and /dev/null differ diff --git a/game/old/images/old/tcells/tcell4.png b/game/old/images/old/tcells/tcell4.png deleted file mode 100755 index 891c32b..0000000 Binary files a/game/old/images/old/tcells/tcell4.png and /dev/null differ diff --git a/game/old/images/old/virus1.png b/game/old/images/old/virus1.png deleted file mode 100644 index d9db175..0000000 Binary files a/game/old/images/old/virus1.png and /dev/null differ diff --git a/game/old/images/old/virusfinal.svg b/game/old/images/old/virusfinal.svg deleted file mode 100644 index 3b61a61..0000000 --- a/game/old/images/old/virusfinal.svg +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/old/images/old/wall_segments/cellwall1.png b/game/old/images/old/wall_segments/cellwall1.png deleted file mode 100755 index 0d71d6e..0000000 Binary files a/game/old/images/old/wall_segments/cellwall1.png and /dev/null differ diff --git a/game/old/images/old/wall_segments/cellwall2.png b/game/old/images/old/wall_segments/cellwall2.png deleted file mode 100755 index f06bf92..0000000 Binary files a/game/old/images/old/wall_segments/cellwall2.png and /dev/null differ diff --git a/game/old/images/old/wall_segments/cellwall3.png b/game/old/images/old/wall_segments/cellwall3.png deleted file mode 100755 index 2b7f3c7..0000000 Binary files a/game/old/images/old/wall_segments/cellwall3.png and /dev/null differ diff --git a/game/old/images/old/wall_segments/cellwall4.png b/game/old/images/old/wall_segments/cellwall4.png deleted file mode 100755 index d33f471..0000000 Binary files a/game/old/images/old/wall_segments/cellwall4.png and /dev/null differ diff --git a/game/old/images/old/wall_segments/cellwall5.png b/game/old/images/old/wall_segments/cellwall5.png deleted file mode 100755 index c0bbabd..0000000 Binary files a/game/old/images/old/wall_segments/cellwall5.png and /dev/null differ diff --git a/game/old/images/old/wall_segments/cellwall6.png b/game/old/images/old/wall_segments/cellwall6.png deleted file mode 100755 index 203950f..0000000 Binary files a/game/old/images/old/wall_segments/cellwall6.png and /dev/null differ diff --git a/game/old/images/old/wall_segments/cellwall7.png b/game/old/images/old/wall_segments/cellwall7.png deleted file mode 100755 index 262a9b3..0000000 Binary files a/game/old/images/old/wall_segments/cellwall7.png and /dev/null differ diff --git a/game/old/images/old/wallcell1.png b/game/old/images/old/wallcell1.png deleted file mode 100644 index 30c4535..0000000 Binary files a/game/old/images/old/wallcell1.png and /dev/null differ diff --git a/game/old/images/screens/creditsscreen.png b/game/old/images/screens/creditsscreen.png deleted file mode 100644 index 40ff9db..0000000 Binary files a/game/old/images/screens/creditsscreen.png and /dev/null differ diff --git a/game/old/images/screens/helpsplash.png b/game/old/images/screens/helpsplash.png deleted file mode 100644 index f92663b..0000000 Binary files a/game/old/images/screens/helpsplash.png and /dev/null differ diff --git a/game/old/images/screens/loadingsplash.png b/game/old/images/screens/loadingsplash.png deleted file mode 100644 index 7825408..0000000 Binary files a/game/old/images/screens/loadingsplash.png and /dev/null differ diff --git a/game/old/images/screens/mainscreenbase.png b/game/old/images/screens/mainscreenbase.png deleted file mode 100644 index dd63a98..0000000 Binary files a/game/old/images/screens/mainscreenbase.png and /dev/null differ diff --git a/game/old/images/screens/settingssplash.png b/game/old/images/screens/settingssplash.png deleted file mode 100644 index 7cd9b4e..0000000 Binary files a/game/old/images/screens/settingssplash.png and /dev/null differ diff --git a/game/old/images/t_animation/tcell_a01.png b/game/old/images/t_animation/tcell_a01.png deleted file mode 100644 index 22b4364..0000000 Binary files a/game/old/images/t_animation/tcell_a01.png and /dev/null differ diff --git a/game/old/images/t_animation/tcell_a02.png b/game/old/images/t_animation/tcell_a02.png deleted file mode 100644 index 6743fbc..0000000 Binary files a/game/old/images/t_animation/tcell_a02.png and /dev/null differ diff --git a/game/old/images/t_animation/tcell_a03.png b/game/old/images/t_animation/tcell_a03.png deleted file mode 100644 index d6b30c9..0000000 Binary files a/game/old/images/t_animation/tcell_a03.png and /dev/null differ diff --git a/game/old/images/t_animation/tcell_a04.png b/game/old/images/t_animation/tcell_a04.png deleted file mode 100644 index 17e9836..0000000 Binary files a/game/old/images/t_animation/tcell_a04.png and /dev/null differ diff --git a/game/old/images/t_animation/tcell_a05.png b/game/old/images/t_animation/tcell_a05.png deleted file mode 100644 index a909794..0000000 Binary files a/game/old/images/t_animation/tcell_a05.png and /dev/null differ diff --git a/game/old/images/t_animation/tcell_a06.png b/game/old/images/t_animation/tcell_a06.png deleted file mode 100644 index af2bf7f..0000000 Binary files a/game/old/images/t_animation/tcell_a06.png and /dev/null differ diff --git a/game/old/images/t_animation/tcell_a07.png b/game/old/images/t_animation/tcell_a07.png deleted file mode 100644 index e6a1f7c..0000000 Binary files a/game/old/images/t_animation/tcell_a07.png and /dev/null differ diff --git a/game/old/images/tcell_2.png b/game/old/images/tcell_2.png deleted file mode 100644 index bcdfd37..0000000 Binary files a/game/old/images/tcell_2.png and /dev/null differ diff --git a/game/old/images/tinyvirus_shadowtrans.png b/game/old/images/tinyvirus_shadowtrans.png deleted file mode 100644 index 06f8178..0000000 Binary files a/game/old/images/tinyvirus_shadowtrans.png and /dev/null differ diff --git a/game/old/images/tinyvirus_trans.png b/game/old/images/tinyvirus_trans.png deleted file mode 100644 index ffad22b..0000000 Binary files a/game/old/images/tinyvirus_trans.png and /dev/null differ diff --git a/game/old/images/wall_segments/cellwall1.png b/game/old/images/wall_segments/cellwall1.png deleted file mode 100644 index 0e4aa10..0000000 Binary files a/game/old/images/wall_segments/cellwall1.png and /dev/null differ diff --git a/game/old/images/wall_segments/cellwall2.png b/game/old/images/wall_segments/cellwall2.png deleted file mode 100644 index 8b07659..0000000 Binary files a/game/old/images/wall_segments/cellwall2.png and /dev/null differ diff --git a/game/old/images/wall_segments/cellwall3.png b/game/old/images/wall_segments/cellwall3.png deleted file mode 100644 index d91f9ac..0000000 Binary files a/game/old/images/wall_segments/cellwall3.png and /dev/null differ diff --git a/game/old/images/wall_segments/cellwall4.png b/game/old/images/wall_segments/cellwall4.png deleted file mode 100644 index aaf96ad..0000000 Binary files a/game/old/images/wall_segments/cellwall4.png and /dev/null differ diff --git a/game/old/images/wall_segments/cellwall5.png b/game/old/images/wall_segments/cellwall5.png deleted file mode 100644 index edb9fa1..0000000 Binary files a/game/old/images/wall_segments/cellwall5.png and /dev/null differ diff --git a/game/old/images/wall_segments/cellwall6.png b/game/old/images/wall_segments/cellwall6.png deleted file mode 100644 index 175ed0f..0000000 Binary files a/game/old/images/wall_segments/cellwall6.png and /dev/null differ diff --git a/game/old/images/wall_segments/cellwall7.png b/game/old/images/wall_segments/cellwall7.png deleted file mode 100644 index e1d20e5..0000000 Binary files a/game/old/images/wall_segments/cellwall7.png and /dev/null differ diff --git a/game/old/images/wallcell_1.png b/game/old/images/wallcell_1.png deleted file mode 100644 index 9f5f197..0000000 Binary files a/game/old/images/wallcell_1.png and /dev/null differ diff --git a/game/old/in_game_state.js b/game/old/in_game_state.js deleted file mode 100644 index d243684..0000000 --- a/game/old/in_game_state.js +++ /dev/null @@ -1,1770 +0,0 @@ -// *** game *** -// NOTE: get_type() returns "game" not "in_game" - -var in_game_state = function (p, previous_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - - // whether or not we are testing - // use it wherever - var testing = false; - obj.testing = function() { return testing; }; - - // --- constants --- - //var num_of_render_levels = 5; Now auto-calculating in init so don't have to change - - // --- private variables --- - - var GOOD_NOTIFICATION_COLOR = p.color(0, 255, 0); - var BAD_NOTIFICATION_COLOR = p.color(255, 0, 0); - - var prev_state = previous_state; - // distance is the x-coordinate of the total distance traveled - // increments with scroll - var distance = 0; - //var score = 0; - var active_cell = null; - var last_active_cell = null; - // multiply each object's scroll amount by this - // factor, which increases throughout the game - var scroll_factor = 1; - - var game_objects = []; - var paused = false; - - var status_bar_height = 40; - var status_height = 20; - - var score = num_status_obj(p, { - pos : new p.PVector(p.width - 100, status_height), - text : "Score:", - num : 0, - format : add_commas - }); - var mult = num_status_obj(p, { - pos : new p.PVector(p.width - 200, status_height), - text : "Multiplier:", - num : 1, - format : function(num) { - return num+"x"; - } - }); - var time_elapsed = 0; // Time elapsed in seconds - var set_time = false; //bool that says if we've started counting time - var time_status = num_status_obj(p, { - pos : new p.PVector(85, status_height), - text : "Time:", - num : time_elapsed, - // formats time to mins:secs - format : function(num) { - var secs = num%60; - if (secs < 10) { secs = "0" + secs; } - return p.floor(num/60) + ":" + secs; - } - }); - var mutation = mutation_obj(p, { status_height : status_height }); - - var pause_button = button(p, { - state: function() { - do_pause(); - console.log("pause button"); - return pause_state(p, obj); - }, - rect: { - pos: new p.PVector(25, status_height), - width: 25, height: 25, - } - }); - // draw two vertical rects - pause_button.draw = function() { - p.pushMatrix(); - // get the rect spec back - var r = pause_button.get_rect(); - var w = r.width; - var h = r.height; - p.translate(r.pos.x-w/2, r.pos.y-h/2); - p.strokeWeight(2); - p.stroke(255); - p.noFill(); - p.ellipse(w/2, h/2, w, h); - p.noStroke(); - p.fill(255); - p.rectMode(p.CORNER); - p.rect(w/4, h/5, w/5, 3*h/5); - p.rect(w-w/4-w/5, h/5, w/5, 3*h/5); - p.popMatrix(); - }; - - // Used to draw all of the statuses (must implement draw) - var all_status_objs = [score, mult, time_status, mutation]; - var all_buttons = [pause_button]; - - var all_notifications = []; - var last_notification_time = -1 - // takes a string and adds a new notification - var notify = function(note, color) { - var the_pos = null; - if (active_cell) { - console.log("Setting to active cell"); - a_pos = active_cell.get_pos(); - the_pos = new p.PVector(a_pos.x, a_pos.y - 30); - } - else { - console.log("Setting to default"); - the_pos = new p.PVector(p.width * (5/8), p.height * (5/8)); - } - if (new Date().getTime() > (last_notification_time + 2000)) { // two seconds - all_notifications.push(notification(p, { "text": note, "color": color, - "pos" : the_pos})); - last_notification_time = new Date().getTime(); - } - }; - - var generator = make_generator(p, { - game : obj, - mutation : mutation - }); - - // temporary flag TODO - //var game_over = false; - - //A mapping from game_object types to their rendering levels - var type_to_level = { - "background_object":0, - "background_edge":0, - "wall":1, - "wall_segment":1, - "particle":2, // general name for level - "cell":3, // general name for level - "wall_cell": 3, - "empty_cell": 3, - "enemy":4, // general name for level - "floater":4, - "tkiller":4, - "antibody":4, - "b_cell": 5, - "multiplier":6, - "info":7 - }; - - // given a type returns the array of objects - // corresponding to that type's level - var level = function(type) { - var lvl = game_objects[type_to_level[type]]; - assert (lvl, type+" not a valid type!"); - return lvl; - }; - - -/* - // Buttons - // Have a rectangle representing their position and - // a state to go to when pressed - var pause_button = { - state : pause_state(), - rectangle : rectangle(p, { - pos : new p.PVector(p.width - 20, 20), - width : 20, - height : 20 - }) - }; - var help_button = { - state : help_state(), - rectangle : rectangle(p, { - pos : new p.PVector(p.width - 80, 20), - width : 20, - height : 20 - }) - }; - var exit_button = { - state : exit_state(), - rectangle : rectangle(p, { - pos : new p.PVector(20, 20), - width : 20, - height : 20 - }) - }; -*/ - //Not ordered - - - // --- private methods --- - - // initialization code goes here - // gets called at the bottom - var init = function() { - // Start playing the game music - if (g.music) { - sounds.play_background_music(); - } - - //Initialize game_objects to be a list of num_of_render_levels empty lists - var num_of_render_levels = 0; - for (var key in type_to_level){ - if (type_to_level.hasOwnProperty(key)) { - var new_level = type_to_level[key]; - if (new_level > num_of_render_levels) { - num_of_render_levels = new_level; - } - } - } - for (var i = 0; i < num_of_render_levels; i++) { - game_objects[i] = []; - } - - var startx = p.width-150; - if (testing) { - var startx = 150; - } - - var initial_cells = [ - cell(p, { - pos: new p.PVector(startx, p.height/2), - vel: new p.PVector(0, 0), - state: "alive", - }), - cell(p, { - pos: new p.PVector(startx+170, p.height/2-40), - vel: new p.PVector(0, 0), - state: "alive", - }), - cell(p, { - pos: new p.PVector(startx+170, p.height/2), - vel: new p.PVector(0, 0), - state: "alive", - }), - cell(p, { - pos: new p.PVector(startx+170, p.height/2+40), - vel: new p.PVector(0, 0), - state: "alive", - }) - ]; - //var cell_level = type_to_level["cell"]; - //game_objects[cell_level].push(initial_cell); - obj.add_objects(initial_cells); - - var initial_par = particle(p, { - pos: new p.PVector(0, p.height/2), - vel: new p.PVector(8, 0), - // start with some gray - mutation_info: mutation.get_info()//p.color(250, 250, 250) - //mutation : mutation - }); - - obj.add_object(initial_par); - - init_walls(); - init_back(); - - //active_cell = initial_cell; - - // Add background - //var bg = background(p, { pos : new p.PVector(0, 0)}); - //obj.add_object(bg); - //console.log(level("background")[0]); - }; - - // creates, adds, and returns a new b_cell with no target - var make_b_cell = function() { - var new_b_cell = b_cell(p, { - pos: new p.PVector(p.width+50, p.random(p.height/4, 3*p.height/4)), - }); - obj.add_object(new_b_cell); - return new_b_cell; - }; - - // creates, adds, and returns a new tkiller with no target - var make_tkiller = function() { - var new_tkiller = tkiller(p, { - pos: new p.PVector(p.width+50, p.random(p.height/4, 3*p.height/4)), - }); - obj.add_object(new_tkiller); - return new_tkiller; - }; - - // Returns the current b cell on the screen, if there is one - var get_b_cell = function(level) { - var the_b_cell = null; - do_to_type( - function(b) { - if (b.get_level() === level) { - the_b_cell = b; - } - }, - "b_cell", true - ); - return the_b_cell; - }; - - var alert_b_cell = function(flo) { - // gets b_cell of the flo's level - var b = get_b_cell(flo.get_level()); - // if there isn't one - if (!b) { - // make one - b = make_b_cell(); - b.set_mutation_info(flo.get_mutation_info()); - b.set_target(flo); - } - // if there is one - else { - // it should be either active, shooting, or outdated - // so do nothing - } - }; - - // Alerts the b cell (only one on screen at a time?) to a newly mutated - // obj. - // If o.mutation_level >= b cells current target.mutation_level and o is - // closer than the b cells curr target (or if b cells curr - // target is null), updates b_cells curr target to be o - /* - var alert_b_cell = function(o) { - //var cell_objs = level("b_cell"); - //var cell_obj = null; - /*for (var i = 0; i < cell_objs.length; i++) { - cell_obj = cell_objs[i]; - if (cell_obj.get_type() === "b_cell") { - the_b_cell = cell_obj; - } - } - / - - var the_b_cell = get_b_cell(); - - if (the_b_cell && the_b_cell.is_alive()) { - var old_target = the_b_cell.get_target(); - - if (old_target) { - // if new macro has higher or equal level - if (//o.get_level() >= old_target.get_level() - // if new macro has current mutation level - o.get_level() === mutation.get_level() - // and it is closer - && old_target.get_pos().dist(the_b_cell.get_pos()) > - o.get_pos().dist(the_b_cell.get_pos())) { - the_b_cell.set_target(o); - } - } - else { - the_b_cell.set_target(o); - } - } - }; - */ - - // sets active_cell to the leftmost infected cell - // if there is one - var next_active_cell = function() { - var sort_fun = function(active_c) { // don't care about active - if (last_active_cell) { - // let's try the nearest cell to the one that died - return function(c1, c2) { - return dist_less_than(last_active_cell, c1, c2) ? -1 : 1; - }; - } - // otherwise leftmost - return function(c1, c2) { - return c1.get_pos().x - c2.get_pos().x; - }; - } - choose_cell(sort_fun); - }; - - // Set the next-left or next-right cell to be active, and - // if appropriate sets current active to be not active - - // Chooses the closest cell to a_pos - var choose_closest_cell = function(a_pos) { - if (active_cell) { // for the beginning - var old_active = active_cell; - var sort_fun = function(active_cell){ - return function(c1, c2){ - return c1.get_pos().dist(a_pos) - - c2.get_pos().dist(a_pos); - } - }; - choose_cell(sort_fun); - - // In case it doesn't change (choose_cell assumes - // that the cell is diff from the curr active) - if (old_active.get_pos().dist(a_pos) < - active_cell.get_pos().dist(a_pos)) { - active_cell.set_state("infected"); - active_cell = old_active; - active_cell.set_state("active"); - } - } - } - - // Chooses the closest cell to the active cell in the direction of comp, - // i.e. such that comp(c1.x, active.x) is true - var choose_cell_helper = function(comp) { - var sort_fun = function(active_c) { //don't rename to active_cell - return function(c1, c2) { - c1x = c1.get_pos().x; - c2x = c2.get_pos().x; - actx = active_c.get_pos().x; - // If one is in the right dir and the other isnt, - // return the one that is - if (comp(c1x, actx) && !(comp(c2x, actx))) { - return -1; - } - else if (!(comp(c1x, actx)) && comp(c2x, actx)) { - return 1; - } - // If they are on the same side, return opposite of comp - else { - if (comp(c1x, c2x)) { - return 1; - } - else { - return -1; - } - } - } - }; - choose_cell(sort_fun); - }; - - // Chooses the next left cell to be active - var choose_left_cell = function() { - choose_cell_helper(function (x, y) {return x < y;}); - - }; - - // Same in the right dir - var choose_right_cell = function() { - choose_cell_helper(function (x, y) {return x > y;}); - }; - - // Sets a cell to be active based on sort_fun, and if this is diff - // from curr cell, sets curr cell to not be active - // sort_fun must take the currently active cell, and return a function - // that takes 2 cells, ad returns true if the first is 'better' than - // the second - var choose_cell = function(sort_fun) { - var cells = level("cell");//game_objects[type_to_level["cell"]]; - var infecteds = cells.filter( - function(cell) { - // don't want empty_cells - return cell.get_type() === "cell" - && cell.get_state() === "infected"; - }); - var sort_f = sort_fun(active_cell); - infecteds.sort(sort_f); - - var curr_active = active_cell; - if (infecteds.length > 0) { - active_cell = infecteds[0]; - //If same as current - if (curr_active) { // for the beginning - curr_active.set_state("infected"); //if same, about to change - } - active_cell.set_state("active"); - //console.log("got next "+active_cell.to_string()); - } - }; - - // Returns true if source is closer to target1 than target2 - // All 3 args are game_objs - var dist_less_than = function(source, target1, target2) { - var source_pos = source.get_pos(); - return source_pos.dist(target1.get_pos()) < - source_pos.dist(target2.get_pos()); - }; - - // Updates all tkillers targets - // Tkillers target the closest infected and targeted cell - var update_tkillers_targets = function(){ - var all_infected_cells = get_all_infected_cells(); - do_to_type(function(tkill){ - // remove bad targets - if (tkill.get_target() - // if it's dead - && (tkill.get_target().is_dead() - // or dying - || tkill.get_target().get_state() === "dying" - // or offscreen - || tkill.get_target().is_offscreen() - // or the target mutated - || !same_mutation_level(tkill, tkill.get_target()))) { - tkill.set_target(null); - } - // set a new target - for_each( - all_infected_cells, - function(infected_cell) { - if (infected_cell.has_antibody() - && same_mutation_level(infected_cell, tkill) - && (!tkill.get_target() || - dist_less_than(tkill, - infected_cell, tkill.get_target()))) { - tkill.set_target(infected_cell); - } - } - ); - }, "tkiller", true); - }; - - // adds new tkillers if need be - var add_tkillers = function() { - var tks = get_all_of_type("tkiller"); - do_to_type( - // for each b_cell - function(b) { - // if it needs a tkiller - if (b.is_shooting()) { - // check if one exists - var has_tkiller = false; - for_each(tks, function(tk) { - if (same_mutation_level(b, tk)) { - has_tkiller = true; - } - }); - // if one doesn't - if (!has_tkiller) { - console.log("made tkiller for lvl "+b.get_level()); - // make one - var tk = make_tkiller(); - tk.set_mutation_info(b.get_mutation_info()); - } - } - }, - "b_cell", true - ); - }; - - - // kills the active cell and updates the targets - // of all the tkillers - var kill_active_cell = function() { - active_cell.die(); - last_active_cell = active_cell; - active_cell = null; - update_tkillers_targets(); - }; - - //Checks whether any 2 objs are colliding, and if so calls handle_collision on them - var check_collisions = (function() { - // rendering levels to check collisions for: - var to_check = [ - //["particle", "particle"], - ["particle", "cell"], - ["particle", "enemy"], - ["particle", "multiplier"], - //["cell", "cell"], - ["cell", "enemy"], - //["enemy", "enemy"], - ["enemy", "b_cell"], - ["b_cell", "wall"], - ["particle", "wall"], - ["multiplier", "wall"], - ["enemy", "wall"] - ]; - - // hey this looks like combinations! - var do_comb = function(arr1, start1, end1, - arr2, start2, end2, fun) { - var i = start1, j = start2; - while (i <= end1) { - while (j <= end2) { - fun(arr1[i], arr2[j]); - j++; - } - i++; - // when arrays are the same - // don't do repeats - if (arr1 === arr2) { - j = i; - } - else { - j = 0; - } - } - }; - - var collision_fun = function() { - // double combinations! - // for each pair of rendering groups - // do_comb(game_objects, 1, 3, - // game_objects, 1, 3, - for_each(to_check, function(pair) { - var lvl1 = level(pair[0]); - var lvl2 = level(pair[1]); - // for each pair of objects in the groups - do_comb(lvl1, 0, lvl1.length-1, - lvl2, 0, lvl2.length-1, check); - }); - //); - }; - - - var check = function(obj1, obj2) { - //console.log("checking "+obj1.to_string() - // +", "+obj2.to_string()); - // check the collisions - // don't check collisions with self - if (obj1 !== obj2 - && check_collision(obj1, obj2)) { - handle_collision(obj1, obj2); - //console.log("collision! " +obj1.to_string() - // +", "+obj2.to_string()); - } - } - - return collision_fun; - }()); - - // Returns whether 2 objects are colliding - var check_collision = function(obj1, obj2) { - var type1 = obj1.get_type(); - var type2 = obj2.get_type(); - - if (check_circle_collision(obj1, obj2)) { - var check_again = retrieve(extra_check, type1, type2); - if (check_again !== undefined) { - return check_again(obj1, obj2); - } - else { - check_again = retrieve(extra_check, type2, type1); - if (check_again !== undefined) { - return check_again(obj2, obj1); - } - else { - return true; - } - } - } - else { - return false; - } - }; - - // Checks for a collision between circle (obj2) and rectangle (obj1) - var check_rectangle_collision = function(rect, circ) { - return overlapping_vertically(circ, rect, rect.get_y_offset()) && - overlapping_horizontally(circ, rect, rect.get_x_offset()); - }; - - // Rectangle and circle collision helper functions - // Returns whether the circle is overlapping the rectangle, horizontally, - // by offset num of pixels - var overlapping_horizontally = function(circ, rect, offset) { - var circlel = circ.get_left(), circler = circ.get_right(); - var rectl = rect.get_left(), rectr = rect.get_right(); - return ((circler <= rectr && circler >= (rectl + offset)) || - (circlel >= rectl && circlel <= (rectr - offset))); - }; - // Returns whether the circle is overlapping the rectangle, vertically, - // by offset num of pixels - var overlapping_vertically = function(circ, rect, offset) { - var circlet = circ.get_top(), circleb = circ.get_bottom(); - var rectt = rect.get_top(), rectb = rect.get_bottom(); - - return (circleb <= rectb && circleb >= (rectt + offset) || - (circlet >= rectt && circlet <= (rectb - offset))); - }; - - // holds extra collision checking functions for certain - // pairs of types - var extra_check = { - "wall_segment": { - "particle": check_rectangle_collision, - "b_cell": check_rectangle_collision, - "multiplier": //check_rectangle_collision - // had to do manually cuz offset was messed up - function(rect, circ) { - return overlapping_vertically(circ, rect, 0) && - overlapping_horizontally(circ, rect, 0); - } - }, - "floater": { - "b_cell": check_rectangle_collision - }, - "wall_cell": { - "particle": check_rectangle_collision - } - }; - - // checks for collisions between two objects by - // checking if their bounding circles are overlapping - // returns true if they are colliding - var check_circle_collision = function(obj1, obj2) { - // if the distance between their center points - // is <= the sum of their radii then they are colliding - // ONLY WORKS FOR CENTERED SHAPES - return (obj1.get_pos().dist(obj2.get_pos()) - <= obj1.get_radius() + obj2.get_radius()); - }; - // make it public - obj.check_circle_collision = check_circle_collision; - - /* - // Reverses 2 objs appropriate velocities - var bounce_collided = (function() { - // A list containing 2 element lists - // Inner lists represent object type pairs to not bounce off each other - var to_exclude = [ ["particle", "multiplier"], - ["particle", "particle"], - ["wall_segment", "b_cell"], - ["particle", "antibody"]]; - - var is_excluded = function(o1, o2) { - var is_excluded = false; - var type1 = o1.get_type(), type2 = o2.get_type(); - var objs_in_list = function(list) { - return ((list[0] === type1 && list[1] === type2) || - (list[0] === type2 && list[1] === type1)); - } - for_each(to_exclude, function(l) { - if (objs_in_list(l)) { - is_excluded = true; - } - }); - return is_excluded; - } - return function(obj1, obj2) { - if (!is_excluded(obj1, obj2)) { - bounce(obj1, obj2); - } - } - }()); - */ - - var bounce = function(obj1, obj2) { - //offset adjusts how closely we check, since we can't check exactly when they collide every time - var offset = 5; - var onel = obj1.get_left(), oner = obj1.get_right(); - var onet = obj1.get_top(), oneb = obj1.get_bottom(); - var twol = obj2.get_left() + offset, twor = obj2.get_right() - offset; - var twot = obj2.get_top() + offset, twob = obj2.get_bottom() - offset; - - //When bouncing, check velocity to make sure they are 'incoming' to each other - //This avoids them getting stuck (makes sure they didn't just collide) - //bounce vertically - var y_vel = obj1.get_vel().y; - var x_vel = obj1.get_vel().x; - if ((onet >= twob && y_vel <= 0) || (oneb <= twot && y_vel >= 0)) { - obj1.reverse_y(); - obj2.reverse_y(); - } - if ((oner <= twol && x_vel >= 0) - || (onel > twor && x_vel <= 0)) { //bounce horizontally - obj1.reverse_x(); - obj2.reverse_x(); - } - }; - - // handles collisions between different object types - var handle_collision = function(obj1, obj2) { - var ot1 = obj1.get_type(); - var ot2 = obj2.get_type(); - - // try first with one order - var handler = retrieve(collision_handlers, ot1, ot2); - if (handler) { - handler(obj1, obj2); - } - // if it didn't work - else { - // try the other order - handler = retrieve(collision_handlers, ot2, ot1); - if (handler) { - handler(obj2, obj1); - } - else { - //Not an error now? - //throw "Unsupported collision type!"; - } - - } - - // Bounce if appropriate - //bounce_collided(obj1, obj2); - }; - - // object to store all the handlers - // created once with a closure - // dont manage bouncing/changing direction here - var collision_handlers = (function() { - var nothing = function(obj1, obj2) {}; - - // infects the cell, kills the particle - var infect = function(par, cell) { - // only if cell is "alive" - // (ie only one particle per cell) - assert(cell, "Not a cell in infect!"); - if (cell.get_state() !== "dead" - && cell.get_state() !== "dying") { - par.die(); - } - if (cell.get_state() === "alive") { - //Play sound - sounds.play_sound("cell_infect"); - - // increase mutation percentage if level is highest on screen - // must be done before setting state of infected cell - // only happens if infected by particle of cur level - if (par.get_level() === mutation.get_level()) { - mutation.infected_cell(); - } - - cell.set_state("infected"); - cell.set_mutation_info(par.get_mutation_info()); - - // Add 10 to score - score.incr(10 * par.get_level() * mult.get_num()); - } - else { - // otherwise deflect - //bounce(par, cell); - } - }; - - - var handlers = { - "particle": { - // particle vs. particle - // do nothing? - "particle": nothing, - - // particle vs. cell - // infect the cell, kill the particle - "cell": infect, - - // particle vs. wall_cell - // bounce particle off cell - // cell doesn't move - "wall_cell": bounce, - - // particle vs. empty_cell - // // infect the cell, kill the particle - // kill the particle - "empty_cell": function(par, cell) { - // TODO diff sound? - sounds.play_sound("cell_infect"); - par.die(); - }, - - // particle vs. floater - // kill the particle - // floater takes on color of particle - "floater": function(par, flo) { - par.die(); - if (flo.is_alive()) { - // update flo if not activated || level < - // par.level - if (!flo.is_activated() || - flo.get_level() < - par.get_level()) { - flo.set_mutation_info(par.get_mutation_info()); - flo.activate(); - alert_b_cell(flo); - sounds.play_sound("macrophage_infect"); - } - notify("Macrophage activated!", BAD_NOTIFICATION_COLOR); - } - }, - - // particle vs. tkiller - // nothing? - "tkiller": nothing, - - // particle vs. multiplier - // get rid of the mult and incr mult - "multiplier": function(par, mul) { - //par.die(); - mul.die(); - mult.incr(1); - }, - - // particle vs wall - // Kill particle - "wall_segment": function(par, wall) { - par.die(); - } - }, - - // cell vs. cell - // cell vs. wall_cell - // cell vs. empty_cell - // wall_cell vs. wall_cell - // wall_cell vs. empty_cell - // empty_cell vs. empty_cell - // don't let them overlap (is bouncing necessary?) - "cell": { - "cell": nothing, - "wall_cell": nothing, - "empty_cell": nothing - }, - "wall_cell": { - "wall_cell": nothing, - "empty_cell": nothing - }, - "empty_cell": { - "empty_cell": nothing - }, - - // floater vs. cell - // floater vs. wall_cell - // floater vs. empty_cell - // floater vs. floater - // no overlap? - "floater": { - "cell": bounce, - "wall_cell": bounce, - "empty_cell": bounce, - "floater": bounce - }, - - "tkiller": { - // tkiller vs. cell - "cell": function(tk, cell) { - if ((cell.get_state() === "infected" || - cell.get_state() === "active") - && cell.has_antibody() - && same_mutation_level(tk, cell)) { - cell.die(); - sounds.play_sound("kill"); - tk.set_target(null); - if (active_cell === cell) { - //last_active_cell = active_cell; - //active_cell = null; - kill_active_cell(); - } - } - }, - - // tkiller vs. wall_cell - // tkiller vs. empty_cell - // tkiller vs. floater - // tkiller vs. tkiller - // nothing? TODO bounce? - "wall_cell": nothing, - "empty_cell": nothing, - "floater": nothing, - "tkiller": nothing - }, - - "antibody": { - "cell": function(a, c) { - if (same_mutation_level(a, c)) { - if (!c.has_antibody() && - (c.get_state() === "infected" || - c.get_state() === "active")) { - c.set_antibody(a); - } - } - } - }, - - "multiplier": { - // multiplier vs wall - // do nothing - "wall_segment": bounce - }, - - "b_cell": { - "floater": function(b, flo) { - if (b.is_alive() && flo.is_activated()) { - b.set_mutation_info(flo.get_mutation_info()); - b.activate(get_bcell_slot()); - bounce(b, flo); - notify("B-cell activated!", BAD_NOTIFICATION_COLOR); - } - // trying to avoid getting stuck - if (b.is_outdated()) { - bounce(b, flo); - b.set_target(null); - } - }, - "wall_segment": function(b, wall) { - //console.log("collision"); - if (b.is_activated()) { - // start making antibodies - b.make_antibodies(); - // make a tkiller - var tk = make_tkiller(); - tk.set_mutation_info(b.get_mutation_info()); - - notify("Incoming antibodies!", BAD_NOTIFICATION_COLOR); - } - else if (b.is_alive()) { - bounce(b, wall); - } - else if (b.is_outdated()) { - } - } - } - }; - return handlers; - }()); - - //Removes all objs which are either off screen or dead - var remove_objs = function() { - var filter_fun = function(x) { - //Check offscreen, but don't remove newly generated - var offscreen = false; - if (x.is_offscreen()) { - //Only remove particles that are off the right - if (x.is_off_right()) { - if (x.get_type() === "particle") { - offscreen = true; - } - //else false - } - else { - //console.log("removing "+x.to_string()); - offscreen = true; - } - } - return (! (offscreen || x.is_dead())); - }; - for (var i = 0; i < game_objects.length; i++) { - game_objects[i] = game_objects[i].filter(filter_fun); - } - - // check offscreen for active cell - if (active_cell && active_cell.is_offscreen()) { - //active_cell = null; - kill_active_cell(); - } - }; - - // Returns whether the 2 objects have the same mutation level - var same_mutation_level = function(o1, o2) { - var o1level = o1.get_mutation_info().level; - var o2level = o2.get_mutation_info().level; - return (o1level === o2level); - }; - - - // adds a new background tile if the rightmost is onscreen - // ASSUMES ALL WALL TILES ARE SAME SIZE - var back_top = null; - var back_btm = null; - var add_back = (function() { - - var add_one = function(edge_tile) { - if (!goes_off_right(edge_tile)) { - //console.log("adding edge"); - - var new_spec = {}; - var x = edge_tile.get_pos().x - + edge_tile.get_width(); - - var y = status_bar_height; - new_spec.is_top = true; - // switch if it's a bottom edge - if (edge_tile === back_btm) { - // this will be changed in the edge object - y = p.height; - new_spec.is_top = false; - } - - new_spec.pos = new p.PVector(x, y); - - var new_tile = background_edge(p, new_spec); - obj.add_object(new_tile); - - if (edge_tile === back_top) { - back_top = new_tile; - } - else { - back_btm = new_tile; - } - //console.log("added tile "+new_tile.to_string()); - } - }; - - var add_both = function() { - add_one(back_top); - add_one(back_btm); - }; - - return add_both; - }()); - - // initialized the background - var init_back = function() { - // initial edges - back_top = background_edge(p, { - pos: new p.PVector(-100, status_bar_height), - is_top: true - }); - obj.add_object(back_top); - - back_btm = background_edge(p, { - pos: new p.PVector(-10, p.height), - is_top: false - }); - obj.add_object(back_btm); - - // add one more tile to fill screen - add_back(); - }; - - // tells if a background tile goes off the right of the screen - var goes_off_right = function(tile) { - return tile.get_pos().x + tile.get_width() > p.width; - }; - - // adds a new wall segment if the rightmost wall - // segment is onscreen - var rightmost_top = null; - var rightmost_btm = null; - var add_wall = (function() { - - // adds either a top or bottom wall - var add_one = function(rightmost) { - // if the rightmost has entered the screen - if (!rightmost.is_off_right()) { - var new_spec = {}; - - // note that new wall coords should be at - // bottom left corner of seg - // should be next to last seg - var x = rightmost.get_pos().x - + rightmost.get_width()/2 - 5; - - // set y for top wall - var y = 95; - new_spec.is_top = true; - // switch if it's a bottom wall - if (rightmost === rightmost_top) { - y = p.height+5; - new_spec.is_top = false; - } - - new_spec.pos = new p.PVector(x, y); - - // add the new segment - var new_seg = wall_segment(p, new_spec); - obj.add_object(new_seg); - - // update the corresponding rightmost - if (rightmost === rightmost_top) { - rightmost_top = new_seg; - } - else { - rightmost_btm = new_seg; - } - } - }; - - var add_both = function() { - add_one(rightmost_top); - add_one(rightmost_btm); - }; - - return add_both; - }()); - - var init_walls = function() { - // add first empty segments - // the values used here are important so don't change them - rightmost_top = wall_segment(p, { - pos: new p.PVector(-10, 0), - width: 5 - }); - - rightmost_btm = wall_segment(p, { - pos: new p.PVector(-10, p.height), - width: 5 - }); - - // while both walls don't span the screen - while(!(rightmost_top.is_off_right() - && rightmost_btm.is_off_right())) { - // add new walls - add_wall(); - } - }; - - //Does a function to every object - //Pass in a function that takes an object - var do_to_all_objs = function(f) { - for (var i=0; i= 0) ) { - do_to_all_objs(function(o) { o.get_pos().add( - new p.PVector(-dist/10, 0)); }); - //["particle", "cell", "enemy"], false); - } - } - }; - - - // --- public methods --- - - obj.get_type = function() { - return "game"; - }; - - //Calls update() on every obj - //after updating, calls remove_objs - obj.update = (function() { - var game_types = ["background", "wall", "particle", - "cell", "enemy", "multiplier", "antibody"]; - - var update_fun = function() { - // Can't be set when object is initialized - // Takes time every update though to check - if (!set_time) { - //Set interval to update time elapsed - var update_time = function() { - if (!paused) { - time_elapsed += 1; - time_status.set_num(time_elapsed); - } - } - setInterval(update_time, 1000); - set_time = true; - } - if (!paused) { - // if we don't have an active cell - if (active_cell === null) { - // try to find the next one - next_active_cell(); - } - // THIS MUST COME BEFORE GAME OVER CHECK - - // check for game over - // (if no particles are left and no active cell) - //console.log("num of particles: " + level("particle").length); - if (active_cell === null && - level("particle").length === 0) { - var go_state = game_over_state(p, previous_state, { - score : score.get_num(), - mutation_level : mutation.get_level() - }); - sounds.pause_background_music(); - obj.set_next_state(go_state); - - // stop the animations - do_to_all_objs( - function(o) { - if (o.stop_animation) { - o.stop_animation(); - } - } - ); - - // stop notifications - all_notifications = []; - - // stop the time and stuff - paused = true; - - // Add to the high score table - // If fb user name and id are set - if (g_user_name && g_user_id) { - scores.submit_score(score.get_num(), - mutation.get_level(), g_user_name, g_user_id); - // Update the high score table - // (not necessary now) - //scores.do_scores(); - } - - // simply don't do the rest of update - return; - } - - //Add any newly generated objs - generator.update(); - - // Make antibodies seek any infected cells they are near - make_antibodies_seek(); - - // Add antibodies generated from b cells - do_to_type( - function(b) { - obj.add_objects(b.get_antibodies()); - }, - "b_cell", true - ); - - // adds a new segment of wall if necessary - add_wall(); - // adds a new background tile if necessary - add_back(); - - add_tkillers(); - update_tkillers_targets(); - - // set outdated t/b cells - set_all_outdated(); - - // scroll all objects - - do_to_all_objs(function(o){ - o.scroll(scroll_factor); - }); - - //dynamic_scroll(); - - // update distance travelled - distance += scroll_factor; - - // update all objects - do_to_all_objs(function(o){ - o.update(); - }); - - check_collisions(); - - remove_objs(); - - update_mutation(); - - /* - // for debugging - var count = 0; - do_to_all_objs(function() { count += 1; }); - console.log(count); - console.log("fr "+p.__frameRate); - */ - } - }; - - var update_mutation = function() { - // check for a new mutation - // if mutation occurred - if (mutation.has_new_mutation() && active_cell) { - // pick infected cell closest to active cell with the current - // mutation level - var choices = get_all_of_type("cell").filter( - function(c) { - return ((c.get_state() === "infected" - || c.get_state() === "active") - && c.get_level() === mutation.get_level()); - } - ); - choices.sort( - function(c1, c2) { - return dist_less_than(active_cell, c1, c2) ? -1 : 1; - } - ); - var cell_to_mutate = choices[0]; - - // do the actual mutation and hold onto new ability - //var new_ability = - mutation.do_mutation(); - // mutate the active cell - cell_to_mutate.set_mutation_info(mutation.get_info()); - // update the scroll factor - scroll_factor += 0.15; - - //if (new_ability) { - // notify("New Ability: " + new_ability); - //} - //else { - notify("Mutation occurred!", GOOD_NOTIFICATION_COLOR); - //} - - console.log("mutation occurred!"); - } - // otherwise check for downgrades - else { - // check for the highest mutation level on screen - var max_level = 0; - var find_max = function(o) { - if (o.get_level() > max_level) { - max_level = o.get_level(); - } - }; - do_to_type(find_max, "cell", false); - do_to_type(find_max, "particle", false); - - // if max level lower than mutation level - if (max_level > 0 && max_level < mutation.get_level()) { - // downgrade to that level - mutation.set_level(max_level); - // reset the counters - mutation.reset_mutation(); - - notify("Lost new strain!", BAD_NOTIFICATION_COLOR); - console.log("downgraded to mutation level "+max_level); - - scroll_factor -= 0.15; - - // TODO do enemies become not outdated? - } - } - }; - - return update_fun; - }()); - - //Calls draw() on every obj - obj.render = function(){ - - // put the active cell at the end of the list - // so it is drawn on top - if (active_cell) { - var cells = level("cell"); - remove_elt(cells, active_cell); - cells.push(active_cell); - } - - p.background(g.background_color); - - for (var i=0; i -Virion - - - - - - -
          - - - - - - diff --git a/game/old/index1.html b/game/old/index1.html deleted file mode 100644 index a096db5..0000000 --- a/game/old/index1.html +++ /dev/null @@ -1,298 +0,0 @@ - - - -Virion - - - - - - - - - - -
          - - - - - - - -
          - - -
          - -
          -
          - Could not load high scores! You may want to check your internet connection. -
          -
          - - - Your browser does not support the HTML5 canvas element. Upgrade to Chrome, Firefox 4, Safari, or Opera to play this game. - -
          -
          Virion was created as an entry in the Hidden Agenda contest.
          If you like the game, leave some feedback on the Hidden Agenda page to help Virion win!
          - -
          -
          - -
          -
          - Note: Virion was built entirely using the new open HTML5 standard and the Processing.js JavaScript library. This means that you will never have to install a proprietary plugin to play our game, and in the near future will be able to play our game on any browser on any platform. Currently, however, some browsers do not yet have full support for the HTML5 standard, so please note the following browser compatibility issues:

          - Google Chrome has no problems, and is highly recommended for the best overall performance
          - If you are using Firefox 3 and the game is not loading or running slowly, try updating to Firefox 4
          - If you are using Safari and seeing performance issues, try turning off the sound effects
          - If you are using Internet Explorer, please switch to any of the above browsers immediately! -

          -
          -
          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/old/indexTest.html b/game/old/indexTest.html deleted file mode 100644 index 15c3b4d..0000000 --- a/game/old/indexTest.html +++ /dev/null @@ -1,105 +0,0 @@ - -Virion - - - - - - - -
          - - - - - - diff --git a/game/old/jplayer/Jplayer.swf b/game/old/jplayer/Jplayer.swf deleted file mode 100755 index 9487f49..0000000 Binary files a/game/old/jplayer/Jplayer.swf and /dev/null differ diff --git a/game/old/jplayer/jquery.jplayer.min.js b/game/old/jplayer/jquery.jplayer.min.js deleted file mode 100755 index b9b7007..0000000 --- a/game/old/jplayer/jquery.jplayer.min.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - * jPlayer Plugin for jQuery JavaScript Library - * http://www.happyworm.com/jquery/jplayer - * - * Copyright (c) 2009 - 2010 Happyworm Ltd - * Dual licensed under the MIT and GPL licenses. - * - http://www.opensource.org/licenses/mit-license.php - * - http://www.gnu.org/copyleft/gpl.html - * - * Author: Mark J Panaghiston - * Version: 2.0.0 - * Date: 20th December 2010 - */ - -(function(c,h){c.fn.jPlayer=function(a){var b=typeof a==="string",d=Array.prototype.slice.call(arguments,1),f=this;a=!b&&d.length?c.extend.apply(null,[true,a].concat(d)):a;if(b&&a.charAt(0)==="_")return f;b?this.each(function(){var e=c.data(this,"jPlayer"),g=e&&c.isFunction(e[a])?e[a].apply(e,d):e;if(g!==e&&g!==h){f=g;return false}}):this.each(function(){var e=c.data(this,"jPlayer");if(e){e.option(a||{})._init();e.option(a||{})}else c.data(this,"jPlayer",new c.jPlayer(a,this))});return f};c.jPlayer= -function(a,b){if(arguments.length){this.element=c(b);this.options=c.extend(true,{},this.options,a);var d=this;this.element.bind("remove.jPlayer",function(){d.destroy()});this._init()}};c.jPlayer.event={ready:"jPlayer_ready",resize:"jPlayer_resize",error:"jPlayer_error",warning:"jPlayer_warning",loadstart:"jPlayer_loadstart",progress:"jPlayer_progress",suspend:"jPlayer_suspend",abort:"jPlayer_abort",emptied:"jPlayer_emptied",stalled:"jPlayer_stalled",play:"jPlayer_play",pause:"jPlayer_pause",loadedmetadata:"jPlayer_loadedmetadata", -loadeddata:"jPlayer_loadeddata",waiting:"jPlayer_waiting",playing:"jPlayer_playing",canplay:"jPlayer_canplay",canplaythrough:"jPlayer_canplaythrough",seeking:"jPlayer_seeking",seeked:"jPlayer_seeked",timeupdate:"jPlayer_timeupdate",ended:"jPlayer_ended",ratechange:"jPlayer_ratechange",durationchange:"jPlayer_durationchange",volumechange:"jPlayer_volumechange"};c.jPlayer.htmlEvent=["loadstart","abort","emptied","stalled","loadedmetadata","loadeddata","canplaythrough","ratechange"];c.jPlayer.pause= -function(){c.each(c.jPlayer.prototype.instances,function(a,b){b.data("jPlayer").status.srcSet&&b.jPlayer("pause")})};c.jPlayer.timeFormat={showHour:false,showMin:true,showSec:true,padHour:false,padMin:true,padSec:true,sepHour:":",sepMin:":",sepSec:""};c.jPlayer.convertTime=function(a){a=new Date(a*1E3);var b=a.getUTCHours(),d=a.getUTCMinutes();a=a.getUTCSeconds();b=c.jPlayer.timeFormat.padHour&&b<10?"0"+b:b;d=c.jPlayer.timeFormat.padMin&&d<10?"0"+d:d;a=c.jPlayer.timeFormat.padSec&&a<10?"0"+a:a;return(c.jPlayer.timeFormat.showHour? -b+c.jPlayer.timeFormat.sepHour:"")+(c.jPlayer.timeFormat.showMin?d+c.jPlayer.timeFormat.sepMin:"")+(c.jPlayer.timeFormat.showSec?a+c.jPlayer.timeFormat.sepSec:"")};c.jPlayer.uaMatch=function(a){a=a.toLowerCase();var b=/(opera)(?:.*version)?[ \/]([\w.]+)/,d=/(msie) ([\w.]+)/,f=/(mozilla)(?:.*? rv:([\w.]+))?/;a=/(webkit)[ \/]([\w.]+)/.exec(a)||b.exec(a)||d.exec(a)||a.indexOf("compatible")<0&&f.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}};c.jPlayer.browser={};var m=c.jPlayer.uaMatch(navigator.userAgent); -if(m.browser){c.jPlayer.browser[m.browser]=true;c.jPlayer.browser.version=m.version}c.jPlayer.prototype={count:0,version:{script:"2.0.0",needFlash:"2.0.0",flash:"unknown"},options:{swfPath:"./",solution:"html, flash",supplied:"mp3",preload:"metadata",volume:0.8,muted:false,backgroundColor:"#000000",cssSelectorAncestor:"#jp_interface_1",cssSelector:{videoPlay:".jp-video-play",play:".jp-play",pause:".jp-pause",stop:".jp-stop",seekBar:".jp-seek-bar",playBar:".jp-play-bar",mute:".jp-mute",unmute:".jp-unmute", -volumeBar:".jp-volume-bar",volumeBarValue:".jp-volume-bar-value",currentTime:".jp-current-time",duration:".jp-duration"},idPrefix:"jp",errorAlerts:false,warningAlerts:false},instances:{},status:{src:"",media:{},paused:true,format:{},formatType:"",waitForPlay:true,waitForLoad:true,srcSet:false,video:false,seekPercent:0,currentPercentRelative:0,currentPercentAbsolute:0,currentTime:0,duration:0},_status:{volume:h,muted:false,width:0,height:0},internal:{ready:false,instance:h,htmlDlyCmdId:h},solution:{html:true, -flash:true},format:{mp3:{codec:'audio/mpeg; codecs="mp3"',flashCanPlay:true,media:"audio"},m4a:{codec:'audio/mp4; codecs="mp4a.40.2"',flashCanPlay:true,media:"audio"},oga:{codec:'audio/ogg; codecs="vorbis"',flashCanPlay:false,media:"audio"},wav:{codec:'audio/wav; codecs="1"',flashCanPlay:false,media:"audio"},webma:{codec:'audio/webm; codecs="vorbis"',flashCanPlay:false,media:"audio"},m4v:{codec:'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',flashCanPlay:true,media:"video"},ogv:{codec:'video/ogg; codecs="theora, vorbis"', -flashCanPlay:false,media:"video"},webmv:{codec:'video/webm; codecs="vorbis, vp8"',flashCanPlay:false,media:"video"}},_init:function(){var a=this;this.element.empty();this.status=c.extend({},this.status,this._status);this.internal=c.extend({},this.internal);this.formats=[];this.solutions=[];this.require={};this.htmlElement={};this.html={};this.html.audio={};this.html.video={};this.flash={};this.css={};this.css.cs={};this.css.jq={};this.status.volume=this._limitValue(this.options.volume,0,1);this.status.muted= -this.options.muted;this.status.width=this.element.css("width");this.status.height=this.element.css("height");this.element.css({"background-color":this.options.backgroundColor});c.each(this.options.supplied.toLowerCase().split(","),function(e,g){var i=g.replace(/^\s+|\s+$/g,"");if(a.format[i]){var j=false;c.each(a.formats,function(n,k){if(i===k){j=true;return false}});j||a.formats.push(i)}});c.each(this.options.solution.toLowerCase().split(","),function(e,g){var i=g.replace(/^\s+|\s+$/g,"");if(a.solution[i]){var j= -false;c.each(a.solutions,function(n,k){if(i===k){j=true;return false}});j||a.solutions.push(i)}});this.internal.instance="jp_"+this.count;this.instances[this.internal.instance]=this.element;this.element.attr("id")===""&&this.element.attr("id",this.options.idPrefix+"_jplayer_"+this.count);this.internal.self=c.extend({},{id:this.element.attr("id"),jq:this.element});this.internal.audio=c.extend({},{id:this.options.idPrefix+"_audio_"+this.count,jq:h});this.internal.video=c.extend({},{id:this.options.idPrefix+ -"_video_"+this.count,jq:h});this.internal.flash=c.extend({},{id:this.options.idPrefix+"_flash_"+this.count,jq:h,swf:this.options.swfPath+(this.options.swfPath!==""&&this.options.swfPath.slice(-1)!=="/"?"/":"")+"Jplayer.swf"});this.internal.poster=c.extend({},{id:this.options.idPrefix+"_poster_"+this.count,jq:h});c.each(c.jPlayer.event,function(e,g){if(a.options[e]!==h){a.element.bind(g+".jPlayer",a.options[e]);a.options[e]=h}});this.htmlElement.poster=document.createElement("img");this.htmlElement.poster.id= -this.internal.poster.id;this.htmlElement.poster.onload=function(){if(!a.status.video||a.status.waitForPlay)a.internal.poster.jq.show()};this.element.append(this.htmlElement.poster);this.internal.poster.jq=c("#"+this.internal.poster.id);this.internal.poster.jq.css({width:this.status.width,height:this.status.height});this.internal.poster.jq.hide();this.require.audio=false;this.require.video=false;c.each(this.formats,function(e,g){a.require[a.format[g].media]=true});this.html.audio.available=false;if(this.require.audio){this.htmlElement.audio= -document.createElement("audio");this.htmlElement.audio.id=this.internal.audio.id;this.html.audio.available=!!this.htmlElement.audio.canPlayType}this.html.video.available=false;if(this.require.video){this.htmlElement.video=document.createElement("video");this.htmlElement.video.id=this.internal.video.id;this.html.video.available=!!this.htmlElement.video.canPlayType}this.flash.available=this._checkForFlash(10);this.html.canPlay={};this.flash.canPlay={};c.each(this.formats,function(e,g){a.html.canPlay[g]= -a.html[a.format[g].media].available&&""!==a.htmlElement[a.format[g].media].canPlayType(a.format[g].codec);a.flash.canPlay[g]=a.format[g].flashCanPlay&&a.flash.available});this.html.desired=false;this.flash.desired=false;c.each(this.solutions,function(e,g){if(e===0)a[g].desired=true;else{var i=false,j=false;c.each(a.formats,function(n,k){if(a[a.solutions[0]].canPlay[k])if(a.format[k].media==="video")j=true;else i=true});a[g].desired=a.require.audio&&!i||a.require.video&&!j}});this.html.support={}; -this.flash.support={};c.each(this.formats,function(e,g){a.html.support[g]=a.html.canPlay[g]&&a.html.desired;a.flash.support[g]=a.flash.canPlay[g]&&a.flash.desired});this.html.used=false;this.flash.used=false;c.each(this.solutions,function(e,g){c.each(a.formats,function(i,j){if(a[g].support[j]){a[g].used=true;return false}})});this.html.used||this.flash.used||this._error({type:c.jPlayer.error.NO_SOLUTION,context:"{solution:'"+this.options.solution+"', supplied:'"+this.options.supplied+"'}",message:c.jPlayer.errorMsg.NO_SOLUTION, -hint:c.jPlayer.errorHint.NO_SOLUTION});this.html.active=false;this.html.audio.gate=false;this.html.video.gate=false;this.flash.active=false;this.flash.gate=false;if(this.flash.used){var b="id="+escape(this.internal.self.id)+"&vol="+this.status.volume+"&muted="+this.status.muted;if(c.browser.msie&&Number(c.browser.version)<=8){var d='';f[1]='';f[2]='';f[3]='';f[4]='';b=document.createElement(d);for(d=0;d0?100*d/this.status.duration:0;if(typeof a.seekable==="object"&&a.seekable.length>0){e=this.status.duration>0?100*a.seekable.end(a.seekable.length-1)/this.status.duration:100;g=100*a.currentTime/a.seekable.end(a.seekable.length-1)}else{e=100;g=f}if(b)f=g=d=0;this.status.seekPercent=e;this.status.currentPercentRelative=g;this.status.currentPercentAbsolute=f;this.status.currentTime=d},_resetStatus:function(){this.status=c.extend({},this.status,c.jPlayer.prototype.status)}, -_trigger:function(a,b,d){a=c.Event(a);a.jPlayer={};a.jPlayer.version=c.extend({},this.version);a.jPlayer.status=c.extend(true,{},this.status);a.jPlayer.html=c.extend(true,{},this.html);a.jPlayer.flash=c.extend(true,{},this.flash);if(b)a.jPlayer.error=c.extend({},b);if(d)a.jPlayer.warning=c.extend({},d);this.element.trigger(a)},jPlayerFlashEvent:function(a,b){if(a===c.jPlayer.event.ready&&!this.internal.ready){this.internal.ready=true;this.version.flash=b.version;this.version.needFlash!==this.version.flash&& -this._error({type:c.jPlayer.error.VERSION,context:this.version.flash,message:c.jPlayer.errorMsg.VERSION+this.version.flash,hint:c.jPlayer.errorHint.VERSION});this._trigger(a)}if(this.flash.gate)switch(a){case c.jPlayer.event.progress:this._getFlashStatus(b);this._updateInterface();this._trigger(a);break;case c.jPlayer.event.timeupdate:this._getFlashStatus(b);this._updateInterface();this._trigger(a);break;case c.jPlayer.event.play:this._seeked();this._updateButtons(true);this._trigger(a);break;case c.jPlayer.event.pause:this._updateButtons(false); -this._trigger(a);break;case c.jPlayer.event.ended:this._updateButtons(false);this._trigger(a);break;case c.jPlayer.event.error:this.status.waitForLoad=true;this.status.waitForPlay=true;this.status.video&&this.internal.flash.jq.css({width:"0px",height:"0px"});this._validString(this.status.media.poster)&&this.internal.poster.jq.show();this.css.jq.videoPlay.length&&this.css.jq.videoPlay.show();this.status.video?this._flash_setVideo(this.status.media):this._flash_setAudio(this.status.media);this._error({type:c.jPlayer.error.URL, -context:b.src,message:c.jPlayer.errorMsg.URL,hint:c.jPlayer.errorHint.URL});break;case c.jPlayer.event.seeking:this._seeking();this._trigger(a);break;case c.jPlayer.event.seeked:this._seeked();this._trigger(a);break;default:this._trigger(a)}return false},_getFlashStatus:function(a){this.status.seekPercent=a.seekPercent;this.status.currentPercentRelative=a.currentPercentRelative;this.status.currentPercentAbsolute=a.currentPercentAbsolute;this.status.currentTime=a.currentTime;this.status.duration=a.duration}, -_updateButtons:function(a){this.status.paused=!a;if(this.css.jq.play.length&&this.css.jq.pause.length)if(a){this.css.jq.play.hide();this.css.jq.pause.show()}else{this.css.jq.play.show();this.css.jq.pause.hide()}},_updateInterface:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.width(this.status.seekPercent+"%");this.css.jq.playBar.length&&this.css.jq.playBar.width(this.status.currentPercentRelative+"%");this.css.jq.currentTime.length&&this.css.jq.currentTime.text(c.jPlayer.convertTime(this.status.currentTime)); -this.css.jq.duration.length&&this.css.jq.duration.text(c.jPlayer.convertTime(this.status.duration))},_seeking:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.addClass("jp-seeking-bg")},_seeked:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.removeClass("jp-seeking-bg")},setMedia:function(a){var b=this;this._seeked();clearTimeout(this.internal.htmlDlyCmdId);var d=this.html.audio.gate,f=this.html.video.gate,e=false;c.each(this.formats,function(g,i){var j=b.format[i].media==="video"; -c.each(b.solutions,function(n,k){if(b[k].support[i]&&b._validString(a[i])){var l=k==="html";if(j)if(l){b.html.audio.gate=false;b.html.video.gate=true;b.flash.gate=false}else{b.html.audio.gate=false;b.html.video.gate=false;b.flash.gate=true}else if(l){b.html.audio.gate=true;b.html.video.gate=false;b.flash.gate=false}else{b.html.audio.gate=false;b.html.video.gate=false;b.flash.gate=true}if(b.flash.active||b.html.active&&b.flash.gate||d===b.html.audio.gate&&f===b.html.video.gate)b.clearMedia();else if(d!== -b.html.audio.gate&&f!==b.html.video.gate){b._html_pause();b.status.video&&b.internal.video.jq.css({width:"0px",height:"0px"});b._resetStatus()}if(j){if(l){b._html_setVideo(a);b.html.active=true;b.flash.active=false}else{b._flash_setVideo(a);b.html.active=false;b.flash.active=true}b.css.jq.videoPlay.length&&b.css.jq.videoPlay.show();b.status.video=true}else{if(l){b._html_setAudio(a);b.html.active=true;b.flash.active=false}else{b._flash_setAudio(a);b.html.active=false;b.flash.active=true}b.css.jq.videoPlay.length&& -b.css.jq.videoPlay.hide();b.status.video=false}e=true;return false}});if(e)return false});if(e){if(this._validString(a.poster))if(this.htmlElement.poster.src!==a.poster)this.htmlElement.poster.src=a.poster;else this.internal.poster.jq.show();else this.internal.poster.jq.hide();this.status.srcSet=true;this.status.media=c.extend({},a);this._updateButtons(false);this._updateInterface()}else{this.status.srcSet&&!this.status.waitForPlay&&this.pause();this.html.audio.gate=false;this.html.video.gate=false; -this.flash.gate=false;this.html.active=false;this.flash.active=false;this._resetStatus();this._updateInterface();this._updateButtons(false);this.internal.poster.jq.hide();this.html.used&&this.require.video&&this.internal.video.jq.css({width:"0px",height:"0px"});this.flash.used&&this.internal.flash.jq.css({width:"0px",height:"0px"});this._error({type:c.jPlayer.error.NO_SUPPORT,context:"{supplied:'"+this.options.supplied+"'}",message:c.jPlayer.errorMsg.NO_SUPPORT,hint:c.jPlayer.errorHint.NO_SUPPORT})}}, -clearMedia:function(){this._resetStatus();this._updateButtons(false);this.internal.poster.jq.hide();clearTimeout(this.internal.htmlDlyCmdId);if(this.html.active)this._html_clearMedia();else this.flash.active&&this._flash_clearMedia()},load:function(){if(this.status.srcSet)if(this.html.active)this._html_load();else this.flash.active&&this._flash_load();else this._urlNotSetError("load")},play:function(a){a=typeof a==="number"?a:NaN;if(this.status.srcSet)if(this.html.active)this._html_play(a);else this.flash.active&& -this._flash_play(a);else this._urlNotSetError("play")},videoPlay:function(){this.play()},pause:function(a){a=typeof a==="number"?a:NaN;if(this.status.srcSet)if(this.html.active)this._html_pause(a);else this.flash.active&&this._flash_pause(a);else this._urlNotSetError("pause")},pauseOthers:function(){var a=this;c.each(this.instances,function(b,d){a.element!==d&&d.data("jPlayer").status.srcSet&&d.jPlayer("pause")})},stop:function(){if(this.status.srcSet)if(this.html.active)this._html_pause(0);else this.flash.active&& -this._flash_pause(0);else this._urlNotSetError("stop")},playHead:function(a){a=this._limitValue(a,0,100);if(this.status.srcSet)if(this.html.active)this._html_playHead(a);else this.flash.active&&this._flash_playHead(a);else this._urlNotSetError("playHead")},mute:function(){this.status.muted=true;this.html.used&&this._html_mute(true);this.flash.used&&this._flash_mute(true);this._updateMute(true);this._updateVolume(0);this._trigger(c.jPlayer.event.volumechange)},unmute:function(){this.status.muted=false; -this.html.used&&this._html_mute(false);this.flash.used&&this._flash_mute(false);this._updateMute(false);this._updateVolume(this.status.volume);this._trigger(c.jPlayer.event.volumechange)},_updateMute:function(a){if(this.css.jq.mute.length&&this.css.jq.unmute.length)if(a){this.css.jq.mute.hide();this.css.jq.unmute.show()}else{this.css.jq.mute.show();this.css.jq.unmute.hide()}},volume:function(a){a=this._limitValue(a,0,1);this.status.volume=a;this.html.used&&this._html_volume(a);this.flash.used&&this._flash_volume(a); -this.status.muted||this._updateVolume(a);this._trigger(c.jPlayer.event.volumechange)},volumeBar:function(a){if(!this.status.muted&&this.css.jq.volumeBar){var b=this.css.jq.volumeBar.offset();a=a.pageX-b.left;b=this.css.jq.volumeBar.width();this.volume(a/b)}},volumeBarValue:function(a){this.volumeBar(a)},_updateVolume:function(a){this.css.jq.volumeBarValue.length&&this.css.jq.volumeBarValue.width(a*100+"%")},_volumeFix:function(a){var b=0.0010*Math.random();return a+(a<0.5?b:-b)},_cssSelectorAncestor:function(a, -b){this.options.cssSelectorAncestor=a;b&&c.each(this.options.cssSelector,function(d,f){self._cssSelector(d,f)})},_cssSelector:function(a,b){var d=this;if(typeof b==="string")if(c.jPlayer.prototype.options.cssSelector[a]){this.css.jq[a]&&this.css.jq[a].length&&this.css.jq[a].unbind(".jPlayer");this.options.cssSelector[a]=b;this.css.cs[a]=this.options.cssSelectorAncestor+" "+b;this.css.jq[a]=b?c(this.css.cs[a]):[];this.css.jq[a].length&&this.css.jq[a].bind("click.jPlayer",function(f){d[a](f);c(this).blur(); -return false});b&&this.css.jq[a].length!==1&&this._warning({type:c.jPlayer.warning.CSS_SELECTOR_COUNT,context:this.css.cs[a],message:c.jPlayer.warningMsg.CSS_SELECTOR_COUNT+this.css.jq[a].length+" found for "+a+" method.",hint:c.jPlayer.warningHint.CSS_SELECTOR_COUNT})}else this._warning({type:c.jPlayer.warning.CSS_SELECTOR_METHOD,context:a,message:c.jPlayer.warningMsg.CSS_SELECTOR_METHOD,hint:c.jPlayer.warningHint.CSS_SELECTOR_METHOD});else this._warning({type:c.jPlayer.warning.CSS_SELECTOR_STRING, -context:b,message:c.jPlayer.warningMsg.CSS_SELECTOR_STRING,hint:c.jPlayer.warningHint.CSS_SELECTOR_STRING})},seekBar:function(a){if(this.css.jq.seekBar){var b=this.css.jq.seekBar.offset();a=a.pageX-b.left;b=this.css.jq.seekBar.width();this.playHead(100*a/b)}},playBar:function(a){this.seekBar(a)},currentTime:function(){},duration:function(){},option:function(a,b){var d=a;if(arguments.length===0)return c.extend(true,{},this.options);if(typeof a==="string"){var f=a.split(".");if(b===h){for(var e=c.extend(true, -{},this.options),g=0;g=9||this.htmlElement.media.load()}},_html_load:function(){if(this.status.waitForLoad){this.status.waitForLoad=false;this.htmlElement.media.src=this.status.src; -try{this.htmlElement.media.load()}catch(a){}}clearTimeout(this.internal.htmlDlyCmdId)},_html_play:function(a){var b=this;this._html_load();this.htmlElement.media.play();if(!isNaN(a))try{this.htmlElement.media.currentTime=a}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.play(a)},100);return}this._html_checkWaitForPlay()},_html_pause:function(a){var b=this;a>0?this._html_load():clearTimeout(this.internal.htmlDlyCmdId);this.htmlElement.media.pause();if(!isNaN(a))try{this.htmlElement.media.currentTime= -a}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.pause(a)},100);return}a>0&&this._html_checkWaitForPlay()},_html_playHead:function(a){var b=this;this._html_load();try{if(typeof this.htmlElement.media.seekable==="object"&&this.htmlElement.media.seekable.length>0)this.htmlElement.media.currentTime=a*this.htmlElement.media.seekable.end(this.htmlElement.media.seekable.length-1)/100;else if(this.htmlElement.media.duration>0&&!isNaN(this.htmlElement.media.duration))this.htmlElement.media.currentTime= -a*this.htmlElement.media.duration/100;else throw"e";}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.playHead(a)},100);return}this.status.waitForLoad||this._html_checkWaitForPlay()},_html_checkWaitForPlay:function(){if(this.status.waitForPlay){this.status.waitForPlay=false;this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide();if(this.status.video){this.internal.poster.jq.hide();this.internal.video.jq.css({width:this.status.width,height:this.status.height})}}},_html_volume:function(a){if(this.html.audio.available)this.htmlElement.audio.volume= -a;if(this.html.video.available)this.htmlElement.video.volume=a},_html_mute:function(a){if(this.html.audio.available)this.htmlElement.audio.muted=a;if(this.html.video.available)this.htmlElement.video.muted=a},_flash_setAudio:function(a){var b=this;try{c.each(this.formats,function(f,e){if(b.flash.support[e]&&a[e]){switch(e){case "m4a":b._getMovie().fl_setAudio_m4a(a[e]);break;case "mp3":b._getMovie().fl_setAudio_mp3(a[e])}b.status.src=a[e];b.status.format[e]=true;b.status.formatType=e;return false}}); -if(this.options.preload==="auto"){this._flash_load();this.status.waitForLoad=false}}catch(d){this._flashError(d)}},_flash_setVideo:function(a){var b=this;try{c.each(this.formats,function(f,e){if(b.flash.support[e]&&a[e]){switch(e){case "m4v":b._getMovie().fl_setVideo_m4v(a[e])}b.status.src=a[e];b.status.format[e]=true;b.status.formatType=e;return false}});if(this.options.preload==="auto"){this._flash_load();this.status.waitForLoad=false}}catch(d){this._flashError(d)}},_flash_clearMedia:function(){this.internal.flash.jq.css({width:"0px", -height:"0px"});try{this._getMovie().fl_clearMedia()}catch(a){this._flashError(a)}},_flash_load:function(){try{this._getMovie().fl_load()}catch(a){this._flashError(a)}this.status.waitForLoad=false},_flash_play:function(a){try{this._getMovie().fl_play(a)}catch(b){this._flashError(b)}this.status.waitForLoad=false;this._flash_checkWaitForPlay()},_flash_pause:function(a){try{this._getMovie().fl_pause(a)}catch(b){this._flashError(b)}if(a>0){this.status.waitForLoad=false;this._flash_checkWaitForPlay()}}, -_flash_playHead:function(a){try{this._getMovie().fl_play_head(a)}catch(b){this._flashError(b)}this.status.waitForLoad||this._flash_checkWaitForPlay()},_flash_checkWaitForPlay:function(){if(this.status.waitForPlay){this.status.waitForPlay=false;this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide();if(this.status.video){this.internal.poster.jq.hide();this.internal.flash.jq.css({width:this.status.width,height:this.status.height})}}},_flash_volume:function(a){try{this._getMovie().fl_volume(a)}catch(b){this._flashError(b)}}, -_flash_mute:function(a){try{this._getMovie().fl_mute(a)}catch(b){this._flashError(b)}},_getMovie:function(){return document[this.internal.flash.id]},_checkForFlash:function(a){var b=false,d;if(window.ActiveXObject)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+a);b=true}catch(f){}else if(navigator.plugins&&navigator.mimeTypes.length>0)if(d=navigator.plugins["Shockwave Flash"])if(navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/,"$1")>=a)b=true;return c.browser.msie&& -Number(c.browser.version)>=9?false:b},_validString:function(a){return a&&typeof a==="string"},_limitValue:function(a,b,d){return ad?d:a},_urlNotSetError:function(a){this._error({type:c.jPlayer.error.URL_NOT_SET,context:a,message:c.jPlayer.errorMsg.URL_NOT_SET,hint:c.jPlayer.errorHint.URL_NOT_SET})},_flashError:function(a){this._error({type:c.jPlayer.error.FLASH,context:this.internal.flash.swf,message:c.jPlayer.errorMsg.FLASH+a.message,hint:c.jPlayer.errorHint.FLASH})},_error:function(a){this._trigger(c.jPlayer.event.error, -a);if(this.options.errorAlerts)this._alert("Error!"+(a.message?"\n\n"+a.message:"")+(a.hint?"\n\n"+a.hint:"")+"\n\nContext: "+a.context)},_warning:function(a){this._trigger(c.jPlayer.event.warning,h,a);if(this.options.errorAlerts)this._alert("Warning!"+(a.message?"\n\n"+a.message:"")+(a.hint?"\n\n"+a.hint:"")+"\n\nContext: "+a.context)},_alert:function(a){alert("jPlayer "+this.version.script+" : id='"+this.internal.self.id+"' : "+a)}};c.jPlayer.error={FLASH:"e_flash",NO_SOLUTION:"e_no_solution",NO_SUPPORT:"e_no_support", -URL:"e_url",URL_NOT_SET:"e_url_not_set",VERSION:"e_version"};c.jPlayer.errorMsg={FLASH:"jPlayer's Flash fallback is not configured correctly, or a command was issued before the jPlayer Ready event. Details: ",NO_SOLUTION:"No solution can be found by jPlayer in this browser. Neither HTML nor Flash can be used.",NO_SUPPORT:"It is not possible to play any media format provided in setMedia() on this browser using your current options.",URL:"Media URL could not be loaded.",URL_NOT_SET:"Attempt to issue media playback commands, while no media url is set.", -VERSION:"jPlayer "+c.jPlayer.prototype.version.script+" needs Jplayer.swf version "+c.jPlayer.prototype.version.needFlash+" but found "};c.jPlayer.errorHint={FLASH:"Check your swfPath option and that Jplayer.swf is there.",NO_SOLUTION:"Review the jPlayer options: support and supplied.",NO_SUPPORT:"Video or audio formats defined in the supplied option are missing.",URL:"Check media URL is valid.",URL_NOT_SET:"Use setMedia() to set the media URL.",VERSION:"Update jPlayer files."};c.jPlayer.warning= -{CSS_SELECTOR_COUNT:"e_css_selector_count",CSS_SELECTOR_METHOD:"e_css_selector_method",CSS_SELECTOR_STRING:"e_css_selector_string",OPTION_KEY:"e_option_key"};c.jPlayer.warningMsg={CSS_SELECTOR_COUNT:"The number of methodCssSelectors found did not equal one: ",CSS_SELECTOR_METHOD:"The methodName given in jPlayer('cssSelector') is not a valid jPlayer method.",CSS_SELECTOR_STRING:"The methodCssSelector given in jPlayer('cssSelector') is not a String or is empty.",OPTION_KEY:"The option requested in jPlayer('option') is undefined."}; -c.jPlayer.warningHint={CSS_SELECTOR_COUNT:"Check your css selector and the ancestor.",CSS_SELECTOR_METHOD:"Check your method name.",CSS_SELECTOR_STRING:"Check your css selector is a string.",OPTION_KEY:"Check your option name."}})(jQuery); diff --git a/game/old/jquery-1.4.4.min.js b/game/old/jquery-1.4.4.min.js deleted file mode 100644 index 8f3ca2e..0000000 --- a/game/old/jquery-1.4.4.min.js +++ /dev/null @@ -1,167 +0,0 @@ -/*! - * jQuery JavaScript Library v1.4.4 - * http://jquery.com/ - * - * Copyright 2010, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * Copyright 2010, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * - * Date: Thu Nov 11 19:04:53 2010 -0500 - */ -(function(E,B){function ka(a,b,d){if(d===B&&a.nodeType===1){d=a.getAttribute("data-"+b);if(typeof d==="string"){try{d=d==="true"?true:d==="false"?false:d==="null"?null:!c.isNaN(d)?parseFloat(d):Ja.test(d)?c.parseJSON(d):d}catch(e){}c.data(a,b,d)}else d=B}return d}function U(){return false}function ca(){return true}function la(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function Ka(a){var b,d,e,f,h,l,k,o,x,r,A,C=[];f=[];h=c.data(this,this.nodeType?"events":"__events__");if(typeof h==="function")h= -h.events;if(!(a.liveFired===this||!h||!h.live||a.button&&a.type==="click")){if(a.namespace)A=RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)");a.liveFired=this;var J=h.live.slice(0);for(k=0;kd)break;a.currentTarget=f.elem;a.data=f.handleObj.data;a.handleObj=f.handleObj;A=f.handleObj.origHandler.apply(f.elem,arguments);if(A===false||a.isPropagationStopped()){d=f.level;if(A===false)b=false;if(a.isImmediatePropagationStopped())break}}return b}}function Y(a,b){return(a&&a!=="*"?a+".":"")+b.replace(La, -"`").replace(Ma,"&")}function ma(a,b,d){if(c.isFunction(b))return c.grep(a,function(f,h){return!!b.call(f,h,f)===d});else if(b.nodeType)return c.grep(a,function(f){return f===b===d});else if(typeof b==="string"){var e=c.grep(a,function(f){return f.nodeType===1});if(Na.test(b))return c.filter(b,e,!d);else b=c.filter(b,e)}return c.grep(a,function(f){return c.inArray(f,b)>=0===d})}function na(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var e=c.data(a[d++]),f=c.data(this, -e);if(e=e&&e.events){delete f.handle;f.events={};for(var h in e)for(var l in e[h])c.event.add(this,h,e[h][l],e[h][l].data)}}})}function Oa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function oa(a,b,d){var e=b==="width"?a.offsetWidth:a.offsetHeight;if(d==="border")return e;c.each(b==="width"?Pa:Qa,function(){d||(e-=parseFloat(c.css(a,"padding"+this))||0);if(d==="margin")e+=parseFloat(c.css(a, -"margin"+this))||0;else e-=parseFloat(c.css(a,"border"+this+"Width"))||0});return e}function da(a,b,d,e){if(c.isArray(b)&&b.length)c.each(b,function(f,h){d||Ra.test(a)?e(a,h):da(a+"["+(typeof h==="object"||c.isArray(h)?f:"")+"]",h,d,e)});else if(!d&&b!=null&&typeof b==="object")c.isEmptyObject(b)?e(a,""):c.each(b,function(f,h){da(a+"["+f+"]",h,d,e)});else e(a,b)}function S(a,b){var d={};c.each(pa.concat.apply([],pa.slice(0,b)),function(){d[this]=a});return d}function qa(a){if(!ea[a]){var b=c("<"+ -a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d==="")d="block";ea[a]=d}return ea[a]}function fa(a){return c.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var t=E.document,c=function(){function a(){if(!b.isReady){try{t.documentElement.doScroll("left")}catch(j){setTimeout(a,1);return}b.ready()}}var b=function(j,s){return new b.fn.init(j,s)},d=E.jQuery,e=E.$,f,h=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,l=/\S/,k=/^\s+/,o=/\s+$/,x=/\W/,r=/\d/,A=/^<(\w+)\s*\/?>(?:<\/\1>)?$/, -C=/^[\],:{}\s]*$/,J=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,w=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,I=/(?:^|:|,)(?:\s*\[)+/g,L=/(webkit)[ \/]([\w.]+)/,g=/(opera)(?:.*version)?[ \/]([\w.]+)/,i=/(msie) ([\w.]+)/,n=/(mozilla)(?:.*? rv:([\w.]+))?/,m=navigator.userAgent,p=false,q=[],u,y=Object.prototype.toString,F=Object.prototype.hasOwnProperty,M=Array.prototype.push,N=Array.prototype.slice,O=String.prototype.trim,D=Array.prototype.indexOf,R={};b.fn=b.prototype={init:function(j, -s){var v,z,H;if(!j)return this;if(j.nodeType){this.context=this[0]=j;this.length=1;return this}if(j==="body"&&!s&&t.body){this.context=t;this[0]=t.body;this.selector="body";this.length=1;return this}if(typeof j==="string")if((v=h.exec(j))&&(v[1]||!s))if(v[1]){H=s?s.ownerDocument||s:t;if(z=A.exec(j))if(b.isPlainObject(s)){j=[t.createElement(z[1])];b.fn.attr.call(j,s,true)}else j=[H.createElement(z[1])];else{z=b.buildFragment([v[1]],[H]);j=(z.cacheable?z.fragment.cloneNode(true):z.fragment).childNodes}return b.merge(this, -j)}else{if((z=t.getElementById(v[2]))&&z.parentNode){if(z.id!==v[2])return f.find(j);this.length=1;this[0]=z}this.context=t;this.selector=j;return this}else if(!s&&!x.test(j)){this.selector=j;this.context=t;j=t.getElementsByTagName(j);return b.merge(this,j)}else return!s||s.jquery?(s||f).find(j):b(s).find(j);else if(b.isFunction(j))return f.ready(j);if(j.selector!==B){this.selector=j.selector;this.context=j.context}return b.makeArray(j,this)},selector:"",jquery:"1.4.4",length:0,size:function(){return this.length}, -toArray:function(){return N.call(this,0)},get:function(j){return j==null?this.toArray():j<0?this.slice(j)[0]:this[j]},pushStack:function(j,s,v){var z=b();b.isArray(j)?M.apply(z,j):b.merge(z,j);z.prevObject=this;z.context=this.context;if(s==="find")z.selector=this.selector+(this.selector?" ":"")+v;else if(s)z.selector=this.selector+"."+s+"("+v+")";return z},each:function(j,s){return b.each(this,j,s)},ready:function(j){b.bindReady();if(b.isReady)j.call(t,b);else q&&q.push(j);return this},eq:function(j){return j=== --1?this.slice(j):this.slice(j,+j+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(N.apply(this,arguments),"slice",N.call(arguments).join(","))},map:function(j){return this.pushStack(b.map(this,function(s,v){return j.call(s,v,s)}))},end:function(){return this.prevObject||b(null)},push:M,sort:[].sort,splice:[].splice};b.fn.init.prototype=b.fn;b.extend=b.fn.extend=function(){var j,s,v,z,H,G=arguments[0]||{},K=1,Q=arguments.length,ga=false; -if(typeof G==="boolean"){ga=G;G=arguments[1]||{};K=2}if(typeof G!=="object"&&!b.isFunction(G))G={};if(Q===K){G=this;--K}for(;K0))if(q){var s=0,v=q;for(q=null;j=v[s++];)j.call(t,b);b.fn.trigger&&b(t).trigger("ready").unbind("ready")}}},bindReady:function(){if(!p){p=true;if(t.readyState==="complete")return setTimeout(b.ready,1);if(t.addEventListener){t.addEventListener("DOMContentLoaded",u,false);E.addEventListener("load",b.ready,false)}else if(t.attachEvent){t.attachEvent("onreadystatechange",u);E.attachEvent("onload", -b.ready);var j=false;try{j=E.frameElement==null}catch(s){}t.documentElement.doScroll&&j&&a()}}},isFunction:function(j){return b.type(j)==="function"},isArray:Array.isArray||function(j){return b.type(j)==="array"},isWindow:function(j){return j&&typeof j==="object"&&"setInterval"in j},isNaN:function(j){return j==null||!r.test(j)||isNaN(j)},type:function(j){return j==null?String(j):R[y.call(j)]||"object"},isPlainObject:function(j){if(!j||b.type(j)!=="object"||j.nodeType||b.isWindow(j))return false;if(j.constructor&& -!F.call(j,"constructor")&&!F.call(j.constructor.prototype,"isPrototypeOf"))return false;for(var s in j);return s===B||F.call(j,s)},isEmptyObject:function(j){for(var s in j)return false;return true},error:function(j){throw j;},parseJSON:function(j){if(typeof j!=="string"||!j)return null;j=b.trim(j);if(C.test(j.replace(J,"@").replace(w,"]").replace(I,"")))return E.JSON&&E.JSON.parse?E.JSON.parse(j):(new Function("return "+j))();else b.error("Invalid JSON: "+j)},noop:function(){},globalEval:function(j){if(j&& -l.test(j)){var s=t.getElementsByTagName("head")[0]||t.documentElement,v=t.createElement("script");v.type="text/javascript";if(b.support.scriptEval)v.appendChild(t.createTextNode(j));else v.text=j;s.insertBefore(v,s.firstChild);s.removeChild(v)}},nodeName:function(j,s){return j.nodeName&&j.nodeName.toUpperCase()===s.toUpperCase()},each:function(j,s,v){var z,H=0,G=j.length,K=G===B||b.isFunction(j);if(v)if(K)for(z in j){if(s.apply(j[z],v)===false)break}else for(;H
          a";var f=d.getElementsByTagName("*"),h=d.getElementsByTagName("a")[0],l=t.createElement("select"), -k=l.appendChild(t.createElement("option"));if(!(!f||!f.length||!h)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(h.getAttribute("style")),hrefNormalized:h.getAttribute("href")==="/a",opacity:/^0.55$/.test(h.style.opacity),cssFloat:!!h.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:k.selected,deleteExpando:true,optDisabled:false,checkClone:false, -scriptEval:false,noCloneEvent:true,boxModel:null,inlineBlockNeedsLayout:false,shrinkWrapBlocks:false,reliableHiddenOffsets:true};l.disabled=true;c.support.optDisabled=!k.disabled;b.type="text/javascript";try{b.appendChild(t.createTextNode("window."+e+"=1;"))}catch(o){}a.insertBefore(b,a.firstChild);if(E[e]){c.support.scriptEval=true;delete E[e]}try{delete b.test}catch(x){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function r(){c.support.noCloneEvent= -false;d.detachEvent("onclick",r)});d.cloneNode(true).fireEvent("onclick")}d=t.createElement("div");d.innerHTML="";a=t.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var r=t.createElement("div");r.style.width=r.style.paddingLeft="1px";t.body.appendChild(r);c.boxModel=c.support.boxModel=r.offsetWidth===2;if("zoom"in r.style){r.style.display="inline";r.style.zoom= -1;c.support.inlineBlockNeedsLayout=r.offsetWidth===2;r.style.display="";r.innerHTML="
          ";c.support.shrinkWrapBlocks=r.offsetWidth!==2}r.innerHTML="
          t
          ";var A=r.getElementsByTagName("td");c.support.reliableHiddenOffsets=A[0].offsetHeight===0;A[0].style.display="";A[1].style.display="none";c.support.reliableHiddenOffsets=c.support.reliableHiddenOffsets&&A[0].offsetHeight===0;r.innerHTML="";t.body.removeChild(r).style.display= -"none"});a=function(r){var A=t.createElement("div");r="on"+r;var C=r in A;if(!C){A.setAttribute(r,"return;");C=typeof A[r]==="function"}return C};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=f=h=null}})();var ra={},Ja=/^(?:\{.*\}|\[.*\])$/;c.extend({cache:{},uuid:0,expando:"jQuery"+c.now(),noData:{embed:true,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:true},data:function(a,b,d){if(c.acceptData(a)){a=a==E?ra:a;var e=a.nodeType,f=e?a[c.expando]:null,h= -c.cache;if(!(e&&!f&&typeof b==="string"&&d===B)){if(e)f||(a[c.expando]=f=++c.uuid);else h=a;if(typeof b==="object")if(e)h[f]=c.extend(h[f],b);else c.extend(h,b);else if(e&&!h[f])h[f]={};a=e?h[f]:h;if(d!==B)a[b]=d;return typeof b==="string"?a[b]:a}}},removeData:function(a,b){if(c.acceptData(a)){a=a==E?ra:a;var d=a.nodeType,e=d?a[c.expando]:a,f=c.cache,h=d?f[e]:e;if(b){if(h){delete h[b];d&&c.isEmptyObject(h)&&c.removeData(a)}}else if(d&&c.support.deleteExpando)delete a[c.expando];else if(a.removeAttribute)a.removeAttribute(c.expando); -else if(d)delete f[e];else for(var l in a)delete a[l]}},acceptData:function(a){if(a.nodeName){var b=c.noData[a.nodeName.toLowerCase()];if(b)return!(b===true||a.getAttribute("classid")!==b)}return true}});c.fn.extend({data:function(a,b){var d=null;if(typeof a==="undefined"){if(this.length){var e=this[0].attributes,f;d=c.data(this[0]);for(var h=0,l=e.length;h-1)return true;return false},val:function(a){if(!arguments.length){var b=this[0];if(b){if(c.nodeName(b,"option")){var d=b.attributes.value;return!d||d.specified?b.value:b.text}if(c.nodeName(b,"select")){var e=b.selectedIndex;d=[];var f=b.options;b=b.type==="select-one"; -if(e<0)return null;var h=b?e:0;for(e=b?e+1:f.length;h=0;else if(c.nodeName(this,"select")){var A=c.makeArray(r);c("option",this).each(function(){this.selected=c.inArray(c(this).val(),A)>=0});if(!A.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true}, -attr:function(a,b,d,e){if(!a||a.nodeType===3||a.nodeType===8)return B;if(e&&b in c.attrFn)return c(a)[b](d);e=a.nodeType!==1||!c.isXMLDoc(a);var f=d!==B;b=e&&c.props[b]||b;var h=Ta.test(b);if((b in a||a[b]!==B)&&e&&!h){if(f){b==="type"&&Ua.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");if(d===null)a.nodeType===1&&a.removeAttribute(b);else a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&& -b.specified?b.value:Va.test(a.nodeName)||Wa.test(a.nodeName)&&a.href?0:B;return a[b]}if(!c.support.style&&e&&b==="style"){if(f)a.style.cssText=""+d;return a.style.cssText}f&&a.setAttribute(b,""+d);if(!a.attributes[b]&&a.hasAttribute&&!a.hasAttribute(b))return B;a=!c.support.hrefNormalized&&e&&h?a.getAttribute(b,2):a.getAttribute(b);return a===null?B:a}});var X=/\.(.*)$/,ia=/^(?:textarea|input|select)$/i,La=/\./g,Ma=/ /g,Xa=/[^\w\s.|`]/g,Ya=function(a){return a.replace(Xa,"\\$&")},ua={focusin:0,focusout:0}; -c.event={add:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(c.isWindow(a)&&a!==E&&!a.frameElement)a=E;if(d===false)d=U;else if(!d)return;var f,h;if(d.handler){f=d;d=f.handler}if(!d.guid)d.guid=c.guid++;if(h=c.data(a)){var l=a.nodeType?"events":"__events__",k=h[l],o=h.handle;if(typeof k==="function"){o=k.handle;k=k.events}else if(!k){a.nodeType||(h[l]=h=function(){});h.events=k={}}if(!o)h.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem, -arguments):B};o.elem=a;b=b.split(" ");for(var x=0,r;l=b[x++];){h=f?c.extend({},f):{handler:d,data:e};if(l.indexOf(".")>-1){r=l.split(".");l=r.shift();h.namespace=r.slice(0).sort().join(".")}else{r=[];h.namespace=""}h.type=l;if(!h.guid)h.guid=d.guid;var A=k[l],C=c.event.special[l]||{};if(!A){A=k[l]=[];if(!C.setup||C.setup.call(a,e,r,o)===false)if(a.addEventListener)a.addEventListener(l,o,false);else a.attachEvent&&a.attachEvent("on"+l,o)}if(C.add){C.add.call(a,h);if(!h.handler.guid)h.handler.guid= -d.guid}A.push(h);c.event.global[l]=true}a=null}}},global:{},remove:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(d===false)d=U;var f,h,l=0,k,o,x,r,A,C,J=a.nodeType?"events":"__events__",w=c.data(a),I=w&&w[J];if(w&&I){if(typeof I==="function"){w=I;I=I.events}if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(f in I)c.event.remove(a,f+b)}else{for(b=b.split(" ");f=b[l++];){r=f;k=f.indexOf(".")<0;o=[];if(!k){o=f.split(".");f=o.shift();x=RegExp("(^|\\.)"+ -c.map(o.slice(0).sort(),Ya).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(A=I[f])if(d){r=c.event.special[f]||{};for(h=e||0;h=0){a.type=f=f.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[f]&&c.each(c.cache,function(){this.events&&this.events[f]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType=== -8)return B;a.result=B;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(e=d.nodeType?c.data(d,"handle"):(c.data(d,"__events__")||{}).handle)&&e.apply(d,b);e=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+f]&&d["on"+f].apply(d,b)===false){a.result=false;a.preventDefault()}}catch(h){}if(!a.isPropagationStopped()&&e)c.event.trigger(a,b,e,true);else if(!a.isDefaultPrevented()){var l;e=a.target;var k=f.replace(X,""),o=c.nodeName(e,"a")&&k=== -"click",x=c.event.special[k]||{};if((!x._default||x._default.call(d,a)===false)&&!o&&!(e&&e.nodeName&&c.noData[e.nodeName.toLowerCase()])){try{if(e[k]){if(l=e["on"+k])e["on"+k]=null;c.event.triggered=true;e[k]()}}catch(r){}if(l)e["on"+k]=l;c.event.triggered=false}}},handle:function(a){var b,d,e,f;d=[];var h=c.makeArray(arguments);a=h[0]=c.event.fix(a||E.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;if(!b){e=a.type.split(".");a.type=e.shift();d=e.slice(0).sort();e=RegExp("(^|\\.)"+ -d.join("\\.(?:.*\\.)?")+"(\\.|$)")}a.namespace=a.namespace||d.join(".");f=c.data(this,this.nodeType?"events":"__events__");if(typeof f==="function")f=f.events;d=(f||{})[a.type];if(f&&d){d=d.slice(0);f=0;for(var l=d.length;f-1?c.map(a.options,function(e){return e.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},Z=function(a,b){var d=a.target,e,f;if(!(!ia.test(d.nodeName)||d.readOnly)){e=c.data(d,"_change_data");f=xa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",f);if(!(e===B||f===e))if(e!=null||f){a.type="change";a.liveFired= -B;return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:Z,beforedeactivate:Z,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return Z.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return Z.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,"_change_data",xa(a))}},setup:function(){if(this.type=== -"file")return false;for(var a in V)c.event.add(this,a+".specialChange",V[a]);return ia.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return ia.test(this.nodeName)}};V=c.event.special.change.filters;V.focus=V.beforeactivate}t.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.trigger(e,null,e.target)}c.event.special[b]={setup:function(){ua[b]++===0&&t.addEventListener(a,d,true)},teardown:function(){--ua[b]=== -0&&t.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,e,f){if(typeof d==="object"){for(var h in d)this[b](h,e,d[h],f);return this}if(c.isFunction(e)||e===false){f=e;e=B}var l=b==="one"?c.proxy(f,function(o){c(this).unbind(o,l);return f.apply(this,arguments)}):f;if(d==="unload"&&b!=="one")this.one(d,e,f);else{h=0;for(var k=this.length;h0?this.bind(b,d,e):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});E.attachEvent&&!E.addEventListener&&c(E).bind("unload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}}); -(function(){function a(g,i,n,m,p,q){p=0;for(var u=m.length;p0){F=y;break}}y=y[g]}m[p]=F}}}var d=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,f=Object.prototype.toString,h=false,l=true;[0,0].sort(function(){l=false;return 0});var k=function(g,i,n,m){n=n||[];var p=i=i||t;if(i.nodeType!==1&&i.nodeType!==9)return[];if(!g||typeof g!=="string")return n;var q,u,y,F,M,N=true,O=k.isXML(i),D=[],R=g;do{d.exec("");if(q=d.exec(R)){R=q[3];D.push(q[1]);if(q[2]){F=q[3]; -break}}}while(q);if(D.length>1&&x.exec(g))if(D.length===2&&o.relative[D[0]])u=L(D[0]+D[1],i);else for(u=o.relative[D[0]]?[i]:k(D.shift(),i);D.length;){g=D.shift();if(o.relative[g])g+=D.shift();u=L(g,u)}else{if(!m&&D.length>1&&i.nodeType===9&&!O&&o.match.ID.test(D[0])&&!o.match.ID.test(D[D.length-1])){q=k.find(D.shift(),i,O);i=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]}if(i){q=m?{expr:D.pop(),set:C(m)}:k.find(D.pop(),D.length===1&&(D[0]==="~"||D[0]==="+")&&i.parentNode?i.parentNode:i,O);u=q.expr?k.filter(q.expr, -q.set):q.set;if(D.length>0)y=C(u);else N=false;for(;D.length;){q=M=D.pop();if(o.relative[M])q=D.pop();else M="";if(q==null)q=i;o.relative[M](y,q,O)}}else y=[]}y||(y=u);y||k.error(M||g);if(f.call(y)==="[object Array]")if(N)if(i&&i.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&k.contains(i,y[g])))n.push(u[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&n.push(u[g]);else n.push.apply(n,y);else C(y,n);if(F){k(F,p,n,m);k.uniqueSort(n)}return n};k.uniqueSort=function(g){if(w){h= -l;g.sort(w);if(h)for(var i=1;i0};k.find=function(g,i,n){var m;if(!g)return[];for(var p=0,q=o.order.length;p":function(g,i){var n,m=typeof i==="string",p=0,q=g.length;if(m&&!/\W/.test(i))for(i=i.toLowerCase();p=0))n||m.push(u);else if(n)i[q]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var i=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=i[1]+(i[2]||1)-0;g[3]=i[3]-0}g[0]=e++;return g},ATTR:function(g,i,n, -m,p,q){i=g[1].replace(/\\/g,"");if(!q&&o.attrMap[i])g[1]=o.attrMap[i];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,i,n,m,p){if(g[1]==="not")if((d.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,i);else{g=k.filter(g[3],i,n,true^p);n||m.push.apply(m,g);return false}else if(o.match.POS.test(g[0])||o.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled=== -true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,i,n){return!!k(n[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"=== -g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,i){return i===0},last:function(g,i,n,m){return i===m.length-1},even:function(g,i){return i%2===0},odd:function(g,i){return i%2===1},lt:function(g,i,n){return in[3]-0},nth:function(g,i,n){return n[3]- -0===i},eq:function(g,i,n){return n[3]-0===i}},filter:{PSEUDO:function(g,i,n,m){var p=i[1],q=o.filters[p];if(q)return q(g,n,i,m);else if(p==="contains")return(g.textContent||g.innerText||k.getText([g])||"").indexOf(i[3])>=0;else if(p==="not"){i=i[3];n=0;for(m=i.length;n=0}},ID:function(g,i){return g.nodeType===1&&g.getAttribute("id")===i},TAG:function(g,i){return i==="*"&&g.nodeType===1||g.nodeName.toLowerCase()=== -i},CLASS:function(g,i){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(i)>-1},ATTR:function(g,i){var n=i[1];n=o.attrHandle[n]?o.attrHandle[n](g):g[n]!=null?g[n]:g.getAttribute(n);var m=n+"",p=i[2],q=i[4];return n==null?p==="!=":p==="="?m===q:p==="*="?m.indexOf(q)>=0:p==="~="?(" "+m+" ").indexOf(q)>=0:!q?m&&n!==false:p==="!="?m!==q:p==="^="?m.indexOf(q)===0:p==="$="?m.substr(m.length-q.length)===q:p==="|="?m===q||m.substr(0,q.length+1)===q+"-":false},POS:function(g,i,n,m){var p=o.setFilters[i[2]]; -if(p)return p(g,n,i,m)}}},x=o.match.POS,r=function(g,i){return"\\"+(i-0+1)},A;for(A in o.match){o.match[A]=RegExp(o.match[A].source+/(?![^\[]*\])(?![^\(]*\))/.source);o.leftMatch[A]=RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[A].source.replace(/\\(\d+)/g,r))}var C=function(g,i){g=Array.prototype.slice.call(g,0);if(i){i.push.apply(i,g);return i}return g};try{Array.prototype.slice.call(t.documentElement.childNodes,0)}catch(J){C=function(g,i){var n=0,m=i||[];if(f.call(g)==="[object Array]")Array.prototype.push.apply(m, -g);else if(typeof g.length==="number")for(var p=g.length;n";n.insertBefore(g,n.firstChild);if(t.getElementById(i)){o.find.ID=function(m,p,q){if(typeof p.getElementById!=="undefined"&&!q)return(p=p.getElementById(m[1]))?p.id===m[1]||typeof p.getAttributeNode!=="undefined"&&p.getAttributeNode("id").nodeValue===m[1]?[p]:B:[]};o.filter.ID=function(m,p){var q=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&q&&q.nodeValue===p}}n.removeChild(g); -n=g=null})();(function(){var g=t.createElement("div");g.appendChild(t.createComment(""));if(g.getElementsByTagName("*").length>0)o.find.TAG=function(i,n){var m=n.getElementsByTagName(i[1]);if(i[1]==="*"){for(var p=[],q=0;m[q];q++)m[q].nodeType===1&&p.push(m[q]);m=p}return m};g.innerHTML="";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")o.attrHandle.href=function(i){return i.getAttribute("href",2)};g=null})();t.querySelectorAll&& -function(){var g=k,i=t.createElement("div");i.innerHTML="

          ";if(!(i.querySelectorAll&&i.querySelectorAll(".TEST").length===0)){k=function(m,p,q,u){p=p||t;m=m.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!u&&!k.isXML(p))if(p.nodeType===9)try{return C(p.querySelectorAll(m),q)}catch(y){}else if(p.nodeType===1&&p.nodeName.toLowerCase()!=="object"){var F=p.getAttribute("id"),M=F||"__sizzle__";F||p.setAttribute("id",M);try{return C(p.querySelectorAll("#"+M+" "+m),q)}catch(N){}finally{F|| -p.removeAttribute("id")}}return g(m,p,q,u)};for(var n in g)k[n]=g[n];i=null}}();(function(){var g=t.documentElement,i=g.matchesSelector||g.mozMatchesSelector||g.webkitMatchesSelector||g.msMatchesSelector,n=false;try{i.call(t.documentElement,"[test!='']:sizzle")}catch(m){n=true}if(i)k.matchesSelector=function(p,q){q=q.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(p))try{if(n||!o.match.PSEUDO.test(q)&&!/!=/.test(q))return i.call(p,q)}catch(u){}return k(q,null,null,[p]).length>0}})();(function(){var g= -t.createElement("div");g.innerHTML="
          ";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){o.order.splice(1,0,"CLASS");o.find.CLASS=function(i,n,m){if(typeof n.getElementsByClassName!=="undefined"&&!m)return n.getElementsByClassName(i[1])};g=null}}})();k.contains=t.documentElement.contains?function(g,i){return g!==i&&(g.contains?g.contains(i):true)}:t.documentElement.compareDocumentPosition? -function(g,i){return!!(g.compareDocumentPosition(i)&16)}:function(){return false};k.isXML=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false};var L=function(g,i){for(var n,m=[],p="",q=i.nodeType?[i]:i;n=o.match.PSEUDO.exec(g);){p+=n[0];g=g.replace(o.match.PSEUDO,"")}g=o.relative[g]?g+"*":g;n=0;for(var u=q.length;n0)for(var h=d;h0},closest:function(a,b){var d=[],e,f,h=this[0];if(c.isArray(a)){var l,k={},o=1;if(h&&a.length){e=0;for(f=a.length;e-1:c(h).is(e))d.push({selector:l,elem:h,level:o})}h= -h.parentNode;o++}}return d}l=cb.test(a)?c(a,b||this.context):null;e=0;for(f=this.length;e-1:c.find.matchesSelector(h,a)){d.push(h);break}else{h=h.parentNode;if(!h||!h.ownerDocument||h===b)break}d=d.length>1?c.unique(d):d;return this.pushStack(d,"closest",a)},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var d=typeof a==="string"?c(a,b||this.context): -c.makeArray(a),e=c.merge(this.get(),d);return this.pushStack(!d[0]||!d[0].parentNode||d[0].parentNode.nodeType===11||!e[0]||!e[0].parentNode||e[0].parentNode.nodeType===11?e:c.unique(e))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a, -2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a, -b){c.fn[a]=function(d,e){var f=c.map(this,b,d);Za.test(a)||(e=d);if(e&&typeof e==="string")f=c.filter(e,f);f=this.length>1?c.unique(f):f;if((this.length>1||ab.test(e))&&$a.test(a))f=f.reverse();return this.pushStack(f,a,bb.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return b.length===1?c.find.matchesSelector(b[0],a)?[b[0]]:[]:c.find.matches(a,b)},dir:function(a,b,d){var e=[];for(a=a[b];a&&a.nodeType!==9&&(d===B||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&& -e.push(a);a=a[b]}return e},nth:function(a,b,d){b=b||1;for(var e=0;a;a=a[d])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var za=/ jQuery\d+="(?:\d+|null)"/g,$=/^\s+/,Aa=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Ba=/<([\w:]+)/,db=/\s]+\/)>/g,P={option:[1, -""],legend:[1,"
          ","
          "],thead:[1,"","
          "],tr:[2,"","
          "],td:[3,"","
          "],col:[2,"","
          "],area:[1,"",""],_default:[0,"",""]};P.optgroup=P.option;P.tbody=P.tfoot=P.colgroup=P.caption=P.thead;P.th=P.td;if(!c.support.htmlSerialize)P._default=[1,"div
          ","
          "];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d= -c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==B)return this.empty().append((this[0]&&this[0].ownerDocument||t).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this}, -wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})}, -prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b, -this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,e;(e=this[d])!=null;d++)if(!a||c.filter(a,[e]).length){if(!b&&e.nodeType===1){c.cleanData(e.getElementsByTagName("*"));c.cleanData([e])}e.parentNode&&e.parentNode.removeChild(e)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild); -return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,e=this.ownerDocument;if(!d){d=e.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(za,"").replace(fb,'="$1">').replace($,"")],e)[0]}else return this.cloneNode(true)});if(a===true){na(this,b);na(this.find("*"),b.find("*"))}return b},html:function(a){if(a===B)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(za,""):null; -else if(typeof a==="string"&&!Ca.test(a)&&(c.support.leadingWhitespace||!$.test(a))&&!P[(Ba.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Aa,"<$1>");try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?h.cloneNode(true):h)}k.length&&c.each(k,Oa)}return this}});c.buildFragment=function(a,b,d){var e,f,h;b=b&&b[0]?b[0].ownerDocument||b[0]:t;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===t&&!Ca.test(a[0])&&(c.support.checkClone||!Da.test(a[0]))){f=true;if(h=c.fragments[a[0]])if(h!==1)e=h}if(!e){e=b.createDocumentFragment();c.clean(a,b,e,d)}if(f)c.fragments[a[0]]=h?e:1;return{fragment:e,cacheable:f}};c.fragments={};c.each({appendTo:"append", -prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var e=[];d=c(d);var f=this.length===1&&this[0].parentNode;if(f&&f.nodeType===11&&f.childNodes.length===1&&d.length===1){d[b](this[0]);return this}else{f=0;for(var h=d.length;f0?this.clone(true):this).get();c(d[f])[b](l);e=e.concat(l)}return this.pushStack(e,a,d.selector)}}});c.extend({clean:function(a,b,d,e){b=b||t;if(typeof b.createElement==="undefined")b=b.ownerDocument|| -b[0]&&b[0].ownerDocument||t;for(var f=[],h=0,l;(l=a[h])!=null;h++){if(typeof l==="number")l+="";if(l){if(typeof l==="string"&&!eb.test(l))l=b.createTextNode(l);else if(typeof l==="string"){l=l.replace(Aa,"<$1>");var k=(Ba.exec(l)||["",""])[1].toLowerCase(),o=P[k]||P._default,x=o[0],r=b.createElement("div");for(r.innerHTML=o[1]+l+o[2];x--;)r=r.lastChild;if(!c.support.tbody){x=db.test(l);k=k==="table"&&!x?r.firstChild&&r.firstChild.childNodes:o[1]===""&&!x?r.childNodes:[];for(o=k.length- -1;o>=0;--o)c.nodeName(k[o],"tbody")&&!k[o].childNodes.length&&k[o].parentNode.removeChild(k[o])}!c.support.leadingWhitespace&&$.test(l)&&r.insertBefore(b.createTextNode($.exec(l)[0]),r.firstChild);l=r.childNodes}if(l.nodeType)f.push(l);else f=c.merge(f,l)}}if(d)for(h=0;f[h];h++)if(e&&c.nodeName(f[h],"script")&&(!f[h].type||f[h].type.toLowerCase()==="text/javascript"))e.push(f[h].parentNode?f[h].parentNode.removeChild(f[h]):f[h]);else{f[h].nodeType===1&&f.splice.apply(f,[h+1,0].concat(c.makeArray(f[h].getElementsByTagName("script")))); -d.appendChild(f[h])}return f},cleanData:function(a){for(var b,d,e=c.cache,f=c.event.special,h=c.support.deleteExpando,l=0,k;(k=a[l])!=null;l++)if(!(k.nodeName&&c.noData[k.nodeName.toLowerCase()]))if(d=k[c.expando]){if((b=e[d])&&b.events)for(var o in b.events)f[o]?c.event.remove(k,o):c.removeEvent(k,o,b.handle);if(h)delete k[c.expando];else k.removeAttribute&&k.removeAttribute(c.expando);delete e[d]}}});var Ea=/alpha\([^)]*\)/i,gb=/opacity=([^)]*)/,hb=/-([a-z])/ig,ib=/([A-Z])/g,Fa=/^-?\d+(?:px)?$/i, -jb=/^-?\d/,kb={position:"absolute",visibility:"hidden",display:"block"},Pa=["Left","Right"],Qa=["Top","Bottom"],W,Ga,aa,lb=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){if(arguments.length===2&&b===B)return this;return c.access(this,a,b,true,function(d,e,f){return f!==B?c.style(d,e,f):c.css(d,e)})};c.extend({cssHooks:{opacity:{get:function(a,b){if(b){var d=W(a,"opacity","opacity");return d===""?"1":d}else return a.style.opacity}}},cssNumber:{zIndex:true,fontWeight:true,opacity:true, -zoom:true,lineHeight:true},cssProps:{"float":c.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,d,e){if(!(!a||a.nodeType===3||a.nodeType===8||!a.style)){var f,h=c.camelCase(b),l=a.style,k=c.cssHooks[h];b=c.cssProps[h]||h;if(d!==B){if(!(typeof d==="number"&&isNaN(d)||d==null)){if(typeof d==="number"&&!c.cssNumber[h])d+="px";if(!k||!("set"in k)||(d=k.set(a,d))!==B)try{l[b]=d}catch(o){}}}else{if(k&&"get"in k&&(f=k.get(a,false,e))!==B)return f;return l[b]}}},css:function(a,b,d){var e,f=c.camelCase(b), -h=c.cssHooks[f];b=c.cssProps[f]||f;if(h&&"get"in h&&(e=h.get(a,true,d))!==B)return e;else if(W)return W(a,b,f)},swap:function(a,b,d){var e={},f;for(f in b){e[f]=a.style[f];a.style[f]=b[f]}d.call(a);for(f in b)a.style[f]=e[f]},camelCase:function(a){return a.replace(hb,lb)}});c.curCSS=c.css;c.each(["height","width"],function(a,b){c.cssHooks[b]={get:function(d,e,f){var h;if(e){if(d.offsetWidth!==0)h=oa(d,b,f);else c.swap(d,kb,function(){h=oa(d,b,f)});if(h<=0){h=W(d,b,b);if(h==="0px"&&aa)h=aa(d,b,b); -if(h!=null)return h===""||h==="auto"?"0px":h}if(h<0||h==null){h=d.style[b];return h===""||h==="auto"?"0px":h}return typeof h==="string"?h:h+"px"}},set:function(d,e){if(Fa.test(e)){e=parseFloat(e);if(e>=0)return e+"px"}else return e}}});if(!c.support.opacity)c.cssHooks.opacity={get:function(a,b){return gb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var d=a.style;d.zoom=1;var e=c.isNaN(b)?"":"alpha(opacity="+b*100+")",f= -d.filter||"";d.filter=Ea.test(f)?f.replace(Ea,e):d.filter+" "+e}};if(t.defaultView&&t.defaultView.getComputedStyle)Ga=function(a,b,d){var e;d=d.replace(ib,"-$1").toLowerCase();if(!(b=a.ownerDocument.defaultView))return B;if(b=b.getComputedStyle(a,null)){e=b.getPropertyValue(d);if(e===""&&!c.contains(a.ownerDocument.documentElement,a))e=c.style(a,d)}return e};if(t.documentElement.currentStyle)aa=function(a,b){var d,e,f=a.currentStyle&&a.currentStyle[b],h=a.style;if(!Fa.test(f)&&jb.test(f)){d=h.left; -e=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;h.left=b==="fontSize"?"1em":f||0;f=h.pixelLeft+"px";h.left=d;a.runtimeStyle.left=e}return f===""?"auto":f};W=Ga||aa;if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetHeight;return a.offsetWidth===0&&b===0||!c.support.reliableHiddenOffsets&&(a.style.display||c.css(a,"display"))==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var mb=c.now(),nb=/)<[^<]*)*<\/script>/gi, -ob=/^(?:select|textarea)/i,pb=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,qb=/^(?:GET|HEAD)$/,Ra=/\[\]$/,T=/\=\?(&|$)/,ja=/\?/,rb=/([?&])_=[^&]*/,sb=/^(\w+:)?\/\/([^\/?#]+)/,tb=/%20/g,ub=/#.*$/,Ha=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!=="string"&&Ha)return Ha.apply(this,arguments);else if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var f=a.slice(e,a.length);a=a.slice(0,e)}e="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b=== -"object"){b=c.param(b,c.ajaxSettings.traditional);e="POST"}var h=this;c.ajax({url:a,type:e,dataType:"html",data:b,complete:function(l,k){if(k==="success"||k==="notmodified")h.html(f?c("
          ").append(l.responseText.replace(nb,"")).find(f):l.responseText);d&&h.each(d,[l.responseText,k,l])}});return this},serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&& -!this.disabled&&(this.checked||ob.test(this.nodeName)||pb.test(this.type))}).map(function(a,b){var d=c(this).val();return d==null?null:c.isArray(d)?c.map(d,function(e){return{name:b.name,value:e}}):{name:b.name,value:d}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:e})}, -getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:e})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return new E.XMLHttpRequest},accepts:{xml:"application/xml, text/xml",html:"text/html", -script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},ajax:function(a){var b=c.extend(true,{},c.ajaxSettings,a),d,e,f,h=b.type.toUpperCase(),l=qb.test(h);b.url=b.url.replace(ub,"");b.context=a&&a.context!=null?a.context:b;if(b.data&&b.processData&&typeof b.data!=="string")b.data=c.param(b.data,b.traditional);if(b.dataType==="jsonp"){if(h==="GET")T.test(b.url)||(b.url+=(ja.test(b.url)?"&":"?")+(b.jsonp||"callback")+"=?");else if(!b.data|| -!T.test(b.data))b.data=(b.data?b.data+"&":"")+(b.jsonp||"callback")+"=?";b.dataType="json"}if(b.dataType==="json"&&(b.data&&T.test(b.data)||T.test(b.url))){d=b.jsonpCallback||"jsonp"+mb++;if(b.data)b.data=(b.data+"").replace(T,"="+d+"$1");b.url=b.url.replace(T,"="+d+"$1");b.dataType="script";var k=E[d];E[d]=function(m){if(c.isFunction(k))k(m);else{E[d]=B;try{delete E[d]}catch(p){}}f=m;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);r&&r.removeChild(A)}}if(b.dataType==="script"&&b.cache===null)b.cache= -false;if(b.cache===false&&l){var o=c.now(),x=b.url.replace(rb,"$1_="+o);b.url=x+(x===b.url?(ja.test(b.url)?"&":"?")+"_="+o:"")}if(b.data&&l)b.url+=(ja.test(b.url)?"&":"?")+b.data;b.global&&c.active++===0&&c.event.trigger("ajaxStart");o=(o=sb.exec(b.url))&&(o[1]&&o[1].toLowerCase()!==location.protocol||o[2].toLowerCase()!==location.host);if(b.dataType==="script"&&h==="GET"&&o){var r=t.getElementsByTagName("head")[0]||t.documentElement,A=t.createElement("script");if(b.scriptCharset)A.charset=b.scriptCharset; -A.src=b.url;if(!d){var C=false;A.onload=A.onreadystatechange=function(){if(!C&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){C=true;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);A.onload=A.onreadystatechange=null;r&&A.parentNode&&r.removeChild(A)}}}r.insertBefore(A,r.firstChild);return B}var J=false,w=b.xhr();if(w){b.username?w.open(h,b.url,b.async,b.username,b.password):w.open(h,b.url,b.async);try{if(b.data!=null&&!l||a&&a.contentType)w.setRequestHeader("Content-Type", -b.contentType);if(b.ifModified){c.lastModified[b.url]&&w.setRequestHeader("If-Modified-Since",c.lastModified[b.url]);c.etag[b.url]&&w.setRequestHeader("If-None-Match",c.etag[b.url])}o||w.setRequestHeader("X-Requested-With","XMLHttpRequest");w.setRequestHeader("Accept",b.dataType&&b.accepts[b.dataType]?b.accepts[b.dataType]+", */*; q=0.01":b.accepts._default)}catch(I){}if(b.beforeSend&&b.beforeSend.call(b.context,w,b)===false){b.global&&c.active--===1&&c.event.trigger("ajaxStop");w.abort();return false}b.global&& -c.triggerGlobal(b,"ajaxSend",[w,b]);var L=w.onreadystatechange=function(m){if(!w||w.readyState===0||m==="abort"){J||c.handleComplete(b,w,e,f);J=true;if(w)w.onreadystatechange=c.noop}else if(!J&&w&&(w.readyState===4||m==="timeout")){J=true;w.onreadystatechange=c.noop;e=m==="timeout"?"timeout":!c.httpSuccess(w)?"error":b.ifModified&&c.httpNotModified(w,b.url)?"notmodified":"success";var p;if(e==="success")try{f=c.httpData(w,b.dataType,b)}catch(q){e="parsererror";p=q}if(e==="success"||e==="notmodified")d|| -c.handleSuccess(b,w,e,f);else c.handleError(b,w,e,p);d||c.handleComplete(b,w,e,f);m==="timeout"&&w.abort();if(b.async)w=null}};try{var g=w.abort;w.abort=function(){w&&Function.prototype.call.call(g,w);L("abort")}}catch(i){}b.async&&b.timeout>0&&setTimeout(function(){w&&!J&&L("timeout")},b.timeout);try{w.send(l||b.data==null?null:b.data)}catch(n){c.handleError(b,w,null,n);c.handleComplete(b,w,e,f)}b.async||L();return w}},param:function(a,b){var d=[],e=function(h,l){l=c.isFunction(l)?l():l;d[d.length]= -encodeURIComponent(h)+"="+encodeURIComponent(l)};if(b===B)b=c.ajaxSettings.traditional;if(c.isArray(a)||a.jquery)c.each(a,function(){e(this.name,this.value)});else for(var f in a)da(f,a[f],b,e);return d.join("&").replace(tb,"+")}});c.extend({active:0,lastModified:{},etag:{},handleError:function(a,b,d,e){a.error&&a.error.call(a.context,b,d,e);a.global&&c.triggerGlobal(a,"ajaxError",[b,a,e])},handleSuccess:function(a,b,d,e){a.success&&a.success.call(a.context,e,d,b);a.global&&c.triggerGlobal(a,"ajaxSuccess", -[b,a])},handleComplete:function(a,b,d){a.complete&&a.complete.call(a.context,b,d);a.global&&c.triggerGlobal(a,"ajaxComplete",[b,a]);a.global&&c.active--===1&&c.event.trigger("ajaxStop")},triggerGlobal:function(a,b,d){(a.context&&a.context.url==null?c(a.context):c.event).trigger(b,d)},httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"), -e=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(e)c.etag[b]=e;return a.status===304},httpData:function(a,b,d){var e=a.getResponseHeader("content-type")||"",f=b==="xml"||!b&&e.indexOf("xml")>=0;a=f?a.responseXML:a.responseText;f&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b==="json"||!b&&e.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&e.indexOf("javascript")>=0)c.globalEval(a);return a}}); -if(E.ActiveXObject)c.ajaxSettings.xhr=function(){if(E.location.protocol!=="file:")try{return new E.XMLHttpRequest}catch(a){}try{return new E.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}};c.support.ajax=!!c.ajaxSettings.xhr();var ea={},vb=/^(?:toggle|show|hide)$/,wb=/^([+\-]=)?([\d+.\-]+)(.*)$/,ba,pa=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b,d){if(a||a===0)return this.animate(S("show", -3),a,b,d);else{d=0;for(var e=this.length;d=0;e--)if(d[e].elem===this){b&&d[e](true);d.splice(e,1)}});b||this.dequeue();return this}});c.each({slideDown:S("show",1),slideUp:S("hide",1),slideToggle:S("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){c.fn[a]=function(d,e,f){return this.animate(b, -d,e,f)}});c.extend({speed:function(a,b,d){var e=a&&typeof a==="object"?c.extend({},a):{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};e.duration=c.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in c.fx.speeds?c.fx.speeds[e.duration]:c.fx.speeds._default;e.old=e.complete;e.complete=function(){e.queue!==false&&c(this).dequeue();c.isFunction(e.old)&&e.old.call(this)};return e},easing:{linear:function(a,b,d,e){return d+e*a},swing:function(a,b,d,e){return(-Math.cos(a* -Math.PI)/2+0.5)*e+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||c.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a=parseFloat(c.css(this.elem,this.prop));return a&&a>-1E4?a:0},custom:function(a,b,d){function e(l){return f.step(l)} -var f=this,h=c.fx;this.startTime=c.now();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;this.pos=this.state=0;e.elem=this.elem;if(e()&&c.timers.push(e)&&!ba)ba=setInterval(h.tick,h.interval)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true; -this.custom(this.cur(),0)},step:function(a){var b=c.now(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var e in this.options.curAnim)if(this.options.curAnim[e]!==true)d=false;if(d){if(this.options.overflow!=null&&!c.support.shrinkWrapBlocks){var f=this.elem,h=this.options;c.each(["","X","Y"],function(k,o){f.style["overflow"+o]=h.overflow[k]})}this.options.hide&&c(this.elem).hide();if(this.options.hide|| -this.options.show)for(var l in this.options.curAnim)c.style(this.elem,l,this.options.orig[l]);this.options.complete.call(this.elem)}return false}else{a=b-this.startTime;this.state=a/this.options.duration;b=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||b](this.state,a,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a= -c.timers,b=0;b-1;e={};var x={};if(o)x=f.position();l=o?x.top:parseInt(l,10)||0;k=o?x.left:parseInt(k,10)||0;if(c.isFunction(b))b=b.call(a,d,h);if(b.top!=null)e.top=b.top-h.top+l;if(b.left!=null)e.left=b.left-h.left+k;"using"in b?b.using.call(a, -e):f.css(e)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),e=Ia.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.css(a,"marginTop"))||0;d.left-=parseFloat(c.css(a,"marginLeft"))||0;e.top+=parseFloat(c.css(b[0],"borderTopWidth"))||0;e.left+=parseFloat(c.css(b[0],"borderLeftWidth"))||0;return{top:d.top-e.top,left:d.left-e.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||t.body;a&&!Ia.test(a.nodeName)&& -c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(e){var f=this[0],h;if(!f)return null;if(e!==B)return this.each(function(){if(h=fa(this))h.scrollTo(!a?e:c(h).scrollLeft(),a?e:c(h).scrollTop());else this[d]=e});else return(h=fa(f))?"pageXOffset"in h?h[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&h.document.documentElement[d]||h.document.body[d]:f[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase(); -c.fn["inner"+b]=function(){return this[0]?parseFloat(c.css(this[0],d,"padding")):null};c.fn["outer"+b]=function(e){return this[0]?parseFloat(c.css(this[0],d,e?"margin":"border")):null};c.fn[d]=function(e){var f=this[0];if(!f)return e==null?null:this;if(c.isFunction(e))return this.each(function(l){var k=c(this);k[d](e.call(this,l,k[d]()))});if(c.isWindow(f))return f.document.compatMode==="CSS1Compat"&&f.document.documentElement["client"+b]||f.document.body["client"+b];else if(f.nodeType===9)return Math.max(f.documentElement["client"+ -b],f.body["scroll"+b],f.documentElement["scroll"+b],f.body["offset"+b],f.documentElement["offset"+b]);else if(e===B){f=c.css(f,d);var h=parseFloat(f);return c.isNaN(h)?f:h}else return this.css(d,typeof e==="string"?e:e+"px")}})})(window); diff --git a/game/old/jquery-ui-1.8.9.custom.min.js b/game/old/jquery-ui-1.8.9.custom.min.js deleted file mode 100755 index 044d307..0000000 --- a/game/old/jquery-ui-1.8.9.custom.min.js +++ /dev/null @@ -1,68 +0,0 @@ -/*! - * jQuery UI 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI - */ -(function(c,j){function k(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.9",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106, -NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this, -"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position"); -if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,l,m){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(l)g-=parseFloat(c.curCSS(f, -"border"+this+"Width",true))||0;if(m)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h, -d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){var b=a.nodeName.toLowerCase(),d=c.attr(a,"tabindex");if("area"===b){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&k(a)}return(/input|select|textarea|button|object/.test(b)?!a.disabled:"a"==b?a.href||!isNaN(d):!isNaN(d))&&k(a)},tabbable:function(a){var b=c.attr(a,"tabindex");return(isNaN(b)||b>=0)&&c(a).is(":focusable")}}); -c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a
          ",remove:null,select:null,show:null,spinner:"Loading…",tabTemplate:"
        • #{label}
        • "},_create:function(){this._tabify(true)},_setOption:function(b,e){if(b=="selected")this.options.collapsible&& -e==this.options.selected||this.select(e);else{this.options[b]=e;this._tabify()}},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+u()},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+w());return d.cookie.apply(null,[b].concat(d.makeArray(arguments)))},_ui:function(b,e){return{tab:b,panel:e,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b= -d(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(b){function e(g,f){g.css("display","");!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}var a=this,c=this.options,h=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=d(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);this.anchors.each(function(g,f){var i=d(f).attr("href"),l=i.split("#")[0],q;if(l&&(l===location.toString().split("#")[0]|| -(q=d("base")[0])&&l===q.href)){i=f.hash;f.href=i}if(h.test(i))a.panels=a.panels.add(a.element.find(a._sanitizeSelector(i)));else if(i&&i!=="#"){d.data(f,"href.tabs",i);d.data(f,"load.tabs",i.replace(/#.*$/,""));i=a._tabId(f);f.href="#"+i;f=a.element.find("#"+i);if(!f.length){f=d(c.panelTemplate).attr("id",i).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else c.disabled.push(g)});if(b){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"); -this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(c.selected===p){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){c.selected=g;return false}});if(typeof c.selected!=="number"&&c.cookie)c.selected=parseInt(a._cookie(),10);if(typeof c.selected!=="number"&&this.lis.filter(".ui-tabs-selected").length)c.selected= -this.lis.index(this.lis.filter(".ui-tabs-selected"));c.selected=c.selected||(this.lis.length?0:-1)}else if(c.selected===null)c.selected=-1;c.selected=c.selected>=0&&this.anchors[c.selected]||c.selected<0?c.selected:0;c.disabled=d.unique(c.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(c.selected,c.disabled)!=-1&&c.disabled.splice(d.inArray(c.selected,c.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active"); -if(c.selected>=0&&this.anchors.length){a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash)).removeClass("ui-tabs-hide");this.lis.eq(c.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[c.selected],a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash))[0]))});this.load(c.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else c.selected=this.lis.index(this.lis.filter(".ui-tabs-selected")); -this.element[c.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");c.cookie&&this._cookie(c.selected,c.cookie);b=0;for(var j;j=this.lis[b];b++)d(j)[d.inArray(b,c.disabled)!=-1&&!d(j).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");c.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(c.event!=="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+ -g)};this.lis.bind("mouseover.tabs",function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(c.fx)if(d.isArray(c.fx)){m=c.fx[0];o=c.fx[1]}else m=o=c.fx;var r=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal", -function(){e(f,o);a._trigger("show",null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},s=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")}; -this.anchors.bind(c.event+".tabs",function(){var g=this,f=d(g).closest("li"),i=a.panels.filter(":not(.ui-tabs-hide)"),l=a.element.find(a._sanitizeSelector(g.hash));if(f.hasClass("ui-tabs-selected")&&!c.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a.panels.filter(":animated").length||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}c.selected=a.anchors.index(this);a.abort();if(c.collapsible)if(f.hasClass("ui-tabs-selected")){c.selected= --1;c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){s(g,i)}).dequeue("tabs");this.blur();return false}else if(!i.length){c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this));this.blur();return false}c.cookie&&a._cookie(c.selected,c.cookie);if(l.length){i.length&&a.element.queue("tabs",function(){s(g,i)});a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier."; -d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(b){if(typeof b=="string")b=this.anchors.index(this.anchors.filter("[href$="+b+"]"));return b},destroy:function(){var b=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e= -d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(c,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});b.cookie&&this._cookie(null,b.cookie);return this},add:function(b, -e,a){if(a===p)a=this.anchors.length;var c=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,b).replace(/#\{label\}/g,e));b=!b.indexOf("#")?b.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var j=c.element.find("#"+b);j.length||(j=d(h.panelTemplate).attr("id",b).data("destroy.tabs",true));j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);j.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]); -j.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");j.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){c._trigger("show",null,c._ui(c.anchors[0],c.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(b){b=this._getIndex(b);var e=this.options,a=this.lis.eq(b).remove(),c=this.panels.eq(b).remove(); -if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(b+(b+1=b?--h:h});this._tabify();this._trigger("remove",null,this._ui(a.find("a")[0],c[0]));return this},enable:function(b){b=this._getIndex(b);var e=this.options;if(d.inArray(b,e.disabled)!=-1){this.lis.eq(b).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=b});this._trigger("enable",null, -this._ui(this.anchors[b],this.panels[b]));return this}},disable:function(b){b=this._getIndex(b);var e=this.options;if(b!=e.selected){this.lis.eq(b).addClass("ui-state-disabled");e.disabled.push(b);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[b],this.panels[b]))}return this},select:function(b){b=this._getIndex(b);if(b==-1)if(this.options.collapsible&&this.options.selected!=-1)b=this.options.selected;else return this;this.anchors.eq(b).trigger(this.options.event+".tabs");return this}, -load:function(b){b=this._getIndex(b);var e=this,a=this.options,c=this.anchors.eq(b)[0],h=d.data(c,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(c,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(b).addClass("ui-state-processing");if(a.spinner){var j=d("span",c);j.data("label.tabs",j.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){e.element.find(e._sanitizeSelector(c.hash)).html(k);e._cleanup();a.cache&&d.data(c, -"cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.error(k,n,b,c)}catch(m){}}}));e.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this}, -url:function(b,e){this.anchors.eq(b).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.9"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(b,e){var a=this,c=this.options,h=a._rotate||(a._rotate=function(j){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=c.selected;a.select(++k= load_max && - image_manager.is_done_preloading() && - sounds.sounds_loaded()){ - // init all image objects - image_manager.init_images(p); - loading_finished(); - } - }; - - - obj.get_all_buttons = function() { - return []; - }; - - obj.key_pressed = function() {}; - - return obj; -}; diff --git a/game/old/multiplier.js b/game/old/multiplier.js deleted file mode 100644 index 569ef0e..0000000 --- a/game/old/multiplier.js +++ /dev/null @@ -1,56 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec - -var multiplier = function(p, spec) { - // --- defaults --- - - spec.width = spec.width || 5; - spec.height = spec.height || 5; - // make sure it goes left - spec.vel = new p.PVector(p.random(0, -1), p.random()); - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "multiplier"; - }; - - // --- private variables --- - - var alive = true; - - // --- public methods --- - - // implementing game_object interface - - obj.update = function() { - obj.bounce(); - obj.move(); - }; - - // (rectangle for now) - obj.draw = function() { - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.fill(0, 255, 0); - p.noStroke(); - - p.ellipse(pos.x, pos.y, - obj.get_width(), obj.get_height()); - }; - - obj.die = function() { - alive = false; - } - - obj.is_dead = function() { - return (!alive); - }; - - return obj; -}; diff --git a/game/old/mutation_obj.js b/game/old/mutation_obj.js deleted file mode 100644 index 3df5fa6..0000000 --- a/game/old/mutation_obj.js +++ /dev/null @@ -1,328 +0,0 @@ -// Manages all information about the current state of mutation -// in the game -// Provides a num_status_obj, which is used for rendering -// spec: -// status_height = y value for status objects - -var mutation_obj = function(p, spec) { - - // obj to return - var obj = {}; - - // --- private variables --- - - var level = 1; - var cells_infected = 0; - var cells_needed; // init'd below - var new_mutation = false; - // Color array for all the mutation levels - var color_array = [ - /* - p.color(250, 250, 40), - p.color(60, 240, 240), - p.color(167, 17, 161), - p.color(100, 250, 110), - p.color(13, 28, 171), - p.color(118, 12, 25) - */ - 0xffff2a7f, - 0xffffff00, - 0xff7f2aff, - 0xff37c871, - 0xffd42aff, - 0xffff7f2a, - 0xff2ad4ff, - 0xffff2a2a, - 0xff7fff2a, - 0xffc8b7b7 - ]; - -/* - // Keeps track of all the abilities earned in the game so far - // If you lose a mutation level, must pop abilities off this array - var abilities = []; - - // All the possible abilities, sorted by level - // An ability can be earned at level x if it is in poss_abilities[0-x] - // TODO: add all abilities and change their levels - // TODO: Change these to be ready to be displayed to the user (or create a formatting mechanism) - var poss_abilities = [ - ["extra_particle"], - ["faster_particles", "bigger_particles"] - ]; -*/ - - // Flashing - var flash_color = null; - var is_flashing = false; - - // Shows the probability of getting a mutation - var bar_status_obj = num_status_obj(p, { - pos : new p.PVector(170, spec.status_height || 20), - text : "Mutation:", - num : 0, - bar : true, - max : 0 // init'd below - }); - - //Shows the curent mutation level - var level_spec = { - pos : new p.PVector(350, spec.status_height || 20), - text : "Level ", - num : 1, - text_color : p.color(0) - }; - var level_status_obj = num_status_obj(p, level_spec); - - // --- private methods - -/* - // Returns a random ability, taking into account the current level - // Every possibile ability has an equal chance - var get_random_ability = function() { - var all_possible = []; - for(var i = 0; i < level; i++) { - for_each(poss_abilities[i], function(a) {all_possible.push(a);}); - } - assert(all_possible.length != 0); - return all_possible[Math.floor(Math.random() * all_possible.length)]; - } -*/ - - // Returns bool saying if a mutation should occur - // takes into account level, cells_infected, and a random probability - var mutation_occured = function() { - //return Math.random() + ( (cells_infected / 50) / (level + 1)) > .95; - //return (Math.random() * (cells_infected / 50)) > .3; - //return (Math.random() + (cells_infected / 100) - (level / 50)) > .98; - return (Math.random()*0.5 + (cells_infected / cells_needed)) > .98; - }; - - // returns the max number of cells the player needs to infect to have - // a 100% probability of mutating - var calc_cells_needed = function() { - return 30 + 20*level; - }; - cells_needed = calc_cells_needed(); - bar_status_obj.set_max(cells_needed); - - // Flashes the mutation bar red and white - var flash_bar = function() { - is_flashing = true; - - // Flash red and white every half second - flash_red(); - setTimeout(flash_white, 500); - setTimeout(flash_red, 1000); - setTimeout(flash_white, 1500); - setTimeout(flash_red, 2000); - setTimeout(flash_white, 2500); - // End flashing in 3 seconds - setTimeout(end_flash, 3000); - } - - // updates the flash color - var flash_red = function() { - flash_color = [255, 0, 0]; - } - var flash_white = function() { - flash_color = [255, 255, 255]; - } - - // Draws the bar with the appropriate flashing color - var draw_flashing_bar = function() { - bar_status_obj.draw_color(flash_color); - } - // Ends the flashing - var end_flash = function() { - is_flashing = false; - } - - // Gives us a rainbow gradient - // Taken from : http://snipplr.com/view.php?codeview&id=14590 - /** - * HSV to RGB color conversion - * - * H runs from 0 to 360 degrees - * S and V run from 0 to 100 - * - * Ported from the excellent java algorithm by Eugene Vishnevsky at: - * http://www.cs.rit.edu/~ncs/color/t_convert.html - */ - var hsvToRgb = function(h, s, v) { - var r, g, b; - var i; - var f, p, q, t; - - // Make sure our arguments stay in-range - h = Math.max(0, Math.min(360, h)); - s = Math.max(0, Math.min(100, s)); - v = Math.max(0, Math.min(100, v)); - - // We accept saturation and value arguments from 0 to 100 because that's - // how Photoshop represents those values. Internally, however, the - // saturation and value are calculated from a range of 0 to 1. We make - // That conversion here. - s /= 100; - v /= 100; - - if(s == 0) { - // Achromatic (grey) - r = g = b = v; - return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; - } - - h /= 60; // sector 0 to 5 - i = Math.floor(h); - f = h - i; // factorial part of h - p = v * (1 - s); - q = v * (1 - s * f); - t = v * (1 - s * (1 - f)); - - switch(i) { - case 0: - r = v; - g = t; - b = p; - break; - - case 1: - r = q; - g = v; - b = p; - break; - - case 2: - r = p; - g = v; - b = t; - break; - - case 3: - r = p; - g = q; - b = v; - break; - - case 4: - r = t; - g = p; - b = v; - break; - - default: // case 5: - r = v; - g = p; - b = q; - } - - return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; - } - - // --- public methods --- - - obj.draw = function() { - bar_status_obj.draw(); - if (is_flashing) { - draw_flashing_bar(); - } - - // draw mutation colored box under level num - p.fill(get_color()); - p.noStroke(); - var lpos = level_spec.pos; - p.rectMode(p.CORNER); - p.rect(lpos.x-30, lpos.y-10, 70, 20); - - level_status_obj.draw(); - }; - - // increments the mutation percentage - obj.infected_cell = function() { - cells_infected += 1; - bar_status_obj.incr(1); - // if a mutation occurs - if (mutation_occured()) { - // set the flag - new_mutation = true; - flash_bar(); - - // Play sounds - sounds.play_sound("level_up"); - } - }; - - // returns true if a new mutation is ready - obj.has_new_mutation = function() { - return new_mutation; - }; - - // to be called when in_game_state decides to enact the new mutation - // as signalled by the flag - // Returns a new ability if one was added - obj.do_mutation = function() { - flash_bar(); - // Add new ability before incrementing level - //var new_ability = get_random_ability(); - //abilities.push(new_ability); - level += 1; - level_status_obj.incr(1); - // update num cells needed - cells_needed = calc_cells_needed(); - bar_status_obj.set_max(cells_needed); - // reset counters - obj.reset_mutation(); - - //return new_ability; - }; - - - // resets the counters and the flag - // to be called after a mutation is enacted in the game - obj.reset_mutation = function() { - cells_infected = 0; - bar_status_obj.set_num(0); - // reset flag - new_mutation = false; - }; - - var get_color = function() { - return color_array[(level - 1) % color_array.length]; - }; - - // Returns the current mutation level and color - obj.get_info = function() { - // color level goes from 0 to 360 - //var new_color_level = (360 - (360 - level * 30)); - //var hue = new_color_level / 360; - //var rgb_arr = hsvToRgb(new_color_level, 75, 75); - return { - level: level, - //color: p.color(rgb_arr[0], rgb_arr[1], rgb_arr[2]), - // level starts at 1, so have to subtract 1 - color : get_color(), //% color_array.size], - // get one new particle every 10 levels - particles: 3+p.floor(level/3), - //abilities: abilities - }; - }; - - obj.get_level = function() { - return level; - }; - - obj.set_level = function(l) { - // decrement by the difference in levels - level_status_obj.incr(l-level); - // Pop off abilities - /* - for (var i = 0; i < (level - l); i++) { - abilities.pop(); - } - */ - // set the new level - level = l; - }; - - return obj; -}; diff --git a/game/old/notification.js b/game/old/notification.js deleted file mode 100644 index dfee58e..0000000 --- a/game/old/notification.js +++ /dev/null @@ -1,64 +0,0 @@ -// Used to alert the user of new information -// draw() returns false if the status update is finished -// spec: -// text : text to display -// color : color of text (defaults to black) -// pos : pos of notification - -var notification = function(p, spec) { - - // object to return - var obj = {}; - - // --- private variables --- - - var time_counter = 0; // used to draw the object at various times - var total_time = 60; // ~ 2 seconds. If changed must be changed in notify in in_game_state to prevent overlap //200; // ~6 secs? - - var text_size = 20; - var box_color = spec.color || p.color(255, 255, 255); - - // --- public methods --- - - - obj.draw = function() { - var time_percent = time_counter / total_time; - //var text_size = 25 - 25*(time_percent); - var text_alpha = 255 - 200*time_percent; - - //var x_pos = (p.width * (5/8)); //+ (p.width / 2) *time_percent; - //var y_pos = (p.height * (5/8)) - (p.height / 2) *time_percent; - - var x_pos = spec.pos.x; - var y_pos = spec.pos.y; - - // I don't like the moving from the center - // so I'm trying it stationary - //var x_pos = p.width / 2; - //var y_pos = 70; - - // this needs to come before textWidth - p.textAlign(p.CENTER, p.CENTER); - p.textSize(text_size); - - var w = p.textWidth(spec.text); - - // draw a box behind it - //p.fill(box_color, text_alpha); - //p.rectMode(p.CORNER) - //p.rect(x_pos-w/2-5, y_pos-p.textAscent(), w+10, p.textAscent()*2); - - //p.fill(p.color(0, 0, 0), text_alpha); - //p.fill(p.color(255, 255, 255), text_alpha); - p.fill(box_color, text_alpha); - p.text(spec.text, x_pos, y_pos); - - if (time_counter > total_time) { // Finished - return false; - } - time_counter++; - return true; - } - - return obj; -}; diff --git a/game/old/num_status_obj.js b/game/old/num_status_obj.js deleted file mode 100644 index fc05e28..0000000 --- a/game/old/num_status_obj.js +++ /dev/null @@ -1,115 +0,0 @@ -// Generic wrapper for a status that includes text and a num -// Can be drawn as a number or a bar -// Provides draw, incr, set_num, and get_num -// spec: -// pos : center pos of text -// text : Will display " " -// num : num to start at -// bar : bool (optional) -// max : num (required if bar) - -var num_status_obj = function(p, spec) { - - // obj to return - var obj = {}; - - // --- private variables --- - - var pos = spec.pos; - var number = spec.num; - var txt = spec.text; - var bar = spec.bar || false; - var max = spec.max; - var height = 20; - var max_width = 100; //for the bar, might need to be passed in - - var get_obj_text = function() { - if (bar) { - return txt; - } - else { - var num_txt = ""+number; - if (spec.format) { - num_txt = spec.format(number); - } - return txt + " " + num_txt; - } - } - - var rect = rectangle(p, { // Really just a text obj - pos : pos, - width : 0, - height : 0, - text : get_obj_text(), - text_size : 14, - text_color: spec.text_color || 255, - }); - - // --- private methods - - var update = function(n) { - - number = n; - - rect.update_text(get_obj_text()); - }; - var draw_full_rect = function(color) { - p.fill(color[0], color[1], color[2]); - //p.strokeWeight(1); - //p.stroke(0); - var topy = pos.y - (height / 2); - var leftx = pos.x + (txt.length * 4); - p.rect(leftx, topy, max_width, height); - }; - - // --- public methods --- - - obj.draw = function() { - rect.draw(); - // Draw the bar separately, if appropriate - if (bar) { - p.noStroke(); - // Draw empty rectangle first - draw_full_rect([255, 255, 255]); - - // Then draw mutation status bar - p.fill(150); - - var topy = pos.y - (height / 2); - var leftx = pos.x + (txt.length * 4); - var rect_width = (number / max) * max_width; - rect_width = rect_width > max_width ? max_width : rect_width; - p.rectMode(p.CORNER); - p.rect(leftx, topy, rect_width, height); - - p.fill(255) - } - }; - - // SHOULD ONLY BE CALLED IF bar IS TRUE - // Draws a full bar of the specified color - // color : 3 element rgb array - obj.draw_color = function(color) { - draw_full_rect(color); - }; - - obj.incr = function(n) { - update(number + n); - }; - - // Set and get - - obj.set_max = function(m) { - max = m; - }; - - obj.set_num = function(n) { - update(n); - }; - - obj.get_num = function() { - return number; - }; - - return obj; -}; diff --git a/game/old/object_with_states.js b/game/old/object_with_states.js deleted file mode 100644 index a18e993..0000000 --- a/game/old/object_with_states.js +++ /dev/null @@ -1,26 +0,0 @@ -// Gives an object the capability to set and get states -// inherits from game_object -// spec: -// spec.state -- current state, default to 'alive' - -var object_with_states = function(p, spec) { - - var obj = game_object(p, spec); - - var state = spec.state || "alive"; - - // --- public methods --- - - obj.set_state = function(s) { - // If outdated, don't update state - if (state != "outdated") { - state = s; - } - }; - - obj.get_state = function() { - return state; - }; - - return obj; -} diff --git a/game/old/old-index.html b/game/old/old-index.html deleted file mode 100644 index 3f3eb4d..0000000 --- a/game/old/old-index.html +++ /dev/null @@ -1,223 +0,0 @@ - - - -Virion - - - - - - - - - -
          - - -
          Login with Facebook to track your high scores!
          - - - - Login with Facebook - - - -

          - -
          You are not Logged In
          - - - - -
          -
          Welcome to Virion beta testing!  Give the game a try and then scroll down to give us your feedback.
          -
          - -
          -
          - Could not load high scores! You may want to check your internet connection. -
          -
          - - - Your browser does not support the HTML5 canvas element. Upgrade to Chrome, Firefox 4, Safari, or Opera to play this game. - -
          -
          -

          Virion Beta Testing Feedback

          -
          - Tell us what you thought of the game by filling out the survey below. You can also email us at viriongame at gmail dot com. Thanks! We appreciate your help.  — The Virion Team -
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/game/old/option_button.js b/game/old/option_button.js deleted file mode 100644 index 5154998..0000000 --- a/game/old/option_button.js +++ /dev/null @@ -1,63 +0,0 @@ -// Have a rectangle representing their position and a state to go to when clicked -// spec: -// rect : spec for a rectangle representing the button -// click_fun : what to do when clicked -// global_var : var that determines whether this option is enabled or not - -var option_button = function(p, spec) { - - // --- defaults --- - //spec.rect.width = spec.width || 200; - //spec.rect.height = spec.height || 60; - - // obj to return - var obj = {}; - - // --- private variables --- - - var but = button(p, spec); - var rect = rectangle(p, spec.rect); - // Left-edge x and top-edge y coordinates of 'checkbox' indicating whether - // option is enabled - var status_x = rect.get_left_x() + 28//50; - var status_y = rect.get_top_y() + 30//37; - var tick_size = 30; - var tick_yes_image = image_manager.get_image("check1.png"); - var tick_no_image = image_manager.get_image("check0.png"); - - // --- public methods --- - - obj.draw = function() { - //rect.draw(); - but.draw(); - - p.imageMode(p.CENTER); - if (g[spec.global_var]) { - //p.fill(255, 255, 255); - //p.ellipse(status_x, status_y, 10, 10); - p.image(tick_yes_image, status_x, status_y, tick_size, tick_size); - } - else { - p.image(tick_no_image, status_x, status_y, tick_size, tick_size); - } - }; - - // Returns the state to go to if clicked, or - // null if not clicked - obj.click = function(x, y) { - //but.is_clicked(); - if (rect.is_in(x, y)) { - spec.click_fun(); - } - // Redraw in case anything changes - obj.draw(); - }; - - obj.is_clicked = function() { return null; }; - - obj.mouse_moved = function(x, y) { - but.mouse_moved(x, y); - }; - - return obj; -}; diff --git a/game/old/options_state.js b/game/old/options_state.js deleted file mode 100644 index fa0bdfb..0000000 --- a/game/old/options_state.js +++ /dev/null @@ -1,193 +0,0 @@ -var options_state = function (p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var background_image = image_manager.get_image("settingssplash.png"); - - var button_style = { - text_x_offset : 60, - text_y_offset: -3, - text_align: p.LEFT - }; - - // Buttons - - var col1_x = p.width/2 - 120; - var col2_x = p.width/2 + 120; - - var back_button = button(p, { - state : function() { - sounds.play_button_back(); - return prev_state; - }, - rect : { - pos : new p.PVector(p.width / 2, p.height - 80), - //width : 120, - //height : 50, - //text: "Back", - //text_x_offset: 5, - //text_y_offset: -8, - image: "back.png", - } - }); - - // Options - //var option_image = "bullet_listcell.png"; - var sound_fx_button = option_button(p, { - click_fun : function() {sounds.play_button_click(); g.toggle_sound_fx();}, - global_var : "sound_fx", - rect : { - pos : new p.PVector(col1_x, p.height/2 - 70), - //text: "Sound Effects", - //text_x_offset: 60, - image : "set_sound.png",//option_image, - //over_image : "set_sound_a.png", - //style: button_style - } - }); - var music_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - // toggle the flag - g.toggle_music(); - }, - global_var : "music", - rect : { - pos : new p.PVector(col1_x, p.height/2 + 40), - //text: "Music", - //text_x_offset: 60, - image : "set_music.png",//option_image, - //over_image : "set_music_a.png", - //style: button_style - } - }); - var spacebar_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - g.toggle_spacebar_to_fire(); - }, - global_var : "spacebar_to_fire", - rect : { - pos : new p.PVector(col2_x, p.height/2 - 70), - //text: "Spacebar to Fire", - //text_x_offset : 60, - image : "set_spacebar.png",//option_image, - //over_image : "set_spacebar_a.png", - //style: button_style - } - }); - var mouse_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - g.toggle_click_to_fire(); - }, - global_var : "click_to_fire", - rect : { - pos : new p.PVector(col2_x, p.height/2 + 40), - //text: "Mouse Click to Fire", - //text_x_offset : 60, - image : "set_click.png",//option_image, - //over_image : "set_click_a.png", - //style: button_style - } - }); - var mouse_to_select_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - g.toggle_mouse_to_select(); - }, - global_var : "mouse_to_select", - rect : { - pos : new p.PVector(col2_x, p.height/2 + 140), - //text: "Mouse to Select Cells\nInstead of Left/Right", - image : "set_mouseselect.png",//option_image, - //over_image : "set_mouseselect_a.png", - //text_x_offset : 60, - //style: button_style - } - }); - var track_left_button = button(p, { - state : function() { - sounds.play_button_click(); - g.prev_track(); - return obj; - }, - rect : { - pos : new p.PVector(col1_x - 50, p.height/2 + 145), - image : "track_left.png", - } - }); - var track_right_button = button(p, { - state : function() { - sounds.play_button_click(); - g.next_track(); - return obj; - }, - rect : { - pos : new p.PVector(col1_x + 50, p.height/2 + 145), - image : "track_right.png", - } - }); - - - - //Not ordered - var all_option_buttons = [sound_fx_button, music_button, - spacebar_button, mouse_button, mouse_to_select_button]; - var all_buttons = [back_button, track_left_button, track_right_button] - .concat(all_option_buttons); - - - // --- public methods --- - - obj.get_type = function() { - return "options"; - }; - - obj.update = function() { - //do nothing - }; - - obj.key_pressed = function(k) { - if (k === 115 || p.keyCode === 13 || k === 32) { //s, enter, space - } - else if (k === 104) { //h - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - obj.render = function() { - //p.background(g.background_color); - //p.fill(g.background_color); - //p.rect(100, 100, 500, 500); - p.imageMode(p.CORNERS); - p.image(background_image, 0, 0);//, p.width, p.height); - - // draw the track button background manually - var track_x = col1_x; - var track_y = p.height/2 + 140; - var track_image = image_manager.get_image("set_track.png"); - p.imageMode(p.CENTER); - p.image(track_image, track_x, track_y); - // draw current track - p.fill(0); - p.textAlign(p.CENTER); - p.textSize(14); - p.text(g.track, track_x, track_y+5); - - for_each(all_option_buttons, function(b) { b.draw(); }); - }; - - obj.mouse_click = function(x, y) { - for_each(all_option_buttons, function(b) { b.click(x, y); }); - }; - - return obj; -}; diff --git a/game/old/particle.js b/game/old/particle.js deleted file mode 100644 index 630645b..0000000 --- a/game/old/particle.js +++ /dev/null @@ -1,437 +0,0 @@ -// *** particle *** -// --- inherits from game_object -// spec: -// game_object spec - -var particle = function(p, spec) { - - // --- defaults --- - - // was 15 - spec.width = spec.width || 10; - spec.height = spec.height || 10; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "particle"; - }; - - // --- private variables --- - - //var par_shape = p.loadShape("images/virusfinal.svg"); - //var par_image = p.loadImage("images/virus1.png"); - var par_image = image_manager.get_image("tinyvirus_trans.png"); - //var mutation = spec.mutation; - - // --- public methods --- - - // implementing game_object interface - - // update is default (move) - - // draw makes a small virus particle - // (circle for now) - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.get_mode()); - //var color = mutation.get_color(); - p.fill(obj.get_color()); - p.noStroke(); - p.ellipse(pos.x, pos.y, - obj.get_width() * .75, obj.get_height() * .75); - p.imageMode(obj.get_mode()); - p.image(par_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - //var d = new Date(); - //console.log(d.getMilliseconds()); - //p.shape(par_shape, pos.x, pos.y, - //obj.get_width() + 20, obj.get_height() + 20); - //draw(canvas.getContext('2d')); - //canvas.getContext('2d').drawSvg("images/virusFinal.svg", 300, 10, 20, 20); - //console.log("a " + d.getMilliseconds()); - - }; - - // override for circular object - obj.calc_radius = function() { - return obj.get_width()/2; - }; - obj.set_radius(obj.calc_radius()); - - return obj; -} - -// SVG -> Javascript code to draw the particle -/* -var draw = function(ctx) { -ctx.save(); -ctx.strokeStyle = 'rgba(0,0,0,0)'; -ctx.lineCap = 'butt'; -ctx.lineJoin = 'miter'; -ctx.miterLimit = 4; -ctx.save(); -ctx.restore(); -ctx.save(); -ctx.restore(); -ctx.save(); -ctx.scale(0.02,0.02); -ctx.save(); -ctx.fillStyle = "#fff1d0"; -ctx.strokeStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.lineWidth = 5; -ctx.miterLimit = 4; -ctx.beginPath(); -ctx.moveTo(411.42857,373.36218); -ctx.bezierCurveTo(378.29148999999995,373.36218,351.42857,400.2251,351.42857,433.36218); -ctx.bezierCurveTo(351.42857,435.74656000000004,351.59556999999995,438.08169000000004,351.86607,440.39343); -ctx.bezierCurveTo(333.68726999999996,446.05755000000005,316.62739,454.24753000000004,301.08482,464.54968); -ctx.bezierCurveTo(293.76497,456.45166,283.20419999999996,451.36218,271.42857,451.36218); -ctx.bezierCurveTo(249.33718,451.36218,231.42856999999998,469.27079000000003,231.42856999999998,491.36218); -ctx.bezierCurveTo(231.42856999999998,503.13781,236.51805,513.69858,244.61606999999998,521.0184300000001); -ctx.bezierCurveTo(234.27291999999997,536.6228600000001,226.0638,553.7583900000001,220.39731999999998,572.0184300000001); -ctx.bezierCurveTo(217.46769999999998,571.5787200000001,214.48073999999997,571.3621800000001,211.42856999999998,571.3621800000001); -ctx.bezierCurveTo(178.29148999999998,571.3621800000001,151.42856999999998,598.2251000000001,151.42856999999998,631.3621800000001); -ctx.bezierCurveTo(151.42856999999998,664.49926,178.29148999999998,691.3621800000001,211.42856999999998,691.3621800000001); -ctx.bezierCurveTo(214.48073999999997,691.3621800000001,217.46769999999998,691.1456400000001,220.39731999999998,690.7059300000001); -ctx.bezierCurveTo(226.0638,708.9659700000001,234.27291999999997,726.1015000000001,244.61606999999998,741.7059300000001); -ctx.bezierCurveTo(236.51805,749.02578,231.42856999999998,759.5865500000001,231.42856999999998,771.3621800000001); -ctx.bezierCurveTo(231.42856999999998,793.4535700000001,249.33718,811.3621800000001,271.42857,811.3621800000001); -ctx.bezierCurveTo(283.20419999999996,811.3621800000001,293.76497,806.2727000000001,301.08482,798.1746800000001); -ctx.bezierCurveTo(316.68924999999996,808.5178300000001,333.82478,816.7269500000001,352.08482,822.3934300000001); -ctx.bezierCurveTo(351.64511,825.3230500000001,351.42857,828.31001,351.42857,831.3621800000001); -ctx.bezierCurveTo(351.42857,864.49926,378.29148999999995,891.3621800000001,411.42857,891.3621800000001); -ctx.bezierCurveTo(444.56565,891.3621800000001,471.42857,864.49926,471.42857,831.3621800000001); -ctx.bezierCurveTo(471.42857,828.31001,471.21202999999997,825.3230500000001,470.77232,822.3934300000001); -ctx.bezierCurveTo(489.03236,816.7269500000001,506.16789,808.5178300000001,521.77232,798.1746800000001); -ctx.bezierCurveTo(529.09217,806.2727000000001,539.6529400000001,811.3621800000001,551.42857,811.3621800000001); -ctx.bezierCurveTo(573.5199600000001,811.3621800000001,591.42857,793.4535700000001,591.42857,771.3621800000001); -ctx.bezierCurveTo(591.42857,759.5865500000001,586.33909,749.02578,578.24107,741.7059300000001); -ctx.bezierCurveTo(588.5842200000001,726.1015000000001,596.7933400000001,708.9659700000001,602.45982,690.7059300000001); -ctx.bezierCurveTo(605.38944,691.1456400000001,608.3764,691.3621800000001,611.42857,691.3621800000001); -ctx.bezierCurveTo(644.56565,691.3621800000001,671.42857,664.49926,671.42857,631.3621800000001); -ctx.bezierCurveTo(671.42857,598.2251000000001,644.56565,571.3621800000001,611.42857,571.3621800000001); -ctx.bezierCurveTo(608.3764,571.3621800000001,605.38944,571.5787200000001,602.45982,572.0184300000001); -ctx.bezierCurveTo(596.7933400000001,553.7583900000001,588.5842200000001,536.6228600000001,578.24107,521.0184300000001); -ctx.bezierCurveTo(586.33909,513.6985800000001,591.42857,503.13781000000006,591.42857,491.3621800000001); -ctx.bezierCurveTo(591.42857,469.2707900000001,573.5199600000001,451.3621800000001,551.42857,451.3621800000001); -ctx.bezierCurveTo(539.6529400000001,451.3621800000001,529.09217,456.45166000000006,521.77232,464.5496800000001); -ctx.bezierCurveTo(506.22975,454.2475300000001,489.16987000000006,446.0575500000001,470.99107000000004,440.3934300000001); -ctx.bezierCurveTo(471.26157000000006,438.0816900000001,471.42857000000004,435.7465600000001,471.42857000000004,433.3621800000001); -ctx.bezierCurveTo(471.42857000000004,400.2251000000001,444.56565000000006,373.3621800000001,411.42857000000004,373.3621800000001); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "#d4d4d4"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.globalAlpha = 0.2752293646335602; -ctx.beginPath(); -ctx.moveTo(530.99107,472.99893); -ctx.bezierCurveTo(556.1068300000001,506.42843999999997,570.99107,547.96659,570.99107,592.99893); -ctx.bezierCurveTo(570.99107,640.61609,554.33443,684.34142,526.55357,718.68643); -ctx.bezierCurveTo(529.38723,724.17581,530.99107,730.39551,530.99107,736.99893); -ctx.bezierCurveTo(530.99107,759.09032,513.0824600000001,776.99893,490.99107000000004,776.99893); -ctx.bezierCurveTo(481.81567,776.99893,473.36493,773.91293,466.61607000000004,768.71768); -ctx.bezierCurveTo(459.44539000000003,772.62788,452.0033,776.1000799999999,444.33482000000004,779.12393); -ctx.bezierCurveTo(459.07273000000004,788.9998499999999,469.20043000000004,805.23816,470.77232000000004,823.90518); -ctx.bezierCurveTo(552.02543,798.48635,610.99107,722.63081,610.99107,632.99893); -ctx.bezierCurveTo(610.99107,567.57432,579.55868,509.48801,530.99107,472.99893); -ctx.closePath(); -ctx.moveTo(250.99107000000004,752.99893); -ctx.bezierCurveTo(275.86402000000004,786.1052599999999,310.78272000000004,811.21984,351.20982000000004,823.87393); -ctx.bezierCurveTo(352.19252000000006,812.2756499999999,356.47693000000004,801.61852,363.11607000000004,792.84268); -ctx.bezierCurveTo(321.11956000000004,791.21726,282.46387000000004,776.64461,250.99107000000004,752.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(330.99107,780.39343); -ctx.bezierCurveTo(353.16121999999996,780.39343,371.13367,763.9635099999999,371.13367,743.6961799999999); -ctx.bezierCurveTo(371.13367,742.58201,371.07697,741.48232,370.97059,740.39343); -ctx.bezierCurveTo(369.14252,759.1119,351.94243,773.78793,330.99107000000004,773.78793); -ctx.bezierCurveTo(310.03970000000004,773.78793,292.83962,759.1119,291.01155000000006,740.39343); -ctx.bezierCurveTo(290.90521000000007,741.48232,290.8484700000001,742.58201,290.8484700000001,743.6961799999999); -ctx.bezierCurveTo(290.8484700000001,763.9635099999999,308.82092000000006,780.3934299999999,330.9910700000001,780.3934299999999); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(530.99107,606.99893); -ctx.bezierCurveTo(553.1612200000001,606.99893,571.13367,590.5690099999999,571.13367,570.30168); -ctx.bezierCurveTo(571.13367,569.1875100000001,571.0769700000001,568.0878200000001,570.97059,566.9989300000001); -ctx.bezierCurveTo(569.14252,585.7174000000001,551.9424300000001,600.3934300000001,530.99107,600.3934300000001); -ctx.bezierCurveTo(510.03970000000004,600.3934300000001,492.83962,585.7174000000001,491.01155000000006,566.9989300000001); -ctx.bezierCurveTo(490.90521000000007,568.0878200000001,490.8484700000001,569.1875100000001,490.8484700000001,570.30168); -ctx.bezierCurveTo(490.8484700000001,590.56901,508.82092000000006,606.99893,530.99107,606.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(290.99107,606.99893); -ctx.bezierCurveTo(313.16121999999996,606.99893,331.13367,590.5690099999999,331.13367,570.30168); -ctx.bezierCurveTo(331.13367,569.1875100000001,331.07697,568.0878200000001,330.97059,566.9989300000001); -ctx.bezierCurveTo(329.14252,585.7174000000001,311.94243,600.3934300000001,290.99107000000004,600.3934300000001); -ctx.bezierCurveTo(270.03970000000004,600.3934300000001,252.83962000000002,585.7174000000001,251.01155000000003,566.9989300000001); -ctx.bezierCurveTo(250.90521000000004,568.0878200000001,250.84847000000002,569.1875100000001,250.84847000000002,570.30168); -ctx.bezierCurveTo(250.84847000000002,590.56901,268.82092,606.99893,290.99107000000004,606.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(410.99107,700.39343); -ctx.bezierCurveTo(444.23506999999995,700.39343,471.18464,675.74855,471.18464,645.34755); -ctx.bezierCurveTo(471.18464,643.6763,471.09964,642.02676,470.94010000000003,640.39343); -ctx.bezierCurveTo(468.19892000000004,668.47114,442.4075,690.48518,410.99107000000004,690.48518); -ctx.bezierCurveTo(379.57463,690.48518,353.78322000000003,668.47114,351.04204000000004,640.39343); -ctx.bezierCurveTo(350.88258,642.02676,350.79750000000007,643.6763,350.79750000000007,645.34755); -ctx.bezierCurveTo(350.79750000000007,675.7485499999999,377.74707000000006,700.39343,410.9910700000001,700.39343); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(379.52232,680.31143); -ctx.bezierCurveTo(369.29332,669.55083,362.99107,655.01762,362.99107,638.99893); -ctx.bezierCurveTo(362.99107,605.86185,389.85398999999995,578.99893,422.99107,578.99893); -ctx.bezierCurveTo(432.90058,578.99893,442.2231,581.43242,450.45982,585.68643); -ctx.bezierCurveTo(439.5286,574.18711,424.10945999999996,566.99893,406.99107,566.99893); -ctx.bezierCurveTo(373.85398999999995,566.99893,346.99107,593.86185,346.99107,626.99893); -ctx.bezierCurveTo(346.99107,650.22651,360.21569999999997,670.34016,379.52232,680.31143); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(385.52232,490.31143); -ctx.bezierCurveTo(375.29332,479.55082999999996,368.99107,465.01761999999997,368.99107,448.99893); -ctx.bezierCurveTo(368.99107,415.86185,395.85398999999995,388.99893,428.99107,388.99893); -ctx.bezierCurveTo(438.90058,388.99893,448.2231,391.43242,456.45982,395.68643); -ctx.bezierCurveTo(445.5286,384.18710999999996,430.10945999999996,376.99893,412.99107,376.99893); -ctx.bezierCurveTo(379.85398999999995,376.99893,352.99107,403.86184999999995,352.99107,436.99893); -ctx.bezierCurveTo(352.99107,460.22650999999996,366.21569999999997,480.34015999999997,385.52232,490.31143); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(410.99107,496.90718); -ctx.bezierCurveTo(444.23506999999995,496.90718,471.18464,472.2623,471.18464,441.86129999999997); -ctx.bezierCurveTo(471.18464,440.19005,471.09964,438.54051,470.94010000000003,436.90718); -ctx.bezierCurveTo(468.19892000000004,464.98489,442.4075,486.99893,410.99107000000004,486.99893); -ctx.bezierCurveTo(379.57463,486.99893,353.78322000000003,464.98488999999995,351.04204000000004,436.90718); -ctx.bezierCurveTo(350.88258,438.54051,350.79750000000007,440.19005,350.79750000000007,441.86129999999997); -ctx.bezierCurveTo(350.79750000000007,472.2623,377.74707000000006,496.90718,410.9910700000001,496.90718); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(385.52232,880.31143); -ctx.bezierCurveTo(375.29332,869.55083,368.99107,855.01762,368.99107,838.99893); -ctx.bezierCurveTo(368.99107,805.86185,395.85398999999995,778.99893,428.99107,778.99893); -ctx.bezierCurveTo(438.90058,778.99893,448.2231,781.43242,456.45982,785.68643); -ctx.bezierCurveTo(445.5286,774.18711,430.10945999999996,766.99893,412.99107,766.99893); -ctx.bezierCurveTo(379.85398999999995,766.99893,352.99107,793.86185,352.99107,826.99893); -ctx.bezierCurveTo(352.99107,850.22651,366.21569999999997,870.34016,385.52232,880.31143); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(214.99107,572.99893); -ctx.bezierCurveTo(181.85399,572.99893,154.99107,599.86185,154.99107,632.99893); -ctx.bezierCurveTo(154.99107,656.22651,168.2157,676.34016,187.52232,686.31143); -ctx.bezierCurveTo(177.29332,675.55083,170.99107,661.01762,170.99107,644.99893); -ctx.bezierCurveTo(170.99107,616.5388399999999,190.81059000000002,592.72182,217.39732,586.56143); -ctx.bezierCurveTo(218.55700000000002,582.09924,219.88045,577.67801,221.33482,573.34268); -ctx.bezierCurveTo(219.25357,573.12367,217.13087000000002,572.99893,214.99107,572.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(610.99107,572.99893); -ctx.bezierCurveTo(608.53101,572.99893,606.12354,573.18,603.74107,573.46768); -ctx.bezierCurveTo(605.0957900000001,578.3556199999999,606.25589,583.31197,607.24107,588.34268); -ctx.bezierCurveTo(613.4279,586.18599,620.06901,584.99893,626.99107,584.99893); -ctx.bezierCurveTo(636.90058,584.99893,646.2231,587.43242,654.45982,591.68643); -ctx.bezierCurveTo(643.5286,580.18711,628.10946,572.99893,610.99107,572.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(270.40757,590.02506); -ctx.bezierCurveTo(263.48731000000004,583.2801400000001,259.22363,574.1704900000001,259.22363,564.12971); -ctx.bezierCurveTo(259.22363,543.3588500000001,277.39728,526.5207300000001,299.81559000000004,526.5207300000001); -ctx.bezierCurveTo(306.51970000000006,526.5207300000001,312.82669000000004,528.0460800000001,318.39911000000006,530.71256); -ctx.bezierCurveTo(311.0037700000001,523.5046000000001,300.5722200000001,518.9989300000001,288.99107000000004,518.9989300000001); -ctx.bezierCurveTo(266.57276,518.9989300000001,248.39911000000004,535.8370500000001,248.39911000000004,556.6079100000001); -ctx.bezierCurveTo(248.39911000000004,571.1673400000001,257.34600000000006,583.7749000000001,270.40757,590.02506); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(509.82696,588.84012); -ctx.bezierCurveTo(503.02601999999996,582.03508,498.83585,572.84422,498.83585,562.71395); -ctx.bezierCurveTo(498.83585,541.75794,516.69616,524.76973,538.7279599999999,524.76973); -ctx.bezierCurveTo(545.31648,524.76973,551.51473,526.30868,556.9910699999999,528.99893); -ctx.bezierCurveTo(549.7232399999999,521.72672,539.4715399999999,517.18089,528.0900599999999,517.18089); -ctx.bezierCurveTo(506.0582699999999,517.18089,488.19795999999985,534.1691,488.19795999999985,555.1251); -ctx.bezierCurveTo(488.19795999999985,569.81431,496.9905899999998,582.5342499999999,509.8269599999999,588.84012); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(249.11607,744.46768); -ctx.bezierCurveTo(239.42177,750.46789,232.99107,761.00366,232.99107,772.99893); -ctx.bezierCurveTo(232.99107,786.0855399999999,240.67045000000002,797.41228,251.86607,803.03018); -ctx.bezierCurveTo(245.93443000000002,796.96757,242.27232,788.77399,242.27232,779.74893); -ctx.bezierCurveTo(242.27232,768.88478,247.54392,759.24582,255.74107,753.06143); -ctx.bezierCurveTo(253.45899,750.25464,251.24597,747.3976,249.11607,744.46768); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(572.05357,748.21768); -ctx.bezierCurveTo(571.2613600000001,749.2555,570.45924,750.28971,569.64732,751.31143); -ctx.bezierCurveTo(573.66413,751.8387799999999,577.4639400000001,753.04166,580.92857,754.78018); -ctx.bezierCurveTo(578.36622,752.16126,575.3596,749.93576,572.05357,748.21768); -ctx.closePath(); -ctx.moveTo(530.45982,788.87393); -ctx.bezierCurveTo(528.51967,790.28432,526.54551,791.65748,524.55357,792.99893); -ctx.bezierCurveTo(527.85458,799.46132,533.17976,804.78457,539.77232,808.09268); -ctx.bezierCurveTo(534.7460100000001,802.9553999999999,531.37795,796.27958,530.45982,788.87393); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(490.99107,780.99893); -ctx.bezierCurveTo(513.16122,780.99893,531.1336699999999,764.5690099999999,531.1336699999999,744.30168); -ctx.bezierCurveTo(531.1336699999999,743.1875100000001,531.07697,742.0878200000001,530.9705899999999,740.9989300000001); -ctx.bezierCurveTo(529.1425199999999,759.7174000000001,511.9424299999999,774.3934300000001,490.9910699999999,774.3934300000001); -ctx.bezierCurveTo(470.0396999999999,774.3934300000001,452.8396199999999,759.7174000000001,451.01154999999994,740.9989300000001); -ctx.bezierCurveTo(450.90520999999995,742.0878200000001,450.84846999999996,743.1875100000001,450.84846999999996,744.30168); -ctx.bezierCurveTo(450.84846999999996,764.56901,468.82091999999994,780.99893,490.99107,780.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(252.5773,518.27473); -ctx.bezierCurveTo(246.64565000000002,512.21212,242.99107,504.02398999999997,242.99107,494.99893); -ctx.bezierCurveTo(242.99107,476.32923,258.56848,461.19444,277.78418,461.19444); -ctx.bezierCurveTo(283.53056,461.19444,288.93655,462.56549,293.71290999999997,464.96223); -ctx.bezierCurveTo(287.37404999999995,458.48341999999997,278.43271999999996,454.43354,268.50602,454.43354); -ctx.bezierCurveTo(249.29031999999998,454.43354,233.71290999999997,469.56833,233.71290999999997,488.23803); -ctx.bezierCurveTo(233.71290999999997,501.32464,241.38166999999996,512.65684,252.57729999999998,518.27473); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(550.99107,456.99893); -ctx.bezierCurveTo(541.15601,456.99893,532.2878900000001,460.96844,525.95982,467.34268); -ctx.bezierCurveTo(529.09436,469.54866,532.14881,471.83973999999995,535.14732,474.21768); -ctx.bezierCurveTo(541.4817800000001,467.78294999999997,550.38418,463.74893,560.27232,463.74893); -ctx.bezierCurveTo(566.0187000000001,463.74893,571.43347,465.13343999999995,576.20982,467.53018); -ctx.bezierCurveTo(569.87097,461.05136999999996,560.91777,456.99893,550.99107,456.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(310.12323,762.27473); -ctx.bezierCurveTo(303.07660999999996,756.21629,298.73508,748.0337999999999,298.73508,739.01495); -ctx.bezierCurveTo(298.73508,720.35811,317.24055999999996,705.23373,340.06822999999997,705.23373); -ctx.bezierCurveTo(346.89475,705.23373,353.3169,706.60384,358.99107,708.9989300000001); -ctx.bezierCurveTo(351.4607,702.5245800000001,340.83867,698.4774900000001,329.04605999999995,698.4774900000001); -ctx.bezierCurveTo(306.2184,698.4774900000001,287.71290999999997,713.6018600000001,287.71290999999997,732.2587100000001); -ctx.bezierCurveTo(287.71290999999997,745.33631,296.82316,756.6607,310.12323,762.2747300000001); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(470.75204,762.27473); -ctx.bezierCurveTo(463.5077,756.21629,459.04435,748.0337999999999,459.04435,739.01495); -ctx.bezierCurveTo(459.04435,720.35811,478.06908,705.23373,501.53727000000003,705.23373); -ctx.bezierCurveTo(508.55534000000006,705.23373,515.15769,706.60384,520.99107,708.9989300000001); -ctx.bezierCurveTo(513.2494,702.5245800000001,502.32933,698.4774900000001,490.20583000000005,698.4774900000001); -ctx.bezierCurveTo(466.73764000000006,698.4774900000001,447.7129100000001,713.6018600000001,447.7129100000001,732.2587100000001); -ctx.bezierCurveTo(447.7129100000001,745.33631,457.0787900000001,756.6607,470.7520400000001,762.2747300000001); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.restore(); -ctx.restore(); -}; -*/ diff --git a/game/old/pause_state.js b/game/old/pause_state.js deleted file mode 100644 index 30e7767..0000000 --- a/game/old/pause_state.js +++ /dev/null @@ -1,121 +0,0 @@ -var pause_state = function (p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - // Buttons - // Have a rectangle representing their position and - // a state to go to when pressed - var button_x = p.width / 2; - var button_top = 200; - var button_sep = 60; - - var button_style = { - text_size: 14, - text_align: p.LEFT, - text_x_offset: 25, - width: 120, - height: 50, - }; - - - var continue_button = button(p, { - state : function() { - sounds.play_button_click(); - return prev_state; - }, - rect : { - pos : new p.PVector(button_x, button_top), - //text: "Continue", - image: "continue.png", - width: 120, - height: 50 - //image_x_offset: 5, - //style: button_style - } - }); - - var options_button = button(p, { - state : function() { - sounds.play_button_click(); - return options_state(p, obj); - }, - rect : { - pos : new p.PVector(button_x, button_top+button_sep), - //text: "Settings", - image: "settings.png", - //style: button_style - } - }); - - var help_button = button(p, { - state : function() { - sounds.play_button_click(); - return help_state(p, obj); - }, - rect : { - pos : new p.PVector(button_x, button_top+2*button_sep), - //text: "Instructions", - //text_x_offset: 10, - image: "instructions.png", - //image_x_offset: 3, - //style: button_style - } - }); - - var quit_button = button(p, { - state : function() { - sounds.play_button_click(); - return splash_state(p); - }, - rect : { - pos : new p.PVector(button_x, button_top+3*button_sep), - //text: "Quit", - //text_x_offset: -5, - image: "quit.png", - //image_x_offset: -5, - //style: button_style - } - }); - - //Not ordered - var all_buttons = [ continue_button, options_button, - help_button, quit_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "pause"; - }; - - obj.update = function() { - //do nothing - }; - - obj.render = function() { - p.noStroke(); - p.fill(0, 150); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.fill(255); - p.textSize(40); - p.textAlign(p.CENTER); - p.text("Game Paused", p.width/2, 150); - }; - - obj.key_pressed = function(k) { - if (k === 112 || p.keyCode === 13 || p.keyCode === 27) { //p, enter, esc - obj.exit_state();; - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/game/old/php_functions.php b/game/old/php_functions.php deleted file mode 100644 index fc47660..0000000 --- a/game/old/php_functions.php +++ /dev/null @@ -1,102 +0,0 @@ - - -var g_soundDataMap = -{ - "cell_fire" : "", - "cell_infect" : "", - "macrophage_infect" : "", - "level_up" : "", - "kill" : "", - "buttonmain" : "", - "buttonback" : "", - "cell_firemp3" : "", - "cell_infectmp3" : "", - "macrophage_infectmp3" : "", - "level_upmp3" : "", - "killmp3" : "", - "buttonmainmp3" : "", - "buttonbackmp3" : "", -}; - -/* -Not working -var dynamic_div_tag = null; -// Jplayer instances - -*/ - -//IMAGES - - -//var image_list = []; -//var g_infected_cell_images = []; -//var g_empty_cell_images = []; - -// to be used in image_manager -all_image_files = {}; - - - diff --git a/game/old/processing-1.0.0.js b/game/old/processing-1.0.0.js deleted file mode 100644 index 605223f..0000000 --- a/game/old/processing-1.0.0.js +++ /dev/null @@ -1,18013 +0,0 @@ -/* - - P R O C E S S I N G . J S - 1.0.0 - a port of the Processing visualization language - - License : MIT - Developer : John Resig: http://ejohn.org - Web Site : http://processingjs.org - Java Version : http://processing.org - Github Repo. : http://github.com/jeresig/processing-js - Bug Tracking : http://processing-js.lighthouseapp.com - Mozilla POW! : http://wiki.Mozilla.org/Education/Projects/ProcessingForTheWeb - Maintained by : Seneca: http://zenit.senecac.on.ca/wiki/index.php/Processing.js - Hyper-Metrix: http://hyper-metrix.com/#Processing - BuildingSky: http://weare.buildingsky.net/pages/processing-js - - */ - -(function() { - - var undef; // intentionally left undefined - - var ajax = function ajax(url) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", url, false); - xhr.setRequestHeader("If-Modified-Since", "Fri, 01 Jan 1960 00:00:00 GMT"); - xhr.send(null); - // failed request? - if (xhr.status !== 200 && xhr.status !== 0) { throw ("XMLHttpRequest failed, status code " + xhr.status); } - return xhr.responseText; - }; - - /* Browsers fixes start */ - function fixReplaceByRegExp() { - var re = /t/g; - if ("t".replace(re,"") !== null && re.exec("t")) { - return; // it is not necessary - } - var _ie_replace = String.prototype.replace; - String.prototype.replace = function(searchValue, repaceValue) { - var result = _ie_replace.apply(this, arguments); - if (searchValue instanceof RegExp && searchValue.global) { - searchValue.lastIndex = 0; - } - return result; - }; - } - - function fixMatchByRegExp() { - var re = /t/g; - if ("t".match(re) !== null && re.exec("t")) { - return; // it is not necessary - } - var _ie_match = String.prototype.match; - String.prototype.match = function(searchValue) { - var result = _ie_match.apply(this, arguments); - if(searchValue instanceof RegExp && searchValue.global) { - searchValue.lastIndex = 0; - } - return result; - }; - } - fixReplaceByRegExp(); - fixMatchByRegExp(); - - (function fixOperaCreateImageData() { - try { - if (!("createImageData" in CanvasRenderingContext2D.prototype)) { - CanvasRenderingContext2D.prototype.createImageData = function (sw, sh) { - return new ImageData(sw, sh); - }; - } - } catch(e) {} - }()); - /* Browsers fixes end */ - - var PConstants = { - X: 0, - Y: 1, - Z: 2, - - R: 3, - G: 4, - B: 5, - A: 6, - - U: 7, - V: 8, - - NX: 9, - NY: 10, - NZ: 11, - - EDGE: 12, - - // Stroke - SR: 13, - SG: 14, - SB: 15, - SA: 16, - - SW: 17, - - // Transformations (2D and 3D) - TX: 18, - TY: 19, - TZ: 20, - - VX: 21, - VY: 22, - VZ: 23, - VW: 24, - - // Material properties - AR: 25, - AG: 26, - AB: 27, - - DR: 3, - DG: 4, - DB: 5, - DA: 6, - - SPR: 28, - SPG: 29, - SPB: 30, - - SHINE: 31, - - ER: 32, - EG: 33, - EB: 34, - - BEEN_LIT: 35, - - VERTEX_FIELD_COUNT: 36, - - // Renderers - P2D: 1, - JAVA2D: 1, - WEBGL: 2, - P3D: 2, - OPENGL: 2, - PDF: 0, - DXF: 0, - - // Platform IDs - OTHER: 0, - WINDOWS: 1, - MAXOSX: 2, - LINUX: 3, - - EPSILON: 0.0001, - - MAX_FLOAT: 3.4028235e+38, - MIN_FLOAT: -3.4028235e+38, - MAX_INT: 2147483647, - MIN_INT: -2147483648, - - PI: Math.PI, - TWO_PI: 2 * Math.PI, - HALF_PI: Math.PI / 2, - THIRD_PI: Math.PI / 3, - QUARTER_PI: Math.PI / 4, - - DEG_TO_RAD: Math.PI / 180, - RAD_TO_DEG: 180 / Math.PI, - - WHITESPACE: " \t\n\r\f\u00A0", - - // Color modes - RGB: 1, - ARGB: 2, - HSB: 3, - ALPHA: 4, - CMYK: 5, - - // Image file types - TIFF: 0, - TARGA: 1, - JPEG: 2, - GIF: 3, - - // Filter/convert types - BLUR: 11, - GRAY: 12, - INVERT: 13, - OPAQUE: 14, - POSTERIZE: 15, - THRESHOLD: 16, - ERODE: 17, - DILATE: 18, - - // Blend modes - REPLACE: 0, - BLEND: 1 << 0, - ADD: 1 << 1, - SUBTRACT: 1 << 2, - LIGHTEST: 1 << 3, - DARKEST: 1 << 4, - DIFFERENCE: 1 << 5, - EXCLUSION: 1 << 6, - MULTIPLY: 1 << 7, - SCREEN: 1 << 8, - OVERLAY: 1 << 9, - HARD_LIGHT: 1 << 10, - SOFT_LIGHT: 1 << 11, - DODGE: 1 << 12, - BURN: 1 << 13, - - // Color component bit masks - ALPHA_MASK: 0xff000000, - RED_MASK: 0x00ff0000, - GREEN_MASK: 0x0000ff00, - BLUE_MASK: 0x000000ff, - - // Projection matrices - CUSTOM: 0, - ORTHOGRAPHIC: 2, - PERSPECTIVE: 3, - - // Shapes - POINT: 2, - POINTS: 2, - LINE: 4, - LINES: 4, - TRIANGLE: 8, - TRIANGLES: 9, - TRIANGLE_STRIP: 10, - TRIANGLE_FAN: 11, - QUAD: 16, - QUADS: 16, - QUAD_STRIP: 17, - POLYGON: 20, - PATH: 21, - RECT: 30, - ELLIPSE: 31, - ARC: 32, - SPHERE: 40, - BOX: 41, - - GROUP: 0, - PRIMITIVE: 1, - //PATH: 21, // shared with Shape PATH - GEOMETRY: 3, - - // Shape Vertex - VERTEX: 0, - BEZIER_VERTEX: 1, - CURVE_VERTEX: 2, - BREAK: 3, - CLOSESHAPE: 4, - - // Shape closing modes - OPEN: 1, - CLOSE: 2, - - // Shape drawing modes - CORNER: 0, // Draw mode convention to use (x, y) to (width, height) - CORNERS: 1, // Draw mode convention to use (x1, y1) to (x2, y2) coordinates - RADIUS: 2, // Draw mode from the center, and using the radius - CENTER_RADIUS: 2, // Deprecated! Use RADIUS instead - CENTER: 3, // Draw from the center, using second pair of values as the diameter - DIAMETER: 3, // Synonym for the CENTER constant. Draw from the center - CENTER_DIAMETER: 3, // Deprecated! Use DIAMETER instead - - // Text vertical alignment modes - BASELINE: 0, // Default vertical alignment for text placement - TOP: 101, // Align text to the top - BOTTOM: 102, // Align text from the bottom, using the baseline - - // UV Texture coordinate modes - NORMAL: 1, - NORMALIZED: 1, - IMAGE: 2, - - // Text placement modes - MODEL: 4, - SHAPE: 5, - - // Stroke modes - SQUARE: 'butt', - ROUND: 'round', - PROJECT: 'square', - MITER: 'miter', - BEVEL: 'bevel', - - // Lighting modes - AMBIENT: 0, - DIRECTIONAL: 1, - //POINT: 2, Shared with Shape constant - SPOT: 3, - - // Key constants - - // Both key and keyCode will be equal to these values - BACKSPACE: 8, - TAB: 9, - ENTER: 10, - RETURN: 13, - ESC: 27, - DELETE: 127, - CODED: 0xffff, - - // p.key will be CODED and p.keyCode will be this value - SHIFT: 16, - CONTROL: 17, - ALT: 18, - CAPSLK: 20, - PGUP: 33, - PGDN: 34, - END: 35, - HOME: 36, - LEFT: 37, - UP: 38, - RIGHT: 39, - DOWN: 40, - INS: 45, - DEL: 46, - F1: 112, - F2: 113, - F3: 114, - F4: 115, - F5: 116, - F6: 117, - F7: 118, - F8: 119, - F9: 120, - F10: 121, - F11: 122, - F12: 123, - NUMLK: 144, - - // Cursor types - ARROW: 'default', - CROSS: 'crosshair', - HAND: 'pointer', - MOVE: 'move', - TEXT: 'text', - WAIT: 'wait', - NOCURSOR: "url('data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), auto", - - // Hints - DISABLE_OPENGL_2X_SMOOTH: 1, - ENABLE_OPENGL_2X_SMOOTH: -1, - ENABLE_OPENGL_4X_SMOOTH: 2, - ENABLE_NATIVE_FONTS: 3, - DISABLE_DEPTH_TEST: 4, - ENABLE_DEPTH_TEST: -4, - ENABLE_DEPTH_SORT: 5, - DISABLE_DEPTH_SORT: -5, - DISABLE_OPENGL_ERROR_REPORT: 6, - ENABLE_OPENGL_ERROR_REPORT: -6, - ENABLE_ACCURATE_TEXTURES: 7, - DISABLE_ACCURATE_TEXTURES: -7, - HINT_COUNT: 10, - - // PJS defined constants - SINCOS_LENGTH: parseInt(360 / 0.5, 10), - PRECISIONB: 15, // fixed point precision is limited to 15 bits!! - PRECISIONF: 1 << 15, - PREC_MAXVAL: (1 << 15) - 1, - PREC_ALPHA_SHIFT: 24 - 15, - PREC_RED_SHIFT: 16 - 15, - NORMAL_MODE_AUTO: 0, - NORMAL_MODE_SHAPE: 1, - NORMAL_MODE_VERTEX: 2, - MAX_LIGHTS: 8 - }; - - // Typed Arrays: fallback to WebGL arrays or Native JS arrays if unavailable - function setupTypedArray(name, fallback) { - // check if TypedArray exists - // typeof on Minefield and Chrome return function, typeof on Webkit returns object. - if (typeof this[name] !== "function" && typeof this[name] !== "object") { - // nope.. check if WebGLArray exists - if (typeof this[fallback] === "function") { - this[name] = this[fallback]; - } else { - // nope.. set as Native JS array - this[name] = function(obj) { - if (obj instanceof Array) { - return obj; - } else if (typeof obj === "number") { - return new Array(obj); - } - }; - } - } - } - - setupTypedArray("Float32Array", "WebGLFloatArray"); - setupTypedArray("Int32Array", "WebGLIntArray"); - setupTypedArray("Uint16Array", "WebGLUnsignedShortArray"); - setupTypedArray("Uint8Array", "WebGLUnsignedByteArray"); - - /** - * An ArrayList stores a variable number of objects. - * - * @param {int} initialCapacity optional defines the initial capacity of the list, it's empty by default - * - * @returns {ArrayList} new ArrayList object - */ - var ArrayList = (function() { - function Iterator(array) { - var index = 0; - this.hasNext = function() { - return index < array.length; - }; - - this.next = function() { - return array[index++]; - }; - - this.remove = function() { - array.splice(index, 1); - }; - } - - function ArrayList() { - var array = arguments.length === 0 ? [] : - typeof arguments[0] === 'number' ? new Array(0 | arguments[0]) : - arguments[0]; - - /** - * @member ArrayList - * ArrayList.get() Returns the element at the specified position in this list. - * - * @param {int} i index of element to return - * - * @returns {Object} the element at the specified position in this list. - */ - this.get = function(i) { - return array[i]; - }; - /** - * @member ArrayList - * ArrayList.contains() Returns true if this list contains the specified element. - * - * @param {Object} item element whose presence in this List is to be tested. - * - * @returns {boolean} true if the specified element is present; false otherwise. - */ - this.contains = function(item) { - return array.indexOf(item) !== -1; - }; - /** - * @member ArrayList - * ArrayList.add() Adds the specified element to this list. - * - * @param {int} index optional index at which the specified element is to be inserted - * @param {Object} object element to be added to the list - */ - this.add = function() { - if (arguments.length === 1) { - array.push(arguments[0]); // for add(Object) - } else if (arguments.length === 2) { - var arg0 = arguments[0]; - if (typeof arg0 === 'number') { - if (arg0 >= 0 && arg0 <= array.length) { - array.splice(arg0, 0, arguments[1]); // for add(i, Object) - } else { - throw(arg0 + " is not a valid index"); - } - } else { - throw(typeof arg0 + " is not a number"); - } - } else { - throw("Please use the proper number of parameters."); - } - }; - - /** - * @member ArrayList - * ArrayList.set() Replaces the element at the specified position in this list with the specified element. - * - * @param {int} index index of element to replace - * @param {Object} object element to be stored at the specified position - */ - this.set = function() { - if (arguments.length === 2) { - var arg0 = arguments[0]; - if (typeof arg0 === 'number') { - if (arg0 >= 0 && arg0 < array.length) { - array.splice(arg0, 1, arguments[1]); - } else { - throw(arg0 + " is not a valid index."); - } - } else { - throw(typeof arg0 + " is not a number"); - } - } else { - throw("Please use the proper number of parameters."); - } - }; - - /** - * @member ArrayList - * ArrayList.size() Returns the number of elements in this list. - * - * @returns {int} the number of elements in this list - */ - this.size = function() { - return array.length; - }; - - /** - * @member ArrayList - * ArrayList.clear() Removes all of the elements from this list. The list will be empty after this call returns. - */ - this.clear = function() { - array.length = 0; - }; - - /** - * @member ArrayList - * ArrayList.remove() Removes the element at the specified position in this list. - * Shifts any subsequent elements to the left (subtracts one from their indices). - * - * @param {int} index the index of the element to removed. - * - * @returns {Object} the element that was removed from the list - */ - this.remove = function(i) { - return array.splice(i, 1)[0]; - }; - - /** - * @member ArrayList - * ArrayList.isEmpty() Tests if this list has no elements. - * - * @returns {boolean} true if this list has no elements; false otherwise - */ - this.isEmpty = function() { - return !array.length; - }; - - /** - * @member ArrayList - * ArrayList.clone() Returns a shallow copy of this ArrayList instance. (The elements themselves are not copied.) - * - * @returns {ArrayList} a clone of this ArrayList instance - */ - this.clone = function() { - return new ArrayList(array.slice(0)); - }; - - /** - * @member ArrayList - * ArrayList.toArray() Returns an array containing all of the elements in this list in the correct order. - * - * @returns {Object[]} Returns an array containing all of the elements in this list in the correct order - */ - this.toArray = function() { - return array.slice(0); - }; - - this.iterator = function() { - return new Iterator(array); - }; - } - - return ArrayList; - }()); - - /** - * A HashMap stores a collection of objects, each referenced by a key. This is similar to an Array, only - * instead of accessing elements with a numeric index, a String is used. (If you are familiar with - * associative arrays from other languages, this is the same idea.) - * - * @param {int} initialCapacity defines the initial capacity of the map, it's 16 by default - * @param {float} loadFactor the load factor for the map, the default is 0.75 - * @param {Map} m gives the new HashMap the same mappings as this Map - */ - var HashMap = (function() { - function virtHashCode(obj) { - if (obj.constructor === String) { - var hash = 0; - for (var i = 0; i < obj.length; ++i) { - hash = (hash * 31 + obj.charCodeAt(i)) & 0xFFFFFFFF; - } - return hash; - } else if (typeof(obj) !== "object") { - return obj & 0xFFFFFFFF; - } else if ("hashCode" in obj) { - return obj.hashCode.call(obj); - } else { - if (obj.$id === undef) { - obj.$id = ((Math.floor(Math.random() * 0x10000) - 0x8000) << 16) | Math.floor(Math.random() * 0x10000); - } - return obj.$id; - } - } - - function virtEquals(obj, other) { - if (obj === null || other === null) { - return (obj === null) && (other === null); - } else if (obj.constructor === String) { - return obj === other; - } else if (typeof(obj) !== "object") { - return obj === other; - } else if ("equals" in obj) { - return obj.equals.call(obj, other); - } else { - return obj === other; - } - } - - /** - * @member HashMap - * A HashMap stores a collection of objects, each referenced by a key. This is similar to an Array, only - * instead of accessing elements with a numeric index, a String is used. (If you are familiar with - * associative arrays from other languages, this is the same idea.) - * - * @param {int} initialCapacity defines the initial capacity of the map, it's 16 by default - * @param {float} loadFactor the load factor for the map, the default is 0.75 - * @param {Map} m gives the new HashMap the same mappings as this Map - */ - function HashMap() { - if (arguments.length === 1 && arguments[0].constructor === HashMap) { - return arguments[0].clone(); - } - - var initialCapacity = arguments.length > 0 ? arguments[0] : 16; - var loadFactor = arguments.length > 1 ? arguments[1] : 0.75; - var buckets = new Array(initialCapacity); - var count = 0; - var hashMap = this; - - function ensureLoad() { - if (count <= loadFactor * buckets.length) { - return; - } - var allEntries = []; - for (var i = 0; i < buckets.length; ++i) { - if (buckets[i] !== undef) { - allEntries = allEntries.concat(buckets[i]); - } - } - buckets = new Array(buckets.length * 2); - for (var j = 0; j < allEntries.length; ++j) { - var index = virtHashCode(allEntries[j].key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - buckets[index] = bucket = []; - } - bucket.push(allEntries[j]); - } - } - - function Iterator(conversion, removeItem) { - var bucketIndex = 0; - var itemIndex = -1; - var endOfBuckets = false; - - function findNext() { - while (!endOfBuckets) { - ++itemIndex; - if (bucketIndex >= buckets.length) { - endOfBuckets = true; - } else if (buckets[bucketIndex] === undef || itemIndex >= buckets[bucketIndex].length) { - itemIndex = -1; - ++bucketIndex; - } else { - return; - } - } - } - - /* - * @member Iterator - * Checks if the Iterator has more items - */ - this.hasNext = function() { - return !endOfBuckets; - }; - - /* - * @member Iterator - * Return the next Item - */ - this.next = function() { - var result = conversion(buckets[bucketIndex][itemIndex]); - findNext(); - return result; - }; - - /* - * @member Iterator - * Remove the current item - */ - this.remove = function() { - removeItem(this.next()); - --itemIndex; - }; - - findNext(); - } - - function Set(conversion, isIn, removeItem) { - this.clear = function() { - hashMap.clear(); - }; - - this.contains = function(o) { - return isIn(o); - }; - - this.containsAll = function(o) { - var it = o.iterator(); - while (it.hasNext()) { - if (!this.contains(it.next())) { - return false; - } - } - return true; - }; - - this.isEmpty = function() { - return hashMap.isEmpty(); - }; - - this.iterator = function() { - return new Iterator(conversion, removeItem); - }; - - this.remove = function(o) { - if (this.contains(o)) { - removeItem(o); - return true; - } - return false; - }; - - this.removeAll = function(c) { - var it = c.iterator(); - var changed = false; - while (it.hasNext()) { - var item = it.next(); - if (this.contains(item)) { - removeItem(item); - changed = true; - } - } - return true; - }; - - this.retainAll = function(c) { - var it = this.iterator(); - var toRemove = []; - while (it.hasNext()) { - var entry = it.next(); - if (!c.contains(entry)) { - toRemove.push(entry); - } - } - for (var i = 0; i < toRemove.length; ++i) { - removeItem(toRemove[i]); - } - return toRemove.length > 0; - }; - - this.size = function() { - return hashMap.size(); - }; - - this.toArray = function() { - var result = new ArrayList(0); - var it = this.iterator(); - while (it.hasNext()) { - result.push(it.next()); - } - return result; - }; - } - - function Entry(pair) { - this._isIn = function(map) { - return map === hashMap && (pair.removed === undef); - }; - - this.equals = function(o) { - return virtEquals(pair.key, o.getKey()); - }; - - this.getKey = function() { - return pair.key; - }; - - this.getValue = function() { - return pair.value; - }; - - this.hashCode = function(o) { - return virtHashCode(pair.key); - }; - - this.setValue = function(value) { - var old = pair.value; - pair.value = value; - return old; - }; - } - - this.clear = function() { - count = 0; - buckets = new Array(initialCapacity); - }; - - this.clone = function() { - var map = new HashMap(); - map.putAll(this); - return map; - }; - - this.containsKey = function(key) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - return false; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - return true; - } - } - return false; - }; - - this.containsValue = function(value) { - for (var i = 0; i < buckets.length; ++i) { - var bucket = buckets[i]; - if (bucket === undef) { - continue; - } - for (var j = 0; j < bucket.length; ++j) { - if (virtEquals(bucket[j].value, value)) { - return true; - } - } - } - return false; - }; - - this.entrySet = function() { - return new Set( - - function(pair) { - return new Entry(pair); - }, - - function(pair) { - return pair.constructor === Entry && pair._isIn(hashMap); - }, - - function(pair) { - return hashMap.remove(pair.getKey()); - }); - }; - - this.get = function(key) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - return null; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - return bucket[i].value; - } - } - return null; - }; - - this.isEmpty = function() { - return count === 0; - }; - - this.keySet = function() { - return new Set( - - function(pair) { - return pair.key; - }, - - function(key) { - return hashMap.containsKey(key); - }, - - function(key) { - return hashMap.remove(key); - }); - }; - - this.put = function(key, value) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - ++count; - buckets[index] = [{ - key: key, - value: value - }]; - ensureLoad(); - return null; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - var previous = bucket[i].value; - bucket[i].value = value; - return previous; - } - } - ++count; - bucket.push({ - key: key, - value: value - }); - ensureLoad(); - return null; - }; - - this.putAll = function(m) { - var it = m.entrySet().iterator(); - while (it.hasNext()) { - var entry = it.next(); - this.put(entry.getKey(), entry.getValue()); - } - }; - - this.remove = function(key) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - return null; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - --count; - var previous = bucket[i].value; - bucket[i].removed = true; - if (bucket.length > 1) { - bucket.splice(i, 1); - } else { - buckets[index] = undef; - } - return previous; - } - } - return null; - }; - - this.size = function() { - return count; - }; - - this.values = function() { - var result = new ArrayList(0); - var it = this.entrySet().iterator(); - while (it.hasNext()) { - var entry = it.next(); - result.push(entry.getValue()); - } - return result; - }; - } - - return HashMap; - }()); - - var PVector = (function() { - function PVector(x, y, z) { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - } - - function createPVectorMethod(method) { - return function(v1, v2) { - var v = v1.get(); - v[method](v2); - return v; - }; - } - - function createSimplePVectorMethod(method) { - return function(v1, v2) { - return v1[method](v2); - }; - } - - var simplePVMethods = "dist dot cross".split(" "); - var method = simplePVMethods.length; - - PVector.angleBetween = function(v1, v2) { - return Math.acos(v1.dot(v2) / (v1.mag() * v2.mag())); - }; - - // Common vector operations for PVector - PVector.prototype = { - set: function(v, y, z) { - if (arguments.length === 1) { - this.set(v.x || v[0], v.y || v[1], v.z || v[2]); - } else { - this.x = v; - this.y = y; - this.z = z; - } - }, - get: function() { - return new PVector(this.x, this.y, this.z); - }, - mag: function() { - return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); - }, - add: function(v, y, z) { - if (arguments.length === 3) { - this.x += v; - this.y += y; - this.z += z; - } else if (arguments.length === 1) { - this.x += v.x; - this.y += v.y; - this.z += v.z; - } - }, - sub: function(v, y, z) { - if (arguments.length === 3) { - this.x -= v; - this.y -= y; - this.z -= z; - } else if (arguments.length === 1) { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z; - } - }, - mult: function(v) { - if (typeof v === 'number') { - this.x *= v; - this.y *= v; - this.z *= v; - } else if (typeof v === 'object') { - this.x *= v.x; - this.y *= v.y; - this.z *= v.z; - } - }, - div: function(v) { - if (typeof v === 'number') { - this.x /= v; - this.y /= v; - this.z /= v; - } else if (typeof v === 'object') { - this.x /= v.x; - this.y /= v.y; - this.z /= v.z; - } - }, - dist: function(v) { - var dx = this.x - v.x, - dy = this.y - v.y, - dz = this.z - v.z; - return Math.sqrt(dx * dx + dy * dy + dz * dz); - }, - dot: function(v, y, z) { - if (arguments.length === 3) { - return (this.x * v + this.y * y + this.z * z); - } else if (arguments.length === 1) { - return (this.x * v.x + this.y * v.y + this.z * v.z); - } - }, - cross: function(v) { - return new PVector(this.y * v.z - v.y * this.z, - this.z * v.x - v.z * this.x, - this.x * v.y - v.x * this.y); - }, - normalize: function() { - var m = this.mag(); - if (m > 0) { - this.div(m); - } - }, - limit: function(high) { - if (this.mag() > high) { - this.normalize(); - this.mult(high); - } - }, - heading2D: function() { - return (-Math.atan2(-this.y, this.x)); - }, - toString: function() { - return "[" + this.x + ", " + this.y + ", " + this.z + "]"; - }, - array: function() { - return [this.x, this.y, this.z]; - } - }; - - while (method--) { - PVector[simplePVMethods[method]] = createSimplePVectorMethod(simplePVMethods[method]); - } - - for (method in PVector.prototype) { - if (PVector.prototype.hasOwnProperty(method) && !PVector.hasOwnProperty(method)) { - PVector[method] = createPVectorMethod(method); - } - } - - return PVector; - }()); - - // Building defaultScope. Changing of the prototype protects - // internal Processing code from the changes in defaultScope - function DefaultScope() {} - DefaultScope.prototype = PConstants; - - var defaultScope = new DefaultScope(); - defaultScope.ArrayList = ArrayList; - defaultScope.HashMap = HashMap; - defaultScope.PVector = PVector; - //defaultScope.PImage = PImage; // TODO - //defaultScope.PShape = PShape; // TODO - //defaultScope.PShapeSVG = PShapeSVG; // TODO - - var Processing = this.Processing = function Processing(curElement, aCode) { - // Previously we allowed calling Processing as a func instead of ctor, but no longer. - if (!(this instanceof Processing)) { - throw("called Processing constructor as if it were a function: missing 'new'."); - } - - // When something new is added to "p." it must also be added to the "names" array. - // The names array contains the names of everything that is inside "p." - var p = this; - - // PJS specific (non-p5) methods and properties to externalize - p.externals = { - canvas: curElement, - context: undef, - sketch: undef, - onblur: function() {}, - onfocus: function() {} - }; - - p.name = 'Processing.js Instance'; // Set Processing defaults / environment variables - p.use3DContext = false; // default '2d' canvas context - - /** - * Confirms if a Processing program is "focused", meaning that it is - * active and will accept input from mouse or keyboard. This variable - * is "true" if it is focused and "false" if not. This variable is - * often used when you want to warn people they need to click on the - * browser before it will work. - */ - p.focused = true; - p.breakShape = false; - - // Glyph path storage for textFonts - p.glyphTable = {}; - - // Global vars for tracking mouse position - p.pmouseX = 0; - p.pmouseY = 0; - p.mouseX = 0; - p.mouseY = 0; - p.mouseButton = 0; - p.mouseScroll = 0; - - // Undefined event handlers to be replaced by user when needed - p.mouseClicked = undef; - p.mouseDragged = undef; - p.mouseMoved = undef; - p.mousePressed = undef; - p.mouseReleased = undef; - p.mouseScrolled = undef; - p.key = undef; - p.keyCode = undef; - p.keyPressed = function(){}; // needed to remove function checks - p.keyReleased = function(){}; - p.keyTyped = function(){}; - p.draw = undef; - p.setup = undef; - - // Remapped vars - p.__mousePressed = false; - p.__keyPressed = false; - p.__frameRate = 0; - - // The current animation frame - p.frameCount = 0; - - // The height/width of the canvas - p.width = curElement.width - 0; - p.height = curElement.height - 0; - - p.defineProperty = function(obj, name, desc) { - if("defineProperty" in Object) { - Object.defineProperty(obj, name, desc); - } else { - if (desc.hasOwnProperty("get")) { - obj.__defineGetter__(name, desc.get); - } - if (desc.hasOwnProperty("set")) { - obj.__defineSetter__(name, desc.set); - } - } - }; - - // "Private" variables used to maintain state - var curContext, - curSketch, - online = true, - doFill = true, - fillStyle = [1.0, 1.0, 1.0, 1.0], - currentFillColor = 0xFFFFFFFF, - isFillDirty = true, - doStroke = true, - strokeStyle = [0.8, 0.8, 0.8, 1.0], - currentStrokeColor = 0xFFFDFDFD, - isStrokeDirty = true, - lineWidth = 1, - loopStarted = false, - doLoop = true, - looping = 0, - curRectMode = PConstants.CORNER, - curEllipseMode = PConstants.CENTER, - normalX = 0, - normalY = 0, - normalZ = 0, - normalMode = PConstants.NORMAL_MODE_AUTO, - inDraw = false, - curFrameRate = 60, - curCursor = PConstants.ARROW, - oldCursor = curElement.style.cursor, - curMsPerFrame = 1, - curShape = PConstants.POLYGON, - curShapeCount = 0, - curvePoints = [], - curTightness = 0, - curveDet = 20, - curveInited = false, - bezDetail = 20, - colorModeA = 255, - colorModeX = 255, - colorModeY = 255, - colorModeZ = 255, - pathOpen = false, - mouseDragging = false, - curColorMode = PConstants.RGB, - curTint = null, - curTextSize = 12, - curTextFont = "Arial", - curTextLeading = 14, - getLoaded = false, - start = new Date().getTime(), - timeSinceLastFPS = start, - framesSinceLastFPS = 0, - textcanvas, - curveBasisMatrix, - curveToBezierMatrix, - curveDrawMatrix, - bezierDrawMatrix, - bezierBasisInverse, - bezierBasisMatrix, - // Keys and Keystrokes - firstCodedDown = true, // first coded key stroke - firstEDGKeyDown = true, // first Enter - Delete Google key stroke - firstEDMKeyDown = true, // first Enter - Delete Mozilla key stroke - firstMKeyDown = true, // first Mozilla key stroke - firstGKeyDown = true, // first Google key stroke - gRefire = false, // Google refire - curContextCache = { attributes: {}, locations: {} }, - // Shaders - programObject3D, - programObject2D, - programObjectUnlitShape, - boxBuffer, - boxNormBuffer, - boxOutlineBuffer, - rectBuffer, - rectNormBuffer, - sphereBuffer, - lineBuffer, - fillBuffer, - fillColorBuffer, - strokeColorBuffer, - pointBuffer, - shapeTexVBO, - canTex, // texture for createGraphics - textTex, // texture for 3d tex - curTexture = {width:0,height:0}, - curTextureMode = PConstants.IMAGE, - usingTexture = false, - textBuffer, - textureBuffer, - indexBuffer, - // Text alignment - horizontalTextAlignment = PConstants.LEFT, - verticalTextAlignment = PConstants.BASELINE, - baselineOffset = 0.2, // percent - tMode = PConstants.MODEL, - // Pixels cache - originalContext, - proxyContext = null, - isContextReplaced = false, - setPixelsCached, - maxPixelsCached = 1000, - codedKeys = [ PConstants.SHIFT, PConstants.CONTROL, PConstants.ALT, PConstants.CAPSLK, PConstants.PGUP, PConstants.PGDN, - PConstants.END, PConstants.HOME, PConstants.LEFT, PConstants.UP, PConstants.RIGHT, PConstants.DOWN, PConstants.NUMLK, - PConstants.INS, PConstants.F1, PConstants.F2, PConstants.F3, PConstants.F4, PConstants.F5, PConstants.F6, PConstants.F7, - PConstants.F8, PConstants.F9, PConstants.F10, PConstants.F11, PConstants.F12 ]; - - // Get padding and border style widths for mouse offsets - var stylePaddingLeft, stylePaddingTop, styleBorderLeft, styleBorderTop; - - if (document.defaultView && document.defaultView.getComputedStyle) { - stylePaddingLeft = parseInt(document.defaultView.getComputedStyle(curElement, null)['paddingLeft'], 10) || 0; - stylePaddingTop = parseInt(document.defaultView.getComputedStyle(curElement, null)['paddingTop'], 10) || 0; - styleBorderLeft = parseInt(document.defaultView.getComputedStyle(curElement, null)['borderLeftWidth'], 10) || 0; - styleBorderTop = parseInt(document.defaultView.getComputedStyle(curElement, null)['borderTopWidth'], 10) || 0; - } - - // User can only have MAX_LIGHTS lights - var lightCount = 0; - - //sphere stuff - var sphereDetailV = 0, - sphereDetailU = 0, - sphereX = [], - sphereY = [], - sphereZ = [], - sinLUT = new Array(PConstants.SINCOS_LENGTH), - cosLUT = new Array(PConstants.SINCOS_LENGTH), - sphereVerts, - sphereNorms; - - // Camera defaults and settings - var cam, - cameraInv, - forwardTransform, - reverseTransform, - modelView, - modelViewInv, - userMatrixStack, - inverseCopy, - projection, - manipulatingCamera = false, - frustumMode = false, - cameraFOV = 60 * (Math.PI / 180), - cameraX = curElement.width / 2, - cameraY = curElement.height / 2, - cameraZ = cameraY / Math.tan(cameraFOV / 2), - cameraNear = cameraZ / 10, - cameraFar = cameraZ * 10, - cameraAspect = curElement.width / curElement.height; - - var vertArray = [], - curveVertArray = [], - curveVertCount = 0, - isCurve = false, - isBezier = false, - firstVert = true; - - //PShape stuff - var curShapeMode = PConstants.CORNER; - - var colors = { - aliceblue: "#f0f8ff", - antiquewhite: "#faebd7", - aqua: "#00ffff", - aquamarine: "#7fffd4", - azure: "#f0ffff", - beige: "#f5f5dc", - bisque: "#ffe4c4", - black: "#000000", - blanchedalmond: "#ffebcd", - blue: "#0000ff", - blueviolet: "#8a2be2", - brown: "#a52a2a", - burlywood: "#deb887", - cadetblue: "#5f9ea0", - chartreuse: "#7fff00", - chocolate: "#d2691e", - coral: "#ff7f50", - cornflowerblue: "#6495ed", - cornsilk: "#fff8dc", - crimson: "#dc143c", - cyan: "#00ffff", - darkblue: "#00008b", - darkcyan: "#008b8b", - darkgoldenrod: "#b8860b", - darkgray: "#a9a9a9", - darkgreen: "#006400", - darkkhaki: "#bdb76b", - darkmagenta: "#8b008b", - darkolivegreen: "#556b2f", - darkorange: "#ff8c00", - darkorchid: "#9932cc", - darkred: "#8b0000", - darksalmon: "#e9967a", - darkseagreen: "#8fbc8f", - darkslateblue: "#483d8b", - darkslategray: "#2f4f4f", - darkturquoise: "#00ced1", - darkviolet: "#9400d3", - deeppink: "#ff1493", - deepskyblue: "#00bfff", - dimgray: "#696969", - dodgerblue: "#1e90ff", - firebrick: "#b22222", - floralwhite: "#fffaf0", - forestgreen: "#228b22", - fuchsia: "#ff00ff", - gainsboro: "#dcdcdc", - ghostwhite: "#f8f8ff", - gold: "#ffd700", - goldenrod: "#daa520", - gray: "#808080", - green: "#008000", - greenyellow: "#adff2f", - honeydew: "#f0fff0", - hotpink: "#ff69b4", - indianred: "#cd5c5c", - indigo: "#4b0082", - ivory: "#fffff0", - khaki: "#f0e68c", - lavender: "#e6e6fa", - lavenderblush: "#fff0f5", - lawngreen: "#7cfc00", - lemonchiffon: "#fffacd", - lightblue: "#add8e6", - lightcoral: "#f08080", - lightcyan: "#e0ffff", - lightgoldenrodyellow: "#fafad2", - lightgrey: "#d3d3d3", - lightgreen: "#90ee90", - lightpink: "#ffb6c1", - lightsalmon: "#ffa07a", - lightseagreen: "#20b2aa", - lightskyblue: "#87cefa", - lightslategray: "#778899", - lightsteelblue: "#b0c4de", - lightyellow: "#ffffe0", - lime: "#00ff00", - limegreen: "#32cd32", - linen: "#faf0e6", - magenta: "#ff00ff", - maroon: "#800000", - mediumaquamarine: "#66cdaa", - mediumblue: "#0000cd", - mediumorchid: "#ba55d3", - mediumpurple: "#9370d8", - mediumseagreen: "#3cb371", - mediumslateblue: "#7b68ee", - mediumspringgreen: "#00fa9a", - mediumturquoise: "#48d1cc", - mediumvioletred: "#c71585", - midnightblue: "#191970", - mintcream: "#f5fffa", - mistyrose: "#ffe4e1", - moccasin: "#ffe4b5", - navajowhite: "#ffdead", - navy: "#000080", - oldlace: "#fdf5e6", - olive: "#808000", - olivedrab: "#6b8e23", - orange: "#ffa500", - orangered: "#ff4500", - orchid: "#da70d6", - palegoldenrod: "#eee8aa", - palegreen: "#98fb98", - paleturquoise: "#afeeee", - palevioletred: "#d87093", - papayawhip: "#ffefd5", - peachpuff: "#ffdab9", - peru: "#cd853f", - pink: "#ffc0cb", - plum: "#dda0dd", - powderblue: "#b0e0e6", - purple: "#800080", - red: "#ff0000", - rosybrown: "#bc8f8f", - royalblue: "#4169e1", - saddlebrown: "#8b4513", - salmon: "#fa8072", - sandybrown: "#f4a460", - seagreen: "#2e8b57", - seashell: "#fff5ee", - sienna: "#a0522d", - silver: "#c0c0c0", - skyblue: "#87ceeb", - slateblue: "#6a5acd", - slategray: "#708090", - snow: "#fffafa", - springgreen: "#00ff7f", - steelblue: "#4682b4", - tan: "#d2b48c", - teal: "#008080", - thistle: "#d8bfd8", - tomato: "#ff6347", - turquoise: "#40e0d0", - violet: "#ee82ee", - wheat: "#f5deb3", - white: "#ffffff", - whitesmoke: "#f5f5f5", - yellow: "#ffff00", - yellowgreen: "#9acd32" - }; - - // Stores states for pushStyle() and popStyle(). - var styleArray = new Array(0); - - // Vertices are specified in a counter-clockwise order - // triangles are in this order: back, front, right, bottom, left, top - var boxVerts = new Float32Array([ - 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, - -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, - -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, - 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, - 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, - -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, - -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, - -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, - -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5]); - - var boxOutlineVerts = new Float32Array([ - 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, - -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, - 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, - -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, - 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, - -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5]); - - var boxNorms = new Float32Array([ - 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, - 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, - 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, - -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, - 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]); - - // These verts are used for the fill and stroke using TRIANGLE_FAN and LINE_LOOP - var rectVerts = new Float32Array([0,0,0, 0,1,0, 1,1,0, 1,0,0]); - - var rectNorms = new Float32Array([0,0,-1, 0,0,-1, 0,0,-1, 0,0,-1]); - - // Vertex shader for points and lines - var vShaderSrcUnlitShape = - "varying vec4 frontColor;" + - - "attribute vec3 aVertex;" + - "attribute vec4 aColor;" + - - "uniform mat4 uView;" + - "uniform mat4 uProjection;" + - - "void main(void) {" + - " frontColor = aColor;" + - " gl_Position = uProjection * uView * vec4(aVertex, 1.0);" + - "}"; - - var fShaderSrcUnlitShape = - "#ifdef GL_ES\n" + - "precision highp float;\n" + - "#endif\n" + - - "varying vec4 frontColor;" + - - "void main(void){" + - " gl_FragColor = frontColor;" + - "}"; - - // Vertex shader for points and lines - var vertexShaderSource2D = - "varying vec4 frontColor;" + - - "attribute vec3 Vertex;" + - "attribute vec2 aTextureCoord;" + - "uniform vec4 color;" + - - "uniform mat4 model;" + - "uniform mat4 view;" + - "uniform mat4 projection;" + - "uniform float pointSize;" + - "varying vec2 vTextureCoord;"+ - - "void main(void) {" + - " gl_PointSize = pointSize;" + - " frontColor = color;" + - " gl_Position = projection * view * model * vec4(Vertex, 1.0);" + - " vTextureCoord = aTextureCoord;" + - "}"; - - var fragmentShaderSource2D = - "#ifdef GL_ES\n" + - "precision highp float;\n" + - "#endif\n" + - - "varying vec4 frontColor;" + - "varying vec2 vTextureCoord;"+ - - "uniform sampler2D uSampler;"+ - "uniform int picktype;"+ - - "void main(void){" + - " if(picktype == 0){"+ - " gl_FragColor = frontColor;" + - " }" + - " else if(picktype == 1){"+ - " float alpha = texture2D(uSampler, vTextureCoord).a;"+ - " gl_FragColor = vec4(frontColor.rgb*alpha, alpha);\n"+ - " }"+ - "}"; - - // Vertex shader for boxes and spheres - var vertexShaderSource3D = - "varying vec4 frontColor;" + - - "attribute vec3 Vertex;" + - "attribute vec3 Normal;" + - "attribute vec4 aColor;" + - "attribute vec2 aTexture;" + - "varying vec2 vTexture;" + - - "uniform vec4 color;" + - - "uniform bool usingMat;" + - "uniform vec3 specular;" + - "uniform vec3 mat_emissive;" + - "uniform vec3 mat_ambient;" + - "uniform vec3 mat_specular;" + - "uniform float shininess;" + - - "uniform mat4 model;" + - "uniform mat4 view;" + - "uniform mat4 projection;" + - "uniform mat4 normalTransform;" + - - "uniform int lightCount;" + - "uniform vec3 falloff;" + - - "struct Light {" + - " bool dummy;" + - " int type;" + - " vec3 color;" + - " vec3 position;" + - " vec3 direction;" + - " float angle;" + - " vec3 halfVector;" + - " float concentration;" + - "};" + - "uniform Light lights[8];" + - - "void AmbientLight( inout vec3 totalAmbient, in vec3 ecPos, in Light light ) {" + - // Get the vector from the light to the vertex - // Get the distance from the current vector to the light position - " float d = length( light.position - ecPos );" + - " float attenuation = 1.0 / ( falloff[0] + ( falloff[1] * d ) + ( falloff[2] * d * d ));" + " totalAmbient += light.color * attenuation;" + - "}" + - - "void DirectionalLight( inout vec3 col, in vec3 ecPos, inout vec3 spec, in vec3 vertNormal, in Light light ) {" + - " float powerfactor = 0.0;" + - " float nDotVP = max(0.0, dot( vertNormal, light.position ));" + - " float nDotVH = max(0.0, dot( vertNormal, normalize( light.position-ecPos )));" + - - " if( nDotVP != 0.0 ){" + - " powerfactor = pow( nDotVH, shininess );" + - " }" + - - " col += light.color * nDotVP;" + - " spec += specular * powerfactor;" + - "}" + - - "void PointLight( inout vec3 col, inout vec3 spec, in vec3 vertNormal, in vec3 ecPos, in vec3 eye, in Light light ) {" + - " float powerfactor;" + - - // Get the vector from the light to the vertex - " vec3 VP = light.position - ecPos;" + - - // Get the distance from the current vector to the light position - " float d = length( VP ); " + - - // Normalize the light ray so it can be used in the dot product operation. - " VP = normalize( VP );" + - - " float attenuation = 1.0 / ( falloff[0] + ( falloff[1] * d ) + ( falloff[2] * d * d ));" + - - " float nDotVP = max( 0.0, dot( vertNormal, VP ));" + - " vec3 halfVector = normalize( VP + eye );" + - " float nDotHV = max( 0.0, dot( vertNormal, halfVector ));" + - - " if( nDotVP == 0.0) {" + - " powerfactor = 0.0;" + - " }" + - " else{" + - " powerfactor = pow( nDotHV, shininess );" + - " }" + - - " spec += specular * powerfactor * attenuation;" + - " col += light.color * nDotVP * attenuation;" + - "}" + - - /* - */ - "void SpotLight( inout vec3 col, inout vec3 spec, in vec3 vertNormal, in vec3 ecPos, in vec3 eye, in Light light ) {" + - " float spotAttenuation;" + - " float powerfactor;" + - - // calculate the vector from the current vertex to the light. - " vec3 VP = light.position - ecPos; " + - " vec3 ldir = normalize( light.direction );" + - - // get the distance from the spotlight and the vertex - " float d = length( VP );" + - " VP = normalize( VP );" + - - " float attenuation = 1.0 / ( falloff[0] + ( falloff[1] * d ) + ( falloff[2] * d * d ) );" + - - // dot product of the vector from vertex to light and light direction. - " float spotDot = dot( VP, ldir );" + - - // if the vertex falls inside the cone - " if( spotDot < cos( light.angle ) ) {" + - " spotAttenuation = pow( spotDot, light.concentration );" + - " }" + - " else{" + - " spotAttenuation = 1.0;" + - " }" + - " attenuation *= spotAttenuation;" + - - " float nDotVP = max( 0.0, dot( vertNormal, VP ));" + - " vec3 halfVector = normalize( VP + eye );" + - " float nDotHV = max( 0.0, dot( vertNormal, halfVector ));" + - - " if( nDotVP == 0.0 ) {" + - " powerfactor = 0.0;" + - " }" + - " else {" + - " powerfactor = pow( nDotHV, shininess );" + - " }" + - - " spec += specular * powerfactor * attenuation;" + - " col += light.color * nDotVP * attenuation;" + - "}" + - - "void main(void) {" + - " vec3 finalAmbient = vec3( 0.0, 0.0, 0.0 );" + - " vec3 finalDiffuse = vec3( 0.0, 0.0, 0.0 );" + - " vec3 finalSpecular = vec3( 0.0, 0.0, 0.0 );" + - - " vec4 col = color;" + - " if(color[0] == -1.0){" + - " col = aColor;" + - " }" + - - " vec3 norm = vec3( normalTransform * vec4( Normal, 0.0 ) );" + - - " vec4 ecPos4 = view * model * vec4(Vertex,1.0);" + - " vec3 ecPos = (vec3(ecPos4))/ecPos4.w;" + - " vec3 eye = vec3( 0.0, 0.0, 1.0 );" + - - // If there were no lights this draw call, just use the - // assigned fill color of the shape and the specular value - " if( lightCount == 0 ) {" + - " frontColor = col + vec4(mat_specular,1.0);" + - " }" + - " else {" + - " for( int i = 0; i < lightCount; i++ ) {" + - " if( lights[i].type == 0 ) {" + - " AmbientLight( finalAmbient, ecPos, lights[i] );" + - " }" + - " else if( lights[i].type == 1 ) {" + - " DirectionalLight( finalDiffuse,ecPos, finalSpecular, norm, lights[i] );" + - " }" + - " else if( lights[i].type == 2 ) {" + - " PointLight( finalDiffuse, finalSpecular, norm, ecPos, eye, lights[i] );" + - " }" + - " else if( lights[i].type == 3 ) {" + - " SpotLight( finalDiffuse, finalSpecular, norm, ecPos, eye, lights[i] );" + - " }" + - " }" + - - " if( usingMat == false ) {" + - " frontColor = vec4( " + - " vec3(col) * finalAmbient +" + - " vec3(col) * finalDiffuse +" + - " vec3(col) * finalSpecular," + - " col[3] );" + - " }" + - " else{" + - " frontColor = vec4( " + - " mat_emissive + " + - " (vec3(col) * mat_ambient * finalAmbient) + " + - " (vec3(col) * finalDiffuse) + " + - " (mat_specular * finalSpecular), " + - " col[3] );" + - " }" + - " }" + - " vTexture.xy = aTexture.xy;" + - " gl_Position = projection * view * model * vec4( Vertex, 1.0 );" + - "}"; - - var fragmentShaderSource3D = - "#ifdef GL_ES\n" + - "precision highp float;\n" + - "#endif\n" + - - "varying vec4 frontColor;" + - - "uniform sampler2D sampler;" + - "uniform bool usingTexture;" + - "varying vec2 vTexture;" + - - // In Processing, when a texture is used, the fill color is ignored - "void main(void){" + - " if(usingTexture){" + - " gl_FragColor = vec4(texture2D(sampler, vTexture.xy));" + - " }"+ - " else{" + - " gl_FragColor = frontColor;" + - " }" + - "}"; - - //////////////////////////////////////////////////////////////////////////// - // 3D Functions - //////////////////////////////////////////////////////////////////////////// - - /* - * Sets a uniform variable in a program object to a particular - * value. Before calling this function, ensure the correct - * program object has been installed as part of the current - * rendering state by calling useProgram. - * - * On some systems, if the variable exists in the shader but isn't used, - * the compiler will optimize it out and this function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {float | Array} varValue either a scalar value or an Array - * - * @returns none - * - * @see uniformi - * @see uniformMatrix - */ - function uniformf(cacheId, programObj, varName, varValue) { - var varLocation = curContextCache.locations[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getUniformLocation(programObj, varName); - curContextCache.locations[cacheId] = varLocation; - } - // the variable won't be found if it was optimized out. - if (varLocation !== -1) { - if (varValue.length === 4) { - curContext.uniform4fv(varLocation, varValue); - } else if (varValue.length === 3) { - curContext.uniform3fv(varLocation, varValue); - } else if (varValue.length === 2) { - curContext.uniform2fv(varLocation, varValue); - } else { - curContext.uniform1f(varLocation, varValue); - } - } - } - - /** - * Sets a uniform int or int array in a program object to a particular - * value. Before calling this function, ensure the correct - * program object has been installed as part of the current - * rendering state. - * - * On some systems, if the variable exists in the shader but isn't used, - * the compiler will optimize it out and this function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {int | Array} varValue either a scalar value or an Array - * - * @returns none - * - * @see uniformf - * @see uniformMatrix - */ - function uniformi(cacheId, programObj, varName, varValue) { - var varLocation = curContextCache.locations[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getUniformLocation(programObj, varName); - curContextCache.locations[cacheId] = varLocation; - } - // the variable won't be found if it was optimized out. - if (varLocation !== -1) { - if (varValue.length === 4) { - curContext.uniform4iv(varLocation, varValue); - } else if (varValue.length === 3) { - curContext.uniform3iv(varLocation, varValue); - } else if (varValue.length === 2) { - curContext.uniform2iv(varLocation, varValue); - } else { - curContext.uniform1i(varLocation, varValue); - } - } - } - - /** - * Binds the VBO, sets the vertex attribute data for the program - * object and enables the attribute. - * - * On some systems, if the attribute exists in the shader but - * isn't used, the compiler will optimize it out and this - * function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {int} size the number of components per vertex attribute - * @param {WebGLBuffer} VBO Vertex Buffer Object - * - * @returns none - * - * @see disableVertexAttribPointer - */ - function vertexAttribPointer(cacheId, programObj, varName, size, VBO) { - var varLocation = curContextCache.attributes[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getAttribLocation(programObj, varName); - curContextCache.attributes[cacheId] = varLocation; - } - if (varLocation !== -1) { - curContext.bindBuffer(curContext.ARRAY_BUFFER, VBO); - curContext.vertexAttribPointer(varLocation, size, curContext.FLOAT, false, 0, 0); - curContext.enableVertexAttribArray(varLocation); - } - } - - /** - * Disables a program object attribute from being sent to WebGL. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName name of the attribute - * - * @returns none - * - * @see vertexAttribPointer - */ - function disableVertexAttribPointer(cacheId, programObj, varName){ - var varLocation = curContextCache.attributes[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getAttribLocation(programObj, varName); - curContextCache.attributes[cacheId] = varLocation; - } - if (varLocation !== -1) { - curContext.disableVertexAttribArray(varLocation); - } - } - - /** - * Sets the value of a uniform matrix variable in a program - * object. Before calling this function, ensure the correct - * program object has been installed as part of the current - * rendering state. - * - * On some systems, if the variable exists in the shader but - * isn't used, the compiler will optimize it out and this - * function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {boolean} transpose must be false - * @param {Array} matrix an array of 4, 9 or 16 values - * - * @returns none - * - * @see uniformi - * @see uniformf - */ - function uniformMatrix(cacheId, programObj, varName, transpose, matrix) { - var varLocation = curContextCache.locations[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getUniformLocation(programObj, varName); - curContextCache.locations[cacheId] = varLocation; - } - // the variable won't be found if it was optimized out. - if (varLocation !== -1) { - if (matrix.length === 16) { - curContext.uniformMatrix4fv(varLocation, transpose, matrix); - } else if (matrix.length === 9) { - curContext.uniformMatrix3fv(varLocation, transpose, matrix); - } else { - curContext.uniformMatrix2fv(varLocation, transpose, matrix); - } - } - } - - var imageModeCorner = function imageModeCorner(x, y, w, h, whAreSizes) { - return { - x: x, - y: y, - w: w, - h: h - }; - }; - var imageModeConvert = imageModeCorner; - - var imageModeCorners = function imageModeCorners(x, y, w, h, whAreSizes) { - return { - x: x, - y: y, - w: whAreSizes ? w : w - x, - h: whAreSizes ? h : h - y - }; - }; - - var imageModeCenter = function imageModeCenter(x, y, w, h, whAreSizes) { - return { - x: x - w / 2, - y: y - h / 2, - w: w, - h: h - }; - }; - - /** - * Creates a WebGL program object. - * - * @param {String} vetexShaderSource - * @param {String} fragmentShaderSource - * - * @returns {WebGLProgram} A program object - */ - var createProgramObject = function(curContext, vetexShaderSource, fragmentShaderSource) { - var vertexShaderObject = curContext.createShader(curContext.VERTEX_SHADER); - curContext.shaderSource(vertexShaderObject, vetexShaderSource); - curContext.compileShader(vertexShaderObject); - if (!curContext.getShaderParameter(vertexShaderObject, curContext.COMPILE_STATUS)) { - throw curContext.getShaderInfoLog(vertexShaderObject); - } - - var fragmentShaderObject = curContext.createShader(curContext.FRAGMENT_SHADER); - curContext.shaderSource(fragmentShaderObject, fragmentShaderSource); - curContext.compileShader(fragmentShaderObject); - if (!curContext.getShaderParameter(fragmentShaderObject, curContext.COMPILE_STATUS)) { - throw curContext.getShaderInfoLog(fragmentShaderObject); - } - - var programObject = curContext.createProgram(); - curContext.attachShader(programObject, vertexShaderObject); - curContext.attachShader(programObject, fragmentShaderObject); - curContext.linkProgram(programObject); - if (!curContext.getProgramParameter(programObject, curContext.LINK_STATUS)) { - throw "Error linking shaders."; - } - - return programObject; - }; - - //////////////////////////////////////////////////////////////////////////// - // Char handling - //////////////////////////////////////////////////////////////////////////// - var charMap = {}; - - var Char = p.Character = function Char(chr) { - if (typeof chr === 'string' && chr.length === 1) { - this.code = chr.charCodeAt(0); - } else { - this.code = NaN; - } - - return (charMap[this.code] === undef) ? charMap[this.code] = this : charMap[this.code]; - }; - - Char.prototype.toString = function() { - return String.fromCharCode(this.code); - }; - - Char.prototype.valueOf = function() { - return this.code; - }; - - /** - * Datatype for storing shapes. Processing can currently load and display SVG (Scalable Vector Graphics) shapes. - * Before a shape is used, it must be loaded with the loadShape() function. The shape() function is used to draw the shape to the display window. - * The PShape object contain a group of methods, linked below, that can operate on the shape data. - *

          The loadShape() method supports SVG files created with Inkscape and Adobe Illustrator. - * It is not a full SVG implementation, but offers some straightforward support for handling vector data. - * - * @param {int} family the shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY - * - * @see #shape() - * @see #loadShape() - * @see #shapeMode() - */ - var PShape = p.PShape = function(family) { - this.family = family || PConstants.GROUP; - this.visible = true; - this.style = true; - this.children = []; - this.nameTable = []; - this.params = []; - this.name = ""; - this.image = null; //type PImage - this.matrix = null; - this.kind = null; - this.close = null; - this.width = null; - this.height = null; - this.parent = null; - - /** - * PShape methods - * missing: findChild(), apply(), contains(), findChild(), getPrimitive(), getParams(), getVertex() , getVertexCount(), - * getVertexCode() , getVertexCodes() , getVertexCodeCount(), getVertexX(), getVertexY(), getVertexZ() - */ - - /** - * @member PShape - * The isVisible() function returns a boolean value "true" if the image is set to be visible, "false" if not. This is modified with the setVisible() parameter. - *

          The visibility of a shape is usually controlled by whatever program created the SVG file. - * For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator. - * - * @return {boolean} returns "true" if the image is set to be visible, "false" if not - */ - this.isVisible = function(){ - return this.visible; - }; - /** - * @member PShape - * The setVisible() function sets the shape to be visible or invisible. This is determined by the value of the visible parameter. - *

          The visibility of a shape is usually controlled by whatever program created the SVG file. - * For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator. - * - * @param {boolean} visible "false" makes the shape invisible and "true" makes it visible - */ - this.setVisible = function (visible){ - this.visible = visible; - }; - /** - * @member PShape - * The disableStyle() function disables the shape's style data and uses Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints. - * Overrides this shape's style information and uses PGraphics styles and colors. Identical to ignoreStyles(true). Also disables styles for all child shapes. - */ - this.disableStyle = function(){ - this.style = false; - for(var i = 0; i < this.children.length; i++) - { - this.children[i].disableStyle(); - } - }; - /** - * @member PShape - * The enableStyle() function enables the shape's style data and ignores Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints. - */ - this.enableStyle = function(){ - this.style = true; - for(var i = 0; i < this.children.length; i++) - { - this.children[i].enableStyle(); - } - }; - /** - * @member PShape - * The getFamily function returns the shape type - * - * @return {int} the shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY - */ - this.getFamily = function(){ - return this.family; - }; - /** - * @member PShape - * The getWidth() function gets the width of the drawing area (not necessarily the shape boundary). - */ - this.getWidth = function(){ - return this.width; - }; - /** - * @member PShape - * The getHeight() function gets the height of the drawing area (not necessarily the shape boundary). - */ - this.getHeight = function(){ - return this.height; - }; - /** - * @member PShape - * The setName() function sets the name of the shape - * - * @param {String} name the name of the shape - */ - this.setName = function(name){ - this.name = name; - }; - /** - * @member PShape - * The getName() function returns the name of the shape - * - * @return {String} the name of the shape - */ - this.getName = function(){ - return this.name; - }; - /** - * @member PShape - * Called by the following (the shape() command adds the g) - * PShape s = loadShapes("blah.svg"); - * shape(s); - */ - this.draw = function(){ - if (this.visible) { - this.pre(); - this.drawImpl(); - this.post(); - } - }; - /** - * @member PShape - * the drawImpl() function draws the SVG document. - */ - this.drawImpl = function(){ - if (this.family === PConstants.GROUP) { - this.drawGroup(); - } else if (this.family === PConstants.PRIMITIVE) { - this.drawPrimitive(); - } else if (this.family === PConstants.GEOMETRY) { - this.drawGeometry(); - } else if (this.family === PConstants.PATH) { - this.drawPath(); - } - }; - /** - * @member PShape - * The drawPath() function draws the part of the SVG document. - */ - this.drawPath = function(){ - if (this.vertices.length === 0) { return; } - - p.beginShape(); - var i; - if (this.vertexCodes.length === 0) { // each point is a simple vertex - if (this.vertices[0].length === 2) { // drawing 2D vertices - for (i = 0; i < this.vertices.length; i++) { - p.vertex(this.vertices[i][0], this.vertices[i][1]); - } - } else { // drawing 3D vertices - for (i = 0; i < this.vertices.length; i++) { - p.vertex(this.vertices[i][0], this.vertices[i][1], this.vertices[i][2]); - } - } - } else { // coded set of vertices - var index = 0; - var j; - if (this.vertices[0].length === 2) { // drawing a 2D path - for (j = 0; j < this.vertexCodes.length; j++) { - switch (this.vertexCodes[j]) { - case PConstants.VERTEX: - p.vertex(this.vertices[index][0], this.vertices[index][1]); - if ( this.vertices[index]["moveTo"] === true) { - vertArray[vertArray.length-1]["moveTo"] = true; - } else if ( this.vertices[index]["moveTo"] === false) { - vertArray[vertArray.length-1]["moveTo"] = false; - } - p.breakShape = false; - index++; - break; - case PConstants.BEZIER_VERTEX: - p.bezierVertex(this.vertices[index+0][0], this.vertices[index+0][1], - this.vertices[index+1][0], this.vertices[index+1][1], - this.vertices[index+2][0], this.vertices[index+2][1]); - index += 3; - break; - case PConstants.CURVE_VERTEX: - p.curveVertex(this.vertices[index][0], this.vertices[index][1]); - index++; - break; - case PConstants.BREAK: - p.breakShape = true; - break; - } - } - } else { // drawing a 3D path - for (j = 0; j < this.vertexCodes.length; j++) { - switch (this.vertexCodes[j]) { - case PConstants.VERTEX: - p.vertex(this.vertices[index][0], this.vertices[index][1], this.vertices[index][2]); - if (this.vertices[index]["moveTo"] === true) { - vertArray[vertArray.length-1]["moveTo"] = true; - } else if (this.vertices[index]["moveTo"] === false) { - vertArray[vertArray.length-1]["moveTo"] = false; - } - p.breakShape = false; - break; - case PConstants.BEZIER_VERTEX: - p.bezierVertex(this.vertices[index+0][0], this.vertices[index+0][1], this.vertices[index+0][2], - this.vertices[index+1][0], this.vertices[index+1][1], this.vertices[index+1][2], - this.vertices[index+2][0], this.vertices[index+2][1], this.vertices[index+2][2]); - index += 3; - break; - case PConstants.CURVE_VERTEX: - p.curveVertex(this.vertices[index][0], this.vertices[index][1], this.vertices[index][2]); - index++; - break; - case PConstants.BREAK: - p.breakShape = true; - break; - } - } - } - } - p.endShape(this.close ? PConstants.CLOSE : PConstants.OPEN); - }; - /** - * @member PShape - * The drawGeometry() function draws the geometry part of the SVG document. - */ - this.drawGeometry = function() { - p.beginShape(this.kind); - var i; - if (this.style) { - for (i = 0; i < this.vertices.length; i++) { - p.vertex(this.vertices[i]); - } - } else { - for (i = 0; i < this.vertices.length; i++) { - var vert = this.vertices[i]; - if (vert[2] === 0) { - p.vertex(vert[0], vert[1]); - } else { - p.vertex(vert[0], vert[1], vert[2]); - } - } - } - p.endShape(); - }; - /** - * @member PShape - * The drawGroup() function draws the part of the SVG document. - */ - this.drawGroup = function() { - for (var i = 0; i < this.children.length; i++) { - this.children[i].draw(); - } - }; - /** - * @member PShape - * The drawPrimitive() function draws SVG document shape elements. These can be point, line, triangle, quad, rect, ellipse, arc, box, or sphere. - */ - this.drawPrimitive = function() { - switch (this.kind) { - case PConstants.POINT: - p.point(this.params[0], this.params[1]); - break; - case PConstants.LINE: - if (this.params.length === 4) { // 2D - p.line(this.params[0], this.params[1], - this.params[2], this.params[3]); - } else { // 3D - p.line(this.params[0], this.params[1], this.params[2], - this.params[3], this.params[4], this.params[5]); - } - break; - case PConstants.TRIANGLE: - p.triangle(this.params[0], this.params[1], - this.params[2], this.params[3], - this.params[4], this.params[5]); - break; - case PConstants.QUAD: - p.quad(this.params[0], this.params[1], - this.params[2], this.params[3], - this.params[4], this.params[5], - this.params[6], this.params[7]); - break; - case PConstants.RECT: - if (this.image !== null) { - p.imageMode(PConstants.CORNER); - p.image(this.image, this.params[0], this.params[1], this.params[2], this.params[3]); - } else { - p.rectMode(PConstants.CORNER); - p.rect(this.params[0], this.params[1], this.params[2], this.params[3]); - } - break; - case PConstants.ELLIPSE: - p.ellipseMode(PConstants.CORNER); - p.ellipse(this.params[0], this.params[1], this.params[2], this.params[3]); - break; - case PConstants.ARC: - p.ellipseMode(PConstants.CORNER); - p.arc(this.params[0], this.params[1], this.params[2], this.params[3], this.params[4], this.params[5]); - break; - case PConstants.BOX: - if (this.params.length === 1) { - p.box(this.params[0]); - } else { - p.box(this.params[0], this.params[1], this.params[2]); - } - break; - case PConstants.SPHERE: - p.sphere(this.params[0]); - break; - } - }; - /** - * @member PShape - * The pre() function performs the preparations before the SVG is drawn. This includes doing transformations and storing previous styles. - */ - this.pre = function() { - if (this.matrix) { - p.pushMatrix(); - curContext.transform(this.matrix.elements[0], this.matrix.elements[3], this.matrix.elements[1], this.matrix.elements[4], this.matrix.elements[2], this.matrix.elements[5]); - //p.applyMatrix(this.matrix.elements[0],this.matrix.elements[0]); - } - if (this.style) { - p.pushStyle(); - this.styles(); - } - }; - /** - * @member PShape - * The post() function performs the necessary actions after the SVG is drawn. This includes removing transformations and removing added styles. - */ - this.post = function() { - if (this.matrix) { - p.popMatrix(); - } - if (this.style) { - p.popStyle(); - } - }; - /** - * @member PShape - * The styles() function changes the Processing's current styles - */ - this.styles = function() { - if (this.stroke) { - p.stroke(this.strokeColor); - p.strokeWeight(this.strokeWeight); - p.strokeCap(this.strokeCap); - p.strokeJoin(this.strokeJoin); - } else { - p.noStroke(); - } - - if (this.fill) { - p.fill(this.fillColor); - - } else { - p.noFill(); - } - }; - /** - * @member PShape - * The getChild() function extracts a child shape from a parent shape. Specify the name of the shape with the target parameter or the - * layer position of the shape to get with the index parameter. - * The shape is returned as a PShape object, or null is returned if there is an error. - * - * @param {String} target the name of the shape to get - * @param {int} index the layer position of the shape to get - * - * @return {PShape} returns a child element of a shape as a PShape object or null if there is an error - */ - this.getChild = function() { - if (typeof arguments[0] === 'number') { - return this.children[arguments[0]]; - } else { - var found, - i; - if(arguments[0] === "" || this.name === arguments[0]){ - return this; - } else { - if(this.nameTable.length > 0) - { - for(i = 0; i < this.nameTable.length || found; i++) - { - if(this.nameTable[i].getName === arguments[0]) { - found = this.nameTable[i]; - } - } - if (found) { return found; } - } - for(i = 0; i < this.children.lenth; i++) - { - found = this.children[i].getChild(arguments[0]); - if(found) { return found; } - } - } - return null; - } - }; - /** - * @member PShape - * The getChildCount() returns the number of children - * - * @return {int} returns a count of children - */ - this.getChildCount = function () { - return this.children.length; - }; - /** - * @member PShape - * The addChild() adds a child to the PShape. - * - * @param {PShape} child the child to add - */ - this.addChild = function( child ) { - this.children.push(child); - child.parent = this; - if (child.getName() !== null) { - this.addName(child.getName(), child); - } - }; - /** - * @member PShape - * The addName() functions adds a shape to the name lookup table. - * - * @param {String} name the name to be added - * @param {PShape} shape the shape - */ - this.addName = function(name, shape) { - if (this.parent !== null) { - this.parent.addName( name, shape ); - } else { - this.nameTable.push( [name, shape] ); - } - }; - /** - * @member PShape - * The translate() function specifies an amount to displace the shape. The x parameter specifies left/right translation, the y parameter specifies up/down translation, and the z parameter specifies translations toward/away from the screen. - * Subsequent calls to the method accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

          Using this method with the z parameter requires using the P3D or OPENGL parameter in combination with size. - * - * @param {int|float} x left/right translation - * @param {int|float} y up/down translation - * @param {int|float} z forward/back translation - * - * @see PMatrix2D#translate - * @see PMatrix3D#translate - */ - this.translate = function() { - if(arguments.length === 2) - { - this.checkMatrix(2); - this.matrix.translate(arguments[0], arguments[1]); - } else { - this.checkMatrix(3); - this.matrix.translate(arguments[0], arguments[1], 0); - } - }; - /** - * @member PShape - * The checkMatrix() function makes sure that the shape's matrix is 1) not null, and 2) has a matrix - * that can handle at least the specified number of dimensions. - * - * @param {int} dimensions the specified number of dimensions - */ - this.checkMatrix = function(dimensions) { - if(this.matrix === null) { - if(dimensions === 2) { - this.matrix = new p.PMatrix2D(); - } else { - this.matrix = new p.PMatrix3D(); - } - }else if(dimensions === 3 && this.matrix instanceof p.PMatrix2D) { - this.matrix = new p.PMatrix3D(); - } - }; - /** - * @member PShape - * The rotateX() function rotates a shape around the x-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

          Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Subsequent calls to the method accumulates the effect. For example, calling rotateX(HALF_PI) and then rotateX(HALF_PI) is the same as rotateX(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

          This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above. - * - * @param {float}angle angle of rotation specified in radians - * - * @see PMatrix3D#rotateX - */ - this.rotateX = function(angle) { - this.rotate(angle, 1, 0, 0); - }; - /** - * @member PShape - * The rotateY() function rotates a shape around the y-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

          Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Subsequent calls to the method accumulates the effect. For example, calling rotateY(HALF_PI) and then rotateY(HALF_PI) is the same as rotateY(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

          This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above. - * - * @param {float}angle angle of rotation specified in radians - * - * @see PMatrix3D#rotateY - */ - this.rotateY = function(angle) { - this.rotate(angle, 0, 1, 0); - }; - /** - * @member PShape - * The rotateZ() function rotates a shape around the z-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

          Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Subsequent calls to the method accumulates the effect. For example, calling rotateZ(HALF_PI) and then rotateZ(HALF_PI) is the same as rotateZ(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

          This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above. - * - * @param {float}angle angle of rotation specified in radians - * - * @see PMatrix3D#rotateZ - */ - this.rotateZ = function(angle) { - this.rotate(angle, 0, 0, 1); - }; - /** - * @member PShape - * The rotate() function rotates a shape the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

          Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Transformations apply to everything that happens after and subsequent calls to the method accumulates the effect. - * For example, calling rotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - * If optional parameters x,y,z are supplied, the rotate is about the point (x, y, z). - * - * @param {float}angle angle of rotation specified in radians - * @param {float}x x-coordinate of the point - * @param {float}y y-coordinate of the point - * @param {float}z z-coordinate of the point - * @see PMatrix2D#rotate - * @see PMatrix3D#rotate - */ - this.rotate = function() { - if(arguments.length === 1){ - this.checkMatrix(2); - this.matrix.rotate(arguments[0]); - } else { - this.checkMatrix(3); - this.matrix.rotate(arguments[0], arguments[1], arguments[2] ,arguments[3]); - } - }; - /** - * @member PShape - * The scale() function increases or decreases the size of a shape by expanding and contracting vertices. Shapes always scale from the relative origin of their bounding box. - * Scale values are specified as decimal percentages. For example, the method call scale(2.0) increases the dimension of a shape by 200%. - * Subsequent calls to the method multiply the effect. For example, calling scale(2.0) and then scale(1.5) is the same as scale(3.0). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

          Using this fuction with the z parameter requires passing P3D or OPENGL into the size() parameter. - * - * @param {float}s percentage to scale the object - * @param {float}x percentage to scale the object in the x-axis - * @param {float}y percentage to scale the object in the y-axis - * @param {float}z percentage to scale the object in the z-axis - * - * @see PMatrix2D#scale - * @see PMatrix3D#scale - */ - this.scale = function() { - if(arguments.length === 2) { - this.checkMatrix(2); - this.matrix.scale(arguments[0], arguments[1]); - } else if (arguments.length === 3) { - this.checkMatrix(2); - this.matrix.scale(arguments[0], arguments[1], arguments[2]); - } else { - this.checkMatrix(2); - this.matrix.scale(arguments[0]); - } - }; - /** - * @member PShape - * The resetMatrix() function resets the matrix - * - * @see PMatrix2D#reset - * @see PMatrix3D#reset - */ - this.resetMatrix = function() { - this.checkMatrix(2); - this.matrix.reset(); - }; - /** - * @member PShape - * The applyMatrix() function multiplies this matrix by another matrix of type PMatrix3D or PMatrix2D. - * Individual elements can also be provided - * - * @param {PMatrix3D|PMatrix2D} matrix the matrix to multiply by - * - * @see PMatrix2D#apply - * @see PMatrix3D#apply - */ - this.applyMatrix = function(matrix) { - if (arguments.length === 1) { - this.applyMatrix(matrix.elements[0], matrix.elements[1], 0, matrix.elements[2], - matrix.elements[3], matrix.elements[4], 0, matrix.elements[5], - 0, 0, 1, 0, - 0, 0, 0, 1); - } else if (arguments.length === 6) { - this.checkMatrix(2); - this.matrix.apply(arguments[0], arguments[1], arguments[2], 0, - arguments[3], arguments[4], arguments[5], 0, - 0, 0, 1, 0, - 0, 0, 0, 1); - - } else if (arguments.length === 16) { - this.checkMatrix(3); - this.matrix.apply(arguments[0], arguments[1], arguments[2], arguments[3], - arguments[4], arguments[5], arguments[6], arguments[7], - arguments[8], arguments[9], arguments[10], arguments[11], - arguments[12], arguments[13], arguments[14], arguments[15]); - } - }; - }; - - /** - * SVG stands for Scalable Vector Graphics, a portable graphics format. It is - * a vector format so it allows for infinite resolution and relatively small - * file sizes. Most modern media software can view SVG files, including Adobe - * products, Firefox, etc. Illustrator and Inkscape can edit SVG files. - * - * @param {PApplet} parent typically use "this" - * @param {String} filename name of the SVG file to load - * @param {XMLElement} xml an XMLElement element - * @param {PShapeSVG} parent the parent PShapeSVG - * - * @see PShape - */ - var PShapeSVG = p.PShapeSVG = function() { - p.PShape.call( this ); // PShape is the base class. - if (arguments.length === 1) { //xml element coming in - this.element = arguments[0] ;//new p.XMLElement(null, arguments[0]); - // set values to their defaults according to the SVG spec - this.vertexCodes = []; - this.vertices = []; - this.opacity = 1; - - this.stroke = false; - this.strokeColor = PConstants.ALPHA_MASK; - this.strokeWeight = 1; - this.strokeCap = PConstants.SQUARE; // equivalent to BUTT in svg spec - this.strokeJoin = PConstants.MITER; - this.strokeGradient = null; - this.strokeGradientPaint = null; - this.strokeName = null; - this.strokeOpacity = 1; - - this.fill = true; - this.fillColor = PConstants.ALPHA_MASK; - this.fillGradient = null; - this.fillGradientPaint = null; - this.fillName = null; - this.fillOpacity = 1; - - if (this.element.getName() !== "svg") { - throw("root is not , it's <" + this.element.getName() + ">"); - } - } - else if (arguments.length === 2) { - if (typeof arguments[1] === 'string') { - if (arguments[1].indexOf(".svg") > -1) { //its a filename - this.element = new p.XMLElement(null, arguments[1]); - // set values to their defaults according to the SVG spec - this.vertexCodes = []; - this.vertices = []; - this.opacity = 1; - - this.stroke = false; - this.strokeColor = PConstants.ALPHA_MASK; - this.strokeWeight = 1; - this.strokeCap = PConstants.SQUARE; // equivalent to BUTT in svg spec - this.strokeJoin = PConstants.MITER; - this.strokeGradient = ""; - this.strokeGradientPaint = ""; - this.strokeName = ""; - this.strokeOpacity = 1; - - this.fill = true; - this.fillColor = PConstants.ALPHA_MASK; - this.fillGradient = null; - this.fillGradientPaint = null; - this.fillOpacity = 1; - - } - } else { // XMLElement - if (arguments[0]) { // PShapeSVG - this.element = arguments[1]; - this.vertexCodes = arguments[0].vertexCodes.slice(); - this.vertices = arguments[0].vertices.slice(); - - this.stroke = arguments[0].stroke; - this.strokeColor = arguments[0].strokeColor; - this.strokeWeight = arguments[0].strokeWeight; - this.strokeCap = arguments[0].strokeCap; - this.strokeJoin = arguments[0].strokeJoin; - this.strokeGradient = arguments[0].strokeGradient; - this.strokeGradientPaint = arguments[0].strokeGradientPaint; - this.strokeName = arguments[0].strokeName; - - this.fill = arguments[0].fill; - this.fillColor = arguments[0].fillColor; - this.fillGradient = arguments[0].fillGradient; - this.fillGradientPaint = arguments[0].fillGradientPaint; - this.fillName = arguments[0].fillName; - this.strokeOpacity = arguments[0].strokeOpacity; - this.fillOpacity = arguments[0].fillOpacity; - this.opacity = arguments[0].opacity; - } - } - } - - this.name = this.element.getStringAttribute("id"); - var displayStr = this.element.getStringAttribute("display", "inline"); - this.visible = displayStr !== "none"; - var str = this.element.getAttribute("transform"); - if (str) { - this.matrix = this.parseMatrix(str); - } - // not proper parsing of the viewBox, but will cover us for cases where - // the width and height of the object is not specified - var viewBoxStr = this.element.getStringAttribute("viewBox"); - if ( viewBoxStr !== null ) { - var viewBox = viewBoxStr.split(" "); - this.width = viewBox[2]; - this.height = viewBox[3]; - } - - // TODO if viewbox is not same as width/height, then use it to scale - // the original objects. for now, viewbox only used when width/height - // are empty values (which by the spec means w/h of "100%" - var unitWidth = this.element.getStringAttribute("width"); - var unitHeight = this.element.getStringAttribute("height"); - if (unitWidth !== null) { - this.width = this.parseUnitSize(unitWidth); - this.height = this.parseUnitSize(unitHeight); - } else { - if ((this.width === 0) || (this.height === 0)) { - // For the spec, the default is 100% and 100%. For purposes - // here, insert a dummy value because this is prolly just a - // font or something for which the w/h doesn't matter. - this.width = 1; - this.height = 1; - - //show warning - throw("The width and/or height is not " + - "readable in the tag of this file."); - } - } - this.parseColors(this.element); - this.parseChildren(this.element); - - }; - /** - * PShapeSVG methods - * missing: getChild(), print(), parseStyleAttributes(), styles() - deals with strokeGradient and fillGradient - */ - PShapeSVG.prototype = { - /** - * @member PShapeSVG - * The parseMatrix() function parses the specified SVG matrix into a PMatrix2D. Note that PMatrix2D - * is rotated relative to the SVG definition, so parameters are rearranged - * here. More about the transformation matrices in - * this section - * of the SVG documentation. - * - * @param {String} str text of the matrix param. - * - * @return {PMatrix2D} a PMatrix2D - */ - parseMatrix: function(str) { - this.checkMatrix(2); - var pieces = []; - str.replace(/\s*(\w+)\((.*?)\)/g, function(all) { - // get a list of transform definitions - pieces.push(p.trim(all)); - }); - if (pieces.length === 0) { - p.println("Transformation:" + str + " is empty"); - return null; - } - for (var i =0; i< pieces.length; i++) { - var m = []; - pieces[i].replace(/\((.*?)\)/, (function() { - return function(all, params) { - // get the coordinates that can be separated by spaces or a comma - m = params.replace(/,+/g, " ").split(/\s+/); - }; - }())); - - if (pieces[i].indexOf("matrix") !== -1) { - this.matrix.set(m[0], m[2], m[4], m[1], m[3], m[5]); - } else if (pieces[i].indexOf("translate") !== -1) { - var tx = m[0]; - var ty = (m.length === 2) ? m[1] : 0; - this.matrix.translate(tx,ty); - } else if (pieces[i].indexOf("scale") !== -1) { - var sx = m[0]; - var sy = (m.length === 2) ? m[1] : m[0]; - this.matrix.scale(sx,sy); - } else if (pieces[i].indexOf("rotate") !== -1) { - var angle = m[0]; - if (m.length === 1) { - this.matrix.rotate(p.radians(angle)); - } else if (m.length === 3) { - this.matrix.translate(m[1], m[2]); - this.matrix.rotate(p.radians(m[0])); - this.matrix.translate(-m[1], -m[2]); - } - } else if (pieces[i].indexOf("skewX") !== -1) { - this.matrix.skewX(parseFloat(m[0])); - } else if (pieces[i].indexOf("skewY") !== -1) { - this.matrix.skewY(m[0]); - } - } - return this.matrix; - }, - /** - * @member PShapeSVG - * The parseChildren() function parses the specified XMLElement - * - * @param {XMLElement}element the XMLElement to parse - */ - parseChildren:function(element) { - var newelement = element.getChildren(); - var children = new p.PShape(); - for (var i = 0; i < newelement.length; i++) { - var kid = this.parseChild(newelement[i]); - if (kid) { - children.addChild(kid); - } - } - this.children.push(children); - }, - /** - * @member PShapeSVG - * The getName() function returns the name - * - * @return {String} the name - */ - getName: function() { - return this.name; - }, - /** - * @member PShapeSVG - * The parseChild() function parses a child XML element. - * - * @param {XMLElement} elem the element to parse - * - * @return {PShape} the newly created PShape - */ - parseChild: function( elem ) { - var name = elem.getName(); - var shape; - switch (name) { - case "g": - shape = new PShapeSVG(this, elem); - break; - case "defs": - // generally this will contain gradient info, so may - // as well just throw it into a group element for parsing - shape = new PShapeSVG(this, elem); - break; - case "line": - shape = new PShapeSVG(this, elem); - shape.parseLine(); - break; - case "circle": - shape = new PShapeSVG(this, elem); - shape.parseEllipse(true); - break; - case "ellipse": - shape = new PShapeSVG(this, elem); - shape.parseEllipse(false); - break; - case "rect": - shape = new PShapeSVG(this, elem); - shape.parseRect(); - break; - case "polygon": - shape = new PShapeSVG(this, elem); - shape.parsePoly(true); - break; - case "polyline": - shape = new PShapeSVG(this, elem); - shape.parsePoly(false); - break; - case "path": - shape = new PShapeSVG(this, elem); - shape.parsePath(); - break; - case "radialGradient": - //return new RadialGradient(this, elem); - break; - case "linearGradient": - //return new LinearGradient(this, elem); - break; - case "text": - p.println("Text in SVG files is not currently supported, convert text to outlines instead." ); - break; - case "filter": - p.println("Filters are not supported."); - break; - case "mask": - p.println("Masks are not supported."); - break; - default: - p.println("Ignoring <" + name + "> tag."); - break; - } - return shape; - }, - /** - * @member PShapeSVG - * The parsePath() function parses the element of the svg file - * A path is defined by including a path element which contains a d="(path data)" attribute, where the d attribute contains - * the moveto, line, curve (both cubic and quadratic Beziers), arc and closepath instructions. - **/ - parsePath: function() { - this.family = PConstants.PATH; - this.kind = 0; - var pathDataChars = []; - var c; - var pathData = p.trim(this.element.getStringAttribute("d").replace(/[\s,]+/g,' ')); //change multiple spaces and commas to single space - if (pathData === null) { return; } - pathData = pathData.toCharArray(); - var cx = 0, - cy = 0, - ctrlX = 0, - ctrlY = 0, - ctrlX1 = 0, - ctrlX2 = 0, - ctrlY1 = 0, - ctrlY2 = 0, - endX = 0, - endY = 0, - ppx = 0, - ppy = 0, - px = 0, - py = 0, - i = 0, - j = 0, - valOf = 0; - var str = ""; - var tmpArray =[]; - var flag = false; - var lastInstruction; - var command; - while (i< pathData.length) { - valOf = pathData[i].valueOf(); - if ((valOf >= 65 && valOf <= 90) || (valOf >= 97 && valOf <= 122)) { // if its a letter - // populate the tmpArray with coordinates - j = i; - i++; - if (i < pathData.length) { // dont go over boundary of array - tmpArray = []; - valOf = pathData[i].valueOf(); - while (!((valOf >= 65 && valOf <= 90) || (valOf >= 97 && valOf <= 100) || (valOf >= 102 && valOf <= 122)) && flag === false) { // if its NOT a letter - if (valOf === 32) { //if its a space and the str isn't empty - // somethimes you get a space after the letter - if (str !== "") { - tmpArray.push(parseFloat(str)); - str = ""; - } - i++; - } else if (valOf === 45) { //if its a - - // allow for 'e' notation in numbers, e.g. 2.10e-9 - if (pathData[i-1].valueOf() === 101) { - str += pathData[i].toString(); - i++; - } else { - // sometimes no space separator after (ex: 104.535-16.322) - if (str !== "") { - tmpArray.push(parseFloat(str)); - } - str = pathData[i].toString(); - i++; - } - } else { - str += pathData[i].toString(); - i++; - } - if (i === pathData.length) { // dont go over boundary of array - flag = true; - } else { - valOf = pathData[i].valueOf(); - } - } - } - if (str !== "") { - tmpArray.push(parseFloat(str)); - str = ""; - } - command = pathData[j]; - switch (command.valueOf()) { - case 77: // M - move to (absolute) - if (tmpArray.length >= 2 && tmpArray.length % 2 ===0) { // need one+ pairs of co-ordinates - cx = tmpArray[0]; - cy = tmpArray[1]; - this.parsePathMoveto(cx, cy); - if (tmpArray.length > 2) { - for (j = 2; j < tmpArray.length; j+=2) { - // absolute line to - cx = tmpArray[j]; - cy = tmpArray[j+1]; - this.parsePathLineto(cx,cy); - } - } - } - break; - case 109: // m - move to (relative) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - cx += tmpArray[0]; - cy += tmpArray[1]; - this.parsePathMoveto(cx,cy); - if (tmpArray.length > 2) { - for (j = 2; j < tmpArray.length; j+=2) { - // relative line to - cx += tmpArray[j]; - cy += tmpArray[j + 1]; - this.parsePathLineto(cx,cy); - } - } - } - break; - case 76: // L - lineto (absolute) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - cx = tmpArray[j]; - cy = tmpArray[j + 1]; - this.parsePathLineto(cx,cy); - } - } - break; - - case 108: // l - lineto (relative) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - cx += tmpArray[j]; - cy += tmpArray[j+1]; - this.parsePathLineto(cx,cy); - } - } - break; - - case 72: // H - horizontal lineto (absolute) - for (j = 0; j < tmpArray.length; j++) { // multiple x co-ordinates can be provided - cx = tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 104: // h - horizontal lineto (relative) - for (j = 0; j < tmpArray.length; j++) { // multiple x co-ordinates can be provided - cx += tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 86: // V - vertical lineto (absolute) - for (j = 0; j < tmpArray.length; j++) { // multiple y co-ordinates can be provided - cy = tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 118: // v - vertical lineto (relative) - for (j = 0; j < tmpArray.length; j++) { // multiple y co-ordinates can be provided - cy += tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 67: // C - curve to (absolute) - if (tmpArray.length >= 6 && tmpArray.length % 6 === 0) { // need one+ multiples of 6 co-ordinates - for (j = 0; j < tmpArray.length; j+=6) { - ctrlX1 = tmpArray[j]; - ctrlY1 = tmpArray[j + 1]; - ctrlX2 = tmpArray[j + 2]; - ctrlY2 = tmpArray[j + 3]; - endX = tmpArray[j + 4]; - endY = tmpArray[j + 5]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 99: // c - curve to (relative) - if (tmpArray.length >= 6 && tmpArray.length % 6 === 0) { // need one+ multiples of 6 co-ordinates - for (j = 0; j < tmpArray.length; j+=6) { - ctrlX1 = cx + tmpArray[j]; - ctrlY1 = cy + tmpArray[j + 1]; - ctrlX2 = cx + tmpArray[j + 2]; - ctrlY2 = cy + tmpArray[j + 3]; - endX = cx + tmpArray[j + 4]; - endY = cy + tmpArray[j + 5]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 83: // S - curve to shorthand (absolute) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - if (lastInstruction.toLowerCase() === "c" || lastInstruction.toLowerCase() === "s") { - ppx = this.vertices[ this.vertices.length-2 ][0]; - ppy = this.vertices[ this.vertices.length-2 ][1]; - px = this.vertices[ this.vertices.length-1 ][0]; - py = this.vertices[ this.vertices.length-1 ][1]; - ctrlX1 = px + (px - ppx); - ctrlY1 = py + (py - ppy); - } else { - //If there is no previous curve, the current point will be used as the first control point. - ctrlX1 = this.vertices[this.vertices.length-1][0]; - ctrlY1 = this.vertices[this.vertices.length-1][1]; - } - ctrlX2 = tmpArray[j]; - ctrlY2 = tmpArray[j + 1]; - endX = tmpArray[j + 2]; - endY = tmpArray[j + 3]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 115: // s - curve to shorthand (relative) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - if (lastInstruction.toLowerCase() === "c" || lastInstruction.toLowerCase() === "s") { - ppx = this.vertices[this.vertices.length-2][0]; - ppy = this.vertices[this.vertices.length-2][1]; - px = this.vertices[this.vertices.length-1][0]; - py = this.vertices[this.vertices.length-1][1]; - ctrlX1 = px + (px - ppx); - ctrlY1 = py + (py - ppy); - } else { - //If there is no previous curve, the current point will be used as the first control point. - ctrlX1 = this.vertices[this.vertices.length-1][0]; - ctrlY1 = this.vertices[this.vertices.length-1][1]; - } - ctrlX2 = cx + tmpArray[j]; - ctrlY2 = cy + tmpArray[j + 1]; - endX = cx + tmpArray[j + 2]; - endY = cy + tmpArray[j + 3]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 81: // Q - quadratic curve to (absolute) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - ctrlX = tmpArray[j]; - ctrlY = tmpArray[j + 1]; - endX = tmpArray[j + 2]; - endY = tmpArray[j + 3]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 113: // q - quadratic curve to (relative) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - ctrlX = cx + tmpArray[j]; - ctrlY = cy + tmpArray[j + 1]; - endX = cx + tmpArray[j + 2]; - endY = cy + tmpArray[j + 3]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 84: // T - quadratic curve to shorthand (absolute) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - if (lastInstruction.toLowerCase() === "q" || lastInstruction.toLowerCase() === "t") { - ppx = this.vertices[this.vertices.length-2][0]; - ppy = this.vertices[this.vertices.length-2][1]; - px = this.vertices[this.vertices.length-1][0]; - py = this.vertices[this.vertices.length-1][1]; - ctrlX = px + (px - ppx); - ctrlY = py + (py - ppy); - } else { - // If there is no previous command or if the previous command was not a Q, q, T or t, - // assume the control point is coincident with the current point. - ctrlX = cx; - ctrlY = cy; - } - endX = tmpArray[j]; - endY = tmpArray[j + 1]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 116: // t - quadratic curve to shorthand (relative) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - if (lastInstruction.toLowerCase() === "q" || lastInstruction.toLowerCase() === "t") { - ppx = this.vertices[this.vertices.length-2][0]; - ppy = this.vertices[this.vertices.length-2][1]; - px = this.vertices[this.vertices.length-1][0]; - py = this.vertices[this.vertices.length-1][1]; - ctrlX = px + (px - ppx); - ctrlY = py + (py - ppy); - } else { - // If there is no previous command or if the previous command was not a Q, q, T or t, - // assume the control point is coincident with the current point. - ctrlX = cx; - ctrlY = cy; - } - endX = cx + tmpArray[j]; - endY = cy + tmpArray[j + 1]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 90: //Z - case 122: //z - this.close = true; - break; - } - lastInstruction = command.toString(); - } else { i++;} - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathQuadto: function(x1, y1, cx, cy, x2, y2) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.BEZIER_VERTEX); - // x1/y1 already covered by last moveto, lineto, or curveto - this.parsePathVertex(x1 + ((cx-x1)*2/3), y1 + ((cy-y1)*2/3)); - this.parsePathVertex(x2 + ((cx-x2)*2/3), y2 + ((cy-y2)*2/3)); - this.parsePathVertex(x2, y2); - } else { - throw ("Path must start with M/m"); - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathCurveto : function(x1, y1, x2, y2, x3, y3) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.BEZIER_VERTEX ); - this.parsePathVertex(x1, y1); - this.parsePathVertex(x2, y2); - this.parsePathVertex(x3, y3); - } else { - throw ("Path must start with M/m"); - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathLineto: function(px, py) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.VERTEX); - this.parsePathVertex(px, py); - // add property to distinguish between curContext.moveTo or curContext.lineTo - this.vertices[this.vertices.length-1]["moveTo"] = false; - } else { - throw ("Path must start with M/m"); - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathMoveto: function(px, py) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.BREAK); - } - this.parsePathCode(PConstants.VERTEX); - this.parsePathVertex(px, py); - // add property to distinguish between curContext.moveTo or curContext.lineTo - this.vertices[this.vertices.length-1]["moveTo"] = true; - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathVertex: function(x, y) { - var verts = []; - verts[0] = x; - verts[1] = y; - this.vertices.push(verts); - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathCode: function(what) { - this.vertexCodes.push(what); - }, - /** - * @member PShapeSVG - * The parsePoly() function parses a polyline or polygon from an SVG file. - * - * @param {boolean}val true if shape is closed (polygon), false if not (polyline) - */ - parsePoly: function(val) { - this.family = PConstants.PATH; - this.close = val; - var pointsAttr = p.trim(this.element.getStringAttribute("points").replace(/[,\s]+/g,' ')); - if (pointsAttr !== null) { - //split into array - var pointsBuffer = pointsAttr.split(" "); - if (pointsBuffer.length % 2 === 0) { - for (var i = 0; i < pointsBuffer.length; i++) { - var verts = []; - verts[0] = pointsBuffer[i]; - verts[1] = pointsBuffer[++i]; - this.vertices.push(verts); - } - } else { - p.println("Error parsing polygon points: odd number of coordinates provided"); - } - } - }, - /** - * @member PShapeSVG - * The parseRect() function parses a rect from an SVG file. - */ - parseRect: function() { - this.kind = PConstants.RECT; - this.family = PConstants.PRIMITIVE; - this.params = []; - this.params[0] = this.element.getFloatAttribute("x"); - this.params[1] = this.element.getFloatAttribute("y"); - this.params[2] = this.element.getFloatAttribute("width"); - this.params[3] = this.element.getFloatAttribute("height"); - if (this.params[2] < 0 || this.params[3] < 0) { - throw("svg error: negative width or height found while parsing "); - } - - }, - /** - * @member PShapeSVG - * The parseEllipse() function handles parsing ellipse and circle tags. - * - * @param {boolean}val true if this is a circle and not an ellipse - */ - parseEllipse: function(val) { - this.kind = PConstants.ELLIPSE; - this.family = PConstants.PRIMITIVE; - this.params = []; - - this.params[0] = this.element.getFloatAttribute("cx") | 0; - this.params[1] = this.element.getFloatAttribute("cy") | 0; - - var rx, ry; - if (val) { //this is a circle - rx = ry = this.element.getFloatAttribute("r"); - if (rx < 0) { - throw("svg error: negative radius found while parsing "); - } - } else { - rx = this.element.getFloatAttribute("rx"); - ry = this.element.getFloatAttribute("ry"); - if (rx < 0 || ry < 0) { - throw("svg error: negative x-axis radius or y-axis radius found while parsing "); - } - } - this.params[0] -= rx; - this.params[1] -= ry; - - this.params[2] = rx*2; - this.params[3] = ry*2; - }, - /** - * @member PShapeSVG - * The parseLine() function handles parsing line tags. - * - * @param {boolean}val true if this is a circle and not an ellipse - */ - parseLine: function() { - this.kind = PConstants.LINE; - this.family = PConstants.PRIMITIVE; - this.params = []; - this.params[0] = this.element.getFloatAttribute("x1"); - this.params[1] = this.element.getFloatAttribute("y1"); - this.params[2] = this.element.getFloatAttribute("x2"); - this.params[3] = this.element.getFloatAttribute("y2"); - }, - /** - * @member PShapeSVG - * The parseColors() function handles parsing the opacity, strijem stroke-width, stroke-linejoin,stroke-linecap, fill, and style attributes - * - * @param {XMLElement}element the element of which attributes to parse - */ - parseColors: function(element) { - if (element.hasAttribute("opacity")) { - this.setOpacity(element.getAttribute("opacity")); - } - if (element.hasAttribute("stroke")) { - this.setStroke(element.getAttribute("stroke")); - } - if (element.hasAttribute("stroke-width")) { - // if NaN (i.e. if it's 'inherit') then default back to the inherit setting - this.setStrokeWeight(element.getAttribute("stroke-width")); - } - if (element.hasAttribute("stroke-linejoin") ) { - this.setStrokeJoin(element.getAttribute("stroke-linejoin")); - } - if (element.hasAttribute("stroke-linecap")) { - this.setStrokeCap(element.getStringAttribute("stroke-linecap")); - } - // fill defaults to black (though stroke defaults to "none") - // http://www.w3.org/TR/SVG/painting.html#FillProperties - if (element.hasAttribute("fill")) { - this.setFill(element.getStringAttribute("fill")); - } - if (element.hasAttribute("style")) { - var styleText = element.getStringAttribute("style"); - var styleTokens = styleText.toString().split( ";" ); - - for (var i = 0; i < styleTokens.length; i++) { - var tokens = p.trim(styleTokens[i].split( ":" )); - switch(tokens[0]){ - case "fill": - this.setFill(tokens[1]); - break; - case "fill-opacity": - this.setFillOpacity(tokens[1]); - break; - case "stroke": - this.setStroke(tokens[1]); - break; - case "stroke-width": - this.setStrokeWeight(tokens[1]); - break; - case "stroke-linecap": - this.setStrokeCap(tokens[1]); - break; - case "stroke-linejoin": - this.setStrokeJoin(tokens[1]); - break; - case "stroke-opacity": - this.setStrokeOpacity(tokens[1]); - break; - case "opacity": - this.setOpacity(tokens[1]); - break; - // Other attributes are not yet implemented - } - } - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} opacityText the value of fillOpacity - * - * @see PShapeSVG#parseColors - */ - setFillOpacity: function(opacityText) { - this.fillOpacity = parseFloat(opacityText); - this.fillColor = this.fillOpacity * 255 << 24 | this.fillColor & 0xFFFFFF; - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} fillText the value of fill - * - * @see PShapeSVG#parseColors - */ - setFill: function (fillText) { - var opacityMask = this.fillColor & 0xFF000000; - if (fillText === "none") { - this.fill = false; - } else if (fillText.indexOf("#") === 0) { - this.fill = true; - if (fillText.length === 4) { - // convert #00F to #0000FF - fillText = fillText.replace(/#(.)(.)(.)/,"#$1$1$2$2$3$3"); - } - this.fillColor = opacityMask | (parseInt(fillText.substring(1), 16)) & 0xFFFFFF; - } else if (fillText.indexOf("rgb") === 0) { - this.fill = true; - this.fillColor = opacityMask | this.parseRGB(fillText); - } else if (fillText.indexOf("url(#") === 0) { - this.fillName = fillText.substring(5, fillText.length - 1 ); - /*Object fillObject = findChild(fillName); - if (fillObject instanceof Gradient) { - fill = true; - fillGradient = (Gradient) fillObject; - fillGradientPaint = calcGradientPaint(fillGradient); //, opacity); - } else { - System.err.println("url " + fillName + " refers to unexpected data"); - }*/ - } else { - if (colors[fillText]) { - this.fill = true; - this.fillColor = opacityMask | (parseInt(colors[fillText].substring(1), 16)) & 0xFFFFFF; - } - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} opacity the value of opacity - * - * @see PShapeSVG#parseColors - */ - setOpacity: function(opacity) { - this.strokeColor = parseFloat(opacity) * 255 << 24 | this.strokeColor & 0xFFFFFF; - this.fillColor = parseFloat(opacity) * 255 << 24 | this.fillColor & 0xFFFFFF; - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} strokeText the value to set stroke to - * - * @see PShapeSVG#parseColors - */ - setStroke: function(strokeText) { - var opacityMask = this.strokeColor & 0xFF000000; - if (strokeText === "none") { - this.stroke = false; - } else if (strokeText.charAt( 0 ) === "#") { - this.stroke = true; - if (strokeText.length === 4) { - // convert #00F to #0000FF - strokeText = strokeText.replace(/#(.)(.)(.)/,"#$1$1$2$2$3$3"); - } - this.strokeColor = opacityMask | (parseInt( strokeText.substring(1), 16)) & 0xFFFFFF; - } else if (strokeText.indexOf( "rgb" ) === 0 ) { - this.stroke = true; - this.strokeColor = opacityMask | this.parseRGB(strokeText); - } else if (strokeText.indexOf( "url(#" ) === 0) { - this.strokeName = strokeText.substring(5, strokeText.length - 1); - //this.strokeObject = findChild(strokeName); - /*if (strokeObject instanceof Gradient) { - strokeGradient = (Gradient) strokeObject; - strokeGradientPaint = calcGradientPaint(strokeGradient); //, opacity); - } else { - System.err.println("url " + strokeName + " refers to unexpected data"); - }*/ - } else { - if (colors[strokeText]){ - this.stroke = true; - this.strokeColor = opacityMask | (parseInt(colors[strokeText].substring(1), 16)) & 0xFFFFFF; - } - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} weight the value to set strokeWeight to - * - * @see PShapeSVG#parseColors - */ - setStrokeWeight: function(weight) { - this.strokeWeight = this.parseUnitSize(weight); - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} linejoin the value to set strokeJoin to - * - * @see PShapeSVG#parseColors - */ - setStrokeJoin: function(linejoin) { - if (linejoin === "miter") { - this.strokeJoin = PConstants.MITER; - - } else if (linejoin === "round") { - this.strokeJoin = PConstants.ROUND; - - } else if (linejoin === "bevel") { - this.strokeJoin = PConstants.BEVEL; - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} linecap the value to set strokeCap to - * - * @see PShapeSVG#parseColors - */ - setStrokeCap: function (linecap) { - if (linecap === "butt") { - this.strokeCap = PConstants.SQUARE; - - } else if (linecap === "round") { - this.strokeCap = PConstants.ROUND; - - } else if (linecap === "square") { - this.strokeCap = PConstants.PROJECT; - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} opacityText the value to set stroke opacity to - * - * @see PShapeSVG#parseColors - */ - setStrokeOpacity: function (opacityText) { - this.strokeOpacity = parseFloat(opacityText); - this.strokeColor = this.strokeOpacity * 255 << 24 | this.strokeColor & 0xFFFFFF; - }, - /** - * @member PShapeSVG - * The parseRGB() function parses an rbg() color string and returns a color int - * - * @param {String} color the color to parse in rbg() format - * - * @return {int} the equivalent color int - */ - parseRGB: function(color) { - var sub = color.substring(color.indexOf('(') + 1, color.indexOf(')')); - var values = sub.split(", "); - return (values[0] << 16) | (values[1] << 8) | (values[2]); - }, - /** - * @member PShapeSVG - * The parseUnitSize() function parse a size that may have a suffix for its units. - * Ignoring cases where this could also be a percentage. - * The units spec: - *
            - *
          • "1pt" equals "1.25px" (and therefore 1.25 user units) - *
          • "1pc" equals "15px" (and therefore 15 user units) - *
          • "1mm" would be "3.543307px" (3.543307 user units) - *
          • "1cm" equals "35.43307px" (and therefore 35.43307 user units) - *
          • "1in" equals "90px" (and therefore 90 user units) - *
          - */ - parseUnitSize: function (text) { - var len = text.length - 2; - if (len < 0) { return text; } - if (text.indexOf("pt") === len) { - return parseFloat(text.substring(0, len)) * 1.25; - } else if (text.indexOf("pc") === len) { - return parseFloat( text.substring( 0, len)) * 15; - } else if (text.indexOf("mm") === len) { - return parseFloat( text.substring(0, len)) * 3.543307; - } else if (text.indexOf("cm") === len) { - return parseFloat(text.substring(0, len)) * 35.43307; - } else if (text.indexOf("in") === len) { - return parseFloat(text.substring(0, len)) * 90; - } else if (text.indexOf("px") === len) { - return parseFloat(text.substring(0, len)); - } else { - return parseFloat(text); - } - } - }; - /** - * The shape() function displays shapes to the screen. - * Processing currently works with SVG shapes only. - * The shape parameter specifies the shape to display and the x - * and y parameters define the location of the shape from its - * upper-left corner. - * The shape is displayed at its original size unless the width - * and height parameters specify a different size. - * The shapeMode() function changes the way the parameters work. - * A call to shapeMode(CORNERS), for example, will change the width - * and height parameters to define the x and y values of the opposite corner - * of the shape. - *

          - * Note complex shapes may draw awkwardly with P2D, P3D, and OPENGL. Those - * renderers do not yet support shapes that have holes or complicated breaks. - * - * @param {PShape} shape the shape to display - * @param {int|float} x x-coordinate of the shape - * @param {int|float} y y-coordinate of the shape - * @param {int|float} width width to display the shape - * @param {int|float} height height to display the shape - * - * @see PShape - * @see loadShape() - * @see shapeMode() - */ - p.shape = function(shape, x, y, width, height) { - if (arguments.length >= 1 && arguments[0] !== null) { - if (shape.isVisible()) { - p.pushMatrix(); - if (curShapeMode === PConstants.CENTER) { - if (arguments.length === 5) { - p.translate(x - width/2, y - height/2); - p.scale(width / shape.getWidth(), height / shape.getHeight()); - } else if (arguments.length === 3) { - p.translate(x - shape.getWidth()/2, - shape.getHeight()/2); - } else { - p.translate(-shape.getWidth()/2, -shape.getHeight()/2); - } - } else if (curShapeMode === PConstants.CORNER) { - if (arguments.length === 5) { - p.translate(x, y); - p.scale(width / shape.getWidth(), height / shape.getHeight()); - } else if (arguments.length === 3) { - p.translate(x, y); - } - } else if (curShapeMode === PConstants.CORNERS) { - if (arguments.length === 5) { - width -= x; - height -= y; - p.translate(x, y); - p.scale(width / shape.getWidth(), height / shape.getHeight()); - } else if (arguments.length === 3) { - p.translate(x, y); - } - } - shape.draw(); - if ((arguments.length === 1 && curShapeMode === PConstants.CENTER ) || arguments.length > 1) { - p.popMatrix(); - } - } - } - }; - - /** - * The shapeMode() function modifies the location from which shapes draw. - * The default mode is shapeMode(CORNER), which specifies the - * location to be the upper left corner of the shape and uses the third - * and fourth parameters of shape() to specify the width and height. - * The syntax shapeMode(CORNERS) uses the first and second parameters - * of shape() to set the location of one corner and uses the third - * and fourth parameters to set the opposite corner. - * The syntax shapeMode(CENTER) draws the shape from its center point - * and uses the third and forth parameters of shape() to specify the - * width and height. - * The parameter must be written in "ALL CAPS" because Processing syntax - * is case sensitive. - * - * @param {int} mode One of CORNER, CORNERS, CENTER - * - * @see shape() - * @see rectMode() - */ - p.shapeMode = function (mode) { - curShapeMode = mode; - }; - - /** - * The loadShape() function loads vector shapes into a variable of type PShape. Currently, only SVG files may be loaded. - * In most cases, loadShape() should be used inside setup() because loading shapes inside draw() will reduce the speed of a sketch. - * - * @param {String} filename an SVG file - * - * @return {PShape} a object of type PShape or null - * @see PShape - * @see PApplet#shape() - * @see PApplet#shapeMode() - */ - p.loadShape = function (filename) { - if (arguments.length === 1) { - if (filename.indexOf(".svg") > -1) { - return new PShapeSVG(null, filename); - } - } - return null; - }; - - /** - * XMLAttribute is an attribute of a XML element. This is an internal class - * - * @param {String} fname the full name of the attribute - * @param {String} n the short name of the attribute - * @param {String} namespace the namespace URI of the attribute - * @param {String} v the value of the attribute - * @param {String }t the type of the attribute - * - * @see XMLElement - */ - var XMLAttribute = function(fname, n, nameSpace, v, t){ - this.fullName = fname || ""; - this.name = n || ""; - this.namespace = nameSpace || ""; - this.value = v; - this.type = t; - }; - /** - * XMLAttribute methods - */ - XMLAttribute.prototype = { - /** - * @member XMLAttribute - * The getName() function returns the short name of the attribute - * - * @return {String} the short name of the attribute - */ - getName: function() { - return this.name; - }, - /** - * @member XMLAttribute - * The getFullName() function returns the full name of the attribute - * - * @return {String} the full name of the attribute - */ - getFullName: function() { - return this.fullName; - }, - /** - * @member XMLAttribute - * The getNamespace() function returns the namespace of the attribute - * - * @return {String} the namespace of the attribute - */ - getNamespace: function() { - return this.namespace; - }, - /** - * @member XMLAttribute - * The getValue() function returns the value of the attribute - * - * @return {String} the value of the attribute - */ - getValue: function() { - return this.value; - }, - /** - * @member XMLAttribute - * The getValue() function returns the type of the attribute - * - * @return {String} the type of the attribute - */ - getType: function() { - return this.type; - }, - /** - * @member XMLAttribute - * The setValue() function sets the value of the attribute - * - * @param {String} newval the new value - */ - setValue: function(newval) { - this.value = newval; - } - }; - - /** - * XMLElement is a representation of an XML object. The object is able to parse XML code - * - * @param {PApplet} parent typically use "this" - * @param {String} filename name of the XML/SVG file to load - * @param {String} xml the xml/svg string - * @param {String} fullname the full name of the element - * @param {String} namespace the namespace of the URI - * @param {String} systemID the system ID of the XML data where the element starts - * @param {Integer }lineNr the line in the XML data where the element starts - */ - var XMLElement = p.XMLElement = function() { - if (arguments.length === 4) { - this.attributes = []; - this.children = []; - this.fullName = arguments[0] || ""; - if (arguments[1]) { - this.name = arguments[1]; - } else { - var index = this.fullName.indexOf(':'); - if (index >= 0) { - this.name = this.fullName.substring(index + 1); - } else { - this.name = this.fullName; - } - } - this.namespace = arguments[1]; - this.content = ""; - this.lineNr = arguments[3]; - this.systemID = arguments[2]; - this.parent = null; - } - else if ((arguments.length === 2 && arguments[1].indexOf(".") > -1) ) { // filename or svg xml element - this.attributes = []; - this.children = []; - this.fullName = ""; - this.name = ""; - this.namespace = ""; - this.content = ""; - this.systemID = ""; - this.lineNr = ""; - this.parent = null; - this.parse(arguments[arguments.length -1]); - } else if (arguments.length === 1 && typeof arguments[0] === "string"){ - //xml string - this.attributes = []; - this.children = []; - this.fullName = ""; - this.name = ""; - this.namespace = ""; - this.content = ""; - this.systemID = ""; - this.lineNr = ""; - this.parent = null; - this.parse(arguments[0]); - } - else { //empty ctor - this.attributes = []; - this.children = []; - this.fullName = ""; - this.name = ""; - this.namespace = ""; - this.content = ""; - this.systemID = ""; - this.lineNr = ""; - this.parent = null; - - } - return this; - }; - /** - * XMLElement methods - * missing: enumerateAttributeNames(), enumerateChildren(), - * NOTE: parse does not work when a url is passed in - */ - XMLElement.prototype = { - /** - * @member XMLElement - * The parse() function retrieves the file via ajax() and uses DOMParser() parseFromString method to make an XML document - * @addon - * - * @param {String} filename name of the XML/SVG file to load - * - * @throws ExceptionType Error loading document - * - * @see XMLElement#parseChildrenRecursive - */ - parse: function(filename) { - var xmlDoc; - try { - if (filename.indexOf(".xml") > -1 || filename.indexOf(".svg") > -1) { - filename = ajax(filename); - } - xmlDoc = new DOMParser().parseFromString(filename, "text/xml"); - var elements = xmlDoc.documentElement; - if (elements) { - this.parseChildrenRecursive(null, elements); - } else { - throw ("Error loading document"); - } - return this; - } catch(e) { - throw(e); - } - }, - /** - * @member XMLElement - * The createElement() function Creates an empty element - * - * @param {String} fullName the full name of the element - * @param {String} namespace the namespace URI - * @param {String} systemID the system ID of the XML data where the element starts - * @param {int} lineNr the line in the XML data where the element starts - */ - createElement: function () { - if (arguments.length === 2) { - return new XMLElement(arguments[0], arguments[1], null, null); - } else { - return new XMLElement(arguments[0], arguments[1], arguments[2], arguments[3]); - } - }, - /** - * @member XMLElement - * The hasAttribute() function returns whether an attribute exists - * - * @param {String} name name of the attribute - * @param {String} namespace the namespace URI of the attribute - * - * @return {boolean} true if the attribute exists - */ - hasAttribute: function () { - if (arguments.length === 1) { - return this.getAttribute(arguments[0]) !== null; - } else if (arguments.length === 2) { - return this.getAttribute(arguments[0],arguments[1]) !== null; - } - }, - /** - * @member XMLElement - * The createPCDataElement() function creates an element to be used for #PCDATA content - * - * @return {XMLElement} new XMLElement element - */ - createPCDataElement: function () { - return new XMLElement(); - }, - /** - * @member XMLElement - * The equals() function checks to see if the element being passed in equals another element - * - * @param {Object} rawElement the element to compare to - * - * @return {boolean} true if the element equals another element - */ - equals: function(object){ - if (typeof object === "Object") { - return this.equalsXMLElement(object); - } - }, - /** - * @member XMLElement - * The equalsXMLElement() function checks to see if the XMLElement being passed in equals another XMLElement - * - * @param {XMLElement} rawElement the element to compare to - * - * @return {boolean} true if the element equals another element - */ - equalsXMLElement: function (object) { - if (object instanceof XMLElement) { - if (this.name !== object.getLocalName()) { return false; } - if (this.attributes.length !== object.getAttributeCount()) { return false; } - for (var i = 0; i < this.attributes.length; i++){ - if (! object.hasAttribute(this.attributes[i].getName(), this.attributes[i].getNamespace())) { return false; } - if (this.attributes[i].getValue() !== object.attributes[i].getValue()) { return false; } - if (this.attributes[i].getType() !== object.attributes[i].getType()) { return false; } - } - if (this.children.length !== object.getChildCount()) { return false; } - var child1, child2; - for (i = 0; i < this.children.length; i++) { - child1 = this.getChildAtIndex(i); - child2 = object.getChildAtIndex(i); - if (! child1.equalsXMLElement(child2)) { return false; } - } - return true; - } - }, - /** - * @member XMLElement - * The getContent() function returns the content of an element. If there is no such content, null is returned - * - * @return {String} the (possibly null) content - */ - getContent: function(){ - return this.content; - }, - /** - * @member XMLElement - * The getAttribute() function returns the value of an attribute - * - * @param {String} name the non-null full name of the attribute - * @param {String} namespace the namespace URI, which may be null - * @param {String} defaultValue the default value of the attribute - * - * @return {String} the value, or defaultValue if the attribute does not exist - */ - getAttribute: function (){ - var attribute; - if( arguments.length === 2 ){ - attribute = this.findAttribute(arguments[0]); - if (attribute) { - return attribute.getValue(); - } else { - return arguments[1]; - } - } else if (arguments.length === 1) { - attribute = this.findAttribute(arguments[0]); - if (attribute) { - return attribute.getValue(); - } else { - return null; - } - } else if (arguments.length === 3) { - attribute = this.findAttribute(arguments[0],arguments[1]); - if (attribute) { - return attribute.getValue(); - } else { - return arguments[2]; - } - } - }, - /** - * @member XMLElement - * The getStringAttribute() function returns the string attribute of the element - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue value is returned. - * When calling the function without the defaultValue parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return {String} the value, or defaultValue if the attribute does not exist - */ - getStringAttribute: function() { - if (arguments.length === 1) { - return this.getAttribute(arguments[0]); - } else if (arguments.length === 2){ - return this.getAttribute(arguments[0], arguments[1]); - } else { - return this.getAttribute(arguments[0], arguments[1],arguments[2]); - } - }, - /** - * @member XMLElement - * The getFloatAttribute() function returns the float attribute of the element. - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue value is returned. - * When calling the function without the defaultValue parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return {float} the value, or defaultValue if the attribute does not exist - */ - getFloatAttribute: function() { - if (arguments.length === 1 ) { - return parseFloat(this.getAttribute(arguments[0], 0)); - } else if (arguments.length === 2 ){ - return this.getAttribute(arguments[0], arguments[1]); - } else { - return this.getAttribute(arguments[0], arguments[1],arguments[2]); - } - }, - /** - * @member XMLElement - * The getIntAttribute() function returns the integer attribute of the element. - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue value is returned. - * When calling the function without the defaultValue parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return {int} the value, or defaultValue if the attribute does not exist - */ - getIntAttribute: function () { - if (arguments.length === 1) { - return this.getAttribute( arguments[0], 0 ); - } else if (arguments.length === 2) { - return this.getAttribute(arguments[0], arguments[1]); - } else { - return this.getAttribute(arguments[0], arguments[1],arguments[2]); - } - }, - /** - * @member XMLElement - * The hasChildren() function returns whether the element has children. - * - * @return {boolean} true if the element has children. - */ - hasChildren: function () { - return this.children.length > 0 ; - }, - /** - * @member XMLElement - * The addChild() function adds a child element - * - * @param {XMLElement} child the non-null child to add. - */ - addChild: function (child) { - if (child !== null) { - child.parent = this; - this.children.push(child); - } - }, - /** - * @member XMLElement - * The insertChild() function inserts a child element at the index provided - * - * @param {XMLElement} child the non-null child to add. - * @param {int} index where to put the child. - */ - insertChild: function (child, index) { - if (child) { - if ((child.getLocalName() === null) && (! this.hasChildren())) { - var lastChild = this.children[this.children.length -1]; - if (lastChild.getLocalName() === null) { - lastChild.setContent(lastChild.getContent() + child.getContent()); - return; - } - } - child.parent = this; - this.children.splice(index,0,child); - } - }, - /** - * @member XMLElement - * The getChild() returns the child XMLElement as specified by the index parameter. - * The value of the index parameter must be less than the total number of children to avoid going out of the array storing the child elements. - * When the path parameter is specified, then it will return all children that match that path. The path is a series of elements and sub-elements, separated by slashes. - * - * @param {int} index where to put the child. - * @param {String} path path to a particular element - * - * @return {XMLElement} the element - */ - getChild: function (){ - if (typeof arguments[0] === "number") { - return this.children[arguments[0]]; - } - else if (arguments[0].indexOf('/') !== -1) { // path was given - this.getChildRecursive(arguments[0].split("/"), 0); - } else { - var kid, kidName; - for (var i = 0; i < this.getChildCount(); i++) { - kid = this.getChild(i); - kidName = kid.getName(); - if (kidName !== null && kidName === arguments[0]) { - return kid; - } - } - return null; - } - }, - /** - * @member XMLElement - * The getChildren() returns all of the children as an XMLElement array. - * When the path parameter is specified, then it will return all children that match that path. - * The path is a series of elements and sub-elements, separated by slashes. - * - * @param {String} path element name or path/to/element - * - * @return {XMLElement} array of child elements that match - * - * @see XMLElement#getChildCount() - * @see XMLElement#getChild() - */ - getChildren: function(){ - if (arguments.length === 1) { - if (typeof arguments[0] === "number") { - return this.getChild( arguments[0]); - } else if (arguments[0].indexOf('/') !== -1) { // path was given - return this.getChildrenRecursive( arguments[0].split("/"), 0); - } else { - var matches = []; - var kid, kidName; - for (var i = 0; i < this.getChildCount(); i++) { - kid = this.getChild(i); - kidName = kid.getName(); - if (kidName !== null && kidName === arguments[0]) { - matches.push(kid); - } - } - return matches; - } - }else { - return this.children; - } - }, - /** - * @member XMLElement - * The getChildCount() returns the number of children for the element. - * - * @return {int} the count - * - * @see XMLElement#getChild() - * @see XMLElement#getChildren() - */ - getChildCount: function(){ - return this.children.length; - }, - /** - * @member XMLElement - * Internal helper function for getChild(). - * - * @param {String[]} items result of splitting the query on slashes - * @param {int} offset where in the items[] array we're currently looking - * - * @return {XMLElement} matching element or null if no match - */ - getChildRecursive: function (items, offset) { - var kid, kidName; - for(var i = 0; i < this.getChildCount(); i++) { - kid = this.getChild(i); - kidName = kid.getName(); - if (kidName !== null && kidName === items[offset]) { - if (offset === items.length-1) { - return kid; - } else { - offset += 1; - return kid.getChildRecursive(items, offset); - } - } - } - return null; - }, - /** - * @member XMLElement - * Internal helper function for getChildren(). - * - * @param {String[]} items result of splitting the query on slashes - * @param {int} offset where in the items[] array we're currently looking - * - * @return {XMLElement[]} matching elements or empty array if no match - */ - getChildrenRecursive: function (items, offset) { - if (offset === items.length-1) { - return this.getChildren(items[offset]); - } - var matches = this.getChildren(items[offset]); - var kidMatches; - for (var i = 0; i < matches.length; i++) { - kidMatches = matches[i].getChildrenRecursive(items, offset+1); - } - return kidMatches; - }, - /** - * @member XMLElement - * Internal helper function for parse(). - * Loops through the - * @addon - * - * @param {XMLElement} parent the parent node - * @param {XML document childNodes} elementpath the remaining nodes that need parsing - * - * @return {XMLElement} the new element and its children elements - */ - parseChildrenRecursive: function (parent , elementpath){ - var xmlelement, - xmlattribute, - tmpattrib; - if (!parent) { - this.fullName = elementpath.localName; - this.name = elementpath.nodeName; - this.content = elementpath.textContent || ""; - xmlelement = this; - } else { // a parent - xmlelement = new XMLElement(elementpath.localName, elementpath.nodeName, "", ""); - xmlelement.content = elementpath.textContent || ""; - xmlelement.parent = parent; - } - - for (var l = 0; l < elementpath.attributes.length; l++) { - tmpattrib = elementpath.attributes[l]; - xmlattribute = new XMLAttribute(tmpattrib.getname , tmpattrib.nodeName, tmpattrib.namespaceURI , tmpattrib.nodeValue , tmpattrib.nodeType); - xmlelement.attributes.push(xmlattribute); - } - - for (var node in elementpath.childNodes){ - if(elementpath.childNodes[node].nodeType === 1) { //ELEMENT_NODE type - xmlelement.children.push( xmlelement.parseChildrenRecursive(xmlelement, elementpath.childNodes[node])); - } - } - return xmlelement; - }, - /** - * @member XMLElement - * The isLeaf() function returns whether the element is a leaf element. - * - * @return {boolean} true if the element has no children. - */ - isLeaf: function(){ - return !this.hasChildren(); - }, - /** - * @member XMLElement - * The listChildren() function put the names of all children into an array. Same as looping through - * each child and calling getName() on each XMLElement. - * - * @return {String[]} a list of element names. - */ - listChildren: function() { - var arr = []; - for (var i = 0; i < this.children.length; i++) { - arr.push( this.getChild(i).getName()); - } - return arr; - }, - /** - * @member XMLElement - * The removeAttribute() function removes an attribute - * - * @param {String} name the non-null name of the attribute. - * @param {String} namespace the namespace URI of the attribute, which may be null. - */ - removeAttribute: function (name , namespace) { - this.namespace = namespace || ""; - for (var i = 0; i < this.attributes.length; i++){ - if (this.attributes[i].getName() === name && this.attributes[i].getNamespace() === this.namespace) { - this.attributes.splice(i, 1); - } - } - }, - /** - * @member XMLElement - * The removeChild() removes a child element. - * - * @param {XMLElement} child the the non-null child to be renoved - */ - removeChild: function(child) { - if (child) { - for (var i = 0; i < this.children.length; i++) { - if (this.children[i].equalsXMLElement(child)) { - this.children.splice(i, 1); - } - } - } - }, - /** - * @member XMLElement - * The removeChildAtIndex() removes the child located at a certain index - * - * @param {int} index the index of the child, where the first child has index 0 - */ - removeChildAtIndex: function(index) { - if (this.children.length > index) { //make sure its not outofbounds - this.children.splice(index, 1); - } - }, - /** - * @member XMLElement - * The findAttribute() function searches an attribute - * - * @param {String} name fullName the non-null full name of the attribute - * @param {String} namespace the name space, which may be null - * - * @return {XMLAttribute} the attribute, or null if the attribute does not exist. - */ - findAttribute: function (name, namespace) { - this.namespace = namespace || ""; - for (var i = 0; i < this.attributes.length; i++ ) { - if (this.attributes[i].getName() === name && this.attributes[i].getNamespace() === this.namespace) { - return this.attributes[i]; - } - } - }, - /** - * @member XMLElement - * The setAttribute() function sets an attribute. - * - * @param {String} name the non-null full name of the attribute - * @param {String} namespace the non-null value of the attribute - */ - setAttribute: function() { - var attr; - if (arguments.length === 3) { - var index = arguments[0].indexOf(':'); - var name = arguments[0].substring(index + 1); - attr = this.findAttribute( name, arguments[1] ); - if (attr) { - attr.setValue(arguments[2]); - } else { - attr = new XMLAttribute(arguments[0], name, arguments[1], arguments[2], "CDATA"); - this.attributes.push(attr); - } - } else { - attr = this.findAttribute(arguments[0]); - if (attr) { - attr.setValue(arguments[1]); - } else { - attr = new XMLAttribute(arguments[0], arguments[0], null, arguments[1], "CDATA"); - this.attributes.push(attr); - } - } - }, - /** - * @member XMLElement - * The setContent() function sets the #PCDATA content. It is an error to call this method with a - * non-null value if there are child objects. - * - * @param {String} content the (possibly null) content - */ - setContent: function(content) { - this.content = content; - }, - /** - * @member XMLElement - * The setName() function sets the full name. This method also sets the short name and clears the - * namespace URI. - * - * @param {String} name the non-null name - * @param {String} namespace the namespace URI, which may be null. - */ - setName: function() { - if (arguments.length === 1) { - this.name = arguments[0]; - this.fullName = arguments[0]; - this.namespace = null; - } else { - var index = arguments[0].indexOf(':'); - if ((arguments[1] === null) || (index < 0)) { - this.name = arguments[0]; - } else { - this.name = arguments[0].substring(index + 1); - } - this.fullName = arguments[0]; - this.namespace = arguments[1]; - } - }, - /** - * @member XMLElement - * The getName() function returns the full name (i.e. the name including an eventual namespace - * prefix) of the element. - * - * @return {String} the name, or null if the element only contains #PCDATA. - */ - getName: function() { - return this.fullName; - }, - getLocalName: function() { - return this.name; - }, - getAttributeCount: function() { - return this.attributes.length; - } - }; - - - //////////////////////////////////////////////////////////////////////////// - // 2D Matrix - //////////////////////////////////////////////////////////////////////////// - /** - * Helper function for printMatrix(). Finds the largest scalar - * in the matrix, then number of digits left of the decimal. - * Call from PMatrix2D and PMatrix3D's print() function. - */ - var printMatrixHelper = function printMatrixHelper(elements) { - var big = 0; - for (var i = 0; i < elements.length; i++) { - if (i !== 0) { - big = Math.max(big, Math.abs(elements[i])); - } else { - big = Math.abs(elements[i]); - } - } - - var digits = (big + "").indexOf("."); - if (digits === 0) { - digits = 1; - } else if (digits === -1) { - digits = (big + "").length; - } - - return digits; - }; - /** - * PMatrix2D is a 3x2 affine matrix implementation. The constructor accepts another PMatrix2D or a list of six float elements. - * If no parameters are provided the matrix is set to the identity matrix. - * - * @param {PMatrix2D} matrix the initial matrix to set to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fifth element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - var PMatrix2D = p.PMatrix2D = function() { - if (arguments.length === 0) { - this.reset(); - } else if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - this.set(arguments[0].array()); - } else if (arguments.length === 6) { - this.set(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); - } - }; - /** - * PMatrix2D methods - */ - PMatrix2D.prototype = { - /** - * @member PMatrix2D - * The set() function sets the matrix elements. The function accepts either another PMatrix2D, an array of elements, or a list of six floats. - * - * @param {PMatrix2D} matrix the matrix to set this matrix to - * @param {float[]} elements an array of elements to set this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fith element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - set: function() { - if (arguments.length === 6) { - var a = arguments; - this.set([a[0], a[1], a[2], - a[3], a[4], a[5]]); - } else if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - this.elements = arguments[0].array(); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - this.elements = arguments[0].slice(); - } - }, - /** - * @member PMatrix2D - * The get() function returns a copy of this PMatrix2D. - * - * @return {PMatrix2D} a copy of this PMatrix2D - */ - get: function() { - var outgoing = new PMatrix2D(); - outgoing.set(this.elements); - return outgoing; - }, - /** - * @member PMatrix2D - * The reset() function sets this PMatrix2D to the identity matrix. - */ - reset: function() { - this.set([1, 0, 0, 0, 1, 0]); - }, - /** - * @member PMatrix2D - * The array() function returns a copy of the element values. - * @addon - * - * @return {float[]} returns a copy of the element values - */ - array: function array() { - return this.elements.slice(); - }, - /** - * @member PMatrix2D - * The translate() function translates this matrix by moving the current coordinates to the location specified by tx and ty. - * - * @param {float} tx the x-axis coordinate to move to - * @param {float} ty the y-axis coordinate to move to - */ - translate: function(tx, ty) { - this.elements[2] = tx * this.elements[0] + ty * this.elements[1] + this.elements[2]; - this.elements[5] = tx * this.elements[3] + ty * this.elements[4] + this.elements[5]; - }, - /** - * @member PMatrix2D - * The transpose() function is not used in processingjs. - */ - transpose: function() { - // Does nothing in Processing. - }, - /** - * @member PMatrix2D - * The mult() function multiplied this matrix. - * If two array elements are passed in the function will multiply a two element vector against this matrix. - * If target is null or not length four, a new float array will be returned. - * The values for vec and target can be the same (though that's less efficient). - * If two PVectors are passed in the function multiply the x and y coordinates of a PVector against this matrix. - * - * @param {PVector} source, target the PVectors used to multiply this matrix - * @param {float[]} source, target the arrays used to multiply this matrix - * - * @return {PVector|float[]} returns a PVector or an array representing the new matrix - */ - mult: function(source, target) { - var x, y; - if (source instanceof PVector) { - x = source.x; - y = source.y; - if (!target) { - target = new PVector(); - } - } else if (source instanceof Array) { - x = source[0]; - y = source[1]; - if (!target) { - target = []; - } - } - if (target instanceof Array) { - target[0] = this.elements[0] * x + this.elements[1] * y + this.elements[2]; - target[1] = this.elements[3] * x + this.elements[4] * y + this.elements[5]; - } else if (target instanceof PVector) { - target.x = this.elements[0] * x + this.elements[1] * y + this.elements[2]; - target.y = this.elements[3] * x + this.elements[4] * y + this.elements[5]; - target.z = 0; - } - return target; - }, - /** - * @member PMatrix2D - * The multX() function calculates the x component of a vector from a transformation. - * - * @param {float} x the x component of the vector being transformed - * @param {float} y the y component of the vector being transformed - * - * @return {float} returnes the result of the calculation - */ - multX: function(x, y) { - return (x * this.elements[0] + y * this.elements[1] + this.elements[2]); - }, - /** - * @member PMatrix2D - * The multY() function calculates the y component of a vector from a transformation. - * - * @param {float} x the x component of the vector being transformed - * @param {float} y the y component of the vector being transformed - * - * @return {float} returnes the result of the calculation - */ - multY: function(x, y) { - return (x * this.elements[3] + y * this.elements[4] + this.elements[5]); - }, - /** - * @member PMatrix2D - * The skewX() function skews the matrix along the x-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewX: function(angle) { - this.apply(1, 0, 1, angle, 0, 0); - }, - /** - * @member PMatrix2D - * The skewY() function skews the matrix along the y-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewY: function(angle) { - this.apply(1, 0, 1, 0, angle, 0); - }, - /** - * @member PMatrix2D - * The determinant() function calvculates the determinant of this matrix. - * - * @return {float} the determinant of the matrix - */ - determinant: function() { - return (this.elements[0] * this.elements[4] - this.elements[1] * this.elements[3]); - }, - /** - * @member PMatrix2D - * The invert() function inverts this matrix - * - * @return {boolean} true if successful - */ - invert: function() { - var d = this.determinant(); - if (Math.abs( d ) > PConstants.MIN_INT) { - var old00 = this.elements[0]; - var old01 = this.elements[1]; - var old02 = this.elements[2]; - var old10 = this.elements[3]; - var old11 = this.elements[4]; - var old12 = this.elements[5]; - this.elements[0] = old11 / d; - this.elements[3] = -old10 / d; - this.elements[1] = -old01 / d; - this.elements[4] = old00 / d; - this.elements[2] = (old01 * old12 - old11 * old02) / d; - this.elements[5] = (old10 * old02 - old00 * old12) / d; - return true; - } - return false; - }, - /** - * @member PMatrix2D - * The scale() function increases or decreases the size of a shape by expanding and contracting vertices. When only one parameter is specified scale will occur in all dimensions. - * This is equivalent to a two parameter call. - * - * @param {float} sx the amount to scale on the x-axis - * @param {float} sy the amount to scale on the y-axis - */ - scale: function(sx, sy) { - if (sx && !sy) { - sy = sx; - } - if (sx && sy) { - this.elements[0] *= sx; - this.elements[1] *= sy; - this.elements[3] *= sx; - this.elements[4] *= sy; - } - }, - /** - * @member PMatrix2D - * The apply() function multiplies the current matrix by the one specified through the parameters. Note that either a PMatrix2D or a list of floats can be passed in. - * - * @param {PMatrix2D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fith element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - apply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - source = arguments[0].array(); - } else if (arguments.length === 6) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - - var result = [0, 0, this.elements[2], - 0, 0, this.elements[5]]; - var e = 0; - for (var row = 0; row < 2; row++) { - for (var col = 0; col < 3; col++, e++) { - result[e] += this.elements[row * 3 + 0] * source[col + 0] + - this.elements[row * 3 + 1] * source[col + 3]; - } - } - this.elements = result.slice(); - }, - /** - * @member PMatrix2D - * The preApply() function applies another matrix to the left of this one. Note that either a PMatrix2D or elements of a matrix can be passed in. - * - * @param {PMatrix2D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fith element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - preApply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - source = arguments[0].array(); - } else if (arguments.length === 6) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - var result = [0, 0, source[2], - 0, 0, source[5]]; - result[2] = source[2] + this.elements[2] * source[0] + this.elements[5] * source[1]; - result[5] = source[5] + this.elements[2] * source[3] + this.elements[5] * source[4]; - result[0] = this.elements[0] * source[0] + this.elements[3] * source[1]; - result[3] = this.elements[0] * source[3] + this.elements[3] * source[4]; - result[1] = this.elements[1] * source[0] + this.elements[4] * source[1]; - result[4] = this.elements[1] * source[3] + this.elements[4] * source[4]; - this.elements = result.slice(); - }, - /** - * @member PMatrix2D - * The rotate() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotate: function(angle) { - var c = Math.cos(angle); - var s = Math.sin(angle); - var temp1 = this.elements[0]; - var temp2 = this.elements[1]; - this.elements[0] = c * temp1 + s * temp2; - this.elements[1] = -s * temp1 + c * temp2; - temp1 = this.elements[3]; - temp2 = this.elements[4]; - this.elements[3] = c * temp1 + s * temp2; - this.elements[4] = -s * temp1 + c * temp2; - }, - /** - * @member PMatrix2D - * The rotateZ() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateZ: function(angle) { - this.rotate(angle); - }, - /** - * @member PMatrix2D - * The print() function prints out the elements of this matrix - */ - print: function() { - var digits = printMatrixHelper(this.elements); - var output = "" + p.nfs(this.elements[0], digits, 4) + " " + - p.nfs(this.elements[1], digits, 4) + " " + - p.nfs(this.elements[2], digits, 4) + "\n" + - p.nfs(this.elements[3], digits, 4) + " " + - p.nfs(this.elements[4], digits, 4) + " " + - p.nfs(this.elements[5], digits, 4) + "\n\n"; - p.println(output); - } - }; - - /** - * PMatrix3D is a 4x4 matrix implementation. The constructor accepts another PMatrix3D or a list of six or sixteen float elements. - * If no parameters are provided the matrix is set to the identity matrix. - */ - var PMatrix3D = p.PMatrix3D = function PMatrix3D() { - // When a matrix is created, it is set to an identity matrix - this.reset(); - }; - /** - * PMatrix3D methods - */ - PMatrix3D.prototype = { - /** - * @member PMatrix2D - * The set() function sets the matrix elements. The function accepts either another PMatrix3D, an array of elements, or a list of six or sixteen floats. - * - * @param {PMatrix3D} matrix the initial matrix to set to - * @param {float[]} elements an array of elements to set this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - */ - set: function() { - if (arguments.length === 16) { - this.elements = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof PMatrix3D) { - this.elements = arguments[0].array(); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - this.elements = arguments[0].slice(); - } - }, - /** - * @member PMatrix3D - * The get() function returns a copy of this PMatrix3D. - * - * @return {PMatrix3D} a copy of this PMatrix3D - */ - get: function() { - var outgoing = new PMatrix3D(); - outgoing.set(this.elements); - return outgoing; - }, - /** - * @member PMatrix3D - * The reset() function sets this PMatrix3D to the identity matrix. - */ - reset: function() { - this.set([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The array() function returns a copy of the element values. - * @addon - * - * @return {float[]} returns a copy of the element values - */ - array: function array() { - return this.elements.slice(); - }, - /** - * @member PMatrix3D - * The translate() function translates this matrix by moving the current coordinates to the location specified by tx, ty, and tz. - * - * @param {float} tx the x-axis coordinate to move to - * @param {float} ty the y-axis coordinate to move to - * @param {float} tz the z-axis coordinate to move to - */ - translate: function(tx, ty, tz) { - if (tz === undef) { - tz = 0; - } - - this.elements[3] += tx * this.elements[0] + ty * this.elements[1] + tz * this.elements[2]; - this.elements[7] += tx * this.elements[4] + ty * this.elements[5] + tz * this.elements[6]; - this.elements[11] += tx * this.elements[8] + ty * this.elements[9] + tz * this.elements[10]; - this.elements[15] += tx * this.elements[12] + ty * this.elements[13] + tz * this.elements[14]; - }, - /** - * @member PMatrix2D - * The transpose() function transpose this matrix. - */ - transpose: function() { - var temp = this.elements.slice(); - this.elements[0] = temp[0]; - this.elements[1] = temp[4]; - this.elements[2] = temp[8]; - this.elements[3] = temp[12]; - this.elements[4] = temp[1]; - this.elements[5] = temp[5]; - this.elements[6] = temp[9]; - this.elements[7] = temp[13]; - this.elements[8] = temp[2]; - this.elements[9] = temp[6]; - this.elements[10] = temp[10]; - this.elements[11] = temp[14]; - this.elements[12] = temp[3]; - this.elements[13] = temp[7]; - this.elements[14] = temp[11]; - this.elements[15] = temp[15]; - }, - /** - * @member PMatrix3D - * The mult() function multiplied this matrix. - * If two array elements are passed in the function will multiply a two element vector against this matrix. - * If target is null or not length four, a new float array will be returned. - * The values for vec and target can be the same (though that's less efficient). - * If two PVectors are passed in the function multiply the x and y coordinates of a PVector against this matrix. - * - * @param {PVector} source, target the PVectors used to multiply this matrix - * @param {float[]} source, target the arrays used to multiply this matrix - * - * @return {PVector|float[]} returns a PVector or an array representing the new matrix - */ - mult: function(source, target) { - var x, y, z, w; - if (source instanceof PVector) { - x = source.x; - y = source.y; - z = source.z; - w = 1; - if (!target) { - target = new PVector(); - } - } else if (source instanceof Array) { - x = source[0]; - y = source[1]; - z = source[2]; - w = source[3] || 1; - - if (!target || target.length !== 3 && target.length !== 4) { - target = [0, 0, 0]; - } - } - - if (target instanceof Array) { - if (target.length === 3) { - target[0] = this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3]; - target[1] = this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7]; - target[2] = this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11]; - } else if (target.length === 4) { - target[0] = this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3] * w; - target[1] = this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7] * w; - target[2] = this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11] * w; - target[3] = this.elements[12] * x + this.elements[13] * y + this.elements[14] * z + this.elements[15] * w; - } - } - if (target instanceof PVector) { - target.x = this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3]; - target.y = this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7]; - target.z = this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11]; - } - return target; - }, - /** - * @member PMatrix3D - * The preApply() function applies another matrix to the left of this one. Note that either a PMatrix3D or elements of a matrix can be passed in. - * - * @param {PMatrix3D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - */ - preApply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix3D) { - source = arguments[0].array(); - } else if (arguments.length === 16) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - - var result = [0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0]; - var e = 0; - for (var row = 0; row < 4; row++) { - for (var col = 0; col < 4; col++, e++) { - result[e] += this.elements[col + 0] * source[row * 4 + 0] + this.elements[col + 4] * - source[row * 4 + 1] + this.elements[col + 8] * source[row * 4 + 2] + - this.elements[col + 12] * source[row * 4 + 3]; - } - } - this.elements = result.slice(); - }, - /** - * @member PMatrix3D - * The apply() function multiplies the current matrix by the one specified through the parameters. Note that either a PMatrix3D or a list of floats can be passed in. - * - * @param {PMatrix3D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - */ - apply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix3D) { - source = arguments[0].array(); - } else if (arguments.length === 16) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - - var result = [0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0]; - var e = 0; - for (var row = 0; row < 4; row++) { - for (var col = 0; col < 4; col++, e++) { - result[e] += this.elements[row * 4 + 0] * source[col + 0] + this.elements[row * 4 + 1] * - source[col + 4] + this.elements[row * 4 + 2] * source[col + 8] + - this.elements[row * 4 + 3] * source[col + 12]; - } - } - this.elements = result.slice(); - }, - /** - * @member PMatrix3D - * The rotate() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotate: function(angle, v0, v1, v2) { - if (!v1) { - this.rotateZ(angle); - } else { - // TODO should make sure this vector is normalized - var c = p.cos(angle); - var s = p.sin(angle); - var t = 1.0 - c; - - this.apply((t * v0 * v0) + c, - (t * v0 * v1) - (s * v2), - (t * v0 * v2) + (s * v1), - 0, - (t * v0 * v1) + (s * v2), - (t * v1 * v1) + c, - (t * v1 * v2) - (s * v0), - 0, - (t * v0 * v2) - (s * v1), - (t * v1 * v2) + (s * v0), - (t * v2 * v2) + c, - 0, 0, 0, 0, 1); - } - }, - /** - * @member PMatrix2D - * The invApply() function applies the inverted matrix to this matrix. - * - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - * - * @return {boolean} returns true if the operation was successful. - */ - invApply: function() { - if (inverseCopy === undef) { - inverseCopy = new PMatrix3D(); - } - var a = arguments; - inverseCopy.set(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], - a[9], a[10], a[11], a[12], a[13], a[14], a[15]); - - if (!inverseCopy.invert()) { - return false; - } - this.preApply(inverseCopy); - return true; - }, - /** - * @member PMatrix3D - * The rotateZ() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateX: function(angle) { - var c = p.cos(angle); - var s = p.sin(angle); - this.apply([1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The rotateY() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateY: function(angle) { - var c = p.cos(angle); - var s = p.sin(angle); - this.apply([c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The rotateZ() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateZ: function(angle) { - var c = Math.cos(angle); - var s = Math.sin(angle); - this.apply([c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The scale() function increases or decreases the size of a matrix by expanding and contracting vertices. When only one parameter is specified scale will occur in all dimensions. - * This is equivalent to a three parameter call. - * - * @param {float} sx the amount to scale on the x-axis - * @param {float} sy the amount to scale on the y-axis - * @param {float} sz the amount to scale on the z-axis - */ - scale: function(sx, sy, sz) { - if (sx && !sy && !sz) { - sy = sz = sx; - } else if (sx && sy && !sz) { - sz = 1; - } - - if (sx && sy && sz) { - this.elements[0] *= sx; - this.elements[1] *= sy; - this.elements[2] *= sz; - this.elements[4] *= sx; - this.elements[5] *= sy; - this.elements[6] *= sz; - this.elements[8] *= sx; - this.elements[9] *= sy; - this.elements[10] *= sz; - this.elements[12] *= sx; - this.elements[13] *= sy; - this.elements[14] *= sz; - } - }, - /** - * @member PMatrix3D - * The skewX() function skews the matrix along the x-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewX: function(angle) { - var t = Math.tan(angle); - this.apply(1, t, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); - }, - /** - * @member PMatrix3D - * The skewY() function skews the matrix along the y-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewY: function(angle) { - var t = Math.tan(angle); - this.apply(1, 0, 0, 0, t, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); - }, - multX: function(x, y, z, w) { - if (!z) { - return this.elements[0] * x + this.elements[1] * y + this.elements[3]; - } else if (!w) { - return this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3]; - } else { - return this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3] * w; - } - }, - multY: function(x, y, z, w) { - if (!z) { - return this.elements[4] * x + this.elements[5] * y + this.elements[7]; - } else if (!w) { - return this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7]; - } else { - return this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7] * w; - } - }, - multZ: function(x, y, z, w) { - if (!w) { - return this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11]; - } else { - return this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11] * w; - } - }, - multW: function(x, y, z, w) { - if (!w) { - return this.elements[12] * x + this.elements[13] * y + this.elements[14] * z + this.elements[15]; - } else { - return this.elements[12] * x + this.elements[13] * y + this.elements[14] * z + this.elements[15] * w; - } - }, - /** - * @member PMatrix3D - * The invert() function inverts this matrix - * - * @return {boolean} true if successful - */ - invert: function() { - var fA0 = this.elements[0] * this.elements[5] - this.elements[1] * this.elements[4]; - var fA1 = this.elements[0] * this.elements[6] - this.elements[2] * this.elements[4]; - var fA2 = this.elements[0] * this.elements[7] - this.elements[3] * this.elements[4]; - var fA3 = this.elements[1] * this.elements[6] - this.elements[2] * this.elements[5]; - var fA4 = this.elements[1] * this.elements[7] - this.elements[3] * this.elements[5]; - var fA5 = this.elements[2] * this.elements[7] - this.elements[3] * this.elements[6]; - var fB0 = this.elements[8] * this.elements[13] - this.elements[9] * this.elements[12]; - var fB1 = this.elements[8] * this.elements[14] - this.elements[10] * this.elements[12]; - var fB2 = this.elements[8] * this.elements[15] - this.elements[11] * this.elements[12]; - var fB3 = this.elements[9] * this.elements[14] - this.elements[10] * this.elements[13]; - var fB4 = this.elements[9] * this.elements[15] - this.elements[11] * this.elements[13]; - var fB5 = this.elements[10] * this.elements[15] - this.elements[11] * this.elements[14]; - - // Determinant - var fDet = fA0 * fB5 - fA1 * fB4 + fA2 * fB3 + fA3 * fB2 - fA4 * fB1 + fA5 * fB0; - - // Account for a very small value - // return false if not successful. - if (Math.abs(fDet) <= 1e-9) { - return false; - } - - var kInv = []; - kInv[0] = +this.elements[5] * fB5 - this.elements[6] * fB4 + this.elements[7] * fB3; - kInv[4] = -this.elements[4] * fB5 + this.elements[6] * fB2 - this.elements[7] * fB1; - kInv[8] = +this.elements[4] * fB4 - this.elements[5] * fB2 + this.elements[7] * fB0; - kInv[12] = -this.elements[4] * fB3 + this.elements[5] * fB1 - this.elements[6] * fB0; - kInv[1] = -this.elements[1] * fB5 + this.elements[2] * fB4 - this.elements[3] * fB3; - kInv[5] = +this.elements[0] * fB5 - this.elements[2] * fB2 + this.elements[3] * fB1; - kInv[9] = -this.elements[0] * fB4 + this.elements[1] * fB2 - this.elements[3] * fB0; - kInv[13] = +this.elements[0] * fB3 - this.elements[1] * fB1 + this.elements[2] * fB0; - kInv[2] = +this.elements[13] * fA5 - this.elements[14] * fA4 + this.elements[15] * fA3; - kInv[6] = -this.elements[12] * fA5 + this.elements[14] * fA2 - this.elements[15] * fA1; - kInv[10] = +this.elements[12] * fA4 - this.elements[13] * fA2 + this.elements[15] * fA0; - kInv[14] = -this.elements[12] * fA3 + this.elements[13] * fA1 - this.elements[14] * fA0; - kInv[3] = -this.elements[9] * fA5 + this.elements[10] * fA4 - this.elements[11] * fA3; - kInv[7] = +this.elements[8] * fA5 - this.elements[10] * fA2 + this.elements[11] * fA1; - kInv[11] = -this.elements[8] * fA4 + this.elements[9] * fA2 - this.elements[11] * fA0; - kInv[15] = +this.elements[8] * fA3 - this.elements[9] * fA1 + this.elements[10] * fA0; - - // Inverse using Determinant - var fInvDet = 1.0 / fDet; - kInv[0] *= fInvDet; - kInv[1] *= fInvDet; - kInv[2] *= fInvDet; - kInv[3] *= fInvDet; - kInv[4] *= fInvDet; - kInv[5] *= fInvDet; - kInv[6] *= fInvDet; - kInv[7] *= fInvDet; - kInv[8] *= fInvDet; - kInv[9] *= fInvDet; - kInv[10] *= fInvDet; - kInv[11] *= fInvDet; - kInv[12] *= fInvDet; - kInv[13] *= fInvDet; - kInv[14] *= fInvDet; - kInv[15] *= fInvDet; - - this.elements = kInv.slice(); - return true; - }, - toString: function() { - var str = ""; - for (var i = 0; i < 15; i++) { - str += this.elements[i] + ", "; - } - str += this.elements[15]; - return str; - }, - /** - * @member PMatrix3D - * The print() function prints out the elements of this matrix - */ - print: function() { - var digits = printMatrixHelper(this.elements); - - var output = "" + p.nfs(this.elements[0], digits, 4) + " " + p.nfs(this.elements[1], digits, 4) + - " " + p.nfs(this.elements[2], digits, 4) + " " + p.nfs(this.elements[3], digits, 4) + - "\n" + p.nfs(this.elements[4], digits, 4) + " " + p.nfs(this.elements[5], digits, 4) + - " " + p.nfs(this.elements[6], digits, 4) + " " + p.nfs(this.elements[7], digits, 4) + - "\n" + p.nfs(this.elements[8], digits, 4) + " " + p.nfs(this.elements[9], digits, 4) + - " " + p.nfs(this.elements[10], digits, 4) + " " + p.nfs(this.elements[11], digits, 4) + - "\n" + p.nfs(this.elements[12], digits, 4) + " " + p.nfs(this.elements[13], digits, 4) + - " " + p.nfs(this.elements[14], digits, 4) + " " + p.nfs(this.elements[15], digits, 4) + "\n\n"; - p.println(output); - }, - invTranslate: function(tx, ty, tz) { - this.preApply(1, 0, 0, -tx, 0, 1, 0, -ty, 0, 0, 1, -tz, 0, 0, 0, 1); - }, - invRotateX: function(angle) { - var c = Math.cos(-angle); - var s = Math.sin(-angle); - this.preApply([1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1]); - }, - invRotateY: function(angle) { - var c = Math.cos(-angle); - var s = Math.sin(-angle); - this.preApply([c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1]); - }, - invRotateZ: function(angle) { - var c = Math.cos(-angle); - var s = Math.sin(-angle); - this.preApply([c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }, - invScale: function(x, y, z) { - this.preApply([1 / x, 0, 0, 0, 0, 1 / y, 0, 0, 0, 0, 1 / z, 0, 0, 0, 0, 1]); - } - }; - - /** - * @private - * The matrix stack stores the transformations and translations that occur within the space. - */ - var PMatrixStack = p.PMatrixStack = function PMatrixStack() { - this.matrixStack = []; - }; - - /** - * @member PMatrixStack - * load pushes the matrix given in the function into the stack - * - * @param {Object | Array} matrix the matrix to be pushed into the stack - */ - PMatrixStack.prototype.load = function load() { - var tmpMatrix; - if (p.use3DContext) { - tmpMatrix = new PMatrix3D(); - } else { - tmpMatrix = new PMatrix2D(); - } - - if (arguments.length === 1) { - tmpMatrix.set(arguments[0]); - } else { - tmpMatrix.set(arguments); - } - this.matrixStack.push(tmpMatrix); - }; - - /** - * @member PMatrixStack - * push adds a duplicate of the top of the stack onto the stack - uses the peek function - */ - PMatrixStack.prototype.push = function push() { - this.matrixStack.push(this.peek()); - }; - - /** - * @member PMatrixStack - * pop removes returns the matrix at the top of the stack - * - * @returns {Object} the matrix at the top of the stack - */ - PMatrixStack.prototype.pop = function pop() { - return this.matrixStack.pop(); - }; - - /** - * @member PMatrixStack - * peek returns but doesn't remove the matrix at the top of the stack - * - * @returns {Object} the matrix at the top of the stack - */ - PMatrixStack.prototype.peek = function peek() { - var tmpMatrix; - if (p.use3DContext) { - tmpMatrix = new PMatrix3D(); - } else { - tmpMatrix = new PMatrix2D(); - } - - tmpMatrix.set(this.matrixStack[this.matrixStack.length - 1]); - return tmpMatrix; - }; - - /** - * @member PMatrixStack - * this function multiplies the matrix at the top of the stack with the matrix given as a parameter - * - * @param {Object | Array} matrix the matrix to be multiplied into the stack - */ - PMatrixStack.prototype.mult = function mult(matrix) { - this.matrixStack[this.matrixStack.length - 1].apply(matrix); - }; - - //////////////////////////////////////////////////////////////////////////// - // Array handling - //////////////////////////////////////////////////////////////////////////// - - /** - * The split() function breaks a string into pieces using a character or string - * as the divider. The delim parameter specifies the character or characters that - * mark the boundaries between each piece. A String[] array is returned that contains - * each of the pieces. - * If the result is a set of numbers, you can convert the String[] array to to a float[] - * or int[] array using the datatype conversion functions int() and float() (see example above). - * The splitTokens() function works in a similar fashion, except that it splits using a range - * of characters instead of a specific character or sequence. - * - * @param {String} str the String to be split - * @param {String} delim the character or String used to separate the data - * - * @returns {string[]} The new string array - * - * @see splitTokens - * @see join - * @see trim - */ - p.split = function(str, delim) { - return str.split(delim); - }; - - /** - * The splitTokens() function splits a String at one or many character "tokens." The tokens - * parameter specifies the character or characters to be used as a boundary. - * If no tokens character is specified, any whitespace character is used to split. - * Whitespace characters include tab (\t), line feed (\n), carriage return (\r), form - * feed (\f), and space. To convert a String to an array of integers or floats, use the - * datatype conversion functions int() and float() to convert the array of Strings. - * - * @param {String} str the String to be split - * @param {Char[]} tokens list of individual characters that will be used as separators - * - * @returns {string[]} The new string array - * - * @see split - * @see join - * @see trim - */ - p.splitTokens = function(str, tokens) { - if (arguments.length === 1) { - tokens = "\n\t\r\f "; - } - - tokens = "[" + tokens + "]"; - - var ary = []; - var index = 0; - var pos = str.search(tokens); - - while (pos >= 0) { - if (pos === 0) { - str = str.substring(1); - } else { - ary[index] = str.substring(0, pos); - index++; - str = str.substring(pos); - } - pos = str.search(tokens); - } - - if (str.length > 0) { - ary[index] = str; - } - - if (ary.length === 0) { - ary = undef; - } - - return ary; - }; - - /** - * Expands an array by one element and adds data to the new position. The datatype of - * the element parameter must be the same as the datatype of the array. - * When using an array of objects, the data returned from the function must be cast to - * the object array's data type. For example: SomeClass[] items = (SomeClass[]) - * append(originalArray, element). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array boolean[], - * byte[], char[], int[], float[], or String[], or an array of objects - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} element new data for the array - * - * @returns Array (the same datatype as the input) - * - * @see shorten - * @see expand - */ - p.append = function(array, element) { - array[array.length] = element; - return array; - }; - - /** - * Concatenates two arrays. For example, concatenating the array { 1, 2, 3 } and the - * array { 4, 5, 6 } yields { 1, 2, 3, 4, 5, 6 }. Both parameters must be arrays of the - * same datatype. - * When using an array of objects, the data returned from the function must be cast to the - * object array's data type. For example: SomeClass[] items = (SomeClass[]) concat(array1, array2). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array1 boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array2 boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * - * @returns Array (the same datatype as the input) - * - * @see splice - */ - p.concat = function(array1, array2) { - return array1.concat(array2); - }; - - /** - * Sorts an array of numbers from smallest to largest and puts an array of - * words in alphabetical order. The original array is not modified, a - * re-ordered array is returned. The count parameter states the number of - * elements to sort. For example if there are 12 elements in an array and - * if count is the value 5, only the first five elements on the array will - * be sorted. Alphabetical ordering is case insensitive. - * - * @param {String[] | int[] | float[]} array Array of elements to sort - * @param {int} numElem Number of elements to sort - * - * @returns {String[] | int[] | float[]} Array (same datatype as the input) - * - * @see reverse - */ - p.sort = function(array, numElem) { - var ret = []; - - // depending on the type used (int, float) or string - // we'll need to use a different compare function - if (array.length > 0) { - // copy since we need to return another array - var elemsToCopy = numElem > 0 ? numElem : array.length; - for (var i = 0; i < elemsToCopy; i++) { - ret.push(array[i]); - } - if (typeof array[0] === "string") { - ret.sort(); - } - // int or float - else { - ret.sort(function(a, b) { - return a - b; - }); - } - - // copy on the rest of the elements that were not sorted in case the user - // only wanted a subset of an array to be sorted. - if (numElem > 0) { - for (var j = ret.length; j < array.length; j++) { - ret.push(array[j]); - } - } - } - return ret; - }; - - /** - * Inserts a value or array of values into an existing array. The first two parameters must - * be of the same datatype. The array parameter defines the array which will be modified - * and the second parameter defines the data which will be inserted. When using an array - * of objects, the data returned from the function must be cast to the object array's data - * type. For example: SomeClass[] items = (SomeClass[]) splice(array1, array2, index). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * @param {boolean|byte|char|int|float|String|boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} - * value boolean, byte, char, int, float, String, boolean[], byte[], char[], int[], - * float[], String[], or other Object: value or an array of objects to be spliced in - * @param {int} index position in the array from which to insert data - * - * @returns Array (the same datatype as the input) - * - * @see contract - * @see subset - */ - p.splice = function(array, value, index) { - - // Trying to splice an empty array into "array" in P5 won't do - // anything, just return the original. - if(value.length === 0) - { - return array; - } - - // If the second argument was an array, we'll need to iterate over all - // the "value" elements and add one by one because - // array.splice(index, 0, value); - // would create a multi-dimensional array which isn't what we want. - if(value instanceof Array) { - for(var i = 0, j = index; i < value.length; j++,i++) { - array.splice(j, 0, value[i]); - } - } else { - array.splice(index, 0, value); - } - - return array; - }; - - /** - * Extracts an array of elements from an existing array. The array parameter defines the - * array from which the elements will be copied and the offset and length parameters determine - * which elements to extract. If no length is given, elements will be extracted from the offset - * to the end of the array. When specifying the offset remember the first array element is 0. - * This function does not change the source array. - * When using an array of objects, the data returned from the function must be cast to the - * object array's data type. - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * @param {int} offset position to begin - * @param {int} length number of values to extract - * - * @returns Array (the same datatype as the input) - * - * @see splice - */ - p.subset = function(array, offset, length) { - if (arguments.length === 2) { - return array.slice(offset, array.length - offset); - } else if (arguments.length === 3) { - return array.slice(offset, offset + length); - } - }; - - /** - * Combines an array of Strings into one String, each separated by the character(s) used for - * the separator parameter. To join arrays of ints or floats, it's necessary to first convert - * them to strings using nf() or nfs(). - * - * @param {Array} array array of Strings - * @param {char|String} separator char or String to be placed between each item - * - * @returns {String} The combined string - * - * @see split - * @see trim - * @see nf - * @see nfs - */ - p.join = function(array, seperator) { - return array.join(seperator); - }; - - /** - * Decreases an array by one element and returns the shortened array. When using an - * array of objects, the data returned from the function must be cast to the object array's - * data type. For example: SomeClass[] items = (SomeClass[]) shorten(originalArray). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array - * boolean[], byte[], char[], int[], float[], or String[], or an array of objects - * - * @returns Array (the same datatype as the input) - * - * @see append - * @see expand - */ - p.shorten = function(ary) { - var newary = []; - - // copy array into new array - var len = ary.length; - for (var i = 0; i < len; i++) { - newary[i] = ary[i]; - } - newary.pop(); - - return newary; - }; - - /** - * Increases the size of an array. By default, this function doubles the size of the array, - * but the optional newSize parameter provides precise control over the increase in size. - * When using an array of objects, the data returned from the function must be cast to the - * object array's data type. For example: SomeClass[] items = (SomeClass[]) expand(originalArray). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} ary - * boolean[], byte[], char[], int[], float[], String[], or an array of objects - * @param {int} newSize positive int: new size for the array - * - * @returns Array (the same datatype as the input) - * - * @see contract - */ - p.expand = function(ary, newSize) { - var temp = ary.slice(0); - if (arguments.length === 1) { - // double size of array - temp.length = ary.length * 2; - return temp; - } else if (arguments.length === 2) { - // size is newSize - temp.length = newSize; - return temp; - } - }; - - /** - * Copies an array (or part of an array) to another array. The src array is copied to the - * dst array, beginning at the position specified by srcPos and into the position specified - * by dstPos. The number of elements to copy is determined by length. The simplified version - * with two arguments copies an entire array to another of the same size. It is equivalent - * to "arrayCopy(src, 0, dst, 0, src.length)". This function is far more efficient for copying - * array data than iterating through a for and copying each element. - * - * @param {Array} src an array of any data type: the source array - * @param {Array} dest an array of any data type (as long as it's the same as src): the destination array - * @param {int} srcPos starting position in the source array - * @param {int} destPos starting position in the destination array - * @param {int} length number of array elements to be copied - * - * @returns none - */ - p.arrayCopy = function() { // src, srcPos, dest, destPos, length) { - var src, srcPos = 0, dest, destPos = 0, length; - - if (arguments.length === 2) { - // recall itself and copy src to dest from start index 0 to 0 of src.length - src = arguments[0]; - dest = arguments[1]; - length = src.length; - } else if (arguments.length === 3) { - // recall itself and copy src to dest from start index 0 to 0 of length - src = arguments[0]; - dest = arguments[1]; - length = arguments[2]; - } else if (arguments.length === 5) { - src = arguments[0]; - srcPos = arguments[1]; - dest = arguments[2]; - destPos = arguments[3]; - length = arguments[4]; - } - - // copy src to dest from index srcPos to index destPos of length recursivly on objects - for (var i = srcPos, j = destPos; i < length + srcPos; i++, j++) { - if (dest[j] !== undef) { - dest[j] = src[i]; - } else { - throw "array index out of bounds exception"; - } - } - }; - - /** - * Reverses the order of an array. - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]} array - * boolean[], byte[], char[], int[], float[], or String[] - * - * @returns Array (the same datatype as the input) - * - * @see sort - */ - p.reverse = function(array) { - return array.reverse(); - }; - - - //////////////////////////////////////////////////////////////////////////// - // Color functions - //////////////////////////////////////////////////////////////////////////// - - // helper functions for internal blending modes - p.mix = function(a, b, f) { - return a + (((b - a) * f) >> 8); - }; - - p.peg = function(n) { - return (n < 0) ? 0 : ((n > 255) ? 255 : n); - }; - - // blending modes - /** - * These are internal blending modes used for BlendColor() - * - * @param {Color} c1 First Color to blend - * @param {Color} c2 Second Color to blend - * - * @returns {Color} The blended Color - * - * @see BlendColor - * @see Blend - */ - p.modes = { - replace: function(c1, c2) { - return c2; - }, - blend: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - p.mix(c1 & PConstants.RED_MASK, c2 & PConstants.RED_MASK, f) & PConstants.RED_MASK | - p.mix(c1 & PConstants.GREEN_MASK, c2 & PConstants.GREEN_MASK, f) & PConstants.GREEN_MASK | - p.mix(c1 & PConstants.BLUE_MASK, c2 & PConstants.BLUE_MASK, f)); - }, - add: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - Math.min(((c1 & PConstants.RED_MASK) + ((c2 & PConstants.RED_MASK) >> 8) * f), PConstants.RED_MASK) & PConstants.RED_MASK | - Math.min(((c1 & PConstants.GREEN_MASK) + ((c2 & PConstants.GREEN_MASK) >> 8) * f), PConstants.GREEN_MASK) & PConstants.GREEN_MASK | - Math.min((c1 & PConstants.BLUE_MASK) + (((c2 & PConstants.BLUE_MASK) * f) >> 8), PConstants.BLUE_MASK)); - }, - subtract: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - Math.max(((c1 & PConstants.RED_MASK) - ((c2 & PConstants.RED_MASK) >> 8) * f), PConstants.GREEN_MASK) & PConstants.RED_MASK | - Math.max(((c1 & PConstants.GREEN_MASK) - ((c2 & PConstants.GREEN_MASK) >> 8) * f), PConstants.BLUE_MASK) & PConstants.GREEN_MASK | - Math.max((c1 & PConstants.BLUE_MASK) - (((c2 & PConstants.BLUE_MASK) * f) >> 8), 0)); - }, - lightest: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - Math.max(c1 & PConstants.RED_MASK, ((c2 & PConstants.RED_MASK) >> 8) * f) & PConstants.RED_MASK | - Math.max(c1 & PConstants.GREEN_MASK, ((c2 & PConstants.GREEN_MASK) >> 8) * f) & PConstants.GREEN_MASK | - Math.max(c1 & PConstants.BLUE_MASK, ((c2 & PConstants.BLUE_MASK) * f) >> 8)); - }, - darkest: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - p.mix(c1 & PConstants.RED_MASK, Math.min(c1 & PConstants.RED_MASK, ((c2 & PConstants.RED_MASK) >> 8) * f), f) & PConstants.RED_MASK | - p.mix(c1 & PConstants.GREEN_MASK, Math.min(c1 & PConstants.GREEN_MASK, ((c2 & PConstants.GREEN_MASK) >> 8) * f), f) & PConstants.GREEN_MASK | - p.mix(c1 & PConstants.BLUE_MASK, Math.min(c1 & PConstants.BLUE_MASK, ((c2 & PConstants.BLUE_MASK) * f) >> 8), f)); - }, - difference: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (ar > br) ? (ar - br) : (br - ar); - var cg = (ag > bg) ? (ag - bg) : (bg - ag); - var cb = (ab > bb) ? (ab - bb) : (bb - ab); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - exclusion: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = ar + br - ((ar * br) >> 7); - var cg = ag + bg - ((ag * bg) >> 7); - var cb = ab + bb - ((ab * bb) >> 7); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - multiply: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (ar * br) >> 8; - var cg = (ag * bg) >> 8; - var cb = (ab * bb) >> 8; - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - screen: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = 255 - (((255 - ar) * (255 - br)) >> 8); - var cg = 255 - (((255 - ag) * (255 - bg)) >> 8); - var cb = 255 - (((255 - ab) * (255 - bb)) >> 8); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - hard_light: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (br < 128) ? ((ar * br) >> 7) : (255 - (((255 - ar) * (255 - br)) >> 7)); - var cg = (bg < 128) ? ((ag * bg) >> 7) : (255 - (((255 - ag) * (255 - bg)) >> 7)); - var cb = (bb < 128) ? ((ab * bb) >> 7) : (255 - (((255 - ab) * (255 - bb)) >> 7)); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - soft_light: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = ((ar * br) >> 7) + ((ar * ar) >> 8) - ((ar * ar * br) >> 15); - var cg = ((ag * bg) >> 7) + ((ag * ag) >> 8) - ((ag * ag * bg) >> 15); - var cb = ((ab * bb) >> 7) + ((ab * ab) >> 8) - ((ab * ab * bb) >> 15); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - overlay: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (ar < 128) ? ((ar * br) >> 7) : (255 - (((255 - ar) * (255 - br)) >> 7)); - var cg = (ag < 128) ? ((ag * bg) >> 7) : (255 - (((255 - ag) * (255 - bg)) >> 7)); - var cb = (ab < 128) ? ((ab * bb) >> 7) : (255 - (((255 - ab) * (255 - bb)) >> 7)); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - dodge: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (br === 255) ? 255 : p.peg((ar << 8) / (255 - br)); // division requires pre-peg()-ing - var cg = (bg === 255) ? 255 : p.peg((ag << 8) / (255 - bg)); // " - var cb = (bb === 255) ? 255 : p.peg((ab << 8) / (255 - bb)); // " - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - burn: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (br === 0) ? 0 : 255 - p.peg(((255 - ar) << 8) / br); // division requires pre-peg()-ing - var cg = (bg === 0) ? 0 : 255 - p.peg(((255 - ag) << 8) / bg); // " - var cb = (bb === 0) ? 0 : 255 - p.peg(((255 - ab) << 8) / bb); // " - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - } - }; - - function color$4(aValue1, aValue2, aValue3, aValue4) { - var r, g, b, a; - - if (curColorMode === PConstants.HSB) { - var rgb = p.color.toRGB(aValue1, aValue2, aValue3); - r = rgb[0]; - g = rgb[1]; - b = rgb[2]; - } else { - r = Math.round(255 * (aValue1 / colorModeX)); - g = Math.round(255 * (aValue2 / colorModeY)); - b = Math.round(255 * (aValue3 / colorModeZ)); - } - - a = Math.round(255 * (aValue4 / colorModeA)); - - // Limit values greater than 255 - r = (r > 255) ? 255 : r; - g = (g > 255) ? 255 : g; - b = (b > 255) ? 255 : b; - a = (a > 255) ? 255 : a; - - // Create color int - return (a << 24) & PConstants.ALPHA_MASK | (r << 16) & PConstants.RED_MASK | (g << 8) & PConstants.GREEN_MASK | b & PConstants.BLUE_MASK; - } - - function color$2(aValue1, aValue2) { - var a; - - // Color int and alpha - if (aValue1 & PConstants.ALPHA_MASK) { - a = Math.round(255 * (aValue2 / colorModeA)); - a = (a > 255) ? 255 : a; - - return aValue1 - (aValue1 & PConstants.ALPHA_MASK) + ((a << 24) & PConstants.ALPHA_MASK); - } - // Grayscale and alpha - else { - if (curColorMode === PConstants.RGB) { - return color$4(aValue1, aValue1, aValue1, aValue2); - } else if (curColorMode === PConstants.HSB) { - return color$4(0, 0, (aValue1 / colorModeX) * colorModeZ, aValue2); - } - } - } - - function color$1(aValue1) { - // Grayscale - if (aValue1 <= colorModeX && aValue1 >= 0) { - if (curColorMode === PConstants.RGB) { - return color$4(aValue1, aValue1, aValue1, colorModeA); - } else if (curColorMode === PConstants.HSB) { - return color$4(0, 0, (aValue1 / colorModeX) * colorModeZ, colorModeA); - } - } - // Color int - else if (aValue1) { - return aValue1; - } - } - - /** - * Creates colors for storing in variables of the color datatype. The parameters are - * interpreted as RGB or HSB values depending on the current colorMode(). The default - * mode is RGB values from 0 to 255 and therefore, the function call color(255, 204, 0) - * will return a bright yellow color. More about how colors are stored can be found in - * the reference for the color datatype. - * - * @param {int|float} aValue1 red or hue or grey values relative to the current color range. - * Also can be color value in hexadecimal notation (i.e. #FFCC00 or 0xFFFFCC00) - * @param {int|float} aValue2 green or saturation values relative to the current color range - * @param {int|float} aValue3 blue or brightness values relative to the current color range - * @param {int|float} aValue4 relative to current color range. Represents alpha - * - * @returns {color} the color - * - * @see colorMode - */ - p.color = function color(aValue1, aValue2, aValue3, aValue4) { - // 4 arguments: (R, G, B, A) or (H, S, B, A) - if (aValue1 !== undef && aValue2 !== undef && aValue3 !== undef && aValue4 !== undef) { - return color$4(aValue1, aValue2, aValue3, aValue4); - } - - // 3 arguments: (R, G, B) or (H, S, B) - else if (aValue1 !== undef && aValue2 !== undef && aValue3 !== undef) { - return color$4(aValue1, aValue2, aValue3, colorModeA); - } - - // 2 arguments: (Color, A) or (Grayscale, A) - else if (aValue1 !== undef && aValue2 !== undef) { - return color$2(aValue1, aValue2); - } - - // 1 argument: (Grayscale) or (Color) - else if (typeof aValue1 === "number") { - return color$1(aValue1); - } - - // Default - else { - return color$4(colorModeX, colorModeY, colorModeZ, colorModeA); - } - }; - - // Ease of use function to extract the colour bits into a string - p.color.toString = function(colorInt) { - return "rgba(" + ((colorInt & PConstants.RED_MASK) >>> 16) + "," + ((colorInt & PConstants.GREEN_MASK) >>> 8) + - "," + ((colorInt & PConstants.BLUE_MASK)) + "," + ((colorInt & PConstants.ALPHA_MASK) >>> 24) / 255 + ")"; - }; - - // Easy of use function to pack rgba values into a single bit-shifted color int. - p.color.toInt = function(r, g, b, a) { - return (a << 24) & PConstants.ALPHA_MASK | (r << 16) & PConstants.RED_MASK | (g << 8) & PConstants.GREEN_MASK | b & PConstants.BLUE_MASK; - }; - - // Creates a simple array in [R, G, B, A] format, [255, 255, 255, 255] - p.color.toArray = function(colorInt) { - return [(colorInt & PConstants.RED_MASK) >>> 16, (colorInt & PConstants.GREEN_MASK) >>> 8, - colorInt & PConstants.BLUE_MASK, (colorInt & PConstants.ALPHA_MASK) >>> 24]; - }; - - // Creates a WebGL color array in [R, G, B, A] format. WebGL wants the color ranges between 0 and 1, [1, 1, 1, 1] - p.color.toGLArray = function(colorInt) { - return [((colorInt & PConstants.RED_MASK) >>> 16) / 255, ((colorInt & PConstants.GREEN_MASK) >>> 8) / 255, - (colorInt & PConstants.BLUE_MASK) / 255, ((colorInt & PConstants.ALPHA_MASK) >>> 24) / 255]; - }; - - // HSB conversion function from Mootools, MIT Licensed - p.color.toRGB = function(h, s, b) { - // Limit values greater than range - h = (h > colorModeX) ? colorModeX : h; - s = (s > colorModeY) ? colorModeY : s; - b = (b > colorModeZ) ? colorModeZ : b; - - h = (h / colorModeX) * 360; - s = (s / colorModeY) * 100; - b = (b / colorModeZ) * 100; - - var br = Math.round(b / 100 * 255); - - if (s === 0) { // Grayscale - return [br, br, br]; - } else { - var hue = h % 360; - var f = hue % 60; - var p = Math.round((b * (100 - s)) / 10000 * 255); - var q = Math.round((b * (6000 - s * f)) / 600000 * 255); - var t = Math.round((b * (6000 - s * (60 - f))) / 600000 * 255); - switch (Math.floor(hue / 60)) { - case 0: - return [br, t, p]; - case 1: - return [q, br, p]; - case 2: - return [p, br, t]; - case 3: - return [p, q, br]; - case 4: - return [t, p, br]; - case 5: - return [br, p, q]; - } - } - }; - - p.color.toHSB = function( colorInt ) { - var red, green, blue; - - red = ((colorInt & PConstants.RED_MASK) >>> 16) / 255; - green = ((colorInt & PConstants.GREEN_MASK) >>> 8) / 255; - blue = (colorInt & PConstants.BLUE_MASK) / 255; - - var max = p.max(p.max(red,green), blue), - min = p.min(p.min(red,green), blue), - hue, saturation; - - if (min === max) { - return [0, 0, max]; - } else { - saturation = (max - min) / max; - - if (red === max) { - hue = (green - blue) / (max - min); - } else if (green === max) { - hue = 2 + ((blue - red) / (max - min)); - } else { - hue = 4 + ((red - green) / (max - min)); - } - - hue /= 6; - - if (hue < 0) { - hue += 1; - } else if (hue > 1) { - hue -= 1; - } - } - return [hue*colorModeX, saturation*colorModeY, max*colorModeZ]; - }; - - /** - * Extracts the brightness value from a color. - * - * @param {color} colInt any value of the color datatype - * - * @returns {float} The brightness color value. - * - * @see red - * @see green - * @see blue - * @see hue - * @see saturation - */ - p.brightness = function(colInt){ - return p.color.toHSB(colInt)[2]; - }; - - /** - * Extracts the saturation value from a color. - * - * @param {color} colInt any value of the color datatype - * - * @returns {float} The saturation color value. - * - * @see red - * @see green - * @see blue - * @see hue - * @see brightness - */ - p.saturation = function(colInt){ - return p.color.toHSB(colInt)[1]; - }; - - /** - * Extracts the hue value from a color. - * - * @param {color} colInt any value of the color datatype - * - * @returns {float} The hue color value. - * - * @see red - * @see green - * @see blue - * @see saturation - * @see brightness - */ - p.hue = function(colInt){ - return p.color.toHSB(colInt)[0]; - }; - - var verifyChannel = function verifyChannel(aColor) { - if (aColor.constructor === Array) { - return aColor; - } else { - return p.color(aColor); - } - }; - - /** - * Extracts the red value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The red color value. - * - * @see green - * @see blue - * @see alpha - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.red = function(aColor) { - return ((aColor & PConstants.RED_MASK) >>> 16) / 255 * colorModeX; - }; - - /** - * Extracts the green value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The green color value. - * - * @see red - * @see blue - * @see alpha - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.green = function(aColor) { - return ((aColor & PConstants.GREEN_MASK) >>> 8) / 255 * colorModeY; - }; - - /** - * Extracts the blue value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The blue color value. - * - * @see red - * @see green - * @see alpha - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.blue = function(aColor) { - return (aColor & PConstants.BLUE_MASK) / 255 * colorModeZ; - }; - - /** - * Extracts the alpha value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The alpha color value. - * - * @see red - * @see green - * @see blue - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.alpha = function(aColor) { - return ((aColor & PConstants.ALPHA_MASK) >>> 24) / 255 * colorModeA; - }; - - /** - * Calculates a color or colors between two colors at a specific increment. - * The amt parameter is the amount to interpolate between the two values where 0.0 - * equal to the first point, 0.1 is very near the first point, 0.5 is half-way in between, etc. - * - * @param {color} c1 interpolate from this color - * @param {color} c2 interpolate to this color - * @param {float} amt between 0.0 and 1.0 - * - * @returns {float} The blended color. - * - * @see blendColor - * @see color - */ - p.lerpColor = function lerpColor(c1, c2, amt) { - // Get RGBA values for Color 1 to floats - var colorBits1 = p.color(c1); - var r1 = (colorBits1 & PConstants.RED_MASK) >>> 16; - var g1 = (colorBits1 & PConstants.GREEN_MASK) >>> 8; - var b1 = (colorBits1 & PConstants.BLUE_MASK); - var a1 = ((colorBits1 & PConstants.ALPHA_MASK) >>> 24) / colorModeA; - - // Get RGBA values for Color 2 to floats - var colorBits2 = p.color(c2); - var r2 = (colorBits2 & PConstants.RED_MASK) >>> 16; - var g2 = (colorBits2 & PConstants.GREEN_MASK) >>> 8; - var b2 = (colorBits2 & PConstants.BLUE_MASK); - var a2 = ((colorBits2 & PConstants.ALPHA_MASK) >>> 24) / colorModeA; - - // Return lerp value for each channel, INT for color, Float for Alpha-range - var r = parseInt(p.lerp(r1, r2, amt), 10); - var g = parseInt(p.lerp(g1, g2, amt), 10); - var b = parseInt(p.lerp(b1, b2, amt), 10); - var a = parseFloat(p.lerp(a1, a2, amt) * colorModeA); - - return p.color.toInt(r, g, b, a); - }; - - // Forced default color mode for #aaaaaa style - /** - * Convert 3 int values to a color in the default color mode RGB even if curColorMode is not set to RGB - * - * @param {int} aValue1 range for the red color - * @param {int} aValue2 range for the green color - * @param {int} aValue3 range for the blue color - * - * @returns {Color} - * - * @see color - */ - p.defaultColor = function(aValue1, aValue2, aValue3) { - var tmpColorMode = curColorMode; - curColorMode = PConstants.RGB; - var c = p.color(aValue1 / 255 * colorModeX, aValue2 / 255 * colorModeY, aValue3 / 255 * colorModeZ); - curColorMode = tmpColorMode; - return c; - }; - - /** - * Changes the way Processing interprets color data. By default, fill(), stroke(), and background() - * colors are set by values between 0 and 255 using the RGB color model. It is possible to change the - * numerical range used for specifying colors and to switch color systems. For example, calling colorMode(RGB, 1.0) - * will specify that values are specified between 0 and 1. The limits for defining colors are altered by setting the - * parameters range1, range2, range3, and range 4. - * - * @param {MODE} mode Either RGB or HSB, corresponding to Red/Green/Blue and Hue/Saturation/Brightness - * @param {int|float} range range for all color elements - * @param {int|float} range1 range for the red or hue depending on the current color mode - * @param {int|float} range2 range for the green or saturation depending on the current color mode - * @param {int|float} range3 range for the blue or brightness depending on the current color mode - * @param {int|float} range4 range for the alpha - * - * @returns none - * - * @see background - * @see fill - * @see stroke - */ - p.colorMode = function colorMode() { // mode, range1, range2, range3, range4 - curColorMode = arguments[0]; - if (arguments.length > 1) { - colorModeX = arguments[1]; - colorModeY = arguments[2] || arguments[1]; - colorModeZ = arguments[3] || arguments[1]; - colorModeA = arguments[4] || arguments[1]; - } - }; - - /** - * Blends two color values together based on the blending mode given as the MODE parameter. - * The possible modes are described in the reference for the blend() function. - * - * @param {color} c1 color: the first color to blend - * @param {color} c2 color: the second color to blend - * @param {MODE} MODE Either BLEND, ADD, SUBTRACT, DARKEST, LIGHTEST, DIFFERENCE, EXCLUSION, MULTIPLY, - * SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, or BURN - * - * @returns {float} The blended color. - * - * @see blend - * @see color - */ - p.blendColor = function(c1, c2, mode) { - var color = 0; - switch (mode) { - case PConstants.REPLACE: - color = p.modes.replace(c1, c2); - break; - case PConstants.BLEND: - color = p.modes.blend(c1, c2); - break; - case PConstants.ADD: - color = p.modes.add(c1, c2); - break; - case PConstants.SUBTRACT: - color = p.modes.subtract(c1, c2); - break; - case PConstants.LIGHTEST: - color = p.modes.lightest(c1, c2); - break; - case PConstants.DARKEST: - color = p.modes.darkest(c1, c2); - break; - case PConstants.DIFFERENCE: - color = p.modes.difference(c1, c2); - break; - case PConstants.EXCLUSION: - color = p.modes.exclusion(c1, c2); - break; - case PConstants.MULTIPLY: - color = p.modes.multiply(c1, c2); - break; - case PConstants.SCREEN: - color = p.modes.screen(c1, c2); - break; - case PConstants.HARD_LIGHT: - color = p.modes.hard_light(c1, c2); - break; - case PConstants.SOFT_LIGHT: - color = p.modes.soft_light(c1, c2); - break; - case PConstants.OVERLAY: - color = p.modes.overlay(c1, c2); - break; - case PConstants.DODGE: - color = p.modes.dodge(c1, c2); - break; - case PConstants.BURN: - color = p.modes.burn(c1, c2); - break; - } - return color; - }; - - //////////////////////////////////////////////////////////////////////////// - // Canvas-Matrix manipulation - //////////////////////////////////////////////////////////////////////////// - - function saveContext() { - curContext.save(); - } - - function restoreContext() { - curContext.restore(); - isStrokeDirty = true; - isFillDirty = true; - } - - /** - * Prints the current matrix to the text window. - * - * @returns none - * - * @see pushMatrix - * @see popMatrix - * @see resetMatrix - * @see applyMatrix - */ - p.printMatrix = function printMatrix() { - modelView.print(); - }; - - /** - * Specifies an amount to displace objects within the display window. The x parameter specifies left/right translation, - * the y parameter specifies up/down translation, and the z parameter specifies translations toward/away from the screen. - * Using this function with the z parameter requires using the P3D or OPENGL parameter in combination with size as shown - * in the above example. Transformations apply to everything that happens after and subsequent calls to the function - * accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). - * If translate() is called within draw(), the transformation is reset when the loop begins again. - * This function can be further controlled by the pushMatrix() and popMatrix(). - * - * @param {int|float} x left/right translation - * @param {int|float} y up/down translation - * @param {int|float} z forward/back translation - * - * @returns none - * - * @see pushMatrix - * @see popMatrix - * @see scale - * @see rotate - * @see rotateX - * @see rotateY - * @see rotateZ - */ - p.translate = function translate(x, y, z) { - if (p.use3DContext) { - forwardTransform.translate(x, y, z); - reverseTransform.invTranslate(x, y, z); - } else { - curContext.translate(x, y); - } - }; - - /** - * Increases or decreases the size of a shape by expanding and contracting vertices. Objects always scale from their - * relative origin to the coordinate system. Scale values are specified as decimal percentages. For example, the - * function call scale(2.0) increases the dimension of a shape by 200%. Transformations apply to everything that - * happens after and subsequent calls to the function multiply the effect. For example, calling scale(2.0) and - * then scale(1.5) is the same as scale(3.0). If scale() is called within draw(), the transformation is reset when - * the loop begins again. Using this fuction with the z parameter requires passing P3D or OPENGL into the size() - * parameter as shown in the example above. This function can be further controlled by pushMatrix() and popMatrix(). - * - * @param {int|float} size percentage to scale the object - * @param {int|float} x percentage to scale the object in the x-axis - * @param {int|float} y percentage to scale the object in the y-axis - * @param {int|float} z percentage to scale the object in the z-axis - * - * @returns none - * - * @see pushMatrix - * @see popMatrix - * @see translate - * @see rotate - * @see rotateX - * @see rotateY - * @see rotateZ - */ - p.scale = function scale(x, y, z) { - if (p.use3DContext) { - forwardTransform.scale(x, y, z); - reverseTransform.invScale(x, y, z); - } else { - curContext.scale(x, y || x); - } - }; - - /** - * Pushes the current transformation matrix onto the matrix stack. Understanding pushMatrix() and popMatrix() - * requires understanding the concept of a matrix stack. The pushMatrix() function saves the current coordinate - * system to the stack and popMatrix() restores the prior coordinate system. pushMatrix() and popMatrix() are - * used in conjuction with the other transformation methods and may be embedded to control the scope of - * the transformations. - * - * @returns none - * - * @see popMatrix - * @see translate - * @see rotate - * @see rotateX - * @see rotateY - * @see rotateZ - */ - p.pushMatrix = function pushMatrix() { - if (p.use3DContext) { - userMatrixStack.load(modelView); - } else { - saveContext(); - } - }; - - /** - * Pops the current transformation matrix off the matrix stack. Understanding pushing and popping requires - * understanding the concept of a matrix stack. The pushMatrix() function saves the current coordinate system to - * the stack and popMatrix() restores the prior coordinate system. pushMatrix() and popMatrix() are used in - * conjuction with the other transformation methods and may be embedded to control the scope of the transformations. - * - * @returns none - * - * @see popMatrix - * @see pushMatrix - */ - p.popMatrix = function popMatrix() { - if (p.use3DContext) { - modelView.set(userMatrixStack.pop()); - } else { - restoreContext(); - } - }; - - /** - * Replaces the current matrix with the identity matrix. The equivalent function in OpenGL is glLoadIdentity(). - * - * @returns none - * - * @see popMatrix - * @see pushMatrix - * @see applyMatrix - * @see printMatrix - */ - p.resetMatrix = function resetMatrix() { - if (p.use3DContext) { - forwardTransform.reset(); - reverseTransform.reset(); - } else { - curContext.setTransform(1,0,0,1,0,0); - } - }; - - /** - * Multiplies the current matrix by the one specified through the parameters. This is very slow because it will - * try to calculate the inverse of the transform, so avoid it whenever possible. The equivalent function - * in OpenGL is glMultMatrix(). - * - * @param {int|float} n00-n15 numbers which define the 4x4 matrix to be multiplied - * - * @returns none - * - * @see popMatrix - * @see pushMatrix - * @see resetMatrix - * @see printMatrix - */ - p.applyMatrix = function applyMatrix() { - var a = arguments; - if (!p.use3DContext) { - for (var cnt = a.length; cnt < 16; cnt++) { - a[cnt] = 0; - } - a[10] = a[15] = 1; - } - - forwardTransform.apply(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]); - reverseTransform.invApply(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]); - }; - - /** - * Rotates a shape around the x-axis the amount specified by the angle parameter. Angles should be - * specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * Objects are always rotated around their relative position to the origin and positive numbers - * rotate objects in a counterclockwise direction. Transformations apply to everything that happens - * after and subsequent calls to the function accumulates the effect. For example, calling rotateX(PI/2) - * and then rotateX(PI/2) is the same as rotateX(PI). If rotateX() is called within the draw(), the - * transformation is reset when the loop begins again. This function requires passing P3D or OPENGL - * into the size() parameter as shown in the example above. - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateY - * @see rotateZ - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotateX = function(angleInRadians) { - forwardTransform.rotateX(angleInRadians); - reverseTransform.invRotateX(angleInRadians); - }; - - /** - * Rotates a shape around the z-axis the amount specified by the angle parameter. Angles should be - * specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * Objects are always rotated around their relative position to the origin and positive numbers - * rotate objects in a counterclockwise direction. Transformations apply to everything that happens - * after and subsequent calls to the function accumulates the effect. For example, calling rotateZ(PI/2) - * and then rotateZ(PI/2) is the same as rotateZ(PI). If rotateZ() is called within the draw(), the - * transformation is reset when the loop begins again. This function requires passing P3D or OPENGL - * into the size() parameter as shown in the example above. - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateX - * @see rotateY - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotateZ = function(angleInRadians) { - forwardTransform.rotateZ(angleInRadians); - reverseTransform.invRotateZ(angleInRadians); - }; - - /** - * Rotates a shape around the y-axis the amount specified by the angle parameter. Angles should be - * specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * Objects are always rotated around their relative position to the origin and positive numbers - * rotate objects in a counterclockwise direction. Transformations apply to everything that happens - * after and subsequent calls to the function accumulates the effect. For example, calling rotateY(PI/2) - * and then rotateY(PI/2) is the same as rotateY(PI). If rotateY() is called within the draw(), the - * transformation is reset when the loop begins again. This function requires passing P3D or OPENGL - * into the size() parameter as shown in the example above. - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateX - * @see rotateZ - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotateY = function(angleInRadians) { - forwardTransform.rotateY(angleInRadians); - reverseTransform.invRotateY(angleInRadians); - }; - - /** - * Rotates a shape the amount specified by the angle parameter. Angles should be specified in radians - * (values from 0 to TWO_PI) or converted to radians with the radians() function. Objects are always - * rotated around their relative position to the origin and positive numbers rotate objects in a - * clockwise direction. Transformations apply to everything that happens after and subsequent calls - * to the function accumulates the effect. For example, calling rotate(HALF_PI) and then rotate(HALF_PI) - * is the same as rotate(PI). All tranformations are reset when draw() begins again. Technically, - * rotate() multiplies the current transformation matrix by a rotation matrix. This function can be - * further controlled by the pushMatrix() and popMatrix(). - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateX - * @see rotateY - * @see rotateZ - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotate = function rotate(angleInRadians) { - if (p.use3DContext) { - forwardTransform.rotateZ(angleInRadians); - reverseTransform.invRotateZ(angleInRadians); - } else { - curContext.rotate(angleInRadians); - } - }; - - /** - * The pushStyle() function saves the current style settings and popStyle() restores the prior settings. - * Note that these functions are always used together. They allow you to change the style settings and later - * return to what you had. When a new style is started with pushStyle(), it builds on the current style information. - * The pushStyle() and popStyle() functions can be embedded to provide more control (see the second example - * above for a demonstration.) - * The style information controlled by the following functions are included in the style: fill(), stroke(), tint(), - * strokeWeight(), strokeCap(), strokeJoin(), imageMode(), rectMode(), ellipseMode(), shapeMode(), colorMode(), - * textAlign(), textFont(), textMode(), textSize(), textLeading(), emissive(), specular(), shininess(), ambient() - * - * @returns none - * - * @see popStyle - */ - p.pushStyle = function pushStyle() { - // Save the canvas state. - saveContext(); - - p.pushMatrix(); - - var newState = { - 'doFill': doFill, - 'currentFillColor': currentFillColor, - 'doStroke': doStroke, - 'currentStrokeColor': currentStrokeColor, - 'curTint': curTint, - 'curRectMode': curRectMode, - 'curColorMode': curColorMode, - 'colorModeX': colorModeX, - 'colorModeZ': colorModeZ, - 'colorModeY': colorModeY, - 'colorModeA': colorModeA, - 'curTextFont': curTextFont, - 'curTextSize': curTextSize - }; - - styleArray.push(newState); - }; - - /** - * The pushStyle() function saves the current style settings and popStyle() restores the prior settings; these - * functions are always used together. They allow you to change the style settings and later return to what you had. - * When a new style is started with pushStyle(), it builds on the current style information. The pushStyle() and - * popStyle() functions can be embedded to provide more control (see the second example above for a demonstration.) - * - * @returns none - * - * @see pushStyle - */ - p.popStyle = function popStyle() { - var oldState = styleArray.pop(); - - if (oldState) { - restoreContext(); - - p.popMatrix(); - - doFill = oldState.doFill; - currentFillColor = oldState.currentFillColor; - doStroke = oldState.doStroke; - currentStrokeColor = oldState.currentStrokeColor; - curTint = oldState.curTint; - curRectMode = oldState.curRectmode; - curColorMode = oldState.curColorMode; - colorModeX = oldState.colorModeX; - colorModeZ = oldState.colorModeZ; - colorModeY = oldState.colorModeY; - colorModeA = oldState.colorModeA; - curTextFont = oldState.curTextFont; - curTextSize = oldState.curTextSize; - } else { - throw "Too many popStyle() without enough pushStyle()"; - } - }; - - //////////////////////////////////////////////////////////////////////////// - // Time based functions - //////////////////////////////////////////////////////////////////////////// - - /** - * Processing communicates with the clock on your computer. - * The year() function returns the current year as an integer (2003, 2004, 2005, etc). - * - * @returns {float} The current year. - * - * @see millis - * @see second - * @see minute - * @see hour - * @see day - * @see month - */ - p.year = function year() { - return new Date().getFullYear(); - }; - /** - * Processing communicates with the clock on your computer. - * The month() function returns the current month as a value from 1 - 12. - * - * @returns {float} The current month. - * - * @see millis - * @see second - * @see minute - * @see hour - * @see day - * @see year - */ - p.month = function month() { - return new Date().getMonth() + 1; - }; - /** - * Processing communicates with the clock on your computer. - * The day() function returns the current day as a value from 1 - 31. - * - * @returns {float} The current day. - * - * @see millis - * @see second - * @see minute - * @see hour - * @see month - * @see year - */ - p.day = function day() { - return new Date().getDate(); - }; - /** - * Processing communicates with the clock on your computer. - * The hour() function returns the current hour as a value from 0 - 23. - * - * @returns {float} The current hour. - * - * @see millis - * @see second - * @see minute - * @see month - * @see day - * @see year - */ - p.hour = function hour() { - return new Date().getHours(); - }; - /** - * Processing communicates with the clock on your computer. - * The minute() function returns the current minute as a value from 0 - 59. - * - * @returns {float} The current minute. - * - * @see millis - * @see second - * @see month - * @see hour - * @see day - * @see year - */ - p.minute = function minute() { - return new Date().getMinutes(); - }; - /** - * Processing communicates with the clock on your computer. - * The second() function returns the current second as a value from 0 - 59. - * - * @returns {float} The current minute. - * - * @see millis - * @see month - * @see minute - * @see hour - * @see day - * @see year - */ - p.second = function second() { - return new Date().getSeconds(); - }; - /** - * Returns the number of milliseconds (thousandths of a second) since starting a sketch. - * This information is often used for timing animation sequences. - * - * @returns {long} The number of milliseconds since starting the sketch. - * - * @see month - * @see second - * @see minute - * @see hour - * @see day - * @see year - */ - p.millis = function millis() { - return new Date().getTime() - start; - }; - - /** - * Executes the code within draw() one time. This functions allows the program to update - * the display window only when necessary, for example when an event registered by - * mousePressed() or keyPressed() occurs. - * In structuring a program, it only makes sense to call redraw() within events such as - * mousePressed(). This is because redraw() does not run draw() immediately (it only sets - * a flag that indicates an update is needed). - * Calling redraw() within draw() has no effect because draw() is continuously called anyway. - * - * @returns none - * - * @see noLoop - * @see loop - */ - p.redraw = function redraw() { - var sec = (new Date().getTime() - timeSinceLastFPS) / 1000; - framesSinceLastFPS++; - var fps = framesSinceLastFPS / sec; - - // recalculate FPS every half second for better accuracy. - if (sec > 0.5) { - timeSinceLastFPS = new Date().getTime(); - framesSinceLastFPS = 0; - p.__frameRate = fps; - } - - p.frameCount++; - - inDraw = true; - - if (p.use3DContext) { - // even if the color buffer isn't cleared with background(), - // the depth buffer needs to be cleared regardless. - curContext.clear(curContext.DEPTH_BUFFER_BIT); - curContextCache = { attributes: {}, locations: {} }; - // Delete all the lighting states and the materials the - // user set in the last draw() call. - p.noLights(); - p.lightFalloff(1, 0, 0); - p.shininess(1); - p.ambient(255, 255, 255); - p.specular(0, 0, 0); - p.camera(); - p.draw(); - } else { - saveContext(); - p.draw(); - restoreContext(); - } - - inDraw = false; - }; - - /** - * Stops Processing from continuously executing the code within draw(). If loop() is - * called, the code in draw() begin to run continuously again. If using noLoop() in - * setup(), it should be the last line inside the block. - * When noLoop() is used, it's not possible to manipulate or access the screen inside event - * handling functions such as mousePressed() or keyPressed(). Instead, use those functions - * to call redraw() or loop(), which will run draw(), which can update the screen properly. - * This means that when noLoop() has been called, no drawing can happen, and functions like - * saveFrame() or loadPixels() may not be used. - * Note that if the sketch is resized, redraw() will be called to update the sketch, even - * after noLoop() has been specified. Otherwise, the sketch would enter an odd state until - * loop() was called. - * - * @returns none - * - * @see redraw - * @see draw - * @see loop - */ - p.noLoop = function noLoop() { - doLoop = false; - loopStarted = false; - clearInterval(looping); - }; - - /** - * Causes Processing to continuously execute the code within draw(). If noLoop() is called, - * the code in draw() stops executing. - * - * @returns none - * - * @see noLoop - */ - p.loop = function loop() { - if (loopStarted) { - return; - } - - looping = window.setInterval(function() { - //try { - if (document.hasFocus instanceof Function) { - p.focused = document.hasFocus(); - } - p.redraw(); - //} catch(e_loop) { - //window.clearInterval(looping); - //throw e_loop; - //} - }, curMsPerFrame); - doLoop = true; - loopStarted = true; - }; - - /** - * Specifies the number of frames to be displayed every second. If the processor is not - * fast enough to maintain the specified rate, it will not be achieved. For example, the - * function call frameRate(30) will attempt to refresh 30 times a second. It is recommended - * to set the frame rate within setup(). The default rate is 60 frames per second. - * - * @param {int} aRate number of frames per second. - * - * @returns none - * - * @see delay - */ - p.frameRate = function frameRate(aRate) { - curFrameRate = aRate; - curMsPerFrame = 1000 / curFrameRate; - - // clear and reset interval - if (doLoop) { - p.noLoop(); - p.loop(); - } - }; - - var eventHandlers = []; - - /** - * Quits/stops/exits the program. Programs without a draw() function exit automatically - * after the last line has run, but programs with draw() run continuously until the - * program is manually stopped or exit() is run. - * Rather than terminating immediately, exit() will cause the sketch to exit after draw() - * has completed (or after setup() completes if called during the setup() method). - * - * @returns none - */ - p.exit = function exit() { - window.clearInterval(looping); - - Processing.removeInstance(p.externals.canvas.id); - - // Step through the libraries to detach them - for (var lib in Processing.lib) { - if (Processing.lib.hasOwnProperty(lib)) { - if (Processing.lib[lib].hasOwnProperty("detach")) { - Processing.lib[lib].detach(p); - } - } - } - - for (var i=0, ehl=eventHandlers.length; i 1 || (arguments.length === 1 && arguments[0] instanceof p.PImage)) { - var image = arguments[0], - x, y; - if (arguments.length >= 3) { - x = arguments[1]; - y = arguments[2]; - if (x < 0 || y < 0 || y >= image.height || x >= image.width) { - throw "x and y must be non-negative and less than the dimensions of the image"; - } - } else { - x = image.width >>> 1; - y = image.height >>> 1; - } - - // see https://developer.mozilla.org/en/Using_URL_values_for_the_cursor_property - var imageDataURL = image.toDataURL(); - var style = "url(\"" + imageDataURL + "\") " + x + " " + y + ", default"; - curCursor = curElement.style.cursor = style; - } else if (arguments.length === 1) { - var mode = arguments[0]; - curCursor = curElement.style.cursor = mode; - } else { - curCursor = curElement.style.cursor = oldCursor; - } - }; - - /** - * Hides the cursor from view. - * - * @returns none - * - * @see cursor - */ - p.noCursor = function noCursor() { - curCursor = curElement.style.cursor = PConstants.NOCURSOR; - }; - - /** - * Links to a webpage either in the same window or in a new window. The complete URL - * must be specified. - * - * @param {String} href complete url as a String in quotes - * @param {String} target name of the window to load the URL as a string in quotes - * - * @returns none - */ - p.link = function(href, target) { - if (target !== undef) { - window.open(href, target); - } else { - window.location = href; - } - }; - - // PGraphics methods - // TODO: These functions are suppose to be called before any operations are called on the - // PGraphics object. They currently do nothing. - p.beginDraw = function beginDraw() {}; - p.endDraw = function endDraw() {}; - - // Imports an external Processing.js library - p.Import = function Import(lib) { - // Replace evil-eval method with a DOM - - - - - - - - - - - -
          -
          - diff --git a/game/old/scores/scores.js b/game/old/scores/scores.js deleted file mode 100644 index d6403b2..0000000 --- a/game/old/scores/scores.js +++ /dev/null @@ -1,221 +0,0 @@ -var make_scores = function(){ - var obj = {}; - - var num_rows = 15; - - // async gets scores and feeds to callback - var get_scores = function(callback){ - // ajax request to get scores - - // want to do them sequentially so we - // chain the callbacks - - // this comes third via callback - var do_global = function() { - // Global High Scores - $.post("scores/get_scores.php", { - num: num_rows, - }, callback("Global Scores", - // at the end of last callback we need to - // make the tabs - function() { - console.log("making tabs"); - $("#scores").tabs(); - - // remove the loading message - console.log("removing loading msg"); - $("#scores-loading").remove(); - - $("#scores").show(); - } - )); - }; - - // this comes second via callback - var do_friends = function() { - var friends = g_get_friends(); - if (friends.length !== 0) { - // Global High Scores - $.post("scores/get_scores.php", { - num: num_rows, - uid: g_user_id, - friends: friends - }, callback("Friends' Scores", do_global)); - console.log("got friends scores"); - } - else { - do_global(); - console.log("skipped friends scores"); - } - }; - - // this comes first - // Personal high scores - if (g_user_id) { - $.post("scores/get_scores.php", { - num: num_rows, - uid : g_user_id - }, callback("Your Scores", do_friends)); - console.log("getting user high scores"); - } - else { - do_global(); - } - }; - - var get_user_scores = function(callback) { - $.post("scores/get_scores.php", { - num : num_rows - }, callback); - }; - - // interprets json and displays it - // Passing it a header returns the actual function - // Must use this style so long as get_scores is async - // Passing a function as do_more does it at the end of the callback - var tab_count = 1; - var display_scores = function(header, do_more) { - var headers = [ "Rank", "Score", "Level", "Name", "Date" ]; - var formatters = { - "score": add_commas, - "date": function(date_str) { - //var d = new Date(date_str); - var d = new Date(); - // date_str must be of format yyyy-mm-dd - var year = parseInt(date_str.substring(0, 4)); - var month = parseInt(date_str.substring(5, 7))-1; - var day = parseInt(date_str.substring(8)); - d.setFullYear(year, month, day); - //return d.f("NNN d, yyyy"); - return d.format("mmm d, yyyy"); - }, - }; - return function(data){ - //console.log(data); - - var link = "
        • " - + header + "
        • "; - $("#tab-list").append(link); - - // con is the content to put in the score tab - var con = "
          "; - - try { - var scores = jQuery.parseJSON(data); - if (!scores) { - throw "No scores loaded"; - } - } - catch (e) { - con += "
          Error loading scores." - +" Please check your internet connection."; - } - if (scores) { - - con += "
          "; - - // -- start header row -- - con += ""; - for_each(headers, function(header) { - con += ""; - }); - con += ""; - // -- end header row -- - - //console.log(scores); - // scores is an array of row objects - var row_count = 1; - for_each(scores, function(row){ - con += ""; - con += ""; - for_each(keys(row), function(key){ - var f = formatters[key] || function(x) { return x; }; - // dont show uid - if (key !== "userid") { - con += ""; - } - }); - con += ""; - row_count += 1; - }); - // fill up rest of table for beauty's sake - while (row_count <= num_rows) { - con += ""; - for_each(headers, function(header){ - con += ""; - }); - con += ""; - row_count += 1; - } - - con += "
          " + header + "
          " + row_count + "." + f(row[key]) + "
           
          "; - con += ""; - - } - - // add it to page - $("#scores").append(con); - // update tab num - tab_count += 1; - - // do some more stuff if necessary - if (do_more) { - do_more(); - } - }; - }; - - // gets and displays scores - obj.do_scores = function(){ - console.log("trying to load scores"); - $("#scores").empty(); - $("#scores").hide(); - $("#scores").append("
            "); - // reset tab count - tab_count = 1; - get_scores(display_scores); - }; - - // inserts a score into the db - // score_obj: - // - score: int score - // - level: mutation level - // - userid: unique id for the user (from fb?) - var post_score = function(score_obj, callback){ - $.post("scores/post_score.php", score_obj, callback); - }; - - // testing function to use with form - obj.submit_score = function(score, level, name, uid){ - /* - var form = document.forms[0]; - var score = form.elements[0].value; - var level = form.elements[1].value; - var userid = form.elements[2].value; - */ - var date_str = (new Date()).format("yyyy-mm-dd"); - - var score_obj = { - /* - score: parseInt(score), - level: parseInt(level), - */ - score: score, - level: level, - name: name, - userid: uid, - //date: new Date().f('yyyy-MM-dd') - date: date_str - }; - console.log(score_obj); - - post_score(score_obj, function(data){ - console.log(data); - //obj.do_scores(); - }); - }; - - return obj; -} - -var scores = make_scores(); diff --git a/game/old/seeker.js b/game/old/seeker.js deleted file mode 100644 index ba3c879..0000000 --- a/game/old/seeker.js +++ /dev/null @@ -1,127 +0,0 @@ -// ABSTRACT class for game objects that seek other game objects -// Classes that implement must override "my_update" instead of "update" -// --- inherits from object_with_states -// spec: -// game_object spec + -// speed = how fast the seeker approaches the target -// no_target_speed = how fast the object moves when there is no target -// target = object to move towards - -var seeker = function(p, spec) { - - // --- defaults --- - - // obj to return - var obj = object_with_states(p, spec); - - // --- private variables --- - - var speed = spec.speed || 0.2; - var no_target_speed = spec.no_target_speed || 0.2; - var alive = true; - var target = spec.target || null; - // initialized to random val at bottom - var target_angle = 0; - - // --- public methods --- - - // implementing game_object interface - - // update makes tkiller chase target cell - obj.update = function() { - var pos = obj.get_pos(); - var speed_to_use = speed; - - if (target && target.is_dead()) { - target = null; - } - - // if no target - if (target === null) { - // meander - if (parseInt(p.random(150)) === 0) { - target_angle += p.random(-p.PI/16, p.PI/16); - } - // laze - speed_to_use = no_target_speed; - } - else { - obj.face_target(); - } - - // change velocity to point towards target - var new_vel = new p.PVector( - p.cos(target_angle), p.sin(target_angle)); - new_vel.mult(speed_to_use); - obj.set_vel(new_vel); - - obj.my_update(); - }; - - // MUST BE OVERWRITTEN - obj.my_update = function() { - console.log("my_update (in seeker) not overwritten!"); - }; - - // Indicates that a mutation has occured and this object - // should float off the screen - // Makes this object stop and float off screen - obj.outdated = function() { - obj.set_state("outdated"); - obj.set_vel(new p.PVector(0,0)); - obj.set_target(null); - }; - - obj.is_outdated = function() { - return obj.get_state() === "outdated"; - }; - - // faces tar, or if tar not supplied, the object's - // target - obj.face_target = function(tar) { - var pos = obj.get_pos(); - if (target) { - var tpos = target.get_pos(); - } - if (tar) { - var tpos = tar.get_pos(); - } - if (tpos) { - // update target_angle - target_angle = p.atan2(tpos.y-pos.y, tpos.x-pos.x); // y first! - } - }; - - - obj.set_target = function(new_target) { - if (obj.get_state() !== "outdated") { - target = new_target; - } - }; - - obj.set_speed = function(new_speed) { - speed = new_speed; - }; - - obj.set_target_angle = function(new_target_angle) { - target_angle = new_target_angle; - }; - - obj.get_target = function() { - return target; - }; - - obj.get_target_angle = function() { - return target_angle; - }; - - // creates a random angle for init'ing - obj.random_target_angle = function() { - return p.random(-p.PI, p.PI); - //Math.random() * (p.PI * 2) - p.PI; //random angle - }; - target_angle = obj.random_target_angle(); - - - return obj; -} diff --git a/game/old/settings.js b/game/old/settings.js deleted file mode 100644 index 691f6e2..0000000 --- a/game/old/settings.js +++ /dev/null @@ -1,66 +0,0 @@ -// Global settings -// Have to be wrapped in an object since primitives are pass-by-value -var game_settings = function() { - var settings = { - sound_fx : true, - music : true, - track: "no track", - click_to_fire : true, - mouse_to_select : false, - spacebar_to_fire : true, - background_color : 0xFF371010 - }; - - var toggle = function(name) { - settings[name] = !settings[name]; - }; - - settings.toggle_sound_fx = function() { toggle("sound_fx"); }; - settings.toggle_click_to_fire = function() { toggle("click_to_fire"); }; - settings.toggle_spacebar_to_fire = function() { toggle("spacebar_to_fire"); }; - settings.toggle_mouse_to_select = function() { toggle("mouse_to_select"); }; - // note that this only toggles the flag, not the actual music - // that should be done with a sound manager method - settings.toggle_music = function() { - toggle("music"); - //console.log(settings.music); - if (settings.music) { - sounds.play_menu_music(); - } - else { - sounds.pause_menu_music(); - } - }; - - settings.next_track = function() { - var t = sounds.next_track(); - settings.track = t; - }; - - settings.prev_track = function() { - var t = sounds.prev_track(); - settings.track = t; - }; - - settings.set_track = function(t) { - settings.track = t; - }; - - return settings; -}; -// abbreviate it -var g = game_settings(); - - -//getters -/* -var g_sound_fx_on = function() { - return g_game_settings.sound_fx; -} -var g_music_on = function() { - return g_game_settings.music; -} -var g_click_to_fire = function() { - return g_game_settings.click_to_fire; -} -*/ diff --git a/game/old/sound.js b/game/old/sound.js deleted file mode 100644 index 092bba8..0000000 --- a/game/old/sound.js +++ /dev/null @@ -1,344 +0,0 @@ -// sound_manager -// utility object to play or not play sounds -// settings for sound still stored in settings object -var sound_manager = function() { - var obj = {}; - - var the_swf_path = "./jplayer/"; - // Taken from http://www.storiesinflight.com/html5/audio.html - - //g_divs_loaded_init_sounds = function() { - //console.log("AAAAA initing sounds"); - obj.play_sound = (function() { - var channel_max = 10; // number of channels - audiochannels = new Array(); - for (var a=0;a= all_bg_music.length) { - track_index = 0; - } - // pause the old one - obj.pause_background_music(); - // set the new one - set_background_music(); - //obj.play_background_music(); - return all_bg_music[track_index].name; - }; - - obj.prev_track = function() { - track_index -= 1; - if (track_index < 0) { - track_index = all_bg_music.length-1; - } - // pause the old one - obj.pause_background_music(); - // set the new one - set_background_music(); - return all_bg_music[track_index].name; - }; - - // sets the background music to the current track index - var set_background_music = function() { - // note that random must be the LAST track - var music = all_bg_music[track_index].music; - if (!music) { - music = all_bg_music - [Math.floor(Math.random()*(track_index-1))] - .music; - } - assert(music, "Random wasn't the last track index or a music div was undefined."); - background_music = music; - }; - - obj.resume_background_music = function() { - if (background_music) - background_music.jPlayer("play"); - } - - obj.pause_background_music = function() { - console.log("Pausing bg music"); - if (background_music) - background_music.jPlayer("pause"); - }; - - var menu_music = null; - var button_sounds = null; - - // Really resume menu music, menu music never restarts - obj.play_menu_music = function() { - if (g.music) - menu_music.jPlayer("play"); - } - obj.resume_menu_music = function() { - if (g.music) - menu_music.jPlayer("play"); - } - obj.pause_menu_music = function() { - menu_music.jPlayer("pause"); - } - obj.play_button_click = function() { - if (g.sound_fx) - play_a_sound(button_sounds, "buttonmain"); - } - obj.play_button_back = function() { - if (g.sound_fx) - play_a_sound(button_sounds, "buttonback"); - } - - var play_a_sound = function(jplayer_instance, sound_name) { - jplayer_instance.jPlayer("setMedia", { - //mp3 : g_soundDataMap[sound_name + "mp3"], - mp3 : "sounds/" + sound_name + ".mp3", - oga : g_soundDataMap[sound_name] - }); - //jplayer_instance.jPlayer.event.ready = function() {console.log("read");}; - jplayer_instance.jPlayer("play"); - } - - obj.load_sounds = function() { - // init all bg music - var all_supplied = "oga, mp3"; - var init_jplayer = function(name, mp3name, oggname, should_loop) { - $(name).jPlayer( { - swfPath : the_swf_path, - ready: function () { - $(this).jPlayer("setMedia", { - mp3 : "sounds/"+mp3name, - oga : "sounds/"+oggname - }); - //console.log(name + " is ready"); - bg_music_loaded(); - $(this).bind($.jPlayer.event.progress, - function(event) { - //console.log(event.jPlayer.status.seekPercent); - if (event.jPlayer.status.seekPercent === 100) { - //console.log("percent = 100, name: " + mp3name); - //bg_music_loaded(); - } - }); - $(this).bind($.jPlayer.error.NO_SOLUTION, - function(event) { - //bg_music_loaded(); - console.log("No audio solutions"); - }); - }, - ended : function() { // loop - if (should_loop) { - $(this).jPlayer("play"); - } - }, - supplied : all_supplied, - preload : "auto", - oggSupport: true - //errorAlerts : true - }); - } - - var init_bg_jplayer = function(num, file_name, oggfn) { - init_jplayer("#jquery_jplayer_bg_"+num, file_name, oggfn, true) - } - /* - console.log("loading heart loop"); - init_bg_jplayer(0, "heart_loop1.mp3"); - console.log("loaded heart loop"); - */ - console.log("loading sinister"); - init_bg_jplayer(0, "sinister.mp3", "sinister.ogg", true); - console.log("loaded sinister"); - - init_bg_jplayer(1, "gameloop2.mp3", "gameloop2.ogg", true); - init_bg_jplayer(2, "Infiltration.mp3", "Infiltration.ogg", true); - - for (var i = 0; i < num_bg_music; i++) { - all_bg_music.push({ - music: $("#jquery_jplayer_bg_"+i), - name: track_names[i] - }); - } - - init_jplayer("#jquery_jplayer_menu", "menu_loop.mp3", "menu_loop.ogg", true); - menu_music = $("#jquery_jplayer_menu"); - - init_jplayer("#jquery_jplayer_buttons", "buttonmain.mp3", "buttonmain.ogg", false); - button_sounds = $("#jquery_jplayer_buttons"); - - // add random option - // THIS MUST BE THE LAST OBJ IN THE ARRAY - all_bg_music.push({ - name: "Random", - // don't try to access this music! - music: null - }); - track_names.push("Random"); - num_bg_music += 1; - track_index = num_bg_music-1; - // set initial track (random) - g.set_track(track_names[track_index]); - }; - - var num_loaded = 0; - var max_loaded = num_bg_music + 2 // + 1 for menu music, + 1 for button - var bg_music_loaded = function() { - num_loaded++; - console.log("Loaded " + num_loaded + " out of " + max_loaded); - }; - - obj.sounds_loaded = function() { - //console.log(num_loaded); - return num_loaded >= max_loaded; - } - return obj; -}; - -// make a global object -var sounds = sound_manager(); - -// to debug without sounds, use this object -/* -var sounds = { - sounds_loaded: function() { return true; }, - play_sound: function() {}, - play_background_music: function() {}, - pause_background_music: function() {}, - resume_background_music: function() {}, - load_sounds: function() {}, -}; -*/ - - - -/* -var jplayer = $("#jquery_jplayer_1").jPlayer( { - ready: function () { - $(this).jPlayer("setMedia", { - oga :g_soundDataMap["kill"] // "/sounds/kill.ogg" - //mp3 : "sounds/heart_loop1.mp3" - }); - $(this).jPlayer("play"); - //asdf_play(); - console.log("ready"); - }, - supplied : "oga" -}); -//$("#jquery_jplayer_1").jPlayer("setMedia", {mp3 : "sounds/heart_loop1.mp3"}); -var asdf_play = function(){ - $("#jquery_jplayer_1").jPlayer("play"); -}; - -*/ diff --git a/game/old/sounds/Infiltration.mp3 b/game/old/sounds/Infiltration.mp3 deleted file mode 100755 index eb48089..0000000 Binary files a/game/old/sounds/Infiltration.mp3 and /dev/null differ diff --git a/game/old/sounds/Infiltration.ogg b/game/old/sounds/Infiltration.ogg deleted file mode 100755 index 5cce4b5..0000000 Binary files a/game/old/sounds/Infiltration.ogg and /dev/null differ diff --git a/game/old/sounds/buttonback.mp3 b/game/old/sounds/buttonback.mp3 deleted file mode 100755 index 730c75f..0000000 Binary files a/game/old/sounds/buttonback.mp3 and /dev/null differ diff --git a/game/old/sounds/buttonback.ogg b/game/old/sounds/buttonback.ogg deleted file mode 100755 index 109a1e9..0000000 Binary files a/game/old/sounds/buttonback.ogg and /dev/null differ diff --git a/game/old/sounds/buttonmain.mp3 b/game/old/sounds/buttonmain.mp3 deleted file mode 100755 index aea705c..0000000 Binary files a/game/old/sounds/buttonmain.mp3 and /dev/null differ diff --git a/game/old/sounds/buttonmain.ogg b/game/old/sounds/buttonmain.ogg deleted file mode 100755 index 81c13d7..0000000 Binary files a/game/old/sounds/buttonmain.ogg and /dev/null differ diff --git a/game/old/sounds/cell_fire.mp3 b/game/old/sounds/cell_fire.mp3 deleted file mode 100755 index 0e3ebf3..0000000 Binary files a/game/old/sounds/cell_fire.mp3 and /dev/null differ diff --git a/game/old/sounds/cell_fire.ogg b/game/old/sounds/cell_fire.ogg deleted file mode 100755 index 7e91316..0000000 Binary files a/game/old/sounds/cell_fire.ogg and /dev/null differ diff --git a/game/old/sounds/cell_infect.mp3 b/game/old/sounds/cell_infect.mp3 deleted file mode 100755 index 5bc1007..0000000 Binary files a/game/old/sounds/cell_infect.mp3 and /dev/null differ diff --git a/game/old/sounds/cell_infect.ogg b/game/old/sounds/cell_infect.ogg deleted file mode 100755 index 57aaaea..0000000 Binary files a/game/old/sounds/cell_infect.ogg and /dev/null differ diff --git a/game/old/sounds/gameloop2.mp3 b/game/old/sounds/gameloop2.mp3 deleted file mode 100755 index 5c8f4c3..0000000 Binary files a/game/old/sounds/gameloop2.mp3 and /dev/null differ diff --git a/game/old/sounds/gameloop2.ogg b/game/old/sounds/gameloop2.ogg deleted file mode 100755 index 1c94d25..0000000 Binary files a/game/old/sounds/gameloop2.ogg and /dev/null differ diff --git a/game/old/sounds/kill.mp3 b/game/old/sounds/kill.mp3 deleted file mode 100755 index 6bdfebe..0000000 Binary files a/game/old/sounds/kill.mp3 and /dev/null differ diff --git a/game/old/sounds/kill.ogg b/game/old/sounds/kill.ogg deleted file mode 100755 index deed4fc..0000000 Binary files a/game/old/sounds/kill.ogg and /dev/null differ diff --git a/game/old/sounds/level_up.mp3 b/game/old/sounds/level_up.mp3 deleted file mode 100755 index 55e3fcf..0000000 Binary files a/game/old/sounds/level_up.mp3 and /dev/null differ diff --git a/game/old/sounds/level_up.ogg b/game/old/sounds/level_up.ogg deleted file mode 100755 index 468cae0..0000000 Binary files a/game/old/sounds/level_up.ogg and /dev/null differ diff --git a/game/old/sounds/macrophage_infect.mp3 b/game/old/sounds/macrophage_infect.mp3 deleted file mode 100755 index 472498e..0000000 Binary files a/game/old/sounds/macrophage_infect.mp3 and /dev/null differ diff --git a/game/old/sounds/macrophage_infect.ogg b/game/old/sounds/macrophage_infect.ogg deleted file mode 100755 index 0a49c6f..0000000 Binary files a/game/old/sounds/macrophage_infect.ogg and /dev/null differ diff --git a/game/old/sounds/menu_loop.mp3 b/game/old/sounds/menu_loop.mp3 deleted file mode 100755 index 10f3c1d..0000000 Binary files a/game/old/sounds/menu_loop.mp3 and /dev/null differ diff --git a/game/old/sounds/menu_loop.ogg b/game/old/sounds/menu_loop.ogg deleted file mode 100755 index 2008e2f..0000000 Binary files a/game/old/sounds/menu_loop.ogg and /dev/null differ diff --git a/game/old/sounds/old/Level Up!2 Trimmed.ogg b/game/old/sounds/old/Level Up!2 Trimmed.ogg deleted file mode 100755 index ee8fa82..0000000 Binary files a/game/old/sounds/old/Level Up!2 Trimmed.ogg and /dev/null differ diff --git a/game/old/sounds/old/cell_fire.ogg b/game/old/sounds/old/cell_fire.ogg deleted file mode 100644 index bbec785..0000000 Binary files a/game/old/sounds/old/cell_fire.ogg and /dev/null differ diff --git a/game/old/sounds/old/cell_fire.wav b/game/old/sounds/old/cell_fire.wav deleted file mode 100644 index 77f1ba9..0000000 Binary files a/game/old/sounds/old/cell_fire.wav and /dev/null differ diff --git a/game/old/sounds/old/cell_infect.ogg b/game/old/sounds/old/cell_infect.ogg deleted file mode 100644 index a3d5cf8..0000000 Binary files a/game/old/sounds/old/cell_infect.ogg and /dev/null differ diff --git a/game/old/sounds/old/cell_infect.wav b/game/old/sounds/old/cell_infect.wav deleted file mode 100644 index 8cb4011..0000000 Binary files a/game/old/sounds/old/cell_infect.wav and /dev/null differ diff --git a/game/old/sounds/old/kill.ogg b/game/old/sounds/old/kill.ogg deleted file mode 100755 index c127f02..0000000 Binary files a/game/old/sounds/old/kill.ogg and /dev/null differ diff --git a/game/old/sounds/old/level_up.ogg b/game/old/sounds/old/level_up.ogg deleted file mode 100755 index d1b818c..0000000 Binary files a/game/old/sounds/old/level_up.ogg and /dev/null differ diff --git a/game/old/sounds/old/macrophage_infect.ogg b/game/old/sounds/old/macrophage_infect.ogg deleted file mode 100644 index 684fc34..0000000 Binary files a/game/old/sounds/old/macrophage_infect.ogg and /dev/null differ diff --git a/game/old/sounds/sinister.mp3 b/game/old/sounds/sinister.mp3 deleted file mode 100755 index 95905df..0000000 Binary files a/game/old/sounds/sinister.mp3 and /dev/null differ diff --git a/game/old/sounds/sinister.ogg b/game/old/sounds/sinister.ogg deleted file mode 100755 index e5e2d94..0000000 Binary files a/game/old/sounds/sinister.ogg and /dev/null differ diff --git a/game/old/splash_state.js b/game/old/splash_state.js deleted file mode 100644 index 9b57b58..0000000 --- a/game/old/splash_state.js +++ /dev/null @@ -1,202 +0,0 @@ -var splash_state = function (p) { - - // object to return - var obj = game_state(p); - - // --- private variables --- - - //var header_image = p.loadImage("images/screens/header.png"); - var back_image = image_manager.get_image("mainscreenbase.png"); - var back_color = g.background_color; - - // Buttons - // Have a rectangle representing their position and - // a state to go to when pressed - - var top_row_y = 200; - var btm_row_y = 480; - var left_x = 460; - var button_style = { - height: 160, - rect_color: back_color - }; - - // Play menu music - sounds.play_menu_music(); - - var pause_menu_music = function() { - sounds.pause_menu_music(); - }; - - var start_button = button(p, { - state : function() { - pause_menu_music(); - sounds.play_button_click(); - return in_game_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x, top_row_y), - image: "mnewgame.png", - over_image: "mnewgame_r.png", - width: 80, - style: button_style, - } - }); - - var help_button = button(p, { - state : function() { - sounds.play_button_click(); - return help_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x+150, top_row_y), - image: "mhowtoplay.png", - over_image: "mhowtoplay_r.png", - width: 100, - style: button_style, - } - }); - - var options_button = button(p, { - state : function() { - sounds.play_button_click(); - return options_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x, btm_row_y), - image: "msettings.png", - over_image: "msettings_r.png", - width: 120, - style: button_style, - } - }); - - var scores_button = button(p, { - state : function() { - sounds.play_button_click(); - return high_scores_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x+150, btm_row_y), - image: "mhighscores.png", - over_image: "mhighscores_r.png", - //text: "High Scores", - width: 100, - style: button_style, - } - }); - - var credits_button = button(p, { - state : function() { - sounds.play_button_click(); - return credits_state(p, obj); - }, - rect: { - pos: new p.PVector(p.width-100, 30), - image: "credits.png", - width: 200, - height: 50, - } - }); - - /* - var splash_style = { - width : 170, - height : 40, - text_color: 0xFFEE0000, - rect_color: back_color, - text_size: 30, - text_align: p.LEFT - }; - - var button_x = 500; - var button_top = 150; - var button_sep = 60; - - var start_button = button(p, { - state : function() { return in_game_state(p, obj); }, - rect : { - pos : new p.PVector(button_x, button_top), - style : splash_style, - text : "New Game" - //image : "images/screens/newgame_listcell.png" - } - }); - - var options_button = button(p, { - state : function() { return options_state(p, obj); }, - rect : { - pos : new p.PVector(button_x, button_top+button_sep), - style : splash_style, - text : "Settings" - } - }); - - var help_button = button(p, { - state : function() { return help_state(p, obj); }, - rect : { - pos : new p.PVector(button_x, button_top+2*button_sep), - style : splash_style, - text : "How To Play" - } - }); - /* - var high_scores_button = { - state : high_scores_state(), - rectangle : rectangle(p, { - pos : new p.PVector(20, 20), - width : 20, - height : 20 - }) - }; - */ - - //Not ordered - var all_buttons = [start_button, options_button, - help_button, scores_button, credits_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "splash"; - }; - - obj.update = function() { - //do nothing - }; - - obj.key_pressed = function(k) { - if (k === 115 || p.keyCode === 13 || k === 32) { //s, enter, space - obj.set_next_state(start_button.get_state()); - pause_menu_music(); - } - else if (k === 104) { //h - obj.set_next_state(help_button.get_state()); - } - }; - - /* - obj.mouse_moved = function(x, y) { - - for_each( - all_buttons, - function(b) { - b.mouse_moved(x, y); - } - ); - }; - */ - - obj.get_all_buttons = function() { - return all_buttons; - }; - - obj.render = function() { - p.background(back_color); - p.imageMode(p.CENTER); - //p.image(header_image, p.width / 2, 100, p.width * 3/4, 100); - p.image(back_image, p.width/2, p.height/2); - }; - - return obj; -}; diff --git a/game/old/state_manager.js b/game/old/state_manager.js deleted file mode 100644 index 811716b..0000000 --- a/game/old/state_manager.js +++ /dev/null @@ -1,187 +0,0 @@ -// *** state_manager *** -// The game engine; manages all of the games states -// Provides update(), mouse_click(x, y), and key_pressed(k) -// The next state to go to, if applicable, is returned by state.update() - -var state_manager = function (p) { - - // object to return - var obj = {}; - - // --- private variables --- - - var curr_state = loading_state(p); //The currently active state - //p.noLoop(); - var displayed_states = [curr_state]; //THIS MUST ALWAYS BE SORTED BY RENDERING LEVEL - - //A mapping from game states to their rendering levels - var type_to_level = { - "splash": 0, - "loading" : 0, - "game": 1, - "game_over": 2, - "pause": 2, - "credits": 2, - "help": 2, - "options" : 2 - }; - - // --- private methods --- - - //Removes a state from the displayed_states - //The state must be in displayed_states, or will throw an error - function remove_from_displayed(s) { - var index = displayed_states.indexOf(s); - if (index === -1) { - throw "error in remove_from_displayed in state_manager"; - } - displayed_states.splice(index, 1); //remove the element - } - - //Adds a state to displayed_states - //Ensures that displayed_states is sorted by ascending rendering level - var add_to_displayed_states = function(s) { - var render_level = type_to_level[s.get_type()]; - //Insert in the array right before a render level that is higher than it, or - //at the end if none - var inserted = false; - for (var i = 0; i < displayed_states.length; i++) { - var old_render_level = type_to_level[displayed_states[i].get_type()]; - if (old_render_level > render_level) { - displayed_states.splice(i, 0, s); - inserted = true; - } - } - if (inserted === false) { //add to end - displayed_states.push(s); - } - } - - - // --- public methods --- - - //Updates the current state and renders all appropriate states - obj.update = function() { - // Update all the states, and get next_state from curr_state.update_wrapper(); - var next_state = null; - var update_function = function(s) { - if (s === curr_state) { - next_state = s.update_wrapper(); - } - else { - // i see no reason to update not current states - //s.update_wrapper(); - } - }; - for_each(displayed_states, update_function); - - //If we have a new state to go to - if (next_state && next_state !== curr_state) { - //console.log("next is "+next_state.get_type()); - //Figure out if next state is an overlay - var state_type = next_state.get_type(); - var is_overlay = -1; - switch (state_type) { - case "splash": - is_overlay = false; - p.noLoop(); - break; - case "game": - is_overlay = false; - p.loop(); - break; - case "pause": - is_overlay = true; - p.noLoop(); - break; - case "help": - is_overlay = true; - p.noLoop(); - break; - case "game_over": - is_overlay = true; - p.noLoop(); - break; - case "options": - is_overlay = true; - p.noLoop(); - break; - case "loading": - is_overlay = false; - p.loop(); - break; - case "high_scores": - is_overlay = true; - p.noLoop(); - break; - case "credits": - is_overlay = true; - p.noLoop(); - break; - } - - //Error checking - if (is_overlay === -1) { - throw "error in update in state_manager"; - } - - //If overlay, add to displayed, otherwise reset displayed - if (is_overlay) { - // account for multiple overlays - // so we can go back to an overlay - if (member(displayed_states, next_state)) { - remove_from_displayed(curr_state); - } - else { - add_to_displayed_states(next_state); - } - } - else { - displayed_states = [next_state]; - } - curr_state = next_state; - //Potentially a problem, we do this even if not returning to a state - curr_state.resume(); - // updating its buttons - curr_state.update_wrapper(); - } - - for (var i = 0; i < displayed_states.length; i++) { - displayed_states[i].render_wrapper(); - } - - /* - if (curr_state.get_type() !== "game") { - p.noLoop(); - } - else { - p.loop(); - } - */ - }; - - //Passes clicks on to curr_state - obj.mouse_click = function (x, y) { - curr_state.mouse_click_wrapper(x, y); - if (curr_state.get_type() !== "game") { - obj.update(); - } - }; - - obj.key_pressed = function(k) { - curr_state.key_pressed(k); - if (curr_state.get_type() !== "game") { - obj.update(); - } - }; - - obj.mouse_moved = function(x,y) { - curr_state.mouse_moved_wrapper(x, y); - if (curr_state.get_type() !== "game") { - obj.update(); - } - //obj.update(); - } - - return obj; -}; diff --git a/game/old/test.js b/game/old/test.js deleted file mode 100644 index cc645eb..0000000 --- a/game/old/test.js +++ /dev/null @@ -1,92 +0,0 @@ -// all the processing code goes in the function -// which gets passed in a processing instance p -var p_code = function(p) { - - var sm, t1, c1, c2; - - p.setup = function() { - p.size(700, 600); - - // deal with console issues - // TODO move this code - if (!window.console) { - console = { log: function() {} }; - } - Processing.logger = console; - - var f = new p.loadFont("_sans"); - p.textFont(f, 14); - - sm = state_manager(p); - - p.frameRate(30); - }; - - update_counter = 0; - // draw is called repeatedly - p.draw = function() { - update_counter += 1; - if (update_counter === 30) { - //console.log("frame "+p.millis()); - //console.log(p.__frameRate); - update_counter = 0; - } - sm.update(); // Also renders - }; - - //Mouse and Keyboard input - p.keyPressed = function() { - sm.key_pressed(p.key); - }; - p.mousePressed = function() { - sm.mouse_click(p.mouseX, p.mouseY); - }; - p.mouseMoved = function() { - sm.mouse_moved(p.mouseX, p.mouseY); - }; -}; - - -// want this to be global -var sketch; - -var start_game = function() { - // attaches the processing code to the canvas - // note that we need to do this AFTER the canvas element is created - var canvas = document.getElementById("test_canvas"); - sketch = new Processing.Sketch(p_code); - //sketch.options.isTransparent = true; - var pInstance = new Processing(canvas, sketch); -}; -window.onload = start_game; - -/* -var back_code = function(p) { - var tiles = []; - p.setup = function() { - p.size(700, 600); - p.frameRate(30); - tiles.push(background(p, { - pos: new p.PVector(0, 0) - })); - tiles.push(background(p, { - pos: new p.PVector(700, 0) - })); - }; - p.draw = function() { - p.background(200); - for_each(tiles, function(tile) { - tile.update(); - tile.scroll(1); - tile.draw(); - }); - }; -}; -*/ -//var back_canvas = document.getElementById("back_canvas"); -//var backInstance = new Processing(back_canvas, back_code); - -// Make spacebar not move the window down -window.onkeydown = function(e) { - return !(e.keyCode == 32); -}; diff --git a/game/old/tkiller.js b/game/old/tkiller.js deleted file mode 100644 index 1ae4dbb..0000000 --- a/game/old/tkiller.js +++ /dev/null @@ -1,121 +0,0 @@ -// *** tkiller *** -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards - -var tkiller = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 35; - spec.height = spec.height || 35; - spec.speed = spec.speed || 1.5; - - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "tkiller"; - }; - - // --- private variables --- - - var alive = true; - /* @pjs preload="images/tcell2.png"; */ - var t_image = image_manager.get_image("tcell_2.png"); - - // Rect to fill in - var rectx_offset = -(8/30)*obj.get_width(); - var recty_offset = -(7/30) * obj.get_height(); - var rect_width = (13 / 30) * obj.get_width(); - var rect_height = (17 / 30) * obj.get_height(); - - - var t_anim = animated_image("t_animation", {anim_rate : 6}); - var t_image; - t_anim.start(); - t_anim.loop(); - - // --- public methods --- - - // implementing game_object interface - - // update makes tkiller chase target cell - obj.my_update = function() { - obj.move(); - obj.set_speed(obj.get_level()/2 + 1); - }; - - // should point towards target - // (triangle for now) - obj.draw = function() { - var pos = obj.get_pos(); - /* - p.pushMatrix(); - - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.fill(50); - p.noStroke(); - - // rightward triangle - p.triangle(-w/2, -h/2, -w/2, h/2, w/2, 0); - - p.popMatrix(); - */ - p.pushMatrix(); - p.imageMode(obj.get_mode()); - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle() + p.PI / 2); - p.fill(obj.get_color()); - p.noStroke(); - p.rectMode(p.CORNER); - p.rect(rectx_offset, recty_offset, rect_width, rect_height); - //p.image(t_image, 0, 0, obj.get_width(), obj.get_height()); - if (obj.get_target() === null) { - t_anim.set_rate(6); - } - else { - t_anim.set_rate(3); - } - t_image = t_anim.get_frame(); - - if (obj.is_illustration()) { - t_image = image_manager.get_image("tcell_2.png"); - // to make it less transparent draw twice - p.image(t_image, 0, 0, - obj.get_width(), obj.get_height()); - } - - p.image(t_image, 0, 0, - obj.get_width(), obj.get_height()); - p.popMatrix(); - }; - - // is_dead just returns whether it isn't alive - obj.is_dead = function() { - return !alive; - }; - - // which means we need a way to die - obj.die = function() { - alive = false; - }; - - obj.stop_animation = function() { - t_anim.pause(); - }; - - obj.resume_animation = function() { - t_anim.start(); - }; - - return obj; -} diff --git a/game/old/wall_cell.js b/game/old/wall_cell.js deleted file mode 100644 index 62be000..0000000 --- a/game/old/wall_cell.js +++ /dev/null @@ -1,63 +0,0 @@ -// *** wall_cell *** -// --- inherits from game_object -// spec: -// game_object spec - -var wall_cell = function(p, spec) { - - var wall_image = image_manager.get_image("wallcell_1.png"); - - // --- defaults --- - - // temporarily dividing by 2 cuz image is too big - spec.width = spec.width || wall_image.width;///2 || 40; - spec.height = spec.height || wall_image.height;///2 || 20; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "wall_cell"; - }; - - // --- private variables --- - - var alive = true; - - // --- public methods --- - - // implementing game_object interface - - // update is back to the default - obj.update = function() { - obj.move(); - }; - - // (rect for now) - obj.draw = function() { - var pos = obj.get_pos(); - /* - p.shapeMode(obj.mode); - - p.fill(100); - p.noStroke(); - - var w = obj.get_width(); - var h = obj.get_height(); - p.rect(pos.x-w/2, pos.y-h/2, w, h); - */ - p.imageMode(obj.get_mode()); - p.image(wall_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - }; - - obj.is_dead = function() { - return !alive; - }; - - obj.die = function() { - alive = false; - }; - - - return obj; -} diff --git a/game/old/wall_segment.js b/game/old/wall_segment.js deleted file mode 100644 index db886ac..0000000 --- a/game/old/wall_segment.js +++ /dev/null @@ -1,114 +0,0 @@ -// list of specs for wall segments to use in the game -// later can include which image/shape to use -// MUST HAVE WIDTH AND HEIGHT SPECIFIED -/* -var wall_specs = [ - { width: 100, height: 51 } - //{ width: 100, height: 30, fill: 0 }, - //{ width: 200, height: 30, fill: 50 }, - //{ width: 50, height: 30, fill: 100 }, - //{ width: 150, height: 30, fill: 150 } -]; -*/ - -// *** wall_segment *** -// --- inherits from game_object -// spec: -// game_object spec -// boolean is_top = true if it is on the top of the screen -// pos should be at bottom left corner -// -// Each wall segment must match up with the other -// wall segments at each end -// Segment images should be formatted for the bottom wall - -var wall_segment = function(p, spec) { - - //var wall_shape = p.loadShape("images/cellwall1draft.svg"); - var wall_image = random_from( - image_manager.get_images("wall_segments")).image; - - // --- defaults --- - - // temporarily dividing by 3 because the images are 3x too big - spec.width = spec.width || wall_image.width;///3;// || 60; - spec.height = spec.height || wall_image.height;///3;// || 60; - spec.fill = spec.fill || 150; - spec.mode = p.CENTER; - // adjust to center coords - spec.pos.add(new p.PVector(spec.width/2, -spec.height/2)); - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "wall_segment"; - }; - - // --- private variables --- - - // --- public methods --- - - obj.get_y_offset = function() { - return obj.get_height()/2; - }; - - // implementing game_object interface - - // update is default (move) - - // (flat rect for now) - obj.draw = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - p.shapeMode(obj.mode); - // all diff colors for testing - p.fill(0);//spec.fill); - p.noStroke(); - - var w = obj.get_width(); - var h = obj.get_height(); - - p.translate(pos.x, pos.y); - - if (spec.is_top) { - p.rotate(p.PI); - } - - //p.rect(-w/2, -h/2, w, h); - p.imageMode(obj.get_mode()); - p.image(wall_image, 0, 0, w, h); - //p.set(0, 0, wall_shape); - //draw(canvas.getContext('2d')); - //var d = new Date(); - //console.log(d.getMilliseconds()); - //canvas.getContext('2d').drawSvg("images/virusFinal.svg", 300, 10, 20, 20); - //console.log(d.getMilliseconds()); - - p.popMatrix(); - }; - - obj.draw_circle = function() {}; - - // walls can't die - obj.is_dead = function() { - return false; - }; - - //var count = 0; - obj.scroll = function(scroll_factor) { - //count += 1; - //if (count === 1) { - //count = 0; - obj.get_pos().add(new p.PVector(obj.get_scroll_dist(), 0)); - //} - }; - - obj.get_scroll_dist = function() { - return -1; - }; - - return obj; -}; - diff --git a/game_object.js b/game_object.js deleted file mode 100644 index 71d409d..0000000 --- a/game_object.js +++ /dev/null @@ -1,276 +0,0 @@ -// *** game_object *** -// spec: -// mode = p.CENTER or p.CORNERS (constants from processing) -// - describes how the coords work, set by p.shapeMode() -// p.PVector pos = initial position (x,y) -// float width = width of the entire object -// float height = height of the entire object -// float radius = circle collision radius (will be auto-calced) -// p.PVector vel = initial velocity -// p.PVector accel = initial acceleration -// mutation_info = object with level, num_particles and color props -// illustration = boolean that says whether or not to draw animations - -var game_object = function (p, spec) { - - - // object to return - var obj = {}; - - // should be overridden by subtypes - obj.get_type = function() { - return "game_object"; - }; - - obj.DEFAULT_SCROLL_DIST = -1.2; - - // --- private variables --- - - var mode = spec.mode || p.CENTER; - var pos = spec.pos || new p.PVector(0, 0); - var width = spec.width || 0; - var height = spec.height || 0; - var vel = spec.vel || new p.PVector(0, 0); - var accel = spec.accel || new p.PVector(0, 0); - // used for circle collision testing - var radius = spec.radius // default set at bottom of file - // used for mutation - var mutation_info = spec.mutation_info || - { level: -1, color: p.color(0, 0, 0), particles: 0 }; - var illustration = spec.illustration || false; - - var alive = true; - - // --- public methods --- - - // all game_objects must implement this interface: - // void update() - called each frame to move/update objects - // void draw() - called each frame to display the object - // void scroll() - moves the object left by a certain amount - - // update moves obj by default - obj.update = function() { obj.move(); }; - - // draw does nothing by default - obj.draw = function() {}; - - // by default returns the negated alive variable - obj.is_dead = function() { return !alive; }; - - // Generic methods for all game_objects: - // returns true if the object is completely offscreen - // i.e. checks pos + dimensions - obj.is_offscreen = function() { - var left_edge = pos.x - width/2; - var right_edge = pos.x + width/2; - var top_edge = pos.y - height/2; - var btm_edge = pos.y + height/2; - return (left_edge > p.width - || right_edge < 0 - || top_edge > p.height - || btm_edge < 0); - }; - - // Returns if the obj is off the right of the screen - obj.is_off_right = function() { - var left_edge = pos.x - width/2; - return left_edge > p.width; - }; - - - // Bounces the object off a wall, if it is at one - obj.bounce = function() { - var left_edge = pos.x - width; - var right_edge = pos.x + width; - var top_edge = pos.y - height; - var btm_edge = pos.y + height; - if (top_edge <= 0 && vel.y < 0) { - vel.y = -vel.y; - } - if (btm_edge >= p.height && vel.y > 0) { - vel.y = -vel.y; - } - if (left_edge <= 0 && vel.x < 0) { - vel.x = -vel.x; - } - if (right_edge >= p.width && vel.x > 0) { - vel.x = -vel.x; - } - }; - - // reverses the y velocity - // used for bouncing vertically - obj.reverse_y = function() { - var vel = obj.get_vel(); - obj.set_vel(new p.PVector(vel.x, -vel.y)); - }; - - // reverses the x velocity - // used for bouncing horizontally - obj.reverse_x = function() { - var vel = obj.get_vel(); - obj.set_vel(new p.PVector(- vel.x, vel.y)); - }; - - // updates the position according to accel and vel - // Bounces off walls - obj.move = function() { - vel.add(accel); - pos.add(vel); - }; - - // stops the object in its tracks by zeroing out vel - obj.stop = function() { - vel = new p.PVector(0, 0); - }; - - // Scrolls the obj a specified distance left or right (positive is right) - obj.scroll = function(scroll_factor) { - var scroll_x = obj.get_scroll_dist(); - if (scroll_x === null) { - scroll_x = obj.DEFAULT_SCROLL_DIST; - } - pos.add(new p.PVector(scroll_x*scroll_factor, 0)); - }; - - obj.die = function() { - alive = false; - }; - - obj.is_illustration = function() { - return illustration; - }; - - // --- setters --- - - obj.set_illustration = function(i) { - illustration = i; - }; - - obj.set_pos = function(new_pos) { - pos = new_pos; - }; - - obj.set_accel = function(new_accel) { - accel = new_accel; - }; - - obj.set_vel = function(new_vel) { - vel = new_vel; - }; - - // should only be used once, just for circular objects - obj.set_radius = function(new_radius) { - radius = new_radius; - }; - - // Should only be used for collisions - obj.set_pos = function(posn) { - pos = posn; - }; - - obj.set_mutation_info = function(m) { - mutation_info = m; - }; - - // --- getters --- - - // Override to set different scroll dist - // or leave as null to use default - obj.get_scroll_dist = function() { - return null; - }; - - obj.get_pos = function() { - return pos; - }; - - obj.get_left = function() { - return pos.x - (width / 2); - }; - - obj.get_top = function() { - return pos.y - (height / 2); - }; - - obj.get_right = function() { - return pos.x + (width / 2); - }; - - obj.get_bottom = function() { - return pos.y + (height / 2); - }; - - // returns the x offset for rectangle collisions - // should be overridden for rectangular objects - obj.get_x_offset = function() { - return 0; - }; - // returns the y offset for rectangle collisions - // should be overridden for rectangular objects - obj.get_y_offset = function() { - return 0; - }; - - obj.get_width = function() { - return width; - }; - - obj.get_height = function() { - return height; - }; - - obj.get_mode = function() { - return mode; - }; - - obj.get_vel = function() { - return vel; - }; - - obj.get_accel = function() { - return accel; - }; - - obj.get_radius = function() { - return radius; - }; - - obj.get_mutation_info = function() { - return mutation_info; - }; - - obj.get_color = function() { - return mutation_info.color; - }; - - obj.get_level = function() { - return mutation_info.level; - }; - - obj.is = function(type) { - return obj.get_type() === type; - }; - - obj.to_string = function() { - return obj.get_type()+" ("+pos.x+", "+pos.y+")"; - }; - - // draws the collision circle as an overlay - obj.draw_circle = function() { - p.fill(255, 50); - p.noStroke(); - p.shapeMode(p.CENTER); - p.ellipse(pos.x, pos.y, 2*radius, 2*radius); - }; - - // uses pythagorean theorem to calc radius of bounding circle - obj.calc_radius = function() { - return 0.5*p.sqrt(width*width+height*height); - }; - - // calc radius if not already set - radius = radius || obj.calc_radius(); - - return obj; -} diff --git a/game_over_state.js b/game_over_state.js deleted file mode 100644 index 6190456..0000000 --- a/game_over_state.js +++ /dev/null @@ -1,175 +0,0 @@ -// spec: -// score : num representing score of game -// mutation_level : num representing mutation level at end of game - -var game_over_state = function (p, prev_state, spec, game_type) { - //right now, prev_state is not used - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var topy = 100; - // Score display - var score_rect = rectangle(p, { - pos : new p.PVector(p.width / 2, topy+80),// 230), - width : 0, - height : 0, - text : "Score: " + add_commas(spec.score), - text_size : 30, - text_color : 255 - }); - - var mutation_rect = rectangle(p, { - pos : new p.PVector(p.width / 2, topy+130),//280), - width : 0, - height : 0, - text : "Mutation Level: " + spec.mutation_level, - text_size : 30, - text_color : 255 - }); - - var b_top = topy+180; - var b_spc = 60; - var button_style = { - width: 120, height: 50, - text_align: p.LEFT, - }; - // Buttons - var restart_button = button(p, { - state : function() { - sounds.play_button_click(); - return in_game_state(p, prev_state, game_type); - }, - rect : { - pos : new p.PVector(p.width / 2, b_top),//330), - //text : "Restart", - //text_x_offset: 40, - image: "restart.png", - //style: button_style - } - }); - var post_button = button(p, { - state : function() { - // only post if they are logged in - if (g_user_id) { - sounds.play_button_click(); - FB.ui({ - method: 'feed', - name: "Play Virion!", - picture: "http://virus-game.cs.brown.edu/images/logo/vlogolarge.png", - link: "http://apps.facebook.com/viriongame", - caption: "I just scored "+add_commas(spec.score)+ - " playing Virion!", - }); - } - return obj; - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+b_spc),//390), - //text : "Post Score to Wall", - //text_x_offset: 35, - image: "postscore.png", - //style: button_style - } - }); - var invite_button = button(p, { - state : function() { - // only post if they are logged in - if (g_user_id) { - sounds.play_button_click(); - FB.ui({ - method: 'apprequests', - title: "Infect Your Friends", - message: 'Check out this awesome game!', - }); - } - return obj; - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+2*b_spc),//450), - //text : "Infect Your Friends", - //text_x_offset: 35, - image: "infectfriends.png", - //style: button_style - } - }); - - // only allow posts/invites if logged in - if (!g_user_id) { - post_button.deactivate(); - invite_button.deactivate(); - } - - var scores_button = button(p, { - state : function() { - sounds.play_button_click(); - return high_scores_state(p, obj); - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+3*b_spc),//510), - //text : "High Scores", - //text_x_offset: 35, - image: "highscores.png", - //style: button_style - } - }); - var splash_button = button(p, { - state : function() { - sounds.play_button_click(); - return splash_state(p); - }, - rect : { - pos : new p.PVector(p.width / 2, b_top+4*b_spc),//570), - //text : "Main Menu", - //text_x_offset: 35, - image: "mainmenu.png", - //style: button_style - } - }); - - //Not ordered - var all_buttons = [restart_button, post_button, - invite_button, splash_button, scores_button]; - var all_rectangles = [score_rect, mutation_rect]; - - // --- public methods --- - - obj.get_type = function() { - return "game_over"; - }; - - obj.update = function() { - //do nothing - }; - - obj.key_pressed = function(k) { - if (k === 114 || p.keyCode === 13) { //r, enter - obj.set_next_state(restart_button.get_state()); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - obj.render = function() { - p.fill(0, 150); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.fill(255); - p.textAlign(p.CENTER); - - p.textSize(50); - p.text("Game Over", p.width/2, topy); - p.textSize(20); - p.text("Your virus was wiped out!", p.width/2, topy+30); - - for_each(all_rectangles, function(r) {r.draw();}); - }; - - return obj; -}; diff --git a/game_state.js b/game_state.js deleted file mode 100644 index 775f8f9..0000000 --- a/game_state.js +++ /dev/null @@ -1,124 +0,0 @@ -// *** game_state *** -// Interface for all game states - -// NOTE ALL OF THE FOLLOWING WHEN CREATING A GAME STATE: -// All game states must take a previous_state in their constructor, and then call set_previous_state() -// The exception to this is splash, which is the base state and should never be exited -// If a state change happens in: -// update() - return the new state -// mouse_click/key_pressed: Call set_next_state(new_state) with the state to go to -// Buttons: -// Drawing and clicking of buttons is taken care of -// You must take care of key strokes - -var game_state = function (p) { - - // object to return - var obj = {}; - - // --- private variables --- - var next_state = null; - var previous_state = null; - var all_buttons = []; //TODO: This is static but is updated every update() - - - // --- public methods --- - - //Wrapper for every states render function - //First draws all the buttons, then calls render - obj.render_wrapper = function() { - obj.render(); - for_each(all_buttons, function(b) { b.draw(); }); - }; - - //Do not over-ride these methods - obj.set_next_state = function(ns) { - next_state = ns; - }; - obj.set_previous_state = function(ps) { - previous_state = ps; - }; - obj.exit_state = function() { - if (previous_state === null) { - throw "error previous state not set in game_state"; - } - assert(previous_state !== null, "Previous state was null in game_state.exit_state"); - next_state = previous_state; - }; - - // Wrapper for every states update function - // Goes to the next state (by returning it) if next_state has been set - obj.update_wrapper = function() { - all_buttons = obj.get_all_buttons(); - if (next_state !== null) { - var to_return = next_state; - //in case we return to this state (CURRENTLY, SHOULDN'T EVER HAPPEN I THINK) - next_state = null; - return to_return; - } - //else - obj.update(); - obj.render_wrapper(); - }; - - // Wrapper for mouse clicks - // First checks if any of the buttons are clicked, then calls mouse_click - obj.mouse_click_wrapper = function(x, y) { - var click_function = function(b) { - var next_state = b.is_clicked(x, y); - if (next_state !== null) { - obj.set_next_state(next_state); - } - } - for_each(all_buttons, click_function); - obj.mouse_click(x, y); - }; - - obj.mouse_moved_wrapper = function(x, y) { - for_each( - all_buttons, - function(b) { - b.mouse_moved(x, y); - } - ); - obj.mouse_moved(x, y); - }; - - - // all game_states must implement the following functions: - - //Returns the type of the state - obj.get_type = function() { - return "get_type not overwritten"; - }; - - //Takes in the key pressed and handles a key press - obj.key_pressed = function(k) {throw "key_pressed not overwritten"}; - - // Do nothing unless overwritten - obj.mouse_moved = function(x, y) {}; - - //Updates the current state, and returns the next state to go to - //next state can be: - // null, if no state change - // a state representing a state to go to (either previous state or newly created next state - obj.update = function() {throw "update not overwritten"}; - - // Returns all of the buttons on the screen - obj.get_all_buttons = function() {throw "get_all_buttons not overwritten"}; - - // --- Optionally implement these, they default to nothing --- - - //Renders the current state - obj.render = function(){ }; //throw "render not overwritten"}; - - //Takes in the x and y coordinates of the mouse, and handles a mouse click - obj.mouse_click = function(x, y){}; //throw "mouse_click not overwritten"}; - - //Called when returning to this state - obj.resume = function() {}; - - - - return obj; -}; diff --git a/generator.js b/generator.js deleted file mode 100644 index acad075..0000000 --- a/generator.js +++ /dev/null @@ -1,393 +0,0 @@ -// *** generator *** -// generates random enemies -// spec: -// game : an in_game_state -// Is going to access: (through getters since we're so safe) -// game_objects - array -// distance - a num -// type_to_level - hash from type to level -// active_cell -// mutation : a mutation obj, so it can get current mutation color - -var make_generator = function(p, spec) { - // --- defaults --- - - // obj to return - var obj = {}; - - // --- private variables --- - - //These will be updated at every call of update() - var game_objects = null; - var distance = null; - var mutation = spec.mutation; - var game = spec.game; - var last_obj = null; // The last object generated - - var default_gen_speed = 10; - // structure that stores the generation settings - // for each type of object - // - start = distance after which to start generating - // - num = how many total on screen - // - cap = upper limit on num - // - rate = determines when to increment num - // when dist % rate = 0, num increments - // - gen_speed = speed with which to generate the object - // 1 (1/100 frames) to 100 (100/100 frames) - // If not specified, defaults to DEFAULT_GEN_SPEED - // - spacing = diagonal space to put b/w objects of this type (optional) - // - gen_x = how far offscreen to gen this type (optional) - // - gen_y = function that returns random y pos for this object (optional) - // - make_new = function that takes a pos and returns a new enemy - // - diminish = Include to make enemy's num decrease over time instead of increasing (optional) - var gen_info = { - "cell": { - // was 8 - start: 0, num: 30, cap: 10, rate: 2000, gen_speed: 55, diminish : true, - spacing: 50, - make_new: function(en_pos) { - return cell(p, { - pos: en_pos, - state: "alive", - }); - } - }, - "wall_cell": { - start: 0, num: 3, cap: 7, rate: 3000, //non testing value: 1000 - spacing: "dynamic",//100, - make_new: function(en_pos) { - return wall_cell(p, { pos: en_pos }); - } - }, - "empty_cell": { - start: 5000, num: 1, cap: 10, rate: 5000, - make_new: function(en_pos) { - return empty_cell(p, { pos: en_pos }); - } - }, - "floater": { - start: 1000, num: 3, cap: 7, rate: 7000, - spacing: "dynamic",//100, - make_new: function(en_pos) { - return floater(p, { pos: en_pos }); - } - }, - /* - "tkiller": { - start: 1000, num: 1, cap: 5, rate: 20000, - make_new: function(en_pos) { - // target will get set later - return tkiller(p, { - pos: en_pos, - mutation_info: game.get_mutation_info() - }); - } - }, - */ - "multiplier": { - start:0, num: 10, cap: 20, rate: 20000, - make_new: function(en_pos) { - return multiplier(p, { pos : en_pos }); - } - }, - /* - "b_cell": { - start:0, num: 1, cap: 1, rate: 999999, - make_new: function(en_pos) { - return b_cell(p, { pos : en_pos }); - } - }, - */ - "background_object": { - start:0, num: 8, cap: 8, rate: 999999, - spacing: p.width/5, gen_x: 500, - gen_y: function() { - return p.random(200, p.height - 180); - }, - make_new: function(en_pos) { - return background_object(p, { pos: en_pos }); - } - }, - }; - - // list of types of enemies - var enemy_types = keys(gen_info); - /*var random_type = function() { - return random_from(enemy_types);//[p.floor(p.random( - //enemy_types.length))]; - }; - */ - - // just some wrappers - var start = function(type) { - return gen_info[type].start; - }; - var num = function(type) { - return gen_info[type].num; - }; - var cap = function(type) { - return gen_info[type].cap; - }; - var rate = function(type) { - return gen_info[type].rate; - }; - var spacing = function(type) { - // dynamic spacing - if(gen_info[type].spacing === "dynamic") { - return p.width/num(type); - } - return gen_info[type].spacing; - }; - var gen_x_pos = function(type) { - return p.width + (gen_info[type].gen_x || 50); - }; - var gen_y_pos = function(type) { - if (gen_info[type].gen_y) { - return gen_info[type].gen_y(); - } - return p.floor(p.random(90, p.height-50)); - }; - var gen_speed = function(type) { - return gen_info[type].gen_speed; - }; - var make_new = function(type) { - return gen_info[type].make_new; - }; - var diminish = function(type) { - return gen_info[type].diminish || false; - } - var gen_more = function(type) { - if (diminish(type)) { - if (num(type) > cap(type)) { - gen_info[type].num = num(type)-1; - } - } - else { - if (num(type) < cap(type)) { - gen_info[type].num = num(type)+1; - } - } - }; - - // Returns whether it is not too soon to generate another - // object, based on last_obj - var ok_to_generate = function() { - if (last_obj) { - if (last_obj.get_type() === "cell") { - // 2 times width spacing - return last_obj.get_pos().x < - (gen_x_pos(last_obj.get_type()) - last_obj.get_width() * 2); - } - } - // else - return true; - }; - - // --- public methods --- - - //Should be called every time the game updates - obj.update = function() { - //game_objects = game.get_game_objects(); - distance = p.floor(game.get_distance()); - - update_types(); - - var enemy_type = random_from(enemy_types);//random_type(); - var num_enemies = count_enemy(enemy_type); - - // if there aren't enough of that enemy on the board - if (num_enemies < num(enemy_type) - // and some random factor - && p.random(100) < (gen_speed(enemy_type) || default_gen_speed ) - // and we are ready to start making this enemy - && distance >= start(enemy_type)) { - //&& ok_to_generate()) { - - var enemy_y = gen_y_pos(enemy_type); - var enemy_pos = new p.PVector(gen_x_pos(enemy_type), enemy_y); - - var new_enemy = make_new(enemy_type)(enemy_pos); - assert(new_enemy, "Error in generator.update()"); - - // make sure it's far enough away from the last object - // of its type - if (!spaced_out_enough(new_enemy)) { - return; - } - - // make sure it's not overlapping anything else - if (is_overlapping(new_enemy) - && !new_enemy.is("background_object")) { - //console.log("overlapped"); - return; - } - - //Add the new enemy to game_objects - game.add_object(new_enemy); - - // If b cell, must update b cells targets - if (new_enemy.get_type() === "b_cell") { - console.log("made new b_cell"); - game.set_b_cell_target(new_enemy); - } - - last_obj = new_enemy; - } - - }; - - // --- private methods --- - - var update_types = function() { - /* - if (distance % 100 <= 0.5) { - console.log(distance); - } - */ - // update nums for types based on rate - for_each( - enemy_types, - function(type) { - if (distance % rate(type) <= 0.1 - && distance >= 10) { - gen_more(type); - console.log("increased num of "+type+ - "s to "+num(type)); - } - } - ); - }; - - // returns how many of given enemy there are - var count_enemy = function(enemy_type) { - var n = 0; - game.do_to_type(function(o) { n++; }, - enemy_type, true); - return n; - } - - // returns true if the enemy overlaps any game objects - var is_overlapping = function(enemy) { - var overlap = false; - var check_overlap = function(obj) { - if (game.check_circle_collision(enemy, obj)) { - overlap = true; - } - }; - game.do_to_type(check_overlap, "particle", false); - game.do_to_type(check_overlap, "cell", false); - game.do_to_type(check_overlap, "enemy", false); - game.do_to_type(check_overlap, "wall_segment", false); - return overlap; - }; - - // returns true if the new enemy if far enough away (in x coord) - // from the rightmost of its type - // or if there is no spacing requirement for that type - var spaced_out_enough = function(new_enemy) { - var to_return = true; - // if there is spacing defined for this type - if (spacing(new_enemy.get_type())) { - var min_dist = 99999; - // find the closest object of the type - game.do_to_type( - function(o) { - var dist = new_enemy.get_pos().dist(o.get_pos()); - if (dist < min_dist) { - min_dist = dist; - // check if it is too close - if (dist < spacing(new_enemy.get_type())) { - to_return = false; - } - } - }, - new_enemy.get_type(), true - ); - } - return to_return; - }; - - - - /* - // return true if it is far enough apart from rightmost of its type - return new_enemy.get_pos().dist( - rightmost(new_enemy.get_type()).get_pos()) - > spacing(new_enemy.get_type()); - } - return true; - }; - - /* - var rightmost = function(type) { - var rightmost_x = 0; - var rightmost; - game.do_to_type( - function(o) { - if (o.get_pos().x > rightmost_x) { - rightmost = o; - rightmost_x = o.get_pos().x; - } - }, - type, true - ); - return rightmost; - }; - */ - - // returns an object: - // cell: number of cells on the screen - // wall_cell: number of wall_cells - // empty_cell: number of empty_cells - // tkiller: number of tkillers - // floater: number of floaters - var get_enemies = (function() { - var total = 0; - - // These are the types to check - //var types = ["cell", "wall_cell", "empty_cell", - // "floater", "tkiller"]; - - //Checks if an element is in an array - var member = function(arr, elem) { - return (arr.indexOf(elem) != -1); - }; - - var get_em = function() { - var enemies = { "cell":0, "wall_cell":0, - "empty_cell":0, "floater":0, "tkiller":0, - "multiplier":0, "b_cell":0}; - - // increment counter for each object - var incr = function(o) { - enemies[o.get_type()] += 1; - }; - game.do_to_type(incr, "cell", false); - game.do_to_type(incr, "enemy", false); - }; - /*for (var type in enemies) { - if (enemies.hasOwnProperty(type)) { - game.do_to_type( - function(o) { - enemies[type] += 1; - }, - type, true); - } - } - /*for (var i = 0; i < game_objects.length; i++) { - var lst = game_objects[i]; - for (var j = 0; j < lst.length; j++) { - var obj = lst[j]; - if (member(types, obj.get_type())) { - total++; - } - } - } - return total; - */ - - return get_em; - }()); - - return obj; -}; diff --git a/global_functions.js b/global_functions.js deleted file mode 100644 index d6c3167..0000000 --- a/global_functions.js +++ /dev/null @@ -1,90 +0,0 @@ -// ** Global Constants -//DEFAULT_SCROLL_DIST = -0.8; - -// *** global_functions *** -// Holds functions used in the whole project - -//Have to catch it so fuck it -/* -function AssertException(message) { this.message = message}; -function assert(exp, message) { - if (!exp) { - throw new AssertException(message); - } -} -*/ - -var assert = function(exp, message) { - if (!exp) { - console.error("Assert error!: " + message); - } -}; - -//Does something to every element of an arr -var for_each = function(arr, fun) { - for (var i = 0; i < arr.length; i++) { - fun(arr[i]); - } -}; - -// returns the index+1 of an element in a list, -// otherwise false -// can't return just the index because 0 is false in js -var member = function(arr, elt) { - for (var i=0; i 1 ? '.' + x[1] : ''; - var rgx = /(\d+)(\d{3})/; - while (rgx.test(x1)) { - x1 = x1.replace(rgx, '$1' + ',' + '$2'); - } - return prefix + x1 + x2; -}; - diff --git a/help.txt b/help.txt deleted file mode 100644 index 7bdf35b..0000000 --- a/help.txt +++ /dev/null @@ -1,9 +0,0 @@ -You've managed to infiltrate the human body's defenses and get your virus particle into the bloodstream! Now you must infect cells and use them to make more copies of your virus before the immune system wipes you out. - -After a particle infects a cell, the virus will use the cell's machinery to start making copies of itself. Once the cell is full of new virus particles, press the SPACEBAR or click the MOUSE to kill the cell, causing virus particles to burst through the cell wall towards other cells in the direction the arrow is pointing. You can pick which cell to burst using the LEFT and RIGHT arrow keys. - -Aim carefully though, because the immune system has sent out macrophages to absorb your particles. If a particle hits a macrophage, it will signal a B-cell, which will start producing antibodies. If an antibody attaches to an infected cell, a T-cell will attack it. If you don't burst the cell in time, the T-cell will kill it, destroying all the particles inside! - -Luckily, your virus can mutate and temporarily escape the immune system. Every time the virus replicates, there are errors when copying the virus's genetic material. These errors may cause mutations in the virus. Each time you infect a cell, the virus becomes more and more likely to mutate. Once you mutate, the immune system will not be able to attack you until a macrophage absorbs a virus particle from the new strain. - -How long will your virus be able to survive? diff --git a/help_state.js b/help_state.js deleted file mode 100644 index 27addf4..0000000 --- a/help_state.js +++ /dev/null @@ -1,626 +0,0 @@ -var help_state = function (p, prev_state) { - - var help_image = image_manager.get_image("helpsplash.png"); - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - var screens = []; - var screen_w = help_image.width - 180; - var screen_h = help_image.height - 200; - var screen_pos = new p.PVector(p.width/2, p.height/2-15); - - var screen_index = 0; - var cur_screen = function() { - return screens[screen_index]; - }; - var next_screen = function() { - if (screen_index <= screens.length-1) { - screen_index += 1; - if (screen_index === screens.length-1) { - next_button.deactivate(); - } - previous_button.activate(); - return true; - } - return false; - }; - var previous_screen = function() { - if (screen_index >= 0) { - screen_index -= 1; - if (screen_index === 0) { - previous_button.deactivate(); - } - next_button.activate(); - return true; - } - return false; - }; - - // a screen is a panel that goes in the screens array - // it displays one or more item - // spec: - // - pos: PVector representing the center of the screen - // - width - // - height - var screen = function(spec) { - var obj = {}; - var items = []; - obj.add_item = function(item) { - items.push(item); - }; - - obj.render = function() { - p.pushMatrix(); - - p.translate(spec.pos.x-spec.width/2, spec.pos.y-spec.height/2); - - // debugging - /* - p.noFill(); - p.stroke(255); - p.rect(0, 0, spec.width, spec.height); - */ - - // translate and render each item - var padding = 15; - for_each( - items, - function(item) { - item.render(); - p.translate(0, item.height()+padding); - } - ); - - p.popMatrix(); - }; - - return obj; - }; - - var new_screen = function() { - return screen({ - pos: screen_pos, - width: screen_w, - height: screen_h - }); - }; - - // item displays text and an image as part of a screen - // spec: - // - width - // - height - // - text - the text to display - // - title - the name of this item (optional) - // - image - image to display - // - illustration (obj) - // - width, height - dimensions for the illustration - // - draw - function that draws some illustration - // (origin at top left corner) - // - img_left - boolean, true if the image/ill should go on the left, - // false for the right - // (should only have image or illustration) - // - var item = function(spec) { - var obj = {}; - - // auto height - spec.height = spec.height - // the 0 here just takes us to the next cond - || (spec.image ? spec.image.height : 0) - // the actual default is at the end of this - || (spec.illustration ? spec.illustration.height : 80); - spec.width = spec.width || screen_w; - spec.padding = spec.padding || 10; - - obj.height = function() { return spec.height; }; - - obj.render = function() { - var text_x = 0; - var text_y = 0; - var text_w = spec.width; - - if (spec.image || spec.illustration) { - // make adjustments based on either one - var i = spec.image || spec.illustration; - text_w -= i.width + spec.padding; - var img_x = spec.width - i.width; - if (spec.img_left) { - img_x = 0; - text_x = i.width + spec.padding; - } - // draw either - if (spec.image) { - p.imageMode(p.CORNER); - p.image(spec.image, img_x, 0); - } - else { - p.pushMatrix(); - p.translate(img_x, 0); - spec.illustration.draw(); - p.popMatrix(); - } - } - - p.textLeading(14); - if (spec.title) { - p.textSize(18); - p.textAlign(p.LEFT, p.TOP); - p.fill(255); - p.text(spec.title, text_x, 0); - text_y += p.textAscent(); - } - p.textSize(14); - p.textAlign(p.LEFT, p.TOP); - p.fill(255); - p.text(spec.text, text_x, text_y, text_w, spec.height-text_y); - }; - - return obj; - }; - - // init the help screens - // eval'd immediately - var init_screens = (function() { - var color1 = 0xffffff00; - var color2 = 0xff7f2aff; - var cimg = image_manager.get_image("infectable_cell_2n.png"); - - var s1 = new_screen(); - screens.push(s1); - s1.add_item(item({ - text: "You've infiltrated the human body's defenses and gotten your virus particle (or virion) into the bloodstream! Here are the cells you may encounter:", - height: 45, - padding: 1, - illustration: { - width: 30, height: 30, - draw: function() { - var img = image_manager.get_image("tinyvirus_trans.png"); - var w = 15; - var h = 15; - p.fill(color1); - p.noStroke(); - p.ellipse(w, h, w*.75, h*.75); - p.imageMode(p.CENTER); - p.image(img, w, h, w, h); - } - }, - img_left: false - })); - s1.add_item(item({ - title: "Infectable (Permissive) Cells", - text: "Hit an infectable cell with a virion to infect it. After penetrating the cell wall, the virion will use the cell's machinery to make copies of itself.", - //image: cimg, - illustration: { - width: 50, height: 60, - draw: (function() { - var c = cell(p, { - pos: new p.PVector(30, 30), - width: 30, height: 30, - illustration: true - }); - c.set_image(cimg); - //c.set_state("active"); - return function() { - c.draw(); - }; - }()), - }, - img_left: true - })); - s1.add_item(item({ - text: "Press SPACEBAR or click the MOUSE to burst an infected cell and shoot the new virions in the direction of the arrow. Pick which cell to burst using the LEFT and RIGHT arrow keys.", - //image: image_manager.get_image("infectable_cell_2n.png"), - illustration: { - width: 30, height: 60, - draw: (function() { - var c = cell(p, { - pos: new p.PVector(20, 30), - width: 30, height: 30, - mutation_info: { color: color1 }, - illustration: true - }); - c.set_image(cimg); - c.set_state("active"); - return function() { - c.draw(); - }; - }()), - }, - img_left: false - })); - s1.add_item(item({ - title: "Non-permissive Cells", - text: "Some cells can be infected, but will not let your virion replicate. A virion that infects a non-permissive cell is as good as dead.", - illustration: { - width: 50, height: 60, - draw: (function() { - var c = empty_cell(p, { - pos: new p.PVector(30, 30), - width: 30, height: 30, - }); - return function() { - c.draw(); - }; - }()), - }, - img_left: true - })); - s1.add_item(item({ - title: "Resistant Cells", - text: "Virions can't break through the cell wall of resistant cells - they will just bounce off in the other direction.", - height: 60, - illustration: { - width: 30, height: 60, - draw: (function() { - var c = wall_cell(p, { - pos: new p.PVector(20, 30), - //width: 30, height: 30, - }); - return function() { - c.draw(); - }; - }()), - }, - img_left: false - })); - - var s2 = new_screen(); - screens.push(s2); - s2.add_item(item({ - text: "Be careful! The immune system will try to destroy your virus. Here are the enemies you should look out for:", - height: 30 - })); - s2.add_item(item({ - title: "Macrophages", - text: "The immune system's first line of defense. They will absorb any virion that hits them and then signal a B cell to give it information about your virus.", - height: 80, - //image: image_manager.get_image("macrophage_1.png"), - illustration: { - width: 50, height: 70, - draw: (function() { - var m = floater(p, { - pos: new p.PVector(25, 35), - width: 50, height: 70, - mutation_info: { color: color1 }, - illustration: true - }); - m.activate(); - return function() { - m.draw(); - }; - }()) - }, - img_left: true - })); - s2.add_item(item({ - title: "B Cells", - text: "Once a B cell knows about your virus, it will produce Y-shaped antibodies that will attach to infected cells, marking them for destruction.", - height: 70, - //image: image_manager.get_image("bcell_normal.png"), - illustration: { - width: 60, height: 60, - draw: (function() { - var b = b_cell(p, { - pos: new p.PVector(30, 55), - width: 40, height: 40, - mutation_info: { color: color1 }, - illustration: true - }); - b.set_state("active"); - b.set_target_angle(-p.PI/2); - - var a1 = antibody(p, { - pos: new p.PVector(40, 17), - mutation_info: { color: color1 }, - }); - a1.set_target_angle(-p.PI/4); - - var a2 = antibody(p, { - pos: new p.PVector(18, 23), - mutation_info: { color: color1 }, - }); - a2.set_target_angle(-3*p.PI/4+.2); - - return function() { - // make a thicker antibody - b.set_anti_count(10); - b.draw(); - a1.draw(); - a2.draw(); - }; - }()) - }, - img_left: false - })); - s2.add_item(item({ - title: "Granulocytes", - text: "If an infected cell is marked with an antibody, the granulocyte will hunt it down and destroy it, along with all the virions inside!", - //image: image_manager.get_image("tcell_2.png"), - illustration: { - width: 60, height: 60, - draw: (function() { - var tk = tkiller(p, { - pos: new p.PVector(30, 30), - width: 60, height: 60, - mutation_info: { color: color1 }, - illustration: true - }); - //tk.set_state("alive"); - - return function() { - tk.draw(); - }; - }()) - }, - img_left: true - })); - - var s3 = new_screen(); - screens.push(s3); - s3.add_item(item({ - title: "Mutation", - text: "Luckily, in the process of replicating a virus's genetic material, mistakes are often made, causing the virus to mutate! If a mutation occurs, a new strain of the virus will be created. Every time you infect a cell, the chance of a mutation occurring increases.", - height: 120, - padding: 15, - illustration: { - width: 90, height: 90, - draw: (function() { - var c1 = cell(p, { - pos: new p.PVector(10, 20), - width: 30, height: 30, - mutation_info: { color: color1 }, - illustration: true - }); - c1.set_image(cimg); - c1.set_state("infected"); - - var c2 = cell(p, { - pos: new p.PVector(70, 80), - width: 30, height: 30, - mutation_info: { color: color2 }, - illustration: true - }); - c2.set_image(cimg); - c2.set_state("infected"); - - return function() { - c1.draw(); - c2.draw(); - p.stroke(255); - p.strokeWeight(3); - p.line(30, 40, 50, 60); - p.line(50, 60, 50, 50); - p.line(50, 60, 40, 60); - }; - }()), - }, - img_left: false - })); - s3.add_item(item({ - text: "Macrophages, B cells, granulocytes, and antibodies are created to attack a specific strain of a virus. So when your virus mutates, the new strain will be safe from the old enemies.", - //image: image_manager.get_image("macrophage_1.png"), - padding: 15, - illustration: { - width: 60, height: 60, - draw: (function() { - var tk = tkiller(p, { - pos: new p.PVector(50, 10), - mutation_info: { color: color1 }, - illustration: true - }); - tk.set_target_angle(-p.PI/4); - //tk.set_state("illustration"); - - var c = cell(p, { - pos: new p.PVector(10, 40), - width: 30, height: 30, - mutation_info: { color: color2 }, - illustration: true - }); - c.set_image(cimg); - c.set_state("infected"); - - var a = antibody(p, { - pos: new p.PVector(20, 15), - mutation_info: { color: color2 } - }); - a.set_target(c); - a.update(); - - return function() { - tk.draw(); - c.draw(); - a.draw(); - }; - }()), - }, - img_left: true - })); - s3.add_item(item({ - text: "Each new strain will be represented by a different color. Therefore, an infected cell can only be attacked by enemies of the same color.", - //image: image_manager.get_image("tcell_2.png"), - //padding: 15, - illustration: { - width: 60, height: 50, - draw: (function() { - var tk = tkiller(p, { - pos: new p.PVector(50, 12), - mutation_info: { color: color2 }, - illustration: true - }); - //tk.set_target_angle(p.PI/4); - //tk.set_state("illustration"); - - var c = cell(p, { - pos: new p.PVector(15, 40), - width: 30, height: 30, - mutation_info: { color: color2 }, - illustration: true - }); - c.set_image(cimg); - c.set_state("infected"); - - tk.set_target(c); - tk.update(); - - var a = antibody(p, { - pos: new p.PVector(5, 15), - mutation_info: { color: color2 } - }); - a.set_target(c); - a.update(); - - return function() { - tk.draw(); - c.draw(); - a.draw(); - }; - }()), - }, - img_left: false - })); - s3.add_item(item({ - title: "Multiplier Particles", - text: "Higher mutation levels will give you more points, as will collecting multiplier particles. When you infect a cell, the amount of points you get is multiplied by your multiplier and level.", - illustration: { - width: 50, height: 90, - draw: (function() { - var poss = [ - new p.PVector(10, 10), - new p.PVector(27, 25), - new p.PVector(20, 45), - new p.PVector(35, 50), - //new p.PVector(23, 30), - new p.PVector(40, 12) - ]; - var ms = []; - for_each(poss, - function(pos) { - ms.push(multiplier(p, { pos: pos })); - } - ); - - return function() { - for_each(ms, function(m) { m.draw(); }); - }; - }()), - }, - img_left: true - })); - - - }()); - - - /* - var box_w = 370; - var box_h = 500; - var box_x = p.width/2 - box_w/2; - var box_y = p.height/2 - box_h/2; - */ - - // Buttons - var button_y = p.height/2 + 190; - var button_style = { - width: 120, - height: 50, - }; - - var back_button = button(p, { - state : function() { sounds.play_button_back(); return prev_state; }, - rect : { - pos : new p.PVector(p.width/2, button_y), //box_x+box_w-80, box_y+box_h-30), - //text: "Back", - //text_x_offset: 5, - //text_y_offset: -8, - image: "back.png", - } - }); - - var next_button = button(p, { - state: function() { - sounds.play_button_click(); - next_screen(); - return obj; - }, - rect: { - pos: new p.PVector(p.width/2+120, button_y), - //text: "Next", - image: "next.png", - //style: button_style - } - }); - - var previous_button = button(p, { - state: function() { - sounds.play_button_back(); - previous_screen(); - return obj; - }, - rect: { - pos: new p.PVector(p.width/2-120, button_y), - //text: "Previous", - image: "previous.png", - //style: button_style - } - }); - previous_button.deactivate(); - - //Not ordered - var all_buttons = [ previous_button, back_button, next_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "help"; - }; - - obj.update = function() { - //do nothing - }; - - - obj.render = function() { - //p.pushMatrix(); - - p.imageMode(p.CENTER); - p.image(help_image, p.width/2, p.height/2); - - cur_screen().render(); - - //p.translate(box_x, box_y); - - //p.fill(0); - //p.rect(0, 0, box_w, box_h); - - //p.noStroke(); - //p.fill(255); - - //p.textAlign(p.CENTER, p.CENTER); - //p.textSize(24); - //p.text("Instructions", box_w/2, 30); - - //p.textAlign(p.LEFT, p.CENTER); - //p.textSize(13); - //p.text(instruction_text, - //5, 20, box_w, box_h-50); - - //p.popMatrix(); - }; - - obj.key_pressed = function(k) { - if (k === 104) { //h - obj.set_next_state(help_button.get_state()); - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/high_scores_state.js b/high_scores_state.js deleted file mode 100644 index 4f3583f..0000000 --- a/high_scores_state.js +++ /dev/null @@ -1,83 +0,0 @@ -var high_scores_state = function (p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - // Buttons - - var button_style = { - text_size: 14, - text_align: p.LEFT, - text_x_offset: 25, - width: 120, - height: 50, - }; - - var back_button = button(p, { - state : function() { - sounds.play_button_back(); - - // hide the div - $("#scores-wrap").hide(); - $("#scores").tabs("destroy"); - return prev_state;//splash_state(p); - }, - rect : { - pos : new p.PVector(540, 550), - //text: "Main Menu", - //text_x_offset: -5, - image: "back.png", - //image_x_offset: -5, - //style: button_style - } - }); - - //Not ordered - var all_buttons = [ back_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "high_scores"; - }; - - obj.update = function() { - }; - - obj.render = function() { - p.noStroke(); - p.fill(0, 150); - p.rect(0, 0, p.width, p.height); - }; - - obj.key_pressed = function(k) { - /* - if (k === 112 || p.keyCode == 13) { //p, enter - obj.exit_state(); - } - */ - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - // init the scores immediately - var init = (function() { - // add a loading message to be removed on load - $("#scores-wrap").prepend( - "
            Loading high score data...
            " - ); - - // show the div - $("#scores-wrap").show(); - // update and render scores - // TODO what if it fails? - scores.do_scores(); - }()); - - return obj; -}; diff --git a/image_manager.js b/image_manager.js deleted file mode 100644 index 0b7192e..0000000 --- a/image_manager.js +++ /dev/null @@ -1,171 +0,0 @@ -// image_manager preloads and holds all the images used in the game - -var make_image_manager = function() { - - // obj to return - var obj = []; - - // --- private variables --- - - // this will be counted in preloading - var num_images = 0; - - // object to hold all arrays of image paths - // and the dir name that they come from - // dir should be name after "images/" and must end in '/' - var all_images = { - infectable_cell : { dir : "infectable_cell/" }, - empty_cell : { dir : "noninfectable_cell/" }, - background : { dir : "background_objects/" }, - screens : { dir : "screens/" }, - wall_segments : { dir : "wall_segments/" }, - macrophage : {dir : "macrophage_animation/"}, - macrophage_active : {dir : "holemacrophage_animation/"}, - bcell : {dir : "b_animation/"}, - burst : { dir : "burstingcell_animation/"}, - cell_infect : { dir : "cellinfect_animation/"}, - t_animation : { dir : "t_animation/"}, - buttons : { dir : "buttons/"}, - // catches all images in images/ - other : { dir : "" }, - }; - - // add "arr" property to each image - for_each( - keys(all_images), - function(key) { - all_images[key].images = []; - } - ); - - // filter out non-images from global image file list - var image_types = ["png", "jpg", "gif"]; - for_each( - keys(all_image_files), - function(key) { - all_image_files[key] = all_image_files[key].filter( - function(name) { - return member(image_types, - name.substring(name.lastIndexOf('.')+1)); - } - ); - } - ); - - // --- public methods --- - - // returns all the image objects of a given type - // if preloading and initing is done - // NOTE: returns a copy of the array of pointers, but the pointers - // will all point to the same objects so don't change the objects - obj.get_images = function(type) { - if (!all_images[type]) { - console.error("Invalid image type: "+type); - } - //for_each(all_images[type], console.log() - return all_images[type].images.slice(); - }; - - // finds and returns the first image with the given name - // (no path necessary) - obj.get_image = function(name) { - var to_return; - for_each( - keys(all_images), - function(key) { - for_each( - all_images[key].images, - function(img_obj) { - if (name === img_obj.path.substring( - img_obj.path.lastIndexOf('/')+1)) { - to_return = img_obj.image; - } - } - ); - } - ); - if (!to_return) { - console.error("Invalid image name: "+name); - } - return to_return; - }; - - // preloads all the images - obj.preload_images = function() { - console.log("preloading images"); - for_each_image( - function(path) { - // let processing load it in the cache - sketch.imageCache.add(path); - // count it - num_images += 1; - console.log("loading "+path); - } - ); - }; - - // DO NOT CALL BEFORE CALLING PRELOAD - obj.num_loaded = function() { - return num_images - sketch.imageCache.pending; - }; - - // DO NOT CALL BEFORE CALLING PRELOAD - obj.num_images = function() { - return num_images; - }; - - // DO NOT CALL BEFORE CALLING PRELOAD - obj.is_done_preloading = function() { - return !sketch.imageCache.pending; - }; - - // DO NOT CALL BEFORE PRELOADING IS DONE - // should be called after preloading is done - // to make the image objects - // note: must be passed a processing instance p - obj.init_images = function(p) { - console.log("initing images"); - for_each_image( - function(img_path, type) { - // make an actual image object for each preloaded image - all_images[type].images.push({ - path: img_path, - image: p.loadImage(img_path), - }); - } - ); - }; - - // --- private methods --- - - // gets array of paths from the object populated by the php function - var files_in_dir = function(dir_path) { - if (!all_image_files[dir_path]) { - console.error("Invalid dir: "+dir_path); - } - return all_image_files[dir_path]; - }; - - // applies f to each image path - // f takes a path and an image type (key) - var for_each_image = function(f) { - // for each type of image - for_each( - keys(all_images), - function(key) { - // for each image in the dir - for_each( - files_in_dir("images/"+all_images[key].dir), - function(path) { - f(path, key); - } - ); - } - ); - }; - - return obj; -}; - -// make a global instance -var image_manager = make_image_manager(); diff --git a/images/b_animation/bcell_a01.png b/images/b_animation/bcell_a01.png deleted file mode 100644 index a11fd65..0000000 Binary files a/images/b_animation/bcell_a01.png and /dev/null differ diff --git a/images/b_animation/bcell_a02.png b/images/b_animation/bcell_a02.png deleted file mode 100644 index 2cdf59d..0000000 Binary files a/images/b_animation/bcell_a02.png and /dev/null differ diff --git a/images/b_animation/bcell_a03.png b/images/b_animation/bcell_a03.png deleted file mode 100644 index 0751bbe..0000000 Binary files a/images/b_animation/bcell_a03.png and /dev/null differ diff --git a/images/b_animation/bcell_a04.png b/images/b_animation/bcell_a04.png deleted file mode 100644 index e1ff517..0000000 Binary files a/images/b_animation/bcell_a04.png and /dev/null differ diff --git a/images/b_animation/bcell_a05.png b/images/b_animation/bcell_a05.png deleted file mode 100644 index d95d849..0000000 Binary files a/images/b_animation/bcell_a05.png and /dev/null differ diff --git a/images/b_animation/bcell_a06.png b/images/b_animation/bcell_a06.png deleted file mode 100644 index 4d11066..0000000 Binary files a/images/b_animation/bcell_a06.png and /dev/null differ diff --git a/images/b_animation/bcell_a07.png b/images/b_animation/bcell_a07.png deleted file mode 100644 index 1f2efb1..0000000 Binary files a/images/b_animation/bcell_a07.png and /dev/null differ diff --git a/images/background1.png b/images/background1.png deleted file mode 100644 index 0232c24..0000000 Binary files a/images/background1.png and /dev/null differ diff --git a/images/background_bottomside.png b/images/background_bottomside.png deleted file mode 100644 index 039dd50..0000000 Binary files a/images/background_bottomside.png and /dev/null differ diff --git a/images/background_objects/.DS_Store b/images/background_objects/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/images/background_objects/.DS_Store and /dev/null differ diff --git a/images/background_objects/background_bcells1.png b/images/background_objects/background_bcells1.png deleted file mode 100644 index 6de753b..0000000 Binary files a/images/background_objects/background_bcells1.png and /dev/null differ diff --git a/images/background_objects/background_bcells2.png b/images/background_objects/background_bcells2.png deleted file mode 100644 index 3a523d9..0000000 Binary files a/images/background_objects/background_bcells2.png and /dev/null differ diff --git a/images/background_objects/background_bcells3.png b/images/background_objects/background_bcells3.png deleted file mode 100644 index ef718b9..0000000 Binary files a/images/background_objects/background_bcells3.png and /dev/null differ diff --git a/images/background_objects/background_bcells4.png b/images/background_objects/background_bcells4.png deleted file mode 100644 index 6295cbd..0000000 Binary files a/images/background_objects/background_bcells4.png and /dev/null differ diff --git a/images/background_objects/background_dstreaks1.png b/images/background_objects/background_dstreaks1.png deleted file mode 100644 index 825f60f..0000000 Binary files a/images/background_objects/background_dstreaks1.png and /dev/null differ diff --git a/images/background_objects/background_dstreaks2.png b/images/background_objects/background_dstreaks2.png deleted file mode 100644 index a6f0582..0000000 Binary files a/images/background_objects/background_dstreaks2.png and /dev/null differ diff --git a/images/background_objects/background_dstreaks3.png b/images/background_objects/background_dstreaks3.png deleted file mode 100644 index c65a2f8..0000000 Binary files a/images/background_objects/background_dstreaks3.png and /dev/null differ diff --git a/images/background_objects/background_lstreaks1.png b/images/background_objects/background_lstreaks1.png deleted file mode 100644 index 74595f5..0000000 Binary files a/images/background_objects/background_lstreaks1.png and /dev/null differ diff --git a/images/background_objects/background_lstreaks2.png b/images/background_objects/background_lstreaks2.png deleted file mode 100644 index 62d1f4e..0000000 Binary files a/images/background_objects/background_lstreaks2.png and /dev/null differ diff --git a/images/background_topside.png b/images/background_topside.png deleted file mode 100644 index 613f9ac..0000000 Binary files a/images/background_topside.png and /dev/null differ diff --git a/images/bcell_normal.png b/images/bcell_normal.png deleted file mode 100644 index 60b8545..0000000 Binary files a/images/bcell_normal.png and /dev/null differ diff --git a/images/bullet_listcell.png b/images/bullet_listcell.png deleted file mode 100644 index b778d5c..0000000 Binary files a/images/bullet_listcell.png and /dev/null differ diff --git a/images/burstingcell_animation/burst_a01.png b/images/burstingcell_animation/burst_a01.png deleted file mode 100644 index 464828e..0000000 Binary files a/images/burstingcell_animation/burst_a01.png and /dev/null differ diff --git a/images/burstingcell_animation/burst_a02.png b/images/burstingcell_animation/burst_a02.png deleted file mode 100644 index 87f6492..0000000 Binary files a/images/burstingcell_animation/burst_a02.png and /dev/null differ diff --git a/images/burstingcell_animation/burst_a03.png b/images/burstingcell_animation/burst_a03.png deleted file mode 100644 index bb6d224..0000000 Binary files a/images/burstingcell_animation/burst_a03.png and /dev/null differ diff --git a/images/burstingcell_animation/burst_a04.png b/images/burstingcell_animation/burst_a04.png deleted file mode 100644 index 174dd4a..0000000 Binary files a/images/burstingcell_animation/burst_a04.png and /dev/null differ diff --git a/images/burstingcell_animation/burst_a05.png b/images/burstingcell_animation/burst_a05.png deleted file mode 100644 index 50fa69f..0000000 Binary files a/images/burstingcell_animation/burst_a05.png and /dev/null differ diff --git a/images/burstingcell_animation/burst_a06.png b/images/burstingcell_animation/burst_a06.png deleted file mode 100644 index 414accb..0000000 Binary files a/images/burstingcell_animation/burst_a06.png and /dev/null differ diff --git a/images/burstingcell_animation/burst_a07.png b/images/burstingcell_animation/burst_a07.png deleted file mode 100644 index 0aa533b..0000000 Binary files a/images/burstingcell_animation/burst_a07.png and /dev/null differ diff --git a/images/burstingcell_animation/burst_a08.png b/images/burstingcell_animation/burst_a08.png deleted file mode 100644 index 735a858..0000000 Binary files a/images/burstingcell_animation/burst_a08.png and /dev/null differ diff --git a/images/burstingcell_animation/burst_a09.png b/images/burstingcell_animation/burst_a09.png deleted file mode 100644 index 74f67d9..0000000 Binary files a/images/burstingcell_animation/burst_a09.png and /dev/null differ diff --git a/images/burstingcell_animation/burst_a10.png b/images/burstingcell_animation/burst_a10.png deleted file mode 100644 index 5182129..0000000 Binary files a/images/burstingcell_animation/burst_a10.png and /dev/null differ diff --git a/images/burstingcell_animation/burst_a11.png b/images/burstingcell_animation/burst_a11.png deleted file mode 100644 index cb79f9a..0000000 Binary files a/images/burstingcell_animation/burst_a11.png and /dev/null differ diff --git a/images/burstingcell_animation/burst_a12.png b/images/burstingcell_animation/burst_a12.png deleted file mode 100644 index 7a75730..0000000 Binary files a/images/burstingcell_animation/burst_a12.png and /dev/null differ diff --git a/images/burstingcell_animation/burst_a13.png b/images/burstingcell_animation/burst_a13.png deleted file mode 100644 index d1054f6..0000000 Binary files a/images/burstingcell_animation/burst_a13.png and /dev/null differ diff --git a/images/buttons/back.png b/images/buttons/back.png deleted file mode 100644 index a6e28a9..0000000 Binary files a/images/buttons/back.png and /dev/null differ diff --git a/images/buttons/check0.png b/images/buttons/check0.png deleted file mode 100644 index 993c88a..0000000 Binary files a/images/buttons/check0.png and /dev/null differ diff --git a/images/buttons/check1.png b/images/buttons/check1.png deleted file mode 100644 index 0207b44..0000000 Binary files a/images/buttons/check1.png and /dev/null differ diff --git a/images/buttons/continue.png b/images/buttons/continue.png deleted file mode 100644 index f5f4bed..0000000 Binary files a/images/buttons/continue.png and /dev/null differ diff --git a/images/buttons/credits.png b/images/buttons/credits.png deleted file mode 100644 index 567677e..0000000 Binary files a/images/buttons/credits.png and /dev/null differ diff --git a/images/buttons/highscores.png b/images/buttons/highscores.png deleted file mode 100644 index e59ce26..0000000 Binary files a/images/buttons/highscores.png and /dev/null differ diff --git a/images/buttons/infectfriends.png b/images/buttons/infectfriends.png deleted file mode 100644 index 6bd07d4..0000000 Binary files a/images/buttons/infectfriends.png and /dev/null differ diff --git a/images/buttons/instructions.png b/images/buttons/instructions.png deleted file mode 100644 index ab6ee9b..0000000 Binary files a/images/buttons/instructions.png and /dev/null differ diff --git a/images/buttons/mainmenu.png b/images/buttons/mainmenu.png deleted file mode 100644 index 3778426..0000000 Binary files a/images/buttons/mainmenu.png and /dev/null differ diff --git a/images/buttons/mainscreenmockup.jpg b/images/buttons/mainscreenmockup.jpg deleted file mode 100755 index 859bae9..0000000 Binary files a/images/buttons/mainscreenmockup.jpg and /dev/null differ diff --git a/images/buttons/mbeginner.png b/images/buttons/mbeginner.png deleted file mode 100755 index e8a99e9..0000000 Binary files a/images/buttons/mbeginner.png and /dev/null differ diff --git a/images/buttons/mbeginner_r.png b/images/buttons/mbeginner_r.png deleted file mode 100755 index 5eeee23..0000000 Binary files a/images/buttons/mbeginner_r.png and /dev/null differ diff --git a/images/buttons/mhighscores.png b/images/buttons/mhighscores.png deleted file mode 100755 index 7065e7b..0000000 Binary files a/images/buttons/mhighscores.png and /dev/null differ diff --git a/images/buttons/mhighscores_r.png b/images/buttons/mhighscores_r.png deleted file mode 100644 index 78ff539..0000000 Binary files a/images/buttons/mhighscores_r.png and /dev/null differ diff --git a/images/buttons/mhowtoplay.png b/images/buttons/mhowtoplay.png deleted file mode 100755 index 229ff4d..0000000 Binary files a/images/buttons/mhowtoplay.png and /dev/null differ diff --git a/images/buttons/mhowtoplay_r.png b/images/buttons/mhowtoplay_r.png deleted file mode 100755 index a21644f..0000000 Binary files a/images/buttons/mhowtoplay_r.png and /dev/null differ diff --git a/images/buttons/mnewgame.png b/images/buttons/mnewgame.png deleted file mode 100644 index 37ae877..0000000 Binary files a/images/buttons/mnewgame.png and /dev/null differ diff --git a/images/buttons/mnewgame_r.png b/images/buttons/mnewgame_r.png deleted file mode 100644 index b8359c5..0000000 Binary files a/images/buttons/mnewgame_r.png and /dev/null differ diff --git a/images/buttons/mnormal.png b/images/buttons/mnormal.png deleted file mode 100755 index a8cd0ce..0000000 Binary files a/images/buttons/mnormal.png and /dev/null differ diff --git a/images/buttons/mnormal_r.png b/images/buttons/mnormal_r.png deleted file mode 100755 index ee2139d..0000000 Binary files a/images/buttons/mnormal_r.png and /dev/null differ diff --git a/images/buttons/msettings.png b/images/buttons/msettings.png deleted file mode 100644 index e1fc244..0000000 Binary files a/images/buttons/msettings.png and /dev/null differ diff --git a/images/buttons/msettings_r.png b/images/buttons/msettings_r.png deleted file mode 100644 index 27fd0d1..0000000 Binary files a/images/buttons/msettings_r.png and /dev/null differ diff --git a/images/buttons/mtutorial.png b/images/buttons/mtutorial.png deleted file mode 100755 index 9de8ca9..0000000 Binary files a/images/buttons/mtutorial.png and /dev/null differ diff --git a/images/buttons/mtutorial_r.png b/images/buttons/mtutorial_r.png deleted file mode 100755 index 804366f..0000000 Binary files a/images/buttons/mtutorial_r.png and /dev/null differ diff --git a/images/buttons/next.png b/images/buttons/next.png deleted file mode 100644 index ee4b257..0000000 Binary files a/images/buttons/next.png and /dev/null differ diff --git a/images/buttons/postscore.png b/images/buttons/postscore.png deleted file mode 100644 index bd6a40d..0000000 Binary files a/images/buttons/postscore.png and /dev/null differ diff --git a/images/buttons/previous.png b/images/buttons/previous.png deleted file mode 100644 index 1d1d0cb..0000000 Binary files a/images/buttons/previous.png and /dev/null differ diff --git a/images/buttons/quit.png b/images/buttons/quit.png deleted file mode 100644 index ca30b7e..0000000 Binary files a/images/buttons/quit.png and /dev/null differ diff --git a/images/buttons/restart.png b/images/buttons/restart.png deleted file mode 100644 index 0a986b5..0000000 Binary files a/images/buttons/restart.png and /dev/null differ diff --git a/images/buttons/return.png b/images/buttons/return.png deleted file mode 100644 index a3f4981..0000000 Binary files a/images/buttons/return.png and /dev/null differ diff --git a/images/buttons/set_click.png b/images/buttons/set_click.png deleted file mode 100644 index f7dbec3..0000000 Binary files a/images/buttons/set_click.png and /dev/null differ diff --git a/images/buttons/set_mouseselect.png b/images/buttons/set_mouseselect.png deleted file mode 100644 index a29db1e..0000000 Binary files a/images/buttons/set_mouseselect.png and /dev/null differ diff --git a/images/buttons/set_music.png b/images/buttons/set_music.png deleted file mode 100644 index 70146ec..0000000 Binary files a/images/buttons/set_music.png and /dev/null differ diff --git a/images/buttons/set_sound.png b/images/buttons/set_sound.png deleted file mode 100644 index 5f0d487..0000000 Binary files a/images/buttons/set_sound.png and /dev/null differ diff --git a/images/buttons/set_spacebar.png b/images/buttons/set_spacebar.png deleted file mode 100644 index 153275c..0000000 Binary files a/images/buttons/set_spacebar.png and /dev/null differ diff --git a/images/buttons/set_track.png b/images/buttons/set_track.png deleted file mode 100644 index c2489cb..0000000 Binary files a/images/buttons/set_track.png and /dev/null differ diff --git a/images/buttons/settings.png b/images/buttons/settings.png deleted file mode 100644 index cb52726..0000000 Binary files a/images/buttons/settings.png and /dev/null differ diff --git a/images/buttons/track_left.png b/images/buttons/track_left.png deleted file mode 100644 index 0ad83cd..0000000 Binary files a/images/buttons/track_left.png and /dev/null differ diff --git a/images/buttons/track_right.png b/images/buttons/track_right.png deleted file mode 100644 index 0890c6e..0000000 Binary files a/images/buttons/track_right.png and /dev/null differ diff --git a/images/buttons/tut_ok.png b/images/buttons/tut_ok.png deleted file mode 100755 index b047b7b..0000000 Binary files a/images/buttons/tut_ok.png and /dev/null differ diff --git a/images/buttons/tutorialbox.png b/images/buttons/tutorialbox.png deleted file mode 100755 index cff6abf..0000000 Binary files a/images/buttons/tutorialbox.png and /dev/null differ diff --git a/images/cellinfect_animation/infect_a01.png b/images/cellinfect_animation/infect_a01.png deleted file mode 100644 index 7d02b1a..0000000 Binary files a/images/cellinfect_animation/infect_a01.png and /dev/null differ diff --git a/images/cellinfect_animation/infect_a02.png b/images/cellinfect_animation/infect_a02.png deleted file mode 100644 index cd5d557..0000000 Binary files a/images/cellinfect_animation/infect_a02.png and /dev/null differ diff --git a/images/cellinfect_animation/infect_a03.png b/images/cellinfect_animation/infect_a03.png deleted file mode 100644 index 070d4d9..0000000 Binary files a/images/cellinfect_animation/infect_a03.png and /dev/null differ diff --git a/images/cellinfect_animation/infect_a04.png b/images/cellinfect_animation/infect_a04.png deleted file mode 100644 index 45c2d2c..0000000 Binary files a/images/cellinfect_animation/infect_a04.png and /dev/null differ diff --git a/images/cellinfect_animation/infect_a05.png b/images/cellinfect_animation/infect_a05.png deleted file mode 100644 index 6b0cf04..0000000 Binary files a/images/cellinfect_animation/infect_a05.png and /dev/null differ diff --git a/images/cellinfect_animation/infect_a06.png b/images/cellinfect_animation/infect_a06.png deleted file mode 100644 index caf6ac5..0000000 Binary files a/images/cellinfect_animation/infect_a06.png and /dev/null differ diff --git a/images/cellinfect_animation/infect_a07.png b/images/cellinfect_animation/infect_a07.png deleted file mode 100644 index fedb457..0000000 Binary files a/images/cellinfect_animation/infect_a07.png and /dev/null differ diff --git a/images/cellinfect_animation/infect_a08.png b/images/cellinfect_animation/infect_a08.png deleted file mode 100644 index 1e0ca69..0000000 Binary files a/images/cellinfect_animation/infect_a08.png and /dev/null differ diff --git a/images/cellinfect_animation/infect_a09.png b/images/cellinfect_animation/infect_a09.png deleted file mode 100644 index 43d1b04..0000000 Binary files a/images/cellinfect_animation/infect_a09.png and /dev/null differ diff --git a/images/cellinfect_animation/infect_a10.png b/images/cellinfect_animation/infect_a10.png deleted file mode 100644 index 0aee860..0000000 Binary files a/images/cellinfect_animation/infect_a10.png and /dev/null differ diff --git a/images/cellinfect_animation/infect_a11.png b/images/cellinfect_animation/infect_a11.png deleted file mode 100644 index 542e505..0000000 Binary files a/images/cellinfect_animation/infect_a11.png and /dev/null differ diff --git a/images/cellinfect_animation/infect_a12.png b/images/cellinfect_animation/infect_a12.png deleted file mode 100644 index 1bcc3ab..0000000 Binary files a/images/cellinfect_animation/infect_a12.png and /dev/null differ diff --git a/images/halogo.jpg b/images/halogo.jpg deleted file mode 100644 index e6e43c0..0000000 Binary files a/images/halogo.jpg and /dev/null differ diff --git a/images/holemacrophage_animation/hmacrophage_a01.png b/images/holemacrophage_animation/hmacrophage_a01.png deleted file mode 100644 index 739eea8..0000000 Binary files a/images/holemacrophage_animation/hmacrophage_a01.png and /dev/null differ diff --git a/images/holemacrophage_animation/hmacrophage_a02.png b/images/holemacrophage_animation/hmacrophage_a02.png deleted file mode 100644 index 189ed3d..0000000 Binary files a/images/holemacrophage_animation/hmacrophage_a02.png and /dev/null differ diff --git a/images/holemacrophage_animation/hmacrophage_a03.png b/images/holemacrophage_animation/hmacrophage_a03.png deleted file mode 100644 index b9011c3..0000000 Binary files a/images/holemacrophage_animation/hmacrophage_a03.png and /dev/null differ diff --git a/images/holemacrophage_animation/hmacrophage_a04.png b/images/holemacrophage_animation/hmacrophage_a04.png deleted file mode 100644 index 315daee..0000000 Binary files a/images/holemacrophage_animation/hmacrophage_a04.png and /dev/null differ diff --git a/images/holemacrophage_animation/hmacrophage_a05.png b/images/holemacrophage_animation/hmacrophage_a05.png deleted file mode 100644 index 6510538..0000000 Binary files a/images/holemacrophage_animation/hmacrophage_a05.png and /dev/null differ diff --git a/images/holemacrophage_animation/hmacrophage_a06.png b/images/holemacrophage_animation/hmacrophage_a06.png deleted file mode 100644 index e4387c2..0000000 Binary files a/images/holemacrophage_animation/hmacrophage_a06.png and /dev/null differ diff --git a/images/holemacrophage_animation/hmacrophage_a07.png b/images/holemacrophage_animation/hmacrophage_a07.png deleted file mode 100644 index 4aefeb5..0000000 Binary files a/images/holemacrophage_animation/hmacrophage_a07.png and /dev/null differ diff --git a/images/holemacrophage_animation/hmacrophage_a08.png b/images/holemacrophage_animation/hmacrophage_a08.png deleted file mode 100644 index f1c0e9c..0000000 Binary files a/images/holemacrophage_animation/hmacrophage_a08.png and /dev/null differ diff --git a/images/holemacrophage_animation/hmacrophage_a09.png b/images/holemacrophage_animation/hmacrophage_a09.png deleted file mode 100644 index aad7670..0000000 Binary files a/images/holemacrophage_animation/hmacrophage_a09.png and /dev/null differ diff --git a/images/holemacrophage_animation/hmacrophage_a10.png b/images/holemacrophage_animation/hmacrophage_a10.png deleted file mode 100644 index 84499ec..0000000 Binary files a/images/holemacrophage_animation/hmacrophage_a10.png and /dev/null differ diff --git a/images/holemacrophage_animation/hmacrophage_a11.png b/images/holemacrophage_animation/hmacrophage_a11.png deleted file mode 100644 index cf9c8e4..0000000 Binary files a/images/holemacrophage_animation/hmacrophage_a11.png and /dev/null differ diff --git a/images/holemacrophage_animation/hmacrophage_a12.png b/images/holemacrophage_animation/hmacrophage_a12.png deleted file mode 100644 index d7d1da2..0000000 Binary files a/images/holemacrophage_animation/hmacrophage_a12.png and /dev/null differ diff --git a/images/holemacrophage_animation/hmacrophage_a13.png b/images/holemacrophage_animation/hmacrophage_a13.png deleted file mode 100644 index 7c7161b..0000000 Binary files a/images/holemacrophage_animation/hmacrophage_a13.png and /dev/null differ diff --git a/images/holemacrophage_animation/hmacrophage_a14.png b/images/holemacrophage_animation/hmacrophage_a14.png deleted file mode 100644 index 3d54eba..0000000 Binary files a/images/holemacrophage_animation/hmacrophage_a14.png and /dev/null differ diff --git a/images/infectable_cell/infectable_cell_2n.png b/images/infectable_cell/infectable_cell_2n.png deleted file mode 100644 index ac98c48..0000000 Binary files a/images/infectable_cell/infectable_cell_2n.png and /dev/null differ diff --git a/images/infectable_cell/infectable_cell_3n.png b/images/infectable_cell/infectable_cell_3n.png deleted file mode 100644 index 5cb97e8..0000000 Binary files a/images/infectable_cell/infectable_cell_3n.png and /dev/null differ diff --git a/images/infectable_cell/infectable_cell_4n.png b/images/infectable_cell/infectable_cell_4n.png deleted file mode 100644 index 8027852..0000000 Binary files a/images/infectable_cell/infectable_cell_4n.png and /dev/null differ diff --git a/images/infectable_cell/infectable_cell_5n.png b/images/infectable_cell/infectable_cell_5n.png deleted file mode 100644 index 6503050..0000000 Binary files a/images/infectable_cell/infectable_cell_5n.png and /dev/null differ diff --git a/images/infectable_cell/infectable_cell_6n.png b/images/infectable_cell/infectable_cell_6n.png deleted file mode 100644 index 41e450e..0000000 Binary files a/images/infectable_cell/infectable_cell_6n.png and /dev/null differ diff --git a/images/infectable_cell/infectable_cell_7n.png b/images/infectable_cell/infectable_cell_7n.png deleted file mode 100644 index f9cbc94..0000000 Binary files a/images/infectable_cell/infectable_cell_7n.png and /dev/null differ diff --git a/images/listcell.png b/images/listcell.png deleted file mode 100644 index 27af90c..0000000 Binary files a/images/listcell.png and /dev/null differ diff --git a/images/logo/logo128.png b/images/logo/logo128.png deleted file mode 100644 index d370aed..0000000 Binary files a/images/logo/logo128.png and /dev/null differ diff --git a/images/logo/logo32.png b/images/logo/logo32.png deleted file mode 100644 index b076f80..0000000 Binary files a/images/logo/logo32.png and /dev/null differ diff --git a/images/logo/logo64.png b/images/logo/logo64.png deleted file mode 100644 index ca134e5..0000000 Binary files a/images/logo/logo64.png and /dev/null differ diff --git a/images/logo/vlogolarge.png b/images/logo/vlogolarge.png deleted file mode 100644 index 274bab9..0000000 Binary files a/images/logo/vlogolarge.png and /dev/null differ diff --git a/images/logo/vlogolargetext.png b/images/logo/vlogolargetext.png deleted file mode 100644 index 6004b8e..0000000 Binary files a/images/logo/vlogolargetext.png and /dev/null differ diff --git a/images/macrophage_1.png b/images/macrophage_1.png deleted file mode 100644 index b03e4cd..0000000 Binary files a/images/macrophage_1.png and /dev/null differ diff --git a/images/macrophage_1_active.png b/images/macrophage_1_active.png deleted file mode 100644 index 4b858d4..0000000 Binary files a/images/macrophage_1_active.png and /dev/null differ diff --git a/images/macrophage_animation/macrophage_a01.png b/images/macrophage_animation/macrophage_a01.png deleted file mode 100644 index 34e9035..0000000 Binary files a/images/macrophage_animation/macrophage_a01.png and /dev/null differ diff --git a/images/macrophage_animation/macrophage_a02.png b/images/macrophage_animation/macrophage_a02.png deleted file mode 100644 index 0cb1089..0000000 Binary files a/images/macrophage_animation/macrophage_a02.png and /dev/null differ diff --git a/images/macrophage_animation/macrophage_a03.png b/images/macrophage_animation/macrophage_a03.png deleted file mode 100644 index 12f9af3..0000000 Binary files a/images/macrophage_animation/macrophage_a03.png and /dev/null differ diff --git a/images/macrophage_animation/macrophage_a04.png b/images/macrophage_animation/macrophage_a04.png deleted file mode 100644 index 3ccaca9..0000000 Binary files a/images/macrophage_animation/macrophage_a04.png and /dev/null differ diff --git a/images/macrophage_animation/macrophage_a05.png b/images/macrophage_animation/macrophage_a05.png deleted file mode 100644 index b5e97c1..0000000 Binary files a/images/macrophage_animation/macrophage_a05.png and /dev/null differ diff --git a/images/macrophage_animation/macrophage_a06.png b/images/macrophage_animation/macrophage_a06.png deleted file mode 100644 index e8a1b97..0000000 Binary files a/images/macrophage_animation/macrophage_a06.png and /dev/null differ diff --git a/images/macrophage_animation/macrophage_a07.png b/images/macrophage_animation/macrophage_a07.png deleted file mode 100644 index 13ab22f..0000000 Binary files a/images/macrophage_animation/macrophage_a07.png and /dev/null differ diff --git a/images/macrophage_animation/macrophage_a08.png b/images/macrophage_animation/macrophage_a08.png deleted file mode 100644 index 7ac4102..0000000 Binary files a/images/macrophage_animation/macrophage_a08.png and /dev/null differ diff --git a/images/macrophage_animation/macrophage_a09.png b/images/macrophage_animation/macrophage_a09.png deleted file mode 100644 index 32f7c20..0000000 Binary files a/images/macrophage_animation/macrophage_a09.png and /dev/null differ diff --git a/images/macrophage_animation/macrophage_a10.png b/images/macrophage_animation/macrophage_a10.png deleted file mode 100644 index 4f64246..0000000 Binary files a/images/macrophage_animation/macrophage_a10.png and /dev/null differ diff --git a/images/macrophage_animation/macrophage_a11.png b/images/macrophage_animation/macrophage_a11.png deleted file mode 100644 index bb1870f..0000000 Binary files a/images/macrophage_animation/macrophage_a11.png and /dev/null differ diff --git a/images/macrophage_animation/macrophage_a12.png b/images/macrophage_animation/macrophage_a12.png deleted file mode 100644 index 506e48b..0000000 Binary files a/images/macrophage_animation/macrophage_a12.png and /dev/null differ diff --git a/images/macrophage_animation/macrophage_a13.png b/images/macrophage_animation/macrophage_a13.png deleted file mode 100644 index 7b14bd9..0000000 Binary files a/images/macrophage_animation/macrophage_a13.png and /dev/null differ diff --git a/images/macrophage_animation/macrophage_a14.png b/images/macrophage_animation/macrophage_a14.png deleted file mode 100644 index f78597b..0000000 Binary files a/images/macrophage_animation/macrophage_a14.png and /dev/null differ diff --git a/images/noninfectable_cell/noninfectable_cell_1n.png b/images/noninfectable_cell/noninfectable_cell_1n.png deleted file mode 100644 index 9768618..0000000 Binary files a/images/noninfectable_cell/noninfectable_cell_1n.png and /dev/null differ diff --git a/images/noninfectable_cell/noninfectable_cell_2n.png b/images/noninfectable_cell/noninfectable_cell_2n.png deleted file mode 100644 index c6b582c..0000000 Binary files a/images/noninfectable_cell/noninfectable_cell_2n.png and /dev/null differ diff --git a/images/noninfectable_cell/noninfectable_cell_3n.png b/images/noninfectable_cell/noninfectable_cell_3n.png deleted file mode 100644 index a387eb0..0000000 Binary files a/images/noninfectable_cell/noninfectable_cell_3n.png and /dev/null differ diff --git a/images/noninfectable_cell/noninfectable_cell_4n.png b/images/noninfectable_cell/noninfectable_cell_4n.png deleted file mode 100644 index 1bf02a8..0000000 Binary files a/images/noninfectable_cell/noninfectable_cell_4n.png and /dev/null differ diff --git a/images/noninfectable_cell/noninfectable_cell_5n.png b/images/noninfectable_cell/noninfectable_cell_5n.png deleted file mode 100644 index 841dd45..0000000 Binary files a/images/noninfectable_cell/noninfectable_cell_5n.png and /dev/null differ diff --git a/images/old/.DS_Store b/images/old/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/images/old/.DS_Store and /dev/null differ diff --git a/images/old/b/.DS_Store b/images/old/b/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/images/old/b/.DS_Store and /dev/null differ diff --git a/images/old/b/macrophage_a1.gif b/images/old/b/macrophage_a1.gif deleted file mode 100755 index ea1ba06..0000000 Binary files a/images/old/b/macrophage_a1.gif and /dev/null differ diff --git a/images/old/background/background_bcells1.png b/images/old/background/background_bcells1.png deleted file mode 100755 index f809f50..0000000 Binary files a/images/old/background/background_bcells1.png and /dev/null differ diff --git a/images/old/background/background_bcells2.png b/images/old/background/background_bcells2.png deleted file mode 100755 index d99ee15..0000000 Binary files a/images/old/background/background_bcells2.png and /dev/null differ diff --git a/images/old/background/background_bcells3.png b/images/old/background/background_bcells3.png deleted file mode 100755 index 099a0f7..0000000 Binary files a/images/old/background/background_bcells3.png and /dev/null differ diff --git a/images/old/background/background_bcells4.png b/images/old/background/background_bcells4.png deleted file mode 100755 index 9ed69c7..0000000 Binary files a/images/old/background/background_bcells4.png and /dev/null differ diff --git a/images/old/background/background_bottomside.png b/images/old/background/background_bottomside.png deleted file mode 100755 index 90bda8d..0000000 Binary files a/images/old/background/background_bottomside.png and /dev/null differ diff --git a/images/old/background/background_dstreaks1.png b/images/old/background/background_dstreaks1.png deleted file mode 100755 index 9f553e6..0000000 Binary files a/images/old/background/background_dstreaks1.png and /dev/null differ diff --git a/images/old/background/background_dstreaks2.png b/images/old/background/background_dstreaks2.png deleted file mode 100755 index 258b8c6..0000000 Binary files a/images/old/background/background_dstreaks2.png and /dev/null differ diff --git a/images/old/background/background_dstreaks3.png b/images/old/background/background_dstreaks3.png deleted file mode 100755 index fcbcbb7..0000000 Binary files a/images/old/background/background_dstreaks3.png and /dev/null differ diff --git a/images/old/background/background_lstreaks1.png b/images/old/background/background_lstreaks1.png deleted file mode 100755 index 3f313ce..0000000 Binary files a/images/old/background/background_lstreaks1.png and /dev/null differ diff --git a/images/old/background/background_lstreaks2.png b/images/old/background/background_lstreaks2.png deleted file mode 100755 index 6d9e38e..0000000 Binary files a/images/old/background/background_lstreaks2.png and /dev/null differ diff --git a/images/old/background/background_topside.png b/images/old/background/background_topside.png deleted file mode 100755 index 70573ac..0000000 Binary files a/images/old/background/background_topside.png and /dev/null differ diff --git a/images/old/bcell1.png b/images/old/bcell1.png deleted file mode 100644 index f383cdd..0000000 Binary files a/images/old/bcell1.png and /dev/null differ diff --git a/images/old/cellwall1.png b/images/old/cellwall1.png deleted file mode 100644 index ac5e3c1..0000000 Binary files a/images/old/cellwall1.png and /dev/null differ diff --git a/images/old/cellwall1draft.svg b/images/old/cellwall1draft.svg deleted file mode 100644 index 0c2ae5a..0000000 --- a/images/old/cellwall1draft.svg +++ /dev/null @@ -1,1120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/images/old/infectable1.png b/images/old/infectable1.png deleted file mode 100644 index 29f9eb1..0000000 Binary files a/images/old/infectable1.png and /dev/null differ diff --git a/images/old/infectable2.png b/images/old/infectable2.png deleted file mode 100644 index 40d0d7d..0000000 Binary files a/images/old/infectable2.png and /dev/null differ diff --git a/images/old/infectable3.png b/images/old/infectable3.png deleted file mode 100644 index 69567be..0000000 Binary files a/images/old/infectable3.png and /dev/null differ diff --git a/images/old/infectable_cell/infectable_cell_2n.png b/images/old/infectable_cell/infectable_cell_2n.png deleted file mode 100755 index 29f9eb1..0000000 Binary files a/images/old/infectable_cell/infectable_cell_2n.png and /dev/null differ diff --git a/images/old/infectable_cell/infectable_cell_3n.png b/images/old/infectable_cell/infectable_cell_3n.png deleted file mode 100755 index 40d0d7d..0000000 Binary files a/images/old/infectable_cell/infectable_cell_3n.png and /dev/null differ diff --git a/images/old/infectable_cell/infectable_cell_4n.png b/images/old/infectable_cell/infectable_cell_4n.png deleted file mode 100755 index 69567be..0000000 Binary files a/images/old/infectable_cell/infectable_cell_4n.png and /dev/null differ diff --git a/images/old/infectable_cell/infectable_cell_5n.png b/images/old/infectable_cell/infectable_cell_5n.png deleted file mode 100755 index 620adbb..0000000 Binary files a/images/old/infectable_cell/infectable_cell_5n.png and /dev/null differ diff --git a/images/old/infectable_cell/infectable_cell_6n.png b/images/old/infectable_cell/infectable_cell_6n.png deleted file mode 100755 index aa65877..0000000 Binary files a/images/old/infectable_cell/infectable_cell_6n.png and /dev/null differ diff --git a/images/old/infectable_cell/infectable_cell_7n.png b/images/old/infectable_cell/infectable_cell_7n.png deleted file mode 100755 index 2951a73..0000000 Binary files a/images/old/infectable_cell/infectable_cell_7n.png and /dev/null differ diff --git a/images/old/macrophage1.png b/images/old/macrophage1.png deleted file mode 100644 index 4dc0f6b..0000000 Binary files a/images/old/macrophage1.png and /dev/null differ diff --git a/images/old/macrophage_active.png b/images/old/macrophage_active.png deleted file mode 100644 index ed7d1ee..0000000 Binary files a/images/old/macrophage_active.png and /dev/null differ diff --git a/images/old/new/.DS_Store b/images/old/new/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/images/old/new/.DS_Store and /dev/null differ diff --git a/images/old/new/infectable1.png b/images/old/new/infectable1.png deleted file mode 100755 index 298f24c..0000000 Binary files a/images/old/new/infectable1.png and /dev/null differ diff --git a/images/old/new/infectable2.png b/images/old/new/infectable2.png deleted file mode 100755 index 01100dd..0000000 Binary files a/images/old/new/infectable2.png and /dev/null differ diff --git a/images/old/new/infectable3.png b/images/old/new/infectable3.png deleted file mode 100755 index 9bc043f..0000000 Binary files a/images/old/new/infectable3.png and /dev/null differ diff --git a/images/old/new/noninfectable.png b/images/old/new/noninfectable.png deleted file mode 100755 index bbe312b..0000000 Binary files a/images/old/new/noninfectable.png and /dev/null differ diff --git a/images/old/noninfectable1.png b/images/old/noninfectable1.png deleted file mode 100644 index dde08a7..0000000 Binary files a/images/old/noninfectable1.png and /dev/null differ diff --git a/images/old/noninfectable_cell/noninfectable_cell_2n.png b/images/old/noninfectable_cell/noninfectable_cell_2n.png deleted file mode 100755 index e586a95..0000000 Binary files a/images/old/noninfectable_cell/noninfectable_cell_2n.png and /dev/null differ diff --git a/images/old/noninfectable_cell/noninfectable_cell_3.png b/images/old/noninfectable_cell/noninfectable_cell_3.png deleted file mode 100755 index a04f17c..0000000 Binary files a/images/old/noninfectable_cell/noninfectable_cell_3.png and /dev/null differ diff --git a/images/old/noninfectable_cell/noninfectable_cell_4.png b/images/old/noninfectable_cell/noninfectable_cell_4.png deleted file mode 100755 index 5114e1d..0000000 Binary files a/images/old/noninfectable_cell/noninfectable_cell_4.png and /dev/null differ diff --git a/images/old/noninfectable_cell/noninfectable_cell_5.png b/images/old/noninfectable_cell/noninfectable_cell_5.png deleted file mode 100755 index 86a67e3..0000000 Binary files a/images/old/noninfectable_cell/noninfectable_cell_5.png and /dev/null differ diff --git a/images/old/particle.png b/images/old/particle.png deleted file mode 100644 index e2c8a15..0000000 Binary files a/images/old/particle.png and /dev/null differ diff --git a/images/old/screens/.DS_Store b/images/old/screens/.DS_Store deleted file mode 100755 index 5008ddf..0000000 Binary files a/images/old/screens/.DS_Store and /dev/null differ diff --git a/images/old/screens/bullet_listcell.png b/images/old/screens/bullet_listcell.png deleted file mode 100755 index 7525958..0000000 Binary files a/images/old/screens/bullet_listcell.png and /dev/null differ diff --git a/images/old/screens/header.png b/images/old/screens/header.png deleted file mode 100755 index 8b83ea6..0000000 Binary files a/images/old/screens/header.png and /dev/null differ diff --git a/images/old/screens/listcell.png b/images/old/screens/listcell.png deleted file mode 100755 index ef2eba2..0000000 Binary files a/images/old/screens/listcell.png and /dev/null differ diff --git a/images/old/screens/loading.png b/images/old/screens/loading.png deleted file mode 100755 index a20886e..0000000 Binary files a/images/old/screens/loading.png and /dev/null differ diff --git a/images/old/screens/loadingsplash.png b/images/old/screens/loadingsplash.png deleted file mode 100755 index 9c3d6bc..0000000 Binary files a/images/old/screens/loadingsplash.png and /dev/null differ diff --git a/images/old/screens/mainscreenbase.png b/images/old/screens/mainscreenbase.png deleted file mode 100755 index 2287e53..0000000 Binary files a/images/old/screens/mainscreenbase.png and /dev/null differ diff --git a/images/old/screens/newgame_listcell.png b/images/old/screens/newgame_listcell.png deleted file mode 100755 index 3360fb7..0000000 Binary files a/images/old/screens/newgame_listcell.png and /dev/null differ diff --git a/images/old/screens/settings.png b/images/old/screens/settings.png deleted file mode 100755 index 3041eea..0000000 Binary files a/images/old/screens/settings.png and /dev/null differ diff --git a/images/old/screens/settingssplash.png b/images/old/screens/settingssplash.png deleted file mode 100755 index ac1891a..0000000 Binary files a/images/old/screens/settingssplash.png and /dev/null differ diff --git a/images/old/tcells/tcell1.png b/images/old/tcells/tcell1.png deleted file mode 100755 index a49799f..0000000 Binary files a/images/old/tcells/tcell1.png and /dev/null differ diff --git a/images/old/tcells/tcell2.png b/images/old/tcells/tcell2.png deleted file mode 100755 index 24b6ac2..0000000 Binary files a/images/old/tcells/tcell2.png and /dev/null differ diff --git a/images/old/tcells/tcell3.png b/images/old/tcells/tcell3.png deleted file mode 100755 index 98dbc44..0000000 Binary files a/images/old/tcells/tcell3.png and /dev/null differ diff --git a/images/old/tcells/tcell4.png b/images/old/tcells/tcell4.png deleted file mode 100755 index 891c32b..0000000 Binary files a/images/old/tcells/tcell4.png and /dev/null differ diff --git a/images/old/virus1.png b/images/old/virus1.png deleted file mode 100644 index d9db175..0000000 Binary files a/images/old/virus1.png and /dev/null differ diff --git a/images/old/virusfinal.svg b/images/old/virusfinal.svg deleted file mode 100644 index 3b61a61..0000000 --- a/images/old/virusfinal.svg +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/images/old/wall_segments/cellwall1.png b/images/old/wall_segments/cellwall1.png deleted file mode 100755 index 0d71d6e..0000000 Binary files a/images/old/wall_segments/cellwall1.png and /dev/null differ diff --git a/images/old/wall_segments/cellwall2.png b/images/old/wall_segments/cellwall2.png deleted file mode 100755 index f06bf92..0000000 Binary files a/images/old/wall_segments/cellwall2.png and /dev/null differ diff --git a/images/old/wall_segments/cellwall3.png b/images/old/wall_segments/cellwall3.png deleted file mode 100755 index 2b7f3c7..0000000 Binary files a/images/old/wall_segments/cellwall3.png and /dev/null differ diff --git a/images/old/wall_segments/cellwall4.png b/images/old/wall_segments/cellwall4.png deleted file mode 100755 index d33f471..0000000 Binary files a/images/old/wall_segments/cellwall4.png and /dev/null differ diff --git a/images/old/wall_segments/cellwall5.png b/images/old/wall_segments/cellwall5.png deleted file mode 100755 index c0bbabd..0000000 Binary files a/images/old/wall_segments/cellwall5.png and /dev/null differ diff --git a/images/old/wall_segments/cellwall6.png b/images/old/wall_segments/cellwall6.png deleted file mode 100755 index 203950f..0000000 Binary files a/images/old/wall_segments/cellwall6.png and /dev/null differ diff --git a/images/old/wall_segments/cellwall7.png b/images/old/wall_segments/cellwall7.png deleted file mode 100755 index 262a9b3..0000000 Binary files a/images/old/wall_segments/cellwall7.png and /dev/null differ diff --git a/images/old/wallcell1.png b/images/old/wallcell1.png deleted file mode 100644 index 30c4535..0000000 Binary files a/images/old/wallcell1.png and /dev/null differ diff --git a/images/screens/creditsscreen.png b/images/screens/creditsscreen.png deleted file mode 100644 index 40ff9db..0000000 Binary files a/images/screens/creditsscreen.png and /dev/null differ diff --git a/images/screens/helpsplash.png b/images/screens/helpsplash.png deleted file mode 100644 index f92663b..0000000 Binary files a/images/screens/helpsplash.png and /dev/null differ diff --git a/images/screens/loadingsplash.png b/images/screens/loadingsplash.png deleted file mode 100644 index 7825408..0000000 Binary files a/images/screens/loadingsplash.png and /dev/null differ diff --git a/images/screens/mainscreenbase.png b/images/screens/mainscreenbase.png deleted file mode 100644 index dd63a98..0000000 Binary files a/images/screens/mainscreenbase.png and /dev/null differ diff --git a/images/screens/settingssplash.png b/images/screens/settingssplash.png deleted file mode 100644 index 7cd9b4e..0000000 Binary files a/images/screens/settingssplash.png and /dev/null differ diff --git a/images/t_animation/tcell_a01.png b/images/t_animation/tcell_a01.png deleted file mode 100644 index 22b4364..0000000 Binary files a/images/t_animation/tcell_a01.png and /dev/null differ diff --git a/images/t_animation/tcell_a02.png b/images/t_animation/tcell_a02.png deleted file mode 100644 index 6743fbc..0000000 Binary files a/images/t_animation/tcell_a02.png and /dev/null differ diff --git a/images/t_animation/tcell_a03.png b/images/t_animation/tcell_a03.png deleted file mode 100644 index d6b30c9..0000000 Binary files a/images/t_animation/tcell_a03.png and /dev/null differ diff --git a/images/t_animation/tcell_a04.png b/images/t_animation/tcell_a04.png deleted file mode 100644 index 17e9836..0000000 Binary files a/images/t_animation/tcell_a04.png and /dev/null differ diff --git a/images/t_animation/tcell_a05.png b/images/t_animation/tcell_a05.png deleted file mode 100644 index a909794..0000000 Binary files a/images/t_animation/tcell_a05.png and /dev/null differ diff --git a/images/t_animation/tcell_a06.png b/images/t_animation/tcell_a06.png deleted file mode 100644 index af2bf7f..0000000 Binary files a/images/t_animation/tcell_a06.png and /dev/null differ diff --git a/images/t_animation/tcell_a07.png b/images/t_animation/tcell_a07.png deleted file mode 100644 index e6a1f7c..0000000 Binary files a/images/t_animation/tcell_a07.png and /dev/null differ diff --git a/images/tcell_2.png b/images/tcell_2.png deleted file mode 100644 index bcdfd37..0000000 Binary files a/images/tcell_2.png and /dev/null differ diff --git a/images/tinyvirus_shadowtrans.png b/images/tinyvirus_shadowtrans.png deleted file mode 100644 index 06f8178..0000000 Binary files a/images/tinyvirus_shadowtrans.png and /dev/null differ diff --git a/images/tinyvirus_trans.png b/images/tinyvirus_trans.png deleted file mode 100644 index ffad22b..0000000 Binary files a/images/tinyvirus_trans.png and /dev/null differ diff --git a/images/wall_segments/cellwall1.png b/images/wall_segments/cellwall1.png deleted file mode 100644 index 0e4aa10..0000000 Binary files a/images/wall_segments/cellwall1.png and /dev/null differ diff --git a/images/wall_segments/cellwall2.png b/images/wall_segments/cellwall2.png deleted file mode 100644 index 8b07659..0000000 Binary files a/images/wall_segments/cellwall2.png and /dev/null differ diff --git a/images/wall_segments/cellwall3.png b/images/wall_segments/cellwall3.png deleted file mode 100644 index d91f9ac..0000000 Binary files a/images/wall_segments/cellwall3.png and /dev/null differ diff --git a/images/wall_segments/cellwall4.png b/images/wall_segments/cellwall4.png deleted file mode 100644 index aaf96ad..0000000 Binary files a/images/wall_segments/cellwall4.png and /dev/null differ diff --git a/images/wall_segments/cellwall5.png b/images/wall_segments/cellwall5.png deleted file mode 100644 index edb9fa1..0000000 Binary files a/images/wall_segments/cellwall5.png and /dev/null differ diff --git a/images/wall_segments/cellwall6.png b/images/wall_segments/cellwall6.png deleted file mode 100644 index 175ed0f..0000000 Binary files a/images/wall_segments/cellwall6.png and /dev/null differ diff --git a/images/wall_segments/cellwall7.png b/images/wall_segments/cellwall7.png deleted file mode 100644 index e1d20e5..0000000 Binary files a/images/wall_segments/cellwall7.png and /dev/null differ diff --git a/images/wallcell_1.png b/images/wallcell_1.png deleted file mode 100644 index 9f5f197..0000000 Binary files a/images/wallcell_1.png and /dev/null differ diff --git a/in_game_state.js b/in_game_state.js deleted file mode 100644 index e377b4e..0000000 --- a/in_game_state.js +++ /dev/null @@ -1,1938 +0,0 @@ -// *** game *** -// NOTE: get_type() returns "game" not "in_game" - -// defined up here cuz instructions need them -// and a game might not be init'd before reading instr -g_speed_factor = 1; // multiply all speed constants in the game by this, for easy mode - -// Global Variable so cell arrows can draw dots -GLOBAL_is_easy = false; - -// flag for whether the tutorial has been played through -// if false, easy mode will include the tutorial -g_tut_done = false; - -// game_type is: -// 0 - easy -// 1 - tutorial -// 2 - hard -var in_game_state = function (p, previous_state, game_type) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - - // whether or not we are testing - // use it wherever - var testing = false; - obj.testing = function() { return testing; }; - - // --- constants --- - //var num_of_render_levels = 5; Now auto-calculating in init so don't have to change - - // --- private variables --- - - - var GOOD_NOTIFICATION_COLOR = p.color(0, 255, 0); - var BAD_NOTIFICATION_COLOR = p.color(255, 0, 0); - - var prev_state = previous_state; - // distance is the x-coordinate of the total distance traveled - // increments with scroll - var distance = 0; - //var score = 0; - var active_cell = null; - var last_active_cell = null; - // multiply each object's scroll amount by this - // factor, which increases throughout the game - var scroll_factor = 1; - if (game_type < 2) { - g_speed_factor = 0.75; - } - scroll_factor *= g_speed_factor; - - var game_objects = []; - var paused = false; - - var status_bar_height = 40; - var status_height = 20; - - var score = num_status_obj(p, { - pos : new p.PVector(p.width - 100, status_height), - text : "Score:", - num : 0, - format : add_commas - }); - var mult = num_status_obj(p, { - pos : new p.PVector(p.width - 200, status_height), - text : "Multiplier:", - num : 1, - format : function(num) { - return num+"x"; - } - }); - var time_elapsed = 0; // Time elapsed in seconds - var set_time = false; //bool that says if we've started counting time - var time_status = num_status_obj(p, { - pos : new p.PVector(85, status_height), - text : "Time:", - num : time_elapsed, - // formats time to mins:secs - format : function(num) { - var secs = num%60; - if (secs < 10) { secs = "0" + secs; } - return p.floor(num/60) + ":" + secs; - } - }); - var mutation = mutation_obj(p, { status_height : status_height }); - - var pause_button = button(p, { - state: function() { - do_pause(); - console.log("pause button"); - return pause_state(p, obj); - }, - rect: { - pos: new p.PVector(25, status_height), - width: 25, height: 25, - } - }); - // draw two vertical rects - pause_button.draw = function() { - p.pushMatrix(); - // get the rect spec back - var r = pause_button.get_rect(); - var w = r.width; - var h = r.height; - p.translate(r.pos.x-w/2, r.pos.y-h/2); - p.strokeWeight(2); - p.stroke(255); - p.noFill(); - p.ellipse(w/2, h/2, w, h); - p.noStroke(); - p.fill(255); - p.rectMode(p.CORNER); - p.rect(w/4, h/5, w/5, 3*h/5); - p.rect(w-w/4-w/5, h/5, w/5, 3*h/5); - p.popMatrix(); - }; - - // Used to draw all of the statuses (must implement draw) - var all_status_objs = [score, mult, time_status, mutation]; - var all_buttons = [pause_button]; - - - var is_tutorial = false; - if (game_type === 1 - // if the tutorial hasn't been done, do on easy mode - || (game_type === 0 && !g_tut_done) ){ - is_tutorial = true; - } - if (game_type < 2) { - GLOBAL_is_easy = true; - } - - - // the popup to draw at a given time - // null if there is none - var tut_window = null; - // flag for unpausing - // when false mouse clicks wont fire - var ok_to_fire = true; - // Call tut_manager.popup(type) when you want to signal a tutorial message - // All the types are in tut_flags - var tut_manager = (function() { - - // object to store all the msgs - var tut_msgs = { - spacebar: "Press SPACEBAR or CLICK the mouse to shoot virions out of an infected cell in the direction of the arrow. The dotted lines will help you aim.", - arrows: "Use the LEFT and RIGHT arrow keys to switch between infected cells.", - macrophage: "Watch out for macrophages! They will kill your virion and alert a B cell.", - antibodies: "Oh no! The B cell is producing antibodies! If an antibody attaches to an infected cell, the cell will be marked for destruction by a granulocyte.", - killer: "A granulocyte just destroyed one of your infected cells marked with an antibody and all the virions inside it! Your virus won't be safe from the granulocyte until it mutates, creating a new strain.", - mutation: "Your virus just mutated to a new strain! Each virion can only be attacked by immune cells that know about its strain. Immune cells that know about a certain strain will be filled with the same color as virions of that strain.", strain: "Uh oh! The last virion of the new strain died, so your current highest mutation level went back down. You should try to keep alive the virions of the newest strain - they will earn you the most points!" }; // These flags are set to false when they've already occured - // built based on tut_msgs - var tut_flags = {}; - for_each( - keys(tut_msgs), - function(type) { - tut_flags[type] = true; - } - ); - - var tut_popup = function(txt) { - var obj = {}; - - var x = p.width/2; - var y = p.height/2; - var w = 400; - var h = 200; - var tw = w-50; - var tut_box = image_manager.get_image("tutorialbox.png"); - obj.draw = function() { - /* - p.noStroke(); - p.fill(100); - p.rectMode(p.CENTER); - p.rect(x, y, w, h); - */ - p.imageMode(p.CENTER); - p.image(tut_box, x, y); - p.fill(255); - p.textLeading(17); - p.textSize(16); - p.textAlign(p.CENTER, p.CENTER); - p.text(txt, x-tw/2, y-h/2, tw, h-50); - }; - - return obj; - }; - - var show_popup = function(text) { - var close_button = button(p, { - state: function() { - tut_window = null; - obj.resume(); - all_buttons.pop() // DANGEROUS... Hope we're not adding any other buttons anytime soon - return obj; // the current state - }, - rect: { - pos: new p.PVector(p.width/2, p.height/2+60), - //width: 50, height: 50, - //text: "OK" - image: "tut_ok.png" - } - }); - all_buttons.push(close_button); - - tut_window = tut_popup(text); - sounds.play_sound("TextPopUp"); - }; - - var tut_obj = { - popup : function(type) { - if (is_tutorial && tut_flags[type]) { - tut_pause(); - ok_to_fire = false; - text = tut_msgs[type]; - show_popup(text); - tut_flags[type] = false; - } - allFinished = true; - for_each( - keys(tut_msgs), - function(type) { - if (tut_flags[type]) { - allFinished = false; - } - } - ); - // the tutorial will have been completely finished by now - if (allFinished) { - g_tut_done = true; - } - } - }; - return tut_obj; - })() - - var all_notifications = []; - var last_notification_time = -1 - // takes a string and adds a new notification - var notify = function(note, color) { - var the_pos = null; - if (active_cell) { - console.log("Setting to active cell"); - a_pos = active_cell.get_pos(); - the_pos = new p.PVector(a_pos.x, a_pos.y - 30); - } - else { - console.log("Setting to default"); - the_pos = new p.PVector(p.width * (5/8), p.height * (5/8)); - } - if (new Date().getTime() > (last_notification_time + 2000)) { // two seconds - all_notifications.push(notification(p, { "text": note, "color": color, - "pos" : the_pos})); - last_notification_time = new Date().getTime(); - } - }; - - var generator = make_generator(p, { - game : obj, - mutation : mutation - }); - - // temporary flag TODO - //var game_over = false; - - //A mapping from game_object types to their rendering levels - var type_to_level = { - "background_object":0, - "background_edge":0, - "wall":1, - "wall_segment":1, - "particle":2, // general name for level - "cell":3, // general name for level - "wall_cell": 3, - "empty_cell": 3, - "enemy":4, // general name for level - "floater":4, - "tkiller":4, - "antibody":4, - "b_cell": 5, - "multiplier":6, - "info":7 - }; - - // given a type returns the array of objects - // corresponding to that type's level - var level = function(type) { - var lvl = game_objects[type_to_level[type]]; - assert (lvl, type+" not a valid type!"); - return lvl; - }; - - -/* - // Buttons - // Have a rectangle representing their position and - // a state to go to when pressed - var pause_button = { - state : pause_state(), - rectangle : rectangle(p, { - pos : new p.PVector(p.width - 20, 20), - width : 20, - height : 20 - }) - }; - var help_button = { - state : help_state(), - rectangle : rectangle(p, { - pos : new p.PVector(p.width - 80, 20), - width : 20, - height : 20 - }) - }; - var exit_button = { - state : exit_state(), - rectangle : rectangle(p, { - pos : new p.PVector(20, 20), - width : 20, - height : 20 - }) - }; -*/ - //Not ordered - - - // --- private methods --- - - // initialization code goes here - // gets called at the bottom - var init = function() { - // Start playing the game music - if (g.music) { - sounds.play_background_music(); - } - - //Initialize game_objects to be a list of num_of_render_levels empty lists - var num_of_render_levels = 0; - for (var key in type_to_level){ - if (type_to_level.hasOwnProperty(key)) { - var new_level = type_to_level[key]; - if (new_level > num_of_render_levels) { - num_of_render_levels = new_level; - } - } - } - for (var i = 0; i < num_of_render_levels; i++) { - game_objects[i] = []; - } - - var startx = p.width-150; - if (testing) { - var startx = 150; - } - - var initial_cells = [ - cell(p, { - pos: new p.PVector(startx, p.height/2), - vel: new p.PVector(0, 0), - state: "alive", - }), - cell(p, { - pos: new p.PVector(startx+170, p.height/2-40), - vel: new p.PVector(0, 0), - state: "alive", - }), - cell(p, { - pos: new p.PVector(startx+170, p.height/2), - vel: new p.PVector(0, 0), - state: "alive", - }), - cell(p, { - pos: new p.PVector(startx+170, p.height/2+40), - vel: new p.PVector(0, 0), - state: "alive", - }) - ]; - //var cell_level = type_to_level["cell"]; - //game_objects[cell_level].push(initial_cell); - obj.add_objects(initial_cells); - - var initial_par = particle(p, { - pos: new p.PVector(0, p.height/2), - vel: new p.PVector(8, 0), - // start with some gray - mutation_info: mutation.get_info()//p.color(250, 250, 250) - //mutation : mutation - }); - - obj.add_object(initial_par); - - init_walls(); - init_back(); - - //active_cell = initial_cell; - - // Add background - //var bg = background(p, { pos : new p.PVector(0, 0)}); - //obj.add_object(bg); - //console.log(level("background")[0]); - }; - - // creates, adds, and returns a new b_cell with no target - var make_b_cell = function() { - var new_b_cell = b_cell(p, { - pos: new p.PVector(p.width+50, p.random(p.height/4, 3*p.height/4)), - }); - obj.add_object(new_b_cell); - return new_b_cell; - }; - - // creates, adds, and returns a new tkiller with no target - var make_tkiller = function() { - var new_tkiller = tkiller(p, { - pos: new p.PVector(p.width+50, p.random(p.height/4, 3*p.height/4)), - }); - obj.add_object(new_tkiller); - return new_tkiller; - }; - - // Returns the current b cell on the screen, if there is one - var get_b_cell = function(level) { - var the_b_cell = null; - do_to_type( - function(b) { - if (b.get_level() === level) { - the_b_cell = b; - } - }, - "b_cell", true - ); - return the_b_cell; - }; - - var alert_b_cell = function(flo) { - // gets b_cell of the flo's level - var b = get_b_cell(flo.get_level()); - // if there isn't one - if (!b) { - // make one - b = make_b_cell(); - b.set_mutation_info(flo.get_mutation_info()); - b.set_target(flo); - } - // if there is one - else { - // it should be either active, shooting, or outdated - // so do nothing - } - }; - - // Alerts the b cell (only one on screen at a time?) to a newly mutated - // obj. - // If o.mutation_level >= b cells current target.mutation_level and o is - // closer than the b cells curr target (or if b cells curr - // target is null), updates b_cells curr target to be o - /* - var alert_b_cell = function(o) { - //var cell_objs = level("b_cell"); - //var cell_obj = null; - /*for (var i = 0; i < cell_objs.length; i++) { - cell_obj = cell_objs[i]; - if (cell_obj.get_type() === "b_cell") { - the_b_cell = cell_obj; - } - } - / - - var the_b_cell = get_b_cell(); - - if (the_b_cell && the_b_cell.is_alive()) { - var old_target = the_b_cell.get_target(); - - if (old_target) { - // if new macro has higher or equal level - if (//o.get_level() >= old_target.get_level() - // if new macro has current mutation level - o.get_level() === mutation.get_level() - // and it is closer - && old_target.get_pos().dist(the_b_cell.get_pos()) > - o.get_pos().dist(the_b_cell.get_pos())) { - the_b_cell.set_target(o); - } - } - else { - the_b_cell.set_target(o); - } - } - }; - */ - - // sets active_cell to the leftmost infected cell - // if there is one - var next_active_cell = function() { - var sort_fun = function(active_c) { // don't care about active - if (last_active_cell) { - // let's try the nearest cell to the one that died - return function(c1, c2) { - return dist_less_than(last_active_cell, c1, c2) ? -1 : 1; - }; - } - // otherwise leftmost - return function(c1, c2) { - return c1.get_pos().x - c2.get_pos().x; - }; - } - choose_cell(sort_fun); - }; - - // Set the next-left or next-right cell to be active, and - // if appropriate sets current active to be not active - - // Chooses the closest cell to a_pos - var choose_closest_cell = function(a_pos) { - if (active_cell) { // for the beginning - var old_active = active_cell; - var sort_fun = function(active_cell){ - return function(c1, c2){ - return c1.get_pos().dist(a_pos) - - c2.get_pos().dist(a_pos); - } - }; - choose_cell(sort_fun); - - // In case it doesn't change (choose_cell assumes - // that the cell is diff from the curr active) - if (old_active.get_pos().dist(a_pos) < - active_cell.get_pos().dist(a_pos)) { - active_cell.set_state("infected"); - active_cell = old_active; - active_cell.set_state("active"); - } - } - } - - // Chooses the closest cell to the active cell in the direction of comp, - // i.e. such that comp(c1.x, active.x) is true - var choose_cell_helper = function(comp) { - var sort_fun = function(active_c) { //don't rename to active_cell - return function(c1, c2) { - c1x = c1.get_pos().x; - c2x = c2.get_pos().x; - actx = active_c.get_pos().x; - // If one is in the right dir and the other isnt, - // return the one that is - if (comp(c1x, actx) && !(comp(c2x, actx))) { - return -1; - } - else if (!(comp(c1x, actx)) && comp(c2x, actx)) { - return 1; - } - // If they are on the same side, return opposite of comp - else { - if (comp(c1x, c2x)) { - return 1; - } - else { - return -1; - } - } - } - }; - choose_cell(sort_fun); - }; - - // Chooses the next left cell to be active - var choose_left_cell = function() { - choose_cell_helper(function (x, y) {return x < y;}); - }; - - // Same in the right dir - var choose_right_cell = function() { - choose_cell_helper(function (x, y) {return x > y;}); - }; - - // Sets a cell to be active based on sort_fun, and if this is diff - // from curr cell, sets curr cell to not be active - // sort_fun must take the currently active cell, and return a function - // that takes 2 cells, ad returns true if the first is 'better' than - // the second - var choose_cell = function(sort_fun) { - var cells = level("cell");//game_objects[type_to_level["cell"]]; - var infecteds = cells.filter( - function(cell) { - // don't want empty_cells - return cell.get_type() === "cell" - && cell.get_state() === "infected"; - }); - var sort_f = sort_fun(active_cell); - infecteds.sort(sort_f); - - var curr_active = active_cell; - if (infecteds.length > 0) { - - // tutorial msg about switching cells - if (infecteds.length > 1) { - tut_manager.popup("arrows"); - } - - active_cell = infecteds[0]; - //If same as current - if (curr_active) { // for the beginning - curr_active.set_state("infected"); //if same, about to change - } - active_cell.set_state("active"); - //console.log("got next "+active_cell.to_string()); - } - }; - - // Returns true if source is closer to target1 than target2 - // All 3 args are game_objs - var dist_less_than = function(source, target1, target2) { - var source_pos = source.get_pos(); - return source_pos.dist(target1.get_pos()) < - source_pos.dist(target2.get_pos()); - }; - - // Updates all tkillers targets - // Tkillers target the closest infected and targeted cell - var update_tkillers_targets = function(){ - var all_infected_cells = get_all_infected_cells(); - do_to_type(function(tkill){ - // remove bad targets - if (tkill.get_target() - // if it's dead - && (tkill.get_target().is_dead() - // or dying - || tkill.get_target().get_state() === "dying" - // or offscreen - || tkill.get_target().is_offscreen() - // or the target mutated - || !same_mutation_level(tkill, tkill.get_target()))) { - tkill.set_target(null); - } - // set a new target - for_each( - all_infected_cells, - function(infected_cell) { - if (infected_cell.has_antibody() - && same_mutation_level(infected_cell, tkill) - && (!tkill.get_target() || - dist_less_than(tkill, - infected_cell, tkill.get_target()))) { - tkill.set_target(infected_cell); - } - } - ); - }, "tkiller", true); - }; - - // adds new tkillers if need be - var add_tkillers = function() { - var tks = get_all_of_type("tkiller"); - do_to_type( - // for each b_cell - function(b) { - // if it needs a tkiller - if (b.is_shooting()) { - // check if one exists - var has_tkiller = false; - for_each(tks, function(tk) { - if (same_mutation_level(b, tk)) { - has_tkiller = true; - } - }); - // if one doesn't - if (!has_tkiller) { - console.log("made tkiller for lvl "+b.get_level()); - // make one - var tk = make_tkiller(); - tk.set_mutation_info(b.get_mutation_info()); - } - } - }, - "b_cell", true - ); - }; - - - // kills the active cell and updates the targets - // of all the tkillers - var kill_active_cell = function() { - active_cell.die(); - last_active_cell = active_cell; - active_cell = null; - update_tkillers_targets(); - }; - - //Checks whether any 2 objs are colliding, and if so calls handle_collision on them - var check_collisions = (function() { - // rendering levels to check collisions for: - var to_check = [ - //["particle", "particle"], - ["particle", "cell"], - ["particle", "enemy"], - ["particle", "multiplier"], - //["cell", "cell"], - ["cell", "enemy"], - //["enemy", "enemy"], - ["enemy", "b_cell"], - ["b_cell", "wall"], - ["particle", "wall"], - ["multiplier", "wall"], - ["enemy", "wall"] - ]; - - // hey this looks like combinations! - var do_comb = function(arr1, start1, end1, - arr2, start2, end2, fun) { - var i = start1, j = start2; - while (i <= end1) { - while (j <= end2) { - fun(arr1[i], arr2[j]); - j++; - } - i++; - // when arrays are the same - // don't do repeats - if (arr1 === arr2) { - j = i; - } - else { - j = 0; - } - } - }; - - var collision_fun = function() { - // double combinations! - // for each pair of rendering groups - // do_comb(game_objects, 1, 3, - // game_objects, 1, 3, - for_each(to_check, function(pair) { - var lvl1 = level(pair[0]); - var lvl2 = level(pair[1]); - // for each pair of objects in the groups - do_comb(lvl1, 0, lvl1.length-1, - lvl2, 0, lvl2.length-1, check); - }); - //); - }; - - - var check = function(obj1, obj2) { - //console.log("checking "+obj1.to_string() - // +", "+obj2.to_string()); - // check the collisions - // don't check collisions with self - if (obj1 !== obj2 - && check_collision(obj1, obj2)) { - handle_collision(obj1, obj2); - //console.log("collision! " +obj1.to_string() - // +", "+obj2.to_string()); - } - } - - return collision_fun; - }()); - - // Returns whether 2 objects are colliding - var check_collision = function(obj1, obj2) { - var type1 = obj1.get_type(); - var type2 = obj2.get_type(); - - if (!obj1.is_off_right() && - !obj2.is_off_right() && - check_circle_collision(obj1, obj2)) { - var check_again = retrieve(extra_check, type1, type2); - if (check_again !== undefined) { - return check_again(obj1, obj2); - } - else { - check_again = retrieve(extra_check, type2, type1); - if (check_again !== undefined) { - return check_again(obj2, obj1); - } - else { - return true; - } - } - } - else { - return false; - } - }; - - // Checks for a collision between circle (obj2) and rectangle (obj1) - var check_rectangle_collision = function(rect, circ) { - return overlapping_vertically(circ, rect, rect.get_y_offset()) && - overlapping_horizontally(circ, rect, rect.get_x_offset()); - }; - - // Rectangle and circle collision helper functions - // Returns whether the circle is overlapping the rectangle, horizontally, - // by offset num of pixels - var overlapping_horizontally = function(circ, rect, offset) { - var circlel = circ.get_left(), circler = circ.get_right(); - var rectl = rect.get_left(), rectr = rect.get_right(); - return ((circler <= rectr && circler >= (rectl + offset)) || - (circlel >= rectl && circlel <= (rectr - offset))); - }; - // Returns whether the circle is overlapping the rectangle, vertically, - // by offset num of pixels - var overlapping_vertically = function(circ, rect, offset) { - var circlet = circ.get_top(), circleb = circ.get_bottom(); - var rectt = rect.get_top(), rectb = rect.get_bottom(); - - return (circleb <= rectb && circleb >= (rectt + offset) || - (circlet >= rectt && circlet <= (rectb - offset))); - }; - - // holds extra collision checking functions for certain - // pairs of types - var extra_check = { - "wall_segment": { - "particle": check_rectangle_collision, - "b_cell": check_rectangle_collision, - "multiplier": //check_rectangle_collision - // had to do manually cuz offset was messed up - function(rect, circ) { - return overlapping_vertically(circ, rect, 0) && - overlapping_horizontally(circ, rect, 0); - } - }, - "floater": { - "b_cell": check_rectangle_collision - }, - "wall_cell": { - "particle": check_rectangle_collision - } - }; - - // checks for collisions between two objects by - // checking if their bounding circles are overlapping - // returns true if they are colliding - var check_circle_collision = function(obj1, obj2) { - // if the distance between their center points - // is <= the sum of their radii then they are colliding - // ONLY WORKS FOR CENTERED SHAPES - return (obj1.get_pos().dist(obj2.get_pos()) - <= obj1.get_radius() + obj2.get_radius()); - }; - // make it public - obj.check_circle_collision = check_circle_collision; - - /* - // Reverses 2 objs appropriate velocities - var bounce_collided = (function() { - // A list containing 2 element lists - // Inner lists represent object type pairs to not bounce off each other - var to_exclude = [ ["particle", "multiplier"], - ["particle", "particle"], - ["wall_segment", "b_cell"], - ["particle", "antibody"]]; - - var is_excluded = function(o1, o2) { - var is_excluded = false; - var type1 = o1.get_type(), type2 = o2.get_type(); - var objs_in_list = function(list) { - return ((list[0] === type1 && list[1] === type2) || - (list[0] === type2 && list[1] === type1)); - } - for_each(to_exclude, function(l) { - if (objs_in_list(l)) { - is_excluded = true; - } - }); - return is_excluded; - } - return function(obj1, obj2) { - if (!is_excluded(obj1, obj2)) { - bounce(obj1, obj2); - } - } - }()); - */ - - var bounce = function(obj1, obj2) { - //offset adjusts how closely we check, since we can't check exactly when they collide every time - var offset = 5; - var onel = obj1.get_left(), oner = obj1.get_right(); - var onet = obj1.get_top(), oneb = obj1.get_bottom(); - var twol = obj2.get_left() + offset, twor = obj2.get_right() - offset; - var twot = obj2.get_top() + offset, twob = obj2.get_bottom() - offset; - - //When bouncing, check velocity to make sure they are 'incoming' to each other - //This avoids them getting stuck (makes sure they didn't just collide) - //bounce vertically - var y_vel = obj1.get_vel().y; - var x_vel = obj1.get_vel().x; - if ((onet >= twob && y_vel <= 0) || (oneb <= twot && y_vel >= 0)) { - obj1.reverse_y(); - obj2.reverse_y(); - } - if ((oner <= twol && x_vel >= 0) - || (onel > twor && x_vel <= 0)) { //bounce horizontally - obj1.reverse_x(); - obj2.reverse_x(); - } - }; - - // handles collisions between different object types - var handle_collision = function(obj1, obj2) { - var ot1 = obj1.get_type(); - var ot2 = obj2.get_type(); - - // try first with one order - var handler = retrieve(collision_handlers, ot1, ot2); - if (handler) { - handler(obj1, obj2); - } - // if it didn't work - else { - // try the other order - handler = retrieve(collision_handlers, ot2, ot1); - if (handler) { - handler(obj2, obj1); - } - else { - //Not an error now? - //throw "Unsupported collision type!"; - } - - } - - // Bounce if appropriate - //bounce_collided(obj1, obj2); - }; - - // object to store all the handlers - // created once with a closure - // dont manage bouncing/changing direction here - var collision_handlers = (function() { - var nothing = function(obj1, obj2) {}; - - // infects the cell, kills the particle - var infect = function(par, cell) { - // only if cell is "alive" - // (ie only one particle per cell) - assert(cell, "Not a cell in infect!"); - if (cell.get_state() !== "dead" - && cell.get_state() !== "dying") { - par.die(); - } - if (cell.get_state() === "alive") { - tut_manager.popup("spacebar"); - //Play sound - sounds.play_sound("cell_infect"); - - // increase mutation percentage if level is highest on screen - // must be done before setting state of infected cell - // only happens if infected by particle of cur level - if (par.get_level() === mutation.get_level()) { - mutation.infected_cell(); - } - - cell.set_state("infected"); - cell.set_mutation_info(par.get_mutation_info()); - - // Add 10 to score - score.incr(10 * par.get_level() * mult.get_num()); - } - else { - // otherwise deflect - //bounce(par, cell); - } - }; - - - var handlers = { - "particle": { - // particle vs. particle - // do nothing? - "particle": nothing, - - // particle vs. cell - // infect the cell, kill the particle - "cell": infect, - - // particle vs. wall_cell - // bounce particle off cell - // cell doesn't move - "wall_cell": bounce, - - // particle vs. empty_cell - // // infect the cell, kill the particle - // kill the particle - "empty_cell": function(par, cell) { - // TODO diff sound? - sounds.play_sound("cell_infect"); - par.die(); - }, - - // particle vs. floater - // kill the particle - // floater takes on color of particle - "floater": function(par, flo) { - par.die(); - if (flo.is_alive()) { - // update flo if not activated || level < - // par.level - if (!flo.is_activated() || - flo.get_level() < - par.get_level()) { - flo.set_mutation_info(par.get_mutation_info()); - flo.activate(); - alert_b_cell(flo); - sounds.play_sound("macrophage_infect"); - tut_manager.popup("macrophage"); - } - notify("Macrophage activated!", BAD_NOTIFICATION_COLOR); - } - }, - - // particle vs. tkiller - // nothing? - "tkiller": nothing, - - // particle vs. multiplier - // get rid of the mult and incr mult - "multiplier": function(par, mul) { - //par.die(); - mul.die(); - mult.incr(1); - }, - - // particle vs wall - // Kill particle - "wall_segment": function(par, wall) { - par.die(); - } - }, - - // cell vs. cell - // cell vs. wall_cell - // cell vs. empty_cell - // wall_cell vs. wall_cell - // wall_cell vs. empty_cell - // empty_cell vs. empty_cell - // don't let them overlap (is bouncing necessary?) - "cell": { - "cell": nothing, - "wall_cell": nothing, - "empty_cell": nothing - }, - "wall_cell": { - "wall_cell": nothing, - "empty_cell": nothing - }, - "empty_cell": { - "empty_cell": nothing - }, - - // floater vs. cell - // floater vs. wall_cell - // floater vs. empty_cell - // floater vs. floater - // no overlap? - "floater": { - "cell": bounce, - "wall_cell": bounce, - "empty_cell": bounce, - "floater": bounce - }, - - "tkiller": { - // tkiller vs. cell - "cell": function(tk, cell) { - if ((cell.get_state() === "infected" || - cell.get_state() === "active") - && cell.has_antibody() - && same_mutation_level(tk, cell)) { - tut_manager.popup("killer"); - cell.die(); - sounds.play_sound("kill"); - tk.set_target(null); - if (active_cell === cell) { - //last_active_cell = active_cell; - //active_cell = null; - kill_active_cell(); - } - } - }, - - // tkiller vs. wall_cell - // tkiller vs. empty_cell - // tkiller vs. floater - // tkiller vs. tkiller - // nothing? TODO bounce? - "wall_cell": nothing, - "empty_cell": nothing, - "floater": nothing, - "tkiller": nothing - }, - - "antibody": { - "cell": function(a, c) { - if (same_mutation_level(a, c)) { - if (!c.has_antibody() && - (c.get_state() === "infected" || - c.get_state() === "active")) { - c.set_antibody(a); - } - } - } - }, - - "multiplier": { - // multiplier vs wall - // do nothing - "wall_segment": bounce - }, - - "b_cell": { - "floater": function(b, flo) { - if (b.is_alive() && flo.is_activated()) { - b.set_mutation_info(flo.get_mutation_info()); - b.activate(get_bcell_slot()); - bounce(b, flo); - notify("B cell activated!", BAD_NOTIFICATION_COLOR); - } - // trying to avoid getting stuck - if (b.is_outdated()) { - bounce(b, flo); - b.set_target(null); - } - }, - "wall_segment": function(b, wall) { - //console.log("collision"); - if (b.is_activated()) { - tut_manager.popup("antibodies"); - // start making antibodies - b.make_antibodies(); - // make a tkiller - var tk = make_tkiller(); - tk.set_mutation_info(b.get_mutation_info()); - - notify("Incoming antibodies!", BAD_NOTIFICATION_COLOR); - } - else if (b.is_alive()) { - bounce(b, wall); - } - else if (b.is_outdated()) { - } - } - } - }; - return handlers; - }()); - - //Removes all objs which are either off screen or dead - var remove_objs = function() { - var filter_fun = function(x) { - //Check offscreen, but don't remove newly generated - var offscreen = false; - if (x.is_offscreen()) { - //Only remove particles that are off the right - if (x.is_off_right()) { - if (x.get_type() === "particle") { - offscreen = true; - } - //else false - } - else { - //console.log("removing "+x.to_string()); - offscreen = true; - } - } - return (! (offscreen || x.is_dead())); - }; - for (var i = 0; i < game_objects.length; i++) { - game_objects[i] = game_objects[i].filter(filter_fun); - } - - // check offscreen for active cell - if (active_cell && active_cell.is_offscreen()) { - //active_cell = null; - kill_active_cell(); - } - }; - - // Returns whether the 2 objects have the same mutation level - var same_mutation_level = function(o1, o2) { - var o1level = o1.get_mutation_info().level; - var o2level = o2.get_mutation_info().level; - return (o1level === o2level); - }; - - - // adds a new background tile if the rightmost is onscreen - // ASSUMES ALL WALL TILES ARE SAME SIZE - var back_top = null; - var back_btm = null; - var add_back = (function() { - - var add_one = function(edge_tile) { - if (!goes_off_right(edge_tile)) { - //console.log("adding edge"); - - var new_spec = {}; - var x = edge_tile.get_pos().x - + edge_tile.get_width(); - - var y = status_bar_height; - new_spec.is_top = true; - // switch if it's a bottom edge - if (edge_tile === back_btm) { - // this will be changed in the edge object - y = p.height; - new_spec.is_top = false; - } - - new_spec.pos = new p.PVector(x, y); - - var new_tile = background_edge(p, new_spec); - obj.add_object(new_tile); - - if (edge_tile === back_top) { - back_top = new_tile; - } - else { - back_btm = new_tile; - } - //console.log("added tile "+new_tile.to_string()); - } - }; - - var add_both = function() { - add_one(back_top); - add_one(back_btm); - }; - - return add_both; - }()); - - // initialized the background - var init_back = function() { - // initial edges - back_top = background_edge(p, { - pos: new p.PVector(-100, status_bar_height), - is_top: true - }); - obj.add_object(back_top); - - back_btm = background_edge(p, { - pos: new p.PVector(-10, p.height), - is_top: false - }); - obj.add_object(back_btm); - - // add one more tile to fill screen - add_back(); - }; - - // tells if a background tile goes off the right of the screen - var goes_off_right = function(tile) { - return tile.get_pos().x + tile.get_width() > p.width; - }; - - // adds a new wall segment if the rightmost wall - // segment is onscreen - var rightmost_top = null; - var rightmost_btm = null; - var add_wall = (function() { - - // adds either a top or bottom wall - var add_one = function(rightmost) { - // if the rightmost has entered the screen - if (!rightmost.is_off_right()) { - var new_spec = {}; - - // note that new wall coords should be at - // bottom left corner of seg - // should be next to last seg - var x = rightmost.get_pos().x - + rightmost.get_width()/2 - 5; - - // set y for top wall - var y = 95; - new_spec.is_top = true; - // switch if it's a bottom wall - if (rightmost === rightmost_top) { - y = p.height+5; - new_spec.is_top = false; - } - - new_spec.pos = new p.PVector(x, y); - - // add the new segment - var new_seg = wall_segment(p, new_spec); - obj.add_object(new_seg); - - // update the corresponding rightmost - if (rightmost === rightmost_top) { - rightmost_top = new_seg; - } - else { - rightmost_btm = new_seg; - } - } - }; - - var add_both = function() { - add_one(rightmost_top); - add_one(rightmost_btm); - }; - - return add_both; - }()); - - var init_walls = function() { - // add first empty segments - // the values used here are important so don't change them - rightmost_top = wall_segment(p, { - pos: new p.PVector(-10, 0), - width: 5 - }); - - rightmost_btm = wall_segment(p, { - pos: new p.PVector(-10, p.height), - width: 5 - }); - - // while both walls don't span the screen - while(!(rightmost_top.is_off_right() - && rightmost_btm.is_off_right())) { - // add new walls - add_wall(); - } - }; - - //Does a function to every object - //Pass in a function that takes an object - var do_to_all_objs = function(f) { - for (var i=0; i= 0) ) { - do_to_all_objs(function(o) { o.get_pos().add( - new p.PVector(-dist/10, 0)); }); - //["particle", "cell", "enemy"], false); - } - } - }; - - - // --- public methods --- - - obj.get_type = function() { - return "game"; - }; - - //Calls update() on every obj - //after updating, calls remove_objs - obj.update = (function() { - var game_types = ["background", "wall", "particle", - "cell", "enemy", "multiplier", "antibody"]; - - var update_fun = function() { - // Can't be set when object is initialized - // Takes time every update though to check - if (!set_time) { - //Set interval to update time elapsed - var update_time = function() { - if (!paused) { - time_elapsed += 1; - time_status.set_num(time_elapsed); - } - } - setInterval(update_time, 1000); - set_time = true; - } - if (!paused) { - // if we don't have an active cell - if (active_cell === null) { - // try to find the next one - next_active_cell(); - } - // THIS MUST COME BEFORE GAME OVER CHECK - - // check for game over - // (if no particles are left and no active cell) - //console.log("num of particles: " + level("particle").length); - if (active_cell === null && - level("particle").length === 0) { - var go_state = game_over_state(p, previous_state, { - score : score.get_num(), - mutation_level : mutation.get_level() - }, game_type); - sounds.pause_background_music(); - obj.set_next_state(go_state); - - // stop the animations - do_to_all_objs( - function(o) { - if (o.stop_animation) { - o.stop_animation(); - } - } - ); - - // stop notifications - all_notifications = []; - - // stop the time and stuff - paused = true; - - // Add to the high score table - // If fb user name and id are set - if (g_user_name && g_user_id) { - scores.submit_score(score.get_num(), - mutation.get_level(), g_user_name, g_user_id); - // Update the high score table - // (not necessary now) - //scores.do_scores(); - } - - // simply don't do the rest of update - return; - } - - //Add any newly generated objs - generator.update(); - - // Make antibodies seek any infected cells they are near - make_antibodies_seek(); - - // Add antibodies generated from b cells - do_to_type( - function(b) { - obj.add_objects(b.get_antibodies()); - }, - "b_cell", true - ); - - // adds a new segment of wall if necessary - add_wall(); - // adds a new background tile if necessary - add_back(); - - add_tkillers(); - update_tkillers_targets(); - - // set outdated t/b cells - set_all_outdated(); - - // scroll all objects - - do_to_all_objs(function(o){ - o.scroll(scroll_factor); - }); - - //dynamic_scroll(); - - // update distance travelled - distance += scroll_factor; - - // update all objects - do_to_all_objs(function(o){ - o.update(); - }); - - check_collisions(); - - remove_objs(); - - update_mutation(); - - /* - // for debugging - var count = 0; - do_to_all_objs(function() { count += 1; }); - console.log(count); - console.log("fr "+p.__frameRate); - */ - } - }; - - var update_mutation = function() { - // check for a new mutation - // if mutation occurred - if (mutation.has_new_mutation() && active_cell) { - // pick infected cell closest to active cell with the current - // mutation level - var choices = get_all_of_type("cell").filter( - function(c) { - return ((c.get_state() === "infected" - || c.get_state() === "active") - && c.get_level() === mutation.get_level()); - } - ); - choices.sort( - function(c1, c2) { - return dist_less_than(active_cell, c1, c2) ? -1 : 1; - } - ); - var cell_to_mutate = choices[0]; - - // do the actual mutation and hold onto new ability - //var new_ability = - mutation.do_mutation(); - // mutate the active cell - cell_to_mutate.set_mutation_info(mutation.get_info()); - // update the scroll factor - scroll_factor += 0.15; - - //if (new_ability) { - // notify("New Ability: " + new_ability); - //} - //else { - notify("Mutation occurred!", GOOD_NOTIFICATION_COLOR); - //} - - - tut_manager.popup("mutation"); - - console.log("mutation occurred!"); - } - // otherwise check for downgrades - else { - // check for the highest mutation level on screen - var max_level = 0; - var find_max = function(o) { - if (o.get_level() > max_level) { - max_level = o.get_level(); - } - }; - do_to_type(find_max, "cell", false); - do_to_type(find_max, "particle", false); - - // if max level lower than mutation level - if (max_level > 0 && max_level < mutation.get_level()) { - // downgrade to that level - mutation.set_level(max_level); - // reset the counters - mutation.reset_mutation(); - - notify("Lost new strain!", BAD_NOTIFICATION_COLOR); - tut_manager.popup("strain"); - console.log("downgraded to mutation level "+max_level); - - scroll_factor -= 0.15; - - // TODO do enemies become not outdated? - } - } - }; - - return update_fun; - }()); - - //Calls draw() on every obj - obj.render = function(){ - - // put the active cell at the end of the list - // so it is drawn on top - if (active_cell) { - var cells = level("cell"); - remove_elt(cells, active_cell); - cells.push(active_cell); - } - - p.background(g.background_color); - - for (var i=0; i -Virion - - - - - - -
            - - - - - - - diff --git a/index1.html b/index1.html deleted file mode 100644 index 5e756e6..0000000 --- a/index1.html +++ /dev/null @@ -1,301 +0,0 @@ - - - -Virion - - - - - - - - - - -
            - - - - - - - -
            - - -
            - -
            -
            - Could not load high scores! You may want to check your internet connection. -
            -
            - - - Your browser does not support the HTML5 canvas element. Upgrade to Chrome, Firefox 4, Safari, or Opera to play this game. - - -
            - -
            -
            - Note: Virion was built entirely using the new open HTML5 standard and the Processing.js JavaScript library. This means that you will never have to install a proprietary plugin to play our game, and in the near future will be able to play our game on any browser on any platform. Currently, however, some browsers do not yet have full support for the HTML5 standard, so please note the following browser compatibility issues:

            - Google Chrome has no problems, and is highly recommended for the best overall performance
            - If you are using Firefox 3 and the game is not loading or running slowly, try updating to Firefox 4
            - If you are using Safari and seeing performance issues, try turning off the sound effects
            - If you are using Internet Explorer, please ensure that you have updated to the latest version (Internet Explorer 9), or the game will not run. -

            -
            -
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/indexTest.html b/indexTest.html deleted file mode 100644 index 15c3b4d..0000000 --- a/indexTest.html +++ /dev/null @@ -1,105 +0,0 @@ - -Virion - - - - - - - -
            - - - - - - diff --git a/jplayer/Jplayer.swf b/jplayer/Jplayer.swf deleted file mode 100755 index 9487f49..0000000 Binary files a/jplayer/Jplayer.swf and /dev/null differ diff --git a/jplayer/jquery.jplayer.min.js b/jplayer/jquery.jplayer.min.js deleted file mode 100755 index b9b7007..0000000 --- a/jplayer/jquery.jplayer.min.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - * jPlayer Plugin for jQuery JavaScript Library - * http://www.happyworm.com/jquery/jplayer - * - * Copyright (c) 2009 - 2010 Happyworm Ltd - * Dual licensed under the MIT and GPL licenses. - * - http://www.opensource.org/licenses/mit-license.php - * - http://www.gnu.org/copyleft/gpl.html - * - * Author: Mark J Panaghiston - * Version: 2.0.0 - * Date: 20th December 2010 - */ - -(function(c,h){c.fn.jPlayer=function(a){var b=typeof a==="string",d=Array.prototype.slice.call(arguments,1),f=this;a=!b&&d.length?c.extend.apply(null,[true,a].concat(d)):a;if(b&&a.charAt(0)==="_")return f;b?this.each(function(){var e=c.data(this,"jPlayer"),g=e&&c.isFunction(e[a])?e[a].apply(e,d):e;if(g!==e&&g!==h){f=g;return false}}):this.each(function(){var e=c.data(this,"jPlayer");if(e){e.option(a||{})._init();e.option(a||{})}else c.data(this,"jPlayer",new c.jPlayer(a,this))});return f};c.jPlayer= -function(a,b){if(arguments.length){this.element=c(b);this.options=c.extend(true,{},this.options,a);var d=this;this.element.bind("remove.jPlayer",function(){d.destroy()});this._init()}};c.jPlayer.event={ready:"jPlayer_ready",resize:"jPlayer_resize",error:"jPlayer_error",warning:"jPlayer_warning",loadstart:"jPlayer_loadstart",progress:"jPlayer_progress",suspend:"jPlayer_suspend",abort:"jPlayer_abort",emptied:"jPlayer_emptied",stalled:"jPlayer_stalled",play:"jPlayer_play",pause:"jPlayer_pause",loadedmetadata:"jPlayer_loadedmetadata", -loadeddata:"jPlayer_loadeddata",waiting:"jPlayer_waiting",playing:"jPlayer_playing",canplay:"jPlayer_canplay",canplaythrough:"jPlayer_canplaythrough",seeking:"jPlayer_seeking",seeked:"jPlayer_seeked",timeupdate:"jPlayer_timeupdate",ended:"jPlayer_ended",ratechange:"jPlayer_ratechange",durationchange:"jPlayer_durationchange",volumechange:"jPlayer_volumechange"};c.jPlayer.htmlEvent=["loadstart","abort","emptied","stalled","loadedmetadata","loadeddata","canplaythrough","ratechange"];c.jPlayer.pause= -function(){c.each(c.jPlayer.prototype.instances,function(a,b){b.data("jPlayer").status.srcSet&&b.jPlayer("pause")})};c.jPlayer.timeFormat={showHour:false,showMin:true,showSec:true,padHour:false,padMin:true,padSec:true,sepHour:":",sepMin:":",sepSec:""};c.jPlayer.convertTime=function(a){a=new Date(a*1E3);var b=a.getUTCHours(),d=a.getUTCMinutes();a=a.getUTCSeconds();b=c.jPlayer.timeFormat.padHour&&b<10?"0"+b:b;d=c.jPlayer.timeFormat.padMin&&d<10?"0"+d:d;a=c.jPlayer.timeFormat.padSec&&a<10?"0"+a:a;return(c.jPlayer.timeFormat.showHour? -b+c.jPlayer.timeFormat.sepHour:"")+(c.jPlayer.timeFormat.showMin?d+c.jPlayer.timeFormat.sepMin:"")+(c.jPlayer.timeFormat.showSec?a+c.jPlayer.timeFormat.sepSec:"")};c.jPlayer.uaMatch=function(a){a=a.toLowerCase();var b=/(opera)(?:.*version)?[ \/]([\w.]+)/,d=/(msie) ([\w.]+)/,f=/(mozilla)(?:.*? rv:([\w.]+))?/;a=/(webkit)[ \/]([\w.]+)/.exec(a)||b.exec(a)||d.exec(a)||a.indexOf("compatible")<0&&f.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}};c.jPlayer.browser={};var m=c.jPlayer.uaMatch(navigator.userAgent); -if(m.browser){c.jPlayer.browser[m.browser]=true;c.jPlayer.browser.version=m.version}c.jPlayer.prototype={count:0,version:{script:"2.0.0",needFlash:"2.0.0",flash:"unknown"},options:{swfPath:"./",solution:"html, flash",supplied:"mp3",preload:"metadata",volume:0.8,muted:false,backgroundColor:"#000000",cssSelectorAncestor:"#jp_interface_1",cssSelector:{videoPlay:".jp-video-play",play:".jp-play",pause:".jp-pause",stop:".jp-stop",seekBar:".jp-seek-bar",playBar:".jp-play-bar",mute:".jp-mute",unmute:".jp-unmute", -volumeBar:".jp-volume-bar",volumeBarValue:".jp-volume-bar-value",currentTime:".jp-current-time",duration:".jp-duration"},idPrefix:"jp",errorAlerts:false,warningAlerts:false},instances:{},status:{src:"",media:{},paused:true,format:{},formatType:"",waitForPlay:true,waitForLoad:true,srcSet:false,video:false,seekPercent:0,currentPercentRelative:0,currentPercentAbsolute:0,currentTime:0,duration:0},_status:{volume:h,muted:false,width:0,height:0},internal:{ready:false,instance:h,htmlDlyCmdId:h},solution:{html:true, -flash:true},format:{mp3:{codec:'audio/mpeg; codecs="mp3"',flashCanPlay:true,media:"audio"},m4a:{codec:'audio/mp4; codecs="mp4a.40.2"',flashCanPlay:true,media:"audio"},oga:{codec:'audio/ogg; codecs="vorbis"',flashCanPlay:false,media:"audio"},wav:{codec:'audio/wav; codecs="1"',flashCanPlay:false,media:"audio"},webma:{codec:'audio/webm; codecs="vorbis"',flashCanPlay:false,media:"audio"},m4v:{codec:'video/mp4; codecs="avc1.42E01E, mp4a.40.2"',flashCanPlay:true,media:"video"},ogv:{codec:'video/ogg; codecs="theora, vorbis"', -flashCanPlay:false,media:"video"},webmv:{codec:'video/webm; codecs="vorbis, vp8"',flashCanPlay:false,media:"video"}},_init:function(){var a=this;this.element.empty();this.status=c.extend({},this.status,this._status);this.internal=c.extend({},this.internal);this.formats=[];this.solutions=[];this.require={};this.htmlElement={};this.html={};this.html.audio={};this.html.video={};this.flash={};this.css={};this.css.cs={};this.css.jq={};this.status.volume=this._limitValue(this.options.volume,0,1);this.status.muted= -this.options.muted;this.status.width=this.element.css("width");this.status.height=this.element.css("height");this.element.css({"background-color":this.options.backgroundColor});c.each(this.options.supplied.toLowerCase().split(","),function(e,g){var i=g.replace(/^\s+|\s+$/g,"");if(a.format[i]){var j=false;c.each(a.formats,function(n,k){if(i===k){j=true;return false}});j||a.formats.push(i)}});c.each(this.options.solution.toLowerCase().split(","),function(e,g){var i=g.replace(/^\s+|\s+$/g,"");if(a.solution[i]){var j= -false;c.each(a.solutions,function(n,k){if(i===k){j=true;return false}});j||a.solutions.push(i)}});this.internal.instance="jp_"+this.count;this.instances[this.internal.instance]=this.element;this.element.attr("id")===""&&this.element.attr("id",this.options.idPrefix+"_jplayer_"+this.count);this.internal.self=c.extend({},{id:this.element.attr("id"),jq:this.element});this.internal.audio=c.extend({},{id:this.options.idPrefix+"_audio_"+this.count,jq:h});this.internal.video=c.extend({},{id:this.options.idPrefix+ -"_video_"+this.count,jq:h});this.internal.flash=c.extend({},{id:this.options.idPrefix+"_flash_"+this.count,jq:h,swf:this.options.swfPath+(this.options.swfPath!==""&&this.options.swfPath.slice(-1)!=="/"?"/":"")+"Jplayer.swf"});this.internal.poster=c.extend({},{id:this.options.idPrefix+"_poster_"+this.count,jq:h});c.each(c.jPlayer.event,function(e,g){if(a.options[e]!==h){a.element.bind(g+".jPlayer",a.options[e]);a.options[e]=h}});this.htmlElement.poster=document.createElement("img");this.htmlElement.poster.id= -this.internal.poster.id;this.htmlElement.poster.onload=function(){if(!a.status.video||a.status.waitForPlay)a.internal.poster.jq.show()};this.element.append(this.htmlElement.poster);this.internal.poster.jq=c("#"+this.internal.poster.id);this.internal.poster.jq.css({width:this.status.width,height:this.status.height});this.internal.poster.jq.hide();this.require.audio=false;this.require.video=false;c.each(this.formats,function(e,g){a.require[a.format[g].media]=true});this.html.audio.available=false;if(this.require.audio){this.htmlElement.audio= -document.createElement("audio");this.htmlElement.audio.id=this.internal.audio.id;this.html.audio.available=!!this.htmlElement.audio.canPlayType}this.html.video.available=false;if(this.require.video){this.htmlElement.video=document.createElement("video");this.htmlElement.video.id=this.internal.video.id;this.html.video.available=!!this.htmlElement.video.canPlayType}this.flash.available=this._checkForFlash(10);this.html.canPlay={};this.flash.canPlay={};c.each(this.formats,function(e,g){a.html.canPlay[g]= -a.html[a.format[g].media].available&&""!==a.htmlElement[a.format[g].media].canPlayType(a.format[g].codec);a.flash.canPlay[g]=a.format[g].flashCanPlay&&a.flash.available});this.html.desired=false;this.flash.desired=false;c.each(this.solutions,function(e,g){if(e===0)a[g].desired=true;else{var i=false,j=false;c.each(a.formats,function(n,k){if(a[a.solutions[0]].canPlay[k])if(a.format[k].media==="video")j=true;else i=true});a[g].desired=a.require.audio&&!i||a.require.video&&!j}});this.html.support={}; -this.flash.support={};c.each(this.formats,function(e,g){a.html.support[g]=a.html.canPlay[g]&&a.html.desired;a.flash.support[g]=a.flash.canPlay[g]&&a.flash.desired});this.html.used=false;this.flash.used=false;c.each(this.solutions,function(e,g){c.each(a.formats,function(i,j){if(a[g].support[j]){a[g].used=true;return false}})});this.html.used||this.flash.used||this._error({type:c.jPlayer.error.NO_SOLUTION,context:"{solution:'"+this.options.solution+"', supplied:'"+this.options.supplied+"'}",message:c.jPlayer.errorMsg.NO_SOLUTION, -hint:c.jPlayer.errorHint.NO_SOLUTION});this.html.active=false;this.html.audio.gate=false;this.html.video.gate=false;this.flash.active=false;this.flash.gate=false;if(this.flash.used){var b="id="+escape(this.internal.self.id)+"&vol="+this.status.volume+"&muted="+this.status.muted;if(c.browser.msie&&Number(c.browser.version)<=8){var d='';f[1]='';f[2]='';f[3]='';f[4]='';b=document.createElement(d);for(d=0;d0?100*d/this.status.duration:0;if(typeof a.seekable==="object"&&a.seekable.length>0){e=this.status.duration>0?100*a.seekable.end(a.seekable.length-1)/this.status.duration:100;g=100*a.currentTime/a.seekable.end(a.seekable.length-1)}else{e=100;g=f}if(b)f=g=d=0;this.status.seekPercent=e;this.status.currentPercentRelative=g;this.status.currentPercentAbsolute=f;this.status.currentTime=d},_resetStatus:function(){this.status=c.extend({},this.status,c.jPlayer.prototype.status)}, -_trigger:function(a,b,d){a=c.Event(a);a.jPlayer={};a.jPlayer.version=c.extend({},this.version);a.jPlayer.status=c.extend(true,{},this.status);a.jPlayer.html=c.extend(true,{},this.html);a.jPlayer.flash=c.extend(true,{},this.flash);if(b)a.jPlayer.error=c.extend({},b);if(d)a.jPlayer.warning=c.extend({},d);this.element.trigger(a)},jPlayerFlashEvent:function(a,b){if(a===c.jPlayer.event.ready&&!this.internal.ready){this.internal.ready=true;this.version.flash=b.version;this.version.needFlash!==this.version.flash&& -this._error({type:c.jPlayer.error.VERSION,context:this.version.flash,message:c.jPlayer.errorMsg.VERSION+this.version.flash,hint:c.jPlayer.errorHint.VERSION});this._trigger(a)}if(this.flash.gate)switch(a){case c.jPlayer.event.progress:this._getFlashStatus(b);this._updateInterface();this._trigger(a);break;case c.jPlayer.event.timeupdate:this._getFlashStatus(b);this._updateInterface();this._trigger(a);break;case c.jPlayer.event.play:this._seeked();this._updateButtons(true);this._trigger(a);break;case c.jPlayer.event.pause:this._updateButtons(false); -this._trigger(a);break;case c.jPlayer.event.ended:this._updateButtons(false);this._trigger(a);break;case c.jPlayer.event.error:this.status.waitForLoad=true;this.status.waitForPlay=true;this.status.video&&this.internal.flash.jq.css({width:"0px",height:"0px"});this._validString(this.status.media.poster)&&this.internal.poster.jq.show();this.css.jq.videoPlay.length&&this.css.jq.videoPlay.show();this.status.video?this._flash_setVideo(this.status.media):this._flash_setAudio(this.status.media);this._error({type:c.jPlayer.error.URL, -context:b.src,message:c.jPlayer.errorMsg.URL,hint:c.jPlayer.errorHint.URL});break;case c.jPlayer.event.seeking:this._seeking();this._trigger(a);break;case c.jPlayer.event.seeked:this._seeked();this._trigger(a);break;default:this._trigger(a)}return false},_getFlashStatus:function(a){this.status.seekPercent=a.seekPercent;this.status.currentPercentRelative=a.currentPercentRelative;this.status.currentPercentAbsolute=a.currentPercentAbsolute;this.status.currentTime=a.currentTime;this.status.duration=a.duration}, -_updateButtons:function(a){this.status.paused=!a;if(this.css.jq.play.length&&this.css.jq.pause.length)if(a){this.css.jq.play.hide();this.css.jq.pause.show()}else{this.css.jq.play.show();this.css.jq.pause.hide()}},_updateInterface:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.width(this.status.seekPercent+"%");this.css.jq.playBar.length&&this.css.jq.playBar.width(this.status.currentPercentRelative+"%");this.css.jq.currentTime.length&&this.css.jq.currentTime.text(c.jPlayer.convertTime(this.status.currentTime)); -this.css.jq.duration.length&&this.css.jq.duration.text(c.jPlayer.convertTime(this.status.duration))},_seeking:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.addClass("jp-seeking-bg")},_seeked:function(){this.css.jq.seekBar.length&&this.css.jq.seekBar.removeClass("jp-seeking-bg")},setMedia:function(a){var b=this;this._seeked();clearTimeout(this.internal.htmlDlyCmdId);var d=this.html.audio.gate,f=this.html.video.gate,e=false;c.each(this.formats,function(g,i){var j=b.format[i].media==="video"; -c.each(b.solutions,function(n,k){if(b[k].support[i]&&b._validString(a[i])){var l=k==="html";if(j)if(l){b.html.audio.gate=false;b.html.video.gate=true;b.flash.gate=false}else{b.html.audio.gate=false;b.html.video.gate=false;b.flash.gate=true}else if(l){b.html.audio.gate=true;b.html.video.gate=false;b.flash.gate=false}else{b.html.audio.gate=false;b.html.video.gate=false;b.flash.gate=true}if(b.flash.active||b.html.active&&b.flash.gate||d===b.html.audio.gate&&f===b.html.video.gate)b.clearMedia();else if(d!== -b.html.audio.gate&&f!==b.html.video.gate){b._html_pause();b.status.video&&b.internal.video.jq.css({width:"0px",height:"0px"});b._resetStatus()}if(j){if(l){b._html_setVideo(a);b.html.active=true;b.flash.active=false}else{b._flash_setVideo(a);b.html.active=false;b.flash.active=true}b.css.jq.videoPlay.length&&b.css.jq.videoPlay.show();b.status.video=true}else{if(l){b._html_setAudio(a);b.html.active=true;b.flash.active=false}else{b._flash_setAudio(a);b.html.active=false;b.flash.active=true}b.css.jq.videoPlay.length&& -b.css.jq.videoPlay.hide();b.status.video=false}e=true;return false}});if(e)return false});if(e){if(this._validString(a.poster))if(this.htmlElement.poster.src!==a.poster)this.htmlElement.poster.src=a.poster;else this.internal.poster.jq.show();else this.internal.poster.jq.hide();this.status.srcSet=true;this.status.media=c.extend({},a);this._updateButtons(false);this._updateInterface()}else{this.status.srcSet&&!this.status.waitForPlay&&this.pause();this.html.audio.gate=false;this.html.video.gate=false; -this.flash.gate=false;this.html.active=false;this.flash.active=false;this._resetStatus();this._updateInterface();this._updateButtons(false);this.internal.poster.jq.hide();this.html.used&&this.require.video&&this.internal.video.jq.css({width:"0px",height:"0px"});this.flash.used&&this.internal.flash.jq.css({width:"0px",height:"0px"});this._error({type:c.jPlayer.error.NO_SUPPORT,context:"{supplied:'"+this.options.supplied+"'}",message:c.jPlayer.errorMsg.NO_SUPPORT,hint:c.jPlayer.errorHint.NO_SUPPORT})}}, -clearMedia:function(){this._resetStatus();this._updateButtons(false);this.internal.poster.jq.hide();clearTimeout(this.internal.htmlDlyCmdId);if(this.html.active)this._html_clearMedia();else this.flash.active&&this._flash_clearMedia()},load:function(){if(this.status.srcSet)if(this.html.active)this._html_load();else this.flash.active&&this._flash_load();else this._urlNotSetError("load")},play:function(a){a=typeof a==="number"?a:NaN;if(this.status.srcSet)if(this.html.active)this._html_play(a);else this.flash.active&& -this._flash_play(a);else this._urlNotSetError("play")},videoPlay:function(){this.play()},pause:function(a){a=typeof a==="number"?a:NaN;if(this.status.srcSet)if(this.html.active)this._html_pause(a);else this.flash.active&&this._flash_pause(a);else this._urlNotSetError("pause")},pauseOthers:function(){var a=this;c.each(this.instances,function(b,d){a.element!==d&&d.data("jPlayer").status.srcSet&&d.jPlayer("pause")})},stop:function(){if(this.status.srcSet)if(this.html.active)this._html_pause(0);else this.flash.active&& -this._flash_pause(0);else this._urlNotSetError("stop")},playHead:function(a){a=this._limitValue(a,0,100);if(this.status.srcSet)if(this.html.active)this._html_playHead(a);else this.flash.active&&this._flash_playHead(a);else this._urlNotSetError("playHead")},mute:function(){this.status.muted=true;this.html.used&&this._html_mute(true);this.flash.used&&this._flash_mute(true);this._updateMute(true);this._updateVolume(0);this._trigger(c.jPlayer.event.volumechange)},unmute:function(){this.status.muted=false; -this.html.used&&this._html_mute(false);this.flash.used&&this._flash_mute(false);this._updateMute(false);this._updateVolume(this.status.volume);this._trigger(c.jPlayer.event.volumechange)},_updateMute:function(a){if(this.css.jq.mute.length&&this.css.jq.unmute.length)if(a){this.css.jq.mute.hide();this.css.jq.unmute.show()}else{this.css.jq.mute.show();this.css.jq.unmute.hide()}},volume:function(a){a=this._limitValue(a,0,1);this.status.volume=a;this.html.used&&this._html_volume(a);this.flash.used&&this._flash_volume(a); -this.status.muted||this._updateVolume(a);this._trigger(c.jPlayer.event.volumechange)},volumeBar:function(a){if(!this.status.muted&&this.css.jq.volumeBar){var b=this.css.jq.volumeBar.offset();a=a.pageX-b.left;b=this.css.jq.volumeBar.width();this.volume(a/b)}},volumeBarValue:function(a){this.volumeBar(a)},_updateVolume:function(a){this.css.jq.volumeBarValue.length&&this.css.jq.volumeBarValue.width(a*100+"%")},_volumeFix:function(a){var b=0.0010*Math.random();return a+(a<0.5?b:-b)},_cssSelectorAncestor:function(a, -b){this.options.cssSelectorAncestor=a;b&&c.each(this.options.cssSelector,function(d,f){self._cssSelector(d,f)})},_cssSelector:function(a,b){var d=this;if(typeof b==="string")if(c.jPlayer.prototype.options.cssSelector[a]){this.css.jq[a]&&this.css.jq[a].length&&this.css.jq[a].unbind(".jPlayer");this.options.cssSelector[a]=b;this.css.cs[a]=this.options.cssSelectorAncestor+" "+b;this.css.jq[a]=b?c(this.css.cs[a]):[];this.css.jq[a].length&&this.css.jq[a].bind("click.jPlayer",function(f){d[a](f);c(this).blur(); -return false});b&&this.css.jq[a].length!==1&&this._warning({type:c.jPlayer.warning.CSS_SELECTOR_COUNT,context:this.css.cs[a],message:c.jPlayer.warningMsg.CSS_SELECTOR_COUNT+this.css.jq[a].length+" found for "+a+" method.",hint:c.jPlayer.warningHint.CSS_SELECTOR_COUNT})}else this._warning({type:c.jPlayer.warning.CSS_SELECTOR_METHOD,context:a,message:c.jPlayer.warningMsg.CSS_SELECTOR_METHOD,hint:c.jPlayer.warningHint.CSS_SELECTOR_METHOD});else this._warning({type:c.jPlayer.warning.CSS_SELECTOR_STRING, -context:b,message:c.jPlayer.warningMsg.CSS_SELECTOR_STRING,hint:c.jPlayer.warningHint.CSS_SELECTOR_STRING})},seekBar:function(a){if(this.css.jq.seekBar){var b=this.css.jq.seekBar.offset();a=a.pageX-b.left;b=this.css.jq.seekBar.width();this.playHead(100*a/b)}},playBar:function(a){this.seekBar(a)},currentTime:function(){},duration:function(){},option:function(a,b){var d=a;if(arguments.length===0)return c.extend(true,{},this.options);if(typeof a==="string"){var f=a.split(".");if(b===h){for(var e=c.extend(true, -{},this.options),g=0;g=9||this.htmlElement.media.load()}},_html_load:function(){if(this.status.waitForLoad){this.status.waitForLoad=false;this.htmlElement.media.src=this.status.src; -try{this.htmlElement.media.load()}catch(a){}}clearTimeout(this.internal.htmlDlyCmdId)},_html_play:function(a){var b=this;this._html_load();this.htmlElement.media.play();if(!isNaN(a))try{this.htmlElement.media.currentTime=a}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.play(a)},100);return}this._html_checkWaitForPlay()},_html_pause:function(a){var b=this;a>0?this._html_load():clearTimeout(this.internal.htmlDlyCmdId);this.htmlElement.media.pause();if(!isNaN(a))try{this.htmlElement.media.currentTime= -a}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.pause(a)},100);return}a>0&&this._html_checkWaitForPlay()},_html_playHead:function(a){var b=this;this._html_load();try{if(typeof this.htmlElement.media.seekable==="object"&&this.htmlElement.media.seekable.length>0)this.htmlElement.media.currentTime=a*this.htmlElement.media.seekable.end(this.htmlElement.media.seekable.length-1)/100;else if(this.htmlElement.media.duration>0&&!isNaN(this.htmlElement.media.duration))this.htmlElement.media.currentTime= -a*this.htmlElement.media.duration/100;else throw"e";}catch(d){this.internal.htmlDlyCmdId=setTimeout(function(){b.playHead(a)},100);return}this.status.waitForLoad||this._html_checkWaitForPlay()},_html_checkWaitForPlay:function(){if(this.status.waitForPlay){this.status.waitForPlay=false;this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide();if(this.status.video){this.internal.poster.jq.hide();this.internal.video.jq.css({width:this.status.width,height:this.status.height})}}},_html_volume:function(a){if(this.html.audio.available)this.htmlElement.audio.volume= -a;if(this.html.video.available)this.htmlElement.video.volume=a},_html_mute:function(a){if(this.html.audio.available)this.htmlElement.audio.muted=a;if(this.html.video.available)this.htmlElement.video.muted=a},_flash_setAudio:function(a){var b=this;try{c.each(this.formats,function(f,e){if(b.flash.support[e]&&a[e]){switch(e){case "m4a":b._getMovie().fl_setAudio_m4a(a[e]);break;case "mp3":b._getMovie().fl_setAudio_mp3(a[e])}b.status.src=a[e];b.status.format[e]=true;b.status.formatType=e;return false}}); -if(this.options.preload==="auto"){this._flash_load();this.status.waitForLoad=false}}catch(d){this._flashError(d)}},_flash_setVideo:function(a){var b=this;try{c.each(this.formats,function(f,e){if(b.flash.support[e]&&a[e]){switch(e){case "m4v":b._getMovie().fl_setVideo_m4v(a[e])}b.status.src=a[e];b.status.format[e]=true;b.status.formatType=e;return false}});if(this.options.preload==="auto"){this._flash_load();this.status.waitForLoad=false}}catch(d){this._flashError(d)}},_flash_clearMedia:function(){this.internal.flash.jq.css({width:"0px", -height:"0px"});try{this._getMovie().fl_clearMedia()}catch(a){this._flashError(a)}},_flash_load:function(){try{this._getMovie().fl_load()}catch(a){this._flashError(a)}this.status.waitForLoad=false},_flash_play:function(a){try{this._getMovie().fl_play(a)}catch(b){this._flashError(b)}this.status.waitForLoad=false;this._flash_checkWaitForPlay()},_flash_pause:function(a){try{this._getMovie().fl_pause(a)}catch(b){this._flashError(b)}if(a>0){this.status.waitForLoad=false;this._flash_checkWaitForPlay()}}, -_flash_playHead:function(a){try{this._getMovie().fl_play_head(a)}catch(b){this._flashError(b)}this.status.waitForLoad||this._flash_checkWaitForPlay()},_flash_checkWaitForPlay:function(){if(this.status.waitForPlay){this.status.waitForPlay=false;this.css.jq.videoPlay.length&&this.css.jq.videoPlay.hide();if(this.status.video){this.internal.poster.jq.hide();this.internal.flash.jq.css({width:this.status.width,height:this.status.height})}}},_flash_volume:function(a){try{this._getMovie().fl_volume(a)}catch(b){this._flashError(b)}}, -_flash_mute:function(a){try{this._getMovie().fl_mute(a)}catch(b){this._flashError(b)}},_getMovie:function(){return document[this.internal.flash.id]},_checkForFlash:function(a){var b=false,d;if(window.ActiveXObject)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+a);b=true}catch(f){}else if(navigator.plugins&&navigator.mimeTypes.length>0)if(d=navigator.plugins["Shockwave Flash"])if(navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/,"$1")>=a)b=true;return c.browser.msie&& -Number(c.browser.version)>=9?false:b},_validString:function(a){return a&&typeof a==="string"},_limitValue:function(a,b,d){return ad?d:a},_urlNotSetError:function(a){this._error({type:c.jPlayer.error.URL_NOT_SET,context:a,message:c.jPlayer.errorMsg.URL_NOT_SET,hint:c.jPlayer.errorHint.URL_NOT_SET})},_flashError:function(a){this._error({type:c.jPlayer.error.FLASH,context:this.internal.flash.swf,message:c.jPlayer.errorMsg.FLASH+a.message,hint:c.jPlayer.errorHint.FLASH})},_error:function(a){this._trigger(c.jPlayer.event.error, -a);if(this.options.errorAlerts)this._alert("Error!"+(a.message?"\n\n"+a.message:"")+(a.hint?"\n\n"+a.hint:"")+"\n\nContext: "+a.context)},_warning:function(a){this._trigger(c.jPlayer.event.warning,h,a);if(this.options.errorAlerts)this._alert("Warning!"+(a.message?"\n\n"+a.message:"")+(a.hint?"\n\n"+a.hint:"")+"\n\nContext: "+a.context)},_alert:function(a){alert("jPlayer "+this.version.script+" : id='"+this.internal.self.id+"' : "+a)}};c.jPlayer.error={FLASH:"e_flash",NO_SOLUTION:"e_no_solution",NO_SUPPORT:"e_no_support", -URL:"e_url",URL_NOT_SET:"e_url_not_set",VERSION:"e_version"};c.jPlayer.errorMsg={FLASH:"jPlayer's Flash fallback is not configured correctly, or a command was issued before the jPlayer Ready event. Details: ",NO_SOLUTION:"No solution can be found by jPlayer in this browser. Neither HTML nor Flash can be used.",NO_SUPPORT:"It is not possible to play any media format provided in setMedia() on this browser using your current options.",URL:"Media URL could not be loaded.",URL_NOT_SET:"Attempt to issue media playback commands, while no media url is set.", -VERSION:"jPlayer "+c.jPlayer.prototype.version.script+" needs Jplayer.swf version "+c.jPlayer.prototype.version.needFlash+" but found "};c.jPlayer.errorHint={FLASH:"Check your swfPath option and that Jplayer.swf is there.",NO_SOLUTION:"Review the jPlayer options: support and supplied.",NO_SUPPORT:"Video or audio formats defined in the supplied option are missing.",URL:"Check media URL is valid.",URL_NOT_SET:"Use setMedia() to set the media URL.",VERSION:"Update jPlayer files."};c.jPlayer.warning= -{CSS_SELECTOR_COUNT:"e_css_selector_count",CSS_SELECTOR_METHOD:"e_css_selector_method",CSS_SELECTOR_STRING:"e_css_selector_string",OPTION_KEY:"e_option_key"};c.jPlayer.warningMsg={CSS_SELECTOR_COUNT:"The number of methodCssSelectors found did not equal one: ",CSS_SELECTOR_METHOD:"The methodName given in jPlayer('cssSelector') is not a valid jPlayer method.",CSS_SELECTOR_STRING:"The methodCssSelector given in jPlayer('cssSelector') is not a String or is empty.",OPTION_KEY:"The option requested in jPlayer('option') is undefined."}; -c.jPlayer.warningHint={CSS_SELECTOR_COUNT:"Check your css selector and the ancestor.",CSS_SELECTOR_METHOD:"Check your method name.",CSS_SELECTOR_STRING:"Check your css selector is a string.",OPTION_KEY:"Check your option name."}})(jQuery); diff --git a/jquery-1.4.4.min.js b/jquery-1.4.4.min.js deleted file mode 100644 index 8f3ca2e..0000000 --- a/jquery-1.4.4.min.js +++ /dev/null @@ -1,167 +0,0 @@ -/*! - * jQuery JavaScript Library v1.4.4 - * http://jquery.com/ - * - * Copyright 2010, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * Copyright 2010, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * - * Date: Thu Nov 11 19:04:53 2010 -0500 - */ -(function(E,B){function ka(a,b,d){if(d===B&&a.nodeType===1){d=a.getAttribute("data-"+b);if(typeof d==="string"){try{d=d==="true"?true:d==="false"?false:d==="null"?null:!c.isNaN(d)?parseFloat(d):Ja.test(d)?c.parseJSON(d):d}catch(e){}c.data(a,b,d)}else d=B}return d}function U(){return false}function ca(){return true}function la(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function Ka(a){var b,d,e,f,h,l,k,o,x,r,A,C=[];f=[];h=c.data(this,this.nodeType?"events":"__events__");if(typeof h==="function")h= -h.events;if(!(a.liveFired===this||!h||!h.live||a.button&&a.type==="click")){if(a.namespace)A=RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)");a.liveFired=this;var J=h.live.slice(0);for(k=0;kd)break;a.currentTarget=f.elem;a.data=f.handleObj.data;a.handleObj=f.handleObj;A=f.handleObj.origHandler.apply(f.elem,arguments);if(A===false||a.isPropagationStopped()){d=f.level;if(A===false)b=false;if(a.isImmediatePropagationStopped())break}}return b}}function Y(a,b){return(a&&a!=="*"?a+".":"")+b.replace(La, -"`").replace(Ma,"&")}function ma(a,b,d){if(c.isFunction(b))return c.grep(a,function(f,h){return!!b.call(f,h,f)===d});else if(b.nodeType)return c.grep(a,function(f){return f===b===d});else if(typeof b==="string"){var e=c.grep(a,function(f){return f.nodeType===1});if(Na.test(b))return c.filter(b,e,!d);else b=c.filter(b,e)}return c.grep(a,function(f){return c.inArray(f,b)>=0===d})}function na(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var e=c.data(a[d++]),f=c.data(this, -e);if(e=e&&e.events){delete f.handle;f.events={};for(var h in e)for(var l in e[h])c.event.add(this,h,e[h][l],e[h][l].data)}}})}function Oa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function oa(a,b,d){var e=b==="width"?a.offsetWidth:a.offsetHeight;if(d==="border")return e;c.each(b==="width"?Pa:Qa,function(){d||(e-=parseFloat(c.css(a,"padding"+this))||0);if(d==="margin")e+=parseFloat(c.css(a, -"margin"+this))||0;else e-=parseFloat(c.css(a,"border"+this+"Width"))||0});return e}function da(a,b,d,e){if(c.isArray(b)&&b.length)c.each(b,function(f,h){d||Ra.test(a)?e(a,h):da(a+"["+(typeof h==="object"||c.isArray(h)?f:"")+"]",h,d,e)});else if(!d&&b!=null&&typeof b==="object")c.isEmptyObject(b)?e(a,""):c.each(b,function(f,h){da(a+"["+f+"]",h,d,e)});else e(a,b)}function S(a,b){var d={};c.each(pa.concat.apply([],pa.slice(0,b)),function(){d[this]=a});return d}function qa(a){if(!ea[a]){var b=c("<"+ -a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d==="")d="block";ea[a]=d}return ea[a]}function fa(a){return c.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var t=E.document,c=function(){function a(){if(!b.isReady){try{t.documentElement.doScroll("left")}catch(j){setTimeout(a,1);return}b.ready()}}var b=function(j,s){return new b.fn.init(j,s)},d=E.jQuery,e=E.$,f,h=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,l=/\S/,k=/^\s+/,o=/\s+$/,x=/\W/,r=/\d/,A=/^<(\w+)\s*\/?>(?:<\/\1>)?$/, -C=/^[\],:{}\s]*$/,J=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,w=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,I=/(?:^|:|,)(?:\s*\[)+/g,L=/(webkit)[ \/]([\w.]+)/,g=/(opera)(?:.*version)?[ \/]([\w.]+)/,i=/(msie) ([\w.]+)/,n=/(mozilla)(?:.*? rv:([\w.]+))?/,m=navigator.userAgent,p=false,q=[],u,y=Object.prototype.toString,F=Object.prototype.hasOwnProperty,M=Array.prototype.push,N=Array.prototype.slice,O=String.prototype.trim,D=Array.prototype.indexOf,R={};b.fn=b.prototype={init:function(j, -s){var v,z,H;if(!j)return this;if(j.nodeType){this.context=this[0]=j;this.length=1;return this}if(j==="body"&&!s&&t.body){this.context=t;this[0]=t.body;this.selector="body";this.length=1;return this}if(typeof j==="string")if((v=h.exec(j))&&(v[1]||!s))if(v[1]){H=s?s.ownerDocument||s:t;if(z=A.exec(j))if(b.isPlainObject(s)){j=[t.createElement(z[1])];b.fn.attr.call(j,s,true)}else j=[H.createElement(z[1])];else{z=b.buildFragment([v[1]],[H]);j=(z.cacheable?z.fragment.cloneNode(true):z.fragment).childNodes}return b.merge(this, -j)}else{if((z=t.getElementById(v[2]))&&z.parentNode){if(z.id!==v[2])return f.find(j);this.length=1;this[0]=z}this.context=t;this.selector=j;return this}else if(!s&&!x.test(j)){this.selector=j;this.context=t;j=t.getElementsByTagName(j);return b.merge(this,j)}else return!s||s.jquery?(s||f).find(j):b(s).find(j);else if(b.isFunction(j))return f.ready(j);if(j.selector!==B){this.selector=j.selector;this.context=j.context}return b.makeArray(j,this)},selector:"",jquery:"1.4.4",length:0,size:function(){return this.length}, -toArray:function(){return N.call(this,0)},get:function(j){return j==null?this.toArray():j<0?this.slice(j)[0]:this[j]},pushStack:function(j,s,v){var z=b();b.isArray(j)?M.apply(z,j):b.merge(z,j);z.prevObject=this;z.context=this.context;if(s==="find")z.selector=this.selector+(this.selector?" ":"")+v;else if(s)z.selector=this.selector+"."+s+"("+v+")";return z},each:function(j,s){return b.each(this,j,s)},ready:function(j){b.bindReady();if(b.isReady)j.call(t,b);else q&&q.push(j);return this},eq:function(j){return j=== --1?this.slice(j):this.slice(j,+j+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(N.apply(this,arguments),"slice",N.call(arguments).join(","))},map:function(j){return this.pushStack(b.map(this,function(s,v){return j.call(s,v,s)}))},end:function(){return this.prevObject||b(null)},push:M,sort:[].sort,splice:[].splice};b.fn.init.prototype=b.fn;b.extend=b.fn.extend=function(){var j,s,v,z,H,G=arguments[0]||{},K=1,Q=arguments.length,ga=false; -if(typeof G==="boolean"){ga=G;G=arguments[1]||{};K=2}if(typeof G!=="object"&&!b.isFunction(G))G={};if(Q===K){G=this;--K}for(;K0))if(q){var s=0,v=q;for(q=null;j=v[s++];)j.call(t,b);b.fn.trigger&&b(t).trigger("ready").unbind("ready")}}},bindReady:function(){if(!p){p=true;if(t.readyState==="complete")return setTimeout(b.ready,1);if(t.addEventListener){t.addEventListener("DOMContentLoaded",u,false);E.addEventListener("load",b.ready,false)}else if(t.attachEvent){t.attachEvent("onreadystatechange",u);E.attachEvent("onload", -b.ready);var j=false;try{j=E.frameElement==null}catch(s){}t.documentElement.doScroll&&j&&a()}}},isFunction:function(j){return b.type(j)==="function"},isArray:Array.isArray||function(j){return b.type(j)==="array"},isWindow:function(j){return j&&typeof j==="object"&&"setInterval"in j},isNaN:function(j){return j==null||!r.test(j)||isNaN(j)},type:function(j){return j==null?String(j):R[y.call(j)]||"object"},isPlainObject:function(j){if(!j||b.type(j)!=="object"||j.nodeType||b.isWindow(j))return false;if(j.constructor&& -!F.call(j,"constructor")&&!F.call(j.constructor.prototype,"isPrototypeOf"))return false;for(var s in j);return s===B||F.call(j,s)},isEmptyObject:function(j){for(var s in j)return false;return true},error:function(j){throw j;},parseJSON:function(j){if(typeof j!=="string"||!j)return null;j=b.trim(j);if(C.test(j.replace(J,"@").replace(w,"]").replace(I,"")))return E.JSON&&E.JSON.parse?E.JSON.parse(j):(new Function("return "+j))();else b.error("Invalid JSON: "+j)},noop:function(){},globalEval:function(j){if(j&& -l.test(j)){var s=t.getElementsByTagName("head")[0]||t.documentElement,v=t.createElement("script");v.type="text/javascript";if(b.support.scriptEval)v.appendChild(t.createTextNode(j));else v.text=j;s.insertBefore(v,s.firstChild);s.removeChild(v)}},nodeName:function(j,s){return j.nodeName&&j.nodeName.toUpperCase()===s.toUpperCase()},each:function(j,s,v){var z,H=0,G=j.length,K=G===B||b.isFunction(j);if(v)if(K)for(z in j){if(s.apply(j[z],v)===false)break}else for(;H
            a";var f=d.getElementsByTagName("*"),h=d.getElementsByTagName("a")[0],l=t.createElement("select"), -k=l.appendChild(t.createElement("option"));if(!(!f||!f.length||!h)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(h.getAttribute("style")),hrefNormalized:h.getAttribute("href")==="/a",opacity:/^0.55$/.test(h.style.opacity),cssFloat:!!h.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:k.selected,deleteExpando:true,optDisabled:false,checkClone:false, -scriptEval:false,noCloneEvent:true,boxModel:null,inlineBlockNeedsLayout:false,shrinkWrapBlocks:false,reliableHiddenOffsets:true};l.disabled=true;c.support.optDisabled=!k.disabled;b.type="text/javascript";try{b.appendChild(t.createTextNode("window."+e+"=1;"))}catch(o){}a.insertBefore(b,a.firstChild);if(E[e]){c.support.scriptEval=true;delete E[e]}try{delete b.test}catch(x){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function r(){c.support.noCloneEvent= -false;d.detachEvent("onclick",r)});d.cloneNode(true).fireEvent("onclick")}d=t.createElement("div");d.innerHTML="";a=t.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var r=t.createElement("div");r.style.width=r.style.paddingLeft="1px";t.body.appendChild(r);c.boxModel=c.support.boxModel=r.offsetWidth===2;if("zoom"in r.style){r.style.display="inline";r.style.zoom= -1;c.support.inlineBlockNeedsLayout=r.offsetWidth===2;r.style.display="";r.innerHTML="
            ";c.support.shrinkWrapBlocks=r.offsetWidth!==2}r.innerHTML="
            t
            ";var A=r.getElementsByTagName("td");c.support.reliableHiddenOffsets=A[0].offsetHeight===0;A[0].style.display="";A[1].style.display="none";c.support.reliableHiddenOffsets=c.support.reliableHiddenOffsets&&A[0].offsetHeight===0;r.innerHTML="";t.body.removeChild(r).style.display= -"none"});a=function(r){var A=t.createElement("div");r="on"+r;var C=r in A;if(!C){A.setAttribute(r,"return;");C=typeof A[r]==="function"}return C};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=f=h=null}})();var ra={},Ja=/^(?:\{.*\}|\[.*\])$/;c.extend({cache:{},uuid:0,expando:"jQuery"+c.now(),noData:{embed:true,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:true},data:function(a,b,d){if(c.acceptData(a)){a=a==E?ra:a;var e=a.nodeType,f=e?a[c.expando]:null,h= -c.cache;if(!(e&&!f&&typeof b==="string"&&d===B)){if(e)f||(a[c.expando]=f=++c.uuid);else h=a;if(typeof b==="object")if(e)h[f]=c.extend(h[f],b);else c.extend(h,b);else if(e&&!h[f])h[f]={};a=e?h[f]:h;if(d!==B)a[b]=d;return typeof b==="string"?a[b]:a}}},removeData:function(a,b){if(c.acceptData(a)){a=a==E?ra:a;var d=a.nodeType,e=d?a[c.expando]:a,f=c.cache,h=d?f[e]:e;if(b){if(h){delete h[b];d&&c.isEmptyObject(h)&&c.removeData(a)}}else if(d&&c.support.deleteExpando)delete a[c.expando];else if(a.removeAttribute)a.removeAttribute(c.expando); -else if(d)delete f[e];else for(var l in a)delete a[l]}},acceptData:function(a){if(a.nodeName){var b=c.noData[a.nodeName.toLowerCase()];if(b)return!(b===true||a.getAttribute("classid")!==b)}return true}});c.fn.extend({data:function(a,b){var d=null;if(typeof a==="undefined"){if(this.length){var e=this[0].attributes,f;d=c.data(this[0]);for(var h=0,l=e.length;h-1)return true;return false},val:function(a){if(!arguments.length){var b=this[0];if(b){if(c.nodeName(b,"option")){var d=b.attributes.value;return!d||d.specified?b.value:b.text}if(c.nodeName(b,"select")){var e=b.selectedIndex;d=[];var f=b.options;b=b.type==="select-one"; -if(e<0)return null;var h=b?e:0;for(e=b?e+1:f.length;h=0;else if(c.nodeName(this,"select")){var A=c.makeArray(r);c("option",this).each(function(){this.selected=c.inArray(c(this).val(),A)>=0});if(!A.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true}, -attr:function(a,b,d,e){if(!a||a.nodeType===3||a.nodeType===8)return B;if(e&&b in c.attrFn)return c(a)[b](d);e=a.nodeType!==1||!c.isXMLDoc(a);var f=d!==B;b=e&&c.props[b]||b;var h=Ta.test(b);if((b in a||a[b]!==B)&&e&&!h){if(f){b==="type"&&Ua.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");if(d===null)a.nodeType===1&&a.removeAttribute(b);else a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&& -b.specified?b.value:Va.test(a.nodeName)||Wa.test(a.nodeName)&&a.href?0:B;return a[b]}if(!c.support.style&&e&&b==="style"){if(f)a.style.cssText=""+d;return a.style.cssText}f&&a.setAttribute(b,""+d);if(!a.attributes[b]&&a.hasAttribute&&!a.hasAttribute(b))return B;a=!c.support.hrefNormalized&&e&&h?a.getAttribute(b,2):a.getAttribute(b);return a===null?B:a}});var X=/\.(.*)$/,ia=/^(?:textarea|input|select)$/i,La=/\./g,Ma=/ /g,Xa=/[^\w\s.|`]/g,Ya=function(a){return a.replace(Xa,"\\$&")},ua={focusin:0,focusout:0}; -c.event={add:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(c.isWindow(a)&&a!==E&&!a.frameElement)a=E;if(d===false)d=U;else if(!d)return;var f,h;if(d.handler){f=d;d=f.handler}if(!d.guid)d.guid=c.guid++;if(h=c.data(a)){var l=a.nodeType?"events":"__events__",k=h[l],o=h.handle;if(typeof k==="function"){o=k.handle;k=k.events}else if(!k){a.nodeType||(h[l]=h=function(){});h.events=k={}}if(!o)h.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem, -arguments):B};o.elem=a;b=b.split(" ");for(var x=0,r;l=b[x++];){h=f?c.extend({},f):{handler:d,data:e};if(l.indexOf(".")>-1){r=l.split(".");l=r.shift();h.namespace=r.slice(0).sort().join(".")}else{r=[];h.namespace=""}h.type=l;if(!h.guid)h.guid=d.guid;var A=k[l],C=c.event.special[l]||{};if(!A){A=k[l]=[];if(!C.setup||C.setup.call(a,e,r,o)===false)if(a.addEventListener)a.addEventListener(l,o,false);else a.attachEvent&&a.attachEvent("on"+l,o)}if(C.add){C.add.call(a,h);if(!h.handler.guid)h.handler.guid= -d.guid}A.push(h);c.event.global[l]=true}a=null}}},global:{},remove:function(a,b,d,e){if(!(a.nodeType===3||a.nodeType===8)){if(d===false)d=U;var f,h,l=0,k,o,x,r,A,C,J=a.nodeType?"events":"__events__",w=c.data(a),I=w&&w[J];if(w&&I){if(typeof I==="function"){w=I;I=I.events}if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(f in I)c.event.remove(a,f+b)}else{for(b=b.split(" ");f=b[l++];){r=f;k=f.indexOf(".")<0;o=[];if(!k){o=f.split(".");f=o.shift();x=RegExp("(^|\\.)"+ -c.map(o.slice(0).sort(),Ya).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(A=I[f])if(d){r=c.event.special[f]||{};for(h=e||0;h=0){a.type=f=f.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[f]&&c.each(c.cache,function(){this.events&&this.events[f]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType=== -8)return B;a.result=B;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(e=d.nodeType?c.data(d,"handle"):(c.data(d,"__events__")||{}).handle)&&e.apply(d,b);e=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+f]&&d["on"+f].apply(d,b)===false){a.result=false;a.preventDefault()}}catch(h){}if(!a.isPropagationStopped()&&e)c.event.trigger(a,b,e,true);else if(!a.isDefaultPrevented()){var l;e=a.target;var k=f.replace(X,""),o=c.nodeName(e,"a")&&k=== -"click",x=c.event.special[k]||{};if((!x._default||x._default.call(d,a)===false)&&!o&&!(e&&e.nodeName&&c.noData[e.nodeName.toLowerCase()])){try{if(e[k]){if(l=e["on"+k])e["on"+k]=null;c.event.triggered=true;e[k]()}}catch(r){}if(l)e["on"+k]=l;c.event.triggered=false}}},handle:function(a){var b,d,e,f;d=[];var h=c.makeArray(arguments);a=h[0]=c.event.fix(a||E.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;if(!b){e=a.type.split(".");a.type=e.shift();d=e.slice(0).sort();e=RegExp("(^|\\.)"+ -d.join("\\.(?:.*\\.)?")+"(\\.|$)")}a.namespace=a.namespace||d.join(".");f=c.data(this,this.nodeType?"events":"__events__");if(typeof f==="function")f=f.events;d=(f||{})[a.type];if(f&&d){d=d.slice(0);f=0;for(var l=d.length;f-1?c.map(a.options,function(e){return e.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},Z=function(a,b){var d=a.target,e,f;if(!(!ia.test(d.nodeName)||d.readOnly)){e=c.data(d,"_change_data");f=xa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",f);if(!(e===B||f===e))if(e!=null||f){a.type="change";a.liveFired= -B;return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:Z,beforedeactivate:Z,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return Z.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return Z.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,"_change_data",xa(a))}},setup:function(){if(this.type=== -"file")return false;for(var a in V)c.event.add(this,a+".specialChange",V[a]);return ia.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return ia.test(this.nodeName)}};V=c.event.special.change.filters;V.focus=V.beforeactivate}t.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.trigger(e,null,e.target)}c.event.special[b]={setup:function(){ua[b]++===0&&t.addEventListener(a,d,true)},teardown:function(){--ua[b]=== -0&&t.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,e,f){if(typeof d==="object"){for(var h in d)this[b](h,e,d[h],f);return this}if(c.isFunction(e)||e===false){f=e;e=B}var l=b==="one"?c.proxy(f,function(o){c(this).unbind(o,l);return f.apply(this,arguments)}):f;if(d==="unload"&&b!=="one")this.one(d,e,f);else{h=0;for(var k=this.length;h0?this.bind(b,d,e):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});E.attachEvent&&!E.addEventListener&&c(E).bind("unload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}}); -(function(){function a(g,i,n,m,p,q){p=0;for(var u=m.length;p0){F=y;break}}y=y[g]}m[p]=F}}}var d=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,f=Object.prototype.toString,h=false,l=true;[0,0].sort(function(){l=false;return 0});var k=function(g,i,n,m){n=n||[];var p=i=i||t;if(i.nodeType!==1&&i.nodeType!==9)return[];if(!g||typeof g!=="string")return n;var q,u,y,F,M,N=true,O=k.isXML(i),D=[],R=g;do{d.exec("");if(q=d.exec(R)){R=q[3];D.push(q[1]);if(q[2]){F=q[3]; -break}}}while(q);if(D.length>1&&x.exec(g))if(D.length===2&&o.relative[D[0]])u=L(D[0]+D[1],i);else for(u=o.relative[D[0]]?[i]:k(D.shift(),i);D.length;){g=D.shift();if(o.relative[g])g+=D.shift();u=L(g,u)}else{if(!m&&D.length>1&&i.nodeType===9&&!O&&o.match.ID.test(D[0])&&!o.match.ID.test(D[D.length-1])){q=k.find(D.shift(),i,O);i=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]}if(i){q=m?{expr:D.pop(),set:C(m)}:k.find(D.pop(),D.length===1&&(D[0]==="~"||D[0]==="+")&&i.parentNode?i.parentNode:i,O);u=q.expr?k.filter(q.expr, -q.set):q.set;if(D.length>0)y=C(u);else N=false;for(;D.length;){q=M=D.pop();if(o.relative[M])q=D.pop();else M="";if(q==null)q=i;o.relative[M](y,q,O)}}else y=[]}y||(y=u);y||k.error(M||g);if(f.call(y)==="[object Array]")if(N)if(i&&i.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&k.contains(i,y[g])))n.push(u[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&n.push(u[g]);else n.push.apply(n,y);else C(y,n);if(F){k(F,p,n,m);k.uniqueSort(n)}return n};k.uniqueSort=function(g){if(w){h= -l;g.sort(w);if(h)for(var i=1;i0};k.find=function(g,i,n){var m;if(!g)return[];for(var p=0,q=o.order.length;p":function(g,i){var n,m=typeof i==="string",p=0,q=g.length;if(m&&!/\W/.test(i))for(i=i.toLowerCase();p=0))n||m.push(u);else if(n)i[q]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var i=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=i[1]+(i[2]||1)-0;g[3]=i[3]-0}g[0]=e++;return g},ATTR:function(g,i,n, -m,p,q){i=g[1].replace(/\\/g,"");if(!q&&o.attrMap[i])g[1]=o.attrMap[i];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,i,n,m,p){if(g[1]==="not")if((d.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,i);else{g=k.filter(g[3],i,n,true^p);n||m.push.apply(m,g);return false}else if(o.match.POS.test(g[0])||o.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled=== -true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,i,n){return!!k(n[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"=== -g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,i){return i===0},last:function(g,i,n,m){return i===m.length-1},even:function(g,i){return i%2===0},odd:function(g,i){return i%2===1},lt:function(g,i,n){return in[3]-0},nth:function(g,i,n){return n[3]- -0===i},eq:function(g,i,n){return n[3]-0===i}},filter:{PSEUDO:function(g,i,n,m){var p=i[1],q=o.filters[p];if(q)return q(g,n,i,m);else if(p==="contains")return(g.textContent||g.innerText||k.getText([g])||"").indexOf(i[3])>=0;else if(p==="not"){i=i[3];n=0;for(m=i.length;n=0}},ID:function(g,i){return g.nodeType===1&&g.getAttribute("id")===i},TAG:function(g,i){return i==="*"&&g.nodeType===1||g.nodeName.toLowerCase()=== -i},CLASS:function(g,i){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(i)>-1},ATTR:function(g,i){var n=i[1];n=o.attrHandle[n]?o.attrHandle[n](g):g[n]!=null?g[n]:g.getAttribute(n);var m=n+"",p=i[2],q=i[4];return n==null?p==="!=":p==="="?m===q:p==="*="?m.indexOf(q)>=0:p==="~="?(" "+m+" ").indexOf(q)>=0:!q?m&&n!==false:p==="!="?m!==q:p==="^="?m.indexOf(q)===0:p==="$="?m.substr(m.length-q.length)===q:p==="|="?m===q||m.substr(0,q.length+1)===q+"-":false},POS:function(g,i,n,m){var p=o.setFilters[i[2]]; -if(p)return p(g,n,i,m)}}},x=o.match.POS,r=function(g,i){return"\\"+(i-0+1)},A;for(A in o.match){o.match[A]=RegExp(o.match[A].source+/(?![^\[]*\])(?![^\(]*\))/.source);o.leftMatch[A]=RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[A].source.replace(/\\(\d+)/g,r))}var C=function(g,i){g=Array.prototype.slice.call(g,0);if(i){i.push.apply(i,g);return i}return g};try{Array.prototype.slice.call(t.documentElement.childNodes,0)}catch(J){C=function(g,i){var n=0,m=i||[];if(f.call(g)==="[object Array]")Array.prototype.push.apply(m, -g);else if(typeof g.length==="number")for(var p=g.length;n";n.insertBefore(g,n.firstChild);if(t.getElementById(i)){o.find.ID=function(m,p,q){if(typeof p.getElementById!=="undefined"&&!q)return(p=p.getElementById(m[1]))?p.id===m[1]||typeof p.getAttributeNode!=="undefined"&&p.getAttributeNode("id").nodeValue===m[1]?[p]:B:[]};o.filter.ID=function(m,p){var q=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&q&&q.nodeValue===p}}n.removeChild(g); -n=g=null})();(function(){var g=t.createElement("div");g.appendChild(t.createComment(""));if(g.getElementsByTagName("*").length>0)o.find.TAG=function(i,n){var m=n.getElementsByTagName(i[1]);if(i[1]==="*"){for(var p=[],q=0;m[q];q++)m[q].nodeType===1&&p.push(m[q]);m=p}return m};g.innerHTML="";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")o.attrHandle.href=function(i){return i.getAttribute("href",2)};g=null})();t.querySelectorAll&& -function(){var g=k,i=t.createElement("div");i.innerHTML="

            ";if(!(i.querySelectorAll&&i.querySelectorAll(".TEST").length===0)){k=function(m,p,q,u){p=p||t;m=m.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!u&&!k.isXML(p))if(p.nodeType===9)try{return C(p.querySelectorAll(m),q)}catch(y){}else if(p.nodeType===1&&p.nodeName.toLowerCase()!=="object"){var F=p.getAttribute("id"),M=F||"__sizzle__";F||p.setAttribute("id",M);try{return C(p.querySelectorAll("#"+M+" "+m),q)}catch(N){}finally{F|| -p.removeAttribute("id")}}return g(m,p,q,u)};for(var n in g)k[n]=g[n];i=null}}();(function(){var g=t.documentElement,i=g.matchesSelector||g.mozMatchesSelector||g.webkitMatchesSelector||g.msMatchesSelector,n=false;try{i.call(t.documentElement,"[test!='']:sizzle")}catch(m){n=true}if(i)k.matchesSelector=function(p,q){q=q.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(p))try{if(n||!o.match.PSEUDO.test(q)&&!/!=/.test(q))return i.call(p,q)}catch(u){}return k(q,null,null,[p]).length>0}})();(function(){var g= -t.createElement("div");g.innerHTML="
            ";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){o.order.splice(1,0,"CLASS");o.find.CLASS=function(i,n,m){if(typeof n.getElementsByClassName!=="undefined"&&!m)return n.getElementsByClassName(i[1])};g=null}}})();k.contains=t.documentElement.contains?function(g,i){return g!==i&&(g.contains?g.contains(i):true)}:t.documentElement.compareDocumentPosition? -function(g,i){return!!(g.compareDocumentPosition(i)&16)}:function(){return false};k.isXML=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false};var L=function(g,i){for(var n,m=[],p="",q=i.nodeType?[i]:i;n=o.match.PSEUDO.exec(g);){p+=n[0];g=g.replace(o.match.PSEUDO,"")}g=o.relative[g]?g+"*":g;n=0;for(var u=q.length;n0)for(var h=d;h0},closest:function(a,b){var d=[],e,f,h=this[0];if(c.isArray(a)){var l,k={},o=1;if(h&&a.length){e=0;for(f=a.length;e-1:c(h).is(e))d.push({selector:l,elem:h,level:o})}h= -h.parentNode;o++}}return d}l=cb.test(a)?c(a,b||this.context):null;e=0;for(f=this.length;e-1:c.find.matchesSelector(h,a)){d.push(h);break}else{h=h.parentNode;if(!h||!h.ownerDocument||h===b)break}d=d.length>1?c.unique(d):d;return this.pushStack(d,"closest",a)},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var d=typeof a==="string"?c(a,b||this.context): -c.makeArray(a),e=c.merge(this.get(),d);return this.pushStack(!d[0]||!d[0].parentNode||d[0].parentNode.nodeType===11||!e[0]||!e[0].parentNode||e[0].parentNode.nodeType===11?e:c.unique(e))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a, -2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a, -b){c.fn[a]=function(d,e){var f=c.map(this,b,d);Za.test(a)||(e=d);if(e&&typeof e==="string")f=c.filter(e,f);f=this.length>1?c.unique(f):f;if((this.length>1||ab.test(e))&&$a.test(a))f=f.reverse();return this.pushStack(f,a,bb.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return b.length===1?c.find.matchesSelector(b[0],a)?[b[0]]:[]:c.find.matches(a,b)},dir:function(a,b,d){var e=[];for(a=a[b];a&&a.nodeType!==9&&(d===B||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&& -e.push(a);a=a[b]}return e},nth:function(a,b,d){b=b||1;for(var e=0;a;a=a[d])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var za=/ jQuery\d+="(?:\d+|null)"/g,$=/^\s+/,Aa=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Ba=/<([\w:]+)/,db=/\s]+\/)>/g,P={option:[1, -""],legend:[1,"
            ","
            "],thead:[1,"","
            "],tr:[2,"","
            "],td:[3,"","
            "],col:[2,"","
            "],area:[1,"",""],_default:[0,"",""]};P.optgroup=P.option;P.tbody=P.tfoot=P.colgroup=P.caption=P.thead;P.th=P.td;if(!c.support.htmlSerialize)P._default=[1,"div
            ","
            "];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d= -c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==B)return this.empty().append((this[0]&&this[0].ownerDocument||t).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this}, -wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})}, -prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b, -this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,e;(e=this[d])!=null;d++)if(!a||c.filter(a,[e]).length){if(!b&&e.nodeType===1){c.cleanData(e.getElementsByTagName("*"));c.cleanData([e])}e.parentNode&&e.parentNode.removeChild(e)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild); -return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,e=this.ownerDocument;if(!d){d=e.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(za,"").replace(fb,'="$1">').replace($,"")],e)[0]}else return this.cloneNode(true)});if(a===true){na(this,b);na(this.find("*"),b.find("*"))}return b},html:function(a){if(a===B)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(za,""):null; -else if(typeof a==="string"&&!Ca.test(a)&&(c.support.leadingWhitespace||!$.test(a))&&!P[(Ba.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Aa,"<$1>");try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?h.cloneNode(true):h)}k.length&&c.each(k,Oa)}return this}});c.buildFragment=function(a,b,d){var e,f,h;b=b&&b[0]?b[0].ownerDocument||b[0]:t;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===t&&!Ca.test(a[0])&&(c.support.checkClone||!Da.test(a[0]))){f=true;if(h=c.fragments[a[0]])if(h!==1)e=h}if(!e){e=b.createDocumentFragment();c.clean(a,b,e,d)}if(f)c.fragments[a[0]]=h?e:1;return{fragment:e,cacheable:f}};c.fragments={};c.each({appendTo:"append", -prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var e=[];d=c(d);var f=this.length===1&&this[0].parentNode;if(f&&f.nodeType===11&&f.childNodes.length===1&&d.length===1){d[b](this[0]);return this}else{f=0;for(var h=d.length;f0?this.clone(true):this).get();c(d[f])[b](l);e=e.concat(l)}return this.pushStack(e,a,d.selector)}}});c.extend({clean:function(a,b,d,e){b=b||t;if(typeof b.createElement==="undefined")b=b.ownerDocument|| -b[0]&&b[0].ownerDocument||t;for(var f=[],h=0,l;(l=a[h])!=null;h++){if(typeof l==="number")l+="";if(l){if(typeof l==="string"&&!eb.test(l))l=b.createTextNode(l);else if(typeof l==="string"){l=l.replace(Aa,"<$1>");var k=(Ba.exec(l)||["",""])[1].toLowerCase(),o=P[k]||P._default,x=o[0],r=b.createElement("div");for(r.innerHTML=o[1]+l+o[2];x--;)r=r.lastChild;if(!c.support.tbody){x=db.test(l);k=k==="table"&&!x?r.firstChild&&r.firstChild.childNodes:o[1]===""&&!x?r.childNodes:[];for(o=k.length- -1;o>=0;--o)c.nodeName(k[o],"tbody")&&!k[o].childNodes.length&&k[o].parentNode.removeChild(k[o])}!c.support.leadingWhitespace&&$.test(l)&&r.insertBefore(b.createTextNode($.exec(l)[0]),r.firstChild);l=r.childNodes}if(l.nodeType)f.push(l);else f=c.merge(f,l)}}if(d)for(h=0;f[h];h++)if(e&&c.nodeName(f[h],"script")&&(!f[h].type||f[h].type.toLowerCase()==="text/javascript"))e.push(f[h].parentNode?f[h].parentNode.removeChild(f[h]):f[h]);else{f[h].nodeType===1&&f.splice.apply(f,[h+1,0].concat(c.makeArray(f[h].getElementsByTagName("script")))); -d.appendChild(f[h])}return f},cleanData:function(a){for(var b,d,e=c.cache,f=c.event.special,h=c.support.deleteExpando,l=0,k;(k=a[l])!=null;l++)if(!(k.nodeName&&c.noData[k.nodeName.toLowerCase()]))if(d=k[c.expando]){if((b=e[d])&&b.events)for(var o in b.events)f[o]?c.event.remove(k,o):c.removeEvent(k,o,b.handle);if(h)delete k[c.expando];else k.removeAttribute&&k.removeAttribute(c.expando);delete e[d]}}});var Ea=/alpha\([^)]*\)/i,gb=/opacity=([^)]*)/,hb=/-([a-z])/ig,ib=/([A-Z])/g,Fa=/^-?\d+(?:px)?$/i, -jb=/^-?\d/,kb={position:"absolute",visibility:"hidden",display:"block"},Pa=["Left","Right"],Qa=["Top","Bottom"],W,Ga,aa,lb=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){if(arguments.length===2&&b===B)return this;return c.access(this,a,b,true,function(d,e,f){return f!==B?c.style(d,e,f):c.css(d,e)})};c.extend({cssHooks:{opacity:{get:function(a,b){if(b){var d=W(a,"opacity","opacity");return d===""?"1":d}else return a.style.opacity}}},cssNumber:{zIndex:true,fontWeight:true,opacity:true, -zoom:true,lineHeight:true},cssProps:{"float":c.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,d,e){if(!(!a||a.nodeType===3||a.nodeType===8||!a.style)){var f,h=c.camelCase(b),l=a.style,k=c.cssHooks[h];b=c.cssProps[h]||h;if(d!==B){if(!(typeof d==="number"&&isNaN(d)||d==null)){if(typeof d==="number"&&!c.cssNumber[h])d+="px";if(!k||!("set"in k)||(d=k.set(a,d))!==B)try{l[b]=d}catch(o){}}}else{if(k&&"get"in k&&(f=k.get(a,false,e))!==B)return f;return l[b]}}},css:function(a,b,d){var e,f=c.camelCase(b), -h=c.cssHooks[f];b=c.cssProps[f]||f;if(h&&"get"in h&&(e=h.get(a,true,d))!==B)return e;else if(W)return W(a,b,f)},swap:function(a,b,d){var e={},f;for(f in b){e[f]=a.style[f];a.style[f]=b[f]}d.call(a);for(f in b)a.style[f]=e[f]},camelCase:function(a){return a.replace(hb,lb)}});c.curCSS=c.css;c.each(["height","width"],function(a,b){c.cssHooks[b]={get:function(d,e,f){var h;if(e){if(d.offsetWidth!==0)h=oa(d,b,f);else c.swap(d,kb,function(){h=oa(d,b,f)});if(h<=0){h=W(d,b,b);if(h==="0px"&&aa)h=aa(d,b,b); -if(h!=null)return h===""||h==="auto"?"0px":h}if(h<0||h==null){h=d.style[b];return h===""||h==="auto"?"0px":h}return typeof h==="string"?h:h+"px"}},set:function(d,e){if(Fa.test(e)){e=parseFloat(e);if(e>=0)return e+"px"}else return e}}});if(!c.support.opacity)c.cssHooks.opacity={get:function(a,b){return gb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var d=a.style;d.zoom=1;var e=c.isNaN(b)?"":"alpha(opacity="+b*100+")",f= -d.filter||"";d.filter=Ea.test(f)?f.replace(Ea,e):d.filter+" "+e}};if(t.defaultView&&t.defaultView.getComputedStyle)Ga=function(a,b,d){var e;d=d.replace(ib,"-$1").toLowerCase();if(!(b=a.ownerDocument.defaultView))return B;if(b=b.getComputedStyle(a,null)){e=b.getPropertyValue(d);if(e===""&&!c.contains(a.ownerDocument.documentElement,a))e=c.style(a,d)}return e};if(t.documentElement.currentStyle)aa=function(a,b){var d,e,f=a.currentStyle&&a.currentStyle[b],h=a.style;if(!Fa.test(f)&&jb.test(f)){d=h.left; -e=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;h.left=b==="fontSize"?"1em":f||0;f=h.pixelLeft+"px";h.left=d;a.runtimeStyle.left=e}return f===""?"auto":f};W=Ga||aa;if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetHeight;return a.offsetWidth===0&&b===0||!c.support.reliableHiddenOffsets&&(a.style.display||c.css(a,"display"))==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var mb=c.now(),nb=/)<[^<]*)*<\/script>/gi, -ob=/^(?:select|textarea)/i,pb=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,qb=/^(?:GET|HEAD)$/,Ra=/\[\]$/,T=/\=\?(&|$)/,ja=/\?/,rb=/([?&])_=[^&]*/,sb=/^(\w+:)?\/\/([^\/?#]+)/,tb=/%20/g,ub=/#.*$/,Ha=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!=="string"&&Ha)return Ha.apply(this,arguments);else if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var f=a.slice(e,a.length);a=a.slice(0,e)}e="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b=== -"object"){b=c.param(b,c.ajaxSettings.traditional);e="POST"}var h=this;c.ajax({url:a,type:e,dataType:"html",data:b,complete:function(l,k){if(k==="success"||k==="notmodified")h.html(f?c("
            ").append(l.responseText.replace(nb,"")).find(f):l.responseText);d&&h.each(d,[l.responseText,k,l])}});return this},serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&& -!this.disabled&&(this.checked||ob.test(this.nodeName)||pb.test(this.type))}).map(function(a,b){var d=c(this).val();return d==null?null:c.isArray(d)?c.map(d,function(e){return{name:b.name,value:e}}):{name:b.name,value:d}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:e})}, -getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,e){if(c.isFunction(b)){e=e||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:e})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return new E.XMLHttpRequest},accepts:{xml:"application/xml, text/xml",html:"text/html", -script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},ajax:function(a){var b=c.extend(true,{},c.ajaxSettings,a),d,e,f,h=b.type.toUpperCase(),l=qb.test(h);b.url=b.url.replace(ub,"");b.context=a&&a.context!=null?a.context:b;if(b.data&&b.processData&&typeof b.data!=="string")b.data=c.param(b.data,b.traditional);if(b.dataType==="jsonp"){if(h==="GET")T.test(b.url)||(b.url+=(ja.test(b.url)?"&":"?")+(b.jsonp||"callback")+"=?");else if(!b.data|| -!T.test(b.data))b.data=(b.data?b.data+"&":"")+(b.jsonp||"callback")+"=?";b.dataType="json"}if(b.dataType==="json"&&(b.data&&T.test(b.data)||T.test(b.url))){d=b.jsonpCallback||"jsonp"+mb++;if(b.data)b.data=(b.data+"").replace(T,"="+d+"$1");b.url=b.url.replace(T,"="+d+"$1");b.dataType="script";var k=E[d];E[d]=function(m){if(c.isFunction(k))k(m);else{E[d]=B;try{delete E[d]}catch(p){}}f=m;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);r&&r.removeChild(A)}}if(b.dataType==="script"&&b.cache===null)b.cache= -false;if(b.cache===false&&l){var o=c.now(),x=b.url.replace(rb,"$1_="+o);b.url=x+(x===b.url?(ja.test(b.url)?"&":"?")+"_="+o:"")}if(b.data&&l)b.url+=(ja.test(b.url)?"&":"?")+b.data;b.global&&c.active++===0&&c.event.trigger("ajaxStart");o=(o=sb.exec(b.url))&&(o[1]&&o[1].toLowerCase()!==location.protocol||o[2].toLowerCase()!==location.host);if(b.dataType==="script"&&h==="GET"&&o){var r=t.getElementsByTagName("head")[0]||t.documentElement,A=t.createElement("script");if(b.scriptCharset)A.charset=b.scriptCharset; -A.src=b.url;if(!d){var C=false;A.onload=A.onreadystatechange=function(){if(!C&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){C=true;c.handleSuccess(b,w,e,f);c.handleComplete(b,w,e,f);A.onload=A.onreadystatechange=null;r&&A.parentNode&&r.removeChild(A)}}}r.insertBefore(A,r.firstChild);return B}var J=false,w=b.xhr();if(w){b.username?w.open(h,b.url,b.async,b.username,b.password):w.open(h,b.url,b.async);try{if(b.data!=null&&!l||a&&a.contentType)w.setRequestHeader("Content-Type", -b.contentType);if(b.ifModified){c.lastModified[b.url]&&w.setRequestHeader("If-Modified-Since",c.lastModified[b.url]);c.etag[b.url]&&w.setRequestHeader("If-None-Match",c.etag[b.url])}o||w.setRequestHeader("X-Requested-With","XMLHttpRequest");w.setRequestHeader("Accept",b.dataType&&b.accepts[b.dataType]?b.accepts[b.dataType]+", */*; q=0.01":b.accepts._default)}catch(I){}if(b.beforeSend&&b.beforeSend.call(b.context,w,b)===false){b.global&&c.active--===1&&c.event.trigger("ajaxStop");w.abort();return false}b.global&& -c.triggerGlobal(b,"ajaxSend",[w,b]);var L=w.onreadystatechange=function(m){if(!w||w.readyState===0||m==="abort"){J||c.handleComplete(b,w,e,f);J=true;if(w)w.onreadystatechange=c.noop}else if(!J&&w&&(w.readyState===4||m==="timeout")){J=true;w.onreadystatechange=c.noop;e=m==="timeout"?"timeout":!c.httpSuccess(w)?"error":b.ifModified&&c.httpNotModified(w,b.url)?"notmodified":"success";var p;if(e==="success")try{f=c.httpData(w,b.dataType,b)}catch(q){e="parsererror";p=q}if(e==="success"||e==="notmodified")d|| -c.handleSuccess(b,w,e,f);else c.handleError(b,w,e,p);d||c.handleComplete(b,w,e,f);m==="timeout"&&w.abort();if(b.async)w=null}};try{var g=w.abort;w.abort=function(){w&&Function.prototype.call.call(g,w);L("abort")}}catch(i){}b.async&&b.timeout>0&&setTimeout(function(){w&&!J&&L("timeout")},b.timeout);try{w.send(l||b.data==null?null:b.data)}catch(n){c.handleError(b,w,null,n);c.handleComplete(b,w,e,f)}b.async||L();return w}},param:function(a,b){var d=[],e=function(h,l){l=c.isFunction(l)?l():l;d[d.length]= -encodeURIComponent(h)+"="+encodeURIComponent(l)};if(b===B)b=c.ajaxSettings.traditional;if(c.isArray(a)||a.jquery)c.each(a,function(){e(this.name,this.value)});else for(var f in a)da(f,a[f],b,e);return d.join("&").replace(tb,"+")}});c.extend({active:0,lastModified:{},etag:{},handleError:function(a,b,d,e){a.error&&a.error.call(a.context,b,d,e);a.global&&c.triggerGlobal(a,"ajaxError",[b,a,e])},handleSuccess:function(a,b,d,e){a.success&&a.success.call(a.context,e,d,b);a.global&&c.triggerGlobal(a,"ajaxSuccess", -[b,a])},handleComplete:function(a,b,d){a.complete&&a.complete.call(a.context,b,d);a.global&&c.triggerGlobal(a,"ajaxComplete",[b,a]);a.global&&c.active--===1&&c.event.trigger("ajaxStop")},triggerGlobal:function(a,b,d){(a.context&&a.context.url==null?c(a.context):c.event).trigger(b,d)},httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"), -e=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(e)c.etag[b]=e;return a.status===304},httpData:function(a,b,d){var e=a.getResponseHeader("content-type")||"",f=b==="xml"||!b&&e.indexOf("xml")>=0;a=f?a.responseXML:a.responseText;f&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b==="json"||!b&&e.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&e.indexOf("javascript")>=0)c.globalEval(a);return a}}); -if(E.ActiveXObject)c.ajaxSettings.xhr=function(){if(E.location.protocol!=="file:")try{return new E.XMLHttpRequest}catch(a){}try{return new E.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}};c.support.ajax=!!c.ajaxSettings.xhr();var ea={},vb=/^(?:toggle|show|hide)$/,wb=/^([+\-]=)?([\d+.\-]+)(.*)$/,ba,pa=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b,d){if(a||a===0)return this.animate(S("show", -3),a,b,d);else{d=0;for(var e=this.length;d=0;e--)if(d[e].elem===this){b&&d[e](true);d.splice(e,1)}});b||this.dequeue();return this}});c.each({slideDown:S("show",1),slideUp:S("hide",1),slideToggle:S("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){c.fn[a]=function(d,e,f){return this.animate(b, -d,e,f)}});c.extend({speed:function(a,b,d){var e=a&&typeof a==="object"?c.extend({},a):{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};e.duration=c.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in c.fx.speeds?c.fx.speeds[e.duration]:c.fx.speeds._default;e.old=e.complete;e.complete=function(){e.queue!==false&&c(this).dequeue();c.isFunction(e.old)&&e.old.call(this)};return e},easing:{linear:function(a,b,d,e){return d+e*a},swing:function(a,b,d,e){return(-Math.cos(a* -Math.PI)/2+0.5)*e+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||c.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a=parseFloat(c.css(this.elem,this.prop));return a&&a>-1E4?a:0},custom:function(a,b,d){function e(l){return f.step(l)} -var f=this,h=c.fx;this.startTime=c.now();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;this.pos=this.state=0;e.elem=this.elem;if(e()&&c.timers.push(e)&&!ba)ba=setInterval(h.tick,h.interval)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true; -this.custom(this.cur(),0)},step:function(a){var b=c.now(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var e in this.options.curAnim)if(this.options.curAnim[e]!==true)d=false;if(d){if(this.options.overflow!=null&&!c.support.shrinkWrapBlocks){var f=this.elem,h=this.options;c.each(["","X","Y"],function(k,o){f.style["overflow"+o]=h.overflow[k]})}this.options.hide&&c(this.elem).hide();if(this.options.hide|| -this.options.show)for(var l in this.options.curAnim)c.style(this.elem,l,this.options.orig[l]);this.options.complete.call(this.elem)}return false}else{a=b-this.startTime;this.state=a/this.options.duration;b=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||b](this.state,a,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a= -c.timers,b=0;b-1;e={};var x={};if(o)x=f.position();l=o?x.top:parseInt(l,10)||0;k=o?x.left:parseInt(k,10)||0;if(c.isFunction(b))b=b.call(a,d,h);if(b.top!=null)e.top=b.top-h.top+l;if(b.left!=null)e.left=b.left-h.left+k;"using"in b?b.using.call(a, -e):f.css(e)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),e=Ia.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.css(a,"marginTop"))||0;d.left-=parseFloat(c.css(a,"marginLeft"))||0;e.top+=parseFloat(c.css(b[0],"borderTopWidth"))||0;e.left+=parseFloat(c.css(b[0],"borderLeftWidth"))||0;return{top:d.top-e.top,left:d.left-e.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||t.body;a&&!Ia.test(a.nodeName)&& -c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(e){var f=this[0],h;if(!f)return null;if(e!==B)return this.each(function(){if(h=fa(this))h.scrollTo(!a?e:c(h).scrollLeft(),a?e:c(h).scrollTop());else this[d]=e});else return(h=fa(f))?"pageXOffset"in h?h[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&h.document.documentElement[d]||h.document.body[d]:f[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase(); -c.fn["inner"+b]=function(){return this[0]?parseFloat(c.css(this[0],d,"padding")):null};c.fn["outer"+b]=function(e){return this[0]?parseFloat(c.css(this[0],d,e?"margin":"border")):null};c.fn[d]=function(e){var f=this[0];if(!f)return e==null?null:this;if(c.isFunction(e))return this.each(function(l){var k=c(this);k[d](e.call(this,l,k[d]()))});if(c.isWindow(f))return f.document.compatMode==="CSS1Compat"&&f.document.documentElement["client"+b]||f.document.body["client"+b];else if(f.nodeType===9)return Math.max(f.documentElement["client"+ -b],f.body["scroll"+b],f.documentElement["scroll"+b],f.body["offset"+b],f.documentElement["offset"+b]);else if(e===B){f=c.css(f,d);var h=parseFloat(f);return c.isNaN(h)?f:h}else return this.css(d,typeof e==="string"?e:e+"px")}})})(window); diff --git a/jquery-ui-1.8.9.custom.min.js b/jquery-ui-1.8.9.custom.min.js deleted file mode 100755 index 044d307..0000000 --- a/jquery-ui-1.8.9.custom.min.js +++ /dev/null @@ -1,68 +0,0 @@ -/*! - * jQuery UI 1.8.9 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI - */ -(function(c,j){function k(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.9",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106, -NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this, -"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position"); -if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,l,m){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(l)g-=parseFloat(c.curCSS(f, -"border"+this+"Width",true))||0;if(m)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h, -d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){var b=a.nodeName.toLowerCase(),d=c.attr(a,"tabindex");if("area"===b){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&k(a)}return(/input|select|textarea|button|object/.test(b)?!a.disabled:"a"==b?a.href||!isNaN(d):!isNaN(d))&&k(a)},tabbable:function(a){var b=c.attr(a,"tabindex");return(isNaN(b)||b>=0)&&c(a).is(":focusable")}}); -c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a
            ",remove:null,select:null,show:null,spinner:"Loading…",tabTemplate:"
          • #{label}
          • "},_create:function(){this._tabify(true)},_setOption:function(b,e){if(b=="selected")this.options.collapsible&& -e==this.options.selected||this.select(e);else{this.options[b]=e;this._tabify()}},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+u()},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+w());return d.cookie.apply(null,[b].concat(d.makeArray(arguments)))},_ui:function(b,e){return{tab:b,panel:e,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b= -d(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(b){function e(g,f){g.css("display","");!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}var a=this,c=this.options,h=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=d(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);this.anchors.each(function(g,f){var i=d(f).attr("href"),l=i.split("#")[0],q;if(l&&(l===location.toString().split("#")[0]|| -(q=d("base")[0])&&l===q.href)){i=f.hash;f.href=i}if(h.test(i))a.panels=a.panels.add(a.element.find(a._sanitizeSelector(i)));else if(i&&i!=="#"){d.data(f,"href.tabs",i);d.data(f,"load.tabs",i.replace(/#.*$/,""));i=a._tabId(f);f.href="#"+i;f=a.element.find("#"+i);if(!f.length){f=d(c.panelTemplate).attr("id",i).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else c.disabled.push(g)});if(b){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"); -this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(c.selected===p){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){c.selected=g;return false}});if(typeof c.selected!=="number"&&c.cookie)c.selected=parseInt(a._cookie(),10);if(typeof c.selected!=="number"&&this.lis.filter(".ui-tabs-selected").length)c.selected= -this.lis.index(this.lis.filter(".ui-tabs-selected"));c.selected=c.selected||(this.lis.length?0:-1)}else if(c.selected===null)c.selected=-1;c.selected=c.selected>=0&&this.anchors[c.selected]||c.selected<0?c.selected:0;c.disabled=d.unique(c.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(c.selected,c.disabled)!=-1&&c.disabled.splice(d.inArray(c.selected,c.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active"); -if(c.selected>=0&&this.anchors.length){a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash)).removeClass("ui-tabs-hide");this.lis.eq(c.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[c.selected],a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash))[0]))});this.load(c.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else c.selected=this.lis.index(this.lis.filter(".ui-tabs-selected")); -this.element[c.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");c.cookie&&this._cookie(c.selected,c.cookie);b=0;for(var j;j=this.lis[b];b++)d(j)[d.inArray(b,c.disabled)!=-1&&!d(j).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");c.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(c.event!=="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+ -g)};this.lis.bind("mouseover.tabs",function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(c.fx)if(d.isArray(c.fx)){m=c.fx[0];o=c.fx[1]}else m=o=c.fx;var r=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal", -function(){e(f,o);a._trigger("show",null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},s=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")}; -this.anchors.bind(c.event+".tabs",function(){var g=this,f=d(g).closest("li"),i=a.panels.filter(":not(.ui-tabs-hide)"),l=a.element.find(a._sanitizeSelector(g.hash));if(f.hasClass("ui-tabs-selected")&&!c.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a.panels.filter(":animated").length||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}c.selected=a.anchors.index(this);a.abort();if(c.collapsible)if(f.hasClass("ui-tabs-selected")){c.selected= --1;c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){s(g,i)}).dequeue("tabs");this.blur();return false}else if(!i.length){c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this));this.blur();return false}c.cookie&&a._cookie(c.selected,c.cookie);if(l.length){i.length&&a.element.queue("tabs",function(){s(g,i)});a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier."; -d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(b){if(typeof b=="string")b=this.anchors.index(this.anchors.filter("[href$="+b+"]"));return b},destroy:function(){var b=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e= -d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(c,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});b.cookie&&this._cookie(null,b.cookie);return this},add:function(b, -e,a){if(a===p)a=this.anchors.length;var c=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,b).replace(/#\{label\}/g,e));b=!b.indexOf("#")?b.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var j=c.element.find("#"+b);j.length||(j=d(h.panelTemplate).attr("id",b).data("destroy.tabs",true));j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);j.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]); -j.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");j.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){c._trigger("show",null,c._ui(c.anchors[0],c.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(b){b=this._getIndex(b);var e=this.options,a=this.lis.eq(b).remove(),c=this.panels.eq(b).remove(); -if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(b+(b+1=b?--h:h});this._tabify();this._trigger("remove",null,this._ui(a.find("a")[0],c[0]));return this},enable:function(b){b=this._getIndex(b);var e=this.options;if(d.inArray(b,e.disabled)!=-1){this.lis.eq(b).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=b});this._trigger("enable",null, -this._ui(this.anchors[b],this.panels[b]));return this}},disable:function(b){b=this._getIndex(b);var e=this.options;if(b!=e.selected){this.lis.eq(b).addClass("ui-state-disabled");e.disabled.push(b);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[b],this.panels[b]))}return this},select:function(b){b=this._getIndex(b);if(b==-1)if(this.options.collapsible&&this.options.selected!=-1)b=this.options.selected;else return this;this.anchors.eq(b).trigger(this.options.event+".tabs");return this}, -load:function(b){b=this._getIndex(b);var e=this,a=this.options,c=this.anchors.eq(b)[0],h=d.data(c,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(c,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(b).addClass("ui-state-processing");if(a.spinner){var j=d("span",c);j.data("label.tabs",j.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){e.element.find(e._sanitizeSelector(c.hash)).html(k);e._cleanup();a.cache&&d.data(c, -"cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.error(k,n,b,c)}catch(m){}}}));e.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this}, -url:function(b,e){this.anchors.eq(b).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.9"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(b,e){var a=this,c=this.options,h=a._rotate||(a._rotate=function(j){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=c.selected;a.select(++k= load_max && - image_manager.is_done_preloading() && - sounds.sounds_loaded()){ - // init all image objects - image_manager.init_images(p); - loading_finished(); - } - }; - - - obj.get_all_buttons = function() { - return []; - }; - - obj.key_pressed = function() {}; - - return obj; -}; diff --git a/multiplier.js b/multiplier.js deleted file mode 100644 index 4fb7830..0000000 --- a/multiplier.js +++ /dev/null @@ -1,56 +0,0 @@ -// --- inherits from game_object -// spec: -// game_object spec - -var multiplier = function(p, spec) { - // --- defaults --- - - spec.width = spec.width || 5; - spec.height = spec.height || 5; - // make sure it goes left - spec.vel = new p.PVector(p.random(0, -1)* g_speed_factor, p.random()* g_speed_factor); - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "multiplier"; - }; - - // --- private variables --- - - var alive = true; - - // --- public methods --- - - // implementing game_object interface - - obj.update = function() { - obj.bounce(); - obj.move(); - }; - - // (rectangle for now) - obj.draw = function() { - var pos = obj.get_pos(); - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.fill(0, 255, 0); - p.noStroke(); - - p.ellipse(pos.x, pos.y, - obj.get_width(), obj.get_height()); - }; - - obj.die = function() { - alive = false; - } - - obj.is_dead = function() { - return (!alive); - }; - - return obj; -}; diff --git a/mutation_obj.js b/mutation_obj.js deleted file mode 100644 index 9403397..0000000 --- a/mutation_obj.js +++ /dev/null @@ -1,328 +0,0 @@ -// Manages all information about the current state of mutation -// in the game -// Provides a num_status_obj, which is used for rendering -// spec: -// status_height = y value for status objects - -var mutation_obj = function(p, spec) { - - // obj to return - var obj = {}; - - // --- private variables --- - - var level = 1; - var cells_infected = 0; - var cells_needed; // init'd below - var new_mutation = false; - // Color array for all the mutation levels - var color_array = [ - /* - p.color(250, 250, 40), - p.color(60, 240, 240), - p.color(167, 17, 161), - p.color(100, 250, 110), - p.color(13, 28, 171), - p.color(118, 12, 25) - */ - 0xffff2a7f, - 0xffffff00, - 0xff7f2aff, - 0xff37c871, - 0xffd42aff, - 0xffff7f2a, - 0xff2ad4ff, - 0xffff2a2a, - 0xff7fff2a, - 0xffc8b7b7 - ]; - -/* - // Keeps track of all the abilities earned in the game so far - // If you lose a mutation level, must pop abilities off this array - var abilities = []; - - // All the possible abilities, sorted by level - // An ability can be earned at level x if it is in poss_abilities[0-x] - // TODO: add all abilities and change their levels - // TODO: Change these to be ready to be displayed to the user (or create a formatting mechanism) - var poss_abilities = [ - ["extra_particle"], - ["faster_particles", "bigger_particles"] - ]; -*/ - - // Flashing - var flash_color = null; - var is_flashing = false; - - // Shows the probability of getting a mutation - var bar_status_obj = num_status_obj(p, { - pos : new p.PVector(170, spec.status_height || 20), - text : "Mutation:", - num : 0, - bar : true, - max : 0 // init'd below - }); - - //Shows the curent mutation level - var level_spec = { - pos : new p.PVector(350, spec.status_height || 20), - text : "Strain ", - num : 1, - text_color : p.color(0) - }; - var level_status_obj = num_status_obj(p, level_spec); - - // --- private methods - -/* - // Returns a random ability, taking into account the current level - // Every possibile ability has an equal chance - var get_random_ability = function() { - var all_possible = []; - for(var i = 0; i < level; i++) { - for_each(poss_abilities[i], function(a) {all_possible.push(a);}); - } - assert(all_possible.length != 0); - return all_possible[Math.floor(Math.random() * all_possible.length)]; - } -*/ - - // Returns bool saying if a mutation should occur - // takes into account level, cells_infected, and a random probability - var mutation_occured = function() { - //return Math.random() + ( (cells_infected / 50) / (level + 1)) > .95; - //return (Math.random() * (cells_infected / 50)) > .3; - //return (Math.random() + (cells_infected / 100) - (level / 50)) > .98; - return (Math.random()*0.5 + (cells_infected / cells_needed)) > .98; - }; - - // returns the max number of cells the player needs to infect to have - // a 100% probability of mutating - var calc_cells_needed = function() { - return 30 + 20*level; - }; - cells_needed = calc_cells_needed(); - bar_status_obj.set_max(cells_needed); - - // Flashes the mutation bar red and white - var flash_bar = function() { - is_flashing = true; - - // Flash red and white every half second - flash_red(); - setTimeout(flash_white, 500); - setTimeout(flash_red, 1000); - setTimeout(flash_white, 1500); - setTimeout(flash_red, 2000); - setTimeout(flash_white, 2500); - // End flashing in 3 seconds - setTimeout(end_flash, 3000); - } - - // updates the flash color - var flash_red = function() { - flash_color = [255, 0, 0]; - } - var flash_white = function() { - flash_color = [255, 255, 255]; - } - - // Draws the bar with the appropriate flashing color - var draw_flashing_bar = function() { - bar_status_obj.draw_color(flash_color); - } - // Ends the flashing - var end_flash = function() { - is_flashing = false; - } - - // Gives us a rainbow gradient - // Taken from : http://snipplr.com/view.php?codeview&id=14590 - /** - * HSV to RGB color conversion - * - * H runs from 0 to 360 degrees - * S and V run from 0 to 100 - * - * Ported from the excellent java algorithm by Eugene Vishnevsky at: - * http://www.cs.rit.edu/~ncs/color/t_convert.html - */ - var hsvToRgb = function(h, s, v) { - var r, g, b; - var i; - var f, p, q, t; - - // Make sure our arguments stay in-range - h = Math.max(0, Math.min(360, h)); - s = Math.max(0, Math.min(100, s)); - v = Math.max(0, Math.min(100, v)); - - // We accept saturation and value arguments from 0 to 100 because that's - // how Photoshop represents those values. Internally, however, the - // saturation and value are calculated from a range of 0 to 1. We make - // That conversion here. - s /= 100; - v /= 100; - - if(s == 0) { - // Achromatic (grey) - r = g = b = v; - return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; - } - - h /= 60; // sector 0 to 5 - i = Math.floor(h); - f = h - i; // factorial part of h - p = v * (1 - s); - q = v * (1 - s * f); - t = v * (1 - s * (1 - f)); - - switch(i) { - case 0: - r = v; - g = t; - b = p; - break; - - case 1: - r = q; - g = v; - b = p; - break; - - case 2: - r = p; - g = v; - b = t; - break; - - case 3: - r = p; - g = q; - b = v; - break; - - case 4: - r = t; - g = p; - b = v; - break; - - default: // case 5: - r = v; - g = p; - b = q; - } - - return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; - } - - // --- public methods --- - - obj.draw = function() { - bar_status_obj.draw(); - if (is_flashing) { - draw_flashing_bar(); - } - - // draw mutation colored box under level num - p.fill(get_color()); - p.noStroke(); - var lpos = level_spec.pos; - p.rectMode(p.CORNER); - p.rect(lpos.x-30, lpos.y-10, 70, 20); - - level_status_obj.draw(); - }; - - // increments the mutation percentage - obj.infected_cell = function() { - cells_infected += 1; - bar_status_obj.incr(1); - // if a mutation occurs - if (mutation_occured()) { - // set the flag - new_mutation = true; - flash_bar(); - - // Play sounds - sounds.play_sound("level_up"); - } - }; - - // returns true if a new mutation is ready - obj.has_new_mutation = function() { - return new_mutation; - }; - - // to be called when in_game_state decides to enact the new mutation - // as signalled by the flag - // Returns a new ability if one was added - obj.do_mutation = function() { - flash_bar(); - // Add new ability before incrementing level - //var new_ability = get_random_ability(); - //abilities.push(new_ability); - level += 1; - level_status_obj.incr(1); - // update num cells needed - cells_needed = calc_cells_needed(); - bar_status_obj.set_max(cells_needed); - // reset counters - obj.reset_mutation(); - - //return new_ability; - }; - - - // resets the counters and the flag - // to be called after a mutation is enacted in the game - obj.reset_mutation = function() { - cells_infected = 0; - bar_status_obj.set_num(0); - // reset flag - new_mutation = false; - }; - - var get_color = function() { - return color_array[(level - 1) % color_array.length]; - }; - - // Returns the current mutation level and color - obj.get_info = function() { - // color level goes from 0 to 360 - //var new_color_level = (360 - (360 - level * 30)); - //var hue = new_color_level / 360; - //var rgb_arr = hsvToRgb(new_color_level, 75, 75); - return { - level: level, - //color: p.color(rgb_arr[0], rgb_arr[1], rgb_arr[2]), - // level starts at 1, so have to subtract 1 - color : get_color(), //% color_array.size], - // get one new particle every 10 levels - particles: 3+p.floor(level/3), - //abilities: abilities - }; - }; - - obj.get_level = function() { - return level; - }; - - obj.set_level = function(l) { - // decrement by the difference in levels - level_status_obj.incr(l-level); - // Pop off abilities - /* - for (var i = 0; i < (level - l); i++) { - abilities.pop(); - } - */ - // set the new level - level = l; - }; - - return obj; -}; diff --git a/notification.js b/notification.js deleted file mode 100644 index dfee58e..0000000 --- a/notification.js +++ /dev/null @@ -1,64 +0,0 @@ -// Used to alert the user of new information -// draw() returns false if the status update is finished -// spec: -// text : text to display -// color : color of text (defaults to black) -// pos : pos of notification - -var notification = function(p, spec) { - - // object to return - var obj = {}; - - // --- private variables --- - - var time_counter = 0; // used to draw the object at various times - var total_time = 60; // ~ 2 seconds. If changed must be changed in notify in in_game_state to prevent overlap //200; // ~6 secs? - - var text_size = 20; - var box_color = spec.color || p.color(255, 255, 255); - - // --- public methods --- - - - obj.draw = function() { - var time_percent = time_counter / total_time; - //var text_size = 25 - 25*(time_percent); - var text_alpha = 255 - 200*time_percent; - - //var x_pos = (p.width * (5/8)); //+ (p.width / 2) *time_percent; - //var y_pos = (p.height * (5/8)) - (p.height / 2) *time_percent; - - var x_pos = spec.pos.x; - var y_pos = spec.pos.y; - - // I don't like the moving from the center - // so I'm trying it stationary - //var x_pos = p.width / 2; - //var y_pos = 70; - - // this needs to come before textWidth - p.textAlign(p.CENTER, p.CENTER); - p.textSize(text_size); - - var w = p.textWidth(spec.text); - - // draw a box behind it - //p.fill(box_color, text_alpha); - //p.rectMode(p.CORNER) - //p.rect(x_pos-w/2-5, y_pos-p.textAscent(), w+10, p.textAscent()*2); - - //p.fill(p.color(0, 0, 0), text_alpha); - //p.fill(p.color(255, 255, 255), text_alpha); - p.fill(box_color, text_alpha); - p.text(spec.text, x_pos, y_pos); - - if (time_counter > total_time) { // Finished - return false; - } - time_counter++; - return true; - } - - return obj; -}; diff --git a/num_status_obj.js b/num_status_obj.js deleted file mode 100644 index fc05e28..0000000 --- a/num_status_obj.js +++ /dev/null @@ -1,115 +0,0 @@ -// Generic wrapper for a status that includes text and a num -// Can be drawn as a number or a bar -// Provides draw, incr, set_num, and get_num -// spec: -// pos : center pos of text -// text : Will display " " -// num : num to start at -// bar : bool (optional) -// max : num (required if bar) - -var num_status_obj = function(p, spec) { - - // obj to return - var obj = {}; - - // --- private variables --- - - var pos = spec.pos; - var number = spec.num; - var txt = spec.text; - var bar = spec.bar || false; - var max = spec.max; - var height = 20; - var max_width = 100; //for the bar, might need to be passed in - - var get_obj_text = function() { - if (bar) { - return txt; - } - else { - var num_txt = ""+number; - if (spec.format) { - num_txt = spec.format(number); - } - return txt + " " + num_txt; - } - } - - var rect = rectangle(p, { // Really just a text obj - pos : pos, - width : 0, - height : 0, - text : get_obj_text(), - text_size : 14, - text_color: spec.text_color || 255, - }); - - // --- private methods - - var update = function(n) { - - number = n; - - rect.update_text(get_obj_text()); - }; - var draw_full_rect = function(color) { - p.fill(color[0], color[1], color[2]); - //p.strokeWeight(1); - //p.stroke(0); - var topy = pos.y - (height / 2); - var leftx = pos.x + (txt.length * 4); - p.rect(leftx, topy, max_width, height); - }; - - // --- public methods --- - - obj.draw = function() { - rect.draw(); - // Draw the bar separately, if appropriate - if (bar) { - p.noStroke(); - // Draw empty rectangle first - draw_full_rect([255, 255, 255]); - - // Then draw mutation status bar - p.fill(150); - - var topy = pos.y - (height / 2); - var leftx = pos.x + (txt.length * 4); - var rect_width = (number / max) * max_width; - rect_width = rect_width > max_width ? max_width : rect_width; - p.rectMode(p.CORNER); - p.rect(leftx, topy, rect_width, height); - - p.fill(255) - } - }; - - // SHOULD ONLY BE CALLED IF bar IS TRUE - // Draws a full bar of the specified color - // color : 3 element rgb array - obj.draw_color = function(color) { - draw_full_rect(color); - }; - - obj.incr = function(n) { - update(number + n); - }; - - // Set and get - - obj.set_max = function(m) { - max = m; - }; - - obj.set_num = function(n) { - update(n); - }; - - obj.get_num = function() { - return number; - }; - - return obj; -}; diff --git a/object_with_states.js b/object_with_states.js deleted file mode 100644 index a18e993..0000000 --- a/object_with_states.js +++ /dev/null @@ -1,26 +0,0 @@ -// Gives an object the capability to set and get states -// inherits from game_object -// spec: -// spec.state -- current state, default to 'alive' - -var object_with_states = function(p, spec) { - - var obj = game_object(p, spec); - - var state = spec.state || "alive"; - - // --- public methods --- - - obj.set_state = function(s) { - // If outdated, don't update state - if (state != "outdated") { - state = s; - } - }; - - obj.get_state = function() { - return state; - }; - - return obj; -} diff --git a/old-index.html b/old-index.html deleted file mode 100644 index 3f3eb4d..0000000 --- a/old-index.html +++ /dev/null @@ -1,223 +0,0 @@ - - - -Virion - - - - - - - - - -
            - - -
            Login with Facebook to track your high scores!
            - - - - Login with Facebook - - - -

            - -
            You are not Logged In
            - - - - -
            -
            Welcome to Virion beta testing!  Give the game a try and then scroll down to give us your feedback.
            -
            - -
            -
            - Could not load high scores! You may want to check your internet connection. -
            -
            - - - Your browser does not support the HTML5 canvas element. Upgrade to Chrome, Firefox 4, Safari, or Opera to play this game. - -
            -
            -

            Virion Beta Testing Feedback

            -
            - Tell us what you thought of the game by filling out the survey below. You can also email us at viriongame at gmail dot com. Thanks! We appreciate your help.  — The Virion Team -
            -
            - -
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/option_button.js b/option_button.js deleted file mode 100644 index 5154998..0000000 --- a/option_button.js +++ /dev/null @@ -1,63 +0,0 @@ -// Have a rectangle representing their position and a state to go to when clicked -// spec: -// rect : spec for a rectangle representing the button -// click_fun : what to do when clicked -// global_var : var that determines whether this option is enabled or not - -var option_button = function(p, spec) { - - // --- defaults --- - //spec.rect.width = spec.width || 200; - //spec.rect.height = spec.height || 60; - - // obj to return - var obj = {}; - - // --- private variables --- - - var but = button(p, spec); - var rect = rectangle(p, spec.rect); - // Left-edge x and top-edge y coordinates of 'checkbox' indicating whether - // option is enabled - var status_x = rect.get_left_x() + 28//50; - var status_y = rect.get_top_y() + 30//37; - var tick_size = 30; - var tick_yes_image = image_manager.get_image("check1.png"); - var tick_no_image = image_manager.get_image("check0.png"); - - // --- public methods --- - - obj.draw = function() { - //rect.draw(); - but.draw(); - - p.imageMode(p.CENTER); - if (g[spec.global_var]) { - //p.fill(255, 255, 255); - //p.ellipse(status_x, status_y, 10, 10); - p.image(tick_yes_image, status_x, status_y, tick_size, tick_size); - } - else { - p.image(tick_no_image, status_x, status_y, tick_size, tick_size); - } - }; - - // Returns the state to go to if clicked, or - // null if not clicked - obj.click = function(x, y) { - //but.is_clicked(); - if (rect.is_in(x, y)) { - spec.click_fun(); - } - // Redraw in case anything changes - obj.draw(); - }; - - obj.is_clicked = function() { return null; }; - - obj.mouse_moved = function(x, y) { - but.mouse_moved(x, y); - }; - - return obj; -}; diff --git a/options_state.js b/options_state.js deleted file mode 100644 index 8333f7b..0000000 --- a/options_state.js +++ /dev/null @@ -1,209 +0,0 @@ -var options_state = function (p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // Used to determine whether to play menu music when 'music' button is toggled - var prev_was_splash = false; - if (prev_state.get_type() === "splash") { - prev_was_splash = true; - } - - - // --- private variables --- - - var background_image = image_manager.get_image("settingssplash.png"); - - var button_style = { - text_x_offset : 60, - text_y_offset: -3, - text_align: p.LEFT - }; - - // Buttons - - var col1_x = p.width/2 - 120; - var col2_x = p.width/2 + 120; - - var back_button = button(p, { - state : function() { - sounds.play_button_back(); - return prev_state; - }, - rect : { - pos : new p.PVector(p.width / 2, p.height - 80), - //width : 120, - //height : 50, - //text: "Back", - //text_x_offset: 5, - //text_y_offset: -8, - image: "back.png", - } - }); - - // Options - //var option_image = "bullet_listcell.png"; - var sound_fx_button = option_button(p, { - click_fun : function() {sounds.play_button_click(); g.toggle_sound_fx();}, - global_var : "sound_fx", - rect : { - pos : new p.PVector(col1_x, p.height/2 - 70), - //text: "Sound Effects", - //text_x_offset: 60, - image : "set_sound.png",//option_image, - //over_image : "set_sound_a.png", - //style: button_style - } - }); - var music_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - // toggle the flag - g.toggle_music(); - - if (g.music) { - if (prev_was_splash) { - sounds.play_menu_music(); - } - } - else { - sounds.pause_menu_music(); - } - }, - global_var : "music", - rect : { - pos : new p.PVector(col1_x, p.height/2 + 40), - //text: "Music", - //text_x_offset: 60, - image : "set_music.png",//option_image, - //over_image : "set_music_a.png", - //style: button_style - } - }); - var spacebar_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - g.toggle_spacebar_to_fire(); - }, - global_var : "spacebar_to_fire", - rect : { - pos : new p.PVector(col2_x, p.height/2 - 70), - //text: "Spacebar to Fire", - //text_x_offset : 60, - image : "set_spacebar.png",//option_image, - //over_image : "set_spacebar_a.png", - //style: button_style - } - }); - var mouse_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - g.toggle_click_to_fire(); - }, - global_var : "click_to_fire", - rect : { - pos : new p.PVector(col2_x, p.height/2 + 40), - //text: "Mouse Click to Fire", - //text_x_offset : 60, - image : "set_click.png",//option_image, - //over_image : "set_click_a.png", - //style: button_style - } - }); - var mouse_to_select_button = option_button(p, { - click_fun : function() { - sounds.play_button_click(); - g.toggle_mouse_to_select(); - }, - global_var : "mouse_to_select", - rect : { - pos : new p.PVector(col2_x, p.height/2 + 140), - //text: "Mouse to Select Cells\nInstead of Left/Right", - image : "set_mouseselect.png",//option_image, - //over_image : "set_mouseselect_a.png", - //text_x_offset : 60, - //style: button_style - } - }); - var track_left_button = button(p, { - state : function() { - sounds.play_button_click(); - g.prev_track(); - return obj; - }, - rect : { - pos : new p.PVector(col1_x - 50, p.height/2 + 145), - image : "track_left.png", - } - }); - var track_right_button = button(p, { - state : function() { - sounds.play_button_click(); - g.next_track(); - return obj; - }, - rect : { - pos : new p.PVector(col1_x + 50, p.height/2 + 145), - image : "track_right.png", - } - }); - - - - //Not ordered - var all_option_buttons = [sound_fx_button, music_button, - spacebar_button, mouse_button, mouse_to_select_button]; - var all_buttons = [back_button, track_left_button, track_right_button] - .concat(all_option_buttons); - - - // --- public methods --- - - obj.get_type = function() { - return "options"; - }; - - obj.update = function() { - //do nothing - }; - - obj.key_pressed = function(k) { - if (k === 115 || p.keyCode === 13 || k === 32) { //s, enter, space - } - else if (k === 104) { //h - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - obj.render = function() { - //p.background(g.background_color); - //p.fill(g.background_color); - //p.rect(100, 100, 500, 500); - p.imageMode(p.CORNERS); - p.image(background_image, 0, 0);//, p.width, p.height); - - // draw the track button background manually - var track_x = col1_x; - var track_y = p.height/2 + 140; - var track_image = image_manager.get_image("set_track.png"); - p.imageMode(p.CENTER); - p.image(track_image, track_x, track_y); - // draw current track - p.fill(0); - p.textAlign(p.CENTER); - p.textSize(14); - p.text(g.track, track_x, track_y+5); - - for_each(all_option_buttons, function(b) { b.draw(); }); - }; - - obj.mouse_click = function(x, y) { - for_each(all_option_buttons, function(b) { b.click(x, y); }); - }; - - return obj; -}; diff --git a/particle.js b/particle.js deleted file mode 100644 index 630645b..0000000 --- a/particle.js +++ /dev/null @@ -1,437 +0,0 @@ -// *** particle *** -// --- inherits from game_object -// spec: -// game_object spec - -var particle = function(p, spec) { - - // --- defaults --- - - // was 15 - spec.width = spec.width || 10; - spec.height = spec.height || 10; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "particle"; - }; - - // --- private variables --- - - //var par_shape = p.loadShape("images/virusfinal.svg"); - //var par_image = p.loadImage("images/virus1.png"); - var par_image = image_manager.get_image("tinyvirus_trans.png"); - //var mutation = spec.mutation; - - // --- public methods --- - - // implementing game_object interface - - // update is default (move) - - // draw makes a small virus particle - // (circle for now) - obj.draw = function() { - var pos = obj.get_pos(); - p.shapeMode(obj.get_mode()); - //var color = mutation.get_color(); - p.fill(obj.get_color()); - p.noStroke(); - p.ellipse(pos.x, pos.y, - obj.get_width() * .75, obj.get_height() * .75); - p.imageMode(obj.get_mode()); - p.image(par_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - //var d = new Date(); - //console.log(d.getMilliseconds()); - //p.shape(par_shape, pos.x, pos.y, - //obj.get_width() + 20, obj.get_height() + 20); - //draw(canvas.getContext('2d')); - //canvas.getContext('2d').drawSvg("images/virusFinal.svg", 300, 10, 20, 20); - //console.log("a " + d.getMilliseconds()); - - }; - - // override for circular object - obj.calc_radius = function() { - return obj.get_width()/2; - }; - obj.set_radius(obj.calc_radius()); - - return obj; -} - -// SVG -> Javascript code to draw the particle -/* -var draw = function(ctx) { -ctx.save(); -ctx.strokeStyle = 'rgba(0,0,0,0)'; -ctx.lineCap = 'butt'; -ctx.lineJoin = 'miter'; -ctx.miterLimit = 4; -ctx.save(); -ctx.restore(); -ctx.save(); -ctx.restore(); -ctx.save(); -ctx.scale(0.02,0.02); -ctx.save(); -ctx.fillStyle = "#fff1d0"; -ctx.strokeStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.lineWidth = 5; -ctx.miterLimit = 4; -ctx.beginPath(); -ctx.moveTo(411.42857,373.36218); -ctx.bezierCurveTo(378.29148999999995,373.36218,351.42857,400.2251,351.42857,433.36218); -ctx.bezierCurveTo(351.42857,435.74656000000004,351.59556999999995,438.08169000000004,351.86607,440.39343); -ctx.bezierCurveTo(333.68726999999996,446.05755000000005,316.62739,454.24753000000004,301.08482,464.54968); -ctx.bezierCurveTo(293.76497,456.45166,283.20419999999996,451.36218,271.42857,451.36218); -ctx.bezierCurveTo(249.33718,451.36218,231.42856999999998,469.27079000000003,231.42856999999998,491.36218); -ctx.bezierCurveTo(231.42856999999998,503.13781,236.51805,513.69858,244.61606999999998,521.0184300000001); -ctx.bezierCurveTo(234.27291999999997,536.6228600000001,226.0638,553.7583900000001,220.39731999999998,572.0184300000001); -ctx.bezierCurveTo(217.46769999999998,571.5787200000001,214.48073999999997,571.3621800000001,211.42856999999998,571.3621800000001); -ctx.bezierCurveTo(178.29148999999998,571.3621800000001,151.42856999999998,598.2251000000001,151.42856999999998,631.3621800000001); -ctx.bezierCurveTo(151.42856999999998,664.49926,178.29148999999998,691.3621800000001,211.42856999999998,691.3621800000001); -ctx.bezierCurveTo(214.48073999999997,691.3621800000001,217.46769999999998,691.1456400000001,220.39731999999998,690.7059300000001); -ctx.bezierCurveTo(226.0638,708.9659700000001,234.27291999999997,726.1015000000001,244.61606999999998,741.7059300000001); -ctx.bezierCurveTo(236.51805,749.02578,231.42856999999998,759.5865500000001,231.42856999999998,771.3621800000001); -ctx.bezierCurveTo(231.42856999999998,793.4535700000001,249.33718,811.3621800000001,271.42857,811.3621800000001); -ctx.bezierCurveTo(283.20419999999996,811.3621800000001,293.76497,806.2727000000001,301.08482,798.1746800000001); -ctx.bezierCurveTo(316.68924999999996,808.5178300000001,333.82478,816.7269500000001,352.08482,822.3934300000001); -ctx.bezierCurveTo(351.64511,825.3230500000001,351.42857,828.31001,351.42857,831.3621800000001); -ctx.bezierCurveTo(351.42857,864.49926,378.29148999999995,891.3621800000001,411.42857,891.3621800000001); -ctx.bezierCurveTo(444.56565,891.3621800000001,471.42857,864.49926,471.42857,831.3621800000001); -ctx.bezierCurveTo(471.42857,828.31001,471.21202999999997,825.3230500000001,470.77232,822.3934300000001); -ctx.bezierCurveTo(489.03236,816.7269500000001,506.16789,808.5178300000001,521.77232,798.1746800000001); -ctx.bezierCurveTo(529.09217,806.2727000000001,539.6529400000001,811.3621800000001,551.42857,811.3621800000001); -ctx.bezierCurveTo(573.5199600000001,811.3621800000001,591.42857,793.4535700000001,591.42857,771.3621800000001); -ctx.bezierCurveTo(591.42857,759.5865500000001,586.33909,749.02578,578.24107,741.7059300000001); -ctx.bezierCurveTo(588.5842200000001,726.1015000000001,596.7933400000001,708.9659700000001,602.45982,690.7059300000001); -ctx.bezierCurveTo(605.38944,691.1456400000001,608.3764,691.3621800000001,611.42857,691.3621800000001); -ctx.bezierCurveTo(644.56565,691.3621800000001,671.42857,664.49926,671.42857,631.3621800000001); -ctx.bezierCurveTo(671.42857,598.2251000000001,644.56565,571.3621800000001,611.42857,571.3621800000001); -ctx.bezierCurveTo(608.3764,571.3621800000001,605.38944,571.5787200000001,602.45982,572.0184300000001); -ctx.bezierCurveTo(596.7933400000001,553.7583900000001,588.5842200000001,536.6228600000001,578.24107,521.0184300000001); -ctx.bezierCurveTo(586.33909,513.6985800000001,591.42857,503.13781000000006,591.42857,491.3621800000001); -ctx.bezierCurveTo(591.42857,469.2707900000001,573.5199600000001,451.3621800000001,551.42857,451.3621800000001); -ctx.bezierCurveTo(539.6529400000001,451.3621800000001,529.09217,456.45166000000006,521.77232,464.5496800000001); -ctx.bezierCurveTo(506.22975,454.2475300000001,489.16987000000006,446.0575500000001,470.99107000000004,440.3934300000001); -ctx.bezierCurveTo(471.26157000000006,438.0816900000001,471.42857000000004,435.7465600000001,471.42857000000004,433.3621800000001); -ctx.bezierCurveTo(471.42857000000004,400.2251000000001,444.56565000000006,373.3621800000001,411.42857000000004,373.3621800000001); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "#d4d4d4"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.globalAlpha = 0.2752293646335602; -ctx.beginPath(); -ctx.moveTo(530.99107,472.99893); -ctx.bezierCurveTo(556.1068300000001,506.42843999999997,570.99107,547.96659,570.99107,592.99893); -ctx.bezierCurveTo(570.99107,640.61609,554.33443,684.34142,526.55357,718.68643); -ctx.bezierCurveTo(529.38723,724.17581,530.99107,730.39551,530.99107,736.99893); -ctx.bezierCurveTo(530.99107,759.09032,513.0824600000001,776.99893,490.99107000000004,776.99893); -ctx.bezierCurveTo(481.81567,776.99893,473.36493,773.91293,466.61607000000004,768.71768); -ctx.bezierCurveTo(459.44539000000003,772.62788,452.0033,776.1000799999999,444.33482000000004,779.12393); -ctx.bezierCurveTo(459.07273000000004,788.9998499999999,469.20043000000004,805.23816,470.77232000000004,823.90518); -ctx.bezierCurveTo(552.02543,798.48635,610.99107,722.63081,610.99107,632.99893); -ctx.bezierCurveTo(610.99107,567.57432,579.55868,509.48801,530.99107,472.99893); -ctx.closePath(); -ctx.moveTo(250.99107000000004,752.99893); -ctx.bezierCurveTo(275.86402000000004,786.1052599999999,310.78272000000004,811.21984,351.20982000000004,823.87393); -ctx.bezierCurveTo(352.19252000000006,812.2756499999999,356.47693000000004,801.61852,363.11607000000004,792.84268); -ctx.bezierCurveTo(321.11956000000004,791.21726,282.46387000000004,776.64461,250.99107000000004,752.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(330.99107,780.39343); -ctx.bezierCurveTo(353.16121999999996,780.39343,371.13367,763.9635099999999,371.13367,743.6961799999999); -ctx.bezierCurveTo(371.13367,742.58201,371.07697,741.48232,370.97059,740.39343); -ctx.bezierCurveTo(369.14252,759.1119,351.94243,773.78793,330.99107000000004,773.78793); -ctx.bezierCurveTo(310.03970000000004,773.78793,292.83962,759.1119,291.01155000000006,740.39343); -ctx.bezierCurveTo(290.90521000000007,741.48232,290.8484700000001,742.58201,290.8484700000001,743.6961799999999); -ctx.bezierCurveTo(290.8484700000001,763.9635099999999,308.82092000000006,780.3934299999999,330.9910700000001,780.3934299999999); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(530.99107,606.99893); -ctx.bezierCurveTo(553.1612200000001,606.99893,571.13367,590.5690099999999,571.13367,570.30168); -ctx.bezierCurveTo(571.13367,569.1875100000001,571.0769700000001,568.0878200000001,570.97059,566.9989300000001); -ctx.bezierCurveTo(569.14252,585.7174000000001,551.9424300000001,600.3934300000001,530.99107,600.3934300000001); -ctx.bezierCurveTo(510.03970000000004,600.3934300000001,492.83962,585.7174000000001,491.01155000000006,566.9989300000001); -ctx.bezierCurveTo(490.90521000000007,568.0878200000001,490.8484700000001,569.1875100000001,490.8484700000001,570.30168); -ctx.bezierCurveTo(490.8484700000001,590.56901,508.82092000000006,606.99893,530.99107,606.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(290.99107,606.99893); -ctx.bezierCurveTo(313.16121999999996,606.99893,331.13367,590.5690099999999,331.13367,570.30168); -ctx.bezierCurveTo(331.13367,569.1875100000001,331.07697,568.0878200000001,330.97059,566.9989300000001); -ctx.bezierCurveTo(329.14252,585.7174000000001,311.94243,600.3934300000001,290.99107000000004,600.3934300000001); -ctx.bezierCurveTo(270.03970000000004,600.3934300000001,252.83962000000002,585.7174000000001,251.01155000000003,566.9989300000001); -ctx.bezierCurveTo(250.90521000000004,568.0878200000001,250.84847000000002,569.1875100000001,250.84847000000002,570.30168); -ctx.bezierCurveTo(250.84847000000002,590.56901,268.82092,606.99893,290.99107000000004,606.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(410.99107,700.39343); -ctx.bezierCurveTo(444.23506999999995,700.39343,471.18464,675.74855,471.18464,645.34755); -ctx.bezierCurveTo(471.18464,643.6763,471.09964,642.02676,470.94010000000003,640.39343); -ctx.bezierCurveTo(468.19892000000004,668.47114,442.4075,690.48518,410.99107000000004,690.48518); -ctx.bezierCurveTo(379.57463,690.48518,353.78322000000003,668.47114,351.04204000000004,640.39343); -ctx.bezierCurveTo(350.88258,642.02676,350.79750000000007,643.6763,350.79750000000007,645.34755); -ctx.bezierCurveTo(350.79750000000007,675.7485499999999,377.74707000000006,700.39343,410.9910700000001,700.39343); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(379.52232,680.31143); -ctx.bezierCurveTo(369.29332,669.55083,362.99107,655.01762,362.99107,638.99893); -ctx.bezierCurveTo(362.99107,605.86185,389.85398999999995,578.99893,422.99107,578.99893); -ctx.bezierCurveTo(432.90058,578.99893,442.2231,581.43242,450.45982,585.68643); -ctx.bezierCurveTo(439.5286,574.18711,424.10945999999996,566.99893,406.99107,566.99893); -ctx.bezierCurveTo(373.85398999999995,566.99893,346.99107,593.86185,346.99107,626.99893); -ctx.bezierCurveTo(346.99107,650.22651,360.21569999999997,670.34016,379.52232,680.31143); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(385.52232,490.31143); -ctx.bezierCurveTo(375.29332,479.55082999999996,368.99107,465.01761999999997,368.99107,448.99893); -ctx.bezierCurveTo(368.99107,415.86185,395.85398999999995,388.99893,428.99107,388.99893); -ctx.bezierCurveTo(438.90058,388.99893,448.2231,391.43242,456.45982,395.68643); -ctx.bezierCurveTo(445.5286,384.18710999999996,430.10945999999996,376.99893,412.99107,376.99893); -ctx.bezierCurveTo(379.85398999999995,376.99893,352.99107,403.86184999999995,352.99107,436.99893); -ctx.bezierCurveTo(352.99107,460.22650999999996,366.21569999999997,480.34015999999997,385.52232,490.31143); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(410.99107,496.90718); -ctx.bezierCurveTo(444.23506999999995,496.90718,471.18464,472.2623,471.18464,441.86129999999997); -ctx.bezierCurveTo(471.18464,440.19005,471.09964,438.54051,470.94010000000003,436.90718); -ctx.bezierCurveTo(468.19892000000004,464.98489,442.4075,486.99893,410.99107000000004,486.99893); -ctx.bezierCurveTo(379.57463,486.99893,353.78322000000003,464.98488999999995,351.04204000000004,436.90718); -ctx.bezierCurveTo(350.88258,438.54051,350.79750000000007,440.19005,350.79750000000007,441.86129999999997); -ctx.bezierCurveTo(350.79750000000007,472.2623,377.74707000000006,496.90718,410.9910700000001,496.90718); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(385.52232,880.31143); -ctx.bezierCurveTo(375.29332,869.55083,368.99107,855.01762,368.99107,838.99893); -ctx.bezierCurveTo(368.99107,805.86185,395.85398999999995,778.99893,428.99107,778.99893); -ctx.bezierCurveTo(438.90058,778.99893,448.2231,781.43242,456.45982,785.68643); -ctx.bezierCurveTo(445.5286,774.18711,430.10945999999996,766.99893,412.99107,766.99893); -ctx.bezierCurveTo(379.85398999999995,766.99893,352.99107,793.86185,352.99107,826.99893); -ctx.bezierCurveTo(352.99107,850.22651,366.21569999999997,870.34016,385.52232,880.31143); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(214.99107,572.99893); -ctx.bezierCurveTo(181.85399,572.99893,154.99107,599.86185,154.99107,632.99893); -ctx.bezierCurveTo(154.99107,656.22651,168.2157,676.34016,187.52232,686.31143); -ctx.bezierCurveTo(177.29332,675.55083,170.99107,661.01762,170.99107,644.99893); -ctx.bezierCurveTo(170.99107,616.5388399999999,190.81059000000002,592.72182,217.39732,586.56143); -ctx.bezierCurveTo(218.55700000000002,582.09924,219.88045,577.67801,221.33482,573.34268); -ctx.bezierCurveTo(219.25357,573.12367,217.13087000000002,572.99893,214.99107,572.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(610.99107,572.99893); -ctx.bezierCurveTo(608.53101,572.99893,606.12354,573.18,603.74107,573.46768); -ctx.bezierCurveTo(605.0957900000001,578.3556199999999,606.25589,583.31197,607.24107,588.34268); -ctx.bezierCurveTo(613.4279,586.18599,620.06901,584.99893,626.99107,584.99893); -ctx.bezierCurveTo(636.90058,584.99893,646.2231,587.43242,654.45982,591.68643); -ctx.bezierCurveTo(643.5286,580.18711,628.10946,572.99893,610.99107,572.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(270.40757,590.02506); -ctx.bezierCurveTo(263.48731000000004,583.2801400000001,259.22363,574.1704900000001,259.22363,564.12971); -ctx.bezierCurveTo(259.22363,543.3588500000001,277.39728,526.5207300000001,299.81559000000004,526.5207300000001); -ctx.bezierCurveTo(306.51970000000006,526.5207300000001,312.82669000000004,528.0460800000001,318.39911000000006,530.71256); -ctx.bezierCurveTo(311.0037700000001,523.5046000000001,300.5722200000001,518.9989300000001,288.99107000000004,518.9989300000001); -ctx.bezierCurveTo(266.57276,518.9989300000001,248.39911000000004,535.8370500000001,248.39911000000004,556.6079100000001); -ctx.bezierCurveTo(248.39911000000004,571.1673400000001,257.34600000000006,583.7749000000001,270.40757,590.02506); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(509.82696,588.84012); -ctx.bezierCurveTo(503.02601999999996,582.03508,498.83585,572.84422,498.83585,562.71395); -ctx.bezierCurveTo(498.83585,541.75794,516.69616,524.76973,538.7279599999999,524.76973); -ctx.bezierCurveTo(545.31648,524.76973,551.51473,526.30868,556.9910699999999,528.99893); -ctx.bezierCurveTo(549.7232399999999,521.72672,539.4715399999999,517.18089,528.0900599999999,517.18089); -ctx.bezierCurveTo(506.0582699999999,517.18089,488.19795999999985,534.1691,488.19795999999985,555.1251); -ctx.bezierCurveTo(488.19795999999985,569.81431,496.9905899999998,582.5342499999999,509.8269599999999,588.84012); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(249.11607,744.46768); -ctx.bezierCurveTo(239.42177,750.46789,232.99107,761.00366,232.99107,772.99893); -ctx.bezierCurveTo(232.99107,786.0855399999999,240.67045000000002,797.41228,251.86607,803.03018); -ctx.bezierCurveTo(245.93443000000002,796.96757,242.27232,788.77399,242.27232,779.74893); -ctx.bezierCurveTo(242.27232,768.88478,247.54392,759.24582,255.74107,753.06143); -ctx.bezierCurveTo(253.45899,750.25464,251.24597,747.3976,249.11607,744.46768); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(572.05357,748.21768); -ctx.bezierCurveTo(571.2613600000001,749.2555,570.45924,750.28971,569.64732,751.31143); -ctx.bezierCurveTo(573.66413,751.8387799999999,577.4639400000001,753.04166,580.92857,754.78018); -ctx.bezierCurveTo(578.36622,752.16126,575.3596,749.93576,572.05357,748.21768); -ctx.closePath(); -ctx.moveTo(530.45982,788.87393); -ctx.bezierCurveTo(528.51967,790.28432,526.54551,791.65748,524.55357,792.99893); -ctx.bezierCurveTo(527.85458,799.46132,533.17976,804.78457,539.77232,808.09268); -ctx.bezierCurveTo(534.7460100000001,802.9553999999999,531.37795,796.27958,530.45982,788.87393); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(185, 185, 185, 0.68627)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(490.99107,780.99893); -ctx.bezierCurveTo(513.16122,780.99893,531.1336699999999,764.5690099999999,531.1336699999999,744.30168); -ctx.bezierCurveTo(531.1336699999999,743.1875100000001,531.07697,742.0878200000001,530.9705899999999,740.9989300000001); -ctx.bezierCurveTo(529.1425199999999,759.7174000000001,511.9424299999999,774.3934300000001,490.9910699999999,774.3934300000001); -ctx.bezierCurveTo(470.0396999999999,774.3934300000001,452.8396199999999,759.7174000000001,451.01154999999994,740.9989300000001); -ctx.bezierCurveTo(450.90520999999995,742.0878200000001,450.84846999999996,743.1875100000001,450.84846999999996,744.30168); -ctx.bezierCurveTo(450.84846999999996,764.56901,468.82091999999994,780.99893,490.99107,780.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(252.5773,518.27473); -ctx.bezierCurveTo(246.64565000000002,512.21212,242.99107,504.02398999999997,242.99107,494.99893); -ctx.bezierCurveTo(242.99107,476.32923,258.56848,461.19444,277.78418,461.19444); -ctx.bezierCurveTo(283.53056,461.19444,288.93655,462.56549,293.71290999999997,464.96223); -ctx.bezierCurveTo(287.37404999999995,458.48341999999997,278.43271999999996,454.43354,268.50602,454.43354); -ctx.bezierCurveTo(249.29031999999998,454.43354,233.71290999999997,469.56833,233.71290999999997,488.23803); -ctx.bezierCurveTo(233.71290999999997,501.32464,241.38166999999996,512.65684,252.57729999999998,518.27473); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(550.99107,456.99893); -ctx.bezierCurveTo(541.15601,456.99893,532.2878900000001,460.96844,525.95982,467.34268); -ctx.bezierCurveTo(529.09436,469.54866,532.14881,471.83973999999995,535.14732,474.21768); -ctx.bezierCurveTo(541.4817800000001,467.78294999999997,550.38418,463.74893,560.27232,463.74893); -ctx.bezierCurveTo(566.0187000000001,463.74893,571.43347,465.13343999999995,576.20982,467.53018); -ctx.bezierCurveTo(569.87097,461.05136999999996,560.91777,456.99893,550.99107,456.99893); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(310.12323,762.27473); -ctx.bezierCurveTo(303.07660999999996,756.21629,298.73508,748.0337999999999,298.73508,739.01495); -ctx.bezierCurveTo(298.73508,720.35811,317.24055999999996,705.23373,340.06822999999997,705.23373); -ctx.bezierCurveTo(346.89475,705.23373,353.3169,706.60384,358.99107,708.9989300000001); -ctx.bezierCurveTo(351.4607,702.5245800000001,340.83867,698.4774900000001,329.04605999999995,698.4774900000001); -ctx.bezierCurveTo(306.2184,698.4774900000001,287.71290999999997,713.6018600000001,287.71290999999997,732.2587100000001); -ctx.bezierCurveTo(287.71290999999997,745.33631,296.82316,756.6607,310.12323,762.2747300000001); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.save(); -ctx.fillStyle = "rgba(255, 255, 255, 0.77647)"; -ctx.strokeStyle = "rgba(0, 0, 0, 0.0)"; -ctx.beginPath(); -ctx.moveTo(470.75204,762.27473); -ctx.bezierCurveTo(463.5077,756.21629,459.04435,748.0337999999999,459.04435,739.01495); -ctx.bezierCurveTo(459.04435,720.35811,478.06908,705.23373,501.53727000000003,705.23373); -ctx.bezierCurveTo(508.55534000000006,705.23373,515.15769,706.60384,520.99107,708.9989300000001); -ctx.bezierCurveTo(513.2494,702.5245800000001,502.32933,698.4774900000001,490.20583000000005,698.4774900000001); -ctx.bezierCurveTo(466.73764000000006,698.4774900000001,447.7129100000001,713.6018600000001,447.7129100000001,732.2587100000001); -ctx.bezierCurveTo(447.7129100000001,745.33631,457.0787900000001,756.6607,470.7520400000001,762.2747300000001); -ctx.closePath(); -ctx.fill(); -ctx.stroke(); -ctx.restore(); -ctx.restore(); -ctx.restore(); -}; -*/ diff --git a/pause_state.js b/pause_state.js deleted file mode 100644 index 30e7767..0000000 --- a/pause_state.js +++ /dev/null @@ -1,121 +0,0 @@ -var pause_state = function (p, prev_state) { - - // object to return - var obj = game_state(p); - obj.set_previous_state(prev_state); - - // --- private variables --- - - // Buttons - // Have a rectangle representing their position and - // a state to go to when pressed - var button_x = p.width / 2; - var button_top = 200; - var button_sep = 60; - - var button_style = { - text_size: 14, - text_align: p.LEFT, - text_x_offset: 25, - width: 120, - height: 50, - }; - - - var continue_button = button(p, { - state : function() { - sounds.play_button_click(); - return prev_state; - }, - rect : { - pos : new p.PVector(button_x, button_top), - //text: "Continue", - image: "continue.png", - width: 120, - height: 50 - //image_x_offset: 5, - //style: button_style - } - }); - - var options_button = button(p, { - state : function() { - sounds.play_button_click(); - return options_state(p, obj); - }, - rect : { - pos : new p.PVector(button_x, button_top+button_sep), - //text: "Settings", - image: "settings.png", - //style: button_style - } - }); - - var help_button = button(p, { - state : function() { - sounds.play_button_click(); - return help_state(p, obj); - }, - rect : { - pos : new p.PVector(button_x, button_top+2*button_sep), - //text: "Instructions", - //text_x_offset: 10, - image: "instructions.png", - //image_x_offset: 3, - //style: button_style - } - }); - - var quit_button = button(p, { - state : function() { - sounds.play_button_click(); - return splash_state(p); - }, - rect : { - pos : new p.PVector(button_x, button_top+3*button_sep), - //text: "Quit", - //text_x_offset: -5, - image: "quit.png", - //image_x_offset: -5, - //style: button_style - } - }); - - //Not ordered - var all_buttons = [ continue_button, options_button, - help_button, quit_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "pause"; - }; - - obj.update = function() { - //do nothing - }; - - obj.render = function() { - p.noStroke(); - p.fill(0, 150); - p.rectMode(p.CORNER); - p.rect(0, 0, p.width, p.height); - - p.fill(255); - p.textSize(40); - p.textAlign(p.CENTER); - p.text("Game Paused", p.width/2, 150); - }; - - obj.key_pressed = function(k) { - if (k === 112 || p.keyCode === 13 || p.keyCode === 27) { //p, enter, esc - obj.exit_state();; - } - }; - - obj.get_all_buttons = function() { - return all_buttons; - }; - - return obj; -}; diff --git a/php_functions.php b/php_functions.php deleted file mode 100644 index ac9629e..0000000 --- a/php_functions.php +++ /dev/null @@ -1,104 +0,0 @@ - - -var g_soundDataMap = -{ - "cell_fire" : "", - "cell_infect" : "", - "macrophage_infect" : "", - "level_up" : "", - "kill" : "", - "buttonmain" : "", - "buttonback" : "", - "TextPopUp" : "", - "cell_firemp3" : "", - "cell_infectmp3" : "", - "macrophage_infectmp3" : "", - "level_upmp3" : "", - "killmp3" : "", - "buttonmainmp3" : "", - "buttonbackmp3" : "", - "TextPopUpmp3" : "", -}; - -/* -Not working -var dynamic_div_tag = null; -// Jplayer instances - -*/ - -//IMAGES - - -//var image_list = []; -//var g_infected_cell_images = []; -//var g_empty_cell_images = []; - -// to be used in image_manager -all_image_files = {}; - - - diff --git a/processing-1.0.0.js b/processing-1.0.0.js deleted file mode 100644 index 605223f..0000000 --- a/processing-1.0.0.js +++ /dev/null @@ -1,18013 +0,0 @@ -/* - - P R O C E S S I N G . J S - 1.0.0 - a port of the Processing visualization language - - License : MIT - Developer : John Resig: http://ejohn.org - Web Site : http://processingjs.org - Java Version : http://processing.org - Github Repo. : http://github.com/jeresig/processing-js - Bug Tracking : http://processing-js.lighthouseapp.com - Mozilla POW! : http://wiki.Mozilla.org/Education/Projects/ProcessingForTheWeb - Maintained by : Seneca: http://zenit.senecac.on.ca/wiki/index.php/Processing.js - Hyper-Metrix: http://hyper-metrix.com/#Processing - BuildingSky: http://weare.buildingsky.net/pages/processing-js - - */ - -(function() { - - var undef; // intentionally left undefined - - var ajax = function ajax(url) { - var xhr = new XMLHttpRequest(); - xhr.open("GET", url, false); - xhr.setRequestHeader("If-Modified-Since", "Fri, 01 Jan 1960 00:00:00 GMT"); - xhr.send(null); - // failed request? - if (xhr.status !== 200 && xhr.status !== 0) { throw ("XMLHttpRequest failed, status code " + xhr.status); } - return xhr.responseText; - }; - - /* Browsers fixes start */ - function fixReplaceByRegExp() { - var re = /t/g; - if ("t".replace(re,"") !== null && re.exec("t")) { - return; // it is not necessary - } - var _ie_replace = String.prototype.replace; - String.prototype.replace = function(searchValue, repaceValue) { - var result = _ie_replace.apply(this, arguments); - if (searchValue instanceof RegExp && searchValue.global) { - searchValue.lastIndex = 0; - } - return result; - }; - } - - function fixMatchByRegExp() { - var re = /t/g; - if ("t".match(re) !== null && re.exec("t")) { - return; // it is not necessary - } - var _ie_match = String.prototype.match; - String.prototype.match = function(searchValue) { - var result = _ie_match.apply(this, arguments); - if(searchValue instanceof RegExp && searchValue.global) { - searchValue.lastIndex = 0; - } - return result; - }; - } - fixReplaceByRegExp(); - fixMatchByRegExp(); - - (function fixOperaCreateImageData() { - try { - if (!("createImageData" in CanvasRenderingContext2D.prototype)) { - CanvasRenderingContext2D.prototype.createImageData = function (sw, sh) { - return new ImageData(sw, sh); - }; - } - } catch(e) {} - }()); - /* Browsers fixes end */ - - var PConstants = { - X: 0, - Y: 1, - Z: 2, - - R: 3, - G: 4, - B: 5, - A: 6, - - U: 7, - V: 8, - - NX: 9, - NY: 10, - NZ: 11, - - EDGE: 12, - - // Stroke - SR: 13, - SG: 14, - SB: 15, - SA: 16, - - SW: 17, - - // Transformations (2D and 3D) - TX: 18, - TY: 19, - TZ: 20, - - VX: 21, - VY: 22, - VZ: 23, - VW: 24, - - // Material properties - AR: 25, - AG: 26, - AB: 27, - - DR: 3, - DG: 4, - DB: 5, - DA: 6, - - SPR: 28, - SPG: 29, - SPB: 30, - - SHINE: 31, - - ER: 32, - EG: 33, - EB: 34, - - BEEN_LIT: 35, - - VERTEX_FIELD_COUNT: 36, - - // Renderers - P2D: 1, - JAVA2D: 1, - WEBGL: 2, - P3D: 2, - OPENGL: 2, - PDF: 0, - DXF: 0, - - // Platform IDs - OTHER: 0, - WINDOWS: 1, - MAXOSX: 2, - LINUX: 3, - - EPSILON: 0.0001, - - MAX_FLOAT: 3.4028235e+38, - MIN_FLOAT: -3.4028235e+38, - MAX_INT: 2147483647, - MIN_INT: -2147483648, - - PI: Math.PI, - TWO_PI: 2 * Math.PI, - HALF_PI: Math.PI / 2, - THIRD_PI: Math.PI / 3, - QUARTER_PI: Math.PI / 4, - - DEG_TO_RAD: Math.PI / 180, - RAD_TO_DEG: 180 / Math.PI, - - WHITESPACE: " \t\n\r\f\u00A0", - - // Color modes - RGB: 1, - ARGB: 2, - HSB: 3, - ALPHA: 4, - CMYK: 5, - - // Image file types - TIFF: 0, - TARGA: 1, - JPEG: 2, - GIF: 3, - - // Filter/convert types - BLUR: 11, - GRAY: 12, - INVERT: 13, - OPAQUE: 14, - POSTERIZE: 15, - THRESHOLD: 16, - ERODE: 17, - DILATE: 18, - - // Blend modes - REPLACE: 0, - BLEND: 1 << 0, - ADD: 1 << 1, - SUBTRACT: 1 << 2, - LIGHTEST: 1 << 3, - DARKEST: 1 << 4, - DIFFERENCE: 1 << 5, - EXCLUSION: 1 << 6, - MULTIPLY: 1 << 7, - SCREEN: 1 << 8, - OVERLAY: 1 << 9, - HARD_LIGHT: 1 << 10, - SOFT_LIGHT: 1 << 11, - DODGE: 1 << 12, - BURN: 1 << 13, - - // Color component bit masks - ALPHA_MASK: 0xff000000, - RED_MASK: 0x00ff0000, - GREEN_MASK: 0x0000ff00, - BLUE_MASK: 0x000000ff, - - // Projection matrices - CUSTOM: 0, - ORTHOGRAPHIC: 2, - PERSPECTIVE: 3, - - // Shapes - POINT: 2, - POINTS: 2, - LINE: 4, - LINES: 4, - TRIANGLE: 8, - TRIANGLES: 9, - TRIANGLE_STRIP: 10, - TRIANGLE_FAN: 11, - QUAD: 16, - QUADS: 16, - QUAD_STRIP: 17, - POLYGON: 20, - PATH: 21, - RECT: 30, - ELLIPSE: 31, - ARC: 32, - SPHERE: 40, - BOX: 41, - - GROUP: 0, - PRIMITIVE: 1, - //PATH: 21, // shared with Shape PATH - GEOMETRY: 3, - - // Shape Vertex - VERTEX: 0, - BEZIER_VERTEX: 1, - CURVE_VERTEX: 2, - BREAK: 3, - CLOSESHAPE: 4, - - // Shape closing modes - OPEN: 1, - CLOSE: 2, - - // Shape drawing modes - CORNER: 0, // Draw mode convention to use (x, y) to (width, height) - CORNERS: 1, // Draw mode convention to use (x1, y1) to (x2, y2) coordinates - RADIUS: 2, // Draw mode from the center, and using the radius - CENTER_RADIUS: 2, // Deprecated! Use RADIUS instead - CENTER: 3, // Draw from the center, using second pair of values as the diameter - DIAMETER: 3, // Synonym for the CENTER constant. Draw from the center - CENTER_DIAMETER: 3, // Deprecated! Use DIAMETER instead - - // Text vertical alignment modes - BASELINE: 0, // Default vertical alignment for text placement - TOP: 101, // Align text to the top - BOTTOM: 102, // Align text from the bottom, using the baseline - - // UV Texture coordinate modes - NORMAL: 1, - NORMALIZED: 1, - IMAGE: 2, - - // Text placement modes - MODEL: 4, - SHAPE: 5, - - // Stroke modes - SQUARE: 'butt', - ROUND: 'round', - PROJECT: 'square', - MITER: 'miter', - BEVEL: 'bevel', - - // Lighting modes - AMBIENT: 0, - DIRECTIONAL: 1, - //POINT: 2, Shared with Shape constant - SPOT: 3, - - // Key constants - - // Both key and keyCode will be equal to these values - BACKSPACE: 8, - TAB: 9, - ENTER: 10, - RETURN: 13, - ESC: 27, - DELETE: 127, - CODED: 0xffff, - - // p.key will be CODED and p.keyCode will be this value - SHIFT: 16, - CONTROL: 17, - ALT: 18, - CAPSLK: 20, - PGUP: 33, - PGDN: 34, - END: 35, - HOME: 36, - LEFT: 37, - UP: 38, - RIGHT: 39, - DOWN: 40, - INS: 45, - DEL: 46, - F1: 112, - F2: 113, - F3: 114, - F4: 115, - F5: 116, - F6: 117, - F7: 118, - F8: 119, - F9: 120, - F10: 121, - F11: 122, - F12: 123, - NUMLK: 144, - - // Cursor types - ARROW: 'default', - CROSS: 'crosshair', - HAND: 'pointer', - MOVE: 'move', - TEXT: 'text', - WAIT: 'wait', - NOCURSOR: "url('data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), auto", - - // Hints - DISABLE_OPENGL_2X_SMOOTH: 1, - ENABLE_OPENGL_2X_SMOOTH: -1, - ENABLE_OPENGL_4X_SMOOTH: 2, - ENABLE_NATIVE_FONTS: 3, - DISABLE_DEPTH_TEST: 4, - ENABLE_DEPTH_TEST: -4, - ENABLE_DEPTH_SORT: 5, - DISABLE_DEPTH_SORT: -5, - DISABLE_OPENGL_ERROR_REPORT: 6, - ENABLE_OPENGL_ERROR_REPORT: -6, - ENABLE_ACCURATE_TEXTURES: 7, - DISABLE_ACCURATE_TEXTURES: -7, - HINT_COUNT: 10, - - // PJS defined constants - SINCOS_LENGTH: parseInt(360 / 0.5, 10), - PRECISIONB: 15, // fixed point precision is limited to 15 bits!! - PRECISIONF: 1 << 15, - PREC_MAXVAL: (1 << 15) - 1, - PREC_ALPHA_SHIFT: 24 - 15, - PREC_RED_SHIFT: 16 - 15, - NORMAL_MODE_AUTO: 0, - NORMAL_MODE_SHAPE: 1, - NORMAL_MODE_VERTEX: 2, - MAX_LIGHTS: 8 - }; - - // Typed Arrays: fallback to WebGL arrays or Native JS arrays if unavailable - function setupTypedArray(name, fallback) { - // check if TypedArray exists - // typeof on Minefield and Chrome return function, typeof on Webkit returns object. - if (typeof this[name] !== "function" && typeof this[name] !== "object") { - // nope.. check if WebGLArray exists - if (typeof this[fallback] === "function") { - this[name] = this[fallback]; - } else { - // nope.. set as Native JS array - this[name] = function(obj) { - if (obj instanceof Array) { - return obj; - } else if (typeof obj === "number") { - return new Array(obj); - } - }; - } - } - } - - setupTypedArray("Float32Array", "WebGLFloatArray"); - setupTypedArray("Int32Array", "WebGLIntArray"); - setupTypedArray("Uint16Array", "WebGLUnsignedShortArray"); - setupTypedArray("Uint8Array", "WebGLUnsignedByteArray"); - - /** - * An ArrayList stores a variable number of objects. - * - * @param {int} initialCapacity optional defines the initial capacity of the list, it's empty by default - * - * @returns {ArrayList} new ArrayList object - */ - var ArrayList = (function() { - function Iterator(array) { - var index = 0; - this.hasNext = function() { - return index < array.length; - }; - - this.next = function() { - return array[index++]; - }; - - this.remove = function() { - array.splice(index, 1); - }; - } - - function ArrayList() { - var array = arguments.length === 0 ? [] : - typeof arguments[0] === 'number' ? new Array(0 | arguments[0]) : - arguments[0]; - - /** - * @member ArrayList - * ArrayList.get() Returns the element at the specified position in this list. - * - * @param {int} i index of element to return - * - * @returns {Object} the element at the specified position in this list. - */ - this.get = function(i) { - return array[i]; - }; - /** - * @member ArrayList - * ArrayList.contains() Returns true if this list contains the specified element. - * - * @param {Object} item element whose presence in this List is to be tested. - * - * @returns {boolean} true if the specified element is present; false otherwise. - */ - this.contains = function(item) { - return array.indexOf(item) !== -1; - }; - /** - * @member ArrayList - * ArrayList.add() Adds the specified element to this list. - * - * @param {int} index optional index at which the specified element is to be inserted - * @param {Object} object element to be added to the list - */ - this.add = function() { - if (arguments.length === 1) { - array.push(arguments[0]); // for add(Object) - } else if (arguments.length === 2) { - var arg0 = arguments[0]; - if (typeof arg0 === 'number') { - if (arg0 >= 0 && arg0 <= array.length) { - array.splice(arg0, 0, arguments[1]); // for add(i, Object) - } else { - throw(arg0 + " is not a valid index"); - } - } else { - throw(typeof arg0 + " is not a number"); - } - } else { - throw("Please use the proper number of parameters."); - } - }; - - /** - * @member ArrayList - * ArrayList.set() Replaces the element at the specified position in this list with the specified element. - * - * @param {int} index index of element to replace - * @param {Object} object element to be stored at the specified position - */ - this.set = function() { - if (arguments.length === 2) { - var arg0 = arguments[0]; - if (typeof arg0 === 'number') { - if (arg0 >= 0 && arg0 < array.length) { - array.splice(arg0, 1, arguments[1]); - } else { - throw(arg0 + " is not a valid index."); - } - } else { - throw(typeof arg0 + " is not a number"); - } - } else { - throw("Please use the proper number of parameters."); - } - }; - - /** - * @member ArrayList - * ArrayList.size() Returns the number of elements in this list. - * - * @returns {int} the number of elements in this list - */ - this.size = function() { - return array.length; - }; - - /** - * @member ArrayList - * ArrayList.clear() Removes all of the elements from this list. The list will be empty after this call returns. - */ - this.clear = function() { - array.length = 0; - }; - - /** - * @member ArrayList - * ArrayList.remove() Removes the element at the specified position in this list. - * Shifts any subsequent elements to the left (subtracts one from their indices). - * - * @param {int} index the index of the element to removed. - * - * @returns {Object} the element that was removed from the list - */ - this.remove = function(i) { - return array.splice(i, 1)[0]; - }; - - /** - * @member ArrayList - * ArrayList.isEmpty() Tests if this list has no elements. - * - * @returns {boolean} true if this list has no elements; false otherwise - */ - this.isEmpty = function() { - return !array.length; - }; - - /** - * @member ArrayList - * ArrayList.clone() Returns a shallow copy of this ArrayList instance. (The elements themselves are not copied.) - * - * @returns {ArrayList} a clone of this ArrayList instance - */ - this.clone = function() { - return new ArrayList(array.slice(0)); - }; - - /** - * @member ArrayList - * ArrayList.toArray() Returns an array containing all of the elements in this list in the correct order. - * - * @returns {Object[]} Returns an array containing all of the elements in this list in the correct order - */ - this.toArray = function() { - return array.slice(0); - }; - - this.iterator = function() { - return new Iterator(array); - }; - } - - return ArrayList; - }()); - - /** - * A HashMap stores a collection of objects, each referenced by a key. This is similar to an Array, only - * instead of accessing elements with a numeric index, a String is used. (If you are familiar with - * associative arrays from other languages, this is the same idea.) - * - * @param {int} initialCapacity defines the initial capacity of the map, it's 16 by default - * @param {float} loadFactor the load factor for the map, the default is 0.75 - * @param {Map} m gives the new HashMap the same mappings as this Map - */ - var HashMap = (function() { - function virtHashCode(obj) { - if (obj.constructor === String) { - var hash = 0; - for (var i = 0; i < obj.length; ++i) { - hash = (hash * 31 + obj.charCodeAt(i)) & 0xFFFFFFFF; - } - return hash; - } else if (typeof(obj) !== "object") { - return obj & 0xFFFFFFFF; - } else if ("hashCode" in obj) { - return obj.hashCode.call(obj); - } else { - if (obj.$id === undef) { - obj.$id = ((Math.floor(Math.random() * 0x10000) - 0x8000) << 16) | Math.floor(Math.random() * 0x10000); - } - return obj.$id; - } - } - - function virtEquals(obj, other) { - if (obj === null || other === null) { - return (obj === null) && (other === null); - } else if (obj.constructor === String) { - return obj === other; - } else if (typeof(obj) !== "object") { - return obj === other; - } else if ("equals" in obj) { - return obj.equals.call(obj, other); - } else { - return obj === other; - } - } - - /** - * @member HashMap - * A HashMap stores a collection of objects, each referenced by a key. This is similar to an Array, only - * instead of accessing elements with a numeric index, a String is used. (If you are familiar with - * associative arrays from other languages, this is the same idea.) - * - * @param {int} initialCapacity defines the initial capacity of the map, it's 16 by default - * @param {float} loadFactor the load factor for the map, the default is 0.75 - * @param {Map} m gives the new HashMap the same mappings as this Map - */ - function HashMap() { - if (arguments.length === 1 && arguments[0].constructor === HashMap) { - return arguments[0].clone(); - } - - var initialCapacity = arguments.length > 0 ? arguments[0] : 16; - var loadFactor = arguments.length > 1 ? arguments[1] : 0.75; - var buckets = new Array(initialCapacity); - var count = 0; - var hashMap = this; - - function ensureLoad() { - if (count <= loadFactor * buckets.length) { - return; - } - var allEntries = []; - for (var i = 0; i < buckets.length; ++i) { - if (buckets[i] !== undef) { - allEntries = allEntries.concat(buckets[i]); - } - } - buckets = new Array(buckets.length * 2); - for (var j = 0; j < allEntries.length; ++j) { - var index = virtHashCode(allEntries[j].key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - buckets[index] = bucket = []; - } - bucket.push(allEntries[j]); - } - } - - function Iterator(conversion, removeItem) { - var bucketIndex = 0; - var itemIndex = -1; - var endOfBuckets = false; - - function findNext() { - while (!endOfBuckets) { - ++itemIndex; - if (bucketIndex >= buckets.length) { - endOfBuckets = true; - } else if (buckets[bucketIndex] === undef || itemIndex >= buckets[bucketIndex].length) { - itemIndex = -1; - ++bucketIndex; - } else { - return; - } - } - } - - /* - * @member Iterator - * Checks if the Iterator has more items - */ - this.hasNext = function() { - return !endOfBuckets; - }; - - /* - * @member Iterator - * Return the next Item - */ - this.next = function() { - var result = conversion(buckets[bucketIndex][itemIndex]); - findNext(); - return result; - }; - - /* - * @member Iterator - * Remove the current item - */ - this.remove = function() { - removeItem(this.next()); - --itemIndex; - }; - - findNext(); - } - - function Set(conversion, isIn, removeItem) { - this.clear = function() { - hashMap.clear(); - }; - - this.contains = function(o) { - return isIn(o); - }; - - this.containsAll = function(o) { - var it = o.iterator(); - while (it.hasNext()) { - if (!this.contains(it.next())) { - return false; - } - } - return true; - }; - - this.isEmpty = function() { - return hashMap.isEmpty(); - }; - - this.iterator = function() { - return new Iterator(conversion, removeItem); - }; - - this.remove = function(o) { - if (this.contains(o)) { - removeItem(o); - return true; - } - return false; - }; - - this.removeAll = function(c) { - var it = c.iterator(); - var changed = false; - while (it.hasNext()) { - var item = it.next(); - if (this.contains(item)) { - removeItem(item); - changed = true; - } - } - return true; - }; - - this.retainAll = function(c) { - var it = this.iterator(); - var toRemove = []; - while (it.hasNext()) { - var entry = it.next(); - if (!c.contains(entry)) { - toRemove.push(entry); - } - } - for (var i = 0; i < toRemove.length; ++i) { - removeItem(toRemove[i]); - } - return toRemove.length > 0; - }; - - this.size = function() { - return hashMap.size(); - }; - - this.toArray = function() { - var result = new ArrayList(0); - var it = this.iterator(); - while (it.hasNext()) { - result.push(it.next()); - } - return result; - }; - } - - function Entry(pair) { - this._isIn = function(map) { - return map === hashMap && (pair.removed === undef); - }; - - this.equals = function(o) { - return virtEquals(pair.key, o.getKey()); - }; - - this.getKey = function() { - return pair.key; - }; - - this.getValue = function() { - return pair.value; - }; - - this.hashCode = function(o) { - return virtHashCode(pair.key); - }; - - this.setValue = function(value) { - var old = pair.value; - pair.value = value; - return old; - }; - } - - this.clear = function() { - count = 0; - buckets = new Array(initialCapacity); - }; - - this.clone = function() { - var map = new HashMap(); - map.putAll(this); - return map; - }; - - this.containsKey = function(key) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - return false; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - return true; - } - } - return false; - }; - - this.containsValue = function(value) { - for (var i = 0; i < buckets.length; ++i) { - var bucket = buckets[i]; - if (bucket === undef) { - continue; - } - for (var j = 0; j < bucket.length; ++j) { - if (virtEquals(bucket[j].value, value)) { - return true; - } - } - } - return false; - }; - - this.entrySet = function() { - return new Set( - - function(pair) { - return new Entry(pair); - }, - - function(pair) { - return pair.constructor === Entry && pair._isIn(hashMap); - }, - - function(pair) { - return hashMap.remove(pair.getKey()); - }); - }; - - this.get = function(key) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - return null; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - return bucket[i].value; - } - } - return null; - }; - - this.isEmpty = function() { - return count === 0; - }; - - this.keySet = function() { - return new Set( - - function(pair) { - return pair.key; - }, - - function(key) { - return hashMap.containsKey(key); - }, - - function(key) { - return hashMap.remove(key); - }); - }; - - this.put = function(key, value) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - ++count; - buckets[index] = [{ - key: key, - value: value - }]; - ensureLoad(); - return null; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - var previous = bucket[i].value; - bucket[i].value = value; - return previous; - } - } - ++count; - bucket.push({ - key: key, - value: value - }); - ensureLoad(); - return null; - }; - - this.putAll = function(m) { - var it = m.entrySet().iterator(); - while (it.hasNext()) { - var entry = it.next(); - this.put(entry.getKey(), entry.getValue()); - } - }; - - this.remove = function(key) { - var index = virtHashCode(key) % buckets.length; - var bucket = buckets[index]; - if (bucket === undef) { - return null; - } - for (var i = 0; i < bucket.length; ++i) { - if (virtEquals(bucket[i].key, key)) { - --count; - var previous = bucket[i].value; - bucket[i].removed = true; - if (bucket.length > 1) { - bucket.splice(i, 1); - } else { - buckets[index] = undef; - } - return previous; - } - } - return null; - }; - - this.size = function() { - return count; - }; - - this.values = function() { - var result = new ArrayList(0); - var it = this.entrySet().iterator(); - while (it.hasNext()) { - var entry = it.next(); - result.push(entry.getValue()); - } - return result; - }; - } - - return HashMap; - }()); - - var PVector = (function() { - function PVector(x, y, z) { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - } - - function createPVectorMethod(method) { - return function(v1, v2) { - var v = v1.get(); - v[method](v2); - return v; - }; - } - - function createSimplePVectorMethod(method) { - return function(v1, v2) { - return v1[method](v2); - }; - } - - var simplePVMethods = "dist dot cross".split(" "); - var method = simplePVMethods.length; - - PVector.angleBetween = function(v1, v2) { - return Math.acos(v1.dot(v2) / (v1.mag() * v2.mag())); - }; - - // Common vector operations for PVector - PVector.prototype = { - set: function(v, y, z) { - if (arguments.length === 1) { - this.set(v.x || v[0], v.y || v[1], v.z || v[2]); - } else { - this.x = v; - this.y = y; - this.z = z; - } - }, - get: function() { - return new PVector(this.x, this.y, this.z); - }, - mag: function() { - return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); - }, - add: function(v, y, z) { - if (arguments.length === 3) { - this.x += v; - this.y += y; - this.z += z; - } else if (arguments.length === 1) { - this.x += v.x; - this.y += v.y; - this.z += v.z; - } - }, - sub: function(v, y, z) { - if (arguments.length === 3) { - this.x -= v; - this.y -= y; - this.z -= z; - } else if (arguments.length === 1) { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z; - } - }, - mult: function(v) { - if (typeof v === 'number') { - this.x *= v; - this.y *= v; - this.z *= v; - } else if (typeof v === 'object') { - this.x *= v.x; - this.y *= v.y; - this.z *= v.z; - } - }, - div: function(v) { - if (typeof v === 'number') { - this.x /= v; - this.y /= v; - this.z /= v; - } else if (typeof v === 'object') { - this.x /= v.x; - this.y /= v.y; - this.z /= v.z; - } - }, - dist: function(v) { - var dx = this.x - v.x, - dy = this.y - v.y, - dz = this.z - v.z; - return Math.sqrt(dx * dx + dy * dy + dz * dz); - }, - dot: function(v, y, z) { - if (arguments.length === 3) { - return (this.x * v + this.y * y + this.z * z); - } else if (arguments.length === 1) { - return (this.x * v.x + this.y * v.y + this.z * v.z); - } - }, - cross: function(v) { - return new PVector(this.y * v.z - v.y * this.z, - this.z * v.x - v.z * this.x, - this.x * v.y - v.x * this.y); - }, - normalize: function() { - var m = this.mag(); - if (m > 0) { - this.div(m); - } - }, - limit: function(high) { - if (this.mag() > high) { - this.normalize(); - this.mult(high); - } - }, - heading2D: function() { - return (-Math.atan2(-this.y, this.x)); - }, - toString: function() { - return "[" + this.x + ", " + this.y + ", " + this.z + "]"; - }, - array: function() { - return [this.x, this.y, this.z]; - } - }; - - while (method--) { - PVector[simplePVMethods[method]] = createSimplePVectorMethod(simplePVMethods[method]); - } - - for (method in PVector.prototype) { - if (PVector.prototype.hasOwnProperty(method) && !PVector.hasOwnProperty(method)) { - PVector[method] = createPVectorMethod(method); - } - } - - return PVector; - }()); - - // Building defaultScope. Changing of the prototype protects - // internal Processing code from the changes in defaultScope - function DefaultScope() {} - DefaultScope.prototype = PConstants; - - var defaultScope = new DefaultScope(); - defaultScope.ArrayList = ArrayList; - defaultScope.HashMap = HashMap; - defaultScope.PVector = PVector; - //defaultScope.PImage = PImage; // TODO - //defaultScope.PShape = PShape; // TODO - //defaultScope.PShapeSVG = PShapeSVG; // TODO - - var Processing = this.Processing = function Processing(curElement, aCode) { - // Previously we allowed calling Processing as a func instead of ctor, but no longer. - if (!(this instanceof Processing)) { - throw("called Processing constructor as if it were a function: missing 'new'."); - } - - // When something new is added to "p." it must also be added to the "names" array. - // The names array contains the names of everything that is inside "p." - var p = this; - - // PJS specific (non-p5) methods and properties to externalize - p.externals = { - canvas: curElement, - context: undef, - sketch: undef, - onblur: function() {}, - onfocus: function() {} - }; - - p.name = 'Processing.js Instance'; // Set Processing defaults / environment variables - p.use3DContext = false; // default '2d' canvas context - - /** - * Confirms if a Processing program is "focused", meaning that it is - * active and will accept input from mouse or keyboard. This variable - * is "true" if it is focused and "false" if not. This variable is - * often used when you want to warn people they need to click on the - * browser before it will work. - */ - p.focused = true; - p.breakShape = false; - - // Glyph path storage for textFonts - p.glyphTable = {}; - - // Global vars for tracking mouse position - p.pmouseX = 0; - p.pmouseY = 0; - p.mouseX = 0; - p.mouseY = 0; - p.mouseButton = 0; - p.mouseScroll = 0; - - // Undefined event handlers to be replaced by user when needed - p.mouseClicked = undef; - p.mouseDragged = undef; - p.mouseMoved = undef; - p.mousePressed = undef; - p.mouseReleased = undef; - p.mouseScrolled = undef; - p.key = undef; - p.keyCode = undef; - p.keyPressed = function(){}; // needed to remove function checks - p.keyReleased = function(){}; - p.keyTyped = function(){}; - p.draw = undef; - p.setup = undef; - - // Remapped vars - p.__mousePressed = false; - p.__keyPressed = false; - p.__frameRate = 0; - - // The current animation frame - p.frameCount = 0; - - // The height/width of the canvas - p.width = curElement.width - 0; - p.height = curElement.height - 0; - - p.defineProperty = function(obj, name, desc) { - if("defineProperty" in Object) { - Object.defineProperty(obj, name, desc); - } else { - if (desc.hasOwnProperty("get")) { - obj.__defineGetter__(name, desc.get); - } - if (desc.hasOwnProperty("set")) { - obj.__defineSetter__(name, desc.set); - } - } - }; - - // "Private" variables used to maintain state - var curContext, - curSketch, - online = true, - doFill = true, - fillStyle = [1.0, 1.0, 1.0, 1.0], - currentFillColor = 0xFFFFFFFF, - isFillDirty = true, - doStroke = true, - strokeStyle = [0.8, 0.8, 0.8, 1.0], - currentStrokeColor = 0xFFFDFDFD, - isStrokeDirty = true, - lineWidth = 1, - loopStarted = false, - doLoop = true, - looping = 0, - curRectMode = PConstants.CORNER, - curEllipseMode = PConstants.CENTER, - normalX = 0, - normalY = 0, - normalZ = 0, - normalMode = PConstants.NORMAL_MODE_AUTO, - inDraw = false, - curFrameRate = 60, - curCursor = PConstants.ARROW, - oldCursor = curElement.style.cursor, - curMsPerFrame = 1, - curShape = PConstants.POLYGON, - curShapeCount = 0, - curvePoints = [], - curTightness = 0, - curveDet = 20, - curveInited = false, - bezDetail = 20, - colorModeA = 255, - colorModeX = 255, - colorModeY = 255, - colorModeZ = 255, - pathOpen = false, - mouseDragging = false, - curColorMode = PConstants.RGB, - curTint = null, - curTextSize = 12, - curTextFont = "Arial", - curTextLeading = 14, - getLoaded = false, - start = new Date().getTime(), - timeSinceLastFPS = start, - framesSinceLastFPS = 0, - textcanvas, - curveBasisMatrix, - curveToBezierMatrix, - curveDrawMatrix, - bezierDrawMatrix, - bezierBasisInverse, - bezierBasisMatrix, - // Keys and Keystrokes - firstCodedDown = true, // first coded key stroke - firstEDGKeyDown = true, // first Enter - Delete Google key stroke - firstEDMKeyDown = true, // first Enter - Delete Mozilla key stroke - firstMKeyDown = true, // first Mozilla key stroke - firstGKeyDown = true, // first Google key stroke - gRefire = false, // Google refire - curContextCache = { attributes: {}, locations: {} }, - // Shaders - programObject3D, - programObject2D, - programObjectUnlitShape, - boxBuffer, - boxNormBuffer, - boxOutlineBuffer, - rectBuffer, - rectNormBuffer, - sphereBuffer, - lineBuffer, - fillBuffer, - fillColorBuffer, - strokeColorBuffer, - pointBuffer, - shapeTexVBO, - canTex, // texture for createGraphics - textTex, // texture for 3d tex - curTexture = {width:0,height:0}, - curTextureMode = PConstants.IMAGE, - usingTexture = false, - textBuffer, - textureBuffer, - indexBuffer, - // Text alignment - horizontalTextAlignment = PConstants.LEFT, - verticalTextAlignment = PConstants.BASELINE, - baselineOffset = 0.2, // percent - tMode = PConstants.MODEL, - // Pixels cache - originalContext, - proxyContext = null, - isContextReplaced = false, - setPixelsCached, - maxPixelsCached = 1000, - codedKeys = [ PConstants.SHIFT, PConstants.CONTROL, PConstants.ALT, PConstants.CAPSLK, PConstants.PGUP, PConstants.PGDN, - PConstants.END, PConstants.HOME, PConstants.LEFT, PConstants.UP, PConstants.RIGHT, PConstants.DOWN, PConstants.NUMLK, - PConstants.INS, PConstants.F1, PConstants.F2, PConstants.F3, PConstants.F4, PConstants.F5, PConstants.F6, PConstants.F7, - PConstants.F8, PConstants.F9, PConstants.F10, PConstants.F11, PConstants.F12 ]; - - // Get padding and border style widths for mouse offsets - var stylePaddingLeft, stylePaddingTop, styleBorderLeft, styleBorderTop; - - if (document.defaultView && document.defaultView.getComputedStyle) { - stylePaddingLeft = parseInt(document.defaultView.getComputedStyle(curElement, null)['paddingLeft'], 10) || 0; - stylePaddingTop = parseInt(document.defaultView.getComputedStyle(curElement, null)['paddingTop'], 10) || 0; - styleBorderLeft = parseInt(document.defaultView.getComputedStyle(curElement, null)['borderLeftWidth'], 10) || 0; - styleBorderTop = parseInt(document.defaultView.getComputedStyle(curElement, null)['borderTopWidth'], 10) || 0; - } - - // User can only have MAX_LIGHTS lights - var lightCount = 0; - - //sphere stuff - var sphereDetailV = 0, - sphereDetailU = 0, - sphereX = [], - sphereY = [], - sphereZ = [], - sinLUT = new Array(PConstants.SINCOS_LENGTH), - cosLUT = new Array(PConstants.SINCOS_LENGTH), - sphereVerts, - sphereNorms; - - // Camera defaults and settings - var cam, - cameraInv, - forwardTransform, - reverseTransform, - modelView, - modelViewInv, - userMatrixStack, - inverseCopy, - projection, - manipulatingCamera = false, - frustumMode = false, - cameraFOV = 60 * (Math.PI / 180), - cameraX = curElement.width / 2, - cameraY = curElement.height / 2, - cameraZ = cameraY / Math.tan(cameraFOV / 2), - cameraNear = cameraZ / 10, - cameraFar = cameraZ * 10, - cameraAspect = curElement.width / curElement.height; - - var vertArray = [], - curveVertArray = [], - curveVertCount = 0, - isCurve = false, - isBezier = false, - firstVert = true; - - //PShape stuff - var curShapeMode = PConstants.CORNER; - - var colors = { - aliceblue: "#f0f8ff", - antiquewhite: "#faebd7", - aqua: "#00ffff", - aquamarine: "#7fffd4", - azure: "#f0ffff", - beige: "#f5f5dc", - bisque: "#ffe4c4", - black: "#000000", - blanchedalmond: "#ffebcd", - blue: "#0000ff", - blueviolet: "#8a2be2", - brown: "#a52a2a", - burlywood: "#deb887", - cadetblue: "#5f9ea0", - chartreuse: "#7fff00", - chocolate: "#d2691e", - coral: "#ff7f50", - cornflowerblue: "#6495ed", - cornsilk: "#fff8dc", - crimson: "#dc143c", - cyan: "#00ffff", - darkblue: "#00008b", - darkcyan: "#008b8b", - darkgoldenrod: "#b8860b", - darkgray: "#a9a9a9", - darkgreen: "#006400", - darkkhaki: "#bdb76b", - darkmagenta: "#8b008b", - darkolivegreen: "#556b2f", - darkorange: "#ff8c00", - darkorchid: "#9932cc", - darkred: "#8b0000", - darksalmon: "#e9967a", - darkseagreen: "#8fbc8f", - darkslateblue: "#483d8b", - darkslategray: "#2f4f4f", - darkturquoise: "#00ced1", - darkviolet: "#9400d3", - deeppink: "#ff1493", - deepskyblue: "#00bfff", - dimgray: "#696969", - dodgerblue: "#1e90ff", - firebrick: "#b22222", - floralwhite: "#fffaf0", - forestgreen: "#228b22", - fuchsia: "#ff00ff", - gainsboro: "#dcdcdc", - ghostwhite: "#f8f8ff", - gold: "#ffd700", - goldenrod: "#daa520", - gray: "#808080", - green: "#008000", - greenyellow: "#adff2f", - honeydew: "#f0fff0", - hotpink: "#ff69b4", - indianred: "#cd5c5c", - indigo: "#4b0082", - ivory: "#fffff0", - khaki: "#f0e68c", - lavender: "#e6e6fa", - lavenderblush: "#fff0f5", - lawngreen: "#7cfc00", - lemonchiffon: "#fffacd", - lightblue: "#add8e6", - lightcoral: "#f08080", - lightcyan: "#e0ffff", - lightgoldenrodyellow: "#fafad2", - lightgrey: "#d3d3d3", - lightgreen: "#90ee90", - lightpink: "#ffb6c1", - lightsalmon: "#ffa07a", - lightseagreen: "#20b2aa", - lightskyblue: "#87cefa", - lightslategray: "#778899", - lightsteelblue: "#b0c4de", - lightyellow: "#ffffe0", - lime: "#00ff00", - limegreen: "#32cd32", - linen: "#faf0e6", - magenta: "#ff00ff", - maroon: "#800000", - mediumaquamarine: "#66cdaa", - mediumblue: "#0000cd", - mediumorchid: "#ba55d3", - mediumpurple: "#9370d8", - mediumseagreen: "#3cb371", - mediumslateblue: "#7b68ee", - mediumspringgreen: "#00fa9a", - mediumturquoise: "#48d1cc", - mediumvioletred: "#c71585", - midnightblue: "#191970", - mintcream: "#f5fffa", - mistyrose: "#ffe4e1", - moccasin: "#ffe4b5", - navajowhite: "#ffdead", - navy: "#000080", - oldlace: "#fdf5e6", - olive: "#808000", - olivedrab: "#6b8e23", - orange: "#ffa500", - orangered: "#ff4500", - orchid: "#da70d6", - palegoldenrod: "#eee8aa", - palegreen: "#98fb98", - paleturquoise: "#afeeee", - palevioletred: "#d87093", - papayawhip: "#ffefd5", - peachpuff: "#ffdab9", - peru: "#cd853f", - pink: "#ffc0cb", - plum: "#dda0dd", - powderblue: "#b0e0e6", - purple: "#800080", - red: "#ff0000", - rosybrown: "#bc8f8f", - royalblue: "#4169e1", - saddlebrown: "#8b4513", - salmon: "#fa8072", - sandybrown: "#f4a460", - seagreen: "#2e8b57", - seashell: "#fff5ee", - sienna: "#a0522d", - silver: "#c0c0c0", - skyblue: "#87ceeb", - slateblue: "#6a5acd", - slategray: "#708090", - snow: "#fffafa", - springgreen: "#00ff7f", - steelblue: "#4682b4", - tan: "#d2b48c", - teal: "#008080", - thistle: "#d8bfd8", - tomato: "#ff6347", - turquoise: "#40e0d0", - violet: "#ee82ee", - wheat: "#f5deb3", - white: "#ffffff", - whitesmoke: "#f5f5f5", - yellow: "#ffff00", - yellowgreen: "#9acd32" - }; - - // Stores states for pushStyle() and popStyle(). - var styleArray = new Array(0); - - // Vertices are specified in a counter-clockwise order - // triangles are in this order: back, front, right, bottom, left, top - var boxVerts = new Float32Array([ - 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, - -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, - -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, - 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, - 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, - -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, - -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, - -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, - -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5]); - - var boxOutlineVerts = new Float32Array([ - 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, - -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, - 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, - -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, - 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, - -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5]); - - var boxNorms = new Float32Array([ - 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, - 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, - 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, - 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, - -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, - 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]); - - // These verts are used for the fill and stroke using TRIANGLE_FAN and LINE_LOOP - var rectVerts = new Float32Array([0,0,0, 0,1,0, 1,1,0, 1,0,0]); - - var rectNorms = new Float32Array([0,0,-1, 0,0,-1, 0,0,-1, 0,0,-1]); - - // Vertex shader for points and lines - var vShaderSrcUnlitShape = - "varying vec4 frontColor;" + - - "attribute vec3 aVertex;" + - "attribute vec4 aColor;" + - - "uniform mat4 uView;" + - "uniform mat4 uProjection;" + - - "void main(void) {" + - " frontColor = aColor;" + - " gl_Position = uProjection * uView * vec4(aVertex, 1.0);" + - "}"; - - var fShaderSrcUnlitShape = - "#ifdef GL_ES\n" + - "precision highp float;\n" + - "#endif\n" + - - "varying vec4 frontColor;" + - - "void main(void){" + - " gl_FragColor = frontColor;" + - "}"; - - // Vertex shader for points and lines - var vertexShaderSource2D = - "varying vec4 frontColor;" + - - "attribute vec3 Vertex;" + - "attribute vec2 aTextureCoord;" + - "uniform vec4 color;" + - - "uniform mat4 model;" + - "uniform mat4 view;" + - "uniform mat4 projection;" + - "uniform float pointSize;" + - "varying vec2 vTextureCoord;"+ - - "void main(void) {" + - " gl_PointSize = pointSize;" + - " frontColor = color;" + - " gl_Position = projection * view * model * vec4(Vertex, 1.0);" + - " vTextureCoord = aTextureCoord;" + - "}"; - - var fragmentShaderSource2D = - "#ifdef GL_ES\n" + - "precision highp float;\n" + - "#endif\n" + - - "varying vec4 frontColor;" + - "varying vec2 vTextureCoord;"+ - - "uniform sampler2D uSampler;"+ - "uniform int picktype;"+ - - "void main(void){" + - " if(picktype == 0){"+ - " gl_FragColor = frontColor;" + - " }" + - " else if(picktype == 1){"+ - " float alpha = texture2D(uSampler, vTextureCoord).a;"+ - " gl_FragColor = vec4(frontColor.rgb*alpha, alpha);\n"+ - " }"+ - "}"; - - // Vertex shader for boxes and spheres - var vertexShaderSource3D = - "varying vec4 frontColor;" + - - "attribute vec3 Vertex;" + - "attribute vec3 Normal;" + - "attribute vec4 aColor;" + - "attribute vec2 aTexture;" + - "varying vec2 vTexture;" + - - "uniform vec4 color;" + - - "uniform bool usingMat;" + - "uniform vec3 specular;" + - "uniform vec3 mat_emissive;" + - "uniform vec3 mat_ambient;" + - "uniform vec3 mat_specular;" + - "uniform float shininess;" + - - "uniform mat4 model;" + - "uniform mat4 view;" + - "uniform mat4 projection;" + - "uniform mat4 normalTransform;" + - - "uniform int lightCount;" + - "uniform vec3 falloff;" + - - "struct Light {" + - " bool dummy;" + - " int type;" + - " vec3 color;" + - " vec3 position;" + - " vec3 direction;" + - " float angle;" + - " vec3 halfVector;" + - " float concentration;" + - "};" + - "uniform Light lights[8];" + - - "void AmbientLight( inout vec3 totalAmbient, in vec3 ecPos, in Light light ) {" + - // Get the vector from the light to the vertex - // Get the distance from the current vector to the light position - " float d = length( light.position - ecPos );" + - " float attenuation = 1.0 / ( falloff[0] + ( falloff[1] * d ) + ( falloff[2] * d * d ));" + " totalAmbient += light.color * attenuation;" + - "}" + - - "void DirectionalLight( inout vec3 col, in vec3 ecPos, inout vec3 spec, in vec3 vertNormal, in Light light ) {" + - " float powerfactor = 0.0;" + - " float nDotVP = max(0.0, dot( vertNormal, light.position ));" + - " float nDotVH = max(0.0, dot( vertNormal, normalize( light.position-ecPos )));" + - - " if( nDotVP != 0.0 ){" + - " powerfactor = pow( nDotVH, shininess );" + - " }" + - - " col += light.color * nDotVP;" + - " spec += specular * powerfactor;" + - "}" + - - "void PointLight( inout vec3 col, inout vec3 spec, in vec3 vertNormal, in vec3 ecPos, in vec3 eye, in Light light ) {" + - " float powerfactor;" + - - // Get the vector from the light to the vertex - " vec3 VP = light.position - ecPos;" + - - // Get the distance from the current vector to the light position - " float d = length( VP ); " + - - // Normalize the light ray so it can be used in the dot product operation. - " VP = normalize( VP );" + - - " float attenuation = 1.0 / ( falloff[0] + ( falloff[1] * d ) + ( falloff[2] * d * d ));" + - - " float nDotVP = max( 0.0, dot( vertNormal, VP ));" + - " vec3 halfVector = normalize( VP + eye );" + - " float nDotHV = max( 0.0, dot( vertNormal, halfVector ));" + - - " if( nDotVP == 0.0) {" + - " powerfactor = 0.0;" + - " }" + - " else{" + - " powerfactor = pow( nDotHV, shininess );" + - " }" + - - " spec += specular * powerfactor * attenuation;" + - " col += light.color * nDotVP * attenuation;" + - "}" + - - /* - */ - "void SpotLight( inout vec3 col, inout vec3 spec, in vec3 vertNormal, in vec3 ecPos, in vec3 eye, in Light light ) {" + - " float spotAttenuation;" + - " float powerfactor;" + - - // calculate the vector from the current vertex to the light. - " vec3 VP = light.position - ecPos; " + - " vec3 ldir = normalize( light.direction );" + - - // get the distance from the spotlight and the vertex - " float d = length( VP );" + - " VP = normalize( VP );" + - - " float attenuation = 1.0 / ( falloff[0] + ( falloff[1] * d ) + ( falloff[2] * d * d ) );" + - - // dot product of the vector from vertex to light and light direction. - " float spotDot = dot( VP, ldir );" + - - // if the vertex falls inside the cone - " if( spotDot < cos( light.angle ) ) {" + - " spotAttenuation = pow( spotDot, light.concentration );" + - " }" + - " else{" + - " spotAttenuation = 1.0;" + - " }" + - " attenuation *= spotAttenuation;" + - - " float nDotVP = max( 0.0, dot( vertNormal, VP ));" + - " vec3 halfVector = normalize( VP + eye );" + - " float nDotHV = max( 0.0, dot( vertNormal, halfVector ));" + - - " if( nDotVP == 0.0 ) {" + - " powerfactor = 0.0;" + - " }" + - " else {" + - " powerfactor = pow( nDotHV, shininess );" + - " }" + - - " spec += specular * powerfactor * attenuation;" + - " col += light.color * nDotVP * attenuation;" + - "}" + - - "void main(void) {" + - " vec3 finalAmbient = vec3( 0.0, 0.0, 0.0 );" + - " vec3 finalDiffuse = vec3( 0.0, 0.0, 0.0 );" + - " vec3 finalSpecular = vec3( 0.0, 0.0, 0.0 );" + - - " vec4 col = color;" + - " if(color[0] == -1.0){" + - " col = aColor;" + - " }" + - - " vec3 norm = vec3( normalTransform * vec4( Normal, 0.0 ) );" + - - " vec4 ecPos4 = view * model * vec4(Vertex,1.0);" + - " vec3 ecPos = (vec3(ecPos4))/ecPos4.w;" + - " vec3 eye = vec3( 0.0, 0.0, 1.0 );" + - - // If there were no lights this draw call, just use the - // assigned fill color of the shape and the specular value - " if( lightCount == 0 ) {" + - " frontColor = col + vec4(mat_specular,1.0);" + - " }" + - " else {" + - " for( int i = 0; i < lightCount; i++ ) {" + - " if( lights[i].type == 0 ) {" + - " AmbientLight( finalAmbient, ecPos, lights[i] );" + - " }" + - " else if( lights[i].type == 1 ) {" + - " DirectionalLight( finalDiffuse,ecPos, finalSpecular, norm, lights[i] );" + - " }" + - " else if( lights[i].type == 2 ) {" + - " PointLight( finalDiffuse, finalSpecular, norm, ecPos, eye, lights[i] );" + - " }" + - " else if( lights[i].type == 3 ) {" + - " SpotLight( finalDiffuse, finalSpecular, norm, ecPos, eye, lights[i] );" + - " }" + - " }" + - - " if( usingMat == false ) {" + - " frontColor = vec4( " + - " vec3(col) * finalAmbient +" + - " vec3(col) * finalDiffuse +" + - " vec3(col) * finalSpecular," + - " col[3] );" + - " }" + - " else{" + - " frontColor = vec4( " + - " mat_emissive + " + - " (vec3(col) * mat_ambient * finalAmbient) + " + - " (vec3(col) * finalDiffuse) + " + - " (mat_specular * finalSpecular), " + - " col[3] );" + - " }" + - " }" + - " vTexture.xy = aTexture.xy;" + - " gl_Position = projection * view * model * vec4( Vertex, 1.0 );" + - "}"; - - var fragmentShaderSource3D = - "#ifdef GL_ES\n" + - "precision highp float;\n" + - "#endif\n" + - - "varying vec4 frontColor;" + - - "uniform sampler2D sampler;" + - "uniform bool usingTexture;" + - "varying vec2 vTexture;" + - - // In Processing, when a texture is used, the fill color is ignored - "void main(void){" + - " if(usingTexture){" + - " gl_FragColor = vec4(texture2D(sampler, vTexture.xy));" + - " }"+ - " else{" + - " gl_FragColor = frontColor;" + - " }" + - "}"; - - //////////////////////////////////////////////////////////////////////////// - // 3D Functions - //////////////////////////////////////////////////////////////////////////// - - /* - * Sets a uniform variable in a program object to a particular - * value. Before calling this function, ensure the correct - * program object has been installed as part of the current - * rendering state by calling useProgram. - * - * On some systems, if the variable exists in the shader but isn't used, - * the compiler will optimize it out and this function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {float | Array} varValue either a scalar value or an Array - * - * @returns none - * - * @see uniformi - * @see uniformMatrix - */ - function uniformf(cacheId, programObj, varName, varValue) { - var varLocation = curContextCache.locations[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getUniformLocation(programObj, varName); - curContextCache.locations[cacheId] = varLocation; - } - // the variable won't be found if it was optimized out. - if (varLocation !== -1) { - if (varValue.length === 4) { - curContext.uniform4fv(varLocation, varValue); - } else if (varValue.length === 3) { - curContext.uniform3fv(varLocation, varValue); - } else if (varValue.length === 2) { - curContext.uniform2fv(varLocation, varValue); - } else { - curContext.uniform1f(varLocation, varValue); - } - } - } - - /** - * Sets a uniform int or int array in a program object to a particular - * value. Before calling this function, ensure the correct - * program object has been installed as part of the current - * rendering state. - * - * On some systems, if the variable exists in the shader but isn't used, - * the compiler will optimize it out and this function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {int | Array} varValue either a scalar value or an Array - * - * @returns none - * - * @see uniformf - * @see uniformMatrix - */ - function uniformi(cacheId, programObj, varName, varValue) { - var varLocation = curContextCache.locations[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getUniformLocation(programObj, varName); - curContextCache.locations[cacheId] = varLocation; - } - // the variable won't be found if it was optimized out. - if (varLocation !== -1) { - if (varValue.length === 4) { - curContext.uniform4iv(varLocation, varValue); - } else if (varValue.length === 3) { - curContext.uniform3iv(varLocation, varValue); - } else if (varValue.length === 2) { - curContext.uniform2iv(varLocation, varValue); - } else { - curContext.uniform1i(varLocation, varValue); - } - } - } - - /** - * Binds the VBO, sets the vertex attribute data for the program - * object and enables the attribute. - * - * On some systems, if the attribute exists in the shader but - * isn't used, the compiler will optimize it out and this - * function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {int} size the number of components per vertex attribute - * @param {WebGLBuffer} VBO Vertex Buffer Object - * - * @returns none - * - * @see disableVertexAttribPointer - */ - function vertexAttribPointer(cacheId, programObj, varName, size, VBO) { - var varLocation = curContextCache.attributes[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getAttribLocation(programObj, varName); - curContextCache.attributes[cacheId] = varLocation; - } - if (varLocation !== -1) { - curContext.bindBuffer(curContext.ARRAY_BUFFER, VBO); - curContext.vertexAttribPointer(varLocation, size, curContext.FLOAT, false, 0, 0); - curContext.enableVertexAttribArray(varLocation); - } - } - - /** - * Disables a program object attribute from being sent to WebGL. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName name of the attribute - * - * @returns none - * - * @see vertexAttribPointer - */ - function disableVertexAttribPointer(cacheId, programObj, varName){ - var varLocation = curContextCache.attributes[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getAttribLocation(programObj, varName); - curContextCache.attributes[cacheId] = varLocation; - } - if (varLocation !== -1) { - curContext.disableVertexAttribArray(varLocation); - } - } - - /** - * Sets the value of a uniform matrix variable in a program - * object. Before calling this function, ensure the correct - * program object has been installed as part of the current - * rendering state. - * - * On some systems, if the variable exists in the shader but - * isn't used, the compiler will optimize it out and this - * function will fail. - * - * @param {WebGLProgram} programObj program object returned from - * createProgramObject - * @param {String} varName the name of the variable in the shader - * @param {boolean} transpose must be false - * @param {Array} matrix an array of 4, 9 or 16 values - * - * @returns none - * - * @see uniformi - * @see uniformf - */ - function uniformMatrix(cacheId, programObj, varName, transpose, matrix) { - var varLocation = curContextCache.locations[cacheId]; - if(varLocation === undef) { - varLocation = curContext.getUniformLocation(programObj, varName); - curContextCache.locations[cacheId] = varLocation; - } - // the variable won't be found if it was optimized out. - if (varLocation !== -1) { - if (matrix.length === 16) { - curContext.uniformMatrix4fv(varLocation, transpose, matrix); - } else if (matrix.length === 9) { - curContext.uniformMatrix3fv(varLocation, transpose, matrix); - } else { - curContext.uniformMatrix2fv(varLocation, transpose, matrix); - } - } - } - - var imageModeCorner = function imageModeCorner(x, y, w, h, whAreSizes) { - return { - x: x, - y: y, - w: w, - h: h - }; - }; - var imageModeConvert = imageModeCorner; - - var imageModeCorners = function imageModeCorners(x, y, w, h, whAreSizes) { - return { - x: x, - y: y, - w: whAreSizes ? w : w - x, - h: whAreSizes ? h : h - y - }; - }; - - var imageModeCenter = function imageModeCenter(x, y, w, h, whAreSizes) { - return { - x: x - w / 2, - y: y - h / 2, - w: w, - h: h - }; - }; - - /** - * Creates a WebGL program object. - * - * @param {String} vetexShaderSource - * @param {String} fragmentShaderSource - * - * @returns {WebGLProgram} A program object - */ - var createProgramObject = function(curContext, vetexShaderSource, fragmentShaderSource) { - var vertexShaderObject = curContext.createShader(curContext.VERTEX_SHADER); - curContext.shaderSource(vertexShaderObject, vetexShaderSource); - curContext.compileShader(vertexShaderObject); - if (!curContext.getShaderParameter(vertexShaderObject, curContext.COMPILE_STATUS)) { - throw curContext.getShaderInfoLog(vertexShaderObject); - } - - var fragmentShaderObject = curContext.createShader(curContext.FRAGMENT_SHADER); - curContext.shaderSource(fragmentShaderObject, fragmentShaderSource); - curContext.compileShader(fragmentShaderObject); - if (!curContext.getShaderParameter(fragmentShaderObject, curContext.COMPILE_STATUS)) { - throw curContext.getShaderInfoLog(fragmentShaderObject); - } - - var programObject = curContext.createProgram(); - curContext.attachShader(programObject, vertexShaderObject); - curContext.attachShader(programObject, fragmentShaderObject); - curContext.linkProgram(programObject); - if (!curContext.getProgramParameter(programObject, curContext.LINK_STATUS)) { - throw "Error linking shaders."; - } - - return programObject; - }; - - //////////////////////////////////////////////////////////////////////////// - // Char handling - //////////////////////////////////////////////////////////////////////////// - var charMap = {}; - - var Char = p.Character = function Char(chr) { - if (typeof chr === 'string' && chr.length === 1) { - this.code = chr.charCodeAt(0); - } else { - this.code = NaN; - } - - return (charMap[this.code] === undef) ? charMap[this.code] = this : charMap[this.code]; - }; - - Char.prototype.toString = function() { - return String.fromCharCode(this.code); - }; - - Char.prototype.valueOf = function() { - return this.code; - }; - - /** - * Datatype for storing shapes. Processing can currently load and display SVG (Scalable Vector Graphics) shapes. - * Before a shape is used, it must be loaded with the loadShape() function. The shape() function is used to draw the shape to the display window. - * The PShape object contain a group of methods, linked below, that can operate on the shape data. - *

            The loadShape() method supports SVG files created with Inkscape and Adobe Illustrator. - * It is not a full SVG implementation, but offers some straightforward support for handling vector data. - * - * @param {int} family the shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY - * - * @see #shape() - * @see #loadShape() - * @see #shapeMode() - */ - var PShape = p.PShape = function(family) { - this.family = family || PConstants.GROUP; - this.visible = true; - this.style = true; - this.children = []; - this.nameTable = []; - this.params = []; - this.name = ""; - this.image = null; //type PImage - this.matrix = null; - this.kind = null; - this.close = null; - this.width = null; - this.height = null; - this.parent = null; - - /** - * PShape methods - * missing: findChild(), apply(), contains(), findChild(), getPrimitive(), getParams(), getVertex() , getVertexCount(), - * getVertexCode() , getVertexCodes() , getVertexCodeCount(), getVertexX(), getVertexY(), getVertexZ() - */ - - /** - * @member PShape - * The isVisible() function returns a boolean value "true" if the image is set to be visible, "false" if not. This is modified with the setVisible() parameter. - *

            The visibility of a shape is usually controlled by whatever program created the SVG file. - * For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator. - * - * @return {boolean} returns "true" if the image is set to be visible, "false" if not - */ - this.isVisible = function(){ - return this.visible; - }; - /** - * @member PShape - * The setVisible() function sets the shape to be visible or invisible. This is determined by the value of the visible parameter. - *

            The visibility of a shape is usually controlled by whatever program created the SVG file. - * For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator. - * - * @param {boolean} visible "false" makes the shape invisible and "true" makes it visible - */ - this.setVisible = function (visible){ - this.visible = visible; - }; - /** - * @member PShape - * The disableStyle() function disables the shape's style data and uses Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints. - * Overrides this shape's style information and uses PGraphics styles and colors. Identical to ignoreStyles(true). Also disables styles for all child shapes. - */ - this.disableStyle = function(){ - this.style = false; - for(var i = 0; i < this.children.length; i++) - { - this.children[i].disableStyle(); - } - }; - /** - * @member PShape - * The enableStyle() function enables the shape's style data and ignores Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints. - */ - this.enableStyle = function(){ - this.style = true; - for(var i = 0; i < this.children.length; i++) - { - this.children[i].enableStyle(); - } - }; - /** - * @member PShape - * The getFamily function returns the shape type - * - * @return {int} the shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY - */ - this.getFamily = function(){ - return this.family; - }; - /** - * @member PShape - * The getWidth() function gets the width of the drawing area (not necessarily the shape boundary). - */ - this.getWidth = function(){ - return this.width; - }; - /** - * @member PShape - * The getHeight() function gets the height of the drawing area (not necessarily the shape boundary). - */ - this.getHeight = function(){ - return this.height; - }; - /** - * @member PShape - * The setName() function sets the name of the shape - * - * @param {String} name the name of the shape - */ - this.setName = function(name){ - this.name = name; - }; - /** - * @member PShape - * The getName() function returns the name of the shape - * - * @return {String} the name of the shape - */ - this.getName = function(){ - return this.name; - }; - /** - * @member PShape - * Called by the following (the shape() command adds the g) - * PShape s = loadShapes("blah.svg"); - * shape(s); - */ - this.draw = function(){ - if (this.visible) { - this.pre(); - this.drawImpl(); - this.post(); - } - }; - /** - * @member PShape - * the drawImpl() function draws the SVG document. - */ - this.drawImpl = function(){ - if (this.family === PConstants.GROUP) { - this.drawGroup(); - } else if (this.family === PConstants.PRIMITIVE) { - this.drawPrimitive(); - } else if (this.family === PConstants.GEOMETRY) { - this.drawGeometry(); - } else if (this.family === PConstants.PATH) { - this.drawPath(); - } - }; - /** - * @member PShape - * The drawPath() function draws the part of the SVG document. - */ - this.drawPath = function(){ - if (this.vertices.length === 0) { return; } - - p.beginShape(); - var i; - if (this.vertexCodes.length === 0) { // each point is a simple vertex - if (this.vertices[0].length === 2) { // drawing 2D vertices - for (i = 0; i < this.vertices.length; i++) { - p.vertex(this.vertices[i][0], this.vertices[i][1]); - } - } else { // drawing 3D vertices - for (i = 0; i < this.vertices.length; i++) { - p.vertex(this.vertices[i][0], this.vertices[i][1], this.vertices[i][2]); - } - } - } else { // coded set of vertices - var index = 0; - var j; - if (this.vertices[0].length === 2) { // drawing a 2D path - for (j = 0; j < this.vertexCodes.length; j++) { - switch (this.vertexCodes[j]) { - case PConstants.VERTEX: - p.vertex(this.vertices[index][0], this.vertices[index][1]); - if ( this.vertices[index]["moveTo"] === true) { - vertArray[vertArray.length-1]["moveTo"] = true; - } else if ( this.vertices[index]["moveTo"] === false) { - vertArray[vertArray.length-1]["moveTo"] = false; - } - p.breakShape = false; - index++; - break; - case PConstants.BEZIER_VERTEX: - p.bezierVertex(this.vertices[index+0][0], this.vertices[index+0][1], - this.vertices[index+1][0], this.vertices[index+1][1], - this.vertices[index+2][0], this.vertices[index+2][1]); - index += 3; - break; - case PConstants.CURVE_VERTEX: - p.curveVertex(this.vertices[index][0], this.vertices[index][1]); - index++; - break; - case PConstants.BREAK: - p.breakShape = true; - break; - } - } - } else { // drawing a 3D path - for (j = 0; j < this.vertexCodes.length; j++) { - switch (this.vertexCodes[j]) { - case PConstants.VERTEX: - p.vertex(this.vertices[index][0], this.vertices[index][1], this.vertices[index][2]); - if (this.vertices[index]["moveTo"] === true) { - vertArray[vertArray.length-1]["moveTo"] = true; - } else if (this.vertices[index]["moveTo"] === false) { - vertArray[vertArray.length-1]["moveTo"] = false; - } - p.breakShape = false; - break; - case PConstants.BEZIER_VERTEX: - p.bezierVertex(this.vertices[index+0][0], this.vertices[index+0][1], this.vertices[index+0][2], - this.vertices[index+1][0], this.vertices[index+1][1], this.vertices[index+1][2], - this.vertices[index+2][0], this.vertices[index+2][1], this.vertices[index+2][2]); - index += 3; - break; - case PConstants.CURVE_VERTEX: - p.curveVertex(this.vertices[index][0], this.vertices[index][1], this.vertices[index][2]); - index++; - break; - case PConstants.BREAK: - p.breakShape = true; - break; - } - } - } - } - p.endShape(this.close ? PConstants.CLOSE : PConstants.OPEN); - }; - /** - * @member PShape - * The drawGeometry() function draws the geometry part of the SVG document. - */ - this.drawGeometry = function() { - p.beginShape(this.kind); - var i; - if (this.style) { - for (i = 0; i < this.vertices.length; i++) { - p.vertex(this.vertices[i]); - } - } else { - for (i = 0; i < this.vertices.length; i++) { - var vert = this.vertices[i]; - if (vert[2] === 0) { - p.vertex(vert[0], vert[1]); - } else { - p.vertex(vert[0], vert[1], vert[2]); - } - } - } - p.endShape(); - }; - /** - * @member PShape - * The drawGroup() function draws the part of the SVG document. - */ - this.drawGroup = function() { - for (var i = 0; i < this.children.length; i++) { - this.children[i].draw(); - } - }; - /** - * @member PShape - * The drawPrimitive() function draws SVG document shape elements. These can be point, line, triangle, quad, rect, ellipse, arc, box, or sphere. - */ - this.drawPrimitive = function() { - switch (this.kind) { - case PConstants.POINT: - p.point(this.params[0], this.params[1]); - break; - case PConstants.LINE: - if (this.params.length === 4) { // 2D - p.line(this.params[0], this.params[1], - this.params[2], this.params[3]); - } else { // 3D - p.line(this.params[0], this.params[1], this.params[2], - this.params[3], this.params[4], this.params[5]); - } - break; - case PConstants.TRIANGLE: - p.triangle(this.params[0], this.params[1], - this.params[2], this.params[3], - this.params[4], this.params[5]); - break; - case PConstants.QUAD: - p.quad(this.params[0], this.params[1], - this.params[2], this.params[3], - this.params[4], this.params[5], - this.params[6], this.params[7]); - break; - case PConstants.RECT: - if (this.image !== null) { - p.imageMode(PConstants.CORNER); - p.image(this.image, this.params[0], this.params[1], this.params[2], this.params[3]); - } else { - p.rectMode(PConstants.CORNER); - p.rect(this.params[0], this.params[1], this.params[2], this.params[3]); - } - break; - case PConstants.ELLIPSE: - p.ellipseMode(PConstants.CORNER); - p.ellipse(this.params[0], this.params[1], this.params[2], this.params[3]); - break; - case PConstants.ARC: - p.ellipseMode(PConstants.CORNER); - p.arc(this.params[0], this.params[1], this.params[2], this.params[3], this.params[4], this.params[5]); - break; - case PConstants.BOX: - if (this.params.length === 1) { - p.box(this.params[0]); - } else { - p.box(this.params[0], this.params[1], this.params[2]); - } - break; - case PConstants.SPHERE: - p.sphere(this.params[0]); - break; - } - }; - /** - * @member PShape - * The pre() function performs the preparations before the SVG is drawn. This includes doing transformations and storing previous styles. - */ - this.pre = function() { - if (this.matrix) { - p.pushMatrix(); - curContext.transform(this.matrix.elements[0], this.matrix.elements[3], this.matrix.elements[1], this.matrix.elements[4], this.matrix.elements[2], this.matrix.elements[5]); - //p.applyMatrix(this.matrix.elements[0],this.matrix.elements[0]); - } - if (this.style) { - p.pushStyle(); - this.styles(); - } - }; - /** - * @member PShape - * The post() function performs the necessary actions after the SVG is drawn. This includes removing transformations and removing added styles. - */ - this.post = function() { - if (this.matrix) { - p.popMatrix(); - } - if (this.style) { - p.popStyle(); - } - }; - /** - * @member PShape - * The styles() function changes the Processing's current styles - */ - this.styles = function() { - if (this.stroke) { - p.stroke(this.strokeColor); - p.strokeWeight(this.strokeWeight); - p.strokeCap(this.strokeCap); - p.strokeJoin(this.strokeJoin); - } else { - p.noStroke(); - } - - if (this.fill) { - p.fill(this.fillColor); - - } else { - p.noFill(); - } - }; - /** - * @member PShape - * The getChild() function extracts a child shape from a parent shape. Specify the name of the shape with the target parameter or the - * layer position of the shape to get with the index parameter. - * The shape is returned as a PShape object, or null is returned if there is an error. - * - * @param {String} target the name of the shape to get - * @param {int} index the layer position of the shape to get - * - * @return {PShape} returns a child element of a shape as a PShape object or null if there is an error - */ - this.getChild = function() { - if (typeof arguments[0] === 'number') { - return this.children[arguments[0]]; - } else { - var found, - i; - if(arguments[0] === "" || this.name === arguments[0]){ - return this; - } else { - if(this.nameTable.length > 0) - { - for(i = 0; i < this.nameTable.length || found; i++) - { - if(this.nameTable[i].getName === arguments[0]) { - found = this.nameTable[i]; - } - } - if (found) { return found; } - } - for(i = 0; i < this.children.lenth; i++) - { - found = this.children[i].getChild(arguments[0]); - if(found) { return found; } - } - } - return null; - } - }; - /** - * @member PShape - * The getChildCount() returns the number of children - * - * @return {int} returns a count of children - */ - this.getChildCount = function () { - return this.children.length; - }; - /** - * @member PShape - * The addChild() adds a child to the PShape. - * - * @param {PShape} child the child to add - */ - this.addChild = function( child ) { - this.children.push(child); - child.parent = this; - if (child.getName() !== null) { - this.addName(child.getName(), child); - } - }; - /** - * @member PShape - * The addName() functions adds a shape to the name lookup table. - * - * @param {String} name the name to be added - * @param {PShape} shape the shape - */ - this.addName = function(name, shape) { - if (this.parent !== null) { - this.parent.addName( name, shape ); - } else { - this.nameTable.push( [name, shape] ); - } - }; - /** - * @member PShape - * The translate() function specifies an amount to displace the shape. The x parameter specifies left/right translation, the y parameter specifies up/down translation, and the z parameter specifies translations toward/away from the screen. - * Subsequent calls to the method accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

            Using this method with the z parameter requires using the P3D or OPENGL parameter in combination with size. - * - * @param {int|float} x left/right translation - * @param {int|float} y up/down translation - * @param {int|float} z forward/back translation - * - * @see PMatrix2D#translate - * @see PMatrix3D#translate - */ - this.translate = function() { - if(arguments.length === 2) - { - this.checkMatrix(2); - this.matrix.translate(arguments[0], arguments[1]); - } else { - this.checkMatrix(3); - this.matrix.translate(arguments[0], arguments[1], 0); - } - }; - /** - * @member PShape - * The checkMatrix() function makes sure that the shape's matrix is 1) not null, and 2) has a matrix - * that can handle at least the specified number of dimensions. - * - * @param {int} dimensions the specified number of dimensions - */ - this.checkMatrix = function(dimensions) { - if(this.matrix === null) { - if(dimensions === 2) { - this.matrix = new p.PMatrix2D(); - } else { - this.matrix = new p.PMatrix3D(); - } - }else if(dimensions === 3 && this.matrix instanceof p.PMatrix2D) { - this.matrix = new p.PMatrix3D(); - } - }; - /** - * @member PShape - * The rotateX() function rotates a shape around the x-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

            Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Subsequent calls to the method accumulates the effect. For example, calling rotateX(HALF_PI) and then rotateX(HALF_PI) is the same as rotateX(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

            This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above. - * - * @param {float}angle angle of rotation specified in radians - * - * @see PMatrix3D#rotateX - */ - this.rotateX = function(angle) { - this.rotate(angle, 1, 0, 0); - }; - /** - * @member PShape - * The rotateY() function rotates a shape around the y-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

            Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Subsequent calls to the method accumulates the effect. For example, calling rotateY(HALF_PI) and then rotateY(HALF_PI) is the same as rotateY(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

            This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above. - * - * @param {float}angle angle of rotation specified in radians - * - * @see PMatrix3D#rotateY - */ - this.rotateY = function(angle) { - this.rotate(angle, 0, 1, 0); - }; - /** - * @member PShape - * The rotateZ() function rotates a shape around the z-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

            Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Subsequent calls to the method accumulates the effect. For example, calling rotateZ(HALF_PI) and then rotateZ(HALF_PI) is the same as rotateZ(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

            This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above. - * - * @param {float}angle angle of rotation specified in radians - * - * @see PMatrix3D#rotateZ - */ - this.rotateZ = function(angle) { - this.rotate(angle, 0, 0, 1); - }; - /** - * @member PShape - * The rotate() function rotates a shape the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() method. - *

            Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. - * Transformations apply to everything that happens after and subsequent calls to the method accumulates the effect. - * For example, calling rotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - * If optional parameters x,y,z are supplied, the rotate is about the point (x, y, z). - * - * @param {float}angle angle of rotation specified in radians - * @param {float}x x-coordinate of the point - * @param {float}y y-coordinate of the point - * @param {float}z z-coordinate of the point - * @see PMatrix2D#rotate - * @see PMatrix3D#rotate - */ - this.rotate = function() { - if(arguments.length === 1){ - this.checkMatrix(2); - this.matrix.rotate(arguments[0]); - } else { - this.checkMatrix(3); - this.matrix.rotate(arguments[0], arguments[1], arguments[2] ,arguments[3]); - } - }; - /** - * @member PShape - * The scale() function increases or decreases the size of a shape by expanding and contracting vertices. Shapes always scale from the relative origin of their bounding box. - * Scale values are specified as decimal percentages. For example, the method call scale(2.0) increases the dimension of a shape by 200%. - * Subsequent calls to the method multiply the effect. For example, calling scale(2.0) and then scale(1.5) is the same as scale(3.0). - * This transformation is applied directly to the shape, it's not refreshed each time draw() is run. - *

            Using this fuction with the z parameter requires passing P3D or OPENGL into the size() parameter. - * - * @param {float}s percentage to scale the object - * @param {float}x percentage to scale the object in the x-axis - * @param {float}y percentage to scale the object in the y-axis - * @param {float}z percentage to scale the object in the z-axis - * - * @see PMatrix2D#scale - * @see PMatrix3D#scale - */ - this.scale = function() { - if(arguments.length === 2) { - this.checkMatrix(2); - this.matrix.scale(arguments[0], arguments[1]); - } else if (arguments.length === 3) { - this.checkMatrix(2); - this.matrix.scale(arguments[0], arguments[1], arguments[2]); - } else { - this.checkMatrix(2); - this.matrix.scale(arguments[0]); - } - }; - /** - * @member PShape - * The resetMatrix() function resets the matrix - * - * @see PMatrix2D#reset - * @see PMatrix3D#reset - */ - this.resetMatrix = function() { - this.checkMatrix(2); - this.matrix.reset(); - }; - /** - * @member PShape - * The applyMatrix() function multiplies this matrix by another matrix of type PMatrix3D or PMatrix2D. - * Individual elements can also be provided - * - * @param {PMatrix3D|PMatrix2D} matrix the matrix to multiply by - * - * @see PMatrix2D#apply - * @see PMatrix3D#apply - */ - this.applyMatrix = function(matrix) { - if (arguments.length === 1) { - this.applyMatrix(matrix.elements[0], matrix.elements[1], 0, matrix.elements[2], - matrix.elements[3], matrix.elements[4], 0, matrix.elements[5], - 0, 0, 1, 0, - 0, 0, 0, 1); - } else if (arguments.length === 6) { - this.checkMatrix(2); - this.matrix.apply(arguments[0], arguments[1], arguments[2], 0, - arguments[3], arguments[4], arguments[5], 0, - 0, 0, 1, 0, - 0, 0, 0, 1); - - } else if (arguments.length === 16) { - this.checkMatrix(3); - this.matrix.apply(arguments[0], arguments[1], arguments[2], arguments[3], - arguments[4], arguments[5], arguments[6], arguments[7], - arguments[8], arguments[9], arguments[10], arguments[11], - arguments[12], arguments[13], arguments[14], arguments[15]); - } - }; - }; - - /** - * SVG stands for Scalable Vector Graphics, a portable graphics format. It is - * a vector format so it allows for infinite resolution and relatively small - * file sizes. Most modern media software can view SVG files, including Adobe - * products, Firefox, etc. Illustrator and Inkscape can edit SVG files. - * - * @param {PApplet} parent typically use "this" - * @param {String} filename name of the SVG file to load - * @param {XMLElement} xml an XMLElement element - * @param {PShapeSVG} parent the parent PShapeSVG - * - * @see PShape - */ - var PShapeSVG = p.PShapeSVG = function() { - p.PShape.call( this ); // PShape is the base class. - if (arguments.length === 1) { //xml element coming in - this.element = arguments[0] ;//new p.XMLElement(null, arguments[0]); - // set values to their defaults according to the SVG spec - this.vertexCodes = []; - this.vertices = []; - this.opacity = 1; - - this.stroke = false; - this.strokeColor = PConstants.ALPHA_MASK; - this.strokeWeight = 1; - this.strokeCap = PConstants.SQUARE; // equivalent to BUTT in svg spec - this.strokeJoin = PConstants.MITER; - this.strokeGradient = null; - this.strokeGradientPaint = null; - this.strokeName = null; - this.strokeOpacity = 1; - - this.fill = true; - this.fillColor = PConstants.ALPHA_MASK; - this.fillGradient = null; - this.fillGradientPaint = null; - this.fillName = null; - this.fillOpacity = 1; - - if (this.element.getName() !== "svg") { - throw("root is not , it's <" + this.element.getName() + ">"); - } - } - else if (arguments.length === 2) { - if (typeof arguments[1] === 'string') { - if (arguments[1].indexOf(".svg") > -1) { //its a filename - this.element = new p.XMLElement(null, arguments[1]); - // set values to their defaults according to the SVG spec - this.vertexCodes = []; - this.vertices = []; - this.opacity = 1; - - this.stroke = false; - this.strokeColor = PConstants.ALPHA_MASK; - this.strokeWeight = 1; - this.strokeCap = PConstants.SQUARE; // equivalent to BUTT in svg spec - this.strokeJoin = PConstants.MITER; - this.strokeGradient = ""; - this.strokeGradientPaint = ""; - this.strokeName = ""; - this.strokeOpacity = 1; - - this.fill = true; - this.fillColor = PConstants.ALPHA_MASK; - this.fillGradient = null; - this.fillGradientPaint = null; - this.fillOpacity = 1; - - } - } else { // XMLElement - if (arguments[0]) { // PShapeSVG - this.element = arguments[1]; - this.vertexCodes = arguments[0].vertexCodes.slice(); - this.vertices = arguments[0].vertices.slice(); - - this.stroke = arguments[0].stroke; - this.strokeColor = arguments[0].strokeColor; - this.strokeWeight = arguments[0].strokeWeight; - this.strokeCap = arguments[0].strokeCap; - this.strokeJoin = arguments[0].strokeJoin; - this.strokeGradient = arguments[0].strokeGradient; - this.strokeGradientPaint = arguments[0].strokeGradientPaint; - this.strokeName = arguments[0].strokeName; - - this.fill = arguments[0].fill; - this.fillColor = arguments[0].fillColor; - this.fillGradient = arguments[0].fillGradient; - this.fillGradientPaint = arguments[0].fillGradientPaint; - this.fillName = arguments[0].fillName; - this.strokeOpacity = arguments[0].strokeOpacity; - this.fillOpacity = arguments[0].fillOpacity; - this.opacity = arguments[0].opacity; - } - } - } - - this.name = this.element.getStringAttribute("id"); - var displayStr = this.element.getStringAttribute("display", "inline"); - this.visible = displayStr !== "none"; - var str = this.element.getAttribute("transform"); - if (str) { - this.matrix = this.parseMatrix(str); - } - // not proper parsing of the viewBox, but will cover us for cases where - // the width and height of the object is not specified - var viewBoxStr = this.element.getStringAttribute("viewBox"); - if ( viewBoxStr !== null ) { - var viewBox = viewBoxStr.split(" "); - this.width = viewBox[2]; - this.height = viewBox[3]; - } - - // TODO if viewbox is not same as width/height, then use it to scale - // the original objects. for now, viewbox only used when width/height - // are empty values (which by the spec means w/h of "100%" - var unitWidth = this.element.getStringAttribute("width"); - var unitHeight = this.element.getStringAttribute("height"); - if (unitWidth !== null) { - this.width = this.parseUnitSize(unitWidth); - this.height = this.parseUnitSize(unitHeight); - } else { - if ((this.width === 0) || (this.height === 0)) { - // For the spec, the default is 100% and 100%. For purposes - // here, insert a dummy value because this is prolly just a - // font or something for which the w/h doesn't matter. - this.width = 1; - this.height = 1; - - //show warning - throw("The width and/or height is not " + - "readable in the tag of this file."); - } - } - this.parseColors(this.element); - this.parseChildren(this.element); - - }; - /** - * PShapeSVG methods - * missing: getChild(), print(), parseStyleAttributes(), styles() - deals with strokeGradient and fillGradient - */ - PShapeSVG.prototype = { - /** - * @member PShapeSVG - * The parseMatrix() function parses the specified SVG matrix into a PMatrix2D. Note that PMatrix2D - * is rotated relative to the SVG definition, so parameters are rearranged - * here. More about the transformation matrices in - * this section - * of the SVG documentation. - * - * @param {String} str text of the matrix param. - * - * @return {PMatrix2D} a PMatrix2D - */ - parseMatrix: function(str) { - this.checkMatrix(2); - var pieces = []; - str.replace(/\s*(\w+)\((.*?)\)/g, function(all) { - // get a list of transform definitions - pieces.push(p.trim(all)); - }); - if (pieces.length === 0) { - p.println("Transformation:" + str + " is empty"); - return null; - } - for (var i =0; i< pieces.length; i++) { - var m = []; - pieces[i].replace(/\((.*?)\)/, (function() { - return function(all, params) { - // get the coordinates that can be separated by spaces or a comma - m = params.replace(/,+/g, " ").split(/\s+/); - }; - }())); - - if (pieces[i].indexOf("matrix") !== -1) { - this.matrix.set(m[0], m[2], m[4], m[1], m[3], m[5]); - } else if (pieces[i].indexOf("translate") !== -1) { - var tx = m[0]; - var ty = (m.length === 2) ? m[1] : 0; - this.matrix.translate(tx,ty); - } else if (pieces[i].indexOf("scale") !== -1) { - var sx = m[0]; - var sy = (m.length === 2) ? m[1] : m[0]; - this.matrix.scale(sx,sy); - } else if (pieces[i].indexOf("rotate") !== -1) { - var angle = m[0]; - if (m.length === 1) { - this.matrix.rotate(p.radians(angle)); - } else if (m.length === 3) { - this.matrix.translate(m[1], m[2]); - this.matrix.rotate(p.radians(m[0])); - this.matrix.translate(-m[1], -m[2]); - } - } else if (pieces[i].indexOf("skewX") !== -1) { - this.matrix.skewX(parseFloat(m[0])); - } else if (pieces[i].indexOf("skewY") !== -1) { - this.matrix.skewY(m[0]); - } - } - return this.matrix; - }, - /** - * @member PShapeSVG - * The parseChildren() function parses the specified XMLElement - * - * @param {XMLElement}element the XMLElement to parse - */ - parseChildren:function(element) { - var newelement = element.getChildren(); - var children = new p.PShape(); - for (var i = 0; i < newelement.length; i++) { - var kid = this.parseChild(newelement[i]); - if (kid) { - children.addChild(kid); - } - } - this.children.push(children); - }, - /** - * @member PShapeSVG - * The getName() function returns the name - * - * @return {String} the name - */ - getName: function() { - return this.name; - }, - /** - * @member PShapeSVG - * The parseChild() function parses a child XML element. - * - * @param {XMLElement} elem the element to parse - * - * @return {PShape} the newly created PShape - */ - parseChild: function( elem ) { - var name = elem.getName(); - var shape; - switch (name) { - case "g": - shape = new PShapeSVG(this, elem); - break; - case "defs": - // generally this will contain gradient info, so may - // as well just throw it into a group element for parsing - shape = new PShapeSVG(this, elem); - break; - case "line": - shape = new PShapeSVG(this, elem); - shape.parseLine(); - break; - case "circle": - shape = new PShapeSVG(this, elem); - shape.parseEllipse(true); - break; - case "ellipse": - shape = new PShapeSVG(this, elem); - shape.parseEllipse(false); - break; - case "rect": - shape = new PShapeSVG(this, elem); - shape.parseRect(); - break; - case "polygon": - shape = new PShapeSVG(this, elem); - shape.parsePoly(true); - break; - case "polyline": - shape = new PShapeSVG(this, elem); - shape.parsePoly(false); - break; - case "path": - shape = new PShapeSVG(this, elem); - shape.parsePath(); - break; - case "radialGradient": - //return new RadialGradient(this, elem); - break; - case "linearGradient": - //return new LinearGradient(this, elem); - break; - case "text": - p.println("Text in SVG files is not currently supported, convert text to outlines instead." ); - break; - case "filter": - p.println("Filters are not supported."); - break; - case "mask": - p.println("Masks are not supported."); - break; - default: - p.println("Ignoring <" + name + "> tag."); - break; - } - return shape; - }, - /** - * @member PShapeSVG - * The parsePath() function parses the element of the svg file - * A path is defined by including a path element which contains a d="(path data)" attribute, where the d attribute contains - * the moveto, line, curve (both cubic and quadratic Beziers), arc and closepath instructions. - **/ - parsePath: function() { - this.family = PConstants.PATH; - this.kind = 0; - var pathDataChars = []; - var c; - var pathData = p.trim(this.element.getStringAttribute("d").replace(/[\s,]+/g,' ')); //change multiple spaces and commas to single space - if (pathData === null) { return; } - pathData = pathData.toCharArray(); - var cx = 0, - cy = 0, - ctrlX = 0, - ctrlY = 0, - ctrlX1 = 0, - ctrlX2 = 0, - ctrlY1 = 0, - ctrlY2 = 0, - endX = 0, - endY = 0, - ppx = 0, - ppy = 0, - px = 0, - py = 0, - i = 0, - j = 0, - valOf = 0; - var str = ""; - var tmpArray =[]; - var flag = false; - var lastInstruction; - var command; - while (i< pathData.length) { - valOf = pathData[i].valueOf(); - if ((valOf >= 65 && valOf <= 90) || (valOf >= 97 && valOf <= 122)) { // if its a letter - // populate the tmpArray with coordinates - j = i; - i++; - if (i < pathData.length) { // dont go over boundary of array - tmpArray = []; - valOf = pathData[i].valueOf(); - while (!((valOf >= 65 && valOf <= 90) || (valOf >= 97 && valOf <= 100) || (valOf >= 102 && valOf <= 122)) && flag === false) { // if its NOT a letter - if (valOf === 32) { //if its a space and the str isn't empty - // somethimes you get a space after the letter - if (str !== "") { - tmpArray.push(parseFloat(str)); - str = ""; - } - i++; - } else if (valOf === 45) { //if its a - - // allow for 'e' notation in numbers, e.g. 2.10e-9 - if (pathData[i-1].valueOf() === 101) { - str += pathData[i].toString(); - i++; - } else { - // sometimes no space separator after (ex: 104.535-16.322) - if (str !== "") { - tmpArray.push(parseFloat(str)); - } - str = pathData[i].toString(); - i++; - } - } else { - str += pathData[i].toString(); - i++; - } - if (i === pathData.length) { // dont go over boundary of array - flag = true; - } else { - valOf = pathData[i].valueOf(); - } - } - } - if (str !== "") { - tmpArray.push(parseFloat(str)); - str = ""; - } - command = pathData[j]; - switch (command.valueOf()) { - case 77: // M - move to (absolute) - if (tmpArray.length >= 2 && tmpArray.length % 2 ===0) { // need one+ pairs of co-ordinates - cx = tmpArray[0]; - cy = tmpArray[1]; - this.parsePathMoveto(cx, cy); - if (tmpArray.length > 2) { - for (j = 2; j < tmpArray.length; j+=2) { - // absolute line to - cx = tmpArray[j]; - cy = tmpArray[j+1]; - this.parsePathLineto(cx,cy); - } - } - } - break; - case 109: // m - move to (relative) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - cx += tmpArray[0]; - cy += tmpArray[1]; - this.parsePathMoveto(cx,cy); - if (tmpArray.length > 2) { - for (j = 2; j < tmpArray.length; j+=2) { - // relative line to - cx += tmpArray[j]; - cy += tmpArray[j + 1]; - this.parsePathLineto(cx,cy); - } - } - } - break; - case 76: // L - lineto (absolute) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - cx = tmpArray[j]; - cy = tmpArray[j + 1]; - this.parsePathLineto(cx,cy); - } - } - break; - - case 108: // l - lineto (relative) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - cx += tmpArray[j]; - cy += tmpArray[j+1]; - this.parsePathLineto(cx,cy); - } - } - break; - - case 72: // H - horizontal lineto (absolute) - for (j = 0; j < tmpArray.length; j++) { // multiple x co-ordinates can be provided - cx = tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 104: // h - horizontal lineto (relative) - for (j = 0; j < tmpArray.length; j++) { // multiple x co-ordinates can be provided - cx += tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 86: // V - vertical lineto (absolute) - for (j = 0; j < tmpArray.length; j++) { // multiple y co-ordinates can be provided - cy = tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 118: // v - vertical lineto (relative) - for (j = 0; j < tmpArray.length; j++) { // multiple y co-ordinates can be provided - cy += tmpArray[j]; - this.parsePathLineto(cx, cy); - } - break; - - case 67: // C - curve to (absolute) - if (tmpArray.length >= 6 && tmpArray.length % 6 === 0) { // need one+ multiples of 6 co-ordinates - for (j = 0; j < tmpArray.length; j+=6) { - ctrlX1 = tmpArray[j]; - ctrlY1 = tmpArray[j + 1]; - ctrlX2 = tmpArray[j + 2]; - ctrlY2 = tmpArray[j + 3]; - endX = tmpArray[j + 4]; - endY = tmpArray[j + 5]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 99: // c - curve to (relative) - if (tmpArray.length >= 6 && tmpArray.length % 6 === 0) { // need one+ multiples of 6 co-ordinates - for (j = 0; j < tmpArray.length; j+=6) { - ctrlX1 = cx + tmpArray[j]; - ctrlY1 = cy + tmpArray[j + 1]; - ctrlX2 = cx + tmpArray[j + 2]; - ctrlY2 = cy + tmpArray[j + 3]; - endX = cx + tmpArray[j + 4]; - endY = cy + tmpArray[j + 5]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 83: // S - curve to shorthand (absolute) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - if (lastInstruction.toLowerCase() === "c" || lastInstruction.toLowerCase() === "s") { - ppx = this.vertices[ this.vertices.length-2 ][0]; - ppy = this.vertices[ this.vertices.length-2 ][1]; - px = this.vertices[ this.vertices.length-1 ][0]; - py = this.vertices[ this.vertices.length-1 ][1]; - ctrlX1 = px + (px - ppx); - ctrlY1 = py + (py - ppy); - } else { - //If there is no previous curve, the current point will be used as the first control point. - ctrlX1 = this.vertices[this.vertices.length-1][0]; - ctrlY1 = this.vertices[this.vertices.length-1][1]; - } - ctrlX2 = tmpArray[j]; - ctrlY2 = tmpArray[j + 1]; - endX = tmpArray[j + 2]; - endY = tmpArray[j + 3]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 115: // s - curve to shorthand (relative) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - if (lastInstruction.toLowerCase() === "c" || lastInstruction.toLowerCase() === "s") { - ppx = this.vertices[this.vertices.length-2][0]; - ppy = this.vertices[this.vertices.length-2][1]; - px = this.vertices[this.vertices.length-1][0]; - py = this.vertices[this.vertices.length-1][1]; - ctrlX1 = px + (px - ppx); - ctrlY1 = py + (py - ppy); - } else { - //If there is no previous curve, the current point will be used as the first control point. - ctrlX1 = this.vertices[this.vertices.length-1][0]; - ctrlY1 = this.vertices[this.vertices.length-1][1]; - } - ctrlX2 = cx + tmpArray[j]; - ctrlY2 = cy + tmpArray[j + 1]; - endX = cx + tmpArray[j + 2]; - endY = cy + tmpArray[j + 3]; - this.parsePathCurveto(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 81: // Q - quadratic curve to (absolute) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - ctrlX = tmpArray[j]; - ctrlY = tmpArray[j + 1]; - endX = tmpArray[j + 2]; - endY = tmpArray[j + 3]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 113: // q - quadratic curve to (relative) - if (tmpArray.length >= 4 && tmpArray.length % 4 === 0) { // need one+ multiples of 4 co-ordinates - for (j = 0; j < tmpArray.length; j+=4) { - ctrlX = cx + tmpArray[j]; - ctrlY = cy + tmpArray[j + 1]; - endX = cx + tmpArray[j + 2]; - endY = cy + tmpArray[j + 3]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 84: // T - quadratic curve to shorthand (absolute) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - if (lastInstruction.toLowerCase() === "q" || lastInstruction.toLowerCase() === "t") { - ppx = this.vertices[this.vertices.length-2][0]; - ppy = this.vertices[this.vertices.length-2][1]; - px = this.vertices[this.vertices.length-1][0]; - py = this.vertices[this.vertices.length-1][1]; - ctrlX = px + (px - ppx); - ctrlY = py + (py - ppy); - } else { - // If there is no previous command or if the previous command was not a Q, q, T or t, - // assume the control point is coincident with the current point. - ctrlX = cx; - ctrlY = cy; - } - endX = tmpArray[j]; - endY = tmpArray[j + 1]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 116: // t - quadratic curve to shorthand (relative) - if (tmpArray.length >= 2 && tmpArray.length % 2 === 0) { // need one+ pairs of co-ordinates - for (j = 0; j < tmpArray.length; j+=2) { - if (lastInstruction.toLowerCase() === "q" || lastInstruction.toLowerCase() === "t") { - ppx = this.vertices[this.vertices.length-2][0]; - ppy = this.vertices[this.vertices.length-2][1]; - px = this.vertices[this.vertices.length-1][0]; - py = this.vertices[this.vertices.length-1][1]; - ctrlX = px + (px - ppx); - ctrlY = py + (py - ppy); - } else { - // If there is no previous command or if the previous command was not a Q, q, T or t, - // assume the control point is coincident with the current point. - ctrlX = cx; - ctrlY = cy; - } - endX = cx + tmpArray[j]; - endY = cy + tmpArray[j + 1]; - this.parsePathQuadto(cx, cy, ctrlX, ctrlY, endX, endY); - cx = endX; - cy = endY; - } - } - break; - - case 90: //Z - case 122: //z - this.close = true; - break; - } - lastInstruction = command.toString(); - } else { i++;} - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathQuadto: function(x1, y1, cx, cy, x2, y2) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.BEZIER_VERTEX); - // x1/y1 already covered by last moveto, lineto, or curveto - this.parsePathVertex(x1 + ((cx-x1)*2/3), y1 + ((cy-y1)*2/3)); - this.parsePathVertex(x2 + ((cx-x2)*2/3), y2 + ((cy-y2)*2/3)); - this.parsePathVertex(x2, y2); - } else { - throw ("Path must start with M/m"); - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathCurveto : function(x1, y1, x2, y2, x3, y3) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.BEZIER_VERTEX ); - this.parsePathVertex(x1, y1); - this.parsePathVertex(x2, y2); - this.parsePathVertex(x3, y3); - } else { - throw ("Path must start with M/m"); - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathLineto: function(px, py) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.VERTEX); - this.parsePathVertex(px, py); - // add property to distinguish between curContext.moveTo or curContext.lineTo - this.vertices[this.vertices.length-1]["moveTo"] = false; - } else { - throw ("Path must start with M/m"); - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathMoveto: function(px, py) { - if (this.vertices.length > 0) { - this.parsePathCode(PConstants.BREAK); - } - this.parsePathCode(PConstants.VERTEX); - this.parsePathVertex(px, py); - // add property to distinguish between curContext.moveTo or curContext.lineTo - this.vertices[this.vertices.length-1]["moveTo"] = true; - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathVertex: function(x, y) { - var verts = []; - verts[0] = x; - verts[1] = y; - this.vertices.push(verts); - }, - /** - * @member PShapeSVG - * PShapeSVG.parsePath() helper function - * - * @see PShapeSVG#parsePath - */ - parsePathCode: function(what) { - this.vertexCodes.push(what); - }, - /** - * @member PShapeSVG - * The parsePoly() function parses a polyline or polygon from an SVG file. - * - * @param {boolean}val true if shape is closed (polygon), false if not (polyline) - */ - parsePoly: function(val) { - this.family = PConstants.PATH; - this.close = val; - var pointsAttr = p.trim(this.element.getStringAttribute("points").replace(/[,\s]+/g,' ')); - if (pointsAttr !== null) { - //split into array - var pointsBuffer = pointsAttr.split(" "); - if (pointsBuffer.length % 2 === 0) { - for (var i = 0; i < pointsBuffer.length; i++) { - var verts = []; - verts[0] = pointsBuffer[i]; - verts[1] = pointsBuffer[++i]; - this.vertices.push(verts); - } - } else { - p.println("Error parsing polygon points: odd number of coordinates provided"); - } - } - }, - /** - * @member PShapeSVG - * The parseRect() function parses a rect from an SVG file. - */ - parseRect: function() { - this.kind = PConstants.RECT; - this.family = PConstants.PRIMITIVE; - this.params = []; - this.params[0] = this.element.getFloatAttribute("x"); - this.params[1] = this.element.getFloatAttribute("y"); - this.params[2] = this.element.getFloatAttribute("width"); - this.params[3] = this.element.getFloatAttribute("height"); - if (this.params[2] < 0 || this.params[3] < 0) { - throw("svg error: negative width or height found while parsing "); - } - - }, - /** - * @member PShapeSVG - * The parseEllipse() function handles parsing ellipse and circle tags. - * - * @param {boolean}val true if this is a circle and not an ellipse - */ - parseEllipse: function(val) { - this.kind = PConstants.ELLIPSE; - this.family = PConstants.PRIMITIVE; - this.params = []; - - this.params[0] = this.element.getFloatAttribute("cx") | 0; - this.params[1] = this.element.getFloatAttribute("cy") | 0; - - var rx, ry; - if (val) { //this is a circle - rx = ry = this.element.getFloatAttribute("r"); - if (rx < 0) { - throw("svg error: negative radius found while parsing "); - } - } else { - rx = this.element.getFloatAttribute("rx"); - ry = this.element.getFloatAttribute("ry"); - if (rx < 0 || ry < 0) { - throw("svg error: negative x-axis radius or y-axis radius found while parsing "); - } - } - this.params[0] -= rx; - this.params[1] -= ry; - - this.params[2] = rx*2; - this.params[3] = ry*2; - }, - /** - * @member PShapeSVG - * The parseLine() function handles parsing line tags. - * - * @param {boolean}val true if this is a circle and not an ellipse - */ - parseLine: function() { - this.kind = PConstants.LINE; - this.family = PConstants.PRIMITIVE; - this.params = []; - this.params[0] = this.element.getFloatAttribute("x1"); - this.params[1] = this.element.getFloatAttribute("y1"); - this.params[2] = this.element.getFloatAttribute("x2"); - this.params[3] = this.element.getFloatAttribute("y2"); - }, - /** - * @member PShapeSVG - * The parseColors() function handles parsing the opacity, strijem stroke-width, stroke-linejoin,stroke-linecap, fill, and style attributes - * - * @param {XMLElement}element the element of which attributes to parse - */ - parseColors: function(element) { - if (element.hasAttribute("opacity")) { - this.setOpacity(element.getAttribute("opacity")); - } - if (element.hasAttribute("stroke")) { - this.setStroke(element.getAttribute("stroke")); - } - if (element.hasAttribute("stroke-width")) { - // if NaN (i.e. if it's 'inherit') then default back to the inherit setting - this.setStrokeWeight(element.getAttribute("stroke-width")); - } - if (element.hasAttribute("stroke-linejoin") ) { - this.setStrokeJoin(element.getAttribute("stroke-linejoin")); - } - if (element.hasAttribute("stroke-linecap")) { - this.setStrokeCap(element.getStringAttribute("stroke-linecap")); - } - // fill defaults to black (though stroke defaults to "none") - // http://www.w3.org/TR/SVG/painting.html#FillProperties - if (element.hasAttribute("fill")) { - this.setFill(element.getStringAttribute("fill")); - } - if (element.hasAttribute("style")) { - var styleText = element.getStringAttribute("style"); - var styleTokens = styleText.toString().split( ";" ); - - for (var i = 0; i < styleTokens.length; i++) { - var tokens = p.trim(styleTokens[i].split( ":" )); - switch(tokens[0]){ - case "fill": - this.setFill(tokens[1]); - break; - case "fill-opacity": - this.setFillOpacity(tokens[1]); - break; - case "stroke": - this.setStroke(tokens[1]); - break; - case "stroke-width": - this.setStrokeWeight(tokens[1]); - break; - case "stroke-linecap": - this.setStrokeCap(tokens[1]); - break; - case "stroke-linejoin": - this.setStrokeJoin(tokens[1]); - break; - case "stroke-opacity": - this.setStrokeOpacity(tokens[1]); - break; - case "opacity": - this.setOpacity(tokens[1]); - break; - // Other attributes are not yet implemented - } - } - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} opacityText the value of fillOpacity - * - * @see PShapeSVG#parseColors - */ - setFillOpacity: function(opacityText) { - this.fillOpacity = parseFloat(opacityText); - this.fillColor = this.fillOpacity * 255 << 24 | this.fillColor & 0xFFFFFF; - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} fillText the value of fill - * - * @see PShapeSVG#parseColors - */ - setFill: function (fillText) { - var opacityMask = this.fillColor & 0xFF000000; - if (fillText === "none") { - this.fill = false; - } else if (fillText.indexOf("#") === 0) { - this.fill = true; - if (fillText.length === 4) { - // convert #00F to #0000FF - fillText = fillText.replace(/#(.)(.)(.)/,"#$1$1$2$2$3$3"); - } - this.fillColor = opacityMask | (parseInt(fillText.substring(1), 16)) & 0xFFFFFF; - } else if (fillText.indexOf("rgb") === 0) { - this.fill = true; - this.fillColor = opacityMask | this.parseRGB(fillText); - } else if (fillText.indexOf("url(#") === 0) { - this.fillName = fillText.substring(5, fillText.length - 1 ); - /*Object fillObject = findChild(fillName); - if (fillObject instanceof Gradient) { - fill = true; - fillGradient = (Gradient) fillObject; - fillGradientPaint = calcGradientPaint(fillGradient); //, opacity); - } else { - System.err.println("url " + fillName + " refers to unexpected data"); - }*/ - } else { - if (colors[fillText]) { - this.fill = true; - this.fillColor = opacityMask | (parseInt(colors[fillText].substring(1), 16)) & 0xFFFFFF; - } - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} opacity the value of opacity - * - * @see PShapeSVG#parseColors - */ - setOpacity: function(opacity) { - this.strokeColor = parseFloat(opacity) * 255 << 24 | this.strokeColor & 0xFFFFFF; - this.fillColor = parseFloat(opacity) * 255 << 24 | this.fillColor & 0xFFFFFF; - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} strokeText the value to set stroke to - * - * @see PShapeSVG#parseColors - */ - setStroke: function(strokeText) { - var opacityMask = this.strokeColor & 0xFF000000; - if (strokeText === "none") { - this.stroke = false; - } else if (strokeText.charAt( 0 ) === "#") { - this.stroke = true; - if (strokeText.length === 4) { - // convert #00F to #0000FF - strokeText = strokeText.replace(/#(.)(.)(.)/,"#$1$1$2$2$3$3"); - } - this.strokeColor = opacityMask | (parseInt( strokeText.substring(1), 16)) & 0xFFFFFF; - } else if (strokeText.indexOf( "rgb" ) === 0 ) { - this.stroke = true; - this.strokeColor = opacityMask | this.parseRGB(strokeText); - } else if (strokeText.indexOf( "url(#" ) === 0) { - this.strokeName = strokeText.substring(5, strokeText.length - 1); - //this.strokeObject = findChild(strokeName); - /*if (strokeObject instanceof Gradient) { - strokeGradient = (Gradient) strokeObject; - strokeGradientPaint = calcGradientPaint(strokeGradient); //, opacity); - } else { - System.err.println("url " + strokeName + " refers to unexpected data"); - }*/ - } else { - if (colors[strokeText]){ - this.stroke = true; - this.strokeColor = opacityMask | (parseInt(colors[strokeText].substring(1), 16)) & 0xFFFFFF; - } - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} weight the value to set strokeWeight to - * - * @see PShapeSVG#parseColors - */ - setStrokeWeight: function(weight) { - this.strokeWeight = this.parseUnitSize(weight); - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} linejoin the value to set strokeJoin to - * - * @see PShapeSVG#parseColors - */ - setStrokeJoin: function(linejoin) { - if (linejoin === "miter") { - this.strokeJoin = PConstants.MITER; - - } else if (linejoin === "round") { - this.strokeJoin = PConstants.ROUND; - - } else if (linejoin === "bevel") { - this.strokeJoin = PConstants.BEVEL; - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} linecap the value to set strokeCap to - * - * @see PShapeSVG#parseColors - */ - setStrokeCap: function (linecap) { - if (linecap === "butt") { - this.strokeCap = PConstants.SQUARE; - - } else if (linecap === "round") { - this.strokeCap = PConstants.ROUND; - - } else if (linecap === "square") { - this.strokeCap = PConstants.PROJECT; - } - }, - /** - * @member PShapeSVG - * PShapeSVG.parseColors() helper function - * - * @param {String} opacityText the value to set stroke opacity to - * - * @see PShapeSVG#parseColors - */ - setStrokeOpacity: function (opacityText) { - this.strokeOpacity = parseFloat(opacityText); - this.strokeColor = this.strokeOpacity * 255 << 24 | this.strokeColor & 0xFFFFFF; - }, - /** - * @member PShapeSVG - * The parseRGB() function parses an rbg() color string and returns a color int - * - * @param {String} color the color to parse in rbg() format - * - * @return {int} the equivalent color int - */ - parseRGB: function(color) { - var sub = color.substring(color.indexOf('(') + 1, color.indexOf(')')); - var values = sub.split(", "); - return (values[0] << 16) | (values[1] << 8) | (values[2]); - }, - /** - * @member PShapeSVG - * The parseUnitSize() function parse a size that may have a suffix for its units. - * Ignoring cases where this could also be a percentage. - * The units spec: - *
              - *
            • "1pt" equals "1.25px" (and therefore 1.25 user units) - *
            • "1pc" equals "15px" (and therefore 15 user units) - *
            • "1mm" would be "3.543307px" (3.543307 user units) - *
            • "1cm" equals "35.43307px" (and therefore 35.43307 user units) - *
            • "1in" equals "90px" (and therefore 90 user units) - *
            - */ - parseUnitSize: function (text) { - var len = text.length - 2; - if (len < 0) { return text; } - if (text.indexOf("pt") === len) { - return parseFloat(text.substring(0, len)) * 1.25; - } else if (text.indexOf("pc") === len) { - return parseFloat( text.substring( 0, len)) * 15; - } else if (text.indexOf("mm") === len) { - return parseFloat( text.substring(0, len)) * 3.543307; - } else if (text.indexOf("cm") === len) { - return parseFloat(text.substring(0, len)) * 35.43307; - } else if (text.indexOf("in") === len) { - return parseFloat(text.substring(0, len)) * 90; - } else if (text.indexOf("px") === len) { - return parseFloat(text.substring(0, len)); - } else { - return parseFloat(text); - } - } - }; - /** - * The shape() function displays shapes to the screen. - * Processing currently works with SVG shapes only. - * The shape parameter specifies the shape to display and the x - * and y parameters define the location of the shape from its - * upper-left corner. - * The shape is displayed at its original size unless the width - * and height parameters specify a different size. - * The shapeMode() function changes the way the parameters work. - * A call to shapeMode(CORNERS), for example, will change the width - * and height parameters to define the x and y values of the opposite corner - * of the shape. - *

            - * Note complex shapes may draw awkwardly with P2D, P3D, and OPENGL. Those - * renderers do not yet support shapes that have holes or complicated breaks. - * - * @param {PShape} shape the shape to display - * @param {int|float} x x-coordinate of the shape - * @param {int|float} y y-coordinate of the shape - * @param {int|float} width width to display the shape - * @param {int|float} height height to display the shape - * - * @see PShape - * @see loadShape() - * @see shapeMode() - */ - p.shape = function(shape, x, y, width, height) { - if (arguments.length >= 1 && arguments[0] !== null) { - if (shape.isVisible()) { - p.pushMatrix(); - if (curShapeMode === PConstants.CENTER) { - if (arguments.length === 5) { - p.translate(x - width/2, y - height/2); - p.scale(width / shape.getWidth(), height / shape.getHeight()); - } else if (arguments.length === 3) { - p.translate(x - shape.getWidth()/2, - shape.getHeight()/2); - } else { - p.translate(-shape.getWidth()/2, -shape.getHeight()/2); - } - } else if (curShapeMode === PConstants.CORNER) { - if (arguments.length === 5) { - p.translate(x, y); - p.scale(width / shape.getWidth(), height / shape.getHeight()); - } else if (arguments.length === 3) { - p.translate(x, y); - } - } else if (curShapeMode === PConstants.CORNERS) { - if (arguments.length === 5) { - width -= x; - height -= y; - p.translate(x, y); - p.scale(width / shape.getWidth(), height / shape.getHeight()); - } else if (arguments.length === 3) { - p.translate(x, y); - } - } - shape.draw(); - if ((arguments.length === 1 && curShapeMode === PConstants.CENTER ) || arguments.length > 1) { - p.popMatrix(); - } - } - } - }; - - /** - * The shapeMode() function modifies the location from which shapes draw. - * The default mode is shapeMode(CORNER), which specifies the - * location to be the upper left corner of the shape and uses the third - * and fourth parameters of shape() to specify the width and height. - * The syntax shapeMode(CORNERS) uses the first and second parameters - * of shape() to set the location of one corner and uses the third - * and fourth parameters to set the opposite corner. - * The syntax shapeMode(CENTER) draws the shape from its center point - * and uses the third and forth parameters of shape() to specify the - * width and height. - * The parameter must be written in "ALL CAPS" because Processing syntax - * is case sensitive. - * - * @param {int} mode One of CORNER, CORNERS, CENTER - * - * @see shape() - * @see rectMode() - */ - p.shapeMode = function (mode) { - curShapeMode = mode; - }; - - /** - * The loadShape() function loads vector shapes into a variable of type PShape. Currently, only SVG files may be loaded. - * In most cases, loadShape() should be used inside setup() because loading shapes inside draw() will reduce the speed of a sketch. - * - * @param {String} filename an SVG file - * - * @return {PShape} a object of type PShape or null - * @see PShape - * @see PApplet#shape() - * @see PApplet#shapeMode() - */ - p.loadShape = function (filename) { - if (arguments.length === 1) { - if (filename.indexOf(".svg") > -1) { - return new PShapeSVG(null, filename); - } - } - return null; - }; - - /** - * XMLAttribute is an attribute of a XML element. This is an internal class - * - * @param {String} fname the full name of the attribute - * @param {String} n the short name of the attribute - * @param {String} namespace the namespace URI of the attribute - * @param {String} v the value of the attribute - * @param {String }t the type of the attribute - * - * @see XMLElement - */ - var XMLAttribute = function(fname, n, nameSpace, v, t){ - this.fullName = fname || ""; - this.name = n || ""; - this.namespace = nameSpace || ""; - this.value = v; - this.type = t; - }; - /** - * XMLAttribute methods - */ - XMLAttribute.prototype = { - /** - * @member XMLAttribute - * The getName() function returns the short name of the attribute - * - * @return {String} the short name of the attribute - */ - getName: function() { - return this.name; - }, - /** - * @member XMLAttribute - * The getFullName() function returns the full name of the attribute - * - * @return {String} the full name of the attribute - */ - getFullName: function() { - return this.fullName; - }, - /** - * @member XMLAttribute - * The getNamespace() function returns the namespace of the attribute - * - * @return {String} the namespace of the attribute - */ - getNamespace: function() { - return this.namespace; - }, - /** - * @member XMLAttribute - * The getValue() function returns the value of the attribute - * - * @return {String} the value of the attribute - */ - getValue: function() { - return this.value; - }, - /** - * @member XMLAttribute - * The getValue() function returns the type of the attribute - * - * @return {String} the type of the attribute - */ - getType: function() { - return this.type; - }, - /** - * @member XMLAttribute - * The setValue() function sets the value of the attribute - * - * @param {String} newval the new value - */ - setValue: function(newval) { - this.value = newval; - } - }; - - /** - * XMLElement is a representation of an XML object. The object is able to parse XML code - * - * @param {PApplet} parent typically use "this" - * @param {String} filename name of the XML/SVG file to load - * @param {String} xml the xml/svg string - * @param {String} fullname the full name of the element - * @param {String} namespace the namespace of the URI - * @param {String} systemID the system ID of the XML data where the element starts - * @param {Integer }lineNr the line in the XML data where the element starts - */ - var XMLElement = p.XMLElement = function() { - if (arguments.length === 4) { - this.attributes = []; - this.children = []; - this.fullName = arguments[0] || ""; - if (arguments[1]) { - this.name = arguments[1]; - } else { - var index = this.fullName.indexOf(':'); - if (index >= 0) { - this.name = this.fullName.substring(index + 1); - } else { - this.name = this.fullName; - } - } - this.namespace = arguments[1]; - this.content = ""; - this.lineNr = arguments[3]; - this.systemID = arguments[2]; - this.parent = null; - } - else if ((arguments.length === 2 && arguments[1].indexOf(".") > -1) ) { // filename or svg xml element - this.attributes = []; - this.children = []; - this.fullName = ""; - this.name = ""; - this.namespace = ""; - this.content = ""; - this.systemID = ""; - this.lineNr = ""; - this.parent = null; - this.parse(arguments[arguments.length -1]); - } else if (arguments.length === 1 && typeof arguments[0] === "string"){ - //xml string - this.attributes = []; - this.children = []; - this.fullName = ""; - this.name = ""; - this.namespace = ""; - this.content = ""; - this.systemID = ""; - this.lineNr = ""; - this.parent = null; - this.parse(arguments[0]); - } - else { //empty ctor - this.attributes = []; - this.children = []; - this.fullName = ""; - this.name = ""; - this.namespace = ""; - this.content = ""; - this.systemID = ""; - this.lineNr = ""; - this.parent = null; - - } - return this; - }; - /** - * XMLElement methods - * missing: enumerateAttributeNames(), enumerateChildren(), - * NOTE: parse does not work when a url is passed in - */ - XMLElement.prototype = { - /** - * @member XMLElement - * The parse() function retrieves the file via ajax() and uses DOMParser() parseFromString method to make an XML document - * @addon - * - * @param {String} filename name of the XML/SVG file to load - * - * @throws ExceptionType Error loading document - * - * @see XMLElement#parseChildrenRecursive - */ - parse: function(filename) { - var xmlDoc; - try { - if (filename.indexOf(".xml") > -1 || filename.indexOf(".svg") > -1) { - filename = ajax(filename); - } - xmlDoc = new DOMParser().parseFromString(filename, "text/xml"); - var elements = xmlDoc.documentElement; - if (elements) { - this.parseChildrenRecursive(null, elements); - } else { - throw ("Error loading document"); - } - return this; - } catch(e) { - throw(e); - } - }, - /** - * @member XMLElement - * The createElement() function Creates an empty element - * - * @param {String} fullName the full name of the element - * @param {String} namespace the namespace URI - * @param {String} systemID the system ID of the XML data where the element starts - * @param {int} lineNr the line in the XML data where the element starts - */ - createElement: function () { - if (arguments.length === 2) { - return new XMLElement(arguments[0], arguments[1], null, null); - } else { - return new XMLElement(arguments[0], arguments[1], arguments[2], arguments[3]); - } - }, - /** - * @member XMLElement - * The hasAttribute() function returns whether an attribute exists - * - * @param {String} name name of the attribute - * @param {String} namespace the namespace URI of the attribute - * - * @return {boolean} true if the attribute exists - */ - hasAttribute: function () { - if (arguments.length === 1) { - return this.getAttribute(arguments[0]) !== null; - } else if (arguments.length === 2) { - return this.getAttribute(arguments[0],arguments[1]) !== null; - } - }, - /** - * @member XMLElement - * The createPCDataElement() function creates an element to be used for #PCDATA content - * - * @return {XMLElement} new XMLElement element - */ - createPCDataElement: function () { - return new XMLElement(); - }, - /** - * @member XMLElement - * The equals() function checks to see if the element being passed in equals another element - * - * @param {Object} rawElement the element to compare to - * - * @return {boolean} true if the element equals another element - */ - equals: function(object){ - if (typeof object === "Object") { - return this.equalsXMLElement(object); - } - }, - /** - * @member XMLElement - * The equalsXMLElement() function checks to see if the XMLElement being passed in equals another XMLElement - * - * @param {XMLElement} rawElement the element to compare to - * - * @return {boolean} true if the element equals another element - */ - equalsXMLElement: function (object) { - if (object instanceof XMLElement) { - if (this.name !== object.getLocalName()) { return false; } - if (this.attributes.length !== object.getAttributeCount()) { return false; } - for (var i = 0; i < this.attributes.length; i++){ - if (! object.hasAttribute(this.attributes[i].getName(), this.attributes[i].getNamespace())) { return false; } - if (this.attributes[i].getValue() !== object.attributes[i].getValue()) { return false; } - if (this.attributes[i].getType() !== object.attributes[i].getType()) { return false; } - } - if (this.children.length !== object.getChildCount()) { return false; } - var child1, child2; - for (i = 0; i < this.children.length; i++) { - child1 = this.getChildAtIndex(i); - child2 = object.getChildAtIndex(i); - if (! child1.equalsXMLElement(child2)) { return false; } - } - return true; - } - }, - /** - * @member XMLElement - * The getContent() function returns the content of an element. If there is no such content, null is returned - * - * @return {String} the (possibly null) content - */ - getContent: function(){ - return this.content; - }, - /** - * @member XMLElement - * The getAttribute() function returns the value of an attribute - * - * @param {String} name the non-null full name of the attribute - * @param {String} namespace the namespace URI, which may be null - * @param {String} defaultValue the default value of the attribute - * - * @return {String} the value, or defaultValue if the attribute does not exist - */ - getAttribute: function (){ - var attribute; - if( arguments.length === 2 ){ - attribute = this.findAttribute(arguments[0]); - if (attribute) { - return attribute.getValue(); - } else { - return arguments[1]; - } - } else if (arguments.length === 1) { - attribute = this.findAttribute(arguments[0]); - if (attribute) { - return attribute.getValue(); - } else { - return null; - } - } else if (arguments.length === 3) { - attribute = this.findAttribute(arguments[0],arguments[1]); - if (attribute) { - return attribute.getValue(); - } else { - return arguments[2]; - } - } - }, - /** - * @member XMLElement - * The getStringAttribute() function returns the string attribute of the element - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue value is returned. - * When calling the function without the defaultValue parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return {String} the value, or defaultValue if the attribute does not exist - */ - getStringAttribute: function() { - if (arguments.length === 1) { - return this.getAttribute(arguments[0]); - } else if (arguments.length === 2){ - return this.getAttribute(arguments[0], arguments[1]); - } else { - return this.getAttribute(arguments[0], arguments[1],arguments[2]); - } - }, - /** - * @member XMLElement - * The getFloatAttribute() function returns the float attribute of the element. - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue value is returned. - * When calling the function without the defaultValue parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return {float} the value, or defaultValue if the attribute does not exist - */ - getFloatAttribute: function() { - if (arguments.length === 1 ) { - return parseFloat(this.getAttribute(arguments[0], 0)); - } else if (arguments.length === 2 ){ - return this.getAttribute(arguments[0], arguments[1]); - } else { - return this.getAttribute(arguments[0], arguments[1],arguments[2]); - } - }, - /** - * @member XMLElement - * The getIntAttribute() function returns the integer attribute of the element. - * If the defaultValue parameter is used and the attribute doesn't exist, the defaultValue value is returned. - * When calling the function without the defaultValue parameter, if the attribute doesn't exist, the value 0 is returned. - * - * @param name the name of the attribute - * @param defaultValue value returned if the attribute is not found - * - * @return {int} the value, or defaultValue if the attribute does not exist - */ - getIntAttribute: function () { - if (arguments.length === 1) { - return this.getAttribute( arguments[0], 0 ); - } else if (arguments.length === 2) { - return this.getAttribute(arguments[0], arguments[1]); - } else { - return this.getAttribute(arguments[0], arguments[1],arguments[2]); - } - }, - /** - * @member XMLElement - * The hasChildren() function returns whether the element has children. - * - * @return {boolean} true if the element has children. - */ - hasChildren: function () { - return this.children.length > 0 ; - }, - /** - * @member XMLElement - * The addChild() function adds a child element - * - * @param {XMLElement} child the non-null child to add. - */ - addChild: function (child) { - if (child !== null) { - child.parent = this; - this.children.push(child); - } - }, - /** - * @member XMLElement - * The insertChild() function inserts a child element at the index provided - * - * @param {XMLElement} child the non-null child to add. - * @param {int} index where to put the child. - */ - insertChild: function (child, index) { - if (child) { - if ((child.getLocalName() === null) && (! this.hasChildren())) { - var lastChild = this.children[this.children.length -1]; - if (lastChild.getLocalName() === null) { - lastChild.setContent(lastChild.getContent() + child.getContent()); - return; - } - } - child.parent = this; - this.children.splice(index,0,child); - } - }, - /** - * @member XMLElement - * The getChild() returns the child XMLElement as specified by the index parameter. - * The value of the index parameter must be less than the total number of children to avoid going out of the array storing the child elements. - * When the path parameter is specified, then it will return all children that match that path. The path is a series of elements and sub-elements, separated by slashes. - * - * @param {int} index where to put the child. - * @param {String} path path to a particular element - * - * @return {XMLElement} the element - */ - getChild: function (){ - if (typeof arguments[0] === "number") { - return this.children[arguments[0]]; - } - else if (arguments[0].indexOf('/') !== -1) { // path was given - this.getChildRecursive(arguments[0].split("/"), 0); - } else { - var kid, kidName; - for (var i = 0; i < this.getChildCount(); i++) { - kid = this.getChild(i); - kidName = kid.getName(); - if (kidName !== null && kidName === arguments[0]) { - return kid; - } - } - return null; - } - }, - /** - * @member XMLElement - * The getChildren() returns all of the children as an XMLElement array. - * When the path parameter is specified, then it will return all children that match that path. - * The path is a series of elements and sub-elements, separated by slashes. - * - * @param {String} path element name or path/to/element - * - * @return {XMLElement} array of child elements that match - * - * @see XMLElement#getChildCount() - * @see XMLElement#getChild() - */ - getChildren: function(){ - if (arguments.length === 1) { - if (typeof arguments[0] === "number") { - return this.getChild( arguments[0]); - } else if (arguments[0].indexOf('/') !== -1) { // path was given - return this.getChildrenRecursive( arguments[0].split("/"), 0); - } else { - var matches = []; - var kid, kidName; - for (var i = 0; i < this.getChildCount(); i++) { - kid = this.getChild(i); - kidName = kid.getName(); - if (kidName !== null && kidName === arguments[0]) { - matches.push(kid); - } - } - return matches; - } - }else { - return this.children; - } - }, - /** - * @member XMLElement - * The getChildCount() returns the number of children for the element. - * - * @return {int} the count - * - * @see XMLElement#getChild() - * @see XMLElement#getChildren() - */ - getChildCount: function(){ - return this.children.length; - }, - /** - * @member XMLElement - * Internal helper function for getChild(). - * - * @param {String[]} items result of splitting the query on slashes - * @param {int} offset where in the items[] array we're currently looking - * - * @return {XMLElement} matching element or null if no match - */ - getChildRecursive: function (items, offset) { - var kid, kidName; - for(var i = 0; i < this.getChildCount(); i++) { - kid = this.getChild(i); - kidName = kid.getName(); - if (kidName !== null && kidName === items[offset]) { - if (offset === items.length-1) { - return kid; - } else { - offset += 1; - return kid.getChildRecursive(items, offset); - } - } - } - return null; - }, - /** - * @member XMLElement - * Internal helper function for getChildren(). - * - * @param {String[]} items result of splitting the query on slashes - * @param {int} offset where in the items[] array we're currently looking - * - * @return {XMLElement[]} matching elements or empty array if no match - */ - getChildrenRecursive: function (items, offset) { - if (offset === items.length-1) { - return this.getChildren(items[offset]); - } - var matches = this.getChildren(items[offset]); - var kidMatches; - for (var i = 0; i < matches.length; i++) { - kidMatches = matches[i].getChildrenRecursive(items, offset+1); - } - return kidMatches; - }, - /** - * @member XMLElement - * Internal helper function for parse(). - * Loops through the - * @addon - * - * @param {XMLElement} parent the parent node - * @param {XML document childNodes} elementpath the remaining nodes that need parsing - * - * @return {XMLElement} the new element and its children elements - */ - parseChildrenRecursive: function (parent , elementpath){ - var xmlelement, - xmlattribute, - tmpattrib; - if (!parent) { - this.fullName = elementpath.localName; - this.name = elementpath.nodeName; - this.content = elementpath.textContent || ""; - xmlelement = this; - } else { // a parent - xmlelement = new XMLElement(elementpath.localName, elementpath.nodeName, "", ""); - xmlelement.content = elementpath.textContent || ""; - xmlelement.parent = parent; - } - - for (var l = 0; l < elementpath.attributes.length; l++) { - tmpattrib = elementpath.attributes[l]; - xmlattribute = new XMLAttribute(tmpattrib.getname , tmpattrib.nodeName, tmpattrib.namespaceURI , tmpattrib.nodeValue , tmpattrib.nodeType); - xmlelement.attributes.push(xmlattribute); - } - - for (var node in elementpath.childNodes){ - if(elementpath.childNodes[node].nodeType === 1) { //ELEMENT_NODE type - xmlelement.children.push( xmlelement.parseChildrenRecursive(xmlelement, elementpath.childNodes[node])); - } - } - return xmlelement; - }, - /** - * @member XMLElement - * The isLeaf() function returns whether the element is a leaf element. - * - * @return {boolean} true if the element has no children. - */ - isLeaf: function(){ - return !this.hasChildren(); - }, - /** - * @member XMLElement - * The listChildren() function put the names of all children into an array. Same as looping through - * each child and calling getName() on each XMLElement. - * - * @return {String[]} a list of element names. - */ - listChildren: function() { - var arr = []; - for (var i = 0; i < this.children.length; i++) { - arr.push( this.getChild(i).getName()); - } - return arr; - }, - /** - * @member XMLElement - * The removeAttribute() function removes an attribute - * - * @param {String} name the non-null name of the attribute. - * @param {String} namespace the namespace URI of the attribute, which may be null. - */ - removeAttribute: function (name , namespace) { - this.namespace = namespace || ""; - for (var i = 0; i < this.attributes.length; i++){ - if (this.attributes[i].getName() === name && this.attributes[i].getNamespace() === this.namespace) { - this.attributes.splice(i, 1); - } - } - }, - /** - * @member XMLElement - * The removeChild() removes a child element. - * - * @param {XMLElement} child the the non-null child to be renoved - */ - removeChild: function(child) { - if (child) { - for (var i = 0; i < this.children.length; i++) { - if (this.children[i].equalsXMLElement(child)) { - this.children.splice(i, 1); - } - } - } - }, - /** - * @member XMLElement - * The removeChildAtIndex() removes the child located at a certain index - * - * @param {int} index the index of the child, where the first child has index 0 - */ - removeChildAtIndex: function(index) { - if (this.children.length > index) { //make sure its not outofbounds - this.children.splice(index, 1); - } - }, - /** - * @member XMLElement - * The findAttribute() function searches an attribute - * - * @param {String} name fullName the non-null full name of the attribute - * @param {String} namespace the name space, which may be null - * - * @return {XMLAttribute} the attribute, or null if the attribute does not exist. - */ - findAttribute: function (name, namespace) { - this.namespace = namespace || ""; - for (var i = 0; i < this.attributes.length; i++ ) { - if (this.attributes[i].getName() === name && this.attributes[i].getNamespace() === this.namespace) { - return this.attributes[i]; - } - } - }, - /** - * @member XMLElement - * The setAttribute() function sets an attribute. - * - * @param {String} name the non-null full name of the attribute - * @param {String} namespace the non-null value of the attribute - */ - setAttribute: function() { - var attr; - if (arguments.length === 3) { - var index = arguments[0].indexOf(':'); - var name = arguments[0].substring(index + 1); - attr = this.findAttribute( name, arguments[1] ); - if (attr) { - attr.setValue(arguments[2]); - } else { - attr = new XMLAttribute(arguments[0], name, arguments[1], arguments[2], "CDATA"); - this.attributes.push(attr); - } - } else { - attr = this.findAttribute(arguments[0]); - if (attr) { - attr.setValue(arguments[1]); - } else { - attr = new XMLAttribute(arguments[0], arguments[0], null, arguments[1], "CDATA"); - this.attributes.push(attr); - } - } - }, - /** - * @member XMLElement - * The setContent() function sets the #PCDATA content. It is an error to call this method with a - * non-null value if there are child objects. - * - * @param {String} content the (possibly null) content - */ - setContent: function(content) { - this.content = content; - }, - /** - * @member XMLElement - * The setName() function sets the full name. This method also sets the short name and clears the - * namespace URI. - * - * @param {String} name the non-null name - * @param {String} namespace the namespace URI, which may be null. - */ - setName: function() { - if (arguments.length === 1) { - this.name = arguments[0]; - this.fullName = arguments[0]; - this.namespace = null; - } else { - var index = arguments[0].indexOf(':'); - if ((arguments[1] === null) || (index < 0)) { - this.name = arguments[0]; - } else { - this.name = arguments[0].substring(index + 1); - } - this.fullName = arguments[0]; - this.namespace = arguments[1]; - } - }, - /** - * @member XMLElement - * The getName() function returns the full name (i.e. the name including an eventual namespace - * prefix) of the element. - * - * @return {String} the name, or null if the element only contains #PCDATA. - */ - getName: function() { - return this.fullName; - }, - getLocalName: function() { - return this.name; - }, - getAttributeCount: function() { - return this.attributes.length; - } - }; - - - //////////////////////////////////////////////////////////////////////////// - // 2D Matrix - //////////////////////////////////////////////////////////////////////////// - /** - * Helper function for printMatrix(). Finds the largest scalar - * in the matrix, then number of digits left of the decimal. - * Call from PMatrix2D and PMatrix3D's print() function. - */ - var printMatrixHelper = function printMatrixHelper(elements) { - var big = 0; - for (var i = 0; i < elements.length; i++) { - if (i !== 0) { - big = Math.max(big, Math.abs(elements[i])); - } else { - big = Math.abs(elements[i]); - } - } - - var digits = (big + "").indexOf("."); - if (digits === 0) { - digits = 1; - } else if (digits === -1) { - digits = (big + "").length; - } - - return digits; - }; - /** - * PMatrix2D is a 3x2 affine matrix implementation. The constructor accepts another PMatrix2D or a list of six float elements. - * If no parameters are provided the matrix is set to the identity matrix. - * - * @param {PMatrix2D} matrix the initial matrix to set to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fifth element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - var PMatrix2D = p.PMatrix2D = function() { - if (arguments.length === 0) { - this.reset(); - } else if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - this.set(arguments[0].array()); - } else if (arguments.length === 6) { - this.set(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); - } - }; - /** - * PMatrix2D methods - */ - PMatrix2D.prototype = { - /** - * @member PMatrix2D - * The set() function sets the matrix elements. The function accepts either another PMatrix2D, an array of elements, or a list of six floats. - * - * @param {PMatrix2D} matrix the matrix to set this matrix to - * @param {float[]} elements an array of elements to set this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fith element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - set: function() { - if (arguments.length === 6) { - var a = arguments; - this.set([a[0], a[1], a[2], - a[3], a[4], a[5]]); - } else if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - this.elements = arguments[0].array(); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - this.elements = arguments[0].slice(); - } - }, - /** - * @member PMatrix2D - * The get() function returns a copy of this PMatrix2D. - * - * @return {PMatrix2D} a copy of this PMatrix2D - */ - get: function() { - var outgoing = new PMatrix2D(); - outgoing.set(this.elements); - return outgoing; - }, - /** - * @member PMatrix2D - * The reset() function sets this PMatrix2D to the identity matrix. - */ - reset: function() { - this.set([1, 0, 0, 0, 1, 0]); - }, - /** - * @member PMatrix2D - * The array() function returns a copy of the element values. - * @addon - * - * @return {float[]} returns a copy of the element values - */ - array: function array() { - return this.elements.slice(); - }, - /** - * @member PMatrix2D - * The translate() function translates this matrix by moving the current coordinates to the location specified by tx and ty. - * - * @param {float} tx the x-axis coordinate to move to - * @param {float} ty the y-axis coordinate to move to - */ - translate: function(tx, ty) { - this.elements[2] = tx * this.elements[0] + ty * this.elements[1] + this.elements[2]; - this.elements[5] = tx * this.elements[3] + ty * this.elements[4] + this.elements[5]; - }, - /** - * @member PMatrix2D - * The transpose() function is not used in processingjs. - */ - transpose: function() { - // Does nothing in Processing. - }, - /** - * @member PMatrix2D - * The mult() function multiplied this matrix. - * If two array elements are passed in the function will multiply a two element vector against this matrix. - * If target is null or not length four, a new float array will be returned. - * The values for vec and target can be the same (though that's less efficient). - * If two PVectors are passed in the function multiply the x and y coordinates of a PVector against this matrix. - * - * @param {PVector} source, target the PVectors used to multiply this matrix - * @param {float[]} source, target the arrays used to multiply this matrix - * - * @return {PVector|float[]} returns a PVector or an array representing the new matrix - */ - mult: function(source, target) { - var x, y; - if (source instanceof PVector) { - x = source.x; - y = source.y; - if (!target) { - target = new PVector(); - } - } else if (source instanceof Array) { - x = source[0]; - y = source[1]; - if (!target) { - target = []; - } - } - if (target instanceof Array) { - target[0] = this.elements[0] * x + this.elements[1] * y + this.elements[2]; - target[1] = this.elements[3] * x + this.elements[4] * y + this.elements[5]; - } else if (target instanceof PVector) { - target.x = this.elements[0] * x + this.elements[1] * y + this.elements[2]; - target.y = this.elements[3] * x + this.elements[4] * y + this.elements[5]; - target.z = 0; - } - return target; - }, - /** - * @member PMatrix2D - * The multX() function calculates the x component of a vector from a transformation. - * - * @param {float} x the x component of the vector being transformed - * @param {float} y the y component of the vector being transformed - * - * @return {float} returnes the result of the calculation - */ - multX: function(x, y) { - return (x * this.elements[0] + y * this.elements[1] + this.elements[2]); - }, - /** - * @member PMatrix2D - * The multY() function calculates the y component of a vector from a transformation. - * - * @param {float} x the x component of the vector being transformed - * @param {float} y the y component of the vector being transformed - * - * @return {float} returnes the result of the calculation - */ - multY: function(x, y) { - return (x * this.elements[3] + y * this.elements[4] + this.elements[5]); - }, - /** - * @member PMatrix2D - * The skewX() function skews the matrix along the x-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewX: function(angle) { - this.apply(1, 0, 1, angle, 0, 0); - }, - /** - * @member PMatrix2D - * The skewY() function skews the matrix along the y-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewY: function(angle) { - this.apply(1, 0, 1, 0, angle, 0); - }, - /** - * @member PMatrix2D - * The determinant() function calvculates the determinant of this matrix. - * - * @return {float} the determinant of the matrix - */ - determinant: function() { - return (this.elements[0] * this.elements[4] - this.elements[1] * this.elements[3]); - }, - /** - * @member PMatrix2D - * The invert() function inverts this matrix - * - * @return {boolean} true if successful - */ - invert: function() { - var d = this.determinant(); - if (Math.abs( d ) > PConstants.MIN_INT) { - var old00 = this.elements[0]; - var old01 = this.elements[1]; - var old02 = this.elements[2]; - var old10 = this.elements[3]; - var old11 = this.elements[4]; - var old12 = this.elements[5]; - this.elements[0] = old11 / d; - this.elements[3] = -old10 / d; - this.elements[1] = -old01 / d; - this.elements[4] = old00 / d; - this.elements[2] = (old01 * old12 - old11 * old02) / d; - this.elements[5] = (old10 * old02 - old00 * old12) / d; - return true; - } - return false; - }, - /** - * @member PMatrix2D - * The scale() function increases or decreases the size of a shape by expanding and contracting vertices. When only one parameter is specified scale will occur in all dimensions. - * This is equivalent to a two parameter call. - * - * @param {float} sx the amount to scale on the x-axis - * @param {float} sy the amount to scale on the y-axis - */ - scale: function(sx, sy) { - if (sx && !sy) { - sy = sx; - } - if (sx && sy) { - this.elements[0] *= sx; - this.elements[1] *= sy; - this.elements[3] *= sx; - this.elements[4] *= sy; - } - }, - /** - * @member PMatrix2D - * The apply() function multiplies the current matrix by the one specified through the parameters. Note that either a PMatrix2D or a list of floats can be passed in. - * - * @param {PMatrix2D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fith element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - apply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - source = arguments[0].array(); - } else if (arguments.length === 6) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - - var result = [0, 0, this.elements[2], - 0, 0, this.elements[5]]; - var e = 0; - for (var row = 0; row < 2; row++) { - for (var col = 0; col < 3; col++, e++) { - result[e] += this.elements[row * 3 + 0] * source[col + 0] + - this.elements[row * 3 + 1] * source[col + 3]; - } - } - this.elements = result.slice(); - }, - /** - * @member PMatrix2D - * The preApply() function applies another matrix to the left of this one. Note that either a PMatrix2D or elements of a matrix can be passed in. - * - * @param {PMatrix2D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the third element of the matrix - * @param {float} m10 the fourth element of the matrix - * @param {float} m11 the fith element of the matrix - * @param {float} m12 the sixth element of the matrix - */ - preApply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix2D) { - source = arguments[0].array(); - } else if (arguments.length === 6) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - var result = [0, 0, source[2], - 0, 0, source[5]]; - result[2] = source[2] + this.elements[2] * source[0] + this.elements[5] * source[1]; - result[5] = source[5] + this.elements[2] * source[3] + this.elements[5] * source[4]; - result[0] = this.elements[0] * source[0] + this.elements[3] * source[1]; - result[3] = this.elements[0] * source[3] + this.elements[3] * source[4]; - result[1] = this.elements[1] * source[0] + this.elements[4] * source[1]; - result[4] = this.elements[1] * source[3] + this.elements[4] * source[4]; - this.elements = result.slice(); - }, - /** - * @member PMatrix2D - * The rotate() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotate: function(angle) { - var c = Math.cos(angle); - var s = Math.sin(angle); - var temp1 = this.elements[0]; - var temp2 = this.elements[1]; - this.elements[0] = c * temp1 + s * temp2; - this.elements[1] = -s * temp1 + c * temp2; - temp1 = this.elements[3]; - temp2 = this.elements[4]; - this.elements[3] = c * temp1 + s * temp2; - this.elements[4] = -s * temp1 + c * temp2; - }, - /** - * @member PMatrix2D - * The rotateZ() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateZ: function(angle) { - this.rotate(angle); - }, - /** - * @member PMatrix2D - * The print() function prints out the elements of this matrix - */ - print: function() { - var digits = printMatrixHelper(this.elements); - var output = "" + p.nfs(this.elements[0], digits, 4) + " " + - p.nfs(this.elements[1], digits, 4) + " " + - p.nfs(this.elements[2], digits, 4) + "\n" + - p.nfs(this.elements[3], digits, 4) + " " + - p.nfs(this.elements[4], digits, 4) + " " + - p.nfs(this.elements[5], digits, 4) + "\n\n"; - p.println(output); - } - }; - - /** - * PMatrix3D is a 4x4 matrix implementation. The constructor accepts another PMatrix3D or a list of six or sixteen float elements. - * If no parameters are provided the matrix is set to the identity matrix. - */ - var PMatrix3D = p.PMatrix3D = function PMatrix3D() { - // When a matrix is created, it is set to an identity matrix - this.reset(); - }; - /** - * PMatrix3D methods - */ - PMatrix3D.prototype = { - /** - * @member PMatrix2D - * The set() function sets the matrix elements. The function accepts either another PMatrix3D, an array of elements, or a list of six or sixteen floats. - * - * @param {PMatrix3D} matrix the initial matrix to set to - * @param {float[]} elements an array of elements to set this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - */ - set: function() { - if (arguments.length === 16) { - this.elements = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof PMatrix3D) { - this.elements = arguments[0].array(); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - this.elements = arguments[0].slice(); - } - }, - /** - * @member PMatrix3D - * The get() function returns a copy of this PMatrix3D. - * - * @return {PMatrix3D} a copy of this PMatrix3D - */ - get: function() { - var outgoing = new PMatrix3D(); - outgoing.set(this.elements); - return outgoing; - }, - /** - * @member PMatrix3D - * The reset() function sets this PMatrix3D to the identity matrix. - */ - reset: function() { - this.set([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The array() function returns a copy of the element values. - * @addon - * - * @return {float[]} returns a copy of the element values - */ - array: function array() { - return this.elements.slice(); - }, - /** - * @member PMatrix3D - * The translate() function translates this matrix by moving the current coordinates to the location specified by tx, ty, and tz. - * - * @param {float} tx the x-axis coordinate to move to - * @param {float} ty the y-axis coordinate to move to - * @param {float} tz the z-axis coordinate to move to - */ - translate: function(tx, ty, tz) { - if (tz === undef) { - tz = 0; - } - - this.elements[3] += tx * this.elements[0] + ty * this.elements[1] + tz * this.elements[2]; - this.elements[7] += tx * this.elements[4] + ty * this.elements[5] + tz * this.elements[6]; - this.elements[11] += tx * this.elements[8] + ty * this.elements[9] + tz * this.elements[10]; - this.elements[15] += tx * this.elements[12] + ty * this.elements[13] + tz * this.elements[14]; - }, - /** - * @member PMatrix2D - * The transpose() function transpose this matrix. - */ - transpose: function() { - var temp = this.elements.slice(); - this.elements[0] = temp[0]; - this.elements[1] = temp[4]; - this.elements[2] = temp[8]; - this.elements[3] = temp[12]; - this.elements[4] = temp[1]; - this.elements[5] = temp[5]; - this.elements[6] = temp[9]; - this.elements[7] = temp[13]; - this.elements[8] = temp[2]; - this.elements[9] = temp[6]; - this.elements[10] = temp[10]; - this.elements[11] = temp[14]; - this.elements[12] = temp[3]; - this.elements[13] = temp[7]; - this.elements[14] = temp[11]; - this.elements[15] = temp[15]; - }, - /** - * @member PMatrix3D - * The mult() function multiplied this matrix. - * If two array elements are passed in the function will multiply a two element vector against this matrix. - * If target is null or not length four, a new float array will be returned. - * The values for vec and target can be the same (though that's less efficient). - * If two PVectors are passed in the function multiply the x and y coordinates of a PVector against this matrix. - * - * @param {PVector} source, target the PVectors used to multiply this matrix - * @param {float[]} source, target the arrays used to multiply this matrix - * - * @return {PVector|float[]} returns a PVector or an array representing the new matrix - */ - mult: function(source, target) { - var x, y, z, w; - if (source instanceof PVector) { - x = source.x; - y = source.y; - z = source.z; - w = 1; - if (!target) { - target = new PVector(); - } - } else if (source instanceof Array) { - x = source[0]; - y = source[1]; - z = source[2]; - w = source[3] || 1; - - if (!target || target.length !== 3 && target.length !== 4) { - target = [0, 0, 0]; - } - } - - if (target instanceof Array) { - if (target.length === 3) { - target[0] = this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3]; - target[1] = this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7]; - target[2] = this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11]; - } else if (target.length === 4) { - target[0] = this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3] * w; - target[1] = this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7] * w; - target[2] = this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11] * w; - target[3] = this.elements[12] * x + this.elements[13] * y + this.elements[14] * z + this.elements[15] * w; - } - } - if (target instanceof PVector) { - target.x = this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3]; - target.y = this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7]; - target.z = this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11]; - } - return target; - }, - /** - * @member PMatrix3D - * The preApply() function applies another matrix to the left of this one. Note that either a PMatrix3D or elements of a matrix can be passed in. - * - * @param {PMatrix3D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - */ - preApply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix3D) { - source = arguments[0].array(); - } else if (arguments.length === 16) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - - var result = [0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0]; - var e = 0; - for (var row = 0; row < 4; row++) { - for (var col = 0; col < 4; col++, e++) { - result[e] += this.elements[col + 0] * source[row * 4 + 0] + this.elements[col + 4] * - source[row * 4 + 1] + this.elements[col + 8] * source[row * 4 + 2] + - this.elements[col + 12] * source[row * 4 + 3]; - } - } - this.elements = result.slice(); - }, - /** - * @member PMatrix3D - * The apply() function multiplies the current matrix by the one specified through the parameters. Note that either a PMatrix3D or a list of floats can be passed in. - * - * @param {PMatrix3D} matrix the matrix to apply this matrix to - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - */ - apply: function() { - var source; - if (arguments.length === 1 && arguments[0] instanceof PMatrix3D) { - source = arguments[0].array(); - } else if (arguments.length === 16) { - source = Array.prototype.slice.call(arguments); - } else if (arguments.length === 1 && arguments[0] instanceof Array) { - source = arguments[0]; - } - - var result = [0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0, 0, 0, 0]; - var e = 0; - for (var row = 0; row < 4; row++) { - for (var col = 0; col < 4; col++, e++) { - result[e] += this.elements[row * 4 + 0] * source[col + 0] + this.elements[row * 4 + 1] * - source[col + 4] + this.elements[row * 4 + 2] * source[col + 8] + - this.elements[row * 4 + 3] * source[col + 12]; - } - } - this.elements = result.slice(); - }, - /** - * @member PMatrix3D - * The rotate() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotate: function(angle, v0, v1, v2) { - if (!v1) { - this.rotateZ(angle); - } else { - // TODO should make sure this vector is normalized - var c = p.cos(angle); - var s = p.sin(angle); - var t = 1.0 - c; - - this.apply((t * v0 * v0) + c, - (t * v0 * v1) - (s * v2), - (t * v0 * v2) + (s * v1), - 0, - (t * v0 * v1) + (s * v2), - (t * v1 * v1) + c, - (t * v1 * v2) - (s * v0), - 0, - (t * v0 * v2) - (s * v1), - (t * v1 * v2) + (s * v0), - (t * v2 * v2) + c, - 0, 0, 0, 0, 1); - } - }, - /** - * @member PMatrix2D - * The invApply() function applies the inverted matrix to this matrix. - * - * @param {float} m00 the first element of the matrix - * @param {float} m01 the second element of the matrix - * @param {float} m02 the third element of the matrix - * @param {float} m03 the fourth element of the matrix - * @param {float} m10 the fifth element of the matrix - * @param {float} m11 the sixth element of the matrix - * @param {float} m12 the seventh element of the matrix - * @param {float} m13 the eight element of the matrix - * @param {float} m20 the nineth element of the matrix - * @param {float} m21 the tenth element of the matrix - * @param {float} m22 the eleventh element of the matrix - * @param {float} m23 the twelveth element of the matrix - * @param {float} m30 the thirteenth element of the matrix - * @param {float} m31 the fourtheenth element of the matrix - * @param {float} m32 the fivetheenth element of the matrix - * @param {float} m33 the sixteenth element of the matrix - * - * @return {boolean} returns true if the operation was successful. - */ - invApply: function() { - if (inverseCopy === undef) { - inverseCopy = new PMatrix3D(); - } - var a = arguments; - inverseCopy.set(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], - a[9], a[10], a[11], a[12], a[13], a[14], a[15]); - - if (!inverseCopy.invert()) { - return false; - } - this.preApply(inverseCopy); - return true; - }, - /** - * @member PMatrix3D - * The rotateZ() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateX: function(angle) { - var c = p.cos(angle); - var s = p.sin(angle); - this.apply([1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The rotateY() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateY: function(angle) { - var c = p.cos(angle); - var s = p.sin(angle); - this.apply([c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The rotateZ() function rotates the matrix. - * - * @param {float} angle the angle of rotation in radiants - */ - rotateZ: function(angle) { - var c = Math.cos(angle); - var s = Math.sin(angle); - this.apply([c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }, - /** - * @member PMatrix3D - * The scale() function increases or decreases the size of a matrix by expanding and contracting vertices. When only one parameter is specified scale will occur in all dimensions. - * This is equivalent to a three parameter call. - * - * @param {float} sx the amount to scale on the x-axis - * @param {float} sy the amount to scale on the y-axis - * @param {float} sz the amount to scale on the z-axis - */ - scale: function(sx, sy, sz) { - if (sx && !sy && !sz) { - sy = sz = sx; - } else if (sx && sy && !sz) { - sz = 1; - } - - if (sx && sy && sz) { - this.elements[0] *= sx; - this.elements[1] *= sy; - this.elements[2] *= sz; - this.elements[4] *= sx; - this.elements[5] *= sy; - this.elements[6] *= sz; - this.elements[8] *= sx; - this.elements[9] *= sy; - this.elements[10] *= sz; - this.elements[12] *= sx; - this.elements[13] *= sy; - this.elements[14] *= sz; - } - }, - /** - * @member PMatrix3D - * The skewX() function skews the matrix along the x-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewX: function(angle) { - var t = Math.tan(angle); - this.apply(1, t, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); - }, - /** - * @member PMatrix3D - * The skewY() function skews the matrix along the y-axis the amount specified by the angle parameter. - * Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * - * @param {float} angle angle of skew specified in radians - */ - skewY: function(angle) { - var t = Math.tan(angle); - this.apply(1, 0, 0, 0, t, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); - }, - multX: function(x, y, z, w) { - if (!z) { - return this.elements[0] * x + this.elements[1] * y + this.elements[3]; - } else if (!w) { - return this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3]; - } else { - return this.elements[0] * x + this.elements[1] * y + this.elements[2] * z + this.elements[3] * w; - } - }, - multY: function(x, y, z, w) { - if (!z) { - return this.elements[4] * x + this.elements[5] * y + this.elements[7]; - } else if (!w) { - return this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7]; - } else { - return this.elements[4] * x + this.elements[5] * y + this.elements[6] * z + this.elements[7] * w; - } - }, - multZ: function(x, y, z, w) { - if (!w) { - return this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11]; - } else { - return this.elements[8] * x + this.elements[9] * y + this.elements[10] * z + this.elements[11] * w; - } - }, - multW: function(x, y, z, w) { - if (!w) { - return this.elements[12] * x + this.elements[13] * y + this.elements[14] * z + this.elements[15]; - } else { - return this.elements[12] * x + this.elements[13] * y + this.elements[14] * z + this.elements[15] * w; - } - }, - /** - * @member PMatrix3D - * The invert() function inverts this matrix - * - * @return {boolean} true if successful - */ - invert: function() { - var fA0 = this.elements[0] * this.elements[5] - this.elements[1] * this.elements[4]; - var fA1 = this.elements[0] * this.elements[6] - this.elements[2] * this.elements[4]; - var fA2 = this.elements[0] * this.elements[7] - this.elements[3] * this.elements[4]; - var fA3 = this.elements[1] * this.elements[6] - this.elements[2] * this.elements[5]; - var fA4 = this.elements[1] * this.elements[7] - this.elements[3] * this.elements[5]; - var fA5 = this.elements[2] * this.elements[7] - this.elements[3] * this.elements[6]; - var fB0 = this.elements[8] * this.elements[13] - this.elements[9] * this.elements[12]; - var fB1 = this.elements[8] * this.elements[14] - this.elements[10] * this.elements[12]; - var fB2 = this.elements[8] * this.elements[15] - this.elements[11] * this.elements[12]; - var fB3 = this.elements[9] * this.elements[14] - this.elements[10] * this.elements[13]; - var fB4 = this.elements[9] * this.elements[15] - this.elements[11] * this.elements[13]; - var fB5 = this.elements[10] * this.elements[15] - this.elements[11] * this.elements[14]; - - // Determinant - var fDet = fA0 * fB5 - fA1 * fB4 + fA2 * fB3 + fA3 * fB2 - fA4 * fB1 + fA5 * fB0; - - // Account for a very small value - // return false if not successful. - if (Math.abs(fDet) <= 1e-9) { - return false; - } - - var kInv = []; - kInv[0] = +this.elements[5] * fB5 - this.elements[6] * fB4 + this.elements[7] * fB3; - kInv[4] = -this.elements[4] * fB5 + this.elements[6] * fB2 - this.elements[7] * fB1; - kInv[8] = +this.elements[4] * fB4 - this.elements[5] * fB2 + this.elements[7] * fB0; - kInv[12] = -this.elements[4] * fB3 + this.elements[5] * fB1 - this.elements[6] * fB0; - kInv[1] = -this.elements[1] * fB5 + this.elements[2] * fB4 - this.elements[3] * fB3; - kInv[5] = +this.elements[0] * fB5 - this.elements[2] * fB2 + this.elements[3] * fB1; - kInv[9] = -this.elements[0] * fB4 + this.elements[1] * fB2 - this.elements[3] * fB0; - kInv[13] = +this.elements[0] * fB3 - this.elements[1] * fB1 + this.elements[2] * fB0; - kInv[2] = +this.elements[13] * fA5 - this.elements[14] * fA4 + this.elements[15] * fA3; - kInv[6] = -this.elements[12] * fA5 + this.elements[14] * fA2 - this.elements[15] * fA1; - kInv[10] = +this.elements[12] * fA4 - this.elements[13] * fA2 + this.elements[15] * fA0; - kInv[14] = -this.elements[12] * fA3 + this.elements[13] * fA1 - this.elements[14] * fA0; - kInv[3] = -this.elements[9] * fA5 + this.elements[10] * fA4 - this.elements[11] * fA3; - kInv[7] = +this.elements[8] * fA5 - this.elements[10] * fA2 + this.elements[11] * fA1; - kInv[11] = -this.elements[8] * fA4 + this.elements[9] * fA2 - this.elements[11] * fA0; - kInv[15] = +this.elements[8] * fA3 - this.elements[9] * fA1 + this.elements[10] * fA0; - - // Inverse using Determinant - var fInvDet = 1.0 / fDet; - kInv[0] *= fInvDet; - kInv[1] *= fInvDet; - kInv[2] *= fInvDet; - kInv[3] *= fInvDet; - kInv[4] *= fInvDet; - kInv[5] *= fInvDet; - kInv[6] *= fInvDet; - kInv[7] *= fInvDet; - kInv[8] *= fInvDet; - kInv[9] *= fInvDet; - kInv[10] *= fInvDet; - kInv[11] *= fInvDet; - kInv[12] *= fInvDet; - kInv[13] *= fInvDet; - kInv[14] *= fInvDet; - kInv[15] *= fInvDet; - - this.elements = kInv.slice(); - return true; - }, - toString: function() { - var str = ""; - for (var i = 0; i < 15; i++) { - str += this.elements[i] + ", "; - } - str += this.elements[15]; - return str; - }, - /** - * @member PMatrix3D - * The print() function prints out the elements of this matrix - */ - print: function() { - var digits = printMatrixHelper(this.elements); - - var output = "" + p.nfs(this.elements[0], digits, 4) + " " + p.nfs(this.elements[1], digits, 4) + - " " + p.nfs(this.elements[2], digits, 4) + " " + p.nfs(this.elements[3], digits, 4) + - "\n" + p.nfs(this.elements[4], digits, 4) + " " + p.nfs(this.elements[5], digits, 4) + - " " + p.nfs(this.elements[6], digits, 4) + " " + p.nfs(this.elements[7], digits, 4) + - "\n" + p.nfs(this.elements[8], digits, 4) + " " + p.nfs(this.elements[9], digits, 4) + - " " + p.nfs(this.elements[10], digits, 4) + " " + p.nfs(this.elements[11], digits, 4) + - "\n" + p.nfs(this.elements[12], digits, 4) + " " + p.nfs(this.elements[13], digits, 4) + - " " + p.nfs(this.elements[14], digits, 4) + " " + p.nfs(this.elements[15], digits, 4) + "\n\n"; - p.println(output); - }, - invTranslate: function(tx, ty, tz) { - this.preApply(1, 0, 0, -tx, 0, 1, 0, -ty, 0, 0, 1, -tz, 0, 0, 0, 1); - }, - invRotateX: function(angle) { - var c = Math.cos(-angle); - var s = Math.sin(-angle); - this.preApply([1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1]); - }, - invRotateY: function(angle) { - var c = Math.cos(-angle); - var s = Math.sin(-angle); - this.preApply([c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1]); - }, - invRotateZ: function(angle) { - var c = Math.cos(-angle); - var s = Math.sin(-angle); - this.preApply([c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }, - invScale: function(x, y, z) { - this.preApply([1 / x, 0, 0, 0, 0, 1 / y, 0, 0, 0, 0, 1 / z, 0, 0, 0, 0, 1]); - } - }; - - /** - * @private - * The matrix stack stores the transformations and translations that occur within the space. - */ - var PMatrixStack = p.PMatrixStack = function PMatrixStack() { - this.matrixStack = []; - }; - - /** - * @member PMatrixStack - * load pushes the matrix given in the function into the stack - * - * @param {Object | Array} matrix the matrix to be pushed into the stack - */ - PMatrixStack.prototype.load = function load() { - var tmpMatrix; - if (p.use3DContext) { - tmpMatrix = new PMatrix3D(); - } else { - tmpMatrix = new PMatrix2D(); - } - - if (arguments.length === 1) { - tmpMatrix.set(arguments[0]); - } else { - tmpMatrix.set(arguments); - } - this.matrixStack.push(tmpMatrix); - }; - - /** - * @member PMatrixStack - * push adds a duplicate of the top of the stack onto the stack - uses the peek function - */ - PMatrixStack.prototype.push = function push() { - this.matrixStack.push(this.peek()); - }; - - /** - * @member PMatrixStack - * pop removes returns the matrix at the top of the stack - * - * @returns {Object} the matrix at the top of the stack - */ - PMatrixStack.prototype.pop = function pop() { - return this.matrixStack.pop(); - }; - - /** - * @member PMatrixStack - * peek returns but doesn't remove the matrix at the top of the stack - * - * @returns {Object} the matrix at the top of the stack - */ - PMatrixStack.prototype.peek = function peek() { - var tmpMatrix; - if (p.use3DContext) { - tmpMatrix = new PMatrix3D(); - } else { - tmpMatrix = new PMatrix2D(); - } - - tmpMatrix.set(this.matrixStack[this.matrixStack.length - 1]); - return tmpMatrix; - }; - - /** - * @member PMatrixStack - * this function multiplies the matrix at the top of the stack with the matrix given as a parameter - * - * @param {Object | Array} matrix the matrix to be multiplied into the stack - */ - PMatrixStack.prototype.mult = function mult(matrix) { - this.matrixStack[this.matrixStack.length - 1].apply(matrix); - }; - - //////////////////////////////////////////////////////////////////////////// - // Array handling - //////////////////////////////////////////////////////////////////////////// - - /** - * The split() function breaks a string into pieces using a character or string - * as the divider. The delim parameter specifies the character or characters that - * mark the boundaries between each piece. A String[] array is returned that contains - * each of the pieces. - * If the result is a set of numbers, you can convert the String[] array to to a float[] - * or int[] array using the datatype conversion functions int() and float() (see example above). - * The splitTokens() function works in a similar fashion, except that it splits using a range - * of characters instead of a specific character or sequence. - * - * @param {String} str the String to be split - * @param {String} delim the character or String used to separate the data - * - * @returns {string[]} The new string array - * - * @see splitTokens - * @see join - * @see trim - */ - p.split = function(str, delim) { - return str.split(delim); - }; - - /** - * The splitTokens() function splits a String at one or many character "tokens." The tokens - * parameter specifies the character or characters to be used as a boundary. - * If no tokens character is specified, any whitespace character is used to split. - * Whitespace characters include tab (\t), line feed (\n), carriage return (\r), form - * feed (\f), and space. To convert a String to an array of integers or floats, use the - * datatype conversion functions int() and float() to convert the array of Strings. - * - * @param {String} str the String to be split - * @param {Char[]} tokens list of individual characters that will be used as separators - * - * @returns {string[]} The new string array - * - * @see split - * @see join - * @see trim - */ - p.splitTokens = function(str, tokens) { - if (arguments.length === 1) { - tokens = "\n\t\r\f "; - } - - tokens = "[" + tokens + "]"; - - var ary = []; - var index = 0; - var pos = str.search(tokens); - - while (pos >= 0) { - if (pos === 0) { - str = str.substring(1); - } else { - ary[index] = str.substring(0, pos); - index++; - str = str.substring(pos); - } - pos = str.search(tokens); - } - - if (str.length > 0) { - ary[index] = str; - } - - if (ary.length === 0) { - ary = undef; - } - - return ary; - }; - - /** - * Expands an array by one element and adds data to the new position. The datatype of - * the element parameter must be the same as the datatype of the array. - * When using an array of objects, the data returned from the function must be cast to - * the object array's data type. For example: SomeClass[] items = (SomeClass[]) - * append(originalArray, element). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array boolean[], - * byte[], char[], int[], float[], or String[], or an array of objects - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} element new data for the array - * - * @returns Array (the same datatype as the input) - * - * @see shorten - * @see expand - */ - p.append = function(array, element) { - array[array.length] = element; - return array; - }; - - /** - * Concatenates two arrays. For example, concatenating the array { 1, 2, 3 } and the - * array { 4, 5, 6 } yields { 1, 2, 3, 4, 5, 6 }. Both parameters must be arrays of the - * same datatype. - * When using an array of objects, the data returned from the function must be cast to the - * object array's data type. For example: SomeClass[] items = (SomeClass[]) concat(array1, array2). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array1 boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array2 boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * - * @returns Array (the same datatype as the input) - * - * @see splice - */ - p.concat = function(array1, array2) { - return array1.concat(array2); - }; - - /** - * Sorts an array of numbers from smallest to largest and puts an array of - * words in alphabetical order. The original array is not modified, a - * re-ordered array is returned. The count parameter states the number of - * elements to sort. For example if there are 12 elements in an array and - * if count is the value 5, only the first five elements on the array will - * be sorted. Alphabetical ordering is case insensitive. - * - * @param {String[] | int[] | float[]} array Array of elements to sort - * @param {int} numElem Number of elements to sort - * - * @returns {String[] | int[] | float[]} Array (same datatype as the input) - * - * @see reverse - */ - p.sort = function(array, numElem) { - var ret = []; - - // depending on the type used (int, float) or string - // we'll need to use a different compare function - if (array.length > 0) { - // copy since we need to return another array - var elemsToCopy = numElem > 0 ? numElem : array.length; - for (var i = 0; i < elemsToCopy; i++) { - ret.push(array[i]); - } - if (typeof array[0] === "string") { - ret.sort(); - } - // int or float - else { - ret.sort(function(a, b) { - return a - b; - }); - } - - // copy on the rest of the elements that were not sorted in case the user - // only wanted a subset of an array to be sorted. - if (numElem > 0) { - for (var j = ret.length; j < array.length; j++) { - ret.push(array[j]); - } - } - } - return ret; - }; - - /** - * Inserts a value or array of values into an existing array. The first two parameters must - * be of the same datatype. The array parameter defines the array which will be modified - * and the second parameter defines the data which will be inserted. When using an array - * of objects, the data returned from the function must be cast to the object array's data - * type. For example: SomeClass[] items = (SomeClass[]) splice(array1, array2, index). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * @param {boolean|byte|char|int|float|String|boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} - * value boolean, byte, char, int, float, String, boolean[], byte[], char[], int[], - * float[], String[], or other Object: value or an array of objects to be spliced in - * @param {int} index position in the array from which to insert data - * - * @returns Array (the same datatype as the input) - * - * @see contract - * @see subset - */ - p.splice = function(array, value, index) { - - // Trying to splice an empty array into "array" in P5 won't do - // anything, just return the original. - if(value.length === 0) - { - return array; - } - - // If the second argument was an array, we'll need to iterate over all - // the "value" elements and add one by one because - // array.splice(index, 0, value); - // would create a multi-dimensional array which isn't what we want. - if(value instanceof Array) { - for(var i = 0, j = index; i < value.length; j++,i++) { - array.splice(j, 0, value[i]); - } - } else { - array.splice(index, 0, value); - } - - return array; - }; - - /** - * Extracts an array of elements from an existing array. The array parameter defines the - * array from which the elements will be copied and the offset and length parameters determine - * which elements to extract. If no length is given, elements will be extracted from the offset - * to the end of the array. When specifying the offset remember the first array element is 0. - * This function does not change the source array. - * When using an array of objects, the data returned from the function must be cast to the - * object array's data type. - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array boolean[], - * byte[], char[], int[], float[], String[], or an array of objects - * @param {int} offset position to begin - * @param {int} length number of values to extract - * - * @returns Array (the same datatype as the input) - * - * @see splice - */ - p.subset = function(array, offset, length) { - if (arguments.length === 2) { - return array.slice(offset, array.length - offset); - } else if (arguments.length === 3) { - return array.slice(offset, offset + length); - } - }; - - /** - * Combines an array of Strings into one String, each separated by the character(s) used for - * the separator parameter. To join arrays of ints or floats, it's necessary to first convert - * them to strings using nf() or nfs(). - * - * @param {Array} array array of Strings - * @param {char|String} separator char or String to be placed between each item - * - * @returns {String} The combined string - * - * @see split - * @see trim - * @see nf - * @see nfs - */ - p.join = function(array, seperator) { - return array.join(seperator); - }; - - /** - * Decreases an array by one element and returns the shortened array. When using an - * array of objects, the data returned from the function must be cast to the object array's - * data type. For example: SomeClass[] items = (SomeClass[]) shorten(originalArray). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} array - * boolean[], byte[], char[], int[], float[], or String[], or an array of objects - * - * @returns Array (the same datatype as the input) - * - * @see append - * @see expand - */ - p.shorten = function(ary) { - var newary = []; - - // copy array into new array - var len = ary.length; - for (var i = 0; i < len; i++) { - newary[i] = ary[i]; - } - newary.pop(); - - return newary; - }; - - /** - * Increases the size of an array. By default, this function doubles the size of the array, - * but the optional newSize parameter provides precise control over the increase in size. - * When using an array of objects, the data returned from the function must be cast to the - * object array's data type. For example: SomeClass[] items = (SomeClass[]) expand(originalArray). - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]|array of objects} ary - * boolean[], byte[], char[], int[], float[], String[], or an array of objects - * @param {int} newSize positive int: new size for the array - * - * @returns Array (the same datatype as the input) - * - * @see contract - */ - p.expand = function(ary, newSize) { - var temp = ary.slice(0); - if (arguments.length === 1) { - // double size of array - temp.length = ary.length * 2; - return temp; - } else if (arguments.length === 2) { - // size is newSize - temp.length = newSize; - return temp; - } - }; - - /** - * Copies an array (or part of an array) to another array. The src array is copied to the - * dst array, beginning at the position specified by srcPos and into the position specified - * by dstPos. The number of elements to copy is determined by length. The simplified version - * with two arguments copies an entire array to another of the same size. It is equivalent - * to "arrayCopy(src, 0, dst, 0, src.length)". This function is far more efficient for copying - * array data than iterating through a for and copying each element. - * - * @param {Array} src an array of any data type: the source array - * @param {Array} dest an array of any data type (as long as it's the same as src): the destination array - * @param {int} srcPos starting position in the source array - * @param {int} destPos starting position in the destination array - * @param {int} length number of array elements to be copied - * - * @returns none - */ - p.arrayCopy = function() { // src, srcPos, dest, destPos, length) { - var src, srcPos = 0, dest, destPos = 0, length; - - if (arguments.length === 2) { - // recall itself and copy src to dest from start index 0 to 0 of src.length - src = arguments[0]; - dest = arguments[1]; - length = src.length; - } else if (arguments.length === 3) { - // recall itself and copy src to dest from start index 0 to 0 of length - src = arguments[0]; - dest = arguments[1]; - length = arguments[2]; - } else if (arguments.length === 5) { - src = arguments[0]; - srcPos = arguments[1]; - dest = arguments[2]; - destPos = arguments[3]; - length = arguments[4]; - } - - // copy src to dest from index srcPos to index destPos of length recursivly on objects - for (var i = srcPos, j = destPos; i < length + srcPos; i++, j++) { - if (dest[j] !== undef) { - dest[j] = src[i]; - } else { - throw "array index out of bounds exception"; - } - } - }; - - /** - * Reverses the order of an array. - * - * @param {boolean[]|byte[]|char[]|int[]|float[]|String[]} array - * boolean[], byte[], char[], int[], float[], or String[] - * - * @returns Array (the same datatype as the input) - * - * @see sort - */ - p.reverse = function(array) { - return array.reverse(); - }; - - - //////////////////////////////////////////////////////////////////////////// - // Color functions - //////////////////////////////////////////////////////////////////////////// - - // helper functions for internal blending modes - p.mix = function(a, b, f) { - return a + (((b - a) * f) >> 8); - }; - - p.peg = function(n) { - return (n < 0) ? 0 : ((n > 255) ? 255 : n); - }; - - // blending modes - /** - * These are internal blending modes used for BlendColor() - * - * @param {Color} c1 First Color to blend - * @param {Color} c2 Second Color to blend - * - * @returns {Color} The blended Color - * - * @see BlendColor - * @see Blend - */ - p.modes = { - replace: function(c1, c2) { - return c2; - }, - blend: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - p.mix(c1 & PConstants.RED_MASK, c2 & PConstants.RED_MASK, f) & PConstants.RED_MASK | - p.mix(c1 & PConstants.GREEN_MASK, c2 & PConstants.GREEN_MASK, f) & PConstants.GREEN_MASK | - p.mix(c1 & PConstants.BLUE_MASK, c2 & PConstants.BLUE_MASK, f)); - }, - add: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - Math.min(((c1 & PConstants.RED_MASK) + ((c2 & PConstants.RED_MASK) >> 8) * f), PConstants.RED_MASK) & PConstants.RED_MASK | - Math.min(((c1 & PConstants.GREEN_MASK) + ((c2 & PConstants.GREEN_MASK) >> 8) * f), PConstants.GREEN_MASK) & PConstants.GREEN_MASK | - Math.min((c1 & PConstants.BLUE_MASK) + (((c2 & PConstants.BLUE_MASK) * f) >> 8), PConstants.BLUE_MASK)); - }, - subtract: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - Math.max(((c1 & PConstants.RED_MASK) - ((c2 & PConstants.RED_MASK) >> 8) * f), PConstants.GREEN_MASK) & PConstants.RED_MASK | - Math.max(((c1 & PConstants.GREEN_MASK) - ((c2 & PConstants.GREEN_MASK) >> 8) * f), PConstants.BLUE_MASK) & PConstants.GREEN_MASK | - Math.max((c1 & PConstants.BLUE_MASK) - (((c2 & PConstants.BLUE_MASK) * f) >> 8), 0)); - }, - lightest: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - Math.max(c1 & PConstants.RED_MASK, ((c2 & PConstants.RED_MASK) >> 8) * f) & PConstants.RED_MASK | - Math.max(c1 & PConstants.GREEN_MASK, ((c2 & PConstants.GREEN_MASK) >> 8) * f) & PConstants.GREEN_MASK | - Math.max(c1 & PConstants.BLUE_MASK, ((c2 & PConstants.BLUE_MASK) * f) >> 8)); - }, - darkest: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - p.mix(c1 & PConstants.RED_MASK, Math.min(c1 & PConstants.RED_MASK, ((c2 & PConstants.RED_MASK) >> 8) * f), f) & PConstants.RED_MASK | - p.mix(c1 & PConstants.GREEN_MASK, Math.min(c1 & PConstants.GREEN_MASK, ((c2 & PConstants.GREEN_MASK) >> 8) * f), f) & PConstants.GREEN_MASK | - p.mix(c1 & PConstants.BLUE_MASK, Math.min(c1 & PConstants.BLUE_MASK, ((c2 & PConstants.BLUE_MASK) * f) >> 8), f)); - }, - difference: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (ar > br) ? (ar - br) : (br - ar); - var cg = (ag > bg) ? (ag - bg) : (bg - ag); - var cb = (ab > bb) ? (ab - bb) : (bb - ab); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - exclusion: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = ar + br - ((ar * br) >> 7); - var cg = ag + bg - ((ag * bg) >> 7); - var cb = ab + bb - ((ab * bb) >> 7); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - multiply: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (ar * br) >> 8; - var cg = (ag * bg) >> 8; - var cb = (ab * bb) >> 8; - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - screen: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = 255 - (((255 - ar) * (255 - br)) >> 8); - var cg = 255 - (((255 - ag) * (255 - bg)) >> 8); - var cb = 255 - (((255 - ab) * (255 - bb)) >> 8); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - hard_light: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (br < 128) ? ((ar * br) >> 7) : (255 - (((255 - ar) * (255 - br)) >> 7)); - var cg = (bg < 128) ? ((ag * bg) >> 7) : (255 - (((255 - ag) * (255 - bg)) >> 7)); - var cb = (bb < 128) ? ((ab * bb) >> 7) : (255 - (((255 - ab) * (255 - bb)) >> 7)); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - soft_light: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = ((ar * br) >> 7) + ((ar * ar) >> 8) - ((ar * ar * br) >> 15); - var cg = ((ag * bg) >> 7) + ((ag * ag) >> 8) - ((ag * ag * bg) >> 15); - var cb = ((ab * bb) >> 7) + ((ab * ab) >> 8) - ((ab * ab * bb) >> 15); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - overlay: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (ar < 128) ? ((ar * br) >> 7) : (255 - (((255 - ar) * (255 - br)) >> 7)); - var cg = (ag < 128) ? ((ag * bg) >> 7) : (255 - (((255 - ag) * (255 - bg)) >> 7)); - var cb = (ab < 128) ? ((ab * bb) >> 7) : (255 - (((255 - ab) * (255 - bb)) >> 7)); - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - dodge: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (br === 255) ? 255 : p.peg((ar << 8) / (255 - br)); // division requires pre-peg()-ing - var cg = (bg === 255) ? 255 : p.peg((ag << 8) / (255 - bg)); // " - var cb = (bb === 255) ? 255 : p.peg((ab << 8) / (255 - bb)); // " - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - }, - burn: function(c1, c2) { - var f = (c2 & PConstants.ALPHA_MASK) >>> 24; - var ar = (c1 & PConstants.RED_MASK) >> 16; - var ag = (c1 & PConstants.GREEN_MASK) >> 8; - var ab = (c1 & PConstants.BLUE_MASK); - var br = (c2 & PConstants.RED_MASK) >> 16; - var bg = (c2 & PConstants.GREEN_MASK) >> 8; - var bb = (c2 & PConstants.BLUE_MASK); - // formula: - var cr = (br === 0) ? 0 : 255 - p.peg(((255 - ar) << 8) / br); // division requires pre-peg()-ing - var cg = (bg === 0) ? 0 : 255 - p.peg(((255 - ag) << 8) / bg); // " - var cb = (bb === 0) ? 0 : 255 - p.peg(((255 - ab) << 8) / bb); // " - // alpha blend (this portion will always be the same) - return (Math.min(((c1 & PConstants.ALPHA_MASK) >>> 24) + f, 0xff) << 24 | - (p.peg(ar + (((cr - ar) * f) >> 8)) << 16) | - (p.peg(ag + (((cg - ag) * f) >> 8)) << 8) | - (p.peg(ab + (((cb - ab) * f) >> 8)))); - } - }; - - function color$4(aValue1, aValue2, aValue3, aValue4) { - var r, g, b, a; - - if (curColorMode === PConstants.HSB) { - var rgb = p.color.toRGB(aValue1, aValue2, aValue3); - r = rgb[0]; - g = rgb[1]; - b = rgb[2]; - } else { - r = Math.round(255 * (aValue1 / colorModeX)); - g = Math.round(255 * (aValue2 / colorModeY)); - b = Math.round(255 * (aValue3 / colorModeZ)); - } - - a = Math.round(255 * (aValue4 / colorModeA)); - - // Limit values greater than 255 - r = (r > 255) ? 255 : r; - g = (g > 255) ? 255 : g; - b = (b > 255) ? 255 : b; - a = (a > 255) ? 255 : a; - - // Create color int - return (a << 24) & PConstants.ALPHA_MASK | (r << 16) & PConstants.RED_MASK | (g << 8) & PConstants.GREEN_MASK | b & PConstants.BLUE_MASK; - } - - function color$2(aValue1, aValue2) { - var a; - - // Color int and alpha - if (aValue1 & PConstants.ALPHA_MASK) { - a = Math.round(255 * (aValue2 / colorModeA)); - a = (a > 255) ? 255 : a; - - return aValue1 - (aValue1 & PConstants.ALPHA_MASK) + ((a << 24) & PConstants.ALPHA_MASK); - } - // Grayscale and alpha - else { - if (curColorMode === PConstants.RGB) { - return color$4(aValue1, aValue1, aValue1, aValue2); - } else if (curColorMode === PConstants.HSB) { - return color$4(0, 0, (aValue1 / colorModeX) * colorModeZ, aValue2); - } - } - } - - function color$1(aValue1) { - // Grayscale - if (aValue1 <= colorModeX && aValue1 >= 0) { - if (curColorMode === PConstants.RGB) { - return color$4(aValue1, aValue1, aValue1, colorModeA); - } else if (curColorMode === PConstants.HSB) { - return color$4(0, 0, (aValue1 / colorModeX) * colorModeZ, colorModeA); - } - } - // Color int - else if (aValue1) { - return aValue1; - } - } - - /** - * Creates colors for storing in variables of the color datatype. The parameters are - * interpreted as RGB or HSB values depending on the current colorMode(). The default - * mode is RGB values from 0 to 255 and therefore, the function call color(255, 204, 0) - * will return a bright yellow color. More about how colors are stored can be found in - * the reference for the color datatype. - * - * @param {int|float} aValue1 red or hue or grey values relative to the current color range. - * Also can be color value in hexadecimal notation (i.e. #FFCC00 or 0xFFFFCC00) - * @param {int|float} aValue2 green or saturation values relative to the current color range - * @param {int|float} aValue3 blue or brightness values relative to the current color range - * @param {int|float} aValue4 relative to current color range. Represents alpha - * - * @returns {color} the color - * - * @see colorMode - */ - p.color = function color(aValue1, aValue2, aValue3, aValue4) { - // 4 arguments: (R, G, B, A) or (H, S, B, A) - if (aValue1 !== undef && aValue2 !== undef && aValue3 !== undef && aValue4 !== undef) { - return color$4(aValue1, aValue2, aValue3, aValue4); - } - - // 3 arguments: (R, G, B) or (H, S, B) - else if (aValue1 !== undef && aValue2 !== undef && aValue3 !== undef) { - return color$4(aValue1, aValue2, aValue3, colorModeA); - } - - // 2 arguments: (Color, A) or (Grayscale, A) - else if (aValue1 !== undef && aValue2 !== undef) { - return color$2(aValue1, aValue2); - } - - // 1 argument: (Grayscale) or (Color) - else if (typeof aValue1 === "number") { - return color$1(aValue1); - } - - // Default - else { - return color$4(colorModeX, colorModeY, colorModeZ, colorModeA); - } - }; - - // Ease of use function to extract the colour bits into a string - p.color.toString = function(colorInt) { - return "rgba(" + ((colorInt & PConstants.RED_MASK) >>> 16) + "," + ((colorInt & PConstants.GREEN_MASK) >>> 8) + - "," + ((colorInt & PConstants.BLUE_MASK)) + "," + ((colorInt & PConstants.ALPHA_MASK) >>> 24) / 255 + ")"; - }; - - // Easy of use function to pack rgba values into a single bit-shifted color int. - p.color.toInt = function(r, g, b, a) { - return (a << 24) & PConstants.ALPHA_MASK | (r << 16) & PConstants.RED_MASK | (g << 8) & PConstants.GREEN_MASK | b & PConstants.BLUE_MASK; - }; - - // Creates a simple array in [R, G, B, A] format, [255, 255, 255, 255] - p.color.toArray = function(colorInt) { - return [(colorInt & PConstants.RED_MASK) >>> 16, (colorInt & PConstants.GREEN_MASK) >>> 8, - colorInt & PConstants.BLUE_MASK, (colorInt & PConstants.ALPHA_MASK) >>> 24]; - }; - - // Creates a WebGL color array in [R, G, B, A] format. WebGL wants the color ranges between 0 and 1, [1, 1, 1, 1] - p.color.toGLArray = function(colorInt) { - return [((colorInt & PConstants.RED_MASK) >>> 16) / 255, ((colorInt & PConstants.GREEN_MASK) >>> 8) / 255, - (colorInt & PConstants.BLUE_MASK) / 255, ((colorInt & PConstants.ALPHA_MASK) >>> 24) / 255]; - }; - - // HSB conversion function from Mootools, MIT Licensed - p.color.toRGB = function(h, s, b) { - // Limit values greater than range - h = (h > colorModeX) ? colorModeX : h; - s = (s > colorModeY) ? colorModeY : s; - b = (b > colorModeZ) ? colorModeZ : b; - - h = (h / colorModeX) * 360; - s = (s / colorModeY) * 100; - b = (b / colorModeZ) * 100; - - var br = Math.round(b / 100 * 255); - - if (s === 0) { // Grayscale - return [br, br, br]; - } else { - var hue = h % 360; - var f = hue % 60; - var p = Math.round((b * (100 - s)) / 10000 * 255); - var q = Math.round((b * (6000 - s * f)) / 600000 * 255); - var t = Math.round((b * (6000 - s * (60 - f))) / 600000 * 255); - switch (Math.floor(hue / 60)) { - case 0: - return [br, t, p]; - case 1: - return [q, br, p]; - case 2: - return [p, br, t]; - case 3: - return [p, q, br]; - case 4: - return [t, p, br]; - case 5: - return [br, p, q]; - } - } - }; - - p.color.toHSB = function( colorInt ) { - var red, green, blue; - - red = ((colorInt & PConstants.RED_MASK) >>> 16) / 255; - green = ((colorInt & PConstants.GREEN_MASK) >>> 8) / 255; - blue = (colorInt & PConstants.BLUE_MASK) / 255; - - var max = p.max(p.max(red,green), blue), - min = p.min(p.min(red,green), blue), - hue, saturation; - - if (min === max) { - return [0, 0, max]; - } else { - saturation = (max - min) / max; - - if (red === max) { - hue = (green - blue) / (max - min); - } else if (green === max) { - hue = 2 + ((blue - red) / (max - min)); - } else { - hue = 4 + ((red - green) / (max - min)); - } - - hue /= 6; - - if (hue < 0) { - hue += 1; - } else if (hue > 1) { - hue -= 1; - } - } - return [hue*colorModeX, saturation*colorModeY, max*colorModeZ]; - }; - - /** - * Extracts the brightness value from a color. - * - * @param {color} colInt any value of the color datatype - * - * @returns {float} The brightness color value. - * - * @see red - * @see green - * @see blue - * @see hue - * @see saturation - */ - p.brightness = function(colInt){ - return p.color.toHSB(colInt)[2]; - }; - - /** - * Extracts the saturation value from a color. - * - * @param {color} colInt any value of the color datatype - * - * @returns {float} The saturation color value. - * - * @see red - * @see green - * @see blue - * @see hue - * @see brightness - */ - p.saturation = function(colInt){ - return p.color.toHSB(colInt)[1]; - }; - - /** - * Extracts the hue value from a color. - * - * @param {color} colInt any value of the color datatype - * - * @returns {float} The hue color value. - * - * @see red - * @see green - * @see blue - * @see saturation - * @see brightness - */ - p.hue = function(colInt){ - return p.color.toHSB(colInt)[0]; - }; - - var verifyChannel = function verifyChannel(aColor) { - if (aColor.constructor === Array) { - return aColor; - } else { - return p.color(aColor); - } - }; - - /** - * Extracts the red value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The red color value. - * - * @see green - * @see blue - * @see alpha - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.red = function(aColor) { - return ((aColor & PConstants.RED_MASK) >>> 16) / 255 * colorModeX; - }; - - /** - * Extracts the green value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The green color value. - * - * @see red - * @see blue - * @see alpha - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.green = function(aColor) { - return ((aColor & PConstants.GREEN_MASK) >>> 8) / 255 * colorModeY; - }; - - /** - * Extracts the blue value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The blue color value. - * - * @see red - * @see green - * @see alpha - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.blue = function(aColor) { - return (aColor & PConstants.BLUE_MASK) / 255 * colorModeZ; - }; - - /** - * Extracts the alpha value from a color, scaled to match current colorMode(). - * This value is always returned as a float so be careful not to assign it to an int value. - * - * @param {color} aColor any value of the color datatype - * - * @returns {float} The alpha color value. - * - * @see red - * @see green - * @see blue - * @see >> right shift - * @see hue - * @see saturation - * @see brightness - */ - p.alpha = function(aColor) { - return ((aColor & PConstants.ALPHA_MASK) >>> 24) / 255 * colorModeA; - }; - - /** - * Calculates a color or colors between two colors at a specific increment. - * The amt parameter is the amount to interpolate between the two values where 0.0 - * equal to the first point, 0.1 is very near the first point, 0.5 is half-way in between, etc. - * - * @param {color} c1 interpolate from this color - * @param {color} c2 interpolate to this color - * @param {float} amt between 0.0 and 1.0 - * - * @returns {float} The blended color. - * - * @see blendColor - * @see color - */ - p.lerpColor = function lerpColor(c1, c2, amt) { - // Get RGBA values for Color 1 to floats - var colorBits1 = p.color(c1); - var r1 = (colorBits1 & PConstants.RED_MASK) >>> 16; - var g1 = (colorBits1 & PConstants.GREEN_MASK) >>> 8; - var b1 = (colorBits1 & PConstants.BLUE_MASK); - var a1 = ((colorBits1 & PConstants.ALPHA_MASK) >>> 24) / colorModeA; - - // Get RGBA values for Color 2 to floats - var colorBits2 = p.color(c2); - var r2 = (colorBits2 & PConstants.RED_MASK) >>> 16; - var g2 = (colorBits2 & PConstants.GREEN_MASK) >>> 8; - var b2 = (colorBits2 & PConstants.BLUE_MASK); - var a2 = ((colorBits2 & PConstants.ALPHA_MASK) >>> 24) / colorModeA; - - // Return lerp value for each channel, INT for color, Float for Alpha-range - var r = parseInt(p.lerp(r1, r2, amt), 10); - var g = parseInt(p.lerp(g1, g2, amt), 10); - var b = parseInt(p.lerp(b1, b2, amt), 10); - var a = parseFloat(p.lerp(a1, a2, amt) * colorModeA); - - return p.color.toInt(r, g, b, a); - }; - - // Forced default color mode for #aaaaaa style - /** - * Convert 3 int values to a color in the default color mode RGB even if curColorMode is not set to RGB - * - * @param {int} aValue1 range for the red color - * @param {int} aValue2 range for the green color - * @param {int} aValue3 range for the blue color - * - * @returns {Color} - * - * @see color - */ - p.defaultColor = function(aValue1, aValue2, aValue3) { - var tmpColorMode = curColorMode; - curColorMode = PConstants.RGB; - var c = p.color(aValue1 / 255 * colorModeX, aValue2 / 255 * colorModeY, aValue3 / 255 * colorModeZ); - curColorMode = tmpColorMode; - return c; - }; - - /** - * Changes the way Processing interprets color data. By default, fill(), stroke(), and background() - * colors are set by values between 0 and 255 using the RGB color model. It is possible to change the - * numerical range used for specifying colors and to switch color systems. For example, calling colorMode(RGB, 1.0) - * will specify that values are specified between 0 and 1. The limits for defining colors are altered by setting the - * parameters range1, range2, range3, and range 4. - * - * @param {MODE} mode Either RGB or HSB, corresponding to Red/Green/Blue and Hue/Saturation/Brightness - * @param {int|float} range range for all color elements - * @param {int|float} range1 range for the red or hue depending on the current color mode - * @param {int|float} range2 range for the green or saturation depending on the current color mode - * @param {int|float} range3 range for the blue or brightness depending on the current color mode - * @param {int|float} range4 range for the alpha - * - * @returns none - * - * @see background - * @see fill - * @see stroke - */ - p.colorMode = function colorMode() { // mode, range1, range2, range3, range4 - curColorMode = arguments[0]; - if (arguments.length > 1) { - colorModeX = arguments[1]; - colorModeY = arguments[2] || arguments[1]; - colorModeZ = arguments[3] || arguments[1]; - colorModeA = arguments[4] || arguments[1]; - } - }; - - /** - * Blends two color values together based on the blending mode given as the MODE parameter. - * The possible modes are described in the reference for the blend() function. - * - * @param {color} c1 color: the first color to blend - * @param {color} c2 color: the second color to blend - * @param {MODE} MODE Either BLEND, ADD, SUBTRACT, DARKEST, LIGHTEST, DIFFERENCE, EXCLUSION, MULTIPLY, - * SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, or BURN - * - * @returns {float} The blended color. - * - * @see blend - * @see color - */ - p.blendColor = function(c1, c2, mode) { - var color = 0; - switch (mode) { - case PConstants.REPLACE: - color = p.modes.replace(c1, c2); - break; - case PConstants.BLEND: - color = p.modes.blend(c1, c2); - break; - case PConstants.ADD: - color = p.modes.add(c1, c2); - break; - case PConstants.SUBTRACT: - color = p.modes.subtract(c1, c2); - break; - case PConstants.LIGHTEST: - color = p.modes.lightest(c1, c2); - break; - case PConstants.DARKEST: - color = p.modes.darkest(c1, c2); - break; - case PConstants.DIFFERENCE: - color = p.modes.difference(c1, c2); - break; - case PConstants.EXCLUSION: - color = p.modes.exclusion(c1, c2); - break; - case PConstants.MULTIPLY: - color = p.modes.multiply(c1, c2); - break; - case PConstants.SCREEN: - color = p.modes.screen(c1, c2); - break; - case PConstants.HARD_LIGHT: - color = p.modes.hard_light(c1, c2); - break; - case PConstants.SOFT_LIGHT: - color = p.modes.soft_light(c1, c2); - break; - case PConstants.OVERLAY: - color = p.modes.overlay(c1, c2); - break; - case PConstants.DODGE: - color = p.modes.dodge(c1, c2); - break; - case PConstants.BURN: - color = p.modes.burn(c1, c2); - break; - } - return color; - }; - - //////////////////////////////////////////////////////////////////////////// - // Canvas-Matrix manipulation - //////////////////////////////////////////////////////////////////////////// - - function saveContext() { - curContext.save(); - } - - function restoreContext() { - curContext.restore(); - isStrokeDirty = true; - isFillDirty = true; - } - - /** - * Prints the current matrix to the text window. - * - * @returns none - * - * @see pushMatrix - * @see popMatrix - * @see resetMatrix - * @see applyMatrix - */ - p.printMatrix = function printMatrix() { - modelView.print(); - }; - - /** - * Specifies an amount to displace objects within the display window. The x parameter specifies left/right translation, - * the y parameter specifies up/down translation, and the z parameter specifies translations toward/away from the screen. - * Using this function with the z parameter requires using the P3D or OPENGL parameter in combination with size as shown - * in the above example. Transformations apply to everything that happens after and subsequent calls to the function - * accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). - * If translate() is called within draw(), the transformation is reset when the loop begins again. - * This function can be further controlled by the pushMatrix() and popMatrix(). - * - * @param {int|float} x left/right translation - * @param {int|float} y up/down translation - * @param {int|float} z forward/back translation - * - * @returns none - * - * @see pushMatrix - * @see popMatrix - * @see scale - * @see rotate - * @see rotateX - * @see rotateY - * @see rotateZ - */ - p.translate = function translate(x, y, z) { - if (p.use3DContext) { - forwardTransform.translate(x, y, z); - reverseTransform.invTranslate(x, y, z); - } else { - curContext.translate(x, y); - } - }; - - /** - * Increases or decreases the size of a shape by expanding and contracting vertices. Objects always scale from their - * relative origin to the coordinate system. Scale values are specified as decimal percentages. For example, the - * function call scale(2.0) increases the dimension of a shape by 200%. Transformations apply to everything that - * happens after and subsequent calls to the function multiply the effect. For example, calling scale(2.0) and - * then scale(1.5) is the same as scale(3.0). If scale() is called within draw(), the transformation is reset when - * the loop begins again. Using this fuction with the z parameter requires passing P3D or OPENGL into the size() - * parameter as shown in the example above. This function can be further controlled by pushMatrix() and popMatrix(). - * - * @param {int|float} size percentage to scale the object - * @param {int|float} x percentage to scale the object in the x-axis - * @param {int|float} y percentage to scale the object in the y-axis - * @param {int|float} z percentage to scale the object in the z-axis - * - * @returns none - * - * @see pushMatrix - * @see popMatrix - * @see translate - * @see rotate - * @see rotateX - * @see rotateY - * @see rotateZ - */ - p.scale = function scale(x, y, z) { - if (p.use3DContext) { - forwardTransform.scale(x, y, z); - reverseTransform.invScale(x, y, z); - } else { - curContext.scale(x, y || x); - } - }; - - /** - * Pushes the current transformation matrix onto the matrix stack. Understanding pushMatrix() and popMatrix() - * requires understanding the concept of a matrix stack. The pushMatrix() function saves the current coordinate - * system to the stack and popMatrix() restores the prior coordinate system. pushMatrix() and popMatrix() are - * used in conjuction with the other transformation methods and may be embedded to control the scope of - * the transformations. - * - * @returns none - * - * @see popMatrix - * @see translate - * @see rotate - * @see rotateX - * @see rotateY - * @see rotateZ - */ - p.pushMatrix = function pushMatrix() { - if (p.use3DContext) { - userMatrixStack.load(modelView); - } else { - saveContext(); - } - }; - - /** - * Pops the current transformation matrix off the matrix stack. Understanding pushing and popping requires - * understanding the concept of a matrix stack. The pushMatrix() function saves the current coordinate system to - * the stack and popMatrix() restores the prior coordinate system. pushMatrix() and popMatrix() are used in - * conjuction with the other transformation methods and may be embedded to control the scope of the transformations. - * - * @returns none - * - * @see popMatrix - * @see pushMatrix - */ - p.popMatrix = function popMatrix() { - if (p.use3DContext) { - modelView.set(userMatrixStack.pop()); - } else { - restoreContext(); - } - }; - - /** - * Replaces the current matrix with the identity matrix. The equivalent function in OpenGL is glLoadIdentity(). - * - * @returns none - * - * @see popMatrix - * @see pushMatrix - * @see applyMatrix - * @see printMatrix - */ - p.resetMatrix = function resetMatrix() { - if (p.use3DContext) { - forwardTransform.reset(); - reverseTransform.reset(); - } else { - curContext.setTransform(1,0,0,1,0,0); - } - }; - - /** - * Multiplies the current matrix by the one specified through the parameters. This is very slow because it will - * try to calculate the inverse of the transform, so avoid it whenever possible. The equivalent function - * in OpenGL is glMultMatrix(). - * - * @param {int|float} n00-n15 numbers which define the 4x4 matrix to be multiplied - * - * @returns none - * - * @see popMatrix - * @see pushMatrix - * @see resetMatrix - * @see printMatrix - */ - p.applyMatrix = function applyMatrix() { - var a = arguments; - if (!p.use3DContext) { - for (var cnt = a.length; cnt < 16; cnt++) { - a[cnt] = 0; - } - a[10] = a[15] = 1; - } - - forwardTransform.apply(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]); - reverseTransform.invApply(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]); - }; - - /** - * Rotates a shape around the x-axis the amount specified by the angle parameter. Angles should be - * specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * Objects are always rotated around their relative position to the origin and positive numbers - * rotate objects in a counterclockwise direction. Transformations apply to everything that happens - * after and subsequent calls to the function accumulates the effect. For example, calling rotateX(PI/2) - * and then rotateX(PI/2) is the same as rotateX(PI). If rotateX() is called within the draw(), the - * transformation is reset when the loop begins again. This function requires passing P3D or OPENGL - * into the size() parameter as shown in the example above. - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateY - * @see rotateZ - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotateX = function(angleInRadians) { - forwardTransform.rotateX(angleInRadians); - reverseTransform.invRotateX(angleInRadians); - }; - - /** - * Rotates a shape around the z-axis the amount specified by the angle parameter. Angles should be - * specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * Objects are always rotated around their relative position to the origin and positive numbers - * rotate objects in a counterclockwise direction. Transformations apply to everything that happens - * after and subsequent calls to the function accumulates the effect. For example, calling rotateZ(PI/2) - * and then rotateZ(PI/2) is the same as rotateZ(PI). If rotateZ() is called within the draw(), the - * transformation is reset when the loop begins again. This function requires passing P3D or OPENGL - * into the size() parameter as shown in the example above. - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateX - * @see rotateY - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotateZ = function(angleInRadians) { - forwardTransform.rotateZ(angleInRadians); - reverseTransform.invRotateZ(angleInRadians); - }; - - /** - * Rotates a shape around the y-axis the amount specified by the angle parameter. Angles should be - * specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. - * Objects are always rotated around their relative position to the origin and positive numbers - * rotate objects in a counterclockwise direction. Transformations apply to everything that happens - * after and subsequent calls to the function accumulates the effect. For example, calling rotateY(PI/2) - * and then rotateY(PI/2) is the same as rotateY(PI). If rotateY() is called within the draw(), the - * transformation is reset when the loop begins again. This function requires passing P3D or OPENGL - * into the size() parameter as shown in the example above. - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateX - * @see rotateZ - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotateY = function(angleInRadians) { - forwardTransform.rotateY(angleInRadians); - reverseTransform.invRotateY(angleInRadians); - }; - - /** - * Rotates a shape the amount specified by the angle parameter. Angles should be specified in radians - * (values from 0 to TWO_PI) or converted to radians with the radians() function. Objects are always - * rotated around their relative position to the origin and positive numbers rotate objects in a - * clockwise direction. Transformations apply to everything that happens after and subsequent calls - * to the function accumulates the effect. For example, calling rotate(HALF_PI) and then rotate(HALF_PI) - * is the same as rotate(PI). All tranformations are reset when draw() begins again. Technically, - * rotate() multiplies the current transformation matrix by a rotation matrix. This function can be - * further controlled by the pushMatrix() and popMatrix(). - * - * @param {int|float} angleInRadians angle of rotation specified in radians - * - * @returns none - * - * @see rotateX - * @see rotateY - * @see rotateZ - * @see rotate - * @see translate - * @see scale - * @see popMatrix - * @see pushMatrix - */ - p.rotate = function rotate(angleInRadians) { - if (p.use3DContext) { - forwardTransform.rotateZ(angleInRadians); - reverseTransform.invRotateZ(angleInRadians); - } else { - curContext.rotate(angleInRadians); - } - }; - - /** - * The pushStyle() function saves the current style settings and popStyle() restores the prior settings. - * Note that these functions are always used together. They allow you to change the style settings and later - * return to what you had. When a new style is started with pushStyle(), it builds on the current style information. - * The pushStyle() and popStyle() functions can be embedded to provide more control (see the second example - * above for a demonstration.) - * The style information controlled by the following functions are included in the style: fill(), stroke(), tint(), - * strokeWeight(), strokeCap(), strokeJoin(), imageMode(), rectMode(), ellipseMode(), shapeMode(), colorMode(), - * textAlign(), textFont(), textMode(), textSize(), textLeading(), emissive(), specular(), shininess(), ambient() - * - * @returns none - * - * @see popStyle - */ - p.pushStyle = function pushStyle() { - // Save the canvas state. - saveContext(); - - p.pushMatrix(); - - var newState = { - 'doFill': doFill, - 'currentFillColor': currentFillColor, - 'doStroke': doStroke, - 'currentStrokeColor': currentStrokeColor, - 'curTint': curTint, - 'curRectMode': curRectMode, - 'curColorMode': curColorMode, - 'colorModeX': colorModeX, - 'colorModeZ': colorModeZ, - 'colorModeY': colorModeY, - 'colorModeA': colorModeA, - 'curTextFont': curTextFont, - 'curTextSize': curTextSize - }; - - styleArray.push(newState); - }; - - /** - * The pushStyle() function saves the current style settings and popStyle() restores the prior settings; these - * functions are always used together. They allow you to change the style settings and later return to what you had. - * When a new style is started with pushStyle(), it builds on the current style information. The pushStyle() and - * popStyle() functions can be embedded to provide more control (see the second example above for a demonstration.) - * - * @returns none - * - * @see pushStyle - */ - p.popStyle = function popStyle() { - var oldState = styleArray.pop(); - - if (oldState) { - restoreContext(); - - p.popMatrix(); - - doFill = oldState.doFill; - currentFillColor = oldState.currentFillColor; - doStroke = oldState.doStroke; - currentStrokeColor = oldState.currentStrokeColor; - curTint = oldState.curTint; - curRectMode = oldState.curRectmode; - curColorMode = oldState.curColorMode; - colorModeX = oldState.colorModeX; - colorModeZ = oldState.colorModeZ; - colorModeY = oldState.colorModeY; - colorModeA = oldState.colorModeA; - curTextFont = oldState.curTextFont; - curTextSize = oldState.curTextSize; - } else { - throw "Too many popStyle() without enough pushStyle()"; - } - }; - - //////////////////////////////////////////////////////////////////////////// - // Time based functions - //////////////////////////////////////////////////////////////////////////// - - /** - * Processing communicates with the clock on your computer. - * The year() function returns the current year as an integer (2003, 2004, 2005, etc). - * - * @returns {float} The current year. - * - * @see millis - * @see second - * @see minute - * @see hour - * @see day - * @see month - */ - p.year = function year() { - return new Date().getFullYear(); - }; - /** - * Processing communicates with the clock on your computer. - * The month() function returns the current month as a value from 1 - 12. - * - * @returns {float} The current month. - * - * @see millis - * @see second - * @see minute - * @see hour - * @see day - * @see year - */ - p.month = function month() { - return new Date().getMonth() + 1; - }; - /** - * Processing communicates with the clock on your computer. - * The day() function returns the current day as a value from 1 - 31. - * - * @returns {float} The current day. - * - * @see millis - * @see second - * @see minute - * @see hour - * @see month - * @see year - */ - p.day = function day() { - return new Date().getDate(); - }; - /** - * Processing communicates with the clock on your computer. - * The hour() function returns the current hour as a value from 0 - 23. - * - * @returns {float} The current hour. - * - * @see millis - * @see second - * @see minute - * @see month - * @see day - * @see year - */ - p.hour = function hour() { - return new Date().getHours(); - }; - /** - * Processing communicates with the clock on your computer. - * The minute() function returns the current minute as a value from 0 - 59. - * - * @returns {float} The current minute. - * - * @see millis - * @see second - * @see month - * @see hour - * @see day - * @see year - */ - p.minute = function minute() { - return new Date().getMinutes(); - }; - /** - * Processing communicates with the clock on your computer. - * The second() function returns the current second as a value from 0 - 59. - * - * @returns {float} The current minute. - * - * @see millis - * @see month - * @see minute - * @see hour - * @see day - * @see year - */ - p.second = function second() { - return new Date().getSeconds(); - }; - /** - * Returns the number of milliseconds (thousandths of a second) since starting a sketch. - * This information is often used for timing animation sequences. - * - * @returns {long} The number of milliseconds since starting the sketch. - * - * @see month - * @see second - * @see minute - * @see hour - * @see day - * @see year - */ - p.millis = function millis() { - return new Date().getTime() - start; - }; - - /** - * Executes the code within draw() one time. This functions allows the program to update - * the display window only when necessary, for example when an event registered by - * mousePressed() or keyPressed() occurs. - * In structuring a program, it only makes sense to call redraw() within events such as - * mousePressed(). This is because redraw() does not run draw() immediately (it only sets - * a flag that indicates an update is needed). - * Calling redraw() within draw() has no effect because draw() is continuously called anyway. - * - * @returns none - * - * @see noLoop - * @see loop - */ - p.redraw = function redraw() { - var sec = (new Date().getTime() - timeSinceLastFPS) / 1000; - framesSinceLastFPS++; - var fps = framesSinceLastFPS / sec; - - // recalculate FPS every half second for better accuracy. - if (sec > 0.5) { - timeSinceLastFPS = new Date().getTime(); - framesSinceLastFPS = 0; - p.__frameRate = fps; - } - - p.frameCount++; - - inDraw = true; - - if (p.use3DContext) { - // even if the color buffer isn't cleared with background(), - // the depth buffer needs to be cleared regardless. - curContext.clear(curContext.DEPTH_BUFFER_BIT); - curContextCache = { attributes: {}, locations: {} }; - // Delete all the lighting states and the materials the - // user set in the last draw() call. - p.noLights(); - p.lightFalloff(1, 0, 0); - p.shininess(1); - p.ambient(255, 255, 255); - p.specular(0, 0, 0); - p.camera(); - p.draw(); - } else { - saveContext(); - p.draw(); - restoreContext(); - } - - inDraw = false; - }; - - /** - * Stops Processing from continuously executing the code within draw(). If loop() is - * called, the code in draw() begin to run continuously again. If using noLoop() in - * setup(), it should be the last line inside the block. - * When noLoop() is used, it's not possible to manipulate or access the screen inside event - * handling functions such as mousePressed() or keyPressed(). Instead, use those functions - * to call redraw() or loop(), which will run draw(), which can update the screen properly. - * This means that when noLoop() has been called, no drawing can happen, and functions like - * saveFrame() or loadPixels() may not be used. - * Note that if the sketch is resized, redraw() will be called to update the sketch, even - * after noLoop() has been specified. Otherwise, the sketch would enter an odd state until - * loop() was called. - * - * @returns none - * - * @see redraw - * @see draw - * @see loop - */ - p.noLoop = function noLoop() { - doLoop = false; - loopStarted = false; - clearInterval(looping); - }; - - /** - * Causes Processing to continuously execute the code within draw(). If noLoop() is called, - * the code in draw() stops executing. - * - * @returns none - * - * @see noLoop - */ - p.loop = function loop() { - if (loopStarted) { - return; - } - - looping = window.setInterval(function() { - //try { - if (document.hasFocus instanceof Function) { - p.focused = document.hasFocus(); - } - p.redraw(); - //} catch(e_loop) { - //window.clearInterval(looping); - //throw e_loop; - //} - }, curMsPerFrame); - doLoop = true; - loopStarted = true; - }; - - /** - * Specifies the number of frames to be displayed every second. If the processor is not - * fast enough to maintain the specified rate, it will not be achieved. For example, the - * function call frameRate(30) will attempt to refresh 30 times a second. It is recommended - * to set the frame rate within setup(). The default rate is 60 frames per second. - * - * @param {int} aRate number of frames per second. - * - * @returns none - * - * @see delay - */ - p.frameRate = function frameRate(aRate) { - curFrameRate = aRate; - curMsPerFrame = 1000 / curFrameRate; - - // clear and reset interval - if (doLoop) { - p.noLoop(); - p.loop(); - } - }; - - var eventHandlers = []; - - /** - * Quits/stops/exits the program. Programs without a draw() function exit automatically - * after the last line has run, but programs with draw() run continuously until the - * program is manually stopped or exit() is run. - * Rather than terminating immediately, exit() will cause the sketch to exit after draw() - * has completed (or after setup() completes if called during the setup() method). - * - * @returns none - */ - p.exit = function exit() { - window.clearInterval(looping); - - Processing.removeInstance(p.externals.canvas.id); - - // Step through the libraries to detach them - for (var lib in Processing.lib) { - if (Processing.lib.hasOwnProperty(lib)) { - if (Processing.lib[lib].hasOwnProperty("detach")) { - Processing.lib[lib].detach(p); - } - } - } - - for (var i=0, ehl=eventHandlers.length; i 1 || (arguments.length === 1 && arguments[0] instanceof p.PImage)) { - var image = arguments[0], - x, y; - if (arguments.length >= 3) { - x = arguments[1]; - y = arguments[2]; - if (x < 0 || y < 0 || y >= image.height || x >= image.width) { - throw "x and y must be non-negative and less than the dimensions of the image"; - } - } else { - x = image.width >>> 1; - y = image.height >>> 1; - } - - // see https://developer.mozilla.org/en/Using_URL_values_for_the_cursor_property - var imageDataURL = image.toDataURL(); - var style = "url(\"" + imageDataURL + "\") " + x + " " + y + ", default"; - curCursor = curElement.style.cursor = style; - } else if (arguments.length === 1) { - var mode = arguments[0]; - curCursor = curElement.style.cursor = mode; - } else { - curCursor = curElement.style.cursor = oldCursor; - } - }; - - /** - * Hides the cursor from view. - * - * @returns none - * - * @see cursor - */ - p.noCursor = function noCursor() { - curCursor = curElement.style.cursor = PConstants.NOCURSOR; - }; - - /** - * Links to a webpage either in the same window or in a new window. The complete URL - * must be specified. - * - * @param {String} href complete url as a String in quotes - * @param {String} target name of the window to load the URL as a string in quotes - * - * @returns none - */ - p.link = function(href, target) { - if (target !== undef) { - window.open(href, target); - } else { - window.location = href; - } - }; - - // PGraphics methods - // TODO: These functions are suppose to be called before any operations are called on the - // PGraphics object. They currently do nothing. - p.beginDraw = function beginDraw() {}; - p.endDraw = function endDraw() {}; - - // Imports an external Processing.js library - p.Import = function Import(lib) { - // Replace evil-eval method with a DOM - - - - - - - - - - - -
            -
            - diff --git a/scores/scores.js b/scores/scores.js deleted file mode 100644 index d6403b2..0000000 --- a/scores/scores.js +++ /dev/null @@ -1,221 +0,0 @@ -var make_scores = function(){ - var obj = {}; - - var num_rows = 15; - - // async gets scores and feeds to callback - var get_scores = function(callback){ - // ajax request to get scores - - // want to do them sequentially so we - // chain the callbacks - - // this comes third via callback - var do_global = function() { - // Global High Scores - $.post("scores/get_scores.php", { - num: num_rows, - }, callback("Global Scores", - // at the end of last callback we need to - // make the tabs - function() { - console.log("making tabs"); - $("#scores").tabs(); - - // remove the loading message - console.log("removing loading msg"); - $("#scores-loading").remove(); - - $("#scores").show(); - } - )); - }; - - // this comes second via callback - var do_friends = function() { - var friends = g_get_friends(); - if (friends.length !== 0) { - // Global High Scores - $.post("scores/get_scores.php", { - num: num_rows, - uid: g_user_id, - friends: friends - }, callback("Friends' Scores", do_global)); - console.log("got friends scores"); - } - else { - do_global(); - console.log("skipped friends scores"); - } - }; - - // this comes first - // Personal high scores - if (g_user_id) { - $.post("scores/get_scores.php", { - num: num_rows, - uid : g_user_id - }, callback("Your Scores", do_friends)); - console.log("getting user high scores"); - } - else { - do_global(); - } - }; - - var get_user_scores = function(callback) { - $.post("scores/get_scores.php", { - num : num_rows - }, callback); - }; - - // interprets json and displays it - // Passing it a header returns the actual function - // Must use this style so long as get_scores is async - // Passing a function as do_more does it at the end of the callback - var tab_count = 1; - var display_scores = function(header, do_more) { - var headers = [ "Rank", "Score", "Level", "Name", "Date" ]; - var formatters = { - "score": add_commas, - "date": function(date_str) { - //var d = new Date(date_str); - var d = new Date(); - // date_str must be of format yyyy-mm-dd - var year = parseInt(date_str.substring(0, 4)); - var month = parseInt(date_str.substring(5, 7))-1; - var day = parseInt(date_str.substring(8)); - d.setFullYear(year, month, day); - //return d.f("NNN d, yyyy"); - return d.format("mmm d, yyyy"); - }, - }; - return function(data){ - //console.log(data); - - var link = "
          • " - + header + "
          • "; - $("#tab-list").append(link); - - // con is the content to put in the score tab - var con = "
            "; - - try { - var scores = jQuery.parseJSON(data); - if (!scores) { - throw "No scores loaded"; - } - } - catch (e) { - con += "
            Error loading scores." - +" Please check your internet connection."; - } - if (scores) { - - con += "
            "; - - // -- start header row -- - con += ""; - for_each(headers, function(header) { - con += ""; - }); - con += ""; - // -- end header row -- - - //console.log(scores); - // scores is an array of row objects - var row_count = 1; - for_each(scores, function(row){ - con += ""; - con += ""; - for_each(keys(row), function(key){ - var f = formatters[key] || function(x) { return x; }; - // dont show uid - if (key !== "userid") { - con += ""; - } - }); - con += ""; - row_count += 1; - }); - // fill up rest of table for beauty's sake - while (row_count <= num_rows) { - con += ""; - for_each(headers, function(header){ - con += ""; - }); - con += ""; - row_count += 1; - } - - con += "
            " + header + "
            " + row_count + "." + f(row[key]) + "
             
            "; - con += ""; - - } - - // add it to page - $("#scores").append(con); - // update tab num - tab_count += 1; - - // do some more stuff if necessary - if (do_more) { - do_more(); - } - }; - }; - - // gets and displays scores - obj.do_scores = function(){ - console.log("trying to load scores"); - $("#scores").empty(); - $("#scores").hide(); - $("#scores").append("
              "); - // reset tab count - tab_count = 1; - get_scores(display_scores); - }; - - // inserts a score into the db - // score_obj: - // - score: int score - // - level: mutation level - // - userid: unique id for the user (from fb?) - var post_score = function(score_obj, callback){ - $.post("scores/post_score.php", score_obj, callback); - }; - - // testing function to use with form - obj.submit_score = function(score, level, name, uid){ - /* - var form = document.forms[0]; - var score = form.elements[0].value; - var level = form.elements[1].value; - var userid = form.elements[2].value; - */ - var date_str = (new Date()).format("yyyy-mm-dd"); - - var score_obj = { - /* - score: parseInt(score), - level: parseInt(level), - */ - score: score, - level: level, - name: name, - userid: uid, - //date: new Date().f('yyyy-MM-dd') - date: date_str - }; - console.log(score_obj); - - post_score(score_obj, function(data){ - console.log(data); - //obj.do_scores(); - }); - }; - - return obj; -} - -var scores = make_scores(); diff --git a/seeker.js b/seeker.js deleted file mode 100644 index ba3c879..0000000 --- a/seeker.js +++ /dev/null @@ -1,127 +0,0 @@ -// ABSTRACT class for game objects that seek other game objects -// Classes that implement must override "my_update" instead of "update" -// --- inherits from object_with_states -// spec: -// game_object spec + -// speed = how fast the seeker approaches the target -// no_target_speed = how fast the object moves when there is no target -// target = object to move towards - -var seeker = function(p, spec) { - - // --- defaults --- - - // obj to return - var obj = object_with_states(p, spec); - - // --- private variables --- - - var speed = spec.speed || 0.2; - var no_target_speed = spec.no_target_speed || 0.2; - var alive = true; - var target = spec.target || null; - // initialized to random val at bottom - var target_angle = 0; - - // --- public methods --- - - // implementing game_object interface - - // update makes tkiller chase target cell - obj.update = function() { - var pos = obj.get_pos(); - var speed_to_use = speed; - - if (target && target.is_dead()) { - target = null; - } - - // if no target - if (target === null) { - // meander - if (parseInt(p.random(150)) === 0) { - target_angle += p.random(-p.PI/16, p.PI/16); - } - // laze - speed_to_use = no_target_speed; - } - else { - obj.face_target(); - } - - // change velocity to point towards target - var new_vel = new p.PVector( - p.cos(target_angle), p.sin(target_angle)); - new_vel.mult(speed_to_use); - obj.set_vel(new_vel); - - obj.my_update(); - }; - - // MUST BE OVERWRITTEN - obj.my_update = function() { - console.log("my_update (in seeker) not overwritten!"); - }; - - // Indicates that a mutation has occured and this object - // should float off the screen - // Makes this object stop and float off screen - obj.outdated = function() { - obj.set_state("outdated"); - obj.set_vel(new p.PVector(0,0)); - obj.set_target(null); - }; - - obj.is_outdated = function() { - return obj.get_state() === "outdated"; - }; - - // faces tar, or if tar not supplied, the object's - // target - obj.face_target = function(tar) { - var pos = obj.get_pos(); - if (target) { - var tpos = target.get_pos(); - } - if (tar) { - var tpos = tar.get_pos(); - } - if (tpos) { - // update target_angle - target_angle = p.atan2(tpos.y-pos.y, tpos.x-pos.x); // y first! - } - }; - - - obj.set_target = function(new_target) { - if (obj.get_state() !== "outdated") { - target = new_target; - } - }; - - obj.set_speed = function(new_speed) { - speed = new_speed; - }; - - obj.set_target_angle = function(new_target_angle) { - target_angle = new_target_angle; - }; - - obj.get_target = function() { - return target; - }; - - obj.get_target_angle = function() { - return target_angle; - }; - - // creates a random angle for init'ing - obj.random_target_angle = function() { - return p.random(-p.PI, p.PI); - //Math.random() * (p.PI * 2) - p.PI; //random angle - }; - target_angle = obj.random_target_angle(); - - - return obj; -} diff --git a/settings.js b/settings.js deleted file mode 100644 index ef1251b..0000000 --- a/settings.js +++ /dev/null @@ -1,61 +0,0 @@ -// Global settings -// Have to be wrapped in an object since primitives are pass-by-value -var game_settings = function() { - var settings = { - sound_fx : true, - music : true, - track: "no track", - click_to_fire : true, - mouse_to_select : false, - spacebar_to_fire : true, - background_color : 0xFF3a0101 - // 0xFF371010 - }; - - var toggle = function(name) { - settings[name] = !settings[name]; - }; - - settings.toggle_sound_fx = function() { toggle("sound_fx"); }; - settings.toggle_click_to_fire = function() { toggle("click_to_fire"); }; - settings.toggle_spacebar_to_fire = function() { toggle("spacebar_to_fire"); }; - settings.toggle_mouse_to_select = function() { toggle("mouse_to_select"); }; - // note that this only toggles the flag, not the actual music - // that should be done with a sound manager method - settings.toggle_music = function() { - toggle("music"); - //console.log(settings.music); - }; - - settings.next_track = function() { - var t = sounds.next_track(); - settings.track = t; - }; - - settings.prev_track = function() { - var t = sounds.prev_track(); - settings.track = t; - }; - - settings.set_track = function(t) { - settings.track = t; - }; - - return settings; -}; -// abbreviate it -var g = game_settings(); - - -//getters -/* -var g_sound_fx_on = function() { - return g_game_settings.sound_fx; -} -var g_music_on = function() { - return g_game_settings.music; -} -var g_click_to_fire = function() { - return g_game_settings.click_to_fire; -} -*/ diff --git a/sound.js b/sound.js deleted file mode 100644 index 6de2aa9..0000000 --- a/sound.js +++ /dev/null @@ -1,345 +0,0 @@ -// sound_manager -// utility object to play or not play sounds -// settings for sound still stored in settings object -var sound_manager = function() { - var obj = {}; - - var the_swf_path = "./jplayer/"; - // Taken from http://www.storiesinflight.com/html5/audio.html - - //g_divs_loaded_init_sounds = function() { - //console.log("AAAAA initing sounds"); - obj.play_sound = (function() { - var channel_max = 10; // number of channels - audiochannels = new Array(); - for (var a=0;a= all_bg_music.length) { - track_index = 0; - } - // pause the old one - obj.pause_background_music(); - // set the new one - set_background_music(); - //obj.play_background_music(); - return all_bg_music[track_index].name; - }; - - obj.prev_track = function() { - track_index -= 1; - if (track_index < 0) { - track_index = all_bg_music.length-1; - } - // pause the old one - obj.pause_background_music(); - // set the new one - set_background_music(); - return all_bg_music[track_index].name; - }; - - // sets the background music to the current track index - var set_background_music = function() { - // note that random must be the LAST track - var music = all_bg_music[track_index].music; - if (!music) { - music = all_bg_music - [Math.floor(Math.random()*(track_index-1))] - .music; - } - assert(music, "Random wasn't the last track index or a music div was undefined."); - background_music = music; - }; - - obj.resume_background_music = function() { - if (background_music) - background_music.jPlayer("play"); - } - - obj.pause_background_music = function() { - console.log("Pausing bg music"); - if (background_music) - background_music.jPlayer("pause"); - }; - - var menu_music = null; - var button_sounds = null; - - // Really resume menu music, menu music never restarts - obj.play_menu_music = function() { - if (g.music) - menu_music.jPlayer("play"); - } - obj.resume_menu_music = function() { - if (g.music) - menu_music.jPlayer("play"); - } - obj.pause_menu_music = function() { - menu_music.jPlayer("pause"); - } - obj.play_button_click = function() { - if (g.sound_fx) - play_a_sound(button_sounds, "buttonmain"); - } - obj.play_button_back = function() { - if (g.sound_fx) - play_a_sound(button_sounds, "buttonback"); - } - - var play_a_sound = function(jplayer_instance, sound_name) { - jplayer_instance.jPlayer("setMedia", { - //mp3 : g_soundDataMap[sound_name + "mp3"], - mp3 : "sounds/" + sound_name + ".mp3", - oga : g_soundDataMap[sound_name] - }); - //jplayer_instance.jPlayer.event.ready = function() {console.log("read");}; - jplayer_instance.jPlayer("play"); - } - - obj.load_sounds = function() { - // init all bg music - var all_supplied = "oga, mp3"; - var init_jplayer = function(name, mp3name, oggname, should_loop) { - $(name).jPlayer( { - swfPath : the_swf_path, - ready: function () { - $(this).jPlayer("setMedia", { - mp3 : "sounds/"+mp3name, - oga : "sounds/"+oggname - }); - //console.log(name + " is ready"); - bg_music_loaded(); - $(this).bind($.jPlayer.event.progress, - function(event) { - //console.log(event.jPlayer.status.seekPercent); - if (event.jPlayer.status.seekPercent === 100) { - //console.log("percent = 100, name: " + mp3name); - //bg_music_loaded(); - } - }); - $(this).bind($.jPlayer.error.NO_SOLUTION, - function(event) { - //bg_music_loaded(); - console.log("No audio solutions"); - }); - }, - ended : function() { // loop - if (should_loop) { - $(this).jPlayer("play"); - } - }, - supplied : all_supplied, - preload : "auto", - oggSupport: true - //errorAlerts : true - }); - } - - var init_bg_jplayer = function(num, file_name, oggfn) { - init_jplayer("#jquery_jplayer_bg_"+num, file_name, oggfn, true) - } - /* - console.log("loading heart loop"); - init_bg_jplayer(0, "heart_loop1.mp3"); - console.log("loaded heart loop"); - */ - console.log("loading sinister"); - init_bg_jplayer(0, "sinister.mp3", "sinister.ogg", true); - console.log("loaded sinister"); - - init_bg_jplayer(1, "gameloop2.mp3", "gameloop2.ogg", true); - init_bg_jplayer(2, "Infiltration.mp3", "Infiltration.ogg", true); - init_bg_jplayer(3, "Incubation.mp3", "Incubation.ogg", true); - - for (var i = 0; i < num_bg_music; i++) { - all_bg_music.push({ - music: $("#jquery_jplayer_bg_"+i), - name: track_names[i] - }); - } - - init_jplayer("#jquery_jplayer_menu", "menu_loop.mp3", "menu_loop.ogg", true); - menu_music = $("#jquery_jplayer_menu"); - - init_jplayer("#jquery_jplayer_buttons", "buttonmain.mp3", "buttonmain.ogg", false); - button_sounds = $("#jquery_jplayer_buttons"); - - // add random option - // THIS MUST BE THE LAST OBJ IN THE ARRAY - all_bg_music.push({ - name: "Random", - // don't try to access this music! - music: null - }); - track_names.push("Random"); - num_bg_music += 1; - track_index = num_bg_music-1; - // set initial track (random) - g.set_track(track_names[track_index]); - }; - - var num_loaded = 0; - var max_loaded = num_bg_music + 2 // + 1 for menu music, + 1 for button - var bg_music_loaded = function() { - num_loaded++; - console.log("Loaded " + num_loaded + " out of " + max_loaded); - }; - - obj.sounds_loaded = function() { - //console.log(num_loaded); - return num_loaded >= max_loaded; - } - return obj; -}; - -// make a global object -var sounds = sound_manager(); - -// to debug without sounds, use this object -/* -var sounds = { - sounds_loaded: function() { return true; }, - play_sound: function() {}, - play_background_music: function() {}, - pause_background_music: function() {}, - resume_background_music: function() {}, - load_sounds: function() {}, -}; -*/ - - - -/* -var jplayer = $("#jquery_jplayer_1").jPlayer( { - ready: function () { - $(this).jPlayer("setMedia", { - oga :g_soundDataMap["kill"] // "/sounds/kill.ogg" - //mp3 : "sounds/heart_loop1.mp3" - }); - $(this).jPlayer("play"); - //asdf_play(); - console.log("ready"); - }, - supplied : "oga" -}); -//$("#jquery_jplayer_1").jPlayer("setMedia", {mp3 : "sounds/heart_loop1.mp3"}); -var asdf_play = function(){ - $("#jquery_jplayer_1").jPlayer("play"); -}; - -*/ diff --git a/sounds/Incubation.mp3 b/sounds/Incubation.mp3 deleted file mode 100755 index aecc196..0000000 Binary files a/sounds/Incubation.mp3 and /dev/null differ diff --git a/sounds/Incubation.ogg b/sounds/Incubation.ogg deleted file mode 100755 index f15e5eb..0000000 Binary files a/sounds/Incubation.ogg and /dev/null differ diff --git a/sounds/Infiltration.mp3 b/sounds/Infiltration.mp3 deleted file mode 100755 index eb48089..0000000 Binary files a/sounds/Infiltration.mp3 and /dev/null differ diff --git a/sounds/Infiltration.ogg b/sounds/Infiltration.ogg deleted file mode 100755 index 5cce4b5..0000000 Binary files a/sounds/Infiltration.ogg and /dev/null differ diff --git a/sounds/TextPopUp.mp3 b/sounds/TextPopUp.mp3 deleted file mode 100755 index 86bbfc9..0000000 Binary files a/sounds/TextPopUp.mp3 and /dev/null differ diff --git a/sounds/TextPopUp.ogg b/sounds/TextPopUp.ogg deleted file mode 100755 index 237fe4b..0000000 Binary files a/sounds/TextPopUp.ogg and /dev/null differ diff --git a/sounds/buttonback.mp3 b/sounds/buttonback.mp3 deleted file mode 100755 index 730c75f..0000000 Binary files a/sounds/buttonback.mp3 and /dev/null differ diff --git a/sounds/buttonback.ogg b/sounds/buttonback.ogg deleted file mode 100755 index 109a1e9..0000000 Binary files a/sounds/buttonback.ogg and /dev/null differ diff --git a/sounds/buttonmain.mp3 b/sounds/buttonmain.mp3 deleted file mode 100755 index aea705c..0000000 Binary files a/sounds/buttonmain.mp3 and /dev/null differ diff --git a/sounds/buttonmain.ogg b/sounds/buttonmain.ogg deleted file mode 100755 index 81c13d7..0000000 Binary files a/sounds/buttonmain.ogg and /dev/null differ diff --git a/sounds/cell_fire.mp3 b/sounds/cell_fire.mp3 deleted file mode 100755 index 0e3ebf3..0000000 Binary files a/sounds/cell_fire.mp3 and /dev/null differ diff --git a/sounds/cell_fire.ogg b/sounds/cell_fire.ogg deleted file mode 100755 index 7e91316..0000000 Binary files a/sounds/cell_fire.ogg and /dev/null differ diff --git a/sounds/cell_infect.mp3 b/sounds/cell_infect.mp3 deleted file mode 100755 index 5bc1007..0000000 Binary files a/sounds/cell_infect.mp3 and /dev/null differ diff --git a/sounds/cell_infect.ogg b/sounds/cell_infect.ogg deleted file mode 100755 index 57aaaea..0000000 Binary files a/sounds/cell_infect.ogg and /dev/null differ diff --git a/sounds/gameloop2.mp3 b/sounds/gameloop2.mp3 deleted file mode 100755 index 5c8f4c3..0000000 Binary files a/sounds/gameloop2.mp3 and /dev/null differ diff --git a/sounds/gameloop2.ogg b/sounds/gameloop2.ogg deleted file mode 100755 index 1c94d25..0000000 Binary files a/sounds/gameloop2.ogg and /dev/null differ diff --git a/sounds/kill.mp3 b/sounds/kill.mp3 deleted file mode 100755 index 6bdfebe..0000000 Binary files a/sounds/kill.mp3 and /dev/null differ diff --git a/sounds/kill.ogg b/sounds/kill.ogg deleted file mode 100755 index deed4fc..0000000 Binary files a/sounds/kill.ogg and /dev/null differ diff --git a/sounds/level_up.mp3 b/sounds/level_up.mp3 deleted file mode 100755 index 55e3fcf..0000000 Binary files a/sounds/level_up.mp3 and /dev/null differ diff --git a/sounds/level_up.ogg b/sounds/level_up.ogg deleted file mode 100755 index 468cae0..0000000 Binary files a/sounds/level_up.ogg and /dev/null differ diff --git a/sounds/macrophage_infect.mp3 b/sounds/macrophage_infect.mp3 deleted file mode 100755 index 472498e..0000000 Binary files a/sounds/macrophage_infect.mp3 and /dev/null differ diff --git a/sounds/macrophage_infect.ogg b/sounds/macrophage_infect.ogg deleted file mode 100755 index 0a49c6f..0000000 Binary files a/sounds/macrophage_infect.ogg and /dev/null differ diff --git a/sounds/menu_loop.mp3 b/sounds/menu_loop.mp3 deleted file mode 100755 index 10f3c1d..0000000 Binary files a/sounds/menu_loop.mp3 and /dev/null differ diff --git a/sounds/menu_loop.ogg b/sounds/menu_loop.ogg deleted file mode 100755 index 2008e2f..0000000 Binary files a/sounds/menu_loop.ogg and /dev/null differ diff --git a/sounds/old/Level Up!2 Trimmed.ogg b/sounds/old/Level Up!2 Trimmed.ogg deleted file mode 100755 index ee8fa82..0000000 Binary files a/sounds/old/Level Up!2 Trimmed.ogg and /dev/null differ diff --git a/sounds/old/cell_fire.ogg b/sounds/old/cell_fire.ogg deleted file mode 100644 index bbec785..0000000 Binary files a/sounds/old/cell_fire.ogg and /dev/null differ diff --git a/sounds/old/cell_fire.wav b/sounds/old/cell_fire.wav deleted file mode 100644 index 77f1ba9..0000000 Binary files a/sounds/old/cell_fire.wav and /dev/null differ diff --git a/sounds/old/cell_infect.ogg b/sounds/old/cell_infect.ogg deleted file mode 100644 index a3d5cf8..0000000 Binary files a/sounds/old/cell_infect.ogg and /dev/null differ diff --git a/sounds/old/cell_infect.wav b/sounds/old/cell_infect.wav deleted file mode 100644 index 8cb4011..0000000 Binary files a/sounds/old/cell_infect.wav and /dev/null differ diff --git a/sounds/old/kill.ogg b/sounds/old/kill.ogg deleted file mode 100755 index c127f02..0000000 Binary files a/sounds/old/kill.ogg and /dev/null differ diff --git a/sounds/old/level_up.ogg b/sounds/old/level_up.ogg deleted file mode 100755 index d1b818c..0000000 Binary files a/sounds/old/level_up.ogg and /dev/null differ diff --git a/sounds/old/macrophage_infect.ogg b/sounds/old/macrophage_infect.ogg deleted file mode 100644 index 684fc34..0000000 Binary files a/sounds/old/macrophage_infect.ogg and /dev/null differ diff --git a/sounds/sinister.mp3 b/sounds/sinister.mp3 deleted file mode 100755 index 95905df..0000000 Binary files a/sounds/sinister.mp3 and /dev/null differ diff --git a/sounds/sinister.ogg b/sounds/sinister.ogg deleted file mode 100755 index e5e2d94..0000000 Binary files a/sounds/sinister.ogg and /dev/null differ diff --git a/splash_state.js b/splash_state.js deleted file mode 100644 index 2ebe87a..0000000 --- a/splash_state.js +++ /dev/null @@ -1,238 +0,0 @@ -var splash_state = function (p) { - - // object to return - var obj = game_state(p); - - // --- private variables --- - - //var header_image = p.loadImage("images/screens/header.png"); - var back_image = image_manager.get_image("mainscreenbase.png"); - var back_color = g.background_color; - - // Buttons - // Have a rectangle representing their position and - // a state to go to when pressed - - var top_row_y = 150; - var btm_row_y = 420; - var left_x_top = 465; - var left_x_btm = 500; - var incr_x = 40; - var incr_y = 60; - var button_style = { - //height: 160, - rect_color: back_color - }; - - // Play menu music - sounds.play_menu_music(); - - var pause_menu_music = function() { - sounds.pause_menu_music(); - }; - - var normal_button = button(p, { - state : function() { - pause_menu_music(); - sounds.play_button_click(); - return in_game_state(p, obj, 2); - }, - rect: { - pos: new p.PVector(left_x_top+2*incr_x, top_row_y), - image: "mnormal.png", - over_image: "mnormal_r.png", - //width: 80, - style: button_style, - } - }); - - var easy_button = button(p, { - state : function() { - pause_menu_music(); - sounds.play_button_click(); - return in_game_state(p, obj, 0); - }, - rect: { - pos: new p.PVector(left_x_top+incr_x, top_row_y+incr_y), - //text : "Easy", - image: "mbeginner.png", - over_image: "mbeginner_r.png", - //width: 80, - style: button_style, - } - }); - - var tut_button = button(p, { - state : function() { - pause_menu_music(); - sounds.play_button_click(); - return in_game_state(p, obj, 1); - }, - rect: { - pos: new p.PVector(left_x_top, top_row_y+2*incr_y), - //text : "Tutorial", - image: "mtutorial.png", - over_image: "mtutorial_r.png", - //width: 80, - style: button_style, - } - }); - - - var help_button = button(p, { - state : function() { - sounds.play_button_click(); - return help_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x_btm, btm_row_y), - image: "mhowtoplay.png", - over_image: "mhowtoplay_r.png", - //width: 100, - style: button_style, - } - }); - - var scores_button = button(p, { - state : function() { - sounds.play_button_click(); - return high_scores_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x_btm+incr_x, btm_row_y+incr_y), - image: "mhighscores.png", - over_image: "mhighscores_r.png", - //text: "High Scores", - //width: 100, - style: button_style, - } - }); - - var options_button = button(p, { - state : function() { - sounds.play_button_click(); - return options_state(p, obj); - }, - rect: { - pos: new p.PVector(left_x_btm+2*incr_x-10, btm_row_y+2*incr_y), - image: "msettings.png", - over_image: "msettings_r.png", - //width: 120, - style: button_style, - } - }); - - var credits_button = button(p, { - state : function() { - sounds.play_button_click(); - return credits_state(p, obj); - }, - rect: { - pos: new p.PVector(p.width-100, 30), - image: "credits.png", - width: 200, - height: 50, - } - }); - - /* - var splash_style = { - width : 170, - height : 40, - text_color: 0xFFEE0000, - rect_color: back_color, - text_size: 30, - text_align: p.LEFT - }; - - var button_x = 500; - var button_top = 150; - var button_sep = 60; - - var start_button = button(p, { - state : function() { return in_game_state(p, obj); }, - rect : { - pos : new p.PVector(button_x, button_top), - style : splash_style, - text : "New Game" - //image : "images/screens/newgame_listcell.png" - } - }); - - var options_button = button(p, { - state : function() { return options_state(p, obj); }, - rect : { - pos : new p.PVector(button_x, button_top+button_sep), - style : splash_style, - text : "Settings" - } - }); - - var help_button = button(p, { - state : function() { return help_state(p, obj); }, - rect : { - pos : new p.PVector(button_x, button_top+2*button_sep), - style : splash_style, - text : "How To Play" - } - }); - /* - var high_scores_button = { - state : high_scores_state(), - rectangle : rectangle(p, { - pos : new p.PVector(20, 20), - width : 20, - height : 20 - }) - }; - */ - - //Not ordered - var all_buttons = [easy_button, tut_button, normal_button, options_button, - help_button, scores_button, credits_button ]; - - // --- public methods --- - - obj.get_type = function() { - return "splash"; - }; - - obj.update = function() { - //do nothing - }; - - obj.key_pressed = function(k) { - if (k === 115 || p.keyCode === 13 || k === 32) { //s, enter, space - obj.set_next_state(start_button.get_state()); - pause_menu_music(); - } - else if (k === 104) { //h - obj.set_next_state(help_button.get_state()); - } - }; - - /* - obj.mouse_moved = function(x, y) { - - for_each( - all_buttons, - function(b) { - b.mouse_moved(x, y); - } - ); - }; - */ - - obj.get_all_buttons = function() { - return all_buttons; - }; - - obj.render = function() { - p.background(back_color); - p.imageMode(p.CENTER); - //p.image(header_image, p.width / 2, 100, p.width * 3/4, 100); - p.image(back_image, p.width/2, p.height/2); - }; - - return obj; -}; diff --git a/state_manager.js b/state_manager.js deleted file mode 100644 index 811716b..0000000 --- a/state_manager.js +++ /dev/null @@ -1,187 +0,0 @@ -// *** state_manager *** -// The game engine; manages all of the games states -// Provides update(), mouse_click(x, y), and key_pressed(k) -// The next state to go to, if applicable, is returned by state.update() - -var state_manager = function (p) { - - // object to return - var obj = {}; - - // --- private variables --- - - var curr_state = loading_state(p); //The currently active state - //p.noLoop(); - var displayed_states = [curr_state]; //THIS MUST ALWAYS BE SORTED BY RENDERING LEVEL - - //A mapping from game states to their rendering levels - var type_to_level = { - "splash": 0, - "loading" : 0, - "game": 1, - "game_over": 2, - "pause": 2, - "credits": 2, - "help": 2, - "options" : 2 - }; - - // --- private methods --- - - //Removes a state from the displayed_states - //The state must be in displayed_states, or will throw an error - function remove_from_displayed(s) { - var index = displayed_states.indexOf(s); - if (index === -1) { - throw "error in remove_from_displayed in state_manager"; - } - displayed_states.splice(index, 1); //remove the element - } - - //Adds a state to displayed_states - //Ensures that displayed_states is sorted by ascending rendering level - var add_to_displayed_states = function(s) { - var render_level = type_to_level[s.get_type()]; - //Insert in the array right before a render level that is higher than it, or - //at the end if none - var inserted = false; - for (var i = 0; i < displayed_states.length; i++) { - var old_render_level = type_to_level[displayed_states[i].get_type()]; - if (old_render_level > render_level) { - displayed_states.splice(i, 0, s); - inserted = true; - } - } - if (inserted === false) { //add to end - displayed_states.push(s); - } - } - - - // --- public methods --- - - //Updates the current state and renders all appropriate states - obj.update = function() { - // Update all the states, and get next_state from curr_state.update_wrapper(); - var next_state = null; - var update_function = function(s) { - if (s === curr_state) { - next_state = s.update_wrapper(); - } - else { - // i see no reason to update not current states - //s.update_wrapper(); - } - }; - for_each(displayed_states, update_function); - - //If we have a new state to go to - if (next_state && next_state !== curr_state) { - //console.log("next is "+next_state.get_type()); - //Figure out if next state is an overlay - var state_type = next_state.get_type(); - var is_overlay = -1; - switch (state_type) { - case "splash": - is_overlay = false; - p.noLoop(); - break; - case "game": - is_overlay = false; - p.loop(); - break; - case "pause": - is_overlay = true; - p.noLoop(); - break; - case "help": - is_overlay = true; - p.noLoop(); - break; - case "game_over": - is_overlay = true; - p.noLoop(); - break; - case "options": - is_overlay = true; - p.noLoop(); - break; - case "loading": - is_overlay = false; - p.loop(); - break; - case "high_scores": - is_overlay = true; - p.noLoop(); - break; - case "credits": - is_overlay = true; - p.noLoop(); - break; - } - - //Error checking - if (is_overlay === -1) { - throw "error in update in state_manager"; - } - - //If overlay, add to displayed, otherwise reset displayed - if (is_overlay) { - // account for multiple overlays - // so we can go back to an overlay - if (member(displayed_states, next_state)) { - remove_from_displayed(curr_state); - } - else { - add_to_displayed_states(next_state); - } - } - else { - displayed_states = [next_state]; - } - curr_state = next_state; - //Potentially a problem, we do this even if not returning to a state - curr_state.resume(); - // updating its buttons - curr_state.update_wrapper(); - } - - for (var i = 0; i < displayed_states.length; i++) { - displayed_states[i].render_wrapper(); - } - - /* - if (curr_state.get_type() !== "game") { - p.noLoop(); - } - else { - p.loop(); - } - */ - }; - - //Passes clicks on to curr_state - obj.mouse_click = function (x, y) { - curr_state.mouse_click_wrapper(x, y); - if (curr_state.get_type() !== "game") { - obj.update(); - } - }; - - obj.key_pressed = function(k) { - curr_state.key_pressed(k); - if (curr_state.get_type() !== "game") { - obj.update(); - } - }; - - obj.mouse_moved = function(x,y) { - curr_state.mouse_moved_wrapper(x, y); - if (curr_state.get_type() !== "game") { - obj.update(); - } - //obj.update(); - } - - return obj; -}; diff --git a/test.js b/test.js deleted file mode 100644 index cc645eb..0000000 --- a/test.js +++ /dev/null @@ -1,92 +0,0 @@ -// all the processing code goes in the function -// which gets passed in a processing instance p -var p_code = function(p) { - - var sm, t1, c1, c2; - - p.setup = function() { - p.size(700, 600); - - // deal with console issues - // TODO move this code - if (!window.console) { - console = { log: function() {} }; - } - Processing.logger = console; - - var f = new p.loadFont("_sans"); - p.textFont(f, 14); - - sm = state_manager(p); - - p.frameRate(30); - }; - - update_counter = 0; - // draw is called repeatedly - p.draw = function() { - update_counter += 1; - if (update_counter === 30) { - //console.log("frame "+p.millis()); - //console.log(p.__frameRate); - update_counter = 0; - } - sm.update(); // Also renders - }; - - //Mouse and Keyboard input - p.keyPressed = function() { - sm.key_pressed(p.key); - }; - p.mousePressed = function() { - sm.mouse_click(p.mouseX, p.mouseY); - }; - p.mouseMoved = function() { - sm.mouse_moved(p.mouseX, p.mouseY); - }; -}; - - -// want this to be global -var sketch; - -var start_game = function() { - // attaches the processing code to the canvas - // note that we need to do this AFTER the canvas element is created - var canvas = document.getElementById("test_canvas"); - sketch = new Processing.Sketch(p_code); - //sketch.options.isTransparent = true; - var pInstance = new Processing(canvas, sketch); -}; -window.onload = start_game; - -/* -var back_code = function(p) { - var tiles = []; - p.setup = function() { - p.size(700, 600); - p.frameRate(30); - tiles.push(background(p, { - pos: new p.PVector(0, 0) - })); - tiles.push(background(p, { - pos: new p.PVector(700, 0) - })); - }; - p.draw = function() { - p.background(200); - for_each(tiles, function(tile) { - tile.update(); - tile.scroll(1); - tile.draw(); - }); - }; -}; -*/ -//var back_canvas = document.getElementById("back_canvas"); -//var backInstance = new Processing(back_canvas, back_code); - -// Make spacebar not move the window down -window.onkeydown = function(e) { - return !(e.keyCode == 32); -}; diff --git a/tkiller.js b/tkiller.js deleted file mode 100644 index db7d2c0..0000000 --- a/tkiller.js +++ /dev/null @@ -1,121 +0,0 @@ -// *** tkiller *** -// --- inherits from seeker.js -// spec: -// game_object spec + -// speed = how fast the tkiller approaches the target -// target = cell to move towards - -var tkiller = function(p, spec) { - - // --- defaults --- - - spec.width = spec.width || 35; - spec.height = spec.height || 35; - spec.speed = (spec.speed || 1.5) * g_speed_factor; - - // obj to return - var obj = seeker(p, spec); - - obj.get_type = function() { - return "tkiller"; - }; - - // --- private variables --- - - var alive = true; - /* @pjs preload="images/tcell2.png"; */ - var t_image = image_manager.get_image("tcell_2.png"); - - // Rect to fill in - var rectx_offset = -(8/30)*obj.get_width(); - var recty_offset = -(7/30) * obj.get_height(); - var rect_width = (13 / 30) * obj.get_width(); - var rect_height = (17 / 30) * obj.get_height(); - - - var t_anim = animated_image("t_animation", {anim_rate : 6}); - var t_image; - t_anim.start(); - t_anim.loop(); - - // --- public methods --- - - // implementing game_object interface - - // update makes tkiller chase target cell - obj.my_update = function() { - obj.move(); - obj.set_speed(obj.get_level()/2 + 1); - }; - - // should point towards target - // (triangle for now) - obj.draw = function() { - var pos = obj.get_pos(); - /* - p.pushMatrix(); - - var w = obj.get_width(); - var h = obj.get_height(); - p.shapeMode(obj.mode); - - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle()); - - p.fill(50); - p.noStroke(); - - // rightward triangle - p.triangle(-w/2, -h/2, -w/2, h/2, w/2, 0); - - p.popMatrix(); - */ - p.pushMatrix(); - p.imageMode(obj.get_mode()); - p.translate(pos.x, pos.y); - p.rotate(obj.get_target_angle() + p.PI / 2); - p.fill(obj.get_color()); - p.noStroke(); - p.rectMode(p.CORNER); - p.rect(rectx_offset, recty_offset, rect_width, rect_height); - //p.image(t_image, 0, 0, obj.get_width(), obj.get_height()); - if (obj.get_target() === null) { - t_anim.set_rate(6); - } - else { - t_anim.set_rate(3); - } - t_image = t_anim.get_frame(); - - if (obj.is_illustration()) { - t_image = image_manager.get_image("tcell_2.png"); - // to make it less transparent draw twice - p.image(t_image, 0, 0, - obj.get_width(), obj.get_height()); - } - - p.image(t_image, 0, 0, - obj.get_width(), obj.get_height()); - p.popMatrix(); - }; - - // is_dead just returns whether it isn't alive - obj.is_dead = function() { - return !alive; - }; - - // which means we need a way to die - obj.die = function() { - alive = false; - }; - - obj.stop_animation = function() { - t_anim.pause(); - }; - - obj.resume_animation = function() { - t_anim.start(); - }; - - return obj; -} diff --git a/wall_cell.js b/wall_cell.js deleted file mode 100644 index 62be000..0000000 --- a/wall_cell.js +++ /dev/null @@ -1,63 +0,0 @@ -// *** wall_cell *** -// --- inherits from game_object -// spec: -// game_object spec - -var wall_cell = function(p, spec) { - - var wall_image = image_manager.get_image("wallcell_1.png"); - - // --- defaults --- - - // temporarily dividing by 2 cuz image is too big - spec.width = spec.width || wall_image.width;///2 || 40; - spec.height = spec.height || wall_image.height;///2 || 20; - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "wall_cell"; - }; - - // --- private variables --- - - var alive = true; - - // --- public methods --- - - // implementing game_object interface - - // update is back to the default - obj.update = function() { - obj.move(); - }; - - // (rect for now) - obj.draw = function() { - var pos = obj.get_pos(); - /* - p.shapeMode(obj.mode); - - p.fill(100); - p.noStroke(); - - var w = obj.get_width(); - var h = obj.get_height(); - p.rect(pos.x-w/2, pos.y-h/2, w, h); - */ - p.imageMode(obj.get_mode()); - p.image(wall_image, pos.x, pos.y, obj.get_width(), obj.get_height()); - }; - - obj.is_dead = function() { - return !alive; - }; - - obj.die = function() { - alive = false; - }; - - - return obj; -} diff --git a/wall_segment.js b/wall_segment.js deleted file mode 100644 index db886ac..0000000 --- a/wall_segment.js +++ /dev/null @@ -1,114 +0,0 @@ -// list of specs for wall segments to use in the game -// later can include which image/shape to use -// MUST HAVE WIDTH AND HEIGHT SPECIFIED -/* -var wall_specs = [ - { width: 100, height: 51 } - //{ width: 100, height: 30, fill: 0 }, - //{ width: 200, height: 30, fill: 50 }, - //{ width: 50, height: 30, fill: 100 }, - //{ width: 150, height: 30, fill: 150 } -]; -*/ - -// *** wall_segment *** -// --- inherits from game_object -// spec: -// game_object spec -// boolean is_top = true if it is on the top of the screen -// pos should be at bottom left corner -// -// Each wall segment must match up with the other -// wall segments at each end -// Segment images should be formatted for the bottom wall - -var wall_segment = function(p, spec) { - - //var wall_shape = p.loadShape("images/cellwall1draft.svg"); - var wall_image = random_from( - image_manager.get_images("wall_segments")).image; - - // --- defaults --- - - // temporarily dividing by 3 because the images are 3x too big - spec.width = spec.width || wall_image.width;///3;// || 60; - spec.height = spec.height || wall_image.height;///3;// || 60; - spec.fill = spec.fill || 150; - spec.mode = p.CENTER; - // adjust to center coords - spec.pos.add(new p.PVector(spec.width/2, -spec.height/2)); - - // obj to return - var obj = game_object(p, spec); - - obj.get_type = function() { - return "wall_segment"; - }; - - // --- private variables --- - - // --- public methods --- - - obj.get_y_offset = function() { - return obj.get_height()/2; - }; - - // implementing game_object interface - - // update is default (move) - - // (flat rect for now) - obj.draw = function() { - p.pushMatrix(); - - var pos = obj.get_pos(); - p.shapeMode(obj.mode); - // all diff colors for testing - p.fill(0);//spec.fill); - p.noStroke(); - - var w = obj.get_width(); - var h = obj.get_height(); - - p.translate(pos.x, pos.y); - - if (spec.is_top) { - p.rotate(p.PI); - } - - //p.rect(-w/2, -h/2, w, h); - p.imageMode(obj.get_mode()); - p.image(wall_image, 0, 0, w, h); - //p.set(0, 0, wall_shape); - //draw(canvas.getContext('2d')); - //var d = new Date(); - //console.log(d.getMilliseconds()); - //canvas.getContext('2d').drawSvg("images/virusFinal.svg", 300, 10, 20, 20); - //console.log(d.getMilliseconds()); - - p.popMatrix(); - }; - - obj.draw_circle = function() {}; - - // walls can't die - obj.is_dead = function() { - return false; - }; - - //var count = 0; - obj.scroll = function(scroll_factor) { - //count += 1; - //if (count === 1) { - //count = 0; - obj.get_pos().add(new p.PVector(obj.get_scroll_dist(), 0)); - //} - }; - - obj.get_scroll_dist = function() { - return -1; - }; - - return obj; -}; -