UVBounds
The area that UV edits keep regions in: the texture, extended by UVMap.overflow texture pixels past each edge. Read it from UVMap.bounds. It is immutable; changing the canvas size or overflow gives a new value on the next read.
const { bounds } = canvas.uv;
bounds.fit({ x: -40, y: 2, width: 8, height: 8 });
// with a 32x32 texture and overflow 4: { x: -4, y: 2, width: 8, height: 8 }Properties
size / overflow
readonly size: Vec2
readonly overflow: numberThe texture size and the overflow the area was built from.
limit
get limit(): SelectionRect | nullThe whole area as a rect, starting at -overflow, -overflow. It is null when overflow is 0, because the area is the texture itself, or Infinity, because there is no edge to show. UV mode draws this rect as the "UV limit" outline.
Methods
fit(rect)
fit(rect: SelectionRect): SelectionRectReturns rect moved the least distance needed to sit inside the area. The size never changes. A rect wider or taller than the area is pinned to its top or left edge and hangs off the far one.
clamp(region, slot?)
clamp(region: UVRegion, slot?: UVSlot | null): UVRegionFits one slot of region, or the whole region when slot is null, which is the default. A whole region keeps its shape and moves as one piece.
move(region, position, slot)
move(region: UVRegion, position: Vec2, slot: UVSlot | null): UVRegionPlaces one slot, or the whole region when slot is null, at position, then fits it. This is how UVMap.move() clamps.
resize(region, rect, slot, options)
resize(
region: UVRegion,
rect: SelectionRect,
slot: UVSlot | null,
options: UVResizeOptions
): UVRegionResizes like UVRegion.resized(), with sizes raised to at least 1px. An edge that would cross the area's border stops on it. A region already past the border keeps its position but cannot grow further out. This is how UVMap.resize() clamps.