Intersects a target rectangle with a boundary, trimming dimensions and masks in-place.
This utility calculates the axis-aligned intersection between the target and bounds.
If the target includes a mask (as in a NullableMaskRect), the mask is physically
cropped and re-aligned using extractMaskBuffer to match the new dimensions.
The boundary rectangle defining the maximum allowable area (e.g., canvas dimensions).
Returns void
Example
constselection = { x: -10, y: -10, w:50, h:50, mask:newUint8Array(2500) }; constcanvas = { x:0, y:0, w:100, h:100 }; // Selection will be moved to (0,0) and resized to 40x40. // The mask is cropped by 10 px on the top and left. trimRectBounds(selection, canvas);
Intersects a target rectangle with a boundary, trimming dimensions and masks in-place. This utility calculates the axis-aligned intersection between the
targetandbounds. If thetargetincludes amask(as in a NullableMaskRect), the mask is physically cropped and re-aligned usingextractMaskBufferto match the new dimensions.