/// <summary> /// Initializes a new DirectXPen class. /// </summary> /// <param name="color">The Color.</param> /// <param name="width">The Width.</param> public DirectXPen(Color color, float width) { _colorBrush = new SolidColorBrush(DirectXHelper.RenderTarget, DirectXHelper.ConvertColor(color)); Width = width; }
/// <summary> /// Fills a Polygon. /// </summary> /// <param name="color">The Color.</param> /// <param name="polygon">The Polygon.</param> public void FillPolygon(Color color, Polygon polygon) { var geometry = new PathGeometry(DirectXHelper.Direct2DFactory); using (GeometrySink sink = geometry.Open()) { sink.BeginFigure(DirectXHelper.ConvertVector(polygon.Points[0]), FigureBegin.Filled); for (int i = 1; i < polygon.Points.Length; i++) { sink.AddLine(DirectXHelper.ConvertVector(polygon.Points[i])); } sink.EndFigure(FigureEnd.Closed); sink.Close(); _renderTarget.FillGeometry(geometry, new SolidColorBrush(DirectXHelper.RenderTarget, DirectXHelper.ConvertColor(color))); } geometry.Dispose(); }
/// <summary> /// Fills a Rectangle. /// </summary> /// <param name="color">The Color.</param> /// <param name="rectangle">The Rectangle.</param> public void FillRectangle(Color color, Rectangle rectangle) { _renderTarget.FillRectangle(new SolidColorBrush(_renderTarget, DirectXHelper.ConvertColor(color)), DirectXHelper.ConvertRectangle(rectangle)); }
/// <summary> /// Fills a Ellipse. /// </summary> /// <param name="color">The Color.</param> /// <param name="ellipse">The Ellipse.</param> public void FillEllipse(Color color, Ellipse ellipse) { _renderTarget.FillEllipse(new SolidColorBrush(_renderTarget, DirectXHelper.ConvertColor(color)), DirectXHelper.ConvertEllipse(ellipse)); }
/// <summary> /// Begins the draw operation. /// </summary> public void Begin() { _renderTarget.BeginDraw(); _renderTarget.Transform = Matrix3x2.Identity; _renderTarget.Clear(DirectXHelper.ConvertColor(_graphicsDevice.ClearColor)); }