ciembor
ciembor

Reputation: 7335

Processing.js and JavaScript syntax

  1. Is it possible to use Processing.js with JavaScript syntax?
  2. If yes, may you show some examples?
  3. Would it be much faster? I don't know how much time takes precompilation of Java code.
  4. Is it possible to precompile Processing into JS script on the server side?

Upvotes: 3

Views: 1219

Answers (1)

George Profenza
George Profenza

Reputation: 51847

  1. Yes, it is possible to integrate js with your Processing.js code
  2. As of version 1.9.8 Processing has a Javascript Mode, similar to the Android one present in 1.5+ , only it generates Processing.js code and writes the html/js files to disk. This version also includes Javascript examples among others. Here's a preview of an example that parses the DOM and generates a tree: nodeTree sample code nodeTree sample preview
  3. Since at the end of the export you have a resulting Processing.js, the converted applet will run with the same speed as any Processing.js applet (slower than Java, but within decent speeds depending on the complexity of the sketch and the client's browser/machine)
  4. The IDE now has this feature and you could make use of it. If you could run the Processing IDE with a GUI server side, that would be an option. On a recent project at work, a colleague uses a Processing applet running on a server to draw a visualization which is then loaded and integrated into a flash website: WWF FWA preview The Processing IDE is different, but if you can run it, that's fine, otherwise, you'll need to replicate the functionality with a server side language of your choice. Thankfully, the Processing project is open source, so you can have a peek at their implementation of the JavaScriptBuild.

To try the new JavaScript mode simply download the latest build from the Processing repository.

Upvotes: 4

Related Questions