summaryrefslogtreecommitdiff
path: root/src/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/string.c b/src/string.c
new file mode 100644
index 0000000..ce93e88
--- /dev/null
+++ b/src/string.c
@@ -0,0 +1,37 @@
+/*
+** string.c for in /home/gayot_o/prog/lib/sdl-digit
+**
+** Made by olivier gayot
+** Login <gayot_o@epitech.net>
+**
+** Started on Mon Apr 23 11:08:25 2012 olivier gayot
+** Last update Mon Apr 23 11:08:25 2012 olivier gayot
+*/
+
+#include <string.h>
+#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);
+}