point.js
doc imports:
-
pointpen.js
-
compass.js
-
center.js
-
point-content.js
-
pointdraw.js
-
relative-xy.js
-
pointcast.js
-
point.js
Meta Data
| dependencies | () |
| unused_keys | ('title',) |
| unknown_keys | ('doc_readme', 'doc_loader', 'doc_content', 'files', 'categories', 'doc_imports') |
| doc_readme | ['point/readme.md'] |
| doc_loader | ['loadDocInfo'] |
| doc_content | ['point/*.md'] |
| files | ['', 'relative-xy.js', 'pointcast.js'] |
| categories | ['primary', 'point'] |
| doc_imports | ['point'] |
| filepath_exists | True |
| path | point.js |
| filepath | point.js |
| clean_files | ('relative-xy.js', 'pointcast.js') |
The entire library is focused upon the single 2D Point.
Getting Started
A Point accepts many properties, or an object.
Default properties:
// accepts: (x, y, radius, rotation)
new Point(100, 200, 20, 90)
Or array of the same four attributes
// accepts: (x, y, radius, rotation)
new Point([100, 200, 20, 90])
The same properties may be applied through an object:
new Point({
x: 100
, y: 200
, radius: 20
, rotation: 90
})
Anything can be applied to the point instance directly:
let point = new Point
point.x = 100
point.y = 200
point.radius = 20
point.rotation = 90
-
VariableDeclaration
-
VariableDeclaration
-
VariableDeclaration
-
ExpressionStatement
:
dict_keys(['type', 'expression', 'pos']) -
ClassDeclarationclass
Positionable
extends Relativeclass comments:The base `Positionable` class provides functionality for plotting the X and Y of an entity. This includes any fundamental methods such as `multiply()`.-
dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])ABOVE X method Multiline - touching.Set the _X_ (horizontal | latitude | across) value of the positionable. From cooridinate top left `(0,0)`` point.x = 100 If the given value is a function, the function is called immediately, with _this_ positionable as the first argument. stage.center.x = (p)=>200
-
dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])Set the _Y_ (vertical | height | longtitude) value of the positionable. From cooridinate top left `(0,0)`` point.x = 100 If the given value is a function, the function is called immediately, with _this_ positionable as the first argument. stage.center.x = (p)=>200
-
dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])Set the given `key`, `value`, assuming the given key is a "special" string, such as "radius". This method is called by the special getters and setters for this point: const point = new Point(100,300, 20) point.setSpecial('radius', 55) Synonymous to: point.radius = 55
-
dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])A callback executed by setSpecial when a "special" property is called. If a method on this point exists matching the _set method_ pattern, the method is called with the given `value`: class MyPoint extends Point { radiusSet(value) { console.log('New Radius value is', value) } }
-
dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])Return a stored _special_ value given a `key`. If the `relIndex` property is not None, the relative value found at the index (within this points relative data Array), add the stashed relative value to the result. const point = new Point(100,300, 20) point.getSpecial('radius', 2) // 20 if a default value is given, and the internal `key` value does not exist, return the default value: point.getSpecial('banana', 'yellow') 'yellow'
-
dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])Returns a new point, with the XY set at the point that is `offset` times the distance from the current point to the other point. this function is also `lerp` for linear interpolation
ClassDeclarationclassRotation
extends Positionableclass comments:Set the rotation in degrees (0 to 360). If `this.modulusRotate` is `true` (default), the given value is fixed through modulus 360 point.rotation = 600 // 240 point.rotation += 1 // 241 To set the rotation (degrees) whilst accounting for the _UP_ vector, consider the `rotate()` method.-
dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])Set the rotation in degrees (0 to 360). If `this.modulusRotate` is `true` (default), the given value is fixed through modulus 360 point.rotation = 600 // 240 point.rotation += 1 // 241 To set the rotation (degrees) whilst accounting for the _UP_ vector, consider the `rotate()` method.
-
dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])Rotate the point such that the angle relative to the `otherPoint` is `0`, essentially _looking at_ the other point. point.lookAt(otherPoint) Return the angle in radians.
-
dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])Return the calculated theta value through atan2 and built to offload some of the boring. The _direction_ denotes the "gravity" pull. Generally this is `DOWN`. Synonymous to: let theta = Math.atan2(point.y, point.x); let theta = Math.atan2(point.y - other.y, point.x - other.x); let theta = Math.atan2(point.y - other.y, point.x - other.x) - DOWN;
ClassDeclarationclassTooling
extends Rotationclass comments:str such as this["rotation"]-
dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])return a point relative from _this_ point towards the `other`, offset by the given number `offset` value. The `pointIndex` (default 0) identifies from which point [this, other] to offset.
ClassDeclarationclassPoint
extends Toolingclass comments:The `Point` is the primary class for manipulating XY 2D points. Arguments: new Point(100, 200) Object | Array: new Point({x: 100, y: 200}) new Point([100, 200]) Properties: point = new Point point.x = 100 point.y = 200-
dict_keys(['kind', 'word', 'static', 'computed', 'is_symbol', 'value', 'type', 'comments', 'pos'])A new point accepts arguments, an object, or an array. By default the `Point` accepts up to four arguments new Point(x, y, radius, rotation) The same properties may be supplied as a single `Array`: new Point([x, y, radius, rotation]) If the given object is an `object`, we can assign properties immediately: point = new Point({x, y, radius, rotation, other:100}) point.other // 100
ExpressionStatement:
dict_keys(['type', 'expression', 'pos'])ExpressionStatement:
dict_keys(['type', 'expression', 'pos'])ExpressionStatement:
dict_keys(['type', 'expression', 'pos']) -