public void Render(bool close_polygon) { m_src_vertices.Close(close_polygon); DrawVarsPart0 dv = new DrawVarsPart0(); DrawVarsPart1 dv1 = new DrawVarsPart1(); DrawVarsPart2 dv2 = new DrawVarsPart2(); LineAAVertex v; int x1; int y1; int x2; int y2; int lprev; LineParameters curr = null; LineParameters next = null; if (close_polygon) { if (m_src_vertices.Count >= 3) { dv.idx = 2; v = m_src_vertices[m_src_vertices.Count - 1]; x1 = v.x; y1 = v.y; lprev = v.len; v = m_src_vertices[0]; x2 = v.x; y2 = v.y; dv.lcurr = v.len; LineParameters prev = new LineParameters(x1, y1, x2, y2, lprev); v = m_src_vertices[1]; dv1.x1 = v.x; dv1.y1 = v.y; dv.lnext = v.len; curr = new LineParameters(x2, y2, dv1.x1, dv1.y1, dv.lcurr); v = m_src_vertices[dv.idx]; dv1.x2 = v.x; dv1.y2 = v.y; next = new LineParameters(dv1.x1, dv1.y1, dv1.x2, dv1.y2, dv.lnext); dv2.xb1 = 0; dv2.yb1 = 0; dv2.xb2 = 0; dv2.yb2 = 0; switch (m_line_join) { case OutlineJoin.NoJoin: dv.flags = 3; break; case OutlineJoin.Mitter: case OutlineJoin.Round: dv.flags = (prev.DiagonalQuadrant == curr.DiagonalQuadrant ? 1 : 0) | ((curr.DiagonalQuadrant == next.DiagonalQuadrant ? 1 : 0) << 1); break; case OutlineJoin.AccurateJoin: dv.flags = 0; break; } if ((dv.flags & 1) == 0 && m_line_join != OutlineJoin.Round) { LineAA.Bisectrix(prev, curr, out dv2.xb1, out dv2.yb1); } if ((dv.flags & 2) == 0 && m_line_join != OutlineJoin.Round) { LineAA.Bisectrix(curr, next, out dv2.xb2, out dv2.yb2); } Draw(ref dv, ref dv1, ref dv2, ref curr, ref next, 0, m_src_vertices.Count); } } else { switch (m_src_vertices.Count) { case 0: case 1: break; case 2: { v = m_src_vertices[0]; x1 = v.x; y1 = v.y; lprev = v.len; v = m_src_vertices[1]; x2 = v.x; y2 = v.y; LineParameters lp = new LineParameters(x1, y1, x2, y2, lprev); if (m_round_cap) { m_ren.SemiDot(CompareDistStart, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1)); } m_ren.Line3(lp, x1 + (y2 - y1), y1 - (x2 - x1), x2 + (y2 - y1), y2 - (x2 - x1)); if (m_round_cap) { m_ren.SemiDot(CompareDistEnd, x2, y2, x2 + (y2 - y1), y2 - (x2 - x1)); } } break; case 3: { int x3, y3; int lnext; v = m_src_vertices[0]; x1 = v.x; y1 = v.y; lprev = v.len; v = m_src_vertices[1]; x2 = v.x; y2 = v.y; lnext = v.len; v = m_src_vertices[2]; x3 = v.x; y3 = v.y; LineParameters lp1 = new LineParameters(x1, y1, x2, y2, lprev); LineParameters lp2 = new LineParameters(x2, y2, x3, y3, lnext); if (m_round_cap) { m_ren.SemiDot(CompareDistStart, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1)); } if (m_line_join == OutlineJoin.Round) { m_ren.Line3(lp1, x1 + (y2 - y1), y1 - (x2 - x1), x2 + (y2 - y1), y2 - (x2 - x1)); m_ren.Pie(x2, y2, x2 + (y2 - y1), y2 - (x2 - x1), x2 + (y3 - y2), y2 - (x3 - x2)); m_ren.Line3(lp2, x2 + (y3 - y2), y2 - (x3 - x2), x3 + (y3 - y2), y3 - (x3 - x2)); } else { LineAA.Bisectrix(lp1, lp2, out dv2.xb1, out dv2.yb1); m_ren.Line3(lp1, x1 + (y2 - y1), y1 - (x2 - x1), dv2.xb1, dv2.yb1); m_ren.Line3(lp2, dv2.xb1, dv2.yb1, x3 + (y3 - y2), y3 - (x3 - x2)); } if (m_round_cap) { m_ren.SemiDot(CompareDistEnd, x3, y3, x3 + (y3 - y2), y3 - (x3 - x2)); } } break; default: { dv.idx = 3; v = m_src_vertices[0]; x1 = v.x; y1 = v.y; lprev = v.len; v = m_src_vertices[1]; x2 = v.x; y2 = v.y; dv.lcurr = v.len; LineParameters prev = new LineParameters(x1, y1, x2, y2, lprev); v = m_src_vertices[2]; dv1.x1 = v.x; dv1.y1 = v.y; dv.lnext = v.len; curr = new LineParameters(x2, y2, dv1.x1, dv1.y1, dv.lcurr); v = m_src_vertices[dv.idx]; dv1.x2 = v.x; dv1.y2 = v.y; next = new LineParameters(dv1.x1, dv1.y1, dv1.x2, dv1.y2, dv.lnext); dv2.xb1 = 0; dv2.yb1 = 0; dv2.xb2 = 0; dv2.yb2 = 0; switch (m_line_join) { case OutlineJoin.NoJoin: dv.flags = 3; break; case OutlineJoin.Mitter: case OutlineJoin.Round: dv.flags = (prev.DiagonalQuadrant == curr.DiagonalQuadrant ? 1 : 0) | ((curr.DiagonalQuadrant == next.DiagonalQuadrant ? 1 : 0) << 1); break; case OutlineJoin.AccurateJoin: dv.flags = 0; break; } if (m_round_cap) { m_ren.SemiDot(CompareDistStart, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1)); } if ((dv.flags & 1) == 0) { if (m_line_join == OutlineJoin.Round) { m_ren.Line3(prev, x1 + (y2 - y1), y1 - (x2 - x1), x2 + (y2 - y1), y2 - (x2 - x1)); m_ren.Pie(prev.x2, prev.y2, x2 + (y2 - y1), y2 - (x2 - x1), curr.x1 + (curr.y2 - curr.y1), curr.y1 - (curr.x2 - curr.x1)); } else { LineAA.Bisectrix(prev, curr, out dv2.xb1, out dv2.yb1); m_ren.Line3(prev, x1 + (y2 - y1), y1 - (x2 - x1), dv2.xb1, dv2.yb1); } } else { m_ren.Line1(prev, x1 + (y2 - y1), y1 - (x2 - x1)); } if ((dv.flags & 2) == 0 && m_line_join != OutlineJoin.Round) { LineAA.Bisectrix(curr, next, out dv2.xb2, out dv2.yb2); } Draw(ref dv, ref dv1, ref dv2, ref curr, ref next, 1, m_src_vertices.Count - 2); if ((dv.flags & 1) == 0) { if (m_line_join == OutlineJoin.Round) { m_ren.Line3(curr, curr.x1 + (curr.y2 - curr.y1), curr.y1 - (curr.x2 - curr.x1), curr.x2 + (curr.y2 - curr.y1), curr.y2 - (curr.x2 - curr.x1)); } else { m_ren.Line3(curr, dv2.xb1, dv2.yb1, curr.x2 + (curr.y2 - curr.y1), curr.y2 - (curr.x2 - curr.x1)); } } else { m_ren.Line2(curr, curr.x2 + (curr.y2 - curr.y1), curr.y2 - (curr.x2 - curr.x1)); } if (m_round_cap) { m_ren.SemiDot(CompareDistEnd, curr.x2, curr.y2, curr.x2 + (curr.y2 - curr.y1), curr.y2 - (curr.x2 - curr.x1)); } } break; } } m_src_vertices.Clear(); }
void Draw(ref DrawVarsPart0 dv, ref DrawVarsPart1 dv1, ref DrawVarsPart2 dv2, ref LineParameters curr, ref LineParameters next, int start, int end) { int i; for (i = start; i < end; i++) { if (m_line_join == OutlineJoin.Round) { dv2.xb1 = curr.x1 + (curr.y2 - curr.y1); dv2.yb1 = curr.y1 - (curr.x2 - curr.x1); dv2.xb2 = curr.x2 + (curr.y2 - curr.y1); dv2.yb2 = curr.y2 - (curr.x2 - curr.x1); } switch (dv.flags) { case 0: m_ren.Line3(curr, dv2.xb1, dv2.yb1, dv2.xb2, dv2.yb2); break; case 1: m_ren.Line2(curr, dv2.xb2, dv2.yb2); break; case 2: m_ren.Line1(curr, dv2.xb1, dv2.yb1); break; case 3: m_ren.Line0(curr); break; } if (m_line_join == OutlineJoin.Round && (dv.flags & 2) == 0) { m_ren.Pie(curr.x2, curr.y2, curr.x2 + (curr.y2 - curr.y1), curr.y2 - (curr.x2 - curr.x1), curr.x2 + (next.y2 - next.y1), curr.y2 - (next.x2 - next.x1)); } dv1.x1 = dv1.x2; dv1.y1 = dv1.y2; dv.lcurr = dv.lnext; dv.lnext = m_src_vertices[dv.idx].len; ++dv.idx; if (dv.idx >= m_src_vertices.Count) { dv.idx = 0; } dv1.x2 = m_src_vertices[dv.idx].x; dv1.y2 = m_src_vertices[dv.idx].y; curr = next; next = new LineParameters(dv1.x1, dv1.y1, dv1.x2, dv1.y2, dv.lnext); dv2.xb1 = dv2.xb2; dv2.yb1 = dv2.yb2; switch (m_line_join) { case OutlineJoin.NoJoin: dv.flags = 3; break; case OutlineJoin.Mitter: dv.flags >>= 1; dv.flags |= (curr.DiagonalQuadrant == next.DiagonalQuadrant ? 1 : 0); if ((dv.flags & 2) == 0) { LineAA.Bisectrix(curr, next, out dv2.xb2, out dv2.yb2); } break; case OutlineJoin.Round: dv.flags >>= 1; dv.flags |= (((curr.DiagonalQuadrant == next.DiagonalQuadrant) ? 1 : 0) << 1); break; case OutlineJoin.AccurateJoin: dv.flags = 0; LineAA.Bisectrix(curr, next, out dv2.xb2, out dv2.yb2); break; } } }
void Draw(ref DrawVarsPart0 dv, ref DrawVarsPart1 dv1, ref DrawVarsPart2 dv2, ref LineParameters curr, ref LineParameters next, int start, int end) { int i; for (i = start; i < end; i++) { if (m_line_join == OutlineJoin.Round) { dv2.xb1 = curr.x1 + (curr.y2 - curr.y1); dv2.yb1 = curr.y1 - (curr.x2 - curr.x1); dv2.xb2 = curr.x2 + (curr.y2 - curr.y1); dv2.yb2 = curr.y2 - (curr.x2 - curr.x1); } switch (dv.flags) { case 0: m_ren.Line3(curr, dv2.xb1, dv2.yb1, dv2.xb2, dv2.yb2); break; case 1: m_ren.Line2(curr, dv2.xb2, dv2.yb2); break; case 2: m_ren.Line1(curr, dv2.xb1, dv2.yb1); break; case 3: m_ren.Line0(curr); break; } if (m_line_join == OutlineJoin.Round && (dv.flags & 2) == 0) { m_ren.Pie(curr.x2, curr.y2, curr.x2 + (curr.y2 - curr.y1), curr.y2 - (curr.x2 - curr.x1), curr.x2 + (next.y2 - next.y1), curr.y2 - (next.x2 - next.x1)); } dv1.x1 = dv1.x2; dv1.y1 = dv1.y2; dv.lcurr = dv.lnext; dv.lnext = m_src_vertices[dv.idx].len; ++dv.idx; if (dv.idx >= m_src_vertices.Count) dv.idx = 0; dv1.x2 = m_src_vertices[dv.idx].x; dv1.y2 = m_src_vertices[dv.idx].y; curr = next; next = new LineParameters(dv1.x1, dv1.y1, dv1.x2, dv1.y2, dv.lnext); dv2.xb1 = dv2.xb2; dv2.yb1 = dv2.yb2; switch (m_line_join) { case OutlineJoin.NoJoin: dv.flags = 3; break; case OutlineJoin.Mitter: dv.flags >>= 1; dv.flags |= (curr.DiagonalQuadrant == next.DiagonalQuadrant ? 1 : 0); if ((dv.flags & 2) == 0) { LineAA.Bisectrix(curr, next, out dv2.xb2, out dv2.yb2); } break; case OutlineJoin.Round: dv.flags >>= 1; dv.flags |= (((curr.DiagonalQuadrant == next.DiagonalQuadrant) ? 1 : 0) << 1); break; case OutlineJoin.AccurateJoin: dv.flags = 0; LineAA.Bisectrix(curr, next, out dv2.xb2, out dv2.yb2); break; } } }