API Reference
@univerjs
@univerjs/core
classes
Rectangle

@univerjs/core v0.4.2Docs


Class: Rectangle

This class provides a set of methods to calculate IRange.

Constructors

new Rectangle()

new Rectangle(): Rectangle

Returns

Rectangle

Methods

clone()

static clone(src): IRange

Parameters

ParameterType
srcIRange

Returns

IRange

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:25 (opens in a new tab)


contains()

static contains(src, target): boolean

Parameters

ParameterType
srcIRange
targetIRange

Returns

boolean

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:193 (opens in a new tab)


equals()

static equals(src, target): boolean

Parameters

ParameterType
srcIRange
targetIRange

Returns

boolean

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:44 (opens in a new tab)


getIntersectionBetweenTwoRect()

static getIntersectionBetweenTwoRect(rect1, rect2): null | Required<IRectLTRB>

Parameters

ParameterType
rect1IRectLTRB
rect2IRectLTRB

Returns

null | Required<IRectLTRB>

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:379 (opens in a new tab)


getIntersects()

static getIntersects(src, target): Nullable<IRange>

Parameters

ParameterType
srcIRange
targetIRange

Returns

Nullable<IRange>

Deprecated

use getIntersectRange instead. This method does not handle NaN and does not return the correct rangeType

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:116 (opens in a new tab)


getPositionRange()

static getPositionRange(
   relativeRange, 
   originRange, 
   absoluteRange?): IRange

Parameters

ParameterType
relativeRangeIRange
originRangeIRange
absoluteRange?IRange

Returns

IRange

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:247 (opens in a new tab)


getRelativeRange()

static getRelativeRange(range, originRange): IRange

Parameters

ParameterType
rangeIRange
originRangeIRange

Returns

IRange

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:239 (opens in a new tab)


hasIntersectionBetweenTwoRect()

static hasIntersectionBetweenTwoRect(rect1, rect2): boolean

Parameters

ParameterType
rect1IRectLTRB
rect2IRectLTRB

Returns

boolean

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:366 (opens in a new tab)


intersects()

static intersects(src, target): boolean

Parameters

ParameterType
srcIRange
targetIRange

Returns

boolean

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:76 (opens in a new tab)


mergeRanges()

static mergeRanges(ranges): IRange[]

Combine smaller rectangles into larger ones

Parameters

ParameterType
rangesIRange[]

Returns

IRange[]

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:349 (opens in a new tab)


moveHorizontal()

static moveHorizontal(
   range, 
   step, 
   length): IRange

Parameters

ParameterTypeDefault value
rangeIRangeundefined
stepnumber0
lengthnumber0

Returns

IRange

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:257 (opens in a new tab)


moveOffset()

static moveOffset(
   range, 
   offsetX, 
   offsetY): IRange

Parameters

ParameterType
rangeIRange
offsetXnumber
offsetYnumber

Returns

IRange

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:269 (opens in a new tab)


moveVertical()

static moveVertical(
   range, 
   step, 
   length): IRange

Parameters

ParameterTypeDefault value
rangeIRangeundefined
stepnumber0
lengthnumber0

Returns

IRange

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:263 (opens in a new tab)


realContain()

static realContain(src, target): boolean

Parameters

ParameterType
srcIRange
targetIRange

Returns

boolean

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:202 (opens in a new tab)


realUnion()

static realUnion(...ranges): IRange

Parameters

ParameterType
...rangesIRange[]

Returns

IRange

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:226 (opens in a new tab)


simpleRangesIntersect()

static simpleRangesIntersect(rangeA, rangeB): boolean

Check intersects of normal range(RANGE_TYPE.NORMAL) For other types of ranges, please consider using the intersects method.

Parameters

ParameterType
rangeAIRange
rangeBIRange

Returns

boolean

boolean

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:66 (opens in a new tab)


sort()

static sort(ranges): IRange[]

Parameters

ParameterType
rangesIRange[]

Returns

IRange[]

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:402 (opens in a new tab)


subtract()

static subtract(range1, range2): IRange[]

Subtract range2 from range1, the result is is horizontal first then vertical

Parameters

ParameterTypeDescription
range1IRangeThe source range
range2IRangeThe range to be subtracted

Returns

IRange[]

Returns the array of ranges, which are the result not intersected with range1

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:283 (opens in a new tab)


subtractMulti()

static subtractMulti(ranges1, ranges2): IRange[]

Parameters

ParameterType
ranges1IRange[]
ranges2IRange[]

Returns

IRange[]

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:353 (opens in a new tab)


union()

static union(...ranges): IRange

Parameters

ParameterType
...rangesIRange[]

Returns

IRange

Defined in

submodules/univer/packages/core/src/shared/rectangle.ts:212 (opens in a new tab)


Copyright © 2021-2024 DreamNum Co,Ltd. All Rights Reserved.