开发者

IDE for Processing.js

I'm just getting started with processing.js and neither of the IDEs I use (Aptana, NetBeans) are able 开发者_运维技巧to understand the JavaScript syntax processing uses. What is a good editor to use when coding processing.js? At minimum I would like code folding and coloring.


Depends on what you want to do, but did you have a look at the Web IDEs on the processing.js website?

  • www.sketchpad.cc
  • www.hascanvas.com
  • sketch.processing.org

jan.

EDIT: sketch.processing.org is a broken.


If you plan to use Processing.js with processing's original Java-based syntax then the best IDE is going to be Processing. The 2.0 alpha versions have a JavaScript mode that you can switch into and will make the workflow easier. It will not provide features such as code completion that you are used to with NetBeans etc. There is no IDE that will give you those features with that syntax and writing normal Java will not translate correctly.

Processing.js is really a JavaScript implementation of the Processing API, it just has and additional feature for converting your Processing java-style code into JS. If you write your Processing.js applications directly in JavaScript you will be able to leverage some additional features from IDEs such as Aptana, but of course your code will not compile into a Java Application / Applet. Their JS Quick Start Guide introduces this method.


The next best thing is to use either C++ or Java syntax highlighting. The main determining factors are:

  • Java doesn't allow file-level variables or functions, which are a core part of the PDE definition
  • C++ uses different keywords for importing, inheriting, referencing parent classes and declaring interfaces and this is a pointer dereference (->) rather than a reference (.)

For syntax highlighting both work fine but because of the above issues no matter what you choose, syntax checking cannot be enabled at the same time as syntax highlighting without errors.


If you want to code in Processing-Java (versus pure javascript), and also want auto-code completion, I suggest using IntelliJ or Eclipse. Import core.jar from processing into your project to enable auto completion.

Then wrap your code inside of a PApplet subclass:

package pde;
import processing.core.*;
import java.util.ArrayList;

public class MySketch extends PApplet
{
    //your code here
}


You could write in on Notepad if you're on Windows. Al you have to do is save it as an HTML document, like the following :

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>
      Your project's title
    </title>
  </head>
  <body>
    <!--The processing.js canvas-->
    <canvas id="mycanvas"></canvas> 
    <!--Imports the processing.js library-->
    <script src="https://cdn.jsdelivr.net/processing.js/1.4.8/processing.min.js">    </script>
    <!--Where you write your code-->
    <script>
    var sketchProc = function(processingInstance) {
      with (processingInstance) {
        //Feel free to change the size
        size(400, 400);
        frameRate(30);
        
        //Write your code here:
        
        
        
        
        
        
      }
    }
    </script>
  </body>
</html>

Hope this helps! :D

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜