mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-28 12:08:46 +00:00
[optimize] optimize smooth curve
This commit is contained in:
@@ -69,6 +69,7 @@
|
|||||||
|
|
||||||
### 日志详情
|
### 日志详情
|
||||||
|
|
||||||
|
* (2022.08.15) 优化`Smooth`贝塞尔曲线算法
|
||||||
* (2022.08.13) 修复`DataZoom`组件开启时图表显示效果可能不正确的问题
|
* (2022.08.13) 修复`DataZoom`组件开启时图表显示效果可能不正确的问题
|
||||||
* (2022.08.11) 优化`Tooltip`支持`ignoreDataDefaultContent`
|
* (2022.08.11) 优化`Tooltip`支持`ignoreDataDefaultContent`
|
||||||
* (2022.08.10) 修复`Chart`在3D相机下部分组件显示异常的问题
|
* (2022.08.10) 修复`Chart`在3D相机下部分组件显示异常的问题
|
||||||
|
|||||||
@@ -1823,7 +1823,7 @@ namespace XUGL
|
|||||||
if (dire == Direction.YAxis)
|
if (dire == Direction.YAxis)
|
||||||
UGLHelper.GetBezierListVertical(ref s_CurvesPosList, sp, ep, smoothness2, smoothStyle);
|
UGLHelper.GetBezierListVertical(ref s_CurvesPosList, sp, ep, smoothness2, smoothStyle);
|
||||||
else
|
else
|
||||||
UGLHelper.GetBezierList(ref s_CurvesPosList, sp, ep, lsp, nep, smoothness2, smoothStyle);
|
UGLHelper.GetBezierList(ref s_CurvesPosList, sp, ep, lsp, nep, smoothness2, smoothStyle, false, dire == Direction.Random);
|
||||||
|
|
||||||
DrawCurvesInternal(vh, s_CurvesPosList, width, color, dire, currProgress);
|
DrawCurvesInternal(vh, s_CurvesPosList, width, color, dire, currProgress);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,23 +108,21 @@ namespace XUGL
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void GetBezierList(ref List<Vector3> posList, Vector3 sp, Vector3 ep,
|
public static void GetBezierList(ref List<Vector3> posList, Vector3 sp, Vector3 ep,
|
||||||
Vector3 lsp, Vector3 nep, float smoothness = 2f, float k = 2.0f, bool limit = false)
|
Vector3 lsp, Vector3 nep, float smoothness = 2f, float k = 2.0f, bool limit = false, bool randomDire = false)
|
||||||
{
|
{
|
||||||
var dist = Vector3.Distance(sp, ep);
|
|
||||||
Vector3 cp1, cp2;
|
Vector3 cp1, cp2;
|
||||||
|
var dist = Vector3.Distance(sp, ep);
|
||||||
var dir = (ep - sp).normalized;
|
var dir = (ep - sp).normalized;
|
||||||
var diff = dist / k;
|
var diff = (randomDire ? dist : Mathf.Abs(sp.x - ep.x)) / k;
|
||||||
if (lsp == sp)
|
if (lsp == sp)
|
||||||
{
|
{
|
||||||
cp1 = sp + (nep - ep).normalized * diff;
|
cp1 = sp + (nep - ep).normalized * diff;
|
||||||
if (limit)
|
if (limit) cp1.y = sp.y;
|
||||||
cp1.y = sp.y;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cp1 = sp + (ep - lsp).normalized * diff;
|
cp1 = sp + (ep - lsp).normalized * diff;
|
||||||
if (limit)
|
if (limit) cp1.y = sp.y;
|
||||||
cp1.y = sp.y;
|
|
||||||
}
|
}
|
||||||
if (nep == ep)
|
if (nep == ep)
|
||||||
{
|
{
|
||||||
@@ -133,8 +131,7 @@ namespace XUGL
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
cp2 = ep - (nep - sp).normalized * diff;
|
cp2 = ep - (nep - sp).normalized * diff;
|
||||||
if (limit)
|
if (limit) cp2.y = ep.y;
|
||||||
cp2.y = ep.y;
|
|
||||||
}
|
}
|
||||||
int segment = (int) (dist / (smoothness <= 0 ? 2f : smoothness));
|
int segment = (int) (dist / (smoothness <= 0 ? 2f : smoothness));
|
||||||
if (segment < 1) segment = (int) (dist / 0.5f);
|
if (segment < 1) segment = (int) (dist / 0.5f);
|
||||||
|
|||||||
Reference in New Issue
Block a user