Point

`Point` represents a point in the plane, defined by its x and y coordinates.

Attribute / Method Short Description
`Point.distance_to()` calculate distance to point or rect
`Point.transform()` transform point with a matrix
`Point.x` the X-coordinate
`Point.y` the Y-coordinate

Class API

class `Point`
`__init__`(self)
`__init__`(self, x, y)
`__init__`(self, point)
`__init__`(self, list)

Without parameters, `Point(0, 0)` will be created.

With another `point` specified, a new copy will be crated. A `list` must be Python sequence object of length 2. For a `list`, it is the user’s responsibility to only provide numeric entries - no error checking is done, and invalid entries will receive a value of `-1.0`.

Parameters: x (float) – X coordinate of the point y (float) – Y coordinate of the point
`distance_to`(x[, unit])

Calculates the distance to `x`, which may be a Rect, IRect or Point. The distance is given in units of either `px` (pixels, default), `in` (inches), `mm` (millimeters) or `cm` (centimeters).

Note

If `x` is a rectangle, the distance is calculated as if the rectangle were finite.

Parameters: x (Rect or IRect or Point) – the object to which the distance is calculated. unit (str) – the unit to be measured in. One of `px`, `in`, `cm`, `mm`. distance to object `x`. float
`transform`(m)
Applies matrix `m` to the point.
Parameters: m – The matrix to be applied. `Point`
`x`
`x Coordinate`
`y`
`y Coordinate`

Remark

A point’s `p` attributes `x` and `y` can also be accessed as indices, e.g. `p.x == p[0]`, and the `tuple()` and `list()` functions yield sequence objects of its components.

Point Algebra

For a general background, see chapter Operator Algebra for Geometry Objects.

Examples

This should illustrate some basic uses:

```>>> fitz.Point(1, 2) * fitz.Matrix(90)
fitz.Point(-2.0, 1.0)
>>>
>>> fitz.Point(1, 2) * 3
fitz.Point(3.0, 6.0)
>>>
>>> fitz.Point(1, 2) + 3
fitz.Point(4.0, 5.0)
>>>
>>> fitz.Point(25, 30) + fitz.Point(1, 2)
fitz.Point(26.0, 32.0)
>>> fitz.Point(25, 30) + (1, 2)
fitz.Point(26.0, 32.0)
>>>
>>> fitz.Point([1, 2])
fitz.Point(1.0, 2.0)
>>>
>>> -fitz.Point(1, 2)
fitz.Point(-1.0, -2.0)
>>>
>>> abs(fitz.Point(25, 30))
39.05124837953327
```