# TRectangle TRectangle related methods Type definition is found in shared/globals.simba The rectangle is defined in clockwise order, from ``Top`` to ``Left`` - - - ## TRectangle.ToTPA ```pascal function TRectangle.ToTPA(): TPointArray; constref; ``` TPA from the rectangle. - - - ## TRectangle.Bounds ```pascal function TRectangle.Bounds(): TBox; constref; ``` Returns the minimum bounding box covering the rectangle - - - ## TRectangle.Radius ```pascal function TRectangle.Radius(): Double; constref; ``` Returns the radius of the shortest side, for the maximum see MaxRadius - - - ## TRectangle.MaxRadius ```pascal function TRectangle.MaxRadius(): Double; constref; ``` Returns the radius of the longest side, for minimum see Radius - - - ## TRectangle.Mean ```pascal function TRectangle.Mean(): TPoint; constref; ``` Middle of the rectangle ```{note} By slacky ``` - - - ## TRectangle.FixOrder ```pascal function TRectangle.FixOrder(): TRectangle; constref; ``` As long as the order of the points are clockwise, this will shift the points so that `Top`, is the topmost,`Right` is the right-most etc... - - - ## TRectangle.Rotate ```pascal function TRectangle.Rotate(Angle: Double): TRectangle; constref; ``` Returns a rotated copy of the rectangle - - - ## TRectangle.Contains ```pascal function TRectangle.Contains(pt: TPoint): Boolean; constref; ``` Returns true if the point `pt` is inside the rectangle. - - - ## TRectangle.DirByLen ```pascal function TRectangle.DirByLen(Longest: Boolean=True): ESplitDirection; constref; ``` Returns the direction which is the longest or shortest. ```{note} By slacky ``` - - - ## TRectangle.Partition ```pascal function TRectangle.Partition(m,n:Int32; dir:ESplitDirection=rpTopLeft): TRectArray; constref; ``` Break the rectangle into smaller rectangles. Goes well along with `DirByLen` ```{note} By slacky ``` - - - ## TRectangle.Offset ```pascal function TRectangle.Offset(pt: TPoint): TRectangle; constref; ``` Offset the rectangle. - - - ## TRectangle.Filter ```pascal function TRectangle.Filter(testSet: TPointArray): TPointArray; constref; ``` Extract all the points from `testSet` that fits within this rectangle. - - - ## TRectangle.Expand ```pascal function TRectangle.Expand(Inc: Int32): TRectangle; constref; ``` Increase or decrease the dimensions of the rectangle. - - - ## TRectangle.NearestEdge ```pascal function TRectangle.NearestEdge(P: TPoint): TPoint; constref; ``` Returns the closest edge point (think Rect.ToTPA.Connect) to the TPoint `P`.