Learning Processing
eBook - ePub

Learning Processing

A Beginner's Guide to Programming Images, Animation, and Interaction

Daniel Shiffman

Share book
  1. 472 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Learning Processing

A Beginner's Guide to Programming Images, Animation, and Interaction

Daniel Shiffman

Book details
Book preview
Table of contents
Citations

About This Book

The free, open-source Processing programming language environment was created at MIT for people who want to develop images, animation, and sound. Based on the ubiquitous Java, it provides an alternative to daunting languages and expensive proprietary software. This book gives graphic designers, artists and illustrators of all stripes a jump start to working with processing by providing detailed information on the basic principles of programming with the language, followed by careful, step-by-step explanations of select advanced techniques.The author teaches computer graphics at NYU's Tisch School of the Arts, and his book has been developed with a supportive learning experience at its core. From algorithms and data mining to rendering and debugging, it teaches object-oriented programming from the ground up within the fascinating context of interactive visual media.Previously announced as "Pixels, Patterns, and Processing"

  • A guided journey from the very basics of computer programming through to creating custom interactive 3D graphics
  • Step-by-step examples, approachable language, exercises, and LOTS of sample code support the reader's learning curve
  • Includes lessons on how to program live video, animated images and interactive sound

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on ā€œCancel Subscriptionā€ - itā€™s as simple as that. After you cancel, your membership will stay active for the remainder of the time youā€™ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlegoā€™s features. The only differences are the price and subscription period: With the annual plan youā€™ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, weā€™ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Learning Processing an online PDF/ePUB?
Yes, you can access Learning Processing by Daniel Shiffman in PDF and/or ePUB format, as well as other popular books in Informatica & Linguaggi di programmazione. We have over one million books available in our catalogue for you to explore.

Information

Year
2009
ISBN
9780080920061
Lesson 1
The Beginning
Chapter 1 Pixels
Chapter 2 Processing
Chapter 3 Interaction
Chapter 1

Pixels

ā€œA journey of a thousand miles begins with a single step.ā€
ā€”Lao-tzu
In this chapter:
ā€“ Specifying pixel coordinates.
ā€“ Basic shapes: point, line, rectangle, ellipse.
ā€“ Color: grayscale, ā€œRGB.ā€
ā€“ Color transparency.
Note that we are not doing any programming yet in this chapter! We are just dipping our feet in the water and getting comfortable with the idea of creating onscreen graphics with text-based commands, that is, ā€œcodeā€!

1.1 Graph Paper

This book will teach you how to program in the context of computational media, and it will use the development environment Processing (http://www.processing.org) as the basis for all discussion and examples. But before any of this becomes relevant or interesting, we must first channel our eighth grade selves, pull out a piece of graph paper, and draw a line. The shortest distance between two points is a good old fashioned line, and this is where we begin, with two points on that graph paper.
Figure 1.1 shows a line between point A (1,0) and point B (4,5). If you wanted to direct a friend of yours to draw that same line, you would give them a shout and say ā€œdraw a line from the point one-zero to the point four-five, please.ā€ Well, for the moment, imagine your friend was a computer and you wanted to instruct this digital pal to display that same line on its screen. The same command applies (only this time you can skip the pleasantries and you will be required to employ a precise formatting). Here, the instruction will look like this:
line(1,0,4,5);
image
Fig. 1.1
Congratulations, you have written your first line of computer code! We will get to the precise formatting of the above later, but for now, even without knowing too much, it should make a fair amount of sense. We are providing a command (which we will refer to as a ā€œfunctionā€) for the machine to follow entitled ā€œline.ā€ In addition, we are specifying some arguments for how that line should be drawn, from pointA (0,1) to point B (4,5). If you think of that line of code as a sentence, the function is a verb and the arguments are the objects of the sentence. The code sentence also ends with a semicolon instead of a period.
image
Fig. 1.2
The key here is to realize that the computer screen is nothing more than a fancier piece of graph paper. Each pixel of the screen is a coordinateā€”two numbers, an ā€œxā€ (horizontal) and a ā€œyā€ (vertical)ā€”that determine the location of a point in space. And it is our job to specify what shapes and colors should appear at these pixel coordinates.
Nevertheless, there is a catch here. The graph paper from eighth grade (ā€œCartesian coordinate systemā€) placed (0,0) in the center with the y-axis pointing up and the x-axis pointing to the right (in the positive direction, negative down and to the left). The coordinate system for pixels in a computer window, however, is reversed along the y-axis. (0,0) can be found at the top left with the positive direction to the right horizontally and down vertically. See Figure 1.3.
image
Exercise 1-1: Looking at how we wrote the instruction for line ā€œline(1,0,4,5);ā€ how would you guess you would write an instruction to draw a rectangle? A circle? A triangle? Write out the instructions in English and then translate it into ā€œcode.ā€
English:_________________________________________________________________
Code:_________________________________________________________________
English:_________________________________________________________________
Code:___________________________________...

Table of contents