CRect:Offset
The Offset method moves a rectangle to new coordinates. The offset can be specified in several different ways so that this method can work as a move, resize, or addition of the corresponding edge coordinates. The offsets can be positive or negative.
CRect:Offset( CRect2 ) CRect:Offset( x ) CRect:Offset( x, y ) CRect:Offset( x1, x2, y1, y2 )
|
The specified offset values are added to the edge coordinates of the rectangle. Using the 3 different argument lists gives great flexibility in changing the rectangle dimensions:
Use
the 1 argument form with a CRect to add the coordinates of one
rectangle to another, edge by edge.
Use
the 1 argument version with a number argument to move the
rectangule using equal offsets for all 4 edges.
Use
the 2 argument version to move the rectangle by offsetting opposite
sides equally.
Use
the 4 argument version to resize the rectangle or to do a
combination of move and resize. If the x1 and y1 arguments are both
0, the rectangle is only resized. This version works like the
CRect version except that the
offsets are given as numbers rather than by using another
CRect.
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 moves and resizes 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. |
|
|
|
-- move and resize the rectangle R |
|
-- result: 102:210, 304:620. |
|
|
|
-- resize the rectangle R |
|
-- result: 102:240, 310:660. |
|
|
|
-- move the rectangle R |
|
-- result: 202:340, 110:460. |
|
|
|
-- move the rectangle R |
|
-- result: 212:350, 120:470. |
|
|
|
-- create another CRect object |
|
-- resize R using another rectangle |
|
-- result: 212:410, 120:550. |
CRect class, Union, Intersection, Inflate
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics,
Inc. All Rights Reserved.