Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@thi.ng/geom

thi-ng2.8kApache-2.08.1.49TypeScript support: included

Functional, polymorphic API for 2D geometry types & SVG generation

2d, 3d, analysis, arc, area, bbox, bezier, centroid, circle, clipping, conversion, datastructure, edges, ellipse, geometry, graph, graphics, group, intersection, parser, path, polygon, polyline, polymorphic, sample, scatter, shape, spline, svg, tessellation, triangulation, typescript

readme

thi.ng/umbrella

GitHub Workflow Status Code Climate Become a patron Mastodon Follow

About

"A collection of functional programming libraries that can be composed together. Unlike a framework, thi.ng is a suite of instruments and you (the user) must be the composer of. Geared towards versatility, not any specific type of music." — @loganpowell via Twitter

Please visit thi.ng for additional information. You might also find the following tools useful to find & explore projects in this vast ecosystem:

This project is NOT a framework and all packages can be used in isolation.

Not including deprecations, this mono-repository is home to 209 individual TypeScript libraries/packages/tools and ~185 example projects illustrating their usage, currently totalling ~238k SLOC and ~4250 source files... Some of the projects have been in regular development since 2015. The monorepo exists in its current form since January 2018.

Unlike most other large mono-repos, this one is not for a single project, but a broad collection of jointly developed, yet independent libraries, tools and general purpose building blocks for the following non-exhaustive list of topics (see package overview below):

  • Functional programming (ES6 iterators/generators, composition, memoization, transducers, multi-methods)
  • Reactive programming, stream / transducer based dataflow graphs / pipelines / DOM
  • Fiber process tree abstraction for ES6 generators (co-routines / cooperative multitasking)
  • Data structures & data transformations for wide range of use cases (maps, sets, heaps, queues, graphs etc.)
  • WebAssembly bridge APIs & data structure bindings code generators for multiple target languages (primarily aimed at Zig & C11)
  • PEG-style functional parser combinators w/ (optional) custom grammar definition language
  • Customizable HTML & Markdown parsers
  • 2D/3D geometry generation, shape primitives, math, manipulation, intersections, conversions & visualizations
  • Canvas abstractions, pixel buffers & SVG serialization/conversion
  • Comprehensive function collection (900+) for nD-vectors and matrices (dense & sparse)
  • ECS implementations with optional support for strided memory layouts
  • Semi-declarative WebGL 1/2 abstraction layer
  • DSL for shader functions defined in TypeScript and cross-compilation to GLSL, JS, VEX etc.
  • Value-based equivalence (vs. native object identity) and associative data structures (sets, maps)
  • DSP building blocks: oscillators, noise generators, filters, 1D FFT/IFFT, muxers, rate converters
  • Immutable data handling, state containers, transacted state updates, Undo-Redo history
  • Reactive UI component toolkits (DOM-based, canvas-based, immediate-mode, multiple approaches...)
  • Multi-format, multi-channel pixel buffers (int & float based), conversions, dithering, Porter-Duff alpha-blending operators
  • Color space/format conversions, matrix based color manipulation, gradient generators, color palettes, dominant color extraction
  • Date-time abstraction, relative dates, iterators, formatters, math
  • WebWorker workflow abstractions
  • Forth-style pointfree DSL for functional composition and DSL development/extension
  • S-expression parser & runtime (interpreter) infrastructure for custom DSL creation
  • WASM-based SIMD batch-processing of vector data
  • Pen-plotter (AxiDraw) toolchain & geometry conversions
  • Interpolations, math helpers, automatic differentiation (Dual numbers)
  • etc.

Once more, this project is NOT a framework. There's no turn-key, one-size-fits-all approach and instead the overall design philosophy encourages a mix & match philosophy for key aspects of application design (inside & outside the browser). Customization points are provided wherever useful and only expect certain interfaces/type signatures rather than hard-coded concrete implementations. In many cases presets are provided too.

All packages:

  • are versioned independently
  • have auto-generated online documentation at docs.thi.ng
  • built via esbuild and tested via bun.sh
  • released via thi.ng/monopub publishing toolchain
  • distributed as ESM modules (ES2022 syntax) with export maps, TypeScript typings & change logs
  • highly modular with often only a single function / class (incl. closely related functions) per file to help w/ selective imports and tree shaking
  • provide re-exports of all their publics for full library imports
  • have either none or only `@thi.ng` internal runtime dependencies (w/ very few exceptions! All dependencies are listed in each package readme)
  • declare public interfaces, enums & types in an api.ts file
  • licensed under Apache Software License 2.0

Getting started

A common misconception is to think of this repo as single project. It is not! The sheer number and varied nature & purpose of these packages makes it impossible to provide traditional "Getting started" tutorials — there would have to be dozens of them... To compensate, this repo provides ~180 example projects, detailed package readmes (at the very least for all the larger and/or more important ones), as well as hundreds of small usage examples/snippets in doc strings & readme files.

Documentation

If you're unsure about something, please reach out! Any constructive feedback is always highly appreciated!

Project templates

You might find one of the following template repos an useful starting point (only updated sporadically, make sure to update dependencies manually):

  • tpl-umbrella-basic: Bare-bones template repo for browser-based projects
  • tpl-umbrella-fxhash: Project template repo for generative art projects on the fx(hash) platform
  • tpl-umbrella-zig: Minimal browser project template for hybrid TypeScript & Zig (WebAssembly) apps

#HowToThing

Between August-November 2023, #HowToThing was a series of short posts & mini-tutorials on Mastodon, demonstrating a range of different techniques, patterns and use cases from across the thi.ng/umbrella ecosystem. These are not necessarily intro examples, but each one comes with heavily commented code (and often with visual outputs/results).

Blog posts

Videos

The following videos have been migrated from YouTube to their new home at makertube.net (more to come):

Examples & Showcase

There's a steadily growing number (~180) of standalone examples of different complexities (often combining functionality from several packages) in the examples directory.

Example screenshots (small selection)

awesome.thi.ng

Due to other priorities still very much in its infancy & planning stage, but please help to document your own usage of these packages by contributing project information to the awesome.thi.ng repo, which will be used to build a showcase site... Thank you!

Generative art projects

Several generative art projects by Karsten Schmidt on fx(hash) were created exclusively with libraries from this collection.

| De/Frag series | | | |--------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------| | | | | | Quasiflock | C-SCAPE | ASCII-SCAPE | | | | | | Bubblemania | Danza (unreleased) | S-TRACE (unreleased) | | | | |

Community, contributing, getting help

[!NOTE] My Mastodon account is the best place to learn about ongoing developments. This is a multi-purpose account, but you can view #ThingUmbrella tagged posts only and/or subscribe to those via RSS.

Join the discussions here on Github, get in touch via Mastodon or use the issue tracker. If you'd like to contribute in other ways, please first read this document.

In general, we welcome contributions of all kinds (docs, examples, bug fixes, feature requests, financial contributions etc.). You can find a detailed overview for contributors here: CONTRIBUTING.md.

Note: The default branch for this repo is develop and all PRs should be based on this branch. This too means, the README files on this branch might refer to yet-unreleased features or packages. Please use the main branch for viewing the most recently released version(s)!.

Wiki

To date, the wiki has only been updated sporadically, but please be sure to check it out for project-wide glossary, information, cookbooks, useful snippets etc.

Projects

Latest updates

As of: 2025-06-24

Status Package Version Changelog
@thi.ng/k-means version changelog
@thi.ng/pixel-analysis version changelog
@thi.ng/pixel-dominant-colors version changelog

Algorithms & data structures

Project Version Changelog Description
@thi.ng/adjacency version changelog Adjacency matrices & graph algorithms
@thi.ng/arrays version changelog Array utilities
@thi.ng/associative version changelog Alt Set & Map implementations
@thi.ng/atom version changelog Immutable value wrappers, views, history
@thi.ng/bitfield version changelog 1D/2D bit field implementations
@thi.ng/bidir-index version changelog Bi-directional key-value map/index
@thi.ng/buffers version changelog Generic read/write buffers w/ diff. behaviors
@thi.ng/cache version changelog In-memory caches / strategies
@thi.ng/cellular version changelog Highly configurable 1D Cellular automata
@thi.ng/dcons version changelog Doubly-linked list
@thi.ng/diff version changelog Array & object diffing
@thi.ng/disjoint-set version changelog Disjoint Set data structure
@thi.ng/dgraph version changelog Dependency graph
@thi.ng/ecs version changelog Entity-Component System
@thi.ng/gp version changelog Genetic programming helpers / AST gen
@thi.ng/heaps version changelog Binary & d-ary heap impls
@thi.ng/idgen version changelog Versioned ID generation / free-list
@thi.ng/k-means version changelog K-means clustering of n-D data
@thi.ng/leaky-bucket version changelog Counter-based Leaky Bucket implementation
@thi.ng/ramp version changelog Parametric, interpolated lookup tables
@thi.ng/quad-edge version changelog Quad-edge, dual-graph data structure
@thi.ng/resolve-map version changelog DAG computations & value resolution
@thi.ng/sorted-map version changelog Sorted map & set datastructure
@thi.ng/sparse-set version changelog Sparse set datastructure
@thi.ng/tensors version changelog 1D-4D tensors, views & operations
@thi.ng/text-analysis version changelog Tokenization, statistics, vector encoding, clustering
@thi.ng/trie version changelog Trie-based map datastructure w/ prefix queries
@thi.ng/vclock version changelog Vector clock functions / comparators
@thi.ng/zipper version changelog Immutable tree editing / navigation

DSLs

Project Version Changelog Description
@thi.ng/lispy version changelog Extensible, interpreted Lisp-style DSL
@thi.ng/pointfree version changelog Stack-based DSL & functional composition
@thi.ng/pointfree-lang version changelog Forth-like syntax layer for @thi.ng/pointfree
@thi.ng/proctext version changelog Procedural text generation engine
@thi.ng/sexpr version changelog S-Expression parser & runtime infrastructure

File / file format / hardware support

Project Version Changelog Description
@thi.ng/axidraw version changelog Minimal, declarative AxiDraw plotter controller
@thi.ng/bencode version changelog Bencode binary format encoding
@thi.ng/csv version changelog Customizable CSV parser/object mapper
@thi.ng/dot version changelog Graphviz DOM & export
@thi.ng/dsp-io-wav version changelog WAV file format exporter
@thi.ng/egf version changelog Extensible Graph Format
@thi.ng/file-io version changelog Assorted file I/O utils for NodeJS
@thi.ng/geom-io-obj version changelog Wavefront OBJ model parser
@thi.ng/hiccup-css version changelog CSS from nested JS data structures
@thi.ng/hiccup-html version changelog Type-checked HTML5 element wrappers for hiccup
@thi.ng/hiccup-html-parse version changelog HTML parsing & transformation to hiccup format
@thi.ng/hiccup-markdown version changelog Hiccup-to-Markdown serialization
@thi.ng/hiccup-svg version changelog hiccup based SVG vocab
@thi.ng/iges version changelog IGES format geometry serialization
@thi.ng/markdown-table version changelog Markdown table generator / formatter
@thi.ng/mime version changelog File extension to MIME type mappings
@thi.ng/msgpack version changelog Msgpack serialization/deserialization
@thi.ng/pixel-io-geotiff version changelog GeoTIFF reader support for thi.ng/pixel
@thi.ng/pixel-io-netpbm version changelog 1/8/16/24bit NetPBM image format reader/writer
@thi.ng/pixel-io-pfm version changelog Portable FloatMap image format reader/writer
@thi.ng/prefixes version changelog Linked Data, RDF & xmlns prefixes/URLs
@thi.ng/sax version changelog SAX-like XML parser / transducer
@thi.ng/tangle version changelog Literate programming utilities

Frontend / UI

Project Version Changelog Description
@thi.ng/blurhash version changelog Fast image blurhash encoder/decoder
@thi.ng/canvas version changelog Canvas creation & HDPI support helpers
@thi.ng/dl-asset version changelog Asset/canvas/file download helpers
@thi.ng/emoji version changelog Bi-directional emoji lookup tables (names/chars)
@thi.ng/hdiff version changelog String diffing w/ hiccup output (includes CLI)
@thi.ng/hdom version changelog Hiccup based VDOM & diffing
@thi.ng/hdom-canvas version changelog hdom adapter for hiccup-canvas
@thi.ng/hdom-components version changelog hdom based UI components
@thi.ng/hdom-mock version changelog hdom mock implementation (testing / prototyping)
@thi.ng/hiccup version changelog S-expression based HTML/XML serialization
@thi.ng/hiccup-canvas version changelog hiccup interpreter for canvas api
@thi.ng/hiccup-carbon-icons version changelog IBM Carbon icons in hiccup format
@thi.ng/imgui version changelog Immediate mode GUI
@thi.ng/interceptors version changelog Composable event handlers & processor
@thi.ng/meta-css version changelog CSS framework codegen, transpiler, bundler
@thi.ng/rdom version changelog Reactive, diff-less, async UI components
@thi.ng/rdom-canvas version changelog rdom component wrapper for thi.ng/hiccup-canvas
@thi.ng/rdom-components version changelog Unstyled, customizable component collection
@thi.ng/rdom-forms version changelog Datadriven HTML form generation
@thi.ng/router version changelog Customizable browser & non-browser router
@thi.ng/text-canvas version changelog Text-mode canvas, drawing, tables, charts
@thi.ng/text-format version changelog Color text formatting w/ ANSI & HTML presets

Fundamentals

Project Version Changelog Description
@thi.ng/args version changelog Declarative & functional CLI arg parsing & coercions
@thi.ng/api version changelog Common types, decorators, mixins
@thi.ng/bench version changelog Basic benchmarking helpers
@thi.ng/checks version changelog Type & value checks
@thi.ng/compare version changelog Comparators
@thi.ng/compose version changelog Functional composition helpers
@thi.ng/date version changelog Date/time iterators, formatters, rounding
@thi.ng/defmulti version changelog Dynamic multiple dispatch
@thi.ng/distance version changelog n-D distance metrics & K-nearest neighborhoods
@thi.ng/equiv version changelog Deep value equivalence checking
@thi.ng/errors version changelog Custom error types
@thi.ng/expose version changelog Conditional global variable exposition
@thi.ng/fibers version changelog Process hierarchies & ops for cooperative multitasking
@thi.ng/hex version changelog Hex value formatters for U4-64 words
@thi.ng/logger version changelog Basis infrastructure for arbitrary logging
@thi.ng/memoize version changelog Function memoization w/ customizable caching
@thi.ng/object-utils version changelog Plain JS object & map manipulation
@thi.ng/oquery version changelog Pattern based query engine for JS objects
@thi.ng/parse version changelog Parser combinators & AST generator/transformer
@thi.ng/paths version changelog Immutable nested object accessors
@thi.ng/strings version changelog Higher-order string formatting utils
@thi.ng/system version changelog Minimal life cycle container for stateful app components
@thi.ng/timestamp version changelog Timestamp abstraction/wrapper
@thi.ng/transclude version changelog Template engine for text document generation
@thi.ng/units version changelog Extensible SI unit conversions

Geometry, image & visualization

Project Version Changelog Description
@thi.ng/boids version changelog Configurable n-dimensional boids simulation
@thi.ng/color version changelog Color conversions, gradients
@thi.ng/color-palettes version changelog Collection of image-based color palettes
@thi.ng/dgraph-dot version changelog Dependency graph -> Graphviz
@thi.ng/distance-transform version changelog Image based distance field generation
@thi.ng/fuzzy-viz version changelog Visualization, instrumentation for @thi.ng/fuzzy
@thi.ng/geom version changelog 2D only geometry types & ops
@thi.ng/geom-accel version changelog Spatial indexing data structures
@thi.ng/geom-axidraw version changelog Shape conversions for AxiDraw pen plotter
@thi.ng/geom-arc version changelog 2D elliptic arc utils
@thi.ng/geom-clip-line version changelog 2D line clipping
@thi.ng/geom-clip-poly version changelog 2D convex polygon clipping
@thi.ng/geom-closest-point version changelog Closest point helpers
@thi.ng/geom-fuzz version changelog Fuzzy 2D shape drawing / filling
@thi.ng/geom-hull version changelog 2D convex hull (Graham scan)
@thi.ng/geom-isec version changelog Point & shape intersection tests
@thi.ng/geom-isoline version changelog 2D contour line extraction
@thi.ng/geom-poly-utils version changelog 2D polygon helpers
@thi.ng/geom-resample version changelog nD polyline / curve resampling
@thi.ng/geom-sdf version changelog 2D SDF creation, conversions, operators, utilities
@thi.ng/geom-splines version changelog nD cubic / quadratic spline ops
@thi.ng/geom-subdiv-curve version changelog nD iterative subdivision curves
@thi.ng/geom-tessellate version changelog nD convex polygon tessellators
@thi.ng/geom-trace-bitmap version changelog bitmap image to vector conversion
@thi.ng/geom-voronoi version changelog 2D iterative delaunay/voronoi
@thi.ng/geom-webgl version changelog thi.ng/geom / WebGL shape conversion & interop
@thi.ng/imago version changelog Declarative & extensible image processing pipelines
@thi.ng/lsys version changelog Extensible L-System architecture
@thi.ng/pixel version changelog Multi-format pixel buffers
@thi.ng/pixel-analysis version changelog Image color & feature analysis utilities
@thi.ng/pixel-convolve version changelog Extensible image convolution & kernel presets
@thi.ng/pixel-dominant-colors version changelog k-means based dominant colors extraction
@thi.ng/pixel-dither version changelog Image dithering w/ various algorithm presets
@thi.ng/poisson version changelog nD Poisson disk sampling
@thi.ng/porter-duff version changelog Alpha blending / compositing ops
@thi.ng/rasterize version changelog Shape drawing, filling & rasterization
@thi.ng/scenegraph version changelog Extensible 2D/3D scenegraph
@thi.ng/simd version changelog WebAssembly SIMD vector batch processing
@thi.ng/tsne version changelog Configurable t-SNE visualization solver
@thi.ng/viz version changelog Declarative & functional data visualization toolkit

Iterator, stream & sequence processing

Project Version Changelog Description
@thi.ng/csp version changelog Channel based async ops
@thi.ng/grid-iterators version changelog 2D grid iterator strategies
@thi.ng/seq version changelog Lisp/Clojure-style sequence abstraction
@thi.ng/transducers version changelog Composable data transformations
@thi.ng/transducers-async version changelog Async transducers, reducers & iterators
@thi.ng/transducers-binary version changelog Binary data related transducers
@thi.ng/transducers-fsm version changelog Finite state transducer
@thi.ng/transducers-hdom version changelog Transducer based hdom UI updates
@thi.ng/transducers-patch version changelog Patch-based, array & object editing
@thi.ng/transducers-stats version changelog Technical / statistical analysis

Low-level, binary, memory management, interop

Project Version Changelog Description
@thi.ng/base-n version changelog Arbitrary base-n encoding/decoding with presets
@thi.ng/binary version changelog Assorted binary / bitwise ops, utilities
@thi.ng/bitstream version changelog Bitwise input / output streams
@thi.ng/block-fs version changelog Block-based storage & filesystem
@thi.ng/dlogic version changelog Digital logic ops / constructs
@thi.ng/leb128 version changelog WASM based LEB128 varint encoder / decoder
@thi.ng/malloc version changelog Raw & typed array memory pool & allocator
@thi.ng/morton version changelog Z-order-curve / Morton coding
@thi.ng/range-coder version changelog Binary data Range encoder / decoder
@thi.ng/rle-pack version changelog Run-length encoding data compression
@thi.ng/soa version changelog Memory mapped data structures & serialization
@thi.ng/unionstruct version changelog Wrapper for C-like structs / unions
@thi.ng/vector-pools version changelog Data structures for memory mapped vectors
@thi.ng/wasm-api version changelog Modular, extensible JS/WebAssembly bridge API
@thi.ng/wasm-api-bindgen version changelog Polyglot bindings code generator for C/Zig/TS
@thi.ng/wasm-api-canvas version changelog WASM-side Canvas2D API bindings
@thi.ng/wasm-api-dom version changelog WASM-side DOM manipulation
@thi.ng/wasm-api-schedule version changelog WASM-side delayed code execution/scheduling

Maths

Project Version Changelog Description
@thi.ng/dual-algebra version changelog Dual number algebra / automatic differentiation
@thi.ng/dsp version changelog DSP utils, composable signal gens/processors
@thi.ng/fuzzy version changelog Fuzzy logic primitives & rule inference engine
@thi.ng/intervals version changelog Open/closed intervals, queries, set ops
@thi.ng/math version changelog Assorted common math functions & utilities
@thi.ng/matrices version changelog Matrix operations
@thi.ng/sparse version changelog Sparse matrix & vector impls
@thi.ng/timestep version changelog Fixed timestep simulation updates with state interpolation
@thi.ng/vectors version changelog Fixed & arbitrary-length vector ops

Network

Project Version Changelog Description
@thi.ng/server version changelog Minimal, extensible, interceptor-based HTTP server

Randomness

Project Version Changelog Description
@thi.ng/colored-noise version changelog 1D colored noise generators
@thi.ng/ksuid version changelog K-sortable unique identifiers, binary & base-N encoded
@thi.ng/lowdisc version changelog n-D Low discrepancy sequence generators
@thi.ng/random version changelog Seedable PRNG implementations, distributions & utilities
@thi.ng/random-fxhash version changelog PRNG impl & utilities for fxhash projects
@thi.ng/uuid version changelog Binary & string-based UUID v4 generator

Reactive programming

Project Version Changelog Description
@thi.ng/rstream version changelog Push-based, reactive event stream primitves
@thi.ng/rstream-csp version changelog Adapter bridge CSP -> rstream
@thi.ng/rstream-dot version changelog Graphviz visualization of rstream topologies
@thi.ng/rstream-gestures version changelog Mouse & touch event stream abstraction
@thi.ng/rstream-graph version changelog Declarative dataflow graph construction
@thi.ng/rstream-log version changelog Hierarchical structured data logging
@thi.ng/rstream-log-file version changelog Log-file output handler
@thi.ng/rstream-query version changelog Triple store & query engine

WebGL / GPGPU

Project Version Changelog Description
@thi.ng/shader-ast version changelog AST DSL for x-platform shader code
@thi.ng/shader-ast-glsl version changelog GLSL code generator
@thi.ng/shader-ast-js version changelog JS code generator
@thi.ng/shader-ast-optimize version changelog AST code optimization strategies
@thi.ng/shader-ast-stdlib version changelog 100+ useful AST shader functions
@thi.ng/webgl version changelog WebGL 1/2 / GPGPU facilities
@thi.ng/webgl-msdf version changelog MSDF font rendering
@thi.ng/webgl-shadertoy version changelog Shadertoy-like WebGL setup

Deprecated packages

The following packages have been deprecated. Their readmes describe reasons and alternatives:

Project Version Changelog Description
@thi.ng/fsm version changelog FSM / parser primitives
@thi.ng/geom-api version changelog Shared types for thi.ng/geom packages
@thi.ng/iterators version changelog ES6 generators / iterators
@thi.ng/testament version changelog Minimal test runner

Building

git clone https://github.com/thi-ng/umbrella.git
cd umbrella

yarn install
yarn build

Once the entire mono-repo has been fully built at least once before, individual packages can then be (re)built like so:

yarn workspace @thi.ng/transducers run build

# or

(cd packages/transducers && yarn build)

# or

(cd packages/transducers && yarn build:esbuild)

Note: The yarn build script alias will also generate TS type declaration files. This step is only needed once in the beginning or if updating the public API of a package. If you're confident it's not needed, using the build:esbuild alias is sufficient and much faster. Also, TS declaration files can be manually rebuilt via build:decl...

Building example projects

Please see the example build instructions in the wiki for further details.

Testing

(Most, but not all packages have tests)

Test for all packages are run via bun.sh.

# build all packages, then run all tests (in one go)
yarn test

# only run all tests
yarn test:only

# or individually
yarn workspace @thi.ng/rstream run test

Building API docs

Autogenerated documentation (using TypeDoc) will be saved under /packages/*/doc/ (more info).

yarn doc

Extracting code examples from readme files & comments

All packages in this repo have prepared infrastructure to extract various code examples & snippets from their README files and from comments in the source code. Altogether, there're 800-1000 of them in this repo, but only ~420 have been processed thus far (it's an ongoing time consuming manual process to prepare & check each of them, but work is under way! Please get in touch if you want to help!).

The code extraction is handled via thi.ng/tangle, itself a part of thi.ng/umbrella. You can read more details about this process here:

To extract code blocks as source files from readmes:

# in the repo root (to process all packages)
yarn doc:readme

# for a single package only
(cd packages/<name> && yarn doc:readme)

To extract example code blocks from doc strings (API docs) in source code:

# in the repo root (to process all packages)
yarn tool:tangle

# for a single package only
(cd packages/<name> && yarn tool:tangle)

In all cases, the extracted files will be saved in each package's /export folder and can then be run directly via bun:

bun packages/arrays/export/topo-sort.ts

Acknowledgements

Maintaining a large monorepo like this requires a lot of infrastructure and I'm grateful for the tooling provided by the following projects to simplify those tasks:

License

© 2015 - 2025 Karsten Schmidt // Apache Software License 2.0

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Karsten Schmidt
Karsten Schmidt

💻 📖 🚧 💵
Alberto
Alberto

💻 💡 🐛 🤔 💵
Arthur Carabott
Arthur Carabott

💻 🤔 💡 📝 💵
André Wachter
André Wachter

💻 🤔 🐛
Gavin Cannizzaro
Gavin Cannizzaro

💻 🐛 🤔
Logan Powell
Logan Powell

📖 🐛 🤔 💵
Marcin Ignac
Marcin Ignac

🐛
arcticnoah
arcticnoah

💻
allforabit
allforabit

🐛 💻 🤔 💵
Yifan Wu
Yifan Wu

🐛 📖
stwind
stwind

💻 🐛
evilive
evilive

💻
Bnaya Peretz
Bnaya Peretz

💻 🐛 🤔
oljeger
oljeger

🐛
Nik Shevchenko
Nik Shevchenko

🐛 💻
Matei Adriel
Matei Adriel

💻 🐛 🤔
Pierre Grimaud
Pierre Grimaud

📖
Matt Huebert
Matt Huebert

💵
Raphael Saunier
Raphael Saunier

💵
Eric Ihli
Eric Ihli

💵
David Pham
David Pham

💵
TBD
TBD

🐛 🤔
Pedro Henriques dos Santos Teixeira
Pedro Henriques dos Santos Teixeira

💵
Jamie Owen
Jamie Owen

💻 🐛
Robert Kesteson
Robert Kesteson

🐛 💻
Chancy Kennedy
Chancy Kennedy

💵
Jarred Sumner
Jarred Sumner

🐛
Jamie Slome
Jamie Slome

🐛 🛡️
d3v53c
d3v53c

🐛 🛡️
Jannis Pohlmann
Jannis Pohlmann

🐛
Shakthi Prasad G S
Shakthi Prasad G S

🐛 💻
Robin Gower
Robin Gower

🐛
Michael Latzoni
Michael Latzoni

🐛
Z Yin
Z Yin

🐛
Damien Seguin
Damien Seguin

🐛 💻
Rui Gil
Rui Gil

🐛
Ja|nz
Ja|nz

💻 🚇 🚧
Tyler Freeman
Tyler Freeman

🐛 💻
blackhuman
blackhuman

🐛
David Negstad
David Negstad

💻
Muhammad Ridho
Muhammad Ridho

🐛 💻
MarcusWagberg
MarcusWagberg

💻
Masashi Yoshikawa
Masashi Yoshikawa

🐛
Guido Schmidt
Guido Schmidt

🐛 💵
tsukamotohideki
tsukamotohideki

💵
Dave Meehan
Dave Meehan

💻 🤔
Aurélien Bottazini
Aurélien Bottazini

🐛
Alex
Alex

🐛 💵
Ross Cairns
Ross Cairns

💵
Ruslan Prakapchuk
Ruslan Prakapchuk

💵
Jarrod Davis
Jarrod Davis

💵
Nicolas Lebrun
Nicolas Lebrun

💡
Dawid Górny
Dawid Górny

💵
Michael Reitzenstein
Michael Reitzenstein

💵
Sam Nosenzo
Sam Nosenzo

💵
Igor Loskutov
Igor Loskutov

💻 🤔
Yury
Yury

💻 🤔 💵
Jean-Frédéric Faust
Jean-Frédéric Faust

💻 🐛

This project follows the all-contributors specification. Contributions of any kind welcome!

changelog

Change Log

All notable changes to this project will be documented in this file. Only versions published since 2022-01-01 are listed here. Please consult the Git history for older version information. See Conventional Commits for commit guidelines.

Note: Unlisted patch versions only involve non-code or otherwise excluded changes and/or version bumps of transitive dependencies.

8.1.39 (2025-04-16)

🩹 Bug fixes

  • update asCubic() for some 3D shapes (5abc2aa)
    • update polygon3, polyline3, quad3, tri3 impls to exclude "break" & "hobby" conversion modes (these modes are currently not supported in 3D)
    • add/update docs
  • update sphere/sphere intersects() impl (43f4059)

♻️ Refactoring

  • minor internal optimizations (vector ops) (c51b0de)

8.1.22 (2025-01-14)

♻️ Refactoring

  • use optional chaining & nullish coalescing (c5a0a13)

8.1.11 (2024-10-05)

♻️ Refactoring

  • add explicit type casts (TS5.6.2) (dcbdd60)

8.1.0 (2024-08-10)

🚀 Features

  • add circle inversion functions (bb3a322)
    • add invertCircle(), invertCirclePoint()

8.0.1 (2024-06-29)

🩹 Bug fixes

  • add missing pkg exports (7ec144f)

8.0.0 (2024-06-21)

🛑 Breaking changes

  • add/update asCubic()/asPath() impls/types/signatures (9b4df2e)
  • BREAKING CHANGE: update asCubic/asPath() to use new CubicOpts
    • add support for more shape types, incl. 3D
  • update svgDoc(), add SVGDocAttribs (a26628b)
  • BREAKING CHANGE: rename __bleed attrib => __margin
    • set default SVG precision to 3 (fractional digits)
  • update clipConvex(), add support for more shape types (5d594c6)
  • BREAKING CHANGE: update clipConvex() to return array of result shapes (rather than single)
    • add support for polyline & open paths
  • update/extend tessellate() to use new setup/behavior (c4dadfd)
  • BREAKING CHANGE: update/extend tessellate() to use new setup/behavior
    • update signature to return Tessellation
    • add/update impls for complex polygons & groups
    • add groupFromTessellation() to process tessellation results
    • add TESSELLATE_EARCUT_COMPLEX preset
    • remove TESSELLATE_EDGE_SPLIT_THRESHOLD & TESSELLATE_TRI_FAN_SPLIT_THRESHOLD (see 97f1f66200)
  • migrate types from @thi.ng/geom-api (3182726)
  • BREAKING CHANGE: migrate/internalize types from @thi.ng/geom-api
    • add/migrate:
      • Attribs, GroupAttribs, IAttributed
      • IShape, IShape2/3
      • AABBLike, SphereLike
      • PCLike, PCLikeConstructor
      • IHiccupShape, IHiccupShape2/3
      • SegmentType2/3
      • PathSegment, PathSegment2/3
      • HiccupPathSegment, IHiccupPathSegment
      • CubicOpts
    • re-export types from geom helper packages (to avoid extraneous imports in user code):
      • IntersectionResult, IntersectionType, NONE (geom-isec)
      • SamplingOpts, setDefaultSamples (geom-resample)
      • SubdivKernel (geom-subdiv-curve)
      • Tessellator, Tessellation (geom-tessellate)
    • update CubicOpts.mode, rename breakpoints => break
    • update imports
    • update deps
  • update tessellate() for new API (4c6a5f4)
  • BREAKING CHANGE: update tessellate() for new API
    • add optional ITessellation arg
    • add basicTessellation() & meshTessellation() factory fns
    • update tessellation post-processors (graphFromTessellation() etc.)
  • update PathBuilder to support 2D/3D, add pathBuilder3() (dcf5210)
  • BREAKING CHANGE: PathBuilder now using injected segment ctors
    • users should only use pathBuilder() & pathBuilder3() factory functions
    • add internal P2D & P3D shape ctor configs
    • update PathBuilder ctor & internals to use injected shape ctors for segments
    • update pathFromSvg()
    • migrate roundedRect() to own file

🚀 Features

  • add/update various 2d/3d shape types (262188c)
    • add 3d shape types & factory functions:
      • Cubic3
      • Line3
      • Path3
      • Points3
      • Polygon3
      • Polyline3
      • Quad3
      • Quadratic3
      • Ray3
      • Triangle3
    • update existing shape type impls & ctors/factories
  • add/update rotate, scale, translate, transform ops (signatures & type support, impls) (cb04a96)
  • add rotateAroundAxis(), add rotateX/Y/Z() ops (8831cc1)
  • update applyTransforms(), add support for 3D shapes/transforms (91be2ec)
  • add/update internal helpers (10a73f2)
  • add/update bounds() impls and fitIntoBounds2/3() types/signatures (e7a0b5c)
  • add/update asPolygon()/asPolyline() / vertices() impls/types/signatures (3ba9714)
  • add/update resample()/simplify()/subdivCurve() impls (1682577)
  • add/update splitAt()/splitArcLength() impls/types (e6f9e64)
  • add/update clipConvex()/convexHull() impls/types (a6215c7)
  • add shape types support for flip() (9628c7b)
  • add shape types support for arcLength() & center() (2a9af0d)
  • add Group3 shape type, update pkg exports (1646263)
  • add sector() path builder (807b5f1)
  • update SVG default attribs & handling (f80f67a)
    • update setSvgDefaultAttribs() to allow merging
  • add/update splitAt() & splitNearPoint() impls (1851b1d)
  • add planeFromRay() (c44d8da)
  • add 2d line impl for classifyPoint() (92e54ea)
  • fix #429, add polygon support for classifyPoint() (b56ecc1)
    • refactor plane impl
  • add/update subdivCurve() type support, args & impls (6233379)
  • update AABB & Rect ctors to clamp size to zero (7cec7d2)
  • add convolve() w/ impls for poly/polyline (incl. 3d versions) (b682d34)
    • also re-export kernel presets (KERNEL_BOX, KERNEL_TRIANGLE, KERNEL_GAUSSIAN)
  • update convolve(), add ComplexPolygon support (bfaa0aa)
  • add/update/fix type info, docs & impls for various ops (d5ccb1a)
  • update convolve(), add group support (00bdc66)
  • add Dummy shape type to wrap arbitrary hiccup data (b6e18bc)
  • add various dummy op impls for Dummy shape type (05eeb9f)
  • add arcLength(), area() default impls (return 0) (f2a30bf)
  • add TESSELLATE_EDGE_SPLIT_THRESHOLD() tessellator (1d8feff)
  • add new tessellators presets (95d6f70)
    • add TESSELLATE_TRI_FAN_SPLIT
    • add TESSELLATE_TRI_FAN_SPLIT_THRESHOLD
  • add tessellation post-processing helpers (7687975)
    • add graphFromTessellation()
    • add edgesFromTessellation()
    • add edgePointsFromTessellation()
    • update deps (adjacency)
    • update pkg exports/meta
  • add smoothPolygon()/smoothPolyline() (217a8c2)
  • add warpPoint(), add docs (bf91ff3)
  • add internal __ensurePCLike() helper (7306b35)
  • update tessellate(), add TESSELLATE_TRI_FAN_BOUNDARY (1c0d1ce)
  • add AABB impl for asPolygon() (16e005c)
  • update/extend subdivCurve() shape type support (b389db1)
    • add docs
    • add example
  • update subdivCurve() to reflect new API, update kernel presets (b715d43)
    • update/rename subdiv kernels to reflect upstream changes (cd69dd4e20)
    • update subdivCurve() impls
    • update docs
  • add ICopyTransformed interface & impls for various shape types (35781b2)
  • update/extend/simplify resample() impls (c13c37a)
  • update/extend/simplify convolve() impls, fix kernel naming (5907a2a)
  • add AABBLike.min(), fix AABBLike.offset() impls (a4dec6b)
  • add centerOfWeight(), centroidOfBounds(), update centroid() (9048aac)
    • update centroid() impls for complex poly & poly, moved to centerOfWeight()
    • update centroid() to support more types
    • update pkg exports
  • add/update iterator impls, add IEmpty impls (0a15df5)
    • update ComplexPolygon
    • update Path/Path3
  • update asPolygon() / asPolyline() (80b8d9a)
    • add support for more types
    • dedupe impls
  • update pathFromCubics() closed shape check (10a7558)
    • use eqDelta() to check if path is closed
  • update splitAt()/splitNearPoint() (d863cdd)
    • add support for more shape types
    • dedupe internals
  • add IPath, update Path/Path3 impls (eb7a97d)
  • merge 2D/3D versions of pathFromCubics() & normalizedPath() (159cd56)
    • add PathConstructor type
    • update pathFromCubics() & normalizedPath()
    • migrate fns to separate files
    • update asPath()

🩹 Bug fixes

  • fix path __samples attrib handling in asPolygon() & asPolyline() impls (3d7bd8c)
  • update various transform op impls for ComplexPolygon (1e12707)
    • minor other internal refactoring
  • update attrib checks in applyTransforms() (a19f7be)
  • fix vertices() impl for Polygon3 (a968737)
  • update pathFromCubics to mark path as closed if needed (c95b5a8)
  • fix typo in centroid() dispatch table (f1f986b)
  • rename KERNEL_TRIANGLE, fix pkg exports (ed776ed)

⏱ Performance improvements

  • update rotate() impls to reuse precomputed matrices (00e33f0)
  • internal update shape attrib copying (fe0609a)
    • rename __copyAttribsRaw => __copyAttribs
    • avoid extraneous fn calls

♻️ Refactoring

  • update offset() & union() ops/signatures (a943342)
  • rename sector() => asSector(), minor refactor (d1fb9bf)
  • minor internal updates asPolygon() (599572e)
  • rename Dummy => Extra (dummy() => extra()) (beb4bf0)
    • update various op impls
    • update pkg exports
  • update group to use GroupAttribs (6f913ff)
  • update SVGDocAttribs (102bb5c)
    • remove __prec (now part of baseAttribs)
  • dedupe 2d/3d versions of pathFromCubics(), normalizedPath() (da8ed42)
  • simplify applyTransforms() for groups (d1f5873)
  • simplify various shape transform ops & impls (ba32846)
    • better re-use of impls for PCLike types
    • remove obsolete internal helpers
  • simplify subdivCurve() impls (e978fab)
  • minor internal updates (644a478)
  • minor update complex poly hiccup serialization (b394842)
  • enforce uniform naming convention of internal functions (56992b2)
  • minor updates splitAt()/splitNearPoint() (3e65f82)
  • update proximity() to accept optional distance fn (df7aef2)
  • dedupe union() impls (c1880c8)
  • dedupe path impls for scale()/translate() (b20cb32)

7.0.1 (2024-05-09)

🩹 Bug fixes

  • update arc() arg defaults, add docs (cc57a57)

7.0.0 (2024-05-08)

🛑 Breaking changes

  • update Path to support sub-paths (holes), update impls (#464) (9329d27)
  • BREAKING CHANGE: update path related ctors & functions
    • add subPaths argument for Path ctor/factory fn
    • rename Path.add() => Path.addSegments()
    • add Path.addSubPaths()
    • update Path.toHiccup() to include sub-paths
    • update pathFromSvg() to always return a single path only
      • sub-paths are included in main path now
    • update impls for following ops to also process sub-paths:
      • bounds()
      • rotate()
      • scale()
      • simplify()
      • translate()
      • transform()
      • transformVertices()
  • update asPolyline(), add support for multiple boundaries (#464) (0616b96)
  • BREAKING CHANGE: update asPolygon() to return array of polylines
    • add/update impls for complexpoly & path to produce multiple results
    • update other internal callsites
    • update tests
  • update Path closing logic (ce3a922)
  • BREAKING CHANGE: update Path closing logic, Path.closed now a readonly property
    • add Path.closed() getter
    • add Path.close() to add a Z-type segment, check if not closed already
    • update Path.addSegments() to check each segment, throw error if path already closed
    • refactor PathBuilder.closePath()
  • add asPolygon() support for complexpoly & path (e3c9f20)
  • BREAKING CHANGE: update asPolygon() to return array of polygons (rather than single only)
    • add support for complexpoly & path (incl. sub-shapes, holes)
    • refactor internal call sites
  • update asPath(), add AsPathOpts (ef0ebdf)
  • BREAKING CHANGE: update asPath() args, add AsPathOpts as 2nd arg
    • add option for using only linear path segments (no cubics)
    • update impls for complexpoly & other polygon types
  • update Path & PathBuilder.close() (b2134c2)
  • BREAKING CHANGE: rename PathBuilder.closePath() => PathBuilder.close()
    • update Path.close() to return path itself
  • rewrite roundedRect() to allow individual corner radii (a4817aa)
  • BREAKING CHANGE: update roundedRect() radius handling to allow individual corner radii
    • update docs
    • add tests

🚀 Features

  • initial import ComplexPolygon & impls (#464) (ded007c)
    • add complexPolygon() factory fn
    • add bounds() & centroid() impls
  • add ops for complex polygons (#464) (35ce854)
    • add implementations for:
      • arcLength()
      • area()
      • asPath()
      • closestPoint()
      • convexHull()
      • edges()
      • flip()
      • pointInside()
      • resample()
      • rotate()
      • scale()
      • simplify()
      • subdivCurve()
      • transform()
      • transformVertices()
      • translate()
      • vertices()
    • add tests
  • add proximity() (5d5951c)
  • update vertices() impl for Path, incl. sub-path vertices (824067f)
  • update simplify() default threshold (bdba298)
  • add arcLength() for Path, refactor complexpoly impl (d133bbe)
  • add/update asCubic() impls for complex poly & path (7f9e927)
  • update pathFromCubics() to auto-create sub-paths if needed (1170e45)
  • add closestPoint() impl for Path (f0cf2f1)
  • add pointInside() impl for Polyline (d10bf43)
  • add centroid() & convexHull() impl for Path (76aa229)
  • add complexPolygonFromPath() (cd526f1)
  • update PathBuilder.close(), fix attrib handling (e68d0bc)
    • only insert closing line segment if needed
    • copy attribs for each new path
    • add docs
  • add opt attribs for pathFromSvg() (2da31f6)
    • update docs
    • add/update tests
  • add scaleWithCenter() (e328494)
  • add complexpoly & path support for clipConvex() (7665dc1)

🩹 Bug fixes

  • update vertices() (2afc05e)
    • update impl for points, poly, polyline to return shallow copy of point array if no opts given

♻️ Refactoring

  • update withAttribs(), make new attribs optional (688e1bf)
  • update geom examples (recent API changes) (f0f5ea7)
  • update area() impl for Path (0960817)
  • update/simplify asPath() impls (cbc71bb)
  • update centroid() for complexpoly (58ac296)
  • update path segment transformations (88b2c40)

6.1.7 (2024-04-20)

♻️ Refactoring

6.1.0 (2024-03-21)

🚀 Features

  • update intersects(), support more shape types (21ce0d4)
    • add IntersectOpts & as optional arg
      • update impl for ray-poly/ray-polyline
    • add support for new shape pairings:
      • line-polygon
      • line-polyline
      • ray-line
      • ray-group
  • update intersects(), add line-group support (1e270fa)
    • add line-group impl
    • refactor/simplify ray-group impl

6.0.6 (2023-12-03)

🩹 Bug fixes

  • fix #431 update Path.withAttribs() impl (eaad1cd)
    • keep closed state of new path the same as original

6.0.2 (2023-11-09)

♻️ Refactoring

  • update all tests (packages A-S) (e3085e4)

6.0.0 (2023-11-01)

🛑 Breaking changes

  • update tessellate() for groups, update return type (1bb1752)
  • BREAKING CHANGE: update tessellate() for groups, update return type to Iterable

5.2.13 (2023-10-27)

♻️ Refactoring

5.2.0 (2023-08-29)

🚀 Features

  • update various shape ctors to accept iterables (ae0cf5b)
    • update shared APC ctor
    • update other shape ctors: BPatch, Group, Path
    • add assertions to verify vertex counts in these ctors:
      • BPatch
      • Cubic
      • Line
      • Quad/Quad3
      • Quadratic
      • Triangle

5.1.0 (2023-08-06)

🚀 Features

  • update API for various shape types (3a45c5f)
    • add IClear impls for APC, Group, Path
    • add .add() methods for APC, Group, Polygon, Polyline
    • update Path.add() to accept multiple args

5.0.0 (2023-04-08)

🛑 Breaking changes

  • update asSVG() bleed handling (cf3eafb)
  • BREAKING CHANGE: rename bleed attrib to __bleed
    • for consistency, keep all control attribs prefixed as __xxx
    • add asSvg() support for __prec
    • update docs
  • update splitArcLength() group handling (6b97085)
  • BREAKING CHANGE: update splitArcLength() group handling & return type
    • update group handling to form sub-groups of predictable length (e.g. grouping shorter shapes and/or splitting longer shapes until desired arc length is reached)
    • remove support for nested groups
    • update docs, add example
    • update all impls to return single group

🚀 Features

  • update inscribedSquare/Hex() args, add attribs (317f630)

4.4.0 (2023-03-24)

🚀 Features

  • avoid recursive application of __samples attrib (189446d)
    • add internal __copyAttribsNoSamples() helper
    • update implementations for:
      • asPolygon()
      • asPolyline()
      • edges()
      • resample()
      • splitArcLength()
    • update Group ctor to make attribs optional
  • add/expose subdiv & tessellation presets (0f79c6d)

4.3.0 (2023-03-22)

🚀 Features

  • add splitArclength() (906a326)
  • add spiral() polyline factory fn (572e0ef)

4.2.0 (2023-01-10)

🚀 Features

  • update vertices() for circle, ellipse, group (9ff890a)
    • add support for SamplingOpts.start (circle/ellipse)
    • add SamplingOpts support for groups
    • migrate internal helpers
    • update export maps

4.1.0 (2022-12-22)

🚀 Features

  • add SVG default attribs & setter (3cb07a6)
    • set defaults to no fill & black stroke
    • add setSvgDefaultAttribs()

4.0.0 (2022-12-10)

🛑 Breaking changes

  • unify function naming (980f625)
  • BREAKING CHANGE: rename rect & aabb ctor fns
    • rename rectFromCentroid => rectWithCentroid
    • rename rectFromCentroidWithMargin => rectWithCentroidAndMargin
    • same for aabb versions

🚀 Features

  • add AABB.toHiccup() impl (2c419cc)
  • add startWithCentroid(), add docs (6b4df6a)
  • update vertices(), config via attribs (b5a53ba)
    • add support for per-shape config overrides via __samples attrib object
    • add docs

🩹 Bug fixes

  • correct withAttribs() return type (867c302)
  • update applyTransforms() (b6262c2)
    • always remove all spatial transform attribs

3.4.6 (2022-08-06)

⏱ Performance improvements

3.4.0 (2022-06-28)

🚀 Features

  • add IAttributed impls for all shape types (ccb40f1)
  • add new transform ops & helpers (cd8217c)
    • add applyTransforms(), rotate(), scale()
    • add internal helpers
    • update transform() rect coercion (now => Quad, previous Polygon)
  • update edges(), support more types (3e1b340)
  • update warpPoints() args, add docs (50cb467)
  • add AABB support for intersects() (768dddd)

🩹 Bug fixes

  • update AABB/Rect.offset(), clamp size to zero (620121d)

3.3.1 (2022-06-23)

♻️ Refactoring

  • update size handling in various ctors (ab4b93d)

3.3.0 (2022-06-20)

🚀 Features

  • update rect/aabb, add new factory fns (f74e377)
    • add ...WithMargin() factory fns
    • add AABBLike.offset() impls
  • update bounds() to support opt. margin (8cdc372)

3.2.1 (2022-04-07)

🩹 Bug fixes

  • fix #336, update attrib ctor arg handling (cb8e52a)
    • update internal __argAttribs() helper
    • add tests

3.2.0 (2022-03-11)

🚀 Features

  • add opt. bleed attrib for svgDoc() (fb3ed1e)
  • add BPatch type, ctors and warp fn (ea81cb5)
  • update/refactor various shape ops (0e3b99a)