diff --git a/packages/geom/README.md b/packages/geom/README.md index 91469fdd77..5e868a7da4 100644 --- a/packages/geom/README.md +++ b/packages/geom/README.md @@ -44,28 +44,29 @@ name](http://thi.ng/geom-clj). All polymorphic operations built on The following shape primitives are provided. For many there're multiple ways to create them, please check linked sources and/or docs. -| Shape/Form | Description | Hiccup support | -|-------------------------------------------------------------------------------------------------------|------------------------------|-----------------| -| [AABB](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/aabb.ts) | 3D Axis-aligned bounding box | ✅(2) | -| [Arc](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/arc.ts) | 2D elliptic arc | ✅ | -| [Circle](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/circle.ts) | 2D circle | ✅ | -| [Cubic](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/cubic.ts) | nD cubic bezier | ✅(1) | -| [Ellipse](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/ellipse.ts) | 2D ellipse | ✅ | -| [Group](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/group.ts) | group of 2D shapes | ✅ | -| [Line](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/line.ts) | 2D line segment | ✅ | -| [Path](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/path-builder.ts) | 2D path | ✅ | -| [Path (from SVG)](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/path-from-svg.ts) | 2D path from SVG `` | ✅ | -| [Plane](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/plane.ts) | 3D plane | ✅(2) | -| [Point cloud](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/points.ts) | nD point cloud | ✅(1) | -| [Polygon](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/polygon.ts) | 2D simple polygon (no holes) | ✅ | -| [Polyline](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/polyline.ts) | 2D polyline | ✅ | -| [Quad](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/quad.ts) | 2D/3D quad (4-gon) | ✅(1) | -| [Quadratic](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/quadratic.ts) | nD quadratic bezier | ✅(1) | -| [Ray](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/ray.ts) | nD ray | ✅(1) | -| [Rectangle](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/rect.ts) | 2D rectangle | ✅ | -| [Sphere](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/sphere.ts) | 3D sphere | ✅(2) | -| [Text](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/text.ts) | Basic stub for text labels | ✅(3) | -| [Triangle](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/triangle.ts) | 2D triangle | ✅ | +| Shape/Form | Description | Hiccup support | +|--------------------------------------------------------------------------------------------------------|---------------------------------------|-----------------| +| [AABB](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/aabb.ts) | 3D Axis-aligned bounding box | ✅(2) | +| [Arc](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/arc.ts) | 2D elliptic arc | ✅ | +| [Circle](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/circle.ts) | 2D circle | ✅ | +| [ComplexPolygon](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/complex-polygon.ts) | 2D polygon w/ holes | ✅ | +| [Cubic](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/cubic.ts) | nD cubic bezier | ✅(1) | +| [Ellipse](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/ellipse.ts) | 2D ellipse | ✅ | +| [Group](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/group.ts) | group of 2D shapes | ✅ | +| [Line](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/line.ts) | 2D line segment | ✅ | +| [Path](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/path-builder.ts) | 2D path (w/ optional holes/sub-paths) | ✅ | +| [Path (from SVG)](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/path-from-svg.ts) | 2D path from SVG | ✅ | +| [Plane](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/plane.ts) | 3D plane | ✅(2) | +| [Point cloud](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/points.ts) | nD point cloud | ✅(1) | +| [Polygon](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/polygon.ts) | 2D simple polygon (no holes) | ✅ | +| [Polyline](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/polyline.ts) | 2D polyline | ✅ | +| [Quad](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/quad.ts) | 2D/3D quad (4-gon) | ✅(1) | +| [Quadratic](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/quadratic.ts) | nD quadratic bezier | ✅(1) | +| [Ray](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/ray.ts) | nD ray | ✅(1) | +| [Rectangle](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/rect.ts) | 2D rectangle | ✅ | +| [Sphere](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/sphere.ts) | 3D sphere | ✅(2) | +| [Text](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/text.ts) | Basic stub for text labels | ✅(3) | +| [Triangle](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/triangle.ts) | 2D triangle | ✅ | - (1) valid hiccup format, currently only useable/supported if 2D geometry - (2) valid hiccup format, currently unused/unsupported elsewhere @@ -77,9 +78,10 @@ With very few exceptions these all are implementing the [`IToHiccup` interface](https://docs.thi.ng/umbrella/api/interfaces/IToHiccup.html) and so can be easily converted (via [hiccup](https://github.com/thi-ng/umbrella/tree/develop/packages/hiccup)) to a -variety of other formats. By design, for better flexibility and performance -reasons, the hiccup flavor used by this package is **not** compatible with that -used by +variety of other formats, incl. [conversion to SVG](#svg-support). + +By design, for better flexibility and performance reasons, the hiccup flavor +used by this package is **not** compatible with that used by [thi.ng/hiccup-svg](https://github.com/thi-ng/umbrella/tree/develop/packages/hiccup-svg), though the latter provides a [`convertTree()`](https://docs.thi.ng/umbrella/hiccup-svg/functions/convertTree.html) @@ -104,8 +106,8 @@ directly and/or perform automatic resampling/conversion if needed). | [`area()`](https://docs.thi.ng/umbrella/geom/functions/area.html) | signed/unsigned surface area | | [`asCubic()`](https://docs.thi.ng/umbrella/geom/functions/asCubic.html) | convert shape boundary to cubic bezier segments | | [`asPath()`](https://docs.thi.ng/umbrella/geom/functions/asPath.html) | convert shape to path | -| [`asPolygon()`](https://docs.thi.ng/umbrella/geom/functions/asPolygon.html) | convert shape to polygon | -| [`asPolyline()`](https://docs.thi.ng/umbrella/geom/functions/asPolyline.html) | convert shape to polyline | +| [`asPolygon()`](https://docs.thi.ng/umbrella/geom/functions/asPolygon.html) | convert shape to polygon(s) | +| [`asPolyline()`](https://docs.thi.ng/umbrella/geom/functions/asPolyline.html) | convert shape to polyline(s) | | [`asSvg()`](https://docs.thi.ng/umbrella/geom/functions/asSvg.html) | serialize shape/group/hierarchy to SVG | | [`bounds()`](https://docs.thi.ng/umbrella/geom/functions/bounds.html) | compute bounding box | | [`center()`](https://docs.thi.ng/umbrella/geom/functions/center.html) | center shape around origin or point | @@ -122,6 +124,7 @@ directly and/or perform automatic resampling/conversion if needed). | [`offset()`](https://docs.thi.ng/umbrella/geom/functions/offset.html) | shape/path offsetting | | [`pointAt()`](https://docs.thi.ng/umbrella/geom/functions/pointAt.html) | compute point on shape boundary at parametric position | | [`pointInside()`](https://docs.thi.ng/umbrella/geom/functions/pointInside.html) | check if point is inside shape | +| [`proximity()`](https://docs.thi.ng/umbrella/geom/functions/proximity.html) | distance from point to shape boundary | | [`resample()`](https://docs.thi.ng/umbrella/geom/functions/resample.html) | resample/convert shape | | [`rotate()`](https://docs.thi.ng/umbrella/geom/functions/rotate.html) | rotate shape | | [`scale()`](https://docs.thi.ng/umbrella/geom/functions/scale.html) | scale shape (uniformly/non-uniformly) | @@ -210,7 +213,7 @@ For Node.js REPL: const geom = await import("@thi.ng/geom"); ``` -Package sizes (brotli'd, pre-treeshake): ESM: 14.23 KB +Package sizes (brotli'd, pre-treeshake): ESM: 14.40 KB ## Dependencies diff --git a/packages/geom/tpl.readme.md b/packages/geom/tpl.readme.md index cc64d7172d..9500a34751 100644 --- a/packages/geom/tpl.readme.md +++ b/packages/geom/tpl.readme.md @@ -17,28 +17,29 @@ name](http://thi.ng/geom-clj). All polymorphic operations built on The following shape primitives are provided. For many there're multiple ways to create them, please check linked sources and/or docs. -| Shape/Form | Description | Hiccup support | -|-------------------------------------------------------------------------------------------------------|------------------------------|-----------------| -| [AABB](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/aabb.ts) | 3D Axis-aligned bounding box | ✅(2) | -| [Arc](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/arc.ts) | 2D elliptic arc | ✅ | -| [Circle](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/circle.ts) | 2D circle | ✅ | -| [Cubic](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/cubic.ts) | nD cubic bezier | ✅(1) | -| [Ellipse](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/ellipse.ts) | 2D ellipse | ✅ | -| [Group](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/group.ts) | group of 2D shapes | ✅ | -| [Line](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/line.ts) | 2D line segment | ✅ | -| [Path](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/path-builder.ts) | 2D path | ✅ | -| [Path (from SVG)](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/path-from-svg.ts) | 2D path from SVG `` | ✅ | -| [Plane](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/plane.ts) | 3D plane | ✅(2) | -| [Point cloud](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/points.ts) | nD point cloud | ✅(1) | -| [Polygon](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/polygon.ts) | 2D simple polygon (no holes) | ✅ | -| [Polyline](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/polyline.ts) | 2D polyline | ✅ | -| [Quad](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/quad.ts) | 2D/3D quad (4-gon) | ✅(1) | -| [Quadratic](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/quadratic.ts) | nD quadratic bezier | ✅(1) | -| [Ray](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/ray.ts) | nD ray | ✅(1) | -| [Rectangle](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/rect.ts) | 2D rectangle | ✅ | -| [Sphere](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/sphere.ts) | 3D sphere | ✅(2) | -| [Text](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/text.ts) | Basic stub for text labels | ✅(3) | -| [Triangle](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/triangle.ts) | 2D triangle | ✅ | +| Shape/Form | Description | Hiccup support | +|--------------------------------------------------------------------------------------------------------|---------------------------------------|-----------------| +| [AABB](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/aabb.ts) | 3D Axis-aligned bounding box | ✅(2) | +| [Arc](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/arc.ts) | 2D elliptic arc | ✅ | +| [Circle](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/circle.ts) | 2D circle | ✅ | +| [ComplexPolygon](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/complex-polygon.ts) | 2D polygon w/ holes | ✅ | +| [Cubic](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/cubic.ts) | nD cubic bezier | ✅(1) | +| [Ellipse](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/ellipse.ts) | 2D ellipse | ✅ | +| [Group](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/group.ts) | group of 2D shapes | ✅ | +| [Line](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/line.ts) | 2D line segment | ✅ | +| [Path](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/path-builder.ts) | 2D path (w/ optional holes/sub-paths) | ✅ | +| [Path (from SVG)](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/path-from-svg.ts) | 2D path from SVG | ✅ | +| [Plane](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/plane.ts) | 3D plane | ✅(2) | +| [Point cloud](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/points.ts) | nD point cloud | ✅(1) | +| [Polygon](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/polygon.ts) | 2D simple polygon (no holes) | ✅ | +| [Polyline](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/polyline.ts) | 2D polyline | ✅ | +| [Quad](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/quad.ts) | 2D/3D quad (4-gon) | ✅(1) | +| [Quadratic](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/quadratic.ts) | nD quadratic bezier | ✅(1) | +| [Ray](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/ray.ts) | nD ray | ✅(1) | +| [Rectangle](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/rect.ts) | 2D rectangle | ✅ | +| [Sphere](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/sphere.ts) | 3D sphere | ✅(2) | +| [Text](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/text.ts) | Basic stub for text labels | ✅(3) | +| [Triangle](https://github.com/thi-ng/umbrella/blob/develop/packages/geom/src/triangle.ts) | 2D triangle | ✅ | - (1) valid hiccup format, currently only useable/supported if 2D geometry - (2) valid hiccup format, currently unused/unsupported elsewhere @@ -50,9 +51,10 @@ With very few exceptions these all are implementing the [`IToHiccup` interface](https://docs.thi.ng/umbrella/api/interfaces/IToHiccup.html) and so can be easily converted (via [hiccup](https://github.com/thi-ng/umbrella/tree/develop/packages/hiccup)) to a -variety of other formats. By design, for better flexibility and performance -reasons, the hiccup flavor used by this package is **not** compatible with that -used by +variety of other formats, incl. [conversion to SVG](#svg-support). + +By design, for better flexibility and performance reasons, the hiccup flavor +used by this package is **not** compatible with that used by [thi.ng/hiccup-svg](https://github.com/thi-ng/umbrella/tree/develop/packages/hiccup-svg), though the latter provides a [`convertTree()`](https://docs.thi.ng/umbrella/hiccup-svg/functions/convertTree.html) @@ -65,7 +67,6 @@ SVG conversion is included via the [`asSvg()`](https://docs.thi.ng/umbrella/geom/functions/asSvg.html) and [`svgDoc()`](https://docs.thi.ng/umbrella/geom/functions/svgDoc.html) functions. - ### Polymorphic operations The following operations are provided (many also applicable to shape groups @@ -78,8 +79,8 @@ directly and/or perform automatic resampling/conversion if needed). | [`area()`](https://docs.thi.ng/umbrella/geom/functions/area.html) | signed/unsigned surface area | | [`asCubic()`](https://docs.thi.ng/umbrella/geom/functions/asCubic.html) | convert shape boundary to cubic bezier segments | | [`asPath()`](https://docs.thi.ng/umbrella/geom/functions/asPath.html) | convert shape to path | -| [`asPolygon()`](https://docs.thi.ng/umbrella/geom/functions/asPolygon.html) | convert shape to polygon | -| [`asPolyline()`](https://docs.thi.ng/umbrella/geom/functions/asPolyline.html) | convert shape to polyline | +| [`asPolygon()`](https://docs.thi.ng/umbrella/geom/functions/asPolygon.html) | convert shape to polygon(s) | +| [`asPolyline()`](https://docs.thi.ng/umbrella/geom/functions/asPolyline.html) | convert shape to polyline(s) | | [`asSvg()`](https://docs.thi.ng/umbrella/geom/functions/asSvg.html) | serialize shape/group/hierarchy to SVG | | [`bounds()`](https://docs.thi.ng/umbrella/geom/functions/bounds.html) | compute bounding box | | [`center()`](https://docs.thi.ng/umbrella/geom/functions/center.html) | center shape around origin or point | @@ -96,6 +97,7 @@ directly and/or perform automatic resampling/conversion if needed). | [`offset()`](https://docs.thi.ng/umbrella/geom/functions/offset.html) | shape/path offsetting | | [`pointAt()`](https://docs.thi.ng/umbrella/geom/functions/pointAt.html) | compute point on shape boundary at parametric position | | [`pointInside()`](https://docs.thi.ng/umbrella/geom/functions/pointInside.html) | check if point is inside shape | +| [`proximity()`](https://docs.thi.ng/umbrella/geom/functions/proximity.html) | distance from point to shape boundary | | [`resample()`](https://docs.thi.ng/umbrella/geom/functions/resample.html) | resample/convert shape | | [`rotate()`](https://docs.thi.ng/umbrella/geom/functions/rotate.html) | rotate shape | | [`scale()`](https://docs.thi.ng/umbrella/geom/functions/scale.html) | scale shape (uniformly/non-uniformly) |