Sg 2.9
Rectangle
Packages RSS
About
News
Gallery
Scripts
Tutorials
Download
Reference
Forum
Users
License
Twitter

A Rectangle specifies an area that is enclosed by it's top-left point (x, y), its width, and its height. It should not be confused with a rectangular path, it is not an item.

Constructors

    Parameters:
  • x: Number — optional
  • y: Number — optional
  • width: Number — optional
  • height: Number — optional

Creates a rectangle object from the passed points. These do not necessarily need to be the top left and bottom right corners, the constructor figures out how to fit a rectangle between them.

    Parameters:
  • point1: Point — The first point defining the rectangle
  • point2: Point — The second point defining the rectangle

Creates a new rectangle object from the passed rectangle object.

Operators

    Returns:
  • Boolean

Properties

x

The x position of the rectangle.

    Returns:
  • Number
y

The y position of the rectangle. This is the top coordinate if in the top-down coordinate system, bottom otherwise. See script.coordinateSystem for more information.

    Returns:
  • Number

The width of the rectangle.

    Returns:
  • Number

The height of the rectangle.

    Returns:
  • Number

Side Positions

The position of the left hand side of the rectangle. Note that this doesn't move the whole rectangle; the right hand side stays where it was.

    Returns:
  • Number
top

The top coordinate of the rectangle. Note that this doesn't move the whole rectangle: the bottom won't move.

    Returns:
  • Number

The position of the right hand side of the rectangle. Note that this doesn't move the whole rectangle; the left hand side stays where it was.

    Returns:
  • Number

The bottom coordinate of the rectangle. Note that this doesn't move the whole rectangle: the top won't move.

    Returns:
  • Number

Corner and Center Point Positions

The center point of the rectangle.

The top left point of the rectangle.

The top right point of the rectangle.

The bottom left point of the rectangle.

The bottom right point of the rectangle.

Functions

Clones the rectangle.

Returns true if the rectangle is empty, false otherwise

    Returns:
  • Boolean

Geometric Tests

Tests if the specified point is inside the boundary of the rectangle.

    Parameters:
  • point: Point — the specified point
    Returns:
  • Booleantrue if the point is inside the rectangle's boundary, false otherwise

Tests if the interior of the rectangle entirely contains the specified rectangle.

    Parameters:
  • rect: Rectangle — The specified rectangle
    Returns:
  • Booleantrue if the rectangle entirely contains the specified rectangle, false otherwise

Tests if the interior of this rectangle intersects the interior of another rectangle.

    Parameters:
  • rect: Rectangle — the specified rectangle
    Returns:
  • Booleantrue if the rectangle and the specified rectangle intersect each other, false otherwise

Boolean Operations

Returns a new rectangle representing the intersection of this rectangle with the specified rectangle.

    Parameters:
  • rect: Rectangle — The rectangle to be intersected with this rectangle
    Returns:
  • Rectangle — The largest rectangle contained in both the specified rectangle and in this rectangle.

Returns a new rectangle representing the union of this rectangle with the specified rectangle.

    Parameters:
  • rect: Rectangle — the rectangle to be combined with this rectangle
    Returns:
  • Rectangle — the smallest rectangle containing both the specified rectangle and this rectangle.

Adds a point to this rectangle. The resulting rectangle is the smallest rectangle that contains both the original rectangle and the specified point.

After adding a point, a call to contains with the added point as an argument does not necessarily return true. The contains method does not return true for points on the right or bottom edges of a rectangle. Therefore, if the added point falls on the left or bottom edge of the enlarged rectangle, contains returns false for that point.

AltStyle によって変換されたページ (->オリジナル) /