diff --git a/docs/reST/ref/surface.rst b/docs/reST/ref/surface.rst index a1aa9187d7..cae2093e1a 100644 --- a/docs/reST/ref/surface.rst +++ b/docs/reST/ref/surface.rst @@ -728,7 +728,7 @@ | :sl:`get the dimensions of the Surface` | :sg:`get_size() -> (width, height)` - Return the width and height of the Surface in pixels. + Return the width and height of the Surface in pixels. Can also be accessed with :attr:`size` .. ## Surface.get_size ## @@ -737,7 +737,7 @@ | :sl:`get the width of the Surface` | :sg:`get_width() -> width` - Return the width of the Surface in pixels. + Return the width of the Surface in pixels. Can also be accessed with :attr:`width` .. ## Surface.get_width ## @@ -746,7 +746,7 @@ | :sl:`get the height of the Surface` | :sg:`get_height() -> height` - Return the height of the Surface in pixels. + Return the height of the Surface in pixels. Can also be accessed with :attr:`height` .. ## Surface.get_height ## @@ -1039,6 +1039,33 @@ .. ## Surface.premul_alpha ## + .. attribute:: width + + | :sl:`Surface width in pixels (read-only)` + | :sg:`width -> int` + + Read-only attribute. Same as :meth:`get_width()` + + .. versionadded:: 2.5.0 + + .. attribute:: height + + | :sl:`Surface height in pixels (read-only)` + | :sg:`height->int` + + Read-only attribute. Same as :meth:`get_height()` + + .. versionadded:: 2.5.0 + + .. attribute:: size + + | :sl:`Surface size in pixels (read-only)` + | :sg:`height->tuple[int, int]` + + Read-only attribute. Same as :meth:`get_size()` + + .. versionadded:: 2.5.0 + .. ## pygame.Surface ## diff --git a/src_c/doc/surface_doc.h b/src_c/doc/surface_doc.h index 358629573f..e901ed70c7 100644 --- a/src_c/doc/surface_doc.h +++ b/src_c/doc/surface_doc.h @@ -52,3 +52,6 @@ #define DOC_SURFACE_GETBUFFER "get_buffer() -> BufferProxy\nacquires a buffer object for the pixels of the Surface." #define DOC_SURFACE_PIXELSADDRESS "_pixels_address -> int\npixel buffer address" #define DOC_SURFACE_PREMULALPHA "premul_alpha() -> Surface\nreturns a copy of the surface with the RGB channels pre-multiplied by the alpha channel." +#define DOC_SURFACE_WIDTH "width -> int\nSurface width in pixels (read-only)" +#define DOC_SURFACE_HEIGHT "height->int\nSurface height in pixels (read-only)" +#define DOC_SURFACE_SIZE "height->tuple[int, int]\nSurface size in pixels (read-only)" diff --git a/src_c/surface.c b/src_c/surface.c index de8a92eb9a..1d0300bffe 100644 --- a/src_c/surface.c +++ b/src_c/surface.c @@ -266,9 +266,9 @@ _PgSurface_SrcAlpha(SDL_Surface *surf); static PyGetSetDef surface_getsets[] = { {"_pixels_address", (getter)surf_get_pixels_address, NULL, "pixel buffer address (readonly)", NULL}, - {"width", (getter)surf_get_width, NULL, NULL, NULL}, - {"height", (getter)surf_get_height, NULL, NULL, NULL}, - {"size", (getter)surf_get_size, NULL, NULL, NULL}, + {"width", (getter)surf_get_width, NULL, DOC_SURFACE_WIDTH, NULL}, + {"height", (getter)surf_get_height, NULL, DOC_SURFACE_HEIGHT, NULL}, + {"size", (getter)surf_get_size, NULL, DOC_SURFACE_SIZE, NULL}, {NULL, NULL, NULL, NULL, NULL}}; static struct PyMethodDef surface_methods[] = {