feat: choose marker
This commit is contained in:
parent
01fb94c9eb
commit
5941ed7909
34
main.py
34
main.py
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user