Новые шаблоны с крестиками по середине
1024×1024 | 512×512 | 256×256
Код
from PIL import Image, ImageDraw
from random import randint
img_size = 1024
square_size = 64
line_width = 1
cross_size = 3
image = Image.new("RGBA", (img_size, img_size), (0, 0, 0, 0))
draw = ImageDraw.Draw(image)
def get_color():
return tuple(randint(128, 255) for _ in range(3)) + (255,)
for x in range(0, img_size, square_size):
for y in range(0, img_size, square_size):
outline_color = get_color()
cross_color = get_color()
x1 = x + line_width // 2
y1 = y + line_width // 2
x2 = x + square_size - line_width // 2 - 1
y2 = y + square_size - line_width // 2 - 1
draw.rectangle(
[x1, y1, x2, y2],
outline = outline_color,
width = line_width
)
draw.line(
[
(x + square_size // 2 - cross_size // 2, y + square_size // 2),
(x + square_size // 2 + cross_size // 2, y + square_size // 2)
],
fill = cross_color,
width = line_width
)
draw.line(
[
(x + square_size // 2, y + square_size // 2 - cross_size // 2),
(x + square_size // 2, y + square_size // 2 + cross_size // 2)
],
fill = cross_color,
width = line_width
)
image.save(f"{img_size}.png")