51 lines
1.0 KiB
Python
51 lines
1.0 KiB
Python
"""
|
|
howto: obs -> window -> filters -> chromake
|
|
"""
|
|
import pygame as p
|
|
import pygame.font as ft
|
|
import pygame.sysfont as sft
|
|
import pygame.image
|
|
|
|
textcolor=(0x00, 0x00, 0x00)
|
|
chromakey=(0x00, 0xFF, 0x00)
|
|
speed=8
|
|
|
|
d = p.display.set_mode()
|
|
c = p.time.Clock()
|
|
|
|
p.display.init()
|
|
"""
|
|
print(ft.get_fonts())
|
|
ft.init()
|
|
sft.initsysfonts()
|
|
ff = sft.SysFont('dejavusans', 28)
|
|
"""
|
|
|
|
i = p.sprite.Sprite()
|
|
#i.image = ff.render("SWNBR", True, textcolor)
|
|
i.image = p.image.load('image.png').convert_alpha()
|
|
i.rect = i.image.get_rect()
|
|
i.rect.x = (d.get_width()/3)
|
|
i.rect.y = (d.get_height()/3)
|
|
|
|
a=[(speed,speed), (speed,-speed), (-speed,-speed), (-speed,speed)]
|
|
b=0
|
|
while True:
|
|
c.tick_busy_loop(60)
|
|
d.fill(chromakey)
|
|
|
|
tmp = i.rect.move(*a[b])
|
|
while (tmp.left < 0 or
|
|
tmp.top < 0 or
|
|
tmp.right > d.get_width() or
|
|
tmp.bottom > d.get_height()):
|
|
if (b == len(a)-1):
|
|
b = 0
|
|
else:
|
|
b += 1
|
|
tmp = tmp.move(*a[b])
|
|
i.rect = tmp
|
|
d.blit(i.image, i.rect)
|
|
|
|
p.display.flip()
|