34 #include <Pt/Gfx/Api.h>
53 Size(Float w, Float h)
58 : _w(other._w), _h(other._h)
67 void set(Float w, Float h)
75 return _w == 0 || _h == 0;
95 {
return Size(_h, _w); }
123 void setWidth(Float w)
126 void setHeight(Float h)
129 void setWidthHeight(Float w, Float h)
135 const Size& addWidth(Float w)
141 const Size& subWidth(Float w)
147 const Size& addHeight(Float h)
153 const Size& subHeight(Float h)
159 void add(
const Size& s)
172 Size& operator+=(
const Size& s)
179 bool isEqual(
const Size& other, Float eps = FloatNearlyZero)
const
181 return std::abs(_w - other._w) <= eps &&
182 std::abs(_h - other._h) <= eps;
185 bool operator<(
const Size& other)
const
187 return _h < other._h || (_h == other._h && _w < other._w);
190 Size operator*(Float v)
const
192 return Size(_w * v, _h * v);
195 Size operator/(Float v)
const
197 return Size(_w / v, _h / v);
200 Size operator+(Float v)
const
202 return Size(_w + v, _h + v);
205 Size operator-(Float v)
const
207 return Size(_w - v, _h - v);
210 Size& operator*=(Float v)
217 Size& operator/=(Float v)
224 Size& operator+=(Float v)
231 Size& operator-=(Float v)
259 : _w(other._w), _h(other._h)
268 void set(Int w, Int h)
276 return _w == 0 || _h == 0;
296 {
return SizeI(_h, _w); }
307 void setHeight(Int h)
310 void setWidthHeight(Int w, Int h)
316 const SizeI& addWidth(Int w)
322 const SizeI& subWidth(Int w)
328 const SizeI& addHeight(Int h)
334 const SizeI& subHeight(Int h)
340 void add(
const SizeI& s)
346 SizeI& operator=(
const SizeI& other)
353 SizeI& operator+=(
const SizeI& s)
360 bool operator==(
const SizeI& other)
const
362 return (_w == other._w && _h == other._h);
365 bool operator!=(
const SizeI& other)
const
367 return (_w != other._w || _h != other._h);
370 SizeI operator*(Int v)
const
372 return SizeI(_w * v, _h * v);
375 SizeI operator+(Int v)
const
377 return SizeI(_w + v, _h + v);
380 SizeI operator-(Int v)
const
382 return SizeI(_w - v, _h - v);
385 SizeI& operator*=(Int v)
392 SizeI& operator+=(Int v)
399 SizeI& operator-=(Int v)
412 : _w(static_cast<Float>(s.width())), _h(static_cast<Float>(s.height()))
417 _w =
static_cast<Float
>(s.width());
418 _h =
static_cast<Float
>(s.height());
424 return SizeI(
static_cast<Int
>(std::lround(_w)),
425 static_cast<Int
>(std::lround(_h)));
430 return SizeI(
static_cast<Int
>(std::floor(_w)),
431 static_cast<Int
>(std::floor(_h)));
436 return SizeI(
static_cast<Int
>(std::ceil(_w)),
437 static_cast<Int
>(std::ceil(_h)));