[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] Draw primitives and RGBA
What about the SDL_gfx library?
It is a library composed of:
Graphic Primitives (SDL_gfxPrimitves.h)
Rotozoomer (SDL_rotozoom.h)
Framerate control (SDL_framerate.h)
MMX image filters (SDL_imageFilter.h)
This a cut and paste of the manual entry for SDL_gfxPrimitives (I've
compiled everything under VisualC and I'm tempted by the idea of having
them in pygame too:-) ):
Note: all ___Color routines expect the color to be in format 0xRRGGBBAA
Pixel
int pixelColor(SDL_Surface * dst, Sint16 x, Sint16 y,
Uint32 color);
int pixelRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r,
Uint8 g, Uint8 b, Uint8 a);
Horizontal line
int hlineColor(SDL_Surface * dst, Sint16 x1, Sint16 x2,
Sint16 y, Uint32 color);
int hlineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 x2,
Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
Vertical line
int vlineColor(SDL_Surface * dst, Sint16 x, Sint16 y1,
Sint16 y2, Uint32 color);
int vlineRGBA(SDL_Surface * dst, Sint16 x, Sint16 y1,
Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
Rectangle
int rectangleColor(SDL_Surface * dst, Sint16 x1, Sint16 y1,
Sint16 x2, Sint16 y2, Uint32 color);
int rectangleRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1,
Sint16 x2, Sint16 y2, Uint8 r, Uint8 g,
Uint8 b, Uint8 a);
Filled rectangle (Box)
int boxColor(SDL_Surface * dst, Sint16 x1, Sint16 y1,
Sint16 x2, Sint16 y2, Uint32 color);
int boxRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2,
Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
Line
int lineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1,
Sint16 x2, Sint16 y2, Uint32 color);
int lineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1,
Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b,
Uint8 a);
AA Line
int aalineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1,
Sint16 x2, Sint16 y2, Uint32 color);
int aalineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1,
Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b,
Uint8 a);
Circle
int circleColor(SDL_Surface * dst, Sint16 x, Sint16 y,
Sint16 r, Uint32 color);
int circleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
AA Circle
int aacircleColor(SDL_Surface * dst, Sint16 x, Sint16 y,
Sint16 r, Uint32 color);
int aacircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
Sint16 rad, Uint8 r, Uint8 g, Uint8 b,
Uint8 a);
Filled Circle
int filledCircleColor(SDL_Surface * dst, Sint16 x, Sint16 y,
Sint16 r, Uint32 color);
int filledCircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
Sint16 rad, Uint8 r, Uint8 g, Uint8 b,
Uint8 a);
Ellipse
int ellipseColor(SDL_Surface * dst, Sint16 x, Sint16 y,
Sint16 rx, Sint16 ry, Uint32 color);
int ellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
Sint16 rx, Sint16 ry, Uint8 r, Uint8 g,
Uint8 b, Uint8 a);
AA Ellipse
int aaellipseColor(SDL_Surface * dst, Sint16 x, Sint16 y,
Sint16 rx, Sint16 ry, Uint32 color);
int aaellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
Sint16 rx, Sint16 ry, Uint8 r, Uint8 g,
Uint8 b, Uint8 a);
Filled Ellipse
int filledEllipseColor(SDL_Surface * dst, Sint16 x, Sint16 y,
Sint16 rx, Sint16 ry, Uint32 color);
int filledEllipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
Sint16 rx, Sint16 ry, Uint8 r, Uint8 g,
Uint8 b, Uint8 a);
Filled Pie
int filledpieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad,
Sint16 start, Sint16 end, Uint32 color);
int filledpieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad,
Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
Polygon
int polygonColor(SDL_Surface * dst, Sint16 * vx, Sint16 * vy,
int n, Uint32 color);
int polygonRGBA(SDL_Surface * dst, Sint16 * vx, Sint16 * vy,
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
AA-Polygon
int aapolygonColor(SDL_Surface * dst, Sint16 * vx, Sint16 * vy,
int n, Uint32 color);
int aapolygonRGBA(SDL_Surface * dst, Sint16 * vx, Sint16 * vy,
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
Filled Polygon
int filledPolygonColor(SDL_Surface * dst, Sint16 * vx,
Sint16 * vy, int n, int color);
int filledPolygonRGBA(SDL_Surface * dst, Sint16 * vx,
Sint16 * vy, int n, Uint8 r, Uint8 g,
Uint8 b, Uint8 a);
8x8 Characters/Strings
int characterColor(SDL_Surface * dst, Sint16 x, Sint16 y,
char c, Uint32 color);
int characterRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
char c, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
int stringColor(SDL_Surface * dst, Sint16 x, Sint16 y, char *c,
Uint32 color);
int stringRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, char *c,
Uint8 r, Uint8 g, Uint8 b, Uint8 a);
I think that it sounds interesting (also the other routines are very
interesting, the filtering and image math stuff, MMX optimized....).
Well, I think that it should not be so difficult to make a working
prototype with SWIG,but that's not the right way of doing things in
pygame I presume...
Hope it helps...
Riccardo
Pete Shinners wrote:
> Korruptor wrote:
>
>> Are there any plans to get the pygame.draw primitives to accept an
>> RGBA colour value? This would be very handy on the polygon one in
>> particular. I have a cunning plan... ;)
>>
>> I'm happy to get alpha by other means, just thought it would be nice...
>
>
> there's two ways to do this. one is to simply set the RGB and A values
> sort of like we are doing now. actually, thinking about it, i believe
> you can already do this? (/me checks the code...) yes, it will already
> work like this, setting the straight alpha values just like RGB.
>
> what you are probably wanting is to actually draw primitive
> transparantly onto the surface. the code is not really difficult, and
> optimized transparent drawing would be far faster than drawing to
> temporary surfaces and blitting.
>
> hmm, i suppose adding an "_alpha" version to the functions would be
> the best way to go (any ideas?) i'll put this on the pygame "todo"
> list, because it is a bit of a beast. another request has been to be
> able to big lists of primitives using a single call. that one is even
> messier, as there are a couple ways to store big lists of primitives.
>
>
>
>
>
>
> ____________________________________
> pygame mailing list
> pygame-users@seul.org
> http://pygame.seul.org
>
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org