Saturday, November 24, 2007

Processing for beginners 2

I knew that processing could do animation but wasn't sure how until now...It was extremely easy... well at least for simple computer graphics demo animation.

The code looks alot like an applet.
First thing you need to know is how to you use reserved functions(whatever the correct term for this is) and what kind of reserved functions are available...

setup() will initialize values
draw() will draw things each frame

so yes you need to determine how fast it draws each frame/time it stops before drawing next frame - easier if i just say determine a frame rate and you do this inside setup() function.


void setup() // don't forget void here
{
size(400, 400); // canvas size 400 by 400
background(0); // black back ground
framerate(30); // frame rate 30fps
}




Yeah, really, that's all it takes. piece of cake. and then you decide what you want to draw inside draw() function.

So basically setup() and draw() are like functions made ready by whoever making this to help you do graphics only. It's really amazing because on java you'd have to write a class, system.out, blah blah and other stuff that you don't really need to know if you just want to do graphics or create something with code or just want to jump into it..Of course Java can do all this can do and a lot more and maybe more efficient but do you really need that much feature if you are not programming some hardcore web apps?

anyways, besides setup() and draw() there are mousePressed() and other functions that adds interactivity to it also. If you learn enough of these you can do alot more with it.

No comments: