blue.c
上传用户:gzelex
上传日期:2007-01-07
资源大小:707k
文件大小:1k
开发平台:

MultiPlatform

  1. #include <fstream.h>
  2. #include <LEDA/list.h>
  3. #include <LEDA/window.h>
  4. main(int argc, char** argv)
  5. {  
  6.    ifstream colors("/usr/lib/X11/rgb.txt");
  7.    int r,g,b;
  8.    char c;
  9.    string s;
  10.    string pat = "blue";
  11.    if (argc > 1) pat = argv[1];
  12.    list<string> L;
  13.    while (colors >> r >> g >> b >> c)
  14.    { colors.putback(c);
  15.      s = read_line(colors);
  16.      if (s.pos(pat) != -1) L.append(s);
  17.     }
  18.    int n = L.length();
  19.    window W(500,500);
  20.    W.init(0,n,0);
  21.    W.set_show_coordinates(false);
  22.    int i = 0;
  23.    forall(s, L) 
  24.    { cout << s << endl;
  25.      W.draw_filled_rectangle(i,0,i+1,n,color(~s));
  26.      //W.draw_rectangle(i,0,i+1,n,black);
  27.      i++;
  28.     }
  29.     cout << i << endl;
  30.     W.read_mouse();
  31.   return 0;
  32. }
  33.