{"id":1862,"library":"pyclipper","title":"pyclipper","description":"Pyclipper is a Cython wrapper that exposes the public functions and classes of the C++ translation of the Angus Johnson's Clipper library (version 6.4.2). It provides robust algorithms for 2D polygon clipping (intersection, union, difference, XOR) and offsetting (inflating/deflating). The library is actively maintained, with the latest version being 1.4.0, and releases occur as needed for updates or Python compatibility.","status":"active","version":"1.4.0","language":"en","source_language":"en","source_url":"https://github.com/fonttools/pyclipper","tags":["geometry","polygon","clipping","offsetting","boolean operations","cython"],"install":[{"cmd":"pip install pyclipper","lang":"bash","label":"Install latest stable version"}],"dependencies":[{"reason":"Requires Python 3.10 or newer.","package":"python","optional":false},{"reason":"Required to build pyclipper from source. Not needed for pip installs from wheels.","package":"Cython","optional":true}],"imports":[{"note":"All core functionality is accessed through the `pyclipper` module.","symbol":"pyclipper","correct":"import pyclipper"}],"quickstart":{"code":"import pyclipper\n\n# Subject polygon (a list of paths, where a path is a list of (x, y) tuples)\nsubj = (\n    ((180, 200), (260, 200), (260, 150), (180, 150)),\n    ((215, 160), (230, 190), (200, 190))\n)\n\n# Clip polygon\nclip = ((190, 210), (240, 210), (240, 130), (190, 130))\n\n# Initialize Clipper object\npc = pyclipper.Pyclipper()\n\n# Add paths to the Clipper object\npc.AddPath(clip, pyclipper.PT_CLIP, True) # Clip path is a closed polygon\npc.AddPaths(subj, pyclipper.PT_SUBJECT, True) # Subject paths are closed polygons\n\n# Execute the clipping operation (intersection in this case)\nsolution = pc.Execute(\n    pyclipper.CT_INTERSECTION,\n    pyclipper.PFT_EVENODD, # Fill type for subject polygons\n    pyclipper.PFT_EVENODD  # Fill type for clip polygons\n)\n\nprint(f\"Intersection solution: {solution}\")\n\n# Example of offsetting\nsubj_offset = ((180, 200), (260, 200), (260, 150), (180, 150))\npco = pyclipper.PyclipperOffset()\npco.AddPath(subj_offset, pyclipper.JT_ROUND, pyclipper.ET_CLOSEDPOLYGON)\nsolution_offset = pco.Execute(-7.0) # Offset by -7 units (inward)\n\nprint(f\"Offset solution: {solution_offset}\")","lang":"python","description":"This quickstart demonstrates basic polygon clipping and offsetting using `pyclipper`. It sets up subject and clip polygons, performs an intersection operation, and then an inward offset on a single polygon. All coordinates are integers, as required by the underlying Clipper library."},"warnings":[{"fix":"Manually scale floating-point coordinates to integers before passing them to `pyclipper` functions using `pyclipper.scale_to_clipper()` and scale results back using `pyclipper.scale_from_clipper()`.","message":"The global `SCALING_FACTOR` variable was removed in version 1.0.0 (and its deprecated usage removed in 1.3.0). This change significantly impacted how floating-point coordinates were handled, as automatic scaling is no longer performed.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always convert your floating-point coordinates to integers by multiplying them with a suitable scaling factor (e.g., 1000000 for high precision) before passing them to `pyclipper`. Use `pyclipper.scale_to_clipper()` and `pyclipper.scale_from_clipper()` helper functions for convenience.","message":"The underlying Clipper library operates exclusively on integer coordinates to ensure numerical robustness. Providing floating-point coordinates directly can lead to precision issues or unexpected behavior.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your project's Python environment is running Python 3.10 or a later version.","message":"Python 3.9 support was dropped, and Python 3.10 or newer is now required.","severity":"breaking","affected_versions":">=1.4.0"},{"fix":"If building from source, ensure Cython is installed in your build environment (`pip install Cython`). For typical `pip install pyclipper` from PyPI, pre-built wheels are usually provided, making Cython unnecessary.","message":"When building `pyclipper` from source (e.g., from a Git clone or sdist), Cython is now always a mandatory dependency, even if pre-generated C++ sources are present in the sdist.","severity":"gotcha","affected_versions":">=1.4.0"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}