New to Kendo UI for AngularStart a free 30-day trial

Rect

Represents a rectangle with position and dimensions. Provides methods for geometric operations and transformations.

NameTypeDefaultDescription

height

number

The height of the rectangle

width

number

The width of the rectangle

x

number

The x-coordinate of the rectangle's top-left corner

y

number

The y-coordinate of the rectangle's top-left corner

Constructors

Rect

(x?: number, y?: number, width?: number, height?: number)

Creates a new Rect instance.

Parameters

x?

number

The x-coordinate of the top-left corner (defaults to 0)
y?

number

The y-coordinate of the top-left corner (defaults to 0)
width?

number

The width of the rectangle (defaults to 0)
height?

number

The height of the rectangle (defaults to 0)

Methods

bottom

Gets the bottom center point of the rectangle.

Returns

Point

A Point at the bottom center edge

bottomLeft

Gets the bottom-left corner point of the rectangle.

Returns

Point

A Point at the bottom-left corner

bottomRight

Gets the bottom-right corner point of the rectangle.

Returns

Point

A Point at the bottom-right corner

center

Gets the center point of the rectangle.

Returns

Point

A Point representing the center of the rectangle

clone

Creates a copy of this rectangle.

Returns

Rect

A new Rect with the same position and dimensions

contains

Determines if a point is contained within this rectangle.

Parameters

point

any

The point to test

Returns

boolean

True if the point is inside the rectangle, false otherwise

empty

Creates an empty rectangle (zero position and dimensions).

Returns

Rect

A new empty Rect instance

equals

Determines if this rectangle is equal to another rectangle.

Parameters

rect

any

The rectangle to compare with

Returns

boolean

True if both rectangles have the same position and dimensions

fromPoints

Creates a rectangle from two points.

Parameters

p

Point

The first point

q

Point

The second point

Returns

Rect

A new Rect with the two points as opposite corners

inflate

Inflates the rectangle by the specified amounts.

Parameters

dx

any

The amount to inflate horizontally

dy?

any

The amount to inflate vertically (defaults to dx if not provided)

Returns

Rect

This rectangle instance for chaining

isEmpty

Determines if this rectangle is empty (zero width and height).

Returns

boolean

True if the rectangle has no area, false otherwise

left

Gets the left center point of the rectangle.

Returns

Point

A Point at the left center edge

offset

Moves the rectangle by the specified offset.

Parameters

dx

any

The horizontal offset (or a Point object)

dy

any

The vertical offset (ignored if dx is a Point)

Returns

Rect

This rectangle instance for chaining

overlaps

Determines if this rectangle overlaps with another rectangle.

Parameters

rect

any

The rectangle to check for overlap

Returns

boolean

True if the rectangles overlap, false otherwise

Gets the right center point of the rectangle.

Returns

Point

A Point at the right center edge

rotatedBounds

Calculates the bounding rectangle after rotating this rectangle by a given angle.

Parameters

angle

any

The rotation angle in radians

Returns

Rect

A new Rect representing the axis-aligned bounding box of the rotated rectangle

rotatedPoints

Gets the four corner points of this rectangle after rotation.

Parameters

angle

any

The rotation angle in radians

Returns

Point[]

An array of four Points representing the rotated corners [topLeft, topRight, bottomRight, bottomLeft]

scale

Scales this rectangle while maintaining a static reference point.

Parameters

scaleX

any

The horizontal scale factor

scaleY

any

The vertical scale factor

staicPoint

any

The static point that should remain fixed during scaling

adornerCenter

any

The center point of the adorner

angle

any

The rotation angle to apply during scaling

top

Gets the top center point of the rectangle.

Returns

Point

A Point at the top center edge

topLeft

Gets the top-left corner point of the rectangle.

Returns

Point

A Point at the top-left corner

topRight

Gets the top-right corner point of the rectangle.

Returns

Point

A Point at the top-right corner

toRect

Converts an object to a Rect instance.

Parameters

rect

any

The object to convert (if not already a Rect)

Returns

Rect

A Rect instance

toString

Returns a string representation of this rectangle.

Parameters

delimiter

any

The delimiter to use between values (defaults to space)

Returns

any

A string in the format "x y width height" (or with custom delimiter)

union

Creates a new rectangle that is the union of this rectangle and another.

Parameters

r

any

The rectangle to union with

Returns

Rect

A new Rect representing the union of both rectangles

zoom

Scales this rectangle by a zoom factor.

Parameters

zoom

any

The zoom factor to apply

Returns

Rect

This rectangle instance for chaining

In this article
ConstructorsRectMethods
Not finding the help you need?
Contact Support