THE SPARKFUN GUIDE TO PROCESSING CREATE INTERACTIVE ART WITH CODE BY DEREK RUNBERG SAN FRANCISCO THE SPARKFUN GUIDE TO PROCESSING. Copyright 2015 by SparkFun Electronics. All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. Printed in USA First printing 19 18 17 16 151 2 3 4 5 6 7 8 9 ISBN-10: 1-59327-612-5 ISBN-13: 978-1-59327-612-6 Publisher: William Pollock Production Editor: Alison Law Cover Illustration: Pete Holm Interior Design: Beth Middleworth Developmental Editor: Jennifer Griffith-Delgado Technical Reviewer: Andres Colubri Copyeditor: Rachel Monaghan Compositor: Susan Glinert Stevens Proofreader: James Fraleigh For information on distribution, translations, or bulk sales, please contact No Starch Press, Inc. directly: No Starch Press, Inc. 245 8th Street, San Francisco, CA 94103 phone: 415.863.9900; www.nostarch.com Library of Congress Cataloging-in-Publication Data:Runberg, Derek.
The SparkFun guide to Processing : create interactive art with code / by Derek Runberg.
pages cm
Includes index.
Summary: A project-based guide for beginners that teaches how to use the programming language Processing.
Covers digital artwork and hardware topics including pixel art, photo editing, video manipulation, 3D design, and using Processing to control an Arduino-- Provided by publisher.
ISBN 978-1-59327-612-6 -- ISBN 1-59327-612-5
1. Processing (Computer program language) 2. Computer art. 3. Digital video. 4.
Arduino (Programmable controller)--Programming. I. SparkFun Electronics. II. Title.
QA76.73.P75.R86 2015
776--dc23
2015024859
No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners.
Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The information in this book is distributed on an As Is basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it. THIS BOOK IS DEDICATED TO
THE EDUCATORS ACROSS THE UNITED STATES
WHO ARE WORKING DILIGENTLY TO BRING
COMPUTER SCIENCE AND ELECTRONICS
TO THE FOREFRONT
OF THEIR CLASSROOM PRACTICE. About the Author Derek Runberg is the educational technologist at SparkFun Electronics, a position dedicated to creating outstanding curriculum for electronics and computer science education.
Before joining SparkFun, Derek was a middle school technology and engineering educator for five years. During this time, he ran a number of after-school and summer programs on both programmable electronics and Processing. Dereks time as an educator has culminated in this book, which takes computer science concepts and breaks them into digestible chunks that everyone can understand. Derek documented his work with Processing in the middle school classroom as the author of the website Processing and Interactivity for Educators. This website focused on developing curricula for teachers using Processing in the mainstream classroom. In his free time, Derek likes to spend time with his two children, Bear and Bridge, and his wife, Zondra. In his free time, Derek likes to spend time with his two children, Bear and Bridge, and his wife, Zondra.
If you ever run into Derek, he will talk your ear off about either food or technology; choose wisely. He enjoys the outdoors, writes code when its raining, and has been known to do both at the same time! About Sparkfun Electronics SparkFun is an online retailer that produces and sells the widgets and parts that end up in a lot of maker projects, prototypes, and even the International Space Station. Nathan Seidle started the company after blowing a circuit board in 2003, while he was an undergraduate at Colorado University. At the time, circuit boards were really hard to get; you had to fax your credit card to another country and hope that you got your hardware in six to eight weeks. Nathan felt he could do better, and he did. SparkFun.com was born, and it now sells over 3,000 different parts of all shapes and sizes for your digital electronic needs.
From a basic Arduino to GPS modules, you can find them and all of the documentation you need to get up and running at SparkFun. SparkFuns Department of Education develops curricula and runs professional development programs for educators of all kinds. The department is at the forefront of a number of computer science and maker initiatives that are making headway in the classroom. Processing is an everyday tool in the department and is a foundational part of SparkFuns professional development workshops around the country. You can learn more about SparkFun and the Department of Education at https://www.sparkfun.com/ and https://learn.sparkfun.com/. About the Technical Reviewer Andres Colubri is an active contributor to the Processing project, as the main developer of the OpenGL renderer and the Video library in Processing 2 and 3.
He studied physics and mathematics in Argentina and later received an MFA from UCLAs Design Media Arts program. He uses Processing as the main tool to bridge his interests in computer graphics, visualization, and statistical modeling. You can see some of his work at http://andrescolubri.net/. Contents Contents in Detail FOREWORD THREE HUNDRED YEARS AGO , books were limited to a select few: members of the clergy and the upper class. Then, as access to education increased dramatically and the printing industry took off, the world struggled to change the educational system to teach students the fundamentals of reading. Today, we take for granted that every student will learn how to readits a necessary skill to operate in the modern world.
But its interesting to note that we have the same anxieties now about how to teach every student the fundamentals of programming as people had about reading so long ago. We all know it needs to happen; the devil is in the details. I learned to program by getting a bootlegged copy of Visual Basic from one of my parents friends and spending countless hours re-creating a board game called Stratego. I even made it work over a modem so I could play against friends who lived across town. This wasnt part of a class that I took in seventh grade; it was raw, unguided determination. I learned a tremendous amount, but it was a slow process and I often programmed in very wrong ways.
I would design what should happen when a piece was placed on a player square and then copy and paste that code 72 times across 72 different player squares. I distinctly remember the day I discovered what a function call was and thinking, Whoa! Thats how that works?! Overnight, my code got a lot smaller and easier to modify, and I learned something I now use every day of my life. I seriously love writing code. Based on this experience, I am of two minds about the learning process. There is part of me that believes every person needs to have the experience of trying to build something, to design something, to sculpt something before they discover the tips and tricks of their profession. That way we will truly understand just how beneficial those tools are.
Next page