Skip to content

Instantly share code, notes, and snippets.

@GoSubRoutine GoSubRoutine/.block
Last active May 30, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.