// Vertex Source Interface public void Rewind(int idx) { if (m_status == StrokeMath.status_e.initial) { m_src_vertices.close(m_closed != 0); ShapePath.shorten_path(m_src_vertices, m_shorten, m_closed); if (m_src_vertices.size() < 3) { m_closed = 0; } } m_status = StrokeMath.status_e.ready; m_src_vertex = 0; m_out_vertex = 0; }
// Vertex Source Interface public void Rewind(int idx) { if (m_status == StrokeMath.status_e.initial) { m_src_vertices.close(true); if (m_auto_detect) { if (!ShapePath.is_oriented(m_orientation)) { m_orientation = (agg_math.calc_polygon_area(m_src_vertices) > 0.0) ? ShapePath.FlagsAndCommand.FlagCCW : ShapePath.FlagsAndCommand.FlagCW; } } if (ShapePath.is_oriented(m_orientation)) { m_stroker.width(ShapePath.is_ccw(m_orientation) ? m_width : -m_width); } } m_status = StrokeMath.status_e.ready; m_src_vertex = 0; }
static public void shorten_path(VertexSequence vs, double s, int closed) { if (s > 0.0 && vs.size() > 1) { double d; int n = (int)(vs.size() - 2); while (n != 0) { d = vs[n].dist; if (d > s) break; vs.RemoveLast(); s -= d; --n; } if (vs.size() < 2) { vs.remove_all(); } else { n = (int)vs.size() - 1; VertexDistance prev = vs[n - 1]; VertexDistance last = vs[n]; d = (prev.dist - s) / prev.dist; double x = prev.x + (last.x - prev.x) * d; double y = prev.y + (last.y - prev.y) * d; last.x = x; last.y = y; if (!prev.IsEqual(last)) vs.RemoveLast(); vs.close(closed != 0); } } }