-
-
Notifications
You must be signed in to change notification settings - Fork 223
Port Image to C code #3331
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
base: main
Are you sure you want to change the base?
Port Image to C code #3331
Changes from all commits
5a8d38a
1d2b186
7898184
3d2baa6
a3cb1f9
b15938e
ef1c27d
363a193
363fa59
afccd4b
c6ba34d
8bc95e5
9710ba9
844f787
7354bfc
98abc4a
990e0e1
852440b
a288e3a
cb17e50
2f2d6fe
3d7afd9
2a77eec
b15b920
fe9db88
b5f507b
32c4df7
4cd828c
b475598
5b9bcd7
9cb3a46
d924463
59789b5
ef94d66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,4 +147,50 @@ class Texture: | |
|
|
||
| @final | ||
| class Image: | ||
| pass | ||
| def __init__( | ||
| self, | ||
| texture_or_image: Union['Texture', 'Image'], | ||
| srcrect: Optional[RectLike] = None, | ||
| ) -> None: ... | ||
| @property | ||
| def alpha(self) -> float: ... | ||
| @alpha.setter | ||
| def alpha(self, value: float) -> None: ... | ||
| @property | ||
| def angle(self) -> float: ... | ||
| @angle.setter | ||
| def angle(self, value: float) -> None: ... | ||
| @property | ||
| def blend_mode(self) -> int: ... | ||
| @blend_mode.setter | ||
| def blend_mode(self, value: int) -> None: ... | ||
| @property | ||
| def color(self) -> Color: ... | ||
| @color.setter | ||
| def color(self, value: ColorLike) -> None: ... | ||
| @property | ||
| def flip_x(self) -> bool: ... | ||
| @flip_x.setter | ||
| def flip_x(self, value: bool) -> None: ... | ||
| @property | ||
| def flip_y(self) -> bool: ... | ||
| @flip_y.setter | ||
| def flip_y(self, value: bool) -> None: ... | ||
| @property | ||
| def origin(self) -> Optional[tuple[float, float]]: ... | ||
| @origin.setter | ||
| def origin(self, value: Optional[Point]) -> None: ... | ||
| @property | ||
| def srcrect(self) -> Optional[RectLike]: ... | ||
| @srcrect.setter | ||
| def srcrect(self, value: Optional[RectLike]) -> None: ... | ||
|
Comment on lines
+184
to
+186
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. srcrect setter typed Optional in stubs, but C setter rejects None The stub advertises
I’ve provided a C diff to accept None in my render.c comments. |
||
| @property | ||
| def texture(self) -> "Texture": ... | ||
| @texture.setter | ||
| def texture(self, value: "Texture") -> None: ... | ||
| def get_rect(self, **kwargs: Any) -> Rect: ... | ||
| def draw( | ||
| self, | ||
| srcrect: Optional[RectLike] = None, | ||
| dstrect: Optional[RectLike] = None, | ||
| ) -> None: ... | ||
|
Comment on lines
+191
to
+196
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Image.get_rect stub claims kwargs support, but C implementation is METH_NOARGS In src_c/render.c, image_get_rect ignores kwargs. Either update the stub to If you choose to implement kwargs handling, apply the C changes suggested in my render.c comments (image_get_rect + image_methods signature). 🤖 Prompt for AI Agents |
||
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.
💡 Verification agent
🧩 Analysis chain
Alpha type differs from Texture.alpha
Image.alpha is typed as float here, while Texture.alpha is int. If fractional alpha isn’t intended as a public API difference, consider aligning Image.alpha to int for consistency, or document the divergence. Also, clamp in C to [0, 255] to avoid wrap-around on negative or >255 values.
🏁 Script executed:
Length of output: 2169
🏁 Script executed:
Length of output: 10391
Align or document alpha type mismatch: In
buildconfig/stubs/pygame/_render.pyi,Texture.alpha(lines 90–92) is typed asintbutImage.alpha(lines 156–158) usesfloat. Unless fractional alpha is a deliberate feature, changeImage.alphatointfor consistency or document the intended float behavior. Also ensure the C implementation clamps values to[0, 255]to prevent wrap-around.🤖 Prompt for AI Agents