Processing Basics
Processing was originally created to enable nonprogrammers to make digital artworks. It is a java application that is an open source tool designed by
Casey Reas and
Ben Fry from MIT. You can downoad it from
http://processing.org/download/.
Processing includes
- an integrated development environment (IDE)
- a programming language
- tools to publish the applications for the web or desktop.
Because Processing runs using Java, it can do almost anything Java can do.You can use it to read and write data, work with images, video and sound, draw in two or three dimensions, create artificial intelligence, and simulate physics.
The Application Interface
Processing uses a language specifically designed to generate and modify images. It allows you to write Java programs with much simpler code. While it
you can structure the code in a function-based (procedural), non–object-oriented
style, once the code is compiled, the output is converted to Java class files—
indistinguishable from any other Java program—and the class files are interpreted within
the Java Virtual Machine as the program runs.
Processing programs are created from instructions known as
commands.
A group of commands together is the
source code. When you tell Processing to
run, your computer looks at the source code and carries out the commands—drawing lines, playing sounds and doing whatever else you've told it to do. This is a process not unlike giving someone written instructions and making them follow those instructions to the letter.
In the
Processing environment, you edit your source code (the list of commands)
in the main window and then give it to the computer to run by pressing
the
run icon.
Processing is an
integrated development environment(IDE).
The IDE is simple to work with.
There are three modes of working, allowing
coders, as they increase their programming literacy, to move from Processing's simplified
procedural approach, to a hybrid approach that uses some more-advanced programming
constructs, to ultimately working in pure Java—all in the same IDE.
Below are the descriptions of the six control buttons:
|
The
run button is the same as in Director and Flash. Press this
to see your code execute as a program. Alternatively you can type ⌘+R.
Pressing ⌘+SHIFT+R creates a full-screen
display of your executing sketch. The sketch window is centered against a neutral
background. You can stop the display by selecting the Stop command in the lowerleft
corner of the screen, or by pressing the Esc key. |
|
The
stop button is the same as in Director and Flash. Press this
to see your program stop executing. |
|
Creates
a new file. Processing calls them sketches. You can
even call them applets, programs, or interactive pieces. Director
and Flash call them movies.Alternatively type ⌘+N. |
|
Open
a pre-existing sketch. A menu will pop up and you can choose from
your own collection, saved in the special Processing sketch folder
which I will show you later. You can also choose from a wide variety
of example sketches by famous new media designer/artists, in order
to learn from them and use them as a code reference.
Alternatively type ⌘+O. |
|
Save
the current sketch into the Processing sketches folder.
Alternatively type ⌘+S.
If you want
to give the sketch a name other than the current date, you can choose
save As from the File menu. Alternatively type ⌘+SHIFT+S. |
|
Export
the current sketch into the Processing sketches folder - this time
as a Java applet - complete with its very own HTML file. Alternatively type ⌘+E.
To Export Application press ⌘+SHIFT+E. This allows you to export your sketch as a stand-alone, platform-specific executable application.
Export Application generates an entire directory
structure (in this case, actually three separate directories) with all the required files
to launch an application under Linux, OS X, and Windows. |
Other useful information
- Sketch menu
- Show Sketch Folder ( ⌘+K): Opens up the directory
of your current sketch. If you haven't moved it, your current sketch directory will reside within
your main sketchbook directory.
-
Sketch>Add File: Opens a file navigator, allowing you to load an image, font, or other media
into a data subdirectory within your sketch directory. If no data directory exists,
Processing will automatically create one for you.
- Tools Menu
- Auto Format (⌘+T): This command attempts to
format the code layout for optimal readability. Skipped lines, also referred to as
whitespace, are retained. Syntax errors, such as missing semicolons, are not corrected.
- Create Font: The command
opens the Create Font dialog box, which allows you to select any font
installed on your system. This dialog includes the options Size,
Filename, Smooth (for anti-aliasing), and All Characters. The font generated is a copy
of an existing font in your system, created in the VLW font format and installed
within a data subdirectory in the current sketch directory. Similar to loading other
media into Processing, a data directory is automatically created, if one doesn't
already exist. There are some memory concerns involved in creating fonts this way.
The larger the font size you specify, the more memory the font will use, as each
font includes the actual raster information needed to draw the individual characters;
normally, fonts are created using vector data. In addition, the Smooth option
also requires a little more memory, as does the All Character option, which includes non-English characters, such as ü and Å.
- Color Picker: This is a simple color picker, showing you the HSB (hue, saturation,
brightness), RGB, and hexadecimal color values of the color selected.
- Archive Sketch:
This command creates a ZIP archive of the current sketch, prompting
you with a Save dialog to choose a location to save the archive.