Guest User

Untitled

a guest
Oct 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. // x = pos inicial
  2. // y = pos inicial
  3. // max_x = pos maxima X
  4. // sx = tamaño X fuente
  5. // sy = tamaño Y fuente
  6. // string ... formato + vars
  7. void drawWrappedString(float x, float y, float max_x, int sx, int sy, char *string, ...){
  8.     char str[4096];
  9.  
  10.     va_list argp;        
  11.     va_start(argp, string);
  12.     vsprintf(str, string, argp);
  13.     va_end(argp);
  14.  
  15.     char *pch = NULL;
  16.     pch = strtok(str, " ");
  17.  
  18.     float cx = x;
  19.     float cy = y;
  20.  
  21.     while(pch != NULL){
  22.         struct _SIZE size = GetTextSize(sx, sy, pch);
  23.  
  24.         if(cx + size.width >= max_x){
  25.             DrawString(cx, cy, "\n");
  26.             cy = GetFontY();
  27.             cx = x;
  28.         }
  29.  
  30.         DrawString(cx, cy, pch);
  31.         DrawString(GetFontX(), cy, " ");
  32.        
  33.         cx = GetFontX();
  34.         cy = GetFontY();
  35.  
  36.         pch = strtok(NULL, " ");
  37.     }
  38. }
Add Comment
Please, Sign In to add comment