gpt4 book ai didi

python - Pygame - 如果你用一个比表面小的矩形来 blit 一个表面会发生什么?

转载 作者:行者123 更新时间:2023-11-28 16:39:59 25 4
gpt4 key购买 nike

在这个blit调用中

screen = pygame.Surface(640, 480)
bgsurf = pygame.Surface(640, 480)
new_rect = pygame.Rect(0, 0, 80, 80)

screen.blit(bgsurf, new_rect, new_rect)

pygame 如何决定将 bgsurf 的哪一部分复制到 new_rect 区域的屏幕?

最佳答案

来自 pygame 文档:

blit(source, dest, area=None, special_flags = 0) -> Rect

Draws a source Surface onto this Surface. The draw can be positionedwith the dest argument. Dest can either be pair of coordinatesrepresenting the upper left corner of the source. A Rect can also bepassed as the destination and the topleft corner of the rectangle willbe used as the position for the blit. The size of the destinationrectangle does not effect the blit.

An optional area rectangle can be passed as well. This represents asmaller portion of the source Surface to draw.

如您所见,pygame 会在 (0,0) 处 blit 整个表面。如果要blit surface的一部分,需要传入Rect区域。

编辑:

在您的情况下,它会将 new_rect 给定的次表面 blit 到屏幕上,其中左上角将放置在 (0,0)。

关于python - Pygame - 如果你用一个比表面小的矩形来 blit 一个表面会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20625107/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com