dat.gui/build/dat.gui.min.js

97 lines
48 KiB
JavaScript
Raw Normal View History

/**
* dat-gui JavaScript Controller Library
* http://code.google.com/p/dat-gui
*
* Copyright 2011 Data Arts Team, Google Creative Lab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
var dat=dat||{};dat.gui=dat.gui||{};dat.utils=dat.utils||{};dat.controllers=dat.controllers||{};dat.dom=dat.dom||{};dat.color=dat.color||{};dat.utils.css=function(){return{load:function(d,a){a=a||document;var c=a.createElement("link");c.type="text/css";c.rel="stylesheet";c.href=d;a.getElementsByTagName("head")[0].appendChild(c)},inject:function(d,a){a=a||document;var c=document.createElement("style");c.type="text/css";c.innerHTML=d;a.getElementsByTagName("head")[0].appendChild(c)}}}();
dat.utils.common=function(){var d=Array.prototype.forEach,a=Array.prototype.slice;return{BREAK:{},extend:function(c){this.each(a.call(arguments,1),function(a){for(var f in a)this.isUndefined(a[f])||(c[f]=a[f])},this);return c},defaults:function(c){this.each(a.call(arguments,1),function(a){for(var f in a)this.isUndefined(c[f])&&(c[f]=a[f])},this);return c},compose:function(){var c=a.call(arguments);return function(){for(var b=a.call(arguments),f=c.length-1;0<=f;f--)b=[c[f].apply(this,b)];return b[0]}},
each:function(a,b,f){if(a)if(d&&a.forEach&&a.forEach===d)a.forEach(b,f);else if(a.length===a.length+0)for(var e=0,r=a.length;e<r&&!(e in a&&b.call(f,a[e],e)===this.BREAK);e++);else for(e in a)if(b.call(f,a[e],e)===this.BREAK)break},defer:function(a){setTimeout(a,0)},toArray:function(c){return c.toArray?c.toArray():a.call(c)},isUndefined:function(a){return void 0===a},isNull:function(a){return null===a},isNaN:function(a){return a!==a},isArray:Array.isArray||function(a){return a.constructor===Array},
isObject:function(a){return a===Object(a)},isNumber:function(a){return a===a+0},isString:function(a){return a===a+""},isBoolean:function(a){return!1===a||!0===a},isFunction:function(a){return"[object Function]"===Object.prototype.toString.call(a)},hasOwnProperty:function(a,b){var f=a.__proto__||a.constructor.prototype;return b in a&&(!(b in f)||f[b]!==a[b])}}}();
dat.controllers.Controller=function(d){var a=function(a,b){this.initialValue=a[b];this.domElement=document.createElement("div");this.object=a;this.property=b;this.__onFinishChange=this.__onChange=void 0};d.extend(a.prototype,{onChange:function(a){this.__onChange=a;return this},onFinishChange:function(a){this.__onFinishChange=a;return this},setValue:function(a){this.object[this.property]=a;this.__onChange&&this.__onChange.call(this,a);this.updateDisplay();return this},getValue:function(){return this.object[this.property]},
2013-12-18 23:27:02 +00:00
updateDisplay:function(){return this},isModified:function(){return this.initialValue!==this.getValue()}});return a}(dat.utils.common);
dat.dom.dom=function(d){function a(e){if("0"===e||d.isUndefined(e))return 0;e=e.match(b);return d.isNull(e)?0:parseFloat(e[1])}var c={};d.each({HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},function(e,a){d.each(e,function(e){c[e]=a})});var b=/(\d+(\.\d+)?)px/,f={makeSelectable:function(e,a){void 0!==e&&void 0!==e.style&&(e.onselectstart=a?function(){return!1}:function(){},e.style.MozUserSelect=a?"auto":"none",e.style.KhtmlUserSelect=
a?"auto":"none",e.unselectable=a?"on":"off")},makeFullscreen:function(e,a,f){d.isUndefined(a)&&(a=!0);d.isUndefined(f)&&(f=!0);e.style.position="absolute";a&&(e.style.left=0,e.style.right=0);f&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(a,f,b,k){b=b||{};var q=c[f];if(!q)throw Error("Event type "+f+" not supported.");var n=document.createEvent(q);switch(q){case "MouseEvents":n.initMouseEvent(f,b.bubbles||!1,b.cancelable||!0,window,b.clickCount||1,0,0,b.x||b.clientX||0,b.y||b.clientY||0,!1,
!1,!1,!1,0,null);break;case "KeyboardEvents":q=n.initKeyboardEvent||n.initKeyEvent;d.defaults(b,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0});q(f,b.bubbles||!1,b.cancelable,window,b.ctrlKey,b.altKey,b.shiftKey,b.metaKey,b.keyCode,b.charCode);break;default:n.initEvent(f,b.bubbles||!1,b.cancelable||!0)}d.defaults(n,k);a.dispatchEvent(n)},bind:function(a,b,c,d){a.addEventListener?a.addEventListener(b,c,d||!1):a.attachEvent&&a.attachEvent("on"+b,c);return f},
unbind:function(a,b,c,d){a.removeEventListener?a.removeEventListener(b,c,d||!1):a.detachEvent&&a.detachEvent("on"+b,c);return f},addClass:function(a,b){if(void 0===a.className)a.className=b;else if(a.className!==b){var c=a.className.split(/ +/);-1==c.indexOf(b)&&(c.push(b),a.className=c.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return f},removeClass:function(a,b){if(b){if(void 0!==a.className)if(a.className===b)a.removeAttribute("class");else{var c=a.className.split(/ +/),d=c.indexOf(b);-1!=
d&&(c.splice(d,1),a.className=c.join(" "))}}else a.className=void 0;return f},hasClass:function(a,b){return(new RegExp("(?:^|\\s+)"+b+"(?:\\s+|$)")).test(a.className)||!1},getWidth:function(e){e=getComputedStyle(e);return a(e["border-left-width"])+a(e["border-right-width"])+a(e["padding-left"])+a(e["padding-right"])+a(e.width)},getHeight:function(e){e=getComputedStyle(e);return a(e["border-top-width"])+a(e["border-bottom-width"])+a(e["padding-top"])+a(e["padding-bottom"])+a(e.height)},getOffset:function(a){var b=
{left:0,top:0};if(a.offsetParent){do b.left+=a.offsetLeft,b.top+=a.offsetTop;while(a=a.offsetParent)}return b},isActive:function(a){return a===document.activeElement&&(a.type||a.href)}};return f}(dat.utils.common);
dat.controllers.OptionController=function(d,a,c){var b=function(f,e,d){b.superclass.call(this,f,e);var l=this;this.__select=document.createElement("select");if(c.isArray(d)){var k={};c.each(d,function(a){k[a]=a});d=k}c.each(d,function(a,e){var b=document.createElement("option");b.innerHTML=e;b.setAttribute("value",a);l.__select.appendChild(b)});this.updateDisplay();a.bind(this.__select,"change",function(){l.setValue(this.options[this.selectedIndex].value)});this.domElement.appendChild(this.__select)};
b.superclass=d;c.extend(b.prototype,d.prototype,{setValue:function(a){a=b.superclass.prototype.setValue.call(this,a);this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue());return a},updateDisplay:function(){this.__select.value=this.getValue();return b.superclass.prototype.updateDisplay.call(this)}});return b}(dat.controllers.Controller,dat.dom.dom,dat.utils.common);
dat.controllers.NumberController=function(d,a){function c(a){a=a.toString();return-1<a.indexOf(".")?a.length-a.indexOf(".")-1:0}var b=function(f,e,d){b.superclass.call(this,f,e);d=d||{};this.__min=d.min;this.__max=d.max;this.__step=d.step;a.isUndefined(this.__step)?this.__impliedStep=0==this.initialValue?1:Math.pow(10,Math.floor(Math.log(Math.abs(this.initialValue))/Math.LN10))/10:this.__impliedStep=this.__step;this.__precision=c(this.__impliedStep)};b.superclass=d;a.extend(b.prototype,d.prototype,
{setValue:function(a){void 0!==this.__min&&a<this.__min?a=this.__min:void 0!==this.__max&&a>this.__max&&(a=this.__max);void 0!==this.__step&&0!=a%this.__step&&(a=Math.round(a/this.__step)*this.__step);return b.superclass.prototype.setValue.call(this,a)},min:function(a){this.__min=a;return this},max:function(a){this.__max=a;return this},step:function(a){this.__impliedStep=this.__step=a;this.__precision=c(a);return this}});return b}(dat.controllers.Controller,dat.utils.common);
dat.controllers.NumberControllerBox=function(d,a,c){var b=function(f,e,d){function l(){var a=parseFloat(n.__input.value);c.isNaN(a)||n.setValue(a)}function k(a){var e=v-a.clientY;n.setValue(n.getValue()+e*n.__impliedStep);v=a.clientY}function q(){a.unbind(window,"mousemove",k);a.unbind(window,"mouseup",q)}this.__truncationSuspended=!1;b.superclass.call(this,f,e,d);var n=this,v;this.__input=document.createElement("input");this.__input.setAttribute("type","text");a.bind(this.__input,"change",l);a.bind(this.__input,
"blur",function(){l();n.__onFinishChange&&n.__onFinishChange.call(n,n.getValue())});a.bind(this.__input,"mousedown",function(e){a.bind(window,"mousemove",k);a.bind(window,"mouseup",q);v=e.clientY});a.bind(this.__input,"keydown",function(a){13===a.keyCode&&(n.__truncationSuspended=!0,this.blur(),n.__truncationSuspended=!1)});this.updateDisplay();this.domElement.appendChild(this.__input)};b.superclass=d;c.extend(b.prototype,d.prototype,{updateDisplay:function(){if(!a.isActive(this.__input)){var c=this.__input,
e;if(this.__truncationSuspended)e=this.getValue();else{e=this.getValue();var d=Math.pow(10,this.__precision);e=Math.round(e*d)/d}c.value=e}return b.superclass.prototype.updateDisplay.call(this)}});return b}(dat.controllers.NumberController,dat.dom.dom,dat.utils.common);
dat.controllers.NumberControllerSlider=function(d,a,c,b,f){function e(a,e,b,c,f){return c+(a-e)/(b-e)*(f-c)}var r=function(b,c,f,d,v){function u(b){b.preventDefault();var c=a.getOffset(g.__background),f=a.getWidth(g.__background);g.setValue(e(b.clientX,c.left,c.left+f,g.__min,g.__max));return!1}function x(){a.unbind(window,"mousemove",u);a.unbind(window,"mouseup",x);g.__onFinishChange&&g.__onFinishChange.call(g,g.getValue())}r.superclass.call(this,b,c,{min:f,max:d,step:v});var g=this;this.__background=
document.createElement("div");this.__foreground=document.createElement("div");a.bind(this.__background,"mousedown",function(e){a.bind(window,"mousemove",u);a.bind(window,"mouseup",x);u(e)});a.addClass(this.__background,"slider");a.addClass(this.__foreground,"slider-fg");this.updateDisplay();this.__background.appendChild(this.__foreground);this.domElement.appendChild(this.__background)};r.superclass=d;r.useDefaultStyles=function(){c.inject(f)};b.extend(r.prototype,d.prototype,{updateDisplay:function(){var a=
(this.getValue()-this.__min)/(this.__max-this.__min);this.__foreground.style.width=100*a+"%";return r.superclass.prototype.updateDisplay.call(this)}});return r}(dat.controllers.NumberController,dat.dom.dom,dat.utils.css,dat.utils.common,"/**\n * dat-gui JavaScript Controller Library\n * http://code.google.com/p/dat-gui\n *\n * Copyright 2011 Data Arts Team, Google Creative Lab\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n */\n\n.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}\n");
dat.controllers.FunctionController=function(d,a,c){var b=function(c,e,d){b.superclass.call(this,c,e);var l=this;this.__button=document.createElement("div");this.__button.innerHTML=void 0===d?"Fire":d;a.bind(this.__button,"click",function(a){a.preventDefault();l.fire();return!1});a.addClass(this.__button,"button");this.domElement.appendChild(this.__button)};b.superclass=d;c.extend(b.prototype,d.prototype,{fire:function(){this.__onChange&&this.__onChange.call(this);this.getValue().call(this.object);
this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}});return b}(dat.controllers.Controller,dat.dom.dom,dat.utils.common);
dat.controllers.BooleanController=function(d,a,c){var b=function(c,e){b.superclass.call(this,c,e);var d=this;this.__prev=this.getValue();this.__checkbox=document.createElement("input");this.__checkbox.setAttribute("type","checkbox");a.bind(this.__checkbox,"change",function(){d.setValue(!d.__prev)},!1);this.domElement.appendChild(this.__checkbox);this.updateDisplay()};b.superclass=d;c.extend(b.prototype,d.prototype,{setValue:function(a){a=b.superclass.prototype.setValue.call(this,a);this.__onFinishChange&&
this.__onFinishChange.call(this,this.getValue());this.__prev=this.getValue();return a},updateDisplay:function(){!0===this.getValue()?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0):this.__checkbox.checked=!1;return b.superclass.prototype.updateDisplay.call(this)}});return b}(dat.controllers.Controller,dat.dom.dom,dat.utils.common);
dat.controllers.UndefinedController=function(d,a,c){var b=function(a,e){b.superclass.call(this,a,e);this.__input=document.createElement("input");this.__input.setAttribute("type","text");this.__input.setAttribute("disabled",!0);this.domElement.appendChild(this.__input)};b.superclass=d;c.extend(b.prototype,d.prototype,{updateDisplay:function(){this.__onFinishChange&&(c.isUndefined(this.object[this.property])||this.__onFinishChange.call(this.object[this.property]));return b.superclass.prototype.updateDisplay.call(this)}});
return b}(dat.controllers.Controller,dat.dom.dom,dat.utils.common);dat.color.toString=function(d){return function(a){if(1==a.a||d.isUndefined(a.a)){for(a=a.hex.toString(16);6>a.length;)a="0"+a;return"#"+a}return"rgba("+Math.round(a.r)+","+Math.round(a.g)+","+Math.round(a.b)+","+a.a+")"}}(dat.utils.common);
dat.color.interpret=function(d,a){var c,b,f=[{litmus:a.isString,conversions:{THREE_CHAR_HEX:{read:function(a){a=a.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null===a?!1:{space:"HEX",hex:parseInt("0x"+a[1].toString()+a[1].toString()+a[2].toString()+a[2].toString()+a[3].toString()+a[3].toString())}},write:d},SIX_CHAR_HEX:{read:function(a){a=a.match(/^#([A-F0-9]{6})$/i);return null===a?!1:{space:"HEX",hex:parseInt("0x"+a[1].toString())}},write:d},CSS_RGB:{read:function(a){a=a.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);
return null===a?!1:{space:"RGB",r:parseFloat(a[1]),g:parseFloat(a[2]),b:parseFloat(a[3])}},write:d},CSS_RGBA:{read:function(a){a=a.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\,\s*(.+)\s*\)/);return null===a?!1:{space:"RGB",r:parseFloat(a[1]),g:parseFloat(a[2]),b:parseFloat(a[3]),a:parseFloat(a[4])}},write:d}}},{litmus:a.isNumber,conversions:{HEX:{read:function(a){return{space:"HEX",hex:a,conversionName:"HEX"}},write:function(a){return a.hex}}}},{litmus:a.isArray,conversions:{RGB_ARRAY:{read:function(a){return 3!=
a.length?!1:{space:"RGB",r:a[0],g:a[1],b:a[2]}},write:function(a){return[a.r,a.g,a.b]}},RGBA_ARRAY:{read:function(a){return 4!=a.length?!1:{space:"RGB",r:a[0],g:a[1],b:a[2],a:a[3]}},write:function(a){return[a.r,a.g,a.b,a.a]}}}},{litmus:a.isObject,conversions:{RGBA_OBJ:{read:function(b){return a.isNumber(b.r)&&a.isNumber(b.g)&&a.isNumber(b.b)&&a.isNumber(b.a)?{space:"RGB",r:b.r,g:b.g,b:b.b,a:b.a}:!1},write:function(a){return{r:a.r,g:a.g,b:a.b,a:a.a}}},RGB_OBJ:{read:function(b){return a.isNumber(b.r)&&
a.isNumber(b.g)&&a.isNumber(b.b)?{space:"RGB",r:b.r,g:b.g,b:b.b}:!1},write:function(a){return{r:a.r,g:a.g,b:a.b}}},HSVA_OBJ:{read:function(b){return a.isNumber(b.h)&&a.isNumber(b.s)&&a.isNumber(b.v)&&a.isNumber(b.a)?{space:"HSV",h:b.h,s:b.s,v:b.v,a:b.a}:!1},write:function(a){return{h:a.h,s:a.s,v:a.v,a:a.a}}},HSV_OBJ:{read:function(b){return a.isNumber(b.h)&&a.isNumber(b.s)&&a.isNumber(b.v)?{space:"HSV",h:b.h,s:b.s,v:b.v}:!1},write:function(a){return{h:a.h,s:a.s,v:a.v}}}}}];return function(){b=!1;
var e=1<arguments.length?a.toArray(arguments):arguments[0];a.each(f,function(d){if(d.litmus(e))return a.each(d.conversions,function(d,f){c=d.read(e);if(!1===b&&!1!==c)return b=c,c.conversionName=f,c.conversion=d,a.BREAK}),a.BREAK});return b}}(dat.color.toString,dat.utils.common);
dat.GUI=dat.gui.GUI=function(d,a,c,b,f,e,r,l,k,q,n,v,u,x,g,m){function w(a,c,h,d){if(!m.hasOwnProperty(c,h))throw Error("Object "+c+' has no property "'+h+'"');d.color?c=new n(c,h):(c=[c,h].concat(d.factoryArgs),c=b.apply(a,c));d.before instanceof f&&(d.before=d.before.__li);I(a,c);g.addClass(c.domElement,"c");h=document.createElement("span");g.addClass(h,"property-name");h.innerHTML=c.property;var e=document.createElement("div");e.appendChild(h);e.appendChild(c.domElement);d=t(a,e,d.before);g.addClass(d,
p.CLASS_CONTROLLER_ROW);g.addClass(d,typeof c.getValue());A(a,d,c);a.__controllers.push(c);return c}function t(a,b,h){var c=document.createElement("li");b&&c.appendChild(b);h?a.__ul.insertBefore(c,params.before):a.__ul.appendChild(c);a.onResize();return c}function A(a,b,h){h.__li=b;h.__gui=a;m.extend(h,{options:function(b){if(1<arguments.length)return h.remove(),w(a,h.object,h.property,{before:h.__li.nextElementSibling,factoryArgs:[m.toArray(arguments)]});if(m.isArray(b)||m.isObject(b))return h.remove(),
w(a,h.object,h.property,{before:h.__li.nextElementSibling,factoryArgs:[b]})},name:function(a){h.__li.firstElementChild.firstElementChild.innerHTML=a;return h},listen:function(){h.__gui.listen(h);return h},remove:function(){h.__gui.remove(h);return h}});if(h instanceof k){var c=new l(h.object,h.property,{min:h.__min,max:h.__max,step:h.__step});m.each(["updateDisplay","onChange","onFinishChange"],function(a){var b=h[a],H=c[a];h[a]=c[a]=function(){var a=Array.prototype.slice.call(arguments);b.apply(h,
a);return H.apply(c,a)}});g.addClass(b,"has-slider");h.domElement.insertBefore(c.domElement,h.domElement.firstElementChild)}else if(h instanceof l){var d=function(b){return m.isNumber(h.__min)&&m.isNumber(h.__max)?(h.remove(),w(a,h.object,h.property,{before:h.__li.nextElementSibling,factoryArgs:[h.__min,h.__max,h.__step]})):b};h.min=m.compose(d,h.min);h.max=m.compose(d,h.max)}else h instanceof e?(g.bind(b,"click",function(){g.fakeEvent(h.__checkbox,"click")}),g.bind(h.__checkbox,"click",function(a){a.stopPropagation()})):
h instanceof r?(g.bind(b,"click",function(){g.fakeEvent(h.__button,"click")}),g.bind(b,"mouseover",function(){g.addClass(h.__button,"hover")}),g.bind(b,"mouseout",function(){g.removeClass(h.__button,"hover")})):h instanceof n?(g.addClass(b,"color"),h.updateDisplay=m.compose(function(a){b.style.borderLeftColor=h.__color.toString();return a},h.updateDisplay),h.updateDisplay()):h instanceof v&&(h.__onFinishChange=function(b){h.remove();return w(a,h.object,h.property,{before:h.__li.nextElementSibling})});
h.setValue=m.compose(function(b){a.getRoot().__preset_select&&h.isModified()&&E(a.getRoot(),!0);return b},h.setValue)}function I(a,b){var c=a.getRoot(),d=c.__rememberedObjects.indexOf(b.object);if(-1!=d){var e=c.__rememberedObjectIndecesToControllers[d];void 0===e&&(e={},c.__rememberedObjectIndecesToControllers[d]=e);e[b.property]=b;if(c.load&&c.load.remembered){c=c.load.remembered;if(c[a.preset])c=c[a.preset];else if(c.Default)c=c.Default;else return;c[d]&&void 0!==c[d][b.property]&&(d=c[d][b.property],
b.initialValue=d,b.setValue(d))}}}function M(a){var b=a.__save_row=document.createElement("li");g.addClass(a.domElement,"has-save");a.__ul.insertBefore(b,a.__ul.firstChild);g.addClass(b,"save-row");var c=document.createElement("span");c.innerHTML="&nbsp;";g.addClass(c,"button gears");var d=document.createElement("span");d.innerHTML="Save";g.addClass(d,"button");g.addClass(d,"save");var e=document.createElement("span");e.innerHTML="New";g.addClass(e,"button");g.addClass(e,"save-as");var f=document.createElement("span");
f.innerHTML="Revert";g.addClass(f,"button");g.addClass(f,"revert");var q=a.__preset_select=document.createElement("select");a.load&&a.load.remembered?m.each(a.load.remembered,function(b,c){F(a,c,c==a.preset)}):F(a,"Default",!1);g.bind(q,"change",function(){for(var b=0;b<a.__preset_select.length;b++)a.__preset_select[b].innerHTML=a.__preset_select[b].value;a.preset=this.value});b.appendChild(q);b.appendChild(c);b.appendChild(d);b.appendChild(e);b.appendChild(f);if(y){var n=function(){l.style.display=
a.useLocalStorage?"block":"none"},b=document.getElementById("dg-save-locally"),l=document.getElementById("dg-local-explain");b.style.display="block";b=document.getElementById("dg-local-storage");"true"===localStorage.getItem(document.location.href+".isLocal")&&b.setAttribute("checked","checked");n();g.bind(b,"change",function(){a.useLocalStorage=!a.useLocalStorage;n()})}var k=document.getElementById("dg-new-constructor");g.bind(k,"keydown",function(a){!a.metaKey||67!==a.which&&67!=a.keyCode||B.hide()});
g.bind(c,"click",function(){k.innerHTML=JSON.stringify(a.getSaveObject(),void 0,2);B.show();k.focus();k.select()});g.bind(d,"click",function(){a.save()});g.bind(e,"click",function(){var b=prompt("Enter a new preset name.");b&&a.saveAs(b)});g.bind(f,"click",function(){a.revert()})}function N(a){function b(f){f.preventDefault();e=f.clientX;g.addClass(a.__closeButton,p.CLASS_DRAG);g.bind(window,"mousemove",c);g.bind(window,"mouseup",d);return!1}function c(b){b.preventDefault();a.width+=e-b.clientX;a.onResize();
e=b.clientX;return!1}function d(){g.removeClass(a.__closeButton,p.CLASS_DRAG);g.unbind(window,"mousemove",c);g.unbind(window,"mouseup",d)}a.__resize_handle=document.createElement("div");m.extend(a.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"});var e;g.bind(a.__resize_handle,"mousedown",b);g.bind(a.__closeButton,"mousedown",b);a.domElement.insertBefore(a.__resize_handle,a.domElement.firstElementChild)}function G(a,b){a.domElement.style.width=
b+"px";a.__save_row&&a.autoPlace&&(a.__save_row.style.width=b+"px");a.__closeButton&&(a.__closeButton.style.width=b+"px")}function C(a,b){var c={};m.each(a.__rememberedObjects,function(d,e){var f={};m.each(a.__rememberedObjectIndecesToControllers[e],function(a,c){f[c]=b?a.initialValue:a.getValue()});c[e]=f});return c}function F(a,b,c){var d=document.createElement("option");d.innerHTML=b;d.value=b;a.__preset_select.appendChild(d);c&&(a.__preset_select.selectedIndex=a.__preset_select.length-1)}function E(a,
b){var c=a.__preset_select[a.__preset_select.selectedIndex];c.innerHTML=b?c.value+"*":c.value}function J(a){0!=a.length&&u(function(){J(a)});m.each(a,function(a){a.updateDisplay()})}d.inject(c);var y;try{y="localStorage"in window&&null!==window.localStorage}catch(H){y=!1}var B,K=!0,z,D=!1,L=[],p=function(a){function b(){var a=c.getRoot();a.width+=1;m.defer(function(){--a.width})}var c=this;this.domElement=document.createElement("div");this.__ul=document.createElement("ul");this.domElement.appendChild(this.__ul);
g.addClass(this.domElement,"dg");this.__folders={};this.__controllers=[];this.__rememberedObjects=[];this.__rememberedObjectIndecesToControllers=[];this.__listening=[];a=a||{};a=m.defaults(a,{autoPlace:!0,width:p.DEFAULT_WIDTH});a=m.defaults(a,{resizable:a.autoPlace,hideable:a.autoPlace});m.isUndefined(a.load)?a.load={preset:"Default"}:a.preset&&(a.load.preset=a.preset);m.isUndefined(a.parent)&&a.hideable&&L.push(this);a.resizable=m.isUndefined(a.parent)&&a.resizable;a.autoPlace&&m.isUndefined(a.scrollable)&&
(a.scrollable=!0);var d=y&&"true"===localStorage.getItem(document.location.href+".isLocal"),e;Object.defineProperties(this,{parent:{get:function(){return a.parent}},scrollable:{get:function(){return a.scrollable}},autoPlace:{get:function(){return a.autoPlace}},preset:{get:function(){return c.parent?c.getRoot().preset:a.load.preset},set:function(b){c.parent?c.getRoot().preset=b:a.load.preset=b;for(b=0;b<this.__preset_select.length;b++)this.__preset_select[b].value==this.preset&&(this.__preset_select.selectedIndex=
b);c.revert()}},width:{get:function(){return a.width},set:function(b){a.width=b;G(c,b)}},name:{get:function(){return a.name},set:function(b){a.name=b;q&&(q.innerHTML=a.name)}},closed:{get:function(){return a.closed},set:function(b){a.closed=b;a.closed?g.addClass(c.__ul,p.CLASS_CLOSED):g.removeClass(c.__ul,p.CLASS_CLOSED);this.onResize();c.__closeButton&&(c.__closeButton.innerHTML=b?p.TEXT_OPEN:p.TEXT_CLOSED)}},load:{get:function(){return a.load}},useLocalStorage:{get:function(){return d},set:function(a){y&&
((d=a)?g.bind(window,"unload",e):g.unbind(window,"unload",e),localStorage.setItem(document.location.href+".isLocal",a))}}});if(m.isUndefined(a.parent)){a.closed=!1;g.addClass(this.domElement,p.CLASS_MAIN);g.makeSelectable(this.domElement,!1);if(y&&d){c.useLocalStorage=!0;var f=localStorage.getItem(document.location.href+".gui");f&&(a.load=JSON.parse(f))}this.__closeButton=document.createElement("div");this.__closeButton.innerHTML=p.TEXT_CLOSED;g.addClass(this.__closeButton,p.CLASS_CLOSE_BUTTON);this.domElement.appendChild(this.__closeButton);
g.bind(this.__closeButton,"click",function(){c.closed=!c.closed})}else{void 0===a.closed&&(a.closed=!0);var q=document.createTextNode(a.name);g.addClass(q,"controller-name");f=t(c,q);g.addClass(this.__ul,p.CLASS_CLOSED);g.addClass(f,"title");g.bind(f,"click",function(a){a.preventDefault();c.closed=!c.closed;return!1});a.closed||(this.closed=!1)}a.autoPlace&&(m.isUndefined(a.parent)&&(K&&(z=document.createElement("div"),g.addClass(z,"dg"),g.addClass(z,p.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(z),
K=!1),z.appendChild(this.domElement),g.addClass(this.domElement,p.CLASS_AUTO_PLACE)),this.parent||G(c,a.width));g.bind(window,"resize",function(){c.onResize()});g.bind(this.__ul,"webkitTransitionEnd",function(){c.onResize()});g.bind(this.__ul,"transitionend",function(){c.onResize()});g.bind(this.__ul,"oTransitionEnd",function(){c.onResize()});this.onResize();a.resizable&&N(this);this.saveToLocalStorageIfPossible=e=function(){y&&"true"===localStorage.getItem(document.location.href+".isLocal")&&localStorage.setItem(document.location.href+
".gui",JSON.stringify(c.getSaveObject()))};c.getRoot();a.parent||b()};p.toggleHide=function(){D=!D;m.each(L,function(a){a.domElement.style.zIndex=D?-999:999;a.domElement.style.opacity=D?0:1})};p.CLASS_AUTO_PLACE="a";p.CLASS_AUTO_PLACE_CONTAINER="ac";p.CLASS_MAIN="main";p.CLASS_CONTROLLER_ROW="cr";p.CLASS_TOO_TALL="taller-than-window";p.CLASS_CLOSED="closed";p.CLASS_CLOSE_BUTTON="close-button";p.CLASS_DRAG="drag";p.DEFAULT_WIDTH=245;p.TEXT_CLOSED="Close Controls";p.TEXT_OPEN="Open Controls";g.bind(window,
"keydown",function(a){"text"===document.activeElement.type||72!==a.which&&72!=a.keyCode||p.toggleHide()},!1);m.extend(p.prototype,{add:function(a,b){return w(this,a,b,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(a,b){return w(this,a,b,{color:!0})},remove:function(a){this.__ul.removeChild(a.__li);var b=this.__listening.indexOf(a);0<b&&this.__listening.pop(b);this.__controllers.pop(this.__controllers.indexOf(a));var c=this;m.defer(function(){c.onResize()})},destroy:function(){this.autoPlace&&
z.removeChild(this.domElement)},addFolder:function(a){if(void 0!==this.__folders[a])throw Error('You already have a folder in this GUI by the name "'+a+'"');var b={name:a,parent:this};b.autoPlace=this.autoPlace;this.load&&this.load.folders&&this.load.folders[a]&&(b.closed=this.load.folders[a].closed,b.load=this.load.folders[a]);b=new p(b);this.__folders[a]=b;a=t(this,b.domElement);g.addClass(a,"folder");return b},open:function(){this.closed=!1},close:function(){this.closed=!0},onResize:function(){var a=
this.getRoot();if(a.scrollable){var b=g.getOffset(a.__ul).top,c=0;m.each(a.__ul.childNodes,function(b){a.autoPlace&&b===a.__save_row||(c+=g.getHeight(b))});window.innerHeight-b-20<c?(g.addClass(a.domElement,p.CLASS_TOO_TALL),a.__ul.style.height=window.innerHeight-b-20+"px"):(g.removeClass(a.domElement,p.CLASS_TOO_TALL),a.__ul.style.height="auto")}a.__resize_handle&&m.defer(function(){a.__resize_handle.style.height=a.__ul.offsetHeight+"px"});a.__closeButton&&(a.__closeButton.style.width=a.width+"px")},
remember:function(){m.isUndefined(B)&&(B=new x,B.domElement.innerHTML=a);if(this.parent)throw Error("You can only call remember on a top level GUI.");var b=this;m.each(Array.prototype.slice.call(arguments),function(a){0==b.__rememberedObjects.length&&M(b);-1==b.__rememberedObjects.indexOf(a)&&b.__rememberedObjects.push(a)});this.autoPlace&&G(this,this.width)},getRoot:function(){for(var a=this;a.parent;)a=a.parent;return a},getSaveObject:function(){var a=this.load;a.closed=this.closed;0<this.__rememberedObjects.length&&
(a.preset=this.preset,a.remembered||(a.remembered={}),a.remembered[this.preset]=C(this));a.folders={};m.each(this.__folders,function(b,c){a.folders[c]=b.getSaveObject()});return a},save:function(){this.load.remembered||(this.load.remembered={});this.load.remembered[this.preset]=C(this);E(this,!1);this.saveToLocalStorageIfPossible()},saveAs:function(a){this.load.remembered||(this.load.remembered={},this.load.remembered.Default=C(this,!0));this.load.remembered[a]=C(this);this.preset=a;F(this,a,!0);
this.saveToLocalStorageIfPossible()},revert:function(a){m.each(this.__controllers,function(b){this.getRoot().load.remembered?I(a||this.getRoot(),b):b.setValue(b.initialValue)},this);m.each(this.__folders,function(a){a.revert(a)});a||E(this.getRoot(),!1)},listen:function(a){var b=0==this.__listening.length;this.__listening.push(a);b&&J(this.__listening)},updateDisplay:function(){for(var a in this.__controllers)this.__controllers[a].updateDisplay();for(var b in this.__folders)this.__folders[b].updateDisplay()}});
return p}(dat.utils.css,'<div id="dg-save" class="dg dialogue">\n\n Here\'s the new load parameter for your <code>GUI</code>\'s constructor:\n\n <textarea id="dg-new-constructor"></textarea>\n\n <div id="dg-save-locally">\n\n <input id="dg-local-storage" type="checkbox" /> Automatically save values to <code>localStorage</code> on exit.\n\n <div id="dg-local-explain">The values saved to <code>localStorage</code> will override those passed to <code>dat.GUI</code>\'s constructor. This makes it easier to work incrementally, but <code>localStorage</code> is fragile, and your friends may not see the same values you do.\n\n </div>\n\n </div>\n\n</div>\n',
".dg {\n /** Clear list styles */\n /* Auto-place container */\n /* Auto-placed GUI's */\n /* Line items that don't contain folders. */\n /** Folder names */\n /** Hides closed items */\n /** Controller row */\n /** Name-half (left) */\n /** Controller-half (right) */\n /** Controller placement */\n /** Shorter number boxes when slider is present. */\n /** Ensure the entire boolean and function row shows a hand */\n}\n\n.dg ul {\n list-style: none;\n margin: 0;\n padding: 0;\n width: 100%;\n clear: both;\n}\n\n.dg.ac {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n height: 0;\n z-index: 0;\n}\n\n.dg:not(.ac) .main {\n /** Exclude mains in ac so that we don't hide close button */\n overflow: hidden;\n}\n\n.dg.main {\n -webkit-transition: opacity 0.1s linear;\n -o-transition: opacity 0.1s linear;\n -moz-transition: opacity 0.1s linear;\n transition: opacity 0.1s linear;\n}\n\n.dg.main.taller-than-window {\n overflow-y: auto;\n}\n\n.dg.main.taller-than-window .close-button {\n opacity: 1;\n /* TODO, these are style notes */\n margin-top: -1px;\n border-top: 1px solid #2c2c2c;\n}\n\n.dg.main ul.closed .close-button {\n opacity: 1 !important;\n}\n\n.dg.main:hover .close-button,\n.dg.main .close-button.drag {\n opacity: 1;\n}\n\n.dg.main .close-button {\n /*opacity: 0;*/\n -webkit-transition: opacity 0.1s linear;\n -o-transition: opacity 0.1s linear;\n -moz-transition: opacity 0.1s linear;\n transition: opacity 0.1s linear;\n border: 0;\n position: absolute;\n line-height: 19px;\n height: 20px;\n /* TODO, these are style notes */\n cursor: pointer;\n text-align: center;\n background-color: #000;\n}\n\n.dg.main .close-button:hover {\n background-color: #111;\n}\n\n.dg.a {\n float: right;\n margin-right: 15px;\n overflow-x: hidden;\n}\n\n.dg.a.has-save> ul {\n margin-top: 27px;\n}\n\n.dg.a.has-save> ul.closed {\n margin-top: 0;\n}\n\n.dg.a .save-row {\n position: fixed;\n top: 0;\n z-index: 1002;\n}\n\n.dg li {\n -webkit-transition: height 0.1s ease-out;\n -o-transition: height 0.1s ease-out;\n -moz-transition: height 0.1s ease-out;\n transition: height 0.1s ease-out;\n}\n\n.dg li:not(.folder) {\n cursor: auto;\n height: 27px;\n line-height: 27px;\n overflow: hidden;\n padding: 0 4px 0 5px;\n}\n\n.dg li.folder {\n padding: 0;\n border-left: 4px solid rgba(0, 0, 0, 0);\n}\n\n.dg li.title {\n cursor: pointer;\n margin-left: -4px;\n}\n\n.dg .closed li:not(.title),\n.dg .closed ul li,\n.dg .closed ul li> * {\n height: 0;\n overflow: hidden;\n border: 0;\n}\n\n.dg .cr {\n clear: both;\n padding-left: 3px;\n height: 27px;\n}\n\n.dg .property-name {\n cursor: default;\n float: left;\n clear: left;\n width: 40%;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.dg .c {\n float: left;\n width: 60%;\n}\n\n.dg .c input[type=text] {\n border: 0;\n margin-top: 4px;\n padding: 3px;\n width: 100%;\n float: right;\n}\n\n.dg .has-slider input[type=text] {\n width: 30%;\n /*display: none;*/\n margin-left: 0;\n}\n\n.dg .slider {\n float: left;\n width: 66%;\n margin-left: -5px;\n margin-right: 0;\n height: 19px;\n margin-top: 4px;\n}\n\n.dg .slider-fg {\n height: 100%;\n}\n\n.dg .c input[type=checkbox] {\n margin-top: 9px;\n}\n\n.dg .c select {\n margin-top: 5px;\n}\n\n.dg .cr.function,\n.dg .cr.function .property-name,\n.dg .cr.function *,\n.dg .cr.boolean,\n.dg .cr.boolean * {\n cursor: pointer;\n}\n\n.dg .selector {\n display: none;\n position: absolute;\n margin-left: -9px;\n margin-top: 23px;\n z-index: 10;\n}\n\n.dg .c:hover .selector,\n.dg .selector.drag {\n display: block;\n}\n\n.dg li.save-row {\n padding: 0;\n}\n\n.dg li.save-row .button {\n display: inline-block;\n padding: 0px 6px;\n}\n\n.dg.dialogue {\n background-color: #222;\n width: 460px;\n padding: 15px;\n font-size: 13px;\n line-height: 15px;\n}\n\n\n/* TODO Separate style and structure */\n\n#dg-new-constructor {\n padding: 10px;\n color: #222;\n font-family: Monaco, monospace;\n font-size: 10px;\n border: 0;\n resize: none;\n box-shadow: inset
dat.controllers.factory=function(d,a,c,b,f,e,r,l){return function(k,q,n,v){var u=k[q];if(l.isArray(n)||l.isObject(n))return new d(k,q,n);if(l.isNumber(u))return l.isNumber(n)&&l.isNumber(v)?new c(k,q,n,v):new a(k,q,{min:n,max:v});if(l.isString(u))return new b(k,q);if(l.isFunction(u))return new f(k,q,"");if(l.isBoolean(u))return new e(k,q);if(l.isUndefined(u))return new r(k,q)}}(dat.controllers.OptionController,dat.controllers.NumberControllerBox,dat.controllers.NumberControllerSlider,dat.controllers.StringController=
function(d,a,c){var b=function(c,d){function r(){l.setValue(l.__input.value)}b.superclass.call(this,c,d);var l=this;this.__input=document.createElement("input");this.__input.setAttribute("type","text");a.bind(this.__input,"keyup",r);a.bind(this.__input,"change",r);a.bind(this.__input,"blur",function(){l.__onFinishChange&&l.__onFinishChange.call(l,l.getValue())});a.bind(this.__input,"keydown",function(a){13===a.keyCode&&this.blur()});this.updateDisplay();this.domElement.appendChild(this.__input)};
b.superclass=d;c.extend(b.prototype,d.prototype,{updateDisplay:function(){a.isActive(this.__input)||(this.__input.value=this.getValue());return b.superclass.prototype.updateDisplay.call(this)}});return b}(dat.controllers.Controller,dat.dom.dom,dat.utils.common),dat.controllers.FunctionController,dat.controllers.BooleanController,dat.controllers.UndefinedController,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(d,a,c,b,f){function e(a,b,c,d){a.style.background="";f.each(k,function(e){a.style.cssText+="background: "+e+"linear-gradient("+b+", "+c+" 0%, "+d+" 100%); "})}function r(a){a.style.background="";a.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);";a.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);";
a.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);";a.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);";a.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}var l=function(d,n){function k(b){m(b);a.bind(window,"mousemove",m);a.bind(window,
"mouseup",u)}function u(){a.unbind(window,"mousemove",m);a.unbind(window,"mouseup",u)}function x(){var a=b(this.value);!1!==a?(t.__color.__state=a,t.setValue(t.__color.toOriginal())):this.value=t.__color.toString()}function g(){a.unbind(window,"mousemove",w);a.unbind(window,"mouseup",g)}function m(b){b.preventDefault();var c=a.getWidth(t.__saturation_field),d=a.getOffset(t.__saturation_field),e=(b.clientX-d.left+document.body.scrollLeft)/c;b=1-(b.clientY-d.top+document.body.scrollTop)/c;1<b?b=1:0>
b&&(b=0);1<e?e=1:0>e&&(e=0);t.__color.v=b;t.__color.s=e;t.setValue(t.__color.toOriginal());return!1}function w(b){b.preventDefault();var c=a.getHeight(t.__hue_field),d=a.getOffset(t.__hue_field);b=1-(b.clientY-d.top+document.body.scrollTop)/c;1<b?b=1:0>b&&(b=0);t.__color.h=360*b;t.setValue(t.__color.toOriginal());return!1}l.superclass.call(this,d,n);this.__color=new c(this.getValue());this.__temp=new c(0);var t=this;this.domElement=document.createElement("div");a.makeSelectable(this.domElement,!1);
2013-12-18 23:27:02 +00:00
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 ";a.bind(this.__input,"keydown",function(a){13===a.keyCode&&x.call(this)});a.bind(this.__input,"blur",x);a.bind(this.__selector,"mousedown",function(b){a.addClass(this,"drag").bind(window,"mouseup",function(b){a.removeClass(t.__selector,"drag")})});var A=document.createElement("div");f.extend(this.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"});f.extend(this.__field_knob.style,
{position:"absolute",width:"12px",height:"12px",border:this.__field_knob_border+(.5>this.__color.v?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1});f.extend(this.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1});f.extend(this.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"});f.extend(A.style,{width:"100%",height:"100%",
background:"none"});e(A,"top","rgba(0,0,0,0)","#000");f.extend(this.__hue_field.style,{width:"15px",height:"100px",display:"inline-block",border:"1px solid #555",cursor:"ns-resize"});r(this.__hue_field);f.extend(this.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:this.__input_textShadow+"rgba(0,0,0,0.7)"});a.bind(this.__saturation_field,"mousedown",k);a.bind(this.__field_knob,"mousedown",k);a.bind(this.__hue_field,"mousedown",function(b){w(b);a.bind(window,
"mousemove",w);a.bind(window,"mouseup",g)});this.__saturation_field.appendChild(A);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()};l.superclass=d;f.extend(l.prototype,d.prototype,{updateDisplay:function(){var a=b(this.getValue());if(!1!==a){var d=!1;
f.each(c.COMPONENTS,function(b){if(!f.isUndefined(a[b])&&!f.isUndefined(this.__color.__state[b])&&a[b]!==this.__color.__state[b])return d=!0,{}},this);d&&f.extend(this.__color.__state,a)}f.extend(this.__temp.__state,this.__color.__state);this.__temp.a=1;var k=.5>this.__color.v||.5<this.__color.s?255:0,l=255-k;f.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("+k+
","+k+","+k+")"});this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px";this.__temp.s=1;this.__temp.v=1;e(this.__saturation_field,"left","#fff",this.__temp.toString());f.extend(this.__input.style,{backgroundColor:this.__input.value=this.__color.toString(),color:"rgb("+k+","+k+","+k+")",textShadow:this.__input_textShadow+"rgba("+l+","+l+","+l+",.7)"})}});var k=["-moz-","-o-","-webkit-","-ms-",""];return l}(dat.controllers.Controller,dat.dom.dom,dat.color.Color=function(d,a,c,b){function f(a,
b,c){Object.defineProperty(a,b,{get:function(){if("RGB"===this.__state.space)return this.__state[b];r(this,b,c);return this.__state[b]},set:function(a){"RGB"!==this.__state.space&&(r(this,b,c),this.__state.space="RGB");this.__state[b]=a}})}function e(a,b){Object.defineProperty(a,b,{get:function(){if("HSV"===this.__state.space)return this.__state[b];l(this);return this.__state[b]},set:function(a){"HSV"!==this.__state.space&&(l(this),this.__state.space="HSV");this.__state[b]=a}})}function r(c,d,e){if("HEX"===
c.__state.space)c.__state[d]=a.component_from_hex(c.__state.hex,e);else if("HSV"===c.__state.space)b.extend(c.__state,a.hsv_to_rgb(c.__state.h,c.__state.s,c.__state.v));else throw"Corrupted color state";}function l(c){var d=a.rgb_to_hsv(c.r,c.g,c.b);b.extend(c.__state,{s:d.s,v:d.v});b.isNaN(d.h)?b.isUndefined(c.__state.h)&&(c.__state.h=0):c.__state.h=d.h}var k=function(){this.__state=d.apply(this,arguments);if(!1===this.__state)throw"Failed to interpret color arguments";this.__state.a=this.__state.a||
1};k.COMPONENTS="r g b h s v hex a".split(" ");b.extend(k.prototype,{toString:function(){return c(this)},toOriginal:function(){return this.__state.conversion.write(this)}});f(k.prototype,"r",2);f(k.prototype,"g",1);f(k.prototype,"b",0);e(k.prototype,"h");e(k.prototype,"s");e(k.prototype,"v");Object.defineProperty(k.prototype,"a",{get:function(){return this.__state.a},set:function(a){this.__state.a=a}});Object.defineProperty(k.prototype,"hex",{get:function(){this.__state.hex=a.rgb_to_hex(this.r,this.g,
this.b);return this.__state.hex},set:function(a){this.__state.space="HEX";this.__state.hex=a}});return k}(dat.color.interpret,dat.color.math=function(){var d;return{hsv_to_rgb:function(a,c,b){var d=a/60-Math.floor(a/60),e=b*(1-c),r=b*(1-d*c);c=b*(1-(1-d)*c);a=[[b,c,e],[r,b,e],[e,b,c],[e,r,b],[c,e,b],[b,e,r]][Math.floor(a/60)%6];return{r:255*a[0],g:255*a[1],b:255*a[2]}},rgb_to_hsv:function(a,c,b){var d=Math.max(a,c,b),e=d-Math.min(a,c,b);if(0==d)return{h:NaN,s:0,v:0};a=(a==d?(c-b)/e:c==d?2+(b-a)/e:
4+(a-c)/e)/6;0>a&&(a+=1);return{h:360*a,s:e/d,v:d/255}},rgb_to_hex:function(a,c,b){a=this.hex_with_component(0,2,a);a=this.hex_with_component(a,1,c);return a=this.hex_with_component(a,0,b)},component_from_hex:function(a,c){return a>>8*c&255},hex_with_component:function(a,c,b){return b<<(d=8*c)|a&~(255<<d)}}}(),dat.color.toString,dat.utils.common),dat.color.interpret,dat.utils.common),dat.controllers.UndefinedController,dat.utils.requestAnimationFrame=function(){return window.requestAnimationFrame||
window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(d,a){window.setTimeout(d,1E3/60)}}(),dat.dom.CenteredDiv=function(d,a){var c=function(){this.backgroundElement=document.createElement("div");a.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",transition:"opacity 0.2s linear"});d.makeFullscreen(this.backgroundElement);
this.backgroundElement.style.position="fixed";this.domElement=document.createElement("div");a.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"});document.body.appendChild(this.backgroundElement);document.body.appendChild(this.domElement);var b=this;d.bind(this.backgroundElement,"click",function(){b.hide()})};c.prototype.show=function(){var b=
this;this.backgroundElement.style.display="block";this.domElement.style.display="block";this.domElement.style.opacity=0;this.domElement.style.webkitTransform="scale(1.1)";this.layout();a.defer(function(){b.backgroundElement.style.opacity=1;b.domElement.style.opacity=1;b.domElement.style.webkitTransform="scale(1)"})};c.prototype.hide=function(){var a=this,c=function(){a.domElement.style.display="none";a.backgroundElement.style.display="none";d.unbind(a.domElement,"webkitTransitionEnd",c);d.unbind(a.domElement,
"transitionend",c);d.unbind(a.domElement,"oTransitionEnd",c)};d.bind(this.domElement,"webkitTransitionEnd",c);d.bind(this.domElement,"transitionend",c);d.bind(this.domElement,"oTransitionEnd",c);this.backgroundElement.style.opacity=0;this.domElement.style.opacity=0;this.domElement.style.webkitTransform="scale(1.1)"};c.prototype.layout=function(){this.domElement.style.left=window.innerWidth/2-d.getWidth(this.domElement)/2+"px";this.domElement.style.top=window.innerHeight/2-d.getHeight(this.domElement)/
2+"px"};return c}(dat.dom.dom,dat.utils.common),dat.dom.dom,dat.utils.common);