unit types

Various types

author: Tomasz Biela (Tebe)


https://www.freepascal.org/docs-html/rtl/types/index-5.html

Interface:

name:description:
Point

function Point(AX, AY: smallint): TPoint;


Create a point
    parameters:
  • ax - position x
  • ay - position y
  • returns:
  • TPoint record
Rect

function Rect(ALeft, ATop, ARight, ABottom: smallint): TRect;


Create a rectangle record
    parameters:
  • ALeft, ATop - left corner
  • ARight, ABottom - right corner
  • returns:
  • TRect record
Bounds

function Bounds(ALeft, ATop, AWidth, AHeight: smallint): TRect;


Create a rectangle, given a position and size
    parameters:
  • ALeft, ATop - position
  • AWidth, AHeigh - size
  • returns:
  • TRect record
EqualRect

function EqualRect(const r1,r2 : TRect) : Boolean;


Check if two rectangles are equal
    parameters:
  • R1, R2 - rectangles
  • returns:
  • TRUE if the rectangles R1 and R2 are equal
PointsEqual

function PointsEqual(const P1, P2: TPoint): Boolean;


Check if two points are equal
    parameters:
  • P1, P2 - points
  • returns:
  • TRUE if the points P1 and P2 are equal
RectWidth

function RectWidth(const Rect: TRect): word;



    RectHeight

    function RectHeight(const Rect: TRect): word;



      PtInEllipse

      function PtInEllipse(const Rect: TRect; const p : TPoint): Boolean;


      Check whether a point is inside a ellipse
        parameters:
      • Rect - TRect record
      • p - TPoint record
      • returns:
      • TRUE if p is located inside ellipse defined by Rect
      PtInRect

      function PtInRect(const Rect : TRect;const p : TPoint) : Boolean;


      Check whether a point is inside a rectangle
        parameters:
      • Rect - TRect record
      • p - TPoint record
      • returns:
      • TRUE if p is located inside Rect
      Avg

      function Avg(a, b: integer): integer;



        CenterPoint

        function CenterPoint(const Rect: TRect): TPoint;


        Return the center point of a rectangle
          parameters:
        • Rect - TRect record
        • returns:
        • TPoint record
        IsRectEmpty

        function IsRectEmpty(const Rect : TRect) : Boolean;


        Check whether a rectangle is empty
          parameters:
        • TRect record
        • returns:
        • TRUE if the rectangle is empty
        IntersectRect

        function IntersectRect(var Rect : TRect;const R1,R2 : TRect) : Boolean;


        Return the intersection of 2 rectangles
          parameters:
        • Rect - destination TRect record
        • R1, R2 - rectangles
        • returns:
        • TRUE if the operation was successfull
        UnionRect

        function UnionRect(var Rect : TRect;const R1,R2 : TRect) : Boolean;


        Return the union of 2 rectangles
          parameters:
        • Rect - destination TRect record
        • R1, R2 - rectangles
        • returns:
        • TRUE if the operation was successfull
        OffsetRect

        function OffsetRect(var Rect : TRect; DX, DY : Smallint) : Boolean;


        Offset the rectangle
          parameters:
        • Rect - TRect record
        • offsets the rectangle Rect by a horizontal distance DX
        • offsets the rectangle Rect by a vertical distance DY
        • returns:
        • TRUE if the operation was successfull
        InflateRect

        function InflateRect(var Rect: TRect; dx, dy: smallint): Boolean;


        Increase the rectangle in size, keeping it centered
          parameters:
        • Rect - TRect record
        • inflates the rectangle horizontally with DX pixels on each side
        • inflates the rectangle verticaly with DY pixels on each side
        • returns:
        • TRUE if the operation was successfull
        NormalizeRect

        procedure NormalizeRect(var Rect: TRect); overload;



          NormalizeRect

          procedure NormalizeRect(var left,top, right,bottom : smallint); overload;



            Size

            function Size(AWidth, AHeight: smallint): TSize; overload;


            Return the size of the rectangle
              parameters:
            • AWidth, AHeight
            • returns:
            • TSize record
            Size

            function Size(const ARect: TRect): TSize; overload;


            Return the size of the rectangle
              parameters:
            • ARect - TRect
            • returns:
            • TSize record