@baku89/pave / Distort
Distort
Factories for distortion callbacks (p: vec2) => mat2d used with Path.distort. Each callback tells Path.distort where segment endpoints should land and how nearby control handles should tilt so curves follow the warp instead of shearing oddly.
Functions
bulge()
bulge(
center,radius,strength,ramp): (p) =>mat2d
Defined in: Distort.ts:144
Spherize-style radial stretch from center: strongest at the center, fading to none at radius. Points beyond radius are unchanged.
Parameters
| Parameter | Type | Description |
|---|---|---|
center | vec2 | Origin of the radial warp. |
radius | number | Outside this distance from center, the warp does nothing. |
strength | number | Scale added along each ray from center at full falloff (0 = identity). Positive pushes outward, negative pinches inward. |
ramp | (t) => number | Falloff from center (1 at center, 0 at radius); default is linear. |
Returns
Function
Parameters
| Parameter | Type |
|---|---|
p | vec2 |
Returns
mat2d
Example
fromPointMap()
fromPointMap(
map): (p) =>mat2d
Defined in: Distort.ts:31
Turn “move each point here” into a callback Path.distort understands. Nearby samples (step 0.01) infer how the warp stretches and turns locally so handles stay plausible. Very sharp or jumpy maps may look wrong.
Parameters
| Parameter | Type | Description |
|---|---|---|
map | (p) => vec2 | For any point, returns its image after your warp. |
Returns
Function
A distortion callback.
Parameters
| Parameter | Type |
|---|---|
p | vec2 |
Returns
mat2d
Example
twirl()
twirl(
center,radius,angle,ramp): (p) =>mat2d
Defined in: Distort.ts:106
Spin the plane around center: full effect at the center, none past radius, blended in between. Points outside the radius are left as-is.
Parameters
| Parameter | Type | Description |
|---|---|---|
center | vec2 | Pivot for the rotation. |
radius | number | Outside this distance from center, the warp does nothing. |
angle | number | Largest rotation at the center, in degrees (scaled by ramp toward the edge). |
ramp | (t) => number | Optional curve on the falloff from center (1 at center, 0 at radius); default is straight-line falloff. |
Returns
Function
Parameters
| Parameter | Type |
|---|---|
p | vec2 |
Returns
mat2d
Example
wave()
wave(
amplitude,width,phase,angle,origin): (p) =>mat2d
Defined in: Distort.ts:64
Push points side-to-side in a sine pattern: travel along one axis in the plane, offset along the perpendicular.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
amplitude | number | undefined | How far points move perpendicular to the wave direction. |
width | number | undefined | Distance along the wave for one full cycle (non-zero). |
phase | number | 0 | Shifts the wave along its direction, in degrees. |
angle | number | 0 | Rotates the wave direction in the plane, in degrees. |
origin | vec2 | vec2.zero | A reference point on the wave axis (with angle, fixes the frame). |
Returns
Function
Parameters
| Parameter | Type |
|---|---|
p | vec2 |
Returns
mat2d