Custom Search

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.

 If you want to change the default location for the sketch file to be saved,  go to File-Preference, and you will be able to change the location there. For mac user, the default location is Documents-Processing.

  When media files, such as images or sound files, are added to a sketch by Sketch-Add File menu, or by dragging them into the text editor, a data folder is created and those files are automatically added in that folder. All the media files added into the sketch must be at the data folder

2. Export a sketch

  A sketch can be exported as a package to be run within a Web browser. When code is exported, it is converted to Java code, and then compiled as a Java applet.


   When you click 'Export' button on the toolbar like the above image, several files are created within a new folder called applet at the same location where .pde file is.

(click the image for larger view) 

  The above image shows the file composition when you export a sketch(e.g. mouser_pointer.pde). There is a folder called mouse_pointer, and mouse_pointer.pde file inside it. After exporting the sketch, a new folder called applet is created and 5 more files are created within that folder.

 - index.html :  HTML file with the applet embedded(1) and links to the source code(2) and the Processing homepage(3) as you can see in the next image. If you double-click this file, you can see the applet run in the default Web browser.

 (click the image for larger view) 

- mouse_pointer.jar : A Java Archive containing all necessary files for the sketch to run, including the Processing core classes, all the media files, and etc.
- mouse_pointer.java : The Jave file created by the .pde file. This is the actual file that is compiled by the Java compiler.
- mouse_pointer.pde : The original pde file. It is linked from the index.html file.
- loading.gif : A loading image displayed when the program is loading in the Web browser.

  Every time a sketch is exported, all the contents in the applet folder are deleted and recreated. So, any changes previously made to the index.html file are lost.
  Also, media files not needed for the applet should be deleted from the data folder before exporting in order to keep the file size small. Because when you export a sketch, all the files in the data folder are added into .jar file.

  In addition to exporting Java applets for the Web, Processing can also export Java applications for the Linux, Macintosh, and Windows platforms. (File-Export Application)



No comments:

Post a Comment