MCPcopy Create free account
hub / github.com/breck7/scroll / clipLine

Function clipLine

external/.d3.js:10931–11003  ·  view source on GitHub ↗
(stream)

Source from the content-addressed store, hash-verified

10929 // intersections 2 - there were intersections, and the first and last segments
10930 // should be rejoined.
10931 function clipLine(stream) {
10932 var point0, // previous point
10933 c0, // code for previous point
10934 v0, // visibility of previous point
10935 v00, // visibility of first point
10936 clean; // no intersections
10937 return {
10938 lineStart: function() {
10939 v00 = v0 = false;
10940 clean = 1;
10941 },
10942 point: function(lambda, phi) {
10943 var point1 = [lambda, phi],
10944 point2,
10945 v = visible(lambda, phi),
10946 c = smallRadius
10947 ? v ? 0 : code(lambda, phi)
10948 : v ? code(lambda + (lambda < 0 ? pi$1 : -pi$1), phi) : 0;
10949 if (!point0 && (v00 = v0 = v)) stream.lineStart();
10950 if (v !== v0) {
10951 point2 = intersect(point0, point1);
10952 if (!point2 || pointEqual(point0, point2) || pointEqual(point1, point2))
10953 point1[2] = 1;
10954 }
10955 if (v !== v0) {
10956 clean = 0;
10957 if (v) {
10958 // outside going in
10959 stream.lineStart();
10960 point2 = intersect(point1, point0);
10961 stream.point(point2[0], point2[1]);
10962 } else {
10963 // inside going out
10964 point2 = intersect(point0, point1);
10965 stream.point(point2[0], point2[1], 2);
10966 stream.lineEnd();
10967 }
10968 point0 = point2;
10969 } else if (notHemisphere && point0 && smallRadius ^ v) {
10970 var t;
10971 // If the codes for two points are different, or are both zero,
10972 // and there this segment intersects with the small circle.
10973 if (!(c & c0) && (t = intersect(point1, point0, true))) {
10974 clean = 0;
10975 if (smallRadius) {
10976 stream.lineStart();
10977 stream.point(t[0][0], t[0][1]);
10978 stream.point(t[1][0], t[1][1]);
10979 stream.lineEnd();
10980 } else {
10981 stream.point(t[1][0], t[1][1]);
10982 stream.lineEnd();
10983 stream.lineStart();
10984 stream.point(t[0][0], t[0][1], 3);
10985 }
10986 }
10987 }
10988 if (v && (!point0 || !pointEqual(point0, point1))) {

Callers 2

clipFunction · 0.70
linePointFunction · 0.70

Calls 7

visibleFunction · 0.85
codeFunction · 0.85
intersectFunction · 0.85
pointEqualFunction · 0.85
lineStartMethod · 0.45
pointMethod · 0.45
lineEndMethod · 0.45

Tested by

no test coverage detected