Download Now

    Reference TRectF

    Declared in Codebot.Graphics.Types.pas on line 254

    TRectF is a floating point rectangle defined by a position and size
      TRectF = record
      public
        { The position and size of the rectangle }
        X: Float;
        Y: Float;
        Width: Float;
        Height: Float;
        { Create an empty rectangle at the origin }
        class function Create: TRectF; overload; static;
        { Create a rectangle at the origin given a size }
        class function Create(Size: TPointF): TRectF; overload; static;
        class function Create(W, H: Float): TRectF; overload; static;
        { Create a rectangle given a position and size }
        class function Create(X, Y, W, H: Float): TRectF; overload; static;
        { Returns true if position and size match }
        function Equals(const Value: TRectF): Boolean;
        { Returns true if a point lies inside the rectangle }
        function Contains(X, Y: Float): Boolean; overload;
        function Contains(const P: TPointF): Boolean; overload;
        { Move the rectangle so its center is at a point or the center of another
          rectangle }
        procedure Center(X, Y: Float); overload;
        procedure Center(const P: TPointF); overload;
        procedure Center(const R: TRectF); overload;
        { Grow the rectangle on each side by an amount }
        procedure Inflate(X, Y: Float); overload;
        procedure Inflate(const P: TPointF); overload;
        { Move the rectangle by an amount }
        procedure Offset(X, Y: Float); overload;
        procedure Offset(const P: TPointF); overload;
        { Empty is true when width or height is zero or less }
        property Empty: Boolean read GetEmpty;
        { The left edge, setting it keeps the right edge in place }
        property Left: Float read X write SetLeft;
        { The top edge, setting it keeps the bottom edge in place }
        property Top: Float read Y write SetTop;
        { The right edge }
        property Right: Float read GetRight write SetRight;
        { The bottom edge }
        property Bottom: Float read GetBottom write SetBottom;
        { The width and height as a point }
        property Size: TPointF read GetSize;
        { Corner points }
        property TopLeft: TPointF read GetTopLeft;
        property TopRight: TPointF read GetTopRight;
        property BottomLeft: TPointF read GetBottomLeft;
        property BottomRight: TPointF read GetBottomRight;
        { The center point }
        property MidPoint: TPointF read GetMidPoint;
        { Midpoints of each edge }
        property MidLeft: TPointF read GetMidLeft;
        property MidTop: TPointF read GetMidTop;
        property MidRight: TPointF read GetMidRight;
        property MidBottom: TPointF read GetMidBottom;
      end;

    See also

    Float in Codebot.System.pas