| Server IP : 93.86.61.54 / Your IP : 216.73.216.206 Web Server : Apache/2.4.62 (Ubuntu) System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64 User : www-data ( 33) PHP Version : 8.4.22 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/lib/python3/dist-packages/ufoLib2/objects/ |
Upload File : |
from __future__ import annotations
from typing import Optional
from attr import define
from ufoLib2.objects.misc import AttrDictMixin
@define
class Guideline(AttrDictMixin):
"""Represents a single guideline.
See http://unifiedfontobject.org/versions/ufo3/glyphs/glif/#guideline. Has some
data composition restrictions.
"""
x: Optional[float] = None
"""The origin x coordinate of the guideline."""
y: Optional[float] = None
"""The origin y coordinate of the guideline."""
angle: Optional[float] = None
"""The angle of the guideline."""
name: Optional[str] = None
"""The name of the guideline, no uniqueness required."""
color: Optional[str] = None
"""The color of the guideline."""
identifier: Optional[str] = None
"""The globally unique identifier of the guideline."""
def __attrs_post_init__(self) -> None:
x, y, angle = self.x, self.y, self.angle
if x is None and y is None:
raise ValueError("x or y must be present")
if x is None or y is None:
if angle is not None:
raise ValueError("if 'x' or 'y' are None, 'angle' must not be present")
if x is not None and y is not None and angle is None:
raise ValueError("if 'x' and 'y' are defined, 'angle' must be defined")
if angle is not None and not (0 <= angle <= 360):
raise ValueError("angle must be between 0 and 360")