public override IReadOnlyList <Path.Point> GetPoints()
    {
        if (Iterations == 0)
        {
            return(null);
        }

        var markerPoints = GetMarkersPoint();

        var curve = new BezierCurve(markerPoints);

        var curvePoints = new Path.Point[Iterations];

        for (var i = 0; i < Iterations; ++i)
        {
            curvePoints[i].Position = curve.Evaluate(i / (Iterations - 1.0f));
            curvePoints[i].Scale    = Vector2.one;
        }

        return(curvePoints);
    }
Exemple #2
0
    public override IReadOnlyList <Path.Point> GetPoints()
    {
        if (transform.childCount == 2)
        {
            var result = new Path.Point[Iterations];
            var child0 = transform.GetChild(0).position;
            var child1 = transform.GetChild(1).position;

            for (var i = 0; i < Iterations; ++i)
            {
                var t    = i / (Iterations - 1.0f);
                var item = result[i];
                item.Position = Vector3.Lerp(child0, child1, t);
                item.Scale    = new Vector2(Mathf.Sqrt(1.0f - (1.0f - t) * (1.0f - t)), 1.0f);
                result[i]     = item;
            }

            return(result);
        }

        throw new Exception("Round corner segment needs 2 points");
    }
    public override IReadOnlyList <Path.Point> GetPoints()
    {
        if (transform.childCount == 2)
        {
            var child0 = transform.GetChild(0).position;
            var child1 = transform.GetChild(1).position;

            var firstPoint = new Path.Point
            {
                Scale    = Vector2.one,
                Position = child0,
            };
            var secondPoint = new Path.Point
            {
                Scale    = Vector2.one,
                Position = child1,
            };

            return(new [] { firstPoint, secondPoint });
        }

        throw new Exception("Round corner segment needs 2 points");
    }