@flatten-js/core
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -5,4 +5,4 @@ // Type definitions for flatten-js library v0.6 | ||
import IntervalTree = require("flatten-interval-tree"); | ||
/// <reference types="flatten-interval-tree" /> | ||
import IntervalTree = require("@flatten-js/interval-tree"); | ||
/// <reference types="@flatten-js/interval-tree" /> | ||
@@ -22,2 +22,4 @@ declare namespace Flatten { | ||
type Comparable = any; // any object that implements operators '<' and '==' and 'max' | ||
type Value = any; | ||
interface Interval { | ||
@@ -35,2 +37,5 @@ low: Comparable; | ||
output() : any; | ||
comparable_max(arg1: Comparable, arg2: Comparable) : Comparable; | ||
comparable_less_than(arg1: Comparable, arg2: Comparable ) : boolean; | ||
} | ||
@@ -84,3 +89,3 @@ | ||
class Box { | ||
class Box implements Interval { | ||
constructor(xmin?: number, ymin?: number, xmax?: number, ymax?: number); | ||
@@ -101,11 +106,14 @@ | ||
// public methods | ||
clone(): Box; | ||
equal_to(box: Box): boolean; | ||
intersect(box: Box): boolean; | ||
less_than(box: Box): boolean; | ||
clone(): Interval; | ||
equal_to(box: Interval): boolean; | ||
intersect(box: Interval): boolean; | ||
less_than(box: Interval): boolean; | ||
merge(box: Box): Box; | ||
not_intersect(box: Box): boolean; | ||
not_intersect(box: Interval): boolean; | ||
output() : void; | ||
set(xmin: number, ymin: number, xmax: number, ymax: number): void; | ||
svg(attrs?: SVGAttributes): string; | ||
comparable_max(arg1: Comparable, arg2: Comparable) : Comparable; | ||
comparable_less_than(arg1: Comparable, arg2: Comparable ) : boolean; | ||
} | ||
@@ -112,0 +120,0 @@ |
{ | ||
"name": "@flatten-js/core", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Javascript library for 2d geometry", | ||
@@ -24,3 +24,2 @@ "main": "dist/main.cjs.js", | ||
"geometry", | ||
"computational geometry", | ||
"2d", | ||
@@ -34,3 +33,4 @@ "algorithms", | ||
"point in polygon", | ||
"spatial search" | ||
"spatial search", | ||
"affine transformations" | ||
], | ||
@@ -62,4 +62,4 @@ "author": "Alex Bol <alexbol99@gmail.com> (https://github.com/alexbol99)", | ||
"dependencies": { | ||
"flatten-interval-tree": "^0.3.6" | ||
"@flatten-js/interval-tree": "^1.0.4" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
[![npm version](https://badge.fury.io/js/flatten-js.svg)](https://badge.fury.io/js/flatten-js) | ||
[![npm version](https://badge.fury.io/js/%40flatten-js%2Fcore.svg)](https://badge.fury.io/js/%40flatten-js%2Fcore) | ||
[![Build Status](https://travis-ci.org/alexbol99/flatten-js.svg?branch=master)](https://travis-ci.org/alexbol99/flatten-js) | ||
@@ -7,20 +7,25 @@ [![Coverage Status](https://coveralls.io/repos/github/alexbol99/flatten-js/badge.svg?branch=master)](https://coveralls.io/github/alexbol99/flatten-js?branch=master) | ||
**This version is Beta** | ||
FlattenJS is a javascript library (about 50 Kb minified) for manipulating abstract geometrical shapes like point, vector, line, segment, | ||
**flatten-js** is a javascript library for manipulating abstract geometrical shapes like point, vector, line, segment, | ||
circle, arc and polygon. Shapes may be organized into Planar Set - searchable container which support spatial queries. | ||
FlattenJS provides a lot of useful methods and algorithms like finding intersections, checking inclusion, calculating distance, apply | ||
**flatten-js** provides a lot of useful methods and algorithms like finding intersections, checking inclusion, calculating distance, apply | ||
transformations and more. | ||
Polygon model is rather comprehensive and supports multi polygons with many islands and holes. Edges of polygon may be circular arcs or segments. | ||
Some algorithms like [Boolean Operations](https://github.com/alexbol99/flatten-boolean-op) and [Offset](https://github.com/alexbol99/flatten-offset), | ||
implemented in separate packages. | ||
This library designed to work in any modern browser as well as under nodejs. | ||
It is written in plain javascript with es6 syntax elements. | ||
You can use es5 precompiled bundled package (added in v0.6.2) if you need to support old browsers. | ||
Library consists of several packages, published under scope **@flatten-js/** (will be more): | ||
| Name | Description | | ||
| ------------- |:-------------:| | ||
| [@flatten-js/core](https://www.npmjs.com/package/@flatten-js/core) | Basic classes and operations | ||
| [@flatten-js/interval-tree](https://www.npmjs.com/package/@flatten-js/interval-tree) | Interval binary search tree | ||
| [@flatten-js/boolean-op](https://www.npmjs.com/package/@flatten-js/boolean-op) | Boolean operations | ||
NOTE: Package [flatten-js](https://www.npmjs.com/package/flatten-js) is not supported and will be deprecated soon. | ||
Read documentation for each package to understand which dependencies should be installed with the package | ||
Library provides different entry points suitable for various targets. | ||
TypeScript users may take advantage of static type checking with typescript definition file index.d.ts included into the package. | ||
FlattenJS does not concern too much about visualization. | ||
**flatten-js** does not concern too much about visualization. | ||
Anyway, all objects have svg() methods, that returns a string which may be inserted into SVG container. | ||
@@ -30,59 +35,33 @@ This works pretty well together with [d3js](https://d3js.org/) library. But it is definitely possible to create bridges to other graphic libraries. | ||
The best way to start working with FlattenJS is to use awesome [Observable](https://beta.observablehq.com/) javascript interactive notebooks. | ||
There are several FlattenJS tutorials published in Observable Notebooks, see below. | ||
There are several **flatten-js** tutorials published in Observable Notebooks, see below. | ||
Full documentation may be found [here](https://alexbol99.github.io/flatten-js/index.html) | ||
Full documentation may be found here: [https://alexbol99.github.io/flatten-js/index.html](https://alexbol99.github.io/flatten-js/index.html) | ||
## Installation | ||
npm install --save flatten-js | ||
npm install --save @flatten-js/core | ||
## Usage | ||
Package may be required in different ways: | ||
##### Require as es6 module: | ||
```javascript | ||
import Flatten from 'flatten-js'; | ||
import {Point, Vector, Circle, Line, Segment, Arc, Box, Polygon, Matrix, PlanarSet} from '@flatten-js/core'; | ||
``` | ||
##### Require as CommonJS package (nodejs) | ||
It is possible to import Flatten namespace as default import, and then destruct all classes from it. | ||
```javascript | ||
const Flatten = require('flatten-js'); | ||
import Flatten from '@flatten-js/core' | ||
const {Point, Vector, Circle, Line, Segment, Arc, Box, Polygon, Matrix, PlanarSet} = Flatten; | ||
``` | ||
##### Require minified package precompiled into UMD format. | ||
[Observable](https://beta.observablehq.com/) notebooks requires this format. | ||
Some classes have shortcuts to avoid annoying *new* constructor: | ||
```javascript | ||
const Flatten = require('flatten-js.umd.min.js'); | ||
import {point, vector, circle, line, segment, arc, ray, matrix} from '@flatten-js/core'; | ||
``` | ||
##### Require precompiled to es5 package in Commonjs2 format. | ||
```javascript | ||
import Flatten from "flatten-js/dist/flatten.commonjs2" | ||
``` | ||
This package is not minified. | ||
This is the way you have to consume the package for [React](https://reactjs.org/) library, at least when you use | ||
[create-react-library](https://github.com/facebook/create-react-app) starter kit: | ||
``` | ||
"" | ||
Some third-party packages don't compile their code to ES5 before publishing to npm. | ||
This often causes problems in the ecosystem because neither browsers (except for most modern versions) | ||
nor some tools currently support all ES6 features. | ||
We recommend to publish code on npm as ES5 at least for a few more years. | ||
"" | ||
``` | ||
You can see example of **FlattenJS + React** usage in [flatten-react-demo](https://github.com/alexbol99/flatten-react-demo) project. | ||
It is live [here](https://alexbol99.github.io/flatten-react-demo/). | ||
Just clone it from the GitHub, install dependencies and start working using *npm start* or | ||
compile it to production using *npm run build*. | ||
## Example | ||
After module required, you can create some construction: | ||
After module imported, it is possible to create some construction: | ||
```javascript | ||
// extract object creators | ||
let {point, circle, segment} = Flatten; | ||
import {point, circle, segment} from '@flatten-js/core'; | ||
@@ -95,4 +74,5 @@ // make some construction | ||
``` | ||
You may test the code above also in [NPM RunKit](https://npm.runkit.com/flatten-js) | ||
You may test the code above also in [NPM RunKit](https://npm.runkit.com/@flatten-js/core) | ||
## Tutorials | ||
@@ -107,4 +87,4 @@ | ||
Follow me on [Twitter](https://twitter.com/alex_bol_) | ||
Follow me on Twitter [@alex_bol_](https://twitter.com/alex_bol_) | ||
"use strict"; | ||
// let IntervalTree = require('flatten-interval-tree'); | ||
import IntervalTree from 'flatten-interval-tree'; | ||
import IntervalTree from '@flatten-js/interval-tree'; | ||
import Flatten from '../flatten'; | ||
@@ -6,0 +6,0 @@ |
@@ -146,3 +146,3 @@ /** | ||
maximal_val(box1, box2) { | ||
comparable_max(box1, box2) { | ||
// return pt1.lessThan(pt2) ? pt2.clone() : pt1.clone(); | ||
@@ -152,3 +152,3 @@ return box1.merge(box2); | ||
val_less_than(pt1, pt2) { | ||
comparable_less_than(pt1, pt2) { | ||
return pt1.lessThan(pt2); | ||
@@ -155,0 +155,0 @@ } |
@@ -8,3 +8,3 @@ /** | ||
import Flatten from '../flatten'; | ||
import IntervalTree from 'flatten-interval-tree'; | ||
import IntervalTree from '@flatten-js/interval-tree'; | ||
@@ -11,0 +11,0 @@ /** |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4532668
174
22663
87
+ Added@flatten-js/interval-tree@1.1.3(transitive)
- Removedflatten-interval-tree@^0.3.6
- Removedflatten-interval-tree@0.3.6(transitive)