Data types: rect
Data structure with coordinates for the top-left and the bottom-right corners of a rectangle, each stored as an individual point value.
Type syntax
rect
Literal syntax
<x1‑value,y1‑value,x2‑value,y2‑value>
Discussion
Operands of this data type are optimized to represent a rectangle in 2D space. The position of the rectangle's top-left corner is determined by the coordinate pair x1 and y1. The position of the bottom-right corner, in turn, is determined by the coordinates x2 and y2:
The rect literal must consist of exact four integer literals x1-value, y1-value, x2-value and y2-value, separated by , (comma) signs and enclosed between a pair of < ... > (angle brackets). The literal can be used within expressions wherever a rect operand is expected. The type name rect, in turn, is designated to be used in declarations of data members. For example:
var rect textArea = <10,20,210,120>; // x1=10, y1=20, x2=210, y2=120 // Rectangle with origin= <10,20> // and size <200,100> var rect scrollArea = <0,-100,200,500>; // x1=0, y1=-100, x2=200, y2=500
Instant constructors
With the instant constructor rect() you can initialize rect operands dynamically at the runtime.
Instant properties
With the following instant properties you can individually access, evaluate and modify the coordinates of a rect operand:
Instant property name |
Short description |
---|---|
Represents the absolute value of the given rect operand. |
|
Represents the area of a rect operand. |
|
Represents the position in the center of a rect operand. |
|
Represents the height of a rect operand. |
|
Reflects the status of a rect. |
|
Represents a rect operand with its origin reset to <0,0>. |
|
Represents the origin position of a rect operand. |
|
Corresponds to the position of the top-left corner of a rect operand. |
|
Corresponds to the position of the bottom-right corner of a rect operand. |
|
Represents the size of a rect operand. |
|
Represents the width of a rect operand. |
|
Represents the origin position of a rect operand. |
|
Corresponds to the x coordinate of the top-left corner of a rect operand. |
|
Corresponds to the x coordinate of the bottom-right corner of a rect operand. |
|
Represents the origin position of a rect operand. |
|
Corresponds to the y coordinate of the top-left corner of a rect operand. |
|
Corresponds to the y coordinate of the bottom-right corner of a rect operand. |
Arithmetic operations
You can combine a rect operand with other operands to arithmetic expressions. The following table provides an overview of the possible operations:
Operator |
Short description |
---|---|
Rectangle positive displacement. |
|
Rectangle negative displacement. |
|
Rectangle inflation. |
|
Rectangle intersection. |
|
Advanced rectangle intersection. |
|
Rectangle union. |
Comparison operations
You can compare a rect operand with other operands in order to test whether these are equal or not. The following table provides an overview of the possible operations:
Operator |
Short description |
---|---|
Equality test for two rect operands. |
|
Inequality test for two rect operands. |
|
Check, whether point is inside a rect. |
|
Check, whether point is outside a rect. |