Anzeigen: Delphi C++
Anzeigeeinstellungen

System.Types.TPointF

Delphi

```  TPointF = record
X: Single;
Y: Single;
public
constructor Create(const X, Y: Single); 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;
function Distance(const P2: TPointF): Double;
procedure SetLocation(const X, Y: Single); overload;
procedure Offset(const DX, DY: Single); 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;
end;```

C++

```struct TPointF: public POINTF{
TPointF() { x = y = 0; }
TPointF(float _x, float _y) { x=_x; y=_y; }
TPointF(const POINT& pt)
{
x = pt.x;
y = pt.y;
}
TPointF(const TPointF& pt)
{
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
{
return _sameValue(x, 0.0F) && _sameValue(y, 0.0F);
}
bool IsEmpty() const
{
return IsZero();
}
void Offset(float DX, float DY)
{
x += DX;
y += DY;
}
void SetLocation(float nX, float nY)
{
x = nX;
y = nY;
}
void SetLocation(const TPointF& p)
{
x = p.x;
y = p.y;
}
double Distance(const TPointF& p2) const
{
return hypot(p2.x - this->x, p2.y - this->y);
}
TPoint Ceiling() const {
return TPoint((int32_t)ceil(this->x), (int32_t)ceil(this->y));
}
TPoint Truncate() const {
return TPoint((int32_t)floor(this->x), (int32_t)floor(this->y));
}
TPoint Round() const {
return TPoint((int32_t)floor(this->x + 0.5), (int32_t)floor(this->y + 0.5));
}
bool PtInCircle(const TPointF& CircleCenter, float Radius) const
{
}
static float __fastcall _sqrf(float i)
{
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  };
};```

Inhaltsverzeichnis

Eigenschaften

Typ Sichtbarkeit Quelle Unit Übergeordnet
struct
class
public
System.Types.pas
System.Types.hpp
System.Types System.Types

Beschreibung

Definiert eine Pixel-Position auf dem Bildschirm.

Der Typ TPointF definiert eine Pixel-Position auf dem Bildschirm. Der Ursprung liegt dabei in der linken oberen Ecke. `X` und `Y` geben die horizontale bzw. die vertikale Koordinate des Punktes an.

Der Typ von X und Y ist Single.