This commit is contained in:
monitor1394
2022-05-22 22:17:38 +08:00
parent 003f4da9de
commit bafe032bb9
391 changed files with 3718 additions and 2774 deletions

View File

@@ -42,7 +42,7 @@ namespace XUGL
}
else
{
var type = s_PathValueRegex.Match(key).Groups[1].ToString().ToCharArray()[0];
var type = s_PathValueRegex.Match(key).Groups[1].ToString().ToCharArray() [0];
var mc3 = s_PathValueRegex2.Matches(key);
SVGPathSeg seg = null;
switch (type)
@@ -151,7 +151,7 @@ namespace XUGL
var cp1 = seg.relative ? np + seg.p1 : seg.p1;
cp2 = seg.relative ? np + seg.p2 : seg.p2;
var ep = seg.relative ? np + seg.p3 : seg.p3;
var dist = (int)Vector2.Distance(np, ep) * 2;
var dist = (int) Vector2.Distance(np, ep) * 2;
if (dist < 2) dist = 2;
UGLHelper.GetBezierList2(ref bezierList, np, ep, dist, cp1, cp2);
for (int n = 1; n < bezierList.Count; n++)
@@ -162,7 +162,7 @@ namespace XUGL
cp1 = np + (np - cp2).normalized * Vector2.Distance(np, cp2);
var scp2 = seg.relative ? np + seg.p1 : seg.p1;
ep = seg.relative ? np + seg.p2 : seg.p2;
dist = (int)Vector2.Distance(np, ep) * 2;
dist = (int) Vector2.Distance(np, ep) * 2;
if (dist < 2) dist = 2;
UGLHelper.GetBezierList2(ref bezierList, np, ep, dist, cp1, scp2);
for (int n = 1; n < bezierList.Count; n++)

View File

@@ -27,7 +27,7 @@ namespace XUGL
/// <param name="dent">箭头凹度</param>
/// <param name="color">颜色</param>
public static void DrawArrow(VertexHelper vh, Vector3 startPoint, Vector3 arrowPoint, float width,
float height, float offset, float dent, Color32 color)
float height, float offset, float dent, Color32 color)
{
var dir = (arrowPoint - startPoint).normalized;
var sharpPos = arrowPoint + (offset + height / 4) * dir;
@@ -187,13 +187,13 @@ namespace XUGL
}
public static void AddVertToVertexHelper(VertexHelper vh, Vector3 top,
Vector3 bottom, Color32 color, bool needTriangle = true)
Vector3 bottom, Color32 color, bool needTriangle = true)
{
AddVertToVertexHelper(vh, top, bottom, color, color, needTriangle);
}
public static void AddVertToVertexHelper(VertexHelper vh, Vector3 top,
Vector3 bottom, Color32 topColor, Color32 bottomColor, bool needTriangle = true)
Vector3 bottom, Color32 topColor, Color32 bottomColor, bool needTriangle = true)
{
var lastVertCount = vh.currentVertCount;
vh.AddVert(top, topColor, Vector2.zero);
@@ -518,7 +518,7 @@ namespace XUGL
/// <param name="color">颜色</param>
/// <param name="vertical">是否垂直方向</param>
public static void DrawRectangle(VertexHelper vh, Vector3 p, float xRadius, float yRadius,
Color32 color, bool vertical = true)
Color32 color, bool vertical = true)
{
DrawRectangle(vh, p, xRadius, yRadius, color, color, vertical);
}
@@ -1049,14 +1049,14 @@ namespace XUGL
if (borderWidth == 0 || UGLHelper.IsClearColor(color)) return;
var halfWid = rectWidth / 2;
var halfHig = rectHeight / 2;
var lbIn = new Vector3(center.x - halfWid, center.y - halfHig);
var lbOt = new Vector3(center.x - halfWid - borderWidth, center.y - halfHig - borderWidth);
var ltIn = new Vector3(center.x - halfWid, center.y + halfHig);
var ltOt = new Vector3(center.x - halfWid - borderWidth, center.y + halfHig + borderWidth);
var rtIn = new Vector3(center.x + halfWid, center.y + halfHig);
var rtOt = new Vector3(center.x + halfWid + borderWidth, center.y + halfHig + borderWidth);
var rbIn = new Vector3(center.x + halfWid, center.y - halfHig);
var rbOt = new Vector3(center.x + halfWid + borderWidth, center.y - halfHig - borderWidth);
var lbIn = new Vector3(center.x - halfWid - extWidth, center.y - halfHig - extWidth);
var lbOt = new Vector3(center.x - halfWid - borderWidth - extWidth, center.y - halfHig - borderWidth - extWidth);
var ltIn = new Vector3(center.x - halfWid - extWidth, center.y + halfHig + extWidth);
var ltOt = new Vector3(center.x - halfWid - borderWidth - extWidth, center.y + halfHig + borderWidth + extWidth);
var rtIn = new Vector3(center.x + halfWid + extWidth, center.y + halfHig + extWidth);
var rtOt = new Vector3(center.x + halfWid + borderWidth + extWidth, center.y + halfHig + borderWidth + extWidth);
var rbIn = new Vector3(center.x + halfWid + extWidth, center.y - halfHig - extWidth);
var rbOt = new Vector3(center.x + halfWid + borderWidth + extWidth, center.y - halfHig - borderWidth - extWidth);
float brLt = 0, brRt = 0, brRb = 0, brLb = 0;
bool needRound = false;
InitCornerRadius(cornerRadius, rectWidth, rectHeight, horizontal, invertCorner, ref brLt, ref brRt, ref brRb,
@@ -1185,7 +1185,7 @@ namespace XUGL
}
public static void DrawTriangle(VertexHelper vh, Vector3 p1,
Vector3 p2, Vector3 p3, Color32 color, Color32 color2, Color32 color3)
Vector3 p2, Vector3 p3, Color32 color, Color32 color2, Color32 color3)
{
UIVertex v1 = new UIVertex();
v1.position = p1;
@@ -1213,7 +1213,7 @@ namespace XUGL
}
public static void DrawCricle(VertexHelper vh, Vector3 center, float radius, Color32 color,
Color32 toColor, float smoothness = 2f)
Color32 toColor, float smoothness = 2f)
{
DrawSector(vh, center, radius, color, toColor, 0, 360, 0, s_ClearColor32, smoothness);
}
@@ -1260,13 +1260,13 @@ namespace XUGL
}
public static void DrawSector(VertexHelper vh, Vector3 center, float radius, Color32 color,
float startDegree, float toDegree, float smoothness = 2f)
float startDegree, float toDegree, float smoothness = 2f)
{
DrawSector(vh, center, radius, color, color, startDegree, toDegree, 0, s_ClearColor32, smoothness);
}
public static void DrawSector(VertexHelper vh, Vector3 center, float radius, Color32 color, Color32 toColor,
float startDegree, float toDegree, int gradientType = 0, bool isYAxis = false, float smoothness = 2f)
float startDegree, float toDegree, int gradientType = 0, bool isYAxis = false, float smoothness = 2f)
{
DrawSector(vh, center, radius, color, toColor, startDegree, toDegree, 0, s_ClearColor32, 0, smoothness,
gradientType, isYAxis);
@@ -1308,7 +1308,7 @@ namespace XUGL
if (gap > 0 && Mathf.Abs(toDegree - startDegree) >= 360) gap = 0;
radius -= borderWidth;
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;
float startAngle = startDegree * Mathf.Deg2Rad;
float toAngle = toDegree * Mathf.Deg2Rad;
@@ -1381,9 +1381,9 @@ namespace XUGL
{
p4 = new Vector3(p3.x, realCenter.y);
var dist = p4.x - realCenter.x;
var tcolor = Color32.Lerp(color, toColor, dist >= 0
? dist / radius
: Mathf.Min(radius + dist, radius) / radius);
var tcolor = Color32.Lerp(color, toColor, dist >= 0 ?
dist / radius :
Mathf.Min(radius + dist, radius) / radius);
if (isLeft && (i == segments || i == 0)) tcolor = toColor;
DrawQuadrilateral(vh, lastP4, p2, p3, p4, lastColor, tcolor);
lastP4 = p4;
@@ -1500,7 +1500,7 @@ namespace XUGL
var needSpace = gap != 0;
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;
float startAngle = startDegree * Mathf.Deg2Rad;
float toAngle = toDegree * Mathf.Deg2Rad;
@@ -1755,7 +1755,7 @@ namespace XUGL
float lineWidth, Color32 lineColor, float smoothness)
{
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);
DrawCurvesInternal(vh, s_CurvesPosList, lineWidth, lineColor);
}
@@ -1898,4 +1898,4 @@ namespace XUGL
}
}
}
}
}

View File

@@ -7,18 +7,18 @@ namespace XUGL
{
public static bool IsValueEqualsColor(Color32 color1, Color32 color2)
{
return color1.a == color2.a
&& color1.b == color2.b
&& color1.g == color2.g
&& color1.r == color2.r;
return color1.a == color2.a &&
color1.b == color2.b &&
color1.g == color2.g &&
color1.r == color2.r;
}
public static bool IsValueEqualsColor(Color color1, Color color2)
{
return color1.a == color2.a
&& color1.b == color2.b
&& color1.g == color2.g
&& color1.r == color2.r;
return color1.a == color2.a &&
color1.b == color2.b &&
color1.g == color2.g &&
color1.r == color2.r;
}
public static bool IsValueEqualsString(string str1, string str2)
@@ -32,21 +32,21 @@ namespace XUGL
public static bool IsValueEqualsVector2(Vector2 v1, Vector2 v2)
{
return v1.x == v2.x
&& v1.y == v2.y;
return v1.x == v2.x &&
v1.y == v2.y;
}
public static bool IsValueEqualsVector3(Vector3 v1, Vector3 v2)
{
return v1.x == v2.x
&& v1.y == v2.y
&& v1.z == v2.z;
return v1.x == v2.x &&
v1.y == v2.y &&
v1.z == v2.z;
}
public static bool IsValueEqualsVector3(Vector3 v1, Vector2 v2)
{
return v1.x == v2.x
&& v1.y == v2.y;
return v1.x == v2.x &&
v1.y == v2.y;
}
public static bool IsValueEqualsList<T>(List<T> list1, List<T> list2)
@@ -60,8 +60,7 @@ namespace XUGL
for (int i = 0; i < list1.Count; i++)
{
if (list1[i] == null && list2[i] == null)
{
}
{ }
else
{
if (list1[i] != null)
@@ -81,25 +80,25 @@ namespace XUGL
public static bool IsClearColor(Color32 color)
{
return color.a == 0
&& color.b == 0
&& color.g == 0
&& color.r == 0;
return color.a == 0 &&
color.b == 0 &&
color.g == 0 &&
color.r == 0;
}
public static bool IsClearColor(Color color)
{
return color.a == 0
&& color.b == 0
&& color.g == 0
&& color.r == 0;
return color.a == 0 &&
color.b == 0 &&
color.g == 0 &&
color.r == 0;
}
public static bool IsZeroVector(Vector3 pos)
{
return pos.x == 0
&& pos.y == 0
&& pos.z == 0;
return pos.x == 0 &&
pos.y == 0 &&
pos.z == 0;
}
public static Vector3 RotateRound(Vector3 position, Vector3 center, Vector3 axis, float angle)
@@ -110,7 +109,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)
{
float dist = Mathf.Abs(sp.x - ep.x);
Vector3 cp1, cp2;
@@ -129,8 +128,8 @@ namespace XUGL
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);
int segment = (int) (dist / (smoothness <= 0 ? 2f : smoothness));
if (segment < 1) segment = (int) (dist / 0.5f);
if (segment < 4) segment = 4;
GetBezierList2(ref posList, sp, ep, segment, cp1, cp2);
if (posList.Count < 2)
@@ -150,7 +149,7 @@ namespace XUGL
Vector3 cp2 = sp + dist / k * dir * (k - 1);
cp1.x = sp.x;
cp2.x = ep.x;
int segment = (int)(dist / (smoothness <= 0 ? 2f : smoothness));
int segment = (int) (dist / (smoothness <= 0 ? 2f : smoothness));
GetBezierList2(ref posList, sp, ep, segment, cp1, cp2);
if (posList.Count < 2)
{
@@ -165,7 +164,7 @@ namespace XUGL
List<Vector3> list = new List<Vector3>();
for (int i = 0; i < segment; i++)
{
list.Add(GetBezier(i / (float)segment, sp, cp, ep));
list.Add(GetBezier(i / (float) segment, sp, cp, ep));
}
list.Add(ep);
return list;
@@ -181,7 +180,7 @@ namespace XUGL
}
for (int i = 0; i < segment; i++)
{
posList.Add((GetBezier2(i / (float)segment, sp, cp, cp2, ep)));
posList.Add((GetBezier2(i / (float) segment, sp, cp, cp2, ep)));
}
posList.Add(ep);
}