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 crop transform #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

m-ender
Copy link
Collaborator

@m-ender m-ender commented Feb 21, 2022

This is a first attempt at a crop transform (#39). I'm pretty sure it needs some work. The code is pretty messy, and I'm not 100% convinced it correctly deals with all possible cases. I also still don't know what the best name for this would be. Truncate, crop, trim, clip all seem reasonable.

And finally, it would be nice if there were a way to not crop a sprite down and right (which sort of happens because those parts of the sprite just get overdrawn). Would it make sense to draw the grid in multiple passes, one per collision layer? This would probably have some other awkward effects for pseudo-3D games. Maybe to do this properly, we'd need some kind of separator syntax in the collision layer list, and then the engine makes a separate rendering pass for each of the segments defined this way.

In any case, I figured I'd throw something together, so you've got something to go off of. This isn't really meant to be merged as is.

@ClementSparrow
Copy link
Owner

I had a look at the code. If I understand well, it provides a way to cut the offset sprite along one (or all) of the sides of the cell? I think I would prefer a way to remove some given number of lines of pixels on a given edge of the sprite, independently of the sprite's offset. To crop along the cell's border you would need to keep track of the sprite's offset and size, but I think this is a more general feature and a simpler one to implement. Also, because I'm working on a sprite editor and the functions to resize a sprite are already written :-D

@m-ender
Copy link
Collaborator Author

m-ender commented Feb 25, 2022

Oh yeah, you're right, a transform to simply shave off a given number of pixels sounds a lot simpler. 😅

@m-ender
Copy link
Collaborator Author

m-ender commented Feb 25, 2022

Reworked the PR to implement your suggested transform instead. Also renamed it to trim because with the new behaviour that seems like the clearest name.

@ClementSparrow ClementSparrow marked this pull request as ready for review March 7, 2022 10:06
@ClementSparrow
Copy link
Owner

Thanks! I keep the PR opened as a reminder. I'm currently working on a feature that requires to change a little bit how sprite transforms are applied, and also I have already done some code to resize sprites in that feature. So, I will integrate this new transform directly with the new feature.

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