drawPolygonFaces method
Draws a polygon with faces of equal size from the center point (x, y)
to
the circumference with a specified number of sides
. The radius
of the
polygon can also be specified, along with an optional rotation
angle.
The method returns this, which allows for method chaining.
Implementation
Graphics drawPolygonFaces(
double x,
double y,
double radius,
int sides, [
double rotation = 0,
]) {
final points = List<Offset>.filled(sides, Offset.zero);
final rel = 2 * Math.PI / sides;
for (var i = 1; i <= sides; ++i) {
points[i - 1] = Offset(
x + radius * Math.cos(i * rel + rotation),
y + radius * Math.sin(i * rel + rotation),
);
}
_path!.addPolygon(points, true);
return this;
}