int fColor, sColor, tColor;
Wedge(String nom, int fColor, int sColor, int tColor, float tScale) {
int[] myFColors = {#b9a998, #103787, #46c304, #f27c0d, #f3131b, #0673e6};
int[] mySColors = {#bFbFbF, #3F3FbF, #7FfF3F, #fF7F3F, #fF3F3F, #3F7FfF};
int[] myTColors = {#f3131b, #f27c0d, #f3131b, #103787, #46c3d4, #fbd90c};
int curSlot = -1, lastSlot = -1;
float rotation = random(TWO_PI);
float angularVelocity = INITVA;
Boolean isDragging = false;
Boolean slowTrigger = false;
crankImg = loadImage("crank1.png");
bgImg = loadImage("hub_bg.png");
textFont(createFont("Helveetica",24));
translate(width/2, height/2);
image(bgImg,-bgImg.width/2, -bgImg.height/2);
Wedge w = wedges.get(curSlot);
translate(width/2-340,0);
textAlign(LEFT,BASELINE);
String[] preloadStrings = {"SKIP LUNCH","Burgers","Boring Salad","비빔밥 Bimbimbap","Taco Truck","Chinese",
"SPIN AGAIN!","Indian Buffet","Hipster Food Truck","That Hole-in-the-wall","Drive-thru","Brew-pub",
"INVITE ONE MORE", "Ice Cream?","Thai Food","Delicatessen","Sub shop","Pizza",
"SPIN AGAIN","Ramen","Fish + Chips + Beer","Sushi","Phở","50's Diner",
"VENDING MACHINE","BBQ Joint","Panini","Food Court","Shawarma"};
float labelWidth = (oRadius-iRadius)-18;
wedges = new ArrayList<Wedge>();
for (int i = 0; i < preloadStrings.length; ++i) {
int sColor,fColor,tColor;
fColor = (i/6)%2 == 0? #000000 : #FFFF00;
sColor = (i/6)%2 == 0? #444444 : #FFFF00;
tColor = (i/6)%2 == 0? #FFFFFF : #000000;
fColor = myFColors[cidx];
sColor = mySColors[cidx];
tColor = myTColors[cidx];
cidx %= myFColors.length;
String nom = preloadStrings[i];
float tScale = min(1,labelWidth/textWidth(nom));
wedges.add(new Wedge(nom, fColor, sColor, tColor, tScale));
int nbrWedges = wedges.size();
float wedgeAngle = 2*PI/nbrWedges;
float tAngle = -wedgeAngle/2;
float bAngle = wedgeAngle/2;
float textCenterX = (iRadius+oRadius)/2;
textAlign(CENTER,CENTER);
if (!slowTrigger && angularVelocity < .001) {
slowTriggerStart = millis();
for (int i = 0; i < nbrWedges; ++i) {
Wedge biz = wedges.get(i);
vertex(cos(tAngle)*iRadius,sin(tAngle)*iRadius);
vertex(cos(tAngle)*oRadius,sin(tAngle)*oRadius);
vertex(cos(bAngle)*oRadius,sin(bAngle)*oRadius);
vertex(cos(bAngle)*iRadius,sin(bAngle)*iRadius);
float tScale = biz.tScale;
tScale += (sin(millis()*.002) * 0.2) * constrain(map(millis()-slowTriggerStart,0,2000,0,1),0,1);
translate(textCenterX,0);
image(crankImg, oRadius,-crankImg.height/2);
int nbrWedges = wedges.size();
float wedgeAngle = 2*PI/nbrWedges;
curSlot = (int) ((nbrWedges-Math.floor((rotation+wedgeAngle/2)/wedgeAngle)) % nbrWedges);
rotation += angularVelocity;
float da = TWO_PI-curSlot*wedgeAngle;
float delta = da - rotation;
angularVelocity += delta*MAGNET;
angularVelocity *= DAMPING;
if (curSlot != lastSlot) {
newVelocity = atan2(mouseY-height/2,mouseX-width/2) - atan2(pmouseY-height/2,pmouseX-width/2);
lastVelocity = newVelocity;
angularVelocity = (newVelocity + lastVelocity)/2;