09.04.2016 Views

www.ebook777.com

Make_Getting_Started_with_Processing_Second_Edition

Make_Getting_Started_with_Processing_Second_Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

96 Getting Started with Processing<br />

<strong>www</strong>.<strong>ebook777.com</strong><br />

void draw() {<br />

background(102);<br />

textSize(32);<br />

text("That’s one small step for man...", 25, 60);<br />

textSize(16);<br />

text("That’s one small step for man...", 27, 90);<br />

}<br />

The first parameter to text() is the character(s) to draw to the<br />

screen. (Notice that the characters are enclosed within quotes.)<br />

The second and third parameters set the horizontal and vertical<br />

location. The location is relative to the baseline of the text (see<br />

Figure 7-1).<br />

Figure 7-1. Typography coordinates<br />

Example 7-7: Draw Text in a Box<br />

You can also set text to draw inside a box by adding fourth and<br />

fifth parameters that specify the width and height of the box:<br />

PFont font;<br />

void setup() {<br />

size(480, 120);<br />

font = createFont("SourceCodePro-Regular.ttf", 24);<br />

textFont(font);<br />

}

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

Saved successfully!

Ooh no, something went wrong!