Tuesday, 5 June 2012

new Android tablet

Microscopic anatomy images on my new Android tablet
My new Android tablet has been fun to program with Processing for Android, once I'd set it up to run via Eclipse it has been straightforward to create the APK files and transfer them to the tablet. There's a good sound hack with apwidgets, solved a lot of problems I'd been having with sound files:

import edu.uic.ketai.inputService.*;
import android.content.pm.ActivityInfo;
import apwidgets.*;

PMediaPlayer player;
KetaiSensorManager sensorManager;
PVector  accelerometer;

int numBalls = 12;
float spring = 0.05;
float gravity = 0.03;
float friction = -0.5;
Ball[] balls = new Ball[numBalls];

void setup()
{
  size(screenWidth, screenHeight);
  orientation(PORTRAIT);
  player = new PMediaPlayer(this); //create new PMediaPlayer
  player.setMediaFile("groupe2_osj.mp3"); //set the file (files are in data folder)

  sensorManager = new KetaiSensorManager(this);
  sensorManager.start();
  smooth();
  noStroke();
  accelerometer = new PVector();

  for (int i = 0; i < numBalls; i++) {
    balls[i] = new Ball(random(width), random(height), random(20, 40), i, balls);
  }
}

void draw()
{
  background(0);
  //
  //   text("Accelerometer data:" 
  //  + nf(accelerometer.x, 2, 2) + "/" 
  //  + nf(accelerometer.y, 2, 2) + "/" 
  //  + nf(accelerometer.z, 2, 2), 5, 20);

  for (int i = 0; i < numBalls; i++) {
    balls[i].collide();
    balls[i].move();
    balls[i].display();
  } 
  if (balls[1].x==width) {

    player.start(); //start play back
    player.start(); //start play back
    player.setLooping(true); //restart playback end reached
    player.setVolume(1.0, 1.0); //Set left and right volumes. Range is from 0.0 to 1.0
  }
}


void onAccelerometerSensorEvent(long time, int accuracy, float x, float y, float z)
{
  accelerometer.set(x, y, z);
}

public void mousePressed() { 
  if (sensorManager.isStarted())
    sensorManager.stop(); 
  else
    sensorManager.start(); 
  println("SensorManager isStarted: " + sensorManager.isStarted());
}


class Ball {
  float x, y;
  float diameter;
  float vx = 0;
  float vy = 0;
  int id;
  Ball[] others;

  Ball(float xin, float yin, float din, int idin, Ball[] oin) {
    x = xin;
    y = yin;
    diameter = din;
    id = idin;
    others = oin;
  } 

  void collide() {
    for (int i = id + 1; i < numBalls; i++) {
      float dx = others[i].x - x;
      float dy = others[i].y - y;
      float distance = sqrt(dx*dx + dy*dy);
      float minDist = others[i].diameter/2 + diameter/2;
      if (distance < minDist) { 
        float angle = atan2(dy, dx);
        float targetX = x + cos(angle) * minDist;
        float targetY = y + sin(angle) * minDist;
        float ax = (targetX - others[i].x) * spring;
        float ay = (targetY - others[i].y) * spring;
        vx -= ax;
        vy -= ay;
        others[i].vx += ax;
        others[i].vy += ay;
      }
    }
  }

  void move() {

    float Acc_gravityX = map(accelerometer.x, -10, 10, 0.5, -0.5);
    float Acc_gravityY = map(accelerometer.y, -10, 10, -0.5, 0.5);

    float gravityX = Acc_gravityX;
    float gravityY = Acc_gravityY;

    vy += gravityY;
    vx += gravityX;
    x += vx;
    y += vy;

    if (x + diameter/2 > width) {
      x = width - diameter/2;
      vx *= friction;
    }
    else if (x - diameter/2 < 0) {
      x = diameter/2;
      vx *= friction;
    }
    if (y + diameter/2 > height) {
      y = height - diameter/2;
      vy *= friction;
    } 
    else if (y - diameter/2 < 0) {
      y = diameter/2;
      vy *= friction;
    }
    //println(nf(x, 2, 2)+"   "+nf(y, 2, 2)+"  "+nf(gravityX, 2, 2)+"  "+nf(gravityY, 2, 2)+"  __"+nf(accelerometer.x, 2, 2)+"  ___"+nf(accelerometer.y, 2, 2));
  }

  void display() {
    fill(255, 204);
    ellipse(x, y, diameter, diameter);
  }
}



Monday, 14 May 2012

Digital Futures: Giving a Talk about our work at the V&A Sackler Centre

On Tuesday 26th of June Alexandra Antonopoulou and I will be giving a talk about our work at the V&A Sackler Centre:
We'll talk about the Phi Books and the way we have used computational models and custom- made software to collaborate on writing and creating Artists' Books.

Wednesday, 25 April 2012

Paper published in the Journal of Writing in Creative Practice

Alexandra Antonopoulou and I have had our joint paper published in The Journal of Writing in Creative Practice, it looks pretty nice...Janis has a chapter as well...we're doing a thing for it on the 4th of May at Goldsmiths.








http://www.writing-pad.org/wiki/JournalWritingCreativePractice

Hokus Pokus opening at Watermans Art Centre

last Saturday's Watermans Art Centre talk went well - nice big crowd, Saturday 21 April, 15.30 – 18.30 followed by the Private View of Michele Barker’s & Anna Munster’s installation 'HokusPokus' .  Janis chairing. Great to hear how this work was developed and to meet Australian artists. A good show of Goldsmith students too....
http://watermans.ticketsolve.com/shows/126521636/events

My friend Magda said my talk was funny..funny is good...right?



Saturday, 10 December 2011

Staging illusion



Despite horrendous storminess this was a great event, I didn't realise some of the other delegates and academics were also illusionists/magicians and members of the magic circle. I'm glad I didnt show anyone how my Pepper's Ghost Buddha works or I would have been in big trouble..drummed out of Brighton at least.