diff options
Diffstat (limited to 'c_src/sdl_rect.c')
| -rw-r--r-- | c_src/sdl_rect.c | 18 | 
1 files changed, 18 insertions, 0 deletions
| diff --git a/c_src/sdl_rect.c b/c_src/sdl_rect.c index eb04d5b..737c920 100644 --- a/c_src/sdl_rect.c +++ b/c_src/sdl_rect.c @@ -55,3 +55,21 @@ int map_to_rect(ErlNifEnv* env, ERL_NIF_TERM map, SDL_Rect* rect)  	return 1;  } + +ERL_NIF_TERM rect_to_map(ErlNifEnv* env, SDL_Rect* rect) +{ +	ERL_NIF_TERM map; + +	map = enif_make_new_map(env); + +	enif_make_map_put(env, map, atom_x, +		enif_make_int(env, rect->x), &map); +	enif_make_map_put(env, map, atom_y, +		enif_make_int(env, rect->y), &map); +	enif_make_map_put(env, map, atom_w, +		enif_make_int(env, rect->w), &map); +	enif_make_map_put(env, map, atom_h, +		enif_make_int(env, rect->h), &map); + +	return map; +} | 
