import
pygame as py
import
os
import
numpy
py.init()
width, height
=
400
,
300
screen
=
py.display.set_mode((width, height))
screen.fill((
255
,
255
,
255
))
py.display.set_caption(
"Image Invert"
)
def
loadimage(img, scale
=
1
):
imagePath
=
os.path.join(os.path.dirname(__file__), img)
logo
=
py.image.load(imagePath).convert()
size
=
logo.get_size()
size
=
(size[
0
]
*
scale, size[
1
]
*
scale)
logo
=
py.transform.scale(logo, size)
return
logo
logo
=
loadimage(
"gfglogo.png"
,
2
)
width, height
=
logo.get_size()
screen
=
py.display.set_mode((width, height))
screen.blit(logo, (
0
,
0
))
py.display.flip()
running
=
True
while
(running):
for
event
in
py.event.get():
if
event.
type
=
=
py.QUIT:
running
=
False
if
event.
type
=
=
py.MOUSEBUTTONDOWN:
x, y
=
event.pos
if
logo.get_rect().collidepoint(x, y):
inv
=
py.Surface(logo.get_size())
inv.fill((
255
,
255
,
255
))
inv.blit(logo, (
0
,
0
),
None
, py.BLEND_RGBA_SUB)
logo
=
inv
screen.blit(logo, (
0
,
0
))
py.display.flip()
py.quit()