mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 17:30:10 +00:00
compatibility
This commit is contained in:
@@ -373,9 +373,25 @@ namespace XUGL
|
||||
/// <param name="color">起始颜色</param>
|
||||
/// <param name="toColor">结束颜色</param>
|
||||
public static void DrawZebraLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width,
|
||||
float zebraWidth, float zebraGap, Color32 color, Color32 toColor)
|
||||
float zebraWidth, float zebraGap, Color32 color, Color32 toColor, float maxDistance)
|
||||
{
|
||||
DrawDotLine(vh, startPoint, endPoint, width, color, toColor, zebraWidth, zebraGap);
|
||||
var dist = Vector3.Distance(startPoint, endPoint);
|
||||
if (dist < 0.1f) return;
|
||||
if (zebraWidth == 0) zebraWidth = 3 * width;
|
||||
if (zebraGap == 0) zebraGap = 3 * width;
|
||||
var allSegment = Mathf.CeilToInt(maxDistance / (zebraWidth + zebraGap));
|
||||
var segment = Mathf.CeilToInt(dist / maxDistance * allSegment);
|
||||
var dir = (endPoint - startPoint).normalized;
|
||||
var sp = startPoint;
|
||||
var np = Vector3.zero;
|
||||
var isGradient = !color.Equals(toColor);
|
||||
zebraWidth = (maxDistance - zebraGap * (allSegment - 1)) / allSegment;
|
||||
for (int i = 1; i <= segment; i++)
|
||||
{
|
||||
np = sp + dir * zebraWidth;
|
||||
DrawLine(vh, sp, np, width, isGradient ? Color32.Lerp(color, toColor, i * 1.0f / allSegment) : color);
|
||||
sp = np + dir * zebraGap;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user