@pbroom/color-kit/planeMapping
rotateRegion
Returns a copy of a region rotated by angleDeg degrees about origin.
import { rotateRegion } from '@pbroom/color-kit/plane';transforms.ts:115function rotateRegion(
region: PlaneRegion,
angleDeg: 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.
Positive angles turn from +x toward +y. Plane points have y increasing downward when drawn (as in toSvgPath output), so positive angles appear clockwise on screen.
Parameters
- region
PlaneRegion - Region to rotate.
- angleDeg
number - Rotation angle in degrees.
- origin?
PlanePoint - Centre of rotation. Defaults to the plane centre
{ x: 0.5, y: 0.5 }.
Returns
PlaneRegionThe rotated region.
Example
import { rotateRegion } from '@pbroom/color-kit/plane';
const corner = { paths: [[{ x: 0.5, y: 0.5 }, { x: 1, y: 0.5 }, { x: 1, y: 1 }, { x: 0.5, y: 1 }]] };
rotateRegion(corner, 90).paths[0];
// → [{ x: 0.5, y: 0.5 }, { x: 0.5, y: 1 }, { x: 0, y: 1 }, { x: 0, y: 0.5 }]See also
Also exported from
@pbroom/color-kitthe same declaration, re-exported