feat: choose marker

This commit is contained in:
julius 2024-08-13 16:14:29 +02:00
parent 01fb94c9eb
commit 5941ed7909
Signed by: julius
GPG Key ID: C80A63E6A5FD7092

34
main.py
View File

@ -1,4 +1,5 @@
import io import io
from typing import Literal
import itertools import itertools
import logging import logging
import random 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/") @app.get("/speckles/")
def make_wallpaper( def make_wallpaper(
speckle_colours: str, speckle_colours: str,
@ -44,8 +74,9 @@ def make_wallpaper(
fileformat: str = "svg", fileformat: str = "svg",
orientation: str | None = "landscape", orientation: str | None = "landscape",
local: bool = False, local: bool = False,
marker: str | None = ".",
): ):
if not fileformat in MEDIA_TYPES: if fileformat not in MEDIA_TYPES:
return return
speckle_colours = speckle_colours.split(",") speckle_colours = speckle_colours.split(",")
background = speckle_colours.pop(0) background = speckle_colours.pop(0)
@ -83,6 +114,7 @@ def make_wallpaper(
[random.random() * y / 8 for _ in range(speckles_per_colour)], [random.random() * y / 8 for _ in range(speckles_per_colour)],
c=color, c=color,
s=size, s=size,
marker=random.choice(marker),
) )
fig.tight_layout() fig.tight_layout()