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

Method winding

MyGUIEngine/src/msdfgen/core/Contour.cpp:57–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55}
56
57int Contour::winding() const {
58 if (edges.empty())
59 return 0;
60 double total = 0;
61 if (edges.size() == 1) {
62 Point2 a = edges[0]->point(0), b = edges[0]->point(1/3.), c = edges[0]->point(2/3.);
63 total += shoelace(a, b);
64 total += shoelace(b, c);
65 total += shoelace(c, a);
66 } else if (edges.size() == 2) {
67 Point2 a = edges[0]->point(0), b = edges[0]->point(.5), c = edges[1]->point(0), d = edges[1]->point(.5);
68 total += shoelace(a, b);
69 total += shoelace(b, c);
70 total += shoelace(c, d);
71 total += shoelace(d, a);
72 } else {
73 Point2 prev = edges.back()->point(0);
74 for (std::vector<EdgeHolder>::const_iterator edge = edges.begin(); edge != edges.end(); ++edge) {
75 Point2 cur = (*edge)->point(0);
76 total += shoelace(prev, cur);
77 prev = cur;
78 }
79 }
80 return sign(total);
81}
82
83void Contour::reverse() {
84 for (int i = (int) edges.size()/2; i > 0; --i)

Callers 1

Calls 7

shoelaceFunction · 0.85
signFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45
pointMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected