Processing Day 11: Working with Type and Loops

I’m interested in words and typography, so I wanted to try and start incorporating that into my Processing sketches. So I was able to use my array and loop and create some cool textures using type!

Example 1


This first example uses one word and draws text to the screen using the default font. For my next exercise I will have to figure out how to load fonts.

It says the word “word.” Heh.

array7-text
And the code:

//an easier way to create an array is with a loop
size(600,600);
background(255);
smooth();


int n = 1000;
float[] xTop = new float[n];
float[] xBottom = new float[n];

//make a loop to fill those in

for(int i = 0; i < n; i++) {
   xTop[i] = random(0, 600); 
 xBottom[i] = random(0, 600); 
 textSize(20);
 fill(0, 102, 153);
 text("word", xTop[i], xBottom[i]);
}
 

Example 2


This second example uses a text string that says "Misunderstanding is the only way of interpreting" from Umberto Eco's Semiotics and the Philosophy of Language. It wraps the string into a constrained box and I then applied the loop to repeat it 1000 times and be placed randomly throughout the sketch area.
array8-textstring
And the code:

//an easier way to create an array is with a loop
size(600,600);
background(255);
smooth();

int n = 1000;
float[] xTop = new float[n];
float[] xBottom = new float[n];

//make a loop to fill those in
for(int i = 0; i < n; i++) {
   xTop[i] = random(0, 600); 
 xBottom[i] = random(0, 600); 
 String s = "Misunderstanding is the only way of interpreting.";
 fill(#338E78, 80);
text(s, xTop[i], xBottom[i], 70, 80); 

}