open-index/open-npm huggingface dataset:
npm package: 2d-bounding-box
Description: A simple 2d bounding box class. Intersections collisions, for use in 2d games
Author: Tschallacka
Latest version: 0.0.1

### simple 2d bounding box library

Note, this is still in alpha and may contain lots and lots of bugs.
Please make an issue if you encounter a bug.

To use it:

```javascript
let BoundingBox = require('2d-bounding-box');

let bb_create = new BoundingBox( min_x, min_y, max_x, max_y, [origin_type]);
```

Sometimes you already have an entity with a certain width and height, and you wish
to create a bounding box based on the dimensions of this creature without having to
calculate the correct positions yourself.

Important is for these calculations that you define where the origin of your 
entity is. Is it smack in the middle of the entity that decides the position 
or anywhere around the entity, bottom left for example. 

```javascript
let bb_from_entity = BoundingBox.create( origin_type, position_x, position_y, width, height);
```

For the origin type there are 9 possible options:

```javascript
BoundingBox.ORIGIN_CENTER;
BoundingBox.ORIGIN_LEFT_BOTTOM;
BoundingBox.ORIGIN_RIGHT_BOTTOM;
BoundingBox.ORIGIN_CENTER_BOTTOM;
BoundingBox.ORIGIN_LEFT_CENTER;
BoundingBox.ORIGIN_LEFT_TOP;
BoundingBox.ORIGIN_CENTER_TOP;
BoundingBox.ORIGIN_RIGHT_TOP;
BoundingBox.ORIGIN_RIGHT_CENTER;
```

If you need more options, you will have to calculate the offsets yourself and
instantiate the bounding box via the `new BoundingBox(...)` method.

Please see the [demo_basic_bb.html](demo/demo_basic_bb.html) file in the demo directory for examples.

If you wish to fiddle with the [demo_basic.js](demo/js/demo_basic.js) file recompile it with
`gulp less browserify` before refreshing the demo_basic_bb.html file.
npm package: 2d-brace
Description: browserify compatible version of the ace editor.
Author: Thorsten Lorenz
Latest version: 0.1.0

# brace

[原始仓库]https://github.com/thlorenz/brace.git

[业务改造仓库]https://github.com/kkYFL/2d-brace.git

## Installation

    npm install brace

## Example

```js
var ace = require('brace');
require('brace/mode/javascript');
require('brace/theme/monokai');

var editor = ace.edit('javascript-editor');
editor.getSession().setMode('ace/mode/javascript');
editor.setTheme('ace/theme/monokai');
```

Include the above as an **entry** in your browserify build, add a `<div id="javascript-editor"></div>` to your html page and
a JavaScript editor will appear.

This editor will show error/warning annotations if your browser supports WebWorkers
created via a blob URL (see testling support badge on top).

Please consult the [detailed example](https://github.com/thlorenz/brace/tree/master/example) for more information.


## Can I use it with TypeScript?

Yes, brace includes modular type definitions so you can do normal import statements and type safety checking
with TypeScript. The example above becomes:

```ts
import * as ace from 'brace';
import 'brace/mode/javascript';
import 'brace/theme/monokai';

const editor = ace.edit('javascript-editor');
editor.getSession().setMode('ace/mode/javascript');
editor.setTheme('ace/theme/monokai');
```

## Test

    npm explore brace
    npm test

## 分支
2d-branch 业务改造分支
npm package: 2d-canvas-image-particles
Description: A simple lightweight 2D particle system using Canvas.
Author: Arkounay
Latest version: 1.4.2

# 2D Particle System using Canvas

A simple lightweight 2D particle system using Canvas.

- Multiple particle systems can be bound to the same canvas
- Particles speed remain the same regardless of the refreshing rate
- Less than 10 KB
- Refresh rate independant : particles have the same behaviour between 60hz / 144hz monitors

[Check the demo page](https://arkounay.github.io/2D-Canvas-Image-Particles/)

## Usage
- Create a canvas 
- Import dist/2d-canvas-image-particles.min.js
- Create a new ParticleSystem : `new ParticleSystem(canvas_id, image_path, options);`

### Example
    <canvas id="js-canvas"></canvas>
    
    <script src="dist/2d-canvas-image-particles.min.js"></script>
    <script>
        new ParticleSystem('js-canvas', 'images/default-particle.png', {
            cursorMode: CursorMode.Zoom
        });
    </script>
    
You can check the [demo page](https://arkounay.github.io/2D-Canvas-Image-Particles/)'s sources for more examples.
You can also use an HTMLCanvasElement instead of an id.

### Usage with npm / Yarn

`npm install 2d-canvas-image-particles` or `yarn add 2d-canvas-image-particles`.

Then you can import it and use it

```js
import '2d-canvas-image-particles';
// ...
new ParticleSystem('id', 'images/default-particle.png', {
    cursorMode: CursorMode.Zoom
});
```
You will need to specify your own images.


### Options
    {
        maxParticles: number,
        velocityAngle: [min, max],
        speed: [min, max],
        rotationStartAngle: [min, max],
        cursorMode: CursorMode,     // (CursorMode.Bounce, CursorMode.Zoom, CursorMode.Light, CursorMode.Follow),
        rotationMode: RotationMode, // (RotationMode.None, RotationMode.Random, RotationMode.FollowVelocity)
        rotationSpeed: [min, max],
        rotationSpeedSizeScale: number
        minimumRotationSpeed: number // if min is negative and max is positive
        tints: [new Tint('#hexColor', opacity)],
        width: [min, max],
        height: [min, max],
        addOnClickNb: number,
        density: number,
        cursorRadius: number
    }


#### Cursor Modes
* CursorMode.**Bounce**: particles will bounce off the cursor.
* CursorMode.**Zoom**: the closer the cursor is, the bigger the particles are.
* CursorMode.**Light**: works with Tint. Particles will enlight when cursor is close.
* CursorMode.**Follow**: generates particles that are following the cursor.

#### Rotation Modes
* RotationMode.**None**
* RotationMode.**Random**
* RotationMode.**FollowVelocity**: Will follow the specified velocity (use it with _CursorMode.Bounce_ so the particles go back to their base velocity, this is used for the rain example)
    
## Build from sources
- `npm install`
- `npm run build`

## IE Support
- IE9+
npm package: 2d-canvas-supportor
Description: [code example](https://github.com/Min-hong-gi/canvas-manager-example)
Latest version: 1.1.7

# canvas 2D draw support
[code example](https://github.com/Min-hong-gi/canvas-manager-example)

## manager

Manages other objects and provides extended functionality.

## unit

Adds convenient unit operations.

## util

Make tedious calculations easy!

## helper

Helps with many other things
npm package: 2d-context
Description: grabs a new 2d canvas context
Author: Matt DesLauriers
Latest version: 1.3.0

# 2d-context

Grabs a CanvasRenderingContext2D, returning null if it doesn't exist. Similar to [webgl-context](https://nodei.co/npm/webgl-context/).

```js
var context = require('2d-context')()
var canvas = context.canvas
```

or

```js
var canvas = document.createElement('canvas')

var context = require('2d-context')({
    canvas: canvas,
    alpha: true,
    width: 256,
    height: 256    
})
```

## Usage

[![NPM](https://nodei.co/npm/2d-context.png)](https://nodei.co/npm/2d-context/)

#### `ctx = require('2d-context')([opt])`

Gets a new canvas context with optional parameters:

- `canvas` a canvas element to use, otherwise creates a new element
- `width` a width to set, otherwise no change
- `height` a height to set, otherwise no change
- other attributes are passed to the getContext call, like `alpha` and `storage`

You can then get a reference of the canvas element with `ctx.canvas`. 

## License

MIT, see [LICENSE.md](http://github.com/mattdesl/2d-context/blob/master/LICENSE.md) for details.
npm package: 2d-css-matrix-parse
Description: Module that parse a 2D css transform matrix into a 3x3 array. Also the module allow you get the matrix array from a specified element
Author: Iran Reyes
Latest version: 1.0.0

# 2d-css-matrix-parse

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

Converts css transform matrix to an 2D array of 6 values(3x3 matrix).

### Function parse

The `parse` function takes a matrix string representation like `matrix(1.1, 0, 0, 1.1, 0, 0)` and parse it to an array of floats.

```js
var matrixTransform = require('./index.js');

var matrix = "matrix(1.1, 0, 0, 1.1, 0, 0)";

matrixTransform.parse(matrix);
// -> [1.1, 0, 0, 1.1, 0, 0]
```

### Function fromElement

The `fromElement` function tries to help you to get the transform string matrix representation and let you pass instead of the string the HTML element itself.

```js
var matrixTransform = require('./index.js');

var element = document.createElement('div');
element.style.transform = "scale(1.5)";
document.body.appendChild(element);

matrixTransform.fromElement(element);
// -> [1.5,0,0,1.5,0,0]
```

**Important Note:**

Doesn't matter if the transform is not formatted as a matrix, in the above example we are setting to `element` the value `scale` instead of the current matrix.

## Usage

[![NPM](https://nodei.co/npm/2d-css-matrix-parse.png)](https://www.npmjs.com/package/2d-css-matrix-parse)

#### `matrixTransform.parse(string)`

It takes a string matrix representation and gives you an array.

#### `matrixTransform.fromElement(HtmlElement)`

It takes an Html Element and gives you an array with the element transformation.

## License

MIT, see [LICENSE.md](http://github.com/mattdesl/float-hsl2rgb/blob/master/LICENSE.md) for details.
npm package: 2d-generate-schema
Description: Effortlessly convert your JSON Object to JSON Schema, Mongoose Schema, or a Generic template for quick documentation / upstart.
Author: 2dfire.mistong.com
Latest version: 1.0.0

# Generate Schemas

Convert JSON Objects to MySQL Table Schema, JSON Schema, Mongoose Schema, ClickHouse Schema, Google BigQuery, or a Generic template for documentation, code generation, and more.

## NOTICE
2d-branch：个性化业务分支改造
基于原工程进行改造，主要解决当前场景原始库不满足的部分功能：如JOSN转化SCHEMA丢失Mock数据
npm package: 2d-grid-neighbors
Description: A library to get the values of neighbors of a grid as represented in a 2D array
Author: Alexander Schaller
Latest version: 1.0.2

# Grid neighbor finder

Library returns the neighbors of a grid represented as a 2D array **without** wrapping.

## Installing
```
npm i 2d-grid-neighbors
```

## Usage

Getting the **values** of the neighbors:
```typescript
const grid = [
    'a', 'b', 'c', 'd',
    'd', 'e', 'f', 'g',
    'h', 'i', 'j', 'k',
    'l', 'm', 'n', '0',
];

const getNeighborsForIndex = 5;
const result = getNeighbors(grid, getNeighborsForIndex);

// result: ['a', 'b', 'c', 'd', 'f', 'h', 'i', 'j']
```

If you need the indices, use ``getNeighborIndices()``.

This library works for a grid of any size provided that the grid has an equal number of columns and rows.
npm package: 2d-mat
Description: Create 2d matrices with superpower
Author: Vikram Jadhav
Latest version: 1.0.0

# 2d-mat
Create multidimensional matrix with superpower


## Install

```sh
$ npm install --save 2d-mat
```

## Example

```js
var Matrix = require('2d-mat');

var mat = new Matrix([1, 2], [3, 4]);

console.log(mat.indexAt(0, 1));
// -> 1

console.log(mat.set(0, 1, 100));
// -> [[100, 2], [3, 4]]

console.log(mat.transpose());
// -> [[1, 3], [2, 4]]

console.log(mat.size());
// -> [2, 2]

console.log(mat.createEmpty(2, 2));
// -> [[undefined, undefined], [undefined, undefined]]

mat.print();
// - > [[1, 2],
//      [3, 4]]
```



## API
`var Matrix = require('2d-mat');`

### new Matrix([list, ...]);
`This will create a matrix object`

#### list

Type: `array`

Accepts sequence of array where each array is length of row and the size of the array is length columns.

### The returned matrix is 0 indexed.

## License MIT

&copy; 2016 vikram. MIT License
npm package: 2d-math-utils
Description: 2D math utilities library
Latest version: 1.0.2

# 2D Math Utils

Common math utilities meant for working with 2D games and simulations. This library provides a collection of functions and classes to simplify working with 2D geometry, physics, and vector math.

[Live Demo](https://aaronbeall.github.io/2d-math-utils/)

## Installation

Install the library using npm:

```bash
npm install 2d-math-utils
```

## Example Usage

Here's an example of how to use the library to calculate the angle between two points and create a vector:

```typescript
import { angle, vector, point } from '2d-math-utils';

const pointA = { x: 0, y: 0 };
const pointB = { x: 3, y: 4 };

// Calculate the angle between two points
const angleBetween = angle.radiansBetweenPoints(pointA, pointB);
console.log(`Angle between points: ${angleBetween} radians`);

// Create a vector from the angle
const directionVector = vector.fromAngleRadians(angleBetween, 5);
console.log('Direction vector:', directionVector);

// Add the vector to pointA to get a new point
const newPoint = point.add(pointA, directionVector);
console.log('New point:', newPoint);
```

### TypeScript

This library is written in TypeScript, providing type definitions out of the box. 

```typescript
import { Point, Vector2d, Line, Circle, Rect } from '2d-math-utils';

const pointA: Point = { x: 0, y: 0 };
const pointB: Point = { x: 3, y: 4 };
```

### Alternative Import

You can also import specific modules directly if you prefer:

```typescript
import * as vector from "math-utils-2d/vector";
```

## Package Overview

### `angle`
Utilities for working with angles, including conversions between degrees and radians, and calculating angles between points.

### `vector`
Functions for creating and manipulating 2D vectors, such as addition, scaling, and rotation.

### `point`
Utilities for working with 2D points, including distance calculations and point transformations.

### `physics` 🧪
**_Experimental_**: Higher level physics-related utilities, including collision detection and basic physics simulations.

### `PhysicalBody`
A class representing a physical body with properties like position, velocity, and mass, useful for simulations. 

### `intersection`
Functions for calculating intersections between geometric shapes, such as lines and circles.
npm package: 2d-point
Description: 2D point object
Author: Peter Saxton
Latest version: 1.0.0

2D Point
========

##### Create and manipulate 2d point object.

Installation
============

Available as a node package. To install use

```
$ npm install 2d-point
```

Methods
=======

The following methods are available.
- [create](#user-content-create-pointcreatex-y)
- [add](#user-content-add-pointaddp-q)
- [multiply](#user-content-subtract-pointsubtractp-q)
- [subtract](#user-content-multiply-pointmultiplya-p)
- [fitWithin](#user-content-fitwithin-pointfitwithincontainer-vector)
- [fitOnce](#user-content-fitonce-pointfitwithincontainer-vector)

Use
===

#### create `Point.create(x, y)`
Creates a frozen 2D point. Defaults to origin coordinate if no arguments given.

```js
var Point = require('2d-point');

var pt = Point.create(2, 4);
// => {x: 2, y: 4}

var origin = Point.create();
// => {x: 0, y: 0}
```

#### add `Point.add(p, q)`
Vector add two points returning a new point.

```js
var p = Point.create(2, 3);
var q = Point.create(4, 5);

Point.add(p, q);
// => {x: 6, y: 8}
```

#### subtract `Point.subtract(p, q)`
Vector subtract two points returning a new point.

```js
var p = Point.create(2, 3);
var q = Point.create(4, 5);

Point.subtract(p, q);
// => {x: -2, y: -2}
```

#### multiply `Point.multiply(a, p)`
Vector scalar multiply a point returning a new point.

```js
var a = 3;
var p = Point.create(2, 3);

Point.multiply(a, p);
// => {x: 6, y: 9}
```

#### fitWithin `Point.fitWithin(container, vector)`
Scales vector to fit just within the bounding box of the container point.

```js
var container = Point.create(2, 2);
var landscape = Point.create(8, 4);
var portrait = Point.create(0.5, 1);

Point.fitWithin(container, landscape);
// => {x: 2, y: 1}

Point.fitWithin(container, portrait);
// => {x: 1, y: 2}
```

#### fitOnce `Point.fitWithin(container, vector)`
Scales vector to fit just within on dimension of the bounding box of the container point.

```js
var container = Point.create(2, 2);
var landscape = Point.create(8, 4);
var portrait = Point.create(0.5, 1);

Point.fitWithin(container, landscape);
// => {x: 4, y: 2}

Point.fitWithin(container, portrait);
// => {x: 2, y: 4}
```

## Considered extensions 

- fit within to deal with zeros ?
- negate ?
- Curry methods ?
- comparison methods ?
- conditionally make svg point if available ? No
- tests in browser ? No
- dot product ?
- convert to radial ? No
- furthest ?
- nearest ?
npm package: 2d-polygon-area
Description: compute the area of a 2d polygon
Author: Elijah Insua
Latest version: 1.0.0

# 2d-polygon-area

compute the area of a 2d polygon

# install 

`npm install 2d-polygon-area`

# use

```
var square = [
[0, 0],
[10, 0],
[10, 10],
[0, 10]
].reverse();

console.log(area(square));

// outputs: 100
```

# license

[MIT](LICENSE.txt)
npm package: 2d-polygon-boolean
Description: perform boolean operations on arbitrary polygons in 2d
Author: Elijah Insua
Latest version: 1.0.1

# polygon.clip

Implementation of the Greiner-Kai "efficient clipping of arbitrary polygons" [paper](http://www.inf.usi.ch/hormann/papers/Greiner.1998.ECO.pdf)

## install

`npm install 2d-polygon-boolean`

## use

### signature

`var polygons = polygonBoolean(array1, array2, mode)`

Where mode is the string `and` (intersect), `or` (union), `not` (cut)

`polygons` is an array of arrays of arrays

e.g
```javascript
  [
    [
      [0, 0],
      [0, 1],
      [1, 1]
    ]
  ]
```
### example

```javascript

var polygonBoolean = require('2d-polygon-boolean');

var subject = [
  [0, 0],
  [100, 0],
  [100, 100],
  [0, 100]
];

var clip = [
  [90, 90],
  [110, 90],
  [110, 110],
  [90, 110],
  [90, 90]
];


var union = polygonBoolean(subject, clip, 'or');
console.log('union results', union);

/*
union results [ [ [ 100, 90 ],
    [ 100, 0 ],
    [ 0, 0 ],
    [ 0, 100 ],
    [ 90, 100 ],
    [ 90, 110 ],
    [ 110, 110 ],
    [ 110, 90 ] ] ]
*/

var cut = polygonBoolean(subject, clip, 'not');
console.log('cut results', cut);

/*
cut results [ [ [ 100, 90 ],
    [ 100, 0 ],
    [ 0, 0 ],
    [ 0, 100 ],
    [ 90, 100 ],
    [ 90, 90 ] ] ]
*/

var intersect = polygonBoolean(subject, clip, 'and');
console.log('intersect results', intersect);

/*
intersect results [ [ [ 100, 90 ], [ 100, 100 ], [ 90, 100 ], [ 90, 90 ] ] ]
*/
```

# license

[MIT](LICENSE.txt)
npm package: 2d-polygon-contains-polygon
Description: test if a polygon completely contains another polygon
Author: Elijah Insua
Latest version: 1.0.0

# 2d-plolygon-contains-polygon

test if a polygon completely contains another polygon

this can useful when computing whether or not a polygon is a hole or island.

This library is not highly optimized, but should suit your needs for the general case.  Hit me up if it's not fast enough and I'll see what we can do.

## install

`npm install 2d-plolygon-contains-polygon`

## use

```javascript

var a = [
  [0, 0],
  [100, 0],
  [100, 100],
  [0, 100]
];

var b = [
  [20, 20],
  [80, 20],
  [80, 80],
  [20, 80]
];

console.log(contains(a, b));
// output: true
```

### api surface

__contains__(`container`, `contained`)

`container` and `container` are polygons represented by a 2d array (i.e. `[[x, y], [x, y], ]`)

returns `true` if `contained` is contained in `container`, and `false` otherwise.

## license

[MIT](LICENSE.txt)
npm package: 2d-polygon-self-intersections
Description: This library may not be fast, but it is robust. Robust in the fact that it will find all of the self-intersections in a polygon - minus of course shared endpoints.
Author: Elijah Insua
Latest version: 1.3.1

# 2d-polygon-self-intersections

find self-intersections in a 2d polygon

This library may not be fast, but it is robust. Robust in the fact that it will find all of the self-intersections in a polygon - minus of course shared endpoints.

You can expect a time complexity of O(n^2)

Why wouldn't we use [Bentley–Ottmann](http://en.wikipedia.org/wiki/Bentley%E2%80%93Ottmann_algorithm)?  We may in the future, but that is going to take some time and having a functional mechanism for detecting self-intersections is far superior to a non-existant one. The api won't have to change for this to happen.

## install

`npm install 2d-polygon-self-intersections`

## use

```javascript
var isects = require('2d-polygon-self-intersections');

var poly = [
  [0, 0],
  [10, 0],
  [0, 10],
  [10, 10]
];

var r = isects(poly);
console.log(r);
// outputs: [ [ 5, 5 ] ]
```

### api

__isects__(`polygon`[, `filterFn`])

* `polygon` - an array of 2 component arrays (i.e. a triangle `[[0, 0], [10, 0], [10, 10]]`) or an array of objects: `[{x:0, y:0}, {x:10, y:0}, {x:10, y:10}]`
* `filterFn` - a filter function called whenever an intersection is found: `filterFn`(`isect`, `start0`, `end0`, `start1`, `end1`, `unique`)
 * `isect` - current intersection (e.g. `[5, 5]`) - mutations in this array get collected
 * `index0` - index of the segment (e.g `1`)
 * `start0` - start of the first segment (e.g `[0, 5]`)
 * `end0` - start of the first segment (e.g `[10, 5]`)
 * `index0` - index of the segment (e.g `3`)
 * `start1` - start of the first segment (e.g `[5, 0]`)
 * `end1` - start of the first segment (e.g `[5, 10]`)
 * `unique` - boolean representing whether or not this intersection point has been seen before
 * __return__ `true` to collect and `false` to discard

__returns__ an empty array if no interesections or an array of 2 component arrays representing the intersection points. 

_NOTE_: this library assumes the polygon is closed, so manually adding the start point as the end point has no effect.

Also note that there are 2 intersections per crossing, this library by default will only report one - all intersections will be unique.  This behavior can be changed with the `filterFn`.

## license

[MIT](LICENSE.txt)
npm package: 2d-quadtree
Description: Quadtree for games and simulations
Author: Anthony Nardi
Latest version: 1.0.4

# How to set up and run
  - Clone the repository
  - Run this command in the root of the repository: 
```sh
    $ git clone https://github.com/anthony-nardi/2d-quadtree-js.git quadtree
    $ cd quadtree
    $ npm install && npm run dev
```
  - Navigate your browser to:
    -  localhost:8000/demos
    -  localhost:8000/demos/space_game

# How to use in your project
  - Install via npm: ```npm install 2d-quadtree ```
  - Require in your files: ``` var Quadtree = require('2d-quadtree'); ```

# Warning
  - This is my first published npm module...
  - There are no tests
  - There is no good looking documentation for you to read

## If you'd like to see any changes or have comments, feel free to email me.
npm package: 2d-quadtree-js
Description: Quadtree for games and simulations
Author: Anthony Nardi
Latest version: 1.0.3
Deprecated: This package has been renamed to 2d-quadtree. Install using 2d-quadtree instead.

# How to set up and run
  - Clone the repository
  - Run this command in the root of the repository: 
```sh
    $ git clone https://github.com/anthony-nardi/2d-quadtree-js.git quadtree
    $ cd quadtree
    $ npm install && npm run dev
```
  - Navigate your browser to:
    -  localhost:8000/demos
    -  localhost:8000/demos/space_game

# How to use in your project
  - Install via npm: ```npm install 2d-quadtree-js ```
  - Require in your files: ``` var Quadtree = require('2d-quadtree-js'); ```

# Warning
  - This is my first published npm module...
  - There are no tests
  - There is no good looking documentation for you to read

## If you'd like to see any changes or have comments, feel free to email me.