Struct Region2D

Rectangular raster region.

struct Region2D;

x and y identify the region origin in its enclosing coordinate system. width and height are extents.

The owner of a Region2D defines the coordinate-space semantics.

Empty regions are representable.

Methods

NameDescription
containsRelative (relative) Tests whether relative fits inside this region when relative.x and relative.y are interpreted relative to this region's origin.
empty () Returns true if either extent is zero.
hasRepresentableExtent () Returns true when the translated end coordinates can be represented without overflowing size_t.
tryResolveRelative (relative, resolved) Resolves a relative child region into the same enclosing coordinate system as this region.

Example

Example using Region2D as coordinate-free rectangular geometry.

import raster;

const region = Region2D(12, 9, 5, 4);
assert(region.x == 12 && region.y == 9);
assert(region.width == 5 && region.height == 4);