-
-
Notifications
You must be signed in to change notification settings - Fork 160
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 skew functionality to pygame.transform #2143
base: main
Are you sure you want to change the base?
Conversation
Just two comments regarding this pull request:
|
|
I do see use cases for this, but it may be redundant. Another thread involves mapping a surface to new points. This skew functionality could be achieved using that method. Although that thread hasn't seen much activity... |
I like the name skew, it is familiar to me for this type of operation (and is the sort of word I'd look for in a transform submodule to get this effect). Photoshop and GIMP use I'm happy having a function like this even if you could achieve the same thing with a more complicated warping function as it is likely that users would look for something like this and might not grasp that a more complicated function could be used for the same thing. If needed we could eventually reduce underlying code duplication by making this API call the more complicated spatial transform with some fixed parameters. |
Co-authored-by: Dan Lawrence <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried this out finally. Unfortunately, there is no test or usage example and when I tired to use it like so:
import pygame
display_surf = pygame.display.set_mode((1280, 600))
display_surf.fill((255, 255, 255))
walt = pygame.image.load("images/walt.png").convert_alpha()
walt_2 = pygame.transform.skew(walt, [[0, 0], [417, 0], [0, 364], [417, 364]])
walt_3 = pygame.transform.skew(walt, [[0, 0], [417, 0], [0, 364], [417, 364]])
pygame.init()
clock = pygame.time.Clock()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
display_surf.fill((255, 255, 255))
display_surf.blit(walt, (0, 100))
display_surf.blit(walt_2, (417, 100))
display_surf.blit(walt_3, (834, 100))
pygame.display.flip()
clock.tick(60)
I get a segmentation fault.
I may be doing it wrong, but in any case we defintely need some clearer documentation on the four points and the order they are supplied in. I'm assuming it goes - [top_left, top_right, bottom_left, bottom_right]
but I could be wrong. I'm also assuming the supplied points are in pixels.
Anyway, I think this could be cool if it worked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reason to believe you are going to push some commits soon, this is just rather minor things I noticed I thought were worth mentioning.
Will probably need to write some tests for this and maybe some further changes to the docs but otherwise at this point I think it is fully functional, unless anyone else has other ideas for this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I can make a PR that fixes the same thing for threshold. Now you don't need to worry about the original _color_from_obj
function.
Co-authored-by: Damiano <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :) (also on phone I can't dismiss my review so this is the only way to remove it. nothing in the code looks strange anyways, and I tested it previously)
This adds a skew function to the transform module as requested by #2098 with modifications to support inputs of any 4 coordinates to map the surface to. Do note this is still a WIP so the full implementation for release has not been completed, feel free however to test out the current algorithm implementation and submit feedback on it.