public static void DrawPolygon(this SharpDX.Direct2D1.RenderTarget target, ID2DPen pen, 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.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.DrawGeometry(path, pen.Brush.NativeBrush, pen.StrokeWidth, pen.StrokeStyle); } }
internal void Draw(RenderContext context, ID2DPen pen, float offsetX, float offsetY) { context.PushTransform2D(); context.Translate2D(offsetX, offsetY); Draw(context, pen); context.PopTransform2D(); }
public static void DrawPath(this RenderContext context, ID2DPen pen, D2DPathData path, float offsetX, float offsetY) { context.PushTransform2D(); context.Translate2D(offsetX, offsetY); context.RenderTarget.DeviceContext2D.DrawPath(pen, path); context.PopTransform2D(); }
public static void DrawLine(this SharpDX.Direct2D1.RenderTarget target, ID2DPen pen, float x1, float y1, float x2, float y2) { var pt1 = new RawVector2(x1, y1); var pt2 = new RawVector2(x2, y2); target.DrawLine(pt1, pt2, pen.Brush.NativeBrush, pen.StrokeWidth, pen.StrokeStyle); }
/// <summary> /// Draws a <see cref="D2DFontPathData"/> to current <see cref="RenderContext"/>. /// </summary> /// <param name="context">The <see cref="RenderContext"/> to draw to.</param> /// <param name="pen">The <see cref="D2DPen"/> to use.</param> /// <param name="path">The <see cref="D2DFontPathData"/> to draw.</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 DrawPath(this RenderContext context, ID2DPen pen, D2DFontPathData path, float offsetX, float offsetY, bool yCorrection) { if (yCorrection) { offsetY += path.LineHeight; } path.Draw(context, pen, offsetX, offsetY); }
public static void DrawBezier(this SharpDX.Direct2D1.RenderTarget target, ID2DPen pen, float x1, float y1, float cx1, float cy1, float cx2, float cy2, float x2, float y2) { using (var path = new PathGeometry(target.Factory)) { using (var sink = path.Open()) { var bezier = new BezierSegment { Point1 = new RawVector2(cx1, cy1), Point2 = new RawVector2(cx2, cy2), Point3 = new RawVector2(x2, y2) }; sink.BeginFigure(new RawVector2(x1, y1), FigureBegin.Filled); sink.AddBezier(bezier); sink.EndFigure(FigureEnd.Open); sink.Close(); } target.DrawGeometry(path, pen.Brush.NativeBrush, pen.StrokeWidth, pen.StrokeStyle); } }
internal void Draw(RenderContext context, ID2DPen pen) { 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.DrawPath(pen, pathData, offsetX, offsetY); } offsetY += lineHeights[i]; } }
public static void DrawQuadraticBezier(this RenderContext context, ID2DPen pen, float x1, float y1, float cx, float cy, float x2, float y2) { context.RenderTarget.DeviceContext2D.DrawQuadraticBezier(pen, x1, y1, cx, cy, x2, y2); }
public static void DrawEllipse(this RenderContext context, ID2DPen pen, float x, float y, float width, float height) { context.RenderTarget.DeviceContext2D.DrawEllipse(pen, x, y, width, height); }
public static void DrawCircle(this RenderContext context, ID2DPen pen, PointF center, float radius) { context.RenderTarget.DeviceContext2D.DrawCircle(pen, center, radius); }
public static void DrawLine(this RenderContext context, ID2DPen pen, float x1, float y1, float x2, float y2) { context.RenderTarget.DeviceContext2D.DrawLine(pen, x1, y1, x2, y2); }
public static void DrawPath(this RenderContext context, ID2DPen pen, D2DPathData path, PointF offset) { context.DrawPath(pen, path, offset.X, offset.Y); }
public static void DrawCircle(this RenderContext context, ID2DPen pen, float x, float y, float radius) { context.RenderTarget.DeviceContext2D.DrawCircle(pen, x, y, radius); }
public static void DrawPath(this RenderContext context, ID2DPen pen, D2DFontPathData path, PointF offset, bool yCorrection) { context.DrawPath(pen, path, offset.X, offset.Y, yCorrection); }
public static void DrawRectangle(this SharpDX.Direct2D1.RenderTarget target, ID2DPen pen, float x, float y, float width, float height) { var rect = new RawRectangleF(x, y, x + width, y + height); target.DrawRectangle(rect, pen.Brush.NativeBrush, pen.StrokeWidth, pen.StrokeStyle); }
public static void DrawEllipse(this SharpDX.Direct2D1.RenderTarget target, ID2DPen pen, float x, float y, float width, float height) { var ellipse = new Ellipse(new RawVector2(x + width / 2, y + height / 2), width / 2, height / 2); target.DrawEllipse(ellipse, pen.Brush.NativeBrush, pen.StrokeWidth, pen.StrokeStyle); }
public static void DrawPath(this RenderContext context, ID2DPen pen, D2DFontPathData path, Point offset) { context.DrawPath(pen, path, offset, true); }
public static void DrawPolygon(this RenderContext context, ID2DPen pen, params PointF[] points) { context.RenderTarget.DeviceContext2D.DrawPolygon(pen, points); }
public static void DrawPath(this RenderContext context, ID2DPen pen, D2DFontPathData path) { path.Draw(context, pen); }
public static void DrawPath(this SharpDX.Direct2D1.RenderTarget target, ID2DPen pen, D2DPathData path) { target.DrawGeometry(path.NativeGeometry, pen.Brush.NativeBrush, pen.StrokeWidth, pen.StrokeStyle); }
public static void DrawCircle(this SharpDX.Direct2D1.RenderTarget target, ID2DPen pen, float x, float y, float radius) { var w = radius + radius; target.DrawEllipse(pen, x - radius, y - radius, w, w); }
public static void DrawCircle(this SharpDX.Direct2D1.RenderTarget target, ID2DPen pen, PointF center, float radius) { var w = radius + radius; target.DrawEllipse(pen, center.X - radius, center.Y - radius, w, w); }
public static void DrawPath(this RenderContext context, ID2DPen pen, D2DPathData path) { context.RenderTarget.DeviceContext2D.DrawPath(pen, path); }
public static void DrawPath(this RenderContext context, ID2DPen pen, D2DFontPathData path, float offsetX, float offsetY) { context.DrawPath(pen, path, offsetX, offsetY, true); }