Type + Code: Processing For Designers

Page 34

Type + Code page >L< even {10} page Yeohyun Ahn.

7.0

Viviana Cordova.

for( ) Repetition We use the function for( ) to create a series of repetitions, here, a repetitive horizontal line formed by an uppercase letter “T”. The distance between each letter is even and controlled by the values we add to for( ). The for() function needs a beginning, middle and end, called: for(initiate; test; update), which are divided by a semicolon (;). In this case, initiate is the beginning point (i equals 0 i=0), test sees if the value of i is less than 250 i<250, if it is, the function then goes to update, to which we have given the value of i equals i plus 5 i=i+5, so the value of i is increased by 5. By using this changing value i, we can have the letter “T” displayed 5 pixels apart across the screen. We need to use the text( ) function to do this text("T", i,40). This calls the letter “T” and uses the variable i to control the x coordinate, while the y coordinate has a constant value of 40, creating a horizontal line running off the canvas size window, which is 250 by 250 pixels. The y coordinate value places the line of “T”s high up on the canvas.

PFont myFont; void setup() { size(250,250); myFont = createFont("Univers",48); textFont(myFont,10); background(255); //for(initiate;test;update) for(int i=0;i<250;i=i+5) { for(int i=0;i<250;i=i+5)

fill(0,0,0); //textFont(font,size) textFont(myFont, 22); //text(letter,i:x ,40:y) text("T",i,40); } }


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.