unit types

Various types

author: Tomasz Biela (Tebe)


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

Interface:

name:description:
Avg

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



    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
    CenterPoint

    function CenterPoint(const Rect: TRect): TPoint;


    Return the center point of a rectangle
      parameters:
    • Rect - TRect record
    • returns:
    • TPoint 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
    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
    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
    IsRectEmpty

    function IsRectEmpty(const Rect : TRect) : Boolean;


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

    procedure NormalizeRect(var Rect: TRect); overload;



      NormalizeRect

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



        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
        Point

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


        Create a point
          parameters:
        • ax - position x
        • ay - position y
        • returns:
        • TPoint record
        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
        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
        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
        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
        RectHeight

        function RectHeight(const Rect: TRect): word;



          RectWidth

          function RectWidth(const Rect: TRect): word;



            Size

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


            Return the size of the rectangle
              parameters:
            • AWidth, AHeight
            • returns:
            • TSize record
            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
            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