PImage a; int buttonCount = 5; TextButtons[] button = new TextButtons[buttonCount]; boolean clickAction; PFont font; void setup() { size(600, 600); stroke(255); frameRate(30); smooth(); a = loadImage("triangle2.jpg"); font = loadFont("UniversLTStd-Light-48.vlw"); //font = loadFont("ScalaSans-Caps-32.vlw"); button[0] = new TextButtons(100, 100, 150,50, "Resume", font, 30, "http://www.williamslabs.com/docs/PhelpsWilliamsResume2008.pdf", false); //button[1] = new TextButtons(400, 100, 150,150, "Contact", font, 30, "http://www.williamslabs.com/me.html"); button[1] = new TextButtons(40, 360, 150,50, "Projects", font, 30, "http://www.williamslabs.com/projects/", false); button[2] = new TextButtons(420, 360, 150,150, "Molecubes", font, 30, "http://molecubes.org/", false); //button[4] = new TextButtons(100, 500, 150,50, "KepCalc", font, 30, "http://sourceforge.net/projects/kepcalc"); button[3] = new TextButtons(240, 520, 150,150, "Pictures", font, 30, "http://picasaweb.google.com/phelpsw", false); button[4] = new TextButtons(370, 100, 150,150, "Pubs/Docs", font, 30, "http://www.williamslabs.com/docs/", false); } float angle; float x; float y; float xe; float ye; float targetX, targetY; float easing = 0.02; void draw() { background(255); for(int i = 0; i 1) { xe += dx * easing; } targetY = mouseY; float dy = mouseY - ye; if(abs(dy) > 1) { ye += dy * easing; } x = xe - width/2; y = ye - height/2; angle = calcRadians(x, y); /* float textx = 50; float texty = 50; float textang = calcRadians(textx - width/2, texty - height/2); float fade = (float)Math.min(Math.abs(textang - angle), Math.abs(textang - (angle + 2*Math.PI))); fade = 1 - fade / (float)(Math.PI); textFont(font); fill(0, 0, 0, sq(fade)* 75 + 25); text("werd", textx,texty); */ translate(width/2, height/2); scale(0.5); rotate(angle); pushMatrix(); translate(-a.width/2, -a.height/2); image(a, 0, 0); popMatrix(); } float calcRadians(float x, float y) { float angle; if(x>=0){ angle = (float)Math.atan(y/x) + (float)Math.PI/2; } else { angle = (float)Math.atan(y/x) + (float)(3*Math.PI/2); } return angle; } void mouseReleased() { clickAction = true; } class Button { int x, y; int w, h; boolean over = false; boolean pressed = false; void pressed() { if(over && clickAction==true) { pressed = true; } else { pressed = false; } } boolean overRect(int x, int y, int width, int height) { if (mouseX >= x && mouseX <= x+width && mouseY >= y && mouseY <= y+height) { return true; } else { return false; } } } class TextButtons extends Button { String txt; String uri; int txtsize; // used for fade calculation float textang; float fade; boolean newpage; TextButtons(int ix, int iy, int wd, int ht, String textin, PFont font, int itxtsize, String addr, boolean newp) { x = ix; y = iy; w = wd; h = ht; txt = textin; uri = addr; txtsize = itxtsize; newpage = newp; } void update() { over(); pressed(); if(pressed) { if(newpage) { link(uri, "_new"); } else { link(uri); } //} else if (over){ // make text glow or something //} else { // who cares! } } void over() { if( overRect(x, y, w, h) ) { over = true; } else { over = false; } } void display() { textang = calcRadians(x - width/2, y - height/2); fade = (float)Math.min(Math.abs(textang - angle), Math.abs(textang - (angle + 2*Math.PI))); fade = 1 - fade / (float)(PI); textFont(font,txtsize); fill(0, 0, 0, sq(fade)*170+85); text(txt, x,y,w,h); } }