Implements
- I
Remarks
Examples
The following example shows a few ways to use Size:
// 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)Members
Show:
Constructors
Properties
Negative values for the height indicate an empty size.
readonlyfinal
Property Value
The height.
Implements
ISize.heightDefined in
ISize.isEmptyNegative values for the width indicate an empty size.
readonlyfinal
Property Value
The width.
Implements
ISize.widthMethods
Determines whether the specified object is of type Size and has the same width and height as this instance.
Determines whether the specified object is of type Size and has the same width and height as this instance.
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.
final
Return Value
- number
- the hash code for this object
final
Parameters
- factor: number
- The factor to multiply the width and height by.
Return Value
- Size
- A new size that has the width and height multiplied by the factor.
Creates a MutableSize instance with the current values of this instance.
Creates a MutableSize instance with the current values of this instance.
final
Return Value
- MutableSize
- A new MutableSize instance whose properties have been initialized with the values of this instance.