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

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

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

32 Getting Started with Processing<br />

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

Robot 1: Draw<br />

This is P5, the Processing Robot. There are 10 different programs<br />

to draw and animate him in the book—each one explores<br />

a different programming idea. P5’s design was inspired by Sputnik<br />

I (1957), Shakey from the Stanford Research Institute<br />

(1966–1972), the fighter drone in David Lynch’s Dune (1984),<br />

and HAL 9000 from 2001: A Space Odyssey (1968), among<br />

other robot favorites.<br />

The first robot program uses the drawing functions introduced<br />

in this chapter. The parameters to the fill() and stroke() functions<br />

set the gray values. The line(), ellipse(), and rect()<br />

functions define the shapes that create the robot’s neck, antennae,<br />

body, and head. To get more familiar with the functions, run<br />

the program and change the values to redesign the robot:<br />

size(720, 480);<br />

strokeWeight(2);<br />

background(0, 153, 204);<br />

ellipseMode(RADIUS);<br />

// Blue background<br />

// Neck<br />

stroke(255);<br />

line(266, 257, 266, 162);<br />

// Set stroke to white<br />

// Left

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

Saved successfully!

Ooh no, something went wrong!