public void CalcAngels() { int x, y; int length = 0; _rootX = _rootY = -1; _allTokens = new List <LeafToken>(); for (y = 0; y < _height; y++) { for (x = 0; x < _width; x++) { if (GetPixel(x, y) == COLOR_POINT_MARK) { SearchNeighbour(x, y, true); } } } for (int i = 0; i < _allTokens.Count; i++) { LeafToken actToken = (LeafToken)_allTokens[i]; DrawSquare(actToken.X1, actToken.Y1, 5, COLOR_BADLINE); } }
private void SearchNeighbour(int x, int y, bool isRoot) { if (GetPixel(x, y) == COLOR_POINT_MARK) { if (isRoot == true) { _rootX = x; _rootY = y; } else if (isRoot == false && _rootX != -1 && _rootY != -1) { if ((_rootX + _rootY) - (x + y) == 0) { return; } DrawLine(_rootX, _rootY, x, y, COLOR_SKELETON); LeafToken ltoken = new LeafToken(_rootX, _rootY, x, y); _allTokens.Add(ltoken); SetPixel(_rootX, _rootY, COLOR_POINT_MARK); SetPixel(x, y, COLOR_POINT_MARK); return; } } else { SetPixel(x, y, COLOR_GOODLINE); } try { if (_pixels[Neighbour(x, y, 0)] == COLOR_POINT_DONE || _pixels[Neighbour(x, y, 0)] == COLOR_POINT_MARK) { SearchNeighbour(x + 1, y, false); } if (_pixels[Neighbour(x, y, 1)] == COLOR_POINT_DONE || _pixels[Neighbour(x, y, 1)] == COLOR_POINT_MARK) { SearchNeighbour(x + 1, y - 1, false); } if (_pixels[Neighbour(x, y, 2)] == COLOR_POINT_DONE || _pixels[Neighbour(x, y, 2)] == COLOR_POINT_MARK) { SearchNeighbour(x, y - 1, false); } if (_pixels[Neighbour(x, y, 3)] == COLOR_POINT_DONE || _pixels[Neighbour(x, y, 3)] == COLOR_POINT_MARK) { SearchNeighbour(x - 1, y - 1, false); } if (_pixels[Neighbour(x, y, 4)] == COLOR_POINT_DONE || _pixels[Neighbour(x, y, 4)] == COLOR_POINT_MARK) { SearchNeighbour(x - 1, y, false); } if (_pixels[Neighbour(x, y, 5)] == COLOR_POINT_DONE || _pixels[Neighbour(x, y, 5)] == COLOR_POINT_MARK) { SearchNeighbour(x - 1, y + 1, false); } if (_pixels[Neighbour(x, y, 6)] == COLOR_POINT_DONE || _pixels[Neighbour(x, y, 6)] == COLOR_POINT_MARK) { SearchNeighbour(x, y + 1, false); } if (_pixels[Neighbour(x, y, 7)] == COLOR_POINT_DONE || _pixels[Neighbour(x, y, 7)] == COLOR_POINT_MARK) { SearchNeighbour(x + 1, y + 1, false); } } catch (Exception e) { } if (isRoot == true) { SetPixel(x, y, COLOR_SKELETON); } }