mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-14 20:00:09 +00:00
[optimize][line]smooth line (#169)
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
|
||||
## master
|
||||
|
||||
* (2022.06.25) 优化`Line`的平滑曲线表现 (#169)
|
||||
* (2022.06.25) 修复`DataZoom`开启时`Tooltip`显示数据不一致的问题 (#203)
|
||||
* (2022.06.25) 修复`Toolip`在类目轴无数据时绘制异常的问题 (#204)
|
||||
* (2022.06.25) 优化`Serie`设置`PlaceHolder`时的`Tooltip`表现
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] protected Material m_SeriePainterMaterial;
|
||||
[SerializeField] protected Material m_UpperPainterMaterial;
|
||||
[SerializeField] protected Material m_TopPainterMaterial;
|
||||
[SerializeField][Range(1, 10)] protected float m_LineSmoothStyle = 3f;
|
||||
[SerializeField][Range(1, 10)] protected float m_LineSmoothStyle = 2.5f;
|
||||
[SerializeField][Range(1f, 20)] protected float m_LineSmoothness = 2f;
|
||||
[SerializeField][Range(0.5f, 20)] protected float m_LineSegmentDistance = 3f;
|
||||
[SerializeField][Range(1, 10)] protected float m_CicleSmoothness = 2f;
|
||||
|
||||
@@ -496,7 +496,7 @@ namespace XCharts.Runtime
|
||||
if (isY)
|
||||
UGLHelper.GetBezierListVertical(ref s_CurvesPosList, sp, ep, smoothness, setting.lineSmoothStyle);
|
||||
else
|
||||
UGLHelper.GetBezierList(ref s_CurvesPosList, sp, ep, lsp, nep, smoothness, setting.lineSmoothStyle);
|
||||
UGLHelper.GetBezierList(ref s_CurvesPosList, sp, ep, lsp, nep, smoothness, setting.lineSmoothStyle, true);
|
||||
|
||||
for (int j = 1; j < s_CurvesPosList.Count; j++)
|
||||
{
|
||||
|
||||
@@ -59,8 +59,7 @@ namespace XUGL
|
||||
|
||||
for (int i = 0; i < list1.Count; i++)
|
||||
{
|
||||
if (list1[i] == null && list2[i] == null)
|
||||
{ }
|
||||
if (list1[i] == null && list2[i] == null) { }
|
||||
else
|
||||
{
|
||||
if (list1[i] != null)
|
||||
@@ -109,7 +108,7 @@ namespace XUGL
|
||||
}
|
||||
|
||||
public static void GetBezierList(ref List<Vector3> posList, Vector3 sp, Vector3 ep,
|
||||
Vector3 lsp, Vector3 nep, float smoothness = 2f, float k = 2.0f)
|
||||
Vector3 lsp, Vector3 nep, float smoothness = 2f, float k = 2.0f, bool limit = false)
|
||||
{
|
||||
float dist = Mathf.Abs(sp.x - ep.x);
|
||||
Vector3 cp1, cp2;
|
||||
@@ -124,9 +123,20 @@ namespace XUGL
|
||||
else
|
||||
{
|
||||
cp1 = sp + (ep - lsp).normalized * diff;
|
||||
if (limit)
|
||||
cp1.y = sp.y;
|
||||
|
||||
}
|
||||
if (nep == ep)
|
||||
{
|
||||
cp2 = ep;
|
||||
}
|
||||
else
|
||||
{
|
||||
cp2 = ep - (nep - sp).normalized * diff;
|
||||
if (limit)
|
||||
cp2.y = ep.y;
|
||||
}
|
||||
if (nep == ep) cp2 = ep;
|
||||
else cp2 = ep - (nep - sp).normalized * diff;
|
||||
dist = Vector3.Distance(sp, ep);
|
||||
int segment = (int) (dist / (smoothness <= 0 ? 2f : smoothness));
|
||||
if (segment < 1) segment = (int) (dist / 0.5f);
|
||||
|
||||
Reference in New Issue
Block a user