From 19336c542ca421a788ea92b66e600fb761b0be59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Mon, 10 Oct 2022 22:59:52 +0000 Subject: [PATCH] random buchstaben position --- api/advent22_api/routers/days.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/advent22_api/routers/days.py b/api/advent22_api/routers/days.py index fa97652..6994e16 100644 --- a/api/advent22_api/routers/days.py +++ b/api/advent22_api/routers/days.py @@ -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