System.Types.TPoint

De RAD Studio API Documentation
Aller à : navigation, rechercher

Delphi

TPoint = record

C++

struct TPoint: public POINT  {
  TPoint() _ALWAYS_INLINE
  { x = y = 0; }
  TPoint(int _x, int _y) _ALWAYS_INLINE
  { x=_x; y=_y; }
  bool operator ==(const TPoint& pt) const _ALWAYS_INLINE {
    return (x == pt.x) && (y == pt.y);
  }
  bool operator !=(const TPoint& pt) const _ALWAYS_INLINE {
    return !(pt == *this);
  }
  TPoint operator +(const TPoint& rhs) const _ALWAYS_INLINE {
    return TPoint(rhs.x + this->x, rhs.y + this->y);
  }
  TPoint operator -(const TPoint& rhs) const _ALWAYS_INLINE {
    return TPoint(this->x - rhs.x, this->y - rhs.y );
  }
  TPoint& operator +=(const TPoint& rhs) _ALWAYS_INLINE {
    this->x += rhs.x;
    this->y += rhs.y;
    return *this;
  }
  TPoint& operator -=(const TPoint& rhs) _ALWAYS_INLINE {
    this->x -= rhs.x;
    this->y -= rhs.y;
    return *this;
  }
  bool IsZero() const _ALWAYS_INLINE {
    return !x && !y;
  }
  bool IsEmpty() const _ALWAYS_INLINE {
    return IsZero();
  }
  void Offset(int DX, int DY) _ALWAYS_INLINE {
    x += DX;
    y += DY;
  }
  void SetLocation(int nX, int nY) _ALWAYS_INLINE {
    x = nX;
    y = nY;
  }
  void SetLocation(const TPoint& p) _ALWAYS_INLINE {
    x = p.x;
    y = p.y;
  }
  double Distance(const TPoint& p2) const _ALWAYS_INLINE {
    return hypot(static_cast<double>(p2.x - this->x), static_cast<double>(p2.y - this->y));
  }
  static int __fastcall _sqr(int i) _ALWAYS_INLINE { // Helper - private?
     return i*i;
  }
  bool PtInCircle(const TPoint& CircleCenter, int Radius) const _ALWAYS_INLINE {
    return (Radius > 0) && ((_sqr(CircleCenter.x-x)+_sqr(CircleCenter.y-y)) < _sqr(Radius));
  }
  float Angle(const TPoint& P) const _ALWAYS_INLINE {
    return atan2((float)y - P.y,(float)x - P.x);
  }
  __property LONG X = { read=x,   write=x  };
  __property LONG Y = { read=y,   write=y  };
};

Propriétés

Type Visibilité  Source Unité  Parent
record
struct
public
System.Types.pas
SystemTypes.h
System.Types System.Types


Description

Définit un emplacement sur l'écran exprimé en pixels.

Le type TPoint définit les coordonnées entières X et Y d'un emplacement sur l'écran exprimé en pixels, avec l'origine dans le coin supérieur gauche. X et Y spécifient respectivement la coordonnée horizontale et la coordonnée verticale du point.

Le type de X et Y est FixedInt.

Voir aussi


Exemples de code