/// <summary> /// Draws the given rounded rectangle with the given brush. /// </summary> public void DrawRoundedRectangle(RectangleF rectangle, float radiusX, float radiusY, BrushResource brush, float strokeWidth = 1f) { if (_renderTarget == null) { return; } rectangle.EnsureNotEmpty(nameof(rectangle)); brush.EnsureNotNull(nameof(brush)); radiusX.EnsurePositiveOrZero(nameof(radiusX)); radiusY.EnsurePositiveOrZero(nameof(radiusY)); strokeWidth.EnsurePositiveOrZero(nameof(strokeWidth)); var roundedRect = new D2D.RoundedRectangle { Rect = rectangle, RadiusX = radiusX, RadiusY = radiusY }; _renderTarget.DrawRoundedRectangle( roundedRect, brush.GetBrush(this.Device), strokeWidth); }
/// <summary> /// Initializes a new instance of the <see cref="Direct2DSingleRenderTextureResource"/> class. /// </summary> /// <param name="fillBrush">The brush which gets used when painting the texture on load time.</param> /// <param name="height">The width of the generated texture.</param> /// <param name="width">The height of the generated texture.</param> public Direct2DSingleRenderTextureResource(BrushResource fillBrush, int width, int height) { fillBrush.EnsureNotNull(nameof(fillBrush)); width.EnsurePositive(nameof(width)); height.EnsurePositive(nameof(height)); m_fillBrush = fillBrush; m_width = width; m_height = height; }
/// <summary> /// Initializes a new instance of the <see cref="Direct2DOneTimeRenderTextureResource"/> class. /// </summary> /// <param name="fillBrush">The brush which gets used when painting the texture on load time.</param> /// <param name="height">The width of the generated texture.</param> /// <param name="width">The height of the generated texture.</param> public Direct2DOneTimeRenderTextureResource(BrushResource fillBrush, int width, int height) { fillBrush.EnsureNotNull(nameof(fillBrush)); width.EnsurePositiveOrZero(nameof(width)); height.EnsurePositiveOrZero(nameof(height)); _fillBrush = fillBrush; _width = width; _height = height; }
/// <summary> /// Fills the given geometry. /// </summary> public void FillGeometry(Geometry2DResourceBase geometry, BrushResource brush) { if (_renderTarget == null) { return; } geometry.EnsureNotNullOrDisposed(nameof(geometry)); brush.EnsureNotNull(nameof(brush)); _renderTarget.FillGeometry( geometry.GetGeometry(), brush.GetBrush(this.Device)); }
/// <summary> /// Fills the given rectangle with the given brush object. /// </summary> /// <param name="rectangle">The rectangle to be filled.</param> /// <param name="brush">The brush to be used.</param> public void FillRectangle(RectangleF rectangle, BrushResource brush) { if (_renderTarget == null) { return; } rectangle.EnsureNotEmpty(nameof(rectangle)); brush.EnsureNotNull(nameof(brush)); _renderTarget.FillRectangle( rectangle, brush.GetBrush(this.Device)); }
/// <summary> /// Draws the given line with the given brush. /// </summary> public void DrawLine(Vector2 start, Vector2 end, BrushResource brush, float strokeWidth = 1f) { if (_renderTarget == null) { return; } brush.EnsureNotNull(nameof(brush)); strokeWidth.EnsurePositiveAndNotZero(nameof(strokeWidth)); _renderTarget.DrawLine( MathConverter.RawFromVector2(start), MathConverter.RawFromVector2(end), brush.GetBrush(this.Device), strokeWidth); }
/// <summary> /// Draws the given rectangle with the given brush. /// </summary> public void DrawRectangle(RectangleF rectangle, BrushResource brush, float strokeWidth = 1f) { if (_renderTarget == null) { return; } brush.EnsureNotNull(nameof(brush)); rectangle.EnsureNotEmpty(nameof(rectangle)); strokeWidth.EnsurePositiveOrZero(nameof(strokeWidth)); _renderTarget.DrawRectangle( rectangle, brush.GetBrush(this.Device), strokeWidth); }
/// <summary> /// Draws the given geometry. /// </summary> public void DrawGeometry(Geometry2DResourceBase geometry, BrushResource brush, float strokeWidth = 1f) { if (_renderTarget == null) { return; } geometry.EnsureNotNullOrDisposed(nameof(geometry)); brush.EnsureNotNull(nameof(brush)); strokeWidth.EnsurePositiveOrZero(nameof(strokeWidth)); _renderTarget.DrawGeometry( geometry.GetGeometry(), brush.GetBrush(this.Device), strokeWidth); }
/// <summary> /// Draws the given text on the screen. /// </summary> /// <param name="textToDraw">The text to draw.</param> /// <param name="textFormat">The TextFormat to be used.</param> /// <param name="targetRectangle">The target rectangle.</param> /// <param name="brush">The brush.</param> /// <param name="drawOptions">Some draw options to be passed to Direct2D.</param> /// <param name="measuringMode">Sets the measuring mode to be passed to Direct2D.</param> public void DrawText( string textToDraw, TextFormatResource textFormat, RectangleF targetRectangle, BrushResource brush, DrawTextOptions drawOptions = DrawTextOptions.None, MeasuringMode measuringMode = MeasuringMode.Natural) { if (_renderTarget == null) { return; } textToDraw.EnsureNotNull(nameof(textToDraw)); targetRectangle.EnsureNotEmpty(nameof(targetRectangle)); brush.EnsureNotNull(nameof(brush)); _renderTarget.DrawText( textToDraw, textFormat.GetTextFormat(this.Device), targetRectangle, brush.GetBrush(this.Device), (D2D.DrawTextOptions)drawOptions, (Vortice.DCommon.MeasuringMode)measuringMode); }