MCPcopy Create free account
hub / github.com/CruiserOne/Astrolog / DrawEllipse2

Function DrawEllipse2

xgeneral.cpp:981–1043  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

979// Draw a filled in circle or ellipse inside a bounding rectangle.
980
981void DrawEllipse2(int x1, int y1, int x2, int y2)
982{
983 int rx, ry, r, i, j, iT, jT, q, qLo, qHi, m1, m2, n1, n2, x, y;
984
985 if (gi.fFile) {
986 x = (x1 + x2) >> 1; y = (y1 + y2) >> 1;
987 rx = NAbs(x2 - x1) >> 1; ry = NAbs(y2 - y1) >> 1;
988 if (gs.ft == ftBmp || gs.ft == ftWire) {
989 // This efficient algorithm has no calculations more complicated than
990 // addition (and multiplication to proportion in case of an ellipse).
991 if (rx == 0 || ry == 0) {
992 DrawBlock(x1, y1, x2, y2);
993 return;
994 }
995 r = Max(rx, ry);
996 j = r; q = r+1; qLo = 1; qHi = r+r-1;
997 m1 = (x1 + x2) >> 1; m2 = m1 + FOdd(x2 - x1);
998 n1 = (y1 + y2) >> 1; n2 = n1 + FOdd(y2 - y1);
999 for (i = 0; i <= r; i++) {
1000 iT = (rx <= ry) ? i : i * ry / rx;
1001 jT = (rx >= ry) ? j : j * rx / ry;
1002 DrawLineX(m1 - jT, m2 + jT, n1 - iT);
1003 DrawLineX(m1 - jT, m2 + jT, n2 + iT);
1004 q -= qLo;
1005 while (q < 0) {
1006 q += qHi;
1007 qHi -= 2;
1008 j--;
1009 }
1010 qLo += 2;
1011 }
1012 }
1013#ifdef PS
1014 else if (gs.ft == ftPS) {
1015 PsLineCap(fFalse);
1016 PsStrokeForce();
1017 PsDash(0);
1018 fprintf(gi.file, "%d %d %d %d ef\n", rx, ry, x, y);
1019 }
1020#endif
1021#ifdef META
1022 else {
1023 gi.kiFillDes = gi.kiCur; // Specify a solid fill brush.
1024 MetaSelect();
1025 MetaEllipse(x1+gi.nPenWid/3, y1+gi.nPenWid/3,
1026 x2+1+gi.nPenWid/3, y2+1+gi.nPenWid/3);
1027 }
1028#endif
1029 }
1030#ifdef X11
1031 else
1032 XFillArc(gi.disp, gi.pmap, gi.gc, x1, y1, x2-x1, y2-y1, 0, nDegMax*64);
1033#endif
1034#ifdef WINANY
1035 else {
1036 wi.hbrush = CreateSolidBrush((COLORREF)KvFromKi(gi.kiCur));
1037 SelectObject(wi.hdc, wi.hbrush);
1038 Ellipse(wi.hdc, x1, y1, x2+1, y2+1);

Callers 2

FEvalFunctionFunction · 0.85
XChartTelescopeFunction · 0.85

Calls 5

DrawBlockFunction · 0.85
PsLineCapFunction · 0.85
PsStrokeForceFunction · 0.85
PsDashFunction · 0.85
MetaSelectFunction · 0.85

Tested by

no test coverage detected