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

Improve documentation around premultiplied alpha #664

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Features

- Support for localizing your GUI into different languages.

- Uses premultiplied alpha blending for improved clarity and accuracy with semi-transparent pixels and improved
performance.

- As closely respecting of the pygame way of doing things as possible.


Expand Down
11 changes: 8 additions & 3 deletions pygame_gui/ui_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,19 @@ def get_mouse_position(self) -> Tuple[int, int]:

def draw_ui(self, window_surface: pygame.surface.Surface):
"""
Draws all the UI elements on the screen. Generally you want this to be after the rest of
your game sprites have been drawn.
Draws all the UI elements on to a surface passed in, usually an opaque surface the size of the screen or window.
Generally you want this to be after the rest of your game sprites have been drawn.

If you want to do something particularly unusual with drawing you may have to write your
own UI manager.

:param window_surface: The screen or window surface on which we are going to draw all of
our UI Elements.
our UI Elements. As pygame_gui uses premultiplied alpha, if the surface passed in is
transparent or semi transparent then it should use premultiplied alpha as well and be
blitted afterward using the BLEND_PREMULTIPLIED special_flag.

You can read more about premultiplied alpha in this short tutorial:
https://pyga.me/docs/tutorials/en/premultiplied-alpha.html

"""
self.ui_group.draw(window_surface)
Expand Down
Loading