Size
Source: size.js:14
Immutable Size class. Warning: the input array is NOT cloned, modifying it will modify the index values.
Constructor
new Size(values: Array.<number>): SizeParameters
values(Array.<number>) — The size values.
Instance Methods
get(i: number): number
Get the size value at the given array index.
Parameters
i(number) — The index to get.
Returns
number— The value.
length(): number
Get the length of the index.
Returns
number— The length.
toString(): string
Get a string representation of the size.
Returns
string— The Size as a string.
getValues(): Array.<number>
Get the values of this index.
Returns
Array.<number>— The array of values.
moreThanOne(dimension: number): boolean
Check if a dimension exists and has more than one element.
Parameters
dimension(number) — The dimension to check.
Returns
boolean— True if the size is more than one.
canScroll3D(viewOrientation?: Matrix33): boolean
Check if the associated data is scrollable in 3D.
Parameters
viewOrientation(Matrix33, optional) — The orientation matrix.
Returns
boolean— True if scrollable.
canScroll(viewOrientation: Matrix33): boolean
Check if the associated data is scrollable: either in 3D or in other directions.
Parameters
viewOrientation(Matrix33) — The orientation matrix.
Returns
boolean— True if scrollable.
getDimSize(dimension: number, start?: number): number
Get the size of a given dimension.
Parameters
dimension(number) — The dimension.start(number, optional) — Optional start dimension to start counting from.
Returns
number— The size.
getTotalSize(start?: number): number
Get the total size.
Parameters
start(number, optional) — Optional start dimension to base the offset on.
Returns
number— The total size.
equals(rhs: Size): boolean
Check for equality.
Parameters
rhs(Size) — The object to compare to.
Returns
boolean— True if both objects are equal.
isInBounds(index: Index, dirs: Array.<number>): boolean
Check that an index is within bounds.
Parameters
index(Index) — The index to check.dirs(Array.<number>) — Optional list of directions to check.
Returns
boolean— True if the given coordinates are within bounds.
indexToOffset(index: Index, start?: number): number
Convert an index to an offset in memory.
Parameters
index(Index) — The index to convert.start(number, optional) — Optional start dimension to base the offset on.
Returns
number— The offset or -1 if out of bounds.
offsetToIndex(offset: number): Index
Convert an offset in memory to an index.
Parameters
offset(number) — The offset to convert.
Returns
Index— The index.
get2D(): Scalar2D
Get the 2D base of this size.
Returns
Scalar2D— The 2D base [0,1] as {x,y}.
normalisePoint(point: Point, extra?: Point): Point
Normalise a point to this size.
Parameters
point(Point) — The input point.extra(Point, optional) — Optional point used to fill extra dimensions.
Returns
Point— The result point.
normaliseIndex(index: Index, extra?: Index): Index
Normalise an index to this size.
Parameters
index(Index) — The input index.extra(Index, optional) — Optional index used to fill extra dimensions.
Returns
Index— The result point.