1 /** 2 * @file size.h 3 * 2D sizes. 4 * 5 * @authors Copyright © 2013 Daniel Swanson <danij@dengine.net> 6 * 7 * @par License 8 * GPL: http://www.gnu.org/licenses/gpl.html 9 * 10 * <small>This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by the 12 * Free Software Foundation; either version 2 of the License, or (at your 13 * option) any later version. This program is distributed in the hope that it 14 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 * Public License for more details. You should have received a copy of the GNU 17 * General Public License along with this program; if not, write to the Free 18 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 19 * 02110-1301 USA</small> 20 */ 21 22 #ifndef LIBDENG_DATA_SIZE_H 23 #define LIBDENG_DATA_SIZE_H 24 25 #include "liblegacy.h" 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 /// @addtogroup legacyMath 32 /// @{ 33 34 /** 35 * Integer width and height. Intended as a handy POD structure for easy 36 * manipulation of two dimensional sizes with integer precison. 37 */ 38 typedef struct Size2Raw_s { 39 union { 40 struct { 41 int width; 42 int height; 43 }; 44 int widthHeight[2]; 45 }; 46 //#ifdef __cplusplus 47 // Size2Raw_s(int w = 0, int h = 0) : width(w), height(h) {} 48 //#endif 49 } Size2Raw; 50 51 struct size2_s; // The Size2 instance (opaque). 52 typedef struct size2_s Size2; 53 54 DENG_PUBLIC Size2 *Size2_New(void); 55 DENG_PUBLIC Size2 *Size2_NewWithDimensions(int width, int height); 56 DENG_PUBLIC Size2 *Size2_NewFromRaw(Size2Raw const *rawSize); 57 DENG_PUBLIC void Size2_Delete(Size2 *size); 58 59 DENG_PUBLIC Size2Raw *Size2_Raw(Size2 const *size, Size2Raw *rawSize); 60 61 DENG_PUBLIC dd_bool Size2_IsNull(Size2 const *size); 62 63 DENG_PUBLIC int Size2_Width(Size2 const *size); 64 DENG_PUBLIC int Size2_Height(Size2 const *size); 65 66 DENG_PUBLIC void Size2_SetWidth(Size2 *size, int width); 67 DENG_PUBLIC void Size2_SetHeight(Size2 *size, int height); 68 69 DENG_PUBLIC int const *Size2_WidthHeight(Size2 const *size); 70 DENG_PUBLIC void Size2_SetWidthHeight(Size2 *size, int width, int height); 71 72 DENG_PUBLIC void Size2_Sum(Size2 *size, Size2 const *other); 73 74 DENG_PUBLIC dd_bool Size2_Equality(Size2 const *point, Size2 const *other); 75 76 /** 77 * Floating-point width and height. Intended as a handy POD structure for easy 78 * manipulation of two dimensional sizes with floating point precison. 79 */ 80 typedef struct Size2Rawf_s { 81 union { 82 struct { 83 double width; 84 double height; 85 }; 86 double widthHeight[2]; 87 }; 88 #ifdef __cplusplus widthSize2Rawf_s89 Size2Rawf_s(double w = 0, double h = 0) : width(w), height(h) {} 90 #endif 91 } Size2Rawf; 92 93 struct size2f_s; // The Size2f instance (opaque). 94 typedef struct size2f_s Size2f; 95 96 DENG_PUBLIC Size2f *Size2f_New(void); 97 DENG_PUBLIC Size2f *Size2f_NewWithDimensions(double width, double height); 98 DENG_PUBLIC Size2f *Size2f_NewFromRaw(Size2Rawf const *rawSize); 99 DENG_PUBLIC void Size2f_Delete(Size2f *size); 100 101 DENG_PUBLIC Size2Rawf *Size2f_Raw(Size2f const *size, Size2Rawf *rawSize); 102 103 DENG_PUBLIC dd_bool Size2f_IsNull(Size2f const *size); 104 105 DENG_PUBLIC double Size2f_Width(Size2f const *size); 106 DENG_PUBLIC double Size2f_Height(Size2f const *size); 107 108 DENG_PUBLIC void Size2f_SetWidth(Size2f *size, double width); 109 DENG_PUBLIC void Size2f_SetHeight(Size2f *size, double height); 110 111 DENG_PUBLIC double const *Size2f_WidthHeight(Size2f const *size); 112 DENG_PUBLIC void Size2f_SetWidthHeight(Size2f *size, double width, double height); 113 114 DENG_PUBLIC void Size2f_Sum(Size2f *size, Size2f const *other); 115 116 DENG_PUBLIC dd_bool Size2f_Equality(Size2f const *size, Size2f const *other); 117 118 /// @} 119 120 #ifdef __cplusplus 121 } // extern "C" 122 #endif 123 124 #endif /* LIBDENG_DATA_SIZE_H */ 125