1 /* 2 3 SDL_gfxPrimitives: graphics primitives for SDL 4 5 LGPL (c) A. Schiffler 6 7 */ 8 9 #ifndef _SDL_gfxPrimitives_h 10 #define _SDL_gfxPrimitives_h 11 12 #include <math.h> 13 #ifndef M_PI 14 #define M_PI 3.1415926535897932384626433832795 15 #endif 16 17 #include "SDL.h" 18 19 /* Set up for C function definitions, even when using C++ */ 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 /* ----- Versioning */ 25 26 #define SDL_GFXPRIMITIVES_MAJOR 2 27 #define SDL_GFXPRIMITIVES_MINOR 0 28 #define SDL_GFXPRIMITIVES_MICRO 23 29 30 31 /* ---- Function Prototypes */ 32 33 #ifdef _MSC_VER 34 # if defined(DLL_EXPORT) && !defined(LIBSDL_GFX_DLL_IMPORT) 35 # define SDL_GFXPRIMITIVES_SCOPE __declspec(dllexport) 36 # else 37 # ifdef LIBSDL_GFX_DLL_IMPORT 38 # define SDL_GFXPRIMITIVES_SCOPE __declspec(dllimport) 39 # endif 40 # endif 41 #endif 42 #ifndef SDL_GFXPRIMITIVES_SCOPE 43 # define SDL_GFXPRIMITIVES_SCOPE extern 44 #endif 45 46 /* Note: all ___Color routines expect the color to be in format 0xRRGGBBAA */ 47 48 /* Pixel */ 49 50 SDL_GFXPRIMITIVES_SCOPE int pixelColor(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color); 51 SDL_GFXPRIMITIVES_SCOPE int pixelRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 52 53 /* Horizontal line */ 54 55 SDL_GFXPRIMITIVES_SCOPE int hlineColor(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color); 56 SDL_GFXPRIMITIVES_SCOPE int hlineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 57 58 /* Vertical line */ 59 60 SDL_GFXPRIMITIVES_SCOPE int vlineColor(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color); 61 SDL_GFXPRIMITIVES_SCOPE int vlineRGBA(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 62 63 /* Rectangle */ 64 65 SDL_GFXPRIMITIVES_SCOPE int rectangleColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); 66 SDL_GFXPRIMITIVES_SCOPE int rectangleRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, 67 Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 68 69 #if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ 70 /* Rounded-Corner Rectangle */ 71 72 SDL_GFXPRIMITIVES_SCOPE int roundedRectangleColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color); 73 SDL_GFXPRIMITIVES_SCOPE int roundedRectangleRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, 74 Sint16 x2, Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 75 #endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ 76 77 /* Filled rectangle (Box) */ 78 79 SDL_GFXPRIMITIVES_SCOPE int boxColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); 80 SDL_GFXPRIMITIVES_SCOPE int boxRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, 81 Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 82 83 #if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ 84 /* Rounded-Corner Filled rectangle (Box) */ 85 86 SDL_GFXPRIMITIVES_SCOPE int roundedBoxColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color); 87 SDL_GFXPRIMITIVES_SCOPE int roundedBoxRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, 88 Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 89 #endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ 90 91 /* Line */ 92 93 SDL_GFXPRIMITIVES_SCOPE int lineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); 94 SDL_GFXPRIMITIVES_SCOPE int lineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, 95 Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 96 97 #if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ 98 /* AA Line */ 99 100 SDL_GFXPRIMITIVES_SCOPE int aalineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); 101 SDL_GFXPRIMITIVES_SCOPE int aalineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, 102 Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 103 104 /* Thick Line */ 105 SDL_GFXPRIMITIVES_SCOPE int thickLineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, 106 Uint8 width, Uint32 color); 107 SDL_GFXPRIMITIVES_SCOPE int thickLineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, 108 Uint8 width, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 109 #endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ 110 111 /* Circle */ 112 113 SDL_GFXPRIMITIVES_SCOPE int circleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint32 color); 114 SDL_GFXPRIMITIVES_SCOPE int circleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 115 116 /* Arc */ 117 118 SDL_GFXPRIMITIVES_SCOPE int arcColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color); 119 SDL_GFXPRIMITIVES_SCOPE int arcRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, 120 Uint8 r, Uint8 g, Uint8 b, Uint8 a); 121 122 /* AA Circle */ 123 124 SDL_GFXPRIMITIVES_SCOPE int aacircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint32 color); 125 SDL_GFXPRIMITIVES_SCOPE int aacircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, 126 Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 127 128 /* Filled Circle */ 129 130 SDL_GFXPRIMITIVES_SCOPE int filledCircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color); 131 SDL_GFXPRIMITIVES_SCOPE int filledCircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, 132 Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 133 134 /* Ellipse */ 135 136 SDL_GFXPRIMITIVES_SCOPE int ellipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color); 137 SDL_GFXPRIMITIVES_SCOPE int ellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, 138 Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 139 140 /* AA Ellipse */ 141 142 SDL_GFXPRIMITIVES_SCOPE int aaellipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color); 143 SDL_GFXPRIMITIVES_SCOPE int aaellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, 144 Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 145 146 /* Filled Ellipse */ 147 148 SDL_GFXPRIMITIVES_SCOPE int filledEllipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color); 149 SDL_GFXPRIMITIVES_SCOPE int filledEllipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, 150 Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 151 152 /* Pie */ 153 154 SDL_GFXPRIMITIVES_SCOPE int pieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, 155 Sint16 start, Sint16 end, Uint32 color); 156 SDL_GFXPRIMITIVES_SCOPE int pieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, 157 Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 158 159 #if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ 160 /* Filled Pie */ 161 162 SDL_GFXPRIMITIVES_SCOPE int filledPieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, 163 Sint16 start, Sint16 end, Uint32 color); 164 SDL_GFXPRIMITIVES_SCOPE int filledPieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, 165 Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 166 #endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ 167 168 /* Trigon */ 169 170 SDL_GFXPRIMITIVES_SCOPE int trigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color); 171 SDL_GFXPRIMITIVES_SCOPE int trigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, 172 Uint8 r, Uint8 g, Uint8 b, Uint8 a); 173 174 /* AA-Trigon */ 175 176 SDL_GFXPRIMITIVES_SCOPE int aatrigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color); 177 SDL_GFXPRIMITIVES_SCOPE int aatrigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, 178 Uint8 r, Uint8 g, Uint8 b, Uint8 a); 179 180 /* Filled Trigon */ 181 182 SDL_GFXPRIMITIVES_SCOPE int filledTrigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color); 183 SDL_GFXPRIMITIVES_SCOPE int filledTrigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, 184 Uint8 r, Uint8 g, Uint8 b, Uint8 a); 185 186 /* Polygon */ 187 188 SDL_GFXPRIMITIVES_SCOPE int polygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color); 189 SDL_GFXPRIMITIVES_SCOPE int polygonRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, 190 int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 191 192 /* AA-Polygon */ 193 194 SDL_GFXPRIMITIVES_SCOPE int aapolygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color); 195 SDL_GFXPRIMITIVES_SCOPE int aapolygonRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, 196 int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 197 198 /* Filled Polygon */ 199 200 SDL_GFXPRIMITIVES_SCOPE int filledPolygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color); 201 SDL_GFXPRIMITIVES_SCOPE int filledPolygonRGBA(SDL_Surface * dst, const Sint16 * vx, 202 const Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 203 SDL_GFXPRIMITIVES_SCOPE int texturedPolygon(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, SDL_Surface * texture,int texture_dx,int texture_dy); 204 205 /* (Note: These MT versions are required for multi-threaded operation.) */ 206 207 SDL_GFXPRIMITIVES_SCOPE int filledPolygonColorMT(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color, int **polyInts, int *polyAllocated); 208 SDL_GFXPRIMITIVES_SCOPE int filledPolygonRGBAMT(SDL_Surface * dst, const Sint16 * vx, 209 const Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a, 210 int **polyInts, int *polyAllocated); 211 SDL_GFXPRIMITIVES_SCOPE int texturedPolygonMT(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, SDL_Surface * texture,int texture_dx,int texture_dy, int **polyInts, int *polyAllocated); 212 213 /* Bezier */ 214 215 SDL_GFXPRIMITIVES_SCOPE int bezierColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, int s, Uint32 color); 216 SDL_GFXPRIMITIVES_SCOPE int bezierRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, 217 int n, int s, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 218 219 #if 0 /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ 220 /* Characters/Strings */ 221 222 SDL_GFXPRIMITIVES_SCOPE void gfxPrimitivesSetFont(const void *fontdata, Uint32 cw, Uint32 ch); 223 SDL_GFXPRIMITIVES_SCOPE void gfxPrimitivesSetFontRotation(Uint32 rotation); 224 SDL_GFXPRIMITIVES_SCOPE int characterColor(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint32 color); 225 SDL_GFXPRIMITIVES_SCOPE int characterRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 226 SDL_GFXPRIMITIVES_SCOPE int stringColor(SDL_Surface * dst, Sint16 x, Sint16 y, const char *s, Uint32 color); 227 SDL_GFXPRIMITIVES_SCOPE int stringRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, const char *s, Uint8 r, Uint8 g, Uint8 b, Uint8 a); 228 #endif /********** CURRENTLY NOT USED BY pygame.gfxdraw **********/ 229 230 /* Ends C function definitions when using C++ */ 231 #ifdef __cplusplus 232 } 233 #endif 234 235 #endif /* _SDL_gfxPrimitives_h */ 236