// Spice Girls selection - Jim Bumgardner /* @pjs preload="/assets/spice_girls.jpg" */ /* @pjs preload="/assets/spice_girls_map.png" */ // Todo: Add the Old Spice guy... PImage colorImage; PImage mapImage; String[] spiceVarieties = {"No","Scary","Baby","Sporty","Ginger","Posh"}; String lastSelection = "Click a spice"; void setup() { size(475, 578); colorImage = loadImage("/assets/spice_girls.jpg"); mapImage = loadImage("/assets/spice_girls_map.png"); } void draw() { image(colorImage, 0,0); fill(255); text(lastSelection, 20, 20); } void mouseClicked() { int px = constrain(mouseX,0,width); int py = constrain(mouseY,0,height); int v = mapImage.pixels[py*mapImage.width + px]; v = red(v) / 32; v = (int) constrain(v, 0, spiceVarieties.length-1); lastSelection = spiceVarieties[v] + " Spice"; }