pygame-ce icon indicating copy to clipboard operation
pygame-ce copied to clipboard

Inconsistency of `font` and `draw` module when handling hex color

Open yunline opened this issue 2 years ago • 3 comments
trafficstars

import pygame

pygame.init()

font = pygame.font.Font(None, 60)

sf = pygame.display.set_mode((640,480))

sf.fill("black")

COLOR_HEX = 0x00ff00ff
COLOR_DEC = (0, 255, 0, 255)


font_sf1 = font.render("test", True, COLOR_HEX)
sf.blit(font_sf1, (10,10))
pygame.draw.rect(sf, COLOR_HEX , (100,10,50,50))
pygame.draw.circle(sf, COLOR_HEX, (200,35), 30)

font_sf2 = font.render("test", True, COLOR_DEC)
sf.blit(font_sf2, (10,100))
pygame.draw.rect(sf, COLOR_DEC , (100,100,50,50))
pygame.draw.circle(sf, COLOR_DEC, (200,125), 30)

pygame.display.flip()

while 1:
    pygame.event.get()

Result:

图片

Expected:

图片

yunline avatar Nov 03 '23 05:11 yunline