Class: Rectangle

Rectangle

Rectangle オブジェクトは、その位置(左上隅のポイント (x, y) で示される)、および幅と高さで定義される領域です。
Rectangle クラスの x、y、width、および height の各プロパティは、互いに独立しているため、
あるプロパティの値を変更しても、他のプロパティに影響はありません。
ただし、right プロパティと bottom プロパティはこれら 4 つのプロパティと不可分に関連しています。
例えば、right プロパティの値を変更すると width プロパティの値も変更されます。
bottom プロパティの値を変更すると、height プロパティの値も変更されます。

A Rectangle object is an area defined by its position,
as indicated by its top-left corner point (x, y) and by its width and its height.
The x, y, width, and height properties of the Rectangle class are independent of each other;
changing the value of one property has no effect on the others. However,
the right and bottom properties are integrally related to those four properties.
For example, if you change the value of the right property, the value of the width property changes;
if you change the bottom property, the value of the height property changes.

new next2d.geom.Rectangle (x, y, width, height)

NameTypeDefaultDescription
xnumber0optional
ynumber0optional
widthnumber0optional
heightnumber0optional
Example

Example usage of Rectangle.

// new Rectangle
const {Rectangle} = next2d.geom;
const rectangle   = new Rectangle(0, 0, 100, 100);

Members

next2d.geom.Rectangle.namespace string staticconstant

指定されたクラスの空間名を返します。
Returns the space name of the specified class.

Default Value:
  • next2d.geom.Rectangle

bottom number

y プロパティと height プロパティの合計です。
The sum of the y and height properties.

bottomRight Point

Rectangle オブジェクトの右下隅の位置で、
right プロパティと bottom プロパティの値で決まります。
The location of the Rectangle object's bottom-right corner,
determined by the values of the right and bottom properties.

height number

矩形の高さ(ピクセル単位)です。
The height of the rectangle, in pixels.

left number

矩形の左上隅の x 座標です。
The x coordinate of the top-left corner of the rectangle.

namespace string constant

指定されたオブジェクトの空間名を返します。
Returns the space name of the specified object.

Default Value:
  • next2d.geom.Rectangle

x プロパティと width プロパティの合計です。
The sum of the x and width properties.

size Point

Rectangle オブジェクトのサイズで、
width プロパティと height プロパティの値を持つ Point オブジェクトとして表現されます。
The size of the Rectangle object,
expressed as a Point object with the values of the width and height properties.

top number

矩形の左上隅の y 座標です。
The y coordinate of the top-left corner of the rectangle.

topLeft Point

Rectangle オブジェクトの左上隅の位置で、
そのポイントの x 座標と y 座標で決まります。
The location of the Rectangle object's top-left corner,
determined by the x and y coordinates of the point.

width number

矩形の幅(ピクセル単位)です。
The width of the rectangle, in pixels.

x number

矩形の左上隅の x 座標です。
The x coordinate of the top-left corner of the rectangle.

y number

矩形の左上隅の y 座標です。
The y coordinate of the top-left corner of the rectangle.

Methods

next2d.geom.Rectangle.toString ()string static

指定されたクラスのストリングを返します。
Returns the string representation of the specified class.

Default Value:
  • [class Rectangle]
Returns:
TypeDescription
string

clone ()Rectangle

元の Rectangle オブジェクトと x、y、width、および height の各プロパティの値が同じである、
新しい Rectangle オブジェクトを返します。
Returns a new Rectangle object with the same values for the x, y, width,
and height properties as the original Rectangle object.

Returns:
TypeDescription
Rectangle

contains (x, y)boolean

指定されたポイントがこの Rectangle オブジェクトで定義される矩形領域内にあるかどうかを判別します。
Determines whether the specified point is contained within
the rectangular region defined by this Rectangle object.

NameTypeDescription
xnumber
ynumber
Returns:
TypeDescription
boolean

containsPoint (point)boolean

指定されたポイントがこの Rectangle オブジェクトで定義される矩形領域内にあるかどうかを判別します。
Determines whether the specified point is contained within
the rectangular region defined by this Rectangle object.

NameTypeDescription
pointPoint
Returns:
TypeDescription
boolean

containsRect (rect)boolean

rect パラメーターで指定された Rectangle オブジェクトがこの Rectangle オブジェクト内にあるかどうかを判別します。
Determines whether the Rectangle object specified by
the rect parameter is contained within this Rectangle object.

NameTypeDescription
rectRectangle
Returns:
TypeDescription
boolean

copyFrom (source_rect)void

すべての矩形データを、ソース Rectangle オブジェクトから、
呼び出し元の Rectangle オブジェクトにコピーします。
Copies all of rectangle data from
the source Rectangle object into the calling Rectangle object.

NameTypeDescription
source_rectRectangle
Returns:
TypeDescription
void

equals (to_compare)boolean

toCompare パラメーターで指定されたオブジェクトが
この Rectangle オブジェクトと等しいかどうかを判別します。
Determines whether the object specified
in the toCompare parameter is equal to this Rectangle object.

NameTypeDescription
to_compareRectangle
Returns:
TypeDescription
boolean

inflate (dx, dy)

Rectangle オブジェクトのサイズを、指定された量(ピクセル単位)だけ大きくします。
Increases the size of the Rectangle object by the specified amounts, in pixels.

NameTypeDescription
dxnumber
dynumber
Returns:
void

inflatePoint (point)void

Rectangle オブジェクトのサイズを大きくします。
Increases the size of the Rectangle object.

NameTypeDescription
pointPoint
Returns:
TypeDescription
void

intersection (to_intersect)Rectangle

toIntersect パラメーターで指定された Rectangle オブジェクトが
この Rectangle オブジェクトと交差する場合に、交差領域を Rectangle オブジェクトとして返します。
If the Rectangle object specified in the toIntersect parameter intersects
with this Rectangle object, returns the area of intersection as a Rectangle object.

NameTypeDescription
to_intersectRectangle
Returns:
TypeDescription
Rectangle

intersects (to_intersect)boolean

toIntersect パラメーターで指定されたオブジェクトが
この Rectangle オブジェクトと交差するかどうかを判別します。
Determines whether the object specified
in the toIntersect parameter intersects with this Rectangle object.

NameTypeDescription
to_intersectRectangle
Returns:
TypeDescription
boolean

isEmpty ()boolean

この Rectangle オブジェクトが空かどうかを判別します。
Determines whether or not this Rectangle object is empty.

Returns:
TypeDescription
boolean

offset (dx, dy)void

Rectangle オブジェクトの位置(左上隅で決定される)を、指定された量だけ調整します。
Adjusts the location of the Rectangle object,
as determined by its top-left corner, by the specified amounts.

NameTypeDescription
dxnumber
dynumber
Returns:
TypeDescription
void

offsetPoint (point)void

Point オブジェクトをパラメーターとして使用して、Rectangle オブジェクトの位置を調整します。
Adjusts the location of the Rectangle object using a Point object as a parameter.

NameTypeDescription
pointPoint
Returns:
TypeDescription
void

setEmpty ()void

Rectangle オブジェクトのすべてのプロパティを 0 に設定します。
Sets all of the Rectangle object's properties to 0.

Returns:
TypeDescription
void

setTo (x, y, width, height)void

Rectangle のメンバーを指定の値に設定します。
Sets the members of Rectangle to the specified values

NameTypeDescription
xnumber
ynumber
widthnumber
heightnumber
Returns:
TypeDescription
void

toString ()string

指定されたオブジェクトのストリングを返します。
Returns the string representation of the specified object.

Returns:
TypeDescription
string

union (to_union)Rectangle

2 つの矩形間の水平と垂直の空間を塗りつぶすことにより、
2 つの矩形を加算して新しい Rectangle オブジェクトを作成します。
Adds two rectangles together to create a new Rectangle object,
by filling in the horizontal and vertical space between the two rectangles.

NameTypeDescription
to_unionRectangle
Returns:
TypeDescription
Rectangle