[英]how to get the color value of a pixel in pygame?
我想獲取像素的顏色值。 我已經閱讀了有關一個名為“ pygame.Surface.get_at()”的函數的內容。 但是,當我使用此功能時,出現此錯誤:
Traceback (most recent call last):
pygame.Surface.get_at(300, 200)
TypeError: descriptor 'get_at' requires a 'pygame.Surface' object but received a 'int'
您在這里有兩個問題:
get_at
需要一個元組(x, y)
因此應使用以下命令調用它:
.get_at((300, 200))
您應該提供要獲得其像素顏色的表面。 像這樣:
screen = pygame.display.set_mode((150, 50)) ... screen.get_at((300, 200))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.