Created
January 20, 2016 16:33
-
-
Save claytical/e3e7fa8acaee1eb2168b to your computer and use it in GitHub Desktop.
Global and Local Variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 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