Bound is a subclass of Group that represents a rectangular boundary.
It includes some convenient properties such as x
, y
, bottomRight,
center, and
size`.
Gets or sets the length of the array. This is a number one higher than the highest element defined in an array.
The first Pt in this group
The second Pt in this group
The third Pt in this group
The forth Pt in this group
The last Pt in this group
The second-last Pt in this group
The third-last Pt in this group
The forth-last Pt in this group
Apply this group as a matrix and calculate matrix multiplication
a scalar number, an array of numeric arrays, or a Group of K Pts, each with N dimensions (K-rows, N-columns) -- or if transposed is true, then N Pts with K dimensions
(Only applicable if it's not elementwise multiplication) If true, then a and b's columns should match (ie, each Pt should have the same dimensions). Default is false
.
if true, then the multiplication is done element-wise. Default is false
.
If not elementwise, this will return a new Group with M Pt, each with N dimensions (M-rows, N-columns).
Zip a group of Pt. eg, [[1,2],[3,4],[5,6]] => [[1,3,5],[2,4,6]]
a default value to fill if index out of bound. If not provided, it will throw an error instead.
If true, find the longest list of values in a Pt and use its length for zipping. Default is false, which uses the first item's length for zipping.
Recalculate center
Recalculate based on bottom-right position and size
Recalculate based on center position and size
Recalculate based on top-left position and size
Recalculte size and center
Add scalar or vector values to this group's Pts.
a list of numbers, an array of number, or an object with {x,y,z,w} properties
Anchor all the Pts in this Group by its absolute position from a target Pt. (ie, add all Pt with the target anchor to get an absolute position). All the Pts' values will be updated.
a Pt, or a numeric index to target a specific Pt in this Group
Anchor all the Pts in this Group using a target Pt as origin. (ie, subtract all Pt with the target anchor to get a relative position). All the Pts' values will be updated.
a Pt, or a numeric index to target a specific Pt in this Group
Find the rectangular bounding box of this group's Pts.
a Group of 2 Pts representing the top-left and bottom-right of the rectangle
Find the centroid of this group's Pts, which is the average middle point.
Clone this bound and return a new one
Divide this group's Pts over scalar or vector values (as element-wise)
a list of numbers, an array of number, or an object with {x,y,z,w} properties
Update each Pt in this Group with a Pt function
string name of an existing Pt function. Note that the function must return Pt.
arguments for the function specified in ptFn
Initiate the bound's properties.
Insert a Pt into this group
Another group of Pts
the index position to insert into
Get an interpolated point on the line segments defined by this Group
a value between 0 to 1 usually
Get all the line segments (ie, edges in a graph) of this group
Move every Pt's position by a specific amount. Same as add
.
a list of numbers, an array of number, or an object with {x,y,z,w} properties
Move the first Pt in this group to a specific position, and move all the other Pts correspondingly
a list of numbers, an array of number, or an object with {x,y,z,w} properties
Multiply scalar or vector values (as element-wise) with this group's Pts.
a list of numbers, an array of number, or an object with {x,y,z,w} properties
Create an operation using this Group, passing this Group into a custom function's first parameter. See the Op guide for details.
For example: let myOp = group.op( fn ); let result = myOp( [1,2,3] );
any function that takes a Group as its first parameter
a resulting function that takes other parameters required in fn
This combines a series of operations into an array. See op()
for details.
For example: let myOps = pt.ops([fn1, fn2, fn3]); let results = myOps.map( (op) => op([1,2,3]) );
an array of functions for op
an array of resulting functions
Reflect this group's Pts along a 2D line. Default anchor point is the first Pt in this group.
a Group of 2 Pts that defines a line for reflection
optional axis such as "yz" to define a 2D plane of reflection
Like Array's splice function, with support for negative index and a friendlier name.
start index, which can be negative (where -1 is at index 0, -2 at index 1, etc)
number of items to remove
The items that are removed.
Rotate this group's Pt from an anchor point in 2D. Default anchor point is the first Pt in this group.
rotate angle
optional anchor point to scale from
optional string such as "yz" to specify a 2D plane
Split this group into an array of sub-group segments
number of Pts in each segment
forward-step to take
if true
, always go through the array till the end and loop back to the beginning to complete the segments if needed
Sort this group's Pts by values in a specific dimension
dimensional index
if true, sort descending. Default is false (ascending)
Split this Group into an array of sub-groups
number of items per sub-group
forward-steps after each sub-group
if true
, always go through the array till the end and loop back to the beginning to complete the segments if needed
Subtract scalar or vector values from this group's Pts.
a list of numbers, an array of number, or an object with {x,y,z,w} properties
Get a string representation of this group
If the Group elements are changed, call this function to update the Bound's properties. It's preferable to change the topLeft/bottomRight etc properties instead of changing the Group array directly.
Zip one slice of an array of Pt. Imagine the Pts are organized in rows, then this function will take the values in a specific column.
a default value to fill if index out of bound. If not provided, it will throw an error instead.
Determines whether all the members of an array satisfy the specified test.
A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array.
Returns the elements of an array that meet the condition specified in a callback function.
A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.
Performs the specified action for each element in an array.
A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
Create a Bound from a ClientRect object.
an object has top/left/bottom/right/width/height properties
a Bound object
Returns the index of the first occurrence of a value in an array.
The value to locate in the array.
The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
Adds all the elements of an array separated by the specified separator string.
A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
Returns the index of the last occurrence of a specified value in an array.
The value to locate in the array.
The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array.
Calls a defined callback function on each element of an array, and returns an array that contains the results.
A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
Calls a defined callback function on each element of an array, and returns an array that contains the results.
A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
Calls a defined callback function on each element of an array, and returns an array that contains the results.
A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
Calls a defined callback function on each element of an array, and returns an array that contains the results.
A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
Calls a defined callback function on each element of an array, and returns an array that contains the results.
A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
Removes the last element from an array and returns it.
Appends new elements to an array, and returns the new length of the array.
New elements of the Array.
Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
Reverses the elements in an Array.
Removes the first element from an array and returns it.
Returns a section of an array.
The beginning of the specified portion of the array.
The end of the specified portion of the array.
Determines whether the specified callback function returns true for any element of an array.
A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array.
Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
The zero-based location in the array from which to start removing elements.
The number of elements to remove.
Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
The zero-based location in the array from which to start removing elements.
The number of elements to remove.
Elements to insert into the array in place of the deleted elements.
Returns a string representation of an array.
Inserts new elements at the start of an array.
Elements to insert at the start of the Array.
Generated using TypeDoc
Bound is a subclass of Group that represents a rectangular boundary. It includes some convenient properties such as
x
,y
, bottomRight,
center, and
size`.