Add RoundedRectanglePolygon and PathBuilder helpers.

Merged
JI
6mo ago
+619-346

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules :cop:.
  • I have provided test coverage for my change (where applicable)

Description

Fixes #9

This pull request introduces support for rounded rectangles in the drawing library by adding a new RoundedRectanglePolygon shape and integrating it with the PathBuilder API. It also includes comprehensive tests and a reference image to ensure correctness and visual fidelity.

New Shape and API Enhancements:

  • Added the RoundedRectanglePolygon class, which defines a rounded rectangle shape with configurable corner radii and provides transformation support.
  • Extended the PathBuilder class with multiple AddRoundedRectangle overloads to easily add rounded rectangles to paths using various parameter types (rectangle, radii, coordinates).

Testing and Validation:

  • Added new tests in RoundedRectangleTests.cs to verify the correctness of the RoundedRectanglePolygon implementation, including bounds, flattening, corner shapes, scaling, and transformation behavior.
  • Added tests in PathBuilderTests.cs to ensure that the new AddRoundedRectangle methods produce paths equivalent to direct construction of RoundedRectanglePolygon.
  • Added a test in DrawingCanvasTests.Primitives.cs to compare rendering output of filled and stroked rounded rectangles against a reference image.
  • Included a new reference PNG image for visual regression testing of rounded rectangles.

Documentation and Minor Improvements:

  • Improved the summary comment for RectangularPolygon for clarity.