| Server IP : 185.208.173.17 / Your IP : 87.236.161.98 Web Server : Microsoft-IIS/10.0 System : Windows NT SRV8576125506 10.0 build 26100 (Windows Server 2016) AMD64 User : IUSR ( 0) PHP Version : 7.4.13 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Program Files/MySQL/MySQL Shell 8.0/lib/Python3.13/Lib/site-packages/svg/ |
Upload File : |
from __future__ import annotations
from dataclasses import dataclass
from decimal import Decimal
from typing import TYPE_CHECKING, Union
if TYPE_CHECKING:
from typing_extensions import Literal
Number = Union[Decimal, float, int]
@dataclass
class Length:
"""
https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
"""
value: Number
unit: Literal["em", "ex", "px", "pt", "pc", "cm", "mm", "in", "%"]
def __str__(self) -> str:
return f"{self.value}{self.unit}"
@dataclass
class PreserveAspectRatio:
"""
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio
"""
alignment: Literal[
"none",
"xMinYMin",
"xMidYMin",
"xMaxYMin",
"xMinYMid",
"xMidYMid",
"xMaxYMid",
"xMinYMax",
"xMidYMax",
"xMaxYMax",
] = "xMidYMid"
scale_type: Literal["meet", "slice"] = "meet"
def __str__(self) -> str:
return f"{self.alignment} {self.scale_type}"
@dataclass
class ViewBoxSpec:
"""
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox
"""
min_x: Number
min_y: Number
width: Number
height: Number
def __str__(self) -> str:
return f"{self.min_x} {self.min_y} {self.width} {self.height}"