Skip to content

Instantly share code, notes, and snippets.

@GoSubRoutine
Last active May 30, 2017 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GoSubRoutine/861b48f0b0118219c6a7cdd28309ee62 to your computer and use it in GitHub Desktop.
Save GoSubRoutine/861b48f0b0118219c6a7cdd28309ee62 to your computer and use it in GitHub Desktop.
DatGuiTest
height: 600
<script async src=http://CDN.JSDelivr.net/npm/p5></script>
<script defer src=http://CDN.JSDelivr.net/gh/dataarts/dat.gui/build/dat.gui.min.js></script>
<script defer src=sketch.js></script>
/**
* DatGuiTest (v2.1.1)
* Kuprin5 (2017-Feb-23)
* mod GoToLoop
*
* forum.Processing.org/two/discussion/21777/
* dat-gui-don-t-update-variables-value#Item_1
*
* Bl.ocks.org/GoSubRoutine/861b48f0b0118219c6a7cdd28309ee62
*/
"use strict";
const props = {
bgColor: [102, 0, 204],
fgColor: 204,
useStroke: true
};
function setup() {
createCanvas(600, 600);
strokeWeight(2.5).ellipseMode(CENTER);
colorMode(RGB).noLoop();
createGUI();
}
function draw() {
background(props.bgColor).fill(props.fgColor);
props.useStroke && stroke(0) || noStroke();
ellipse(width>>1, height>>1, height>>1);
}
function mousePressed() { // Conflicting listener fix hack!
return false;
}
function createGUI() {
const gui = new dat.GUI;
gui.addColor(props, 'bgColor').onFinishChange(redraw);
gui.add(props, 'fgColor', 0, 0xff, 1).onChange(redraw);
gui.add(props, 'useStroke').onChange(redraw);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment