[boolean] Add basic boolean functionality (boolean() and Polygon.boolean())

This commit is contained in:
jan 2026-02-16 17:41:58 -08:00
commit 7ad59d6b89
8 changed files with 430 additions and 4 deletions

View file

@ -0,0 +1,46 @@
from typing import Any
from collections.abc import Iterable, Sequence
import numpy
from numpy.typing import NDArray
# Basic types for Clipper integer coordinates
Path = Sequence[tuple[int, int]]
Paths = Sequence[Path]
# Types for input/output floating point coordinates
FloatPoint = tuple[float, float] | NDArray[numpy.floating]
FloatPath = Sequence[FloatPoint] | NDArray[numpy.floating]
FloatPaths = Iterable[FloatPath]
# Constants
PT_SUBJECT: int
PT_CLIP: int
PT_UNION: int
PT_INTERSECTION: int
PT_DIFFERENCE: int
PT_XOR: int
PFT_EVENODD: int
PFT_NONZERO: int
PFT_POSITIVE: int
PFT_NEGATIVE: int
# Scaling functions
def scale_to_clipper(paths: FloatPaths, scale: float = ...) -> Paths: ...
def scale_from_clipper(paths: Path | Paths, scale: float = ...) -> Any: ...
class PolyNode:
Contour: Path
Childs: list[PolyNode]
Parent: PolyNode
IsHole: bool
class Pyclipper:
def __init__(self) -> None: ...
def AddPath(self, path: Path, poly_type: int, closed: bool) -> None: ...
def AddPaths(self, paths: Paths, poly_type: int, closed: bool) -> None: ...
def Execute(self, clip_type: int, subj_fill_type: int = ..., clip_fill_type: int = ...) -> Paths: ...
def Execute2(self, clip_type: int, subj_fill_type: int = ..., clip_fill_type: int = ...) -> PolyNode: ...
def Clear(self) -> None: ...