Skip to content

Instantly share code, notes, and snippets.

@claytical
Created January 20, 2016 16:33
Show Gist options
  • Save claytical/e3e7fa8acaee1eb2168b to your computer and use it in GitHub Desktop.
Save claytical/e3e7fa8acaee1eb2168b to your computer and use it in GitHub Desktop.
Global and Local Variables
/* variables declared outside of functions are
are called "global" as they can be referred to
anywhere. */
var g_variable = 50;
function setup() {
createCanvas(400,400);
/* variables declared inside of a function are
only available in that specific function.
*/
var l_variable = 30;
ellipse(l_variable, g_variable, 10, 10);
}
function draw() {
ellipse(100, 100, g_variable, g_variable)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment