open-index/open-npm huggingface dataset:
npm package: @jingwood/drawing2d
Description: Lightweight Javascript canvas 2D drawing library. Supports both immediate-mode rendering and 2D scene rendering.
Author: Jingwood
Latest version: 1.0.23

# js-drawing2d
Lightweight Javascript canvas 2D drawing library. Supports both immediate-mode rendering and 2D scene rendering.

# Installation

```shell
yarn add @jingwood/drawing2d
```

# Hello-world

```js
const renderer = new Renderer2D({
  canvasId: "myCanvas"
});

const scene = new Scene2D();

// create a rectangle object
const rect1 = new Rectangle2D();
rect1.origin.set(500, 300);
rect1.size.set(400, 300);

// rotate 45˚
rect1.angle = 45;

scene.add(rect1);

renderer.show(scene);
```
[See example code](test/test.js)

# API Objects

- **Renderer** - The rendering context.
- **Graphics** - Provides the immediate-mode rendering APIs.
- **Scene** - Collection of objects to be rendered.
- **Object** - An object instance inside scene to be rendered.

# Built-in geometry objects

- Line Segment
- Rectangle2D
- Ellipse2D
- Polygon2D
- Image2D

# License

Released under MIT license.

Copyright (c) 2015-2024 Jingwood, UNVELL Inc., All rights reserved.
npm package: @jingwood/graphics-math
Description: Math library for JavaScript 2D/3D graphics rendering.
Author: Jingwood
Latest version: 1.1.19

![npm](https://img.shields.io/npm/v/@jingwood/graphics-math.svg)

# js-graphics-math

Math library for JavaScript 2D/3D graphics rendering.

# Classes

The following classes available under [src](src) folder.

- [Vector2](src/vec2.js)
- [Vector3](src/vec3.js)
- [Matrix3](src/matrix3.js)
- [Matrix4](src/matrix4.js)
- [Quaternion](src/quaternion.js)
- [BoundingBox 2D](src/bbox2.js)
- [BoundingBox 3D](src/bbox3.js)
- KDTree for 2D points
- KDTree for 3D points
- KDTree for 3D triangles
- [OCTree for 3D triangles](src/spacetree.js)
- [Ray](src/ray.js)
- [Color3 (RGB)](src/color3.js)
- [Color4 (RGBA)](src/color4.js)

# Functions

Functions below available at [src/functions.js](src/functions.js).

## Base math functions

- clamp (1D/2D/3D)
- smoothstep
- angleToArc

## Distance measuring

- distancePointToPoint (2D/3D)
- distancePointToLine (2D)
- distancePointToLineSegment (2D)
- distancePointToRect (2D)
- distancePointToPolygon (2D)
- findNearestPointToLineSegement (2D)
- findNearestPointToPolygon (2D)

## Intersecting test

- lineIntersectsLine (2D)
- lineIntersectsRect (2D)
- lineIntersectsPolygon (2D)
- rectIntersectsRect (2D)
- rectIntersectsPolygon (2D)
- checkLineParallel

## Containing test

- rectContainsPoint (2D)
- triangleContainsPoint (2D)
- polygonContainsPoint (2D)
- polygonContainsRect (2D)
- calcPolygonArea (2D)

## Ray test

- rayIntersectsPlane (3D)
- rayIntersectsTriangle (3D)
- rayIntersectsSphere (3D)
- rayIntersectsBox (3D)

## Vertex interpolation

- **calcVertexInterpolation (3D)**
  Calculate the interpolated vertex coordinate on a specified point of a 3D triangle with vertex coordinates.

# Software uses this library

- tarumae-viewer - Optimized WebGL engine for Showcase application<br/>
  [https://github.com/bulbinc/tarumae-viewer](https://github.com/bulbinc/tarumae-viewer)

# Related Libraries

- cpp-graphics-module (A C++ version of this library)<br/>
  [https://github.com/jingwood/cpp-graphics-module](https://github.com/jingwood/cpp-graphics-module)

# License

Released under MIT License.

Copyright (C) Jingwood & unvell.com, all rights reserved.
npm package: @jingwood/input-control
Description: A lightweight Javascript library used to handle the input events of mouse, keyboard and touch control from end-user.
Author: Jingwood
Latest version: 1.1.1


# @jingwood/input-control

A lightweight Javascript library used to handle the input events of mouse, keyboard and touch control from end-user.

# Features

- Event registeriton and dispatching
- Receives and dispatches mouse, keyboard and touch events
- Provides and dispatches dragging events based on mouse and touch events
- Provides functions to check whether specified key is pressed
- Provides hotkey define feature (todo)

# Installation

```shell
yarn add @jingwood/input-control
```

# Hello-World

```js

// get the element to receive mouse, keyboard and touch events
const element = document.getElementById(myTargetElement);

// make sure the element can receive keyboard events
element.tabIndex = 0;
element.focus();

// create controller and use 'on' method to receive input events
const controller = new InputController(element);

// keyup event
controller.on("keyup" e => {
  if (e.keyCode === 32) {
    alert("Space key was pressed");
  }
});

// drag event
controller.on("drag", e => {
  console.log("mouse moving " + e.movement.x + ", " + e.movement.y);
});
```

# License

Released under MIT License

Copyright (C) 2015-2020 Jingwood, unvell.com, all rights reserved.