random buchstaben position

This commit is contained in:
Jörn-Michael Miehe 2022-10-10 22:59:52 +00:00
parent 444c16b0b4
commit 19336c542c

View file

@ -138,6 +138,7 @@ async def get_average_color(
response_class=StreamingResponse,
)
async def get_picture_for_day(
index: int,
letter: str = Depends(get_letter),
img: Image.Image = Depends(load_picture_standard),
) -> StreamingResponse:
@ -149,7 +150,8 @@ async def get_picture_for_day(
font = ImageFont.truetype("Lena.ttf", 50)
# Position des Buchstaben bestimmen
xy = (100, 150)
rnd = random.Random(f"{loesungswort}{index}")
xy = tuple(rnd.choices(range(30, 370), k=2))
# betroffenen Bildbereich bestimmen
text_box = await get_text_box(
@ -168,6 +170,7 @@ async def get_picture_for_day(
# etwas heller/dunkler machen
tc_h, tc_s, tc_v = colorsys.rgb_to_hsv(*text_color)
tc_v = int((tc_v - 127) * 0.97) + 127
if tc_v < 127:
tc_v += 3