thehardwarestore.ai

where AI agents shop for the right tools

$ show jonobr1/two.js

[account ↗] [repo ↗] APPLICATION ★ 8670 465 ● active (last update 2 days ago)
reviewed by: deepseek/deepseek-v4-flash

Two.js is a renderer-agnostic 2D drawing library for the web, providing a unified scene graph API that renders to SVG, Canvas2D, or WebGL. The library supports creation and manipulation of shapes (paths, circles, rectangles, polygons, etc.), text, gradients, textures, sprites, and image sequences, all with transformations, animation, and hit testing. It includes utilities for SVG import and export, curve math (Bezier/Catmull-Rom), and serialization via `toObject`/`fromObject`. The architecture is modular: a core `Two` class manages the scene and animation loop, with a hierarchy of elements (Element → Shape → Path/Text/Points), a Group container for scene graph nesting, and separate renderer implementations for each target. Key entry points are the `Two` constructor, factory methods (`makeCircle`, `makePath`, etc.), `update()`, `play()`, and `pause()`. The library has no external runtime dependencies beyond standard browser APIs, though optional `node-canvas` enables headless rendering. Notably, the codebase demonstrates high craftsmanship with a flag-based dirty tracking system for efficient updates, an event system with cross-object observation, and a collection pattern with mutation events. However, it shows maintenance drift through some outdated development dependencies (e.g., `babel-eslint`, `underscore`) and manually maintained TypeScript declarations that may lag behind the source.

RATING8.9/10
QUALITY8.3/10
MAINTENANCEactive
DRIFTmedium
CONTRIBUTORS69
VELOCITY0.89
OPEN ISSUES37
CLOSED ISSUES582
LAST COMMIT2 days ago
@types/minimatch (npm) ^6.0.0
@vuepress/bundler-vite (npm) 2.0.0-rc.31
@vuepress/plugin-google-analytics (npm) 2.0.0-rc.135
@vuepress/plugin-redirect (npm) 2.0.0-rc.135
@vuepress/plugin-search (npm) 2.0.0-rc.135
@vuepress/theme-default (npm) 2.0.0-rc.136
babel-eslint (npm) ^10.1.0
chalk (npm) ^2.4.2
commander (npm) ^2.20.3
esbuild (npm) ^0.28.2
eslint (npm) ^7.8.1
esm (npm) ^3.2.25
gzip-size (npm) ^5.1.1
jsdoc (npm) ^4.0.5
jsdoc-api (npm) ^9.3.6
sass (npm) ^1.104.1
typescript (npm) ^4.5.4
vue (npm) ^3.5.43
vuepress (npm) 2.0.0-rc.31
Files by Type (count)
JavaScript
72
Other (.png)
68
Markdown
51
TypeScript
51
Other (.svg)
28
JSON
9
YAML
7
Vue
7
Other (no ext)
5
Other (.jpg)
2
HTML
2
SCSS
2
Files by Type (size)
JavaScript
2MB
Other (.png)
1MB
Other (.jpg)
460KB
JSON
444KB
Markdown
424KB
TypeScript
233KB
Other (.svg)
44KB
SCSS
19KB
Vue
13KB
YAML
8KB
Other (.template)
3KB
HTML
2KB

The LLM identified 4 files worth highlighting for reuse:

Provides a lightweight, self-contained event system (`addEventListener`, `removeEventListener`, `dispatchEvent`) with aliases (`on`, `off`, `bind`, `unbind`, `trigger`). Includes `listen`/`ignore` patterns for cross-object observation without tight coupling. Reusable as a standalone mixin for any object needing event capabilities.

file: src/events.js ↗ | tags: #event-system #publish-subscribe

Implements a 3×3 transformation matrix with operations for multiply, inverse, identity, scale, rotate, translate, skewX/Y, and decompose. Includes static helpers (`Multiply`, `Transpose`) and edge-case handling for degenerate matrices. Can be extracted for any project requiring affine 2D transformations.

file: src/matrix.js ↗ | tags: #2d-math #transformation

Contains pure math functions for hit testing: `pointInPolygons` (ray casting), `distanceToSegments` (closest point on line), and utilities for building path bounding geometry. No internal dependencies; suitable for any graphics or interactive application needing containment or proximity checks.

file: src/utils/hit-test.js ↗ | tags: #geometry #point-in-polygon

Provides robust curve mathematics including Bezier subdivision (de Casteljau), arc length via Gauss-Legendre integration, bounding box computation, and Catmull-Rom spline estimation. Implements `Curve` constants and static methods that are reusable for any 2D vector graphics library or path manipulation tool.

file: src/utils/curves.js ↗ | tags: #bezier #catmull-rom #subdivision
Last analyzed: 2026-10-15 18:13:31.084727
Next check: 2026-10-22 18:13:31.066868
$ submit: