pygame-ce
pygame-ce copied to clipboard
transform.solid_overlay
closes #1847
import pygame
dis = pygame.display.set_mode((600, 600))
img = pygame.image.load("transparent_walt.png")
img = pygame.transform.solid_overlay(img, (0, 0, 0))
while True:
dis.fill((100, 100, 100))
for event in pygame.event.get():
if event.type == pygame.QUIT:
raise SystemExit
dis.blit(img, (30, 30))
pygame.display.update()
produces:
Any idea what's going on here?
import pygame
dis = pygame.display.set_mode((600, 600))
img = pygame.image.load("examples/data/alien1.png").convert_alpha()
img = pygame.transform.scale(img, (600, 600))
overlay_rect = pygame.Rect(200, 200, 100, 100)
subsurface = img.subsurface(overlay_rect)
subsurface = pygame.transform.solid_overlay(subsurface, (0, 0, 0))
while True:
dis.fill((100, 100, 100))
for event in pygame.event.get():
if event.type == pygame.QUIT:
raise SystemExit
dis.blit(img, (0, 0))
pygame.draw.rect(dis, "red", overlay_rect, 2)
pygame.display.update()
EDIT: I realize now that I am an idiot
Also, when trying to use a string for the color, an error is raised:
pygame-ce 2.3.1.dev1 (SDL 2.26.4, Python 3.11.1)
Traceback (most recent call last):
File "c:\Users\andre\Projects\pygame-ce\test.py", line 10, in <module>
subsurface = pygame.transform.solid_overlay(subsurface, "black")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: invalid search_color argument
That isn't really this PRs fault, though it's something I plan to tackle in the near future
As per @ScriptLineStudios on Discord I'll take over this PR.
Ltl graph to show improvement for 32bit surfaces:
One test on Debian Multiarch / Debian (Bullseye - 11) [s390x] is failing but it's unclear why and it's the only platform exhibiting this behaviour. Hopefully is just a blip but correct me if i'm wrong here.
One test on
Debian Multiarch / Debian (Bullseye - 11) [s390x]is failing but it's unclear why and it's the only platform exhibiting this behaviour. Hopefully is just a blip but correct me if i'm wrong here.
Likely to be an endianness issue - s390x is big endian. I would first change this failing test to an assertEqual() type so it will show the values that are different on the CI.
@itzpr3d4t0r after typing.py, ColorValue isn't available anymore. If you can you can update the branch and replace ColorValue with ColorLike from pygame.typing
@itzpr3d4t0r after typing.py, ColorValue isn't available anymore. If you can you can update the branch and replace ColorValue with ColorLike from pygame.typing
I'm not sure i can do it right atm. I've always committed from github because of commit permissions being broken in my ide for some reason... so I'm afraid someone else has to do it.