// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Platform;
namespace Avalonia.Media
{
///
/// Represents the geometry of an polyline or polygon.
///
public class PolylineGeometry : Geometry
{
private IList _points;
private bool _isFilled;
public PolylineGeometry(IList points, bool isFilled)
{
_points = points;
_isFilled = isFilled;
IPlatformRenderInterface factory = AvaloniaLocator.Current.GetService();
IStreamGeometryImpl impl = factory.CreateStreamGeometry();
using (IStreamGeometryContextImpl context = impl.Open())
{
if (points.Count > 0)
{
context.BeginFigure(points[0], isFilled);
for (int i = 1; i < points.Count; i++)
{
context.LineTo(points[i]);
}
context.EndFigure(isFilled);
}
}
PlatformImpl = impl;
}
///
public override Geometry Clone()
{
return new PolylineGeometry(new List(_points), _isFilled);
}
}
}