public SnappableLine CreateLine(Point start, Point end, int gridSize) { var line = new SnappableLine(start, end, gridSize); SnapLineEndIfItIsCloseToAnotherLine(line, start, end); _lines.Add(line); return(line); }
private void SnapLineEndIfItIsCloseToAnotherLine(SnappableLine line, Point start, Point end) { foreach (var existingLine in _lines) { var distance = existingLine.DistanceFrom(end); if (!IsCloseEnoughToSnap(distance)) { continue; } SnapLineEndToPoint(line, start, distance.ClosestPointInLine); return; } line.Move(start, end); }
private void SnapLineEndToPoint(SnappableLine line, Point start, Point snapPoint) { line.Move(start, snapPoint, false); }
public void MoveLine(SnappableLine line, Point start, Point end) { SnapLineEndIfItIsCloseToAnotherLine(line, start, end); }