PavePave
Home
Guide
API
Sandbox
  • English
  • 日本語
GitHub
Home
Guide
API
Sandbox
  • English
  • 日本語
GitHub
  • Distort

@baku89/pave v0.7.2


@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

ParameterTypeDescription
centervec2Origin of the radial warp.
radiusnumberOutside this distance from center, the warp does nothing.
strengthnumberScale added along each ray from center at full falloff (0 = identity). Positive pushes outward, negative pinches inward.
ramp(t) => numberFalloff from center (1 at center, 0 at radius); default is linear.

Returns

Function

Parameters
ParameterType
pvec2
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

ParameterTypeDescription
map(p) => vec2For any point, returns its image after your warp.

Returns

Function

A distortion callback.

Parameters
ParameterType
pvec2
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

ParameterTypeDescription
centervec2Pivot for the rotation.
radiusnumberOutside this distance from center, the warp does nothing.
anglenumberLargest rotation at the center, in degrees (scaled by ramp toward the edge).
ramp(t) => numberOptional curve on the falloff from center (1 at center, 0 at radius); default is straight-line falloff.

Returns

Function

Parameters
ParameterType
pvec2
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

ParameterTypeDefault valueDescription
amplitudenumberundefinedHow far points move perpendicular to the wave direction.
widthnumberundefinedDistance along the wave for one full cycle (non-zero).
phasenumber0Shifts the wave along its direction, in degrees.
anglenumber0Rotates the wave direction in the plane, in degrees.
originvec2vec2.zeroA reference point on the wave axis (with angle, fixes the frame).

Returns

Function

Parameters
ParameterType
pvec2
Returns

mat2d

Example

Edit this page