Skip to content

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

Merged
spydon merged 7 commits intoflame-engine:mainfrom
TRI99ERED:feat/regular-polygon-constructors
May 8, 2026
Merged

feat: Add regular polygon constructors to PolygonComponent and PolygonHitbox#3891
spydon merged 7 commits intoflame-engine:mainfrom
TRI99ERED:feat/regular-polygon-constructors

Conversation

@TRI99ERED
Copy link
Copy Markdown
Contributor

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.

Comment thread packages/flame/lib/src/geometry/polygon_component.dart Outdated
@spydon
Copy link
Copy Markdown
Member

spydon commented Apr 19, 2026

@TRI99ERED will you update this PR? :)

@TRI99ERED
Copy link
Copy Markdown
Contributor Author

Sorry for the delay, some stuff came up.

@spydon spydon requested a review from ufrshubham April 22, 2026 10:48
Copy link
Copy Markdown
Member

@spydon spydon left a comment

Choose a reason for hiding this comment

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

Lgtm, thanks for your contribution

bool? shrinkToBounds,
}) : this(
List.generate(sides, (i) {
final angle = 2 * pi * i / sides;
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.

nit: can use tau here

@luanpotter
Copy link
Copy Markdown
Member

(I rebased the PR to use my new CI fixes)

@spydon
Copy link
Copy Markdown
Member

spydon commented May 8, 2026

@TRI99ERED the tests are failing

@spydon spydon enabled auto-merge (squash) May 8, 2026 15:50
@spydon spydon merged commit 0d91f0f into flame-engine:main May 8, 2026
8 checks passed
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

4 participants