mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-27 11:40:13 +00:00
[feature][UGL] add UGL.DrawPolyon API
This commit is contained in:
@@ -1940,5 +1940,25 @@ namespace XUGL
|
||||
angle += smoothness;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充任意多边形(目前只支持凸多边形)
|
||||
/// </summary>
|
||||
/// <param name="vh"></param>
|
||||
/// <param name="points"></param>
|
||||
/// <param name="color"></param>
|
||||
public static void DrawPolygon(VertexHelper vh, List<Vector3> points, Color32 color)
|
||||
{
|
||||
if (points.Count < 3 || UGLHelper.IsClearColor(color)) return;
|
||||
var cv = vh.currentVertCount;
|
||||
foreach (var pos in points)
|
||||
{
|
||||
vh.AddVert(pos, color, Vector2.zero);
|
||||
}
|
||||
for (int i = 2; i < points.Count; i++)
|
||||
{
|
||||
vh.AddTriangle(cv, cv + i - 1, cv + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user