public string AddPolygon(Color color, params Vector2[] points) { var polyPoints = new SvgPointCollection(); polyPoints.AddRange( points.SelectMany(p => new[] { new SvgUnit(p.X), new SvgUnit(p.Y) })); var id = Guid.NewGuid().ToString(); _svg.Children.Add(new SvgPolygon { Points = polyPoints, Fill = new SvgColourServer(color), ID = id }); return(id); }
public void DrawPolygon(IEnumerable <Point> points, GraphicsContext context, DeviceDescription description) { var svgContext = _mapper.MapGraphicsContextToSvg(context); var collection = new SvgPointCollection(); collection.AddRange(points.Select(p => _mapper.MapPoint(p)) .Select(p => new[] { p.X, p.Y }) .SelectMany(p => p)); AddChild(new SvgPolygon { Fill = svgContext.Fill, FillOpacity = svgContext.Opacity, Points = collection, Stroke = svgContext.Pen.Stroke, StrokeDashArray = svgContext.Pen.StrokeDashArray, StrokeLineCap = svgContext.Pen.StrokeLineCap, StrokeLineJoin = svgContext.Pen.StrokeLineJoin, StrokeWidth = svgContext.Pen.StrokeWidth }); }
public void DrawPolyline(IEnumerable<Point> points, GraphicsContext context, DeviceDescription description) { var svgContext = _mapper.MapGraphicsContextToSvg(context); var collection = new SvgPointCollection(); collection.AddRange(points.Select(p => _mapper.MapPoint(p, SvgUnitType.User)) .Select(p => new[] { p.X, p.Y }) .SelectMany(p => p)); AddChild(new SvgPolyline { Fill = svgContext.Fill, FillOpacity = svgContext.Opacity, Points = collection, Stroke = svgContext.Pen.Stroke, StrokeDashArray = svgContext.Pen.StrokeDashArray, StrokeLineCap = svgContext.Pen.StrokeLineCap, StrokeLineJoin = svgContext.Pen.StrokeLineJoin, StrokeWidth = svgContext.Pen.StrokeWidth }); }