Monday, 8 February 2010

Using Mobile Processing (Part 2)

My following experiments with mobile processing involved extending it to involve simple interactions with the user. I experimented with many things, touchscreen, sound, video and camera.

My first attempts with touch screen were quite successful, I basically made a very simple app that acted as a kind of "random bright triangles brush stroke" It was based on a simple sketch I saw for Processing by Vault Dweller. This midlet (at they are known) utilised the touchscreen on my phone as a method for drawing the images. The stroke comrpised of generating randomly sized and positioned triangles around the pointer, all with high brightness and saturation.

The following experiments were not so succesful. After wrestling for many hours with my phone, trawling message boards for help I came to the conclusion that my phone was unable to run apps that used either video or cameras. With regards to sound it was inconclusive - so if I desire to try again it might be worth playing around with making simple synthesizers for mobile phones. Although without a way to test or run apps (the emulator also wont allow video or camera input) it was impossible to extend out into these areas.

Here is the code for the Triangle's App (sorry, it has hacky and useless bits left in from other experiments which are unnecessary to run the app, but at least it works!) -

int x;
int y;
int lastX;
int lastY;
boolean screenTouch;

void setup() {
softkey("Shake");

x = width / 2;
y = height / 2;

framerate(15);
background(0);
stroke(255);
fill(0);
stroke(0);
strokeWeight(3);
colorMode(HSB);
}

void draw() {
if(screenTouch){

lastX = x;
lastY = y;
fill(random(0,255), 255, 255);
triangle(x + random(-20, +20), y + random(-20, +20),
x + random(-20, +20), y + random(-20, +20),
x + random(-20, +20), y + random(-20, +20));

}
}

void pointerDragged(){

x=pointerX;
y=pointerY;
redraw();
}

void pointerPressed(){
x = pointerX;
y = pointerY;
lastX = x;
lastY = y;
screenTouch = true;
}

void pointerReleased(){
screenTouch = false;
}

void softkeyPressed(String label) {
if (label.equals("Shake")) {
background(0);
}
}

No comments:

Post a Comment