import java.applet.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.util.zip.*; public class natzke extends BApplet { int xWidth = 328, yHeight = 214; int total = 70192; Bouncer[] bouncer = new Bouncer[total]; Follower f1 = new Follower(); int select = 3; boolean clear = true; boolean click = false; boolean binary = true; boolean lines = true; int counter = 0; int strokeVar = 2; BImage tbg; int[] tbgPixels; void setup() { size(500,350); tbgPixels = new int[width*height]; noBackground(); smooth(); fill(51); noStroke(); rect(0,0,width,height); ellipseMode(CENTER_DIAMETER); tbg = loadImage("natzke.jpg"); for(int i=0; i distMax-1){ distance = distMax-1; } if (!click){ xd = xPos - initX; yd = yPos - initY; d = sqrt(sq(xd) + sq(yd)); newXVel = xVel * ((501 - distance)/550) + (initX - xPos) * (distance/distMax); newYVel = yVel * ((501 - distance)/550) + (initY - yPos) * (distance/distMax); xVel -= (xVel - newXVel) * .2f; yVel -= (yVel - newYVel) * .2f; if (d < 2){ xVel = 0; yVel = 0; xPos = initX; yPos = initY; } } else { newXVel = xVel * sin(distance/10) + (mouseX - xPos) * sin(distance/10); newYVel = yVel * cos(distance/10) + (mouseY - yPos) * cos(distance/10); xVel -= (xVel - newXVel) * .2f; yVel -= (yVel - newYVel) * .2f; } } void enlarge(){ distMax = 500; xDelta = f1.xPos - xPos; yDelta = f1.yPos - yPos; distance = sqrt(sq(xDelta) + sq(yDelta)); if (distance > distMax-1){ distance = distMax-1; } if (!click){ xd = xPos - initX; yd = yPos - initY; d = sqrt(sq(xd) + sq(yd)); newXVel = xVel * ((distMax - distance)/(distMax + 200)) + (initX - xPos) * (distance/(distMax + 200)); newYVel = yVel * ((distMax - distance)/(distMax + 200)) + (initY - yPos) * (distance/(distMax + 200)); xVel -= (xVel - newXVel) * .2f; yVel -= (yVel - newYVel) * .2f; } else { newXVel = xVel * (sin((distance)/(distMax/3))) + (mouseX - xPos) * (sin((distance)/(distMax + 0)) - .5f); newYVel = yVel * (cos((distance)/(distMax/3))) + (mouseY - yPos) * (sin((distance)/(distMax + 0)) - .5f); xVel -= (xVel - newXVel) * .1f; yVel -= (yVel - newYVel) * .1f; } } void spherize(){ distMax = 10000; xDelta = f1.xPos - xPos; yDelta = f1.yPos - yPos; distance = sqrt(sq(xDelta) + sq(yDelta)); if (distance > distMax-1){ distance = distMax-1; } if (!click){ xd = xPos - initX; yd = yPos - initY; d = sqrt(sq(xd) + sq(yd)); newXVel = xVel * ((distMax - distance)/(distMax + 200)) + (initX - xPos) * (distance/(distMax + 200)); newYVel = yVel * ((distMax - distance)/(distMax + 200)) + (initY - yPos) * (distance/(distMax + 200)); xVel -= (xVel - newXVel) * .2f; yVel -= (yVel - newYVel) * .2f; } else { newXVel = xVel * (cos((distMax - distance)/(distMax))) + (mouseX - xPos) * (sin((distance)/(distMax + 500)) -.1f); newYVel = yVel * (cos((distMax - distance)/(distMax))) + (mouseY - yPos) * (sin((distance)/(distMax + 500)) -.1f); xVel -= (xVel - newXVel) * .1f; yVel -= (yVel - newYVel) * .1f; } } void slowmo(){ distMax = 10000; xDelta = f1.xPos - xPos; yDelta = f1.yPos - yPos; distance = sqrt(sq(xDelta) + sq(yDelta)); if (distance > distMax-1){ distance = distMax-1; } if (!click){ xd = xPos - initX; yd = yPos - initY; d = sqrt(sq(xd) + sq(yd)); newXVel = xVel * ((distMax - distance)/(distMax + 200)) + (initX - xPos) * (distance/(distMax + 200)); newYVel = yVel * ((distMax - distance)/(distMax + 200)) + (initY - yPos) * (distance/(distMax + 200)); xVel -= (xVel - newXVel) * .2f; yVel -= (yVel - newYVel) * .2f; } else { newXVel = xVel * ((distMax - distance)/(distMax + 200)) + (mouseX - xPos) * (distance/(distMax + 200)); newYVel = yVel * ((distMax - distance)/(distMax + 200)) + (mouseY - yPos) * (distance/(distMax + 200)); xVel -= (xVel - newXVel) * .2f; yVel -= (yVel - newYVel) * .2f; } } void staticTrail(){ distMax = 500; xDelta = f1.xPos - xPos; yDelta = f1.yPos - yPos; distance = sqrt(sq(xDelta) + sq(yDelta)); if (distance > distMax-1){ distance = distMax-1; } if (!click){ xd = xPos - initX; yd = yPos - initY; d = sqrt(sq(xd) + sq(yd)); newXVel = xVel * ((501 - distance)/550) + (initX - xPos) * (distance/distMax); newYVel = yVel * ((501 - distance)/550) + (initY - yPos) * (distance/distMax); xVel -= (xVel - newXVel) * .2f; yVel -= (yVel - newYVel) * .2f; /*if (d < 2){ xVel = 0; yVel = 0; xPos = initX; yPos = initY; }*/ } else { newXVel = xVel * cos(distance/2)/10 + (mouseX - xPos) * sin(distance/2)/10; newYVel = yVel * cos(distance/2)/10 + (mouseY - yPos) * cos(distance/2)/10; xVel -= (xVel - newXVel) * .2f; yVel -= (yVel - newYVel) * .2f; } } void breakApart(){ distMax = 50; xDelta = f1.xPos - xPos; yDelta = f1.yPos - yPos; distance = sqrt(sq(xDelta) + sq(yDelta)); if (!click){ xd = xPos - initX; yd = yPos - initY; d = sqrt(sq(xd) + sq(yd)); newXVel = xVel * .5f + (initX - xPos) * .8f; newYVel = yVel * .5f + (initY - yPos) * .8f; xVel -= (xVel - newXVel); yVel -= (yVel - newYVel); } else { if (distance < 15){ if (mouseX > pmouseX){ xd = mouseX - pmouseX; if (xd > 50){ xd = 50; } xVel = yd; } else if (pmouseX > mouseX){ xd = mouseX - pmouseX; if (xd < -50){ xd = -50; } xVel = yd; } if (mouseY > pmouseY){ yd = mouseY - pmouseY; if (yd > 50){ yd = 50; } yVel = yd; } else if (pmouseY > mouseY){ yd = mouseY - pmouseY; if (yd < -50){ yd = -50; } yVel = yd; } } } } void breakApart2(){ distMax = 500; xDelta = f1.xPos - xPos; yDelta = f1.yPos - yPos; distance = sqrt(sq(xDelta) + sq(yDelta)); if (distance > distMax-1){ distance = distMax-1; } if (!click){ xd = xPos - initX; yd = yPos - initY; d = sqrt(sq(xd) + sq(yd)); newXVel = xVel * .5f + (initX - xPos) * .8f; newYVel = yVel * .5f + (initY - yPos) * .8f; xVel -= (xVel - newXVel); yVel -= (yVel - newYVel); } else { if (distance < 10){ if (mouseX > pmouseX){ xd = mouseX - pmouseX; xVel = random(0,xd); } else if (pmouseX > mouseX){ xd = mouseX - pmouseX; xVel = random(xd,0); } if (mouseY > pmouseY){ yd = mouseY - pmouseY; yVel = random(0,yd); } else if (pmouseY > mouseY){ yd = mouseY - pmouseY; yVel = random(yd,0); } } newXVel = xVel * ((distance/distMax)) + (mouseX - xPos) * ((distance/distMax)/5); newYVel = yVel * ((distance/distMax)) + (mouseY - yPos) * ((distance/distMax)/5); xVel -= (xVel - newXVel) * ((distance/distMax)/5); yVel -= (yVel - newYVel) * ((distance/distMax)/5); } } void borders(){ if ((xPos + xVel) < 0){ xPos = 0; //xVel *= -1; } else if ((xPos + xVel) > width){ xPos = width; //xVel *= -1; } if ((yPos + yVel) < 0){ yPos = 0; //yVel *= -1; } else if ((yPos + yVel) > height){ yPos = height; //yVel *= -1; } } } }