Type + Code: Processing For Designers

Page 48

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

11.1

Viviana Cordova.

for( ) and rotate( ) Repetition and rotation Using repetition with for() and rotation with rotate(), a modified serif alphabet has been created (see right). The amount of repetition is set with for(int i=0;i<6;i=i+1)— it starts with i equals 0, then tests if i is less than 6, and creates the new value of i as i plus 1. This ensures the letter is rotated six times. Color is set as black fill(0,0,0) and the letter has been aligned in the center with textAlign(CENTER). Finally, pushMatrix() sets the structure for our finished visual using the value i in rotate(PI*i/3) (as the value of i increases as a result of the for( ) function, so the letter is rotated) and text("S",0,0). The function of popMatrix( ) closes this part of the operation.

PFont myFont;

fill(0,0,0);

void setup(){

textAlign(CENTER);

size(800, 800);

pushMatrix(); rotate(PI*i/3);

background(255,255,255);

text("S",0,0); popMatrix();

// String[] fontList = PFont. If you want to change the font styles, please delete // on the code (right) and all of the available fonts will be displayed on the bottom window in Processing. And then, if you want to change the font, for example, Times-Roman to Helvetica, please change the “Times-Roman” in myFont = createFont("TimesRoman",48).

PushMatrix and popMatrix are introduced on page 31.

list(); // println(fontList); myFont = createFont("TimesRoman",48); textFont(myFont,272); translate(400,400); for(int i=0;i<6;i=i+1) {

} }


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