dopatraman
dopatraman

Reputation: 13908

writing in processing vs javascript in processing.js

My understanding is that Processing.js converts Processing code into javascript. But if one does not want to write in Processing, one can use methods and properties of the processing object like so:

function sketchCirc(processing) {

    function drawCirc() {
            processing.background(100);
            processing.ellipse(X,Y,radius,radius);
            processing.fill(0,121,184);
            processing.stroke(255);
        }

    processing.draw = function() {

        drawCirc();
    }

I prefer to use the above approach (meaning accessing methods of the processing object), but are there any downsides to this? I want to avoid having to learn the Processing language from scratch. Please let me know what your ideas are.

Upvotes: 2

Views: 4958

Answers (1)

George Profenza
George Profenza

Reputation: 51837

Processing.js doesn't convert Processing code into JavaScript. It is a Javascript library that mirrors/wraps Processing methods. It's still a javascript library, like any and since it mirrors Processing's main functions, you can use roughly the same syntax. If Processing.js converted Processing code into JavaScript, it would convert Java libraries to JavaScript, which is not true.

There shouldn't be any downsides to using Processing as you've described above.

Processing's reference isn't amazingly long nor difficult and if you plan to stay in 2D, you'll probably use even less of what's listed there. If you're using an IDE with autocompletion for JS you probably won't even need to the reference as function names are mostly intuitive.

It might worth having a play with Processing and getting used as you'll also be able to deploy standalone applications to Windows/Linux/OSX/Android. The alpha releases even include a JavaScript mode with some neat examples, straight out of the box.

Update Using Processing 2 or newer versions you can add a JavaScript Mode into the IDE which will also include some nice examples.

Also, there is newer, pure javascript implementation called p5.js. This might be closer to hat you're looking for.

Still if Processing isn't your cup of tea, you might want to try PaperJS or Raphael.

Upvotes: 4

Related Questions