surface color swap
This commit is contained in:
parent
a0aba9a0bb
commit
1fcfbb3211
|
@ -1,7 +1,7 @@
|
|||
from random import randint
|
||||
from math import sin, cos, atan2, radians, sqrt
|
||||
|
||||
from pygame import Surface
|
||||
from pygame import Surface, PixelArray
|
||||
from pygame.locals import *
|
||||
|
||||
def get_step(start, end, speed):
|
||||
|
@ -128,3 +128,10 @@ def render_box(font, text, antialias, color, background=None, border=None,
|
|||
bordered_surface.blit(surface, rect)
|
||||
surface = bordered_surface
|
||||
return surface
|
||||
|
||||
def get_color_swapped_surface(surface, current, replacement):
|
||||
swapped = surface.copy()
|
||||
pixels = PixelArray(swapped)
|
||||
pixels.replace(current, replacement)
|
||||
del pixels
|
||||
return swapped
|
||||
|
|
Loading…
Reference in New Issue