Moved old SDL::Palette to SDL::Game::Palette.
[sdlgit/SDL_perl.git] / src / Core / objects / Palette.xs
CommitLineData
997e38e1 1#include "EXTERN.h"
2#include "perl.h"
3#include "XSUB.h"
4
5#ifndef aTHX_
6#define aTHX_
7#endif
8
9#include <SDL.h>
10
11MODULE = SDL::Palette PACKAGE = SDL::Palette PREFIX = palette_
12
13=for documentation
14
15SDL_Palette -- Color palette for 8-bit pixel formats
16
17 typedef struct{
18 int ncolors;
19 SDL_Color *colors
20 } SDL_Palette;
21
22=cut
23
24int
25palette_ncolors ( palette )
26 SDL_Palette *palette
27 CODE:
28 RETVAL = palette->ncolors;
29 OUTPUT:
30 RETVAL
31
32AV *
33palette_colors ( palette )
34 SDL_Palette *palette
35 CODE:
36 RETVAL = newAV();
37 int i;
38 for(i = 0; i < palette->ncolors; i++)
39 {
40
41 av_push(RETVAL,newSViv( PTR2IV( palette->colors + i ) ) );
42
43 }
44 OUTPUT:
45 RETVAL
46
47
48SDL_Color *
60891a9e 49palette_color_index ( palette, index )
997e38e1 50 SDL_Palette *palette
51 int index
52 PREINIT:
53 char * CLASS = "SDL::Color";
54 CODE:
55 RETVAL = (SDL_Color *)(palette->colors + index);
56 OUTPUT:
57 RETVAL
58
59
60