(sprito.py) Added functions rect, fill_screen, invert_pixel, invert_rect.

This commit is contained in:
KikooDX 2020-04-10 14:28:27 +02:00
parent d8683ffca5
commit 30ba1948dc
1 changed files with 18 additions and 1 deletions

View File

@ -1,4 +1,4 @@
from casioplot import set_pixel
from casioplot import set_pixel, get_pixel
class SpriteIndexed:
def __init__(self, w: int, h: int, data):
@ -35,3 +35,20 @@ class SpriteRaw(SpriteIndexed):
SpriteIndexed.draw(self, x, y, None)
def to_raw(self) -> None:
return None
def rect(x: int, y: int, w: int, h: int, color: tuple) -> None:
for i in range(x, x + w):
for j in range(y, y + h):
set_pixel(i, j, color)
def fill_screen(color: tuple) -> None:
rect(0, 0, 384, 192, color)
def invert_pixel(x: int, y: int) -> None:
ocolor = get_pixel(x, y)
set_pixel(x, y, (255 - ocolor[0], 255 - ocolor[1], 255 - ocolor[2]))
def invert_rect(x: int, y: int, w: int, h: int) -> None:
for i in range(x, x + w):
for j in range(y, y + h):
invert_pixel(i, j)