void XFillPolygon( Display* display, /* Display. */ Drawable d, /* Draw on this. */ GC gc, /* Use this GC. */ XPoint* points, /* Array of points. */ int npoints, /* Number of points. */ int shape, /* Shape to draw. */ int mode) /* Drawing mode. */ { MacDrawable *macWin = (MacDrawable *) d; PolyHandle polygon; CGrafPtr saveWorld; GDHandle saveDevice; GWorldPtr destPort; int i; destPort = TkMacGetDrawablePort(d); display->request++; GetGWorld(&saveWorld, &saveDevice); SetGWorld(destPort, NULL); TkMacSetUpClippingRgn(d); TkMacSetUpGraphicsPort(gc); PenNormal(); polygon = OpenPoly(); MoveTo((short) (macWin->xOff + points[0].x), (short) (macWin->yOff + points[0].y)); for (i = 1; i < npoints; i++) { if (mode == CoordModePrevious) { Line((short) (macWin->xOff + points[i].x), (short) (macWin->yOff + points[i].y)); } else { LineTo((short) (macWin->xOff + points[i].x), (short) (macWin->yOff + points[i].y)); } } ClosePoly(); FillCPoly(polygon, gPenPat); KillPoly(polygon); SetGWorld(saveWorld, saveDevice); }
void XFillArc( Display* display, /* Display. */ Drawable d, /* Draw on this. */ GC gc, /* Use this GC. */ int x, /* Upper left of */ int y, /* bounding rect. */ unsigned int width, /* Width & height. */ unsigned int height, int angle1, /* Staring angle of arc. */ int angle2) /* Ending angle of arc. */ { MacDrawable *macWin = (MacDrawable *) d; Rect theRect; short start, extent; PolyHandle polygon; double sin1, cos1, sin2, cos2, angle; double boxWidth, boxHeight; double vertex[2], center1[2], center2[2]; CGrafPtr saveWorld; GDHandle saveDevice; GWorldPtr destPort; destPort = TkMacGetDrawablePort(d); display->request++; GetGWorld(&saveWorld, &saveDevice); SetGWorld(destPort, NULL); TkMacSetUpClippingRgn(d); TkMacSetUpGraphicsPort(gc); theRect.left = (short) (macWin->xOff + x); theRect.top = (short) (macWin->yOff + y); theRect.right = (short) (theRect.left + width); theRect.bottom = (short) (theRect.top + height); start = (short) (90 - (angle1 / 64)); extent = (short) (- (angle2 / 64)); if (gc->arc_mode == ArcChord) { boxWidth = theRect.right - theRect.left; boxHeight = theRect.bottom - theRect.top; angle = -(angle1/64.0)*PI/180.0; sin1 = sin(angle); cos1 = cos(angle); angle -= (angle2/64.0)*PI/180.0; sin2 = sin(angle); cos2 = cos(angle); vertex[0] = (theRect.left + theRect.right)/2.0; vertex[1] = (theRect.top + theRect.bottom)/2.0; center1[0] = vertex[0] + cos1*boxWidth/2.0; center1[1] = vertex[1] + sin1*boxHeight/2.0; center2[0] = vertex[0] + cos2*boxWidth/2.0; center2[1] = vertex[1] + sin2*boxHeight/2.0; polygon = OpenPoly(); MoveTo((short) ((theRect.left + theRect.right)/2), (short) ((theRect.top + theRect.bottom)/2)); LineTo((short) (center1[0] + 0.5), (short) (center1[1] + 0.5)); LineTo((short) (center2[0] + 0.5), (short) (center2[1] + 0.5)); ClosePoly(); ShowPen(); FillCArc(&theRect, start, extent, gPenPat); FillCPoly(polygon, gPenPat); KillPoly(polygon); } else { ShowPen(); FillCArc(&theRect, start, extent, gPenPat); } SetGWorld(saveWorld, saveDevice); }
void _HYPlatformGraphicPane::_FillPolygon (Ptr rgn) { if (rgn) FillCPoly ((PolyHandle)rgn,fillColor); }