This commit is contained in:
Casey Reas
2011-09-05 23:20:15 +00:00
parent 5a1c9d8bab
commit b99624cdb4
6 changed files with 30 additions and 30 deletions
@@ -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;
@@ -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);
@@ -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);