Docs: Rewrote part of the new docs for TLazCanvas.Polygon in order to explain the filling algorithms.

This commit is contained in:
wp_xyz 2023-01-30 13:17:02 +01:00
parent c7a8416d83
commit 6575787574

View File

@ -402,7 +402,7 @@ used in <var>TCanvas</var>.
<short>Implements a polygon fill algorithm not present in fcl-image.</short>
<descr>
<p>
Implements a polygon fill algorithm not present in fcl-image. The algorithm
Implements a polygon fill algorithm not present in fcl-image. Part of the algorithm
is explained <url href="http://alienryderflex.com/polygon_fill/">here</url>.
</p>
</descr>
@ -418,7 +418,7 @@ the non-zero winding rule in the fill operation.
</seealso>
</element>
<element name="TLazCanvas.DoPolygonFill.points">
<short>Array with the TPoint instances for the polygon corners.</short>
<short>Array with the TPoint records for the polygon corners.</short>
</element>
<element name="TLazCanvas.DoLine">
@ -968,20 +968,38 @@ Overloaded method which adds support for the non-zero winding rule.
</short>
<descr>
<p>
Polygon is an overloaded method in TLazCanvas. It provides support for the
non-zero winding rule in the polygon fill operation.
<var>Polygon()</var> overloads an equally-named method inherited from <var>TFPCustomCanvas</var>
which
fills a polygon via <var>DoPolygonFill()</var>.
By default, the even-odd rule is applied for filling.
The current overload, however, adds support for filling the polygon
by the <url href="https://en.wikipedia.org/wiki/Nonzero-rule/">non-zero winding rule</url>.
</p>
<p>
The overloaded variant extends the method from TFPCustomCanvas to include the
Winding argument used in the DoPolygonFill method. When Winding is set to
<b>True</b>, DoPolygonFill calculates the winding number for the sorted
vertices on the polygon and calls DrawPixel to apply the brush color needed
for the pixels inside the winding path.
In each case, the polygon is filled by drawing horizontal lines across the polygon
starting at the left
The intersection points of this line with the polygon segments are calculated
and sorted from left to right.
</p>
<p>
Polygon updates the internal member used to store the value in Winding, and
calls the inherited method in TFPCustomCanvas where the brush and pen colors
are used to draw the polygon represented in Points.
In the even-odd rule, lines are drawn between adjacent intersection points in
an alternating way.
<p>
</p>
In the non-zero winding rule the "winding number"
(starting at zero for each line) is incremented/decremented depending on whether
the hit polygon segment is oriented upward or downward.
The following line segment is drawn only when the accumulated winding number
is not zero.
</p>
<p>
The non-zero winding rule is selected when the <var>Winding</var> argument of the
method is <b>true</b>.
Otherwise the even-odd rule is applied.
</p>
<p>
The <var>DrawPixel()</var> method is called along the filling lines in order to apply the
brush color to the canvas pixels in an either opaque or semi-transparent way.
</p>
</descr>
<version>
@ -997,6 +1015,9 @@ Array with the TPoint instances for the vertices on the polygon.
<element name="TLazCanvas.Polygon.Winding">
<short>
<b>True</b> if the non-zero winding rule is enabled for the canvas instance.
Otherwise the polygon is filled by means of the "even-odd" rule in which
alternating horizontal lines are drawn between pairs of polygon intersection
points.
</short>
</element>