CRect:new
The new method constructs a new instance of a CRect object. The CRect class includes 4 data members that describe the minimum and maximum x dimension and the minimum and maximum y dimension.
R = CRect:new() Creates a default CRect R with data members initialized to the default values 0,0,0,0. R = CRect:new( CRect2 ) This is a copy constructor. It creates a new CRect R initialized to the data members of the CRect2 argument. R = CRect:new( xmin, xmax, ymin, ymax ) Creates a CRect R initialized to xmin, xmax, ymin, ymax. |
Three overloads are provided for the CRect class. They create a default CRect, a copy of a CRect, or an initialized CRect. If you pass something other than nil, another CRect, or data member values—such as a string—then the default constructor is used.
The following script fragment illustrates using the 3 constructors. All produce the same result:
A = CRect:new(100,300,400,800) |
-- create CRect A and set values |
Printf("%d:%d,%d:%d", A:Xmin(), A:Xmax(), A:Ymin(), A:Ymax() ) |
-- result: 100:300, 400:800 |
|
|
B = CRect:new(A) |
-- copy A to a new CRect B |
Printf("%d:%d,%d:%d", B:Xmin(), B:Xmax(), B:Ymin(), B:Ymax() ) |
-- result: 100:300, 400:800 |
|
|
C = CRect:new() |
-- create a default CRect C |
C:Set(100,300,400,800) |
|
Printf("%d:%d,%d:%d", C:Xmin(), C:Xmax(), C:Ymin(), C:Ymax() ) |
-- result: 100:300, 400:800 |