Skip to content

Instantly share code, notes, and snippets.

@georgebashi
Created April 26, 2010 13:56
Show Gist options
  • Save georgebashi/379360 to your computer and use it in GitHub Desktop.
Save georgebashi/379360 to your computer and use it in GitHub Desktop.
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment