Hi!
I'm up to make a little applet with processing, which displays some graph-stuff.. Its just about 10 Points.
At the moment, I have a matrix, where the Point-Connections are stored.. (like "arr[][]={{2,5}, {4,6}, {10},...")
Then the Script will generate Random numbers for the x and y Axis.
Everything works fine, but I dont like the unclearly way how it is displayed..
So I thought about arranging all the dots in an ellipse, but thats not what im going for...
My Question:
Would it be possible to arrange the 10 Dots, so that no (or less) lines are crossing each other?
Are there any example scripts for something like this available? Are there other better/easier possibilities to display the dots?
Heres my current Source-Code (I know, its a bit stupid - but that was the first time for me working with processing and i wanted to have a clear look):
Code:int arrPos[][] = {{2,5}, {4,6}, {10}, {6,9,10}, {}, {7}, {}, {9}, {}, {}};
size(250, 250);
background(255);
int pntx[] = new int[10];
int pnty[] = new int[10];
int rndR = 200;
long tempX;
long tempY;
//##### 10 Points, Random X,Y;
// RANDOM 10 X, Y:
for (int i =0; i < 10; i++){
tempX = Math.round(rndR * Math.random());
tempY = Math.round(rndR * Math.random());
pntx[i] = toInt(tempX);
pnty[i] = toInt(tempY);
}
// DISPLAY POINTS:
beginShape(POINT);
for (int i =0; i < 10; i++){
vertex (pntx[i], pnty[i]);
} endShape();
//---------- ---------- ----------
//##### ellipse:
for (int i =0; i < 10; i++){
fill(180);
ellipse(pntx[i], pnty[i], 10, 10);
}
//##### LINES #####
for (int i =0; i < arrPos.length ; i++){
for(int x =0; x < arrPos[i].length ; x++){
line(pntx[i], pnty[i], pntx[arrPos[i][x] - 1], pnty[arrPos[i][x] - 1]);
}
}
// DISPLAY TEXT:
for (int i =0; i < 10; i++){
fill(255,0,255);
PFont eur = loadFont("sansserif-12.vlw");
textFont(eur);
text(i + 1, pntx[i], pnty[i]);
}
Thank you very much!
And sorry for my bad english