Point essential
Represents a point in a buffer in row/column coordinates.
Every public method that takes a point also accepts a point-compatible Array. This means a 2-element array containing Numbers representing the row and column. So the following are equivalent:
1212# Point compatible Array
Properties
Construction
.fromObject(object, copy)
Convert any point-compatible object to a Point.
Argument | Description |
---|---|
object |
This can be an object that's already a Point, in which case it's simply returned, or an array containing two Numbers representing the row and column. |
copy |
An optional boolean indicating whether to force the copying of objects that are already points. |
Return values |
---|
Returns: A Point based on the given object. |
Comparison
Operations
::freeze()
Makes this point immutable and returns itself.
Return values |
---|
Returns an immutable version of this Point |
::traverse(other)
Build and return a new Point by traversing the rows and columns specified by the given point.
This method differs from the direct, vector-style addition offered by ::translate. Rather than adding the rows and columns directly, it derives the new point from traversing in "typewriter space". At the end of every row traversed, a carriage return occurs that returns the columns to 0 before continuing the traversal.
Argument | Description |
---|---|
other |
A Point providing the rows and columns to traverse by. |
Return values |
---|
Returns a Point. |
Conversion
::toArray()
Return values |
---|
Returns an array of this point's row and column. |
::serialize()
Return values |
---|
Returns an array of this point's row and column. |
::toString()
Return values |
---|
Returns a string representation of the point. |