Corrupt?, 17 March 2009

Mobile Processing app which displays patterns of bright colours and vibrates the phone. Just an experiment into J2ME, not too successful, but still… pretty!

Download the JAD and JAR for Java-compatible phones.

import processing.phone.*;
int BOX_HEIGHT = 10;
int N_COLOURS = 4;
int N_SIZES = 5;
color[] colours;
int[] sizes;
int i;
int j;
Phone p;
void setup() {
  p = new Phone(this);
  p.fullscreen();
  colorMode(HSB, 360, 100, 100);
  noStroke();
  BOX_HEIGHT = random(1,40);
  N_COLOURS = random(2, 50);
  N_SIZES = random(2, 50);
  colours = new color[N_COLOURS];
  for (int i = 0; i < N_COLOURS; i++) {
    colours[i] = color(random(360), 100, 100);
  }
  sizes = new int[N_SIZES];
  for (int i = 0; i < N_SIZES; i++) {
    sizes[i] = random(1, width / 2);
  }
  i = j = 0;
}
void keyPressed() {
  setup();
}
void draw() {
  background(0);
  if (i == j) {
    p.vibrate(150);
  }
  for (int y = 0; y < height; y += BOX_HEIGHT) {
    for (int x = 0; x < width; ) {
      int this_width = sizes[j];
      fill(colours[i = (i + 1) % N_COLOURS]);
      rect(x, y, this_width, BOX_HEIGHT);      
      x += this_width;
    }
  }
  i = (i + 1) % N_COLOURS;
  j = (j + 1) % N_SIZES;
}

Comment

  1. spelling mistake on this page…??? Sort it out boy!!

    Caroline · 7 April 2009 · #

Commenting is closed for this article.