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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.