mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 00:03:07 +00:00
random buchstaben position
This commit is contained in:
parent
444c16b0b4
commit
19336c542c
1 changed files with 4 additions and 1 deletions
|
@ -138,6 +138,7 @@ async def get_average_color(
|
||||||
response_class=StreamingResponse,
|
response_class=StreamingResponse,
|
||||||
)
|
)
|
||||||
async def get_picture_for_day(
|
async def get_picture_for_day(
|
||||||
|
index: int,
|
||||||
letter: str = Depends(get_letter),
|
letter: str = Depends(get_letter),
|
||||||
img: Image.Image = Depends(load_picture_standard),
|
img: Image.Image = Depends(load_picture_standard),
|
||||||
) -> StreamingResponse:
|
) -> StreamingResponse:
|
||||||
|
@ -149,7 +150,8 @@ async def get_picture_for_day(
|
||||||
font = ImageFont.truetype("Lena.ttf", 50)
|
font = ImageFont.truetype("Lena.ttf", 50)
|
||||||
|
|
||||||
# Position des Buchstaben bestimmen
|
# 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
|
# betroffenen Bildbereich bestimmen
|
||||||
text_box = await get_text_box(
|
text_box = await get_text_box(
|
||||||
|
@ -168,6 +170,7 @@ async def get_picture_for_day(
|
||||||
|
|
||||||
# etwas heller/dunkler machen
|
# etwas heller/dunkler machen
|
||||||
tc_h, tc_s, tc_v = colorsys.rgb_to_hsv(*text_color)
|
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:
|
if tc_v < 127:
|
||||||
tc_v += 3
|
tc_v += 3
|
||||||
|
|
Loading…
Reference in a new issue