System.Types.TPointF
From RAD Studio API Documentation
Delphi
TPointF = record X: Single; Y: Single; public constructor Create(const P: TPointF); overload; constructor Create(const X, Y: Single); overload; constructor Create(P: TPoint); overload; class operator Equal(const Lhs, Rhs: TPointF): Boolean; class operator NotEqual(const Lhs, Rhs: TPointF): Boolean; class operator Add(const Lhs, Rhs: TPointF): TPointF; class operator Subtract(const Lhs, Rhs: TPointF): TPointF; class operator Multiply(const Lhs, Rhs: TPointF): TPointF; function Distance(const P2: TPointF): Double; procedure SetLocation(const X, Y: Single); overload; procedure SetLocation(const P: TPointF); overload; procedure SetLocation(const P: TPoint); overload; procedure Offset(const DX, DY: Single); overload; procedure Offset(const Point: TPointF); overload; procedure Offset(const Point: TPoint); overload; function Add(const Point: TPointF): TPointF; overload; function Add(const Point: TPoint): TPointF; overload; function Subtract(const Point: TPointF): TPointF; overload; function Subtract(const Point: TPoint): TPointF; overload; function IsZero: Boolean; function Ceiling: TPoint; function Truncate: TPoint; function Round: TPoint; function Scale(const AFactor: Single): TPointF; function Normalize: TPointF; end;
C++
struct TPointF : public POINTF { TPointF() _ALWAYS_INLINE { x = y = 0; } TPointF(float _x, float _y) _ALWAYS_INLINE { x=_x; y=_y; } TPointF(const POINT& pt) _ALWAYS_INLINE { x = pt.x; y = pt.y; } bool operator ==(const TPointF& pt) const { return _sameValue(x, pt.x) && _sameValue(y, pt.y); } bool operator !=(const TPointF& pt) const { return !(pt == *this); } TPointF operator +(const TPointF& rhs) const { return TPointF(rhs.x + this->x, rhs.y + this->y); } TPointF operator -(const TPointF& rhs) const { return TPointF(this->x - rhs.x, this->y - rhs.y); } TPointF& operator +=(const TPointF& rhs) { this->x += rhs.x; this->y += rhs.y; return *this; } TPointF& operator -=(const TPointF& rhs) { this->x -= rhs.x; this->y -= rhs.y; return *this; } bool IsZero() const _ALWAYS_INLINE { return _sameValue(x, 0.0F) && _sameValue(y, 0.0F); } bool IsEmpty() const _ALWAYS_INLINE { return IsZero(); } void Offset(float DX, float DY) _ALWAYS_INLINE { x += DX; y += DY; } void SetLocation(float nX, float nY) _ALWAYS_INLINE { x = nX; y = nY; } void SetLocation(const TPointF& p) _ALWAYS_INLINE { x = p.x; y = p.y; } double Distance(const TPointF& p2) const _ALWAYS_INLINE { return hypot(p2.x - this->x, p2.y - this->y); } TPoint Ceiling() const _ALWAYS_INLINE { return TPoint((int32_t)ceil(this->x), (int32_t)ceil(this->y)); } TPoint Truncate() const _ALWAYS_INLINE { return TPoint((int32_t)floor(this->x), (int32_t)floor(this->y)); } TPoint Round() const _ALWAYS_INLINE { return TPoint((int32_t)floor(this->x + 0.5), (int32_t)floor(this->y + 0.5)); } bool PtInCircle(const TPointF& CircleCenter, float Radius) const _ALWAYS_INLINE { return (Radius > 0.0F) && ((_sqrf(CircleCenter.x-x)+_sqrf(CircleCenter.y-y)) < _sqrf(Radius)); } static float __fastcall _sqrf(float i) _ALWAYS_INLINE { return i*i; } static bool __fastcall _sameValue(float a, float b) { const float SINGLE_RESOLUTION = 1.25E-6f; const float SINGLE_ZERO =6.25E-37f; float _epsilon = (float) ((fabs(a) > fabs(b)) ? fabs(a): fabs(b)) * SINGLE_RESOLUTION; if (_epsilon == 0) _epsilon = SINGLE_ZERO; // both a and b are very little, _epsilon was 0 because of normalization return (a > b) ? ((a - b) <= _epsilon): ((b - a) <= _epsilon); } __property float X = { read=x, write=x }; __property float Y = { read=y, write=y }; };
Contents |
Properties
| Type | Visibility | Source | Unit | Parent |
|---|---|---|---|---|
record struct |
public | System.Types.pas SystemTypes.h |
System.Types | System.Types |
Description
Defines a pixel location on-screen.
The TPointF type defines the floating-point X and Y coordinates of a pixel location on-screen, with the origin in the upper-left corner. X and Y specify the horizontal and vertical coordinates of a point, respectively.
The type of X and Y is Single.
The TPointF type is primarily used for the coordinates of FireMonkey objects.
See Also
- System.Types.TPointF.X
- System.Types.TPointF.Y
- System.Types.PointF
- System.Types.TPoint
- Type conversion routines