void dev_arc(int xc, int yc, double r, double start, double end, double aspect) { double th, ph, xs, ys, xe, ye, x, y; int i; if (r < 1) { r = 1; } while (end < start) { end += M_PI * 2.0; } th = (end - start) / r; xs = xc + r * cos(start); ys = yc + r * aspect * sin(start); xe = xc + r * cos(end); ye = yc + r * aspect * sin(end); x = xs; y = ys; for (i = 1; i < r; i++) { ph = start + i * th; xs = xc + r * cos(ph); ys = yc + r * aspect * sin(ph); dev_line(x, y, xs, ys); x = xs; y = ys; } dev_line(x, y, xe, ye); }
/** * draw rectangle (filled or not) */ void dev_rect(int x1, int y1, int x2, int y2, int fill) { int px1, py1, px2, py2; int c1, c2, in1, in2; px1 = x1; py1 = y1; px2 = x2; py2 = y2; W2D4(x1, y1, x2, y2); if (x1 == x2) { dev_line(px1, py1, px2, py2); return; } if (y1 == y2) { dev_line(px1, py1, px2, py2); return; } /* * check inside */ CLIPENCODE(x1, y1, c1); CLIPENCODE(x2, y2, c2); in1 = CLIPIN(c1); in2 = CLIPIN(c2); if (in1 && in2) { /* * its inside */ osd_rect(x1, y1, x2, y2, fill); } else { /* * partial inside * TODO: something fast */ int y; if (fill) { for (y = py1; y <= py2; y++) { dev_line(px1, y, px2, y); } } else { dev_line(px1, py1, px1, py2); dev_line(px1, py2, px2, py2); dev_line(px2, py2, px2, py1); dev_line(px2, py1, px1, py1); } } }
/* * Fills the scan line described by the current AET at the specified Y * coordinate in the specified color, using the odd/even fill rule. */ void pf_scan_out_AET(int YToScan) { int LeftX; struct EdgeState *CurrentEdge; /* * Scan through the AET, drawing line segments as each pair of edge * crossings is encountered. The nearest pixel on or to the right * of left edges is drawn, and the nearest pixel to the left of but * not on right edges is drawn */ CurrentEdge = AETPtr; while (CurrentEdge != NULL) { LeftX = CurrentEdge->X; CurrentEdge = CurrentEdge->NextEdge; /* * 8/5/95, NDC: Zen's bug */ if (CurrentEdge->X) dev_line(LeftX, YToScan, CurrentEdge->X - 1, YToScan); CurrentEdge = CurrentEdge->NextEdge; } }
void set_4line(int x, int y, int xc, int yc) { dev_line(xc - x, yc + y, xc + x, yc + y); dev_line(xc - x, yc - y, xc + x, yc - y); }