mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 10:20:10 +00:00
增加Symbol的EmptyTriangle和EmptyDiamond的支持,优化Symbol表现效果
This commit is contained in:
@@ -74,6 +74,7 @@ slug: /changelog
|
|||||||
|
|
||||||
日志详情:
|
日志详情:
|
||||||
|
|
||||||
|
* (2023.07.31) 增加`Symbol`的`EmptyTriangle`和`EmptyDiamond`的支持,优化`Symbol`表现效果
|
||||||
* (2023.07.31) 优化`Line`的默认配置效果
|
* (2023.07.31) 优化`Line`的默认配置效果
|
||||||
* (2023.07.27) 增加`Serie`的`minRadius`可设置最小半径
|
* (2023.07.27) 增加`Serie`的`minRadius`可设置最小半径
|
||||||
* (2023.07.26) 增加`MLValue`多样式数值
|
* (2023.07.26) 增加`MLValue`多样式数值
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace XCharts.Runtime
|
|||||||
[SerializeField] private bool m_Show = true;
|
[SerializeField] private bool m_Show = true;
|
||||||
[SerializeField] private LineType m_LineType = LineType.BrokenLine;
|
[SerializeField] private LineType m_LineType = LineType.BrokenLine;
|
||||||
[SerializeField] private Color32 m_LineColor = ChartConst.clearColor32;
|
[SerializeField] private Color32 m_LineColor = ChartConst.clearColor32;
|
||||||
[SerializeField] private float m_LineAngle = 0;
|
[SerializeField] private float m_LineAngle = 60;
|
||||||
[SerializeField] private float m_LineWidth = 1.0f;
|
[SerializeField] private float m_LineWidth = 1.0f;
|
||||||
[SerializeField] private float m_LineGap = 1.0f;
|
[SerializeField] private float m_LineGap = 1.0f;
|
||||||
[SerializeField] private float m_LineLength1 = 25f;
|
[SerializeField] private float m_LineLength1 = 25f;
|
||||||
@@ -44,7 +44,7 @@ namespace XCharts.Runtime
|
|||||||
m_Show = false;
|
m_Show = false;
|
||||||
m_LineType = LineType.BrokenLine;
|
m_LineType = LineType.BrokenLine;
|
||||||
m_LineColor = Color.clear;
|
m_LineColor = Color.clear;
|
||||||
m_LineAngle = 0;
|
m_LineAngle = 60;
|
||||||
m_LineWidth = 1.0f;
|
m_LineWidth = 1.0f;
|
||||||
m_LineGap = 1.0f;
|
m_LineGap = 1.0f;
|
||||||
m_LineLength1 = 25f;
|
m_LineLength1 = 25f;
|
||||||
|
|||||||
@@ -49,53 +49,92 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
if (tickness > 0)
|
if (tickness > 0)
|
||||||
{
|
{
|
||||||
UGL.DrawRoundRectangle(vh, pos, symbolSize, symbolSize, color, color, 0, cornerRadius, true);
|
UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true);
|
||||||
UGL.DrawBorder(vh, pos, symbolSize, symbolSize, tickness, borderColor, 0, cornerRadius);
|
UGL.DrawBorder(vh, pos, symbolSize, symbolSize, tickness, borderColor, 0, cornerRadius);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
UGL.DrawRoundRectangle(vh, pos, symbolSize, symbolSize, color, color, 0, cornerRadius, true);
|
UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SymbolType.EmptyRect:
|
case SymbolType.EmptyRect:
|
||||||
if (gap > 0)
|
if (gap > 0)
|
||||||
{
|
{
|
||||||
UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
|
UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
|
||||||
UGL.DrawBorder(vh, pos, symbolSize / 2, symbolSize / 2, tickness, color);
|
UGL.DrawBorder(vh, pos, symbolSize * 2, symbolSize * 2, tickness, color);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UGL.DrawBorder(vh, pos, symbolSize / 2, symbolSize / 2, tickness, color);
|
UGL.DrawBorder(vh, pos, symbolSize * 2 - tickness * 2, symbolSize * 2 - tickness * 2, tickness, color);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SymbolType.Triangle:
|
case SymbolType.Triangle:
|
||||||
|
case SymbolType.EmptyTriangle:
|
||||||
if (gap > 0)
|
if (gap > 0)
|
||||||
{
|
{
|
||||||
UGL.DrawTriangle(vh, pos, symbolSize + gap, backgroundColor);
|
UGL.DrawTriangle(vh, pos, symbolSize * 1.4f + gap * 2f, backgroundColor);
|
||||||
UGL.DrawTriangle(vh, pos, symbolSize, color, toColor);
|
UGL.DrawTriangle(vh, pos, symbolSize * 1.4f, color, toColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UGL.DrawTriangle(vh, pos, symbolSize, color, toColor);
|
UGL.DrawTriangle(vh, pos, symbolSize * 1.4f, color, toColor);
|
||||||
|
}
|
||||||
|
if (type == SymbolType.EmptyTriangle)
|
||||||
|
{
|
||||||
|
UGL.DrawTriangle(vh, pos, symbolSize * 1.4f - tickness * 2, backgroundColor);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SymbolType.Diamond:
|
case SymbolType.Diamond:
|
||||||
|
case SymbolType.EmptyDiamond:
|
||||||
|
var xRadius = symbolSize;
|
||||||
|
var yRadius = symbolSize * 1.5f;
|
||||||
if (gap > 0)
|
if (gap > 0)
|
||||||
{
|
{
|
||||||
UGL.DrawDiamond(vh, pos, symbolSize + gap, backgroundColor);
|
UGL.DrawDiamond(vh, pos, xRadius + gap, yRadius + gap, backgroundColor, backgroundColor);
|
||||||
UGL.DrawDiamond(vh, pos, symbolSize, color, toColor);
|
UGL.DrawDiamond(vh, pos, xRadius, yRadius, color, toColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UGL.DrawDiamond(vh, pos, symbolSize, color, toColor);
|
UGL.DrawDiamond(vh, pos, xRadius, yRadius, color, toColor);
|
||||||
|
}
|
||||||
|
if (type == SymbolType.EmptyDiamond)
|
||||||
|
{
|
||||||
|
UGL.DrawDiamond(vh, pos, xRadius - tickness, (symbolSize - tickness) * 1.5f, backgroundColor, backgroundColor);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SymbolType.Arrow:
|
case SymbolType.Arrow:
|
||||||
|
case SymbolType.EmptyArrow:
|
||||||
var arrowWidth = symbolSize * 2;
|
var arrowWidth = symbolSize * 2;
|
||||||
var arrowHeight = arrowWidth * 1.5f;
|
var arrowHeight = arrowWidth * 1.5f;
|
||||||
var arrowOffset = 0;
|
var arrowOffset = 0;
|
||||||
var arrowDent = arrowWidth / 3.3f;
|
var arrowDent = arrowWidth / 3.3f;
|
||||||
|
if (gap > 0)
|
||||||
|
{
|
||||||
|
arrowWidth = (symbolSize + gap) * 2;
|
||||||
|
arrowHeight = arrowWidth * 1.5f;
|
||||||
|
arrowOffset = 0;
|
||||||
|
arrowDent = arrowWidth / 3.3f;
|
||||||
|
var dir = (pos - startPos).normalized;
|
||||||
|
var sharpPos = pos + gap * dir;
|
||||||
|
UGL.DrawArrow(vh, startPos, sharpPos, arrowWidth, arrowHeight,
|
||||||
|
arrowOffset, arrowDent, backgroundColor);
|
||||||
|
}
|
||||||
|
arrowWidth = symbolSize * 2;
|
||||||
|
arrowHeight = arrowWidth * 1.5f;
|
||||||
|
arrowOffset = 0;
|
||||||
|
arrowDent = arrowWidth / 3.3f;
|
||||||
UGL.DrawArrow(vh, startPos, pos, arrowWidth, arrowHeight,
|
UGL.DrawArrow(vh, startPos, pos, arrowWidth, arrowHeight,
|
||||||
arrowOffset, arrowDent, color);
|
arrowOffset, arrowDent, color);
|
||||||
|
if (type == SymbolType.EmptyArrow)
|
||||||
|
{
|
||||||
|
arrowWidth = (symbolSize - tickness) * 2;
|
||||||
|
arrowHeight = arrowWidth * 1.5f;
|
||||||
|
arrowOffset = 0;
|
||||||
|
arrowDent = arrowWidth / 3.3f;
|
||||||
|
var dir = (pos - startPos).normalized;
|
||||||
|
var sharpPos = pos - tickness * dir;
|
||||||
|
UGL.DrawArrow(vh, startPos, sharpPos, arrowWidth, arrowHeight,
|
||||||
|
arrowOffset, arrowDent, backgroundColor);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -443,10 +443,15 @@ namespace XUGL
|
|||||||
/// <param name="toColor">渐变色2</param>
|
/// <param name="toColor">渐变色2</param>
|
||||||
public static void DrawDiamond(VertexHelper vh, Vector3 center, float size, Color32 color, Color32 toColor)
|
public static void DrawDiamond(VertexHelper vh, Vector3 center, float size, Color32 color, Color32 toColor)
|
||||||
{
|
{
|
||||||
var p1 = new Vector2(center.x - size, center.y);
|
DrawDiamond(vh, center, size, size, color, toColor);
|
||||||
var p2 = new Vector2(center.x, center.y + size);
|
}
|
||||||
var p3 = new Vector2(center.x + size, center.y);
|
|
||||||
var p4 = new Vector2(center.x, center.y - size);
|
public static void DrawDiamond(VertexHelper vh, Vector3 center, float xRadius, float yRadius, Color32 color, Color32 toColor)
|
||||||
|
{
|
||||||
|
var p1 = new Vector2(center.x - xRadius, center.y);
|
||||||
|
var p2 = new Vector2(center.x, center.y + yRadius);
|
||||||
|
var p3 = new Vector2(center.x + xRadius, center.y);
|
||||||
|
var p4 = new Vector2(center.x, center.y - yRadius);
|
||||||
DrawTriangle(vh, p4, p1, p2, color, color, toColor);
|
DrawTriangle(vh, p4, p1, p2, color, color, toColor);
|
||||||
DrawTriangle(vh, p3, p4, p2, color, color, toColor);
|
DrawTriangle(vh, p3, p4, p2, color, color, toColor);
|
||||||
}
|
}
|
||||||
@@ -1327,7 +1332,7 @@ namespace XUGL
|
|||||||
if (gap > 0 && isCircle) gap = 0;
|
if (gap > 0 && isCircle) gap = 0;
|
||||||
radius -= borderWidth;
|
radius -= borderWidth;
|
||||||
smoothness = (smoothness < 0 ? 2f : smoothness);
|
smoothness = (smoothness < 0 ? 2f : smoothness);
|
||||||
int segments = (int) ((2 * Mathf.PI * radius) * (Mathf.Abs(toDegree - startDegree) / 360) / smoothness);
|
int segments = (int)((2 * Mathf.PI * radius) * (Mathf.Abs(toDegree - startDegree) / 360) / smoothness);
|
||||||
if (segments < 1) segments = 1;
|
if (segments < 1) segments = 1;
|
||||||
float startAngle = startDegree * Mathf.Deg2Rad;
|
float startAngle = startDegree * Mathf.Deg2Rad;
|
||||||
float toAngle = toDegree * Mathf.Deg2Rad;
|
float toAngle = toDegree * Mathf.Deg2Rad;
|
||||||
@@ -1520,7 +1525,7 @@ namespace XUGL
|
|||||||
var needSpace = gap != 0;
|
var needSpace = gap != 0;
|
||||||
var diffAngle = Mathf.Abs(toDegree - startDegree) * Mathf.Deg2Rad;
|
var diffAngle = Mathf.Abs(toDegree - startDegree) * Mathf.Deg2Rad;
|
||||||
|
|
||||||
int segments = (int) ((2 * Mathf.PI * outsideRadius) * (diffAngle * Mathf.Rad2Deg / 360) / smoothness);
|
int segments = (int)((2 * Mathf.PI * outsideRadius) * (diffAngle * Mathf.Rad2Deg / 360) / smoothness);
|
||||||
if (segments < 1) segments = 1;
|
if (segments < 1) segments = 1;
|
||||||
float startAngle = startDegree * Mathf.Deg2Rad;
|
float startAngle = startDegree * Mathf.Deg2Rad;
|
||||||
float toAngle = toDegree * Mathf.Deg2Rad;
|
float toAngle = toDegree * Mathf.Deg2Rad;
|
||||||
@@ -1779,7 +1784,7 @@ namespace XUGL
|
|||||||
float lineWidth, Color32 lineColor, float smoothness, Direction dire = Direction.XAxis)
|
float lineWidth, Color32 lineColor, float smoothness, Direction dire = Direction.XAxis)
|
||||||
{
|
{
|
||||||
var dist = Vector3.Distance(sp, ep);
|
var dist = Vector3.Distance(sp, ep);
|
||||||
var segment = (int) (dist / (smoothness <= 0 ? 2f : smoothness));
|
var segment = (int)(dist / (smoothness <= 0 ? 2f : smoothness));
|
||||||
UGLHelper.GetBezierList2(ref s_CurvesPosList, sp, ep, segment, cp1, cp2);
|
UGLHelper.GetBezierList2(ref s_CurvesPosList, sp, ep, segment, cp1, cp2);
|
||||||
DrawCurvesInternal(vh, s_CurvesPosList, lineWidth, lineColor, dire);
|
DrawCurvesInternal(vh, s_CurvesPosList, lineWidth, lineColor, dire);
|
||||||
}
|
}
|
||||||
@@ -1801,15 +1806,15 @@ namespace XUGL
|
|||||||
bool closed = false)
|
bool closed = false)
|
||||||
{
|
{
|
||||||
var count = points.Count;
|
var count = points.Count;
|
||||||
var size = (closed?count : count - 1);
|
var size = (closed ? count : count - 1);
|
||||||
if (closed)
|
if (closed)
|
||||||
dire = Direction.Random;
|
dire = Direction.Random;
|
||||||
for (int i = 0; i < size; i++)
|
for (int i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
var sp = points[i];
|
var sp = points[i];
|
||||||
var ep = closed?(i == size - 1 ? points[0] : points[i + 1]) : points[i + 1];
|
var ep = closed ? (i == size - 1 ? points[0] : points[i + 1]) : points[i + 1];
|
||||||
var lsp = i > 0 ? points[i - 1] : (closed?points[count - 1] : sp);
|
var lsp = i > 0 ? points[i - 1] : (closed ? points[count - 1] : sp);
|
||||||
var nep = i < points.Count - 2 ? points[i + 2] : (closed?points[(i + 2) % count] : ep);
|
var nep = i < points.Count - 2 ? points[i + 2] : (closed ? points[(i + 2) % count] : ep);
|
||||||
var smoothness2 = smoothness;
|
var smoothness2 = smoothness;
|
||||||
if (currProgress != float.NaN)
|
if (currProgress != float.NaN)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user