TFPImageCanvas does not support polygon fills
Summary
Polygons drawn on a TFPImageCanvas
cannot be filled by any brush pattern, not even by bsSolid
. They are always empty and only show the borderline.
System Information
- Operating system: Windows
- Processor architecture: x86-64
- Compiler version: trunk, 3.2.2, older versions not tested, but should show the issue as well
- Device: Computer
Steps to reproduce
The project attached below draws a triangle and a self-intersecting star shape with a hole, and tries to fill each of them with one of the elements of the TBrush.Style
enumeration, from left to right: bsSolid
, bsHorizontal
, bsVertical
, bsCross
, bsFDiagonal
, bsBDiagonal
, bsDiagCross
, bsPattern
, bsImage
(with absolute and relative position of brush image)
Example Project
What is the current bug behavior?
Here is the output image created by the example project: none of the polygons is filled.
What is the expected (correct) behavior?
Here is the output image created after application of the patch discussed below. In addition, the define PATCH_APPLIED
has been activated which duplicates the star-shaped polygon in a third row, but now filled by means of the non-zero winding rule (while the polygons in the second row are filled by application of the even-odd rule). All fills are as expected
Fix
The TLazCanvas
of the Lazarus project (unit lazcanvas) implements a basic polygon fill algorithm which supports even-odd and non-zero winding fill rules, however, only for solid brushes. I took the basic idea, adapted it to the style of the other fill routines in fcl-image, and extended it for the other fill patterns.
To control the polygon fill rule I added a new boolean property PolygonNonZeroWindingRule
to TFPPixelCanvas
.
The attachment contains
- a new unit, PolygonFillTools, with the fill routines: polygonfilltools.pp
- a patch for the
TFPPixelCanvas
in which the new routines are called in methodDoPolygonFill()
: polygon_fill.diff