Skip to content

Commit

Permalink
docs(geom-sdf): update readme example
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jun 23, 2022
1 parent 7313984 commit 6c46434
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 4 additions & 5 deletions packages/geom-sdf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Package sizes (gzipped, pre-treeshake): ESM: 3.87 KB
[Generated API docs](https://docs.thi.ng/umbrella/geom-sdf/)

```js
import { asSvg, bounds, circle, group, simplify, svgDoc } from "@thi.ng/geom";
import { asSvg, bounds, circle, group, svgDoc } from "@thi.ng/geom";
import { asPolygons, asSDF, sample2d } from "@thi.ng/geom-sdf";
import { range, repeatedly } from "@thi.ng/transducers";
import { randMinMax2 } from "@thi.ng/vectors";
Expand Down Expand Up @@ -196,11 +196,10 @@ const image = sample2d(sdf, sceneBounds, RES);

// extract contour polygons from given image
// in this case the contours extracted are at distances in the [0..32) interval
// afterwards we also simplify the resulting polygons using the Douglas-Peucker algorithm
// the function also simplifies the resulting polygons using the Douglas-Peucker algorithm
// with the given threshold (0.25) - the default setting only removes co-linear vertices...
// see: https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm
const contours = asPolygons(image, sceneBounds, RES, range(0, 32, 4)).map(
(p) => simplify(p, 0.25)
);
const contours = asPolygons(image, sceneBounds, RES, range(0, 32, 4), 0.25);

// convert to SVG and output as file
writeFileSync(
Expand Down
9 changes: 4 additions & 5 deletions packages/geom-sdf/tpl.readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ ${examples}
${docLink}

```js
import { asSvg, bounds, circle, group, simplify, svgDoc } from "@thi.ng/geom";
import { asSvg, bounds, circle, group, svgDoc } from "@thi.ng/geom";
import { asPolygons, asSDF, sample2d } from "@thi.ng/geom-sdf";
import { range, repeatedly } from "@thi.ng/transducers";
import { randMinMax2 } from "@thi.ng/vectors";
Expand Down Expand Up @@ -152,11 +152,10 @@ const image = sample2d(sdf, sceneBounds, RES);

// extract contour polygons from given image
// in this case the contours extracted are at distances in the [0..32) interval
// afterwards we also simplify the resulting polygons using the Douglas-Peucker algorithm
// the function also simplifies the resulting polygons using the Douglas-Peucker algorithm
// with the given threshold (0.25) - the default setting only removes co-linear vertices...
// see: https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm
const contours = asPolygons(image, sceneBounds, RES, range(0, 32, 4)).map(
(p) => simplify(p, 0.25)
);
const contours = asPolygons(image, sceneBounds, RES, range(0, 32, 4), 0.25);

// convert to SVG and output as file
writeFileSync(
Expand Down

0 comments on commit 6c46434

Please sign in to comment.