[fpc-devel] Size() function
Graeme Geldenhuys
graemeg.lists at gmail.com
Tue Jul 25 14:09:19 CEST 2006
> > Would there be a use for these funtions in the Types.pas unit? They
> > do what Point() does for TPoint...
> >
> > function Size(AWidth, AHeight: Integer): TSize;
> > function Size(ARect: TRect): TSize;
>
> You mean it would compute the surface size ?
They return a TSize record, same as Point() returns a TPoint record.
I don't know why Size() wasn't included in the first place and Point()
& Rect() was?
-------------------------
function Size(AWidth, AHeight: Integer): TSize;
begin
Result.cx := AWidth;
Result.cy := AHeight;
end;
function Size(ARect: TRect): TSize;
begin
Result.cx := ARect.Right - ARect.Left;
Result.cy := ARect.Bottom - ARect.Top;
end;
-------------------------
I also have a few arithmetic operator functions that work against
TPoint, TSize and TRect so you can compare for example two TSize
records against each other, etc...
operator = (const ASize1, ASize2: TSize) b: Boolean;
operator + (const APoint1, APoint2: TPoint) p: TPoint;
operator + (const APoint: TPoint; ASize: TSize) p: TPoint;
operator + (const ASize: TSize; APoint: TPoint) s: TSize;
operator + (const ASize1, ASize2: TSize) s: TSize;
operator + (const APoint: TPoint; i: Integer) p: TPoint;
operator + (const ASize: TSize; i: Integer) s: TSize;
operator - (const APoint1, APoint2: TPoint) p: TPoint;
operator - (const APoint: TPoint; i: Integer) p: TPoint;
operator - (const ASize: TSize; const APoint: TPoint) s: TSize;
operator - (const ASize: TSize; i: Integer) s: TSize;
[...]
Graeme.
--
There's no place like 127.0.0.1
More information about the fpc-devel
mailing list