Skip to content

Commit 2b6aefa

Browse files
committed
documentation fix
1 parent 8829c2d commit 2b6aefa

9 files changed

Lines changed: 53 additions & 30 deletions

File tree

docs/content/docs/api/builders.mdx

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,57 @@ import { createStar, createCircle, createRectangle, createPolygon, cornerRoundin
1212
## `createCircle`
1313

1414
```ts
15-
createCircle(vertices?: number): RoundedPolygon
15+
createCircle(numVertices?: number, radius?: number, centerX?: number, centerY?: number): RoundedPolygon
1616
```
1717

18-
Creates a circle approximation using cubic Bezier curves. Default is 8 vertices. More vertices = smoother circle.
18+
Creates a circle approximation using cubic Bezier curves. Default is 8 vertices, radius 1, centered at the origin. More vertices = smoother circle.
1919

2020
## `createRectangle`
2121

2222
```ts
23-
createRectangle(width: number, height: number, rounding?: CornerRounding): RoundedPolygon
23+
createRectangle(
24+
width?: number,
25+
height?: number,
26+
rounding?: CornerRounding,
27+
perVertexRounding?: CornerRounding[] | null,
28+
centerX?: number,
29+
centerY?: number
30+
): RoundedPolygon
2431
```
2532

26-
Creates a rectangle with optional corner rounding.
33+
Creates a rectangle with optional corner rounding. Defaults to a 2x2 rectangle centered at the origin. Use `perVertexRounding` to apply different rounding to each corner.
2734

2835
## `createStar`
2936

3037
```ts
3138
createStar(
32-
points: number,
33-
outerRadius: number,
34-
innerRadius: number,
35-
rounding: CornerRounding
39+
numVerticesPerRadius: number,
40+
radius?: number,
41+
innerRadius?: number,
42+
rounding?: CornerRounding,
43+
innerRounding?: CornerRounding | null,
44+
perVertexRounding?: CornerRounding[] | null,
45+
centerX?: number,
46+
centerY?: number
3647
): RoundedPolygon
3748
```
3849

39-
Creates a star polygon. `innerRadius` is relative to `outerRadius` - a value of `0.5` means the inner points are halfway to the center.
50+
Creates a star polygon. Defaults to radius 1, inner radius 0.5, centered at the origin. `innerRadius` is relative to `radius` - a value of `0.5` means the inner points are halfway to the center. Use `innerRounding` to apply different rounding to inner vertices.
4051

4152
## `createPolygon`
4253

4354
```ts
44-
createPolygon(vertices: number, rounding: CornerRounding): RoundedPolygon
55+
createPolygon(
56+
numVertices: number,
57+
radius?: number,
58+
centerX?: number,
59+
centerY?: number,
60+
rounding?: CornerRounding,
61+
perVertexRounding?: CornerRounding[] | null
62+
): RoundedPolygon
4563
```
4664

47-
Creates a regular polygon (triangle, pentagon, hexagon, etc.) with the given number of vertices.
65+
Creates a regular polygon (triangle, pentagon, hexagon, etc.) with the given number of vertices. Defaults to radius 1, centered at the origin, with no rounding.
4866

4967
## `cornerRounding`
5068

@@ -54,13 +72,13 @@ cornerRounding(radius: number, smoothing?: number): CornerRounding
5472

5573
Creates a corner rounding configuration.
5674

57-
- **radius** (01): Fraction of edge length used for rounding. `0` is sharp, `1` rounds the entire edge.
58-
- **smoothing** (01, default `0`): Cubic Bezier easing applied to the rounding. `0` gives circular arcs, higher values produce softer organic curves.
75+
- **radius** (0-1): Fraction of edge length used for rounding. `0` is sharp, `1` rounds the entire edge.
76+
- **smoothing** (0-1, default `0`): Cubic Bezier easing applied to the rounding. `0` gives circular arcs, higher values produce softer organic curves.
5977

6078
## `RoundedPolygon`
6179

6280
The base shape class. Key methods:
6381

6482
### `.normalized(): RoundedPolygon`
6583

66-
Returns a copy centered at the origin and scaled to fit within a unit circle. **Required before passing custom polygons to `Morph`.**
84+
Returns a copy scaled to fit within a 0-1 coordinate space (unit square), centered within the bounding box. **Required before passing custom polygons to `Morph`.**

docs/content/docs/api/core.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Creates a morph between two shapes. Handles feature-matching, subdivision, and i
1919

2020
### `morph.asCubics(progress: number): Cubic[]`
2121

22-
Returns the interpolated cubic curves at the given progress (01). Progress 0 is the start shape, 1 is the end shape.
22+
Returns the interpolated cubic curves at the given progress (0-1). Progress 0 is the start shape, 1 is the end shape.
2323

2424
## `getShape`
2525

@@ -32,7 +32,7 @@ Returns a preset Material Design 3 shape as a `RoundedPolygon`. See [Available S
3232
## `shapeNames`
3333

3434
```ts
35-
const shapeNames: readonly ShapeName[]
35+
const shapeNames: ShapeName[]
3636
```
3737
3838
Array of all 35 shape names. Useful for iteration.

docs/content/docs/api/output.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ The fixed vertex count is what makes CSS transitions work - both start and end p
3838
## `toClipPathPath`
3939

4040
```ts
41-
toClipPathPath(cubics: Cubic[], samples?: number): string
41+
toClipPathPath(cubics: Cubic[], size?: number): string
4242
```
4343

44-
Converts cubics to a CSS `clip-path: path("...")` string. Preserves exact cubic Bezier curves. CSS **cannot** transition between two `path()` values, so use this only for static shapes.
44+
Converts cubics to a CSS `clip-path: path("...")` string. Optional `size` scales the output (default 100). Preserves exact cubic Bezier curves. CSS **cannot** transition between two `path()` values, so use this only for static shapes.
4545

4646
## `toMorphPair`
4747

docs/content/docs/guides/custom-shapes.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ import { createPolygon, cornerRounding } from "shape-morph";
3939

4040
const hexagon = createPolygon(
4141
6, // number of vertices
42+
1, // radius
43+
0, // centerX
44+
0, // centerY
4245
cornerRounding(0.1) // corner rounding
4346
);
4447
```
@@ -58,8 +61,8 @@ const smoothCircle = createCircle(16); // more vertices = smoother
5861
import { cornerRounding } from "shape-morph";
5962

6063
const rounding = cornerRounding(
61-
0.2, // radius (01, fraction of edge length)
62-
0.5 // smoothing (01, optional, default 0)
64+
0.2, // radius (0-1, fraction of edge length)
65+
0.5 // smoothing (0-1, optional, default 0)
6366
);
6467
```
6568

@@ -80,4 +83,4 @@ const morph = new Morph(star.normalized(), rect.normalized());
8083
const d = toPathD(morph.asCubics(0.5), 200);
8184
```
8285

83-
`.normalized()` centers the shape at the origin and scales it to fit within a unit circle. This ensures both shapes share the same coordinate space for morphing.
86+
`.normalized()` scales the shape to fit within a 0-1 coordinate space (unit square), centered within the bounding box. This ensures both shapes share the same coordinate space for morphing.

docs/content/docs/guides/react.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ Props:
2121
| Prop | Type | Default | Description |
2222
|---|---|---|---|
2323
| `name` | `ShapeName` | required | Shape to render |
24-
| `size` | `number` | `24` | Width and height in pixels |
24+
| `size` | `number` | `48` | Width and height in pixels |
2525
| `fill` | `string` | `"currentColor"` | Fill color |
2626
| `stroke` | `string` | - | Stroke color |
27+
| `strokeWidth` | `number` | - | Stroke width |
2728
| `className` | `string` | - | Class on the `<svg>` element |
2829
| `style` | `CSSProperties` | - | Style on the `<svg>` element |
2930

@@ -58,17 +59,18 @@ Change the target `progress` and the hook smoothly animates from the current pos
5859

5960
| Option | Type | Default | Description |
6061
|---|---|---|---|
61-
| `progress` | `number` | `0` | Target progress (01) |
62+
| `progress` | `number` | `0` | Target progress (0-1) |
6263
| `duration` | `number` | `300` | Animation duration in ms |
63-
| `size` | `number` | - | Output size for `pathD` |
64+
| `samples` | `number` | `4` | Samples per cubic for polygon output |
65+
| `size` | `number` | `100` | Output size for `pathD` |
6466

6567
### Return value
6668

6769
| Property | Type | Description |
6870
|---|---|---|
6971
| `pathD` | `string` | SVG path `d` attribute |
7072
| `clipPath` | `string` | CSS `clip-path: polygon(...)` |
71-
| `progress` | `number` | Current animated progress (01) |
73+
| `progress` | `number` | Current animated progress (0-1) |
7274

7375
The `progress` return value is the eased, animated value - not the target. Use it to sync other animations like rotation or color transitions.
7476

src/core/material-shapes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Ported from AOSP MaterialShapes.kt
22

3-
// all 37 Material Design 3 predefined shapes
3+
// all 35 Material Design 3 predefined shapes
44

55
import {
66
type CornerRounding,

src/output/clip-path.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function toClipPathPath(cubics: Cubic[], size = 100): string {
4242
* // Both have the same vertex count → CSS can transition between them
4343
* ```
4444
*
45-
* @param cubics - Array of Cubic bezier curves (normalized 01)
45+
* @param cubics - Array of Cubic bezier curves (normalized 0-1)
4646
* @param samplesPerCubic - Points to sample per cubic segment (default 4)
4747
* @returns CSS `polygon(...)` string with percentage coordinates
4848
*/

src/output/svg-path.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { RoundedPolygon } from "../core/polygon";
88
* anchor1 (end). These map to the SVG cubic bezier command:
99
* C control0X,control0Y control1X,control1Y anchor1X,anchor1Y
1010
*
11-
* Shapes from `getShape()` are normalized to 01 coordinates.
11+
* Shapes from `getShape()` are normalized to 0-1 coordinates.
1212
* The `size` parameter scales them to pixel/viewBox space.
1313
*/
1414
export function toPathD(cubics: Cubic[], size = 100): string {

src/react/use-morph.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { toClipPathPolygon } from "../output/clip-path";
55
import { toPathD } from "../output/svg-path";
66

77
export interface MorphOptions {
8-
/** Target progress (01). Changes trigger animation. */
8+
/** Target progress (0-1). Changes trigger animation. */
99
progress: number;
1010
/** Animation duration in ms (default 300) */
1111
duration?: number;
@@ -20,7 +20,7 @@ export interface MorphOutput {
2020
pathD: string;
2121
/** CSS `clip-path: polygon(...)` value */
2222
clipPath: string;
23-
/** Current animated progress (01) */
23+
/** Current animated progress (0-1) */
2424
progress: number;
2525
}
2626

0 commit comments

Comments
 (0)