Files
processing4/java/examples/Basics/Typography/Letters/Letters.pde
2012-12-09 21:49:22 +00:00

55 lines
1.0 KiB
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="Courier.ttf"; */
PFont f;
void setup() {
size(640, 360);
background(0);
// Create the font
println(PFont.list());
f = createFont("Monospaced", 24);
textFont(f);
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, 204, 0);
}
else {
fill(255);
}
// Draw the letter to the screen
text(letter, x, y);
// Increment the counter
counter++;
}
}
}