- #36
STEMucator
Homework Helper
- 2,076
- 140
jedishrfu said:Checkout the open source Processing.org website. Processing is designed for casual programmers and interactive graphic artists. Programs are called sketches and there is a large collection of samples and books to learn from.
The Processing IDE supports several languages: java, javascript, python and scala (earlier version of the IDE)
We've used it at work for quick prototyping. The programming model is extremely simple. You define a setup() method that is run once and a draw() method that is called by default 60 times a second.
Java:void setup() { size(200,200); } void draw() { ellipse(mouseX,mouseY,10,10); }
The sketch shown above creates a 200x200 pixel window and reacts to mouse movement drawing a circle about each mouse cursor position.
Processing also supports an ANDROID mode where your program can be sideloaded onto an Android device which can make Android development a lot of fun.
You made me dig up some of my old Processing code. Here's an old sketch I made a long time ago:
Java:
//Recursively draw a leaf.
float aa = -PI / 3; //Angle a.
float ab = (11 * PI) / 36; //Angle b.
void setup(){
size(1400, 900);
background(255);
stroke(0, 200, 0);
strokeWeight(1.25);
drawStem(0, height / 3, 0, 150);
}
void drawStem(float x, float y, float angle, float lineLength){
if(lineLength > 1){
float endX = x + (lineLength * cos(angle));
float endY = y + (lineLength * sin(angle));
line(x, y, endX, endY);
drawStem(endX, endY, angle + 0.05, lineLength * 0.9); //Main stem.
drawStem(x + (endX - x)/3, y + (endY - y)/3, angle + ab, lineLength / 3); //Bottom leafs.
drawStem(endX, endY, angle + aa, lineLength / 3); //Top leafs.
}
}
I remember having a lot of fun with this language.
Last edited: