===== Processing \ Hacks ===== There's a tremendous amount that you can do with Processing that extends beyond the officially supported language and environment. Processing Hacks is an effort to document some of the trickier and more advanced topics that Processing users are stumbling across as they gain experience and cross-fertilize their work with other platforms, languages, and libraries. **Processing Hacks is a //wiki// and contributions are //encouraged//. You can log-in with your discourse name and password.** Please use the [[wiki:playground|playground]] to test the wiki, learn its [[wiki:syntax|formatting syntax]] (it's really easy) and read through the [[wiki:styleguide|style guide]] before contributing content. If you're creating a new hack, look at the [[hacks:example|example hack template]] (with guidelines) to get you started. ===== Processing In Depth ===== * [[hacks:community|Where to look]] (Community hacks) * [[hacks:core|core.jar overview]] (What each file is/does) * [[hacks:compiling|Building Processing from Source]] (Linux/Mac/Win) ===== Graphics ===== === 2D techniques === * [[hacks:typography|Flowing text, justifying text, kerning text]] * [[hacks:textoncurves|Writing text on curves]] * Manipulating color values: [[hacks:bitshifts|bitshifts]] and [[hacks:blending|blending]] * [[hacks:fading|Fading the screen to black/any colour]] * [[hacks:offscreen|Drawing to offscreen images]] * [[hacks:hdr|Drawing high-dynamic range images]] (using individual ints/floats for rgb and scaling 0:255 for display) * [[hacks:colors|Setting clipping regions]] (dirty regions etc) * [[hacks:slideshow|Simple slideshow]] with only 1 PImage * [[hacks:voronoicones|drawing voronoi regions using cones]] * [[hacks:wordwrap|Word Wrap Text]] * [[hacks:arctext|text on a circle or arc]] * [[hacks:fatline|fat lines]] === 3D techniques === * [[hacks:picking|Picking/selecting objects in 3D]] (raycasting, backbuffer/buffer, projecting triangles, marquee selection) * [[hacks:povray|Rendering with Povray]] * [[hacks:arcball|Arcball]] (with and without quaternions?) * [[hacks:stereo_viewing|Stereo viewing]](stereo pairs ... red-green?) * More primitives - cone, cylinder, regular n-gon (filled and stroked, Processing style), Extrusion object? * 'toon rendering * [[hacks:backface_culling|Backface culling]] - in software... enabling in hardware * P3D Display lists (ties in with Scene Graph somewhat... build the triangle list in world coordinates and then directly copy it to the triangles array?) === OpenGL Stuff === * [[hacks:OpenGL_applet|OpenGL in an Applet]] Using OpenGL in an online applet. * [[hacks:pure JOGL|pure JOGL]] 'pure' JOGL in Processing without processing.opengl.* * [[hacks:openglstrokes|OpenGL Strokes]] stroke joins and caps in OpenGL using Java2d * [[hacks:1000000points|1000000 Points]] visualizing 1 million points in OpenGL using Vertex Arrays. * JOGL Display lists, vertex buffers, frame buffers, vertex arrays, point sprites * [[hacks:blending|Blending]] a simple additive blending example ===== Over-riding Default Behaviour ====== * [[hacks:framerate|Frame rate]] adjustments for sketches with occasional heavy computations * [[hacks:clickedmousepos|Clicked mouseposition]], when mouse isn't clicked.. * [[hacks:undecoratedFrame|Undecorated frame]] and adjusting the location of the frame * [[hacks:deepmatrixstack|Deepmatrixstack]] overriding the default stackdepth of pushMatrix() and popMatrix() (32) to whatever you like ===== Libraries ===== * [[hacks:libraries|Writing libraries]] (or just point to http://dev.processing.org?) * [[hacks:jni|Interfacing with native code using JNI]] (not worth it just for maths routines, but worth it for hardware integration) * [[hacks:jnative|Interfacing with native code (DLLs) using JNative]] (if you don't have access to the DLL's source code and/or don't want to write any native code) * [[hacks:usinglibraries|Using libraries]] (additional help with the ~25 libraries at http://processing.org/reference/libraries) There is some overlap with file formats here, since that's what lots of the libraries do. ===== Import/Export and Working with Data ===== * Loading/saving from/to: [[hacks:ps|Postscript]], [[hacks:illustrator|Illustrator]], [[hacks:dxf|DXF]], [[hacks:obj|OBJ]], [[hacks:svg|SVG]], [[hacks:pdf|PDF]], [[hacks:rss|RSS/Atom]], [[hacks:html|HTML]], [[hacks:csv|CSV]], [[hacks:xml|XML]]. * Loading text as a stream instead of with loadStrings (for big files) * [[hacks:saveAsJpg|Save a PImage as jpg]] * [[hacks:saveToWeb|Saving files to a web-server using POST and PHP]] * [[hacks:ftp|ftp - edtftpj]] * [[hacks:quickScreenGrab|Taking a Quick Screen-Grab]] * [[hacks:importColorPalettes|Import .cs and .act color palettes]] * [[hacks:dataloadqueue|Asynchronous data/image loading (with cache support) using separate thread]] ===== Security ===== * [[hacks:signapplet|How to sign an applet]] * Accessing the camera/video in an applet * Loading files from any web server using PHP/Perl/etc. to get around the need to sign * OpenGL accelerated applets ===== Using built-in Java classes ===== * [[hacks:string|String and all it's equality foibles]] * Java Collections framework for Processing: [[hacks:vector|Vector]], [[hacks:hashes|Hashtable]], etc. * [[hacks:sorting|Sorting arbitrary things with Comparable and Comparator]] * [[hacks:listing-files|Listing files from the data path]] with java.io.File * [[hacks:clipboard|Cutting and pasting from the clipboard]] * [[hacks:Hashtable|Using Hash tables / Associative arrays in Processing]] * [[hacks:comparable|Using the Comparable interface to sort a list of objects based on specific value]] === AWT === * [[Using AWT's Polygon class to test for insideness.]] * [[Fun with the frame object]] * [[hacks:robot|Controlling the mouse with the Robot class]] * Using AWT's Color class to convert RGB/HSB. === Swing === * [[hacks:SwingSliders | Swing JSliders with Processing]] ===== Alternative Development Methods ===== * [[hacks:commandline|Compiling on the command line]] * [[hacks:eclipse|The definitive Processing in Eclipse tutorial]] * [[hacks:jbuilder|Using JBuilder with Processing]] * Editing with [[hacks:jedit|JEdit]]/Vim/Emacs (syntax highlighting etc) * Editing Java in the Processing environment "public class blah extends PApplet" / tab.java / etc. * Using core.jar in Swing/AWT apps * [[hacks:jedit|Using jEdit as external editor]] ===== General Java/OO Programming ===== * Deep copying/shallow copying/copying arrays/expanding arrays/inserting/removing in arrays * [[hacks:precedence|Understanding operator precedence in Java]] * Inheritance / interfaces / polymorphism * Design patterns ===== Interaction ===== * [[hacks:multiplekeys|Keeping track of multiple key presses]] * [[hacks:doubleclick|Using double-click]] * Robustly accepting typed input (catching BACKSPACE/TAB/ENTER etc and not adding it to your String) * [[hacks:wasdinput|W-A-S-D control keyboard input]] * [[hacks:livecoding|Live coding]] ===== Optimisation/Numerical Stuff ===== * [[hacks:sincoslookup|Using a lookup table for sin/cos]] (or sincos in one? or incremental trig from game programming gems?) * Verlet integration / Runge-Kutta integration * [[hacks:fixedpointmath|Fixed point math]] (Processing mobile?) * Random number distributions * [[hacks:mersennetwister|Mersenne Twister pseudorandom number generator]] as a replacement for Java's java.util.Random. Faster, better and more consistent. ===== Web Services ===== * [[hacks:delicious|del.icio.us]] * [[hacks:flickr|Flickr]] * [[hacks:google|Google]] * [[hacks:amazon|Amazon]] * HTTP POST/GET - RESTian things * XML-RPC and friends ===== Deployment/Presentation ===== * [[hacks:runviacommandline|Running on the command line (present mode etc)]] * Changing screen resolution for full-screen apps * Displaying on multiple monitors * [[hacks:dynamicsize|Specifying width/height at run-time]] * [[hacks:proguard|Obfuscating/shrinking applets]] * [[hacks:extraram|Increasing available memory, checking memory]] * Starting applets with keyboard focus * [[hacks:Sharing_core_files|Sharing core files]] for minimal server diskusage. * [[hacks:configfiles|Using external configuration files]] ===== Website Integration ===== * [[hacks:corereuse|Using one copy of core.jar for a website with many Processing applets]] * [[hacks:jarfiles|Putting more than one applet in a jar file]] * [[hacks:scripting|Communication with Flash/Javascript]] * [[hacks:blogs|Using Wordpress/Movable Type/Blogger to publish a sketchbook]] * [[hacks:javadoc|Generating up to date code documentation with javadoc]] * [[hacks:highlighting|Automatic syntax highlighting of source code in webpages]] * [[hacks:webstart|Deploying Processing sketches using webstart]] ===== Other Platforms ===== Converting to and from: * [[hacks:flashconversion|Flash]] * [[hacks:directorconversion|Director]] * [[hacks:javaconversion|Java]] * [[hacks:openglconversion|C/C++/OpenGL/Glut]] * [[hacks:vrmlconversion|VRML]] * [[hacks:p5conversion|Processing (Alpha)]] (Particularly the loop/draw problem, what constants were renamed, etc.) * [[hacks:mobileconversion|Processing Mobile]] * [[hacks:maxmspconversion|MAX/MSP/Jitter]] * [[hacks:vvvvconversion|vvvv]] And comparisons with these platforms, transition methods to/from those platforms, gotchas, etc. ===== Mapping ===== * [[hacks:mapprojection|Transforming latitude and longitude into screen space]] * [[hacks:gps|Talking to a GPS device]] * [[hacks:gpx|Loading GPS data in the GPX format]] * [[hacks:openstreetmap|Getting geodata from OpenStreetMap]] * [[hacks:tiger|Working with TIGER geodata]] * [[hacks:wms|Accessing WMS sources such as Landsat]] ===== Experimental/Aspirational ===== * Using a Processing file as a screensaver (export to applet, use args properly ... add a config option? Is a preview possible?) ... on Mac/Linux? * Using "headless" processing for generating images (in TomCat?) * [[hacks:livecoding|Live coding]] * Scene Graph using underlying triangle libraries and caching the matrices (not abstracting on top of exposed functions) * [[http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Sound;action=display;num=1164147978|OpenAL / Surround Sound]] ===== Computer Vision and Image Processing ===== * [[hacks:noise|Using FFT to remove noise from an image]] * [[hacks:infra-red|Use an infra-red webcam for installations in the dark]] ===== Communication ===== * [[hacks:applescript|make applescript calls from processing]] * [[hacks:whois|A simple Whois lookup in Processing]] * [[hacks:vbs|Run Visual Basic Script from Processing]] ===== Miscellaneous / Things to Sort / What Else? ===== * [[hacks:fpscounter|Automatically measure the framerate]] * I've said nothing about sound, textures, lighting * Has anyone got joysticks working? What about Sony PS2 pads? * Capturing video from any source (e.g. DVD) using a Digital Video camera * Vector fonts? (Fry was doing stuff for OpenGL, and Java2D already used TT fonts if available... what else?) * Threading? Asynchronous operations... posting to a website. * Image Processing / Colour Tracking / etc. * Gesture recognition (mouse, and... video?) * Video manipulation / image compression - is in-memory compression feasible? * [[hacks:wacom|Wacom tablets]] * What else would be needed for games? AI? Pathfinding? * [[Detecting line to line intersection]] * Specific stuff on info-vis? * Specific stuff on OSC? * Read email with Processing (directly open POP/IMAP, or bounce it off a webservice) * Receive SMS with Processing (gotta be an extension of the email one really) * Mo-cap hardware (ask Chiron?) * Make a movie - can the Quicktime libraries, or some other Java libraries, compile a folder of images into a movie? * Time-based animation * GUI libraries etc. * Orthographic/perspective rendering (is that a hack any more?) * [[hacks:exceptions|Exception handling]] * Vector/Matrix libraries? * Convex hulls * Marching squares / cubes * Particle systems * Physics/collision detection * [[Physics libraries]] * [[hacks:graphtheory|Graph Theory]] * [[hacks:files|Manipulating files and folders]] * [[hacks:filechooser|Opening a file chooser dialog box]] * [[hacks:sql|Using data from an SQL database]] * [[hacks:exif|Reading/writing JPEG files with EXIF data]] * [[hacks:subversion|Using subversion to synchronise sketchbooks between multiple locations]] * [[hacks:contours|Contours]] * [[hacks:triangulation|Triangulation]] * RDF vs CSV etc. * Other metadata formats (e.g. ID3 for Mp3?) * Installable libraries (like JSyn, JOGL perhaps) * Glen Murphy's Fasttext? * [[hacks:registerEvents|Listening for Processing Events]] * [[hacks:readingSequences|Reading a Sequence.#####.png]] * [[hacks:incrementalFilename|Auto-incrementing filenames, i.e. "sketch-####.png"]] * [[Midi usage as files or as input stream]]