position.dart 585 B

123456789101112131415161718192021222324252627
  1. class Position {
  2. const Position(this.x, this.y);
  3. final int x;
  4. final int y;
  5. bool isBefore(Position another) {
  6. return another.y > y || (another.y == y && another.x > x);
  7. }
  8. bool isAfter(Position another) {
  9. return another.y < y || (another.y == y && another.x < x);
  10. }
  11. bool isBeforeOrSame(Position another) {
  12. return another.y > y || (another.y == y && another.x >= x);
  13. }
  14. bool isAfterOrSame(Position another) {
  15. return another.y < y || (another.y == y && another.x <= x);
  16. }
  17. @override
  18. String toString() {
  19. return 'MouseOffset($x, $y)';
  20. }
  21. }