Jan-15-2020, 01:11 AM
When I enter in the alpha value for a color, nothing changes no matter what I set it to. I don't even get an error message. My program just acts like I haven't set a fourth value in the rgba tuple.
color = ((0, 0, 0), 0)
import pygame pygame.init() block=100 winH=block*5 winW=block*5 screen=pygame.display.set_mode((winW,winH)) while True: for event in pygame.event.get(): if event.type==pygame.QUIT: pygame.quit() quit() ##colors pygame.draw.rect(screen,(255,0,0,128),(0,0,block,winH)) ##shading shade1=pygame.draw.rect(screen,(0,255,0,128),(0,0,winW,block)) pygame.display.update()
((255,0,0,128))Then it enters as one value instead of 4.
s = pygame.Surface((1000,750)) # the size of your rect s.set_alpha(128) # alpha level s.fill((255,255,255)) # this fills the entire surface windowSurface.blit(s, (0,0)) # (0,0) are the top-left coordinates or, s = pygame.Surface((1000,750), pygame.SRCALPHA) # per-pixel alpha s.fill((255,255,255,128)) # notice the alpha value in the color windowSurface.blit(s, (0,0))
import pygame orange = pygame.Color("orange") print(orange) darken = orange.hsla darken = darken[0], darken[1], darken[2] - 5, darken[3] orange.hsla = darken print(orange)