From f82cdf08143671c88a8486d4aad9d057da26231a Mon Sep 17 00:00:00 2001 From: lnd212 Date: Sat, 6 Nov 2021 02:41:59 +0400 Subject: [PATCH] reverted position balancing --- flutter/lib/curve_painter.dart | 37 ++++++++++++++++------------------ 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/flutter/lib/curve_painter.dart b/flutter/lib/curve_painter.dart index ffcda88..42365e6 100644 --- a/flutter/lib/curve_painter.dart +++ b/flutter/lib/curve_painter.dart @@ -86,8 +86,7 @@ class CurvePainter extends CustomPainter { return higest; } - Map getDotPos(int dotsAm, Size size, int exclude) { - dotsAm--; + Map getDotPos(int dotsAm, Size size, [int? exclude]) { Map off = {}; var width = size.width / 2; var height = size.height / 2; @@ -96,7 +95,6 @@ class CurvePainter extends CustomPainter { double x = cos(2 * pi * i / dotsAm) * circleRad + width; double y = sin(2 * pi * i / dotsAm) * circleRad + height; - if (i == exclude - 1) add++; off[i + add] = Offset(x, y); } @@ -125,7 +123,7 @@ class CurvePainter extends CustomPainter { path.relativeCubicTo(0, 0, -(from.dx + to.dx) / length - 40, -(from.dy + to.dy) / length - 40, to.dx - from.dx, to.dy - from.dy); path = - ArrowPath.make(path: path, isDoubleSided: doubleSided, tipLength: 13); + ArrowPath.make(path: path, isDoubleSided: doubleSided, tipLength: 16); canvas.drawPath(path, paint); } @@ -212,23 +210,22 @@ class CurvePainter extends CustomPainter { //Offset(size.width, size.height / 2)); //gr = getGraph(); - int higest = getHighConnections(); - if (higest > -1) { - var off = getDotPos(gr.getDotAmount(), size, higest); - off[higest] = Offset(size.width / 2, size.height / 2); - for (int i in off.keys) { - drawDot(canvas, off[i]!); - drawDotNames( - canvas, off[i]!, "${gr.getDots()[i - 1].getName()}:[${i}]"); - } - //var g = gr.getNoRepeatDots(); - //print(g); - var g = gr.getDots(); - drawConnections(canvas, size, g, off); - //pringArr(canvas, size); - //drawArrow(canvas, Offset(size.width / 2, size.height / 2), - // Offset(size.width / 2 + 50, size.height / 2 + 200)); + //int higest = getHighConnections(); + //if (higest > -1) { + var off = getDotPos(gr.getDotAmount(), size); //, higest); + //off[higest] = Offset(size.width / 2, size.height / 2); + for (int i in off.keys) { + drawDot(canvas, off[i]!); + drawDotNames(canvas, off[i]!, "${gr.getDots()[i - 1].getName()}:[${i}]"); } + //var g = gr.getNoRepeatDots(); + //print(g); + var g = gr.getDots(); + drawConnections(canvas, size, g, off); + //pringArr(canvas, size); + //drawArrow(canvas, Offset(size.width / 2, size.height / 2), + // Offset(size.width / 2 + 50, size.height / 2 + 200)); + //} } @override