Path: blob/main/system/include/SDL/SDL_gfxPrimitives.h
6169 views
/*12SDL_gfxPrimitives.h: graphics primitives for SDL34Copyright (C) 2001-2011 Andreas Schiffler56This software is provided 'as-is', without any express or implied7warranty. In no event will the authors be held liable for any damages8arising from the use of this software.910Permission is granted to anyone to use this software for any purpose,11including commercial applications, and to alter it and redistribute it12freely, subject to the following restrictions:13141. The origin of this software must not be misrepresented; you must not15claim that you wrote the original software. If you use this software16in a product, an acknowledgment in the product documentation would be17appreciated but is not required.18192. Altered source versions must be plainly marked as such, and must not be20misrepresented as being the original software.21223. This notice may not be removed or altered from any source23distribution.2425Andreas Schiffler -- aschiffler at ferzkopp dot net2627*/2829#ifndef _SDL_gfxPrimitives_h30#define _SDL_gfxPrimitives_h3132#include <math.h>33#ifndef M_PI34#define M_PI 3.141592653589793238462643383279535#endif3637#include "SDL.h"3839/* Set up for C function definitions, even when using C++ */40#ifdef __cplusplus41extern "C" {42#endif4344/* ----- Versioning */4546#define SDL_GFXPRIMITIVES_MAJOR 247#define SDL_GFXPRIMITIVES_MINOR 048#define SDL_GFXPRIMITIVES_MICRO 23495051/* ---- Function Prototypes */5253#ifdef _MSC_VER54# if defined(DLL_EXPORT) && !defined(LIBSDL_GFX_DLL_IMPORT)55# define SDL_GFXPRIMITIVES_SCOPE __declspec(dllexport)56# else57# ifdef LIBSDL_GFX_DLL_IMPORT58# define SDL_GFXPRIMITIVES_SCOPE __declspec(dllimport)59# endif60# endif61#endif62#ifndef SDL_GFXPRIMITIVES_SCOPE63# define SDL_GFXPRIMITIVES_SCOPE extern64#endif6566/* Note: all ___Color routines expect the color to be in format 0xRRGGBBAA */6768/* Pixel */6970SDL_GFXPRIMITIVES_SCOPE int pixelColor(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color);71SDL_GFXPRIMITIVES_SCOPE int pixelRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a);7273/* Horizontal line */7475SDL_GFXPRIMITIVES_SCOPE int hlineColor(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color);76SDL_GFXPRIMITIVES_SCOPE int hlineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a);7778/* Vertical line */7980SDL_GFXPRIMITIVES_SCOPE int vlineColor(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color);81SDL_GFXPRIMITIVES_SCOPE int vlineRGBA(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);8283/* Rectangle */8485SDL_GFXPRIMITIVES_SCOPE int rectangleColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);86SDL_GFXPRIMITIVES_SCOPE int rectangleRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1,87Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);8889/* Rounded-Corner Rectangle */9091SDL_GFXPRIMITIVES_SCOPE int roundedRectangleColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color);92SDL_GFXPRIMITIVES_SCOPE int roundedRectangleRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1,93Sint16 x2, Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);9495/* Filled rectangle (Box) */9697SDL_GFXPRIMITIVES_SCOPE int boxColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);98SDL_GFXPRIMITIVES_SCOPE int boxRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2,99Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);100101/* Rounded-Corner Filled rectangle (Box) */102103SDL_GFXPRIMITIVES_SCOPE int roundedBoxColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color);104SDL_GFXPRIMITIVES_SCOPE int roundedBoxRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2,105Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);106107/* Line */108109SDL_GFXPRIMITIVES_SCOPE int lineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);110SDL_GFXPRIMITIVES_SCOPE int lineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1,111Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);112113/* AA Line */114115SDL_GFXPRIMITIVES_SCOPE int aalineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);116SDL_GFXPRIMITIVES_SCOPE int aalineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1,117Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);118119/* Thick Line */120SDL_GFXPRIMITIVES_SCOPE int thickLineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,121Uint8 width, Uint32 color);122SDL_GFXPRIMITIVES_SCOPE int thickLineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,123Uint8 width, Uint8 r, Uint8 g, Uint8 b, Uint8 a);124125/* Circle */126127SDL_GFXPRIMITIVES_SCOPE int circleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint32 color);128SDL_GFXPRIMITIVES_SCOPE int circleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);129130/* Arc */131132SDL_GFXPRIMITIVES_SCOPE int arcColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color);133SDL_GFXPRIMITIVES_SCOPE int arcRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end,134Uint8 r, Uint8 g, Uint8 b, Uint8 a);135136/* AA Circle */137138SDL_GFXPRIMITIVES_SCOPE int aacircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint32 color);139SDL_GFXPRIMITIVES_SCOPE int aacircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,140Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);141142/* Filled Circle */143144SDL_GFXPRIMITIVES_SCOPE int filledCircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color);145SDL_GFXPRIMITIVES_SCOPE int filledCircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,146Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);147148/* Ellipse */149150SDL_GFXPRIMITIVES_SCOPE int ellipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color);151SDL_GFXPRIMITIVES_SCOPE int ellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,152Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a);153154/* AA Ellipse */155156SDL_GFXPRIMITIVES_SCOPE int aaellipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color);157SDL_GFXPRIMITIVES_SCOPE int aaellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,158Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a);159160/* Filled Ellipse */161162SDL_GFXPRIMITIVES_SCOPE int filledEllipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color);163SDL_GFXPRIMITIVES_SCOPE int filledEllipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,164Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a);165166/* Pie */167168SDL_GFXPRIMITIVES_SCOPE int pieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad,169Sint16 start, Sint16 end, Uint32 color);170SDL_GFXPRIMITIVES_SCOPE int pieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad,171Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a);172173/* Filled Pie */174175SDL_GFXPRIMITIVES_SCOPE int filledPieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad,176Sint16 start, Sint16 end, Uint32 color);177SDL_GFXPRIMITIVES_SCOPE int filledPieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad,178Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a);179180/* Trigon */181182SDL_GFXPRIMITIVES_SCOPE int trigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color);183SDL_GFXPRIMITIVES_SCOPE int trigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,184Uint8 r, Uint8 g, Uint8 b, Uint8 a);185186/* AA-Trigon */187188SDL_GFXPRIMITIVES_SCOPE int aatrigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color);189SDL_GFXPRIMITIVES_SCOPE int aatrigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,190Uint8 r, Uint8 g, Uint8 b, Uint8 a);191192/* Filled Trigon */193194SDL_GFXPRIMITIVES_SCOPE int filledTrigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color);195SDL_GFXPRIMITIVES_SCOPE int filledTrigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,196Uint8 r, Uint8 g, Uint8 b, Uint8 a);197198/* Polygon */199200SDL_GFXPRIMITIVES_SCOPE int polygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color);201SDL_GFXPRIMITIVES_SCOPE int polygonRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy,202int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a);203204/* AA-Polygon */205206SDL_GFXPRIMITIVES_SCOPE int aapolygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color);207SDL_GFXPRIMITIVES_SCOPE int aapolygonRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy,208int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a);209210/* Filled Polygon */211212SDL_GFXPRIMITIVES_SCOPE int filledPolygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color);213SDL_GFXPRIMITIVES_SCOPE int filledPolygonRGBA(SDL_Surface * dst, const Sint16 * vx,214const Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a);215SDL_GFXPRIMITIVES_SCOPE int texturedPolygon(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, SDL_Surface * texture,int texture_dx,int texture_dy);216217/* (Note: These MT versions are required for multi-threaded operation.) */218219SDL_GFXPRIMITIVES_SCOPE int filledPolygonColorMT(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color, int **polyInts, int *polyAllocated);220SDL_GFXPRIMITIVES_SCOPE int filledPolygonRGBAMT(SDL_Surface * dst, const Sint16 * vx,221const Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a,222int **polyInts, int *polyAllocated);223SDL_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);224225/* Bezier */226227SDL_GFXPRIMITIVES_SCOPE int bezierColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, int s, Uint32 color);228SDL_GFXPRIMITIVES_SCOPE int bezierRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy,229int n, int s, Uint8 r, Uint8 g, Uint8 b, Uint8 a);230231/* Characters/Strings */232233SDL_GFXPRIMITIVES_SCOPE void gfxPrimitivesSetFont(const void *fontdata, Uint32 cw, Uint32 ch);234SDL_GFXPRIMITIVES_SCOPE void gfxPrimitivesSetFontRotation(Uint32 rotation);235SDL_GFXPRIMITIVES_SCOPE int characterColor(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint32 color);236SDL_GFXPRIMITIVES_SCOPE int characterRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint8 r, Uint8 g, Uint8 b, Uint8 a);237SDL_GFXPRIMITIVES_SCOPE int stringColor(SDL_Surface * dst, Sint16 x, Sint16 y, const char *s, Uint32 color);238SDL_GFXPRIMITIVES_SCOPE int stringRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, const char *s, Uint8 r, Uint8 g, Uint8 b, Uint8 a);239240/* Ends C function definitions when using C++ */241#ifdef __cplusplus242}243#endif244245#endif /* _SDL_gfxPrimitives_h */246247248