From 106d081dda7d76f3f42347b742fe568e0ca98f46 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Tue, 11 Aug 2015 11:09:12 +0200 Subject: [PATCH] #2690 creaWT Feature New Normal - wt Documentation --- wt/data/infoConf_server_fcgi/Readme.txt | 17 +- wt/data/infoConf_server_fcgi/Readme.txt~ | 23 +- wt/data/resourcesXTK/styleWT.css | 27 + wt/data/resourcesXTK/xtk.js | 420 +++ wt/data/resourcesXTK/xtk_xdat.gui.js | 3665 ++++++++++++++++++++++ 5 files changed, 4145 insertions(+), 7 deletions(-) create mode 100644 wt/data/resourcesXTK/styleWT.css create mode 100644 wt/data/resourcesXTK/xtk.js create mode 100644 wt/data/resourcesXTK/xtk_xdat.gui.js diff --git a/wt/data/infoConf_server_fcgi/Readme.txt b/wt/data/infoConf_server_fcgi/Readme.txt index 8d63d71..ea5925f 100644 --- a/wt/data/infoConf_server_fcgi/Readme.txt +++ b/wt/data/infoConf_server_fcgi/Readme.txt @@ -17,7 +17,7 @@ mkdir /var/www/testwtdbg/docroot 3) Apache configuration -cp fastcgi-wt.conf /etc/httpd/conf.modules.d/. +cp fastcgi-wt.conf /etc/httpd/conf.d/. service httpd restart 4) wt temporary diractory @@ -26,11 +26,12 @@ chown apache:apache /var/run/wt 5) wt CONFIGURATION mkdir /etc/wt -cp wt_config.xml /etc/wt +cp wt_config.xml /etc/wt/. 6) Prepare wt application site mkdir / +chown apache:apache / mkdir //imagesTMP cp bbiWeb.php //. ln -s /share/Wt/resources //resources @@ -45,6 +46,18 @@ http://localhost//bbiWeb.php ------------------------------------------------------ +TODO: +0) BUG: bbiWeb.wt reads just 1 bbs : demoPresentacion1Boton02.bbs +0.5) BUG The tempFiles from bbtk-wt are in nn + +1) BUG: Modify Thirdparty-install-Base-rpm.sh + separate the devel modules +2) FUTURE: Add creaWT in bbtk stuff +3) FUTURE: Install de directory data of creaWT in share/creaWT/data +4) BUG: creaWT/wt/data/resourcesXTK +5) bbtk-WT hola.nii can't be generated automaticaly +------------------------------------------------------ + Genaral Notes: -------------- diff --git a/wt/data/infoConf_server_fcgi/Readme.txt~ b/wt/data/infoConf_server_fcgi/Readme.txt~ index 086225c..ea5925f 100644 --- a/wt/data/infoConf_server_fcgi/Readme.txt~ +++ b/wt/data/infoConf_server_fcgi/Readme.txt~ @@ -6,7 +6,7 @@ yum install fcgi-devel yum install mod_fcgid 1) ld configuration -cp bbtk.conf/etc/ld.so.conf.d/. +cp bbtk.conf /etc/ld.so.conf.d/. ldconfig 2) Create virtual site apache @@ -17,7 +17,7 @@ mkdir /var/www/testwtdbg/docroot 3) Apache configuration -cp fastcgi-wt.conf /etc/httpd/conf.modules.d/. +cp fastcgi-wt.conf /etc/httpd/conf.d/. service httpd restart 4) wt temporary diractory @@ -25,12 +25,13 @@ mkdir /var/run/wt chown apache:apache /var/run/wt 5) wt CONFIGURATION - -cp wt_config.xml /etc/wt mkdir /etc/wt +cp wt_config.xml /etc/wt/. + 6) Prepare wt application site mkdir / +chown apache:apache / mkdir //imagesTMP cp bbiWeb.php //. ln -s /share/Wt/resources //resources @@ -38,13 +39,25 @@ ln -s /wt/data/reosurcesXTK /resourcesXTK ln -s /bin/bbiWeb.wt /bbiWeb.wt -6) Call application from browser +7) Call application from browser http://localhost//bbiWeb.php ------------------------------------------------------ +TODO: +0) BUG: bbiWeb.wt reads just 1 bbs : demoPresentacion1Boton02.bbs +0.5) BUG The tempFiles from bbtk-wt are in nn + +1) BUG: Modify Thirdparty-install-Base-rpm.sh + separate the devel modules +2) FUTURE: Add creaWT in bbtk stuff +3) FUTURE: Install de directory data of creaWT in share/creaWT/data +4) BUG: creaWT/wt/data/resourcesXTK +5) bbtk-WT hola.nii can't be generated automaticaly +------------------------------------------------------ + Genaral Notes: -------------- diff --git a/wt/data/resourcesXTK/styleWT.css b/wt/data/resourcesXTK/styleWT.css new file mode 100644 index 0000000..85a7d47 --- /dev/null +++ b/wt/data/resourcesXTK/styleWT.css @@ -0,0 +1,27 @@ +.yellow-box { + background-color: #ffffb4; + border: 1px solid black; + margin-top: 1ex; + margin-bottom: 1ex; +} + +.green-box { + background-color: #c4ffb4; + min-height: 30px; + text-align: center; + padding: 3px; +} + +.blue-box { + background-color: #65dae8; + min-height: 30px; + text-align: center; + padding: 3px; +} + +.black-box { + background-color: #000000; + min-height: 30px; + text-align: center; + padding: 3px; +} diff --git a/wt/data/resourcesXTK/xtk.js b/wt/data/resourcesXTK/xtk.js new file mode 100644 index 0000000..4bac033 --- /dev/null +++ b/wt/data/resourcesXTK/xtk.js @@ -0,0 +1,420 @@ +/* + * + * xxxxxxx xxxxxxx + * x:::::x x:::::x + * x:::::x x:::::x + * x:::::xx:::::x + * x::::::::::x + * x::::::::x + * x::::::::x + * x::::::::::x + * x:::::xx:::::x + * x:::::x x:::::x + * x:::::x x:::::x + * THE xxxxxxx xxxxxxx TOOLKIT + * + * http://www.goXTK.com + * + * Copyright (c) 2012 The X Toolkit Developers + * + * The X Toolkit (XTK) is licensed under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + * + * "Free software" is a matter of liberty, not price. + * "Free" as in "free speech", not as in "free beer". + * - Richard M. Stallman + * + * FUELED BY: + * - the wonderful Constructive Solid Geometry library by Evan Wallace (http://madebyevan.com) + * LICENSE: https://raw.github.com/xtk/X/master/lib/csg/LICENSE + * + * - parts of the Google Closure Library (http://code.google.com/closure/library) + * LICENSE: https://raw.github.com/xtk/google-closure-library/master/LICENSE + * + * - zlib.js, the ultimate gzip/zlib javascript implementation (https://github.com/imaya/zlib.js) + * LICENSE: https://raw.github.com/imaya/zlib.js/master/LICENSE + * + * MORE CREDITS: https://raw.github.com/xtk/X/master/LICENSE + * + */ +function m(a){throw a;}var p=void 0,q=!0,t=null,u=!1;function aa(){return function(){}}function ca(a){return function(b){this[a]=b}}function v(a){return function(){return this[a]}}var w,fa=this;function ga(){} +function ha(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null"; +else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function ia(a){return a!==p}function ja(a){return"array"==ha(a)}function ma(a){var b=ha(a);return"array"==b||"object"==b&&"number"==typeof a.length}function na(a){return"string"==typeof a}function x(a){return"number"==typeof a}function oa(a){return"function"==ha(a)}function pa(a){var b=typeof a;return"object"==b&&a!=t||"function"==b}function qa(a){return a[ra]||(a[ra]=++sa)}var ra="closure_uid_"+(1E9*Math.random()>>>0),sa=0; +function ta(a,b,c){return a.call.apply(a.bind,arguments)}function ua(a,b,c){a||m(Error());if(2a&&(a=this.byteLength+a);0>c&&(c=this.byteLength+c);ca&&(a=0);0>c&&(c=0);a>this.byteLength&&(a=this.byteLength);c>this.byteLength&&(c=this.byteLength);for(var e=new ArrayBuffer(c-a),d=new Uint8Array(this),f=new Uint8Array(e),g=a,h=0;g")&&(a=a.replace(Va,">"));-1!=a.indexOf('"')&&(a=a.replace(Wa,"""));return a}var Ta=/&/g,Ua=//g,Wa=/\"/g,Sa=/[&<>\"]/;var Xa,Ya,Za,$a,ab,bb,db;function eb(){return fa.navigator?fa.navigator.userAgent:t}function fb(){return fa.navigator}$a=Za=Ya=Xa=u;var gb;if(gb=eb()){var hb=fb();Xa=0==gb.indexOf("Opera");Ya=!Xa&&-1!=gb.indexOf("MSIE");Za=!Xa&&-1!=gb.indexOf("WebKit");$a=!Xa&&!Za&&"Gecko"==hb.product}var ib=Xa,K=Ya,jb=$a,lb=Za,mb,pb=fb();mb=pb&&pb.platform||"";ab=-1!=mb.indexOf("Mac");bb=-1!=mb.indexOf("Win");db=-1!=mb.indexOf("Linux");var qb=!!fb()&&-1!=(fb().appVersion||"").indexOf("X11"); +function rb(){var a=fa.document;return a?a.documentMode:p}var sb;a:{var wb="",xb;if(ib&&fa.opera)var yb=fa.opera.version,wb="function"==typeof yb?yb():yb;else if(jb?xb=/rv\:([^\);]+)(\)|;)/:K?xb=/MSIE\s+([^\);]+)(\)|;)/:lb&&(xb=/WebKit\/(\S+)/),xb)var zb=xb.exec(eb()),wb=zb?zb[1]:"";if(K){var Ab=rb();if(Ab>parseFloat(wb)){sb=String(Ab);break a}}sb=wb}var Bb={}; +function Cb(a){var b;if(!(b=Bb[a])){b=0;for(var c=String(sb).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),e=String(a).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),d=Math.max(c.length,e.length),f=0;0==b&&f(0==n[1].length?0:parseInt(n[1],10))?1:0)||((0==k[2].length)<(0==n[2].length)?-1:(0==k[2].length)>(0==n[2].length)?1:0)||(k[2]n[2]?1:0)}while(0==b)}b=Bb[a]=0<=b}return b}var Db=fa.document,Eb=!Db||!K?p:rb()||("CSS1Compat"==Db.compatMode?parseInt(sb,10):5);var Fb=!K||K&&9<=Eb,Gb=K&&!Cb("9");!lb||Cb("528");jb&&Cb("1.9b")||K&&Cb("8")||ib&&Cb("9.5")||lb&&Cb("528");jb&&!Cb("8")||K&&Cb("9");var Hb=Array.prototype,Ib=Hb.indexOf?function(a,b,c){return Hb.indexOf.call(a,b,c)}:function(a,b,c){c=c==t?0:0>c?Math.max(0,a.length+c):c;if(na(a))return!na(b)||1!=b.length?-1:a.indexOf(b,c);for(;c=arguments.length?Hb.slice.call(a,b):Hb.slice.call(a,b,c)};function Pb(){0!=Qb&&(this.xl=Error().stack,qa(this))}var Qb=0;function Rb(a,b){this.type=a;this.currentTarget=this.target=b}w=Rb.prototype;w.wc=u;w.defaultPrevented=u;w.ye=q;w.stopPropagation=function(){this.wc=q};w.preventDefault=function(){this.defaultPrevented=q;this.ye=u};function Sb(a){Sb[" "](a);return a}Sb[" "]=ga;function Tb(a,b){a&&this.Ca(a,b)}C(Tb,Rb);w=Tb.prototype;w.target=t;w.relatedTarget=t;w.offsetX=0;w.offsetY=0;w.clientX=0;w.clientY=0;w.screenX=0;w.screenY=0;w.button=0;w.keyCode=0;w.charCode=0;w.ctrlKey=u;w.altKey=u;w.shiftKey=u;w.metaKey=u;w.Wj=u;w.sb=t; +w.Ca=function(a,b){var c=this.type=a.type;Rb.call(this,c);this.target=a.target||a.srcElement;this.currentTarget=b;var e=a.relatedTarget;if(e){if(jb){var d;a:{try{Sb(e.nodeName);d=q;break a}catch(f){}d=u}d||(e=t)}}else"mouseover"==c?e=a.fromElement:"mouseout"==c&&(e=a.toElement);this.relatedTarget=e;this.offsetX=lb||a.offsetX!==p?a.offsetX:a.layerX;this.offsetY=lb||a.offsetY!==p?a.offsetY:a.layerY;this.clientX=a.clientX!==p?a.clientX:a.pageX;this.clientY=a.clientY!==p?a.clientY:a.pageY;this.screenX= +a.screenX||0;this.screenY=a.screenY||0;this.button=a.button;this.keyCode=a.keyCode||0;this.charCode=a.charCode||("keypress"==c?a.keyCode:0);this.ctrlKey=a.ctrlKey;this.altKey=a.altKey;this.shiftKey=a.shiftKey;this.metaKey=a.metaKey;this.Wj=ab?a.metaKey:a.ctrlKey;this.state=a.state;this.sb=a;a.defaultPrevented&&this.preventDefault();delete this.wc};w.stopPropagation=function(){Tb.u.stopPropagation.call(this);this.sb.stopPropagation?this.sb.stopPropagation():this.sb.cancelBubble=q}; +w.preventDefault=function(){Tb.u.preventDefault.call(this);var a=this.sb;if(a.preventDefault)a.preventDefault();else if(a.returnValue=u,Gb)try{if(a.ctrlKey||112<=a.keyCode&&123>=a.keyCode)a.keyCode=-1}catch(b){}};w.Gi=v("sb");var Ub={},Vb={},Wb={},Xb={};function L(a,b,c,e,d){if(ja(b)){for(var f=0;fd.keyCode||d.returnValue!=p)return q;a:{var l=u;if(0==d.keyCode)try{d.keyCode=-1;break a}catch(j){l=q}if(l||d.returnValue==p)d.returnValue=q}}l=new Tb;l.Ca(d,this);d=q;try{if(g){for(var k=[],n=l.currentTarget;n;n=n.parentNode)k.push(n);f=e[q];f.Na=f.oa;for(var s=k.length- +1;!l.wc&&0<=s&&f.Na;s--)l.currentTarget=k[s],d&=fc(f,k[s],c,q,l);if(h){f=e[u];f.Na=f.oa;for(s=0;!l.wc&&sj?2:1E-52*this.oa&&Ac(this),q):u};function Ac(a){if(a.oa!=a.S.length){for(var b=0,c=0;ba||360a||360a||360a)&&m(Error("Invalid opacity."));for(var b=this.c,c=b.length,e=0,e=0;eb.ya?-1:1}A("X.object",Y);A("X.object.prototype.modified",Y.prototype.q);A("X.object.prototype.remove",Y.prototype.remove); +A("X.object.prototype.destroy",Y.prototype.Ta);function od(){}function pd(a){for(var b=a.h.count,c=[],e=0,e=0;e");c=c.join("")}var f=a.createElement(c);e&&(na(e)?f.className=e:ja(e)?Ud.apply(t,[f].concat(e)):Na(e,function(a,b){"style"==b?f.style.cssText=a:"class"==b?f.className=a:"for"==b?f.htmlFor=a:b in ce?f.setAttribute(ce[b],a):0==b.lastIndexOf("aria-",0)||0==b.lastIndexOf("data-",0)?f.setAttribute(b,a): +f[b]=a}));if(2=this.left&&a.right<=this.right&&a.top>=this.top&&a.bottom<=this.bottom:a.x>=this.left&&a.x<=this.right&&a.y>=this.top&&a.y<=this.bottom}; +w.ceil=function(){this.top=Math.ceil(this.top);this.right=Math.ceil(this.right);this.bottom=Math.ceil(this.bottom);this.left=Math.ceil(this.left);return this};w.floor=function(){this.top=Math.floor(this.top);this.right=Math.floor(this.right);this.bottom=Math.floor(this.bottom);this.left=Math.floor(this.left);return this};w.round=function(){this.top=Math.round(this.top);this.right=Math.round(this.right);this.bottom=Math.round(this.bottom);this.left=Math.round(this.left);return this}; +w.translate=function(a,b){a instanceof Xd?(this.left+=a.x,this.right+=a.x,this.top+=a.y,this.bottom+=a.y):(this.left+=a,this.right+=a,x(b)&&(this.top+=b,this.bottom+=b));return this};w.scale=function(a,b){var c=x(b)?b:a;this.left*=a;this.right*=a;this.top*=c;this.bottom*=c;return this};function le(a,b,c,e){this.left=a;this.top=b;this.width=c;this.height=e}w=le.prototype;w.l=function(){return new le(this.left,this.top,this.width,this.height)};w.Tg=function(a){var b=Math.max(this.left,a.left),c=Math.min(this.left+this.width,a.left+a.width);if(b<=c){var e=Math.max(this.top,a.top);a=Math.min(this.top+this.height,a.top+a.height);if(e<=a)return this.left=b,this.top=e,this.width=c-b,this.height=a-e,q}return u}; +w.contains=function(a){return a instanceof le?this.left<=a.left&&this.left+this.width>=a.left+a.width&&this.top<=a.top&&this.top+this.height>=a.top+a.height:a.x>=this.left&&a.x<=this.left+this.width&&a.y>=this.top&&a.y<=this.top+this.height};function me(a,b){var c=b.xa.clientWidth||a.scrollHeight>a.clientHeight||"fixed"==c||"absolute"==c||"relative"==c))return a;return t} +function se(a){for(var b=new ke(0,Infinity,Infinity,0),c=Zd(a),e=c.ka.body,d=c.ka.documentElement,f=!lb&&"CSS1Compat"==c.ka.compatMode?c.ka.documentElement:c.ka.body;a=re(a);)if((!K||0!=a.clientWidth)&&(!lb||0!=a.clientHeight||a!=e)&&a!=e&&a!=d&&"visible"!=oe(a,"overflow")){var g=te(a),h;h=a;if(jb&&!Cb("1.9")){var l=parseFloat(ne(h,"borderLeftWidth"));if(ue(h))var j=h.offsetWidth-h.clientWidth-l-parseFloat(ne(h,"borderRightWidth")),l=l+j;h=new Xd(l,parseFloat(ne(h,"borderTopWidth")))}else h=new Xd(h.clientLeft, +h.clientTop);g.x+=h.x;g.y+=h.y;b.top=Math.max(b.top,g.y);b.right=Math.min(b.right,g.x+a.clientWidth);b.bottom=Math.min(b.bottom,g.y+a.clientHeight);b.left=Math.max(b.left,g.x)}e=f.scrollLeft;f=f.scrollTop;b.left=Math.max(b.left,e);b.top=Math.max(b.top,f);c=(c.ka.parentWindow||c.ka.defaultView||window).document;c="CSS1Compat"==c.compatMode?c.documentElement:c.body;c=new Vd(c.clientWidth,c.clientHeight);b.right=Math.min(b.right,e+c.width);b.bottom=Math.min(b.bottom,f+c.height);return 0<=b.top&&0<=b.left&& +b.bottom>b.top&&b.right>b.left?b:t} +function te(a){var b,c=ae(a),e=oe(a,"position"),d=jb&&c.getBoxObjectFor&&!a.getBoundingClientRect&&"absolute"==e&&(b=c.getBoxObjectFor(a))&&(0>b.screenX||0>b.screenY),f=new Xd(0,0),g=pe(c);if(a==g)return f;if(a.getBoundingClientRect)b=qe(a),a=je(Zd(c)),f.x=b.left+a.x,f.y=b.top+a.y;else if(c.getBoxObjectFor&&!d)b=c.getBoxObjectFor(a),a=c.getBoxObjectFor(g),f.x=b.screenX-a.screenX,f.y=b.screenY-a.screenY;else{b=a;do{f.x+=b.offsetLeft;f.y+=b.offsetTop;b!=a&&(f.x+=b.clientLeft||0,f.y+=b.clientTop||0); +if(lb&&"fixed"==oe(b,"position")){f.x+=c.body.scrollLeft;f.y+=c.body.scrollTop;break}b=b.offsetParent}while(b&&b!=a);if(ib||lb&&"absolute"==e)f.y-=c.body.offsetTop;for(b=a;(b=re(b))&&b!=c.body&&b!=g;)if(f.x-=b.scrollLeft,!ib||"TR"!=b.tagName)f.y-=b.scrollTop}return f} +function ve(a){var b=new Xd;if(1==a.nodeType){if(a.getBoundingClientRect){var c=qe(a);b.x=c.left;b.y=c.top}else{var c=je(Zd(a)),e=te(a);b.x=e.x-c.x;b.y=e.y-c.y}if(jb&&!Cb(12)){var d;K?d="-ms-transform":lb?d="-webkit-transform":ib?d="-o-transform":jb&&(d="-moz-transform");var f;d&&(f=oe(a,d));f||(f=oe(a,"transform"));f?(a=f.match(we),a=!a?new Xd(0,0):new Xd(parseFloat(a[1]),parseFloat(a[2]))):a=new Xd(0,0);b=new Xd(b.x+a.x,b.y+a.y)}}else d=oa(a.Gi),f=a,a.targetTouches?f=a.targetTouches[0]:d&&a.sb.targetTouches&& +(f=a.sb.targetTouches[0]),b.x=f.clientX,b.y=f.clientY;return b}function xe(a,b){"number"==typeof a&&(a=(b?Math.round(a):a)+"px");return a}function ye(a){if("none"!=oe(a,"display"))return ze(a);var b=a.style,c=b.display,e=b.visibility,d=b.position;b.visibility="hidden";b.position="absolute";b.display="inline";a=ze(a);b.display=c;b.position=d;b.visibility=e;return a} +function ze(a){var b=a.offsetWidth,c=a.offsetHeight,e=lb&&!b&&!c;return(!ia(b)||e)&&a.getBoundingClientRect?(a=qe(a),new Vd(a.right-a.left,a.bottom-a.top)):new Vd(b,c)}function Ae(a,b){a.style.display=b?"":"none"}function ue(a){return"rtl"==oe(a,"direction")}function Be(a,b){if(/^\d+px?$/.test(b))return parseInt(b,10);var c=a.style.left,e=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;a.style.left=b;var d=a.style.pixelLeft;a.style.left=c;a.runtimeStyle.left=e;return d} +function Ce(a,b){var c=a.currentStyle?a.currentStyle[b]:t;return c?Be(a,c):0}var De={thin:2,medium:4,thick:6};function Ee(a,b){if("none"==(a.currentStyle?a.currentStyle[b+"Style"]:t))return 0;var c=a.currentStyle?a.currentStyle[b+"Width"]:t;return c in De?De[c]:Be(a,c)}var we=/matrix\([0-9\.\-]+, [0-9\.\-]+, [0-9\.\-]+, [0-9\.\-]+, ([0-9\.\-]+)p?x?, ([0-9\.\-]+)p?x?\)/;function Fe(a,b){jc.call(this);this.H=a;var c=pa(this.H)&&1==this.H.nodeType?this.H:this.H?this.H.body:t;this.aj=!!c&&ue(c);this.Jl=L(this.H,jb?"DOMMouseScroll":"mousewheel",this,b)}C(Fe,jc); +Fe.prototype.handleEvent=function(a){var b=0,c=0,e=0;a=a.sb;if("mousewheel"==a.type){c=1;if(K||lb&&(bb||Cb("532.0")))c=40;e=Ge(-a.wheelDelta,c);ia(a.wheelDeltaX)?(b=Ge(-a.wheelDeltaX,c),c=Ge(-a.wheelDeltaY,c)):c=e}else e=a.detail,100e&&(e=-3),ia(a.axis)&&a.axis===a.HORIZONTAL_AXIS?b=e:c=e;x(this.Yg)&&(b=Math.min(Math.max(b,-this.Yg),this.Yg));x(this.Zg)&&(c=Math.min(Math.max(c,-this.Zg),this.Zg));this.aj&&(b=-b);b=new He(e,a,b,c);this.dispatchEvent(b)}; +function Ge(a,b){return lb&&(ab||db)&&0!=a%b?a:a/b}function He(a,b,c,e){b&&this.Ca(b,p);this.type="mousewheel";this.detail=a;this.yl=c;this.Xc=e}C(He,Tb);K||lb&&Cb("525");function Ie(a){M.call(this);this.f="interactor";this.Oa=a;this.Se=this.og=this.ng=this.pg=this.mg=this.qg=t;this.Yd=q;this.Xb=this.Qb=this.wb=u;this.ua=[0,0];this.Ne=new D.m(0,0,0);this.gd=new D.m(0,0,0);this.Vg=0;this.xg=this.Wd=t;this.wg=u;this.R={MOUSEWHEEL_ENABLED:q,MOUSECLICKS_ENABLED:q,KEYBOARD_ENABLED:q,HOVERING_ENABLED:q,CONTEXTMENU_ENABLED:u,TOUCH_ENABLED:q,TOUCH_BOUNCING_ENABLED:u}}C(Ie,M);Ie.prototype.__defineGetter__("config",v("R"));Ie.prototype.__defineGetter__("leftButtonDown",v("wb")); +Ie.prototype.__defineGetter__("middleButtonDown",v("Qb"));Ie.prototype.__defineGetter__("rightButtonDown",v("Xb")); +Ie.prototype.Ca=function(){this.R.MOUSEWHEEL_ENABLED?(this.Se=new Fe(this.Oa),this.qg=L(this.Se,"mousewheel",this.Kd.bind(this))):(bc(this.qg),this.Se=t);this.R.MOUSECLICKS_ENABLED?(this.mg=L(this.Oa,"mousedown",this.vj.bind(this)),this.pg=L(this.Oa,"mouseup",this.Aj.bind(this))):(bc(this.mg),bc(this.pg));this.Oa.oncontextmenu=this.R.CONTEXTMENU_ENABLED?t:function(){return u};window.onkeydown=this.R.KEYBOARD_ENABLED?this.ih.bind(this):t;this.R.TOUCH_ENABLED?(this.R.TOUCH_BOUNCING_ENABLED||document.body.addEventListener("touchmove", +function(a){a.preventDefault()},u),this.ci=L(this.Oa,"touchstart",this.Pj.bind(this)),this.bi=L(this.Oa,"touchmove",this.Nj.bind(this)),this.ai=L(this.Oa,"touchend",this.Jj.bind(this))):(bc(this.ci),bc(this.bi),bc(this.ai));bc(this.ng);bc(this.og);this.ng=L(this.Oa,"mousemove",this.xj.bind(this));this.og=L(this.Oa,"mouseout",this.yj.bind(this))}; +Ie.prototype.vj=function(a){0==a.button?this.wb=q:1==a.button?this.Qb=q:2==a.button&&(this.Xb=q);eval("this.onMouseDown("+this.wb+","+this.Qb+","+this.Xb+")");Je(this);a.preventDefault()};Ie.prototype.uj=aa();Ie.prototype.Aj=function(a){0==a.button?this.wb=u:1==a.button?this.Qb=u:2==a.button&&(this.Xb=u);eval("this.onMouseUp("+this.wb+","+this.Qb+","+this.Xb+")");Je(this);a.preventDefault()};Ie.prototype.__defineGetter__("mousePosition",v("ua"));w=Ie.prototype;w.zj=aa(); +w.yj=function(a){this.Yd=u;this.R.KEYBOARD_ENABLED&&(window.onkeydown=t);this.Xb=this.Qb=this.wb=u;Je(this);this.Ne=new D.m(0,0,0);a.preventDefault()};w.wj=aa();w.Pj=function(a){a.preventDefault();a.Ca(a.sb.targetTouches[0],a.currentTarget);eval("this.onTouchStart("+a.clientX+","+a.clientY+")");this.gd=new D.m(a.clientX,a.clientY,0);this.xg=setTimeout(this.Lj.bind(this,a),500)};w.Oj=aa(); +w.Lj=function(a){eval("this.onTouchHover("+a.clientX+","+a.clientY+")");a=new Jd;a.vb=q;a.ib=this instanceof Ke;this.dispatchEvent(a);this.be=q};w.Kj=aa();function Le(a){clearTimeout(a.xg);if(a.be){var b=new Jd;b.vb=u;b.ib=a instanceof Ke;a.dispatchEvent(b)}a.be=u}w.Jj=function(a){a.preventDefault();eval("this.onTouchEnd()");Le(this)};w.Ij=aa(); +w.Nj=function(a){a.preventDefault();this.be||Le(this);this.touchmoveEvent=a=a.sb;eval("this.onTouchMove(this['touchmoveEvent'])");var b=a.targetTouches;if(1==b.length){a=b[0];var c=[a.clientX,a.clientY];a=new D.m(c[0],c[1],0);var b=c[0]>3*this.Oa.clientWidth/4,e=c[0]3*this.Oa.clientHeight/4,c=!b&&!e&&!d&&!c,d=this.gd.wa(a);this.gd=a.l();if(this.be)a=new Hd,5d.x&&(d.x=-1),5d.y&&(d.y=-1),a.ya=d,this.dispatchEvent(a); +else if(this instanceof Me&&(b||e))a=new Kd,a.V=0>d.y,this.dispatchEvent(a);else if(this instanceof Ke||c)d.scale(3),a=new Id,a.ya=d,this.dispatchEvent(a)}else 2==b.length&&(a=b[0],b=b[1],a=[a.clientX,a.clientY],b=[b.clientX,b.clientY],a=new D.m(a[0],a[1],0),b=new D.m(b[0],b[1],0),d=Gc(a,b),b=d-this.Vg,this.Vg=d,this.gd.wa(a),this.gd=a.l(),10=f&&(a.preventDefault(),d?a=new Hd:b?a=new Jd:(a=new Id,this instanceof Me&&(a=new Kd)),a&&(c=new D.m(0,0,0),37==f?(c.x=5,a.V=u,b&&(a.V=q,a.vb=q,a.ib=u)):39==f?(c.x=-5,a.V=q,b&&(a.vb=u,a.ib=u)):38==f?(c.y=5,a.V=q,b&&(a.vb=q,a.ib=q)):40==f&&(c.y=-5,a.V=u,b&&(a.vb= +u,a.ib=q)),a.ya=c,this.dispatchEvent(a)))}};A("X.interactor",Ie);A("X.interactor.prototype.init",Ie.prototype.Ca);A("X.interactor.prototype.onMouseDown",Ie.prototype.uj);A("X.interactor.prototype.onMouseUp",Ie.prototype.zj);A("X.interactor.prototype.onMouseMove",Ie.prototype.wj);A("X.interactor.prototype.onMouseWheel",Ie.prototype.Bj);A("X.interactor.prototype.onKey",Ie.prototype.sj);A("X.interactor.prototype.onTouchStart",Ie.prototype.Oj);A("X.interactor.prototype.onTouchMove",Ie.prototype.Mj); +A("X.interactor.prototype.onTouchEnd",Ie.prototype.Ij);A("X.interactor.prototype.onTouchHover",Ie.prototype.Kj);function Me(a){Ie.call(this,a);this.f="interactor2D"}C(Me,Ie);Me.prototype.Kd=function(a){Me.u.Kd.call(this,a);var b=new Kd;a.Xc==t&&(a.Xc=0);b.V=0>a.Xc;this.dispatchEvent(b)};function Ne(){M.call(this);this.f="parser";this.J=t;this.C=0;this.Zh=0<(new Int8Array((new Int16Array([1])).buffer))[0];this.Mc=q;this.rl=-Infinity;this.ql=Infinity}C(Ne,M);Ne.prototype.parse=function(){m(Error("The function parse() should be overloaded."))};function Oe(a){for(var b=Infinity,c=-Infinity,e=a.length,d=0,d=0;d +g;f--,g++){var h=b[g];b[g]=b[f];b[f]=h}b=a}return 1==c?b[0]:b} +function Qe(a,b){var c=[Number.MAX_VALUE,-Number.MAX_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE],e=Qc(0,0,0,1),d=Pc();cd(a,e,d);c[0]=d[0]c[1]?d[0]:c[1];c[2]=d[1]c[3]?d[1]:c[3];c[4]=d[2]c[5]?d[2]:c[5];e=Qc(0,0,b[2]-1,1);cd(a,e,d);c[0]=d[0]c[1]?d[0]:c[1];c[2]=d[1]c[3]?d[1]:c[3];c[4]=d[2]c[5]?d[2]:c[5];e=Qc(0,b[1]- +1,0,1);cd(a,e,d);c[0]=d[0]c[1]?d[0]:c[1];c[2]=d[1]c[3]?d[1]:c[3];c[4]=d[2]c[5]?d[2]:c[5];e=Qc(b[0]-1,0,0,1);cd(a,e,d);c[0]=d[0]c[1]?d[0]:c[1];c[2]=d[1]c[3]?d[1]:c[3];c[4]=d[2]c[5]?d[2]:c[5];e=Qc(b[0]-1,b[1]-1,0,1);cd(a,e,d);c[0]=d[0]c[1]?d[0]:c[1];c[2]=d[1]c[3]?d[1]:c[3];c[4]=d[2]c[5]?d[2]:c[5];e=Qc(b[0]-1,0,b[2]-1,1);cd(a,e,d);c[0]=d[0]c[1]?d[0]:c[1];c[2]=d[1]c[3]?d[1]:c[3];c[4]=d[2]c[5]?d[2]:c[5];e=Qc(0,b[1]-1,b[2]-1,1);cd(a,e,d);c[0]=d[0]c[1]?d[0]:c[1];c[2]=d[1]c[3]?d[1]:c[3];c[4]=d[2]c[5]?d[2]:c[5];e=Qc(b[0]-1,b[1]-1,b[2]-1,1);cd(a,e,d);c[0]=d[0]c[1]?d[0]:c[1];c[2]=d[1]c[3]?d[1]:c[3];c[4]=d[2]c[5]?d[2]:c[5];return c} +function Re(a,b){var c=Sc();if(!(a.length==b.length&&a[0]==b[0]&&a[1]==b[1]&&a[2]==b[2])){var e=Math.acos(a[2]),d=Mc(),f=a[0],g=a[1],h=a[2],l=b[0],j=b[1],k=b[2];d[0]=g*k-h*j;d[1]=h*l-f*k;d[2]=f*j-g*l;Oc(d,d);f=Math.cos(e/2);g=Math.sin(e/2)*d[0];h=Math.sin(e/2)*d[1];e=Math.sin(e/2)*d[2];T(c,0,f*f+g*g-h*h-e*e,2*(g*h-f*e),2*(g*e+f*h),0);T(c,1,2*(g*h+f*e),f*f+h*h-g*g-e*e,2*(h*e-f*g),0);T(c,2,2*(g*e-f*h),2*(h*e+f*g),f*f+e*e-h*h-g*g,0)}e=Rc();ad(c,e);return[c,e]} +function Se(a,b,c,e,d,f,g,h,l){var j=new Te;Oc(c,c);for(var k=[],n=[],s=0;6>s;s++)for(var r=Math.floor(s/2),y=(r+1)%3,z=(r+2)%3,F=(4+2*r)%6,G=0;2>G;G++){var H=(2+G+2*r)%6,B=-(c[r]*(d[s]-a[r])+c[y]*(d[H]-a[y]))/c[z]+a[z];if(B>=d[F]&&B<=d[F+1]||B<=d[F]&&B>=d[F+1]){var E=[];E[r]=d[s];E[y]=d[H];E[z]=B;k.push(E)}else E=[],E[r]=d[s],E[y]=d[H],E[z]=B,n.push(E)}a=Nc(0,0,1);a=Re(c,a);d=a[0];a=a[1];r=[];for(n=0;ns[1]&&(s[1]=r[n][0]),r[n][1]s[3]&&(s[3]=r[n][1]),r[n][2]s[5]&&(s[5]=r[n][2]);n=Qc(s[0]+(s[1]-s[0])/2,s[2]+(s[3]-s[2])/2,s[4]+(s[5]-s[4])/2,0);r=Pc();$c(a,n,r);y=Math.floor(s[0]);z=Math.ceil(s[1]);y==z&&z++;F=z-y;G=Math.floor(s[2]); +H=Math.ceil(s[3]);G==H&&H++;B=H-G;E=b[0];b=b[1];var n=Math.ceil(F/E),I=Math.ceil(B/b),N=new Uint8Array(4*n*I),Q=new gd;Q.Ye=n;Q.Xe=I;var I=Pc(),O=Qc(0,0,s[4],1),S=Rc();$c(g.Qh,a,S);for(var da=H-1E-7,J=z-1E-7,ba=0,la=0,U=0,V=G,V=G;V<=da;V+=b){U++;la=0;O[1]=V;for(n=y;n<=J;n+=E){la++;O[0]=n;cd(S,O,I);var Ga=4*ba,tb=Math.floor(I[2]),ub=Math.floor(I[1]),vb=Math.floor(I[0]);if(0<=vb&&vbh;h++){var l=Math.floor(h/2),j=(l+1)%3,k=(l+2)%3,n=(2+2*l)%6,s=(4+2*l)%6,r=(d[h]-b[l])*(1/c[l]);if(Infinity!=r&&-Infinity!=r){var y=b[j]+c[j]*r,r=b[k]+c[k]*r;y>=d[n]&&y<=d[n+1]&&r>=d[s]&&r<=d[s+1]?(n=[],n[l]=d[h],n[j]=y,n[k]=r,f.push(n)):(n=[],n[l]=d[h],n[j]=y,n[k]=r,g.push(n))}}d=[f,g];b=d[0];e.b[a].k=d;d=Fc(new R(b[0][0],b[0][1],b[0][2]),new R(b[1][0],b[1][1],b[1][2]));e.b[a].nl=d;f=Nc(0,0,1);g=Re(c,f)[0];h=Qc(e.ad[0],e.ad[1],e.ad[2],0); +f=Pc();cd(g,h,f);g=Pc();h=f[2];g[0]=c[0]*h;g[1]=c[1]*h;g[2]=c[2]*h;g[3]=c[3]*h;0.1>Math.abs(f[0])&&(f[0]=0.1);0.1>Math.abs(f[1])&&(f[1]=0.1);f[0]/=e.ae;f[1]/=e.ae;e.b[a].Ga=[Math.abs(f[0]),Math.abs(f[1])];e.b[a].Sc=f[2];e.b[a].B=g;d=Math.floor(Math.abs(d/f[2]));e.ud[a]=d+1;e.b[a].p=d+1;e.b[a].k[0][0][0]>e.b[a].k[0][1][0]?0g[0]&&(d=e.b[a].k[0][0],e.b[a].k[0][0]=e.b[a].k[0][1],e.b[a].k[0][1]= +d):e.b[a].k[0][0][1]>e.b[a].k[0][1][1]?0g[1]&&(d=e.b[a].k[0][0],e.b[a].k[0][0]=e.b[a].k[0][1],e.b[a].k[0][1]=d):e.b[a].k[0][0][2]>e.b[a].k[0][1][2]?0g[2]&&(d=e.b[a].k[0][0],e.b[a].k[0][0]=e.b[a].k[0][1],e.b[a].k[0][1]=d);e.b[a].Ue=-(c[0]*b[0][0]+c[1]*b[0][1]+c[2]*b[0][2])} +function Ve(a,b){var c;c=b.J;for(var e=b.ca,d=b.ia,f=b.ra,g=Array(e[2]),h=Array(e[2]),l=e[1]*e[0],j=0,k=0,n=0,s=0,r=0,s=0;sb;b++){var c=this.c[b],e=0,d=0;0==b?(e=this.Cb,d=this.Hc,this.Hc=this.Cb):1==b?(e=this.Db,d=this.Ic,this.Ic=this.Db):2==b&&(e=this.Eb,d=this.Jc,this.Jc=this.Eb);if(this.c[b].c[parseInt(e,10)]==t){var f=Mc();f[0]=this.b[b].k[0][0][0]+this.b[b].B[0]*parseInt(e,10);f[1]=this.b[b].k[0][0][1]+this.b[b].B[1]* +parseInt(e,10);f[2]=this.b[b].k[0][0][2]+this.b[b].B[2]*parseInt(e,10);if(this.L){var g=Se(f,this.b[b].Ga,this.b[b].i,this.b[b].w,this.ma,this.e.$,this.e,this.e.L,this.e.xa.Ka);this.e.c[b].c[parseInt(e,10)]=g;this.e.c[b].q(q)}f=Se(f,this.b[b].Ga,this.b[b].i,this.b[b].w,this.ma,this.$,this,q,t);this.L&&(f.e=f.G,f.e=this.e.c[b].c[parseInt(e,10)].G);c.c[parseInt(e,10)]=f;this.c[b].q(q)}d=c.c[parseInt(d,10)];this.Ra||(d.visible=u);c=c.c[parseInt(e,10)];c.visible=q;c.za=1;this.Ra&&(c.c[0].O=u,b!=this.X&& +(c.visible=u,c.za=0))}this.Ra&&-1!=this.X&&We(this,this.X)}a&&P.u.q.call(this)};P.prototype.__defineGetter__("dimensions",v("ca"));P.prototype.__defineSetter__("dimensions",ca("ca"));P.prototype.__defineGetter__("spacing",v("qb"));P.prototype.__defineSetter__("spacing",ca("qb"));P.prototype.__defineGetter__("bbox",v("ma"));P.prototype.__defineGetter__("range",v("ud"));P.prototype.__defineGetter__("dimensionsRAS",v("dg"));P.prototype.__defineGetter__("volumeRendering",v("Ra")); +P.prototype.__defineSetter__("volumeRendering",function(a){this.Ra=a;this.q(u)});P.prototype.__defineGetter__("visible",v("O"));P.prototype.__defineSetter__("visible",function(a){if(a)this.O=a,this.q(u);else{for(var b=this.c,c=b.length,e=0,e=0;e=a.length))&&m(Error("Invalid volumeRederingCache."));this.de=a});P.prototype.__defineGetter__("image",v("jb"));P.prototype.__defineGetter__("labelmap",function(){this.e||(this.e=new Xe(this));return this.e});P.prototype.__defineGetter__("indexX",v("Cb"));P.prototype.__defineSetter__("indexX",function(a){x(a)&&(0<=a&&a>8)+c(a&255)+(c((e&65280)>>8)+c(e&255)),2);4294967295==e&&(e=0);b+=e/2;break;default:b+=e/2}return b} +bf.prototype.vc=function(a,b){this.J=a;if("undefined"==typeof b.ta||b.ta==t)b.ta=[];for(var c={pixel_spacing:[0.1,0.1,Infinity],image_orientation_patient:[1,0,0,0,1,0],image_position_patient:[0,0,0],transfer_syntax_uid:"no_transfer_syntax_uid"},e=Z(this,"ushort",this.J.byteLength),d=66,f=t,g=t,h=t,l=t;d> +8,j+=String.fromCharCode(g),j+=String.fromCharCode(h);c.transfer_syntax_uid=j.replace(/\0/g,"");break;default:d=cf(e,d,h,l)}break;case 40:switch(g){case 16:c.rows=e[d];d+=l/2;break;case 17:c.columns=e[d];d+=l/2;break;case 256:c.gf=e[d];d+=l/2;break;case 257:c.bits_stored=e[d];d+=l/2;break;case 2:c.number_of_images=e[d];d+=l/2;break;case 48:j="";for(f=0;f>8,j+=String.fromCharCode(g),j+=String.fromCharCode(h);j=j.split("\\");c.pixel_spacing=[parseFloat(j[0]),parseFloat(j[1]), +Infinity];break;default:d=cf(e,d,h,l)}break;case 32:switch(g){case 14:c.series_instance_uid="";for(f=0;f>8,c.series_instance_uid+=String.fromCharCode(g),c.series_instance_uid+=String.fromCharCode(h);break;case 19:j="";for(f=0;f>8,j+=String.fromCharCode(g),j+=String.fromCharCode(h);c.instance_number=parseInt(j,10);break;case 50:j="";for(f=0;f>8,j+=String.fromCharCode(g),j+=String.fromCharCode(h); +j=j.split("\\");c.image_position_patient=[parseFloat(j[0]),parseFloat(j[1]),parseFloat(j[2])];break;case 55:j="";for(f=0;f>8,j+=String.fromCharCode(g),j+=String.fromCharCode(h);j=j.split("\\");c.image_orientation_patient=[parseFloat(j[0]),parseFloat(j[1]),parseFloat(j[2]),parseFloat(j[3]),parseFloat(j[4]),parseFloat(j[5])];break;default:d=cf(e,d,h,l)}break;case 65534:switch(g){default:l=0,d+=l/2}break;case 8:switch(g){case 24:c.sop_instance_uid="";for(f=0;f>8,c.sop_instance_uid+=String.fromCharCode(g),c.sop_instance_uid+=String.fromCharCode(h);break;default:d=cf(e,d,h,l)}break;case 16:switch(g){case 8720:for(f=0;f=k);n++){var s=parseInt(j[n],10),r=c.get(s);e.add(r[0],r[1],r[2]);var y=s,z=r;"LINES"==this.Pa?(y=parseInt(j[n+1],10),z=c.get(y),e.add(z[0],z[1],z[2])):"TRIANGLE_STRIPS"==this.Pa&&(0==n||n==k-1)&&e.add(r[0],r[1],r[2]);sc&&10!=g);Z(this,"uchar");d=Z(this,"uint");c=Z(this,"uint");var h=Z(this,"float",3*d);g=Z(this,"uint",3*c);var l=new Uint32Array(d),j=new Float32Array(9*c);b.h=e=new W(9*c);b.n=d=new W(9*c);var k;for(k=0;k>>8^d[(b^a[c])&255];for(f=e>>3;f--;c+=8)b=b>>>8^d[(b^a[c])&255],b=b>>>8^d[(b^a[c+1])&255],b=b>>>8^d[(b^a[c+2])&255],b=b>>>8^d[(b^a[c+3])&255],b=b>>>8^d[(b^a[c+4])&255],b=b>>>8^d[(b^a[c+5])&255],b=b>>>8^d[(b^a[c+6])&255],b=b>>>8^d[(b^a[c+7])&255];return(b^4294967295)>>>0}}; +gf.Mh=new Uint32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101, +3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271, +366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376, +3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954, +1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836, +1088359270,936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function hf(a){var b=a.length,c=0,e=Number.POSITIVE_INFINITY,d,f,g,h,l,j,k,n,s;for(n=0;nc&&(c=a[n]),a[n]>=1;for(s=j;s>>=1;switch(a){case 0:var a=this.input,b=this.M,c=this.Ua,e=this.la,d=p,f=p,g=p,h=c.length,d=p;this.rb=this.Bd=0;d=a[b++];d===p&&m(Error("invalid uncompressed block header: LEN (first byte)"));f=d;d=a[b++];d===p&&m(Error("invalid uncompressed block header: LEN (second byte)"));f|=d<<8;d=a[b++];d===p&&m(Error("invalid uncompressed block header: NLEN (first byte)"));g=d;d=a[b++];d===p&&m(Error("invalid uncompressed block header: NLEN (second byte)"));g|= +d<<8;f===~g&&m(Error("invalid uncompressed block header: length verify"));b+f>a.length&&m(Error("input buffer is broken"));switch(this.kf){case lf:for(;e+f>c.length;)d=h-e,f-=d,c.set(a.subarray(b,b+d),e),e+=d,b+=d,this.la=e,c=this.tc(),e=this.la;break;case kf:for(;e+f>c.length;)c=this.tc({Jg:2});break;default:m(Error("invalid inflate mode"))}c.set(a.subarray(b,b+f),e);e+=f;this.M=b+=f;this.la=e;this.Ua=c;break;case 1:this.rf(nf,of);break;case 2:pf(this);break;default:m(Error("unknown BTYPE: "+a))}}return this.Dg()}; +var qf=new Uint16Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),rf=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258]),sf=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0]),tf=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577]),uf=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),vf=new Uint8Array(288), +wf,xf;wf=0;for(xf=vf.length;wf=wf?8:255>=wf?9:279>=wf?7:8;var nf=hf(vf),yf=new Uint8Array(30),zf,Af;zf=0;for(Af=yf.length;zf>>b;a.rb=e-b;a.M=f;return g} +function Bf(a,b){for(var c=a.Bd,e=a.rb,d=a.input,f=a.M,g=b[0],h=b[1],l;e>>16;a.Bd=c>>g;a.rb=e-g;a.M=f;return d&65535} +function pf(a){function b(a,b,c){var d,e,f;for(f=0;ff)e>=d&&(this.la=e,c=this.tc(),e=this.la),c[e++]=f;else{f-=257;h=rf[f];0=d&&(this.la=e,c=this.tc(),e=this.la);for(;h--;)c[e]=c[e++-g]}for(;8<=this.rb;)this.rb-=8,this.M--;this.la=e}; +w.ri=function(a,b){var c=this.Ua,e=this.la;this.Gg=a;for(var d=c.length,f,g,h;256!==(f=Bf(this,a));)if(256>f)e>=d&&(c=this.tc(),d=c.length),c[e++]=f;else{f-=257;h=rf[f];0d&&(c=this.tc(),d=c.length);for(;h--;)c[e]=c[e++-g]}for(;8<=this.rb;)this.rb-=8,this.M--;this.la=e}; +w.tc=function(){var a=new Uint8Array(this.la-32768),b=this.la-32768,c=this.Ua;a.set(c.subarray(32768,a.length));this.hf.push(a);this.Vf+=a.length;c.set(c.subarray(b,b+32768));this.la=32768;return c};w.xi=function(a){var b=this.input.length/this.M+1|0,c=this.input,e=this.Ua;a&&("number"===typeof a.Jg&&(b=a.Jg),"number"===typeof a.fi&&(b+=a.fi));2>b?(a=(c.length-this.M)/this.Gg[2],a=258*(a/2)|0,a=aCf;++Cf)for(var Df=Cf,Ef=7,Df=Df>>>1;Df;Df>>>=1)--Ef;var Ff=[],Gf;for(Gf=0;288>Gf;Gf++)switch(q){case 143>=Gf:Ff.push([Gf+48,8]);break;case 255>=Gf:Ff.push([Gf-144+400,9]);break;case 279>=Gf:Ff.push([Gf-256+0,7]);break;case 287>=Gf:Ff.push([Gf-280+192,8]);break;default:m("invalid literal: "+Gf)} +function Hf(){var a=If;switch(q){case 3===a:return[257,a-3,0];case 4===a:return[258,a-4,0];case 5===a:return[259,a-5,0];case 6===a:return[260,a-6,0];case 7===a:return[261,a-7,0];case 8===a:return[262,a-8,0];case 9===a:return[263,a-9,0];case 10===a:return[264,a-10,0];case 12>=a:return[265,a-11,1];case 14>=a:return[266,a-13,1];case 16>=a:return[267,a-15,1];case 18>=a:return[268,a-17,1];case 22>=a:return[269,a-19,2];case 26>=a:return[270,a-23,2];case 30>=a:return[271,a-27,2];case 34>=a:return[272,a- +31,2];case 42>=a:return[273,a-35,3];case 50>=a:return[274,a-43,3];case 58>=a:return[275,a-51,3];case 66>=a:return[276,a-59,3];case 82>=a:return[277,a-67,4];case 98>=a:return[278,a-83,4];case 114>=a:return[279,a-99,4];case 130>=a:return[280,a-115,4];case 162>=a:return[281,a-131,5];case 194>=a:return[282,a-163,5];case 226>=a:return[283,a-195,5];case 257>=a:return[284,a-227,5];case 258===a:return[285,a-258,0];default:m("invalid length: "+a)}}var Jf=[],If,Kf; +for(If=3;258>=If;If++)Kf=Hf(),Jf[If]=Kf[2]<<24|Kf[1]<<16|Kf[0];new Uint32Array(Jf);function Lf(){};function Mf(a){this.input=a;this.M=0;this.member=[]} +Mf.prototype.Yb=function(){for(var a=this.input.length;this.M>>0;gf.lf(d)!==c&&m(Error("invalid CRC-32 checksum: 0x"+gf.lf(d).toString(16)+ +" / 0x"+c.toString(16)));b.Fl=c=(h[e++]|h[e++]<<8|h[e++]<<16|h[e++]<<24)>>>0;(d.length&4294967295)!==c&&m(Error("invalid input size: "+(d.length&4294967295)+" / "+c));this.member.push(b);this.M=e}a=this.member;b=d=e=0;for(h=a.length;bj;++j)l[j]=e.fb[3][j]-(c[j+0]*f[0]*g+c[j+4]*f[1]*h+c[j+8]*f[2]*d);Uc(c,l[0],l[1],l[2],1)}e.eb=c;e.gb=Rc();ad(e.eb,e.gb);g=Qc(0,0,0,1);f=Pc();cd(c,g,f);h=Qc(1,1,1,1);g=Pc();cd(c,h,g);c=Qe(c,b.ca);e.Bc=[g[0]-f[0],g[1]-f[1],g[2]-f[2]];e.zc=[c[1]-c[0]+1,c[3]-c[2]+1,c[5]-c[4]+1];e.Ac=[c[0],c[2],c[4]];b.Gb(e);D.Da(this.f+".parse");b.jb=Ve(this,b);e=new ld;e.D=b;e.v=a;this.dispatchEvent(e)}; +Nf.prototype.vc=function(a){this.J=a;a={version:0,Ph:0,Nh:0,Ei:0,Oh:0,Bf:0,Cf:0,Df:0,nj:0,type:0,vi:0,vh:0,Ck:t,fb:t,Gh:t,data:t,min:Infinity,max:-Infinity};a.version=Z(this,"uint");a.Bf=Z(this,"uint");a.Cf=Z(this,"uint");a.Df=Z(this,"uint");a.nj=Z(this,"uint");a.type=Z(this,"uint");a.vi=Z(this,"uint");a.vh=Z(this,"ushort");if(0d&&m(Error("Could not find scalar for vertex.")),l=g[l],f[h++]=l,f[h++]=l,f[h++]=l;b.F.I= +g;b.F.dd=f;b.F.j=q;D.Da(this.f+".parse");e=new ld;e.D=b;e.v=a;this.dispatchEvent(e)};A("X.parserLBL",Of);A("X.parserLBL.prototype.parse",Of.prototype.parse);function Pf(){Ne.call(this);this.f="parserCRV";this.Mc=u}C(Pf,Ne); +Pf.prototype.parse=function(a,b,c){D.Ja(this.f+".parse");var e=b.Nc;0==e.length&&m(Error("No _pointIndices defined on the X.object."));this.J=c;this.C=3;var d=Z(this,"uint");Z(this,"uint");Z(this,"uint");var f=0,g=0,h=0,l=0,j=0,k=0,n=0,s=0,r=0,y=0,z=0;c=Array(2);var F=Array(2),G=Z(this,"float",d),H;for(H=0;H>>0,c=b;if("string"===typeof c){var c=c.split(""),e,d;e=0;for(d=c.length;e>>0}e=1;d=0;for(var f=c.length,g,h=0;0>>0&&m(Error("invalid adler-32 checksum"))}return b};function Rf(){Ne.call(this);this.f="parserRAW"}C(Rf,Ne); +Rf.prototype.parse=function(a,b,c,e){D.Ja(this.f+".parse");e&&(c=(new Qf(new Uint8Array(c))).Yb(),c=c.buffer);e={};e.data=new Uint8Array(c);var d=Oe(e.data);c=d[0];d=d[1];e.min=b.ra=b.fa=c;e.max=b.ia=b.ea=d;-Infinity==b.U&&(b.U=c);Infinity==b.W&&(b.W=d);d=Sc();e.eb=d;e.gb=Sc();var f=Qc(0,0,0,1);c=Pc();cd(d,f,c);var g=Qc(1,1,1,1),f=Pc();cd(d,g,f);d=Qe(d,b.ca);e.Bc=[f[0]-c[0],f[1]-c[1],f[2]-c[2]];e.zc=[d[1]-d[0]+1,d[3]-d[2]+1,d[5]-d[4]+1];e.Ac=[d[0],d[2],d[4]];b.Gb(e);D.Da(this.f+".parse");b.jb=Ve(this, +b);e=new ld;e.D=b;e.v=a;this.dispatchEvent(e)};A("X.parserRAW",Rf);A("X.parserRAW.prototype.parse",Rf.prototype.parse);function Sf(){Ne.call(this);this.f="parserIMAGE"}C(Sf,Ne);Sf.prototype.parse=function(a,b,c,e){c instanceof ArrayBuffer||m(Error());for(var d=new Uint8Array(c),f=d.length,g=Array(f);f--;)g[f]=String.fromCharCode(d[f]);d=window.btoa(g.join(""));f=new Image;$b(f,"load",this.Uj.bind(this,f,a,b,c,e));f.src="data:image/"+e+";base64,"+d};Sf.prototype.Uj=function(a,b,c){b.jb=a;b.Wb=t;a=new ld;a.D=c;a.v=b;this.dispatchEvent(a)};A("X.parserIMAGE",Sf);A("X.parserIMAGE.prototype.parse",Sf.prototype.parse);function Tf(){Ne.call(this);this.f="parserLUT"}C(Tf,Ne); +Tf.prototype.parse=function(a,b,c){D.Ja(this.f+".parse");this.J=c;c=Z(this,"uchar",c.byteLength);var e=c.length,d=0,f;for(f=0;fa.qc-(a.he-a.qc)?(a.min=a.ff,a.max=a.qc+(a.qc-a.ff)): +(a.min=a.qc-(a.he-a.qc),a.max=a.he);return a};A("X.parserMRC",Uf);A("X.parserMRC.prototype.parse",Uf.prototype.parse);function Vf(){Ne.call(this);this.f="parserNRRD"}C(Vf,Ne); +Vf.prototype.parse=function(a,b,c){D.Ja(this.f+".parse");this.J=c;c=Z(this,"uchar",c.byteLength);var e=c.length,d=t,f=0,g;for(g=1;g=k;k++)e.push(!isNaN(this.Tf[k])?this.ha[k].scale(this.Tf[k]):p)}f=c.subarray(f);if("gzip"==this.encoding||"gz"==this.encoding)f=(new Mf(new Uint8Array(f))).Yb();f=f.buffer;c={data:t,min:Infinity,max:-Infinity};c.data=new this.Mb(f);k=Oe(c.data);f=c.min=k[0];k=c.max=k[1];b.ra=b.fa=f;b.ia=b.ea=k;b.ca=[this.Rf[0],this.Rf[1],this.Rf[2]];e=(new R(this.ha[0][0],this.ha[0][1], +this.ha[0][2])).Ib();d=(new R(this.ha[1][0],this.ha[1][1],this.ha[1][2])).Ib();g=(new R(this.ha[2][0],this.ha[2][1],this.ha[2][2])).Ib();b.qb=[e,d,g];-Infinity==b.U&&(b.U=f);Infinity==b.W&&(b.W=k);e=k=1;"left-posterior-superior"==this.zh&&(e=k=-1);f=Sc();"false"==b.reslicing||b.reslicing==u?(T(f,0,k,0,0,0),T(f,1,0,e,0,0),T(f,2,0,0,1,0)):(T(f,0,k*this.ha[0][0],k*this.ha[1][0],k*this.ha[2][0],k*this.Sf[0]),T(f,1,e*this.ha[0][1],e*this.ha[1][1],e*this.ha[2][1],e*this.Sf[1]),T(f,2,1*this.ha[0][2],1*this.ha[1][2], +1*this.ha[2][2],1*this.Sf[2]));T(f,3,0,0,0,1);c.eb=f;c.gb=Rc();ad(c.eb,c.gb);e=Qc(0,0,0,1);k=Pc();cd(f,e,k);d=Qc(1,1,1,1);e=Pc();cd(f,d,e);f=Qe(f,b.ca);c.Bc=[e[0]-k[0],e[1]-k[1],e[2]-k[2]];c.zc=[f[1]-f[0]+1,f[3]-f[2]+1,f[5]-f[4]+1];c.Ac=[f[0],f[2],f[4]];b.Gb(c);D.Da(this.f+".parse");b.jb=Ve(this,b);c=new ld;c.D=b;c.v=a;this.dispatchEvent(c)}; +Vf.prototype.Ai={type:function(a){switch(a){case "uchar":case "unsigned char":case "uint8":case "uint8_t":this.Mb=Uint8Array;break;case "signed char":case "int8":case "int8_t":this.Mb=Int8Array;break;case "short":case "short int":case "signed short":case "signed short int":case "int16":case "int16_t":this.Mb=Int16Array;break;case "ushort":case "unsigned short":case "unsigned short int":case "uint16":case "uint16_t":this.Mb=Uint16Array;break;case "int":case "signed int":case "int32":case "int32_t":this.Mb= +Int32Array;break;case "uint":case "unsigned int":case "uint32":case "uint32_t":this.Mb=Uint32Array;break;case "float":this.Mb=Float32Array;break;case "double":this.Mb=Float64Array;break;default:m(Error("Unsupported NRRD data type: "+a))}return this.type=a},endian:function(a){return this.Al=a},encoding:function(a){return this.encoding=a},dimension:function(a){return this.Zb=parseInt(a,10)},sizes:function(a){var b,c,e,d;e=a.split(/\s+/);d=[];b=0;for(c=e.length;bc.sa[0]&&(h=-h);T(d,0,f,0,0,0);T(d,1,0,g,0,0);T(d,2,0,0,h,0)}else if(0l?(l=1/Math.sqrt(j*j+k*k+n*n),j*=l,k*=l,n*=l,l=0):l=Math.sqrt(l);0c.sa[0]&&(h=-h);T(d,0,(l*l+j*j-k*k-n*n)*f,2*(j*k-l*n)*g,2*(j*n+l*k)*h,s);T(d,1,2*(j*k+l*n)*f,(l*l+k*k-j*j-n*n)*g,2*(k*n-l*j)*h,r);T(d,2,2*(j*n-l*k)*f,2*(k*n+l*j)*g,(l*l+n*n-k*k-j*j)*h,y)}else 0z)z=I;if(!F||SG)G=da;if(!e||Jd)d=ba;n.push(N);s.push(Q)}g=(y+z)/2;h=(F+G)/2;G=(e+d)/2;F=new Float32Array(f);b.h=e=new W(f);b.n=d=new W(f);b.pa=f=new W(f);for(j=y=0;jj;j++)if(0!=c[j]){l=q;break}l==u&&(c[0]=c[5]=c[10]=c[15]=1);D.Da(this.f+".parse");D.g.Wf(c,b.ja.Q); +c=new ld;c.D=b;c.v=a;this.dispatchEvent(c)};A("X.parserTRK",Zf);A("X.parserTRK.prototype.parse",Zf.prototype.parse);function $f(){Ne.call(this);this.f="parserOBJ"}C($f,Ne); +$f.prototype.parse=function(a,b,c){D.Ja(this.f+".parse");this.J=c;c=c.byteLength;var e=Z(this,"uchar",c),d=[];b.h=new W(c);b.n=new W(c);var f=b.h,g=b.n,h=0,l;for(l=0;la.Xc;b.ib=q;this.dispatchEvent(b)};function lg(a){M.call(this);this.f="array";this.I=[];this.cg=a}C(lg,M);function mg(a,b,c){for(var e=0;4>e;e++)if(a[e+0]!==b[e+c])return u;return q}lg.prototype.add=function(a){this.I.push(a);return q};lg.prototype.remove=function(a){a=this.I.indexOf(a);-1e)){e=b+Math.floor(e/2);ng(a,b,e);for(ng(a,e,c);bf.cg(f.I[g+1],d);){var l=f,j=g+1,k=l.I[g];l.I[g]=l.I[j];l.I[j]=k;++g}f.I[g]=d}}}lg.prototype.sort=function(){ng(this,0,this.I.length)};function og(a,b){eg.call(this,a,b);this.f="camera2D"}C(og,eg);og.prototype.rotate=function(a){a=og.u.rotate.call(this,a);var b=new Gd;0a.x&&b.df++;0a.y&&b.Re--;this.dispatchEvent(b)};og.prototype.$f=function(a){var b=20;a!=t&&!a&&(b=0.02);this.o[14]+=b};og.prototype.ag=function(a){var b=20;a!=t&&!a&&(b=0.02);this.o[14]-=b}; +og.prototype.Lf=function(a){ja(a)&&2==a.length?a=new D.m(a[0],a[1],0):a instanceof D.m||m(Error("Invalid distance vector for pan operation."));this.o[12]-=a.x/this.o[14];this.o[13]+=a.y/this.o[14]};function pg(a,b){eg.call(this,a,b);this.f="camera3D";this.eg=45;this.We=D.g.zf(D.g.Ed(),this.eg,a/b,1,1E4)}C(pg,eg);pg.prototype.rotate=function(a){a=pg.u.rotate.call(this,a);var b=-a.x/5*Math.PI/180;a=-a.y/5*Math.PI/180;var c=new D.m(this.o[1],this.o[5],this.o[9]),e=new D.m(this.o[0],this.o[4],this.o[8]);c.normalize();e.normalize();D.g.rotate(this.o,b,c.x,c.y,c.d);D.g.rotate(this.o,a,e.x,e.y,e.d)};pg.prototype.ue=function(a,b){var c=pg.u.ue.call(this,a,b);D.g.Xg(c,a,b,this.V);return c}; +function qg(a,b,c,e){var d=new Float32Array(4),f=new Float32Array(4),g=new Float32Array(16),h=new Float32Array(16);new Float32Array(16);D.g.multiply(a.We,a.o,h);D.g.Y(h,g);d[0]=b;d[1]=c;d[2]=2*e-1;d[3]=1;D.g.ah(g,d,f);f[3]=1/f[3];f[0]*=f[3];f[1]*=f[3];f[2]*=f[3];return f}A("X.camera3D",pg);function rg(a){Pb.call(this);this.Hb=a;this.S=[]}C(rg,Pb);var sg=[];function tg(a,b,c,e,d){ja(c)||(sg[0]=c,c=sg);for(var f=0;fthis.Af?this.Af-this.Hg:asb&&L(this.t(),"resize",this.Ge,u,this);this.Ge();var a=this.t();a.setAttribute("role","progressbar");a.setAttribute("aria-live","polite")};w.le=function(){zg.u.le.call(this);K&&7>sb&&ac(this.t(),"resize",this.Ge,u,this)};w.qe=function(){return this.Md.qe()};w.Od=function(a){this.Md.Od(a);this.t()&&Cg(this)};function Cg(a){var b=a.qe();a.t().setAttribute("aria-valuenow",b)}w.pe=function(){return this.Md.pe()};w.oe=function(){return this.Md.oe()};w.mh="horizontal"; +w.Ki=function(){this.Ge();this.dispatchEvent("change")};w.Ge=function(){if(this.Ab){var a=this.pe(),b=this.oe(),a=(this.qe()-a)/(b-a),b=Math.round(100*a);"vertical"==this.mh?K&&7>sb?(this.Ab.style.top=0,this.Ab.style.height="100%",b=this.Ab.offsetHeight,a=Math.round(a*b),this.Ab.style.top=b-a+"px",this.Ab.style.height=a+"px"):(this.Ab.style.top=100-b+"%",this.Ab.style.height=b+"%"):this.Ab.style.width=b+"%"}};function Dg(a,b){a==t&&m(Error("No valid parent element."));b==t&&m(Error("Invalid initial value."));zg.call(this);this.f="progressbar";this.bb=a;this.Ve="";this.Td=this.Fb=t;this.fc=[];var c;c=".progress-bar-horizontal {\n position: relative;\n border: 1px solid #949dad;\n";c+=" background: white;\n";c+=" padding: 1px;\n";c+=" overflow: hidden;\n";c+=" margin: 2px;\n";c+=" width: 100px;\n";c+=" height: 5px;\n";c+="}";var e;e=".progress-bar-thumb {\n position: relative;\n background: #F62217;\n"; +e+=" overflow: hidden;\n";e+=" width: 0%;\n";e+=" height: 100%;\n";e+="}";var d;d=".progress-bar-thumb-done {\n background: #57E964;\n}";this.fc=[c,e,d];this.Od(b);this.vf()}C(Dg,zg); +Dg.prototype.vf=function(){var a=ne(this.bb,"position");if("static"==a||""==a)this.Ve=this.bb.style.position,this.bb.style.position="relative";var a=document.getElementsByTagName("head")[0],b=de("style");b.type="text/css";b.media="screen";var c=document.createTextNode(String(this.fc[0])),e=document.createTextNode(String(this.fc[1])),d=document.createTextNode(String(this.fc[2]));a.appendChild(b);b.appendChild(c);b.appendChild(e);b.appendChild(d);this.Fb=b;this.cc(this.bb);a=this.t();a.style.position= +"absolute";a.style.top=(this.bb.clientHeight-5)/2+"px";a.style.left=(this.bb.clientWidth-100)/2+"px";a.classList.add("xtk-progress-bar")};function Eg(a){var b=a.t().style.top,c=a.t().style.left;fe(a.t());var e=new Dg(a.bb,100),d=e.t();d.style.position="absolute";d.style.top=b;d.style.left=c;d.classList.add("xtk-progress-bar");(d.firstElementChild!=p?d.firstElementChild:ge(d.firstChild)).classList.add("progress-bar-thumb-done");a.Td=e} +Dg.prototype.Fd=function(){this.Fb&&fe(this.Fb);this.t()&&fe(this.t());this.Td&&fe(this.Td.t());this.Td=this.Fb=t;this.Ve&&(this.bb.style.position=this.Ve)};function Fg(a,b,c){oa(a)?c&&(a=va(a,c)):a&&"function"==typeof a.handleEvent?a=va(a.handleEvent,a):m(Error("Invalid listener argument"));return 2147483647..) is required."));var b=a;na(b)&&(b=be(a));pa(b)&&1==b.nodeType||m(Error("Could not find the given container."));this.v=b});w=Gg.prototype;w.Nd=function(){this.N.reset()}; +w.Ca=function(a){var b=de("canvas");this.v.appendChild(b);this.K=this.v.clientWidth;this.A=this.v.clientHeight;b.width=this.K;b.height=this.A;try{var c=b.getContext(a);c||m(Error())}catch(e){var d="Sorry, "+a+' context is not supported on this machine! See http://crash.goXTK.com for requirements..';this.v.innerHTML='

Oooops..

'+d+"

"; +m(Error(d))}this.aa=new ag;L(this.aa,Ad,this.Dj.bind(this));this.na=b;this.a=c;b=new Ke(this.na);"2d"==a&&(b=new Me(this.na));b.Ca();L(b,wd,this.Nd.bind(this));L(b,Bd,this.Jf.bind(this));L(b,vd,this.Kf.bind(this));this.T=b;b=new pg(this.K,this.A);"2d"==a&&(b=new og(this.K,this.A));b.observe(this.T);this.N=b;L(window,"resize",this.ve,u,this)};w.add=function(a){(a instanceof kg||a instanceof ig||a instanceof gg)&&a.q();this.Ha.push(a);this.ub(a)}; +w.remove=function(a){(!this.na||!this.a)&&m(Error("The renderer was not initialized properly."));if(a!=t){dc(a);var b=this.Ha.length,c;for(c=0;c=d.right))f&=-2;if(132==(f&132)&&(h.y=d.bottom))f&=-5;h.xd.right&&f&16)&&(g.width=Math.max(g.width-(h.x+g.width-d.right),0),e|=4);h.x+g.width>d.right&&f&1&&(h.x=Math.max(d.right-g.width, +d.left),e|=1);f&2&&(e|=(h.xd.right?32:0));h.y=d.top&&(h.y+g.height>d.bottom&&f&32)&&(g.height=Math.max(g.height-(h.y+g.height-d.bottom),0),e|=8);h.y+g.height>d.bottom&&f&4&&(h.y=Math.max(d.bottom-g.height,d.top),e|=2);f&8&&(e|=(h.yd.bottom?128:0));h=e}else h=256;if(h&496)return h}f=a;d=jb&&(ab||qb)&&Cb("1.9");f instanceof +Xd?(a=f.x,f=f.y):(a=f,f=p);b.style.left=xe(a,d);b.style.top=xe(f,d);if(!(c==g||(!c||!g?0:c.width==g.width&&c.height==g.height)))a=ie(Zd(ae(b))),K&&(!a||!Cb("8"))?(c=b.style,a?(K?(a=Ce(b,"paddingLeft"),d=Ce(b,"paddingRight"),f=Ce(b,"paddingTop"),e=Ce(b,"paddingBottom"),a=new ke(f,d,e,a)):(a=ne(b,"paddingLeft"),d=ne(b,"paddingRight"),f=ne(b,"paddingTop"),e=ne(b,"paddingBottom"),a=new ke(parseFloat(f),parseFloat(d),parseFloat(e),parseFloat(a))),K?(d=Ee(b,"borderLeft"),f=Ee(b,"borderRight"),e=Ee(b,"borderTop"), +b=Ee(b,"borderBottom"),b=new ke(e,f,b,d)):(d=ne(b,"borderLeftWidth"),f=ne(b,"borderRightWidth"),e=ne(b,"borderTopWidth"),b=ne(b,"borderBottomWidth"),b=new ke(parseFloat(e),parseFloat(f),parseFloat(b),parseFloat(d))),c.pixelWidth=g.width-b.left-a.left-a.right-b.right,c.pixelHeight=g.height-b.top-a.top-a.bottom-b.bottom):(c.pixelWidth=g.width,c.pixelHeight=g.height)):(b=b.style,jb?b.MozBoxSizing="border-box":lb?b.WebkitBoxSizing="border-box":b.boxSizing="border-box",b.width=Math.max(g.width,0)+"px", +b.height=Math.max(g.height,0)+"px");return h};function Jg(){}Jg.prototype.tb=aa();function Kg(a,b){this.of=a instanceof Xd?a:new Xd(a,b)}C(Kg,Jg);Kg.prototype.tb=function(a,b,c,e){Hg(pe(a),0,a,b,this.of,c,t,e)};function Lg(a,b,c){this.element=a;this.Fg=b;this.Tj=c}C(Lg,Jg);Lg.prototype.tb=function(a,b,c){Hg(this.element,this.Fg,a,b,p,c,this.Tj)};function Mg(a,b){jc.call(this);this.Hb=new rg(this);this.Pf(a||t);b&&(this.$c=b)}C(Mg,jc);w=Mg.prototype;w.H=t;w.gi=q;w.zg=t;w.Ma=u;w.ek=u;w.xf=-1;w.Wg=-1;w.Pi=u;w.wi=q;w.$c="toggle_display";w.t=v("H");w.Pf=function(a){this.Ma&&m(Error("Can not change this state of the popup while showing."));this.H=a}; +function Ng(a,b){a.Fe&&a.Fe.stop();a.re&&a.re.stop();if(b){if(!a.Ma&&a.Ef()){a.H||m(Error("Caller must call setElement before trying to show the popup"));a.tb();var c=ae(a.H);a.Pi&&tg(a.Hb,c,"keydown",a.rj,q);if(a.gi)if(tg(a.Hb,c,"mousedown",a.hh,q),K){var e;try{e=c.activeElement}catch(d){}for(;e&&"IFRAME"==e.nodeName;){try{var f=e.contentDocument||e.contentWindow.document}catch(g){break}c=f;e=c.activeElement}tg(a.Hb,c,"mousedown",a.hh,q);tg(a.Hb,c,"deactivate",a.gh)}else tg(a.Hb,c,"blur",a.gh);"toggle_display"== +a.$c?(a.H.style.visibility="visible",Ae(a.H,q)):"move_offscreen"==a.$c&&a.tb();a.Ma=q;a.Fe?($b(a.Fe,"end",a.kh,u,a),a.Fe.play()):a.kh()}}else Og(a)}w.tb=ga;function Og(a,b){if(!a.Ma||!a.dispatchEvent({type:"beforehide",target:b}))return u;a.Hb&&a.Hb.xe();a.Ma=u;a.Wg=xa();a.re?($b(a.re,"end",wa(a.Eg,b),u,a),a.re.play()):a.Eg(b);return q}w.Eg=function(a){"toggle_display"==this.$c?this.ek?Fg(this.Og,0,this):this.Og():"move_offscreen"==this.$c&&(this.H.style.top="-10000px");this.If(a)}; +w.Og=function(){this.H.style.visibility="hidden";Ae(this.H,u)};w.Ef=function(){return this.dispatchEvent("beforeshow")};w.kh=function(){this.xf=xa();this.Wg=-1;this.dispatchEvent("show")};w.If=function(a){this.dispatchEvent({type:"hide",target:a})};w.hh=function(a){a=a.target;!he(this.H,a)&&((!this.zg||he(this.zg,a))&&!(150>xa()-this.xf))&&Og(this,a)};w.rj=function(a){27==a.keyCode&&Og(this,a.target)&&(a.preventDefault(),a.stopPropagation())}; +w.gh=function(a){if(this.wi){var b=ae(this.H);if(K||ib){if(a=b.activeElement,!a||he(this.H,a)||"BODY"==a.tagName)return}else if(a.target!=b)return;150>xa()-this.xf||Og(this)}};function Pg(a,b){this.Xj=4;this.we=b||p;Mg.call(this,a)}C(Pg,Mg);Pg.prototype.tb=function(){if(this.we){var a=!this.Ma&&"move_offscreen"!=this.$c,b=this.t();a&&(b.style.visibility="hidden",Ae(b,q));this.we.tb(b,this.Xj,this.Kl);a&&Ae(b,u)}};function Qg(a){this.ga=new zc;a&&this.ef(a)}function Rg(a){var b=typeof a;return"object"==b&&a||"function"==b?"o"+qa(a):b.substr(0,1)+a}w=Qg.prototype;w.tf=function(){return this.ga.tf()};w.add=function(a){this.ga.set(Rg(a),a)};w.ef=function(a){a=yc(a);for(var b=a.length,c=0;c 0.0) {\n";a+=" if (labelmapColor.a != -255.0) {\n";a+=" if (all(equal(floor(texture2 * vec4(255)), labelmapColor))) {\n";a+=" if (labelmapOpacity < 1.0) {\n";a+=" textureSum = mix(texture2, textureSum, 1.0 - labelmapOpacity);\n";a+=" } else {\n";a+=" textureSum = texture2;\n";a+=" }\n";a+=" }\n";a+=" } else {\n";a+=" if (labelmapOpacity < 1.0) {\n";a+=" textureSum = mix(texture2, textureSum, 1.0 - labelmapOpacity);\n"; +a+=" } else {\n";a+=" textureSum = texture2;\n";a+=" }\n";a+=" }\n";a+=" }\n";a+=" }\n";a+=" if (volumeTexture) {\n";a+=" float _volumeLowerThreshold = (volumeLowerThreshold - volumeScalarMin)/ (volumeScalarMax - volumeScalarMin);\n";a+=" float _volumeUpperThreshold = (volumeUpperThreshold - volumeScalarMin)/ (volumeScalarMax - volumeScalarMin);\n";a+=" if (texture1.r < _volumeLowerThreshold ||\n";a+=" texture1.r > _volumeUpperThreshold ||\n"; +a+=" texture1.a == 0.0 ) {\n";a+=" discard;\n";a+=" };\n";a+=" };\n";a+=" gl_FragColor = textureSum;\n";a+=" gl_FragColor.a = objectOpacity;\n";a+=" } else {\n";a+=" vec3 nNormal = normalize(fTransformedVertexNormal);\n";a+=" if (fVertexNormal == vec3(0.0,0.0,0.0)) {\n";a+=" gl_FragColor = vec4(fragmentColor,1.0);\n";a+=" return;\n";a+=" }\n";a+=" vec3 light = vec3(0.0, 0.0, 1.0);\n";a+=" vec3 lightDirection = vec3(0,0,-10);\n";a+=" lightDirection = normalize(lightDirection);\n"; +a+=" vec3 eyeDirection = normalize(-fVertexPosition.xyz);\n";a+=" vec3 reflectionDirection = reflect(-lightDirection, nNormal);\n";a+=" float specular = pow(max(dot(reflectionDirection, eyeDirection), 0.0), 10.0);\n";a+=" float diffuse = 0.8 * max(dot(nNormal, light), 0.0);\n";a+=" float ambient = 0.3;\n";a+=" gl_FragColor = vec4(fragmentColor * ambient +\n";a+=" fragmentColor * diffuse +\n";a+=" vec3(0.2, 0.2, 0.2) * specular,\n";a+=" objectOpacity);\n"; +a+=" }\n";this.Ud=a+="}\n"}C(eh,M); +var fh={$k:"vertexPosition",Zk:"vertexNormal",Yk:"vertexColor",bl:"vertexTexturePos",al:"vertexScalar"},gh={cl:"view",Hk:"perspective",yk:"center",Gk:"objectTransform",Uk:"useObjectColor",Ek:"objectColor",Wk:"useScalars",Qk:"scalarsReplaceMode",Nk:"scalarsMin",Kk:"scalarsMax",Ok:"scalarsMinColor",Lk:"scalarsMaxColor",Pk:"scalarsMinThreshold",Mk:"scalarsMaxThreshold",Jk:"scalarsInterpolation",Ik:"pointSize",Fk:"objectOpacity",Dk:"normal",Vk:"usePicking",Xk:"useTexture",Tk:"useLabelMapTexture",Bk:"labelmapOpacity", +Ak:"labelmapColor",Rk:"textureSampler",Sk:"textureSampler2",dl:"volumeLowerThreshold",jl:"volumeUpperThreshold",gl:"volumeScalarMin",el:"volumeScalarMax",hl:"volumeScalarMinColor",fl:"volumeScalarMaxColor",ll:"volumeWindowLow",kl:"volumeWindowHigh",il:"volumeTexture"};function hh(){Gg.call(this);this.f="renderer3D";this.md=this.pd=this.ld=this.od=this.kd=this.nd=this.Ze=this.$e=t;this.z=[0,0,0];this.bd=[0,0,0];this.rg=t;this.Je=new zc;this.xd=new zc;this.pc=new zc;this.qd=new zc;this.Ec=new zc;this.Pc=new zc;this.oc=new zc;this.wd=new zc;this.R={PROGRESSBAR_ENABLED:q,PICKING_ENABLED:q,ORDERING_ENABLED:q,STATISTICS_ENABLED:u,INTERMEDIATE_RENDERING:u}}C(hh,Gg);hh.prototype.__defineGetter__("config",v("R"));w=hh.prototype; +w.Zj=function(){this.md=this.pd=this.ld=this.od=this.kd=this.nd=t;this.z=[0,0,0]};w.Jf=function(a){hh.u.Jf.call(this,a);var b=a.fe;a=a.ge;var c=this.Nf(b,a);if(c=this.get(c))if(c=c.Dc){var e=ve(this.v);(new dh(this.v,e.x+b+10,e.y+a+10,this.T)).t().innerHTML=c}}; +w.Ca=function(){hh.u.Ca.call(this,"experimental-webgl");try{if(this.a.viewport(0,0,this.K,this.A),this.a.clearColor(this.bd[0],this.bd[1],this.bd[2],0),this.a.enable(this.a.BLEND),this.a.blendEquation(this.a.FUNC_ADD),this.a.blendFunc(this.a.SRC_ALPHA,this.a.ONE_MINUS_SRC_ALPHA),this.a.enable(this.a.DEPTH_TEST),this.a.depthFunc(this.a.LEQUAL),this.a.clear(this.a.COLOR_BUFFER_BIT|this.a.DEPTH_BUFFER_BIT),this.R.PICKING_ENABLED){var a=this.a.createFramebuffer(),b=this.a.createRenderbuffer(),c=this.a.createTexture(); +this.a.bindTexture(this.a.TEXTURE_2D,c);this.a.texImage2D(this.a.TEXTURE_2D,0,this.a.RGB,this.K,this.A,0,this.a.RGB,this.a.UNSIGNED_BYTE,t);this.a.texParameteri(this.a.TEXTURE_2D,this.a.TEXTURE_WRAP_S,this.a.CLAMP_TO_EDGE);this.a.texParameteri(this.a.TEXTURE_2D,this.a.TEXTURE_WRAP_T,this.a.CLAMP_TO_EDGE);this.a.texParameteri(this.a.TEXTURE_2D,this.a.TEXTURE_MAG_FILTER,this.a.NEAREST);this.a.texParameteri(this.a.TEXTURE_2D,this.a.TEXTURE_MIN_FILTER,this.a.NEAREST);this.a.bindFramebuffer(this.a.FRAMEBUFFER, +a);this.a.bindRenderbuffer(this.a.RENDERBUFFER,b);this.a.renderbufferStorage(this.a.RENDERBUFFER,this.a.DEPTH_COMPONENT16,this.K,this.A);this.a.bindRenderbuffer(this.a.RENDERBUFFER,t);this.a.framebufferTexture2D(this.a.FRAMEBUFFER,this.a.COLOR_ATTACHMENT0,this.a.TEXTURE_2D,c,0);this.a.framebufferRenderbuffer(this.a.FRAMEBUFFER,this.a.DEPTH_ATTACHMENT,this.a.RENDERBUFFER,b);this.a.bindFramebuffer(this.a.FRAMEBUFFER,t);this.rg=a}}catch(e){m(Error("Exception while accessing GL Context!\n"+e))}a=new eh; +(this.na==t||this.a==t||this.N==t)&&m(Error("Renderer was not initialized properly."));(a==t||!(a instanceof eh))&&m(Error("Could not add shaders."));b=Object.keys(gh);Object.keys(fh).every(function(a){a=fh[a];return-1!=this.ce.search(a)||-1!=this.Ud.search(a)}.bind(a))||m(Error("Could not find all attributes in the shader sources."));b.every(function(a){a=gh[a];return-1!=this.ce.search(a)||-1!=this.Ud.search(a)}.bind(a))||m(Error("Could not find all uniforms in the shader sources."));b=this.a.createShader(this.a.FRAGMENT_SHADER); +c=this.a.createShader(this.a.VERTEX_SHADER);this.a.shaderSource(b,a.Ud);this.a.shaderSource(c,a.ce);this.a.compileShader(b);this.a.compileShader(c);this.a.getShaderParameter(b,this.a.COMPILE_STATUS)||m(Error("Fragement Shader compilation failed!\n"+this.a.getShaderInfoLog(b)));this.a.getShaderParameter(c,this.a.COMPILE_STATUS)||m(Error("Vertex Shader compilation failed!\n"+this.a.getShaderInfoLog(c)));var d=this.a.createProgram();this.a.attachShader(d,c);this.a.attachShader(d,b);this.a.linkProgram(d); +this.a.getProgramParameter(d,this.a.LINK_STATUS)||m(Error("Could not create shader program!\n"+this.a.getShaderInfoLog(b)+"\n"+this.a.getShaderInfoLog(c)+"\n"+this.a.getProgramInfoLog(d)));this.a.useProgram(d);this.Ze=d;Object.keys(fh).forEach(function(a){a=fh[a];this.Je.set(a,this.a.getAttribLocation(this.Ze,a));this.a.enableVertexAttribArray(this.Je.get(a))}.bind(this));Object.keys(gh).forEach(function(a){a=gh[a];this.xd.set(a,this.a.getUniformLocation(this.Ze,a))}.bind(this));this.$e=a}; +w.ub=function(a){hh.u.ub.call(this,a);var b=u;if(a!=t){this.get(a.qa)&&(b=q);var c=a.qa,e=a.h,d=a.n,f=a.pa,g=a.G,h=a.r,l=a.ja,j=a.xa,k=a.e,n=a.F;if(k!=t&&k.r!=t&&k.r.j)this.ub(k);else if(k!=t&&k.j&&this.ub(k),j!=t&&j.r!=t&&j.r.j)this.aa.load(j,a);else if(g!=t&&g.r!=t&&g.r.j)this.aa.load(g,a);else{if(h!=t&&ja(h))if(a.yc!=t){if(a.yc.yf!=h.length||!a.j)return}else{b=0;c=h.length;for(b=0;bthis.kd)this.kd=j.x;if(this.od===t||g.ythis.ld)this.ld=j.y;if(this.pd===t||g.dthis.md)this.md=j.d;this.z=[(this.nd+this.kd)/ +2,(this.od+this.ld)/2,(this.pd+this.md)/2];l.j=u}b&&e.j&&(l=this.pc.get(c),l!=t&&this.a.isBuffer(l.P)&&this.a.deleteBuffer(l.P));l=t;!b||e.j?(l=this.a.createBuffer(),e.Jb(),this.a.bindBuffer(this.a.ARRAY_BUFFER,l),this.a.bufferData(this.a.ARRAY_BUFFER,e.da,this.a.STATIC_DRAW),l=new Sd(l,e.count,3),e.j=u):l=this.pc.get(c);bg(this.aa,0.3);b&&d.j&&(g=this.pc.get(c),g!=t&&this.a.isBuffer(g.P)&&this.a.deleteBuffer(g.P));g=t;!b||d.j?(g=this.a.createBuffer(),d.Jb(),this.a.bindBuffer(this.a.ARRAY_BUFFER, +g),this.a.bufferData(this.a.ARRAY_BUFFER,d.da,this.a.STATIC_DRAW),g=new Sd(g,d.count,3),d.j=u):g=this.qd.get(c);bg(this.aa,0.3);b&&(f&&f.j)&&(d=this.Ec.get(c),d!=t&&this.a.isBuffer(d.P)&&this.a.deleteBuffer(d.P));d=t;f&&(!b||f.j?(f.length!=e.length&&m(Error("Mismatch between points and point colors.")),d=this.a.createBuffer(),f.Jb(),this.a.bindBuffer(this.a.ARRAY_BUFFER,d),this.a.bufferData(this.a.ARRAY_BUFFER,f.da,this.a.STATIC_DRAW),d=new Sd(d,f.count,3),f.j=u):d=this.Ec.get(c));bg(this.aa,0.2); +b&&(n&&n.j)&&(f=this.Pc.get(c),f!=t&&this.a.isBuffer(f.P)&&this.a.deleteBuffer(f.P));f=t;n&&(f=n.dd,!b||n.j?(f.length!=e.length&&m(Error("Mismatch between points and scalars.")),e=this.a.createBuffer(),this.a.bindBuffer(this.a.ARRAY_BUFFER,e),this.a.bufferData(this.a.ARRAY_BUFFER,f,this.a.STATIC_DRAW),f=new Sd(e,f.length,3),n.j=u):f=this.Pc.get(c));bg(this.aa,0.1);b||this.ab.add(a);this.pc.set(c,l);this.qd.set(c,g);this.Ec.set(c,d);this.oc.set(c,h);this.Pc.set(c,f);this.Xd=a.j=u}}else a.j=u}}}; +w.Nf=function(a,b){if(this.R.PICKING_ENABLED){this.dc(q,u);var c=new Uint8Array(4);this.a.readPixels(a,this.A-b,1,1,this.a.RGBA,this.a.UNSIGNED_BYTE,c);return c[0]+255*c[1]+65025*c[2]}return-1}; +w.dc=function(a,b){hh.u.dc.call(this,a,b);this.a.viewport(0,0,this.K,this.A);this.a.clear(this.a.COLOR_BUFFER_BIT|this.a.DEPTH_BUFFER_BIT);var c=this.ab.I,e=c.length;if(0!=e){a?this.a.bindFramebuffer(this.a.FRAMEBUFFER,this.rg):this.a.bindFramebuffer(this.a.FRAMEBUFFER,t);var d=this.N.We,f=this.N.o;this.a.uniformMatrix4fv(this.xd.get("perspective"),u,d);this.a.uniformMatrix4fv(this.xd.get("view"),u,f);d=this.z;this.a.uniform3f(this.xd.get("center"),parseFloat(d[0]),parseFloat(d[1]),parseFloat(d[2])); +f=this.Ha.length;for(d=0;dh*(l+n))for(h=h=0;hh;h++){var l=Math.floor(h/2),j=(l+1)%3,k=(l+2)%3,s=(2+2*l)%6,y=(4+2*l)%6,z=(r[h]-f[l])*(1/a[l]);Infinity!=z&&-Infinity!=z&&(n=f[j]+a[j]*z,z=f[k]+a[k]*z,n>=r[s]&&n<=r[s+1]&&z>=r[y]&&z<=r[y+1]?(s=[],s[l]=r[h],s[j]=n,s[k]=z,b.push(s)):(s=[],s[l]=r[h],s[j]=n,s[k]=z,g.push(s)))}a=[b,g];a=a[0];if(0==a.length)return t;g=Array(2);for(r=0;2>r;r++)b=a[r],g[r]=Math.sqrt((b[0]-f[0])*(b[0]-f[0])+(b[1]-f[1])*(b[1]-f[1])+(b[2]-f[2])*(b[2]-f[2]));f=b=r=t;g[0]n&&aj&&b=c.b[0].p?d=c.b[0].p-1:0>d&&(d=0),k=Math.round((c.b[1].i[0]* +g[0]+c.b[1].i[1]*g[1]+c.b[1].i[2]*g[2]+c.b[1].Ue)/c.b[1].Sc),k>=c.b[1].p?k=c.b[1].p-1:0>k&&(k=0),e=Math.round((c.b[2].i[0]*g[0]+c.b[2].i[1]*g[1]+c.b[2].i[2]*g[2]+c.b[2].Ue)/c.b[2].Sc),e>=c.b[2].p?e=c.b[2].p-1:0>e&&(e=0),[[d,k,e],[f[0],f[1],f[2]],[g[0],g[1],g[2]]]):t}; +w.dc=function(a,b){kh.u.dc.call(this,a,b);if(0!=this.ab.I.length){var c=this.Ha[0],e=t,e=0==this.Fa?c.indexX:1==this.Fa?c.indexY:c.indexZ,d=this.cb[parseInt(e,10)].jg,f=this.cb[parseInt(e,10)].ig;this.Uc=this.cb[parseInt(e,10)].Vc;this.Rc=this.cb[parseInt(e,10)].Gc;this.Tc=d;this.Qc=f;var g=this.K,h=this.A,l=this.N.o;this.a.save();this.a.clearRect(-g,-h,2*g,2*h);this.a.restore();this.xb=Math.max(l[14],1E-4);this.a.setTransform(this.xb,0,0,this.xb,0,0);var j=1*l[12],l=-1*l[13],k=t;c.e&&(k=c.e.af); +var n=this.cb[parseInt(e,10)],s=n.G.Wb,n=n.e,r=t;n&&(r=n.Wb);var y=this.Tc,z=this.Qc,F=this.fg,G=this.kg,H=F.getImageData(0,0,y,z),B=G.getImageData(0,0,y,z),E=H.data,I=B.data,N=E.length,Q=c.U,O=c.W,S=c.fa,da=c.ea;if(this.Ke!=e||this.U!=Q||this.W!=O||this.fa!=S||this.ea!=da||k&&!mg(k,this.lg,0)){var J=this.Vd;J.width=d;J.height=f;J=this.fd;J.width=d;J.height=f;d=0;do{var J=[0,0,0,0],f=[0,0,0,0],ba=s[d]/255*(c.ia-c.ra)+c.ra,la=da-S,U=la/2+S,V=0,V=baU+la/2?255:255*(ba-(U-la/2))/la;ba>=Q&& +ba<=O&&(J=new R(c.Rb[0],c.Rb[1],c.Rb[2]),J=(new R(c.Pb[0],c.Pb[1],c.Pb[2])).scale(V).add(J.scale(255-V)),J=[Math.floor(J.x),Math.floor(J.y),Math.floor(J.d),255],n&&(-255==k[3]?f=[r[d],r[d+1],r[d+2],r[d+3]]:mg(k,r,d)&&(f=[r[d],r[d+1],r[d+2],r[d+3]])));"X"==this.Qa?(E[d]=J[0],E[d+1]=J[1],E[d+2]=J[2],E[d+3]=J[3],I[d]=f[0],I[d+1]=f[1],I[d+2]=f[2],I[d+3]=f[3]):"Y"==this.Qa?(V=Math.floor(d/(4*y)),V=4*V*y+(4*(y-1)-(d-4*V*y)),E[V]=J[0],E[V+1]=J[1],E[V+2]=J[2],E[V+3]=J[3],I[V]=f[0],I[V+1]=f[1],I[V+2]=f[2], +I[V+3]=f[3]):(V=N-1-d,E[V-3]=J[0],E[V-2]=J[1],E[V-1]=J[2],E[V]=J[3],I[V-3]=f[0],I[V-2]=f[1],I[V-1]=f[2],I[V]=f[3]);d+=4}while(d= 0; i--) { + args = [toCall[i].apply(this, args)]; + } + return args[0]; + } + }, + + each: function(obj, itr, scope) { + + + if (ARR_EACH && obj.forEach === ARR_EACH) { + + obj.forEach(itr, scope); + + } else if (obj.length === obj.length + 0) { // Is number but not NaN + + for (var key = 0, l = obj.length; key < l; key++) + if (key in obj && itr.call(scope, obj[key], key) === this.BREAK) + return; + + } else { + + for (var key in obj) + if (itr.call(scope, obj[key], key) === this.BREAK) + return; + + } + + }, + + defer: function(fnc) { + setTimeout(fnc, 0); + }, + + toArray: function(obj) { + if (obj.toArray) return obj.toArray(); + return ARR_SLICE.call(obj); + }, + + isUndefined: function(obj) { + return obj === undefined; + }, + + isNull: function(obj) { + return obj === null; + }, + + isNaN: function(obj) { + return obj !== obj; + }, + + isArray: Array.isArray || function(obj) { + return obj.constructor === Array; + }, + + isObject: function(obj) { + return obj === Object(obj); + }, + + isNumber: function(obj) { + return obj === obj+0; + }, + + isString: function(obj) { + return obj === obj+''; + }, + + isBoolean: function(obj) { + return obj === false || obj === true; + }, + + isFunction: function(obj) { + return Object.prototype.toString.call(obj) === '[object Function]'; + } + + }; + +})(); + + +dat.controllers.Controller = (function (common) { + + /** + * @class An "abstract" class that represents a given property of an object. + * + * @param {Object} object The object to be manipulated + * @param {string} property The name of the property to be manipulated + * + * @member dat.controllers + */ + var Controller = function(object, property) { + + this.initialValue = object[property]; + + /** + * Those who extend this class will put their DOM elements in here. + * @type {DOMElement} + */ + this.domElement = document.createElement('div'); + + /** + * The object to manipulate + * @type {Object} + */ + this.object = object; + + /** + * The name of the property to manipulate + * @type {String} + */ + this.property = property; + + /** + * The function to be called on change. + * @type {Function} + * @ignore + */ + this.__onChange = undefined; + + /** + * The function to be called on finishing change. + * @type {Function} + * @ignore + */ + this.__onFinishChange = undefined; + + }; + + common.extend( + + Controller.prototype, + + /** @lends dat.controllers.Controller.prototype */ + { + + /** + * Specify that a function fire every time someone changes the value with + * this Controller. + * + * @param {Function} fnc This function will be called whenever the value + * is modified via this Controller. + * @returns {dat.controllers.Controller} this + */ + onChange: function(fnc) { + this.__onChange = fnc; + return this; + }, + + /** + * Specify that a function fire every time someone "finishes" changing + * the value wih this Controller. Useful for values that change + * incrementally like numbers or strings. + * + * @param {Function} fnc This function will be called whenever + * someone "finishes" changing the value via this Controller. + * @returns {dat.controllers.Controller} this + */ + onFinishChange: function(fnc) { + this.__onFinishChange = fnc; + return this; + }, + + /** + * Change the value of object[property] + * + * @param {Object} newValue The new value of object[property] + */ + setValue: function(newValue) { + this.object[this.property] = newValue; + if (this.__onChange) { + this.__onChange.call(this, newValue); + } + this.updateDisplay(); + return this; + }, + + /** + * Gets the value of object[property] + * + * @returns {Object} The current value of object[property] + */ + getValue: function() { + return this.object[this.property]; + }, + + /** + * Refreshes the visual display of a Controller in order to keep sync + * with the object's current value. + * @returns {dat.controllers.Controller} this + */ + updateDisplay: function() { + return this; + }, + + /** + * @returns {Boolean} true if the value has deviated from initialValue + */ + isModified: function() { + return this.initialValue !== this.getValue() + } + + } + + ); + + return Controller; + + +})(dat.utils.common); + + +dat.dom.dom = (function (common) { + + var EVENT_MAP = { + 'HTMLEvents': ['change'], + 'MouseEvents': ['click','mousemove','mousedown','mouseup', 'mouseover'], + 'KeyboardEvents': ['keydown'] + }; + + var EVENT_MAP_INV = {}; + common.each(EVENT_MAP, function(v, k) { + common.each(v, function(e) { + EVENT_MAP_INV[e] = k; + }); + }); + + var CSS_VALUE_PIXELS = /(\d+(\.\d+)?)px/; + + function cssValueToPixels(val) { + + if (val === '0' || common.isUndefined(val)) return 0; + + var match = val.match(CSS_VALUE_PIXELS); + + if (!common.isNull(match)) { + return parseFloat(match[1]); + } + + // TODO ...ems? %? + + return 0; + + } + + /** + * @namespace + * @member dat.dom + */ + var dom = { + + /** + * + * @param elem + * @param selectable + */ + makeSelectable: function(elem, selectable) { + + if (elem === undefined || elem.style === undefined) return; + + elem.onselectstart = selectable ? function() { + return false; + } : function() { + }; + + elem.style.MozUserSelect = selectable ? 'auto' : 'none'; + elem.style.KhtmlUserSelect = selectable ? 'auto' : 'none'; + elem.unselectable = selectable ? 'on' : 'off'; + + }, + + /** + * + * @param elem + * @param horizontal + * @param vertical + */ + makeFullscreen: function(elem, horizontal, vertical) { + + if (common.isUndefined(horizontal)) horizontal = true; + if (common.isUndefined(vertical)) vertical = true; + + elem.style.position = 'absolute'; + + if (horizontal) { + elem.style.left = 0; + elem.style.right = 0; + } + if (vertical) { + elem.style.top = 0; + elem.style.bottom = 0; + } + + }, + + /** + * + * @param elem + * @param eventType + * @param params + */ + fakeEvent: function(elem, eventType, params, aux) { + params = params || {}; + var className = EVENT_MAP_INV[eventType]; + if (!className) { + throw new Error('Event type ' + eventType + ' not supported.'); + } + var evt = document.createEvent(className); + switch (className) { + case 'MouseEvents': + var clientX = params.x || params.clientX || 0; + var clientY = params.y || params.clientY || 0; + evt.initMouseEvent(eventType, params.bubbles || false, + params.cancelable || true, window, params.clickCount || 1, + 0, //screen X + 0, //screen Y + clientX, //client X + clientY, //client Y + false, false, false, false, 0, null); + break; + case 'KeyboardEvents': + var init = evt.initKeyboardEvent || evt.initKeyEvent; // webkit || moz + common.defaults(params, { + cancelable: true, + ctrlKey: false, + altKey: false, + shiftKey: false, + metaKey: false, + keyCode: undefined, + charCode: undefined + }); + init(eventType, params.bubbles || false, + params.cancelable, window, + params.ctrlKey, params.altKey, + params.shiftKey, params.metaKey, + params.keyCode, params.charCode); + break; + default: + evt.initEvent(eventType, params.bubbles || false, + params.cancelable || true); + break; + } + common.defaults(evt, aux); + elem.dispatchEvent(evt); + }, + + /** + * + * @param elem + * @param event + * @param func + * @param bool + */ + bind: function(elem, event, func, bool) { + bool = bool || false; + if (elem.addEventListener) + elem.addEventListener(event, func, bool); + else if (elem.attachEvent) + elem.attachEvent('on' + event, func); + return dom; + }, + + /** + * + * @param elem + * @param event + * @param func + * @param bool + */ + unbind: function(elem, event, func, bool) { + bool = bool || false; + if (elem.removeEventListener) + elem.removeEventListener(event, func, bool); + else if (elem.detachEvent) + elem.detachEvent('on' + event, func); + return dom; + }, + + /** + * + * @param elem + * @param className + */ + addClass: function(elem, className) { + if (elem.className === undefined) { + elem.className = className; + } else if (elem.className !== className) { + var classes = elem.className.split(/ +/); + if (classes.indexOf(className) == -1) { + classes.push(className); + elem.className = classes.join(' ').replace(/^\s+/, '').replace(/\s+$/, ''); + } + } + return dom; + }, + + /** + * + * @param elem + * @param className + */ + removeClass: function(elem, className) { + if (className) { + if (elem.className === undefined) { + // elem.className = className; + } else if (elem.className === className) { + elem.removeAttribute('class'); + } else { + var classes = elem.className.split(/ +/); + var index = classes.indexOf(className); + if (index != -1) { + classes.splice(index, 1); + elem.className = classes.join(' '); + } + } + } else { + elem.className = undefined; + } + return dom; + }, + + hasClass: function(elem, className) { + return new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)').test(elem.className) || false; + }, + + /** + * + * @param elem + */ + getWidth: function(elem) { + + var style = getComputedStyle(elem); + + return cssValueToPixels(style['border-left-width']) + + cssValueToPixels(style['border-right-width']) + + cssValueToPixels(style['padding-left']) + + cssValueToPixels(style['padding-right']) + + cssValueToPixels(style['width']); + }, + + /** + * + * @param elem + */ + getHeight: function(elem) { + + var style = getComputedStyle(elem); + + return cssValueToPixels(style['border-top-width']) + + cssValueToPixels(style['border-bottom-width']) + + cssValueToPixels(style['padding-top']) + + cssValueToPixels(style['padding-bottom']) + + cssValueToPixels(style['height']); + }, + + /** + * + * @param elem + */ + getOffset: function(elem) { + var offset = {left: 0, top:0}; + if (elem.offsetParent) { + do { + offset.left += elem.offsetLeft; + offset.top += elem.offsetTop; + } while (elem = elem.offsetParent); + } + return offset; + }, + + // http://stackoverflow.com/posts/2684561/revisions + /** + * + * @param elem + */ + isActive: function(elem) { + return elem === document.activeElement && ( elem.type || elem.href ); + } + + }; + + return dom; + +})(dat.utils.common); + + +dat.controllers.OptionController = (function (Controller, dom, common) { + + /** + * @class Provides a select input to alter the property of an object, using a + * list of accepted values. + * + * @extends dat.controllers.Controller + * + * @param {Object} object The object to be manipulated + * @param {string} property The name of the property to be manipulated + * @param {Object|string[]} options A map of labels to acceptable values, or + * a list of acceptable string values. + * + * @member dat.controllers + */ + var OptionController = function(object, property, options) { + + OptionController.superclass.call(this, object, property); + + var _this = this; + + /** + * The drop down menu + * @ignore + */ + this.__select = document.createElement('select'); + + if (common.isArray(options)) { + var map = {}; + common.each(options, function(element) { + map[element] = element; + }); + options = map; + } + + common.each(options, function(value, key) { + + var opt = document.createElement('option'); + opt.innerHTML = key; + opt.setAttribute('value', value); + _this.__select.appendChild(opt); + + }); + + // Acknowledge original value + this.updateDisplay(); + + dom.bind(this.__select, 'change', function() { + var desiredValue = this.options[this.selectedIndex].value; + _this.setValue(desiredValue); + }); + + this.domElement.appendChild(this.__select); + + }; + + OptionController.superclass = Controller; + + common.extend( + + OptionController.prototype, + Controller.prototype, + + { + + setValue: function(v) { + var toReturn = OptionController.superclass.prototype.setValue.call(this, v); + if (this.__onFinishChange) { + this.__onFinishChange.call(this, this.getValue()); + } + return toReturn; + }, + + updateDisplay: function() { + this.__select.value = this.getValue(); + return OptionController.superclass.prototype.updateDisplay.call(this); + } + + } + + ); + + return OptionController; + +})(dat.controllers.Controller, +dat.dom.dom, +dat.utils.common); + + +dat.controllers.NumberController = (function (Controller, common) { + + /** + * @class Represents a given property of an object that is a number. + * + * @extends dat.controllers.Controller + * + * @param {Object} object The object to be manipulated + * @param {string} property The name of the property to be manipulated + * @param {Object} [params] Optional parameters + * @param {Number} [params.min] Minimum allowed value + * @param {Number} [params.max] Maximum allowed value + * @param {Number} [params.step] Increment by which to change value + * + * @member dat.controllers + */ + var NumberController = function(object, property, params) { + + NumberController.superclass.call(this, object, property); + + params = params || {}; + + this.__min = params.min; + this.__max = params.max; + this.__step = params.step; + + if (common.isUndefined(this.__step)) { + + if (this.initialValue == 0) { + this.__impliedStep = 1; // What are we, psychics? + } else { + // Hey Doug, check this out. + this.__impliedStep = Math.pow(10, Math.floor(Math.log(this.initialValue)/Math.LN10))/10; + } + + } else { + + this.__impliedStep = this.__step; + + } + + this.__precision = numDecimals(this.__impliedStep); + + + }; + + NumberController.superclass = Controller; + + common.extend( + + NumberController.prototype, + Controller.prototype, + + /** @lends dat.controllers.NumberController.prototype */ + { + + setValue: function(v) { + + if (this.__min !== undefined && v < this.__min) { + v = this.__min; + } else if (this.__max !== undefined && v > this.__max) { + v = this.__max; + } + + if (this.__step !== undefined && v % this.__step != 0) { + v = Math.round(v / this.__step) * this.__step; + } + + return NumberController.superclass.prototype.setValue.call(this, v); + + }, + + /** + * Specify a minimum value for object[property]. + * + * @param {Number} minValue The minimum value for + * object[property] + * @returns {dat.controllers.NumberController} this + */ + min: function(v) { + this.__min = v; + return this; + }, + + /** + * Specify a maximum value for object[property]. + * + * @param {Number} maxValue The maximum value for + * object[property] + * @returns {dat.controllers.NumberController} this + */ + max: function(v) { + this.__max = v; + return this; + }, + + /** + * Specify a step value that dat.controllers.NumberController + * increments by. + * + * @param {Number} stepValue The step value for + * dat.controllers.NumberController + * @default if minimum and maximum specified increment is 1% of the + * difference otherwise stepValue is 1 + * @returns {dat.controllers.NumberController} this + */ + step: function(v) { + this.__step = v; + return this; + } + + } + + ); + + function numDecimals(x) { + x = x.toString(); + if (x.indexOf('.') > -1) { + return x.length - x.indexOf('.') - 1; + } else { + return 0; + } + } + + return NumberController; + +})(dat.controllers.Controller, +dat.utils.common); + + +dat.controllers.NumberControllerBox = (function (NumberController, dom, common) { + + /** + * @class Represents a given property of an object that is a number and + * provides an input element with which to manipulate it. + * + * @extends dat.controllers.Controller + * @extends dat.controllers.NumberController + * + * @param {Object} object The object to be manipulated + * @param {string} property The name of the property to be manipulated + * @param {Object} [params] Optional parameters + * @param {Number} [params.min] Minimum allowed value + * @param {Number} [params.max] Maximum allowed value + * @param {Number} [params.step] Increment by which to change value + * + * @member dat.controllers + */ + var NumberControllerBox = function(object, property, params) { + + this.__truncationSuspended = false; + + NumberControllerBox.superclass.call(this, object, property, params); + + var _this = this; + + /** + * {Number} Previous mouse y position + * @ignore + */ + var prev_y; + + this.__input = document.createElement('input'); + this.__input.setAttribute('type', 'text'); + + // Makes it so manually specified values are not truncated. + + dom.bind(this.__input, 'change', onChange); + dom.bind(this.__input, 'blur', onBlur); + dom.bind(this.__input, 'mousedown', onMouseDown); + dom.bind(this.__input, 'keydown', function(e) { + + // When pressing entire, you can be as precise as you want. + if (e.keyCode === 13) { + _this.__truncationSuspended = true; + this.blur(); + _this.__truncationSuspended = false; + } + + }); + + function onChange() { + var attempted = parseFloat(_this.__input.value); + if (!common.isNaN(attempted)) _this.setValue(attempted); + } + + function onBlur() { + onChange(); + if (_this.__onFinishChange) { + _this.__onFinishChange.call(_this, _this.getValue()); + } + } + + function onMouseDown(e) { + dom.bind(window, 'mousemove', onMouseDrag); + dom.bind(window, 'mouseup', onMouseUp); + prev_y = e.clientY; + } + + function onMouseDrag(e) { + + var diff = prev_y - e.clientY; + _this.setValue(_this.getValue() + diff * _this.__impliedStep); + + prev_y = e.clientY; + + } + + function onMouseUp() { + dom.unbind(window, 'mousemove', onMouseDrag); + dom.unbind(window, 'mouseup', onMouseUp); + } + + this.updateDisplay(); + + this.domElement.appendChild(this.__input); + + }; + + NumberControllerBox.superclass = NumberController; + + common.extend( + + NumberControllerBox.prototype, + NumberController.prototype, + + { + + updateDisplay: function() { + + this.__input.value = this.__truncationSuspended ? this.getValue() : roundToDecimal(this.getValue(), this.__precision); + return NumberControllerBox.superclass.prototype.updateDisplay.call(this); + } + + } + + ); + + function roundToDecimal(value, decimals) { + var tenTo = Math.pow(10, decimals); + return Math.round(value * tenTo) / tenTo; + } + + return NumberControllerBox; + +})(dat.controllers.NumberController, +dat.dom.dom, +dat.utils.common); + + +dat.controllers.NumberControllerSlider = (function (NumberController, dom, css, common, styleSheet) { + + /** + * @class Represents a given property of an object that is a number, contains + * a minimum and maximum, and provides a slider element with which to + * manipulate it. It should be noted that the slider element is made up of + * <div> tags, not the html5 + * <slider> element. + * + * @extends dat.controllers.Controller + * @extends dat.controllers.NumberController + * + * @param {Object} object The object to be manipulated + * @param {string} property The name of the property to be manipulated + * @param {Number} minValue Minimum allowed value + * @param {Number} maxValue Maximum allowed value + * @param {Number} stepValue Increment by which to change value + * + * @member dat.controllers + */ + var NumberControllerSlider = function(object, property, min, max, step) { + + NumberControllerSlider.superclass.call(this, object, property, { min: min, max: max, step: step }); + + var _this = this; + + this.__background = document.createElement('div'); + this.__foreground = document.createElement('div'); + + + + dom.bind(this.__background, 'mousedown', onMouseDown); + + dom.addClass(this.__background, 'slider'); + dom.addClass(this.__foreground, 'slider-fg'); + + function onMouseDown(e) { + + dom.bind(window, 'mousemove', onMouseDrag); + dom.bind(window, 'mouseup', onMouseUp); + + onMouseDrag(e); + } + + function onMouseDrag(e) { + + e.preventDefault(); + + var offset = dom.getOffset(_this.__background); + var width = dom.getWidth(_this.__background); + + _this.setValue( + map(e.clientX, offset.left, offset.left + width, _this.__min, _this.__max) + ); + + return false; + + } + + function onMouseUp() { + dom.unbind(window, 'mousemove', onMouseDrag); + dom.unbind(window, 'mouseup', onMouseUp); + if (_this.__onFinishChange) { + _this.__onFinishChange.call(_this, _this.getValue()); + } + } + + this.updateDisplay(); + + this.__background.appendChild(this.__foreground); + this.domElement.appendChild(this.__background); + + }; + + NumberControllerSlider.superclass = NumberController; + + /** + * Injects default stylesheet for slider elements. + */ + NumberControllerSlider.useDefaultStyles = function() { + css.inject(styleSheet); + }; + + common.extend( + + NumberControllerSlider.prototype, + NumberController.prototype, + + { + + updateDisplay: function() { + var pct = (this.getValue() - this.__min)/(this.__max - this.__min); + this.__foreground.style.width = pct*100+'%'; + return NumberControllerSlider.superclass.prototype.updateDisplay.call(this); + } + + } + + + + ); + + function map(v, i1, i2, o1, o2) { + return o1 + (o2 - o1) * ((v - i1) / (i2 - i1)); + } + + return NumberControllerSlider; + +})(dat.controllers.NumberController, +dat.dom.dom, +dat.utils.css, +dat.utils.common, +".slider {\n box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);\n height: 1em;\n border-radius: 1em;\n background-color: #eee;\n padding: 0 0.5em;\n overflow: hidden;\n}\n\n.slider-fg {\n padding: 1px 0 2px 0;\n background-color: #aaa;\n height: 1em;\n margin-left: -0.5em;\n padding-right: 0.5em;\n border-radius: 1em 0 0 1em;\n}\n\n.slider-fg:after {\n display: inline-block;\n border-radius: 1em;\n background-color: #fff;\n border: 1px solid #aaa;\n content: '';\n float: right;\n margin-right: -1em;\n margin-top: -1px;\n height: 0.9em;\n width: 0.9em;\n}"); + + +dat.controllers.FunctionController = (function (Controller, dom, common) { + + /** + * @class Provides a GUI interface to fire a specified method, a property of an object. + * + * @extends dat.controllers.Controller + * + * @param {Object} object The object to be manipulated + * @param {string} property The name of the property to be manipulated + * + * @member dat.controllers + */ + var FunctionController = function(object, property, text) { + + FunctionController.superclass.call(this, object, property); + + var _this = this; + + this.__button = document.createElement('div'); + this.__button.innerHTML = text === undefined ? 'Fire' : text; + dom.bind(this.__button, 'click', function(e) { + e.preventDefault(); + _this.fire(); + return false; + }); + + dom.addClass(this.__button, 'button'); + + this.domElement.appendChild(this.__button); + + + }; + + FunctionController.superclass = Controller; + + common.extend( + + FunctionController.prototype, + Controller.prototype, + { + + fire: function() { + if (this.__onChange) { + this.__onChange.call(this); + } + if (this.__onFinishChange) { + this.__onFinishChange.call(this, this.getValue()); + } + this.getValue().call(this.object); + } + } + + ); + + return FunctionController; + +})(dat.controllers.Controller, +dat.dom.dom, +dat.utils.common); + + +dat.controllers.BooleanController = (function (Controller, dom, common) { + + /** + * @class Provides a checkbox input to alter the boolean property of an object. + * @extends dat.controllers.Controller + * + * @param {Object} object The object to be manipulated + * @param {string} property The name of the property to be manipulated + * + * @member dat.controllers + */ + var BooleanController = function(object, property) { + + BooleanController.superclass.call(this, object, property); + + var _this = this; + this.__prev = this.getValue(); + + this.__checkbox = document.createElement('input'); + this.__checkbox.setAttribute('type', 'checkbox'); + + + dom.bind(this.__checkbox, 'change', onChange, false); + + this.domElement.appendChild(this.__checkbox); + + // Match original value + this.updateDisplay(); + + function onChange() { + _this.setValue(!_this.__prev); + } + + }; + + BooleanController.superclass = Controller; + + common.extend( + + BooleanController.prototype, + Controller.prototype, + + { + + setValue: function(v) { + var toReturn = BooleanController.superclass.prototype.setValue.call(this, v); + if (this.__onFinishChange) { + this.__onFinishChange.call(this, this.getValue()); + } + this.__prev = this.getValue(); + return toReturn; + }, + + updateDisplay: function() { + + if (this.getValue() === true) { + this.__checkbox.setAttribute('checked', 'checked'); + this.__checkbox.checked = true; + } else { + this.__checkbox.checked = false; + } + + return BooleanController.superclass.prototype.updateDisplay.call(this); + + } + + + } + + ); + + return BooleanController; + +})(dat.controllers.Controller, +dat.dom.dom, +dat.utils.common); + + +dat.color.toString = (function (common) { + + return function(color) { + + if (color.a == 1 || common.isUndefined(color.a)) { + + var s = color.hex.toString(16); + while (s.length < 6) { + s = '0' + s; + } + + return '#' + s; + + } else { + + return 'rgba(' + Math.round(color.r) + ',' + Math.round(color.g) + ',' + Math.round(color.b) + ',' + color.a + ')'; + + } + + } + +})(dat.utils.common); + + +dat.color.interpret = (function (toString, common) { + + var result, toReturn; + + var interpret = function() { + + toReturn = false; + + var original = arguments.length > 1 ? common.toArray(arguments) : arguments[0]; + + common.each(INTERPRETATIONS, function(family) { + + if (family.litmus(original)) { + + common.each(family.conversions, function(conversion, conversionName) { + + result = conversion.read(original); + + if (toReturn === false && result !== false) { + toReturn = result; + result.conversionName = conversionName; + result.conversion = conversion; + return common.BREAK; + + } + + }); + + return common.BREAK; + + } + + }); + + return toReturn; + + }; + + var INTERPRETATIONS = [ + + // Strings + { + + litmus: common.isString, + + conversions: { + + THREE_CHAR_HEX: { + + read: function(original) { + + var test = original.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i); + if (test === null) return false; + + return { + space: 'HEX', + hex: parseInt( + '0x' + + test[1].toString() + test[1].toString() + + test[2].toString() + test[2].toString() + + test[3].toString() + test[3].toString()) + }; + + }, + + write: toString + + }, + + SIX_CHAR_HEX: { + + read: function(original) { + + var test = original.match(/^#([A-F0-9]{6})$/i); + if (test === null) return false; + + return { + space: 'HEX', + hex: parseInt('0x' + test[1].toString()) + }; + + }, + + write: toString + + }, + + CSS_RGB: { + + read: function(original) { + + var test = original.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/); + if (test === null) return false; + + return { + space: 'RGB', + r: parseFloat(test[1]), + g: parseFloat(test[2]), + b: parseFloat(test[3]) + }; + + }, + + write: toString + + }, + + CSS_RGBA: { + + read: function(original) { + + var test = original.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\,\s*(.+)\s*\)/); + if (test === null) return false; + + return { + space: 'RGB', + r: parseFloat(test[1]), + g: parseFloat(test[2]), + b: parseFloat(test[3]), + a: parseFloat(test[4]) + }; + + }, + + write: toString + + } + + } + + }, + + // Numbers + { + + litmus: common.isNumber, + + conversions: { + + HEX: { + read: function(original) { + return { + space: 'HEX', + hex: original, + conversionName: 'HEX' + } + }, + + write: function(color) { + return color.hex; + } + } + + } + + }, + + // Arrays + { + + litmus: common.isArray, + + conversions: { + + RGB_ARRAY: { + read: function(original) { + if (original.length != 3) return false; + return { + space: 'RGB', + r: original[0]*255, + g: original[1]*255, + b: original[2]*255 + }; + }, + + write: function(color) { + return [color.r/255, color.g/255, color.b/255]; + } + + }, + + RGBA_ARRAY: { + read: function(original) { + if (original.length != 4) return false; + return { + space: 'RGB', + r: original[0], + g: original[1], + b: original[2], + a: original[3] + }; + }, + + write: function(color) { + return [color.r, color.g, color.b, color.a]; + } + + } + + } + + }, + + // Objects + { + + litmus: common.isObject, + + conversions: { + + RGBA_OBJ: { + read: function(original) { + if (common.isNumber(original.r) && + common.isNumber(original.g) && + common.isNumber(original.b) && + common.isNumber(original.a)) { + return { + space: 'RGB', + r: original.r, + g: original.g, + b: original.b, + a: original.a + } + } + return false; + }, + + write: function(color) { + return { + r: color.r, + g: color.g, + b: color.b, + a: color.a + } + } + }, + + RGB_OBJ: { + read: function(original) { + if (common.isNumber(original.r) && + common.isNumber(original.g) && + common.isNumber(original.b)) { + return { + space: 'RGB', + r: original.r, + g: original.g, + b: original.b + } + } + return false; + }, + + write: function(color) { + return { + r: color.r, + g: color.g, + b: color.b + } + } + }, + + HSVA_OBJ: { + read: function(original) { + if (common.isNumber(original.h) && + common.isNumber(original.s) && + common.isNumber(original.v) && + common.isNumber(original.a)) { + return { + space: 'HSV', + h: original.h, + s: original.s, + v: original.v, + a: original.a + } + } + return false; + }, + + write: function(color) { + return { + h: color.h, + s: color.s, + v: color.v, + a: color.a + } + } + }, + + HSV_OBJ: { + read: function(original) { + if (common.isNumber(original.h) && + common.isNumber(original.s) && + common.isNumber(original.v)) { + return { + space: 'HSV', + h: original.h, + s: original.s, + v: original.v + } + } + return false; + }, + + write: function(color) { + return { + h: color.h, + s: color.s, + v: color.v + } + } + + } + + } + + } + + + ]; + + return interpret; + + +})(dat.color.toString, +dat.utils.common); + + +dat.GUI = dat.gui.GUI = (function (css, saveDialogueContents, styleSheet, controllerFactory, Controller, BooleanController, FunctionController, NumberControllerBox, NumberControllerSlider, OptionController, ColorController, requestAnimationFrame, CenteredDiv, dom, common) { + + css.inject(styleSheet); + + /** Outer-most className for GUI's */ + var CSS_NAMESPACE = 'dg'; + + var HIDE_KEY_CODE = 72; + + /** The only value shared between the JS and SCSS. Use caution. */ + var CLOSE_BUTTON_HEIGHT = 20; + + var DEFAULT_DEFAULT_PRESET_NAME = 'Default'; + + var SUPPORTS_LOCAL_STORAGE = (function() { + try { + return 'localStorage' in window && window['localStorage'] !== null; + } catch (e) { + return false; + } + })(); + + var SAVE_DIALOGUE; + + /** Have we yet to create an autoPlace GUI? */ + var auto_place_virgin = true; + + /** Fixed position div that auto place GUI's go inside */ + var auto_place_container; + + /** Are we hiding the GUI's ? */ + var hide = false; + + /** GUI's which should be hidden */ + var hideable_guis = []; + + /** + * A lightweight controller library for JavaScript. It allows you to easily + * manipulate variables and fire functions on the fly. + * @class + * + * @member dat.gui + * + * @param {Object} [params] + * @param {String} [params.name] The name of this GUI. + * @param {Object} [params.load] JSON object representing the saved state of + * this GUI. + * @param {Boolean} [params.auto=true] + * @param {dat.gui.GUI} [params.parent] The GUI I'm nested in. + * @param {Boolean} [params.closed] If true, starts closed + */ + var GUI = function(params) { + + var _this = this; + + /** + * Outermost DOM Element + * @type DOMElement + */ + this.domElement = document.createElement('div'); + this.__ul = document.createElement('ul'); + this.domElement.appendChild(this.__ul); + + dom.addClass(this.domElement, CSS_NAMESPACE); + + /** + * Nested GUI's by name + * @ignore + */ + this.__folders = {}; + + this.__controllers = []; + + /** + * List of objects I'm remembering for save, only used in top level GUI + * @ignore + */ + this.__rememberedObjects = []; + + /** + * Maps the index of remembered objects to a map of controllers, only used + * in top level GUI. + * + * @private + * @ignore + * + * @example + * [ + * { + * propertyName: Controller, + * anotherPropertyName: Controller + * }, + * { + * propertyName: Controller + * } + * ] + */ + this.__rememberedObjectIndecesToControllers = []; + + this.__listening = []; + + params = params || {}; + + // Default parameters + params = common.defaults(params, { + autoPlace: true, + width: GUI.DEFAULT_WIDTH + }); + + params = common.defaults(params, { + resizable: params.autoPlace, + hideable: params.autoPlace + }); + + + if (!common.isUndefined(params.load)) { + + // Explicit preset + if (params.preset) params.load.preset = params.preset; + + } else { + + params.load = { preset: DEFAULT_DEFAULT_PRESET_NAME }; + + } + + if (common.isUndefined(params.parent) && params.hideable) { + hideable_guis.push(this); + } + + // Only root level GUI's are resizable. + params.resizable = common.isUndefined(params.parent) && params.resizable; + + + if (params.autoPlace && common.isUndefined(params.scrollable)) { + params.scrollable = true; + } +// params.scrollable = common.isUndefined(params.parent) && params.scrollable === true; + + // Not part of params because I don't want people passing this in via + // constructor. Should be a 'remembered' value. + var use_local_storage = + SUPPORTS_LOCAL_STORAGE && + localStorage.getItem(getLocalStorageHash(this, 'isLocal')) === 'true'; + + Object.defineProperties(this, + + /** @lends dat.gui.GUI.prototype */ + { + + /** + * The parent GUI + * @type dat.gui.GUI + */ + parent: { + get: function() { + return params.parent; + } + }, + + scrollable: { + get: function() { + return params.scrollable; + } + }, + + /** + * Handles GUI's element placement for you + * @type Boolean + */ + autoPlace: { + get: function() { + return params.autoPlace; + } + }, + + /** + * The identifier for a set of saved values + * @type String + */ + preset: { + + get: function() { + if (_this.parent) { + return _this.getRoot().preset; + } else { + return params.load.preset; + } + }, + + set: function(v) { + if (_this.parent) { + _this.getRoot().preset = v; + } else { + params.load.preset = v; + } + setPresetSelectIndex(this); + _this.revert(); + } + + }, + + /** + * The width of GUI element + * @type Number + */ + width: { + get: function() { + return params.width; + }, + set: function(v) { + params.width = v; + setWidth(_this, v); + } + }, + + /** + * The name of GUI. Used for folders. i.e + * a folder's name + * @type String + */ + name: { + get: function() { + return params.name; + }, + set: function(v) { + // TODO Check for collisions among sibling folders + params.name = v; + if (title_row_name) { + title_row_name.innerHTML = params.name; + } + } + }, + + /** + * Whether the GUI is collapsed or not + * @type Boolean + */ + closed: { + get: function() { + return params.closed; + }, + set: function(v) { + params.closed = v; + if (params.closed) { + dom.addClass(_this.__ul, GUI.CLASS_CLOSED); + } else { + dom.removeClass(_this.__ul, GUI.CLASS_CLOSED); + } + // For browsers that aren't going to respect the CSS transition, + // Lets just check our height against the window height right off + // the bat. + this.onResize(); + + if (_this.__closeButton) { + _this.__closeButton.innerHTML = v ? GUI.TEXT_OPEN : GUI.TEXT_CLOSED; + } + } + }, + + /** + * Contains all presets + * @type Object + */ + load: { + get: function() { + return params.load; + } + }, + + /** + * Determines whether or not to use localStorage as the means for + * remembering + * @type Boolean + */ + useLocalStorage: { + + get: function() { + return use_local_storage; + }, + set: function(bool) { + if (SUPPORTS_LOCAL_STORAGE) { + use_local_storage = bool; + if (bool) { + dom.bind(window, 'unload', saveToLocalStorage); + } else { + dom.unbind(window, 'unload', saveToLocalStorage); + } + localStorage.setItem(getLocalStorageHash(_this, 'isLocal'), bool); + } + } + + } + + }); + + // Are we a root level GUI? + if (common.isUndefined(params.parent)) { + + params.closed = false; + + dom.addClass(this.domElement, GUI.CLASS_MAIN); + dom.makeSelectable(this.domElement, false); + + // Are we supposed to be loading locally? + if (SUPPORTS_LOCAL_STORAGE) { + + if (use_local_storage) { + + _this.useLocalStorage = true; + + var saved_gui = localStorage.getItem(getLocalStorageHash(this, 'gui')); + + if (saved_gui) { + params.load = JSON.parse(saved_gui); + } + + } + + } + + this.__closeButton = document.createElement('div'); + this.__closeButton.innerHTML = GUI.TEXT_CLOSED; + dom.addClass(this.__closeButton, GUI.CLASS_CLOSE_BUTTON); + this.domElement.appendChild(this.__closeButton); + + dom.bind(this.__closeButton, 'click', function() { + + _this.closed = !_this.closed; + + + }); + + + // Oh, you're a nested GUI! + } else { + + if (params.closed === undefined) { + params.closed = true; + } + + var title_row_name = document.createTextNode(params.name); + dom.addClass(title_row_name, 'controller-name'); + + var title_row = addRow(_this, title_row_name); + + var on_click_title = function(e) { + e.preventDefault(); + _this.closed = !_this.closed; + return false; + }; + + dom.addClass(this.__ul, GUI.CLASS_CLOSED); + + dom.addClass(title_row, 'title'); + dom.bind(title_row, 'click', on_click_title); + + if (!params.closed) { + this.closed = false; + } + + } + + if (params.autoPlace) { + + if (common.isUndefined(params.parent)) { + + if (auto_place_virgin) { + auto_place_container = document.createElement('div'); + dom.addClass(auto_place_container, CSS_NAMESPACE); + dom.addClass(auto_place_container, GUI.CLASS_AUTO_PLACE_CONTAINER); + document.body.appendChild(auto_place_container); + auto_place_virgin = false; + } + + // Put it in the dom for you. + auto_place_container.appendChild(this.domElement); + + // Apply the auto styles + dom.addClass(this.domElement, GUI.CLASS_AUTO_PLACE); + + } + + + // Make it not elastic. + if (!this.parent) setWidth(_this, params.width); + + } + + dom.bind(window, 'resize', function() { _this.onResize() }); + dom.bind(this.__ul, 'webkitTransitionEnd', function() { _this.onResize(); }); + dom.bind(this.__ul, 'transitionend', function() { _this.onResize() }); + dom.bind(this.__ul, 'oTransitionEnd', function() { _this.onResize() }); + this.onResize(); + + + if (params.resizable) { + addResizeHandle(this); + } + + function saveToLocalStorage() { + localStorage.setItem(getLocalStorageHash(_this, 'gui'), JSON.stringify(_this.getSaveObject())); + } + + var root = _this.getRoot(); + function resetWidth() { + var root = _this.getRoot(); + root.width += 1; + common.defer(function() { + root.width -= 1; + }); + } + + if (!params.parent) { + resetWidth(); + } + + }; + + GUI.toggleHide = function() { + + hide = !hide; + common.each(hideable_guis, function(gui) { + gui.domElement.style.zIndex = hide ? -999 : 999; + gui.domElement.style.opacity = hide ? 0 : 1; + }); + }; + + GUI.CLASS_AUTO_PLACE = 'a'; + GUI.CLASS_AUTO_PLACE_CONTAINER = 'ac'; + GUI.CLASS_MAIN = 'main'; + GUI.CLASS_CONTROLLER_ROW = 'cr'; + GUI.CLASS_TOO_TALL = 'taller-than-window'; + GUI.CLASS_CLOSED = 'closed'; + GUI.CLASS_CLOSE_BUTTON = 'close-button'; + GUI.CLASS_DRAG = 'drag'; + + GUI.DEFAULT_WIDTH = 245; + GUI.TEXT_CLOSED = 'Close Controls'; + GUI.TEXT_OPEN = 'Open Controls'; + + dom.bind(window, 'keydown', function(e) { + + if (document.activeElement.type !== 'text' && + (e.which === HIDE_KEY_CODE || e.keyCode == HIDE_KEY_CODE)) { + GUI.toggleHide(); + } + + }, false); + + common.extend( + + GUI.prototype, + + /** @lends dat.gui.GUI */ + { + + /** + * @param object + * @param property + * @returns {dat.controllers.Controller} The new controller that was added. + * @instance + */ + add: function(object, property) { + + return add( + this, + object, + property, + { + factoryArgs: Array.prototype.slice.call(arguments, 2) + } + ); + + }, + + /** + * @param object + * @param property + * @returns {dat.controllers.ColorController} The new controller that was added. + * @instance + */ + addColor: function(object, property) { + + return add( + this, + object, + property, + { + color: true + } + ); + + }, + + /** + * @param controller + * @instance + */ + remove: function(controller) { + + // TODO listening? + this.__ul.removeChild(controller.__li); + this.__controllers.slice(this.__controllers.indexOf(controller), 1); + var _this = this; + common.defer(function() { + _this.onResize(); + }); + + }, + + destroy: function() { + + if (this.autoPlace) { + auto_place_container.removeChild(this.domElement); + } + + }, + + /** + * @param name + * @returns {dat.gui.GUI} The new folder. + * @throws {Error} if this GUI already has a folder by the specified + * name + * @instance + */ + addFolder: function(name) { + + // We have to prevent collisions on names in order to have a key + // by which to remember saved values + if (this.__folders[name] !== undefined) { + throw new Error('You already have a folder in this GUI by the' + + ' name "' + name + '"'); + } + + var new_gui_params = { name: name, parent: this }; + + // We need to pass down the autoPlace trait so that we can + // attach event listeners to open/close folder actions to + // ensure that a scrollbar appears if the window is too short. + new_gui_params.autoPlace = this.autoPlace; + + // Do we have saved appearance data for this folder? + + if (this.load && // Anything loaded? + this.load.folders && // Was my parent a dead-end? + this.load.folders[name]) { // Did daddy remember me? + + // Start me closed if I was closed + new_gui_params.closed = this.load.folders[name].closed; + + // Pass down the loaded data + new_gui_params.load = this.load.folders[name]; + + } + + var gui = new GUI(new_gui_params); + this.__folders[name] = gui; + + var li = addRow(this, gui.domElement); + dom.addClass(li, 'folder'); + return gui; + + }, + + open: function() { + this.closed = false; + }, + + close: function() { + this.closed = true; + }, + + onResize: function() { + + var root = this.getRoot(); + + if (root.scrollable) { + + var top = dom.getOffset(root.__ul).top; + var h = 0; + + common.each(root.__ul.childNodes, function(node) { + if (! (root.autoPlace && node === root.__save_row)) + h += dom.getHeight(node); + }); + + if (window.innerHeight - top - CLOSE_BUTTON_HEIGHT < h) { + dom.addClass(root.domElement, GUI.CLASS_TOO_TALL); + root.__ul.style.height = window.innerHeight - top - CLOSE_BUTTON_HEIGHT + 'px'; + } else { + dom.removeClass(root.domElement, GUI.CLASS_TOO_TALL); + root.__ul.style.height = 'auto'; + } + + } + + if (root.__resize_handle) { + common.defer(function() { + root.__resize_handle.style.height = root.__ul.offsetHeight + 'px'; + }); + } + + if (root.__closeButton) { + root.__closeButton.style.width = root.width + 'px'; + } + + }, + + /** + * Mark objects for saving. The order of these objects cannot change as + * the GUI grows. When remembering new objects, append them to the end + * of the list. + * + * @param {Object...} objects + * @throws {Error} if not called on a top level GUI. + * @instance + */ + remember: function() { + + if (common.isUndefined(SAVE_DIALOGUE)) { + SAVE_DIALOGUE = new CenteredDiv(); + SAVE_DIALOGUE.domElement.innerHTML = saveDialogueContents; + } + + if (this.parent) { + throw new Error("You can only call remember on a top level GUI."); + } + + var _this = this; + + common.each(Array.prototype.slice.call(arguments), function(object) { + if (_this.__rememberedObjects.length == 0) { + addSaveMenu(_this); + } + if (_this.__rememberedObjects.indexOf(object) == -1) { + _this.__rememberedObjects.push(object); + } + }); + + if (this.autoPlace) { + // Set save row width + setWidth(this, this.width); + } + + }, + + /** + * @returns {dat.gui.GUI} the topmost parent GUI of a nested GUI. + * @instance + */ + getRoot: function() { + var gui = this; + while (gui.parent) { + gui = gui.parent; + } + return gui; + }, + + /** + * @returns {Object} a JSON object representing the current state of + * this GUI as well as its remembered properties. + * @instance + */ + getSaveObject: function() { + + var toReturn = this.load; + + toReturn.closed = this.closed; + + // Am I remembering any values? + if (this.__rememberedObjects.length > 0) { + + toReturn.preset = this.preset; + + if (!toReturn.remembered) { + toReturn.remembered = {}; + } + + toReturn.remembered[this.preset] = getCurrentPreset(this); + + } + + toReturn.folders = {}; + common.each(this.__folders, function(element, key) { + toReturn.folders[key] = element.getSaveObject(); + }); + + return toReturn; + + }, + + save: function() { + + if (!this.load.remembered) { + this.load.remembered = {}; + } + + this.load.remembered[this.preset] = getCurrentPreset(this); + markPresetModified(this, false); + + }, + + saveAs: function(presetName) { + + if (!this.load.remembered) { + + // Retain default values upon first save + this.load.remembered = {}; + this.load.remembered[DEFAULT_DEFAULT_PRESET_NAME] = getCurrentPreset(this, true); + + } + + this.load.remembered[presetName] = getCurrentPreset(this); + this.preset = presetName; + addPresetOption(this, presetName, true); + + }, + + revert: function(gui) { + + common.each(this.__controllers, function(controller) { + // Make revert work on Default. + if (!this.getRoot().load.remembered) { + controller.setValue(controller.initialValue); + } else { + recallSavedValue(gui || this.getRoot(), controller); + } + }, this); + + common.each(this.__folders, function(folder) { + folder.revert(folder); + }); + + if (!gui) { + markPresetModified(this.getRoot(), false); + } + + + }, + + listen: function(controller) { + + var init = this.__listening.length == 0; + this.__listening.push(controller); + if (init) updateDisplays(this.__listening); + + } + + } + + ); + + function add(gui, object, property, params) { + + if (object[property] === undefined) { + throw new Error("Object " + object + " has no property \"" + property + "\""); + } + + var controller; + + if (params.color) { + + controller = new ColorController(object, property); + + } else { + + var factoryArgs = [object,property].concat(params.factoryArgs); + controller = controllerFactory.apply(gui, factoryArgs); + + } + + if (params.before instanceof Controller) { + params.before = params.before.__li; + } + + recallSavedValue(gui, controller); + + dom.addClass(controller.domElement, 'c'); + + var name = document.createElement('span'); + dom.addClass(name, 'property-name'); + name.innerHTML = controller.property; + + var container = document.createElement('div'); + container.appendChild(name); + container.appendChild(controller.domElement); + + var li = addRow(gui, container, params.before); + + dom.addClass(li, GUI.CLASS_CONTROLLER_ROW); + + if (params.color) { + dom.addClass(li, 'string'); + } else { + dom.addClass(li, typeof controller.getValue()); + } + + augmentController(gui, li, controller); + + gui.__controllers.push(controller); + + return controller; + + } + + /** + * Add a row to the end of the GUI or before another row. + * + * @param gui + * @param [dom] If specified, inserts the dom content in the new row + * @param [liBefore] If specified, places the new row before another row + */ + function addRow(gui, dom, liBefore) { + var li = document.createElement('li'); + if (dom) li.appendChild(dom); + if (liBefore) { + gui.__ul.insertBefore(li, params.before); + } else { + gui.__ul.appendChild(li); + } + gui.onResize(); + return li; + } + + function augmentController(gui, li, controller) { + + controller.__li = li; + controller.__gui = gui; + + common.extend(controller, { + + options: function(options) { + + if (arguments.length > 1) { + controller.remove(); + + return add( + gui, + controller.object, + controller.property, + { + before: controller.__li.nextElementSibling, + factoryArgs: [common.toArray(arguments)] + } + ); + + } + + if (common.isArray(options) || common.isObject(options)) { + controller.remove(); + + return add( + gui, + controller.object, + controller.property, + { + before: controller.__li.nextElementSibling, + factoryArgs: [options] + } + ); + + } + + }, + + name: function(v) { + controller.__li.firstElementChild.firstElementChild.innerHTML = v; + return controller; + }, + + listen: function() { + controller.__gui.listen(controller); + return controller; + }, + + remove: function() { + controller.__gui.remove(controller); + return controller; + } + + }); + + // All sliders should be accompanied by a box. + if (controller instanceof NumberControllerSlider) { + + var box = new NumberControllerBox(controller.object, controller.property, + { min: controller.__min, max: controller.__max, step: controller.__step }); + + common.each(['updateDisplay', 'onChange', 'onFinishChange'], function(method) { + var pc = controller[method]; + var pb = box[method]; + controller[method] = box[method] = function() { + var args = Array.prototype.slice.call(arguments); + pc.apply(controller, args); + return pb.apply(box, args); + } + }); + + dom.addClass(li, 'has-slider'); + controller.domElement.insertBefore(box.domElement, controller.domElement.firstElementChild); + + } + else if (controller instanceof NumberControllerBox) { + + var r = function(returned) { + + // Have we defined both boundaries? + if (common.isNumber(controller.__min) && common.isNumber(controller.__max)) { + + // Well, then lets just replace this with a slider. + controller.remove(); + return add( + gui, + controller.object, + controller.property, + { + before: controller.__li.nextElementSibling, + factoryArgs: [controller.__min, controller.__max, controller.__step] + }); + + } + + return returned; + + }; + + controller.min = common.compose(r, controller.min); + controller.max = common.compose(r, controller.max); + + } + else if (controller instanceof BooleanController) { + + dom.bind(li, 'click', function() { + dom.fakeEvent(controller.__checkbox, 'click'); + }); + + dom.bind(controller.__checkbox, 'click', function(e) { + e.stopPropagation(); // Prevents double-toggle + }) + + } + else if (controller instanceof FunctionController) { + + dom.bind(li, 'click', function() { + dom.fakeEvent(controller.__button, 'click'); + }); + + dom.bind(li, 'mouseover', function() { + dom.addClass(controller.__button, 'hover'); + }); + + dom.bind(li, 'mouseout', function() { + dom.removeClass(controller.__button, 'hover'); + }); + + } + else if (controller instanceof ColorController) { + + dom.addClass(li, 'color'); + controller.updateDisplay = common.compose(function(r) { + li.style.borderLeftColor = controller.__color.toString(); + return r; + }, controller.updateDisplay); + + controller.updateDisplay(); + + } + + controller.setValue = common.compose(function(r) { + if (gui.getRoot().__preset_select && controller.isModified()) { + markPresetModified(gui.getRoot(), true); + } + return r; + }, controller.setValue); + + } + + function recallSavedValue(gui, controller) { + + // Find the topmost GUI, that's where remembered objects live. + var root = gui.getRoot(); + + // Does the object we're controlling match anything we've been told to + // remember? + var matched_index = root.__rememberedObjects.indexOf(controller.object); + + // Why yes, it does! + if (matched_index != -1) { + + // Let me fetch a map of controllers for thcommon.isObject. + var controller_map = + root.__rememberedObjectIndecesToControllers[matched_index]; + + // Ohp, I believe this is the first controller we've created for this + // object. Lets make the map fresh. + if (controller_map === undefined) { + controller_map = {}; + root.__rememberedObjectIndecesToControllers[matched_index] = + controller_map; + } + + // Keep track of this controller + controller_map[controller.property] = controller; + + // Okay, now have we saved any values for this controller? + if (root.load && root.load.remembered) { + + var preset_map = root.load.remembered; + + // Which preset are we trying to load? + var preset; + + if (preset_map[gui.preset]) { + + preset = preset_map[gui.preset]; + + } else if (preset_map[DEFAULT_DEFAULT_PRESET_NAME]) { + + // Uhh, you can have the default instead? + preset = preset_map[DEFAULT_DEFAULT_PRESET_NAME]; + + } else { + + // Nada. + + return; + + } + + + // Did the loaded object remember thcommon.isObject? + if (preset[matched_index] && + + // Did we remember this particular property? + preset[matched_index][controller.property] !== undefined) { + + // We did remember something for this guy ... + var value = preset[matched_index][controller.property]; + + // And that's what it is. + controller.initialValue = value; + controller.setValue(value); + + } + + } + + } + + } + + function getLocalStorageHash(gui, key) { + // TODO how does this deal with multiple GUI's? + return document.location.href + '.' + key; + + } + + function addSaveMenu(gui) { + + var div = gui.__save_row = document.createElement('li'); + + dom.addClass(gui.domElement, 'has-save'); + + gui.__ul.insertBefore(div, gui.__ul.firstChild); + + dom.addClass(div, 'save-row'); + + var gears = document.createElement('span'); + gears.innerHTML = ' '; + dom.addClass(gears, 'button gears'); + + // TODO replace with FunctionController + var button = document.createElement('span'); + button.innerHTML = 'Save'; + dom.addClass(button, 'button'); + dom.addClass(button, 'save'); + + var button2 = document.createElement('span'); + button2.innerHTML = 'New'; + dom.addClass(button2, 'button'); + dom.addClass(button2, 'save-as'); + + var button3 = document.createElement('span'); + button3.innerHTML = 'Revert'; + dom.addClass(button3, 'button'); + dom.addClass(button3, 'revert'); + + var select = gui.__preset_select = document.createElement('select'); + + if (gui.load && gui.load.remembered) { + + common.each(gui.load.remembered, function(value, key) { + addPresetOption(gui, key, key == gui.preset); + }); + + } else { + addPresetOption(gui, DEFAULT_DEFAULT_PRESET_NAME, false); + } + + dom.bind(select, 'change', function() { + + + for (var index = 0; index < gui.__preset_select.length; index++) { + gui.__preset_select[index].innerHTML = gui.__preset_select[index].value; + } + + gui.preset = this.value; + + }); + + div.appendChild(select); + div.appendChild(gears); + div.appendChild(button); + div.appendChild(button2); + div.appendChild(button3); + + if (SUPPORTS_LOCAL_STORAGE) { + + var saveLocally = document.getElementById('dg-save-locally'); + var explain = document.getElementById('dg-local-explain'); + + saveLocally.style.display = 'block'; + + var localStorageCheckBox = document.getElementById('dg-local-storage'); + + if (localStorage.getItem(getLocalStorageHash(gui, 'isLocal')) === 'true') { + localStorageCheckBox.setAttribute('checked', 'checked'); + } + + function showHideExplain() { + explain.style.display = gui.useLocalStorage ? 'block' : 'none'; + } + + showHideExplain(); + + // TODO: Use a boolean controller, fool! + dom.bind(localStorageCheckBox, 'change', function() { + gui.useLocalStorage = !gui.useLocalStorage; + showHideExplain(); + }); + + } + + var newConstructorTextArea = document.getElementById('dg-new-constructor'); + + dom.bind(newConstructorTextArea, 'keydown', function(e) { + if (e.metaKey && (e.which === 67 || e.keyCode == 67)) { + SAVE_DIALOGUE.hide(); + } + }); + + dom.bind(gears, 'click', function() { + newConstructorTextArea.innerHTML = JSON.stringify(gui.getSaveObject(), undefined, 2); + SAVE_DIALOGUE.show(); + newConstructorTextArea.focus(); + newConstructorTextArea.select(); + }); + + dom.bind(button, 'click', function() { + gui.save(); + }); + + dom.bind(button2, 'click', function() { + var presetName = prompt('Enter a new preset name.'); + if (presetName) gui.saveAs(presetName); + }); + + dom.bind(button3, 'click', function() { + gui.revert(); + }); + +// div.appendChild(button2); + + } + + function addResizeHandle(gui) { + + gui.__resize_handle = document.createElement('div'); + + common.extend(gui.__resize_handle.style, { + + width: '6px', + marginLeft: '-3px', + height: '200px', + cursor: 'ew-resize', + position: 'absolute' +// border: '1px solid blue' + + }); + + var pmouseX; + + dom.bind(gui.__resize_handle, 'mousedown', dragStart); + dom.bind(gui.__closeButton, 'mousedown', dragStart); + + gui.domElement.insertBefore(gui.__resize_handle, gui.domElement.firstElementChild); + + function dragStart(e) { + + e.preventDefault(); + + pmouseX = e.clientX; + + dom.addClass(gui.__closeButton, GUI.CLASS_DRAG); + dom.bind(window, 'mousemove', drag); + dom.bind(window, 'mouseup', dragStop); + + return false; + + } + + function drag(e) { + + e.preventDefault(); + + gui.width += pmouseX - e.clientX; + gui.onResize(); + pmouseX = e.clientX; + + return false; + + } + + function dragStop() { + + dom.removeClass(gui.__closeButton, GUI.CLASS_DRAG); + dom.unbind(window, 'mousemove', drag); + dom.unbind(window, 'mouseup', dragStop); + + } + + } + + function setWidth(gui, w) { + gui.domElement.style.width = w + 'px'; + // Auto placed save-rows are position fixed, so we have to + // set the width manually if we want it to bleed to the edge + if (gui.__save_row && gui.autoPlace) { + gui.__save_row.style.width = w + 'px'; + }if (gui.__closeButton) { + gui.__closeButton.style.width = w + 'px'; + } + } + + function getCurrentPreset(gui, useInitialValues) { + + var toReturn = {}; + + // For each object I'm remembering + common.each(gui.__rememberedObjects, function(val, index) { + + var saved_values = {}; + + // The controllers I've made for thcommon.isObject by property + var controller_map = + gui.__rememberedObjectIndecesToControllers[index]; + + // Remember each value for each property + common.each(controller_map, function(controller, property) { + saved_values[property] = useInitialValues ? controller.initialValue : controller.getValue(); + }); + + // Save the values for thcommon.isObject + toReturn[index] = saved_values; + + }); + + return toReturn; + + } + + function addPresetOption(gui, name, setSelected) { + var opt = document.createElement('option'); + opt.innerHTML = name; + opt.value = name; + gui.__preset_select.appendChild(opt); + if (setSelected) { + gui.__preset_select.selectedIndex = gui.__preset_select.length - 1; + } + } + + function setPresetSelectIndex(gui) { + for (var index = 0; index < gui.__preset_select.length; index++) { + if (gui.__preset_select[index].value == gui.preset) { + gui.__preset_select.selectedIndex = index; + } + } + } + + function markPresetModified(gui, modified) { + var opt = gui.__preset_select[gui.__preset_select.selectedIndex]; +// console.log('mark', modified, opt); + if (modified) { + opt.innerHTML = opt.value + "*"; + } else { + opt.innerHTML = opt.value; + } + } + + function updateDisplays(controllerArray) { + + + if (controllerArray.length != 0) { + + requestAnimationFrame(function() { + updateDisplays(controllerArray); + }); + + } + + common.each(controllerArray, function(c) { + c.updateDisplay(); + }); + + } + + return GUI; + +})(dat.utils.css, +"
\n\n Here's the new load parameter for your GUI's constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI's constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n \n
\n \n
\n\n
", +".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity 0.1s linear;-o-transition:opacity 0.1s linear;-moz-transition:opacity 0.1s linear;transition:opacity 0.1s linear;border:0;position:absolute;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-x:hidden}.dg.a.has-save ul{margin-top:27px}.dg.a.has-save ul.closed{margin-top:0}.dg.a .save-row{position:fixed;top:0;z-index:1002}.dg li{-webkit-transition:height 0.1s ease-out;-o-transition:height 0.1s ease-out;-moz-transition:height 0.1s ease-out;transition:height 0.1s ease-out}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;overflow:hidden;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li > *{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:9px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2fa1d6}.dg .cr.number input[type=text]{color:#2fa1d6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2fa1d6}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n", +dat.controllers.factory = (function (OptionController, NumberControllerBox, NumberControllerSlider, StringController, FunctionController, BooleanController, common) { + + return function(object, property) { + + var initialValue = object[property]; + + // Providing options? + if (common.isArray(arguments[2]) || common.isObject(arguments[2])) { + return new OptionController(object, property, arguments[2]); + } + + // Providing a map? + + if (common.isNumber(initialValue)) { + + if (common.isNumber(arguments[2]) && common.isNumber(arguments[3])) { + + // Has min and max. + return new NumberControllerSlider(object, property, arguments[2], arguments[3]); + + } else { + + return new NumberControllerBox(object, property, { min: arguments[2], max: arguments[3] }); + + } + + } + + if (common.isString(initialValue)) { + return new StringController(object, property); + } + + if (common.isFunction(initialValue)) { + return new FunctionController(object, property, ''); + } + + if (common.isBoolean(initialValue)) { + return new BooleanController(object, property); + } + + } + + })(dat.controllers.OptionController, +dat.controllers.NumberControllerBox, +dat.controllers.NumberControllerSlider, +dat.controllers.StringController = (function (Controller, dom, common) { + + /** + * @class Provides a text input to alter the string property of an object. + * + * @extends dat.controllers.Controller + * + * @param {Object} object The object to be manipulated + * @param {string} property The name of the property to be manipulated + * + * @member dat.controllers + */ + var StringController = function(object, property) { + + StringController.superclass.call(this, object, property); + + var _this = this; + + this.__input = document.createElement('input'); + this.__input.setAttribute('type', 'text'); + + dom.bind(this.__input, 'keyup', onChange); + dom.bind(this.__input, 'change', onChange); + dom.bind(this.__input, 'blur', onBlur); + dom.bind(this.__input, 'keydown', function(e) { + if (e.keyCode === 13) { + this.blur(); + } + }); + + + function onChange() { + _this.setValue(_this.__input.value); + } + + function onBlur() { + if (_this.__onFinishChange) { + _this.__onFinishChange.call(_this, _this.getValue()); + } + } + + this.updateDisplay(); + + this.domElement.appendChild(this.__input); + + }; + + StringController.superclass = Controller; + + common.extend( + + StringController.prototype, + Controller.prototype, + + { + + updateDisplay: function() { + // Stops the caret from moving on account of: + // keyup -> setValue -> updateDisplay + if (!dom.isActive(this.__input)) { + this.__input.value = this.getValue(); + } + return StringController.superclass.prototype.updateDisplay.call(this); + } + + } + + ); + + return StringController; + +})(dat.controllers.Controller, +dat.dom.dom, +dat.utils.common), +dat.controllers.FunctionController, +dat.controllers.BooleanController, +dat.utils.common), +dat.controllers.Controller, +dat.controllers.BooleanController, +dat.controllers.FunctionController, +dat.controllers.NumberControllerBox, +dat.controllers.NumberControllerSlider, +dat.controllers.OptionController, +dat.controllers.ColorController = (function (Controller, dom, Color, interpret, common) { + + var ColorController = function(object, property) { + + ColorController.superclass.call(this, object, property); + + this.__color = new Color(this.getValue()); + this.__temp = new Color(0); + + var _this = this; + + this.domElement = document.createElement('div'); + + dom.makeSelectable(this.domElement, false); + + this.__selector = document.createElement('div'); + this.__selector.className = 'selector'; + + this.__saturation_field = document.createElement('div'); + this.__saturation_field.className = 'saturation-field'; + + this.__field_knob = document.createElement('div'); + this.__field_knob.className = 'field-knob'; + this.__field_knob_border = '2px solid '; + + this.__hue_knob = document.createElement('div'); + this.__hue_knob.className = 'hue-knob'; + + this.__hue_field = document.createElement('div'); + this.__hue_field.className = 'hue-field'; + + this.__input = document.createElement('input'); + this.__input.type = 'text'; + this.__input_textShadow = '0 1px 1px '; + + dom.bind(this.__input, 'keydown', function(e) { + if (e.keyCode === 13) { // on enter + onBlur.call(this); + } + }); + + dom.bind(this.__input, 'blur', onBlur); + + dom.bind(this.__selector, 'mousedown', function(e) { + + dom + .addClass(this, 'drag') + .bind(window, 'mouseup', function(e) { + dom.removeClass(_this.__selector, 'drag'); + }); + + }); + + var value_field = document.createElement('div'); + + common.extend(this.__selector.style, { + width: '122px', + height: '102px', + padding: '3px', + backgroundColor: '#222', + boxShadow: '0px 1px 3px rgba(0,0,0,0.3)' + }); + + common.extend(this.__field_knob.style, { + position: 'absolute', + width: '12px', + height: '12px', + border: this.__field_knob_border + (this.__color.v < .5 ? '#fff' : '#000'), + boxShadow: '0px 1px 3px rgba(0,0,0,0.5)', + borderRadius: '12px', + zIndex: 1 + }); + + common.extend(this.__hue_knob.style, { + position: 'absolute', + width: '15px', + height: '2px', + borderRight: '4px solid #fff', + zIndex: 1 + }); + + common.extend(this.__saturation_field.style, { + width: '100px', + height: '100px', + border: '1px solid #555', + marginRight: '3px', + display: 'inline-block', + cursor: 'pointer' + }); + + common.extend(value_field.style, { + width: '100%', + height: '100%', + background: 'none' + }); + + linearGradient(value_field, 'top', 'rgba(0,0,0,0)', '#000'); + + common.extend(this.__hue_field.style, { + width: '15px', + height: '100px', + display: 'inline-block', + border: '1px solid #555', + cursor: 'ns-resize' + }); + + hueGradient(this.__hue_field); + + common.extend(this.__input.style, { + outline: 'none', +// width: '120px', + textAlign: 'center', +// padding: '4px', +// marginBottom: '6px', + color: '#fff', + border: 0, + fontWeight: 'bold', + textShadow: this.__input_textShadow + 'rgba(0,0,0,0.7)' + }); + + dom.bind(this.__saturation_field, 'mousedown', fieldDown); + dom.bind(this.__field_knob, 'mousedown', fieldDown); + + dom.bind(this.__hue_field, 'mousedown', function(e) { + setH(e); + dom.bind(window, 'mousemove', setH); + dom.bind(window, 'mouseup', unbindH); + }); + + function fieldDown(e) { + setSV(e); + // document.body.style.cursor = 'none'; + dom.bind(window, 'mousemove', setSV); + dom.bind(window, 'mouseup', unbindSV); + } + + function unbindSV() { + dom.unbind(window, 'mousemove', setSV); + dom.unbind(window, 'mouseup', unbindSV); + // document.body.style.cursor = 'default'; + } + + function onBlur() { + var i = interpret(this.value); + if (i !== false) { + _this.__color.__state = i; + _this.setValue(_this.__color.toOriginal()); + } else { + this.value = _this.__color.toString(); + } + } + + function unbindH() { + dom.unbind(window, 'mousemove', setH); + dom.unbind(window, 'mouseup', unbindH); + } + + this.__saturation_field.appendChild(value_field); + this.__selector.appendChild(this.__field_knob); + this.__selector.appendChild(this.__saturation_field); + this.__selector.appendChild(this.__hue_field); + this.__hue_field.appendChild(this.__hue_knob); + + this.domElement.appendChild(this.__input); + this.domElement.appendChild(this.__selector); + + this.updateDisplay(); + + function setSV(e) { + + e.preventDefault(); + + var w = dom.getWidth(_this.__saturation_field); + var o = dom.getOffset(_this.__saturation_field); + var s = (e.clientX - o.left + document.body.scrollLeft) / w; + var v = 1 - (e.clientY - o.top + document.body.scrollTop) / w; + + if (v > 1) v = 1; + else if (v < 0) v = 0; + + if (s > 1) s = 1; + else if (s < 0) s = 0; + + _this.__color.v = v; + _this.__color.s = s; + + _this.setValue(_this.__color.toOriginal()); + + + return false; + + } + + function setH(e) { + + e.preventDefault(); + + var s = dom.getHeight(_this.__hue_field); + var o = dom.getOffset(_this.__hue_field); + var h = 1 - (e.clientY - o.top + document.body.scrollTop) / s; + + if (h > 1) h = 1; + else if (h < 0) h = 0; + + _this.__color.h = h * 360; + + _this.setValue(_this.__color.toOriginal()); + + return false; + + } + + }; + + ColorController.superclass = Controller; + + common.extend( + + ColorController.prototype, + Controller.prototype, + + { + + updateDisplay: function() { + + var i = interpret(this.getValue()); + + if (i !== false) { + + var mismatch = false; + + // Check for mismatch on the interpreted value. + + common.each(Color.COMPONENTS, function(component) { + if (!common.isUndefined(i[component]) && + !common.isUndefined(this.__color.__state[component]) && + i[component] !== this.__color.__state[component]) { + mismatch = true; + return {}; // break + } + }, this); + + // If nothing diverges, we keep our previous values + // for statefulness, otherwise we recalculate fresh + if (mismatch) { + common.extend(this.__color.__state, i); + } + + } + + common.extend(this.__temp.__state, this.__color.__state); + + this.__temp.a = 1; + + var flip = (this.__color.v < .5 || this.__color.s > .5) ? 255 : 0; + var _flip = 255 - flip; + + common.extend(this.__field_knob.style, { + marginLeft: 100 * this.__color.s - 7 + 'px', + marginTop: 100 * (1 - this.__color.v) - 7 + 'px', + backgroundColor: this.__temp.toString(), + border: this.__field_knob_border + 'rgb(' + flip + ',' + flip + ',' + flip +')' + }); + + this.__hue_knob.style.marginTop = (1 - this.__color.h / 360) * 100 + 'px' + + this.__temp.s = 1; + this.__temp.v = 1; + + linearGradient(this.__saturation_field, 'left', '#fff', this.__temp.toString()); + + common.extend(this.__input.style, { + backgroundColor: this.__input.value = this.__color.toString(), + color: 'rgb(' + flip + ',' + flip + ',' + flip +')', + textShadow: this.__input_textShadow + 'rgba(' + _flip + ',' + _flip + ',' + _flip +',.7)' + }); + + } + + } + + ); + + var vendors = ['-moz-','-o-','-webkit-','-ms-','']; + + function linearGradient(elem, x, a, b) { + elem.style.background = ''; + common.each(vendors, function(vendor) { + elem.style.cssText += 'background: ' + vendor + 'linear-gradient('+x+', '+a+' 0%, ' + b + ' 100%); '; + }); + } + + function hueGradient(elem) { + elem.style.background = ''; + elem.style.cssText += 'background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);' + elem.style.cssText += 'background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);' + elem.style.cssText += 'background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);' + elem.style.cssText += 'background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);' + elem.style.cssText += 'background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);' + } + + + return ColorController; + +})(dat.controllers.Controller, +dat.dom.dom, +dat.color.Color = (function (interpret, math, toString, common) { + + var Color = function() { + + this.__state = interpret.apply(this, arguments); + + if (this.__state === false) { + throw 'Failed to interpret color arguments'; + } + + this.__state.a = this.__state.a || 1; + + + }; + + Color.COMPONENTS = ['r','g','b','h','s','v','hex','a']; + + common.extend(Color.prototype, { + + toString: function() { + return toString(this); + }, + + toOriginal: function() { + return this.__state.conversion.write(this); + } + + }); + + defineRGBComponent(Color.prototype, 'r', 2); + defineRGBComponent(Color.prototype, 'g', 1); + defineRGBComponent(Color.prototype, 'b', 0); + + defineHSVComponent(Color.prototype, 'h'); + defineHSVComponent(Color.prototype, 's'); + defineHSVComponent(Color.prototype, 'v'); + + Object.defineProperty(Color.prototype, 'a', { + + get: function() { + return this.__state.a; + }, + + set: function(v) { + this.__state.a = v; + } + + }); + + Object.defineProperty(Color.prototype, 'hex', { + + get: function() { + + if (!this.__state.space !== 'HEX') { + this.__state.hex = math.rgb_to_hex(this.r, this.g, this.b); + } + + return this.__state.hex; + + }, + + set: function(v) { + + this.__state.space = 'HEX'; + this.__state.hex = v; + + } + + }); + + function defineRGBComponent(target, component, componentHexIndex) { + + Object.defineProperty(target, component, { + + get: function() { + + if (this.__state.space === 'RGB') { + return this.__state[component]; + } + + recalculateRGB(this, component, componentHexIndex); + + return this.__state[component]; + + }, + + set: function(v) { + + if (this.__state.space !== 'RGB') { + recalculateRGB(this, component, componentHexIndex); + this.__state.space = 'RGB'; + } + + this.__state[component] = v; + + } + + }); + + } + + function defineHSVComponent(target, component) { + + Object.defineProperty(target, component, { + + get: function() { + + if (this.__state.space === 'HSV') + return this.__state[component]; + + recalculateHSV(this); + + return this.__state[component]; + + }, + + set: function(v) { + + if (this.__state.space !== 'HSV') { + recalculateHSV(this); + this.__state.space = 'HSV'; + } + + this.__state[component] = v; + + } + + }); + + } + + function recalculateRGB(color, component, componentHexIndex) { + + if (color.__state.space === 'HEX') { + + color.__state[component] = math.component_from_hex(color.__state.hex, componentHexIndex); + + } else if (color.__state.space === 'HSV') { + + common.extend(color.__state, math.hsv_to_rgb(color.__state.h, color.__state.s, color.__state.v)); + + } else { + + throw 'Corrupted color state'; + + } + + } + + function recalculateHSV(color) { + + var result = math.rgb_to_hsv(color.r, color.g, color.b); + + common.extend(color.__state, + { + s: result.s, + v: result.v + } + ); + + if (!common.isNaN(result.h)) { + color.__state.h = result.h; + } else if (common.isUndefined(color.__state.h)) { + color.__state.h = 0; + } + + } + + return Color; + +})(dat.color.interpret, +dat.color.math = (function () { + + var tmpComponent; + + return { + + hsv_to_rgb: function(h, s, v) { + + var hi = Math.floor(h / 60) % 6; + + var f = h / 60 - Math.floor(h / 60); + var p = v * (1.0 - s); + var q = v * (1.0 - (f * s)); + var t = v * (1.0 - ((1.0 - f) * s)); + var c = [ + [v, t, p], + [q, v, p], + [p, v, t], + [p, q, v], + [t, p, v], + [v, p, q] + ][hi]; + + return { + r: c[0] * 255, + g: c[1] * 255, + b: c[2] * 255 + }; + + }, + + rgb_to_hsv: function(r, g, b) { + + var min = Math.min(r, g, b), + max = Math.max(r, g, b), + delta = max - min, + h, s; + + if (max != 0) { + s = delta / max; + } else { + return { + h: NaN, + s: 0, + v: 0 + }; + } + + if (r == max) { + h = (g - b) / delta; + } else if (g == max) { + h = 2 + (b - r) / delta; + } else { + h = 4 + (r - g) / delta; + } + h /= 6; + if (h < 0) { + h += 1; + } + + return { + h: h * 360, + s: s, + v: max / 255 + }; + }, + + rgb_to_hex: function(r, g, b) { + var hex = this.hex_with_component(0, 2, r); + hex = this.hex_with_component(hex, 1, g); + hex = this.hex_with_component(hex, 0, b); + return hex; + }, + + component_from_hex: function(hex, componentIndex) { + return (hex >> (componentIndex * 8)) & 0xFF; + }, + + hex_with_component: function(hex, componentIndex, value) { + return value << (tmpComponent = componentIndex * 8) | (hex & ~ (0xFF << tmpComponent)); + } + + } + +})(), +dat.color.toString, +dat.utils.common), +dat.color.interpret, +dat.utils.common), +dat.utils.requestAnimationFrame = (function () { + + /** + * requirejs version of Paul Irish's RequestAnimationFrame + * http://paulirish.com/2011/requestanimationframe-for-smart-animating/ + */ + + return window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + function(callback, element) { + + window.setTimeout(callback, 1000 / 60); + + }; +})(), +dat.dom.CenteredDiv = (function (dom, common) { + + + var CenteredDiv = function() { + + this.backgroundElement = document.createElement('div'); + common.extend(this.backgroundElement.style, { + backgroundColor: 'rgba(0,0,0,0.8)', + top: 0, + left: 0, + display: 'none', + zIndex: '1000', + opacity: 0, + WebkitTransition: 'opacity 0.2s linear' + }); + + dom.makeFullscreen(this.backgroundElement); + this.backgroundElement.style.position = 'fixed'; + + this.domElement = document.createElement('div'); + common.extend(this.domElement.style, { + position: 'fixed', + display: 'none', + zIndex: '1001', + opacity: 0, + WebkitTransition: '-webkit-transform 0.2s ease-out, opacity 0.2s linear' + }); + + + document.body.appendChild(this.backgroundElement); + document.body.appendChild(this.domElement); + + var _this = this; + dom.bind(this.backgroundElement, 'click', function() { + _this.hide(); + }); + + + }; + + CenteredDiv.prototype.show = function() { + + var _this = this; + + + + this.backgroundElement.style.display = 'block'; + + this.domElement.style.display = 'block'; + this.domElement.style.opacity = 0; +// this.domElement.style.top = '52%'; + this.domElement.style.webkitTransform = 'scale(1.1)'; + + this.layout(); + + common.defer(function() { + _this.backgroundElement.style.opacity = 1; + _this.domElement.style.opacity = 1; + _this.domElement.style.webkitTransform = 'scale(1)'; + }); + + }; + + CenteredDiv.prototype.hide = function() { + + var _this = this; + + var hide = function() { + + _this.domElement.style.display = 'none'; + _this.backgroundElement.style.display = 'none'; + + dom.unbind(_this.domElement, 'webkitTransitionEnd', hide); + dom.unbind(_this.domElement, 'transitionend', hide); + dom.unbind(_this.domElement, 'oTransitionEnd', hide); + + }; + + dom.bind(this.domElement, 'webkitTransitionEnd', hide); + dom.bind(this.domElement, 'transitionend', hide); + dom.bind(this.domElement, 'oTransitionEnd', hide); + + this.backgroundElement.style.opacity = 0; +// this.domElement.style.top = '48%'; + this.domElement.style.opacity = 0; + this.domElement.style.webkitTransform = 'scale(1.1)'; + + }; + + CenteredDiv.prototype.layout = function() { + this.domElement.style.left = window.innerWidth/2 - dom.getWidth(this.domElement) / 2 + 'px'; + this.domElement.style.top = window.innerHeight/2 - dom.getHeight(this.domElement) / 2 + 'px'; + }; + + function lockScroll(e) { + console.log(e); + } + + return CenteredDiv; + +})(dat.dom.dom, +dat.utils.common), +dat.dom.dom, +dat.utils.common); -- 2.47.1