if()
if()
Allows the program to make a decision about which code to execute.
Reference:http://www.processing.org/reference/if_.html
Syntax if(expression) {
statements
}
for()
Controls a sequence of repetitions.
Reference:http://processing.org/reference/for_.html
Syntax for(init; test; update) {
statements
}
Let's start!
//Programed by Yeohyun Ahn
size(250,250);
PFont font;
font = loadFont("Univers-Condensed-48.vlw");
background(255);
for(int i=0;i<250;i=i+20){
textFont(font, 22);
fill(0,0,0);
text("A", i, 100);
}
Output:

//Programed by Yeohyun Ahn
size(250,250);
PFont font;
font = loadFont("Univers-Condensed-48.vlw");
background(255);
for(int i=0;i<250;i=i+20){
textFont(font, 22);
fill(0,0,0);
text("B", i, 100);
if(i==0 || i== 40 || i==80 || i==120 || i==160 || i==200 || i==240 )
{
textFont(font, 42);
fill(0,0,0,150);
text("C", i, 120);
}
}
Output:

//Programed by Yeohyun Ahn
size(400,400);
PFont font;
font = loadFont("Univers-Condensed-48.vlw");
background(255);
for(int i=0;i<400;i=i+20){
for(int j=0;j<400;j=j+20){
fill(0,0,0);
textFont(font, 22);
text("T", i, j);
}
}
Output:

//Programed by Yeohyun Ahn
size(400,400);
PFont font;
font = loadFont("Univers-Condensed-48.vlw");
background(255);
for(int i=0;i<400;i=i+20){
for(int j=0;j<400;j=j+20){
fill(0,0,0);
textFont(font, 22);
text("T", i, j);
if(i%100==0 || j%100==0)
{
fill(0,0,0);
textFont(font, 22);
text("A", i, j);
}
}
}
Output:

//Programed by Yeohyun Ahn
size(400,400);
PFont font;
font = loadFont("Univers-Condensed-48.vlw");
background(255);
for(int i=0;i<400;i=i+20){
for(int j=0;j<400;j=j+20){
if(i%100==0 || j%100==0)
{
fill(0,0,0);
textFont(font, 22);
text("A", i, j);
}
else {
fill(0,0,0);
textFont(font, 22);
text("T", i, j);
}
}
}
Output:

Exercise1) Change the value of 'i,' and 'j' as well as change your font size, styles, and color.
Exercise 2) Change || to && in if() statement.
Extra Tips:
%
Calculates the remainer when one number is divided by another.
It is extremely useful for keeping numbers within a boundary such as keeping a shape on the screen.
Reference:http://www.processing.org/reference/modulo.html
||
Reference: http://www.processing.org/reference/logicalOR.html
&&
Reference: http://www.processing.org/reference/logicalAND.html