返回介绍

ImagePath Module

发布于 2021-01-07 09:04:44 字数 2882 浏览 935 评论 0 收藏 0

The ImagePath module is used to store and manipulate 2-dimensional vector data. Path objects can be passed to the methods on the ImageDraw module.

class PIL.ImagePath.Path

A path object. The coordinate list can be any sequence object containing either 2-tuples [(x, y), …] or numeric values [x, y, …].

You can also create a path object from another path object.

In 1.1.6 and later, you can also pass in any object that implements Python’s buffer API. The buffer should provide read access, and contain C floats in machine byte order.

The path object implements most parts of the Python sequence interface, and behaves like a list of (x, y) pairs. You can use len(), item access, and slicing as usual. However, the current version does not support slice assignment, or item and slice deletion.

参数:xy – A sequence. The sequence can contain 2-tuples [(x, y), ...] or a flat list of numbers [x, y, ...].
PIL.ImagePath.Path.compact(distance=2)

Compacts the path, by removing points that are close to each other. This method modifies the path in place, and returns the number of points left in the path.

distance is measured as Manhacodean distance and defaults to two pixels.

PIL.ImagePath.Path.getbbox()

Gets the bounding box of the path.

返回:(x0, y0, x1, y1)
PIL.ImagePath.Path.map(function)

Maps the path through a function.

PIL.ImagePath.Path.tolist(flat=0)

Converts the path to a Python list [(x, y), …].

参数:flat – By default, this function returns a list of 2-tuples [(x, y), ...]. If this argument is True, it returns a flat list [x, y, ...] instead.
返回:A list of coordinates. See flat.
PIL.ImagePath.Path.transform(matrix)

Transforms the path in place, using an affine transform. The matrix is a 6-tuple (a, b, c, d, e, f), and each point is mapped as follows:

xOut = xIn * a + yIn * b + c
yOut = xIn * d + yIn * e + f

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文