File: TEXT_BOR.C | Size: 4,832 bytes | Download file | Back to directory listing | BWPOW's homepage
/**********************************************************************
                 TEXT WITH BORDER LIBRARY FOR ALLEGRO 3.11
 
                           By David Aranda Alonso
 
12-10-1999                                                 davidj@ozu.es
***********************************************************************/
 
#include <stdarg.h>
#include <stdio.h>
#include "allegro.h"
#include "text_bor.h"
 
 
void textout_centre_border (BITMAP *bmp, FONT *fuente, unsigned char *str, int x, int y, int color, int border, int size, int mode)
{
  int times;
 
 text_mode (mode);
 if (size!=-1)    /* size==-1 do another method of border, look down */
   {
   for (times=1;times<size+1;times++)
     {
     textout_centre (bmp, fuente, str, x,  y-times,  border);
     textout_centre (bmp, fuente, str, x+times,  y-times,  border);
     textout_centre (bmp, fuente, str, x-times,  y,  border);
     textout_centre (bmp, fuente, str, x-times,  y-times,  border);
     textout_centre (bmp, fuente, str, x+times,  y,  border);
     textout_centre (bmp, fuente, str, x,  y+times,  border);
     textout_centre (bmp, fuente, str, x-times,  y+times,  border);
     textout_centre (bmp, fuente, str, x+times,  y+times,  border);
     }
    }
   else
     {
     textout_centre (bmp, fuente, str, x-1,  y,  border);
     textout_centre (bmp, fuente, str, x+1,  y,  border);
     textout_centre (bmp, fuente, str, x,  y-1,  border);
     textout_centre (bmp, fuente, str, x,  y+1,  border);
 
     textout_centre (bmp, fuente, str, x,  y,  border);
     }
 
  text_mode(-1);
  textout_centre (bmp, fuente, str, x, y, color);
  text_mode (mode);
}
 
 
void textout_border (BITMAP *bmp, FONT *fuente, unsigned char *str, int x, int y, int color, int border, int size, int mode)
{
 int times;
 
 text_mode (mode);
 
 if (size!=-1) 
   {
    for (times=1;times<size+1;times++)
     {
      textout (bmp, fuente, str, x,  y-times,  border);
      textout (bmp, fuente, str, x+times,  y-times,  border);
      textout (bmp, fuente, str, x-times,  y,  border);
      textout (bmp, fuente, str, x-times,  y-times,  border);
      textout (bmp, fuente, str, x+times,  y,  border);
      textout (bmp, fuente, str, x,  y+times,  border);
      textout (bmp, fuente, str, x-times,  y+times,  border);
      textout (bmp, fuente, str, x+times,  y+times,  border);
     }
    }
   else
     {
     textout (bmp, fuente, str, x-1,  y,  border);
     textout (bmp, fuente, str, x+1,  y,  border);
     textout (bmp, fuente, str, x,  y-1,  border);
     textout (bmp, fuente, str, x,  y+1,  border);
 
     textout (bmp, fuente, str, x,  y,  border);
     }
 
  text_mode(-1);
  textout (bmp, fuente, str, x, y, color);
  text_mode (mode);
}
 
 
void textout_justify_border (BITMAP *bmp, FONT *fuente, unsigned char *str, int x, int x2, int y, int diff, int color, int border, int size, int mode)
{
int times;
 
 text_mode (mode);
 if (size!=-1)
   {
   for (times=1;times<size+1;times++)
     {
     textout_justify (bmp, fuente, str, x, x2, y-times, diff, border);
     textout_justify (bmp, fuente, str, x+times, x2+times,  y-times, diff, border);
     textout_justify (bmp, fuente, str, x-times, x2-times, y,  diff, border);
     textout_justify (bmp, fuente, str, x-times, x2-times, y-times,  diff, border);
     textout_justify (bmp, fuente, str, x+times, x2+times, y,  diff, border);
     textout_justify (bmp, fuente, str, x, x2, y+times,  diff, border);
     textout_justify (bmp, fuente, str, x-times, x2-times, y+times,  diff, border);
     textout_justify (bmp, fuente, str, x+times, x2+times, y+times,  diff, border);
     }
   }
 
   else
     {
     textout_justify (bmp, fuente, str, x-1, x2, y, diff, border);
     textout_justify (bmp, fuente, str, x+1, x2, y, diff, border);
     textout_justify (bmp, fuente, str, x, x2, y-1, diff, border);
     textout_justify (bmp, fuente, str, x, x2, y+1, diff, border);
 
     textout_justify (bmp, fuente, str, x, x2, y, diff, border);
     }
 
  text_mode(-1);
  textout_justify (bmp, fuente, str, x, x2, y, diff, color);
  text_mode (mode);
}
 
void textprintf_border(BITMAP *bmp, FONT *f, int x, int y, int color, int border, int size, int mode, char *format, ...)
 {
   char buf[256];
 
   va_list ap;
   va_start(ap, format);
   vsprintf(buf, format, ap);
   va_end(ap);
 
   textout_border(bmp, f, buf, x, y, color, border, size, mode);
   }
 
void textprintf_centre_border(BITMAP *bmp, FONT *f, int x, int y, int color, int border, int size, int mode, char *format, ...)
 {
   char buf[256];
 
   va_list ap;
   va_start(ap, format);
   vsprintf(buf, format, ap);
   va_end(ap);
 
   textout_centre_border(bmp, f, buf, x, y, color, border, size, mode);
   }