How to dynamicly generate distinct colors

Hello!I am writing a program to draw a dynamic caky-chart,how can I distribute the different colors dynamic at one time. Is there anybody who got algorithm to deal with color manipulation? thanks in advance.
[229 byte] By [ellis_huang] at [2007-9-26 1:45:20]
# 1

Hi !

I didn't clearly understand what you need :

do you need an algorithm to create the proper chart ?

do you need an algorithm to allocate a color to the different parts ?

For the colors :

--

String[] colors = {"FF0000","FFFF00","00FF00", ... };

// ...

To create the chart :

--

// Start point (in degrees)

int start = 0;

// For every element of your chart (in % , I guess)

for(int i=0; i <= numberOfElements ; i++){

int end = 0 + percentageOfElement /100*360;

/*Draw an arc from "start" to "end" with the color colors, and, for instance, add the value inside (I would insert it at ((end-start)/2) so that it is in the middle)

check how to do that with 2DGraphics, or with what you're building your applet with

...

*/

start = end;

}

It's somewhat theorical, but I hope it helps

stephmor

stephmor at 2007-6-29 2:41:43 > top of Java-index,Archived Forums,Java Programming...
# 2
Thank you for your answer,I have found the solution about color.
ellis_huang at 2007-6-29 2:41:43 > top of Java-index,Archived Forums,Java Programming...