CRect:Inflate
The Inflate method expands a rectangle outward on all 4 sides. Using positive values for the inflation, xmin and ymin are reduced while xmax and ymax are increased. You can inflate using either positive or negative values.
CRect:Inflate( CRect2 ) CRect:Inflate( x ) CRect:Inflate( x, y ) CRect:Inflate( x1, x2, y1, y2 )
|
Using the 3 different argument lists gives great flexibility in changing the rectangle dimensions:
The difference between Offset and Inflate is that Offset adds positive offsets to all 4 edges, whereas Inflate subtracts positive offsets from the minimum edges while adding positive offsets to the maximum edges.
The following script inflates the CRect R using various argument lists. Note that CRect:Get returns 4 arguments, which can be automatically filled into the 4 fields of the Printf function as shown.
|
-- create a CRect object R |
|
|
|
-- result: 100:200, 300:600. |
|
|
|
-- inflate the rectangle R |
|
-- result: 98:210, 296:620. |
|
|
|
-- inflate the rectangle R |
|
-- result: -2:410, 196:820. |
|
|
|
-- deflate the rectangle R |
|
-- result: 98:210, 296:620. |
|
|
|
-- inflate the rectangle R |
|
-- result: 88:220, 286:630. |
|
|
|
-- create another CRect object |
|
-- inflate R using another rectangle |
|
-- result: 88:280, 246:710. |