feat: choose marker

This commit is contained in:
julius 2024-08-13 16:14:29 +02:00
parent 01fb94c9eb
commit 5941ed7909
No known key found for this signature in database
GPG Key ID: C80A63E6A5FD7092

34
main.py
View File

@ -1,4 +1,5 @@
import io
from typing import Literal
import itertools
import logging
import random
@ -36,6 +37,35 @@ MEDIA_TYPES = {
}
Marker = Literal[
".",
",",
"o",
"v",
"^",
"<",
">",
"1",
"2",
"3",
"4",
"8",
"s",
"p",
"P",
"*",
"h",
"H",
"+",
"x",
"X",
"D",
"d",
"|",
"_",
]
@app.get("/speckles/")
def make_wallpaper(
speckle_colours: str,
@ -44,8 +74,9 @@ def make_wallpaper(
fileformat: str = "svg",
orientation: str | None = "landscape",
local: bool = False,
marker: str | None = ".",
):
if not fileformat in MEDIA_TYPES:
if fileformat not in MEDIA_TYPES:
return
speckle_colours = speckle_colours.split(",")
background = speckle_colours.pop(0)
@ -83,6 +114,7 @@ def make_wallpaper(
[random.random() * y / 8 for _ in range(speckles_per_colour)],
c=color,
s=size,
marker=random.choice(marker),
)
fig.tight_layout()