Thursday, September 20, 2012

The *.pde file from the previoust post



Although it was a simple example, i share with you the file/sketch from my last post.

Best regards.

;)

Wednesday, September 19, 2012

A little bit of coding...


A little bit of coding...


In my last posts, i just opened a door about android applications.

As you know, there are many websites that allow you to create such applications, but when i started with the idea of android development, i wanted to create something from scracth, of my own efforts.

The cruel and hard world teach us that you have to use/take all you can and sell it before other to gain some money or reputation, but, i still want to create my own stuff.... i know, i will be poor forever...

Anyway, the real issue of this post is to introduce, in some way, into the programming behind android as well many other platform applications.

As i am a fan of free and open source software today i bring you PROCESSING.

As wiki say:

"Processing is an open source programming language and integrated development environment (IDE) built for the electronic arts 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."

As of note, many android applications can and are built in the java language, so you can this post as some kind of java introdution lesson ^_^

This said/writen, i begin...

The programming languages are a way of comunication beetwin the computer/hardware and us/users, and have to be writen/used with some kind of carefull, remember that viruses and buggy programs are built using them, you can easily crash your computer filling all your RAM or even melt down your processor.

I say this to make you use VARIABLES.

Wiki:

"In computer programming, a variable is a storage location and an associated symbolic name which contains some known or unknown quantity or information, a value. The variable name is the usual way to reference the stored value; this separation of name and content allows the name to be used independently of the exact information it represents.[dubious ] A variable name in computer source code is an identifier that can be bound to a value during run time, and the value may change during the course of program execution."

For example, you can imagine the letter a as a variable that will store a number, for example, 8.
a = 8;

I know this is a lot like maths...

Lets download processing and see this in action.

As you open processing you see this screen:


As you see up there, the programming result in some circles in a dark background.
You can make something similar with these line of code:

background(0);
int a=20;
int b=20;
int c=40;
int d=40;
ellipse(a,b,c,d);

As an exercise, try to save this file in the processing format and filling the window with more circles


Understanding the code is easy:
  • background is a processing function that allow you to change the back color of the window;
  • int is the format of the files that variable accepts, this time it accepts integral values, like 1,2,3,400 or 1000;
  • ellipse is a processing function that allow you to create a circle in the window based in two groups of coordinates (controlling the center and the ray of the circle) - (20,20) are the center and (40,40) are 40 for width and 40 to height.
Try different combinations and using other functions like rect ;)