Removing a few examples for 2.0

This commit is contained in:
Casey Reas
2011-09-16 00:02:20 +00:00
parent 93b887ee24
commit c3b8b312a0
31 changed files with 318 additions and 417 deletions
@@ -1,39 +1,37 @@
/**
* Variable Scope.
*
* Variables may either have a global or local "scope".
* Variables have a global or local "scope".
* For example, variables declared within either the
* setup() or loop() functions may be only used in these
* setup() or draw() functions may be only used in these
* functions. Global variables, variables declared outside
* of setup() and loop(), may be used anywhere within the program.
* of setup() and draw(), may be used anywhere within the program.
* If a local variable is declared with the same name as a
* global variable, the program will use the local variable to make
* its calculations within the current scope. Variables may be localized
* within classes, functions, and iterative statements.
* its calculations within the current scope. Variables are localized
* within each block, the space between a { and }.
*/
int a = 20; // Create a global variable "a"
int a = 80; // Create a global variable "a"
void setup()
{
size(200, 200);
background(51);
void setup() {
size(640, 360);
background(0);
stroke(255);
noLoop();
}
void draw()
{
void draw() {
// Draw a line using the global variable "a"
line(a, 0, a, height);
// Create a new variable "a" local to the for() statement
for(int a=50; a<80; a += 2) {
for (int a = 120; a < 200; a += 2) {
line(a, 0, a, height);
}
// Create a new variable "a" local to the loop() method
int a = 100;
// Create a new variable "a" local to the draw() function
int a = 300;
// Draw a line using the new local variable "a"
line(a, 0, a, height);
@@ -44,16 +42,14 @@ void draw()
drawYetAnotherLine();
}
void drawAnotherLine()
{
void drawAnotherLine() {
// Create a new variable "a" local to this method
int a = 185;
int a = 320;
// Draw a line using the local variable "a"
line(a, 0, a, height);
}
void drawYetAnotherLine()
{
void drawYetAnotherLine() {
// Because no new local variable "a" is set,
// this lines draws using the original global
// variable "a" which is set to the value 20.