Source code for domilite.svg

from domilite.dom_tag import Flags
from domilite.tags import html_tag

__all__ = [
    "svg_tag",
    "svg",
    "animate",
    "animateMotion",
    "animateTransform",
    "circle",
    "clipPath",
    "defs",
    "desc",
    "ellipse",
    "g",
    "image",
    "line",
    "linearGradient",
    "marker",
    "mask",
    "mpath",
    "pattern",
    "polygon",
    "radialGradient",
    "path",
    "rect",
    "stop",
    "switch",
    "symbol",
    "text",
    "textPath",
    "title",
    "tspan",
    "use",
    "view",
    "filter",
]

DASHED_ATTRIBUTES = {
    "accent",
    "alignment",
    "arabic",
    "baseline",
    "cap",
    "clip",
    "color",
    "dominant",
    "enable",
    "fill",
    "flood",
    "font",
    "glyph",
    "horiz",
    "image",
    "letter",
    "lighting",
    "marker",
    "overline",
    "paint",
    "panose",
    "pointer",
    "rendering",
    "shape",
    "stop",
    "strikethrough",
    "stroke",
    "text",
    "underline",
    "unicode",
    "units",
    "v",
    "vector",
    "vert",
    "word",
    "writing",
    "x",
}


[docs] class svg_tag(html_tag):
[docs] @staticmethod def normalize_attribute(attribute: str) -> str: words = attribute.split("_") if words and words[0] in DASHED_ATTRIBUTES: return attribute.replace("_", "-") return attribute
[docs] class svg(svg_tag): """SVG tag class"""
[docs] class animate(svg_tag): """The animate tag class is used to animate an element's attributes over time."""
[docs] class animateMotion(svg_tag): """The animateMotion tag is used to animate an element's motion over time."""
[docs] class animateTransform(svg_tag): """The animateTransform tag is used to animate an element's transformation over time.""" flags = Flags.SINGLE | Flags.PRETTY
[docs] class circle(svg_tag): """The circle tag is used to draw a circle."""
[docs] class clipPath(svg_tag): """The clipPath tag is used to define a clipping path."""
[docs] class defs(svg_tag): """The defs tag is used to define elements that can be reused throughout the SVG document."""
[docs] class desc(svg_tag): """The desc tag is used to provide a description of the SVG document."""
[docs] class ellipse(svg_tag): """The ellipse tag is used to draw an ellipse."""
[docs] class g(svg_tag): """The g tag is used to group SVG elements together."""
[docs] class image(svg_tag): """The image tag is used to embed an image into an SVG document."""
[docs] class line(svg_tag): """The line tag is used to draw a line."""
[docs] class linearGradient(svg_tag): """The linearGradient tag is used to define a linear gradient."""
[docs] class marker(svg_tag): """The <marker> element defines the graphic that is to be used for drawing arrowheads or polymarkers on a given <path>, <line>, <polyline> or <polygon> element."""
[docs] class mask(svg_tag): """The <mask> element defines a mask."""
[docs] class mpath(svg_tag): """The <mpath> element is used to reference a path element for use in a mask."""
[docs] class pattern(svg_tag): """The <pattern> element is used to define a pattern that can be used to fill or stroke an element."""
[docs] class polygon(svg_tag): """The polygon tag is used to draw a polygon."""
[docs] class radialGradient(svg_tag): """The radialGradient tag is used to define a radial gradient."""
[docs] class path(svg_tag): """The path tag is used to define a path."""
[docs] class rect(svg_tag): """The rect tag is used to draw a rectangle."""
[docs] class stop(svg_tag): """The svg tag is used to define an SVG document."""
[docs] class switch(svg_tag): """The switch tag is used to define a group of elements that can be used to switch between different elements."""
[docs] class symbol(svg_tag): """The symbol tag is used to define a graphics object that can be referenced by other elements."""
[docs] class text(svg_tag): """The text tag is used to define text."""
[docs] class textPath(svg_tag): """The textPath tag is used to define a path for text."""
[docs] class title(svg_tag): """The title tag is used to define a title for an element."""
[docs] class tspan(svg_tag): """The tspan tag is used to define a subregion of text."""
[docs] class use(svg_tag): """The use tag is used to reuse an element."""
[docs] class view(svg_tag): """The view tag is used to define a view of an SVG document."""
[docs] class filter(svg_tag): pass
class feBlend(svg_tag): pass class feColorMatrix(svg_tag): pass class feComponentTransfer(svg_tag): pass class feComposite(svg_tag): pass class feConvolveMatrix(svg_tag): pass class feDiffuseLighting(svg_tag): pass class feDisplacementMap(svg_tag): pass class feFlood(svg_tag): pass class feGaussianBlur(svg_tag): pass class feImage(svg_tag): pass class feMerge(svg_tag): pass class feMorphology(svg_tag): pass class feOffset(svg_tag): pass class feSpecularLighting(svg_tag): pass class feTile(svg_tag): pass class feTurbulence(svg_tag): pass class feDistantLight(svg_tag): pass class fePointLight(svg_tag): pass class feSpotLight(svg_tag): pass