hi everybody,
i allmost got it, but i still have the problem that i want to have the values going to the centre of the circle (tried with green). You will see that the red value everything is aimed at the right side. Could somebody help me with my final problem?
Code:
import java.util.ArrayList;
XMLElement xml;
int r = 0;
int maxPlace = 63;
int maxTime = 498-60;
float piCircle = TWO_PI/height;
ArrayList playerA = new ArrayList ();
ArrayList fromPlaceA = new ArrayList ();
ArrayList dice1A = new ArrayList ();
ArrayList dice2A = new ArrayList ();
ArrayList totalA = new ArrayList ();
ArrayList toPlaceA = new ArrayList ();
ArrayList setNum = new ArrayList ();
float a = 0.0;
float inc = TWO_PI/25.0;
//int widthMax = width/2;
//int lengthMax
float level = 0.1;
float rate = 0.1;
void setup() {
size(800, 800);
background(255);
smooth();
loadXML();
}
void loadXML() {
xml = new XMLElement(this, "XML_final.xml");
XMLElement game = xml.getChild(0);
int num_dots = game.getChildCount();
for (int i=0; i<num_dots; i++) {
XMLElement move = game.getChild(i);
XMLElement throw_val = move.getChild(3);
int player = int(move.getChild(0).getContent());
int timeFirst = int(move.getChild(1).getContent());
int timeLast = int(move.getChild(2).getContent());
int dice1 = int(throw_val.getChild(0).getContent());
int dice2 = int(throw_val.getChild(1).getContent());
int total = int(move.getChild(4).getContent());
int fromPlace = int(move.getChild(5).getContent());
int toPlace = int(move.getChild(6).getContent());
println(player+" "+timeFirst+" "+timeLast+" "+dice1+" "+dice2+" "+total+" "+fromPlace+" "+toPlace);
setNum.add(new Integer(i));
playerA.add(new Integer(player));
dice1A.add(new Integer(dice1));
dice2A.add(new Integer(dice2));
totalA.add(new Integer(total));
fromPlaceA.add(new Integer(fromPlace));
toPlaceA.add(new Integer(toPlace));
}
float r = width/2;
float deg = 360/num_dots;
for (int i=0; i<num_dots-1; i++) {
float xpos1 = (cos(radians(deg*i))*r) + width/2;
float ypos1 = (sin(radians(deg*i))*r) + height/2;
float xpos2 = (cos(radians(deg*(i+1)))*r) + (width/2);
float ypos2 = (sin(radians(deg*(i+1)))*r) + (height/2);
noStroke();
fill(#fd0012,60);
ellipse(xpos1, ypos1, ((Integer)totalA.get(i)*10), ((Integer)totalA.get(i))*10);
i++;
fill(#36ff27,60);
ellipse(xpos2, ypos2, ((Integer)totalA.get(i)*10), ((Integer)totalA.get(i))*10);
stroke(0);
}
for (int i=0; i<num_dots-1; i++) {
float xpos1 = (cos(radians(deg*i))*r) + width/2;
float ypos1 = (sin(radians(deg*i))*r) + height/2;
float xpos2 = (cos(radians(deg*(i+1)))*r) + (width/2);
float ypos2 = (sin(radians(deg*(i+1)))*r) + (height/2);
int curveLength = 200;
int curveHeight = 100;
bezier(xpos1, ypos1, xpos1, ypos1, xpos2, ypos2, xpos2, ypos2);
//println("xpos1: "+xpos1+" ypos1: "+ypos1+" xpos2: "+xpos2+" ypos2: "+xpos2);
// int steps = (Integer)fromPlaceA.get(i) - (Integer)toPlaceA.get(i);
}
for (int i=0; i<num_dots-1; i++) {
int steps = (Integer)toPlaceA.get(i);
for(int q=0; q<steps; q++) {
float xpos1 = (cos(radians(deg*i))*r) + width/2;
float ypos1 = (sin(radians(deg*i))*r) + height/2;
float xpos2 = (cos(radians(deg*(i+1)))*r) + (width/2);
float ypos2 = (sin(radians(deg*(i+1)))*r) + (height/2);
int curveLength = 200;
int curveHeight = 100;
bezier(xpos1, ypos1, xpos1, ypos1, xpos2, ypos2, xpos2, ypos2);
float t = q / float(steps);
float x = bezierPoint(xpos1, xpos1, xpos2, xpos2, t);
float y = bezierPoint(ypos1, ypos1, ypos2, ypos2, t);
float v = curveHeight * sin(t * TWO_PI/25.0 * 25.0);
float u = curveHeight * cos(t * TWO_PI/25.0 );
stroke(#fd0012);
line(x, y, x + u, y + v);
stroke(100);
a = a + inc;
}
i++;
int steps2 = (Integer)toPlaceA.get(i);
for(int q=0; q<steps2; q++) {
float xpos1 = (cos(radians(deg*i))*r) + width/2;
float ypos1 = (sin(radians(deg*i))*r) + height/2;
float xpos1r = (acos(radians(deg*i))*r) + width/2;
float ypos1r = (asin(radians(deg*i))*r) + height/2;
float xpos2 = (cos(radians(deg*(i+1)))*r) + (width/2);
float xpos2r = (acos(radians(deg*(i+1)))*r) + (width/2);
float ypos2 = (sin(radians(deg*(i+1)))*r) + (height/2);
float ypos2r = (asin(radians(deg*(i+1)))*r) + (height/2);
int curveLength = 200;
int curveHeight = 50;
bezier(xpos1, ypos1, xpos1, ypos1, xpos2, ypos2, xpos2, ypos2);
bezier(xpos1r, ypos1, xpos1, ypos1, xpos2, ypos2, xpos2, ypos2);
float t = q / float(steps2);
float x = bezierPoint(xpos1, xpos1, xpos2, xpos2, t);
float y = bezierPoint(ypos1, ypos1, ypos2, ypos2, t);
float vx = sin(t * TWO_PI/25.0 * 25.0);
float ux = cos(t * TWO_PI/25.0 * 25.0);
float v = curveHeight * sin(vx)+ (height/2);
float u = curveHeight * cos(ux )+(width/2);
stroke(100);
stroke(#36ff27);
line(x, y, x + u, y + v);
stroke(100);
a = a + inc;
}
level += rate;
}
}