Skip to content

HarryStevens/geometric

Repository files navigation

Geometric.js

Geometric.js logo

CI npm version npm downloads GitHub stars license

Geometric.js is a JavaScript library for working with points, lines, polygons, and angles. It uses plain JavaScript arrays for geometry primitives, includes TypeScript declarations for editor autocomplete and type checking, and works in modern browsers and Node.js.

Documentation and interactive examples are on the Geometric.js website.

Install

npm install geometric -S
import * as geometric from "geometric";

Why Geometric.js?

Geometric.js keeps geometry simple. A point is an [x, y] array, a line is an array of two points, and a polygon is an array of points.

const point = [0, 0];
const line = [
  [0, 0],
  [10, 10],
];
const polygon = [
  [0, 0],
  [10, 0],
  [10, 10],
  [0, 10],
];

There are no custom classes to instantiate and no special data structures to learn. The values you pass into Geometric.js are the same values you can serialize, inspect, draw to SVG or Canvas, store in JSON, or pass to other JavaScript code.

Development

pnpm install
pnpm test

The test suite builds the package, runs runtime tests, and checks the TypeScript declarations.

About

A JavaScript library for doing geometry.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors