15 April 2012

Sketch Outline - Processing Tool

Processing is an open source programming language and environment for people who want to create images, animations, and interactionsInitially developed to serve as a software sketchbook and to teach fundamentals of computer programming within a visual context, Processing also has evolved into a tool for generating finished professional work. Today, there are tens of thousands of students, artists, designers, researchers, and hobbyists who use Processing for learning, prototyping, and production. It's highly recommended for learning the art of programming.

I've been a long time user of Processing. It's my favorite language when it comes to quick prototyping and testing out new ideas or concepts. The fact that it's Java based, one can use native Java code too. Processing comes with its own basic IDE designed for beginners. The IDE supports plugin like components called Tools which extend its functionality. I had earlier developed a tool for Processing - Color Selector Plus. I've now developed a second tool - Sketch Outline.


Sketch Outline running in Processing 1.5.1 (OS X Lion) and in Processing 2.04 (Windows 7)

Sketch Outline provides a tree view of the member variables, functions and classes within a sketch and allows easy navigation between them. Clicking on any node scrolls and moves the cursor to its definition in the code. This is kinda similar to the Outline View available in Eclipse and many other IDEs. It helps in easy navigation while writing code and very helpful for larger projects.

I've used java parser for generating the AST(Abstract Syntax Tree). An AST is a tree representation of the abstract syntactic structure of source code written in a programming language. Java parser library is simple to use and was a good learning experience for me regarding code parsers. But it has limited functionality, and hasn't been updated to Java 1.6. I'm currently working on a more advanced version of this tool that would use the Eclipse JDT core components. Eclipse JDT core is the back end of the Eclipse Java IDE, responsible for many of the cool features like generating the outline view, background compilation, real time error reporting, code completion suggestions, etc. For now, I plan to use its AST generation feature(it can recover from errors in syntax and still generate the AST!), and batch compilation for reporting syntax as well as compilation errors in real time. 

You can grab the latest version from here. If you're using version 2.0 of Processing or higher, you can also get it from within the IDE by going to Tools menu → Add Tool. Sketch Outline is also listed on Processing's tools page.

The project is open source and hosted on Google Code. Try it out and feel free to give any suggestions or report any bugs in the forum thread, in the issues section of the project or as a comment. 

Cheers!  :)

7 April 2012

Ninja Air Hockey

Today, I'll be sharing a fun little game I'd made some time back - Ninja Air Hockey. It's your regular air hockey with a twist - You control your bat not with the mouse or keyboard, but with some colored object! Sounds weird? Check out its video in action:

I've decided to make it open source. Ninja Air Hockey was designed using openFrameworks and OpenCV. openFrameworks is an opensource C++ toolkit for creative coding. 

According to its authors, openFrameworks was developed:
(for) folks using computers for creative, artistic expression, and who would like low level access to the data inside of media in order manipulate, analyze or explore. That audience we felt was significantly underserved by the current crop of C++ libraries.

oF is designed to be used on Windows, Mac OS X and Linux and supports XCode, Code::Blocks, Visual Studio and EclipseI had used an older version of openFrameworks - v0062 on Visual Studio. This version is archived here. Here's how you can set it up on Visual Studio:

  • Download the Visual Studio 2010 FAT(v0062), and unzip it. 
  • You need to have OpenCV set up as well. For instructions on how to install OpenCV on Windows, check out the earlier post. Make sure you've Quicktime installed too.
  • Download the source code from google code here.
  • Copy AirHockey folder into apps/addonsExamples.
  • Open AirHockey.sln, wait for the project to load. Press F5 to run. When running for the first time, it can take upto 2-3 mins to start since Visual Studio will build the openFrameworks libraries first.

The all important source files are present in the AirHockey/src folder. And data files are present in the AirHockey/bin/data folder. Using them, you can build this project on the platform and IDE of your choice. Please refer to openFrameworks wiki for instructions on how to set it up on your platform and IDE.

Screenshot
The code is well commented and should be fairly easy to understand. For any questions, feel free to comment. :)

Cheers!