Processing: A Programming Handbook for Visual Designers and Artists

Download Processing: A Programming Handbook for Visual Designers and Artists

Post on 07-Apr-2016

215 views

Category:

Documents

1 download

Embed Size (px)

DESCRIPTION

 

TRANSCRIPT

<ul><li><p>Processing:a programming handbook for visual designers and artists </p><p>Casey ReasBen Fry</p><p>The MIT PressCambridge, MassachusettsLondon, England</p><p>Reas_00_i-xxvi.indd Sec1:iiiReas_00_i-xxvi.indd Sec1:iii 5/16/07 9:53:05 AM5/16/07 9:53:05 AM</p></li><li><p> 2007 Massachusetts Institute of Technology</p><p>All rights reserved. No part of this book may be reproduced in any form by any electronic or mechanical means (including photocopying, recording, or information storage and retrieval) without permission in writing from the publisher.</p><p>MIT Press books may be purchased at special quantity discounts for business or sales promotional use. For information, please email special_sales@mitpress.mit.edu or write to Special Sales Department, The MIT Press, 55 Hayward Street, Cambridge, MA 02142.</p><p>Printed and bound in the United States of America.</p><p>Library of Congress Cataloging-in-Publication Data</p><p>Reas, Casey. Processing : a programming handbook for visual designers and artists / Casey Reas &amp; Ben Fry ; foreword by John Maeda. p. cm. Includes bibliographical references and index. ISBN 978-0-262-18262-1 (hardcover : alk. paper) 1. Computer programming. 2. Computer graphicsComputer programs. 3. Digital artComputer programs. 4. ArtData processing. 5. Art and technology. I. Fry, Ben. II. Title. </p><p>QA76.6.R4138 2007005.1dc22 2006034768</p><p>10 9 8 7 6 5 4 3 2 1</p><p>Reas_00_i-xxvi.indd Sec1:ivReas_00_i-xxvi.indd Sec1:iv 5/16/07 9:53:06 AM5/16/07 9:53:06 AM</p></li><li><p>29 34 45 57 67 72</p><p>91 99 113 121 131 141</p><p>192 204 208 221 225 233</p><p>247 289 297 307 320 324</p><p>336 344 352 354 359 409</p><p>447 451 472 493 530 551</p><p>84</p><p>189</p><p>244</p><p>331</p><p>415</p><p>535</p><p>Reas_00_i-xxvi.indd Sec1:viReas_00_i-xxvi.indd Sec1:vi 5/16/07 9:53:06 AM5/16/07 9:53:06 AM</p></li><li><p>vii </p><p> Foreword Preface </p><p> Processing . . . Using Processing</p><p> Structure 1: Code Elements Shape 1: Coordinates, Primitives Data 1: Variables Math 1: Arithmetic, Functions Control 1: Decisions Control 2: Repetition Shape 2: Vertices Math 2: Curves Color 1: Color by Numbers Image 1: Display, Tint Data 2: Text Data 3: Conversion, Objects Typography 1: Display Math 3: Trigonometry Math 4: Random Transform 1: Translate, Matrices Transform 2: Rotate, Scale Development 1: Sketching, Techniques Synthesis 1: Form and Code Interviews 1: Print</p><p> Structure 2: Continuous Structure 3: Functions Shape 3: Parameters, Recursion Input 1: Mouse I Drawing 1: Static Forms Input 2: Keyboard Input 3: Events Input 4: Mouse II Input 5: Time, Date Development 2: Iteration, Debugging Synthesis 2: Input and Response Interviews 2: Software, Web</p><p> Motion 1: Lines, Curves Motion 2: Machine, Organism Data 4: Arrays Image 2: Animation Image 3: Pixels Typography 2: Motion Typography 3: Response Color 2: Components Image 4: Filter, Blend, Copy, Mask Image 5: Image Processing Output 1: Images Synthesis 3: Motion and Arrays Interviews 3: Animation, Video</p><p> Structure 4: Objects I Drawing 2: Kinetic Forms Output 2: File Export Input 6: File Import Input 7: Interface Structure 5: Objects II Simulate 1: Biology Simulate 2: Physics Synthesis 4: Structure, Interface Interviews 4: Performance, Installation</p><p> Extension 1: Continuing . . . Extension 2: 3D Extension 3: Vision Extension 4: Network Extension 5: Sound Extension 6: Print Extension 7: Mobile Extension 8: Electronics</p><p> Appendixes Related Media Glossary Code Index Index</p><p>Contents</p><p>xixxxi</p><p>1</p><p>9</p><p>17</p><p>23</p><p>37</p><p>43</p><p>51</p><p>61</p><p>69</p><p>79</p><p>85</p><p>95</p><p>101</p><p>105</p><p>111</p><p>117</p><p>127</p><p>133</p><p>137</p><p>145</p><p>149</p><p>155</p><p>173</p><p>181</p><p>197</p><p>205</p><p>217</p><p>223</p><p>229</p><p>237</p><p>245</p><p>251</p><p>255</p><p>261</p><p>279</p><p>291</p><p>301</p><p>315</p><p>321</p><p>327</p><p>333</p><p>337</p><p>347</p><p>355</p><p>367</p><p>371</p><p>377</p><p>395</p><p>413</p><p>421</p><p>427</p><p>435</p><p>453</p><p>461</p><p>477</p><p>495</p><p>501</p><p>519</p><p>525</p><p>547</p><p>563</p><p>579</p><p>603</p><p>617</p><p>633</p><p>661</p><p>693</p><p>699</p><p>703</p><p>705</p><p>Reas_00_i-xxvi.indd Sec1:viiReas_00_i-xxvi.indd Sec1:vii 5/16/07 9:53:09 AM5/16/07 9:53:09 AM</p></li><li><p>viii </p><p>88 342 55 65 305 220</p><p>98 319 323 351 353 359</p><p>225 232 240 247 444 44</p><p>124 129 288 296 29 32</p><p>202 470 488 184 190 407</p><p>141 113 329 335 530 535</p><p>415</p><p>207</p><p>83</p><p>75</p><p>455</p><p>551</p><p>Reas_00_i-xxvi.indd Sec1:viiiReas_00_i-xxvi.indd Sec1:viii 5/16/07 9:53:10 AM5/16/07 9:53:10 AM</p></li><li><p>ix </p><p> Foreword Preface </p><p> Processing . . . Using Processing</p><p> Color 1: Color by Numbers Color 2: Components Control 1: Decisions Control 2: Repetition Data 1: Variables Data 2: Text Data 3: Conversion, Objects Data 4: Arrays Development 1: Sketching, Techniques Development 2: Iteration, Debugging Drawing 1: Static Forms Drawing 2: Kinetic Forms Image 1: Display, Tint Image 2: Animation Image 3: Pixels Image 4: Filter, Blend, Copy, Mask Image 5: Image Processing Input 1: Mouse I Input 2: Keyboard Input 3: Events Input 4: Mouse II Input 5: Time, Date Input 6: File Import Input 7: Interface Math 1: Arithmetic, Functions Math 2: Curves Math 3: Trigonometry Math 4: Random Motion 1: Lines, Curves Motion 2: Machine, Organism Output 1: Images Output 2: File Export</p><p> Shape 1: Coordinates, Primitives Shape 2: Vertices Shape 3: Parameters, Recursion Simulate 1: Biology Simulate 2: Physics Structure 1: Code Elements Structure 2: Continuous Structure 3: Functions Structure 4: Objects I Structure 5: Objects II Synthesis 1: Form and Code Synthesis 2: Input and Response Synthesis 3: Motion and Arrays Synthesis 4: Structure, Interface Transform 1: Translate, Matrices Transform 2: Rotate, Scale Typography 1: Display Typography 2: Motion Typography 3: Response</p><p> Interviews 1: Print Interviews 2: Software, Web Interviews 3: Animation, Video Interviews 4: Performance, Installation</p><p> Extension 1: Continuing . . . Extension 2: 3D Extension 3: Vision Extension 4: Network Extension 5: Sound Extension 6: Print Extension 7: Mobile Extension 8: Electronics</p><p> Appendixes Related Media Glossary Code Index Index</p><p>Contents by category</p><p>xixxxi</p><p>1</p><p>9</p><p>85</p><p>337</p><p>51</p><p>61</p><p>37</p><p>101</p><p>105</p><p>301</p><p>145</p><p>251</p><p>217</p><p>413</p><p>95</p><p>315</p><p>321</p><p>347</p><p>355</p><p>205</p><p>223</p><p>229</p><p>237</p><p>245</p><p>427</p><p>435</p><p>43</p><p>79</p><p>117</p><p>127</p><p>279</p><p>291</p><p>367</p><p>421</p><p>23</p><p>69</p><p>197</p><p>461</p><p>477</p><p>17</p><p>173</p><p>181</p><p>395</p><p>453</p><p>149</p><p>255</p><p>371</p><p>495</p><p>133</p><p>137</p><p>111</p><p>327</p><p>333</p><p>155</p><p>261</p><p>377</p><p>501</p><p>519</p><p>525</p><p>547</p><p>563</p><p>579</p><p>603</p><p>617</p><p>633</p><p>661</p><p>693</p><p>699</p><p>703</p><p>705</p><p>Reas_00_i-xxvi.indd Sec1:ixReas_00_i-xxvi.indd Sec1:ix 5/18/07 9:44:32 AM5/18/07 9:44:32 AM</p></li><li><p>x </p><p>29 30 44 55 63 70</p><p>88 97 113 124 128 137</p><p>186 200 206 219 225 231</p><p>246 281 293 306 316 322</p><p>334 340 349 353 406</p><p>441 458 464 484 530 535</p><p>83</p><p>174</p><p>239</p><p>329</p><p>414</p><p>551</p><p>356</p><p>Reas_00_i-xxvi.indd Sec1:xReas_00_i-xxvi.indd Sec1:x 5/16/07 9:53:14 AM5/16/07 9:53:14 AM</p></li><li><p>xi </p><p> Foreword by John Maeda </p><p> Preface Contents How to read this book Caseys introduction Bens introduction Acknowledgments</p><p> Processing . . . Software Literacy Open Education Network Context</p><p> Using Processing Download, Install Environment Export Example walk-through Reference</p><p> Structure 1: Code Elements Comments //, /* */</p><p> Functions Expressions, Statements ;, ,</p><p> Case sensitivity Whitespace Console print(), println()</p><p>Extended contents</p><p> Shape 1: Coordinates, Primitives Coordinates size()</p><p> Primitive shapes point(), line(), </p><p> triangle(), quad(), rect(), </p><p> ellipse(), bezier() </p><p> Drawing order Gray values background(), fill(),stroke(), </p><p> noFill(), noStroke()</p><p> Drawing attributes smooth(), noSmooth(),</p><p> strokeWeight(), strokeCap(), </p><p> strokeJoin()</p><p> Drawing modes ellipseMode(), rectMode()</p><p> Data 1: Variables Data types int, float, boolean, </p><p> true, false</p><p> Variables =</p><p> Processing variables width, height</p><p> Math 1: Arithmetic, Functions Arithmetic +, -, *, /, % </p><p> Operator precedence, Grouping ()</p><p> Shortcuts ++, --, +=, -=, *=, /=, - Constraining numbers ceil(), floor(), round(), min(), max() </p><p>xix</p><p>xxixxi</p><p>xxiixxiiixxivxxv</p><p>1</p><p>1</p><p>3</p><p>4</p><p>4</p><p>6</p><p>7</p><p>9</p><p>9</p><p>9</p><p>10</p><p>11</p><p>16</p><p>17</p><p>17</p><p>18</p><p>18</p><p>20</p><p>20</p><p>20</p><p>23</p><p>23</p><p>25</p><p>31</p><p>31</p><p>33</p><p>34</p><p>37</p><p>37</p><p>38</p><p>40</p><p>43</p><p>43</p><p>47</p><p>48</p><p>49</p><p>Reas_00_i-xxvi.indd Sec1:xiReas_00_i-xxvi.indd Sec1:xi 5/16/07 9:53:17 AM5/16/07 9:53:17 AM</p></li><li><p>xii </p><p> Control 1: Decisions Relational expressions &gt;, =, </p></li><li><p>xiii </p><p> Transform 1: Translate, Matrices Translation translate()</p><p> Controlling transformations pushMatrix(), popMatrix()</p><p> Transform 2: Rotate, Scale Rotation, Scaling rotate(), scale() </p><p> Combining transformations New coordinates</p><p> Development 1: Sketching, Techniques Sketching software Programming techniques</p><p> Synthesis 1: Form and Code Collage Engine Riley Waves Wilson Grids Mandelbrot Set</p><p> Interviews 1: Print Jared Tarbell. Fractal.Invaders, Substrate Martin Wattenberg. Shape of Song James Paterson. The Objectivity Engine LettError. RandomFont Beowolf</p><p> Structure 2: Continuous Continuous evaluation draw(), frameRate(), </p><p> frameCount</p><p> Controlling the ow setup(), noLoop(), </p><p> Variable scope</p><p> Structure 3: Functions Abstraction Creating functions void</p><p> Function overloading Calculating and returning values return</p><p> Shape 3: Parameters, Recursion Parameterized form Recursion</p><p> Input 1: Mouse I Mouse data mouseX, mouseY, </p><p> pmouseX, pmouseY</p><p> Mouse buttons mousePressed, mouseButton</p><p> Cursor icon cursor(), noCursor()</p><p> Drawing 1: Static Forms Simple tools Drawing with images</p><p> Input 2: Keyboard Keyboard data keyPressed, key</p><p> Coded keys keyCode</p><p> Input 3: Events Mouse events mousePressed(),</p><p> mouseReleased(), </p><p> mouseMoved(), mouseDragged()</p><p> Key events keyPressed(), keyReleased()</p><p> Controlling the ow loop(), redraw()</p><p>133</p><p>133</p><p>134</p><p>137</p><p>137</p><p>139</p><p>142</p><p>145</p><p>145</p><p>146</p><p>149</p><p>150</p><p>151</p><p>152</p><p>153</p><p>155</p><p>157</p><p>161</p><p>165</p><p>169</p><p>173</p><p>173</p><p>177</p><p>178</p><p>181</p><p>182</p><p>183</p><p>193</p><p>194</p><p>197</p><p>197</p><p>201</p><p>205</p><p>205</p><p>212</p><p>213</p><p>217</p><p>218</p><p>221</p><p>223</p><p>224</p><p>227</p><p>229</p><p>229</p><p>232</p><p>235</p><p>Reas_00_i-xxvi.indd Sec1:xiiiReas_00_i-xxvi.indd Sec1:xiii 5/16/07 9:53:18 AM5/16/07 9:53:18 AM</p></li><li><p>xiv </p><p> Input 4: Mouse II Constrain constrain() </p><p> Distance dist()</p><p> Easing abs()</p><p> Speed Orientation atan2()</p><p> Input 5: Time, Date Seconds, Minutes, Hours second(), minute(), hour(), </p><p> millis()</p><p> Date day(), month(), year() </p><p> Development 2: Iteration, Debugging Iteration Debugging</p><p> Synthesis 2: Input and Response Tennis Cursor. Peter Cho Typing Banded Clock. Golan Levin</p><p> Interviews 2: Software, Web Ed Burton. Sodaconstructor Josh On. They Rule Jrg Lehni. Hektor and Scriptographer Auriea Harvey and Michal Samyn. The Endless Forest</p><p> Motion 1: Lines, Curves Controlling motion Moving along curves Motion through transformation</p><p> Motion 2: Machine, Organism Mechanical motion Organic motion</p><p> Data 4: Arrays Using arrays Array, [], new, Array.length</p><p> Storing mouse data Array functions append(), shorten(), </p><p> expand(), arraycopy() </p><p> Two-dimensional arrays</p><p> Image 2: Animation Sequential images Images in motion</p><p> Image 3: Pixels Reading pixels get()</p><p> Writing pixels set() </p><p> Typography 2: Motion Words in motion Letters in motion</p><p> Typography 3: Response Responsive words Responsive letters</p><p> Color 2: Components Extracting color red(), blue(), green(), </p><p> alpha(), hue(), saturation(), </p><p> brightness(), </p><p> Dynamic color palettes</p><p> Image 4: Filter, Blend, Copy, Mask Filtering, Blending filter(), blend(), </p><p> blendColor()</p><p> Copying pixels copy()</p><p> Masking mask()</p><p>237</p><p>237</p><p>238</p><p>239</p><p>242</p><p>243</p><p>245</p><p>245</p><p>249</p><p>251</p><p>251</p><p>252</p><p>255</p><p>256</p><p>257</p><p>258</p><p>259</p><p>261</p><p>263</p><p>267</p><p>271</p><p>275</p><p>279</p><p>279</p><p>284</p><p>287</p><p>291</p><p>291</p><p>295</p><p>301</p><p>303</p><p>306</p><p>309</p><p>312</p><p>315</p><p>316</p><p>319</p><p>321</p><p>321</p><p>324</p><p>327</p><p>327</p><p>331</p><p>333</p><p>333</p><p>335</p><p>337</p><p>337</p><p>341</p><p>347</p><p>347</p><p>353</p><p>354</p><p>Reas_00_i-xxvi.indd Sec1:xivReas_00_i-xxvi.indd Sec1:xiv 5/16/07 9:53:18 AM5/16/07 9:53:18 AM</p></li><li><p>xv </p><p> Image 5: Image Processing Pixels pixels[], loadPixels(), </p><p> updatePixels(), createImage()</p><p> Pixel components Convolution Image as data</p><p> Output 1: Images Saving images save()</p><p> Saving sequential images saveFrame()</p><p> Synthesis 3: Motion and Arrays Centipede. Ariel Malka Chronodraw. Andreas Gysin AmoebaAbstract_03. Marius Watz Mr. Roboto. Leon Hong</p><p> Interviews 3: Animation, Video Motion Theory. R.E.M. Animal Bob Sabiston. Waking Life Jennifer Steinkamp. Eye Catching Semiconductor. The Mini-Epoch Series</p><p> Structure 4: Objects I Object-oriented programming Using classes and objects class, Object</p><p> Arrays of objects Multiple les</p><p> Drawing 2: Kinetic Forms Active tools Active drawings</p><p> Output 2: File Export Formatting data nf()</p><p> Exporting les saveStrings(), PrintWriter, createWriter(), </p><p> PrintWriter.flush(), </p><p> PrintWriter.close(), exit()</p><p> Input 6: File Import Loading numbers loadStrings(), </p><p> split(), splitTokens()</p><p> Loading characters WHITESPACE</p><p> Input 7: Interface Rollover, Button, Dragging Check boxes, Radio buttons Scrollbar</p><p> Structure 5: Objects II Multiple constructors Composite objects Inheritance extends, super</p><p> Simulate 1: Biology Cellular automata Autonomous agents</p><p> Simulate 2: Physics Motion simulation Particle systems Springs</p><p> Synthesis 4: Structure, Interface WithoutTitle. Lia Pond. William Ngan Swingtree. ART+COM, Andreas Schlegel SodaProcessing. Ed Burton</p><p>355</p><p>356</p><p>359</p><p>360</p><p>364</p><p>367</p><p>368</p><p>369</p><p>371</p><p>372</p><p>373</p><p>374</p><p>375</p><p>377</p><p>379</p><p>383</p><p>387</p><p>391</p><p>395</p><p>395</p><p>398</p><p>406</p><p>409</p><p>413</p><p>414</p><p>416</p><p>421</p><p>421</p><p>422</p><p>427</p><p>428</p><p>431</p><p>435</p><p>436</p><p>442</p><p>448</p><p>453</p><p>453</p><p>454</p><p>456</p><p>461</p><p>461</p><p>469</p><p>477</p><p>477</p><p>481</p><p>487</p><p>495</p><p>496</p><p>497</p><p>498</p><p>499</p><p>Reas_00_i-xxvi.indd Sec1:xvReas_00_i-xxvi.indd Sec1:xv 5/16/07 9:53:19 AM5/16/07 9:53:19 AM</p></li><li><p>xvi </p><p> Interviews 4: Performance, Installation SUE.C. Mini Movies Chris Csikszentmihlyi. DJ I, Robot Sound System Golan Levin, Zachary Lieberman. Messa di Voce Marc Hansen. Listening Post</p><p> Extension 1: Continuing . . . Extending Processing Processing and Java Other programming languages</p><p> Extension 2: 3D. Simon Greenwold A short history of 3D software 3D form Camera Material and lights Tools for 3D Conclusion Code Resources</p><p> Extension 3: Vision. Golan Levin Computer vision in interactive art Elementary computer vision techniques Computer vision in the physical world Tools for computer vision Conclusion Code Resources</p><p> Extension 4: Network. Alexander R. Galloway The Internet and the arts Internet protocols and concepts Network tools Conclusion Code Resources</p><p> Extension 5: Sound. R. Luke DuBois Music and sound programming in the arts Sound and musical informatics Digital representation of sound and music Music as information Tools for sound programming Conclusion Code Resources</p><p> Extension 6: Print. Casey Reas Print and computers High-resolution le export Production Conclusion Code Resources</p><p> Extension 7: Mobile. Francis Li Mobile software applications The mobile platform Programming for mobile phones Mobile programming platforms Conclusion Code Resources</p><p> Extension 8: Electronics. Hernando Barragn and Casey Reas Electronics in the arts Electricity Components Circuits Microcontrollers and I/O boards Sensors and communication Controlling physical media Conclusion Code Resources</p><p>501</p><p>503</p><p>507</p><p>511</p><p>515</p><p>519</p><p>519</p><p>521</p><p>522</p><p>525</p><p>525</p><p>526</p><p>531</p><p>532</p><p>536</p><p>538</p><p>539</p><p>545</p><p>547</p><p>547</p><p>549</p><p>552</p><p>554</p><p>555</p><p>556</p><p>561</p><p>563</p><p>563</p><p>565</p><p>569</p><p>571</p><p>572</p><p>576</p><p>579</p><p>579</p><p>582</p><p>584</p><p>588</p><p>591</p><p>592</p><p>593</p><p>599</p><p>603</p><p>603</p><p>606</p><p>608</p><p>612</p><p>613</p><p>615</p><p>617</p><p>617</p><p>619</p><p>622</p><p>624</p><p>625</p><p>626</p><p>631</p><p>633</p><p>633</p><p>635</p><p>637</p><p>638</p><p>639</p><p>642</p><p>646</p><p>648</p><p>649</p><p>658</p><p>Reas_00_i-xxvi.indd Sec1:xviReas_0...</p></li></ul>

Recommended

View more >