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

Generate Pixmap on Sprite::new #73

Merged
merged 5 commits into from
Oct 30, 2023
Merged

Generate Pixmap on Sprite::new #73

merged 5 commits into from
Oct 30, 2023

Conversation

nyurik
Copy link
Contributor

@nyurik nyurik commented Oct 14, 2023

Do not merge until #72 is merged - this PR includes code from that

Make Sprite a readonly struct, with the Pixmap loading on creation.

This paves a way for simpler and quicker sprites because Sprite is now guaranteed to be valid if passed anywhere.

Also, I suspect the make_unique can be simplified to use Pixmap values instead of converting them temporarily into PNGs

@nyurik
Copy link
Contributor Author

nyurik commented Oct 21, 2023

@flother hi, a friendly ping - let me know if anything else is needed here and in other PRs. Thanks!!

@flother
Copy link
Owner

flother commented Oct 22, 2023

Sorry for the radio silence. The free time I have to spend on open-source tends to come in waves, all dependent on what life throws at me. I hope I'll have some time in the coming week to take a look at the open PRs here

@flother
Copy link
Owner

flother commented Oct 30, 2023

Looks like merging #72 has caused a trivial conflict. Could you take a quick look?

@nyurik
Copy link
Contributor Author

nyurik commented Oct 30, 2023

fixed

@flother
Copy link
Owner

flother commented Oct 30, 2023

More conflicts now #71 has been merged (sorry, should have waited on that before asking you to resolve the earlier conflicts)

This is a partial simplification from the other PR, without any breaking changes.
I am NOT certain if this is correct logically - please take a look:

Currently, sprites are iterated by key, so it goes in sorted order (due to it being a `BTreeMap`).

I changed it to iteration over pixmaps - so now `items` have a different order. It seems to be ok, because the `pack_into_po2` seem to resort them according to the largest first anyway, but I am not as familiar with the algo.

Also, a minor code de-duplication and spelling fix
Make Sprite a readonly struct, with the Pixmap loading on creation.
@nyurik
Copy link
Contributor Author

nyurik commented Oct 30, 2023

fixed

@flother flother merged commit 97cb1c5 into flother:master Oct 30, 2023
4 checks passed
@flother
Copy link
Owner

flother commented Oct 30, 2023

Thanks!

@nyurik nyurik deleted the pixmap branch October 30, 2023 21:18
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.

2 participants