开发者

I don't understand how processing.js works

开发者_Python百科Does the javascript in the processing.js script find the script type="application/processing" and convert it to javascript?


If you're looking at the basic example located here:

http://processingjs.org/source/basic-example/processingjs_basic-example.html

Then no it isn't. That special script tag handling is actually in:

http://processingjs.org/source/basic-example/processing.init.js

Which is not part of main package but is in the examples package as examples/init.js


Since the processingjs does have support for events and since the only real job is to have a canvas and a function to load your .pde with i'd say it's quite easy going. As for support just view the learning tab at processing.org it's a lot of useful examples there.

As for java .pde it's a fully object-event-oriented environment where you can create any object you can think of and load any graphical components you can produce by means of the preload method provided in processingjs. By creating an instance of processing in your javascript you can add and control any data-maniputation that you require in your processing .pde and by creating an interface in the .pde you can call any external javascript you may need. I'd say if you are crafty with your JS you can decide how much work you want to do where (java resp. javascript). As for environment the processing-ide processing-ide allows for syntax-highlighting and parsing of your scripts and an easy way to add your graphical data. Since your .pde file will be compiled to JS during runtime you can actually se the interpretation of your .pde-class or something that you did (if you use firebug..).

As for animations you can chose to not loop and omit framerate to just present a static picture that you can dynamically alter by means of rewrite. That kind of image-processing is kind of powerful. This means that your canvas can be populated with data at runtime by a user or a service. This is powerful since it allows for some really cool things. Like this: cool stuff and let's say it supports some cool rendering-modes: processingjs.org/articles/RenderingModes.html.

As for the java-part it's rare that you only use JS in your web-app. I mean it might be dynamic content produced through JS, Java, PHP, XML, JSON, HTML, CSS some framework (Play, JSF, Rails) all at once so i wouldn't mind the java-part (it's well documented :))

Have fun!


Processing.js includes a compiler, if you want to use the Processing language.

When you use it as an embedded script, then it does exactly as you describe.

http://processingjs.org/reference/articles/p5QuickStart#processingcodeinwebpage

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜