Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Rect

轴对齐矩形。 矩形内的所有点都大于等于矩形的最小点 (xMin, yMin) 并且小于等于矩形的最大点 (xMax, yMax)。 矩形的宽度定义为 xMax - xMin;高度定义为 yMax - yMin。

Hierarchy

Index

Constructors

constructor

  • newRect(other: Rect): Rect
  • newRect(x?: undefined | number, y?: undefined | number, width?: undefined | number, height?: undefined | number): Rect
  • en

    Constructs a Rect from another one.

    zh

    构造与指定矩形相等的矩形。

    Parameters

    • other: Rect

      Specified Rect.

    Returns Rect

  • en

    Constructs a Rect with specified values.

    zh

    构造具有指定的最小值和尺寸的矩形。

    Parameters

    • Optional x: undefined | number

      The minimum X coordinate of the rectangle.

    • Optional y: undefined | number

      The minimum Y coordinate of the rectangle.

    • Optional width: undefined | number

      The width of the rectangle, measured from the X position.

    • Optional height: undefined | number

      The height of the rectangle, measured from the Y position.

    Returns Rect

Properties

T

T: any

返回当前矩形的字符串表示。

returns

The information of the current rect in string

height

height: number

矩形的高度。

width

width: number

矩形的宽度。

x

x: number

矩形最小点的 x 坐标。

y

y: number

矩形最小点的 y 坐标。

Accessors

center

  • get center(): Vec2
  • set center(value: Vec2): void

origin

  • get origin(): Vec2
  • set origin(value: Vec2): void

size

  • get size(): Size
  • set size(value: Size): void

w

  • get w(): number
  • set w(val: number): void

xMax

  • get xMax(): number
  • set xMax(value: number): void

xMin

  • get xMin(): number
  • set xMin(value: number): void

yMax

  • get yMax(): number
  • set yMax(value: number): void

yMin

  • get yMin(): number
  • set yMin(value: number): void

z

  • get z(): number
  • set z(val: number): void

Methods

clone

contains

  • contains(point: Vec2): boolean
  • 判断当前矩形是否包含指定的点。

    Parameters

    • point: Vec2

      Specified point.

    Returns boolean

    The specified point is included in the rectangle and returns true', otherwise it returnsfalse'.

containsRect

  • containsRect(other: Rect): boolean
  • 判断当前矩形是否包含指定矩形。

    Parameters

    • other: Rect

      Specified rectangles.

    Returns boolean

    Returns true' if all the points of the specified rectangle are included in the current rectangle,false' otherwise.

equals

  • equals(other: Rect): boolean
  • 判断当前矩形是否与指定矩形相等。

    Parameters

    • other: Rect

      Specified rectangles.

    Returns boolean

    Returns true' when the minimum and maximum values of both rectangles are equal, respectively; otherwise, returnsfalse'.

intersects

  • intersects(other: Rect): boolean
  • 判断当前矩形是否与指定矩形相交。

    Parameters

    • other: Rect

      Specified rectangles.

    Returns boolean

    If intersected, return true', otherwise returnfalse'.

lerp

  • lerp(to: Rect, ratio: number): this
  • 根据指定的插值比率,从当前矩形到目标矩形之间做插值。

    Parameters

    • to: Rect

      Target Rect.

    • ratio: number

      The interpolation coefficient.The range is [0,1].

    Returns this

set

  • set(other: Rect): any
  • set(x?: undefined | number, y?: undefined | number, width?: undefined | number, height?: undefined | number): any
  • 设置当前矩形使其与指定矩形相等。

    Parameters

    • other: Rect

      Specified Rect.

    Returns any

    this

  • 设置当前矩形使其与指定参数的矩形相等。

    Parameters

    • Optional x: undefined | number

      The x parameter of the specified rectangle

    • Optional y: undefined | number

      The y parameter of the specified rectangle

    • Optional width: undefined | number

      The width parameter of the specified rectangle

    • Optional height: undefined | number

      The height parameter of the specified rectangle

    Returns any

    this

toString

  • toString(): string

transformMat4

  • transformMat4(mat: Mat4): this
  • 应用矩阵变换到当前矩形: 应用矩阵变换到当前矩形的最小点得到新的最小点, 将当前矩形的尺寸视为二维向量应用矩阵变换得到新的尺寸; 并将如此构成的新矩形。

    Parameters

    Returns this

Static fromMinMax

  • fromMinMax<Out, VecLike>(out: Out, v1: VecLike, v2: VecLike): Out
  • 由任意两个点创建一个矩形,目标矩形即是这两个点各向 x、y 轴作线所得到的矩形。

    Type parameters

    Parameters

    • out: Out
    • v1: VecLike

      Specified point 1.

    • v2: VecLike

      Specified point 2.

    Returns Out

    Target rectangle.

Static intersection

  • intersection<Out>(out: Out, one: Out, other: Out): Out
  • 计算当前矩形与指定矩形重叠部分的矩形,将其赋值给出口矩形。

    Type parameters

    Parameters

    • out: Out

      Output Rect.

    • one: Out

      One of the specify Rect.

    • other: Out

      Another of the specify Rect.

    Returns Out

Static lerp

  • lerp<Out>(out: Out, from: Out, to: Out, ratio: number): Out
  • 根据指定的插值比率,从当前矩形到目标矩形之间做插值。

    Type parameters

    Parameters

    • out: Out

      Output rect.

    • from: Out

      Original rect.

    • to: Out

      Target rect.

    • ratio: number

      The interpolation coefficient.The range is [0,1].

    Returns Out

Static union

  • union<Out>(out: Out, one: Out, other: Out): Out
  • 创建同时包含当前矩形和指定矩形的最小矩形,将其赋值给出口矩形。

    Type parameters

    Parameters

    • out: Out

      Output Rect.

    • one: Out

      One of the specify Rect.

    • other: Out

      Another of the specify Rect.

    Returns Out

Generated using TypeDoc