Page 153 - Hacking Roomba
P. 153

134       Part II — Fun Things to Do





                               Listing 7-1 Continued

                               void draw() {
                                 background(51);
                                 fill(0,0,255);
                                 rectMode(CENTER);
                                 rect(mouseX,mouseY, width/5,height/5);
                               }




                             When the Run button is clicked, the sketch content is embedded in a Java class, compiled, and
                             run. These are the exact steps that you do when writing normal Java programs, but the process
                             has been streamlined and made transparent to the user. If you’ve ever tried to write a Java pro-
                             gram that just draws on the screen, you’ll appreciate how much Processing does for you.
                             The Processing installation includes many sample Processing sketches and you can download
                             even more samples from the Processing website (http://processing.org/learning/).
                             Load a few of them and play with them.

                             You can access the Processing samples by selecting File ➪ Sketchbook ➪ Examples.






                             Why Use Processing?

                             Processing enables you to create, run, and share dynamic graphical programs. If you are a pro-
                             fessional software engineer, Processing may at first seem unnecessary. But many software pro-
                             fessionals use Processing just because its sketching metaphor and helper functions enable them
                             to try out ideas fast. Artists and animators find its direct approach to painting on the screen
                             attractive. And it’s a good tool for beginning programmers due to its simplified environment
                             and language.
                             There are many tools somewhat similar to Processing. In the Java development space you have
                             Java IDEs like the free and awesome Eclipse (www.eclipse.org/). For animation there’s Adobe
                             Flash (www.adobe.com/products/flash/), which has been getting more powerful as a
                             general-purpose tool as its ActionScript language has become more standards compliant. For
                             audio/video processing, there’s Max/MSP/Jitter (www.cycling74.com/products/maxmsp).
                             This is just a small representative sampling of the tools out there, and all of these tools are better
                             than Processing in some ways and worse in others.

                             Cost
                             Processing is not only free; it’s open source. Anyone can see exactly what Processing is doing and
                             modify the code to suit his or her needs. Or borrow it. Some of the original RoombaCommSerial
                             code was taken from the Serial library in Processing. Reading other people’s code is a great way
   148   149   150   151   152   153   154   155   156   157   158