ViewRect Class

A rectangle in unsigned integer view coordinates with (0,0) corresponding to the top-left corner of the view. Increasing x moves from left to right, and increasing y moves from top to bottom. ViewRect.left, ViewRect.top, ViewRect.right, and ViewRect.bottom are required to be non-negative integers; any negative inputs are treated as zero and any non-integer inputs are rounded down to the nearest integer.

extensions

Methods

Name Description
constructor(left: number = 0, top: number = 0, right: number = 0, bottom: number = 0): ViewRect Construct a new ViewRect.  
clone(result?: ViewRect): ViewRect Duplicate this ViewRect.  
computeOverlap(other: ViewRect, out?: ViewRect): undefined | ViewRect Return a ViewRect that is the overlap (intersection) of this ViewRect and another ViewRect.  
containsPoint(point: Readonly<WritableXAndY>): boolean Return true if the supplied point is contained in this ViewRect.  
equals(other: ViewRect): boolean Return true is this ViewRect is exactly equal to another ViewRect.  
extend(other: ViewRect): void    
init(left: number, top: number, right: number, bottom: number): void Initialize this ViewRect from its left/top/right/bottom parameters.  
initFromPoints(topLeft: Readonly<WritableXAndY>, bottomRight: Readonly<WritableXAndY>): void Initialize this ViewRect from two points.  
initFromRange(input: Readonly<WritableLowAndHighXY>): void Initialize this ViewRect from a range.  
inset(deltaX: number, deltaY: number): void Inset this ViewRect by values in the x and y directions.  
insetByPercent(percent: number): void Inset this ViewRect by a percentage of its current width.  
insetUniform(offset: number): void Inset this ViewRect by the same value in all directions.  
isContained(other: ViewRect): boolean Determine if this ViewRect is entirely contained within the bounds of another ViewRect.  
overlaps(other: ViewRect): boolean Determine whether this ViewRect overlaps another.  
scaleAboutCenter(xScale: number, yScale: number): void Scale this ViewRect about its center by the supplied scale factors.  
setFrom(other: ViewRect): void Initialize this ViewRect from another ViewRect.  

Properties

Name Type Description
area Accessor ReadOnly number The area (width*height) of this ViewRect.  
aspect Accessor ReadOnly number The aspect ratio (width/height) of this ViewRect.  
bottom Accessor number The bottommost side of this ViewRect.  
height Accessor number The height (bottom-top) of this ViewRect.  
isNull Accessor ReadOnly boolean True if this ViewRect has an area <= 0.  
isValid Accessor ReadOnly boolean True if !isNull  
left Accessor number The leftmost side of this ViewRect.  
right Accessor number The rightmost side of this ViewRect.  
top Accessor number The topmost side of this ViewRect.  
width Accessor number The width (right-left) of this ViewRect.  

Defined in

Last Updated: 30 November, 2023