Files
processing4/java/examples/Basics/Typography/Letters/Letters.pde
Casey Reas 5b0214704c
2011-09-18 06:31:29 +00:00

51 lines
975 B
Plaintext

/**
* Letters.
*
* Draws letters to the screen. This requires loading a font,
* setting the font, and then drawing the letters.
*/
// The next line is needed if running in JavaScript Mode with Processing.js
/* @pjs font="Georgia.ttf"; */
void setup() {
size(640, 360);
background(0);
// Create the font
textFont(createFont("Georgia",24));
textAlign(CENTER, CENTER);
}
void draw() {
background(0);
// Set the left and top margin
int margin = 10;
translate(margin*4, margin*4);
int gap = 46;
int counter = 35;
for (int y = 0; y < height-gap; y += gap) {
for (int x = 0; x < width-gap; x += gap) {
char letter = char(counter);
if (letter == 'A' || letter == 'E' || letter == 'I' || letter == 'O' || letter == 'U') {
fill(255);
}
else {
fill(102);
}
// Draw the letter to the screen
text(letter, x, y);
// Increment the counter
counter++;
}
}
}