getClip method
Returns a description of the clip given that the render object being clipped is of the given size.
Implementation
@override
Path getClip(Size size) {
final path = Path();
final center = Offset(size.width / 2, size.height / 2);
// 创建临时布局来计算顶点
final layout = orientation == HexOrientation.pointy
? HexLayout.pointy(size: hexSize, origin: center)
: HexLayout.flat(size: hexSize, origin: center);
// 获取六边形的顶点(中心坐标为 0,0,0)
final corners = layout.hexCorners(const HexCoordinate(0, 0, 0));
if (corners.isNotEmpty) {
path.moveTo(corners[0].dx, corners[0].dy);
for (var i = 1; i < corners.length; i++) {
path.lineTo(corners[i].dx, corners[i].dy);
}
path.close();
}
return path;
}