dat.gui/index.html

153 lines
6.4 KiB
HTML
Raw Normal View History

2011-01-25 07:42:20 +00:00
<!doctype html>
<head>
2011-01-27 02:45:34 +00:00
<title>gui-dat</title>
2011-01-25 08:14:24 +00:00
2011-01-27 06:35:45 +00:00
<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="gui.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.js"></script>
<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.number.js"></script>
<script type="text/javascript" src="controllers/controller.string.js"></script>
<script type="text/javascript" src="controllers/controller.boolean.js"></script>
<script type="text/javascript" src="controllers/controller.function.js"></script>
2011-01-26 23:25:40 +00:00
<script type="text/javascript" src="demo/improvedNoise.js"></script>
2011-01-26 02:30:05 +00:00
<script type="text/javascript" src="demo/demo.js"></script>
<script type="text/javascript">
var fizzyText;
var gui;
2011-01-25 07:42:20 +00:00
window.onload = function() {
// prettyPrint();
2011-01-26 02:30:05 +00:00
fizzyText = new FizzyText("gui-dat");
gui = new GUI();
gui.start();
2011-01-26 00:58:52 +00:00
2011-01-27 02:45:34 +00:00
// Text field
gui.add(fizzyText, "message").listen();
2011-01-27 02:45:34 +00:00
// Sliders with min and max
gui.add(fizzyText, "maxSize", 0.5, 7);
gui.add(fizzyText, "growthSpeed", 0.01, 1);
gui.add(fizzyText, "speed", 0.1, 2);
2011-01-26 23:25:40 +00:00
2011-01-27 02:45:34 +00:00
// Sliders with min, max and increment.
gui.add(fizzyText, "noiseStrength", 10, 100, 5);
2011-01-27 02:45:34 +00:00
// Boolean checkbox
gui.add(fizzyText, "displayOutline").onChange(function(v) {
alert(v);
});
2011-01-27 02:48:27 +00:00
// Fires a function called "explode"
gui.add(fizzyText, "explode")
.name('Explode!'); // Specify a custom name.
2011-01-25 07:42:20 +00:00
};
2011-01-26 18:00:39 +00:00
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);
})();
2011-01-25 07:42:20 +00:00
</script>
</head>
<body>
2011-01-28 21:19:26 +00:00
<div id="container">
2011-01-27 02:45:34 +00:00
<div id = "helvetica-demo"></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>
<p>
2011-01-26 01:55:59 +00:00
<strong>gui-dat</strong> is a lightweight controller library for JavaScript. It allows you to easily manipulate variables and fire functions on the fly.
</p>
2011-01-26 23:25:40 +00:00
2011-01-27 02:45:34 +00:00
<ul>
2011-01-27 02:52:08 +00:00
<li><a href="https://github.com/jonobr1/GUI-DAT/raw/master/gui.min.js"><strong>Download the minified source</strong></a> <small>[9.8kb]</small></li>
2011-01-27 21:34:56 +00:00
<li><a href="http://github.com/jonobr1/GUI-DAT">Contribute on GitHub!</a></li>
2011-01-27 02:45:34 +00:00
</ul>
2011-01-26 23:25:40 +00:00
2011-01-26 01:55:59 +00:00
<h2>Basic Usage</h2>
2011-01-28 21:19:26 +00:00
<pre class="prettyprint">&lt;script type=&quot;text/javascript&quot; src=&quot;demo/demo.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
window.onload = function() {
var fizzyText = new <a href="demo/demo.js">FizzyText</a>(&quot;gui-dat&quot;);
var gui = new GUI();
gui.start();
// Text field
gui.add(fizzyText, &quot;message&quot;);
// Sliders with min and max
gui.add(fizzyText, &quot;maxSize&quot;, 0.5, 7);
gui.add(fizzyText, &quot;growthSpeed&quot;, 0.01, 1);
gui.add(fizzyText, &quot;speed&quot;, 0.1, 2);
2011-01-28 21:19:26 +00:00
// Sliders with min, max and increment
gui.add(fizzyText, &quot;noiseStrength&quot;, 10, 100, 5);
// Boolean checkbox
gui.add(fizzyText, &quot;displayOutline&quot;);
// Fires a function called &quot;explode&quot;
gui.add(fizzyText, &quot;explode&quot;).name(&quot;Explode!&quot;); // Specify a custom name.
};
&lt;/script&gt;</pre>
2011-01-26 01:55:59 +00:00
2011-01-27 02:45:34 +00:00
<ul id="desc">
<li><strong>gui-dat</strong> will infer the type of the property you're trying to add<br/>(based on its initial value) and create the corresponding control.</li>
<li>The properties must be public, i.e. defined by <code><strong>this</strong>.prop = value</code>.</li>
</ul>
2011-01-28 21:19:26 +00:00
<hr/>
2011-01-28 21:19:26 +00:00
<h2>Fire a function when someone uses a control</h2>
<pre class="prettyprint">gui.add(obj, "propName").onChange(function(n) {
2011-01-28 21:19:26 +00:00
alert("You changed me to " + n);
});</pre>
<hr/>
<h2>Listen for 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>
<pre class="prettyprint">gui.add(obj, "propName").listen();</pre>
<hr/>
<h2>Advanced listening</h2>
<p>By default, <strong>gui-dat</strong> will create an internal interval that checks for changes in the values you've marked with <code>listen()</code>. If you'd like to check for these changes in an interval of your own definition, use the following:
<pre class="prettyprint">
gui.autoListen = false; // disables internal interval
gui.add(obj, "propName").listen();
// Make your own loop
setInterval(function() {
gui.listen(); // updates values you've marked with listen()
}, 1000 / 60);
</pre>
<p>Alternatively, you can forego calling <code>listen()</code> on individual controllers, and instead choose to monitor changes in <em>all</em> values controlled by your gui.</p>
<pre class="prettyprint">
gui.autoListen = false; // disables internal interval
gui.add(obj, "add");
gui.add(obj, "lotsa");
gui.add(obj, "properties");
// Make your own loop
setInterval(function() {
gui.listenAll(); // updates ALL values managed by this gui
}, 1000 / 60);
</pre>
2011-01-26 02:15:20 +00:00
<footer>
2011-01-28 21:19:26 +00:00
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.
2011-01-26 02:15:20 +00:00
</footer>
2011-01-28 21:19:26 +00:00
</div>
2011-01-25 07:42:20 +00:00
</body>
2011-01-23 21:23:53 +00:00
</html>