diff options
author | Loïc Hoguin <[email protected]> | 2018-02-06 00:05:12 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-02-06 00:05:12 +0100 |
commit | 0e6c291c64e77181851b8a3255a3da8827124080 (patch) | |
tree | 825bc984cf63b24ad8437cc0bbc27760ea95dfef /c_src/sdl_pixels.c | |
parent | 251a2457fe10910b357e33609a59545684294bc3 (diff) | |
download | esdl2-0e6c291c64e77181851b8a3255a3da8827124080.tar.gz esdl2-0e6c291c64e77181851b8a3255a3da8827124080.tar.bz2 esdl2-0e6c291c64e77181851b8a3255a3da8827124080.zip |
Initial work on the SDL_ttf functions
Diffstat (limited to 'c_src/sdl_pixels.c')
-rw-r--r-- | c_src/sdl_pixels.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/c_src/sdl_pixels.c b/c_src/sdl_pixels.c index aa22329..1bdec60 100644 --- a/c_src/sdl_pixels.c +++ b/c_src/sdl_pixels.c @@ -60,3 +60,34 @@ NIF_ENUM_TO_ATOM_FUNCTION(pixel_format_to_atom, Uint32, PIXEL_FORMAT_ENUM) NIF_ATOM_TO_ENUM_FUNCTION(atom_to_pixel_format, Uint32, PIXEL_FORMAT_ENUM) + +int map_to_color(ErlNifEnv* env, ERL_NIF_TERM map, SDL_Color* color) +{ + ERL_NIF_TERM r, g, b, a; + unsigned int ri, gi, bi, ai; + + if (!enif_get_map_value(env, map, atom_r, &r)) + return 0; + if (!enif_get_map_value(env, map, atom_g, &g)) + return 0; + if (!enif_get_map_value(env, map, atom_b, &b)) + return 0; + if (!enif_get_map_value(env, map, atom_a, &a)) + return 0; + + if (!enif_get_uint(env, r, &ri)) + return 0; + if (!enif_get_uint(env, g, &gi)) + return 0; + if (!enif_get_uint(env, b, &bi)) + return 0; + if (!enif_get_uint(env, a, &ai)) + return 0; + + color->r = ri; + color->g = gi; + color->b = bi; + color->a = ai; + + return 1; +} |