The rectangle this icon point exists inside/outside of.
The size of the rectangle.
The point that exists inside/outside the rectangle. This is in relative positioning to the rectangle.
StaticdefaultStatic offset to use when none is passed.
StaticdefaultStatic anchor to use when none is passed. Default value of 0.5 signifies the anchor stars in the middle.
StaticversionThe version of the module.
An object storing the position of the point that was set. This is the point on the rectangle.
It can be changed at runtime.
| |
| x |
| |
|_______|
Gets the new point's position inside a rectangle after taking pAngle into account.
The point inside/outside of the rectangle after rotating.
// Create a rectangle at the position of (0,0)
const rectangle = { x: 0, y: 0 };
// Make the dimensions of the rectangle 100x50
const bounds = { width: 100, height: 50 };
// Create a point at the top left corner of the rectangle
const point = { x: 1, y: 1 };
// Create an icon point that will track the point on this rectangle when it moves/rotates
const tlPoint = new IconPoint(rectangle, bounds, point);
// Verify the point is where it should be
console.log(tlPoint.getPoint()) // { x: 0, y: 0 } This shows that the point is at the position (0,0) which is the top left position of the rectangle
// Changing the position of the rectangle
rectangle.x += 100;
// Verify the point is where it should be after the rectangle changes positions
console.log(tlPoint.getPoint()) // { x: 100, y: 0 } This shows that the point has moved to the updated position of the rectangle
// Applying some offsets to the rectangle
const rectangleOffsets = { x: 25, y: 25 };
// Verify the point is where it should be after offsets have been applied to the rectangle
console.log(tlPoint.getPoint(undefined, rectangleOffsets)) // { x: 125, y: 25 } This shows that the point has moved to the updated position based on the offsets of the rectangle
// Applying some rotation to the rectangle
const angle = Math.PI;
// Verify the point is where it should be after rotating the rectangle by `angle`
console.log(tlPoint.getPoint(angle)) // {x: 200, y: 50.00000000000001} This shows that the point has moved to the updated position after the rectangle had been rotated by `angle`.
Updates the bounds of the rectangle this icon point exists inside/outside of.
The bounds to update the rectangle with.
Transforms the point.
The transform to transform the point to.
The IconPoint class
A point that exists inside/outside a virtual rectangle. The point's position inside/outside of the rectangle is maintained when the rectangle is rotated.
Example: Example usage of this class