// import 'dart:math' as math;

import 'package:fis_measure/interfaces/date_types/int_size.dart';

class IntPoint {
  static final zero = IntPoint(0, 0);

  int _x = 0;
  int _y = 0;

  // ignore: unnecessary_getters_setters
  int get x => _x;
  set x(int value) => _x = value;

  // ignore: unnecessary_getters_setters
  int get y => _y;
  set y(int value) => _y = value;

  IntPoint(num x, num y) {
    _x = x.round();
    _y = y.round();
  }

  factory IntPoint.size(IntSize size) {
    return IntPoint(size.width, size.height);
  }

  factory IntPoint.dw(int dw) {
    return IntPoint(LOWORD(dw), HIWORD(dw));
  }

  void addOffset(int dx, int dy) {
    x += dx;
    y += dy;
  }

  // ignore: non_constant_identifier_names
  static int HIWORD(int n) {
    return ((n >> 0x10) & 0xffff);
  }

// ignore: non_constant_identifier_names
  static int LOWORD(int n) {
    return (n & 0xffff);
  }

  @override
  bool operator ==(Object other) {
    return other is IntPoint && x == other.x && y == other.y;
  }

  @override
  int get hashCode => x ^ y;

  @override
  String toString() => '$x,$y';
}
