/// <summary> /// Draws the box3 d. /// </summary> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="length">The length.</param> /// <param name="stroke">The stroke.</param> /// <param name="brush">The brush.</param> /// <param name="interiorBrush">The interior brush.</param> public void DrawBox3D(int x, int y, int width, int height, int length, float stroke, ID2DBrush brush, ID2DBrush interiorBrush) { var first = new RawRectangleF(x, y, x + width, y + height); var second = new RawRectangleF(x + length, y - length, first.Right + length, first.Bottom - length); var lineStart = new RawVector2(x, y); var lineEnd = new RawVector2(second.Left, second.Top); _device.DrawRectangle(first, brush.GetBrush(), stroke); _device.DrawRectangle(second, brush.GetBrush(), stroke); _device.FillRectangle(first, interiorBrush.GetBrush()); _device.FillRectangle(second, interiorBrush.GetBrush()); _device.DrawLine(lineStart, lineEnd, brush.GetBrush(), stroke); lineStart.X += width; lineEnd.X = lineStart.X + length; _device.DrawLine(lineStart, lineEnd, brush.GetBrush(), stroke); lineStart.Y += height; lineEnd.Y += height; _device.DrawLine(lineStart, lineEnd, brush.GetBrush(), stroke); lineStart.X -= width; lineEnd.X -= width; _device.DrawLine(lineStart, lineEnd, brush.GetBrush(), stroke); }
internal void Fill(RenderContext context, ID2DBrush brush, float offsetX, float offsetY) { context.PushTransform2D(); context.Translate2D(offsetX, offsetY); Fill(context, brush); context.PopTransform2D(); }
public static void FillPath(this RenderContext context, ID2DBrush brush, D2DPathData path, float offsetX, float offsetY) { context.PushTransform2D(); context.Translate2D(offsetX, offsetY); context.RenderTarget.DeviceContext2D.FillPath(brush, path); context.PopTransform2D(); }
public D2DPen(ID2DBrush brush, float strokeWidth, StrokeStyle style) { Brush = brush; StrokeWidth = strokeWidth; StrokeStyle = style; _isExternalBrush = true; }
/// <summary> /// Do not buffer text if you draw i.e. FPS. Use buffer for player names, rank.... /// </summary> /// <param name="text">The text.</param> /// <param name="font">The font.</param> /// <param name="brush">The brush.</param> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <param name="bufferText">if set to <c>true</c> [buffer text].</param> public void DrawText(string text, TextFormat font, ID2DBrush brush, int x, int y, bool bufferText = true) { if (bufferText) { var bufferPos = -1; for (var i = 0; i < _layoutContainer.Count; i++) { if (_layoutContainer[i].Text.Length != text.Length || _layoutContainer[i].Text != text) { continue; } bufferPos = i; break; } if (bufferPos == -1) { _layoutContainer.Add(new TextLayoutBuffer(text, new TextLayout(_fontFactory, text, font, float.MaxValue, float.MaxValue))); bufferPos = _layoutContainer.Count - 1; } _device.DrawTextLayout(new RawVector2(x, y), _layoutContainer[bufferPos].TextLayout, brush.GetBrush(), DrawTextOptions.NoSnap); } else { var layout = new TextLayout(_fontFactory, text, font, float.MaxValue, float.MaxValue); _device.DrawTextLayout(new RawVector2(x, y), layout, brush.GetBrush()); layout.Dispose(); } }
public static void FillPolygon(this SharpDX.Direct2D1.RenderTarget target, ID2DBrush brush, FillMode fillMode, params PointF[] points) { if (points == null) { throw new ArgumentNullException(nameof(points)); } if (points.Length == 0) { return; } using (var path = new PathGeometry(target.Factory)) { using (var sink = path.Open()) { sink.SetFillMode((SharpDX.Direct2D1.FillMode)fillMode); sink.BeginFigure(new RawVector2(points[0].X, points[0].Y), FigureBegin.Filled); var len = points.Length; for (var i = 1; i < len; ++i) { var pt = points[i]; sink.AddLine(new RawVector2(pt.X, pt.Y)); } sink.EndFigure(FigureEnd.Closed); sink.Close(); } target.FillGeometry(path, brush.NativeBrush); } }
public OverlayNotification(D2DDevice device, ID2DBrush background, ID2DBrush foreground, D2DFont font) { _device = device; BackgroundBrush = background; ForegroundBrush = foreground; Font = font; }
/// <summary> /// Fills a <see cref="D2DFontPathData"/> to current <see cref="RenderContext"/>. /// </summary> /// <param name="context">The <see cref="RenderContext"/> to fill to.</param> /// <param name="brush">The <see cref="D2DBrushBase"/> to use.</param> /// <param name="path">The <see cref="D2DFontPathData"/> to fill.</param> /// <param name="offsetX">The X offset on target <see cref="RenderContext"/>.</param> /// <param name="offsetY">The Y offset on target <see cref="RenderContext"/>.</param> /// <param name="yCorrection">If <see langword="true"/>, apply automatic Y correction: y(real) = offsetY + lineHeight. If <see langword="false"/>, the Y value stays untouched.</param> public static void FillPath(this RenderContext context, ID2DBrush brush, D2DFontPathData path, float offsetX, float offsetY, bool yCorrection) { if (yCorrection) { offsetY += path.LineHeight; } path.Fill(context, brush, offsetX, offsetY); }
/// <summary> /// Bordereds the circle. /// </summary> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <param name="radius">The radius.</param> /// <param name="stroke">The stroke.</param> /// <param name="brush">The brush.</param> /// <param name="borderBrush">The border brush.</param> public void BorderedCircle(int x, int y, int radius, float stroke, ID2DBrush brush, ID2DBrush borderBrush) { _device.DrawEllipse(new Ellipse(new RawVector2(x, y), radius + stroke, radius + stroke), borderBrush.GetBrush(), stroke); _device.DrawEllipse(new Ellipse(new RawVector2(x, y), radius, radius), brush.GetBrush(), stroke); _device.DrawEllipse(new Ellipse(new RawVector2(x, y), radius - stroke, radius - stroke), borderBrush.GetBrush(), stroke); }
/// <summary> /// Draws the plus. /// </summary> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <param name="length">The length.</param> /// <param name="stroke">The stroke.</param> /// <param name="brush">The brush.</param> public void DrawPlus(int x, int y, int length, float stroke, ID2DBrush brush) { var first = new RawVector2(x - length, y); var second = new RawVector2(x + length, y); var third = new RawVector2(x, y - length); var fourth = new RawVector2(x, y + length); _device.DrawLine(first, second, brush.GetBrush(), stroke); _device.DrawLine(third, fourth, brush.GetBrush(), stroke); }
/// <summary> /// Bordereds the rectangle. /// </summary> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="stroke">The stroke.</param> /// <param name="borderStroke">The border stroke.</param> /// <param name="brush">The brush.</param> /// <param name="borderBrush">The border brush.</param> public void BorderedRectangle(int x, int y, int width, int height, float stroke, float borderStroke, ID2DBrush brush, ID2DBrush borderBrush) { _device.DrawRectangle( new RawRectangleF(x - (stroke - borderStroke), y - (stroke - borderStroke), x + width + stroke - borderStroke, y + height + stroke - borderStroke), borderBrush.GetBrush(), borderStroke); _device.DrawRectangle(new RawRectangleF(x, y, x + width, y + height), brush.GetBrush(), stroke); _device.DrawRectangle( new RawRectangleF(x + (stroke - borderStroke), y + (stroke - borderStroke), x + width - stroke + borderStroke, y + height - stroke + borderStroke), borderBrush.GetBrush(), borderStroke); }
/// <summary> /// Draws the bar v. /// </summary> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="value">The value.</param> /// <param name="stroke">The stroke.</param> /// <param name="brush">The brush.</param> /// <param name="interiorBrush">The interior brush.</param> public void DrawBarV(int x, int y, int width, int height, float value, float stroke, ID2DBrush brush, ID2DBrush interiorBrush) { var first = new RawRectangleF(x, y, x + width, y + height); _device.DrawRectangle(first, brush.GetBrush(), stroke); if (Math.Abs(value) < 0) { return; } first.Right -= width - width / 100.0f * value; _device.FillRectangle(first, interiorBrush.GetBrush()); }
internal void Fill(RenderContext context, ID2DBrush brush) { const float offsetX = 0; var offsetY = 0f; var pathDataArray = _pathDataArray; var lineHeights = _lineHeights; var len = pathDataArray.Length; for (var i = 0; i < len; ++i) { var pathData = pathDataArray[i]; if (pathData != null) { context.FillPath(brush, pathData, offsetX, offsetY); } offsetY += lineHeights[i]; } }
public static void FillPath(this RenderContext context, ID2DBrush brush, D2DPathData path) { context.RenderTarget.DeviceContext2D.FillPath(brush, path); }
public static void DrawText(this RenderContext context, string text, ID2DBrush brush, D2DFont font, float destX, float destY) { context.RenderTarget.DeviceContext2D.DrawText(text, brush, font, destX, destY); }
public static void FillPolygon(this RenderContext context, ID2DBrush brush, FillMode fillMode, params PointF[] points) { context.RenderTarget.DeviceContext2D.FillPolygon(brush, fillMode, points); }
public static void FillEllipse(this RenderContext context, ID2DBrush brush, float x, float y, float width, float height) { context.RenderTarget.DeviceContext2D.FillEllipse(brush, x, y, width, height); }
public void Fill(ID2DBrush brush) { _device.FillGeometry(_geometry, brush); }
public void DrawDashed(float stroke, ID2DBrush brush) { _device.DrawDashedGeometry(_geometry, stroke, brush); }
public static void FillPath(this RenderContext context, ID2DBrush brush, D2DFontPathData path) { path.Fill(context, brush); }
public static void FillPath(this RenderContext context, ID2DBrush brush, D2DFontPathData path, PointF offset, bool yCorrection) { context.FillPath(brush, path, offset.X, offset.Y, yCorrection); }
public static void FillCircle(this RenderContext context, ID2DBrush brush, float x, float y, float radius) { context.RenderTarget.DeviceContext2D.FillCircle(brush, x, y, radius); }
public static void FillPath(this RenderContext context, ID2DBrush brush, D2DPathData path, PointF offset) { context.FillPath(brush, path, offset.X, offset.Y); }
public static void FillCircle(this SharpDX.Direct2D1.RenderTarget target, ID2DBrush brush, PointF center, float radius) { var w = radius + radius; target.FillEllipse(brush, center.X - radius, center.Y - radius, w, w); }
public static void FillCircle(this SharpDX.Direct2D1.RenderTarget target, ID2DBrush brush, float x, float y, float radius) { var w = radius + radius; target.FillEllipse(brush, x - radius, y - radius, w, w); }
public static void FillMesh(this SharpDX.Direct2D1.RenderTarget target, ID2DBrush brush, D2DMesh mesh) { target.FillMesh(mesh.Native, brush.NativeBrush); }
public static void FillMesh(this RenderContext context, ID2DBrush brush, D2DMesh mesh) { context.RenderTarget.DeviceContext2D.FillMesh(brush, mesh); }
public static void FillPath(this RenderContext context, ID2DBrush brush, D2DFontPathData path, float offsetX, float offsetY) { context.FillPath(brush, path, offsetX, offsetY, true); }
public static void FillCircle(this RenderContext context, ID2DBrush brush, PointF center, float radius) { context.RenderTarget.DeviceContext2D.FillCircle(brush, center, radius); }
public static void FillPath(this RenderContext context, ID2DBrush brush, D2DFontPathData path, Point offset) { context.FillPath(brush, path, offset, true); }