Skip to content

feat: Add regular polygon constructors to PolygonComponent and PolygonHitbox#3891

Open
TRI99ERED wants to merge 1 commit intoflame-engine:mainfrom
TRI99ERED:feat/regular-polygon-constructors
Open

feat: Add regular polygon constructors to PolygonComponent and PolygonHitbox#3891
TRI99ERED wants to merge 1 commit intoflame-engine:mainfrom
TRI99ERED:feat/regular-polygon-constructors

Conversation

@TRI99ERED
Copy link
Copy Markdown

Summary

Adds PolygonComponent.regularPolygon and PolygonHitbox.regularPolygon constructors to easily create regular (equiangular and equilateral) polygons by specifying the number of sides and radius.

Usage

`dart
// Create a regular hexagon
PolygonComponent.regularPolygon(6, radius: 100);

// Create a regular octagon hitbox
PolygonHitbox.regularPolygon(8, radius: 50, isSolid: true);
`

Closes #3890

@TRI99ERED TRI99ERED changed the title feat: add regular polygon constructors to PolygonComponent and PolygonHitbox feat: Add regular polygon constructors to PolygonComponent and PolygonHitbox Apr 6, 2026
Copy link
Copy Markdown
Member

@ufrshubham ufrshubham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TRI99ERED please follow the original PR description template. Also, add some tests for this change.

/// polygon from number of sides and radius anywhere in the 2d-space. It will
/// automatically calculate the [size] of the Polygon (the bounding box) if no
/// size is given.
PolygonComponent.regularPolygon(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's revert to regular like you had initially, it doesn't make it any clearer by repeating polygon.
I had forgot regular is the actual math term for these types of polygons, so let's go with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add regular constructors to PolygonComponent and PolygonHitbox

3 participants