34#include <Pt/Gfx/Api.h>
75 Size(Float w, Float h)
79 Size(
const Size& other)
80 : _w(other._w), _h(other._h)
89 void set(Float w, Float h)
97 return _w == 0 || _h == 0;
117 {
return Size(_h, _w); }
145 void setWidth(Float w)
148 void setHeight(Float h)
151 void setWidthHeight(Float w, Float h)
157 const Size& addWidth(Float w)
163 const Size& subWidth(Float w)
169 const Size& addHeight(Float h)
175 const Size& subHeight(Float h)
181 void add(
const Size& s)
194 Size& operator+=(
const Size& s)
201 bool isEqual(
const Size& other, Float eps = FloatNearlyZero)
const
203 return std::abs(_w - other._w) <= eps &&
204 std::abs(_h - other._h) <= eps;
207 bool operator<(
const Size& other)
const
209 return _h < other._h || (_h == other._h && _w < other._w);
212 Size operator*(Float v)
const
214 return Size(_w * v, _h * v);
217 Size operator/(Float v)
const
219 return Size(_w / v, _h / v);
222 Size operator+(Float v)
const
224 return Size(_w + v, _h + v);
227 Size operator-(Float v)
const
229 return Size(_w - v, _h - v);
232 Size& operator*=(Float v)
239 Size& operator/=(Float v)
246 Size& operator+=(Float v)
253 Size& operator-=(Float v)
289 SizeI(
const SizeI& other)
290 : _w(other._w), _h(other._h)
299 void set(Int w, Int h)
307 return _w == 0 || _h == 0;
327 {
return SizeI(_h, _w); }
338 void setHeight(Int h)
341 void setWidthHeight(Int w, Int h)
347 const SizeI& addWidth(Int w)
353 const SizeI& subWidth(Int w)
359 const SizeI& addHeight(Int h)
365 const SizeI& subHeight(Int h)
371 void add(
const SizeI& s)
377 SizeI& operator=(
const SizeI& other)
384 SizeI& operator+=(
const SizeI& s)
391 bool operator==(
const SizeI& other)
const
393 return (_w == other._w && _h == other._h);
396 bool operator!=(
const SizeI& other)
const
398 return (_w != other._w || _h != other._h);
401 SizeI operator*(Int v)
const
403 return SizeI(_w * v, _h * v);
406 SizeI operator+(Int v)
const
408 return SizeI(_w + v, _h + v);
411 SizeI operator-(Int v)
const
413 return SizeI(_w - v, _h - v);
416 SizeI& operator*=(Int v)
423 SizeI& operator+=(Int v)
430 SizeI& operator-=(Int v)
443: _w(static_cast<Float>(s.width())), _h(static_cast<Float>(s.height()))
448 _w =
static_cast<Float
>(s.width());
449 _h =
static_cast<Float
>(s.height());
455 return SizeI(
static_cast<Int
>(std::lround(_w)),
456 static_cast<Int
>(std::lround(_h)));
461 return SizeI(
static_cast<Int
>(std::floor(_w)),
462 static_cast<Int
>(std::floor(_h)));
467 return SizeI(
static_cast<Int
>(std::ceil(_w)),
468 static_cast<Int
>(std::ceil(_h)));
Integer width and height.
Definition Size.h:279
Int area() const
Returns the area (width * height).
Definition Size.h:312
SizeI toTransposed() const
Returns a copy with width and height swapped.
Definition Size.h:326
void transpose()
Swaps width and height in place.
Definition Size.h:317
Floating-point width and height.
Definition Size.h:69
Size toTransposed() const
Returns a copy with width and height swapped.
Definition Size.h:116
Size & operator=(const SizeI &s)
Assigns from a SizeI by widening the dimensions.
Definition Size.h:446
SizeI floor() const
Floors each dimension and returns a SizeI.
Definition Size.h:459
Float area() const
Returns the area (width * height).
Definition Size.h:102
SizeI round() const
Rounds each dimension to the nearest integer and returns a SizeI.
Definition Size.h:453
SizeI ceil() const
Ceils each dimension and returns a SizeI.
Definition Size.h:465
void transpose()
Swaps width and height in place.
Definition Size.h:107
Graphics and imaging services.
Definition Api-Argb32Image.h:12
Core module.
Definition Allocator.h:33