{"id":23037147,"url":"https://github.com/fonttools/pyclipper","last_synced_at":"2025-05-16T02:07:19.720Z","repository":{"id":27431068,"uuid":"30908907","full_name":"fonttools/pyclipper","owner":"fonttools","description":"Cython wrapper for the C++ translation of the Angus Johnson's Clipper library (ver. 6.4.2)","archived":false,"fork":false,"pushed_at":"2024-10-18T12:08:18.000Z","size":442,"stargazers_count":241,"open_issues_count":23,"forks_count":43,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-27T21:47:48.923Z","etag":null,"topics":["clipping","polygon","polygon-boolean","polygon-clipping","polygon-clipping-algorithm","polygon-intersection","polygon-offsetting","polygon-union","vatti"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fonttools.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-17T08:40:20.000Z","updated_at":"2025-04-24T03:03:33.000Z","dependencies_parsed_at":"2023-01-14T06:44:04.491Z","dependency_job_id":"d69f9620-fc98-41ec-8501-aba20fd0a3ac","html_url":"https://github.com/fonttools/pyclipper","commit_stats":{"total_commits":186,"total_committers":16,"mean_commits":11.625,"dds":0.5967741935483871,"last_synced_commit":"e349e2bb02b7e7f88541ec30b71061cc3f6f3ce1"},"previous_names":["greginvm/pyclipper"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fonttools%2Fpyclipper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fonttools%2Fpyclipper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fonttools%2Fpyclipper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fonttools%2Fpyclipper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fonttools","download_url":"https://codeload.github.com/fonttools/pyclipper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254453652,"owners_count":22073617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clipping","polygon","polygon-boolean","polygon-clipping","polygon-clipping-algorithm","polygon-intersection","polygon-offsetting","polygon-union","vatti"],"created_at":"2024-12-15T17:29:26.921Z","updated_at":"2025-05-16T02:07:19.702Z","avatar_url":"https://github.com/fonttools.png","language":"C++","readme":"About\n=====\n\n.. image:: https://badge.fury.io/py/pyclipper.svg\n    :target: https://badge.fury.io/py/pyclipper\n.. image:: https://github.com/fonttools/pyclipper/workflows/Build%20+%20Deploy/badge.svg\n    :target: https://github.com/fonttools/pyclipper/actions?query=workflow%3A%22Build+%2B+Deploy%22\n\nPyclipper is a Cython wrapper exposing public functions and classes of\nthe C++ translation of the `Angus Johnson's Clipper library (ver.\n6.4.2) \u003chttp://www.angusj.com/delphi/clipper.php\u003e`__.\n\nPyclipper releases were tested with Python 2.7 and 3.4 on Linux (Ubuntu\n14.04, x64) and Windows (8.1, x64).\n\nSource code is available on\n`GitHub \u003chttps://github.com/fonttools/pyclipper\u003e`__. The package is published on \n`PyPI \u003chttps://pypi.python.org/pypi/pyclipper\u003e`__.\n\n\nAbout Clipper\n-------------\n\n        Clipper - an open source freeware library for clipping and\n        offsetting lines and polygons.\n\n        The Clipper library performs line \u0026 polygon clipping -\n        intersection, union, difference \u0026 exclusive-or, and line \u0026\n        polygon offsetting. The library is based on Vatti's clipping\n        algorithm.\n\n        \\ `Angus Johnson's Clipper\n        library \u003chttp://www.angusj.com/delphi/clipper.php\u003e`__\\ \n\nInstall\n=======\n\nDependencies\n------------\n\nCython dependency is optional. Cpp sources generated with Cython are\navailable in releases.\n\nNote on using the ``setup.py``:\n\n``setup.py`` operates in 2 modes that are based on the presence of the\n``dev`` file in the root of the project.\n\n-  When ``dev`` is **present**, Cython will be used to compile the ``.pyx``\n   sources. This is the *development mode* (as you get it in the git\n   repository).\n-  When ``dev`` is **absent**, C/C++ compiler will be used to compile the\n   ``.cpp`` sources (that were prepared in in the development mode).\n   This is the distribution mode (as you get it on PyPI).\n\nThis way the package can be used without or with an incompatible version\nof Cython.\n\nThe idea comes from `Matt Shannon's bandmat\nlibrary \u003chttps://github.com/MattShannon/bandmat\u003e`__.\n\nFrom PyPI\n---------\n\nCython not required.\n\n::\n\n        pip install pyclipper\n        \n\nFrom source\n-----------\n\nCython required.\n\nClone the repository:\n\n::\n\n        git clone git@github.com:fonttools/pyclipper.git\n        \n\nInstall:\n\n::\n\n        python setup.py install\n        \n\nAfter every modification of ``.pyx`` files compile with Cython:\n\n::\n\n        python setup.py build_ext --inplace\n        \n\nClippers' preprocessor directives\n---------------------------------\nClipper can be compiled with the following preprocessor directives: ``use_int32``, ``use_xyz``, ``use_lines`` and ``use_deprecated``. \nAmong these the ``use_int32`` and ``use_lines`` can be used with Pyclipper.\n\n-  ``use_int32`` - when enabled 32bit ints are used instead of 64bit ints. This improve performance but coordinate values are limited to the range +/- 46340. In Pyclipper this directive is **disabled** by default.\n\n-  ``use_lines`` - enables line clipping. Adds a very minor cost to performance. In Pyclipper this directive is **enabled** by default (since version 0.9.2b0).\n\nIn case you would want to change these settings, clone this repository and change the ``define_macros`` collection (``setup.py``, pyclipper extension definition). Add a set like ``('use_int32', 1)`` to enable the directive, or remove the set to disable it. After that you need to rebuild the package.\n\nHow to use\n==========\n\nThis wrapper library tries to follow naming conventions of the original\nlibrary.\n\n-  ``ClipperLib`` namespace is represented by the ``pyclipper`` module,\n-  classes ``Clipper`` and ``ClipperOffset`` -\u003e \n   ``Pyclipper`` and ``PyclipperOffset``,\n-  when Clipper is overloading functions with different number of\n   parameters or different types (eg. ``Clipper.Execute``, one function\n   fills a list of paths the other PolyTree) that becomes\n   ``Pyclipper.Execute`` and ``Pyclipper.Execute2``.\n\nBasic clipping example (based on `Angus Johnson's Clipper\nlibrary \u003chttp://www.angusj.com/delphi/clipper.php\u003e`__):\n\n.. code:: python\n\n    import pyclipper\n\n    subj = (\n        ((180, 200), (260, 200), (260, 150), (180, 150)),\n        ((215, 160), (230, 190), (200, 190))\n    )\n    clip = ((190, 210), (240, 210), (240, 130), (190, 130))\n\n    pc = pyclipper.Pyclipper()\n    pc.AddPath(clip, pyclipper.PT_CLIP, True)\n    pc.AddPaths(subj, pyclipper.PT_SUBJECT, True)\n\n    solution = pc.Execute(pyclipper.CT_INTERSECTION, pyclipper.PFT_EVENODD, pyclipper.PFT_EVENODD) \n    \n    # solution (a list of paths): [[[240, 200], [190, 200], [190, 150], [240, 150]], [[200, 190], [230, 190], [215, 160]]]\n    \n\nBasic offset example:\n\n.. code:: python\n\n    import pyclipper\n\n    subj = ((180, 200), (260, 200), (260, 150), (180, 150))\n\n    pco = pyclipper.PyclipperOffset()\n    pco.AddPath(subj, pyclipper.JT_ROUND, pyclipper.ET_CLOSEDPOLYGON)\n\n    solution = pco.Execute(-7.0)\n    \n    # solution (a list of paths): [[[253, 193], [187, 193], [187, 157], [253, 157]]]\n\nThe Clipper library uses integers instead of floating point values to\npreserve numerical robustness. If you need to scale coordinates of your polygons, this library provides helper functions ``scale_to_clipper()`` and ``scale_from_clipper()`` to achieve that. \n\nMigrating from Pyclipper ``0.9.3b0``\n------------------------------------\n\nIn previous version of Pyclipper (``0.9.3b0``) polygons could be automatically scaled using the ``SCALING_FACTOR`` variable. This was removed in version ``1.0.0`` due to inexact conversions related to floating point operations. This way the library now provides the original numerical robustness of the base library.\n\nThe ``SCALING_FACTOR`` removal **breaks backward compatibility**. \nFor an explanation and help with migration, see https://github.com/fonttools/pyclipper/wiki/Deprecating-SCALING_FACTOR.\n\nAuthors\n=======\n\n-  The Clipper library is written by `Angus\n   Johnson \u003chttp://www.angusj.com/delphi/clipper.php\u003e`__,\n-  This wrapper was initially written by `Maxime\n   Chalton \u003chttps://sites.google.com/site/maxelsbackyard/home/pyclipper\u003e`__,\n-  Adaptions to make it work with version 5 written by `Lukas\n   Treyer \u003chttp://www.lukastreyer.com\u003e`__,\n-  Adaptions to make it work with version 6.2.1 and PyPI package written by `Gregor Ratajc \u003chttp://www.gregorratajc.com\u003e`__,\n-  ``SCALING_FACTOR`` removal and additions to documentation by Michael Schwarz (@Feuermurmel),\n-  Bug fix `sympy.Zero` is not a collection by Jamie Bull (@jamiebull1),\n-  Travis CI and Appveyor CI integration for continuous builds of wheel packages by Cosimo Lupo (@anthrotype).\n\nThe package is maintained by Cosimo Lupo (`@anthrotype \u003chttps://github.com/anthrotype\u003e`__).\n\nLicense\n=======\n\n-  Pyclipper is available under `MIT\n   license \u003chttp://opensource.org/licenses/MIT\u003e`__.\n-  The core Clipper library is available under `Boost Software\n   License \u003chttp://www.boost.org/LICENSE_1_0.txt\u003e`__. Freeware for both\n   open source and commercial applications.\n\nChangelog\n=========\n\n1.1.0\n-------\n\n- Updated embedded Clipper library to version 6.4.2.\n\n1.0.6\n-------\n-  Added support for Python 3.6.\n\n1.0.3\n-------\n-  added Travis CI and Appveyor CI to build wheel packages (thanks to @anthrotype)\n\n1.0.2\n-------\n-  bug fix: `sympy.Zero` recognized as a collection (thanks to @jamiebull1)\n\n1.0.0\n-------\n- **(breaks backwards compatibility)** removes SCALING_FACTOR (thanks to @Feuermurmel)\n\n0.9.3b0\n-------\n-  Applied SCALING_FACTOR to the relevant function parameters and class properties\n-  Refactored tests\n\n0.9.2b1\n-------\n-  bug fix: Fix setting of the PyPolyNode.IsHole property\n\n0.9.2b0\n-------\n-  enable preprocessor directive ``use_lines`` by default,\n-  bug fix: PyPolyNode.Contour that is now one path and not a list of paths as it was previously.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffonttools%2Fpyclipper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffonttools%2Fpyclipper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffonttools%2Fpyclipper/lists"}