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

Function FDrawClip

xgeneral.cpp:843–882  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

841// viewport or if entire line is outside of viewport and nothing at all drawn.
842
843flag FDrawClip(int x1, int y1, int x2, int y2, int xl, int yl, int xh, int yh,
844 int skip, int *x0, int *y0)
845{
846 if ((x1 < xl && x2 < xl) || (y1 < yl && y2 < yl) || // Skip if outside
847 (x1 > xh && x2 > xh) || (y1 > yh && y2 > yh)) // bounding box.
848 return fFalse;
849 if (x1 < xl)
850 ClipLesser (&y1, &x1, &y2, &x2, xl); // Check left side of window.
851 if (x2 < xl)
852 ClipLesser (&y2, &x2, &y1, &x1, xl);
853 if (y1 < yl)
854 ClipLesser (&x1, &y1, &x2, &y2, yl); // Check top side of window.
855 if (y2 < yl)
856 ClipLesser (&x2, &y2, &x1, &y1, yl);
857 if (x1 > xh)
858 ClipGreater(&y1, &x1, &y2, &x2, xh); // Check right of window.
859 if (x2 > xh)
860 ClipGreater(&y2, &x2, &y1, &x1, xh);
861 if (y1 > yh)
862 ClipGreater(&x1, &y1, &x2, &y2, yh); // Check bottom of window.
863 if (y2 > yh)
864 ClipGreater(&x2, &y2, &x1, &y1, yh);
865 if (x1 < xl || x2 < xl || y1 < yl || y2 < yl || // Skip if not inside
866 x1 > xh || x2 > xh || y1 > yh || y2 > yh) // bounding box.
867 return fFalse;
868 DrawDash(x1, y1, x2, y2, skip); // Go draw the line.
869
870 // Return coordinates at which drawn line crosses bounding box.
871 if (x0 != NULL) {
872 if (x1 == xl || x1 == xh || y1 == yl || y1 == yh) {
873 *x0 = x1; *y0 = y1;
874 return fTrue;
875 }
876 if (x2 == xl || x2 == xh || y2 == yl || y2 == yh) {
877 *x0 = x2; *y0 = y2;
878 return fTrue;
879 }
880 }
881 return fFalse;
882}
883
884
885// Fast version of rotating that assumes the slow trigonometry values have

Callers 2

XChartTelescopeFunction · 0.85
XChartLocalFunction · 0.85

Calls 3

ClipLesserFunction · 0.85
ClipGreaterFunction · 0.85
DrawDashFunction · 0.85

Tested by

no test coverage detected