/* ** string.c for in /home/gayot_o/prog/lib/sdl-digit ** ** Made by olivier gayot ** Login ** ** Started on Mon Apr 23 11:08:25 2012 olivier gayot ** Last update Mon Apr 23 11:08:25 2012 olivier gayot */ #include #include "sdl_digit.h" void draw_string(SDL_Surface *surf, SDL_Rect *rect, const char *str, Uint32 color, int size) { SDL_Rect rect_; rect_.x = (rect) ? rect->x : 0; rect_.y = (rect) ? rect->y : 0; while (*str) { if (draw_digit(surf, &rect_, size, color, *str)) rect_.x += size * 150. / 100.; ++str; } } SDL_Surface *new_string(const char *str, Uint32 color, int size) { SDL_Surface *surf; int w; int h; w = (size * 150. / 100.) * strlen(str);; h = (size * 2) + (size / 5); surf = SDL_CreateRGBSurface(SDL_HWSURFACE, w, h, 32, 0, 0, 0, 0); draw_string(surf, NULL, str, color, size); return (surf); }