Skip to content

Commit

Permalink
docs(ramp): update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Feb 12, 2024
1 parent 62c01d1 commit 17d5260
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
21 changes: 19 additions & 2 deletions packages/ramp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- [Numeric](#numeric)
- [nD vectors](#nd-vectors)
- [Nested objects](#nested-objects)
- [Grouped & nested ramps](#grouped--nested-ramps)
- [Authors](#authors)
- [License](#license)

Expand Down Expand Up @@ -74,7 +75,7 @@ For Node.js REPL:
const ramp = await import("@thi.ng/ramp");
```

Package sizes (brotli'd, pre-treeshake): ESM: 1.25 KB
Package sizes (brotli'd, pre-treeshake): ESM: 1.66 KB

## Dependencies

Expand Down Expand Up @@ -195,7 +196,7 @@ const r = ramp(

// produce an iterator of N uniformly spaced sample points
// across the full range of the ramp
console.log([...r.interpolatedPoints(10)]);
console.log([...r.samples(10)]);

// [
// [0, { a: 0, b: { c: [100, 100] } }],
Expand All @@ -212,6 +213,22 @@ console.log([...r.interpolatedPoints(10)]);
// ]
```

### Grouped & nested ramps

```ts tangle:export/readme-group.ts
import { LINEAR_V, group, linear, ramp, wrap } from "@thi.ng/ramp";
import { VEC2 } from "@thi.ng/vectors";

const example = group({
// child timeline with looping behavior
a: linear([[0,0], [20, 100]], { domain: wrap }),
// another child timeline
b: linear([[10, 100], [90, 200]])
});

console.log([...example.samples(20)]);
```

## Authors

- [Karsten Schmidt](https://thi.ng)
Expand Down
30 changes: 29 additions & 1 deletion packages/ramp/tpl.readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const r = ramp(

// produce an iterator of N uniformly spaced sample points
// across the full range of the ramp
console.log([...r.interpolatedPoints(10)]);
console.log([...r.samples(10)]);

// [
// [0, { a: 0, b: { c: [100, 100] } }],
Expand All @@ -149,4 +149,32 @@ console.log([...r.interpolatedPoints(10)]);
// ]
```

### Grouped & nested ramps

```ts tangle:export/readme-group.ts
import { group, linear, wrap } from "@thi.ng/ramp";

const example = group({
// child timeline with looping behavior
a: linear([[0, 0], [20, 100]], { domain: wrap }),
// another child timeline
b: linear([[10, 100], [90, 200]]),
});

console.log(JSON.stringify([...example.samples(10, 0, 100)]));
// [
// [0, { a: 0, b: 100 }],
// [10, { a: 50, b: 100 }],
// [20, { a: 100, b: 112.5 }],
// [30, { a: 50, b: 125 }],
// [40, { a: 100, b: 137.5 }],
// [50, { a: 50, b: 150 }],
// [60, { a: 0, b: 162.5 }],
// [70, { a: 50, b: 175 }],
// [80, { a: 0, b: 187.5 }],
// [90, { a: 50, b: 200 }],
// [100, { a: 50, b: 200 }]
// ]
```

<!-- include ../../assets/tpl/footer.md -->

0 comments on commit 17d5260

Please sign in to comment.