isCrossLine method

bool isCrossLine(
  1. List<LetterOffset> offsets
)

check if the drawn line on a 45 degree angled track

Implementation

bool isCrossLine(List<LetterOffset> offsets) {
  if (offsets.isEmpty) {
    return false;
  } else if (offsets.first == offsets.last) {
    return false;
  }

  for (int x = 0; x < offsets.length; x++) {
    if (x > 0) {
      int a = offsets[x].getSmallerOffset.dx.toInt() -
          offsets[x - 1].getSmallerOffset.dx.toInt();
      int b = offsets[x].getSmallerOffset.dy.toInt() -
          offsets[x - 1].getSmallerOffset.dy.toInt();

      if (a.abs() - b.abs() != 0) {
        return false;
      }
    }
  }

  return true;
}