Skip to content

Commit 09b051e

Browse files
authored
Merge pull request #664 from MyreMylar/improve-draw-ui-docs
Improve documentation around premultiplied alpha
2 parents f4b101d + d33acd3 commit 09b051e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

docs/source/index.rst

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ Features
2121

2222
- Support for localizing your GUI into different languages.
2323

24+
- Uses premultiplied alpha blending for improved clarity and accuracy with semi-transparent pixels and improved
25+
performance.
26+
2427
- As closely respecting of the pygame way of doing things as possible.
2528

2629

pygame_gui/ui_manager.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,19 @@ def get_mouse_position(self) -> Tuple[int, int]:
361361

362362
def draw_ui(self, window_surface: pygame.surface.Surface):
363363
"""
364-
Draws all the UI elements on the screen. Generally you want this to be after the rest of
365-
your game sprites have been drawn.
364+
Draws all the UI elements on to a surface passed in, usually an opaque surface the size of the screen or window.
365+
Generally you want this to be after the rest of your game sprites have been drawn.
366366
367367
If you want to do something particularly unusual with drawing you may have to write your
368368
own UI manager.
369369
370370
:param window_surface: The screen or window surface on which we are going to draw all of
371-
our UI Elements.
371+
our UI Elements. As pygame_gui uses premultiplied alpha, if the surface passed in is
372+
transparent or semi transparent then it should use premultiplied alpha as well and be
373+
blitted afterward using the BLEND_PREMULTIPLIED special_flag.
374+
375+
You can read more about premultiplied alpha in this short tutorial:
376+
https://pyga.me/docs/tutorials/en/premultiplied-alpha.html
372377
373378
"""
374379
self.ui_group.draw(window_surface)

0 commit comments

Comments
 (0)