Represents the size of a rectangular object with a given width and height.
Remarks
This is a convertible type that can be used with the following notation(s) in parameter lists, parameter objects or setters.
It is possible to specify an Array or plain Object to define the Size:
[20, 20] // width, height
{ width: 20, height: 20 }
Examples
// Create a new size
const size = new Size(10, 15)
console.log(
`The size has width ${size.width} and height ${size.height} representing an area of ${size.area}`,
)
// Create another size
const size2 = new Size(5, 17)
// Enlarge it by multiplying with a factor
const larger = size2.multiply(1.5)
// Make the first size only half as large
const half = size.multiply(0.5)
Type Details
- yFiles module
- core
See Also
Sample Graphs
Constructors
Properties
Methods
Determines whether the specified object is of type Size and has the same width and height as this instance.
Returns a hash code for this object.
Remarks
The hash code is a numeric value that can be used to treat this object as a key in a hash table or similar data structure.
Two objects that are considered equal must have the same hash code. However, the reverse does not hold and two objects having the same hash code don't have to be equal. Ideally, the hash code should be roughly uniformly-distributed to prevent hash tables from performing poorly. Calculating the hash code is also a potentially frequent operation and should therefore be fast.
Returns
- ↪number
- the hash code for this object
Creates a MutableSize instance with the current values of this instance.
Returns
- ↪MutableSize
- A new MutableSize instance whose properties have been initialized with the values of this instance.
Constants
The "infinite" size that has width and height set to Number.POSITIVE_INFINITY.
Static Methods
Creates a Size instance from the given size-like object by performing automatic type conversion.