Jump to content

Filled Polygon


sandy1028

Recommended Posts

This code creates the line graph.

I want to fill the color from start to end point of line graph.

 

I tried using the imagefilledpolygon but I am not able to pass the array of values.

 

Please help me with this

 

 

// Create line graph
for ($i=0; $i<$count; $i++){

$graphValues[$i]=round(($graphValues[$i]*$yheight)/$max,2);
}

for($i=0;$i<$count;$i++){
imageline($image,40+$i*$xinc,(40+125-$graphValues[$i]),40+($i+1)*$xinc,(40+125-$graphValues[$i+1]),$colorBlue);

imagefilledpolygon($image,array(40,$graphValues[$i+1],165,$graphValues[$i]),$count,$black);
}


Link to comment
https://forums.phpfreaks.com/topic/70443-filled-polygon/
Share on other sites

[pre]

                  x5,y5

                    /|

                  / |

          x3,y3  /  |

          /\    /  |

          /  \  /    |

  x2,y2 /    \/    |

        |  x4,y4    |

        |____________| x5,y1

  x2,y1       

         

[/pre]         

the array would be (x2,y1,x2,y2,x3,y3,x4,y4,x5,y5,x5,y1)

 

Build the array as you plot the points and call imagefilled polygon after the loop

Link to comment
https://forums.phpfreaks.com/topic/70443-filled-polygon/#findComment-353919
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.