TornEdges changes

This commit is contained in:
Jaex 2017-05-15 10:47:26 +03:00
parent f2a3b80d60
commit cb840b932a

View file

@ -1295,16 +1295,13 @@ public static Image TornEdges(Image img, int tornDepth, int tornRange, AnchorSty
List<Point> points = new List<Point>();
Point previousPoint, currentPoint;
Point previousPoint = Point.Empty, currentPoint;
int horizontalTornCount = img.Width / tornRange;
int verticalTornCount = img.Height / tornRange;
if (sides.HasFlag(AnchorStyles.Top))
{
previousPoint = new Point(tornRange, MathHelpers.Random(0, tornDepth));
points.Add(previousPoint);
for (int i = 0; i < horizontalTornCount - 1; i++)
for (int i = 0; i < horizontalTornCount; i++)
{
currentPoint = new Point(previousPoint.X + tornRange, MathHelpers.Random(0, tornDepth));
points.Add(currentPoint);
@ -1313,7 +1310,6 @@ public static Image TornEdges(Image img, int tornDepth, int tornRange, AnchorSty
}
else
{
previousPoint = new Point(0, 0);
points.Add(previousPoint);
currentPoint = new Point(img.Width - 1, 0);
points.Add(currentPoint);
@ -1331,6 +1327,8 @@ public static Image TornEdges(Image img, int tornDepth, int tornRange, AnchorSty
}
else
{
currentPoint = new Point(img.Width - 1, 0);
points.Add(currentPoint);
currentPoint = new Point(img.Width - 1, img.Height - 1);
points.Add(currentPoint);
previousPoint = currentPoint;
@ -1347,6 +1345,8 @@ public static Image TornEdges(Image img, int tornDepth, int tornRange, AnchorSty
}
else
{
currentPoint = new Point(img.Width - 1, img.Height - 1);
points.Add(currentPoint);
currentPoint = new Point(0, img.Height - 1);
points.Add(currentPoint);
previousPoint = currentPoint;
@ -1363,6 +1363,8 @@ public static Image TornEdges(Image img, int tornDepth, int tornRange, AnchorSty
}
else
{
currentPoint = new Point(0, img.Height - 1);
points.Add(currentPoint);
currentPoint = new Point(0, 0);
points.Add(currentPoint);
previousPoint = currentPoint;