CRect Class Description


The CRect class encapsulates functionality for a rectangle object used for computing statistics, setting window boundaries, setting up the image cursor for measurements, and plots, and for other uses. The rectangle is described in terms of pixel coordinates.

Usage

Construction

Object = new_rect()

Object = CRect:new()

Destruction

Object:delete()

Properties

This class has 4 properties that describe the rectangle and may be directly used. For example, if the class object is R, then the minimum x value is accessed by R.xmin. You can access this and other properties directly from the class object using the dot operator. You can also use the accessor methods like Xmin and SetXmin. Remember that properties use the dot operator whereas methods use the colon operator.

xmin

The minimum x value of the rectangle.

xmax

The maximum x value of the rectangle.

ymin

The minimum y value of the rectangle.

ymax

The maximum y value of the rectangle.

Creation - Non-class Functions

This function is normally used to create a new CRect object as an alternative to the class-based new method.

new_rect

Global function that creates a new CRect object.

Construction and Destruction - Class Methods

new

Creates a new instance of the CRect class. Various constructors are available.

delete

Deletes the instance of the CRect object.

Accessing Properties

In addition to using the properties by name, like R.xmin, the methods below allow you to set or get all the properties in one operation.

Get

Returns the 4 properties corresponding to the min and max x and the min and max y of the rectangle.

Set

Sets the 4 properties for the x and y limits of the rectangle.

Operations

Floor

Truncates all rectangle limits to the next lower integer value.

Height

Returns the height of the rectangle.

Inflate

Inflates a rectangle by pulling outward on all 4 sides.

Intersection

Returns a rectangle having the 4 inner dimensions of 2 overlapping rectangles.

Normalize

Normalizes the CRect so that the minimum is less than the maximum value in each direction.

Offset

Offsets a rectangle's sides to move and/or resize it.

PtInside

Returns true if the specified point x,y is inside the rectangle.

PtInsideInt

Returns true if the specified point x,y is inside the rectangle.

RectInside

Returns true if the specified rectangle is completely enclosed with the rectangle.

Round

Rounds the rectanble limits to the nearest integer value.

Size

Returns the width and height of the rectangle.

Union

Returns a rectangle having the 4 outer dimensions of 2 overlapping rectangles.

Width

Returns the width of the rectangle.

Related Topics

Script Classes, Image Coordinate System, Subpixel Coordinate Definition

 

 


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.