在pygame中禁用抗锯齿功能

时间:2019-03-10 23:27:15

标签: python pygame antialiasing

我尝试使用pygame.PixelArray在pygame中设置单个像素。不幸的是,看起来pygame自动对这些像素进行抗锯齿处理。到目前为止,这是我尝试过的:

import pygame


BLACK = (0, 0, 0)
BLUE  = (0, 0, 255)
WHITE = (255,255,255)


class GUI:

    def __init__(self):

        self.screen = pygame.display.set_mode((300, 300))
        pygame.mouse.set_visible(True)
        self.clock = pygame.time.Clock()

    def gameloop(self):

        running = True
        while running:
            self.screen.fill(WHITE)
            # event handling
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    running = False
            # drawing
            # for some reason, everything gets anti-aliased
            pixel_array = pygame.PixelArray(self.screen)
            pixel_array[100][100] = BLACK
            pixel_array[100][101] = BLUE
            pixel_array[101][100] = BLUE
            pixel_array[101][101] = BLACK
            del pixel_array
            # update full display
            pygame.display.flip()
            self.clock.tick(30)


def main():

    pygame.init()
    gui = GUI()
    gui.gameloop()
    pygame.quit()


if __name__ == '__main__':

    main()

我所拥有的:

anti-aliased pixels

我希望得到的东西:

pixels

系统:

Python版本:3.7.2(64位)
操作系统:Windows 10 Home Version 1803 Build 17134.590
pygame版本:1.9.4
显示器:集成在Lenovo笔记本电脑中(1920 x 1080)
处理器:Intel-Core-i5-6300HQ
IGP:英特尔高清显卡530
GPU:Nvidia GeForce GTX 960M

0 个答案:

没有答案