-
Notifications
You must be signed in to change notification settings - Fork 0
/
pixelbattleImage.py
50 lines (39 loc) · 932 Bytes
/
pixelbattleImage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""Main module"""
# = Import =
import PIL
from PIL import Image
# = Global Variables =
SizeX, SizeY = 10, 10
"""Size of the canvas"""
Canvas = Image.new(
mode="RGB",
size=(SizeX, SizeY),
color=(255, 255, 255)
)
"""Global canvas"""
# = Functions =
def ClearCanvas():
"""Clear canvas"""
global Canvas
Canvas = Image.new(
mode="RGB",
size=(SizeX, SizeY),
color=(255, 255, 255)
)
def SetPixel(x:int, y:int, color:(int, int, int)):
"""Set one pixel"""
global Canvas
if (x < 0) or (y < 0) or (x >= SizeX) or (y >= SizeY):
return
Canvas.putpixel((x, y), color)
def Fill(x1:int, y1:int, x2:int, y2:int, color:(int, int, int)):
"""Fill rectangle"""
global Canvas
for x in range(x1, x2):
for y in range(y1, y2):
SetPixel(x, y, color)
def Show():
"""Show canvas"""
global Canvas
Canvas.show()
# return Canvas