public void AddVertex(double x, double y, ShapePath.FlagsAndCommand cmd) { m_status = StrokeMath.status_e.initial; if (ShapePath.is_move_to(cmd)) { m_src_vertices.modify_last(new VertexDistance(x, y)); } else { if (ShapePath.is_vertex(cmd)) { m_src_vertices.add(new VertexDistance(x, y)); } else { if (ShapePath.is_end_poly(cmd)) { m_closed = (ShapePath.get_close_flag(cmd) == ShapePath.FlagsAndCommand.FlagClose); if (m_orientation == ShapePath.FlagsAndCommand.FlagNone) { m_orientation = ShapePath.get_orientation(cmd); } } } } }
public StrokeGenerator() { m_stroker = new StrokeMath(); m_src_vertices = new VertexSequence(); m_out_vertices = new Vector2Container(); m_status = StrokeMath.status_e.initial; }
public ContourGenerator() { m_stroker = new StrokeMath(); m_width = 1; m_src_vertices = new VertexSequence(); m_out_vertices = new Vector2Container(); m_status = StrokeMath.status_e.initial; m_src_vertex = 0; m_closed = false; m_orientation = 0; m_auto_detect = false; }
// 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; }
public void AddVertex(double x, double y, ShapePath.FlagsAndCommand cmd) { m_status = StrokeMath.status_e.initial; if (ShapePath.is_move_to(cmd)) { m_src_vertices.modify_last(new VertexDistance(x, y)); } else { if (ShapePath.is_vertex(cmd)) { m_src_vertices.add(new VertexDistance(x, y)); } else { m_closed = (int)ShapePath.get_close_flag(cmd); } } }
// 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; }
public ShapePath.FlagsAndCommand Vertex(ref double x, ref double y) { ShapePath.FlagsAndCommand cmd = ShapePath.FlagsAndCommand.CommandLineTo; while (!ShapePath.is_stop(cmd)) { switch (m_status) { case StrokeMath.status_e.initial: Rewind(0); goto case StrokeMath.status_e.ready; case StrokeMath.status_e.ready: if (m_src_vertices.size() < 2 + (m_closed ? 1 : 0)) { cmd = ShapePath.FlagsAndCommand.CommandStop; break; } m_status = StrokeMath.status_e.outline1; cmd = ShapePath.FlagsAndCommand.CommandMoveTo; m_src_vertex = 0; m_out_vertex = 0; goto case StrokeMath.status_e.outline1; case StrokeMath.status_e.outline1: if (m_src_vertex >= m_src_vertices.size()) { m_status = StrokeMath.status_e.end_poly1; break; } m_stroker.calc_join(m_out_vertices, m_src_vertices.prev(m_src_vertex), m_src_vertices.curr(m_src_vertex), m_src_vertices.next(m_src_vertex), m_src_vertices.prev(m_src_vertex).dist, m_src_vertices.curr(m_src_vertex).dist); ++m_src_vertex; m_status = StrokeMath.status_e.out_vertices; m_out_vertex = 0; goto case StrokeMath.status_e.out_vertices; case StrokeMath.status_e.out_vertices: if (m_out_vertex >= m_out_vertices.size()) { m_status = StrokeMath.status_e.outline1; } else { Vector2 c = m_out_vertices[m_out_vertex++]; x = c.x; y = c.y; return cmd; } break; case StrokeMath.status_e.end_poly1: if (!m_closed) return ShapePath.FlagsAndCommand.CommandStop; m_status = StrokeMath.status_e.stop; return ShapePath.FlagsAndCommand.CommandEndPoly | ShapePath.FlagsAndCommand.FlagClose | ShapePath.FlagsAndCommand.FlagCCW; case StrokeMath.status_e.stop: return ShapePath.FlagsAndCommand.CommandStop; } } return cmd; }
// Generator interface public void RemoveAll() { m_src_vertices.remove_all(); m_closed = false; m_status = StrokeMath.status_e.initial; }
public ShapePath.FlagsAndCommand Vertex(ref double x, ref double y) { ShapePath.FlagsAndCommand cmd = ShapePath.FlagsAndCommand.CommandLineTo; while (!ShapePath.is_stop(cmd)) { switch (m_status) { case StrokeMath.status_e.initial: Rewind(0); goto case StrokeMath.status_e.ready; case StrokeMath.status_e.ready: if (m_src_vertices.size() < 2 + (m_closed != 0 ? 1 : 0)) { cmd = ShapePath.FlagsAndCommand.CommandStop; break; } m_status = (m_closed != 0) ? StrokeMath.status_e.outline1 : StrokeMath.status_e.cap1; cmd = ShapePath.FlagsAndCommand.CommandMoveTo; m_src_vertex = 0; m_out_vertex = 0; break; case StrokeMath.status_e.cap1: m_stroker.calc_cap(m_out_vertices, m_src_vertices[0], m_src_vertices[1], m_src_vertices[0].dist); m_src_vertex = 1; m_prev_status = StrokeMath.status_e.outline1; m_status = StrokeMath.status_e.out_vertices; m_out_vertex = 0; break; case StrokeMath.status_e.cap2: m_stroker.calc_cap(m_out_vertices, m_src_vertices[m_src_vertices.size() - 1], m_src_vertices[m_src_vertices.size() - 2], m_src_vertices[m_src_vertices.size() - 2].dist); m_prev_status = StrokeMath.status_e.outline2; m_status = StrokeMath.status_e.out_vertices; m_out_vertex = 0; break; case StrokeMath.status_e.outline1: if (m_closed != 0) { if (m_src_vertex >= m_src_vertices.size()) { m_prev_status = StrokeMath.status_e.close_first; m_status = StrokeMath.status_e.end_poly1; break; } } else { if (m_src_vertex >= m_src_vertices.size() - 1) { m_status = StrokeMath.status_e.cap2; break; } } m_stroker.calc_join(m_out_vertices, m_src_vertices.prev(m_src_vertex), m_src_vertices.curr(m_src_vertex), m_src_vertices.next(m_src_vertex), m_src_vertices.prev(m_src_vertex).dist, m_src_vertices.curr(m_src_vertex).dist); ++m_src_vertex; m_prev_status = m_status; m_status = StrokeMath.status_e.out_vertices; m_out_vertex = 0; break; case StrokeMath.status_e.close_first: m_status = StrokeMath.status_e.outline2; cmd = ShapePath.FlagsAndCommand.CommandMoveTo; goto case StrokeMath.status_e.outline2; case StrokeMath.status_e.outline2: if (m_src_vertex <= (m_closed == 0 ? 1 : 0)) { m_status = StrokeMath.status_e.end_poly2; m_prev_status = StrokeMath.status_e.stop; break; } --m_src_vertex; m_stroker.calc_join(m_out_vertices, m_src_vertices.next(m_src_vertex), m_src_vertices.curr(m_src_vertex), m_src_vertices.prev(m_src_vertex), m_src_vertices.curr(m_src_vertex).dist, m_src_vertices.prev(m_src_vertex).dist); m_prev_status = m_status; m_status = StrokeMath.status_e.out_vertices; m_out_vertex = 0; break; case StrokeMath.status_e.out_vertices: if (m_out_vertex >= m_out_vertices.size()) { m_status = m_prev_status; } else { Vector2 c = m_out_vertices[(int)m_out_vertex++]; x = c.x; y = c.y; return(cmd); } break; case StrokeMath.status_e.end_poly1: m_status = m_prev_status; return(ShapePath.FlagsAndCommand.CommandEndPoly | ShapePath.FlagsAndCommand.FlagClose | ShapePath.FlagsAndCommand.FlagCCW); case StrokeMath.status_e.end_poly2: m_status = m_prev_status; return(ShapePath.FlagsAndCommand.CommandEndPoly | ShapePath.FlagsAndCommand.FlagClose | ShapePath.FlagsAndCommand.FlagCW); case StrokeMath.status_e.stop: cmd = ShapePath.FlagsAndCommand.CommandStop; break; } } return(cmd); }
// Vertex Generator Interface public void RemoveAll() { m_src_vertices.remove_all(); m_closed = 0; m_status = StrokeMath.status_e.initial; }
public ShapePath.FlagsAndCommand Vertex(ref double x, ref double y) { ShapePath.FlagsAndCommand cmd = ShapePath.FlagsAndCommand.LineTo; while (!ShapePath.is_stop(cmd)) { switch (m_status) { case StrokeMath.status_e.initial: Rewind(0); goto case StrokeMath.status_e.ready; case StrokeMath.status_e.ready: if (m_src_vertices.size() < 2 + (m_closed ? 1 : 0)) { cmd = ShapePath.FlagsAndCommand.Stop; break; } m_status = StrokeMath.status_e.outline1; cmd = ShapePath.FlagsAndCommand.MoveTo; m_src_vertex = 0; m_out_vertex = 0; goto case StrokeMath.status_e.outline1; case StrokeMath.status_e.outline1: if (m_src_vertex >= m_src_vertices.size()) { m_status = StrokeMath.status_e.end_poly1; break; } m_stroker.calc_join(m_out_vertices, m_src_vertices.prev(m_src_vertex), m_src_vertices.curr(m_src_vertex), m_src_vertices.next(m_src_vertex), m_src_vertices.prev(m_src_vertex).dist, m_src_vertices.curr(m_src_vertex).dist); ++m_src_vertex; m_status = StrokeMath.status_e.out_vertices; m_out_vertex = 0; goto case StrokeMath.status_e.out_vertices; case StrokeMath.status_e.out_vertices: if (m_out_vertex >= m_out_vertices.size()) { m_status = StrokeMath.status_e.outline1; } else { Vector2 c = m_out_vertices[m_out_vertex++]; x = c.X; y = c.Y; return(cmd); } break; case StrokeMath.status_e.end_poly1: if (!m_closed) { return(ShapePath.FlagsAndCommand.Stop); } m_status = StrokeMath.status_e.stop; return(ShapePath.FlagsAndCommand.EndPoly | ShapePath.FlagsAndCommand.FlagClose | ShapePath.FlagsAndCommand.FlagCCW); case StrokeMath.status_e.stop: return(ShapePath.FlagsAndCommand.Stop); } } return(cmd); }