@pbroom/color-kit/planeMapping
translateRegion
Returns a copy of a region with every point shifted by (dx, dy).
import { translateRegion } from '@pbroom/color-kit/plane';transforms.ts:37function 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
- region
PlaneRegion - Region to move.
- dx
number - Horizontal offset.
- dy
number - Vertical offset.
Returns
PlaneRegionThe translated region.
Example
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
@pbroom/color-kitthe same declaration, re-exported