Line data Source code
1 : /* Copyright (C) 2021 Wildfire Games. 2 : * This file is part of 0 A.D. 3 : * 4 : * 0 A.D. is free software: you can redistribute it and/or modify 5 : * it under the terms of the GNU General Public License as published by 6 : * the Free Software Foundation, either version 2 of the License, or 7 : * (at your option) any later version. 8 : * 9 : * 0 A.D. is distributed in the hope that it will be useful, 10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 : * GNU General Public License for more details. 13 : * 14 : * You should have received a copy of the GNU General Public License 15 : * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 : */ 17 : 18 : #include "precompiled.h" 19 : 20 : #include "Size2D.h" 21 : 22 7106 : CSize2D::CSize2D() = default; 23 : 24 2419 : CSize2D::CSize2D(const CSize2D& size) : Width(size.Width), Height(size.Height) 25 : { 26 2419 : } 27 : 28 3 : CSize2D::CSize2D(const float width, const float height) : Width(width), Height(height) 29 : { 30 3 : } 31 : 32 3357 : CSize2D& CSize2D::operator=(const CSize2D& size) 33 : { 34 3357 : Width = size.Width; 35 3357 : Height = size.Height; 36 3357 : return *this; 37 : } 38 : 39 1 : bool CSize2D::operator==(const CSize2D& size) const 40 : { 41 1 : return Width == size.Width && Height == size.Height; 42 : } 43 : 44 0 : bool CSize2D::operator!=(const CSize2D& size) const 45 : { 46 0 : return !(*this == size); 47 : } 48 : 49 0 : CSize2D CSize2D::operator+(const CSize2D& size) const 50 : { 51 0 : return CSize2D(Width + size.Width, Height + size.Height); 52 : } 53 : 54 0 : CSize2D CSize2D::operator-(const CSize2D& size) const 55 : { 56 0 : return CSize2D(Width - size.Width, Height - size.Height); 57 : } 58 : 59 0 : CSize2D CSize2D::operator/(const float a) const 60 : { 61 0 : return CSize2D(Width / a, Height / a); 62 : } 63 : 64 0 : CSize2D CSize2D::operator*(const float a) const 65 : { 66 0 : return CSize2D(Width * a, Height * a); 67 : } 68 : 69 0 : void CSize2D::operator+=(const CSize2D& size) 70 : { 71 0 : Width += size.Width; 72 0 : Height += size.Height; 73 0 : } 74 : 75 0 : void CSize2D::operator-=(const CSize2D& size) 76 : { 77 0 : Width -= size.Width; 78 0 : Height -= size.Height; 79 0 : } 80 : 81 0 : void CSize2D::operator/=(const float a) 82 : { 83 0 : Width /= a; 84 0 : Height /= a; 85 0 : } 86 : 87 0 : void CSize2D::operator*=(const float a) 88 : { 89 0 : Width *= a; 90 0 : Height *= a; 91 0 : }