1
Fork 0
mirror of https://github.com/Steffo99/emblematic.git synced 2024-11-22 06:44:19 +00:00

Make some progress

This commit is contained in:
Steffo 2023-03-10 09:43:49 +00:00 committed by GitHub
parent f606315eea
commit 8851e21ca3
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 0 deletions

36
emblematic/compose.py Normal file
View file

@ -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 ``<svg>`` and the given foreground ``<svg>``.
"""
if bg.name != "svg":
raise ValueError("bg is not a <svg> tag.")
if fg.name != "svg":
raise ValueError("fg is not a <svg> 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("""
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000">
</svg>
""")
container: bs4.Tag = doc.svg
container.append(bg)
container.append(fg)
return doc

22
emblematic/fontawesome.py Normal file
View file

@ -0,0 +1,22 @@
"""
Module containing function to process `Font Awesome <https://fontawesome.com/>`_ 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",
)