示例#1
0
文件: ranwlk.c 项目: aquila62/eegl24
/* otherwise return zero */
int walk(xxfmt *xx)
   {
   int col;         /* column coordinate */
   int row;         /* row    coordinate */
   int ch;          /* input character */
   int *p,*q,*r;    /* pointers to the random walk array */
   /* shift random walk pixels one pixel to the left */
   col = 0;
   p = (int *) xx->newwave;
   q = (int *) xx->newwave + xx->dpywdth - 1;
   r = (int *) xx->newwave + 1;
   while (p < q)
      {
      *p = *r;
      /* erase pixel + 1 */
      if (*r != xx->middlerow)    /* do not erase the middle row */
         {
         XSetForeground(xx->dpy, xx->gc, xx->whiteColor);
         XDrawPoint(xx->dpy, xx->w, xx->gc, col+1, *r);
         } /* if not the red line */
      /* copy to pixel + 0 */
      if (*p != xx->middlerow)    /* do not write over the middle row */
         {
         XSetForeground(xx->dpy, xx->gc, xx->blackColor);
         XDrawPoint(xx->dpy, xx->w, xx->gc, col, *p);
         } /* if not the red line */
      /* point to next pixel, and repeat loop */
      col++;
      p++;
      r++;
      } /* for each pixel in the wave */
   ch = getbit();    /* read one random bit from stdin */
   /* this program is sometimes used to read a finite */
   /* irrational number binary expansion */
   /* therefore it sometimes reads to end of file */
   if (ch == EOF) return(EOF);   /* if end of file, go to end of job */
   /* if input bit is '1', raise random walk one pixel */
   if (ch == '1')
      {
      row = *p + 1;
      if (row > xx->dpyhght) row = xx->dpyhght;
      *p = row;
      } /* if input bit == '1' */
   /* if input bit is '0', lower random walk one pixel */
   else
      {
      row = *p - 1;
      if (row < 0) row = 0;
      *p = row;
      } /* else input bit == '0' */
   /* write pixel at end of random walk */
   XSetForeground(xx->dpy, xx->gc, xx->blackColor);
   XDrawPoint(xx->dpy, xx->w, xx->gc, col, row);
   /* re-write middle line in red */
   XSetForeground(xx->dpy, xx->gc, xx->red);
   XDrawLine(xx->dpy, xx->w, xx->gc,
      0, xx->middlerow,
      xx->dpywdth, xx->middlerow);
   return(0);        /* return not-end-of-file */
   } /* walk */
示例#2
0
文件: xskin_loadBMP.c 项目: 1c0n/xbmc
int Draw4bit( Display *d, Pixmap p, GC gc, BMPHeader *bmp, struct timidity_file *fp ) {

  int x,y;
  int col,col1,col2;
  int pad;

  for ( y=bmp->h ; y>0 ; --y ) {
    pad = ((bmp->w+7)/8)*8;
    for ( x=0 ; x<pad ; x+=2 ) {
      col=ugetc(fp);
      col1=(col>>4)&0x0f;
      col2=col&0x0f;
      if ( col1 >= bmp->ncolors ) col1=0;
      if ( col2 >= bmp->ncolors ) col2=0;
      if ( x<bmp->w-1 ) {
	XSetForeground( d, gc, color_palletes[col1] );
	XDrawPoint( d, p, gc, x, y-1 );
	XSetForeground( d, gc, color_palletes[col2] );
	XDrawPoint( d, p, gc, x+1, y-1 );
      }
    }
  }

  return 0;
}
int Desenha_reta(Display * display, GC gc, Window win, struct ponto2D primeiro, struct ponto2D segundo) {
 	float a, b, x, y;
 	struct ponto2D aux;
 	if (primeiro.x >= segundo.x) {
	   	aux.x = primeiro.x;
	   	aux.y = primeiro.y;
	   	primeiro.x = segundo.x;
	   	primeiro.y = segundo.y;
	   	segundo.x = aux.x;
	   	segundo.y = aux.y;	
	}

 	if (primeiro.x == segundo.x) {
    	x = primeiro.x;
    	y = primeiro.y;
    	while (y <= segundo.y) {
     		XDrawPoint(display, win, gc, (int)round(x), (int)round(y));
      		y++;
      	}
    }else{
	   	a = ((float)(segundo.y - primeiro.y))/((float)(segundo.x - primeiro.x));
	   	b = (primeiro.y) - a*(primeiro.x);
	   	x = (float) primeiro.x++;
	   	y = a*x + b;
	   	while (x <= segundo.x) {
      		XDrawPoint(display, win, gc, (int)round(x), (int)round(y));
      		y = a*(++x) + b;
      	}
   	}
 	return 0;
}
示例#4
0
int DessineDisque(TC *p,int xc,int yc,int rayon,int couleur,int couleurBord)
{
  int x,y;
  int xmxc2,r2,d2;
  int borne = 7; // arbitraire...

  r2 = rayon*rayon;

  for (x=(xc-rayon) ; x<=(xc+rayon) ; x++)
  {
    xmxc2 = (x-xc)*(x-xc);
    for (y=(yc-rayon) ; y<=(yc+rayon) ; y++)
    {
      d2 = xmxc2+(y-yc)*(y-yc);
      if (d2 < r2)
      {
        setCouleurCrayon(p,couleur);
        XDrawPoint(p->display,p->win,p->gc,x,y);
      }

      if ((-borne < (d2-r2)) && ((d2-r2) < borne))
      {
        setCouleurCrayon(p,couleurBord);
        XDrawPoint(p->display,p->win,p->gc,x,y);
      } 
    }
  }
    
  XFlush(p->display);

  return 0;
}
示例#5
0
文件: xskin_loadBMP.c 项目: 1c0n/xbmc
int DrawCompressed4bit( Display *d, Pixmap p, GC gc,
			BMPHeader *bmp, struct timidity_file *fp ) {
  int i,j;
  int a,b;
  int x,y;
  int z=1;

  x=0;
  y=bmp->h;

  while (z) {

    a=ugetc(fp);
    b=ugetc(fp);
    if ( b==EOF ) break;

    if ( a!=0 ) {
      if ( b>=bmp->ncolors ) b=0;
      for ( i=0 ; i<a ; i+=2 ) {
	if ( x<bmp->w ) {
	  XSetForeground( d, gc, color_palletes[(b>>4)&0x0f] );
	  XDrawPoint( d, p, gc, x, y-1 );
	  x++;
	  if ( i!=a-1 ) {
	    XSetForeground( d, gc, color_palletes[b&0x0f] );
	    XDrawPoint( d, p, gc, x, y-1 );
	    x++;
	  }
	}
      }

    } else {

      switch( b ) {
static inline void 
render_disc(struct state *st, Drawable drawable, GC fgc, struct field *f, int dnum) 
{
    Disc *di = &(f->discs[dnum]);
    int n, m;
    float dx, dy, d;
    float a, p2x, p2y, h, p3ax, p3ay, p3bx, p3by;
    unsigned long c;

    /* Find intersecting points with all ascending discs */
    for (n = di->id + 1; n < f->num; n++) {
        dx = f->discs[n].x - di->x;
        dy = f->discs[n].y - di->y;
        d = sqrt(dx * dx + dy * dy);

        /* intersection test */
        if (d < (f->discs[n].r + di->r)) {
            /* complete containment test */
            if (d > abs(f->discs[n].r - di->r)) {
                /* find solutions */
                a = (di->r * di->r - f->discs[n].r * f->discs[n].r + d * d) / (2 * d);
                p2x = di->x + a * (f->discs[n].x - di->x) / d;
                p2y = di->y + a * (f->discs[n].y - di->y) / d;

                h = sqrt(di->r * di->r - a * a);

                p3ax = p2x + h * (f->discs[n].y - di->y) / d;
                p3ay = p2y - h * (f->discs[n].x - di->x) / d;

                p3bx = p2x - h * (f->discs[n].y - di->y) / d;
                p3by = p2y + h * (f->discs[n].x - di->x) / d;

                /* bounds check */
                if ((p3ax < 0) || (p3ax >= f->width) || (p3ay < 0) || (p3ay >= f->height) ||
                    (p3bx < 0) || (p3bx >= f->width) || (p3by < 0) || (p3by >= f->height))
                    continue;
                
                /* p3a and p3b might be identical, ignore this case for now */
                /* XPutPixel(f->off_map, p3ax, p3ay, f->fgcolor); */
                c = trans_point(st, p3ax, p3ay, 255, 0.75, f);
                XSetForeground(st->dpy, fgc, get_pixel (st, c));
                XDrawPoint(st->dpy, drawable, fgc, p3ax, p3ay);

                /* XPutPixel(f->off_map, p3bx, p3by, f->fgcolor); */
                c = trans_point(st, p3bx, p3by, 255, 0.75, f);
                XSetForeground(st->dpy, fgc, get_pixel (st, c));
                XDrawPoint(st->dpy, drawable, fgc, p3bx, p3by);
                XSetForeground(st->dpy, fgc, f->fgcolor);
            }
        }

    }

    /* Render all the pixel riders */
    for (m = 0; m < di->numr; m++) {
        moverender_rider(st, drawable, fgc, f, &(di->pxRiders[m]), 
                         di->x, di->y, di->r);
    }
}
示例#7
0
void
draw_dot (int x, int y)
{
    set_foreground (5);
	XDrawPoint (dd, tb.win, fore_gc, x, y);
    set_foreground (4);
	XDrawPoint (dd, tb.win, fore_gc, x + 1, y + 1);
}
示例#8
0
void* iupdrvImageCreateImageRaw(int width, int height, int bpp, iupColor* colors, int colors_count, unsigned char *imgdata)
{
  int y, x;
  Pixmap pixmap;
  GC gc;

  pixmap = XCreatePixmap(iupmot_display,
          RootWindow(iupmot_display,iupmot_screen),
          width, height, iupdrvGetScreenDepth());
  if (!pixmap)
    return NULL;

  gc = XCreateGC(iupmot_display,pixmap,0,NULL);

  /* Pixmap is top-bottom */
  /* imgdata is bottom up */

  if (bpp == 8)
  {
    Pixel color2pixel[256];
    int i;
    for (i=0;i<colors_count;i++)
      color2pixel[i] = iupmotColorGetPixel(colors[i].r, colors[i].g, colors[i].b);

    for (y=0;y<height;y++)
    {
      int lineoffset = (height-1 - y)*width;  /* imgdata is bottom up */
      for(x=0;x<width;x++)
      {
        unsigned long p = color2pixel[imgdata[lineoffset+x]];
        XSetForeground(iupmot_display,gc,p);
        XDrawPoint(iupmot_display,pixmap,gc,x,y);
      }
    }
  }
  else
  {
    /* planes are separated in imgdata */
    int planesize = width*height;
    unsigned char *r = imgdata,
                  *g = imgdata+planesize,
                  *b = imgdata+2*planesize;
    for (y=0;y<height;y++)
    {
      int lineoffset = (height-1 - y)*width;  /* imgdata is bottom up */
      for(x=0;x<width;x++)
      {
        unsigned long p = iupmotColorGetPixel(r[lineoffset+x], g[lineoffset+x], b[lineoffset+x]);
        XSetForeground(iupmot_display,gc,p);
        XDrawPoint(iupmot_display,pixmap,gc,x,y);
      }
    }
  }

  XFreeGC(iupmot_display,gc);

  return (void*)pixmap;
}
示例#9
0
void drawDecorations(Display *display, Drawable window, GC gc, const char *title, XWindowAttributes attr) {
	if (!white || !black) {
		white = XWhitePixel(display, DefaultScreen(display));
		black = XBlackPixel(display, DefaultScreen(display));
	}
	
	// Draw bounding box
	whiteOutTitleBar(display, window, gc, attr);
	XSetForeground(display, gc, black);
	XDrawRectangle(display, window, gc, RECT_TITLEBAR);
	
	// Draw texture
	for (int y = TITLEBAR_TEXTURE_START; y < TITLEBAR_TEXTURE_START + TITLEBAR_CONTROL_SIZE; y += TITLEBAR_TEXTURE_SPACE) {
		XDrawLine(display, window, gc, 2, y, attr.width - 4, y);
	}
	
	// White out areas for buttons and title
	XSetForeground(display, gc, white);
	// Subwindow box
	XFillRectangle(display, window, gc,
				   1,
				   TITLEBAR_THICKNESS,
				   attr.width - 3,
				   attr.height - (TITLEBAR_THICKNESS + 3));
	
	// Draw buttons and title
	XSetForeground(display, gc, black);
	// Subwindow box
	XDrawRectangle(display, window, gc,
				   0,
				   TITLEBAR_THICKNESS - 1,
				   attr.width - 2,
				   attr.height - 20);
	// Shadow
	XDrawLine(display, window, gc, 1, attr.height - 1, attr.width, attr.height - 1);
	XDrawLine(display, window, gc, attr.width - 1, attr.height - 1, attr.width - 1, 1);

	// White out the shadow ends
	XSetForeground(display, gc, white);
	XDrawPoint(display, window, gc, 0, attr.height - 1);
	XDrawPoint(display, window, gc, attr.width - 1, 0);
	XSetForeground(display, gc, black);
	
	// Draw Title
	drawTitle(display, window, gc, title, attr);
	
	// Draw Close Button
	drawCloseButton(display, window, gc, RECT_CLOSE_BTN);
	
	// Draw Maximize Button
	drawMaximizeButton(display, window, gc, RECT_MAX_BTN);

#ifdef COLLAPSE_BUTTON_ENABLED
	// Draw Collapse Button
	drawCollapseButton(display, window, gc, RECT_COLLAPSE_BTN);
#endif
}
示例#10
0
文件: window.c 项目: tommie/xppaut
static void draw_gradient(Pixmap pmap, int width, int height) {
  int xx, yy;
  double cosine;
  XColor bcolour, col2, diffcol;
  Colormap cmap = DefaultColormap(display, DefaultScreen(display));
  XParseColor(display, cmap, UserWhite, &bcolour);
  XParseColor(display, cmap, UserBlack, &diffcol);

  for (yy = 0; yy < height; yy += 1) {
    if (yy < 1.0) {
      col2.red = 65535;
      col2.green = 65355;
      col2.blue = 65355;
    } else {
      if (yy < (height / 2.0)) {
        cosine = 1.0;
      } else if ((height - yy) <= 1.0) {
        cosine = 0.1;
      } else {
        cosine = 0.93;
      }
      col2.red = bcolour.red * cosine;
      col2.green = bcolour.green * cosine;
      col2.blue = bcolour.blue * cosine;
    }

    XAllocColor(display, cmap, &col2);
    XSetForeground(display, gc, col2.pixel);

    for (xx = 1; xx < width - 1; xx += 1) {
      XDrawPoint(display, pmap, gc, xx, yy);
    }

    /*Now do xx=0 and xx=width-1*/
    xx = 0;
    col2.red = 65535;
    col2.green = 65355;
    col2.blue = 65355;
    XAllocColor(display, cmap, &col2);
    XSetForeground(display, gc, col2.pixel);
    XDrawPoint(display, pmap, gc, xx, yy);
    xx = width - 1;
    cosine = 0.1;
    col2.red = bcolour.red * cosine;
    col2.green = bcolour.green * cosine;
    col2.blue = bcolour.blue * cosine;

    XAllocColor(display, cmap, &col2);
    XSetForeground(display, gc, col2.pixel);
    XDrawPoint(display, pmap, gc, xx, yy);
  }
}
示例#11
0
文件: gdisp_lld_X.c 项目: bigzed/uGFX
LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g)
{
	xPriv *	priv = (xPriv *)g->priv;
	XColor	col;

	col.red = RED_OF(g->p.color) << 8;
	col.green = GREEN_OF(g->p.color) << 8;
	col.blue = BLUE_OF(g->p.color) << 8;
	XAllocColor(dis, cmap, &col);
	XSetForeground(dis, priv->gc, col.pixel);
	XDrawPoint(dis, priv->pix, priv->gc, (int)g->p.x, (int)g->p.y );
	XDrawPoint(dis, priv->win, priv->gc, (int)g->p.x, (int)g->p.y );
	XFlush(dis);
}
示例#12
0
void
_pl_x_paint_point (S___(Plotter *_plotter))
{
  double xx, yy;
  int ix, iy;
  plColor oldcolor, newcolor;

  if (_plotter->drawstate->pen_type != 0)
    /* have a pen to draw with */
    {
      /* set pen color as foreground color in GC used for drawing (but
	 first, check whether we can avoid a function call) */
      newcolor = _plotter->drawstate->fgcolor;
      oldcolor = _plotter->drawstate->x_current_fgcolor; /* as stored in gc */
      if (newcolor.red != oldcolor.red 
	  || newcolor.green != oldcolor.green 
	  || newcolor.blue != oldcolor.blue
	  || ! _plotter->drawstate->x_gc_fgcolor_status)
	_pl_x_set_pen_color (S___(_plotter));
      
      xx = XD(_plotter->drawstate->pos.x, _plotter->drawstate->pos.y);
      yy = YD(_plotter->drawstate->pos.x, _plotter->drawstate->pos.y);
      ix = IROUND(xx);
      iy = IROUND(yy);

      if (_plotter->x_double_buffering != X_DBL_BUF_NONE)
	/* double buffering, have a `x_drawable3' to draw into */
	XDrawPoint (_plotter->x_dpy, _plotter->x_drawable3, 
		    _plotter->drawstate->x_gc_fg, 
		    ix, iy);
      else
	/* not double buffering, have no `x_drawable3' */
	{
	  if (_plotter->x_drawable1)
	    XDrawPoint (_plotter->x_dpy, _plotter->x_drawable1, 
			_plotter->drawstate->x_gc_fg, 
			ix, iy);
	  if (_plotter->x_drawable2)
	    XDrawPoint (_plotter->x_dpy, _plotter->x_drawable2, 
			_plotter->drawstate->x_gc_fg, 
			ix, iy);
	}
    }
        
  /* maybe flush X output buffer and handle X events (a no-op for
     XDrawablePlotters, which is overridden for XPlotters) */
  if (_plotter->x_paint_pixel_count % X_POINT_FLUSH_PERIOD == 0)
    _maybe_handle_x_events (S___(_plotter));
  _plotter->x_paint_pixel_count++;
}
示例#13
0
文件: draw.c 项目: BrianMulhall/ocaml
value caml_gr_plot(value vx, value vy)
{
  int x = Int_val(vx);
  int y = Int_val(vy);
  caml_gr_check_open();
  if(caml_gr_remember_modeflag)
    XDrawPoint(caml_gr_display, caml_gr_bstore.win, caml_gr_bstore.gc, x,
               Bcvt(y));
  if(caml_gr_display_modeflag) {
    XDrawPoint(caml_gr_display, caml_gr_window.win, caml_gr_window.gc, x,
               Wcvt(y));
    XFlush(caml_gr_display);
  }
  return Val_unit;
}
示例#14
0
 void Graphics::DrawPoint(const Point & p)
 {
   this->PrepareGraphicsContext();
   Point newPoint = this->transform * p;
   XDrawPoint(this->display, this->window, this->gc, (int)newPoint.x, (int)newPoint.y);
   DebugDelay(string("DrawPoint"));
 }
void
DisplayX11::draw_point( DisplayObject * d_obj,
                        const RGBcolor & col,
                        const Point2d & point )
{
    D_XPoint * myobj;

    if ( ! d_obj )
    {
        myobj = &d_xpoint;
        myobj->mark_col_change();
        myobj->mark_pos_change();
    }
    else
    {
        myobj = static_cast< D_XPoint * >( d_obj ); //dynamic_cast should also work, but it doesn't <- why?
    }

    if ( myobj->col_change )
    {
        myobj->col_change = false;
        myobj->XColor_pixel = AGetColor( col );
    }

    if ( myobj->area_number != area_number )
    {
        myobj->area_number = area_number;
        copy_2_XPoint( myobj->p, point );
    }

    ASetForeground( myobj->XColor_pixel );

    XDrawPoint( disp, pixmap, gc, myobj->p.x, myobj->p.y );
}
示例#16
0
/* create a nice curved background gradient */
static Pixmap createGradPixmap(Display *dpy, int width, int height,
			char *basecolour){
	int x = 0, y;
	double cosine, l2rads;
	XColor bcolour, col2, diffcol;
	Colormap cmap = DefaultColormap(dpy, DefaultScreen(dpy));
	Pixmap pmap;
	GC gc = dc.gc;
	Window win = DefaultRootWindow(dpy);

	width = 1;
	l2rads = M_PIl/(height);

	XParseColor(dpy, cmap, basecolour, &bcolour);
	diffcol.red = min(bcolour.red, 0xffff-bcolour.red);
	diffcol.green = min(bcolour.green, 0xffff-bcolour.green);
	diffcol.blue = min(bcolour.blue, 0xffff-bcolour.blue);
	fprintf(stderr, "height %d, width %d, %s\n", height, width, basecolour);
	
	pmap = XCreatePixmap(dpy, win, width, height, 
		DefaultDepth(dpy, DefaultScreen(dpy)));
	for(y = 0; y < height; y += 1){
		cosine = cos(l2rads * y)/2.0; /* mute it */
		col2.red = bcolour.red + diffcol.red * cosine;
		col2.green = bcolour.green + diffcol.green * cosine;
		col2.blue = bcolour.blue + diffcol.blue * cosine;
		XAllocColor(dpy, cmap, &col2);
		XSetForeground(dpy, gc, col2.pixel);
		for (x = 0; x < width; x += 1){
			XDrawPoint(dpy, pmap, gc, x, y);
		}
	}
	return pmap;
}
示例#17
0
/* INTPROTO */
static Pixmap
rxvt_render_pixmap(rxvt_t *r, const char *const *data, int width, int height)
{
	char			a;
	int				x, y;
	Pixmap			d;
	unsigned long	pointcolour;

	d = XCreatePixmap (r->Xdisplay, r->scrollBar.win, width, height,
			XDEPTH);
	if (None == d)
		return None;

	for (y = 0; y < height; y++) {
		for (x = 0; x < width; x++) {
			if ((a = data[y][x]) == ' ' || a == 'w')
				pointcolour = r->scrollBar.next_white;
			else if (a == '.' || a == 'l')
				pointcolour = r->scrollBar.next_bg;
			else if (a == '%' || a == 'd')
				pointcolour = r->scrollBar.next_dark;
			else		/* if (a == '#' || a == 'b' || a) */
				pointcolour = r->scrollBar.next_fg;
			CHOOSE_GC_FG(r, pointcolour);
			XDrawPoint(r->Xdisplay, d, r->scrollBar.gc, x, y);
		}
	}

	return d;
}
示例#18
0
void affich(char * expr, int * tab, int choix)
{
   int i;
   /*affichage des axes*/
   XDrawLine(dpy,win,gcontext,0,199,399,199);
   XDrawLine(dpy,win,gcontext,199,0,199,399);
   
   /*affichage du nom de la fonction*/
   XDrawString(dpy,win,gcontext,0,10,expr,strlen(expr)-1);
   
   /*affichage point par point*/
   if(choix == 1)
   {
      for(i=0;i<399;i++)
      {
         if(tab[i] > 0 && tab[i] < 399 && tab[i+1] > 0 && tab[i+1] < 399)
            XDrawLine(dpy,win,gcontext,i,tab[i],i+1,tab[i+1]);
      }
   }
   else
   {
      for(i=0;i<400;i++)
      {
         if(tab[i] > 0 && tab[i] < 399)
            XDrawPoint(dpy,win,gcontext,i,tab[i]);
      }
   }
}
示例#19
0
static void
rock_draw(Window win, arock *arocks, int draw_p)
{
  rockstruct *rp = &rocks[screen];
  if (draw_p)
    XSetForeground(dsp, Scr[screen].gc, arocks->color);
  else
    XSetForeground(dsp, Scr[screen].gc, BlackPixel(dsp, screen));
  if (arocks->x <= 0 || arocks->y <= 0 ||
      arocks->x >= rp->width || arocks->y >= rp->height) {
    /* this means that if a rock were to go off the screen at 12:00, but
       would have been visible at 3:00, it won't come back once the observer
       rotates around so that the rock would have been visible again.
       Oh well.
     */
    if (!rp->move_p) arocks->depth = 0;
      return;
  }
  if (arocks->size <= 1)
    XDrawPoint (dsp, win, Scr[screen].gc, arocks->x, arocks->y);
  else if (arocks->size <= 3 || !draw_p)
    XFillRectangle(dsp, win, Scr[screen].gc,
		    arocks->x - arocks->size/2, arocks->y - arocks->size/2,
		    arocks->size, arocks->size);
  else if (arocks->size < MAX_WIDTH)
    XCopyPlane(dsp, rp->pixmaps[arocks->size], win, Scr[screen].gc,
		0, 0, arocks->size, arocks->size,
		arocks->x - arocks->size/2, arocks->y - arocks->size/2,
		1L);
}
示例#20
0
void draw_map() { //also drew the route
    int xcord, ycord;
    for (ycord = 0; ycord < MAP_SIZE; ycord++) {
        for (xcord = 0; xcord < MAP_SIZE; xcord++) {
            if (mappoints[xcord][ycord] == 1) {
                XDrawPoint(dis, win, blue_gc, (xcord + 50), (ycord + 50));
            }
        }
    }
    int allroutepoints[100];
    int i, j;
    int x, xx;
    int y, yy;
    int sizeorwhat;
    if (route_points != 0) {
        for (i = 1; i <= route_points; i++) {
            allroutepoints[i] = en_route_x[i] + en_route_y[i] * 1000; //x + 1000* y
        }

        for (j = 1; j < route_points; j++) {
            x = allroutepoints[j] % 1000;
            y = (allroutepoints[j] - x) / 1000;
            xx = allroutepoints[j + 1] % 1000;
            yy = (allroutepoints[j + 1] - xx) / 1000;
            XPoint points[] = {
                {(x + 50), (y + 50)},
                {(xx + 50), (yy + 50)},
            };
            sizeorwhat = sizeof (points) / sizeof (XPoint);
            XDrawLines(dis, win, green_gc, points, sizeorwhat, CoordModeOrigin);
        }
    }
}
/**
 * @brief Show the cursor on a window of type Ecore_X_Window.
 * @param win The window for which the cursor will be showed.
 * @param show Enables the show of the cursor on the window if equals EINA_TRUE, disables if equals EINA_FALSE.
 */
EAPI void
ecore_x_window_cursor_show(Ecore_X_Window win,
                           Eina_Bool show)
{
   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   if (win == 0)
     win = DefaultRootWindow(_ecore_x_disp);

   if (!show)
     {
        Cursor c;
        XColor cl;
        Pixmap p, m;
        GC gc;
        XGCValues gcv;

        p = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1);
        m = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1);
        gc = XCreateGC(_ecore_x_disp, m, 0, &gcv);
        XSetForeground(_ecore_x_disp, gc, 0);
        XDrawPoint(_ecore_x_disp, m, gc, 0, 0);
        XFreeGC(_ecore_x_disp, gc);
        c = XCreatePixmapCursor(_ecore_x_disp, p, m, &cl, &cl, 0, 0);
        XDefineCursor(_ecore_x_disp, win, c);
        XFreeCursor(_ecore_x_disp, c);
        XFreePixmap(_ecore_x_disp, p);
        XFreePixmap(_ecore_x_disp, m);
     }
   else
     XDefineCursor(_ecore_x_disp, win, 0);
}
示例#22
0
int main(void)
   {
   xxfmt *xx;
   kissfmt *kk;
   xx = (xxfmt *) malloc(sizeof(xxfmt));
   if (xx == NULL)
      {
      fprintf(stderr,"main: out of memory "
         "allocating xx\n");
      exit(1);
      } /* out of mem */
   initx(xx);
   kk = (kissfmt *) ekissinit();
   xx->runflg = 1;
   while(xx->runflg)
      {
      int x;
      int y;
      x = (int) ekisspwr(kk,9);   /* 0 to 511 */
      y = (int) ekisspwr(kk,9);   /* 0 to 511 */
      if (ekisspwr(kk,1))
           XSetForeground(xx->dpy, xx->gc, xx->whiteColor);
      else
           XSetForeground(xx->dpy, xx->gc, xx->blackColor);
      XDrawPoint(xx->dpy,xx->w,xx->gc,x,y);
      ifkey(xx);
      } /* while runflg != 0 */
   XFreeGC(xx->dpy,xx->gc);
   XDestroyWindow(xx->dpy,xx->w);
   XCloseDisplay(xx->dpy);
   free(kk->state);
   free(kk);
   free(xx);
   return(0);
   } /* main */
示例#23
0
文件: xutil.c 项目: astrotycoon/grace
void xdrawgrid(X11Stuff *xstuff)
{
    int i, j;
    double step;
    XPoint xp;
    unsigned long black = BlackPixel(xstuff->disp, xstuff->screennumber);
    unsigned long white = WhitePixel(xstuff->disp, xstuff->screennumber);
    
    XSetForeground(xstuff->disp, xstuff->gc, white);
    XSetFillStyle(xstuff->disp, xstuff->gc, FillSolid);
    XFillRectangle(xstuff->disp, xstuff->bufpixmap, xstuff->gc, 0, 0, xstuff->win_w, xstuff->win_h);
    XSetForeground(xstuff->disp, xstuff->gc, black);
    
    step = (double) (xstuff->win_scale)/10;
    for (i = 0; i < xstuff->win_w/step; i++) {
        for (j = 0; j < xstuff->win_h/step; j++) {
            xp.x = rint(i*step);
            xp.y = xstuff->win_h - rint(j*step);
            XDrawPoint(xstuff->disp, xstuff->bufpixmap,
                xstuff->gc, xp.x, xp.y);
        }
    }
    
    XSetLineAttributes(xstuff->disp, xstuff->gc,
        1, LineSolid, CapButt, JoinMiter);
    XDrawRectangle(xstuff->disp, xstuff->bufpixmap,
        xstuff->gc, 0, 0, xstuff->win_w - 1, xstuff->win_h - 1);
}
示例#24
0
void
WindowDevice::V2F(float x, float y)
{
#ifdef _UNIX
  // Flip the Y-Coordinate because X goes from 0->height as we 
  // go top->bottom while GL goes from height->0 as we go top->bottom. 
  y = height-y;	
  if (drawingPolygon)
  {
    if (numPoints == MAX_NUM_POINTS_FOR_POLYGON)
      {
	opserr << "ERROR: Maximum number of points has been exceeded" << endln;
	return;
      }
    polygonPointArray[numPoints].x = (int)x;
    polygonPointArray[numPoints].y = (int)y;
    numPoints++;
  }
  else
  {
    XDrawPoint(theDisplay, theWindow, theGC, (int) x, (int) y);
  }
#else
		glVertex2f(x,y);
#endif
}
示例#25
0
void
Fgl_setpixel (int x, int y, int col)
{
    int i;
    if (clipping_flag)
	if (x < xclip_x1 || x > xclip_x2 || y < xclip_y1 || y > xclip_y2)
	    return;
    col &= 0xff;

    i = pixmap_index(x,y);

#ifdef ALLOW_PIX_DOUBLING
    if (pix_double) {
	if ((int) pixmap[i] != col)
	{
	    pixmap[i] = (unsigned char) col;
	    XFillRectangle (display.dpy, display.win,
			    display.pixcolour_gc[col], x * 2, y * 2, 2, 2);
	}
    } else {
#endif
	if ((int) pixmap[i] != col)
	{
	    pixmap[i] = (unsigned char) col;
	    XDrawPoint (display.dpy, display.win,
			display.pixcolour_gc[col], x + borderx, y + bordery);
	}
#ifdef ALLOW_PIX_DOUBLING
    }
#endif
}
示例#26
0
int Safe_Point_X (int x, int y)
{
    if ((x < 0) || (y < 0) || (x >= TheWidth) || (y >= TheHeight)) {return 0 ;}
    XDrawPoint(TheDisplay, TheDrawable, ThePixmapContext,
               x,  TheHeight - 1 - y) ;
    return 1 ;
}
示例#27
0
static void
draw_planet(ModeInfo * mi, planetstruct * planet)
{
	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);
	GC          gc = MI_GC(mi);
	gravstruct *gp = &gravs[MI_SCREEN(mi)];
	double      D;		/* A distance variable to work with */
	register unsigned char cmpt;

	D = POS(X) * POS(X) + POS(Y) * POS(Y) + POS(Z) * POS(Z);
	if (D < COLLIDE)
		D = COLLIDE;
	D = sqrt(D);
	D = D * D * D;
	for (cmpt = X; cmpt < DIMENSIONS; cmpt++) {
		ACC(cmpt) = POS(cmpt) * GRAV / D;
		if (decay) {
			if (ACC(cmpt) > MaxA)
				ACC(cmpt) = MaxA;
			else if (ACC(cmpt) < -MaxA)
				ACC(cmpt) = -MaxA;
			VEL(cmpt) = VEL(cmpt) + ACC(cmpt);
			VEL(cmpt) *= DAMP;
		} else {
			/* update velocity */
			VEL(cmpt) = VEL(cmpt) + ACC(cmpt);
		}
		/* update position */
		POS(cmpt) = POS(cmpt) + VEL(cmpt);
	}

	gp->x = planet->xi;
	gp->y = planet->yi;

	if (POS(Z) > -ALMOST) {
		planet->xi = (int)
			((double) gp->width * (HALF + POS(X) / (POS(Z) + DIST)));
		planet->yi = (int)
			((double) gp->height * (HALF + POS(Y) / (POS(Z) + DIST)));
	} else
		planet->xi = planet->yi = -1;

	/* Mask */
	XSetForeground(display, gc, MI_BLACK_PIXEL(mi));
	Planet(gp->x, gp->y);
	if (trail) {
		XSetForeground(display, gc, planet->colors);
		XDrawPoint(display, MI_WINDOW(mi), gc, gp->x, gp->y);
	}
	/* Move */
	gp->x = planet->xi;
	gp->y = planet->yi;
	planet->ri = RADIUS;

	/* Redraw */
	XSetForeground(display, gc, planet->colors);
	Planet(gp->x, gp->y);
}
示例#28
0
int DessinePoint(TC *p,int x,int y,int couleur)
{
  setCouleurCrayon(p,couleur);
  XDrawPoint(p->display,p->win,p->gc,x,y);

  XFlush(p->display);
  return 0;
}
示例#29
0
void PlotDot(int i, int j)
/*The PlotDot function draws a point at i,j */
{
   if (isgraphic)
   {
      XDrawPoint(display,win,drawgc,i,j+top_marg_size);
   }
}
示例#30
0
	void
draw_screen(Display* display, GC gc, GC rev_gc, Drawable window)
{
	int x = 0, y = 0;
	for (y = 0; y < SCREEN_HEIGHT; ++y)
		for (x = 0; x < SCREEN_WIDTH; ++x)
			XDrawPoint(display, window, IsPixelSet(x, y) ? gc : rev_gc, x, y);
}