Instant properties: w

The instant property w represents the width of a rectangle stored within a rect operand.

Declaration

int32 rect.w

Discussion

A rect operand stores the coordinates of a rectangle in its both values point1 and point2, which accordingly represent the rectangle's top-left and bottom-right corners. As such, both corners can be evaluated and adjusted individually.

The instant property w, in contrast, provides a more convenient way to access and modify the rectangle's coordinates. Reading the property results in the width of the rectangle, calculated from the difference between the coordinates of the bottom-right and the top-left corners. In turn, modifying the w property changes the coordinates of the bottom-right corner only, resulting in a rectangle with the new width without changing the rectangle's origin position. For example:

var rect r = <100,200,110,220>; // Read the rectangle width var int32 result = r.w; // result = 10 // Modify the rectangle width r.w = 50; // r = <100,200,150,220>

Usage in Inspector

When working with Inspector you can easily access, evaluate and modify the width of a rectangle. For this purpose select in Inspector the desired rect property or attribute and click on the small triangle on its left side to expand and display the subordinated values: