| single |
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) `__.
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.
\ [Angus Johnson's Clipper
library]\
Install
=======
From PyPI
---------
::
pip install pyclipper
From source
-----------
Clone the repository:
::
git clone git@github.com:fonttools/pyclipper.git
Install:
::
pip install .
For development, use an editable install:
::
pip install -e .
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]):
.. code:: python
import pyclipper
subj = (
((180, 200), (260, 200), (260, 150), (180, 150)),
|