Custom Search

Saturday, 24 April 2010

Processing-07. Data Type : Variables-02

Image

  Processing can load .gif, .jpg, .tga, and .png images. Images can be displayed in 2d or 3d space. In order for an image to be used, a variable for an image must be defined by PImage() function and the image must be loaded with loadImage() function.

1. Load and Display an image
  The same way that intergers are stored in variables of the int data type and true/false values are stored in the boolean data type, images are stored in variables of the PImage data type.
e.g.) PImage img;     // define a variable 'img' as an image variable.

  In order to load an image into the defined variable, loadImage() function is used to load an image into the sketch. You need to be sure to include the file format extension as a part of the name and to put the entire name in quotes. Be careful to use the correct capitalization and do not use spaces in image names, which can cause error.
e.g.) img=loadImage("apple.jpg");      // load apple.jpg into an image variable 'img'.

Wednesday, 31 March 2010

Processing-06. Data Type: Variables-01

Variables

  In the Processing, programers use various kinds of variables in order to assign numbers, texts, or images so that they can be reused many times within a program. Every variable has a specific data type that defines the category of data it can hold to let the computer know how to manage it. int, float, boolean, char, String, etc. are such functions to assign data into different variables.
  Variables should have names that describe their contents easily and concisely. Their names should not be tedius, long, or too cryptic.
e.g.) roomTemp, outTemp, inTemp are the good examples for the names of variables than t, x, y, z.

Tuesday, 23 March 2010

Processing-05. Coordination & Primitive Geometries

1. Coordination System

(click the image for the larger view)

The above image (A) presents the coordination system of the Processing and how it works. In the processing, the origin(0, 0) is the upper-left corner of the window and the value of X and Y increases down and to the right.
  The image (B) shows some examples of the coordination of points in the 100x100 pixel window. The thing is that the coordination starts with zero. So in the 100x100 pixel window, you need to keep in mind that the coordination of the upper-right corner is (99, 0) the lower-right (99, 99), and the lower-left (99, 0).
  The last image (C) gives an idea of the coordination system in 3 dimensions. The Z-values become negative as moving back in the space. 

Wednesday, 17 March 2010

Processing-04. Basic Code Elements

Basic Syntax

 

1. Comment( // )
  Comments offer notes or explanation of program coded by you or others. It is difficult to read and understand codes of more than hundreds lines just by looking at them. So, comments help users to understand functions and structures of programs acting like a footnote.
Two forward slashes are used to denote a comment in one line.

e.g.) // You can write a comment here like this.
       // If you want to write more than one line, put another two slashes before writing more.

Wednesday, 10 March 2010

Processing-03. Composition of a Project File

1. Saving a project(sketch)

  In the processing, a project file is called sketch.  When you save a sketch, a new folder with the same name as the sketch file is created and the sketch file is found inside that folder. For example, if a sketch is named sketch012, then the folder for the sketch will be called sketch012, and the main project file will be called sketch012.pde, being placed in that folder. .pde stands for the Processing Development Environment.

Processing-02. Interface

Once you run the processing software by double-clicking Processing.app, you will be surprised at the interface of its simplicity.
Processing consists of 2 windows; Processing Development Environment(PDE) which is a simple text editor for writing code, and Display Window which displays the result of the code written in PDE.



Processing-01. Download and Install

Processing software can be downloaded from the Processing website(http://www.processing.org). Using a internet web browser, go to the main page of processing and click on the link(1 or 2 in the image).