9/13/1
This commit is contained in:
36
lib/views/home/map_widget.dart/hexegone_clipper.dart
Normal file
36
lib/views/home/map_widget.dart/hexegone_clipper.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class HexagonClipper extends CustomClipper<Path> {
|
||||
@override
|
||||
Path getClip(Size size) {
|
||||
final path = Path();
|
||||
final height = size.height;
|
||||
final width = size.width;
|
||||
final centerX = width / 2;
|
||||
final centerY = height / 2;
|
||||
final radius = width / 2;
|
||||
|
||||
const angle = 2 * pi / 10; // Angle between each side of the hexagon
|
||||
|
||||
// Start at the top right vertex of the hexagon
|
||||
final startX = centerX + radius * cos(0);
|
||||
final startY = centerY + radius * sin(0);
|
||||
path.moveTo(startX, startY);
|
||||
|
||||
// Draw the remaining sides of the hexagon
|
||||
for (int i = 1; i < 10; i++) {
|
||||
final x = centerX + radius * cos(angle * i);
|
||||
final y = centerY + radius * sin(angle * i);
|
||||
path.lineTo(x, y);
|
||||
}
|
||||
|
||||
path.close();
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldReclip(HexagonClipper oldClipper) => false;
|
||||
}
|
||||
Reference in New Issue
Block a user