From 4d3e7f1605f9915c4a9d339242db92683b8f7bc6 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 16 Apr 2020 09:36:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`PieChart`=E5=9C=A8=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE`Space`=E5=8F=82=E6=95=B0=E5=90=8E=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E7=BB=98=E5=88=B6=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Utility/ChartDrawer.cs | 40 +++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/Runtime/Utility/ChartDrawer.cs b/Runtime/Utility/ChartDrawer.cs index 41d15bf2..406532a7 100644 --- a/Runtime/Utility/ChartDrawer.cs +++ b/Runtime/Utility/ChartDrawer.cs @@ -655,15 +655,22 @@ namespace XCharts realCenter += borderDiff * middleDire; borderAngle = 2 * Mathf.Asin(borderWidth / (2 * radius)); realStartAngle = realStartAngle + borderAngle; - var borderX1 = GetPos(p, radius, realStartAngle); - DrawPolygon(vh, realCenter, spaceCenter, p2, borderX1, borderColor); - p2 = borderX1; - realToAngle = realToAngle - borderAngle; - if (realToAngle < realStartAngle) realToAngle = realStartAngle; - var borderX2 = GetPos(p, radius, realToAngle); - var pEnd = GetPos(p, radius, toAngle - spaceAngle); - DrawPolygon(vh, realCenter, borderX2, pEnd, spaceCenter, borderColor); + if (realToAngle < realStartAngle) + { + realToAngle = realStartAngle; + p2 = GetPos(p, radius, realStartAngle); + } + else + { + var borderX1 = GetPos(p, radius, realStartAngle); + DrawPolygon(vh, realCenter, spaceCenter, p2, borderX1, borderColor); + p2 = borderX1; + + var borderX2 = GetPos(p, radius, realToAngle); + var pEnd = GetPos(p, radius, toAngle - spaceAngle); + DrawPolygon(vh, realCenter, borderX2, pEnd, spaceCenter, borderColor); + } } } float segmentAngle = (realToAngle - realStartAngle) / segments; @@ -676,14 +683,17 @@ namespace XCharts } if (needBorder || needSpace) { - var borderX2 = p + radius * GetDire(realToAngle); - DrawTriangle(vh, realCenter, p2, borderX2, toColor, color, color); - if (needBorder) + if (realToAngle > realStartAngle) { - var realStartDegree = (realStartAngle - borderAngle) * Mathf.Rad2Deg; - var realToDegree = (realToAngle + borderAngle) * Mathf.Rad2Deg; - DrawDoughnut(vh, p, radius, radius + borderWidth, borderColor, Color.clear, realStartDegree, - realToDegree, smoothness); + var borderX2 = p + radius * GetDire(realToAngle); + DrawTriangle(vh, realCenter, p2, borderX2, toColor, color, color); + if (needBorder) + { + var realStartDegree = (realStartAngle - borderAngle) * Mathf.Rad2Deg; + var realToDegree = (realToAngle + borderAngle) * Mathf.Rad2Deg; + DrawDoughnut(vh, p, radius, radius + borderWidth, borderColor, Color.clear, realStartDegree, + realToDegree, smoothness); + } } } }