04.04.2013 Views

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

This will output a list of all the fonts currently installed on your computer. In the line of the<br />

sketch that reads font2 = createFont("Helvetica", 32);, you can replace Helvetica<br />

with any font you have installed.<br />

In addition to createFont(), I also used the loadFont() comm<strong>and</strong>:<br />

font = loadFont("Garamond-32.vlw");<br />

Before I could use loadFont(), I needed to first use the CreateFont comm<strong>and</strong> from the<br />

Tools menu. I selected Garamond <strong>and</strong> a size of 32, <strong>and</strong> left the smooth box checked <strong>and</strong><br />

the All Characters box unchecked. If you don’t have the font Garamond, pick another font,<br />

but be sure to change the name in the following sketch. The Tools ➤ CreateFont comm<strong>and</strong><br />

automatically creates <strong>and</strong> installs the VLW font in your current sketch’s data directory.<br />

/*<br />

Orbiting Text<br />

Ira Greenberg, November 14, 2005<br />

*/<br />

PFont font;<br />

String s = "Spinning Word";<br />

PFont font2;<br />

String s2 = "flipping Word";<br />

float ang = 0, ang2 =0;<br />

void setup(){<br />

size(400, 400, P3D);<br />

//load text from data directory<br />

font = loadFont("Garamond-32.vlw");<br />

//dynamically create text <strong>and</strong> specify size as the second argument<br />

font2 = createFont("Helvetica", 32);<br />

}<br />

//rotates text in 3D space<br />

void draw(){<br />

background(255);<br />

translate(width/2, height/2, 50);<br />

pushMatrix();<br />

rotateY(radians(ang));<br />

textFont(font, 32);<br />

fill(45, 78, 28);<br />

text(s, -textWidth(s)/2, 0, 100);<br />

popMatrix();<br />

pushMatrix();<br />

rotateX(radians(ang2));<br />

textFont(font2, 24);<br />

fill(250, 125, 28);<br />

text(s2, -textWidth(s2)/2, 0, 0);<br />

popMatrix();<br />

ang+=3;<br />

ang2-=10;<br />

}<br />

PROCESSING LANGUAGE API<br />

739<br />

A

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!