diff --git a/examples/js/index/index.js b/examples/js/index/index.js index 89d4374..44d5cad 100644 --- a/examples/js/index/index.js +++ b/examples/js/index/index.js @@ -243,8 +243,8 @@ function log(...args) { const lineNo = parseInt(logElem.dataset.lineNo || 1); const lines = logElem.textContent.split('\\n'); lines.push(\`\${lineNo}: \${args.join(' ')}\`); - if (lines.length > 3) { - lines.shift(); + if (lines.length > 5) { + lines.splice(0, lines.length - 5); } logElem.textContent = lines.join('\\n'); logElem.dataset.lineNo = lineNo + 1; diff --git a/index.html b/index.html index 1532635..a942824 100644 --- a/index.html +++ b/index.html @@ -304,6 +304,8 @@
const waveData = new Array(100).fill(0);
+const waveData2 = new Array(100).fill(0);
const gui = new GUI();
helpers.graph(
@@ -330,6 +341,14 @@ Canvas:
max: +2,
interval: 200,
});
+helpers.graph(
+ gui.addCanvas('wave 2').canvas,
+ waveData2,
+ {
+ min: -2,
+ max: +2,
+ interval: 10,
+ });
@@ -502,9 +521,34 @@ Get called when the user changes a value.
+ +
+const s = {
+ count: 123,
+ name: 'Buffy',
+ speed: 45,
+};
+
+const gui = new GUI();
+gui.add(s, 'count').onChange(logCount);
+gui.add(s, 'name').onChange(logName);
+gui.add(s, 'speed', 0, 100).onChange(logSpeed);
+gui.onChange(logAll); // or folder
+
+function logCount(v) { log('count:', v); }
+function logName(v) { log('name:', v); }
+function logSpeed(v) { log('speed:', v); }
+function logAll() { log(JSON.stringify(s)); }
+
+ Listens for changes.
+Listens for changes. (auto update)