public LinearGradientBrushImpl( Perspex.Media.LinearGradientBrush brush, SharpDX.Direct2D1.RenderTarget target, Size destinationSize) { if (brush != null) { var gradientStops = brush.GradientStops.Select(s => new SharpDX.Direct2D1.GradientStop { Color = s.Color.ToDirect2D(), Position = (float)s.Offset }).ToArray(); Point startPoint = new Point(0, 0); Point endPoint = new Point(0, 0); switch (brush.MappingMode) { case Perspex.Media.BrushMappingMode.Absolute: // TODO: break; case Perspex.Media.BrushMappingMode.RelativeToBoundingBox: startPoint = new Point(brush.StartPoint.X * destinationSize.Width, brush.StartPoint.Y * destinationSize.Height); endPoint = new Point(brush.EndPoint.X * destinationSize.Width, brush.EndPoint.Y * destinationSize.Height); break; } PlatformBrush = new SharpDX.Direct2D1.LinearGradientBrush( target, new SharpDX.Direct2D1.LinearGradientBrushProperties { StartPoint = startPoint.ToSharpDX(), EndPoint = endPoint.ToSharpDX() }, new SharpDX.Direct2D1.BrushProperties { Opacity = (float)brush.Opacity, Transform = target.Transform }, new SharpDX.Direct2D1.GradientStopCollection(target, gradientStops, brush.SpreadMethod.ToDirect2D()) ); } }
public void QuadraticBezierTo(Point control, Point dest) { _sink.AddQuadraticBezier(new D2D.QuadraticBezierSegment { Point1 = control.ToSharpDX(), Point2 = dest.ToSharpDX() }); }
public void CubicBezierTo(Point point1, Point point2, Point point3) { _sink.AddBezier(new D2D.BezierSegment { Point1 = point1.ToSharpDX(), Point2 = point2.ToSharpDX(), Point3 = point3.ToSharpDX(), }); }
public void ArcTo( Point point, Size size, double rotationAngle, bool isLargeArc, Avalonia.Media.SweepDirection sweepDirection) { _sink.AddArc(new D2D.ArcSegment { Point = point.ToSharpDX(), Size = size.ToSharpDX(), RotationAngle = (float)rotationAngle, ArcSize = isLargeArc ? ArcSize.Large : ArcSize.Small, SweepDirection = (SweepDirection)sweepDirection, }); }
/// <summary> /// Draws a line. /// </summary> /// <param name="pen">The stroke pen.</param> /// <param name="p1">The first point of the line.</param> /// <param name="p2">The second point of the line.</param> public void DrawLine(Pen pen, Point p1, Point p2) { if (pen != null) { var size = new Rect(p1, p2).Size; using (var d2dBrush = CreateBrush(pen.Brush, size)) using (var d2dStroke = pen.ToDirect2DStrokeStyle(_renderTarget)) { if (d2dBrush.PlatformBrush != null) { _renderTarget.DrawLine( p1.ToSharpDX(), p2.ToSharpDX(), d2dBrush.PlatformBrush, (float)pen.Thickness, d2dStroke); } } } }
public void LineTo(Point point) { _sink.AddLine(point.ToSharpDX()); }
public void BeginFigure(Point startPoint, bool isFilled) { _sink.BeginFigure(startPoint.ToSharpDX(), isFilled ? FigureBegin.Filled : FigureBegin.Hollow); }