pixelToHex method

HexCoordinate pixelToHex(
  1. Offset point
)

将像素坐标转换为六边形坐标

Implementation

HexCoordinate pixelToHex(Offset point) {
  final m = orientation;
  final pt = Offset(
    (point.dx - origin.dx) / size,
    (point.dy - origin.dy) / size,
  );
  final x = m.b0 * pt.dx + m.b1 * pt.dy;
  final z = m.b2 * pt.dx + m.b3 * pt.dy;
  final y = -x - z;
  return _hexRound(x, y, z);
}