|Home | Tutorial | Classes | Functions | QSA Workbench | Language | Qt API | QSA Articles | Qt Script for Applications | ![]() |
[Prev: Point] [Home] [Next: Size]
A Rect object represents a rectangle.
The rectangle class provides three constructors.
var rect = new Rect( 10, 20, 30, 40 ); // x=10, y=20, width=30, height=40 var duplicate = new Rect( rect ); // x=10, y=20, width=30, height=40 var empty = new Rect(); // x=0, y=0, width=0, height=0
x : Number; The left position of the rectangle.
y : Number; The right position of the rectangle.
width : Number; The width of the rectangle.
height : Number; The height of the rectangle.
top : Number; The position of the top of the rectangle. This is defined as top = y.
bottom : Number; The position of the bottom of the rectangle. This is defined as bottom = y + height + 1.
left : Number; The position of the rectangle's left side. This is defined as left = x
right : Number; The position of the rectangle's right side. This is defined as right = x + width + 1.
center : Point; The center of the rectangle.
isNull() : Boolean;
var empty = new Rect(); empty.isNull(); // true; var square = new Rect( 10, 10, 10, 10 ); square.isNull(); // false;
Returns true if the rectangle has a width and height of 0.
isEmpty() : Boolean;
var rect = new Rect( 10, 10, -10, -10 ); rect.isEmpty(); // true var rect = new Rect( 10, 10, 10, 10 ); rect.isEmpty(); // false
Returns true if the rectangle is empty, meaning that it has width and/or height that is negative.
contains( otherRect : Rect ) : Boolean;
new Rect( 0, 0, 100, 100 ).contains( new Rect( 10, 10, 10, 10 ) ); // true new rect( 10, 10, 10, 10 ).contains( new Rect( 0, 0, 100, 100 ) ); // false
Returns true if the rectangle contains the other rectangle.
intersection( otherRect : Rect ) : Rect; Returns the intersection between this rectangle and another rectangle. The intersection of two rectangles is the part of the rectangles that overlap. If they do not overlap, an empty rectangle is returned.
union( otherRect : Rect ) : Rect; Returns the union of two rectangles. The union is a rectangle large enough to encompass both rectangles.
intersects( otherRect : Rect ) : Boolean; Returns true if this rectangle intersects the other rectangle.
normalize(); Normalizes this rectangle. This means changing the prefix of the width and/or height if they are negative. After being normalized, a rectangle will no longer be empty.
moveLeft( pos : Number ); Moves the rectangle so that its left property is equal to pos.
moveRight( pos : Number ); Moves the rectangle so that its right property is equal to pos.
moveTop( pos : Number ); Moves the rectangle so that its top property is equal to pos.
moveBottom( pos : Number ); Moves the rectangle so that its bottom property is equal to pos.
moveBy( dx : Number, dy : Number ); Translates the rectangle by dx and dy. dx and dy will be added to x and y, and width and height will be left unchanged.
[Prev: Point] [Home] [Next: Size]
Copyright © 2001-2006 Trolltech | Trademarks | QSA version 1.1.5
|