mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
Merge branch 'master' into gh-pages
This commit is contained in:
commit
2bab9a0699
@ -2,11 +2,22 @@ var Controller = function() {
|
|||||||
|
|
||||||
var onChange = null;
|
var onChange = null;
|
||||||
|
|
||||||
this.setName = function(n) {
|
this.parent = null;
|
||||||
|
|
||||||
|
this.name = function(n) {
|
||||||
this.propertyNameElement.innerHTML = n;
|
this.propertyNameElement.innerHTML = n;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.listen = function() {
|
||||||
|
this.parent.watchController(this);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getValue = function() {
|
||||||
|
return this.object[this.propertyName];
|
||||||
|
}
|
||||||
|
|
||||||
this.setValue = function(n) {
|
this.setValue = function(n) {
|
||||||
this.object[this.propertyName] = n;
|
this.object[this.propertyName] = n;
|
||||||
if (onChange != null) {
|
if (onChange != null) {
|
||||||
@ -15,8 +26,8 @@ var Controller = function() {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getValue = function() {
|
this.watchValue = function() {
|
||||||
return this.object[this.propertyName];
|
this.updateValue(this.object[this.propertyName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.onChange = function(fnc) {
|
this.onChange = function(fnc) {
|
||||||
@ -46,7 +57,7 @@ var Controller = function() {
|
|||||||
|
|
||||||
this.propertyNameElement = document.createElement('span');
|
this.propertyNameElement = document.createElement('span');
|
||||||
this.propertyNameElement.setAttribute('class', 'guidat-propertyname');
|
this.propertyNameElement.setAttribute('class', 'guidat-propertyname');
|
||||||
this.setName(this.propertyName);
|
this.name(this.propertyName);
|
||||||
this.domElement.appendChild(this.propertyNameElement);
|
this.domElement.appendChild(this.propertyNameElement);
|
||||||
|
|
||||||
this.makeUnselectable(this.domElement);
|
this.makeUnselectable(this.domElement);
|
||||||
|
@ -20,14 +20,8 @@ var NumberController = function() {
|
|||||||
var step = arguments[4];
|
var step = arguments[4];
|
||||||
|
|
||||||
if (!step) {
|
if (!step) {
|
||||||
if (min != undefined && max != undefined) {
|
step = min != undefined && max != undefined ? (max-min)*0.01: 1;
|
||||||
step = (max-min)*0.01;
|
|
||||||
} else {
|
|
||||||
step = 1;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
console.log("step " + step);
|
|
||||||
|
|
||||||
var numberField = document.createElement('input');
|
var numberField = document.createElement('input');
|
||||||
numberField.setAttribute('id', this.propertyName);
|
numberField.setAttribute('id', this.propertyName);
|
||||||
@ -70,7 +64,7 @@ var NumberController = function() {
|
|||||||
|
|
||||||
document.addEventListener('mouseup', function(e) {
|
document.addEventListener('mouseup', function(e) {
|
||||||
document.removeEventListener('mousemove', dragNumberField, false);
|
document.removeEventListener('mousemove', dragNumberField, false);
|
||||||
_this.makeSelectable(GUI.domElement);
|
_this.makeSelectable(_this.parent.domElement);
|
||||||
_this.makeSelectable(numberField);
|
_this.makeSelectable(numberField);
|
||||||
if (clickedNumberField && !draggedNumberField) {
|
if (clickedNumberField && !draggedNumberField) {
|
||||||
numberField.focus();
|
numberField.focus();
|
||||||
@ -94,7 +88,7 @@ var NumberController = function() {
|
|||||||
// We don't want to be highlighting this field as we scroll.
|
// We don't want to be highlighting this field as we scroll.
|
||||||
// Or any other fields in this gui for that matter ...
|
// Or any other fields in this gui for that matter ...
|
||||||
// TODO: Make makeUselectable go through each element and child element.
|
// TODO: Make makeUselectable go through each element and child element.
|
||||||
_this.makeUnselectable(GUI.domElement);
|
_this.makeUnselectable(_this.parent.domElement);
|
||||||
_this.makeUnselectable(numberField);
|
_this.makeUnselectable(numberField);
|
||||||
|
|
||||||
py = y;
|
py = y;
|
||||||
|
@ -12,6 +12,7 @@ var StringController = function() {
|
|||||||
|
|
||||||
input.setAttribute('value', initialValue);
|
input.setAttribute('value', initialValue);
|
||||||
input.setAttribute('spellcheck', 'false');
|
input.setAttribute('spellcheck', 'false');
|
||||||
|
|
||||||
this.domElement.addEventListener('mouseup', function() {
|
this.domElement.addEventListener('mouseup', function() {
|
||||||
input.focus();
|
input.focus();
|
||||||
input.select();
|
input.select();
|
||||||
@ -22,6 +23,11 @@ var StringController = function() {
|
|||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
this.domElement.appendChild(input);
|
this.domElement.appendChild(input);
|
||||||
|
|
||||||
|
this.updateValue = function(val) {
|
||||||
|
input.setAttribute('value', val);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
StringController.prototype = new Controller();
|
StringController.prototype = new Controller();
|
||||||
StringController.prototype.constructor = StringController;
|
StringController.prototype.constructor = StringController;
|
@ -1,5 +1,7 @@
|
|||||||
function FizzyText(message) {
|
function FizzyText(message) {
|
||||||
|
|
||||||
|
var that = this;
|
||||||
|
|
||||||
// These are the variables that we manipulate with gui-dat.
|
// These are the variables that we manipulate with gui-dat.
|
||||||
// Notice they're all defined with "this". That makes them public.
|
// Notice they're all defined with "this". That makes them public.
|
||||||
// Otherwise, gui-dat can't see them.
|
// Otherwise, gui-dat can't see them.
|
||||||
@ -9,6 +11,7 @@ function FizzyText(message) {
|
|||||||
this.noiseStrength = 10; // how turbulent is the flow?
|
this.noiseStrength = 10; // how turbulent is the flow?
|
||||||
this.speed = 0.4; // how fast do particles move?
|
this.speed = 0.4; // how fast do particles move?
|
||||||
this.displayOutline = false; // should we draw the message as a stroke?
|
this.displayOutline = false; // should we draw the message as a stroke?
|
||||||
|
this.framesRendered = 0;
|
||||||
|
|
||||||
// __defineGetter__ and __defineSetter__ makes JavaScript believe that
|
// __defineGetter__ and __defineSetter__ makes JavaScript believe that
|
||||||
// we've defined a variable 'this.message'. This way, whenever we
|
// we've defined a variable 'this.message'. This way, whenever we
|
||||||
@ -98,6 +101,8 @@ function FizzyText(message) {
|
|||||||
// Called once per frame, updates the animation.
|
// Called once per frame, updates the animation.
|
||||||
var render = function () {
|
var render = function () {
|
||||||
|
|
||||||
|
that.framesRendered ++;
|
||||||
|
|
||||||
g.clearRect(0, 0, width, height);
|
g.clearRect(0, 0, width, height);
|
||||||
|
|
||||||
if (_this.displayOutline) {
|
if (_this.displayOutline) {
|
||||||
|
1538
demo/prettify.js
Normal file
1538
demo/prettify.js
Normal file
File diff suppressed because it is too large
Load Diff
6
gui.css
6
gui.css
@ -8,9 +8,6 @@
|
|||||||
left: 100%;
|
left: 100%;
|
||||||
margin-left: -300px;
|
margin-left: -300px;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
-moz-transition: margin-top .2s ease-out;
|
|
||||||
-webkit-transition: margin-top .2s ease-out;
|
|
||||||
transition: margin-top .2s ease-out;
|
|
||||||
-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
|
-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
|
||||||
-moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
|
-moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
|
||||||
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
|
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
|
||||||
@ -26,6 +23,9 @@
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
background-color: rgba(0,0,0,0.1);
|
background-color: rgba(0,0,0,0.1);
|
||||||
|
-moz-transition: height .2s ease-out;
|
||||||
|
-webkit-transition: height .2s ease-out;
|
||||||
|
transition: height .2s ease-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
#guidat-toggle {
|
#guidat-toggle {
|
||||||
|
150
gui.js
150
gui.js
@ -1,60 +1,35 @@
|
|||||||
var GUI = new function() {
|
var GUI = function () {
|
||||||
|
|
||||||
var _this = this;
|
var _this = this, open = false,
|
||||||
|
controllers = [], controllersWatched = [];
|
||||||
|
|
||||||
var controllers = [];
|
this.domElement = document.createElement('div');
|
||||||
|
this.domElement.setAttribute('id', 'guidat');
|
||||||
|
|
||||||
this.add = function() {
|
controllerContainer = document.createElement('div');
|
||||||
|
controllerContainer.setAttribute('id', 'guidat-controllers');
|
||||||
|
controllerContainer.style.height = '0px';
|
||||||
|
|
||||||
// We need to call GUI.start() before .add()
|
toggleButton = document.createElement('a');
|
||||||
if (!started) {
|
toggleButton.setAttribute('id', 'guidat-toggle');
|
||||||
error("Make sure to call GUI.start() in the window.onload function");
|
toggleButton.setAttribute('href', '#');
|
||||||
return;
|
toggleButton.innerHTML = "Show Controls";
|
||||||
|
toggleButton.addEventListener('click', function(e) {
|
||||||
|
_this.toggle();
|
||||||
|
e.preventDefault();
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
this.domElement.appendChild(controllerContainer);
|
||||||
|
this.domElement.appendChild(toggleButton);
|
||||||
|
|
||||||
|
// Controllers Watcher
|
||||||
|
setInterval( function() {
|
||||||
|
for (var c in controllersWatched) {
|
||||||
|
controllersWatched[c].watchValue();
|
||||||
}
|
}
|
||||||
|
}, 1000 / 60 );
|
||||||
|
|
||||||
var object = arguments[0];
|
var handlerTypes = {
|
||||||
var propertyName = arguments[1];
|
|
||||||
|
|
||||||
// Have we already added this?
|
|
||||||
if (alreadyControlled(object, propertyName)) {
|
|
||||||
error("Controller for \"" + propertyName+"\" already added.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var value = object[propertyName];
|
|
||||||
|
|
||||||
// Does this value exist? Is it accessible?
|
|
||||||
if (value == undefined) {
|
|
||||||
error(object + " either has no property \""+propertyName+"\", or the property is inaccessible.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var type = typeof value;
|
|
||||||
var handler = addHandlers[type];
|
|
||||||
|
|
||||||
// Do we know how to deal with this data type?
|
|
||||||
if (handler == undefined) {
|
|
||||||
error("Cannot create controller for data type \""+type+"\"");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var controllerObject = construct(handler, arguments);
|
|
||||||
|
|
||||||
// Were we able to make the controller?
|
|
||||||
if (!controllerObject) {
|
|
||||||
error("Error creating controller for \""+propertyName+"\".");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Success.
|
|
||||||
controllerContainer.appendChild(controllerObject.domElement);
|
|
||||||
controllers.push(controllerObject);
|
|
||||||
|
|
||||||
return controllerObject;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var addHandlers = {
|
|
||||||
"number": NumberController,
|
"number": NumberController,
|
||||||
"string": StringController,
|
"string": StringController,
|
||||||
"boolean": BooleanController,
|
"boolean": BooleanController,
|
||||||
@ -85,64 +60,69 @@ var GUI = new function() {
|
|||||||
return new F();
|
return new F();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.add = function() {
|
||||||
|
|
||||||
|
var object = arguments[0];
|
||||||
|
var propertyName = arguments[1];
|
||||||
|
|
||||||
// GUI ... GUI
|
// Have we already added this?
|
||||||
|
if (alreadyControlled(object, propertyName)) {
|
||||||
|
error("Controller for \"" + propertyName+"\" already added.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.domElement = null;
|
var value = object[propertyName];
|
||||||
var controllerContainer;
|
|
||||||
var started = false;
|
|
||||||
var open = false;
|
|
||||||
|
|
||||||
// TODO: obtain this dynamically?
|
// Does this value exist? Is it accessible?
|
||||||
var domElementMarginTop = 300;
|
if (value == undefined) {
|
||||||
|
error(object + " either has no property \""+propertyName+"\", or the property is inaccessible.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.start = function() {
|
var type = typeof value;
|
||||||
|
var handler = handlerTypes[type];
|
||||||
|
|
||||||
this.domElement = document.createElement('div');
|
// Do we know how to deal with this data type?
|
||||||
this.domElement.setAttribute('id', 'guidat');
|
if (handler == undefined) {
|
||||||
|
error("Cannot create controller for data type \""+type+"\"");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
controllerContainer = document.createElement('div');
|
var controllerObject = construct( handler, arguments);
|
||||||
controllerContainer.setAttribute('id', 'guidat-controllers');
|
controllerObject.parent = _this;
|
||||||
|
|
||||||
toggleButton = document.createElement('a');
|
// Were we able to make the controller?
|
||||||
toggleButton.setAttribute('id', 'guidat-toggle');
|
if (!controllerObject) {
|
||||||
toggleButton.setAttribute('href', '#');
|
error("Error creating controller for \""+propertyName+"\".");
|
||||||
toggleButton.innerHTML = "Show Controls";
|
return;
|
||||||
toggleButton.addEventListener('click', function(e) {
|
}
|
||||||
_this.toggle();
|
|
||||||
e.preventDefault();
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
this.domElement.appendChild(controllerContainer);
|
// Success.
|
||||||
this.domElement.appendChild(toggleButton);
|
controllerContainer.appendChild(controllerObject.domElement);
|
||||||
|
controllers.push(controllerObject);
|
||||||
|
|
||||||
this.domElement.style.marginTop = -domElementMarginTop+"px";
|
return controllerObject;
|
||||||
|
|
||||||
document.body.appendChild(this.domElement);
|
|
||||||
|
|
||||||
started = true;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.toggle = function() {
|
this.watchController = function(c) {
|
||||||
|
|
||||||
|
controllersWatched.push(c);
|
||||||
|
|
||||||
if (open) {
|
|
||||||
this.hide();
|
|
||||||
} else {
|
|
||||||
this.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.toggle = function() {
|
||||||
|
open ? this.hide() : this.show();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.show = function() {
|
this.show = function() {
|
||||||
this.domElement.style.marginTop = 0+"px";
|
controllerContainer.style.height = '300px';
|
||||||
toggleButton.innerHTML = "Hide Controls";
|
toggleButton.innerHTML = "Hide Controls";
|
||||||
open = true;
|
open = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hide = function() {
|
this.hide = function() {
|
||||||
this.domElement.style.marginTop = -domElementMarginTop+"px";
|
controllerContainer.style.height = '0px';
|
||||||
toggleButton.innerHTML = "Show Controls";
|
toggleButton.innerHTML = "Show Controls";
|
||||||
open = false;
|
open = false;
|
||||||
}
|
}
|
||||||
|
76
index.html
76
index.html
@ -4,52 +4,58 @@
|
|||||||
|
|
||||||
<link rel="icon" type="image/png" href="demo/assets/favicon.png" />
|
<link rel="icon" type="image/png" href="demo/assets/favicon.png" />
|
||||||
<link href="demo/demo.css" media="screen" rel="stylesheet" type="text/css" />
|
<link href="demo/demo.css" media="screen" rel="stylesheet" type="text/css" />
|
||||||
<script type="text/javascript" src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></script>
|
|
||||||
<script type="text/javascript" src="gui.min.js"></script>
|
<!-- <script type="text/javascript" src="gui.min.js"></script> -->
|
||||||
|
|
||||||
|
<link href="gui.css" media="screen" rel="stylesheet" type="text/css" />
|
||||||
|
|
||||||
|
<script type="text/javascript" src="controllers/slider.js"></script>
|
||||||
|
<script type="text/javascript" src="controllers/controller.js"></script>
|
||||||
|
<script type="text/javascript" src="controllers/controller.boolean.js"></script>
|
||||||
|
<script type="text/javascript" src="controllers/controller.function.js"></script>
|
||||||
|
<script type="text/javascript" src="controllers/controller.number.js"></script>
|
||||||
|
<script type="text/javascript" src="controllers/controller.string.js"></script>
|
||||||
|
<script type="text/javascript" src="gui.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="demo/improvedNoise.js"></script>
|
<script type="text/javascript" src="demo/improvedNoise.js"></script>
|
||||||
|
<script type="text/javascript" src="demo/prettify.js"></script>
|
||||||
<script type="text/javascript" src="demo/demo.js"></script>
|
<script type="text/javascript" src="demo/demo.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
|
|
||||||
prettyPrint();
|
prettyPrint();
|
||||||
|
|
||||||
var fizzyText = new FizzyText("gui-dat");
|
var fizzyText = new FizzyText("gui-dat");
|
||||||
|
|
||||||
GUI.start();
|
var gui = new GUI();
|
||||||
|
document.body.appendChild( gui.domElement );
|
||||||
|
|
||||||
// Text field
|
// Text field
|
||||||
GUI.add(fizzyText, "message");
|
gui.add(fizzyText, "message");
|
||||||
|
|
||||||
// Sliders with min and max
|
// Sliders with min and max
|
||||||
GUI.add(fizzyText, "maxSize", 0.5, 7);
|
gui.add(fizzyText, "maxSize", 0.5, 7);
|
||||||
GUI.add(fizzyText, "growthSpeed", 0.01, 1);
|
gui.add(fizzyText, "growthSpeed", 0.01, 1);
|
||||||
GUI.add(fizzyText, "speed", 0.1, 2);
|
gui.add(fizzyText, "speed", 0.1, 2);
|
||||||
|
|
||||||
// Sliders with min, max and increment.
|
// Sliders with min, max and increment.
|
||||||
GUI.add(fizzyText, "noiseStrength", 10, 100, 5);
|
gui.add(fizzyText, "noiseStrength", 10, 100, 5);
|
||||||
|
|
||||||
// Boolean checkbox
|
// Boolean checkbox
|
||||||
GUI.add(fizzyText, "displayOutline");
|
gui.add(fizzyText, "displayOutline");
|
||||||
|
|
||||||
|
// Watches a property
|
||||||
|
gui.add(fizzyText, "framesRendered").listen();
|
||||||
|
|
||||||
// Fires a function called "explode"
|
// Fires a function called "explode"
|
||||||
GUI.add(fizzyText, "explode")
|
gui.add(fizzyText, "explode").setName("Explode!"); // Specify a custom name.
|
||||||
.setName('Explode!'); // Specify a custom name.
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var _gaq = _gaq || [];
|
|
||||||
_gaq.push(['_setAccount', 'UA-20996084-1']);
|
|
||||||
_gaq.push(['_trackPageview']);
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
||||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|
||||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
||||||
})();
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="container">
|
|
||||||
<div id = "helvetica-demo"></div>
|
<div id = "helvetica-demo"></div>
|
||||||
<div id = "notifier"></div>
|
<div id = "notifier"></div>
|
||||||
<h1><a href = "http://twitter.com/guidat"><img src = "demo/assets/profile.png" border = "0" alt = "GUI-DAT flag" /></a></h1>
|
<h1><a href = "http://twitter.com/guidat"><img src = "demo/assets/profile.png" border = "0" alt = "GUI-DAT flag" /></a></h1>
|
||||||
@ -63,31 +69,35 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h2>Basic Usage</h2>
|
<h2>Basic Usage</h2>
|
||||||
<pre class="prettyprint"><script type="text/javascript" src="demo/demo.js"></script>
|
<pre id="demo-pre" class="prettyprint"><script type="text/javascript" src="demo/demo.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
|
|
||||||
var fizzyText = new <a href="demo/demo.js">FizzyText</a>("gui-dat");
|
var fizzyText = new <a href="demo/demo.js">FizzyText</a>("gui-dat");
|
||||||
|
|
||||||
GUI.start();
|
var gui = new GUI();
|
||||||
|
document.body.appendChild( gui.domElement );
|
||||||
|
|
||||||
// Text field
|
// Text field
|
||||||
GUI.add(fizzyText, "message");
|
gui.add(fizzyText, "message");
|
||||||
|
|
||||||
// Sliders with min and max
|
// Sliders with min and max
|
||||||
GUI.add(fizzyText, "maxSize", 0.5, 7);
|
gui.add(fizzyText, "maxSize", 0.5, 7);
|
||||||
GUI.add(fizzyText, "growthSpeed", 0.01, 1);
|
gui.add(fizzyText, "growthSpeed", 0.01, 1);
|
||||||
GUI.add(fizzyText, "speed", 0.1, 2);
|
gui.add(fizzyText, "speed", 0.1, 2);
|
||||||
|
|
||||||
// Sliders with min, max and increment
|
// Sliders with min, max and increment.
|
||||||
GUI.add(fizzyText, "noiseStrength", 10, 100, 5);
|
gui.add(fizzyText, "noiseStrength", 10, 100, 5);
|
||||||
|
|
||||||
// Boolean checkbox
|
// Boolean checkbox
|
||||||
GUI.add(fizzyText, "displayOutline");
|
gui.add(fizzyText, "displayOutline");
|
||||||
|
|
||||||
|
// Watches a property
|
||||||
|
gui.add(fizzyText, "framesRendered").listen();
|
||||||
|
|
||||||
// Fires a function called "explode"
|
// Fires a function called "explode"
|
||||||
GUI.add(fizzyText, "explode").setName("Explode!"); // Specify a custom name.
|
gui.add(fizzyText, "explode").setName("Explode!"); // Specify a custom name.
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -98,7 +108,7 @@ window.onload = function() {
|
|||||||
<li>The properties must be public, i.e. defined by <code><strong>this</strong>.prop = value</code>.</li>
|
<li>The properties must be public, i.e. defined by <code><strong>this</strong>.prop = value</code>.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<!-- <hr/>
|
<hr/>
|
||||||
<h2>Monitor variable changes <em>outside</em> of the GUI</h2>
|
<h2>Monitor variable changes <em>outside</em> of the GUI</h2>
|
||||||
<p>Let's say you have a variable that changes by itself from time to time. If you'd like the GUI to reflect those changes, use the <code>listen()</code> method.</p>
|
<p>Let's say you have a variable that changes by itself from time to time. If you'd like the GUI to reflect those changes, use the <code>listen()</code> method.</p>
|
||||||
<pre class="prettyprint">GUI.add(obj, "propName").listen();</pre>
|
<pre class="prettyprint">GUI.add(obj, "propName").listen();</pre>
|
||||||
@ -106,7 +116,7 @@ window.onload = function() {
|
|||||||
<h2>Fire a function when someone uses a control</h2>
|
<h2>Fire a function when someone uses a control</h2>
|
||||||
<pre class="prettyprint">GUI.add(obj, "propName").onChange(function(n) {
|
<pre class="prettyprint">GUI.add(obj, "propName").onChange(function(n) {
|
||||||
alert("You changed me to " + n);
|
alert("You changed me to " + n);
|
||||||
});</pre> -->
|
});</pre>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
Initiated by <a href="http://georgemichaelbrower.com/">George Michael Brower</a> and <a href="http://jonobr1.com/">Jono Brandel</a> of the Data Arts Team, Google Creative Lab.
|
Initiated by <a href="http://georgemichaelbrower.com/">George Michael Brower</a> and <a href="http://jonobr1.com/">Jono Brandel</a> of the Data Arts Team, Google Creative Lab.
|
||||||
|
Loading…
Reference in New Issue
Block a user