A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pypi.python.org/pypi/pyclipper below:

pyclipper · PyPI

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.

Angus Johnson’s Clipper library

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.

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.

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.

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.

Authors

The package is maintained by Cosimo Lupo (@anthrotype).

License Changelog 1.1.0 1.0.6 1.0.3 1.0.2 1.0.0 0.9.3b0 0.9.2b1 0.9.2b0

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4