Roxen.git / server / modules / graphics / graphic_text.pike

version» Context lines:

Roxen.git/server/modules/graphics/graphic_text.pike:1: - string cvs_version="$Id: graphic_text.pike,v 1.2 1996/12/04 01:53:55 per Exp $"; + string cvs_version="$Id: graphic_text.pike,v 1.3 1996/12/04 06:06:34 per Exp $";   #include <module.h>   inherit "module";   inherit "roxenlib";         array register_module()   {    return ({ MODULE_LOCATION | MODULE_PARSER,    "Graphics text",    "Makes a few new tags:"
Roxen.git/server/modules/graphics/graphic_text.pike:37:    " quant=cols Use this number of colors\n"    " magic[=message] Modifier to href, more flashy links\n"    " Does <b>not</b> work with 'split'\n"    " fs Use floyd-steinberg dithering\n"    " border=int,#col Draw an border (width is the first argument\n"    " in the specified color\n"    " spacing=int Add this amount of spacing around the text\n"    " bevel=int Draw a bevel box (width is the argument)\n"    " textbox=al,#col Use 'al' as opaque value to draw a box below\n"    " the text with the specified color.\n" -  " shadow=int Draw a drop-shadow (variable distance)\n" +  " shadow=int,dist Draw a drop-shadow (variable distance/intensity)\n"    " fuzz=#col The 'shine' effect used in the 'magic'\n"    " highlightning\n"    " opaque=0-100% Draw with more or less opaque text (100%\n"    " is default)\n"    " rotate=ang(deg.)Rotate the finished image\n"    " background=file Use the specifed file as a background\n"    " texture=file Use the specified file as text texture\n"    "</pre>\n",    0,    1,
Roxen.git/server/modules/graphics/graphic_text.pike:158:   }      constant white = ({ 255,255,255 });   constant lgrey = ({ 200,200,200 });   constant grey = ({ 128,128,128 });   constant black = ({ 0,0,0 });      constant wwwb = ({ lgrey,lgrey,grey,black });   object (Image) bevel(object (Image) in, int width)   { -  object vedge_white = Image(width, in->ysize()-width*2, 255,255,255); -  object vedge_black = Image(width, in->ysize()-width, 0,0,0); -  object hedge_white = Image(in->xsize()-width, width, 255,255,255); -  object hedge_black = Image(in->xsize()-width, width, 0,0,0); -  object corner = Image(width+1,width+1); +  int h=in->ysize(); +  int w=in->xsize();    -  for(int i=-1; i<=width; i++) -  corner->line(i,width-i,i,-1, 200,200,200); +  in->paste_alpha(Image(width,h-width*2,@white), 160, 0, width); +  in->paste_alpha(Image(width,h-width*2,@black), 128, in->xsize()-width, width); +  in->paste_alpha(Image(w-width*2,width,@white), 160, 0, 0); +  in->paste_alpha(Image(w-width*2,width,@black), 128, width, in->ysize()-width);    -  in->paste_alpha(vedge_white, 160, 0, width); -  in->paste_alpha(vedge_black, 128, in->xsize()-width, width); -  in->paste_alpha(hedge_white, 160, 0, 0); -  in->paste_alpha(hedge_black, 128, width, in->ysize()-width); +  object corner = Image(width+1,width+1); +  for(int i=-1; i<=width; i++) corner->line(i,width-i,i,-1, 200,200,200);    in->paste_alpha(corner, 128, in->xsize()-width,0);    in->paste_alpha(corner, 128, -1, in->ysize()-width); -  vedge_white=vedge_black=hedge_white=hedge_black=0; +  corner=0;       return in;   }         object (Image) make_text_image(mapping args, object font, string text)   {    object (Image) text_alpha=font->write(@(text/"\n"));    int xoffset=0, yoffset=0;   
Roxen.git/server/modules/graphics/graphic_text.pike:215:    xsize += ((int)args->spacing)*2;    ysize += ((int)args->spacing)*2;    }       if(args->yspacing)    {    yoffset += (int)args->yspacing;    ysize += ((int)args->yspacing)*2;    }    +  if(args->shadow) +  { +  xsize+=((int)(args->shadow/",")[-1])+2; +  ysize+=((int)(args->shadow/",")[-1])+2; +  } +     if(args->xspacing)    {    xoffset += (int)args->xspacing;    xsize += ((int)args->xspacing)*2;    }       if(args->border)    {    xoffset += (int)args->border;    yoffset += (int)args->border;
Roxen.git/server/modules/graphics/graphic_text.pike:236:    ysize += ((int)args->border)*2;    }          array (int) bgcolor = parse_color(args->bg);    array (int) fgcolor = parse_color(args->fg);       object background,foreground;       -  if(args->background) background = load_image(args->background); +     if(args->texture) foreground = load_image(args->texture);    -  if(!background) background = Image(xsize, ysize, @bgcolor); -  if(!foreground) foreground = Image(xsize, ysize, @fgcolor); -  +  if(args->background) +  { +  background = load_image(args->background);    xsize = background->xsize();    ysize = background->ysize(); -  +  } else +  background = Image(xsize, ysize, @bgcolor);       if(args->bevel) background = bevel(background, (int)args->bevel);       if(args->textbox) // Draw a text-box on the background.    { -  int alpha; +  int alpha,border;    string bg;    sscanf(args->textbox, "%d,%s", alpha, bg); -  background->paste_alpha(Image(txsize,tysize, @parse_color(bg)), -  255-(alpha*255/100), xoffset,yoffset); +  sscanf(bg,"%s,%d", bg,border); +  background->paste_alpha(Image(txsize+border,tysize+border,@parse_color(bg)), +  255-(alpha*255/100), xoffset, yoffset);    }    -  background->paste_mask(foreground, text_alpha, xoffset, yoffset); +  if(args->shadow) +  { +  int sd = ((int)args->shadow+10)*2; +  int sdist = ((int)(args->shadow/",")[-1])+2; +  object ta = text_alpha->copy(); +  ta = ta->color(256-sd,256-sd,256-sd); +  background->paste_mask(Image(txsize,tysize),ta,xoffset+sdist, yoffset+sdist); +  }    -  +  if(!foreground) foreground=Image(xsize, ysize, @fgcolor);    -  +  background->paste_mask(foreground, text_alpha, xoffset, yoffset); +     foreground = text_alpha = 0;          if(args->scale)    if((float)args->scale <= 2.0)    background = background->scale((float)args->scale);       if(args->rotate)    {    string c;    if(sscanf(args->rotate, "%*d,%s", c))    background->setcolor(@parse_color(c));    else    background->setcolor(@bgcolor);    background = background->rotate((float)args->rotate);    }    -  if(args->crop) -  background = background->autocrop(); +  if(args->crop) background = background->autocrop();       return background;   }         array(int)|string write_text(int _args, string text, int size,    object id)   {    object img;    mapping args = cached_args[_args];