[UPHPU] GD library imagefill() help needed
Mac Newbold
mac at macnewbold.com
Tue Jun 5 23:56:57 MDT 2007
Today at 9:28pm, Walt Haas said:
> I'm trying to make a shape that is a portion of a ring. Imagine that
> you took a lifesaver and cut a 45 degree slice from it. The shape I
> want to make is the 45 degree slice (well, in two dimensions).
>
> So I make two arcs with the same center and different radii, then draw a
> straight line to close the open ends. So now I have an enclosed shape
> that looks like a rectangle that was left out in the sun too long and
> kind of drooped :-) Now I want to flood-fill this shape with a solid
> color, so I find a point in the middle of my shape and start imagefill()
> from that point outward.
>
> The weird thing is that this works great for certain orientations of the
> shape, but as I rotate my shape around the center there are orientations
> where the whole image is filled, not just the shape and not everything
> but the shape, the whole image.
>
> If I display the point where the fill starts, it's inside the shape
> alright, so that's not the problem.
>
> Any ideas?
There could be some rounding errors or other slight differences in the end
points of your arcs and the lines you're using to close the ends of the
shape. I'm not sure how you'd tell for sure, or fix it if there were a
problem, but that could be all or part of the problem.
I've known other systems where the direction in which you drew lines,
polygons, etc. would determine which side was "inside" and which was
"outside", but I don't think there is any distinction in GD.
If you can't get it to work reliably, you might try making a complete
double ring, filling it, then cutting or whiting out the parts that
shouldn't be there. You might need to do it in a separate image then
copymerge it into the one where you want it to really appear.
Mac
--
Mac Newbold MNE - Mac Newbold Enterprises, LLC
mac at macnewbold.com http://www.macnewbold.com/
More information about the UPHPU
mailing list