Rect class

A Rect describes a rectangular two-dimensional area as a top-left point (x and y values) and a size (width and height values).

Use the static functions Rect.parse and Rect.stringify to convert to and from a standard string representation that is independent of the current locale.

When an instance of this class is the value of a property of a GraphObject class or Diagram or CommandHandler or a Tool class, you should treat the object as if it were frozen or read-only -- you cannot modify its properties. This allows the property to return a value without allocating a new instance. If you need to do your own calculations with the value, call #copy to make a new instance with the same values that you can modify.

Many methods modify the object's properties and then return a reference to "this" object. The only instance method to allocate a new object is the #copy method. The static Rect.parse method also allocates a new object. The #center, #position, and #size properties all allocate and return a new object.

The "Debug" implementation of this class is significantly slower than the "Release" implementation, mostly due to additional error checking.

You cannot inherit from this class.

Available Extensions
Annotations
  • @JS()
  • @staticInterop

Constructors

Rect([Object? x, Object? y, num? w, num? h])
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

alloc() Rect
allocAt(num x, num y, num w, num h) Rect
contains(num rx, num ry, num rw, num rh, num x, num y, [num? w, num? h]) bool
This static function indicates whether a Rect contains the given Point/Rect.
free(Rect temp) → void
intersects(num rx, num ry, num rw, num rh, num x, num y, num w, num h) bool
This static function indicates whether a Rect partly or wholly overlaps the given Rect.
intersectsLineSegment(num x, num y, num w, num h, num p1x, num p1y, num p2x, num p2y) bool
This static function is true if a rectangular area is intersected by a finite straight line segment.
parse(String str) Rect
This static function can be used to read in a Rect from a string that was produced by Rect.stringify.
stringify(Rect val) String
This static function can be used to write out a Rect as a string that can be read by Rect.parse.