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 skew functionality to pygame.transform #2143

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a16dc3e
beginning skew work
Temmie3754 May 2, 2023
f0e013f
further developments
Temmie3754 May 3, 2023
64aad78
adapted algorithm to handle all quad cases
Temmie3754 May 4, 2023
c89db5c
Improve algorithm, add sequence handling
Temmie3754 May 5, 2023
f3cdc5c
Resulting shape improvements
Temmie3754 May 6, 2023
b95bc5e
Correct image flipping, resulting shape
Temmie3754 May 8, 2023
043c4de
Add docs, fix segfault, proper input handling
Temmie3754 May 9, 2023
f789371
Revert cython changes
Temmie3754 May 9, 2023
e42664a
Add background colour option, fix size bug
Temmie3754 May 9, 2023
3616cd5
Fix check errors
Temmie3754 May 12, 2023
f8c2a68
Update version number
Temmie3754 Oct 3, 2023
e5a7fef
Merge branch 'main' into skew
Temmie3754 Oct 5, 2023
d8e88cc
Re-add new color_from_obj method
Temmie3754 Oct 5, 2023
83da4e4
Merge branch 'pygame-community:main' into skew
Temmie3754 Oct 7, 2023
d4e0112
Merge branch 'main' into skew
MyreMylar Oct 5, 2024
b36454f
fix type hints
MyreMylar Oct 5, 2024
245cf01
Fix segfault and improve docs
Temmie3754 Oct 8, 2024
4c8a45e
Fix compilation issue
Temmie3754 Oct 8, 2024
41f375e
Remove unintentional edit
Temmie3754 Oct 8, 2024
970d881
Change color handler to allow for strings
Temmie3754 Oct 8, 2024
1f758db
Exception wording change
Temmie3754 Oct 10, 2024
2da25af
Merge branch 'main' into skew
Temmie3754 Oct 24, 2024
69bc9ce
Merge branch 'skew' of https://github.com/Temmie3754/pygame-ce into skew
Temmie3754 Oct 24, 2024
0eae228
Add tests, update docs and add unique check
Temmie3754 Oct 25, 2024
9e9aaaa
Move _color_from_obj definition
Temmie3754 Oct 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions buildconfig/stubs/pygame/transform.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ def scale_by(
dest_surface: Optional[Surface] = None,
) -> Surface: ...
def rotate(surface: Surface, angle: float) -> Surface: ...
def skew(
surface: Surface,
points: SequenceLike[Point],
bg_color: Optional[ColorLike] = None,
adjust_size: bool = True,
dest_surface: Optional[Surface] = None,
) -> Surface: ...
def rotozoom(surface: Surface, angle: float, scale: float) -> Surface: ...
def scale2x(surface: Surface, dest_surface: Optional[Surface] = None) -> Surface: ...
def grayscale(surface: Surface, dest_surface: Optional[Surface] = None) -> Surface: ...
Expand Down Expand Up @@ -62,13 +69,13 @@ def box_blur(
surface: Surface,
radius: int,
repeat_edge_pixels: bool = True,
dest_surface: Optional[Surface] = None
dest_surface: Optional[Surface] = None,
) -> Surface: ...
def gaussian_blur(
surface: Surface,
radius: int,
repeat_edge_pixels: bool = True,
dest_surface: Optional[Surface] = None
dest_surface: Optional[Surface] = None,
) -> Surface: ...
def hsl(
surface: Surface,
Expand Down
25 changes: 25 additions & 0 deletions docs/reST/ref/transform.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,31 @@ Instead, always begin with the original image and scale to the desired size.)

.. ## pygame.transform.rotozoom ##

.. function:: skew

| :sl:`skew an image to specified points`
| :sg:`skew(surface, points, bg_color=None, adjust_size=True, dest_surface=None)`

This maps an image to a new surface warping the image so that its corners
match the provided points in a clockwise order: top left, top right, bottom
right, bottom left. Provided points represent the pixel coordinates of the
new corners of the image, they must be unique and can be positive or negative
provided they fit in the new surface.

When no 'dest_surface' is provided, the 'adjust_size' option will set the
size of the resulting surface to be the smallest surface the points are
capable of fitting in, if false it will use the original size of the
provided surface.

If 'bg_color' is not provided then it will select a color to use based on
the surface. If the image has pixel alphas, the padded area will be
transparent. Otherwise pygame will pick a color that matches the Surface
colorkey or the top left pixel value.

.. versionadded:: 2.5.2

.. ## pygame.transform.skew ##

.. function:: scale2x

| :sl:`specialized image doubler`
Expand Down
1 change: 1 addition & 0 deletions src_c/doc/transform_doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#define DOC_TRANSFORM_SCALEBY "scale_by(surface, factor, dest_surface=None) -> Surface\nresize to new resolution, using scalar(s)"
#define DOC_TRANSFORM_ROTATE "rotate(surface, angle) -> Surface\nrotate an image"
#define DOC_TRANSFORM_ROTOZOOM "rotozoom(surface, angle, scale) -> Surface\nfiltered scale and rotation"
#define DOC_TRANSFORM_SKEW "skew(surface, points, bg_color=None, adjust_size=True, dest_surface=None)\nskew an image to specified points"
#define DOC_TRANSFORM_SCALE2X "scale2x(surface, dest_surface=None) -> Surface\nspecialized image doubler"
#define DOC_TRANSFORM_SMOOTHSCALE "smoothscale(surface, size, dest_surface=None) -> Surface\nscale a surface to an arbitrary size smoothly"
#define DOC_TRANSFORM_SMOOTHSCALEBY "smoothscale_by(surface, factor, dest_surface=None) -> Surface\nresize to new resolution, using scalar(s)"
Expand Down
Loading
Loading