Roxen.git / server / etc / modules / Map.pmod

version» Context lines:

Roxen.git/server/etc/modules/Map.pmod:270:    "com":"united states of america",    "net":"united states of america",    "org":"united states of america",    "edu":"united states of america",    "gov":"united states of america",    "mil":"united states of america",    "nato":"united states of america",    ]);      class Legend { -  static private string state_color_scheme = "white-to-red"; +  private string state_color_scheme = "white-to-red";    -  static private mapping color_schemes = ([ "white-to-red": +  private mapping color_schemes = ([ "white-to-red":    ([ 0:({ 0xff,0xff,0xff }),    1:({ 0xe0,0xc0,0x80 }),    2:({ 0xe0,0x80,0x40 }),    3:({ 0xd0,0x40,0x00 }),    4:({ 0x80,0x00,0x00 }) ]),    "white-to-green":    ([ 0:({ 0xff,0xff,0xff }),    1:({ 0xe0,0xe0,0x80 }),    2:({ 0x80,0xe0,0x40 }),    3:({ 0x40,0xd0,0x00 }),
Roxen.git/server/etc/modules/Map.pmod:358:    opt->titles = ({ "1" })+ (opt->titles || ({ "" }));       object font = opt->font; // Image.font("default");    int nom = font->height();    int title_h = nom*sizeof(opt->title/"\n")+nom/2;    int bar_h = 6*nom;    int width = max(font->text_extents(@opt->title/"\n")[0],    font->text_extents(@opt->titles)[0] + nom+nom/2);    int height = title_h + bar_h + 2*nom + nom;    -  object img = Image.image(width, height+100, @opt->background_color); +  Image.Image img = Image.Image(width, height+100, @opt->background_color);       img->paste_alpha_color(font->write(@(opt->title/"\n")),    @opt->title_color, 0, 0);       for(int i = 0; i < bar_h; i++)    img->line(0, title_h+i, nom, title_h+i,    @color_scale(1.0 - i/(float)(bar_h), opt->color_scheme));    img->box(0, title_h+bar_h+nom/2, nom, title_h+bar_h+nom/2+(int)(nom*0.8),    @color_scale(0, opt->color_scheme));    img->paste_alpha_color(font->write("0")->scale(0.8),
Roxen.git/server/etc/modules/Map.pmod:386:    }       img = img->autocrop()->setcolor(@opt->background_color);    img = img->copy(-opt->border, -opt->border,    img->xsize()+opt->border-1, img->ysize()+opt->border-1);    return img->scale(min(min(fixed_width/(float)img->xsize(), 1.0),    min(fixed_height/(float)img->ysize(), 1.0)));    }   }    - static private mapping map_of_the_earth = + private mapping map_of_the_earth =    decode_value(Stdio.read_bytes("etc/maps/worldmap"));      class Earth { -  static string state_region; -  static string state_country; +  protected string state_region; +  protected string state_country;       // Aliases.    mapping(string:array(string)) country_name_aliases =    ([ "United States of America":({ "USA", "US" }),    "Russian Federation":({ "Russia" }),    "England":({ "United Kingdom", "UK" }),    "Viet Nam":({ "Vietnam" }),    ]);       // Official names.
Roxen.git/server/etc/modules/Map.pmod:428:    {    return sort(({ "World", "Europe", "Asia", "Africa", "Arab States",    "North America", "South America", "Oceania" }));    }       object country(string new_country)    {    return object_program(this_object())(state_region, new_country);    }    -  static private string capitalize_country(string s) +  private string capitalize_country(string s)    {    return Array.map(s/" ",    lambda(string w)    {    switch(w) {    case "of":    case "and":    return w;    default:    return capitalize(w);
Roxen.git/server/etc/modules/Map.pmod:454:    {    return sort(Array.map(indices(map_of_the_earth), capitalize_country));    }       mixed polygons()    {    if(state_country)    return map_of_the_earth[state_country];    }    -  static private array(float) transform(float x, float y, mapping opt) +  private array(float) transform(float x, float y, mapping opt)    {    y = 1.0-y;       switch(lower_case(opt->region||state_region||"")) {    case "europe":    x = (x-0.33)*3.0;    y = (y-0.05)*3.0;    break;    case "africa":    x = (x-0.20)*1.5;
Roxen.git/server/etc/modules/Map.pmod:493:    case "oceania":    x = (x-0.63)*2.0;    y = (y-0.47)*2.0;    break;    default:    }       return ({ x, y });    }    -  object image(int width, int height, mapping|void opt) +  Image.Image image(int width, int height, mapping|void opt)    {    opt = opt || ([]);    opt->color_sea = opt->color_sea || ({ 0x10,0x10,0x40 });    opt->color_fu = opt->color_fu || lambda() { return ({ 0xff,0xff,0xff }); };    -  Image.image map = Image.image(width, height, @opt->color_sea); +  Image.Image map = Image.Image(width, height, @opt->color_sea);    foreach(indices(map_of_the_earth), string cntry) {    map->setcolor(@opt->color_fu(cntry, @(opt->fu_args||({}))));    foreach(map_of_the_earth[cntry], array(float) original_vertices) {    array(float) vertices = copy_value(original_vertices);       for(int v = 0; v < sizeof(vertices); v += 2) {    array(float) a = transform(vertices[v+0], vertices[v+1], opt);    vertices[v+0] = a[0]*width;    vertices[v+1] = a[1]*height;    }
Roxen.git/server/etc/modules/Map.pmod:538:    map->setcolor(@marker->color);    map->polyfill( ({ x1, marker->y,    marker->x, y1,    x2, marker->y,    marker->x, y2 }) );    }    }       // Apply borders.    if(opt->border) -  map = Image.image(map->xsize()+2*opt->border, +  map = Image.Image(map->xsize()+2*opt->border,    map->ysize()+2*opt->border,    @opt->color_sea)->paste(map, opt->border, opt->border);       return map;    }       void create(void|string _state_region, void|string _state_country)    {    state_region = _state_region;    state_country = _state_country;    }   }