@pbroom/color-kit/planeMapping

translateRegion

Returns a copy of a region with every point shifted by (dx, dy).

functionimport { translateRegion } from '@pbroom/color-kit/plane';transforms.ts:37
function translateRegion(
  region: PlaneRegion,
  dx: number,
  dy: number,
): 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.

Parameters

regionPlaneRegion
Region to move.
dxnumber
Horizontal offset.
dynumber
Vertical offset.

Returns

PlaneRegionThe translated region.

Example

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

const square = { paths: [[{ x: 0, y: 0 }, { x: 0.5, y: 0 }, { x: 0.5, y: 0.5 }, { x: 0, y: 0.5 }]] };

translateRegion(square, 0.25, 0.1).paths[0];
// → [{ x: 0.25, y: 0.1 }, { x: 0.75, y: 0.1 }, { x: 0.75, y: 0.6 }, { x: 0.25, y: 0.6 }]

See also

Also exported from