public void join_path(PathStorage vs, int path_id) { double x, y; vs.rewind(path_id); ShapePath.FlagsAndCommand PathAndFlags = vs.vertex(out x, out y); if (!ShapePath.is_stop(PathAndFlags)) { if (ShapePath.is_vertex(PathAndFlags)) { double x0, y0; ShapePath.FlagsAndCommand PathAndFlags0 = last_vertex(out x0, out y0); if (ShapePath.is_vertex(PathAndFlags0)) { if (agg_math.calc_distance(x, y, x0, y0) > agg_math.vertex_dist_epsilon) { if (ShapePath.is_move_to(PathAndFlags)) { PathAndFlags = ShapePath.FlagsAndCommand.CommandLineTo; } vertices.AddVertex(x, y, PathAndFlags); } } else { if (ShapePath.is_stop(PathAndFlags0)) { PathAndFlags = ShapePath.FlagsAndCommand.CommandMoveTo; } else { if (ShapePath.is_move_to(PathAndFlags)) { PathAndFlags = ShapePath.FlagsAndCommand.CommandLineTo; } } vertices.AddVertex(x, y, PathAndFlags); } } while (!ShapePath.is_stop(PathAndFlags = vs.vertex(out x, out y))) { vertices.AddVertex(x, y, ShapePath.is_move_to(PathAndFlags) ? ShapePath.FlagsAndCommand.CommandLineTo : PathAndFlags); } } }
public static bool get_bounding_rect(PathStorage vs, int[] gi, int start, int num, out double x1, out double y1, out double x2, out double y2) { int i; double x = 0; double y = 0; bool first = true; x1 = 1; y1 = 1; x2 = 0; y2 = 0; for (i = 0; i < num; i++) { vs.rewind(gi[start + i]); ShapePath.FlagsAndCommand PathAndFlags; while (!ShapePath.is_stop(PathAndFlags = vs.vertex(out x, out y))) { if (ShapePath.is_vertex(PathAndFlags)) { if (first) { x1 = x; y1 = y; x2 = x; y2 = y; first = false; } else { if (x < x1) x1 = x; if (y < y1) y1 = y; if (x > x2) x2 = x; if (y > y2) y2 = y; } } } } return x1 <= x2 && y1 <= y2; }
public void join_path(PathStorage vs, int path_id) { double x, y; vs.rewind(path_id); ShapePath.FlagsAndCommand PathAndFlags = vs.vertex(out x, out y); if (!ShapePath.is_stop(PathAndFlags)) { if (ShapePath.is_vertex(PathAndFlags)) { double x0, y0; ShapePath.FlagsAndCommand PathAndFlags0 = last_vertex(out x0, out y0); if (ShapePath.is_vertex(PathAndFlags0)) { if(agg_math.calc_distance(x, y, x0, y0) > agg_math.vertex_dist_epsilon) { if (ShapePath.is_move_to(PathAndFlags)) PathAndFlags = ShapePath.FlagsAndCommand.CommandLineTo; vertices.AddVertex(x, y, PathAndFlags); } } else { if (ShapePath.is_stop(PathAndFlags0)) { PathAndFlags = ShapePath.FlagsAndCommand.CommandMoveTo; } else { if (ShapePath.is_move_to(PathAndFlags)) PathAndFlags = ShapePath.FlagsAndCommand.CommandLineTo; } vertices.AddVertex(x, y, PathAndFlags); } } while (!ShapePath.is_stop(PathAndFlags = vs.vertex(out x, out y))) { vertices.AddVertex(x, y, ShapePath.is_move_to(PathAndFlags) ? ShapePath.FlagsAndCommand.CommandLineTo : PathAndFlags); } } }