✨
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
static/images/*
|
static/images/*
|
||||||
current_games/*
|
current_games/*
|
||||||
|
|
||||||
|
__pycache__/
|
@ -24,6 +24,6 @@ Roboto
|
|||||||
#Roboto Slab
|
#Roboto Slab
|
||||||
#Rockwell
|
#Rockwell
|
||||||
#Sabon
|
#Sabon
|
||||||
Segoe UI
|
#Segoe UI
|
||||||
#Times New Roman
|
#Times New Roman
|
||||||
#Verdana
|
#Verdana
|
Binary file not shown.
@ -1,13 +1,16 @@
|
|||||||
import os
|
import os
|
||||||
|
import random
|
||||||
from PIL import Image, ImageFont, ImageDraw
|
from PIL import Image, ImageFont, ImageDraw
|
||||||
import lorem
|
import lorem
|
||||||
|
|
||||||
from font_game import gen_id, IMAGE_SIZE, IMAGE_BACKGROUND, MARGINS, FONT_COLOR
|
from font_game import gen_id, IMAGE_SIZE, IMAGE_BACKGROUND, MARGINS, FONT_COLOR
|
||||||
|
|
||||||
def gen_image(font: ImageFont.ImageFont) -> str:
|
def gen_image(font: ImageFont.ImageFont) -> str:
|
||||||
img = Image.new("RGB", IMAGE_SIZE, IMAGE_BACKGROUND)
|
image_mult = random.uniform(0.8,1.2)
|
||||||
|
image_size = (int(IMAGE_SIZE[0]*image_mult), int(IMAGE_SIZE[1]*image_mult))
|
||||||
|
img = Image.new("RGB", image_size, IMAGE_BACKGROUND)
|
||||||
drawer = ImageDraw.Draw(img)
|
drawer = ImageDraw.Draw(img)
|
||||||
text_width = IMAGE_SIZE[0] - 2 * MARGINS
|
text_width = int((IMAGE_SIZE[0] - 2 * MARGINS)*image_mult)
|
||||||
text = lorem.sentence()
|
text = lorem.sentence()
|
||||||
text_list = []
|
text_list = []
|
||||||
line = ""
|
line = ""
|
||||||
@ -21,7 +24,7 @@ def gen_image(font: ImageFont.ImageFont) -> str:
|
|||||||
text_list.append(line)
|
text_list.append(line)
|
||||||
|
|
||||||
drawer.text(
|
drawer.text(
|
||||||
(MARGINS, MARGINS),
|
(int(MARGINS*image_mult), int(MARGINS*image_mult)),
|
||||||
'\n'.join(text_list),
|
'\n'.join(text_list),
|
||||||
FONT_COLOR,
|
FONT_COLOR,
|
||||||
font,
|
font,
|
||||||
|
BIN
fonts/Bembo.OTF
Normal file
BIN
fonts/Bembo.OTF
Normal file
Binary file not shown.
BIN
fonts/Cambria.TTF
Normal file
BIN
fonts/Cambria.TTF
Normal file
Binary file not shown.
Reference in New Issue
Block a user