Point¶
Point
represents a point in the plane, defined by its x and y coordinates.
Attribute / Method |
Description |
---|---|
calculate distance to point or rect |
|
transform point with a matrix |
|
same as unit, but positive coordinates |
|
point coordinates divided by |
|
the X-coordinate |
|
the Y-coordinate |
Class API
-
class
Point
¶ -
__init__
(self)¶
-
__init__
(self, x, y)
-
__init__
(self, point)
-
__init__
(self, sequence) Overloaded constructors.
Without parameters,
Point(0, 0)
will be created.With another point specified, a new copy will be crated, “sequence” must be Python sequence object of 2 floats (see Using Python Sequences as Arguments in PyMuPDF).
- Parameters
x (float) – x coordinate of the point
y (float) – y coordinate of the point
-
distance_to
(x[, unit])¶
-
transform
(m)¶ Applies matrix
m
to the point and replaces it with the result.
-
unit
¶ Result of dividing each coordinate by
abs(point)
, the distance of the point to (0,0). This is a vector of length 1 pointing in the same direction as the point does. Its x, resp. y values are equal to the cosine, resp. sine of the angle this vector (and the point itself) has with the x axis.- Type
-
x
¶ The x coordinate
- Type
float
-
y
¶ The y coordinate
- Type
float
-
Remark¶
This class adheres to the sequence protocol, so components can be manipulated via their index. Also refer to Using Python Sequences as Arguments in PyMuPDF.
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
>>>
>>> fitz.Point(1, 2) / (1, 2, 3, 4, 5, 6)
fitz.Point(2.0, -2.0)