Drawing.DrawBezierLine C# (CSharp) Метод

DrawBezierLine() публичный статический Метод

public static DrawBezierLine ( Vector2 start, Vector2 startTangent, Vector2 end, Vector2 endTangent, Color color, float width, bool antiAlias, int segments ) : void
start Vector2
startTangent Vector2
end Vector2
endTangent Vector2
color Color
width float
antiAlias bool
segments int
Результат void
    public static void DrawBezierLine(Vector2 start, Vector2 startTangent, Vector2 end, Vector2 endTangent, Color color, float width, bool antiAlias, int segments)
    {
        Vector2 lastV = CubeBezier(start, startTangent, end, endTangent, 0);
        for (int i = 1; i < segments; ++i)
        {
            Vector2 v = CubeBezier(start, startTangent, end, endTangent, i / (float)segments);
            Drawing.DrawLine(lastV, v, color, width, antiAlias);
            lastV = v;
        }
    }

Usage Example

    void DrawLineBetweenNodes(Node n1, Node n2, Color?color = null)
    {
        var n1Rect       = CalculateAbsoluteRectForNode(n1);
        var n2Rect       = CalculateAbsoluteRectForNode(n2);
        var isOnSameLine = Mathf.Abs(n2Rect.x - n1Rect.x) < 40f;
        var side         = Mathf.Sign(n2Rect.x - n1Rect.x);

        var n1Point = n1Rect.center + Vector2.right * n1Rect.width * 0.5f * side;
        var n2Point = n2Rect.center - Vector2.right * n2Rect.width * 0.5f * side;

        if (isOnSameLine)
        {
            n2Point = n2Rect.center + Vector2.right * n2Rect.width * 0.5f * side;
        }

        Vector2 startHandle = n1Point;

        startHandle.x = n2Point.x;
        Vector2 endHandle = n2Point;

        endHandle.x = n1Point.x;

        Drawing.DrawBezierLine(n1Point, startHandle, n2Point, endHandle, Color.black * 0.5f, 3.0f, true, 12);
        Drawing.DrawLine(n2Point, n2Point + Vector2.left * 5f * side + Vector2.up * 3f, Color.black * 0.5f, 2.0f, true);
        Drawing.DrawLine(n2Point, n2Point + Vector2.left * 5f * side - Vector2.up * 3f, Color.black * 0.5f, 2.0f, true);


        Drawing.DrawBezierLine(n1Point, startHandle, n2Point, endHandle, color == null ? Color.white : color.Value, 1.0f, true, 24);
        Drawing.DrawLine(n2Point, n2Point + Vector2.left * 5f * side + Vector2.up * 3f, color == null ? Color.white : color.Value, 1.0f, true);
        Drawing.DrawLine(n2Point, n2Point + Vector2.left * 5f * side - Vector2.up * 3f, color == null ? Color.white : color.Value, 1.0f, true);
    }
All Usage Examples Of Drawing::DrawBezierLine