- Accurately detects collision and intersection points between 2D shapes
- Optimized for high-performance and reliability
- Supports collision and intersection calculations for lines, rectangles, circles, and triangles
- User-friendly API with comprehensive documentation and examples
- Designed to be extensible, allowing developers to add support for additional shapes and algorithms in the future
You can install @manojtgn/collision2djs using npm:
npm install @manojtgn/collision2djs
To use the package, import it into your code and call the relevant function(s) for the shapes you want to detect collisions or intersections for.
Here's an example of how to detect a collision between two rectangles:
const { Rect, Circle } = require("@manojtgn/collision2djs");
const circle = new Circle(400, 400, 25);
const rect = new Rect(10,10,100,100);
addShape(rect);addShape(circle);
if (circle.isCollideWith(rect)) {
console.log("Colliding!");
} else {
console.log("Not Colliding.");
}
Please refer to the package's documentation for more details on how to use it.
The full documentation for @manojtgn/collision2djs can be found in the docs folder of the package's GitHub repository.
Contributions are welcome! Please see our contribution guidelines for more information on how to get started.
@manojtgn/collision2djs is licensed under the MIT License.