System.Types.TSizeF

Aus RAD Studio API Documentation
Wechseln zu: Navigation, Suche

Delphi

  TSizeF = record
    cx: Single;
    cy: Single;
  public
    constructor Create(P: TSizeF); overload;
    constructor Create(const X, Y: Single); overload;
    class operator Equal(const Lhs, Rhs: TSizeF): Boolean;
    class operator NotEqual(const Lhs, Rhs: TSizeF): Boolean;
    class operator Add(const Lhs, Rhs: TSizeF): TSizeF;
    class operator Subtract(const Lhs, Rhs: TSizeF): TSizeF;
    class operator Implicit(const Size: TSizeF): TPointF;
    class operator Implicit(const Point: TPointF): TSizeF;
    class operator Implicit(const Size: TSize): TSizeF;
    function Ceiling: TSize;
    function Truncate: TSize;
    function Round: TSize;
    function Add(const Point: TSizeF): TSizeF;
    function Subtract(const Point: TSizeF): TSizeF;
    function Distance(const P2: TSizeF): Double;
    function IsZero: Boolean;
    function SwapDimensions: TSizeF;
    property Width: Single read cx write cx;
    property Height: Single read cy write cy;
  end;

C++

struct TSizeF
{
  float cx;
  float cy;
public:
  TSizeF() _ALWAYS_INLINE {
    cx = cy = 0;
  }
  TSizeF(float w, float h) _ALWAYS_INLINE {
    cx = w;
    cy = h;
  }
  TSizeF(const TSize& s) _ALWAYS_INLINE {
    cx = s.cx;
    cy = s.cy;
  }
  bool operator ==(const TSizeF& sf) const {
    return _sameValue(cx, sf.cx) && _sameValue(cy, sf.cy);
  }
  bool operator !=(const TSizeF& sf) const {
    return !(sf == *this);
  }
  TSizeF operator +(const TSizeF& rhs) const {
    return TSizeF(rhs.cx + this->cx, rhs.cy + this->cy);
  }
  TSizeF operator -(const TSizeF& rhs) const {
    return TSizeF(this->cx - rhs.cx, this->cy - rhs.cy);
  }
  TSizeF& operator +=(const TSizeF& rhs) {
    this->cx += rhs.cx;
    this->cy += rhs.cy;
    return *this;
  }
  TSizeF& operator -=(const TSizeF& rhs) {
    this->cx -= rhs.cx;
    this->cy -= rhs.cy;
    return *this;
  }
  bool IsZero() const _ALWAYS_INLINE {
    return _sameValue(cx, 0.0F) && _sameValue(cy, 0.0F);
  }
  double Distance(const TSizeF& s2) const _ALWAYS_INLINE {
  #ifdef _WIN64 // RS-53817
    return System::hypotWA(s2.cx - this->cx, s2.cy - this->cy);
  #else
    return hypot(s2.cx - this->cx, s2.cy - this->cy);
  #endif
  }
  TSize Ceiling() const _ALWAYS_INLINE {
    return TSize((int32_t)ceil(this->cx), (int32_t)ceil(this->cy));
  }
  TSize Truncate() const _ALWAYS_INLINE {
    return TSize((int32_t)floor(this->cx), (int32_t)floor(this->cy));
  }
  TSize Round() const _ALWAYS_INLINE {
    return TSize((int32_t)floor(this->cx + 0.5), (int32_t)floor(this->cy + 0.5));
  }
  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 Width =  { read=cx,   write=cx  };
  __property float Height = { read=cy,   write=cy  };
};

Eigenschaften

Typ Sichtbarkeit Quelle Unit Übergeordnet
record
struct
public
System.Types.pas
SystemTypes.h
System.Types System.Types

Beschreibung

Repräsentiert die Gleitkomma-Breite und -Höhe eines Objekts.

TSizeF repräsentiert die Gleitkommagröße eines Objekts, das die Eigenschaften Width und Height verwendet. Das Objekt kann ein Rechteck, ein Formular, eine Schaltfläche usw. sein. Normalerweise sind die implizierten Maßeinheiten Pixel.

  • Width wird im Feld cx gespeichert.
  • Height wird im Feld cy gespeichert.

Das Objekt kann ein Rechteck, ein Formular, eine Schatfläche usw. sein. Normalerweise sind die implizierten Maßeinheiten Pixel.

Die Eigenschaften Width und Height haben den Typ Single.

Siehe auch