Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 9-patch to examples #2985

Merged
merged 4 commits into from
Oct 5, 2024
Merged

Conversation

damusss
Copy link
Contributor

@damusss damusss commented Jul 11, 2024

After a short discussion with @Starbuck5 9-patch scaling is a recipe like process that doesn't involve algorithmic pixel manipulation so an example is probably good enough for it.

This is a good place to come every time you need your own 9-patch function and good to teach for GUI purposes. It's also existing in every other game engine so at least an example is needed.

I made the 9-patch code behave like a transform function would, adding comments and type hinting.

@damusss damusss requested a review from a team as a code owner July 11, 2024 21:01
@damusss
Copy link
Contributor Author

damusss commented Jul 12, 2024

Attaching a preview of the example for ease of review
image

Copy link
Contributor

@bilhox bilhox left a comment

Choose a reason for hiding this comment

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

Overall the example is really cool. I would apprecate since you mentionned it works for any custom surface to actually use a custom surface, like an image with the necessary properties to make it work.

Anyways, good job :)

examples/ninepatch.py Outdated Show resolved Hide resolved
examples/ninepatch.py Outdated Show resolved Hide resolved
examples/ninepatch.py Outdated Show resolved Hide resolved
@damusss
Copy link
Contributor Author

damusss commented Aug 27, 2024

With my las commit I

  • used pygame.Vector2.elementwise
  • changed the while True
  • added a real image on top of the rect

Copy link
Contributor

@bilhox bilhox left a comment

Choose a reason for hiding this comment

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

LGTM, I left some requested changes.

examples/ninepatch.py Outdated Show resolved Hide resolved
examples/ninepatch.py Outdated Show resolved Hide resolved
Copy link
Member

@MyreMylar MyreMylar left a comment

Choose a reason for hiding this comment

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

OK, LGTM 👍

Copy link
Contributor

@bilhox bilhox left a comment

Choose a reason for hiding this comment

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

LGTM!

@bilhox bilhox added this to the 2.5.2 milestone Oct 5, 2024
@bilhox bilhox merged commit 70f6bde into pygame-community:main Oct 5, 2024
3 checks passed
@damusss damusss deleted the examples-ninepatch branch October 10, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants