Graphs_dart/tex/dart/painter/pos.dart

24 lines
709 B
Dart
Raw Permalink Normal View History

2021-11-24 20:35:55 +03:00
Map<int, Offset> _getDotPos(int dotsAm, Size size) {
Map<int, Offset> off = <int, Offset>{};
var width = size.width / 2;
var height = size.height / 2;
int add = 0;
int h = _getHighInputConnections();
for (int i = 0; i < dotsAm; i++) {
if ((i + 1) != h) {
double x =
cos(2 * pi * (i - add) / (dotsAm - add)) * _circleRad + width;
double y =
sin(2 * pi * (i - add) / (dotsAm - add)) * _circleRad + height;
off[i + 1] = Offset(x, y);
} else if ((i + 1) == h) {
off[i + 1] = Offset(width + 2, height - 2);
add = 1;
h = 0;
} else {
print("GetDotPos error");
}
}
return off;
}