Skip to content

Instantly share code, notes, and snippets.

@djsnipa1
Created October 8, 2019 13:22
Show Gist options
  • Select an option

  • Save djsnipa1/8a1ad9029e03ab614aa6ea236a1c2a50 to your computer and use it in GitHub Desktop.

Select an option

Save djsnipa1/8a1ad9029e03ab614aa6ea236a1c2a50 to your computer and use it in GitHub Desktop.
p5.gui pacman template
// A p5.gui Template feat. Pacman
// gui params
var myAngle = 30;
var myColor = '#eeee00';
var gui;
function setup() {
createCanvas(windowWidth, windowHeight);
// Create the GUI
sliderRange(0, 90, 1);
gui = createGui('p5.gui');
gui.addGlobals('myColor', 'myAngle');
// Only call draw when then gui is changed
noLoop();
}
function draw() {
// this is a piece of cake
background(0);
fill(myColor);
angleMode(DEGREES);
arc(width/2, height/2, 100, 100, myAngle/2, 360 - myAngle/2, PIE);
}
// dynamically adjust the canvas to the window
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.4/p5.js"></script>
<script src="https://cdn.rawgit.com/bit101/quicksettings/master/quicksettings.js"></script>
<script src="https://cdn.rawgit.com/bitcraftlab/p5.gui/master/libraries/p5.gui.js"></script>
body {
padding: 0;
margin: 0;
}
canvas {
vertical-align: top;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment