diff --git a/emblematic/compose.py b/emblematic/compose.py new file mode 100644 index 0000000..5b9615d --- /dev/null +++ b/emblematic/compose.py @@ -0,0 +1,36 @@ +import bs4 + + +def compose_basic(bg: bs4.Tag, fg: bs4.Tag) -> bs4.Tag: + """ + Create a nice icon from the given background ```` and the given foreground ````. + """ + + if bg.name != "svg": + raise ValueError("bg is not a tag.") + if fg.name != "svg": + raise ValueError("fg is not a tag.") + + bg = bg.__copy__() + bg.attrs["id"] = "emblematic-bg" + bg.attrs["width"] = "100%" + bg.attrs["height"] = "100%" + + fg = fg.__copy__() + fg.attrs["id"] = "emblematic-fg" + fg.attrs["width"] = "63%" + fg.attrs["height"] = "63%" + fg.attrs["preserveAspectRation"] = "xMidYMid meet" + fg.attrs["transform"] = "translate(185, 185)" + + doc = bs4.BeautifulSoup(""" + + + + """) + container: bs4.Tag = doc.svg + container.append(bg) + container.append(fg) + + return doc + diff --git a/emblematic/fontawesome.py b/emblematic/fontawesome.py new file mode 100644 index 0000000..0a6abcf --- /dev/null +++ b/emblematic/fontawesome.py @@ -0,0 +1,22 @@ +""" +Module containing function to process `Font Awesome `_ SVG icons. +""" + +import typing as t +import bs4 +import pathlib + + +def get_icons(path: pathlib.Path): + if not path.exists(): + raise ValueError("Given path does not exist.") + if not path.is_dir(): + raise ValueError("Given path is not a directory.") + + svgs = path.joinpath("svgs") + return svgs.glob("**/*.svg") + + +__all__ = ( + "get_icons", +)