예제 #1
0
파일: devpoly.c 프로젝트: OPSF/uClinux
/**
 * Draw a polygon in the foreground color, applying clipping if necessary.
 * The polygon is only closed if the first point is repeated at the end.
 * Some care is taken to plot the endpoints correctly if the current
 * drawing mode is XOR.  However, internal crossings are not handled
 * correctly.
 *
 * @param psd Drawing surface.
 * @param count Number of points in polygon.
 * @param points The array of points.
 */
void
GdPoly(PSD psd, int count, MWPOINT *points)
{
  MWCOORD firstx;
  MWCOORD firsty;
  MWBOOL didline;

  if (count < 2)
	  return;
  firstx = points->x;
  firsty = points->y;
  didline = FALSE;

  while (count-- > 1) {
	if (didline && (gr_mode == MWMODE_XOR))
		drawpoint(psd, points->x, points->y);
	/* note: change to drawline*/
	GdLine(psd, points[0].x, points[0].y, points[1].x, points[1].y, TRUE);
	points++;
	didline = TRUE;
  }
  if (gr_mode == MWMODE_XOR) {
	  points--;
	  if (points->x == firstx && points->y == firsty)
		drawpoint(psd, points->x, points->y);
  }
  GdFixCursor(psd);
}
예제 #2
0
int TBMP::drawline(int x0, int y0, int x1, int y1){
#ifdef BMP_TEST
	if (!checkborder(x0, y0) || !checkborder(x1, y1))
		return 1;
	if (x0==x1 && y0==y1)
	    return drawpoint(x0, y0);
	
	int xs, ys, xe, ye;
	int i, j;
	double t;
	if (abs(x0-x1) >= abs(y0-y1)){
		if (x0 < x1){
			xs = x0;
			ys = y0;
			xe = x1;
			ye = y1;
		}
		else{
			xs = x1;
			ys = y1;
			xe = x0;
			ye = y0;
		}
		t = (double)(ye - ys) / (double)(xe - xs);
		for (i=xs; i<=xe; i++){
			j = (int)((i - xs) * t + ys);
			drawpoint(i,j);
			//bitmap[j][i] = Grey;
		}
	}
	else{
		if (y0 < y1){
			xs = x0;
			ys = y0;
			xe = x1;
			ye = y1;
		}
		else{
			xs = x1;
			ys = y1;
			xe = x0;
			ye = y0;
		}
		t = (double)(xe - xs) / (double)(ye - ys);
		for (j=ys; j<=ye; j++){
			i = (int)((j-ys) * t + xs);
			drawpoint(i,j);
			//bitmap[j][i] =Grey;
		}
	}
	return 0;
#endif
}
예제 #3
0
void draw_data(FR_GUI_GRAPH_T* gr,FR_DATA_T* data_struct){




	if(data_struct->pointQTY>=2){

		FR_DATA_POINT_T* actualpoint;
		FR_DATA_POINT_T* nextpoint;

		actualpoint=data_struct->first_point;

		do{
			nextpoint=actualpoint->next;

			//GUI_DrawLine(actualpoint->x,actualpoint->y,nextpoint->x,nextpoint->y);

			drawpoint(actualpoint,nextpoint,gr);

			actualpoint=nextpoint;
		}while(actualpoint!=NULL);





	}



}
예제 #4
0
void myDisplay(void)
{
	// 清除。GL_COLOR_BUFFER_BIT表示清除颜色
	/*
	在RGB模式下,使用glClearColor来指定“空”的颜色,它需要四个参数,其参数的意义跟glColor4f相似。
	在索引颜色模式下,使用glClearIndex来指定“空”的颜色所在的索引,它需要一个参数,其意义跟glIndexi相似。
	*/
	glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
	glClear(GL_COLOR_BUFFER_BIT);

	drawrect();

	drawpoint();

	drawline();

	drawpolygon();
	
	draw5star();

	drawsin();

	drawtriangle();

	//保证前面的OpenGL命令立即执行(而不是让它们在缓冲区中等待)。其作用跟fflush(stdout)类似。
	glFlush();

}
예제 #5
0
/**
 * Draw a polygon in the foreground color, applying clipping if necessary.
 * The polygon is only closed if the first point is repeated at the end.
 * Some care is taken to plot the endpoints correctly if the current
 * drawing mode is XOR.  However, internal crossings are not handled
 * correctly.
 *
 * @param psd Drawing surface.
 * @param count Number of points in polygon.
 * @param points The array of points.
 */
void cgfx_Poly(CoreGfxBase *CoreGfxBase, struct CRastPort *rp, int count, CGfxPoint *points)
{
    INT32 firstx;
    INT32 firsty;
    BOOL didline;

    if (count < 2) return;
    firstx = points->x;
    firsty = points->y;
    didline = FALSE;

    while (count-- > 1) {
        if (didline && (rp->crp_Mode == ROP_XOR)) drawpoint(CoreGfxBase, rp, points->x, points->y);
        /* note: change to drawline*/
        Line(rp, points[0].x, points[0].y, points[1].x, points[1].y, TRUE);
        points++;
        didline = TRUE;
    }
    if (rp->crp_Mode == ROP_XOR) {
        points--;
        if (points->x == firstx && points->y == firsty) drawpoint(CoreGfxBase, rp, points->x, points->y);
    }
    FixCursor(rp->crp_PixMap);
}