| 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.141592654 |
| 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 10 |
| 29 |
|
| 30 |
/* ----- Prototypes */ |
| 31 |
|
| 32 |
/* Note: all ___Color routines expect the color to be in format 0xRRGGBBAA */ |
| 33 |
|
| 34 |
/* Pixel */ |
| 35 |
|
| 36 |
extern int pixelColor(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color); |
| 37 |
extern int pixelRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 38 |
|
| 39 |
/* Horizontal line */ |
| 40 |
|
| 41 |
extern int hlineColor(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color); |
| 42 |
extern int hlineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 43 |
|
| 44 |
/* Vertical line */ |
| 45 |
|
| 46 |
extern int vlineColor(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color); |
| 47 |
extern int vlineRGBA(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 48 |
|
| 49 |
/* Rectangle */ |
| 50 |
|
| 51 |
extern int rectangleColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); |
| 52 |
extern int rectangleRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, |
| 53 |
Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 54 |
|
| 55 |
/* Filled rectangle (Box) */ |
| 56 |
|
| 57 |
extern int boxColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); |
| 58 |
extern int boxRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, |
| 59 |
Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 60 |
|
| 61 |
/* Line */ |
| 62 |
|
| 63 |
extern int lineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); |
| 64 |
extern int lineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, |
| 65 |
Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 66 |
|
| 67 |
/* AA Line */ |
| 68 |
extern int aalineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); |
| 69 |
extern int aalineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, |
| 70 |
Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 71 |
|
| 72 |
/* Circle */ |
| 73 |
|
| 74 |
extern int circleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color); |
| 75 |
extern int circleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 76 |
|
| 77 |
/* AA Circle */ |
| 78 |
|
| 79 |
extern int aacircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color); |
| 80 |
extern int aacircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, |
| 81 |
Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 82 |
|
| 83 |
/* Filled Circle */ |
| 84 |
|
| 85 |
extern int filledCircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color); |
| 86 |
extern int filledCircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, |
| 87 |
Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 88 |
|
| 89 |
/* Ellipse */ |
| 90 |
|
| 91 |
extern int ellipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color); |
| 92 |
extern int ellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, |
| 93 |
Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 94 |
|
| 95 |
/* AA Ellipse */ |
| 96 |
|
| 97 |
extern int aaellipseColor(SDL_Surface * dst, Sint16 xc, Sint16 yc, Sint16 rx, Sint16 ry, Uint32 color); |
| 98 |
extern int aaellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, |
| 99 |
Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 100 |
|
| 101 |
/* Filled Ellipse */ |
| 102 |
|
| 103 |
extern int filledEllipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color); |
| 104 |
extern int filledEllipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, |
| 105 |
Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 106 |
/* Filled Pie */ |
| 107 |
|
| 108 |
extern int filledpieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, |
| 109 |
Sint16 start, Sint16 end, Uint32 color); |
| 110 |
extern int filledpieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, |
| 111 |
Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 112 |
|
| 113 |
/* Trigon */ |
| 114 |
|
| 115 |
extern int trigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color); |
| 116 |
extern int trigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, |
| 117 |
Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 118 |
|
| 119 |
/* AA-Trigon */ |
| 120 |
|
| 121 |
extern int aatrigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color); |
| 122 |
extern int aatrigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, |
| 123 |
Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 124 |
|
| 125 |
/* Filled Trigon */ |
| 126 |
|
| 127 |
extern int filledTrigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, int color); |
| 128 |
extern int filledTrigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, |
| 129 |
Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 130 |
|
| 131 |
/* Polygon */ |
| 132 |
|
| 133 |
extern int polygonColor(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, int n, Uint32 color); |
| 134 |
extern int polygonRGBA(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, |
| 135 |
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 136 |
|
| 137 |
/* AA-Polygon */ |
| 138 |
|
| 139 |
extern int aapolygonColor(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, int n, Uint32 color); |
| 140 |
extern int aapolygonRGBA(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, |
| 141 |
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 142 |
|
| 143 |
/* Filled Polygon */ |
| 144 |
|
| 145 |
extern int filledPolygonColor(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, int n, int color); |
| 146 |
extern int filledPolygonRGBA(SDL_Surface * dst, Sint16 * vx, |
| 147 |
Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 148 |
|
| 149 |
/* Bezier */ |
| 150 |
/* s = number of steps */ |
| 151 |
|
| 152 |
extern int bezierColor(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, int n, int s, Uint32 color); |
| 153 |
extern int bezierRGBA(SDL_Surface * dst, Sint16 * vx, Sint16 * vy, |
| 154 |
int n, int s, Uint8 r, Uint8 g, Uint8 b, Uint8 a); |
| 155 |
|
| 156 |
/* Ends C function definitions when using C++ */ |
| 157 |
#ifdef __cplusplus |
| 158 |
} |
| 159 |
#endif |
| 160 |
|
| 161 |
#endif /* _SDL_gfxPrimitives_h */ |