From b99624cdb4f9d683b58c3a634e06bba7c18e7d5e Mon Sep 17 00:00:00 2001 From: Casey Reas Date: Mon, 5 Sep 2011 23:20:15 +0000 Subject: [PATCH] --- .../Basics/Color/Brightness/Brightness.pde | 2 -- .../Control/Conditionals2/Conditionals2.pde | 12 ++++---- .../Basics/Data/Variables/Variables.pde | 30 ++++++++++--------- .../Topics/Cellular Automata/Wolfram/CA.pde | 6 ++-- .../Cellular Automata/Wolfram/Wolfram.pde | 3 -- .../Topics/Interaction/Tickle/Tickle.pde | 7 ++--- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/java/examples/Basics/Color/Brightness/Brightness.pde b/java/examples/Basics/Color/Brightness/Brightness.pde index d227ce64c..261fdce38 100644 --- a/java/examples/Basics/Color/Brightness/Brightness.pde +++ b/java/examples/Basics/Color/Brightness/Brightness.pde @@ -4,8 +4,6 @@ * * Brightness is the relative lightness or darkness of a color. * Move the cursor vertically over each bar to alter its brightness. - * - * Updated 28 February 2010. */ int barWidth = 20; diff --git a/java/examples/Basics/Control/Conditionals2/Conditionals2.pde b/java/examples/Basics/Control/Conditionals2/Conditionals2.pde index a2bc272b5..b43be6e2c 100644 --- a/java/examples/Basics/Control/Conditionals2/Conditionals2.pde +++ b/java/examples/Basics/Control/Conditionals2/Conditionals2.pde @@ -1,9 +1,9 @@ /** * Conditionals 2. * - * We extend the language of conditionals by adding the - * keyword "else". This allows conditionals to ask - * two or more sequential questions, each with a different + * We extend the language of conditionals from the previous + * example by adding the keyword "else". This allows conditionals + * to ask two or more sequential questions, each with a different * action. */ @@ -11,14 +11,16 @@ size(640, 360); background(0); for(int i = 2; i < width-2; i += 2) { - // If 'i' divides by 20 with no remainder - // draw the first line else draw the second line + // If 'i' divides by 20 with no remainder if((i % 20) == 0) { stroke(255); line(i, 80, i, height/2); + // If 'i' divides by 10 with no remainder } else if ((i % 10) == 0) { stroke(153); line(i, 20, i, 180); + // If neither of the above two conditions are met + // then draw this line } else { stroke(102); line(i, height/2, i, height-20); diff --git a/java/examples/Basics/Data/Variables/Variables.pde b/java/examples/Basics/Data/Variables/Variables.pde index 9566ae472..597e72508 100644 --- a/java/examples/Basics/Data/Variables/Variables.pde +++ b/java/examples/Basics/Data/Variables/Variables.pde @@ -1,23 +1,25 @@ /** * Variables. * - * Variables are used for storing values. In this example, changing - * the values of variables 'a' and 'b' significantly change the composition. + * Variables are used for storing values. In this example, change + * the values of variables 'a' and 'b' to affect the composition. */ -size(200, 200); +size(640, 360); background(0); stroke(153); +strokeWeight(2); + +int a = 60; +int b = 100; +int c = 200; +int d = 120; + +line(a, b, a+c, b); + +a += 100; +b += 50; +line(a, b, a+c, b); + -int a = 20; -int b = 50; -int c = a*8; -int d = a*9; -int e = b-a; -int f = b*2; -int g = f+e; -line(a, f, b, g); -line(b, e, b, g); -line(b, e, d, c); -line(a, e, d-e, c); diff --git a/java/examples/Topics/Cellular Automata/Wolfram/CA.pde b/java/examples/Topics/Cellular Automata/Wolfram/CA.pde index 30d02a378..ce0b484af 100644 --- a/java/examples/Topics/Cellular Automata/Wolfram/CA.pde +++ b/java/examples/Topics/Cellular Automata/Wolfram/CA.pde @@ -37,7 +37,8 @@ class CA { for (int i = 0; i < cells.length; i++) { cells[i] = 0; } - cells[cells.length/2] = 1; // We arbitrarily start with just the middle cell having a state of "1" + // We arbitrarily start with just the middle cell having a state of "1" + cells[cells.length/2] = 1; generation = 0; } @@ -69,7 +70,8 @@ class CA { } // Implementing the Wolfram rules - // Could be improved and made more concise, but here we can explicitly see what is going on for each case + // Could be improved and made more concise, but here we can + // explicitly see what is going on for each case int rules (int a, int b, int c) { if (a == 1 && b == 1 && c == 1) return rules[0]; if (a == 1 && b == 1 && c == 0) return rules[1]; diff --git a/java/examples/Topics/Cellular Automata/Wolfram/Wolfram.pde b/java/examples/Topics/Cellular Automata/Wolfram/Wolfram.pde index 328e6b9b9..fe604c0b0 100644 --- a/java/examples/Topics/Cellular Automata/Wolfram/Wolfram.pde +++ b/java/examples/Topics/Cellular Automata/Wolfram/Wolfram.pde @@ -33,6 +33,3 @@ void mousePressed() { ca.randomize(); ca.restart(); } - - - diff --git a/java/examples/Topics/Interaction/Tickle/Tickle.pde b/java/examples/Topics/Interaction/Tickle/Tickle.pde index b01794b1f..d9f799f99 100644 --- a/java/examples/Topics/Interaction/Tickle/Tickle.pde +++ b/java/examples/Topics/Interaction/Tickle/Tickle.pde @@ -10,10 +10,9 @@ float x, y; // X and Y coordinates of text float hr, vr; // horizontal and vertical radius of the text void setup() { - size(200, 200); - PFont font = loadFont("AmericanTypewriter-24.vlw"); - textFont(font); + size(640, 360); textAlign(CENTER, CENTER); + textSize(48); hr = textWidth(message) / 2; vr = (textAscent() + textDescent()) / 2; noStroke(); @@ -22,7 +21,7 @@ void setup() { } void draw() { - // instead of clearing the background, fade it by drawing + // Instead of clearing the background, fade it by drawing // a semi-transparent rectangle on top fill(204, 120); rect(0, 0, width, height);