From 89e7a09e648bf8cb01a8840ada47a3463d2b7abb Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 13 Jun 2024 23:04:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Edge=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Internal/Data/GraphData.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Runtime/Internal/Data/GraphData.cs b/Runtime/Internal/Data/GraphData.cs index b5fe2e9f..269f4ef8 100644 --- a/Runtime/Internal/Data/GraphData.cs +++ b/Runtime/Internal/Data/GraphData.cs @@ -484,7 +484,8 @@ namespace XCharts.Runtime public double value; public GraphData hostGraph; - public List points = new List(); + public List upPoints = new List(); + public List downPoints = new List(); public float width; public float distance; public bool highlight; @@ -496,5 +497,24 @@ namespace XCharts.Runtime this.node2 = node2; this.value = value; } + + public bool IsPointInEdge(Vector2 point) + { + if (upPoints.Count == 0 || downPoints.Count == 0) return false; + var lastCount = upPoints.Count - 1; + if (point.x < upPoints[0].x || point.x > upPoints[lastCount].x) return false; + if (point.y > upPoints[0].y && point.y > upPoints[lastCount].y) return false; + if (point.y < downPoints[0].y && point.y < downPoints[lastCount].y) return false; + + for (int i = 0; i < upPoints.Count - 1; i++) + { + var diff = point.x - upPoints[i].x; + if (diff <= 0) + { + return point.y < upPoints[i].y && point.y > downPoints[i].y; + } + } + return false; + } } } \ No newline at end of file