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.35 1997/02/27 04:14:02 per Exp $"; + string cvs_version="$Id: graphic_text.pike,v 1.36 1997/02/27 04:38:20 per Exp $";   #include <module.h>   inherit "module";   inherit "roxenlib";    -  + #if efun(_static_modules)   import Image; -  + #else + # define image Image + #endif      array register_module()   {    return ({ MODULE_LOCATION | MODULE_PARSER,    "Graphics text",    "Makes a few new tags, which render text to gifs "    "using the image module in pike. \n<p>"    "<b>&lt;gh1&gt;</b> to <b>&lt;gh6&gt;:</b> Headers<br>\n"    "<b>&lt;gh&gt;:</b> Header<br>\n"    "<b>&lt;gtext&gt;:</b> Graphical text<br>\n"
Roxen.git/server/modules/graphics/graphic_text.pike:165:    int j;    res = Array.map(allocate(size), lambda(int s, int size){    return allocate(size); }, size);       for(i=0; i<size; i++)    for(j=0; j<size; j++)    res[i][j] = (int)MAX((float)size/2.0-sqrt((size/2-i)*(size/2-i) + (size/2-j)*(size/2-j)),0);    return matrixes[size] = res;   }    + string fix_relative(string file, object got) + { +  string other; +  if(file != "" && file[0] == '/') +  return file; +  other=got->not_query; +  if(file != "" && file[0] == '#') +  file = got->not_query+ file; +  else +  file = dirname(got->not_query) + "/" + file; +  return simplify_path(replace(file, ({ "//", "..."}), ({"./..", "//"}))); + }      object last_image;   string last_image_name; - object (image) load_image(string f) + object (image) load_image(string f,object id)   {    if(last_image_name==f) return last_image; -  object file = files.file(); +     string data; -  +  object file;    object img = image();    -  if(!file->open(f,"r")) return 0; -  if(!(data=file->read(0x7fffffff))) return 0; +  if(file=open(f,"r")) +  { +  if(!(data=file->read(0x7fffffff))) +  return 0; +  } else { +  f = fix_relative(f, id); +  if(!(data=roxen->try_get_file(f,id))) +  return 0; +  } +     if(!img->frompnm(data) && !img->fromgif(data)) return 0;      // last_image_name=f;   // last_image=img;   //call_out(lambda(){last_image=last_image_name=0;}, 10);    return img/*->copy()*/;   }      object (image) blur(object (image) img, int amnt)   {
Roxen.git/server/modules/graphics/graphic_text.pike:258:    in->paste_mask(corner, corner->invert()->color(128,128,128),    -1, in->ysize()-width);    in->paste_mask(corner2, corner2->color(70,70,70), -1, -1);       corner = corner2 = pix = 0;       return in;   }       - object (image) make_text_image(mapping args, object font, string text) + object (image) make_text_image(mapping args, object font, string text,object id)   {    object (image) text_alpha=font->write(@(text/"\n"));    int xoffset=0, yoffset=0;       if(!text_alpha->xsize() || !text_alpha->ysize())    text_alpha = image(10,10, 0,0,0);      // perror("Making image of '%s', args=%O\n", text, args);       if(int op=((((int)args->opaque)*255)/100)) // Transparent text...
Roxen.git/server/modules/graphics/graphic_text.pike:342:    ysize += ((int)args->border)*2;    }          array (int) bgcolor = parse_color(args->bg);    array (int) fgcolor = parse_color(args->fg);       object background,foreground;       -  if(args->texture) foreground = load_image(args->texture); +  if(args->texture) foreground = load_image(args->texture,id);       if(args->background)    { -  background = load_image(args->background); +  background = load_image(args->background,id);    xsize = background->xsize();    ysize = background->ysize();    switch(lower_case(args->talign||"left"))    {    case "center":    xoffset = (xsize/2 - txsize/2);    break;    case "right":    xoffset = (xsize - txsize);    break;
Roxen.git/server/modules/graphics/graphic_text.pike:544:    string fkey = args->font+"/"+args->talign+"/"+args->xpad+"/"+args->ypad;    data = cache_lookup("fonts", fkey);    if(!data)    {    data = load_font(args->font, lower_case(args->talign||"left"),(int)args->xpad,(int)args->ypad);    cache_set("fonts", fkey, data);    }       // Fonts and such are now initialized.    -  img = make_text_image(args,data,text); +  img = make_text_image(args,data,text,id);       // Now we have the image in 'img', or nothing.       if(!img) return 0;       int q = (int)args->quant||(args->background||args->texture?250:QUERY(cols));       if(q>255) q=255;    if(q<3) q=3;   
Roxen.git/server/modules/graphics/graphic_text.pike:704:    if(!short)    return query_location()+num+"/";    else    return (string)num;   }      string tag_graphicstext(string t, mapping arg, string contents,    object id, object foo, mapping defines)   {   // Allow <accessed> and others inside <gtext>. +  + #if efun(_static_modules)    contents = parse_rxml(contents, id, foo, defines); -  + #else +  contents = parse_rxml(contents, id, foo); + #endif       string pre, post, defalign, gt, rest, magic;    int i, split;       // No images here, let's generate an alternative..    if(!id->supports->images || id->prestate->noimages)    {    if(!arg->split) contents=replace(contents,"\n", "\n<br>\n");    if(arg->submit) return "<input type=submit name=\""+(arg->name+".x")+"\" value=\""+contents+"\">";    switch(t)