本文整理汇总了C#中Path.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# Path.RemoveAt方法的具体用法?C# Path.RemoveAt怎么用?C# Path.RemoveAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path.RemoveAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CleanPolygon
//------------------------------------------------------------------------------
public static Path CleanPolygon(Path path,
double distance = 1.415)
{
//distance = proximity in units/pixels below which vertices
//will be stripped. Default ~= sqrt(2) so when adjacent
//vertices have both x & y coords within 1 unit, then
//the second vertex will be stripped.
double distSqrd = (distance * distance);
int highI = path.Count -1;
Path result = new Path(highI + 1);
while (highI > 0 && PointsAreClose(path[highI], path[0], distSqrd)) highI--;
if (highI < 2) return result;
IntPoint pt = path[highI];
int i = 0;
for (;;)
{
while (i < highI && PointsAreClose(pt, path[i], distSqrd)) i+=2;
int i2 = i;
while (i < highI && (PointsAreClose(path[i], path[i + 1], distSqrd) ||
SlopesNearCollinear(pt, path[i], path[i + 1], distSqrd))) i++;
if (i >= highI) break;
else if (i != i2) continue;
pt = path[i++];
result.Add(pt);
}
if (i <= highI) result.Add(path[i]);
i = result.Count;
if (i > 2 && SlopesNearCollinear(result[i - 2], result[i - 1], result[0], distSqrd))
result.RemoveAt(i -1);
if (result.Count < 3) result.Clear();
return result;
}
示例2: StripDupsAndGetBotPt
//------------------------------------------------------------------------------
internal static bool StripDupsAndGetBotPt(Path in_path,
Path out_path, bool closed, out IntPoint botPt)
{
botPt = new IntPoint(0, 0);
int len = in_path.Count;
if (closed)
while (len > 0 && (in_path[0] == in_path[len -1])) len--;
if (len == 0) return false;
out_path.Capacity = len;
int j = 0;
out_path.Add(in_path[0]);
botPt = in_path[0];
for (int i = 1; i < len; ++i)
if (in_path[i] != out_path[j])
{
out_path.Add(in_path[i]);
j++;
if (out_path[j].Y > botPt.Y ||
((out_path[j].Y == botPt.Y) && out_path[j].X < botPt.X))
botPt = out_path[j];
}
j++;
if (j < 2 || (closed && (j == 2))) j = 0;
while (out_path.Count > j) out_path.RemoveAt(j);
return j > 0;
}