Senin, 05 Januari 2015

Meet Processing, an awesome IDE/Editor for Java.

Hello again :D

This time, i want to introduce you to an IDE/Editor for Java named Processing.

Processing is an open source programming language and integrated development environment (IDE) built for the electronic arts, new media art, and visual design communities with the purpose of teaching the fundamentals of computer programming in a visual context, and to serve as the foundation for electronic sketchbooks. The project was initiated in 2001 by Casey Reas and Benjamin Fry, both formerly of the Aesthetics and Computation Group at the MIT Media Lab. One of the stated aims of Processing is to act as a tool to get non-programmers started with programming, through the instant gratification of visual feedback. The language builds on the Java language, but uses a simplified syntax and graphics programming model. Since 2001, Processing has promoted software literacy within the visual arts and visual literacy within technology. Initially created to serve as a software sketchbook and to teach computer programming fundamentals within a visual context, Processing evolved into a development tool for professionals. Today, there are tens of thousands of students, artists, designers, researchers, and hobbyists who use Processing for learning, prototyping, and production. Told you, it's awesome right?

Okay, in this post, i will show you how to compile a simple source code with Processing and look how awesome it is.

You need to download it first, of course, you can do it by click this link and choose your Operating System. It support many operating system, so you don't have to worry.

Once you finished, open containing folder that store Processing zip-file and extract it. (You must know how to extract a zip-file, don't you?)

And open Processing folder, and click on Processing.exe. And it should look like this.

















Make sure the option on right up corner is "Java", so you won't have problems ahead.
Okay, let's try to compile some source code.
I got this code from here that will show you a better example of the look and feel of the language.


//Hello mouse.
void setup() {
       size(400, 400);
       stroke(255);
       background(192, 64, 0);
}

void draw() {
       line(150, 25, mouseX, mouseY);
}

After you type it down, just click Play symbol on the left corner, it means run and compile the code and see how it works.














A straight line will drawn by your mouse movement everywhere within the orange box.

A program written as a list of statements is called a static sketch. In a static sketch, a series of functions are used to perform tasks or create a single image without any animation or interaction. Interactive programs are drawn as a series of frames, which you can create by adding functions titled setup() and draw() as shown in the code. These are built-in functions that are called automatically.

The setup() block runs once, and the draw() block runs repeatedly. As such, setup() can be used for any initialization; in this case, setting the screen size, making the background orange, and setting the stroke color to white. The draw() block is used to handle animation. The size() function must always be the first line inside setup().

Because the background() function is used only once, the screen will fill with lines as the mouse is moved. To draw just a single line that follows the mouse, move the background() function to the draw() function, which will clear the display window (filling it with orange) each time draw() runs.

Static programs are most commonly used for extremely simple examples, or for scripts that run in a linear fashion and then exit. For instance, a static program might start, draw a page to a PDF file, and exit.

Most programs will use the setup() and draw() blocks. More advanced mouse handling can also be introduced; for instance, the mousePressed() function will be called whenever the mouse is pressed. In the following example, when the mouse is pressed, the screen is cleared via the background() function:

Do you with me so far? Feel free to ask if you have a question.
Okay, this is the end of the post. Good morning.

0 komentar:

Posting Komentar