Tuesday, 24 May 2016

Android App Development using Processing - Part II : Intro to Programming

Last time we have installed Android Studio and Processing software. Now it's time to start programming.(I assume you have some basic knowledge of programming )
Usually, every processing Sketch has two functions
1. Setup 
This function runs once only when sketch initiated.
All things that need to be run just once can put under this function like defining the size of the screen.
2. Draw
 After the sketch is initiated and Setup part is run then Draw part runs forever until the program is shut down.
Basically, it works as an infinite loop.
All the things that need to run for entire time like feedback from user need to put inside Draw function.

Example 
    Let's take an example of loading an image on the screen.



Description
    PImage : Datatype for storing images.
    size : For Screen size
    loadImage : Loads an image into a variable of type PImage
    image : The image() function draws an image to the display window




Code:

PImage bg,bg1;
int click=0;
void setup()
{
  
  size(displayWidth,displayHeight);
  orientation(PORTRAIT);
  bg = loadImage("bg.jpg");
  bg1 = loadImage("bg1.jpg");
  imageMode(CENTER);
  textSize(height/11);
}

void draw()
{
  if(click%2 == 0)
  image(bg, width/2,height/2,width,height);
  else
  image(bg1, width/2,height/2,width,height);
}
void mousePressed()
{
 click+=1;
  


Sunday, 1 May 2016

Android App Development using Processing - Part I : Installation

INTRODUCTION: What is Processing?
An open-source platform for developers and tinkerers to code for graphics and visual arts.
or
Processing is a flexible software sketchbook and a language for learning how to code within the context of the visual arts.
  • » Free to download and open source
  • » Interactive programs with 2D, 3D or PDF output
  • » OpenGL integration for accelerated 2D and 3D
  • » For GNU/Linux, Mac OS X, and Windows
  • » Over 100 libraries extend the core software
  • » Well documented, with many books available
HOW TO INSTALL?
  1. Download and Install Android Stand-alone SDK toolkit.
  2. In android SDK manager install 'Android SDK Tools','Plateform Tools','Build Tools' & 'Android 4.1.2'.
  3. Download Processing and install it.
  4. Open Processing.exe and go to Add Mode and add Android Mode.
  5. Select Android mode instead of Java mode, a comment will show up asking ' Is android SDK installed?' , then choose to  'locate SDK path manually' and go to Android SDK folder and select it.
  6. Installation Done, Enjoy!


Stay tuned...