29 lines
995 B
Python
29 lines
995 B
Python
from PIL import Image, ImageDraw
|
|
|
|
|
|
def make_grid(char_w, char_h):
|
|
"""
|
|
Arguments
|
|
char_w : character's width (int)
|
|
char_h : character's height (int)
|
|
|
|
Description
|
|
Make a grid with 1 pxl of padding and boxes around each character in order to make easier the font creation.
|
|
|
|
Usage
|
|
Just enter :
|
|
>>> make_grid(char_width, char_height)
|
|
An image will be create in the same folder that this programm in *.png format and the name starts by : 'grid_'.
|
|
"""
|
|
width, height = 16 * (char_w + 2), 6 * (char_h + 2)
|
|
grid = Image.new('RGB', (width, height), 'white')
|
|
draw = ImageDraw.Draw(grid)
|
|
|
|
for x in range(0, width, char_w + 2):
|
|
for y in range(0, height, char_h + 2):
|
|
if (x // (char_w + 2) - y // (char_h + 2)) % 2: color = 'blue'
|
|
else: color = 'orange'
|
|
draw.rectangle((x, y, x + char_w + 1, y + char_h + 1), fill=None, outline=color)
|
|
|
|
grid.save(f"grid_{char_w}—{char_h}.png")
|