@pbroom/color-kit/planeMapping

scaleRegion

Returns a copy of a region scaled by (sx, sy) about origin.

functionimport { scaleRegion } from '@pbroom/color-kit/plane';transforms.ts:74
function scaleRegion(
  region: PlaneRegion,
  sx: number,
  sy?: number,
  origin?: PlanePoint,
): PlaneRegion;

Operates on raw point coordinates, so offsets are in the region's own space (plane-normalized units for query results, where 1 is one full axis span). Points are not clamped to [0, 1]. Returns a new region; the input is not mutated. Negative factors mirror the region across origin.

Parameters

regionPlaneRegion
Region to scale.
sxnumber
Horizontal scale factor.
sy?numberdefault sx
Vertical scale factor. Defaults to sx (uniform scale).
origin?PlanePoint
Fixed point of the scale. Defaults to the plane centre { x: 0.5, y: 0.5 }.

Returns

PlaneRegionThe scaled region.

Example

TypeScript
import { scaleRegion } from '@pbroom/color-kit/plane';

const full = { paths: [[{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 1, y: 1 }, { x: 0, y: 1 }]] };

scaleRegion(full, 0.5).paths[0];
// → [{ x: 0.25, y: 0.25 }, { x: 0.75, y: 0.25 }, { x: 0.75, y: 0.75 }, { x: 0.25, y: 0.75 }]

See also

Also exported from