Getting started with Processing
Java developers would find it easy to use Processing as the programming style matches Java. Most of the object-oriented concepts can be used. There are two special functions in Processing, which are called internally: setup(): This function will be executed only once during the initial start of the sketch. Initial screen layout, UI initialisation and other basic configurations are done in this function. draw(): This will be called automatically by Processing for each frame and it renders graphical animation. Apart from these two functions, there are many in-built core functions and event handlers to handle user actions and to design various shapes. All functions in Processing are straightforward and the names are self-explanatory. Refer to http://processing.org/reference/ for a detailed list of functions and their documentation, along with examples.
Static sketch – ‘Hello World!’: In this example, let’s look at how to draw a static sketch. In Processing, you need X-Y pixel coordinates to draw the shapes. For example, to draw a line, you need two points with X-Y coordinates. Similarly, to draw a rectangle or ellipse, you need four points with X-Y coordinates.
size(400,400); int widthLen = width/2; int heightLen = height/2-100; rectMode(CENTER); rect(widthLen, heightLen + 75, 60, 100); line(widthLen,heightLen+20, widthLen+80, heightLen+80); line(widthLen,heightLen+20, widthLen-80, heightLen+80); ellipse(widthLen-55,heightLen-5,12,25); ellipse(widthLen+55,heightLen-5,12,25); ellipse(widthLen,heightLen,100,100); ellipse(widthLen-25,heightLen-7,25,12);