Cython wrapper for the C++ translation of the Angus Johnson's Clipper library (ver. 6.4.2)
Project description
About
Pyclipper is a Cython wrapper exposing public functions and classes of the C++ translation of the Angus Johnson’s Clipper library (ver. 6.4.2).
Pyclipper releases were tested with Python 2.7 and 3.4 on Linux (Ubuntu 14.04, x64) and Windows (8.1, x64).
Source code is available on GitHub. The package is published on PyPI.
About Clipper
Clipper - an open source freeware library for clipping and offsetting lines and polygons.
The Clipper library performs line & polygon clipping - intersection, union, difference & exclusive-or, and line & polygon offsetting. The library is based on Vatti’s clipping algorithm.
Install
Dependencies
Cython dependency is optional. Cpp sources generated with Cython are available in releases.
Note on using the setup.py:
setup.py operates in 2 modes that are based on the presence of the dev file in the root of the project.
When dev is present, Cython will be used to compile the .pyx sources. This is the development mode (as you get it in the git repository).
When dev is absent, C/C++ compiler will be used to compile the .cpp sources (that were prepared in in the development mode). This is the distribution mode (as you get it on PyPI).
This way the package can be used without or with an incompatible version of Cython.
The idea comes from Matt Shannon’s bandmat library.
From PyPI
Cython not required.
pip install pyclipper
From source
Cython required.
Clone the repository:
git clone git@github.com:fonttools/pyclipper.git
Install:
python setup.py install
After every modification of .pyx files compile with Cython:
python setup.py build_ext --inplace
Clippers’ preprocessor directives
Clipper can be compiled with the following preprocessor directives: use_int32, use_xyz, use_lines and use_deprecated. Among these the use_int32 and use_lines can be used with Pyclipper.
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.
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).
In 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.
How to use
This wrapper library tries to follow naming conventions of the original library.
ClipperLib namespace is represented by the pyclipper module,
classes Clipper and ClipperOffset -> Pyclipper and PyclipperOffset,
when Clipper is overloading functions with different number of parameters or different types (eg. Clipper.Execute, one function fills a list of paths the other PolyTree) that becomes Pyclipper.Execute and Pyclipper.Execute2.
Basic clipping example (based on Angus Johnson’s Clipper library):
import pyclipper
subj = (
((180, 200), (260, 200), (260, 150), (180, 150)),
((215, 160), (230, 190), (200, 190))
)
clip = ((190, 210), (240, 210), (240, 130), (190, 130))
pc = pyclipper.Pyclipper()
pc.AddPath(clip, pyclipper.PT_CLIP, True)
pc.AddPaths(subj, pyclipper.PT_SUBJECT, True)
solution = pc.Execute(pyclipper.CT_INTERSECTION, pyclipper.PFT_EVENODD, pyclipper.PFT_EVENODD)
# solution (a list of paths): [[[240, 200], [190, 200], [190, 150], [240, 150]], [[200, 190], [230, 190], [215, 160]]]
Basic offset example:
import pyclipper
subj = ((180, 200), (260, 200), (260, 150), (180, 150))
pco = pyclipper.PyclipperOffset()
pco.AddPath(subj, pyclipper.JT_ROUND, pyclipper.ET_CLOSEDPOLYGON)
solution = pco.Execute(-7.0)
# solution (a list of paths): [[[253, 193], [187, 193], [187, 157], [253, 157]]]
The Clipper library uses integers instead of floating point values to preserve 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.
Migrating from Pyclipper 0.9.3b0
In 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.
The SCALING_FACTOR removal breaks backward compatibility. For an explanation and help with migration, see https://github.com/fonttools/pyclipper/wiki/Deprecating-SCALING_FACTOR.
License
Pyclipper is available under MIT license.
The core Clipper library is available under Boost Software License. Freeware for both open source and commercial applications.
Changelog
1.1.0
Updated embedded Clipper library to version 6.4.2.
1.0.6
Added support for Python 3.6.
1.0.3
added Travis CI and Appveyor CI to build wheel packages (thanks to @anthrotype)
1.0.2
bug fix: sympy.Zero recognized as a collection (thanks to @jamiebull1)
1.0.0
(breaks backwards compatibility) removes SCALING_FACTOR (thanks to @Feuermurmel)
0.9.3b0
Applied SCALING_FACTOR to the relevant function parameters and class properties
Refactored tests
0.9.2b1
bug fix: Fix setting of the PyPolyNode.IsHole property
0.9.2b0
enable preprocessor directive use_lines by default,
bug fix: PyPolyNode.Contour that is now one path and not a list of paths as it was previously.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pyclipper-1.3.0.post3-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24b6b70114941805c14a33e9378e52d24b18791f1bfc365853d5adb33425f173 |
|
MD5 | 086e16c338f42cf091c211f342496da9 |
|
BLAKE2b-256 | 19013e27eb17f5b38379f38454ec6825d8223e6876b3d1489b7a10bebc3912ad |
Hashes for pyclipper-1.3.0.post3-pp38-pypy38_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee52b9d29512eb7b8b9faee6db3f8694eb6c8455785a5d2d561c40eca67b226f |
|
MD5 | 9b39743bd312d49c8d36dd412988d6aa |
|
BLAKE2b-256 | 914918b56aaa87174b6c05d90e570b1221ff93530f8f9d05a39688d36f5cb33e |
Hashes for pyclipper-1.3.0.post3-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab7e2f9b655333a37002b90bea47d77ff8d1f01293798911afa7f39217f1b71d |
|
MD5 | f857a6d71e0fb9d896a419b851609f47 |
|
BLAKE2b-256 | ede0a4ece59884e6aa6435a2b298bccc990b28df54d090d07632030e06a2804a |
Hashes for pyclipper-1.3.0.post3-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d51757df15f1721946f39016191c7d685306fc69d8a5f2933a1d22119150a1d |
|
MD5 | 8c671405db7bb01c1fd55b1d13211741 |
|
BLAKE2b-256 | 83884ddf31300434fed0951f27f5da651f0a0f9ac9427d96bcc0edb7d60cd9d2 |
Hashes for pyclipper-1.3.0.post3-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ace0de72f252e48eda28981e24142a2b02ac17eacc3d8a2baf628671dd8cc8f |
|
MD5 | b835800c11dc9634d239157060994e3b |
|
BLAKE2b-256 | 4166935a7eb5b708db4b83726d8b4165c60c64b0569e8a7943c7ed514d0f1632 |
Hashes for pyclipper-1.3.0.post3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8d77755a00566e0f0cf48da2e42e76ff93423b55880621944f950058be3fc0e |
|
MD5 | 397c193957d0d102e4232806b2e9ff4a |
|
BLAKE2b-256 | d6c06441a8c89d7c08a5ef81e0761e4a734796e13016ab9c29c1d80f6e6e6671 |
Hashes for pyclipper-1.3.0.post3-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed5ea68bc6f3428fbf9d98f1e72e2020d763d88053cc9a9d31b2eeb49500b26f |
|
MD5 | 4880bc8fb615cb0d76d5fdbc624aa106 |
|
BLAKE2b-256 | 08b3a04e58521dcdfb52d08333481a2d229a89f04b082739643787e9153782c1 |
Hashes for pyclipper-1.3.0.post3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd9f0496daa9b505902848d401bfc3ffe80ee3a6863451fc6c05ceb2a45b9d8f |
|
MD5 | e5dd791ebf87fc50d7e8751bf795378e |
|
BLAKE2b-256 | 2fe28a06198adbd4624744a515042105a65591abd65c9e95a01b347f40e66599 |
Hashes for pyclipper-1.3.0.post3-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b4e0e360ebfc25d01c7e0873b27f912d1c02d99b84393d526bc01836a5fb9f4 |
|
MD5 | 05be386bace388aa748e0e6056826da8 |
|
BLAKE2b-256 | 716ba3b04d3d668a7d4f91211335896ff7ebd0f919aaa5bf171c9b100694512f |
Hashes for pyclipper-1.3.0.post3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f428ecdd224ec30c1a4dbdbaac44e746cbe9a05c25627b05cc7bc2dcda235a26 |
|
MD5 | 08ca892eddcd815cd6730f3f4bcb0e8b |
|
BLAKE2b-256 | b7350fb0508e21ef2a543dd9cd6d2ea9da29b5fc0ff974a585d18392182f50db |
Hashes for pyclipper-1.3.0.post3-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 771ba332790e88eb4aa9de2172131af25525ac23fdda789691e543962849f149 |
|
MD5 | d824960b6d123382f62f0c100016fc1f |
|
BLAKE2b-256 | 99a10a3064336ebff8b686d02a2907c8a05df616658cdeba2472d7f2367a18dc |
Hashes for pyclipper-1.3.0.post3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bad590e701eaef644899ce164631f83e39669796e552f17aef5a37238646b392 |
|
MD5 | 07a7d8cc6eb0c782edb1315aa4917f2f |
|
BLAKE2b-256 | 2fd0439e3db9d0ad8c8f626af85919d35a209bcc9fc85b1386c935038ad2f343 |
Hashes for pyclipper-1.3.0.post3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b509cfd696962683553cd6b9fc7f0baf05bff47c09fd68b085a8aea493436267 |
|
MD5 | 1d2b624adfa4a832d2db5a1a486a08a2 |
|
BLAKE2b-256 | 917e09768b1fae0690b2e6862b23cdf1326cc5f8b7dc56cfa0f9fea9e4440d32 |
Hashes for pyclipper-1.3.0.post3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1408461fba4985d58589fa74c59e273e8aa91d8b55c2e9a6abf966eed7562d90 |
|
MD5 | dbcb0276bcbfdfd3328542f7072a4455 |
|
BLAKE2b-256 | 40e520e5e111e58d24ccb807ca601591fcdac791d397bfd87299c59cf07cca27 |
Hashes for pyclipper-1.3.0.post3-cp39-cp39-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0097aef9ac8a5e10434059641fea338fb682c61993bfe65670e459ec14b4151 |
|
MD5 | bfaf4a25f748bb55be43f2650ab1da40 |
|
BLAKE2b-256 | bbf8ddaa5c7712df3e298db4432c27e6f9660ea2c51402d30be880098bd37d40 |
Hashes for pyclipper-1.3.0.post3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b0950dada5b56a002dddccf131815a8f9b55c4df86ff6a43b7ef48a91b572aa |
|
MD5 | 8ef7b3b6cc0c3bdb57db802eceb85e1f |
|
BLAKE2b-256 | 57d584c9bf3d7a7fca07b3eb0ea632eb3dc5d9e67600adc363207ff0399ff557 |
Hashes for pyclipper-1.3.0.post3-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da4d8f253dd8e152b3364902bed5e221165d3af4e71e2ae81eb9a9a9802089a2 |
|
MD5 | 5c2f432cdfbe6a20c08ff2d471f3cfa3 |
|
BLAKE2b-256 | d6ba030d8525e739f9b545b9a38c8046e3ebad90dc7eb8095cd503eb46b4aec6 |
Hashes for pyclipper-1.3.0.post3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 341556b83ce2a5d4ee36e263e04751a9949e4161f60f0011f9500b845b25ce3c |
|
MD5 | 74e16d4ff81f5f992919f6313c832bb8 |
|
BLAKE2b-256 | 942d273cd5ff1bd5c4875b8532d60b3fb19752b7e54887fb52c5e455e96978a4 |
Hashes for pyclipper-1.3.0.post3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb5ad68b82c2aa408672444e567cea138db29790997d603525878632d61fd6ec |
|
MD5 | 68503a51b95b23fb055b15251be47856 |
|
BLAKE2b-256 | b14a75ff9e45a7f864b5010d2134f3bacb6d13cca36259cc826b813562eddafb |
Hashes for pyclipper-1.3.0.post3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60f20e96e9e055e9bb2e729fe6078969ce252c6b7b1b18d8d963e5343d99f99e |
|
MD5 | 18e2514826585de3c01f22ac21d5e9f4 |
|
BLAKE2b-256 | 146ec072ec2510c188b322dc077bf4e0932b0caa6625de1bbff992cf43cae2c7 |
Hashes for pyclipper-1.3.0.post3-cp38-cp38-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1df7e4bce6ac68abfe926d319f52b749b7c9d5e0a6bd7112a0c7f2f908abecbc |
|
MD5 | e3f482f5019a0c873dda69c50208da1e |
|
BLAKE2b-256 | 2860cc8bf6fdb0d5991b857cbf5d95c20ba6e18293f7088eb469683211da7e11 |
Hashes for pyclipper-1.3.0.post3-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5434e1e69425dc7958579b1f7bedfa8a7cce79400e1b708a42be769a165a3a2c |
|
MD5 | fe5a5db45f86f4dd7d09cab7427971e6 |
|
BLAKE2b-256 | bdea510d38929416d3943ad195b8d4311bc4dbed2432c5967a44b8c11bd6b004 |
Hashes for pyclipper-1.3.0.post3-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fabba875314ebc751b66e571b8b0d5319c76e22051304880a552d70db2252af |
|
MD5 | 1a4359cec53e42eeae05f4518e918448 |
|
BLAKE2b-256 | 708b17709e9620a7edba7b6fa76d288c49faa74e9018ac7616094302aff457a0 |
Hashes for pyclipper-1.3.0.post3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a050ec9df95e9611461adb7f86da4f066848c045d966c46e7b124593e6410e2a |
|
MD5 | 3873a1b0e445014245786a302a78e328 |
|
BLAKE2b-256 | df09dff9b4729b2b91d1414c866930058f45dd85dc7bed5c0f55e91778b482f5 |
Hashes for pyclipper-1.3.0.post3-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 679bfd1fd4595a3f58a706256dc6cc7179ee40fbeff4d134aa3163a9c87ca545 |
|
MD5 | ecbcc154a45f28d7b22fbdfa5e42f7a1 |
|
BLAKE2b-256 | 5b88737eb2291aad95d77765b8bc6b4cb2a59b69e72b5d1922c7bab9a0979cdb |
Hashes for pyclipper-1.3.0.post3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebc13dbfaec1b489fc6ed92a642b8a2c7072fa2d4bc12514cc2bbeacd47c5baf |
|
MD5 | b7090c9f6874734a58c6671c76c1426b |
|
BLAKE2b-256 | 9bce128954cf9dc334dae9609eeec16dba0f1b1bbf534d64a3f3732b92f51e4d |
Hashes for pyclipper-1.3.0.post3-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46b3996c8dcda562c408e653ccef8efd95a7d69400f9119df2c2cb8083d36bf8 |
|
MD5 | 9bab38cb64be5b0ac40f434413173972 |
|
BLAKE2b-256 | 87dfe56b7b961123dba8d2e1c9fcbfb821a6ad63acb965e4b0304fbb9fa63660 |
Hashes for pyclipper-1.3.0.post3-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6748239b89a5edd00b3ce36cb5c7a177978ff3361de861fe2cc559bb2760625d |
|
MD5 | 14e272a8e97891076a3800bd6387facc |
|
BLAKE2b-256 | 9a5b06dd129fe020094c8195d34507560c515776774ac56b4c180a70c2385050 |
Hashes for pyclipper-1.3.0.post3-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5f3ad171f21511813085ac549bb717bbdcc0f4da27abf6b0629438e1f23ca0b |
|
MD5 | 3d72e7fd0db1d5ff620da20843df6430 |
|
BLAKE2b-256 | 99e2ecfd1089ff69688c1e063e44931e1b1e922ef3e8872c131f9a50dc0225fd |
Hashes for pyclipper-1.3.0.post3-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 615bece709d8c304d97089a83f8ff91ca0d2646e8fe42f2637d7cdfcf99a6e4e |
|
MD5 | 76c22d147ddfda49ffffca6c684cc69d |
|
BLAKE2b-256 | 80ad45a80902091fb76717eb04395ff34f3c0c6cdc4420ac4c3e8670046bcf69 |
Hashes for pyclipper-1.3.0.post3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c586ca07c1418d4f010c6bc65215c4b193211e1b95dd8a1bd312d8207c5ccf6a |
|
MD5 | f002766cfa6ad266ffca269624ea3f3e |
|
BLAKE2b-256 | c3ad25aa0d68910a8cb30aef8539f6a419b3e2806c7e51b2235073935975d31c |