projects/wms-framework/src/lib/models/controls/Rect.ts
Describes the width, height, and point origin of a rectangle.
Properties |
Methods |
Accessors |
constructor(arg1?: unknown, arg2?: unknown, arg3?: unknown, arg4?: unknown)
|
|||||||||||||||
Parameters :
|
Public Height |
Type : number
|
Default value : 0
|
Gets or sets the height of the rectangle. |
Public Left |
Type : number
|
Default value : 0
|
Gets the x-axis value of the left side of the rectangle. |
Public Top |
Type : number
|
Default value : 0
|
Gets the y-axis position of the top of the rectangle. |
Public Width |
Type : number
|
Default value : 0
|
Gets or sets the width of the rectangle. |
Public Contains | ||||||
Contains(point: PointModel)
|
||||||
True if the specified point is contained in the Rect
Parameters :
Returns :
boolean
{boolean} |
Public Intersect | ||||||
Intersect(other: Rect)
|
||||||
Sets or sets the x-axis value of the left side of the rectangle.
Parameters :
Returns :
number
|
X | ||||||
getX()
|
||||||
Gets or sets the x-axis value of the left side of the rectangle.
Returns :
number
|
||||||
setX(value: number)
|
||||||
Sets or sets the x-axis value of the left side of the rectangle.
Parameters :
Returns :
void
|
Y | ||||||
getY()
|
||||||
Gets or sets the y-axis value of the top side of the rectangle.
Returns :
number
|
||||||
setY(value: number)
|
||||||
Sets or sets the y-axis value of the top side of the rectangle.
Parameters :
Returns :
void
|
Bottom |
getBottom()
|
Gets the y-axis value of the bottom of the rectangle.
Returns :
number
|
Right |
getRight()
|
Gets the x-axis value of the right side of the rectangle.
Returns :
number
|
import { Debugger } from '../../diagnostics/Debugger';
import { PointModel } from './PointModel';
import { Size } from './Size';
/**
* Describes the width, height, and point origin of a rectangle.
*
* @export
* @class Rect
* @wType System.Windows.Rect
*/
export class Rect {
/**
* Gets the y-axis position of the top of the rectangle.
*
* @type {number}
* @memberof Rect
*/
public Top: number = 0;
/**
* Gets the x-axis value of the left side of the rectangle.
*
* @type {number}
* @memberof Rect
*/
public Left: number = 0;
/**
* Gets or sets the width of the rectangle.
*
* @type {number}
* @memberof Rect
*/
public Width: number = 0;
/**
* Gets or sets the height of the rectangle.
*
* @type {number}
* @memberof Rect
*/
public Height: number = 0;
/**
* Creates a new instance of Rect
*
* @memberof Rect
*/
constructor();
constructor(p: PointModel, size: Size);
constructor(left: number, top: number, width: number, height: number);
constructor(arg1?: unknown, arg2?: unknown, arg3?: unknown, arg4?: unknown) {
if (
typeof arg1 === 'number' &&
typeof arg2 === 'number' &&
typeof arg3 === 'number' &&
typeof arg4 === 'number'
) {
this.Left = arg1;
this.Top = arg2;
this.Width = arg3;
this.Height = arg4;
} else if (arg1 instanceof PointModel && arg2 instanceof Size) {
this.Top = arg1.Y;
this.Left = arg1.X;
this.Width = arg2.Width;
this.Height = arg2.Height;
} else {
this.Top = 0;
this.Left = 0;
this.Width = 0;
this.Height = 0;
}
}
/**
* Gets or sets the x-axis value of the left side of the rectangle.
*
* @type {number}
* @memberof Rect
*/
public get X(): number {
return this.Left;
}
/**
* Sets or sets the x-axis value of the left side of the rectangle.
*
* @type {number}
* @memberof Rect
*/
public set X(value: number) {
this.Left = value;
}
/**
* Gets or sets the y-axis value of the top side of the rectangle.
*
* @type {number}
* @memberof Rect
*/
public get Y(): number {
return this.Top;
}
/**
* Sets or sets the y-axis value of the top side of the rectangle.
*
* @type {number}
* @memberof Rect
*/
public set Y(value: number) {
this.Top = value;
}
/**
* Gets the y-axis value of the bottom of the rectangle.
*
* @type {number}
* @memberof Rect
*/
public get Bottom(): number {
return this.Top + this.Height;
}
/**
* Gets the x-axis value of the right side of the rectangle.
*
* @type {number}
* @memberof Rect
*/
public get Right(): number {
return this.Left + this.Width;
}
/**
* Sets or sets the x-axis value of the left side of the rectangle.
*
* @type {number}
* @memberof Rect
* @wNoMap
*/
public Intersect(other: Rect): number {
Debugger.Throw('Not implemented');
return 0;
}
/**
* True if the specified point is contained in the Rect
*
* @param {PointModel} point
* @return {*} {boolean}
* @memberof Rect
*/
public Contains(point: PointModel): boolean {
return (
point?.X >= this.Left &&
point?.X <= this.Right &&
point?.Y >= this.Top &&
point?.Y <= this.Bottom
);
}
}