Skip to content

Commit

Permalink
docs(geom-trace-bitmap): update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Dec 26, 2022
1 parent c4c35f4 commit 2f671d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
19 changes: 11 additions & 8 deletions packages/geom-trace-bitmap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ This project is part of the

Bitmap image to hairline vector and point cloud conversions. This is a support package for [@thi.ng/geom](https://github.com/thi-ng/umbrella/tree/develop/packages/geom).

This package extracts user selectable single-pixel width line segments in
horizontal, vertical and diagonal (45°) directions and/or extracts as pixels 2d
point cloud. The main
This package provides an extensible setup to extract user selectable
single-pixel width line segments in horizontal, vertical and diagonal (45°)
directions and/or single pixels 2d point cloud. The main
[`traceBitmap()`](https://docs.thi.ng/umbrella/geom-trace-bitmap/functions/traceBitmap.html)
function supports a predicate function to filter qualifying pixel values,
options to control which line orientations should be considered (and in which
order) and a 2x3 matrix to transform extracted points (coordinates). See
options to control which line orientations should be considered (incl. providing
custom ones and in which order of application), as well as a 2x3 matrix to
transform extracted points (pixel coordinates). See
[`TraceBitmapOpts`](https://docs.thi.ng/umbrella/geom-trace-bitma/interfaces/TraceBitmapOpts.html)
and example below for details.

Expand Down Expand Up @@ -64,7 +65,7 @@ For Node.js REPL:
const geomTraceBitmap = await import("@thi.ng/geom-trace-bitmap");
```

Package sizes (brotli'd, pre-treeshake): ESM: 655 bytes
Package sizes (brotli'd, pre-treeshake): ESM: 697 bytes

## Dependencies

Expand Down Expand Up @@ -97,7 +98,9 @@ import { traceBitmap } from "@thi.ng/geom-trace-bitmap";
import { read } from "@thi.ng/pixel-io-netpbm";
import { readFileSync, writeFileSync } from "fs";

// vectorize bitmap
// vectorize bitmap, the returned arrays contain:
// - pairs of vectors (line segments)
// - vectors (points)
const { lines, points: dots } = traceBitmap({
// source image (WILL be mutated!)
img: read(readFileSync("foo.pgm")),
Expand All @@ -114,7 +117,7 @@ writeFileSync(
svgDoc(
{},
group({}, lines.map(([a,b]) => line(a, b))),
points(dots)
points(dots, { fill: "#000", stroke: "none" })
)
)
);
Expand Down
17 changes: 10 additions & 7 deletions packages/geom-trace-bitmap/tpl.readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

{{pkg.description}}

This package extracts user selectable single-pixel width line segments in
horizontal, vertical and diagonal (45°) directions and/or extracts as pixels 2d
point cloud. The main
This package provides an extensible setup to extract user selectable
single-pixel width line segments in horizontal, vertical and diagonal (45°)
directions and/or single pixels 2d point cloud. The main
[`traceBitmap()`](https://docs.thi.ng/umbrella/geom-trace-bitmap/functions/traceBitmap.html)
function supports a predicate function to filter qualifying pixel values,
options to control which line orientations should be considered (and in which
order) and a 2x3 matrix to transform extracted points (coordinates). See
options to control which line orientations should be considered (incl. providing
custom ones and in which order of application), as well as a 2x3 matrix to
transform extracted points (pixel coordinates). See
[`TraceBitmapOpts`](https://docs.thi.ng/umbrella/geom-trace-bitma/interfaces/TraceBitmapOpts.html)
and example below for details.

Expand Down Expand Up @@ -58,7 +59,9 @@ import { traceBitmap } from "@thi.ng/geom-trace-bitmap";
import { read } from "@thi.ng/pixel-io-netpbm";
import { readFileSync, writeFileSync } from "fs";

// vectorize bitmap
// vectorize bitmap, the returned arrays contain:
// - pairs of vectors (line segments)
// - vectors (points)
const { lines, points: dots } = traceBitmap({
// source image (WILL be mutated!)
img: read(readFileSync("foo.pgm")),
Expand All @@ -75,7 +78,7 @@ writeFileSync(
svgDoc(
{},
group({}, lines.map(([a,b]) => line(a, b))),
points(dots)
points(dots, { fill: "#000", stroke: "none" })
)
)
);
Expand Down

0 comments on commit 2f671d3

Please sign in to comment.