Sign in

vitor-internCopy the usernamekit-logo-remix-remix

logo.py

In source/At 0e5d198Copy the commit ID

0e5d198History

Preview

Code3.2 KiB
import xml.etree.ElementTree as E
from .design import UNO_BLUE, FACE_OUTLINES, SPHERE, GRADIENTS, BORDER, K, I, T

NS = "{http://www.w3.org/2000/svg}"
E.register_namespace("", NS[1:-1])

def element(parent, name, **attributes):
    return E.SubElement(parent, NS + name, {k.replace("_", "-"): str(v) for k, v in attributes.items()})

def draw_face(parent, gradient, outline):
    return element(parent, "path", d=outline, fill=f"url(#{gradient})", stroke=f"url(#{gradient})", stroke_width=".12", stroke_linejoin="round")

def render(grid=True):
    root = E.Element(NS + "svg", {"width": "1000", "height": "1000", "viewBox": "0 0 80 80", "role": "img", "aria-labelledby": "title desc"})
    element(root, "title", id="title").text = "KIT geometric logo"
    element(root, "desc", id="desc").text = "A blue sphere, red pyramid, yellow cube, and green cylinder above wide KIT lettering in a blue square border."
    defs = element(root, "defs")
    for definition in GRADIENTS.values():
        gradient = E.SubElement(defs, NS + "linearGradient", definition["coordinates"])
        for stop in definition["stops"]:
            E.SubElement(gradient, NS + "stop", stop)
    element(root, "rect", width=80, height=80, fill="white")
    if grid:
        fade = element(defs, "radialGradient", id="grid-fade", gradientUnits="userSpaceOnUse", cx=0, cy=0, r=1, gradientTransform="translate(40 27.7) scale(33.2 19.7)")
        for offset, opacity in [("0", "1"), (".50", "1"), (".76", ".64"), (".91", ".20"), ("1", "0")]:
            element(fade, "stop", offset=offset, stop_color="white", stop_opacity=opacity)
        mask = element(defs, "mask", id="grid-fade-mask", maskUnits="userSpaceOnUse", x="6.8", y=8, width="66.4", height="39.4")
        element(mask, "rect", x="6.8", y=8, width="66.4", height="39.4", fill="url(#grid-fade)")
        clip = element(defs, "clipPath", id="design-grid-clip")
        element(clip, "rect", x="6.8", y=8, width="66.4", height="39.4")
        lines = element(root, "g", id="design-grid", clip_path="url(#design-grid-clip)", mask="url(#grid-fade-mask)", fill="none", stroke=UNO_BLUE, stroke_width=".085", stroke_opacity=".40")
        commands = []
        for offset in range(-44, 92, 4):
            commands.extend([f"M0 {offset} 80 {offset+40}", f"M0 {offset+40} 80 {offset}"])
        element(lines, "path", d=" ".join(commands))
    shapes = element(root, "svg", x=0, y=0, width=80, height=80, viewBox="-500 -500 1000 1000")
    for name in ["pyramid", "cylinder", "sphere", "cube"]:
        group = element(shapes, "g", aria_label=name.title())
        if name == "sphere":
            cx, cy, radius, gradient = SPHERE
            element(group, "circle", cx=cx, cy=cy, r=radius, fill=f"url(#{gradient})")
        for gradient, outline in FACE_OUTLINES[name]:
            if name == "sphere":
                element(group, "path", d=outline, fill=f"url(#{gradient})")
            else:
                draw_face(group, gradient, outline)
    element(root, "path", d=BORDER, fill="none", stroke=UNO_BLUE, stroke_width="1.682")
    element(root, "path", d=K, fill=UNO_BLUE)
    E.SubElement(root, NS + "rect", I)
    element(root, "path", d=T, fill=UNO_BLUE)
    return E.tostring(root, encoding="unicode")

Files

Loading files

Details

Size
3.2 KiB (3,246 bytes)
Object ID
3f69d95…6f3Copy the object ID
Verification
Size
3.2 KiB (3,246 bytes)
Object ID
3f69d95…6f3Copy the object ID
Storage
Stored as one object
Verification
  • AGENTS.md
  • README.md
  • build.py
  • cover.png
  • manifest.json