重构代码

This commit is contained in:
monitor1394
2020-05-17 20:36:14 +08:00
parent bc5bd1214e
commit f23347a86e
62 changed files with 1021 additions and 1030 deletions

View File

@@ -1038,5 +1038,96 @@ namespace XCharts
}
}
}
public static void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
float tickness, Vector3 pos, Color color, Color toColor, float gap, float[] cornerRadius,
Color backgroundColor, float smoothness)
{
switch (type)
{
case SerieSymbolType.None:
break;
case SerieSymbolType.Circle:
if (gap > 0)
{
ChartDrawer.DrawDoughnut(vh, pos, symbolSize, symbolSize + gap, backgroundColor, color, toColor, smoothness);
}
else
{
ChartDrawer.DrawCricle(vh, pos, symbolSize, color, toColor, smoothness);
}
break;
case SerieSymbolType.EmptyCircle:
if (gap > 0)
{
ChartDrawer.DrawCricle(vh, pos, symbolSize + gap, backgroundColor, smoothness);
ChartDrawer.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, toColor, backgroundColor, smoothness);
}
else
{
ChartDrawer.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, toColor, backgroundColor, smoothness);
}
break;
case SerieSymbolType.Rect:
if (gap > 0)
{
ChartDrawer.DrawPolygon(vh, pos, symbolSize + gap, backgroundColor);
ChartDrawer.DrawPolygon(vh, pos, symbolSize, color, toColor);
}
else
{
//ChartDrawer.DrawPolygon(vh, pos, symbolSize, color, toColor);
ChartDrawer.DrawRoundRectangle(vh, pos, symbolSize, symbolSize, color, 0, cornerRadius);
}
break;
case SerieSymbolType.Triangle:
if (gap > 0)
{
ChartDrawer.DrawTriangle(vh, pos, symbolSize + gap, backgroundColor);
ChartDrawer.DrawTriangle(vh, pos, symbolSize, color, toColor);
}
else
{
ChartDrawer.DrawTriangle(vh, pos, symbolSize, color, toColor);
}
break;
case SerieSymbolType.Diamond:
if (gap > 0)
{
ChartDrawer.DrawDiamond(vh, pos, symbolSize + gap, backgroundColor);
ChartDrawer.DrawDiamond(vh, pos, symbolSize, color, toColor);
}
else
{
ChartDrawer.DrawDiamond(vh, pos, symbolSize, color, toColor);
}
break;
}
}
public static void DrawLineStyle(VertexHelper vh, LineStyle lineStyle,
Vector3 startPos, Vector3 endPos, Color color)
{
var type = lineStyle.type;
var width = lineStyle.width;
switch (type)
{
case LineStyle.Type.Dashed:
ChartDrawer.DrawDashLine(vh, startPos, endPos, width, color);
break;
case LineStyle.Type.Dotted:
ChartDrawer.DrawDotLine(vh, startPos, endPos, width, color);
break;
case LineStyle.Type.Solid:
ChartDrawer.DrawLine(vh, startPos, endPos, width, color);
break;
case LineStyle.Type.DashDot:
ChartDrawer.DrawDashDotLine(vh, startPos, endPos, width, color);
break;
case LineStyle.Type.DashDotDot:
ChartDrawer.DrawDashDotDotLine(vh, startPos, endPos, width, color);
break;
}
}
}
}

View File

@@ -0,0 +1,52 @@
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
{
internal static class PropertyUtility
{
public static bool SetColor(ref Color currentValue, Color newValue)
{
if (currentValue.r == newValue.r && currentValue.g == newValue.g && currentValue.b == newValue.b && currentValue.a == newValue.a)
return false;
currentValue = newValue;
return true;
}
public static bool SetColor(ref Color32 currentValue, Color32 newValue)
{
if (currentValue.r == newValue.r && currentValue.g == newValue.g && currentValue.b == newValue.b && currentValue.a == newValue.a)
return false;
currentValue = newValue;
return true;
}
public static bool SetStruct<T>(ref T currentValue, T newValue) where T : struct
{
if (EqualityComparer<T>.Default.Equals(currentValue, newValue))
return false;
currentValue = newValue;
return true;
}
public static bool SetClass<T>(ref T currentValue, T newValue, bool notNull = false) where T : class
{
if (notNull)
{
if (newValue == null)
{
Debug.LogError("can not be null.");
return false;
}
}
if ((currentValue == null && newValue == null) || (currentValue != null && currentValue.Equals(newValue)))
return false;
currentValue = newValue;
return true;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: deeae684afb4a40cea4b11461d9692e8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: