MCPcopy Create free account
hub / github.com/MyGUI/mygui / overlap

Method overlap

MyGUIEngine/src/msdfgen/core/Scanline.cpp:27–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27double Scanline::overlap(const Scanline &a, const Scanline &b, double xFrom, double xTo, FillRule fillRule) {
28 double total = 0;
29 bool aInside = false, bInside = false;
30 int ai = 0, bi = 0;
31 double ax = !a.intersections.empty() ? a.intersections[ai].x : xTo;
32 double bx = !b.intersections.empty() ? b.intersections[bi].x : xTo;
33 while (ax < xFrom || bx < xFrom) {
34 double xNext = min(ax, bx);
35 if (ax == xNext && ai < (int) a.intersections.size()) {
36 aInside = interpretFillRule(a.intersections[ai].direction, fillRule);
37 ax = ++ai < (int) a.intersections.size() ? a.intersections[ai].x : xTo;
38 }
39 if (bx == xNext && bi < (int) b.intersections.size()) {
40 bInside = interpretFillRule(b.intersections[bi].direction, fillRule);
41 bx = ++bi < (int) b.intersections.size() ? b.intersections[bi].x : xTo;
42 }
43 }
44 double x = xFrom;
45 while (ax < xTo || bx < xTo) {
46 double xNext = min(ax, bx);
47 if (aInside == bInside)
48 total += xNext-x;
49 if (ax == xNext && ai < (int) a.intersections.size()) {
50 aInside = interpretFillRule(a.intersections[ai].direction, fillRule);
51 ax = ++ai < (int) a.intersections.size() ? a.intersections[ai].x : xTo;
52 }
53 if (bx == xNext && bi < (int) b.intersections.size()) {
54 bInside = interpretFillRule(b.intersections[bi].direction, fillRule);
55 bx = ++bi < (int) b.intersections.size() ? b.intersections[bi].x : xTo;
56 }
57 x = xNext;
58 }
59 if (aInside == bInside)
60 total += xTo-x;
61 return total;
62}
63
64Scanline::Scanline() : lastIndex(0) { }
65

Callers

nothing calls this directly

Calls 4

minFunction · 0.85
interpretFillRuleFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected