Changeset 1130 for cpp/common/2d.h
- Timestamp:
- 04/16/21 15:55:34 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/2d.h
r1028 r1130 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-202 0Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2021 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 6 6 #define _2D_H_ 7 7 8 #include "nonstd_stl.h"9 8 #include <math.h> 9 #include <algorithm> 10 10 11 11 //unification of old GUIXY and Pt2D … … 58 58 template<> inline bool XY<int>::operator==(const XY<int> &p) const { return (x == p.x) && (y == p.y); } 59 59 60 template <typename T> XY<T> xymin(const XY<T> &a, const XY<T> &b) { return XY<T>( min(a.x, b.x),min(a.y, b.y)); }61 template <typename T> XY<T> xymax(const XY<T> &a, const XY<T> &b) { return XY<T>( max(a.x, b.x),max(a.y, b.y)); }60 template <typename T> XY<T> xymin(const XY<T> &a, const XY<T> &b) { return XY<T>(std::min(a.x, b.x), std::min(a.y, b.y)); } 61 template <typename T> XY<T> xymax(const XY<T> &a, const XY<T> &b) { return XY<T>(std::max(a.x, b.x), std::max(a.y, b.y)); } 62 62 63 63 template <typename T> … … 74 74 T vertical() const { return top + bottom; } 75 75 bool operator==(const XYMargin &other) const { return left == other.left && top == other.top && right == other.right && bottom == other.bottom; } 76 XYMargin normalized() const { return XYMargin( max(left, T(0)), max(top, T(0)), max(right, T(0)),max(bottom, T(0))); }76 XYMargin normalized() const { return XYMargin(std::max(left, T(0)), std::max(top, T(0)), std::max(right, T(0)), std::max(bottom, T(0))); } 77 77 }; 78 78 … … 162 162 } 163 163 164 XYRect fitAspect(float aspect) ///< place a new rectangle having 'aspect' inside the rectangle164 XYRect fitAspect(float aspect) const ///< place a new rectangle having 'aspect' inside the rectangle 165 165 { 166 166 XYRect r; … … 179 179 XY<T> p2 = p + size; 180 180 XY<T> rp2 = r.p + r.size; 181 i.p.x = max(p.x, r.p.x);182 i.p.y = max(p.y, r.p.y);183 i.size.x = min(p2.x, rp2.x) - i.p.x;184 i.size.y = min(p2.y, rp2.y) - i.p.y;181 i.p.x = std::max(p.x, r.p.x); 182 i.p.y = std::max(p.y, r.p.y); 183 i.size.x = std::min(p2.x, rp2.x) - i.p.x; 184 i.size.y = std::min(p2.y, rp2.y) - i.p.y; 185 185 return i; 186 186 }
Note: See TracChangeset
for help on using the changeset viewer.