File: Rect.rst

package info (click to toggle)
mupdf 1.27.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,224 kB
  • sloc: ansic: 335,320; python: 20,906; java: 7,520; javascript: 2,213; makefile: 1,152; xml: 675; cpp: 639; sh: 513; cs: 307; awk: 10; sed: 7; lisp: 3
file content (123 lines) | stat: -rw-r--r-- 2,923 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
.. default-domain:: js

.. highlight:: javascript

Rect
====

A Rect describes an axis-aligned rectangle by specifying the coordinates
of its upper left and lower right corners. In Javascript they are
represented by a 4-element array: ``[minX, minY, maxX, maxY]``

The relationship between the ``minX``, ``minY``, ``maxX`` and ``maxY``
values can be set so that a rectangle is categorized as invalid, empty or
infinite. This matters when passing such rectangles to
`Rect.transform()`. There are convenience functions to obtain such
rectangles: `Rect.empty`, `Rect.invalid` and
`Rect.infinite`.

In TypeScript the Rect type is defined as follows:

.. code-block::

	type Rect = [number, number, number, number]

Constructors
------------

.. class:: Rect

	|interface_type|

Rects are not represented by a class; they are just plain arrays of four numbers.

Static properties
-----------------

.. data:: Rect.empty

	A rectangle whose coordinates are such that it is categorized as empty.

.. data:: Rect.invalid

	A rectangle whose coordinates are such that it is categorized as invalid.

.. data:: Rect.infinite

	A rectangle whose coordinates are such that it is categorized as infinite.

Static methods
--------------

.. function:: Rect.isEmpty(rect)

	Returns whether the rectangle is empty or not.

	:param Rect rect: Rectangle to evaluate.

	:returns: boolean

	.. code-block::

		var isEmpty = mupdf.Rect.isEmpty([0, 0, 0, 0]) // true
		var isEmpty = mupdf.Rect.isEmpty([0, 0, 100, 100]) // false

.. function:: Rect.isValid(rect)

	Returns whether the rectangle is valid or not.

	:param Rect rect: Rectangle to evaluate.

	:returns: boolean

	.. code-block::

		var isValid = mupdf.Rect.isValid([0, 0, 100, 100]) // true
		var isValid = mupdf.Rect.isValid([0, 0, -100, 100]) // false

.. function:: Rect.isInfinite(rect)

	Returns whether the rectangle is infinite or not.

	:param Rect rect: Rectangle to evaluate.

	:returns: boolean

	.. code-block::

		var isInfinite = mupdf.Rect.isInfinite([0x80000000, 0x80000000, 0x7fffff80, 0x7fffff80]) //true
		var isInfinite = mupdf.Rect.isInfinite([0, 0, 100, 100]) // false

.. function:: Rect.transform(rect, matrix)

	Transforms the supplied rectangle by the given transformation matrix.

	Transforming an invalid, empty or infinite rectangle results in the
	supplied rectangle being returned without change.

	:param Rect rect: Rectangle to transform.
	:param Matrix matrix: Matrix describing transformation to perform.

	:returns: `Rect`

	.. code-block::

		var m = mupdf.Rect.transform([0, 0, 100, 100], [1, 0.5, 1, 1, 1, 1])

.. function:: Rect.isPointInside(rect, point)

	Return whether the point is inside the rectangle.

	:returns boolean

	.. code-block::

		var inside = mupdf.Rect.isPointInside([0, 0, 100, 100], [50, 50])

.. function:: Rect.rectFromQuad(quad)

	Create a Rect that encompasses the entire quad.

	:param Quad quad:

	:returns: `Rect`