2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the LGPL License, Version 2.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * https://www.gnu.org/licenses/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
27 constexpr inline VPointF(float x, float y) noexcept : mx(x), my(y) {}
28 constexpr inline float x() const noexcept { return mx; }
29 constexpr inline float y() const noexcept { return my; }
30 inline float & rx() noexcept { return mx; }
31 inline float & ry() noexcept { return my; }
32 inline void setX(float x) { mx = x; }
33 inline void setY(float y) { my = y; }
34 inline VPointF operator-() noexcept { return {-mx, -my}; }
35 inline VPointF & operator+=(const VPointF &p) noexcept;
36 inline VPointF & operator-=(const VPointF &p) noexcept;
37 friend const VPointF operator+(const VPointF &p1, const VPointF &p2)
39 return VPointF(p1.mx + p2.mx, p1.my + p2.my);
41 inline friend bool fuzzyCompare(const VPointF &p1, const VPointF &p2);
42 inline friend VDebug & operator<<(VDebug &os, const VPointF &o);
44 friend inline VPointF operator-(const VPointF &p1, const VPointF &p2);
45 friend inline const VPointF operator*(const VPointF &, float val);
46 friend inline const VPointF operator*(float val, const VPointF &);
47 friend inline const VPointF operator/(const VPointF &, float val);
48 friend inline const VPointF operator/(float val, const VPointF &);
55 inline bool fuzzyCompare(const VPointF &p1, const VPointF &p2)
57 return (vCompare(p1.mx, p2.mx) && vCompare(p1.my, p2.my));
60 inline VPointF operator-(const VPointF &p1, const VPointF &p2)
62 return {p1.mx - p2.mx, p1.my - p2.my};
65 inline const VPointF operator*(const VPointF &p, float c)
67 return VPointF(p.mx * c, p.my * c);
70 inline const VPointF operator*(float c, const VPointF &p)
72 return VPointF(p.mx * c, p.my * c);
75 inline const VPointF operator/(const VPointF &p, float c)
77 return VPointF(p.mx / c, p.my / c);
80 inline const VPointF operator/(float c, const VPointF &p)
82 return VPointF(p.mx / c, p.my / c);
85 inline VDebug &operator<<(VDebug &os, const VPointF &o)
87 os << "{P " << o.x() << "," << o.y() << "}";
91 inline VPointF &VPointF::operator+=(const VPointF &p) noexcept
98 inline VPointF &VPointF::operator-=(const VPointF &p) noexcept
108 constexpr inline VPoint(int x, int y) noexcept : mx(x), my(y) {}
109 constexpr inline int x() const noexcept { return mx; }
110 constexpr inline int y() const noexcept { return my; }
111 inline void setX(int x) { mx = x; }
112 inline void setY(int y) { my = y; }
113 inline VPoint & operator+=(const VPoint &p) noexcept;
114 inline VPoint & operator-=(const VPoint &p) noexcept;
115 constexpr inline bool operator==(const VPoint &o) const;
116 constexpr inline bool operator!=(const VPoint &o) const
118 return !(operator==(o));
120 friend inline VPoint operator-(const VPoint &p1, const VPoint &p2);
121 inline friend VDebug &operator<<(VDebug &os, const VPoint &o);
127 inline VDebug &operator<<(VDebug &os, const VPoint &o)
129 os << "{P " << o.x() << "," << o.y() << "}";
133 inline VPoint operator-(const VPoint &p1, const VPoint &p2)
135 return {p1.mx - p2.mx, p1.my - p2.my};
138 constexpr inline bool VPoint::operator==(const VPoint &o) const
140 return (mx == o.x() && my == o.y());
143 inline VPoint &VPoint::operator+=(const VPoint &p) noexcept
150 inline VPoint &VPoint::operator-=(const VPoint &p) noexcept
160 constexpr inline VSize(int w, int h) noexcept : mw(w), mh(h) {}
161 bool empty() const {return (mw <= 0 || mh <= 0);}
162 constexpr inline int width() const noexcept { return mw; }
163 constexpr inline int height() const noexcept { return mh; }
164 inline void setWidth(int w) { mw = w; }
165 inline void setHeight(int h) { mh = h; }
166 inline VSize & operator+=(const VSize &p) noexcept;
167 inline VSize & operator-=(const VSize &p) noexcept;
168 constexpr inline bool operator==(const VSize &o) const;
169 constexpr inline bool operator!=(const VSize &o) const
171 return !(operator==(o));
173 inline friend VDebug &operator<<(VDebug &os, const VSize &o);
179 inline VDebug &operator<<(VDebug &os, const VSize &o)
181 os << "{P " << o.width() << "," << o.height() << "}";
184 constexpr inline bool VSize::operator==(const VSize &o) const
186 return (mw == o.width() && mh == o.height());
189 inline VSize &VSize::operator+=(const VSize &p) noexcept
196 inline VSize &VSize::operator-=(const VSize &p) noexcept