snapToIntersection method
Implementation
@override
Point<num> snapToIntersection(Point<num> worldPos) {
final worldPosD = worldPos.cast<double>();
final tile = worldToTile(worldPos);
final center = tileCenterInWorld(tile);
final vector = worldPosD - center;
var angle = atan2(vector.y, vector.x) + pi;
if (!horizontal) {
angle = pi * 15 / 6 - angle;
}
var angleFixed = (angle * 3 / pi).round() % 6;
var off = _fromShift(_angleToOffset(angleFixed));
var scaled = Point(off.x * tileWidth, off.y * tileHeight);
return center + scaled;
}