Skip to content

feat: Adding bleed option to SpriteBatch#3871

Draft
erickzanardo wants to merge 3 commits intomainfrom
feat/bleed-in-spritebatch
Draft

feat: Adding bleed option to SpriteBatch#3871
erickzanardo wants to merge 3 commits intomainfrom
feat/bleed-in-spritebatch

Conversation

@erickzanardo
Copy link
Member

Description

Replace this text.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

@erickzanardo erickzanardo marked this pull request as draft March 23, 2026 00:13
required this.transform,
Color? color,
this.flip = false,
this.bleed = 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

We should do an assertion to prevent negative values

Comment on lines +325 to +327
if (bleed == 0) {
return transform;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (bleed == 0) {
return transform;
}
if (bleed <= 0) {
return transform;
}

Comment on lines +334 to +335
final scos = transform.scos * scaleX;
final ssin = transform.ssin * scaleY;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not scale by x or y but by math.max of either so we can preserve rotation (and ensure scale happens uniformly even if width and height are not equal).

And then the tx and ty should be multiplied by the scos and ssin (subtract for tx, addition for ty). That should keep the centerr fixed to bleed across the borders when we are dealing with rotation

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.

3 participants