mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-18 06:20:15 +00:00
性能优化,减少Color隐式转化
This commit is contained in:
@@ -15,22 +15,22 @@ namespace xcharts
|
||||
public class ThemeInfo
|
||||
{
|
||||
public Font font;
|
||||
public Color backgroundColor;
|
||||
public Color contrastColor;
|
||||
public Color textColor;
|
||||
public Color subTextColor;
|
||||
public Color unableColor;
|
||||
public Color32 backgroundColor;
|
||||
public Color32 contrastColor;
|
||||
public Color32 textColor;
|
||||
public Color32 subTextColor;
|
||||
public Color32 unableColor;
|
||||
|
||||
public Color axisLineColor;
|
||||
public Color axisSplitLineColor;
|
||||
public Color32 axisLineColor;
|
||||
public Color32 axisSplitLineColor;
|
||||
|
||||
public Color tooltipBackgroundColor;
|
||||
public Color tooltipFlagAreaColor;
|
||||
public Color tooltipTextColor;
|
||||
public Color32 tooltipBackgroundColor;
|
||||
public Color32 tooltipFlagAreaColor;
|
||||
public Color32 tooltipTextColor;
|
||||
|
||||
public Color[] colorPalette;
|
||||
public Color32[] colorPalette;
|
||||
|
||||
public Color GetColor(int index)
|
||||
public Color32 GetColor(int index)
|
||||
{
|
||||
if(index < 0)
|
||||
{
|
||||
@@ -52,7 +52,7 @@ namespace xcharts
|
||||
axisSplitLineColor = theme.axisSplitLineColor;
|
||||
tooltipBackgroundColor = theme.tooltipBackgroundColor;
|
||||
tooltipTextColor = theme.tooltipTextColor;
|
||||
colorPalette = new Color[theme.colorPalette.Length];
|
||||
colorPalette = new Color32[theme.colorPalette.Length];
|
||||
for(int i = 0; i < theme.colorPalette.Length; i++)
|
||||
{
|
||||
colorPalette[i] = theme.colorPalette[i];
|
||||
@@ -76,7 +76,7 @@ namespace xcharts
|
||||
tooltipBackgroundColor = GetColor("#515151B5"),
|
||||
tooltipTextColor = GetColor("#FFFFFFFF"),
|
||||
tooltipFlagAreaColor = GetColor("#51515120"),
|
||||
colorPalette = new Color[]
|
||||
colorPalette = new Color32[]
|
||||
{
|
||||
new Color32(194, 53, 49, 255),
|
||||
new Color32(47, 69, 84, 255),
|
||||
@@ -111,7 +111,7 @@ namespace xcharts
|
||||
tooltipBackgroundColor = GetColor("#515151B5"),
|
||||
tooltipTextColor = GetColor("#FFFFFFFF"),
|
||||
tooltipFlagAreaColor = GetColor("#51515120"),
|
||||
colorPalette = new Color[]
|
||||
colorPalette = new Color32[]
|
||||
{
|
||||
new Color32(55, 162, 218, 255),
|
||||
new Color32(255, 159, 127, 255),
|
||||
@@ -148,7 +148,7 @@ namespace xcharts
|
||||
tooltipBackgroundColor = GetColor("#515151B5"),
|
||||
tooltipTextColor = GetColor("#FFFFFFFF"),
|
||||
tooltipFlagAreaColor = GetColor("#51515120"),
|
||||
colorPalette = new Color[]
|
||||
colorPalette = new Color32[]
|
||||
{
|
||||
new Color32(221, 107, 102, 255),
|
||||
new Color32(117, 154, 160, 255),
|
||||
@@ -166,11 +166,11 @@ namespace xcharts
|
||||
}
|
||||
}
|
||||
|
||||
public static Color GetColor(string hexColorStr)
|
||||
public static Color32 GetColor(string hexColorStr)
|
||||
{
|
||||
Color color;
|
||||
ColorUtility.TryParseHtmlString(hexColorStr,out color);
|
||||
return color;
|
||||
return (Color32)color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace xcharts
|
||||
return tooltipObj;
|
||||
}
|
||||
|
||||
public static void DrawLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, Color color)
|
||||
public static void DrawLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, Color32 color)
|
||||
{
|
||||
Vector3 v = Vector3.Cross(p2 - p1, Vector3.forward).normalized * size;
|
||||
vertex[0].position = p1 + v;
|
||||
@@ -133,7 +133,7 @@ namespace xcharts
|
||||
vh.AddUIVertexQuad(vertex);
|
||||
}
|
||||
|
||||
public static void DrawPolygon(VertexHelper vh, Vector3 p, float size, Color color)
|
||||
public static void DrawPolygon(VertexHelper vh, Vector3 p, float size, Color32 color)
|
||||
{
|
||||
Vector3 p1 = new Vector3(p.x - size, p.y - size);
|
||||
Vector3 p2 = new Vector3(p.x + size, p.y - size);
|
||||
@@ -143,14 +143,14 @@ namespace xcharts
|
||||
}
|
||||
|
||||
public static void DrawPolygon(VertexHelper vh, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4,
|
||||
Color color)
|
||||
Color32 color)
|
||||
{
|
||||
DrawPolygon(vh, p1, p2, p3, p4, color, color);
|
||||
}
|
||||
|
||||
|
||||
public static void DrawPolygon(VertexHelper vh, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4,
|
||||
Color startColor, Color toColor)
|
||||
Color32 startColor, Color32 toColor)
|
||||
{
|
||||
vertex[0].position = p1;
|
||||
vertex[1].position = p2;
|
||||
@@ -165,7 +165,7 @@ namespace xcharts
|
||||
}
|
||||
|
||||
public static void DrawTriangle(VertexHelper vh, Vector3 p1,
|
||||
Vector3 p2, Vector3 p3, Color color)
|
||||
Vector3 p2, Vector3 p3, Color32 color)
|
||||
{
|
||||
UIVertex v1 = new UIVertex();
|
||||
v1.position = p1;
|
||||
@@ -179,12 +179,14 @@ namespace xcharts
|
||||
v3.position = p3;
|
||||
v3.color = color;
|
||||
v3.uv0 = Vector3.zero;
|
||||
int startIndex = vh.currentVertCount;
|
||||
vh.AddVert(v1);
|
||||
vh.AddVert(v2);
|
||||
vh.AddVert(v3);
|
||||
vh.AddTriangle(startIndex, startIndex + 1, startIndex + 2);
|
||||
}
|
||||
|
||||
public static void DrawCricle(VertexHelper vh, Vector3 p, float radius, Color color,
|
||||
public static void DrawCricle(VertexHelper vh, Vector3 p, float radius, Color32 color,
|
||||
int segments = 0, bool fill = true)
|
||||
{
|
||||
if (segments <= 0)
|
||||
@@ -195,7 +197,7 @@ namespace xcharts
|
||||
}
|
||||
|
||||
public static void DrawCicleNotFill(VertexHelper vh, Vector3 p, float radius, float tickness,
|
||||
Color color, int segments = 0)
|
||||
Color32 color, int segments = 0)
|
||||
{
|
||||
if (segments <= 0)
|
||||
{
|
||||
@@ -215,7 +217,7 @@ namespace xcharts
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawSector(VertexHelper vh, Vector3 p, float radius, Color color,
|
||||
public static void DrawSector(VertexHelper vh, Vector3 p, float radius, Color32 color,
|
||||
float startDegree, float toDegree, int segments = 0)
|
||||
{
|
||||
if (segments <= 0)
|
||||
@@ -237,7 +239,7 @@ namespace xcharts
|
||||
}
|
||||
|
||||
public static void DrawDoughnut(VertexHelper vh, Vector3 p, float insideRadius, float outsideRadius,
|
||||
float startDegree, float toDegree, Color color, int segments = 0)
|
||||
float startDegree, float toDegree, Color32 color, int segments = 0)
|
||||
{
|
||||
if (insideRadius <= 0)
|
||||
{
|
||||
@@ -277,7 +279,7 @@ namespace xcharts
|
||||
Vector3 cp2 = sp + dist / k * dir * (k - 1);
|
||||
cp1.y = sp.y;
|
||||
cp2.y = ep.y;
|
||||
int segment = (int)(dist / 0.1f);
|
||||
int segment = (int)(dist / 0.3f);
|
||||
return GetBezierList2(sp, ep, segment, cp1, cp2);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace xcharts
|
||||
{
|
||||
if (!legend.IsShowSeries(j)) continue;
|
||||
Series series = seriesList[j];
|
||||
Color color = themeInfo.GetColor(j);
|
||||
Color32 color = themeInfo.GetColor(j);
|
||||
Vector3 lp = Vector3.zero;
|
||||
Vector3 np = Vector3.zero;
|
||||
float startX = zeroX + (xAxis.boundaryGap ? scaleWid / 2 : 0);
|
||||
|
||||
Reference in New Issue
Block a user