Hello World! Processing.

myimage

Taking a bit of the blog dust.

I admit, I am not the programmer kind, I like to experiment and learn, but I am from the hardware side of the force.

Recently I needed to create a programm for one of my projects, a kind of dot matrix printer from scrap, I did the project to participate in a contest in instructables, what I needed was a language that would allow me (a noob in programming) make use of image processing and serial port.

Complicated …. I have played with java lately, but I would not make it in Java at the level I am. So, what language I could use? Then I remembered of Processing and that Arduino was based on it, if Arduino makes the things easy in the side of microcontrollers, it could make them easy also on the side of computers.I was correct, Processing is a very user-friendly tool, and I am loving it.

The cool thing with Processing for those who want to have a first contact with programming, is that instead of giving you face a black or white screen or whatever the console color you are using,  you have a canvas to experiment, which means that with it you can draw lines, shapes, write text, images and animations on screen and exercise your criativity. As Java, Processing can run on Windows, Linux and Mac.

Well, looks nice, if you want to download it, visit this page. I Recommend downloading the 32-bit version even if you use a 64-bit system, because some libraries, such as Serial, may not work in 64-bit package.

If you have ever used Arduino, must understand how libraries work, a library is a set of codes created by someone that are made available for use by anyone. The idea is to make the use of any tools easier. For example, the Serial library allows easy use of the serial ports available on your computer. To add a new library to the Processing just put the library folder that you downloaded in the Processing libraries folder, simple. There are libraries for playing sounds, create 3D models, animations and much more.

Hello World!

Let’s see an example I created to demonstrate some nice things of Processing.

Hey, maybe you have played the second generation of Pokémon games. In this generation were introduced the Unown, Pokémons in of shape of letters that in certain parts of the game, Crystal at least, appeared showing the following sentence:

unown1c

“Our words shall remain here for the ages”

This gave me an idea, create a sketch (that’s how are called the Processing codes) that generated from a phrase any image that sentence formed from Unowns.

So, how to proceed?

First, get the images of Unowns. That was easy. In fact, if you search on google, you can find the sprites of Pokémons from any game. The sprites I used were the Diammond version.

Second, interpret the string with the text and relate each letter with a Unown sprite.

Third, show on the screen the phrase using the sprites.

Below the code:

The loadImage( and Image() load the images in memory and show them on the screen respectively. To form a sentence,  the images are load  in their correct position. Imagine an array where the positions can be filled with letters or spaces.

You can download the project here.

To write something, just put the desired phrase in quotation marks in String name, for example:

To separate the lines, use the “/“. You can use the characters “!” and “?” also in phrases, use only lowercase letters.

Below are some examples:

 

 dragao sem chama“Dragao sem chama”

myimage“Hello world!”

myimage

“Escrevendo com unowns”

That’s it, thanks for reading, maybe we come back with another post experimenting another language. See you!

 

Robson Couto

I am a Electrical Engineering student. I should be studying motors or transmission lines right now, but instead I am probably reading about computer history, microcontrollers, buses and protocols. My life is basically I having trouble because of this. God help me please.

Leave a Reply

Your email address will not be published. Required fields are marked *