示例#1
0
//void SimpleDrawTest(cdCanvas* canvas)
void SimpleDrawVectorFont(cdCanvas* canvas)
{
  cdBackground(CD_WHITE);
  cdClear();
  cdLineStyle(CD_CONTINUOUS);
  cdLineWidth(1);

//  wdVectorText(0.1, 0.4, "ãõñç áéíóú àèìòù âêîôû äëïöü");
//  wdVectorText(0.1, 0.2, "ÃÕÑÇ ÁÉÍÓÚ ÀÈÌÒÙ ÂÊÎÔÛ ÄËÏÖÜ ");
  cdVectorFont("../etc/vectorfont26.txt"); /* original Simplex II */
  {
    int i;
    char t[2];
    char s[10];
    int x = 10;
    int y = 600;
    t[1] = 0;
  cdFont(CD_COURIER, CD_BOLD, 14);
  cdVectorCharSize(25);
    for (i = 128; i < 256; i++)
    {
      int dx = 30;
      t[0] = (char)i;
      sprintf(s, "%3d", i);
      cdForeground(CD_DARK_RED);
      cdText(x, y, s);
//      cdText(x+dx, y, t);
      cdForeground(CD_BLACK);
      cdVectorText(x+2*dx-10, y, t);
      
      x += 3*dx;
      if ((i+1) % 8 == 0)
      {
        x = 10;
        y -= 30;
      }
    }
  //cdFont(CD_TIMES_ROMAN, CD_PLAIN, 24);
  //cdVectorCharSize(24);
  //  for (i = 192; i < 256; i++)
  //  {
  //    int dx = 92;
  //    t[0] = (char)i;
  //    sprintf(s, "%d", i);
  //    cdText(x, y, s);
  //    cdText(x+dx, y, t);
  //    cdVectorText(x+2*dx, y, t);
  //    
  //    x += 3*dx + 2*dx/3;
  //    if ((i+1) % 4 == 0)
  //    {
  //      x = 30;
  //      y += 52;
  //    }
  //  }
  }
}
示例#2
0
static int draw_cb(Ihandle* ih, int i, int j, int xmin, int xmax, int ymin, int ymax)
{
  if (((i%2) && (j%2)) || (((i+1)%2) && ((j+1)%2)))
    cdForeground(CD_WHITE);
  else
    cdForeground(CD_BLACK);

  cdBox(xmin, xmax, ymin, ymax);
  return IUP_DEFAULT;
}
示例#3
0
文件: colorbar.c 项目: xubingyue/iup
int switch_cb(Ihandle* self, int primcell, int seccell)
{
    long fgcolor;
    cdActivate(cdcanvas);
    fgcolor = cdForeground(CD_QUERY);
    cdForeground(cdBackground(CD_QUERY));
    cdBackground(fgcolor);
    redraw_cb(cnvs);
    return IUP_DEFAULT;
}
示例#4
0
static int switch_cb(Ihandle* ih, int primcell, int seccell)
{
  long fgcolor;
  if (!cdcanvas)
    return IUP_DEFAULT;
  printf("switch_cb(%d, %d)\n", primcell, seccell);
  cdActivate(cdcanvas) ;
  fgcolor = cdForeground(CD_QUERY);
  cdForeground(cdBackground(CD_QUERY));
  cdBackground(fgcolor);
  redraw_cb(canvas);
  return IUP_DEFAULT;
}
示例#5
0
static int select_cb(Ihandle* ih, int cell, int type)
{
  long cd_color;
  char str[30];
  int ri, gi, bi;

  sprintf(str, "CELL%d", cell);
  sscanf(IupGetAttribute(ih, str), "%d %d %d", &ri, &gi, &bi);
  printf("select_cb(%d, %d): %d, %d, %d\n", cell, type, ri, gi, bi);

  cd_color = cdEncodeColor((unsigned char)ri,(unsigned char)gi,(unsigned char)bi);

  if (!cdcanvas)
    return IUP_DEFAULT;
  
  cdActivate( cdcanvas ) ;
  if (type == -1)
    cdForeground(cd_color);
  else
    cdBackground(cd_color);

  redraw_cb(canvas);

  return IUP_DEFAULT;
}
示例#6
0
//void SimpleDrawTest(cdCanvas* canvas)
void SimpleDrawPoly(cdCanvas* canvas)
{
  int w, h;
  cdGetCanvasSize(&w, &h, 0, 0);

  cdBackground(CD_WHITE);
  cdClear();

  //cdSetAttribute("ANTIALIAS", "0");
  cdForeground(cdEncodeAlpha(cdEncodeColor(255, 0, 0), 100));

  cdfCanvasArc(cdActiveCanvas(), 255, 255, 100, 100, 0, 360);

  cdLine(0, 0, 200, 200);

  cdBegin(CD_BEZIER);
  cdVertex(100, 100); 
  cdVertex(150, 200); 
  cdVertex(180, 250); 
  cdVertex(180, 200); 
  cdVertex(180, 150); 
  cdVertex(150, 100); 
  cdVertex(300, 100); 
  cdEnd();


  cdEnd();
}
示例#7
0
void draw_wd(void)
{
  char* text;
  double x, y;
  double rect[8];

  cdBackground(CD_WHITE);
  cdClear();
  cdLineStyle(CD_CONTINUOUS);
  cdLineWidth(1);

//  wdVectorTextDirection(0, 0, 1, 1);
  cdTextAlignment(CD_NORTH_WEST);

//  text = "Vector Text";
  text = "Vector Text\nSecond Line\nThird Line";
  x = 0.25;
  y = 0.40;

  cdForeground(CD_BLACK);
  wdLine(0, 0, 1, 1);
  wdLine(0, 1, 1, 0);

  cdForeground(CD_GREEN);
  cdMarkType(CD_STAR);
  wdMark(x, y);

  cdForeground(CD_BLUE);
  wdVectorCharSize(0.1);
  wdVectorText(x, y, text);

  cdForeground(CD_RED);
  wdGetVectorTextBounds(text, x, y, rect);
  cdBegin(CD_CLOSED_LINES);
  wdVertex(rect[0], rect[1]);
  wdVertex(rect[2], rect[3]);
  wdVertex(rect[4], rect[5]);
  wdVertex(rect[6], rect[7]);
  cdEnd();
}
示例#8
0
static int drawcb(Ihandle *h, int lin, int col,int x1, int x2, int y1, int y2)
{
  if (lin < 5 || lin > 12 || col < 2 || col > 8)
    return IUP_IGNORE;

  cdForeground(CD_RED);
  cdLine(x1, y1, x2, y2);
  cdLine(x1, y2, x2, y1);

  {
    char s[50];
    sprintf(s, "%d:%d", lin, col);
    cdTextAlignment(CD_CENTER);
    cdText((x1+x2)/2, (y1+y2)/2, s);
  }

  return IUP_DEFAULT;
}
示例#9
0
文件: colorbar.c 项目: xubingyue/iup
int select_cb(Ihandle* self, int cell, int type)
{
    long cd_color;
    char str[30];
    int ri, gi, bi;
    sprintf(str, "CELL%d", cell);
    sscanf(IupGetAttribute(self, str), "%d %d %d", &ri, &gi, &bi);
    cd_color = cdEncodeColor((unsigned char)ri,(unsigned char)gi,(unsigned char)bi);

    cdActivate( cdcanvas );
    if (type == IUP_PRIMARY)
        cdForeground(cd_color);
    else
        cdBackground(cd_color);

    redraw_cb(cnvs);

    return IUP_DEFAULT;
}
示例#10
0
文件: colorbar.c 项目: xubingyue/iup
char* cell_cb(Ihandle* self, int cell)
{
    unsigned char r, g, b;
    int ri, gi, bi;
    static char str[30];
    sprintf(str, "CELL%d", cell);
    sscanf(IupGetAttribute(self, str), "%d %d %d", &ri, &gi, &bi);
    r = (unsigned char)ri;
    g = (unsigned char)gi;
    b = (unsigned char)bi;
    if (IupGetColor(IUP_MOUSEPOS, IUP_MOUSEPOS, &r, &g, &b))
    {
        sprintf(str, "%d %d %d", (int)r, (int)g, (int)b);
        cdActivate( cdcanvas );
        cdForeground(cdEncodeColor(r, g, b));
        redraw_cb(cnvs);
        return str;
    }
    return NULL;
}