https://github.com/basilfx/es6-geometry
Collection of immutable ES6 classes for simple 2D geometric objects and calculations.
https://github.com/basilfx/es6-geometry
Last synced: about 1 year ago
JSON representation
Collection of immutable ES6 classes for simple 2D geometric objects and calculations.
- Host: GitHub
- URL: https://github.com/basilfx/es6-geometry
- Owner: basilfx
- License: mit
- Created: 2016-03-15T10:39:55.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T20:20:56.000Z (over 3 years ago)
- Last Synced: 2025-03-24T16:55:07.843Z (about 1 year ago)
- Language: JavaScript
- Size: 2.98 MB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ES6-Geometry
Collection of immutable ES6 classes for simple 2D geometric objects and calculations.
[](https://travis-ci.org/basilfx/babel-plugin-transform-react-pure-components)
## Features
* Immutable classes.
* Statically typed using [Flow](https://flow.org).
* Arguments checking (zero overhead in production).
* Inspired by [Victor.js](http://victorjs.org/).
## Installation
`npm install --save es6-geometry`
## Usage
As an example:
```js
import { Point, Rectangle, Vector } from 'es6-geometry';
// A vector is an offset with a certain length (magnitude) and direction.
const vector = Vector.fromArray([100, 100]);
// A rectangle is defined by two points.
const rectangle = new Rectangle(
new Point(10, 10),
new Point(20, 20)
);
// Operations are immutable: rectangle remains untouched.
const newRectangle = rectangle.move(vector);
```
See the documentation for more information.
## Development
To (re)compile, run `npm run compile`. If you prefer to have a Webpack bundle, run `npm run bundle`.
Tests can be invoked using `npm run test`. Mocha is used as the test framework.
## License
See the `LICENSE.md` file (MIT).