I'm utilizing TCanvas.Polygon()
and would like to know how I can go about shrinking the size of the polygon, either if there is already a function for this, or how to write one. I have a type declared TPoints: Array of TPoint;
and using it when calling TCanvas.Polygon()
.
The trouble is, if I have to write this function, how does it recognize which direction each point needs to move (based on proportion to the rest of the polygon)?
For example, if I made an array of points (TPoints
) to represent a 5 pointed star, and I needed to shrink it by 2 pixels, how would it know the direction to move the points?
The end intention is to implement a gradient for a polygon. There will be a loop to perform this, in which a) color is slightly adjusted, b) polygon points need to shrink by a few pixels, and c) polygon gets drawn (smaller than the previously drawn one); thus, creating a gradient.
It seems to me you're looking for a way to do polygon offsetting - shrinking or expanding polygons by a specified number of units (pixels). My Clipper Library (written in Delphi, C++ and C#) does polygon offsetting. The 'direction the points move' (ie shrinking or expanding) will depend on the sign (positive vs negative) of the supplied 'delta' parameter to the OffsetPolygons function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With