bro
This commit is contained in:
1 parent
de41a02749
commit
9af09cebd3
764 files changed
+54218
-78859
No files matched your search
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
"""pygame.examples.blend_fill
|
||||
""" pygame.examples.blend_fill
|
||||
|
||||
BLEND_ing colors in different ways with Surface.fill().
|
||||
|
||||
@@ -10,10 +10,8 @@ Keyboard Controls:
|
||||
* A - ADD, S- SUB, M- MULT, - MIN, + MAX to change the blend modes
|
||||
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
import pygame
|
||||
import pygame as pg
|
||||
from pygame import K_1, K_2, K_3, K_4, K_5, K_6, K_7, K_8, K_9
|
||||
|
||||
|
||||
@@ -34,63 +32,63 @@ def main():
|
||||
blendtype = 0
|
||||
step = 5
|
||||
|
||||
pygame.init()
|
||||
screen = pygame.display.set_mode((640, 480))
|
||||
pg.init()
|
||||
screen = pg.display.set_mode((640, 480), 0, 32)
|
||||
screen.fill((100, 100, 100))
|
||||
|
||||
image = pygame.image.load(os.path.join(data_dir, "liquid.webp")).convert()
|
||||
blendimage = pygame.image.load(os.path.join(data_dir, "liquid.webp")).convert()
|
||||
image = pg.image.load(os.path.join(data_dir, "liquid.bmp")).convert()
|
||||
blendimage = pg.image.load(os.path.join(data_dir, "liquid.bmp")).convert()
|
||||
screen.blit(image, (10, 10))
|
||||
screen.blit(blendimage, (200, 10))
|
||||
|
||||
pygame.display.flip()
|
||||
pygame.key.set_repeat(500, 30)
|
||||
pg.display.flip()
|
||||
pg.key.set_repeat(500, 30)
|
||||
usage()
|
||||
|
||||
going = True
|
||||
while going:
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
for event in pg.event.get():
|
||||
if event.type == pg.QUIT:
|
||||
going = False
|
||||
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.type == pg.KEYDOWN:
|
||||
usage()
|
||||
|
||||
if event.key == pygame.K_ESCAPE:
|
||||
if event.key == pg.K_ESCAPE:
|
||||
going = False
|
||||
|
||||
if event.key == pygame.K_r:
|
||||
if event.key == pg.K_r:
|
||||
color[0] += step
|
||||
if color[0] > 255:
|
||||
color[0] = 0
|
||||
changed = True
|
||||
|
||||
elif event.key == pygame.K_g:
|
||||
elif event.key == pg.K_g:
|
||||
color[1] += step
|
||||
if color[1] > 255:
|
||||
color[1] = 0
|
||||
changed = True
|
||||
|
||||
elif event.key == pygame.K_b:
|
||||
elif event.key == pg.K_b:
|
||||
color[2] += step
|
||||
if color[2] > 255:
|
||||
color[2] = 0
|
||||
changed = True
|
||||
|
||||
elif event.key == pygame.K_a:
|
||||
blendtype = pygame.BLEND_ADD
|
||||
elif event.key == pg.K_a:
|
||||
blendtype = pg.BLEND_ADD
|
||||
changed = True
|
||||
elif event.key == pygame.K_s:
|
||||
blendtype = pygame.BLEND_SUB
|
||||
elif event.key == pg.K_s:
|
||||
blendtype = pg.BLEND_SUB
|
||||
changed = True
|
||||
elif event.key == pygame.K_m:
|
||||
blendtype = pygame.BLEND_MULT
|
||||
elif event.key == pg.K_m:
|
||||
blendtype = pg.BLEND_MULT
|
||||
changed = True
|
||||
elif event.key == pygame.K_PLUS:
|
||||
blendtype = pygame.BLEND_MAX
|
||||
elif event.key == pg.K_PLUS:
|
||||
blendtype = pg.BLEND_MAX
|
||||
changed = True
|
||||
elif event.key == pygame.K_MINUS:
|
||||
blendtype = pygame.BLEND_MIN
|
||||
elif event.key == pg.K_MINUS:
|
||||
blendtype = pg.BLEND_MIN
|
||||
changed = True
|
||||
|
||||
elif event.key in (K_1, K_2, K_3, K_4, K_5, K_6, K_7, K_8, K_9):
|
||||
@@ -100,15 +98,16 @@ def main():
|
||||
screen.fill((100, 100, 100))
|
||||
screen.blit(image, (10, 10))
|
||||
blendimage.blit(image, (0, 0))
|
||||
# blendimage.fill (color, (0, 0, 20, 20), blendtype)
|
||||
blendimage.fill(color, None, blendtype)
|
||||
screen.blit(blendimage, (200, 10))
|
||||
print(
|
||||
f"Color: {tuple(color)}, Pixel (0,0): {[blendimage.get_at((0, 0))]}"
|
||||
)
|
||||
changed = False
|
||||
pygame.display.flip()
|
||||
pg.display.flip()
|
||||
|
||||
pygame.quit()
|
||||
pg.quit()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user