Tutorial #4: The world of Processing

Hello everyone, today I would like to talk about a cool project called ‘Processing’.

Processing is an open source project mainly used for developing 2D/3D animations and interactions. It has built in OpenGL integration for accelerated 3D and provides a developing environment that makes programming a lot easier! 🙂

I have been using Processing for quite some time now. Through this tutorial I will show some of the features that Processing has to offer to all the developers using two sample programs.

Requirements: First of all, you need to download the appropriate version of Processing for your computer from here.

Extract the .zip file and you are ready to start!

Program 1: Change Image on pressing a key on the keyboard

Open the Processing application and you should see a window as follows:

If you notice the right hand side of the toolbar, you will see the “Java” mode being selected. You can switch modes and even choose either JavaScript mode or Android mode. I have used the default Java mode.

Now start writing your code for program 1 in the editor area.

PImage img;
PImage img2;

void setup()
//size of the output window
size(200, 200);
// Images must be in the "data" directory to load correctly
img = loadImage("tree1.png");
img2= loadImage("plant1.jpg");

void draw()
 //if you press a key
if (keyPressed == true)
image(img, 50, 50,100,100);
image(img2, 50, 50,100,100);

Now, by clicking on the Run button in the toolbar, start the application and you should see a window as follows:


Note: By default the data directory is created inside the documents folder. You can find it at :

path to your documents folder\Processing\processing_java\data\

If you get an error saying unable to load tree1.png then try adding the file. Click on Sketch–> Add file and select your image file.

Program 2: Writing content into a file using PrintWriter

PrintWriter output;
int count=0;

void setup() 
  // Create a new file in the sketch directory
  output = createWriter("sample.txt"); 

void draw()
  output.println("count is:" +(count++)); //Write counter value to file

void keyPressed() 
  output.flush(); // Writes the remaining data to the file
  output.close(); // close the file
  exit(); // end program

On running the program, you will find that a new textfile is created inside your sketch folder. To view the file go to Sketch–>Show sketch folder.

So guys, these were just two sample programs for those of you who want to start using Processing. I will be posting a few more examples that involves 2D and 3D animations in my next tutorial on Processing! 🙂

Happy birthday Google!

In the year 1998, exactly 14 years ago, two Stanford university students, Larry Page and Sergey Brin, came together to form a company that would change the face of the Internet world. Today, Google has made an impact in almost every walk of life with a wide range of products continuing to mesmerize millions of people all across the globe.

Here’s wishing the search engine giant a very happy 14th birthday. Just like good wine, it’s sure gonna get better with age! 🙂

Tutorial #3: Android 4.1(JellyBean) Notification Demo

I first read about JellyBean’s new notification features at this Android central blog post.

I even got a chance to view the demo live at the g|day India event in Mumbai.

jellybean.jpg file

I couldn’t wait to try this new feature out. Here is how I went about it.

Requirements: Android SDK, Eclipse Helios. Target SDK version Android 4.1

Step 1: Create a new Android project named NotificationBuilderExample with package name com.example. Make sure to select Android 4.1 as build SDK.

Step 2: Create activity named MainActivity

Note: If you are not familiar with Notifications in Android refer the links NotificationManager and Notification before proceeding further.

Step 3: Java code

public class MainActivity extends Activity 
	private NotificationManager notificationManager;
     public void onCreate(Bundle savedInstanceState) 
        notificationManager = getNotificationManager();
         Builder build = new Notification.Builder(this)  //using the Notification.Builder class
        .setContentTitle("New JellyBean Notification")   
        .setContentText("This is just an example")
          PendingIntent.getActivity(getApplicationContext(), 0,getIntent(), 0, null))
         PendingIntent.getActivity(getApplicationContext(), 0,getIntent(), 0, null))
         PendingIntent.getActivity(getApplicationContext(), 0,getIntent(), 0, null));

         Notification notification = new Notification.BigPictureStyle(build)
         BitmapFactory.decodeResource(getResources(),R.drawable.jellybean)).build();  //show image along with the notification
         Intent notificationIntent = new Intent(this, MainActivity.class);
         notificationManager.notify(0, notification);         

     private NotificationManager getNotificationManager() 
		return (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
     public boolean onCreateOptionsMenu(Menu menu)
        getMenuInflater().inflate(R.menu.main, menu);
        return true;


No change is required for the XML files over here. Run the application and you should see a screen as shown in Figure 2:

Find the source code of the project over here.

Figure 2

Getting started with Kivy

Kivy is a popular cross platform open source library for developing applications involving different user interfaces. Currently, Kivy is running on Linux, Windows, MacOSX, Android and iOS.

Let’s start by downloading Kivy for Windows from here : Kivy for Windows.

Unzip the downloaded file to find the kivy.bat file shown below:

Copy the path to this folder.

Now right click My Computer -> Properties -> Advanced System Settings -> Environment Variables

Select Path under System variables and click on Edit. Add the path you copied at the end of the Variable Value entry followed by a semicolon(;)

Open up a command prompt and type kivy to see whether kivy has be set up properly. You should see a message saying “done bootstrapping kivy..”

That completes the Kivy installation for Windows. Now moving on, let’s try a simple program.

Open any editor such as Notepad++ or best you can use the Python IDLE that comes along with a standard Python installation.

Write the following code:

import kivy

from kivy.app import App
from kivy.uix.image import Image
from kivy.uix.widget import Widget

class ShowImage(Image):
class MyApp(App):
	  def build(self):
		    return ShowImage(source='tech2.jpg',pos=(30, 130),size=(256, 256))
if __name__ == '__main__':

Save the above file as imagedemo.py. The above code is used to display an Image using Kivy. ‘tech2.jpg’ is the name of the image file. Note that the image file and the imagedemo.py file should be placed inside the same folder.

Now switch to command prompt once again, navigate to the folder contain the python file and type the command –> kivy imagedemo.py

You should see a screen with an image as below:

Tutorial #2: Create a skewing TextView in Android


Today I will try and create a custom TextView with a skewing effect in Android.

Requirements: Eclipse IDE and Android SDK.I have used Eclipse Helios with target SDK version as Android 2.2 for this tutorial.

Step 1: Create new Android project. I have named my project SkewingTextView. Let the package name be com.example

Step 2: Create an Activity class named MainActivity

Java code:

import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity

    public void onCreate(Bundle savedInstanceState) 
        Demo d=new Demo(getApplicationContext());

As seen for the above code, in the onCreate method, I am creating an object of the “Demo” class. I am passing the context of the Activity to the Demo class.

The code for the Demo class is as follows:

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.TextView;

//class that we are going to use to create custom TextView
public class Demo extends TextView 
	    Context context;
	    String firstText;  
       //use the paint object if you need to add colors to your text
	    Paint mPaint = new Paint();
	  public Demo(Context context,AttributeSet attrs)
	    this.context = context;
	    this.firstText = attrs.getAttributeValue("http://schemas.android.com/apk/res/com.example", "first_name");

	  public Demo(Context context)
	  this.context = context;
	  Log.i("sampletextview", "MyTextView");
	  protected void onDraw(Canvas canvas) 
	    setText(firstText);  //display the text
	    setTextSize(50);  //set the size for the TextView
	    canvas.skew(1.0f, 0.3f);  //change values to suit your needs
	    Rotate3dAnimation skew = new Rotate3dAnimation(-20, 30, 200, 200, 0, false); //change values if you want

In the above code, we have created an object “skew” of the Rotate3dAnimation class. The source code for the Rotate3dAnimation class is over here.

Using the Rotate3dAnimation.java code we can also add/apply transformations.

Layout file: main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

This completes the tutorial. Make sure the project does not contain any errors. Run the application to get the output as follows:

The source code of the project can be found over here.

Tutorial #1: Android Accelerometer Demo

Hello everyone, today I am going to create an Android application to show how an accelerometer works.

Requirements: Eclipse IDE and Android SDK. I have used Eclipse Helios with target SDK version as Android 2.2 for this tutorial.

Step 1: Create new Android project. I have given my project the name AccelerometerDemo. Let the package name be com.example

Step 2: Create activity class in your project.  I have gone with the default name MainActivity

Now let’s start coding!

1) MainActivity.java

We need to first implement the SensorEventListener for our class:

public class MainActivity extends Activity implements SensorEventListener { }

Now we create an object for SensorManager and Sensor within our MainActivity class. We also declare TextViews and a RelativeLayout used for displaying accelerometer values.

   private SensorManager mSensorManager;
   private Sensor mAccelerometer;
   TextView title,tv,tv1,tv2;
   RelativeLayout layout;

write the onCreate method that defines the starting point of our Activity

   public final void onCreate(Bundle savedInstanceState)
      setContentView(R.layout.activity_main); //refer layout file code below
      //get the sensor service
      mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
      //get the accelerometer sensor
      mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
      //get layout
      layout = (RelativeLayout)findViewById(R.id.relative);
       //get textviews

Now we need to override two methods that are associated with SensorEventListener namely onAccuracyChanged and onSensorChanged

    public final void onAccuracyChanged(Sensor sensor, int accuracy)
       // Do something here if sensor accuracy changes.
   public final void onSensorChanged(SensorEvent event)
      // Many sensors return 3 values, one for each axis.
     float x = event.values[0];
     float y = event.values[1];
     float z = event.values[2];
     //display values using TextView
     tv.setText("X axis" +"\t\t"+x);
     tv1.setText("Y axis" + "\t\t" +y);
     tv2.setText("Z axis" +"\t\t" +z);

After we have done this, it is important to register and unregister the SensorListener in the Activity lifecycle methods onResume and onPause as follows:

   protected void onResume()
   mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
   protected void onPause()

2) Layout file: activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"



Finally, this completes our first tutorial. Run the application and you should see a screen as below:

Complete source code of project can be found over here.

How to utilize the time post your final engineering exam

Final exams done and the long vacations begin…!!!

(After 2 weeks or so)

“Hey dude, wassup these days? “, “Hi, what are doing in your vacations?”, “Arrey joining ka kuch pata chala kya?” .For those of you who are really bored right now, just try and copy paste these common one liners in your chat box search and you’ll probably be surprised with the number of results that come up. A low count might indicate that you are really busy with something or even might mean that you have already told everyone about your vacation plans so that no one pings you to ask about. If you are one of those who get a high count then one thing I can guarantee you is that reading the remaining part of this post would certainly help you in utilizing your time in a much better way! 🙂

Being an engineer, I know what it means to spend 4 years in one college, writing assignments, preparing for vivas and most importantly coping with the stress when submission dates are fast approaching. I won’t go into details about Engineering life as that isn’t what I want to convey through this post. The question arises, “What after engineering?” .Yes! You have managed to survive those 4 years, cope with the stress, you even pass with flying colours but then why is it that these long vacations turn you into an idle and lethargic individual. The reasons are many but I believe that you need to keep yourself active both physically and mentally now-a-days in order to compete with the rat race outside.

Hobby!! This 5 letter word is slowly losing its importance. How would you justify the fact that once as school kids we might have written short essays on the topic “My favourite hobby” and today when we have the time to follow it we ponder (Am I doing anything?). Very few think of turning their passion or their hobby into a full time business. Hobbies have started to become mere assignments that we just write about and then forget. So my first appeal to you guys is start following your hobby and it will definitely help you kill the idle time during vacations.

It is also possible that you might not have a hobby from the beginning. It’s fine. It can be developed. But if you are one of those couch potatoes who loves sitting in front of the television or computer screen, opening up tabs for Facebook, Twitter etc checking out what’s going on in your social network then I am afraid you’ll only succeed in increasing your spectacle power and fail in doing something constructive. Physical activity becomes a must here. Try and get yourself enrolled at a gym or a health club and spend time doing exercises. Meditation and yoga could also prove beneficial. Here, I would like to share that I too was once a couch potato but listening to my parent’s advice for the same helped me come out of it. So thank you mom and dad! 🙂

By now you may think I am bit cynical. Haha! Not really. I know that in every dark cloud there is a   silver lining and as a matter of fact there are quite a number of creative and innovative people out there who you just don’t need to tell how to spend their idle time during a vacation. Here, I would like to talk about a dear friend of mine, Ajit. Ajit was the one who persuaded me to buy my first Android phone and to start developing for it. He is one of those guys who always came up with these weird, wacky yet innovative ideas that if one could implement successfully, would eventually turn out to be a money making machine. So guys just try to be creative in whatever way you can and I am certain you will succeed in killing the idle time you encounter during vacations.

From couch potatoes to innovators, are we done yet? No! We have forgotten that there are certain people who are always mistaken to be Geeks. They have a hunger to learn and try to get maximum knowledge out of a particular thing. Their hunger for learning never dies. Using their knowledge they create and share. Sometimes, they encounter success and sometimes despair. However, this doesn’t stop them from doing what they do. If you are one those then perhaps you’ll be successful in killing your idle time 9 out of 10 times. If you are interested in learning programming languages, you could always try enrolling for a specific language course. If you have already familiar with one, you could possible do an internship to get a more practical experience. All these are just alternatives but it’s up to you to decide what’s going to be your source of learning.

I must confess that it’s difficult for me to spend even a day without my family and my close friends. Imagine those who spend 4 years. The sight of a boy or a girl leaving their hometown to fulfil his/her dream and pursue a career is common when we think about such small town wonders. They learn to live the hard way and have a comparatively busier life. However, sometimes boredom does manage to sneak into their lives increasing the amount of idle time. In such situations, spending time with your family and friends is a good solution. Here I am not asking you to adopt a sedentary lifestyle instead I want you to kill your idle time by narrating incidents, moments you spent while you were away, to your parents and grandparents or perhaps even pen them down somewhere looking at those old photographs and greeting cards that I am sure one would never forget.

Just remember that time and tide waits for no man. While this could perhaps be your last de-stressful vacation, you ought to make the best of it, free of boredom and laziness as many you might be stepping into the corporate world soon…!!!

Get busy. Get Going

The long wait ends!

Sunday, 23rd September 2012 will be etched in my memory forever as I took my first step into the IPv6 world with the launch of my own personal website.

As I write my first post over here, I would like to thank my parents for supporting and believing in me. I couldn’t have started this process without the encouragement of all my friends in school and college. As time goes by you will find some really interesting articles over here. Before you proceed please make sure to read the FAQ.

Hope you guys enjoy the website and please do keep visiting it! I promise to have lots in store for the future! 🙂