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; }
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; }
int DessineLigne(TC *p,int x1,int y1,int x2,int y2,int couleur) { setCouleurCrayon(p,couleur); XDrawLine(p->display,p->win,p->gc,x1,y1,x2,y2); XFlush(p->display); return 0; }
int DessineRectangle(TC *p,int xg,int yg,int xd,int yd,int couleur,int style) { setCouleurCrayon(p,couleur); if (style == CREUX) XDrawRectangle(p->display,p->win,p->gc,xg,yg,(xd-xg),(yd-yg)); if (style == PLEIN) XFillRectangle(p->display,p->win,p->gc,xg,yg,(1+xd-xg),(1+yd-yg)); XFlush(p->display); return 0; }