PFont f; XMLElement xml; PImage[] images = new PImage[20]; String[] lis; String[] lis2; int[] c = {0, 125, 200}; int h = 450; void setup() { size(740,h+30); smooth(); f = loadFont("SansSerif.bold-16.vlw"); textFont(f,20); textAlign(LEFT); frameRate(30); noStroke(); background(255); noLoop(); xml = new XMLElement(this, "topcreators.xml"); XMLElement thing = xml; XMLElement[] creators = thing.getChildren("creator"); System.out.println(creators.length); String[] name = new String[creators.length]; String[] values = new String[creators.length]; for(int k = 0; k< creators.length; k++) { name[k] = creators[k].getChild("name").getContent(); values[k] = creators[k].getChild("subscriptions").getContent(); images[k] = loadImage("http://www.spore.com/static/" + creators[k].getChild("image").getContent()); } lis=name; lis2 = values; } void draw(){ fill(0.85*c[0], 0.85*c[1], 0.85*c[2]); rect(5, 2, width-10, 26); for(int j = 1; j<=10; j++) { float cF = colorFactor(j, 10); //fill(cF*c[0], cF*c[1], cF*c[2]); fill(c[0], c[1], c[2], cF*255); drawSquare(lis[10-j], lis2[10-j], 10-j, 10); } fill(255); rect(55, 0, 2, height); rect(610, 0, 2, height); textFont(f,14); textAlign(CENTER); text("RANK", 30, 20); textAlign(LEFT); text("CREATOR", 205, 20); textAlign(LEFT); text("BUDDIES", 646 ,20); save("leaderboardslist.png"); } void drawSquare(String txt1, String txt2, int pos, int n){ float a = h*pos/n; int b = round(a); rect(0+5, b+30, width-10, h/n-2); fill(0); textFont(f,16); textAlign(RIGHT); text(Integer.toString(pos+1) + ".", 40, b+h/(n)+10); textAlign(LEFT); text(txt1, 115, b+h/(n)+10); textAlign(RIGHT); text(txt2, 30*width/32, b+h/(n)+10); image(images[pos], 75 , b+h/(n)-10, 30,30); } float colorFactor(int i, int n) { float ff = 1.1/(1-1/n)*(i)/n ; return ff; }