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

Function DrawArc

xgeneral.cpp:895–976  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

893// parameters allow the ellipse to be rotated, or a subarc to be drawn.
894
895void DrawArc(int x1, int y1, int x2, int y2, real rRotate, real t1, real t2)
896{
897 int x, y, rx, ry, m, n, u, v, i, di;
898 real rS, rC, dx, dy, dx2, dy2, dt, t;
899
900 if (gi.fFile || rRotate != 0.0) {
901 x = (x1+x2)/2; y = (y1+y2)/2; rx = (x2-x1)/2; ry = (y2-y1)/2;
902 if (gs.ft == ftBmp || gs.ft == ftWire || rRotate != 0.0) {
903 RotateR2Init(rS, rC, rRotate);
904 dt = (t2 - t1) / rDegMax;
905 i = NAbs(rx) + NAbs(ry);
906 di = 2 + (i < 90) + (i < 72) + (i < 60) + (i < 40);
907 for (i = 0; i <= nDegMax; i += di) {
908 t = t1 + dt*(real)i;
909 dx = ((real)rx+rRound) * RCosD(t);
910 dy = ((real)ry+rRound) * RSinD(t);
911 if (rRotate != 0.0) {
912 // Fast rotation if doing a rotated ellipse.
913 RotateR2(dx, dy, dx2, dy2, rS, rC);
914 } else {
915 dx2 = dx; dy2 = dy;
916 }
917 u = x + (int)dx2; v = y + (int)dy2;
918 if (i > 0)
919 DrawLine(m, n, u, v);
920 m = u; n = v;
921 }
922 }
923#ifdef PS
924 else if (gs.ft == ftPS) {
925 PsLineCap(fFalse);
926 PsStrokeForce();
927 PsDash(0);
928 fprintf(gi.file, "%d %d %d %d el\n", rx, ry, x, y);
929 }
930#endif
931#ifdef META
932 else if (gs.ft == ftWmf) {
933 gi.kiFillDes = cColor; // Specify a hollow fill brush.
934 MetaSelect();
935 MetaEllipse(x1, y1, x2+gi.nPenWid*2, y2+gi.nPenWid*2);
936 }
937#endif
938#ifdef SVG
939 else if (gs.ft == ftSVG) {
940 SvgSetColor();
941 if (rx == ry)
942 fprintf(gi.file, "<circle r=\"%d\" cx=\"%d\" cy=\"%d\"/>\n",
943 rx, x, y);
944 else
945 fprintf(gi.file, "<ellipse rx=\"%d\" ry=\"%d\" "
946 "cx=\"%d\" cy=\"%d\"/>\n", rx, ry, x, y);
947 }
948#endif
949 }
950#ifdef X11
951 else {
952 i = nDegMax*64;

Callers 1

XChartTelescopeFunction · 0.85

Calls 5

PsLineCapFunction · 0.85
PsStrokeForceFunction · 0.85
PsDashFunction · 0.85
MetaSelectFunction · 0.85
SvgSetColorFunction · 0.85

Tested by

no test coverage detected