Source code for pygerber.renderer.aperture.aperture

# -*- coding: utf-8 -*-
from __future__ import annotations

from abc import ABC, abstractmethod
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from pygerber.renderer import Renderer

from pygerber.mathclasses import BoundingBox
from pygerber.renderer.arc_util_mixin import ArcUtilMixin
from pygerber.renderer.spec import ArcSpec, FlashSpec, LineSpec
from pygerber.tokens.add import ADD_Token


[docs]class Aperture(ABC, ArcUtilMixin): def __init__(self, args: ADD_Token.ARGS, renderer: Renderer) -> None: raise TypeError()
[docs] @abstractmethod def flash(self, spec: FlashSpec) -> None: raise TypeError()
[docs] @abstractmethod def line(self, spec: LineSpec) -> None: raise TypeError()
[docs] @abstractmethod def arc(self, spec: ArcSpec) -> None: raise TypeError()
[docs] @abstractmethod def bbox(self) -> BoundingBox: raise TypeError()
[docs] def flash_bbox(self, spec: FlashSpec) -> BoundingBox: return self.bbox().transform(spec.location)
[docs] def line_bbox(self, spec: LineSpec) -> BoundingBox: return self.bbox().transform(spec.begin) + self.bbox().transform(spec.end)
[docs] def arc_bbox(self, spec: ArcSpec) -> BoundingBox: radius = spec.get_radius() + self.DIAMETER / 2 return BoundingBox( spec.center.x - radius, spec.center.y - radius, spec.center.x + radius, spec.center.y + radius, )