This commit is contained in:
Scott Williams 2017-02-09 10:41:56 +00:00
Родитель 4af41417ae
Коммит f195205f65
2 изменённых файлов: 13 добавлений и 5 удалений

Просмотреть файл

@ -32,7 +32,7 @@ namespace SixLabors.Shapes
/// Initializes a new instance of the <see cref="BezierLineSegment"/> class.
/// </summary>
/// <param name="points">The points.</param>
public BezierLineSegment(Vector2[] points)
public BezierLineSegment(ImmutableArray<Vector2> points)
{
Guard.NotNull(points, nameof(points));
Guard.MustBeGreaterThanOrEqualTo(points.Length, 4, nameof(points));
@ -44,11 +44,20 @@ namespace SixLabors.Shapes
}
this.controlPoints = points.ToArray();
this.linePoints = this.GetDrawingPoints(points);
this.linePoints = GetDrawingPoints(points);
this.EndPoint = points[points.Length - 1];
}
/// <summary>
/// Initializes a new instance of the <see cref="BezierLineSegment"/> class.
/// </summary>
/// <param name="points">The points.</param>
public BezierLineSegment(Vector2[] points)
: this(ImmutableArray.Create(points))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="BezierLineSegment"/> class.
/// </summary>
@ -172,10 +181,10 @@ namespace SixLabors.Shapes
{
int pointsAddedCount = 0;
pointsAddedCount += FindDrawingPoints(curveIndex, t0, midT, pointList, insertionIndex, controlPoints, depth+1);
pointsAddedCount += FindDrawingPoints(curveIndex, t0, midT, pointList, insertionIndex, controlPoints, depth + 1);
pointList.Insert(insertionIndex + pointsAddedCount, mid);
pointsAddedCount++;
pointsAddedCount += FindDrawingPoints(curveIndex, midT, t1, pointList, insertionIndex + pointsAddedCount, controlPoints, depth+1);
pointsAddedCount += FindDrawingPoints(curveIndex, midT, t1, pointList, insertionIndex + pointsAddedCount, controlPoints, depth + 1);
return pointsAddedCount;
}

Просмотреть файл

@ -15,7 +15,6 @@ namespace SixLabors.Shapes.Tests
{
var segment = new BezierLineSegment(new Vector2(0, 0), new Vector2(10, 0), new Vector2(10, 0), new Vector2(20, 0));
var points = segment.Flatten();
Assert.Equal(51, points.Length);
Assert.Contains(new Vector2(0, 0), points);
Assert.Contains(new Vector2(10, 0), points);
Assert.Contains(new Vector2(20, 0), points);