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
Inhaltsverzeichnis
1;Front Cover;1 2;Learning Processing;4 3;Copyright Page;5 4;Contents;6 5;Acknowledgments;8 6;Introduction;10 6.1;What is this book?;10 6.2;Who is this book for?;10 6.3;What is Processing ?;10 6.4;But shouldnt I be Learning __________ ?;12 6.5;Write in this book!;13 6.6;How should I read this book?;13 6.7;Is this a textbook?;14 6.8;Will this be on the test?;15 6.9;Do you have a web site?;15 6.10;Take It One Step at a Time;16 6.11;Algorithms;17 7;Lesson 1: The Beginning;20 7.1;Chapter 1: Pixels;22 7.1.1;1.1 Graph Paper;22 7.1.2;1.2 Simple Shapes;24 7.1.3;1.3 Grayscale Color;28 7.1.4;1.4 RGB Color;31 7.1.5;1.5 Color Transparency;33 7.1.6;1.6 Custom Color Ranges;33 7.2;Chapter 2: Processing;36 7.2.1;2.1 Processing to the Rescue;36 7.2.2;2.2 How do I get Processing?;37 7.2.3;2.3 The Processing Application;37 7.2.4;2.4 The Sketchbook;38 7.2.5;2.5 Coding in Processing;39 7.2.6;2.6 Errors;41 7.2.7;2.7 The Processing Reference;43 7.2.8;2.8 The "Play" Button;44 7.2.9;2.9 Your First Sketch;45 7.2.10;2.10 Publishing Your Program;47 7.3;Chapter 3: Interaction;50 7.3.1;3.1 Go with the flow;50 7.3.2;3.2 Our Good Friends, setup() and draw();51 7.3.3;3.3 Variation with the Mouse;54 7.3.4;3.4 Mouse Clicks and Key Presses;58 7.4;Lesson One Project;61 8;Lesson 2: Everything You Need to Know;62 8.1;Chapter 4: Variables;64 8.1.1;4.1 What is a Variable?;64 8.1.2;4.2 Variable Declaration and Initialization;66 8.1.3;4.3 Using a Variable;68 8.1.4;4.4 Many Variables;71 8.1.5;4.5 System Variables;72 8.1.6;4.6 Random: Variety is the spice of life;74 8.1.7;4.7 Variable Zoog;76 8.2;Chapter 5: Conditionals;78 8.2.1;5.1 Boolean Expressions;78 8.2.2;5.2 Conditionals: If, Else, Else If;79 8.2.3;5.3 Conditionals in a Sketch;82 8.2.4;5.4 Logical Operators;85 8.2.5;5.5 Multiple Rollovers;88 8.2.6;5.6 Boolean Variables;89 8.2.7;5.7 A Bouncing Ball;92 8.2.8;5.8 Physics 101;97 8.3;Chapter 6: Loops;100 8.3.1;6.1 What is iteration? I mean, what is iteration? Seriously, what is iteration?;100 8.3.2;6.2 "WHIL
E" Loop, the Only Loop You Really Need;102 8.3.3;6.3 "Exit" Conditions;105 8.3.4;6.4 "FOR" Loop;106 8.3.5;6.5 Local vs. Global Variables (AKA "Variable Scope");109 8.3.6;6.6 Loop Inside the Main Loop;112 8.3.7;6.7 Zoog grows arms;114 8.4;Lesson Two Project;117 9;Lesson 3: Organization;118 9.1;Chapter 7: Functions;120 9.1.1;7.1 Break It Down;120 9.1.2;7.2 "User Defined" Functions;122 9.1.3;7.3 Defining a Function;122 9.1.4;7.4 Simple Modularity;123 9.1.5;7.5 Arguments;126 9.1.6;7.6 Passing a Copy;131 9.1.7;7.7 Return Type;133 9.1.8;7.8 Zoog Reorganization;136 9.2;Chapter 8: Objects;140 9.2.1;8.1 I'm down with OOP;140 9.2.2;8.2 Using an Object;141 9.2.3;8.3 Writing the Cookie Cutter;143 9.2.4;8.4 Using an Object: The Details;145 9.2.5;8.5 Putting It Together with a Tab;146 9.2.6;8.6 Constructor Arguments;149 9.2.7;8.7 Objects are data types too!;153 9.2.8;8.8 Object-Oriented Zoog;153 9.3;Lesson Three Project;156 10;Lesson 4: More of the Same;158 10.1;Chapter 9: Arrays;160 10.1.1;9.1 Arrays, why do we care?;160 10.1.2;9.2 What is an array?;163 10.1.3;9.3 Declaring and Creating an Array;164 10.1.4;9.4 Initializing an Array;166 10.1.5;9.5 Array Operations;167 10.1.6;9.6 Simple Array Example: The Snake;169 10.1.7;9.7 Arrays of Objects;172 10.1.8;9.8 Interactive Objects;174 10.1.9;9.9 Processing's Array Functions;177 10.1.10;9.10 One Thousand and One Zoogs;179 10.2;Lesson Four Project;181 11;Lesson 5: Putting It All Together;182 11.1;Chapter 10: Algorithms;184 11.1.1;10.1 Where have we been? Where are we going?;184 11.1.2;10.2 Algorithm: Dance to the beat of your own drum;185 11.1.3;10.3 From Idea to Parts;186 11.1.4;10.4 Part 1: The Catcher;187 11.1.5;10.5 Part 2: Intersection;189 11.1.6;10.6 Part 3: The Timer;194 11.1.7;10.7 Part 4: Raindrops;197 11.1.8;10.8 Integration: Puttin' on the Ritz;201 11.1.9;10.9 Getting Ready for Act II;207 11.2;Lesson Five Project;209 11.3;Chapter 11: Debugging;210 11.3.1;11.1 Tip #1: Take a break;210 11.3.2;11.2 Tip #2: Get another human bei
ng involved;210 11.3.3;11.3 Tip #3: Simplify;211 11.3.4;11.4 Tip #4: println() is your friend;212 11.4;Chapter 12: Libraries;214 11.4.1;12.1 Libraries;214 11.4.2;12.2 Built-in Libraries;215 11.4.3;12.3 Contributed Libraries;215 12;Lesson 6: The World Revolves Around You;218 12.1;Chapter 13: Mathematics;220 12.1.1;13.1 Mathematics and Programming;220 12.1.2;13.2 Modulus;221 12.1.3;13.3 Random Numbers;222 12.1.4;13.4 Probability Review;223 12.1.5;13.5 Event Probability in Code;224 12.1.6;13.6 Perlin Noise;226 12.1.7;13.7 Angles;229 12.1.8;13.8 Trigonometry;231 12.1.9;13.9 Oscillation;233 12.1.10;13.10 Recursion;235 12.1.11;13.11 Two-Dimensional Arrays;239 12.2;Chapter 14: Translation and Rotation (in 3D!);246 12.2.1;14.1 The Z-Axis;246 12.2.2;14.2 P3D vs. OPENGL;251 12.2.3;14.3 Vertex Shapes;252 12.2.4;14.4 Custom 3D Shapes;254 12.2.5;14.5 Simple Rotation;256 12.2.6;14.6 Rotation Around Different Axes;258 12.2.7;14.7 Scale;261 12.2.8;14.8 The Matrix: Pushing and Popping;261 12.2.9;14.9 A Processing Solar System;268 12.3;Lesson Six Project;271 13;Lesson 7: Pixels Under a Microscope;272 13.1;Chapter 15: Images;274 13.1.1;15.1 Getting Started with Images;274 13.1.2;15.2 Animation with an Image;276 13.1.3;15.3 My Very First Image Processing Filter;278 13.1.4;15.4 An Array of Images;279 13.1.5;15.5 Pixels, Pixels, and More Pixels;281 13.1.6;15.6 Intro to Image Processing;284 13.1.7;15.7 Our Second Image Processing Filter, Making Our Own Tint();285 13.1.8;15.8 Writing to Another PImage Object's Pixels;286 13.1.9;15.9 Level II: Pixel Group Processing;288 13.1.10;15.10 Creative Visualization;291 13.2;Chapter 16: Video;294 13.2.1;16.1 Before Processing;294 13.2.2;16.2 Live Video 101;295 13.2.3;16.3 Recorded Video;300 13.2.4;16.4 Software Mirrors;302 13.2.5;16.5 Video as Sensor, Computer Vision;308 13.2.6;16.6 Background Removal;312 13.2.7;16.7 Motion Detection;315 13.2.8;16.8 Computer Vision Libraries;318 13.2.9;16.9 The Sandbox;319 13.3;Lesson Seven Project;320 14;Lesson 8: T
he Outside World;322 14.1;Chapter 17: Text;324 14.1.1;17.1 Where do Strings come from?;324 14.1.2;17.2 What is a String?;325 14.1.3;17.3 Displaying Text;328 14.1.4;17.4 Text Animation;330 14.1.5;17.5 Text Mosaic;333 14.1.6;17.6 Rotating Text;335 14.1.7;17.7 Display text character by character;337 14.2;Chapter 18: Data Input;344 14.2.1;18.1 Manipulating Strings;344 14.2.2;18.2 Splitting and Joining;345 14.2.3;18.3 Reading and Writing Text Files;348 14.2.4;18.4 Text Parsing;354 14.2.5;18.5 Text Analysis;359 14.2.6;18.6 Asynchronous Requests;360 14.2.7;18.7 Beginner XML;363 14.2.8;18.8 Using the Processing XML Library;368 14.2.9;18.9 The Yahoo API;371 14.2.10;18.10 Sandbox;373 14.3;Chapter 19: Data Streams;376 14.3.1;19.1 Synchronous vs. Asynchronous;376 14.3.2;19.2 Creating a Server;377 14.3.3;19.3 Creating a Client;380 14.3.4;19.4 Broadcasting;382 14.3.5;19.5 Multi-User Communication, Part 1: The Server;385 14.3.6;19.6 Multi-User Communication, Part 2: The Client;388 14.3.7;19.7 Multi-User Communication, Part 3: All Together Now;390 14.3.8;19.8 Serial Communication;391 14.3.9;19.9 Serial communication with handshaking;393 14.3.10;19.10 Serial Communication with Strings;395 14.4;Lesson Eight Project;397 15;Lesson 9: Making Noise;398 15.1;Chapter 20: Sound;400 15.1.1;20.1 Really Simple Sound;400 15.1.2;20.2 Getting Started with Sonia and Minim;401 15.1.3;20.3 Basic Sound Playback;402 15.1.4;20.4 A Bit Fancier Sound Playback;408 15.1.5;20.5 Live input;410 15.1.6;20.6 Sound Thresholding;412 15.2;Chapter 21: Exporting;416 15.2.1;21.1 Web Applets;416 15.2.2;21.2 Stand-Alone Applications;416 15.2.3;21.3 High-Resolution PDFs;418 15.2.4;21.4 Images/saveFrame();421 15.2.5;21.5 MovieMaker;422 15.3;Lesson Nine Project;425 16;Lesson 10: Beyond Processing;426 16.1;Chapter 22: Advanced Object-Oriented Programming;428 16.1.1;22.1 Encapsulation;428 16.1.2;22.2 Inheritance;431 16.1.3;22.3 An Inheritance Example: SHAPES;434 16.1.4;22.4 Polymorphism;437 16.1.5;22.5 Overloading;440 16.2;
Chapter 23: Java;442 16.2.1;23.1 Revealing the Wizard;442 16.2.2;23.2 If we did not have Processing, what would our code look like?;442 16.2.3;23.3 Exploring the Java API;444 16.2.4;23.4 Other Useful Java Classes: ArrayList;447 16.2.5;23.5 Other Useful Java Classes: Rectangle;451 16.2.6;23.6 Exception (Error) Handling;453 16.2.7;23.7 Java Outside of Processing;455 17;Appendix: Common Errors;458 18;Index;466 18.1;A;466 18.2;B;466 18.3;C;466 18.4;D;467 18.5;E;467 18.6;F;467 18.7;G;468 18.8;H;468 18.9;I;468 18.10;J;468 18.11;K;469 18.12;L;469 18.13;M;469 18.14;N;469 18.15;O;469 18.16;P;470 18.17;Q;470 18.18;R;470 18.19;S;470 18.20;T;471 18.21;U;472 18.22;V;472 18.23;W;472 18.24;X;472 18.25;Y;472 18.26;Z;472