File

projects/wms-framework/src/lib/models/controls/Rect.ts

Description

Describes the width, height, and point origin of a rectangle.

Index

Properties
Methods
Accessors

Constructor

constructor(arg1?: unknown, arg2?: unknown, arg3?: unknown, arg4?: unknown)
Parameters :
Name Type Optional
arg1 unknown Yes
arg2 unknown Yes
arg3 unknown Yes
arg4 unknown Yes

Properties

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.

Methods

Public Contains
Contains(point: PointModel)

True if the specified point is contained in the Rect

Parameters :
Name Type Optional
point PointModel No
Returns : boolean

{boolean}

Public Intersect
Intersect(other: Rect)

Sets or sets the x-axis value of the left side of the rectangle.

Parameters :
Name Type Optional
other Rect No
Returns : number

Accessors

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 :
Name Type Optional
value number No
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 :
Name Type Optional
value number No
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
    );
  }
}

result-matching ""

    No results matching ""