/// <summary> /// Initialize bresenhame path structure for shape moving /// </summary> private void InitPath() { int middleX = Math.Abs(shape1.X + shape2.X) / 2; int middleY = Math.Abs(shape1.Y + shape2.Y) / 2; Point middle = new Point(middleX, middleY); path1 = new BresenhamApproximation(shape1.X, shape1.Y, middle.x, middle.y).GetEnumerator(); path2 = new BresenhamApproximation(shape2.X, shape2.Y, middle.x, middle.y).GetEnumerator(); }
/// <summary> /// Draw doted line on render with context cordinate /// </summary> /// <param name="x1">First point X position</param> /// <param name="y1">First point Y position</param> /// <param name="x2">Second point X position</param> /// <param name="y2">Second point Y position</param> public void DrawDotedLine(int x1, int y1, int x2, int y2, int lineSegmentLength = 2) { int length = lineSegmentLength; bool draw = true; var approximation = new BresenhamApproximation(x1, y1, x2, y2); foreach (var p in approximation) { if (length == 0) { draw = !draw; length = lineSegmentLength; } if (draw) { DrawPoint(p); } length--; } }