Hey everyone. I used the pie graph example to construct my own, and I have modified it to change every 3 seconds. For some reason, the program is not reading my data. (which i made sure all equals to 360 degrees). Could someone please help me out?
//Original Pie Graph by Ira Greenberg. http://processing.org/learning/basics/piechart.html
void setup(){
size(500, 500);
background(255);
smooth();
noStroke();
}
void draw(){
float diameter = min(width, height) * 0.75;
// it creates a float variable (a decimal value used in processing more often than double) set equal to the minimum width and height of the graphic * 3/4
//int[] angs = {30, 10, 45, 35, 60, 38, 75, 67};
float[] angs = {141,180,32,1,6};
//float[] angs = {141,120,32,31,36};
// formula for angles (data point/ total of the data points) * 360
float time = 0;
float lastAng = 0;
if (time == 1)
{
angs = new float[]{168,157,27,4,4};
}
if (time == 2)
{
angs =new float[]{ 184,137,33,5,1};
}
if (time == 3)
{
angs = new float[]{232, 116,6,3,3} ;
}
if (time == 4)
{
angs = new float[]{236,91,28,3,2};
}
for (int i = 0; i < angs.length; i++){
if (i==1)
{
fill (255,0,0) ;
}
if (i==2 )
{
fill (255,100,0) ;
}
if (i==3)
{
fill (255,100,255) ;
}
if (i==4)
{
fill (255,255,0) ;
}
if (i==5)
{
fill (0,255,0);
}
//fill(angs[i] * 3.0);
arc(width/2, height/2, diameter, diameter, lastAng, lastAng+radians(angs[i]));
lastAng += radians(angs[i]);
time= time + 1;
//delay (3000);
}
}
//Original Pie Graph by Ira Greenberg. http://processing.org/learning/basics/piechart.html
void setup(){
size(500, 500);
background(255);
smooth();
noStroke();
}
void draw(){
float diameter = min(width, height) * 0.75;
// it creates a float variable (a decimal value used in processing more often than double) set equal to the minimum width and height of the graphic * 3/4
//int[] angs = {30, 10, 45, 35, 60, 38, 75, 67};
float[] angs = {141,180,32,1,6};
//float[] angs = {141,120,32,31,36};
// formula for angles (data point/ total of the data points) * 360
float time = 0;
float lastAng = 0;
if (time == 1)
{
angs = new float[]{168,157,27,4,4};
}
if (time == 2)
{
angs =new float[]{ 184,137,33,5,1};
}
if (time == 3)
{
angs = new float[]{232, 116,6,3,3} ;
}
if (time == 4)
{
angs = new float[]{236,91,28,3,2};
}
for (int i = 0; i < angs.length; i++){
if (i==1)
{
fill (255,0,0) ;
}
if (i==2 )
{
fill (255,100,0) ;
}
if (i==3)
{
fill (255,100,255) ;
}
if (i==4)
{
fill (255,255,0) ;
}
if (i==5)
{
fill (0,255,0);
}
//fill(angs[i] * 3.0);
arc(width/2, height/2, diameter, diameter, lastAng, lastAng+radians(angs[i]));
lastAng += radians(angs[i]);
time= time + 1;
//delay (3000);
}
}
1