//Aaron Koblin
//Design for Interactive Media 157A
//11/5/04
//Digital Meditation v. .98
//
//Digital Meditation is an interactive application that allows the user
//to investigate images of the Buddha. The process of materializing the
//image comes through the users interaction (or lack there of). Cryptic
//charater-esque symbols are used to reveal the images at varying sizes
//based on speed. The result is an inversely proportional relationship
//between mass and resolution. When the user is not moving, more
//precise mathematical patterns from the selected area are drawn.
int stagex = 400; //stage width
int stagey = 400; //steage height
int angle, angle2, speed, speed2, radius, state = 1;
int centery, centerx, fadedelay, lagcounter;
float[] centersx = new float[10];
float[] centersy = new float[10];
float[] spritesx = new float[10];
float[] spritesy = new float[10];
float[] speeds = new float[10];
boolean flag1;
BImage brush1, fade, bg1, bg2;
int[] bgpixels;
void setup(){
// framerate(30);
fadedelay = 0;
background(255);
size(stagex, stagey);
centerx = stagex/2;
centery = stagey/2;
centerverts(); //plots the centers for each sprite in a circle;
brush1 = loadImage("brush1.jpg");
fade = loadImage("fade.jpg");
tint(255,255,255,255);
image(fade, 0, 0, stagex, stagey);
speed2=0;
initverts();
bgpixels = new int[width*height];
bg1 = loadImage("bg.jpg");
bg2 = loadImage("bg2.jpg");
initbg();
}
void loop(){
plotsprites();
drawpattern();
tint(255,255,255,1);
angle++;
if(angle > 360){ //prevents overflow after long run-time
angle = 1;
setspeeds();
}
approachmouse();
radius = int(dist(mouseX, mouseY, centerx,centery)*.75);
if(fadedelay > 10){
image(fade, 0, 0, stagex, stagey); //causes fade effect
fadedelay = 0;
}else fadedelay++;
lagcheck();
}
void initbg(){
BImage thepicture;
if(state == 1){
thepicture = bg1;
}else thepicture = bg2;
for(int i=0; i<width*height; i++) {
bgpixels[i] = thepicture.pixels[i];
}
}
void lagcheck(){
if((pmouseX == mouseX) && (pmouseY == mouseY)){
lagcounter ++;
}else lagcounter = 0;
if(lagcounter > 100){
radius = lagcounter/25;
}
}
void mousePressed()
{
state = state * -1;
initbg();
}
void setspeeds(){
for(int x = 0;x<10;x++){
speeds[x] = 20+int(random(70)); // setup a speed for the rotation of each vert
}
}
void approachmouse(){
speed2 = (6-int(dist(centerx, centery, mouseX, mouseY)/40));
if(speed2 < 0){
speed2=0;}
if(centerx < mouseX){
centerx+=speed2;
}
if(centerx > mouseX){
centerx-=speed2;
}
if(centery < mouseY){
centery+=speed2;
}
if(centery > mouseY){
centery-=speed2;
}
centerverts();
}
void initverts(){
for(int x=0;x< centersx.length ;x++){
angle = 0;
angle = 36 * x;
centersx[x] = centerx + (cos(angle*3.14/180)*radius);
centersy[x] = centery + (sin(angle*3.14/180)*radius);
}
}
void centerverts(){
for(int x=0;x< centersx.length ;x++){
angle2 = 0;
angle2 = 36 * x;
centersx[x] = centerx + (cos(angle2*3.14/180)*radius);
centersy[x] = centery + (sin(angle2*3.14/180)*radius);
}
}
void plotsprites(){
for(int x=0;x< spritesx.length ;x++){
speed = int(random(100));
spritesx[x] = centersx[x] + (sin((angle*speeds[x])*3.14/180)*radius);
spritesy[x] = centersy[x] + (cos((angle*speeds[x])*3.14/180)*radius);
}
}
void drawpattern(){
color c1 = color(255, 255, 255,158);
for(int x=0;x< spritesx.length;x++){
if(((spritesx[x]<width)&&(spritesx[x]>0))&&((spritesy[x]<height)&&(spritesy[x]>0))){
c1 = bgpixels[int(spritesy[x])*width+int(spritesx[x])];
tint(c1);
image(brush1, spritesx[x], spritesy[x], 4-speed2/2, 4-speed2/2);
// println(speed2);
}
}
}
Assignment: Image: Develop a responsive experience based on a static image of your choice (size 400 x 400 pixels). Choose your image based on your idea and develop your program in a way that it responds to the content of the image.