// applet size variables int xSize = 350; int ySize = 350; int xMid = xSize/2; int yMid = ySize/2; int xOffset = 75; int yOffset = 75; float counter = 0.25; float distMeter = 50.0; LightGrid lightGrid; BImage glow; void setup(){ size(xSize, ySize); ellipseMode(CENTER_DIAMETER); imageMode(CENTER_DIAMETER); colorMode(RGB,255); glow = loadImage("glow.gif"); brightToAlpha(glow); // create lightGrid (xNum, yNum, res) lightGrid = new LightGrid(10, 10, 20); } void loop(){ background(22); if (mousePressed){ counter = 0.25; distMeter = 50.0; if (mouseX > xOffset && mouseX < (xOffset + lightGrid.xNum * lightGrid.res)){ if (mouseY > yOffset && mouseY < (yOffset + lightGrid.yNum * lightGrid.res)){ int xClicked = (mouseX - xOffset)/lightGrid.res; int yClicked = (mouseY - yOffset)/lightGrid.res; lightGrid.xClicked = xClicked; lightGrid.yClicked = yClicked; } } } lightGrid.exist(); counter += 1.0; distMeter += 8.0; //delay(10); } class Light{ int index; int res; float x, y; float bb; boolean clicked; Light(float sentX, float sentY, int sentIndex, int sentRes){ x = sentX; y = sentY; index = sentIndex; res = sentRes - 4; } void exist(){ findBrightness(); render(); } void findBrightness(){ float dist = findDistance(x + xOffset, y + yOffset, lightGrid.xCenter, lightGrid.yCenter); if (dist < distMeter){ bb = (sin((255 - dist + (counter * 10.0) + 20.0)/20.0) * 122.5 + 122.5) - counter*2.0; } else { bb = 0; } } void render(){ //tint(0,0,255,bb); //image(glow, x + xOffset, y + yOffset + 1.0, 25 + (bb/10.0), 25 + (bb/10.0)); fill(0,0,255,bb/5.0); noStroke(); ellipse(x + xOffset + res/2, y + yOffset + res/2, res/2 + 20, res/2 + 20); fill(0,0,255,bb/2.0); noStroke(); ellipse(x + xOffset + res/2, y + yOffset + res/2, res/2 + 13, res/2 + 13); fill(0,0,255,bb); noStroke(); ellipse(x + xOffset + res/2, y + yOffset + res/2, res/2 + 5, res/2 + 5); fill(0,0,0); noStroke(); ellipse(x + xOffset + res/2, y + yOffset + res/2, res/2, res/2); //rect(x + xOffset, y + yOffset, res, res); } } class LightGrid{ Light[][] light; int xNum; int yNum; int xClicked = 5; int yClicked = 5; int xCenter; int yCenter; int res; float bodyRadius; float xRot, yRot, zRot; LightGrid(int sentXNum, int sentYNum, int sentRes){ xNum = sentXNum; yNum = sentYNum; res = sentRes; light = new Light[xNum][yNum]; for (int y=0; y